CLI 命令参考(规范命令树)
每个操作只有一个规范路径,写作 abx 组 动词。在此之上只有一小组固定的顶层快捷方式,对应最常用的命令。
这组快捷方式写死在代码里:不能通过配置增加、改名或删除,也没有按用户配置的别名表。
顶层命令仅有这些:abx sandbox、abx template、abx config、abx mcp、abx provider、abx create、abx list、abx info、abx kill、abx exec、abx connect、abx upload、abx download、abx run、abx deploy。
abx --help 分三段列出:Command groups(sandbox、template、config、mcp)、Providers(provider)、
Sandbox shortcuts(十个快捷方式,每个都写作 "Same as 'abx …'")。该列表与本页不一致时,测试会失败。
快捷方式
| 快捷方式 | 等价于 |
|---|---|
abx create |
abx sandbox create |
abx list |
abx sandbox list |
abx info |
abx sandbox info |
abx kill |
abx sandbox kill |
abx exec |
abx sandbox exec |
abx connect |
abx sandbox connect |
abx upload |
abx sandbox upload |
abx download |
abx sandbox download |
abx run |
abx sandbox command run |
abx deploy |
abx template deploy |
没有顶层的 abx init 和 abx install:请用 abx template init、abx template install(凭证配置是 abx config init)。
规范命令树
abx
├── sandbox
│ ├── create [DESCRIPTION] list info SANDBOX_ID kill [SANDBOX_ID]
│ ├── exec SANDBOX_ID COMMAND... connect SANDBOX_ID
│ ├── upload SANDBOX_ID LOCAL REMOTE download SANDBOX_ID REMOTE LOCAL
│ ├── capabilities SANDBOX_ID
│ ├── files list | mkdir | mv | rm | search | stat
│ ├── process list | info | signal (只查看/控制;启动进程用 exec --background)
│ ├── command list | run (沙箱内服务端注册的具名命令)
│ └── system env | info | metrics | packages | ports
├── template init | search | info | list | build | push | create | delete | deploy | install
├── config init | get | set | list | delete
├── mcp deploy | install | start | status | stop
└── provider list | show | info | install | uninstall | update | default | config | doctor | test
abx provider --help 由 Provider 文档负责(见Providers);本页只涉及固定命令面中的 provider 组本身。
用法行(取自 abx … --help):
| 命令 | 用法 |
|---|---|
abx sandbox create |
create [OPTIONS] [DESCRIPTION] |
abx sandbox list |
list [OPTIONS] |
abx sandbox info |
info [OPTIONS] SANDBOX_ID |
abx sandbox kill |
kill [OPTIONS] [SANDBOX_ID] |
abx sandbox exec |
exec [OPTIONS] SANDBOX_ID COMMAND... |
abx sandbox connect |
connect [OPTIONS] SANDBOX_ID |
abx sandbox upload |
upload [OPTIONS] SANDBOX_ID LOCAL_PATH REMOTE_PATH |
abx sandbox download |
download [OPTIONS] SANDBOX_ID REMOTE_PATH LOCAL_PATH |
abx sandbox capabilities |
capabilities [OPTIONS] SANDBOX_ID |
abx sandbox files list\|mkdir\|mv\|rm\|search\|stat |
files <动词> [OPTIONS] SANDBOX_ID(路径选项 -p/--path、-s/--source、-d/--dest) |
abx sandbox process list |
process list [OPTIONS] SANDBOX_ID |
abx sandbox process info\|signal |
process <动词> [OPTIONS] SANDBOX_ID PID |
abx sandbox command list |
command list [OPTIONS] SANDBOX_ID |
abx sandbox command run |
command run [OPTIONS] SANDBOX_ID COMMAND_NAME |
abx sandbox system env\|info\|metrics\|packages\|ports |
system <动词> [OPTIONS] SANDBOX_ID |
abx template init |
init [OPTIONS] [DIRECTORY] |
abx template search |
search [OPTIONS] QUERY |
abx template info / delete |
<动词> [OPTIONS] TEMPLATE_ID |
abx template list |
list [OPTIONS] |
abx template build / deploy |
<动词> [OPTIONS] TEMPLATE_DIR(顶层 abx deploy 的 [PATH] 可省略,默认 .) |
abx template push / create |
<动词> [OPTIONS] IMAGE |
abx template install |
install [OPTIONS] TEMPLATE_REF |
abx config init\|list |
<动词> [OPTIONS] |
abx config get\|delete |
<动词> [OPTIONS] KEY |
abx config set |
set [OPTIONS] KEY [VALUE] |
abx mcp deploy\|install\|start\|status\|stop |
<动词> [OPTIONS] |
全局选项
-j/--json、-q/--quiet、-v/--verbose、--no-color、--log-level [debug|info|warning|error]、--ci、
--version、-h/--help。它们写在命令之前(abx --json list)。
没有全局 --timeout,也没有 --profile。沙箱生命周期是 abx create 独有的 --timeout SECONDS;
命令超时是 abx exec 的 --timeout SECONDS。
运行命令:abx exec
abx exec SANDBOX_ID -- python --version # 等待完成,退出码即远端退出码
abx exec SANDBOX_ID --cwd /app --env DEBUG=1 --timeout 300 -- pytest -q
abx exec SANDBOX_ID --stream -- pip install numpy # 实时输出 stdout/stderr
abx exec SANDBOX_ID --background -- python -m http.server 8000 # 打印 pid 后立即返回
abx exec SANDBOX_ID "ls /app | wc -l" # 单个带引号的参数按命令行处理(支持管道)
| 选项 | 含义 |
|---|---|
--cwd PATH |
工作目录(为空表示容器默认) |
-e/--env KEY=VALUE |
环境变量,可重复 |
-t/--timeout SECONDS |
命令超时(默认 60) |
--stream |
命令运行时实时打印 stdout/stderr |
--background |
启动命令、打印 pid、不等待(不能与 --stream 同用) |
-- 之后的命令按原样执行,不经过 shell;单个带引号的参数按命令行解析,仅当含管道或重定向时才套 shell。
需要变量展开时使用 sh -c '...'。后台进程用 abx sandbox process list|info|signal 查看或发信号。
abx connect SANDBOX_ID 打开逐行 REPL:每一行都是一个新进程(cd、导出的变量等状态不会保留),它不是 PTY。
具名命令:abx run / abx sandbox command
只有一种机制:注册在沙箱内服务端的命令(CommandRegistry、GET /commands、POST /commands/{name})。
它们不写在 template.yaml 里。
abx sandbox command list SANDBOX_ID # 名称、参数、说明
abx run SANDBOX_ID build --arg target=staging --arg n=2 # 等价于 abx sandbox command run
abx run SANDBOX_ID add --json-args '{"x": 1, "y": 2}' # 带类型的值
| 选项 | 含义 |
|---|---|
-a/--arg KEY=VALUE |
命令参数(可重复;服务端按声明的类型转换字符串) |
--json-args JSON |
以 JSON 对象传参 |
--server-port PORT |
沙箱内服务端端口(默认 9000) |
字符串结果原样打印,其他值以 JSON 打印(--json 时包装为 {"result": ...})。命令在服务端执行失败时退出码为 1;
名称不存在退出码为 2;沙箱里没有运行中的服务端时提示 "No SandboxServer reachable" 并以非零退出。
初始化:abx config init
abx config init 默认只询问凭证和区域。两个选项追加配置段:
| 选项 | 追加内容 |
|---|---|
--build |
ACR 命名空间与阿里云 AccessKey(template build/deploy/install 需要) |
--llm |
模板生成使用的 LLM API Key(abx create "描述"、abx template init "描述") |
缺少相应设置时,功能会打印一行指向 abx config init --build 或 abx config init --llm 的提示。
无终端(或带 --yes/--ci)时命令不会提示输入,而是打印等价的 abx config set …。
已移除的写法
| 已移除 | 替代 |
|---|---|
顶层 abx init、abx install |
abx template init、abx template install |
abx sandbox process start |
abx exec --background |
abx sandbox shell-stream |
abx exec --stream |
abx sandbox run |
abx run / abx sandbox command run |
全局 -t/--timeout、全局 -p/--profile |
abx create --timeout、abx exec --timeout;--profile 无替代 |
config.toml 中的 [shortcuts]、abx config set shortcuts.<name> |
无(快捷方式固定) |
template.yaml 中的 custom_commands |
在沙箱内服务端注册具名命令 |
abx deploy --traditional |
无(流水线固定) |