English | 简体中文
Manage Sandbox resources — isolated execution environments for code, shell,
file system and browser operations. The command group is also available as the
shorter alias ar sb.
Sandbox has a Template + Instance two-layer model:
- Template defines the sandbox flavor (CPU/memory/network/image/env). Managed
via the
templatesub-group. - Instance is created from a template and is where you actually run workloads.
Four sandbox types are supported: CodeInterpreter, Browser, AllInOne,
CustomImage.
Top-level (instance lifecycle & execution):
Sub-groups:
- file — read / write / upload / download / ls / stat / mv / rm / mkdir
- process — list / get / kill
- context — create / list / get / delete
- template — create / get / list / update / delete
- browser — cdp-url / vnc-url / screenshot / navigate
ar sandbox create --template <name> --type <type> [options]
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
--template |
string | yes | Template name to instantiate. | |
--type |
string | yes | Sandbox type: CodeInterpreter / Browser / AllInOne / CustomImage. |
|
--id |
string | no | auto | Custom sandbox id. |
--idle-timeout |
int | no | 600 |
Idle timeout in seconds. |
--nas-server-addr |
string | no | NAS server address. | |
--nas-mount-dir |
string | no | /mnt/nas |
NAS mount path inside the sandbox. |
--oss-bucket |
string | no | OSS bucket name. | |
--oss-mount-dir |
string | no | /mnt/oss |
OSS mount path inside the sandbox. |
--from-file |
path | no | JSON file with a full SandboxInput. |
ar sandbox create --template my-tpl --type CodeInterpreter
ar sandbox create --template browser-tpl --type Browser --idle-timeout 1800
ar sandbox create --template aio-tpl --type AllInOne \
--oss-bucket my-bucket --oss-mount-dir /dataar sandbox get <SANDBOX_ID>
ar sandbox get sb-001ar sandbox list [options]
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
--max-results |
int | no | 10 |
Max results per page. |
--next-token |
string | no | Pagination token. | |
--status |
string | no | Filter by status. | |
--template |
string | no | Filter by template name. | |
--type |
string | no | Filter by sandbox type. |
ar sandbox list
ar sandbox list --type Browser --status Running --max-results 50Stop a running sandbox (can be restarted).
ar sandbox stop <SANDBOX_ID>
ar sandbox stop sb-001Permanently delete a sandbox.
ar sandbox delete <SANDBOX_ID>
ar sandbox delete sb-001Check sandbox health status.
ar sandbox health <SANDBOX_ID>
ar sandbox health sb-001Execute code inside a sandbox. Must supply either --code or --file.
ar sandbox exec <SANDBOX_ID> (--code <src> | --file <path>) [options]
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
SANDBOX_ID |
positional | yes | Target sandbox id. | |
--code |
string | one of | Inline code to run. | |
--file |
path | one of | Path to a code file. | |
--language |
string | no | python when --context-id is not set; mutually exclusive with --context-id |
python or javascript. Passing both --context-id and --language is an error. |
--context-id |
string | no | Stateful context id (see context). | |
--timeout |
int | no | 30 |
Execution timeout (seconds). |
ar sandbox exec sb-001 --code "print(2 + 3)"
ar sandbox exec sb-001 --file ./script.py --language python --timeout 120
ar sandbox exec sb-001 --code "x = 1" --context-id ctx-a
ar sandbox exec sb-001 --code "print(x)" --context-id ctx-a # x preservedExecute a shell command inside a sandbox.
ar sandbox cmd <SANDBOX_ID> --command <cmd> --cwd <dir> [--timeout <sec>]
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
SANDBOX_ID |
positional | yes | Target sandbox id. | |
--command |
string | yes | Shell command to run. | |
--cwd |
string | yes | Working directory. | |
--timeout |
int | no | 30 |
Timeout (seconds). |
ar sandbox cmd sb-001 --command "ls -la" --cwd /tmp
ar sandbox cmd sb-001 --command "pip install requests" --cwd /workspace --timeout 120ar sandbox file — file system operations on a sandbox. All commands take
<SANDBOX_ID> as the first positional argument.
ar sandbox file read <SANDBOX_ID> <PATH>
ar sandbox file read sb-001 /workspace/main.pyar sandbox file write <SANDBOX_ID> <PATH> [--content <text> | --stdin] [--mode <octal>] [--encoding <enc>]
| Flag | Default | Description |
|---|---|---|
--content |
Inline content. | |
--stdin |
false | Read content from stdin. |
--mode |
644 |
File permission mode. |
--encoding |
utf-8 |
File encoding. |
ar sandbox file write sb-001 /tmp/hello.txt --content "Hello"
echo "piped" | ar sandbox file write sb-001 /tmp/from-pipe.txt --stdinUpload a local file to the sandbox.
ar sandbox file upload <SANDBOX_ID> <LOCAL_PATH> <REMOTE_PATH>
ar sandbox file upload sb-001 ./data.csv /workspace/data.csvDownload a file from the sandbox to local disk.
ar sandbox file download <SANDBOX_ID> <REMOTE_PATH> <LOCAL_PATH>
ar sandbox file download sb-001 /workspace/report.pdf ./report.pdfList directory entries.
ar sandbox file ls <SANDBOX_ID> [<PATH>] [--depth <n>]
| Flag | Default | Description |
|---|---|---|
PATH |
/ |
Path to list. |
--depth |
1 |
Recursive depth. |
ar sandbox file ls sb-001 /workspace
ar sandbox file ls sb-001 /workspace --depth 3Show file metadata.
ar sandbox file stat <SANDBOX_ID> <PATH>
ar sandbox file stat sb-001 /workspace/main.pyMove or rename a file.
ar sandbox file mv <SANDBOX_ID> <SOURCE> <DESTINATION>
ar sandbox file mv sb-001 /tmp/a.txt /tmp/b.txtRemove a file or directory.
ar sandbox file rm <SANDBOX_ID> <PATH>
ar sandbox file rm sb-001 /tmp/unused.logCreate a directory.
ar sandbox file mkdir <SANDBOX_ID> <PATH> [--mode <octal>]
| Flag | Default | Description |
|---|---|---|
--mode |
0755 |
Directory permission mode. |
ar sandbox file mkdir sb-001 /workspace/new
ar sandbox file mkdir sb-001 /var/data --mode 0700ar sandbox process — inspect and kill processes inside a sandbox.
ar sandbox process list <SANDBOX_ID>
ar sandbox process list sb-001ar sandbox process get <SANDBOX_ID> <PID>
ar sandbox process get sb-001 1234ar sandbox process kill <SANDBOX_ID> <PID> [--force-shell]
| Flag | Default | Description |
|---|---|---|
--force-shell |
false | If the Process API does not know this PID, fall back to kill -9 <PID> via the shell. Useful for ending PIDs that appear in process list but were not started through the Process API. |
ar sandbox process kill sb-001 1234
ar sandbox process kill sb-001 1234 --force-shellar sandbox context — manage stateful execution contexts. A context preserves
variables / imports across multiple sandbox exec calls (like a Jupyter kernel).
ar sandbox context create <SANDBOX_ID> [--language <lang>] [--cwd <dir>]
| Flag | Default | Description |
|---|---|---|
--language |
python |
python or javascript. |
--cwd |
Working directory. |
ar sandbox context create sb-001
ar sandbox context create sb-001 --language javascript --cwd /workspacear sandbox context list <SANDBOX_ID>
ar sandbox context get <SANDBOX_ID> <CONTEXT_ID>
ar sandbox context delete <SANDBOX_ID> <CONTEXT_ID>
ar sandbox template — manage sandbox templates.
ar sandbox template create --type <type> [options]
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
--type |
string | yes | CodeInterpreter / Browser / AllInOne / CustomImage. |
|
--name |
string | no | auto | Template name. |
--cpu |
float | no | CPU cores. | |
--memory |
int | no | Memory (MB). | |
--disk-size |
int | no | Disk size (MB). | |
--idle-timeout |
int | no | Sandbox idle timeout (seconds). | |
--ttl |
int | no | Sandbox max TTL (seconds). | |
--concurrency |
int | no | Max concurrency per sandbox. | |
--description |
string | no | Description. | |
--env |
multi | no | Environment variable KEY=VALUE, repeatable. |
|
--network-mode |
string | no | PUBLIC / PRIVATE / PUBLIC_AND_PRIVATE. |
|
--credential-name |
string | no | Credential name. | |
--container-image |
string | no | Container image (CustomImage type). |
|
--container-port |
int | no | Container port (CustomImage type). |
|
--from-file |
path | no | JSON file with a full TemplateInput. |
ar sandbox template create --type CodeInterpreter --name my-tpl \
--cpu 1 --memory 2048 --idle-timeout 900
ar sandbox template create --type CustomImage --name my-custom \
--container-image registry.example.com/my-env:v1 --container-port 8080ar sandbox template get <TEMPLATE_NAME>
ar sandbox template list [--page <n>] [--page-size <n>] [--type <type>]
| Flag | Default | Description |
|---|---|---|
--page |
1 |
Page number. |
--page-size |
10 |
Page size. |
--type |
Filter by type. |
ar sandbox template update <TEMPLATE_NAME> [options]
| Flag | Description |
|---|---|
--cpu |
CPU cores. |
--memory |
Memory (MB). |
--idle-timeout |
Idle timeout (seconds). |
--ttl |
Max TTL (seconds). |
--description |
Description. |
--env |
Environment variable KEY=VALUE, repeatable. |
--from-file |
JSON file with update fields. |
ar sandbox template delete <TEMPLATE_NAME>
ar sandbox browser — browser automation commands (for Browser / AllInOne
sandbox types).
Get a CDP WebSocket URL (for attaching Playwright / puppeteer / your own CDP client).
ar sandbox browser cdp-url <SANDBOX_ID> [--with-headers]
| Flag | Description |
|---|---|
--with-headers |
Include auth headers in the response. |
ar sandbox browser cdp-url sb-001
ar sandbox browser cdp-url sb-001 --with-headersGet a VNC WebSocket URL (for live-view in a browser).
ar sandbox browser vnc-url <SANDBOX_ID> [--with-headers]
Capture a screenshot of the current page.
ar sandbox browser screenshot <SANDBOX_ID> [options]
| Flag | Default | Description |
|---|---|---|
--save-path |
./screenshot.png |
Local file path. |
--full-page |
false | Capture full page, not just the viewport. |
--format |
png |
png or jpeg. |
--quality |
80 |
JPEG quality 1–100. |
ar sandbox browser screenshot sb-001 --full-page --save-path page.png
ar sandbox browser screenshot sb-001 --format jpeg --quality 90Navigate the browser to a URL.
ar sandbox browser navigate <SANDBOX_ID> <URL> [options]
| Flag | Default | Description |
|---|---|---|
--wait-until |
load |
load, domcontentloaded, or networkidle. |
--timeout |
30 |
Navigation timeout (seconds). |
ar sandbox browser navigate sb-001 https://example.com
ar sandbox browser navigate sb-001 https://example.com --wait-until networkidle --timeout 60