Skip to content

Commit e62cbb0

Browse files
authored
Feat/sandbox cli v8 (#120)
2 parents 7256fda + ad56436 commit e62cbb0

23 files changed

Lines changed: 3635 additions & 568 deletions

agentkit/auth/model_login.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
(codex: OPENAI_API_KEY); that is stripped before injection and an api-key-only file is
2424
rejected, so a long-lived key never reaches the sandbox. See sanitize_*_for_injection.
2525
26-
The sandbox config.toml is not touched; select the subscription at exec with
27-
`codex exec -c model_provider=openai`. Stdlib only; the sandbox transport lives in
28-
sandbox/cli_model_login.py.
26+
The sandbox transport configures a codex_login provider for OAuth auth. Stdlib only; the
27+
sandbox transport lives in sandbox/cli_model_login.py.
2928
"""
3029

3130
from __future__ import annotations

agentkit/toolkit/cli/sandbox/README.md

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,28 @@ agentkit sandbox create \
5353
Options:
5454

5555
- `--tool-type`: optional. Tool type to create; defaults to `CodeEnv`.
56+
`Private` creates a private-image tool and applies the CLI's default
57+
aio-sandbox environment, command, and port profile.
5658
- `--tool-name`: optional. Tool name. If omitted, the CLI generates a name like
5759
`agentkit-codeenv-<random>`.
60+
- `--image-url`: optional custom image URL. Required when
61+
`--tool-type Private`.
5862
- `--tos-bucket`: optional. TOS bucket to mount. If omitted, the tool is
5963
created without TOS mount configuration.
6064
- `--tos-mount`: optional. Local mount path for `--tos-bucket`; defaults to
6165
`/home/gem/workspace`.
6266
- `--cpu`: optional. Sandbox vCPU count; allowed values are `2`, `4`, `8`, and
6367
`16`. Defaults to `4`. Memory is derived as 2 GiB per vCPU.
68+
- `--network-config`: optional. Network configuration as inline JSON or a path
69+
to a JSON file. If omitted, the tool is created with public access enabled
70+
and private access disabled.
6471
- `--model-provider`: optional. Model provider marker to inject into
65-
`AGENTKIT_SANDBOX_MODEL_PROVIDER`; defaults to `model_square`. The built-in
66-
providers `model_square`, `coding_plan`, and `agent_plan` also provide base
67-
URLs, default models, and Codex model catalog entries. Other provider strings
68-
are passed through without built-in URL or catalog handling.
72+
`AGENTKIT_SANDBOX_MODEL_PROVIDER`; defaults to `model_square`, or
73+
`byteplus_model_square` when `CLOUD_PROVIDER` / `AGENTKIT_CLOUD_PROVIDER` is
74+
`byteplus`. The built-in providers `model_square`, `coding_plan`,
75+
`agent_plan`, `byteplus_model_square`, and `byteplus_coding_plan` also
76+
provide base URLs, default models, and Codex model catalog entries. Other
77+
provider strings are passed through without built-in URL or catalog handling.
6978
- `--model-name`: optional. Injected into the tool as `OPENCODE_MODEL`,
7079
`CODEX_MODEL`, and `ANTHROPIC_MODEL`. If omitted for a built-in provider,
7180
that provider's default model is used. Custom model names are allowed and are
@@ -85,7 +94,49 @@ Options:
8594
The sandbox create request maps `--cpu` to `CpuMilli=<cpu * 1000>` and
8695
`MemoryMb=<cpu * 2048>`, so the default shape is 4 vCPU / 8 GiB.
8796

88-
The tool injects the selected built-in provider's Volcengine Ark compatible
97+
Network configuration uses the same access concepts as the AgentKit console:
98+
99+
```json
100+
{
101+
"private_access": true,
102+
"public_access": true,
103+
"vpc_id": "vpc-xxxxxxxx",
104+
"subnet_ids": ["subnet-aaaaaaaa"],
105+
"enable_shared_internet_access": true
106+
}
107+
```
108+
109+
`public_access` defaults to `true`; `private_access` defaults to `false`.
110+
When `private_access` is `true`, `vpc_id` is required. `subnet_ids` may be an
111+
array of strings or a comma-separated string. The CLI validates JSON syntax,
112+
field names, field types, and field combinations before calling `CreateTool`.
113+
VPC and subnet existence or availability errors are returned by the control
114+
plane.
115+
116+
Examples:
117+
118+
```bash
119+
agentkit sandbox create \
120+
--network-config network.json
121+
122+
agentkit sandbox create \
123+
--network-config '{"private_access":true,"public_access":true,"vpc_id":"vpc-xxxxxxxx","subnet_ids":["subnet-aaaaaaaa"]}'
124+
```
125+
126+
When `--tool-type Private` is used, the CLI creates a private-image tool and
127+
applies the default aio-sandbox startup profile:
128+
129+
```bash
130+
agentkit sandbox create \
131+
--tool-type Private \
132+
--image-url registry.example.com/custom-image:latest
133+
```
134+
135+
The CreateTool request uses `ToolType: Private`, `Command: /opt/gem/run.sh`,
136+
port `8080`, and the environment variables matching the aio-sandbox startup
137+
profile. Future CLI options may expose command, port, and environment overrides.
138+
139+
The tool injects the selected built-in provider's Ark-compatible
89140
endpoints into `OPENCODE_BASE_URL`, `CODEX_BASE_URL`, `MODEL_BASE_URL`, and
90141
`ANTHROPIC_BASE_URL`, and stores the selected provider in
91142
`AGENTKIT_SANDBOX_MODEL_PROVIDER`. For built-in provider URLs, the same provider
@@ -105,6 +156,8 @@ Provider defaults:
105156
| `model_square` | `deepseek-v4-flash-260425` | `https://ark.cn-beijing.volces.com/api/v3` |
106157
| `coding_plan` | `deepseek-v4-flash` | `https://ark.cn-beijing.volces.com/api/coding/v3` |
107158
| `agent_plan` | `deepseek-v4-flash` | `https://ark.cn-beijing.volces.com/api/plan/v3` |
159+
| `byteplus_model_square` | `deepseek-v4-flash-260425` | `https://ark.ap-southeast.bytepluses.com/api/v3` |
160+
| `byteplus_coding_plan` | `deepseek-v4-flash` | `https://ark.ap-southeast.bytepluses.com/api/coding/v3` |
108161

109162
Credential resolution is delegated to the underlying SDK/service clients:
110163
`AgentkitToolsClient` handles `CreateTool` credentials, and `TOSService` handles
@@ -467,11 +520,11 @@ Options:
467520
as `OPENCODE_MODEL`, `CODEX_MODEL`, and `ANTHROPIC_MODEL`. Custom model names
468521
are allowed.
469522
- `--model-provider`: optional. When creating a sandbox session, injects the
470-
provider marker. The built-in providers `model_square`, `coding_plan`, and
471-
`agent_plan` also provide default models, base URL envs, and
472-
`CODEX_CONFIG_TOML` / `CODEX_MODEL_CATALOG_JSON` updates for `CodeEnv`
473-
sessions. Other provider strings are passed through without built-in URL or
474-
catalog handling.
523+
provider marker. The built-in providers `model_square`, `coding_plan`,
524+
`agent_plan`, `byteplus_model_square`, and `byteplus_coding_plan` also
525+
provide default models, base URL envs, and `CODEX_CONFIG_TOML` /
526+
`CODEX_MODEL_CATALOG_JSON` updates for `CodeEnv` sessions. Other provider
527+
strings are passed through without built-in URL or catalog handling.
475528
- `--model-base-url`: optional. When creating a sandbox session, injects the
476529
value into `OPENCODE_BASE_URL`, `CODEX_BASE_URL`, `MODEL_BASE_URL`, and
477530
`ANTHROPIC_BASE_URL`. When provided, it takes precedence over provider base
@@ -507,7 +560,9 @@ current shell ID from the list when that connection is detached or closed.
507560

508561
When `--model-name` is provided without `--model-provider`, `exec` first tries
509562
to reuse `AGENTKIT_SANDBOX_MODEL_PROVIDER` from the cached or remote tool
510-
configuration, then falls back to `model_square` when no marker is available.
563+
configuration. When no marker is available, it falls back to `model_square`, or
564+
`byteplus_model_square` when `CLOUD_PROVIDER` / `AGENTKIT_CLOUD_PROVIDER` is
565+
`byteplus`.
511566
For built-in providers, it updates `CODEX_CONFIG_TOML` /
512567
`CODEX_MODEL_CATALOG_JSON` for `CodeEnv` sessions. If the tool carries a custom
513568
model base URL, exec inherits that URL and writes it into the generated Codex

0 commit comments

Comments
 (0)