diff --git a/gigacode/Cargo.toml b/gigacode/Cargo.toml
new file mode 100644
index 0000000..29a4e86
--- /dev/null
+++ b/gigacode/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "gigacode"
+version.workspace = true
+edition.workspace = true
+authors.workspace = true
+license.workspace = true
+description = "Sandbox Agent CLI with OpenCode attach by default"
+repository.workspace = true
+
+[[bin]]
+name = "gigacode"
+path = "src/main.rs"
+
+[dependencies]
+clap.workspace = true
+sandbox-agent.workspace = true
+tracing.workspace = true
diff --git a/gigacode/README.md b/gigacode/README.md
new file mode 100644
index 0000000..3ebbd89
--- /dev/null
+++ b/gigacode/README.md
@@ -0,0 +1,97 @@
+
+
+
+
+
Supports Claude Code, Codex, and Amp.
+
+
+ This is not a fork (and never will be).
It's powered by Sandbox Agent SDK's wizardry.
Experimental & just for fun.
+
+
+
+ Issues — Discord — Supported OpenCode Features
+
+
+
+## How It Works
+
+```
+┌─ Gigacode ────────────────────────────────────────────────────────┐
+│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
+│ │ OpenCode TUI │───▶│ Sandbox Agent │───▶│ Claude Code / │ │
+│ │ │ │ │ │ Codex / Amp │ │
+│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
+└───────────────────────────────────────────────────────────────────┘
+```
+
+- [Sandbox Agent SDK](https://sandboxagent.dev) provides a universal HTTP API for controlling Claude Code, Codex, and Amp
+- Sandbox Agent SDK exposes an [OpenCode-compatible endpoint](https://sandboxagent.dev/docs/opencode-compatibility) so OpenCode can talk to any agent
+- OpenCode connects to Sandbox Agent SDK via [`attach`](https://opencode.ai/docs/cli/#attach)
+
+## OpenCode Models vs Gigacode Agents
+
+- **OpenCode** supports **switching between inference providers** (Anthropic, OpenAI, etc.). This is OpenCode talking directly to the models with its own tools, system prompts, and agentic loop.
+- **Gigacode** automates other coding agent harnesses, so it's using the **exact same logic that you would if you ran Claude Code**, Codex, or Amp natively.
+
+```
+OpenCode (native): Model → OpenCode's tool loop → result
+Gigacode: Model → Claude Code / Codex / Amp CLI → result
+```
+
+This means you get each agent's specialized capabilities (such as Claude Code's `Read`/`Write`/`Bash` tools, Codex's sandboxed execution, and Amp's permission rules) rather than a single tool loop with different models behind it.
+
+## Install
+
+**macOS / Linux / WSL (Recommended)**
+
+```bash
+curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/gigacode-install.sh | sh
+```
+
+**npm i -g**
+
+```bash
+npm install -g @sandbox-agent/gigacode
+gigacode --help
+```
+
+**bun add -g**
+
+```bash
+bun add -g @sandbox-agent/gigacode
+# Allow Bun to run postinstall scripts for native binaries.
+bun pm -g trust @sandbox-agent/gigacode-linux-x64 @sandbox-agent/gigacode-linux-arm64 @sandbox-agent/gigacode-darwin-arm64 @sandbox-agent/gigacode-darwin-x64 @sandbox-agent/gigacode-win32-x64
+gigacode --help
+```
+
+**npx**
+
+```bash
+npx @sandbox-agent/gigacode --help
+```
+
+**bunx**
+
+```bash
+bunx @sandbox-agent/gigacode --help
+```
+
+> **Note:** Windows is unsupported. Please use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install).
+
+## Usage
+
+**TUI**
+
+Launch the OpenCode TUI with any coding agent:
+
+```bash
+gigacode
+```
+
+**Web UI**
+
+Use the [OpenCode Web UI](https://sandboxagent.dev/docs/opencode-compatibility) to control any coding agent from the browser.
+
+**OpenCode SDK**
+
+Use the [`@opencode-ai/sdk`](https://sandboxagent.dev/docs/opencode-compatibility) to programmatically control any coding agent.
diff --git a/gigacode/src/main.rs b/gigacode/src/main.rs
new file mode 100644
index 0000000..87e93aa
--- /dev/null
+++ b/gigacode/src/main.rs
@@ -0,0 +1,28 @@
+use clap::Parser;
+use sandbox_agent::cli::{
+ init_logging, run_command, CliConfig, CliError, Command, GigacodeCli, OpencodeArgs,
+};
+
+fn main() {
+ if let Err(err) = run() {
+ tracing::error!(error = %err, "gigacode failed");
+ std::process::exit(1);
+ }
+}
+
+fn run() -> Result<(), CliError> {
+ let cli = GigacodeCli::parse();
+ let config = CliConfig {
+ token: cli.token,
+ no_token: cli.no_token,
+ gigacode: true,
+ };
+ let command = cli
+ .command
+ .unwrap_or_else(|| Command::Opencode(OpencodeArgs::default()));
+ if let Err(err) = init_logging(&command) {
+ eprintln!("failed to init logging: {err}");
+ return Err(err);
+ }
+ run_command(&command, &config)
+}
diff --git a/justfile b/justfile
index f9d4103..714768c 100644
--- a/justfile
+++ b/justfile
@@ -48,6 +48,33 @@ check:
fmt:
cargo fmt --all
+[group('dev')]
+install-fast-sa:
+ cargo build --release -p sandbox-agent
+ cp target/release/sandbox-agent ~/.cargo/bin/sandbox-agent
+
+[group('dev')]
+install-fast-gigacode:
+ cargo build --release -p gigacode
+ cp target/release/gigacode ~/.cargo/bin/gigacode
+
[group('dev')]
dev-docs:
cd docs && pnpm dlx mintlify dev
+
+install:
+ pnpm install
+ pnpm build --filter @sandbox-agent/inspector...
+ cargo install --path server/packages/sandbox-agent --debug
+ cargo install --path gigacode --debug
+
+install-fast:
+ SANDBOX_AGENT_SKIP_INSPECTOR=1 cargo install --path server/packages/sandbox-agent --debug
+ SANDBOX_AGENT_SKIP_INSPECTOR=1 cargo install --path gigacode --debug
+
+install-release:
+ pnpm install
+ pnpm build --filter @sandbox-agent/inspector...
+ cargo install --path server/packages/sandbox-agent
+ cargo install --path gigacode
+
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5bfc5da..819556a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -17,7 +17,7 @@ importers:
version: 2.7.6
vitest:
specifier: ^3.0.0
- version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
examples/cloudflare:
dependencies:
@@ -36,10 +36,10 @@ importers:
devDependencies:
'@cloudflare/workers-types':
specifier: latest
- version: 4.20260131.0
+ version: 4.20260206.0
'@types/node':
specifier: latest
- version: 25.2.0
+ version: 25.2.1
'@types/react':
specifier: ^18.3.3
version: 18.3.27
@@ -48,32 +48,32 @@ importers:
version: 18.3.7(@types/react@18.3.27)
'@vitejs/plugin-react':
specifier: ^4.5.0
- version: 4.7.0(vite@6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
+ version: 4.7.0(vite@6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
typescript:
specifier: latest
version: 5.9.3
vite:
specifier: ^6.2.0
- version: 6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ version: 6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
vitest:
specifier: ^3.0.0
- version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
wrangler:
specifier: latest
- version: 4.61.1(@cloudflare/workers-types@4.20260131.0)
+ version: 4.63.0(@cloudflare/workers-types@4.20260206.0)
examples/daytona:
dependencies:
'@daytonaio/sdk':
specifier: latest
- version: 0.138.0(ws@8.19.0)
+ version: 0.139.0(ws@8.19.0)
'@sandbox-agent/example-shared':
specifier: workspace:*
version: link:../shared
devDependencies:
'@types/node':
specifier: latest
- version: 25.2.0
+ version: 25.2.1
tsx:
specifier: latest
version: 4.21.0
@@ -95,7 +95,7 @@ importers:
version: 4.0.1
'@types/node':
specifier: latest
- version: 25.2.0
+ version: 25.2.1
tsx:
specifier: latest
version: 4.21.0
@@ -104,7 +104,7 @@ importers:
version: 5.9.3
vitest:
specifier: ^3.0.0
- version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
examples/e2b:
dependencies:
@@ -120,7 +120,7 @@ importers:
devDependencies:
'@types/node':
specifier: latest
- version: 25.2.0
+ version: 25.2.1
tsx:
specifier: latest
version: 4.21.0
@@ -129,7 +129,7 @@ importers:
version: 5.9.3
vitest:
specifier: ^3.0.0
- version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
examples/shared:
dependencies:
@@ -139,7 +139,7 @@ importers:
devDependencies:
'@types/node':
specifier: latest
- version: 25.2.0
+ version: 25.2.1
typescript:
specifier: latest
version: 5.9.3
@@ -158,7 +158,7 @@ importers:
devDependencies:
'@types/node':
specifier: latest
- version: 25.2.0
+ version: 25.2.1
tsx:
specifier: latest
version: 4.21.0
@@ -167,7 +167,7 @@ importers:
version: 5.9.3
vitest:
specifier: ^3.0.0
- version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
frontend/packages/inspector:
dependencies:
@@ -189,7 +189,7 @@ importers:
version: 18.3.7(@types/react@18.3.27)
'@vitejs/plugin-react':
specifier: ^4.3.1
- version: 4.7.0(vite@5.4.21(@types/node@25.2.0))
+ version: 4.7.0(vite@5.4.21(@types/node@25.2.1))
sandbox-agent:
specifier: workspace:*
version: link:../../../sdks/typescript
@@ -198,19 +198,19 @@ importers:
version: 5.9.3
vite:
specifier: ^5.4.7
- version: 5.4.21(@types/node@25.2.0)
+ version: 5.4.21(@types/node@25.2.1)
frontend/packages/website:
dependencies:
'@astrojs/react':
specifier: ^4.2.0
- version: 4.4.2(@types/node@25.2.0)(@types/react-dom@18.3.7(@types/react@18.3.27))(@types/react@18.3.27)(jiti@1.21.7)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(tsx@4.21.0)(yaml@2.8.2)
+ version: 4.4.2(@types/node@25.2.1)(@types/react-dom@18.3.7(@types/react@18.3.27))(@types/react@18.3.27)(jiti@1.21.7)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(tsx@4.21.0)(yaml@2.8.2)
'@astrojs/tailwind':
specifier: ^6.0.0
- version: 6.0.2(astro@5.16.15(@types/node@25.2.0)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2))(tailwindcss@3.4.19(tsx@4.21.0)(yaml@2.8.2))
+ version: 6.0.2(astro@5.16.15(@types/node@25.2.1)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2))(tailwindcss@3.4.19(tsx@4.21.0)(yaml@2.8.2))
astro:
specifier: ^5.1.0
- version: 5.16.15(@types/node@25.2.0)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2)
+ version: 5.16.15(@types/node@25.2.1)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2)
framer-motion:
specifier: ^12.0.0
version: 12.29.2(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
@@ -241,10 +241,10 @@ importers:
dependencies:
'@anthropic-ai/claude-code':
specifier: latest
- version: 2.1.29
+ version: 2.1.34
'@openai/codex':
specifier: latest
- version: 0.94.0
+ version: 0.98.0
cheerio:
specifier: ^1.0.0
version: 1.2.0
@@ -319,14 +319,14 @@ importers:
dependencies:
'@daytonaio/sdk':
specifier: latest
- version: 0.138.0(ws@8.19.0)
+ version: 0.139.0(ws@8.19.0)
'@e2b/code-interpreter':
specifier: latest
version: 2.3.3
devDependencies:
'@types/node':
specifier: latest
- version: 25.2.0
+ version: 25.2.1
tsx:
specifier: latest
version: 4.21.0
@@ -358,7 +358,7 @@ importers:
devDependencies:
vitest:
specifier: ^3.0.0
- version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
sdks/cli-shared:
devDependencies:
@@ -382,6 +382,42 @@ importers:
sdks/cli/platforms/win32-x64: {}
+ sdks/gigacode:
+ dependencies:
+ '@sandbox-agent/cli-shared':
+ specifier: workspace:*
+ version: link:../cli-shared
+ optionalDependencies:
+ '@sandbox-agent/gigacode-darwin-arm64':
+ specifier: workspace:*
+ version: link:platforms/darwin-arm64
+ '@sandbox-agent/gigacode-darwin-x64':
+ specifier: workspace:*
+ version: link:platforms/darwin-x64
+ '@sandbox-agent/gigacode-linux-arm64':
+ specifier: workspace:*
+ version: link:platforms/linux-arm64
+ '@sandbox-agent/gigacode-linux-x64':
+ specifier: workspace:*
+ version: link:platforms/linux-x64
+ '@sandbox-agent/gigacode-win32-x64':
+ specifier: workspace:*
+ version: link:platforms/win32-x64
+ devDependencies:
+ vitest:
+ specifier: ^3.0.0
+ version: 3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+
+ sdks/gigacode/platforms/darwin-arm64: {}
+
+ sdks/gigacode/platforms/darwin-x64: {}
+
+ sdks/gigacode/platforms/linux-arm64: {}
+
+ sdks/gigacode/platforms/linux-x64: {}
+
+ sdks/gigacode/platforms/win32-x64: {}
+
sdks/typescript:
dependencies:
'@sandbox-agent/cli-shared':
@@ -410,8 +446,8 @@ packages:
resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}
engines: {node: '>=10'}
- '@anthropic-ai/claude-code@2.1.29':
- resolution: {integrity: sha512-vMHTOXrYdnreGtKUsWdd3Bwx5fKprTyNG7shrvbx3L2/jU9jexkOJrEKmN5loeR5jrE54LSB38QpaIj8pVM6eQ==}
+ '@anthropic-ai/claude-code@2.1.34':
+ resolution: {integrity: sha512-uQ3yv41lvCExj2Ju/pCZ1KIKub5d5V3RQyeSKICPoJzk/H2Ktp0zonZeLkD/Q56qa4vPpA8MmvsBmFkAr+Z42w==}
engines: {node: '>=18.0.0'}
hasBin: true
@@ -756,38 +792,38 @@ packages:
workerd:
optional: true
- '@cloudflare/workerd-darwin-64@1.20260128.0':
- resolution: {integrity: sha512-XJN8zWWNG3JwAUqqwMLNKJ9fZfdlQkx/zTTHW/BB8wHat9LjKD6AzxqCu432YmfjR+NxEKCzUOxMu1YOxlVxmg==}
+ '@cloudflare/workerd-darwin-64@1.20260205.0':
+ resolution: {integrity: sha512-ToOItqcirmWPwR+PtT+Q4bdjTn/63ZxhJKEfW4FNn7FxMTS1Tw5dml0T0mieOZbCpcvY8BdvPKFCSlJuI8IVHQ==}
engines: {node: '>=16'}
cpu: [x64]
os: [darwin]
- '@cloudflare/workerd-darwin-arm64@1.20260128.0':
- resolution: {integrity: sha512-vKnRcmnm402GQ5DOdfT5H34qeR2m07nhnTtky8mTkNWP+7xmkz32AMdclwMmfO/iX9ncyKwSqmml2wPG32eq/w==}
+ '@cloudflare/workerd-darwin-arm64@1.20260205.0':
+ resolution: {integrity: sha512-402ZqLz+LrG0NDXp7Hn7IZbI0DyhjNfjAlVenb0K3yod9KCuux0u3NksNBvqJx0mIGHvVR4K05h+jfT5BTHqGA==}
engines: {node: '>=16'}
cpu: [arm64]
os: [darwin]
- '@cloudflare/workerd-linux-64@1.20260128.0':
- resolution: {integrity: sha512-RiaR+Qugof/c6oI5SagD2J5wJmIfI8wQWaV2Y9905Raj6sAYOFaEKfzkKnoLLLNYb4NlXicBrffJi1j7R/ypUA==}
+ '@cloudflare/workerd-linux-64@1.20260205.0':
+ resolution: {integrity: sha512-rz9jBzazIA18RHY+osa19hvsPfr0LZI1AJzIjC6UqkKKphcTpHBEQ25Xt8cIA34ivMIqeENpYnnmpDFesLkfcQ==}
engines: {node: '>=16'}
cpu: [x64]
os: [linux]
- '@cloudflare/workerd-linux-arm64@1.20260128.0':
- resolution: {integrity: sha512-U39U9vcXLXYDbrJ112Q7D0LDUUnM54oXfAxPgrL2goBwio7Z6RnsM25TRvm+Q06F4+FeDOC4D51JXlFHb9t1OA==}
+ '@cloudflare/workerd-linux-arm64@1.20260205.0':
+ resolution: {integrity: sha512-jr6cKpMM/DBEbL+ATJ9rYue758CKp0SfA/nXt5vR32iINVJrb396ye9iat2y9Moa/PgPKnTrFgmT6urUmG3IUg==}
engines: {node: '>=16'}
cpu: [arm64]
os: [linux]
- '@cloudflare/workerd-windows-64@1.20260128.0':
- resolution: {integrity: sha512-fdJwSqRkJsAJFJ7+jy0th2uMO6fwaDA8Ny6+iFCssfzlNkc4dP/twXo+3F66FMLMe/6NIqjzVts0cpiv7ERYbQ==}
+ '@cloudflare/workerd-windows-64@1.20260205.0':
+ resolution: {integrity: sha512-SMPW5jCZYOG7XFIglSlsgN8ivcl0pCrSAYxCwxtWvZ88whhcDB/aISNtiQiDZujPH8tIo2hE5dEkxW7tGEwc3A==}
engines: {node: '>=16'}
cpu: [x64]
os: [win32]
- '@cloudflare/workers-types@4.20260131.0':
- resolution: {integrity: sha512-ELgvb2mp68Al50p+FmpgCO2hgU5o4tmz8pi7kShN+cRXc0UZoEdxpDIikR0CeT7b3tV7wlnEnsUzd0UoJLS0oQ==}
+ '@cloudflare/workers-types@4.20260206.0':
+ resolution: {integrity: sha512-rHbE1XM3mfwzoyOiKm1oFRTp00Cv4U5UiuMDQwmu/pc79yOA3nDiOC0lue8aOpobBrP4tPHQqsPcWG606Zrw/w==}
'@connectrpc/connect-web@2.0.0-rc.3':
resolution: {integrity: sha512-w88P8Lsn5CCsA7MFRl2e6oLY4J/5toiNtJns/YJrlyQaWOy3RO8pDgkz+iIkG98RPMhj2thuBvsd3Cn4DKKCkw==}
@@ -804,14 +840,14 @@ packages:
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'}
- '@daytonaio/api-client@0.138.0':
- resolution: {integrity: sha512-mKO3Aqk2aCnOw4ej+UxvKE+Z1ixmo9OKTAFElkvRb6UOwb5zioudqTyqEfijkA2tXUXO8yPGhQDPaICLgpPopA==}
+ '@daytonaio/api-client@0.139.0':
+ resolution: {integrity: sha512-Xmjrkq7MW/DaZLQEf0HfT7Y38N8SesXvWqAKSEjdf3ifGVQVx37aOB8El1jOvfrndqzTcSbumSxro2nhKK5K5A==}
- '@daytonaio/sdk@0.138.0':
- resolution: {integrity: sha512-cnbsflZYJ1NA4pQ2uX2lLN4w4ZQsO/xqdGDnpmwSu/LIW5F+O5gA8z4mfuWdIRcFFT4UhIpTzMuh3zRwxH7dIw==}
+ '@daytonaio/sdk@0.139.0':
+ resolution: {integrity: sha512-67NSkhnl9NiUgBfheN5AtkH0/T5U+WTZmGlY2k+ujAAl/ntpyA/T/q+Pznk44oCJyM1O39OEWt/ugmAEyqRWLg==}
- '@daytonaio/toolbox-api-client@0.138.0':
- resolution: {integrity: sha512-unM9e7MOQiyDXdY8hCW1uTctYbxpo/TGZ6L71ZXyS/j2Cnz9/ud4VWBLcQP2VzlC+lrBP2YMrhT90zSSvcNfmA==}
+ '@daytonaio/toolbox-api-client@0.139.0':
+ resolution: {integrity: sha512-zLonkWHsdmrwT2qCZ/zBt4dpWNJ7N08eGYjCk30Bihzk4JY0afNBPDqd+pdGdXKtuJ44yCxR4iJyjfWR11J9PA==}
'@e2b/code-interpreter@2.3.3':
resolution: {integrity: sha512-WOpSwc1WpvxyOijf6WMbR76BUuvd2O9ddXgCHHi65lkuy6YgQGq7oyd8PNsT331O9Tqbccjy6uF4xanSdLX1UA==}
@@ -1717,8 +1753,8 @@ packages:
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
engines: {node: '>= 8'}
- '@openai/codex@0.94.0':
- resolution: {integrity: sha512-GKOU2ty3NXls2aeiFSCnSSB6zQBtENqC5OnPa8s79Z576YP1r2DIfUrhQZzVDKmFei852E1SG4TNljFL/081gg==}
+ '@openai/codex@0.98.0':
+ resolution: {integrity: sha512-CKjrhAmzTvWn7Vbsi27iZRKBAJw9a7ZTTkWQDbLgQZP1weGbDIBk1r6wiLEp1ZmDO7w0fHPLYgnVspiOrYgcxg==}
engines: {node: '>=16'}
hasBin: true
@@ -2203,8 +2239,8 @@ packages:
'@types/node@24.10.9':
resolution: {integrity: sha512-ne4A0IpG3+2ETuREInjPNhUGis1SFjv1d5asp8MzEAGtOZeTeHVDOYqOgqfhvseqg/iXty2hjBf1zAOb7RNiNw==}
- '@types/node@25.2.0':
- resolution: {integrity: sha512-DZ8VwRFUNzuqJ5khrvwMXHmvPe+zGayJhr2CDNiKB1WBE1ST8Djl00D0IC4vvNmHMdj6DlbYRIaFE7WHjlDl5w==}
+ '@types/node@25.2.1':
+ resolution: {integrity: sha512-CPrnr8voK8vC6eEtyRzvMpgp3VyVRhgclonE7qYi6P9sXwYb59ucfrnmFBTaP0yUi8Gk4yZg/LlTJULGxvTNsg==}
'@types/prop-types@15.7.15':
resolution: {integrity: sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==}
@@ -2948,11 +2984,13 @@ packages:
glob@10.5.0:
resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==}
+ deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
hasBin: true
glob@11.1.0:
resolution: {integrity: sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==}
engines: {node: 20 || >=22}
+ deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
hasBin: true
gopd@1.2.0:
@@ -3347,8 +3385,8 @@ packages:
resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==}
engines: {node: '>=12'}
- miniflare@4.20260128.0:
- resolution: {integrity: sha512-AVCn3vDRY+YXu1sP4mRn81ssno6VUqxo29uY2QVfgxXU2TMLvhRIoGwm7RglJ3Gzfuidit5R86CMQ6AvdFTGAw==}
+ miniflare@4.20260205.0:
+ resolution: {integrity: sha512-jG1TknEDeFqcq/z5gsOm1rKeg4cNG7ruWxEuiPxl3pnQumavxo8kFpeQC6XKVpAhh2PI9ODGyIYlgd77sTHl5g==}
engines: {node: '>=18.0.0'}
hasBin: true
@@ -3937,7 +3975,7 @@ packages:
tar@7.5.6:
resolution: {integrity: sha512-xqUeu2JAIJpXyvskvU3uvQW8PAmHrtXp2KDuMJwQqW8Sqq0CaZBAQ+dKS3RBXVhU4wC5NjAdKrmh84241gO9cA==}
engines: {node: '>=18'}
- deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me
+ deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
text-decoder@1.2.3:
resolution: {integrity: sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==}
@@ -4381,17 +4419,17 @@ packages:
resolution: {integrity: sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA==}
engines: {node: '>=18'}
- workerd@1.20260128.0:
- resolution: {integrity: sha512-EhLJGptSGFi8AEErLiamO3PoGpbRqL+v4Ve36H2B38VxmDgFOSmDhfepBnA14sCQzGf1AEaoZX2DCwZsmO74yQ==}
+ workerd@1.20260205.0:
+ resolution: {integrity: sha512-CcMH5clHwrH8VlY7yWS9C/G/C8g9czIz1yU3akMSP9Z3CkEMFSoC3GGdj5G7Alw/PHEeez1+1IrlYger4pwu+w==}
engines: {node: '>=16'}
hasBin: true
- wrangler@4.61.1:
- resolution: {integrity: sha512-hfYQ16VLPkNi8xE1/V3052S2stM5e+vq3Idpt83sXoDC3R7R1CLgMkK6M6+Qp3G+9GVDNyHCkvohMPdfFTaD4Q==}
+ wrangler@4.63.0:
+ resolution: {integrity: sha512-+R04jF7Eb8K3KRMSgoXpcIdLb8GC62eoSGusYh1pyrSMm/10E0hbKkd7phMJO4HxXc6R7mOHC5SSoX9eof30Uw==}
engines: {node: '>=20.0.0'}
hasBin: true
peerDependencies:
- '@cloudflare/workers-types': ^4.20260128.0
+ '@cloudflare/workers-types': ^4.20260205.0
peerDependenciesMeta:
'@cloudflare/workers-types':
optional: true
@@ -4512,7 +4550,7 @@ snapshots:
'@alloc/quick-lru@5.2.0': {}
- '@anthropic-ai/claude-code@2.1.29':
+ '@anthropic-ai/claude-code@2.1.34':
optionalDependencies:
'@img/sharp-darwin-arm64': 0.33.5
'@img/sharp-darwin-x64': 0.33.5
@@ -4557,15 +4595,15 @@ snapshots:
dependencies:
prismjs: 1.30.0
- '@astrojs/react@4.4.2(@types/node@25.2.0)(@types/react-dom@18.3.7(@types/react@18.3.27))(@types/react@18.3.27)(jiti@1.21.7)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(tsx@4.21.0)(yaml@2.8.2)':
+ '@astrojs/react@4.4.2(@types/node@25.2.1)(@types/react-dom@18.3.7(@types/react@18.3.27))(@types/react@18.3.27)(jiti@1.21.7)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(tsx@4.21.0)(yaml@2.8.2)':
dependencies:
'@types/react': 18.3.27
'@types/react-dom': 18.3.7(@types/react@18.3.27)
- '@vitejs/plugin-react': 4.7.0(vite@6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
+ '@vitejs/plugin-react': 4.7.0(vite@6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
react: 19.2.4
react-dom: 19.2.4(react@19.2.4)
ultrahtml: 1.6.0
- vite: 6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ vite: 6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
transitivePeerDependencies:
- '@types/node'
- jiti
@@ -4580,9 +4618,9 @@ snapshots:
- tsx
- yaml
- '@astrojs/tailwind@6.0.2(astro@5.16.15(@types/node@25.2.0)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2))(tailwindcss@3.4.19(tsx@4.21.0)(yaml@2.8.2))':
+ '@astrojs/tailwind@6.0.2(astro@5.16.15(@types/node@25.2.1)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2))(tailwindcss@3.4.19(tsx@4.21.0)(yaml@2.8.2))':
dependencies:
- astro: 5.16.15(@types/node@25.2.0)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2)
+ astro: 5.16.15(@types/node@25.2.1)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2)
autoprefixer: 10.4.23(postcss@8.5.6)
postcss: 8.5.6
postcss-load-config: 4.0.2(postcss@8.5.6)
@@ -5274,28 +5312,28 @@ snapshots:
dependencies:
'@cloudflare/containers': 0.0.30
- '@cloudflare/unenv-preset@2.12.0(unenv@2.0.0-rc.24)(workerd@1.20260128.0)':
+ '@cloudflare/unenv-preset@2.12.0(unenv@2.0.0-rc.24)(workerd@1.20260205.0)':
dependencies:
unenv: 2.0.0-rc.24
optionalDependencies:
- workerd: 1.20260128.0
+ workerd: 1.20260205.0
- '@cloudflare/workerd-darwin-64@1.20260128.0':
+ '@cloudflare/workerd-darwin-64@1.20260205.0':
optional: true
- '@cloudflare/workerd-darwin-arm64@1.20260128.0':
+ '@cloudflare/workerd-darwin-arm64@1.20260205.0':
optional: true
- '@cloudflare/workerd-linux-64@1.20260128.0':
+ '@cloudflare/workerd-linux-64@1.20260205.0':
optional: true
- '@cloudflare/workerd-linux-arm64@1.20260128.0':
+ '@cloudflare/workerd-linux-arm64@1.20260205.0':
optional: true
- '@cloudflare/workerd-windows-64@1.20260128.0':
+ '@cloudflare/workerd-windows-64@1.20260205.0':
optional: true
- '@cloudflare/workers-types@4.20260131.0': {}
+ '@cloudflare/workers-types@4.20260206.0': {}
'@connectrpc/connect-web@2.0.0-rc.3(@bufbuild/protobuf@2.11.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.11.0))':
dependencies:
@@ -5310,18 +5348,18 @@ snapshots:
dependencies:
'@jridgewell/trace-mapping': 0.3.9
- '@daytonaio/api-client@0.138.0':
+ '@daytonaio/api-client@0.139.0':
dependencies:
axios: 1.13.4
transitivePeerDependencies:
- debug
- '@daytonaio/sdk@0.138.0(ws@8.19.0)':
+ '@daytonaio/sdk@0.139.0(ws@8.19.0)':
dependencies:
'@aws-sdk/client-s3': 3.975.0
'@aws-sdk/lib-storage': 3.975.0(@aws-sdk/client-s3@3.975.0)
- '@daytonaio/api-client': 0.138.0
- '@daytonaio/toolbox-api-client': 0.138.0
+ '@daytonaio/api-client': 0.139.0
+ '@daytonaio/toolbox-api-client': 0.139.0
'@iarna/toml': 2.2.5
axios: 1.13.4
busboy: 1.6.0
@@ -5338,7 +5376,7 @@ snapshots:
- debug
- ws
- '@daytonaio/toolbox-api-client@0.138.0':
+ '@daytonaio/toolbox-api-client@0.139.0':
dependencies:
axios: 1.13.4
transitivePeerDependencies:
@@ -5891,7 +5929,7 @@ snapshots:
'@nodelib/fs.scandir': 2.1.5
fastq: 1.20.1
- '@openai/codex@0.94.0': {}
+ '@openai/codex@0.98.0': {}
'@oslojs/encoding@1.1.0': {}
@@ -6427,13 +6465,13 @@ snapshots:
'@types/docker-modem@3.0.6':
dependencies:
- '@types/node': 25.2.0
+ '@types/node': 25.2.1
'@types/ssh2': 1.15.5
'@types/dockerode@4.0.1':
dependencies:
'@types/docker-modem': 3.0.6
- '@types/node': 25.2.0
+ '@types/node': 25.2.1
'@types/ssh2': 1.15.5
'@types/estree@1.0.8': {}
@@ -6466,7 +6504,7 @@ snapshots:
dependencies:
undici-types: 7.16.0
- '@types/node@25.2.0':
+ '@types/node@25.2.1':
dependencies:
undici-types: 7.16.0
@@ -6508,7 +6546,7 @@ snapshots:
- bare-abort-controller
- react-native-b4a
- '@vitejs/plugin-react@4.7.0(vite@5.4.21(@types/node@25.2.0))':
+ '@vitejs/plugin-react@4.7.0(vite@5.4.21(@types/node@25.2.1))':
dependencies:
'@babel/core': 7.28.6
'@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/core@7.28.6)
@@ -6516,11 +6554,11 @@ snapshots:
'@rolldown/pluginutils': 1.0.0-beta.27
'@types/babel__core': 7.20.5
react-refresh: 0.17.0
- vite: 5.4.21(@types/node@25.2.0)
+ vite: 5.4.21(@types/node@25.2.1)
transitivePeerDependencies:
- supports-color
- '@vitejs/plugin-react@4.7.0(vite@6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))':
+ '@vitejs/plugin-react@4.7.0(vite@6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))':
dependencies:
'@babel/core': 7.28.6
'@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/core@7.28.6)
@@ -6528,7 +6566,7 @@ snapshots:
'@rolldown/pluginutils': 1.0.0-beta.27
'@types/babel__core': 7.20.5
react-refresh: 0.17.0
- vite: 6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ vite: 6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
transitivePeerDependencies:
- supports-color
@@ -6540,13 +6578,13 @@ snapshots:
chai: 5.3.3
tinyrainbow: 2.0.0
- '@vitest/mocker@3.2.4(vite@5.4.21(@types/node@25.2.0))':
+ '@vitest/mocker@3.2.4(vite@5.4.21(@types/node@25.2.1))':
dependencies:
'@vitest/spy': 3.2.4
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
- vite: 5.4.21(@types/node@25.2.0)
+ vite: 5.4.21(@types/node@25.2.1)
'@vitest/pretty-format@3.2.4':
dependencies:
@@ -6613,7 +6651,7 @@ snapshots:
assertion-error@2.0.1: {}
- astro@5.16.15(@types/node@25.2.0)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2):
+ astro@5.16.15(@types/node@25.2.1)(jiti@1.21.7)(rollup@4.56.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2):
dependencies:
'@astrojs/compiler': 2.13.0
'@astrojs/internal-helpers': 0.7.5
@@ -6670,8 +6708,8 @@ snapshots:
unist-util-visit: 5.1.0
unstorage: 1.17.4
vfile: 6.0.3
- vite: 6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
- vitefu: 1.1.1(vite@6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
+ vite: 6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ vitefu: 1.1.1(vite@6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2))
xxhash-wasm: 1.1.0
yargs-parser: 21.1.1
yocto-spinner: 0.2.3
@@ -8016,12 +8054,12 @@ snapshots:
mimic-fn@4.0.0: {}
- miniflare@4.20260128.0:
+ miniflare@4.20260205.0:
dependencies:
'@cspotcode/source-map-support': 0.8.1
sharp: 0.34.5
undici: 7.18.2
- workerd: 1.20260128.0
+ workerd: 1.20260205.0
ws: 8.18.0
youch: 4.1.0-beta.10
transitivePeerDependencies:
@@ -8287,7 +8325,7 @@ snapshots:
'@protobufjs/path': 1.1.2
'@protobufjs/pool': 1.1.0
'@protobufjs/utf8': 1.1.0
- '@types/node': 25.2.0
+ '@types/node': 25.2.1
long: 5.3.2
proxy-from-env@1.1.0: {}
@@ -9000,13 +9038,13 @@ snapshots:
- tsx
- yaml
- vite-node@3.2.4(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
+ vite-node@3.2.4(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
dependencies:
cac: 6.7.14
debug: 4.4.3
es-module-lexer: 1.7.0
pathe: 2.0.3
- vite: 6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ vite: 6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
transitivePeerDependencies:
- '@types/node'
- jiti
@@ -9030,13 +9068,13 @@ snapshots:
'@types/node': 22.19.7
fsevents: 2.3.3
- vite@5.4.21(@types/node@25.2.0):
+ vite@5.4.21(@types/node@25.2.1):
dependencies:
esbuild: 0.21.5
postcss: 8.5.6
rollup: 4.56.0
optionalDependencies:
- '@types/node': 25.2.0
+ '@types/node': 25.2.1
fsevents: 2.3.3
vite@6.4.1(@types/node@22.19.7)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
@@ -9054,7 +9092,7 @@ snapshots:
tsx: 4.21.0
yaml: 2.8.2
- vite@6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
+ vite@6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
dependencies:
esbuild: 0.25.12
fdir: 6.5.0(picomatch@4.0.3)
@@ -9063,21 +9101,21 @@ snapshots:
rollup: 4.56.0
tinyglobby: 0.2.15
optionalDependencies:
- '@types/node': 25.2.0
+ '@types/node': 25.2.1
fsevents: 2.3.3
jiti: 1.21.7
tsx: 4.21.0
yaml: 2.8.2
- vitefu@1.1.1(vite@6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)):
+ vitefu@1.1.1(vite@6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)):
optionalDependencies:
- vite: 6.4.1(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ vite: 6.4.1(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
vitest@3.2.4(@types/debug@4.1.12)(@types/node@22.19.7)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.4
- '@vitest/mocker': 3.2.4(vite@5.4.21(@types/node@25.2.0))
+ '@vitest/mocker': 3.2.4(vite@5.4.21(@types/node@25.2.1))
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
@@ -9115,11 +9153,11 @@ snapshots:
- tsx
- yaml
- vitest@3.2.4(@types/debug@4.1.12)(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
+ vitest@3.2.4(@types/debug@4.1.12)(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2):
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.4
- '@vitest/mocker': 3.2.4(vite@5.4.21(@types/node@25.2.0))
+ '@vitest/mocker': 3.2.4(vite@5.4.21(@types/node@25.2.1))
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
@@ -9137,12 +9175,12 @@ snapshots:
tinyglobby: 0.2.15
tinypool: 1.1.1
tinyrainbow: 2.0.0
- vite: 5.4.21(@types/node@25.2.0)
- vite-node: 3.2.4(@types/node@25.2.0)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
+ vite: 5.4.21(@types/node@25.2.1)
+ vite-node: 3.2.4(@types/node@25.2.1)(jiti@1.21.7)(tsx@4.21.0)(yaml@2.8.2)
why-is-node-running: 2.3.0
optionalDependencies:
'@types/debug': 4.1.12
- '@types/node': 25.2.0
+ '@types/node': 25.2.1
transitivePeerDependencies:
- jiti
- less
@@ -9184,26 +9222,26 @@ snapshots:
dependencies:
string-width: 7.2.0
- workerd@1.20260128.0:
+ workerd@1.20260205.0:
optionalDependencies:
- '@cloudflare/workerd-darwin-64': 1.20260128.0
- '@cloudflare/workerd-darwin-arm64': 1.20260128.0
- '@cloudflare/workerd-linux-64': 1.20260128.0
- '@cloudflare/workerd-linux-arm64': 1.20260128.0
- '@cloudflare/workerd-windows-64': 1.20260128.0
+ '@cloudflare/workerd-darwin-64': 1.20260205.0
+ '@cloudflare/workerd-darwin-arm64': 1.20260205.0
+ '@cloudflare/workerd-linux-64': 1.20260205.0
+ '@cloudflare/workerd-linux-arm64': 1.20260205.0
+ '@cloudflare/workerd-windows-64': 1.20260205.0
- wrangler@4.61.1(@cloudflare/workers-types@4.20260131.0):
+ wrangler@4.63.0(@cloudflare/workers-types@4.20260206.0):
dependencies:
'@cloudflare/kv-asset-handler': 0.4.2
- '@cloudflare/unenv-preset': 2.12.0(unenv@2.0.0-rc.24)(workerd@1.20260128.0)
+ '@cloudflare/unenv-preset': 2.12.0(unenv@2.0.0-rc.24)(workerd@1.20260205.0)
blake3-wasm: 2.1.5
esbuild: 0.27.0
- miniflare: 4.20260128.0
+ miniflare: 4.20260205.0
path-to-regexp: 6.3.0
unenv: 2.0.0-rc.24
- workerd: 1.20260128.0
+ workerd: 1.20260205.0
optionalDependencies:
- '@cloudflare/workers-types': 4.20260131.0
+ '@cloudflare/workers-types': 4.20260206.0
fsevents: 2.3.3
transitivePeerDependencies:
- bufferutil
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index dda7e8c..f60a64a 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -3,6 +3,8 @@ packages:
- "sdks/*"
- "sdks/cli"
- "sdks/cli/platforms/*"
+ - "sdks/gigacode"
+ - "sdks/gigacode/platforms/*"
- "resources/agent-schemas"
- "resources/vercel-ai-sdk-schemas"
- "scripts/release"
diff --git a/research/agents/amp.md b/research/agents/amp.md
index f6b800f..ff314dd 100644
--- a/research/agents/amp.md
+++ b/research/agents/amp.md
@@ -4,11 +4,13 @@ Research notes on Sourcegraph Amp's configuration, credential discovery, and run
## Overview
-- **Provider**: Anthropic (via Sourcegraph)
+- **Provider**: Anthropic (via Sourcegraph, proxied through ampcode.com)
- **Execution Method**: CLI subprocess (`amp` command)
- **Session Persistence**: Session ID (string)
- **SDK**: `@sourcegraph/amp-sdk` (closed source)
+- **Binary**: Bun-bundled JS application (ELF wrapping Bun runtime + embedded JS)
- **Binary Location**: `/usr/local/bin/amp`
+- **Backend**: `https://ampcode.com/` (server-side proxy for all LLM requests)
## CLI Usage
@@ -208,6 +210,211 @@ curl -fsSL "https://storage.googleapis.com/amp-public-assets-prod-0/cli/${VERSIO
- Default timeout: 5 minutes (300,000 ms)
- Process killed with `SIGTERM` on timeout
+## Model Discovery
+
+**No model discovery mechanism exists.** Amp uses a server-side proxy architecture where model selection is abstracted behind "modes".
+
+### Architecture (Reverse Engineered)
+
+Amp is **NOT a Go binary** as previously thought — it is a **Bun-bundled JavaScript application** (ELF binary wrapping Bun runtime + embedded JS). The CLI logs confirm: `"argv":["bun","/$bunfs/root/amp-linux-x64",...]`.
+
+**Amp is a server-side proxy.** All LLM requests go through `https://ampcode.com/`:
+1. CLI authenticates via `AMP_API_KEY` env var or browser-based OAuth to `https://ampcode.com/auth/cli-login`
+2. On startup, calls `getUserInfo` against `https://ampcode.com/`
+3. Model selection is handled **server-side**, not client-side
+
+### Modes Instead of Models
+
+Amp uses **modes** (`--mode` / `-m` flag) instead of direct model selection. Each mode bundles a model, system prompt, and tool selection together server-side.
+
+#### Agent Modes
+
+| Mode | Primary Model | Description |
+|------|---------------|-------------|
+| `smart` | Claude Opus 4.6 | Default. Unconstrained state-of-the-art model use, maximum capability and autonomy |
+| `rush` | Claude Haiku 4.5 | Faster and cheaper, suitable for small, well-defined tasks |
+| `deep` | GPT-5.2 Codex | Deep reasoning with extended thinking for complex problems. Requires `amp.experimental.modes: ["deep"]` |
+| `free` | Unknown | Free tier (listed in CLI `--help` but not on docs site) |
+| `large` | Unknown | Hidden/undocumented mode (referenced in docs but no details) |
+
+Source: [ampcode.com/manual](https://ampcode.com/manual), [ampcode.com/models](https://ampcode.com/models)
+
+#### Specialized Models (not user-selectable)
+
+Amp also uses additional models for specific subtasks:
+
+| Role | Model | Purpose |
+|------|-------|---------|
+| Review | Gemini 3 Pro | Code review and bug detection |
+| Search subagent | Gemini 3 Flash | Codebase retrieval |
+| Oracle subagent | GPT-5.2 | Complex code reasoning |
+| Librarian subagent | Claude Sonnet 4.5 | External code research |
+| Image/PDF analysis | Gemini 3 Flash | Multimodal input processing |
+| Content generation | Gemini 3 Pro Image (Painter) | Image generation |
+| Handoff (context) | Gemini 2.5 Flash | Context management |
+| Thread categorization | Gemini 2.5 Flash-Lite | Thread organization |
+| Title generation | Claude Haiku 4.5 | Thread title generation |
+
+#### Mode Subsettings
+
+- **`amp.experimental.modes`** — Array of experimental mode names to enable. Currently only `["deep"]` is documented.
+- **`amp.internal.deepReasoningEffort`** — Override reasoning effort for GPT-5.2 Codex in deep mode. Options: `medium`, `high`, `xhigh`. Default: `medium`. Keyboard shortcut `Alt+D` cycles through `deep` → `deep²` → `deep³` (corresponding to medium → high → xhigh).
+
+#### Switching Modes
+
+- **CLI flag**: `--mode
` or `-m `
+- **Interactive TUI**: `Ctrl+O` → type "mode"
+- **Editor extension**: Mode selector in the prompt field
+
+#### No Programmatic Mode Listing
+
+There is no CLI command (`amp modes list`) or API endpoint to list available modes. The modes are:
+- Hardcoded in the `--help` text: `deep, free, rush, smart`
+- Documented on [ampcode.com/manual](https://ampcode.com/manual) and [ampcode.com/models](https://ampcode.com/models)
+- Up-to-date list available at [ampcode.com/manual#agent-modes](https://ampcode.com/manual#agent-modes)
+
+The `--model` flag also still exists on the CLI but modes are the primary interface. It's unclear if `--model` bypasses mode selection or if it's ignored.
+
+### Reverse Engineering Methodology
+
+#### Step 1: CLI help analysis
+
+```bash
+amp --help
+```
+
+Revealed:
+- `-m, --mode ` flag with `deep`, `free`, `rush`, `smart` options (not `--model` for models)
+- `AMP_URL` env var defaults to `https://ampcode.com/`
+- `AMP_API_KEY` env var for authentication
+- Settings at `~/.config/amp/settings.json`
+- Logs at `~/.cache/amp/logs/cli.log`
+
+#### Step 2: Binary analysis
+
+```bash
+file ~/.local/bin/amp # → ELF 64-bit LSB executable, 117MB
+ls -lh ~/.local/bin/amp # → 117M
+strings ~/.local/bin/amp | grep 'ampcode' # → 43 matches, embedded JS visible
+```
+
+The `file` command showed an ELF binary, initially suggesting a compiled Go binary. But `strings` revealed embedded JavaScript source code, and the debug logs later confirmed it's actually a **Bun-bundled application** (`argv: ["bun", "/$bunfs/root/amp-linux-x64", ...]`).
+
+The embedded JS is minified but partially readable via `strings`. Found tool definitions (`edit_file`, `write_file`, `create_file`), skill loading code, and MCP integration code. Did not find hardcoded model lists or mode→model mappings — these are server-side.
+
+#### Step 3: strace (failed for network, useful for file IO)
+
+```bash
+strace -e trace=connect -f amp --execute "say hello" ...
+```
+
+**Result: No `AF_INET` connections captured.** Only saw:
+- `AF_UNIX` socket to `/tmp/tmux-1000/default` (tmux IPC)
+- `socketpair()` for internal IPC between threads
+
+**Why it failed:** Bun uses `io_uring` for async network IO on Linux, which bypasses traditional `connect()`/`sendto()` syscalls. strace hooks into the syscall layer, but io_uring submits work directly to the kernel via shared memory rings, making it invisible to strace.
+
+Even with full syscall tracing (`strace -f -s 512` capturing 27,000 lines), zero TCP connections appeared.
+
+#### Step 4: Process network inspection (partial success)
+
+```bash
+# While amp was running:
+ss -tnp | grep amp
+cat /proc//net/tcp6
+```
+
+From `/proc/net/tcp6`, decoded a connection to port `01BB` (443/HTTPS). Resolved the destination to `34.54.147.251` via:
+
+```bash
+dig ampcode.com +short # → 34.54.147.251
+```
+
+Confirmed Amp connects to `ampcode.com:443`. But `ss -tnp` couldn't attribute the connection to the amp process (process had already exited or Bun's process model confused ss).
+
+#### Step 5: Debug logging (most useful)
+
+```bash
+env AMP_API_KEY=fake-key amp --execute "say hello" --stream-json --log-level debug
+# Then read: ~/.cache/amp/logs/cli.log
+```
+
+The debug log revealed the complete startup sequence and API flow. Key log messages:
+- `"Initializing CLI context"` — shows `hasAmpAPIKey`, `hasAmpURL`, `hasSettingsFile`
+- `"Resolved Amp URL"` → `https://ampcode.com/`
+- `"API key lookup before login"` — `found: true/false`
+- `"API request for getUserInfo failed: 401"` — confirms API call to ampcode.com with our fake key
+- `"Starting Amp background services"` — proceeds even after auth failure
+
+#### Step 6: Fake API key to bypass login (success)
+
+Without `AMP_API_KEY`, Amp hangs indefinitely trying to open a browser for OAuth at `https://ampcode.com/auth/cli-login?authToken=...&callbackPort=...`. Setting `AMP_API_KEY=fake-key` bypasses the browser login flow and reaches the API call stage (where it gets a 401).
+
+#### Step 7: NODE_DEBUG (failed)
+
+```bash
+env NODE_DEBUG=http,https,net amp ...
+```
+
+No output — Bun ignores Node.js debug environment variables.
+
+### What Was NOT Captured
+
+- **Actual HTTP request/response bodies** — Would require mitmproxy with HTTPS interception (set `amp.proxy` or `HTTPS_PROXY` env var, install custom CA cert). Not attempted.
+- **Mode→model mappings** — These are server-side in ampcode.com. The CLI sends a mode name and the server selects the model.
+- **Full API schema** — Only saw `getUserInfo` endpoint name in error message. Thread creation, message streaming, and other endpoints are unknown.
+- **Whether `--model` bypasses mode selection** — Couldn't test without a valid API key.
+
+### Future Investigation
+
+To capture full HTTP traffic, set up mitmproxy:
+
+```bash
+# Install mitmproxy
+pip install mitmproxy
+
+# Start proxy
+mitmproxy --listen-port 8080
+
+# Run amp through proxy (amp.proxy setting or env var)
+# amp respects amp.proxy setting in ~/.config/amp/settings.json:
+# { "amp.proxy": "http://localhost:8080" }
+#
+# Then install mitmproxy's CA cert for TLS interception.
+```
+
+Alternatively, since amp is a Bun binary, it may respect `HTTPS_PROXY` env var by default (Go's `net/http` does, Bun's `fetch` may as well).
+
+### API Flow (from debug logs)
+
+```
+1. "Starting Amp CLI" (version 0.0.1770352274-gd36e02)
+2. "Initializing CLI context" (hasAmpAPIKey: true/false)
+3. "Resolved Amp URL" → https://ampcode.com/
+4. Skills loading, MCP initialization, toolbox registration
+5. "API key lookup before login"
+6. getUserInfo API call → https://ampcode.com/ (401 with invalid key)
+7. "Starting Amp background services"
+8. Thread creation + message streaming via ampcode.com
+```
+
+### Current Behavior
+
+The sandbox-agent passes `--model` through to Amp without validation:
+
+```rust
+if let Some(model) = options.model.as_deref() {
+ command.arg("--model").arg(model);
+}
+```
+
+### Possible Approaches
+
+1. **Proxy provider APIs** — Not applicable; Amp proxies through ampcode.com, not directly to model providers
+2. **Hardcode known modes** — Expose the four modes (`deep`, `free`, `rush`, `smart`) as the available "model" options
+3. **Wait for Amp API** — Amp may add model/mode discovery in a future release
+4. **Scrape ampcode.com** — Check if the web UI exposes available modes/models
+
## Notes
- Amp is similar to Claude Code (same streaming format)
diff --git a/research/agents/claude.md b/research/agents/claude.md
index 42a552b..b78f278 100644
--- a/research/agents/claude.md
+++ b/research/agents/claude.md
@@ -226,6 +226,59 @@ Claude output is converted via `convertClaudeOutput()`:
3. Parse with `ClaudeCliResponseSchema` as fallback
4. Extract `structured_output` as metadata if present
+## Model Discovery
+
+Claude Code's `/models` slash command uses the **standard Anthropic Models API**.
+
+### API Endpoint
+
+```
+GET https://api.anthropic.com/v1/models?beta=true
+```
+
+Found by reverse engineering the CLI bundle at `node_modules/@anthropic-ai/claude-code/cli.js`.
+
+### API Client
+
+The CLI contains an internal `Models` class with two methods:
+
+```javascript
+// List all models
+GET /v1/models?beta=true
+
+// Retrieve a single model
+GET /v1/models/${modelId}?beta=true
+```
+
+Uses `this._client.getAPIList()` which handles paginated responses. The `?beta=true` query parameter is hardcoded to include beta/preview models.
+
+### Authentication
+
+Uses the same Anthropic API key / OAuth credentials that Claude Code uses for conversations. The request goes to the standard Anthropic API base URL.
+
+### Hardcoded Context Window Data
+
+The CLI also contains hardcoded output token limits for certain models (used as fallback):
+
+```javascript
+{
+ "claude-opus-4-20250514": 8192,
+ "claude-opus-4-0": 8192,
+ "claude-opus-4-1-20250805": 8192,
+ // ... more entries
+}
+```
+
+### How to Replicate
+
+Call the Anthropic API directly — no need to go through the Claude CLI:
+
+```
+GET https://api.anthropic.com/v1/models?beta=true
+x-api-key:
+anthropic-version: 2023-06-01
+```
+
## Notes
- Claude CLI manages its own OAuth refresh internally
diff --git a/research/agents/codex.md b/research/agents/codex.md
index b0e4098..8d3d970 100644
--- a/research/agents/codex.md
+++ b/research/agents/codex.md
@@ -318,6 +318,35 @@ fn codex_thread_id_from_server_notification(notification) -> Option {
}
```
+## Model Discovery
+
+Codex exposes a `model/list` JSON-RPC method through its app-server process.
+
+### JSON-RPC Method
+
+```json
+{
+ "jsonrpc": "2.0",
+ "id": 1,
+ "method": "model/list",
+ "params": {
+ "cursor": null,
+ "limit": null
+ }
+}
+```
+
+Supports pagination via `cursor` and `limit` parameters. Defined in `resources/agent-schemas/artifacts/json-schema/codex.json`.
+
+### How to Replicate
+
+Requires a running Codex app-server process. Send the JSON-RPC request to the app-server over stdio. The response contains the list of models available to the Codex instance (depends on configured API keys / providers).
+
+### Limitations
+
+- Requires an active app-server process (cannot query models without starting one)
+- No standalone CLI command like `codex models`
+
## Notes
- SDK is dynamically imported to reduce bundle size
diff --git a/research/agents/opencode.md b/research/agents/opencode.md
index 8a19fd2..8708282 100644
--- a/research/agents/opencode.md
+++ b/research/agents/opencode.md
@@ -509,6 +509,82 @@ const pollInterval = setInterval(async () => {
}, 2000);
```
+## Model Discovery
+
+OpenCode has the richest model discovery support with both CLI and HTTP API.
+
+### CLI Commands
+
+```bash
+opencode models # List all available models
+opencode models # List models for a specific provider
+```
+
+### HTTP Endpoint
+
+```
+GET /provider
+```
+
+### Response Schema
+
+```json
+{
+ "all": [
+ {
+ "id": "anthropic",
+ "name": "Anthropic",
+ "api": "string",
+ "env": ["ANTHROPIC_API_KEY"],
+ "npm": "string",
+ "models": {
+ "model-key": {
+ "id": "string",
+ "name": "string",
+ "family": "string",
+ "release_date": "string",
+ "attachment": true,
+ "reasoning": false,
+ "tool_call": true,
+ "cost": {
+ "input": 0.003,
+ "output": 0.015,
+ "cache_read": 0.0003,
+ "cache_write": 0.00375
+ },
+ "limit": {
+ "context": 200000,
+ "input": 200000,
+ "output": 8192
+ },
+ "modalities": {
+ "input": ["text", "image"],
+ "output": ["text"]
+ },
+ "experimental": false,
+ "status": "beta"
+ }
+ }
+ }
+ ],
+ "default": {
+ "anthropic": "claude-sonnet-4-20250514"
+ },
+ "connected": ["anthropic"]
+}
+```
+
+### SDK Usage
+
+```typescript
+const client = createOpencodeClient();
+const response = await client.provider.list();
+```
+
+### How to Replicate
+
+When an OpenCode server is running, call `GET /provider` on its HTTP port. Returns full model metadata including capabilities, costs, context limits, and modalities.
+
## Notes
- OpenCode is the most feature-rich runtime (streaming, questions, permissions)
diff --git a/research/opencode-compat/COMPARISON.md b/research/opencode-compat/COMPARISON.md
new file mode 100644
index 0000000..08cc040
--- /dev/null
+++ b/research/opencode-compat/COMPARISON.md
@@ -0,0 +1,70 @@
+# Native OpenCode vs Sandbox-Agent: OpenCode API Comparison
+
+## Overview
+
+Captured API output from both native OpenCode server (v1.1.49) and sandbox-agent's
+OpenCode compatibility layer, sending identical request patterns:
+1. Message 1: Simple text response (echo/text)
+2. Message 2: Tool call (ls/mock.search)
+
+## Bugs Found and Fixed
+
+### 1. Tool name (`tool` field) changed between events [FIXED]
+
+**Bug**: The `tool` field in tool part events changed between `pending` and `running`/`completed`
+states. In the `pending` event it correctly showed `"mock.search"`, but in subsequent events
+(from ToolResult) it showed `"tool"` because `extract_tool_content` doesn't return tool_name
+for ToolResult items.
+
+**Fix**: Added `tool_name_by_call` HashMap to `OpenCodeSessionRuntime` to persist tool names
+from ToolCall events and look them up during ToolResult processing.
+
+### 2. Tool `input` lost on ToolResult events [FIXED]
+
+**Bug**: When the ToolResult event came in, the tool's input arguments were lost because
+ToolResult content only contains `call_id` and `output`, not arguments.
+
+**Fix**: Added `tool_args_by_call` HashMap to `OpenCodeSessionRuntime` to persist arguments
+from ToolCall events and look them up during ToolResult processing.
+
+### 3. Tool `output` in wrong field (`error` instead of `output`) [FIXED]
+
+**Bug**: When tool result status was `Failed`, the output text was put in `"error"` field.
+Native OpenCode uses `"output"` field for tool output regardless of success/failure.
+
+**Fix**: Changed the failed tool result JSON to use `"output"` instead of `"error"`.
+
+### 4. Text doubling in streaming [FIXED]
+
+**Bug**: During text streaming, `ItemStarted` emitted a text part with full content, then
+`ItemDelta` appended delta text, then `ItemCompleted` emitted again, causing doubled text.
+
+**Fix**: `ItemStarted` now only initializes empty text in runtime without emitting a part event.
+`ItemCompleted` emits the final text using accumulated delta text or fallback to content text.
+
+### 5. Missing `delta` field in text streaming events [FIXED]
+
+**Bug**: `delta` field was not included in `message.part.updated` events for text streaming.
+Native OpenCode includes `delta` on streaming events and omits it on the final event.
+
+**Fix**: Changed `apply_item_delta` to use `part_event_with_delta` instead of `part_event`.
+
+### 6. Not bugs (noted for completeness)
+
+- **Missing `step-start`/`step-finish` parts**: These are OpenCode-specific (git snapshot
+ tracking) and not expected from sandbox-agent.
+- **Missing `time` on text parts**: Minor; could be added in future.
+- **Missing `time.completed` on some assistant messages**: Minor timing issue.
+
+## Verification
+
+After fixes, all tool events now correctly show:
+- `"tool": "mock.search"` across all states (pending, running, error)
+- `"input": {"query": "example"}` preserved across all states
+- `"output": "mock search results"` on the error event (not `"error"`)
+- Text streaming includes `delta` field
+- No text doubling
+
+All 28 OpenCode compat tests pass.
+All 10 session snapshot tests pass.
+All 3 HTTP endpoint tests pass.
diff --git a/research/opencode-compat/capture-native.ts b/research/opencode-compat/capture-native.ts
new file mode 100644
index 0000000..07f3336
--- /dev/null
+++ b/research/opencode-compat/capture-native.ts
@@ -0,0 +1,260 @@
+/**
+ * Capture native OpenCode server API output for comparison.
+ *
+ * Usage:
+ * npx tsx capture-native.ts
+ *
+ * Starts a native OpenCode headless server, creates a Claude session,
+ * sends 2 messages (one that triggers tool calls), and captures all
+ * session events and message snapshots.
+ */
+import { spawn, type ChildProcess } from "node:child_process";
+import { writeFileSync, mkdirSync, existsSync } from "node:fs";
+import { createServer, type AddressInfo } from "node:net";
+
+const OUTPUT_DIR = new URL("./snapshots/native", import.meta.url).pathname;
+
+async function getFreePort(): Promise {
+ return new Promise((resolve, reject) => {
+ const server = createServer();
+ server.unref();
+ server.on("error", reject);
+ server.listen(0, "127.0.0.1", () => {
+ const address = server.address() as AddressInfo;
+ server.close(() => resolve(address.port));
+ });
+ });
+}
+
+async function waitForHealth(baseUrl: string, timeoutMs = 30_000): Promise {
+ const start = Date.now();
+ while (Date.now() - start < timeoutMs) {
+ try {
+ const res = await fetch(`${baseUrl}/global/health`);
+ if (res.ok) return;
+ } catch {}
+ await new Promise((r) => setTimeout(r, 300));
+ }
+ throw new Error("Timed out waiting for native opencode health");
+}
+
+function saveJson(name: string, data: unknown) {
+ if (!existsSync(OUTPUT_DIR)) mkdirSync(OUTPUT_DIR, { recursive: true });
+ const path = `${OUTPUT_DIR}/${name}.json`;
+ writeFileSync(path, JSON.stringify(data, null, 2));
+ console.log(` [saved] ${path}`);
+}
+
+async function waitForIdle(baseUrl: string, sessionId: string, timeoutMs: number): Promise {
+ const start = Date.now();
+ // Give a small initial delay for the status to change to busy
+ await new Promise((r) => setTimeout(r, 500));
+ while (Date.now() - start < timeoutMs) {
+ try {
+ const statusRes = await fetch(`${baseUrl}/session/status`);
+ const statuses = await statusRes.json();
+ const sessionStatus = statuses?.[sessionId];
+ if (sessionStatus?.type === "idle" || sessionStatus === undefined) {
+ return;
+ }
+ } catch {}
+ await new Promise((r) => setTimeout(r, 500));
+ }
+ throw new Error("Timed out waiting for session to become idle");
+}
+
+async function main() {
+ const port = await getFreePort();
+ const baseUrl = `http://127.0.0.1:${port}`;
+
+ console.log(`Starting native OpenCode server on port ${port}...`);
+
+ const child: ChildProcess = spawn("opencode", ["serve", "--port", String(port)], {
+ stdio: "pipe",
+ env: { ...process.env },
+ });
+
+ let stderr = "";
+ child.stderr?.on("data", (chunk) => {
+ stderr += chunk.toString();
+ });
+ child.stdout?.on("data", (chunk) => {
+ const text = chunk.toString();
+ if (text.includes("listening")) console.log(` [opencode] ${text.trim()}`);
+ });
+
+ // Track all SSE events in a separate array
+ const allEvents: any[] = [];
+ let sseAbort: AbortController | null = null;
+ let currentBaseUrl = "";
+
+ try {
+ await waitForHealth(baseUrl);
+ currentBaseUrl = baseUrl;
+ console.log("Native OpenCode server is healthy!");
+
+ // 1. Capture initial metadata
+ const [agentRes, configRes] = await Promise.all([
+ fetch(`${baseUrl}/agent`).then((r) => r.json()),
+ fetch(`${baseUrl}/config`).then((r) => r.json()),
+ ]);
+ saveJson("metadata-agent", agentRes);
+ saveJson("metadata-config", configRes);
+
+ // 2. Start SSE event collection
+ sseAbort = new AbortController();
+ const ssePromise = (async () => {
+ try {
+ const res = await fetch(`${baseUrl}/event`, {
+ signal: sseAbort!.signal,
+ headers: { Accept: "text/event-stream" },
+ });
+ if (!res.ok || !res.body) {
+ console.error("SSE connection failed:", res.status);
+ return;
+ }
+ const reader = res.body.getReader();
+ const decoder = new TextDecoder();
+ let buffer = "";
+
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ buffer += decoder.decode(value, { stream: true });
+
+ const lines = buffer.split("\n");
+ buffer = lines.pop() || "";
+
+ for (const line of lines) {
+ if (line.startsWith("data: ")) {
+ try {
+ const parsed = JSON.parse(line.slice(6));
+ allEvents.push(parsed);
+ // Auto-approve permissions
+ if (parsed.type === "permission.asked" && parsed.properties?.id) {
+ const permId = parsed.properties.id;
+ console.log(` [auto-approving permission ${permId}]`);
+ fetch(`${currentBaseUrl}/permission/${permId}/reply`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ allow: true }),
+ }).catch(() => {});
+ }
+ } catch {}
+ }
+ }
+ }
+ } catch (err: any) {
+ if (err.name !== "AbortError") {
+ // Ignore - expected when server closes
+ }
+ }
+ })();
+
+ // Give SSE time to connect
+ await new Promise((r) => setTimeout(r, 500));
+
+ // 3. Create a session
+ console.log("Creating session...");
+ const sessionRes = await fetch(`${baseUrl}/session`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({}),
+ });
+ const session = await sessionRes.json();
+ saveJson("session-create", session);
+ const sessionId = session.id;
+ console.log(` Session ID: ${sessionId}`);
+
+ // Use anthropic provider with a cheap model for testing
+ const model = { providerID: "anthropic", modelID: "claude-haiku-4-5" };
+
+ // 4. Send first message (simple text response) - use prompt_async + wait
+ console.log("Sending message 1 (simple text)...");
+ await fetch(`${baseUrl}/session/${sessionId}/prompt_async`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ model,
+ parts: [{ type: "text", text: "Respond with exactly: 'Hello from OpenCode'. Nothing else." }],
+ }),
+ });
+
+ // Wait for the response to be fully processed
+ console.log(" Waiting for message 1 to complete...");
+ await waitForIdle(baseUrl, sessionId, 60_000);
+ await new Promise((r) => setTimeout(r, 1000));
+
+ // 5. Get messages after first request
+ const messagesAfter1 = await fetch(`${baseUrl}/session/${sessionId}/message`).then((r) =>
+ r.json()
+ );
+ saveJson("messages-after-1", messagesAfter1);
+ console.log(` Got ${messagesAfter1.length} messages after msg 1`);
+
+ // 6. Send second message (ask for a tool call - file write) - use prompt_async
+ console.log("Sending message 2 (should trigger tool calls)...");
+ await fetch(`${baseUrl}/session/${sessionId}/prompt_async`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ model,
+ parts: [
+ {
+ type: "text",
+ text: "List the files in the current directory. Use the list/ls tool. Only list the top-level contents, do not recurse.",
+ },
+ ],
+ }),
+ });
+
+ // Wait for completion (longer timeout for tool calls + permissions)
+ console.log(" Waiting for message 2 to complete...");
+ try {
+ await waitForIdle(baseUrl, sessionId, 120_000);
+ } catch (e) {
+ console.log(" Warning: timed out waiting for idle, capturing what we have...");
+ }
+ await new Promise((r) => setTimeout(r, 2000));
+
+ // 7. Get messages after second request
+ const messagesAfter2 = await fetch(`${baseUrl}/session/${sessionId}/message`).then((r) =>
+ r.json()
+ );
+ saveJson("messages-after-2", messagesAfter2);
+ console.log(` Got ${messagesAfter2.length} messages after msg 2`);
+
+ // 8. Get session details
+ const sessionDetails = await fetch(`${baseUrl}/session/${sessionId}`).then((r) => r.json());
+ saveJson("session-details", sessionDetails);
+
+ // 9. Get session status
+ const sessionStatus = await fetch(`${baseUrl}/session/status`).then((r) => r.json());
+ saveJson("session-status", sessionStatus);
+
+ // 10. Stop SSE and save events
+ sseAbort.abort();
+ await new Promise((r) => setTimeout(r, 500));
+ saveJson("all-events", allEvents);
+
+ // Filter events for this session
+ const sessionEvents = allEvents.filter(
+ (e) => e.properties?.sessionID === sessionId ||
+ (e.type === "session.created" && e.properties?.info?.id === sessionId)
+ );
+ saveJson("session-events", sessionEvents);
+
+ console.log(`\nCapture complete! ${allEvents.length} total events, ${sessionEvents.length} session events.`);
+ console.log(`Output saved to: ${OUTPUT_DIR}/`);
+ } finally {
+ if (sseAbort) sseAbort.abort();
+ child.kill("SIGTERM");
+ await new Promise((r) => setTimeout(r, 1000));
+ if (child.exitCode === null) child.kill("SIGKILL");
+ }
+}
+
+main().catch((err) => {
+ console.error("Fatal error:", err);
+ process.exit(1);
+});
diff --git a/research/opencode-compat/capture-sandbox-agent.ts b/research/opencode-compat/capture-sandbox-agent.ts
new file mode 100644
index 0000000..9d14ea7
--- /dev/null
+++ b/research/opencode-compat/capture-sandbox-agent.ts
@@ -0,0 +1,249 @@
+/**
+ * Capture sandbox-agent OpenCode compatibility API output for comparison.
+ *
+ * Usage:
+ * npx tsx capture-sandbox-agent.ts
+ *
+ * Starts sandbox-agent with mock agent, creates a session via /opencode API,
+ * sends 2 messages (text + tool call), and captures all events/messages.
+ */
+import { spawn, type ChildProcess } from "node:child_process";
+import { writeFileSync, mkdirSync, existsSync } from "node:fs";
+import { createServer, type AddressInfo } from "node:net";
+import { randomBytes } from "node:crypto";
+
+const OUTPUT_DIR = new URL("./snapshots/sandbox-agent", import.meta.url).pathname;
+
+async function getFreePort(): Promise {
+ return new Promise((resolve, reject) => {
+ const server = createServer();
+ server.unref();
+ server.on("error", reject);
+ server.listen(0, "127.0.0.1", () => {
+ const address = server.address() as AddressInfo;
+ server.close(() => resolve(address.port));
+ });
+ });
+}
+
+async function waitForHealth(baseUrl: string, token: string, timeoutMs = 30_000): Promise {
+ const start = Date.now();
+ while (Date.now() - start < timeoutMs) {
+ try {
+ const res = await fetch(`${baseUrl}/v1/health`, {
+ headers: { Authorization: `Bearer ${token}` },
+ });
+ if (res.ok) return;
+ } catch {}
+ await new Promise((r) => setTimeout(r, 300));
+ }
+ throw new Error("Timed out waiting for sandbox-agent health");
+}
+
+function saveJson(name: string, data: unknown) {
+ if (!existsSync(OUTPUT_DIR)) mkdirSync(OUTPUT_DIR, { recursive: true });
+ const path = `${OUTPUT_DIR}/${name}.json`;
+ writeFileSync(path, JSON.stringify(data, null, 2));
+ console.log(` [saved] ${path}`);
+}
+
+async function main() {
+ const port = await getFreePort();
+ const host = "127.0.0.1";
+ const baseUrl = `http://${host}:${port}`;
+ const opencodeUrl = `${baseUrl}/opencode`;
+ const token = randomBytes(24).toString("hex");
+
+ console.log(`Starting sandbox-agent on port ${port}...`);
+
+ // Use the locally built binary, not the installed one
+ const binaryPath = new URL("../../target/release/sandbox-agent", import.meta.url).pathname;
+ const child: ChildProcess = spawn(
+ binaryPath,
+ ["server", "--host", host, "--port", String(port), "--token", token],
+ {
+ stdio: "pipe",
+ env: {
+ ...process.env,
+ SANDBOX_AGENT_SKIP_INSPECTOR: "1",
+ },
+ }
+ );
+
+ let stderr = "";
+ child.stderr?.on("data", (chunk) => {
+ stderr += chunk.toString();
+ });
+
+ const allEvents: any[] = [];
+ let sseAbort: AbortController | null = null;
+
+ try {
+ await waitForHealth(baseUrl, token);
+ console.log("sandbox-agent is healthy!");
+
+ // 1. Capture initial metadata via /opencode routes
+ const headers = { Authorization: `Bearer ${token}` };
+ const [agentRes, configRes] = await Promise.all([
+ fetch(`${opencodeUrl}/agent`, { headers }).then((r) => r.json()),
+ fetch(`${opencodeUrl}/config`, { headers }).then((r) => r.json()),
+ ]);
+ saveJson("metadata-agent", agentRes);
+ saveJson("metadata-config", configRes);
+
+ // 2. Start SSE event collection
+ sseAbort = new AbortController();
+ const ssePromise = (async () => {
+ try {
+ const res = await fetch(`${opencodeUrl}/event`, {
+ signal: sseAbort!.signal,
+ headers: { ...headers, Accept: "text/event-stream" },
+ });
+ if (!res.ok || !res.body) {
+ console.error("SSE connection failed:", res.status, await res.text());
+ return;
+ }
+ const reader = res.body.getReader();
+ const decoder = new TextDecoder();
+ let buffer = "";
+
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ buffer += decoder.decode(value, { stream: true });
+
+ const lines = buffer.split("\n");
+ buffer = lines.pop() || "";
+
+ for (const line of lines) {
+ if (line.startsWith("data: ")) {
+ try {
+ const parsed = JSON.parse(line.slice(6));
+ allEvents.push(parsed);
+ } catch {}
+ }
+ }
+ }
+ } catch (err: any) {
+ if (err.name !== "AbortError") {
+ // ignore
+ }
+ }
+ })();
+
+ // Give SSE time to connect
+ await new Promise((r) => setTimeout(r, 500));
+
+ // 3. Create a session
+ console.log("Creating session...");
+ const sessionRes = await fetch(`${opencodeUrl}/session`, {
+ method: "POST",
+ headers: { ...headers, "Content-Type": "application/json" },
+ body: JSON.stringify({}),
+ });
+ const session = await sessionRes.json();
+ saveJson("session-create", session);
+ const sessionId = session.id;
+ console.log(` Session ID: ${sessionId}`);
+
+ // 4. Send first message (simple text response) using mock agent's "echo" command
+ console.log("Sending message 1 (simple text - echo)...");
+ const msg1Res = await fetch(`${opencodeUrl}/session/${sessionId}/prompt_async`, {
+ method: "POST",
+ headers: { ...headers, "Content-Type": "application/json" },
+ body: JSON.stringify({
+ model: { providerID: "sandbox-agent", modelID: "mock" },
+ parts: [{ type: "text", text: "echo Hello from sandbox-agent" }],
+ }),
+ });
+ console.log(` prompt_async status: ${msg1Res.status}`);
+
+ // Wait for idle
+ console.log(" Waiting for message 1 to complete...");
+ await waitForIdle(opencodeUrl, sessionId, headers, 30_000);
+ await new Promise((r) => setTimeout(r, 1000));
+
+ // 5. Get messages after first request
+ const messagesAfter1 = await fetch(`${opencodeUrl}/session/${sessionId}/message`, { headers }).then((r) => r.json());
+ saveJson("messages-after-1", messagesAfter1);
+ console.log(` Got ${messagesAfter1.length} messages after msg 1`);
+
+ // 6. Send second message (trigger tool calls) using mock agent's "tool" command
+ console.log("Sending message 2 (tool calls)...");
+ const msg2Res = await fetch(`${opencodeUrl}/session/${sessionId}/prompt_async`, {
+ method: "POST",
+ headers: { ...headers, "Content-Type": "application/json" },
+ body: JSON.stringify({
+ model: { providerID: "sandbox-agent", modelID: "mock" },
+ parts: [{ type: "text", text: "tool" }],
+ }),
+ });
+ console.log(` prompt_async status: ${msg2Res.status}`);
+
+ // Wait for completion
+ console.log(" Waiting for message 2 to complete...");
+ await waitForIdle(opencodeUrl, sessionId, headers, 30_000);
+ await new Promise((r) => setTimeout(r, 1000));
+
+ // 7. Get messages after second request
+ const messagesAfter2 = await fetch(`${opencodeUrl}/session/${sessionId}/message`, { headers }).then((r) => r.json());
+ saveJson("messages-after-2", messagesAfter2);
+ console.log(` Got ${messagesAfter2.length} messages after msg 2`);
+
+ // 8. Get session details
+ const sessionDetails = await fetch(`${opencodeUrl}/session/${sessionId}`, { headers }).then((r) => r.json());
+ saveJson("session-details", sessionDetails);
+
+ // 9. Get session status
+ const sessionStatus = await fetch(`${opencodeUrl}/session/status`, { headers }).then((r) => r.json());
+ saveJson("session-status", sessionStatus);
+
+ // 10. Stop SSE and save events
+ sseAbort.abort();
+ await new Promise((r) => setTimeout(r, 500));
+ saveJson("all-events", allEvents);
+
+ // Filter session events
+ const sessionEvents = allEvents.filter(
+ (e) =>
+ e.properties?.sessionID === sessionId ||
+ (e.type === "session.created" && e.properties?.info?.id === sessionId)
+ );
+ saveJson("session-events", sessionEvents);
+
+ console.log(`\nCapture complete! ${allEvents.length} total events, ${sessionEvents.length} session events.`);
+ console.log(`Output saved to: ${OUTPUT_DIR}/`);
+ } finally {
+ if (sseAbort) sseAbort.abort();
+ child.kill("SIGTERM");
+ await new Promise((r) => setTimeout(r, 1000));
+ if (child.exitCode === null) child.kill("SIGKILL");
+ }
+}
+
+async function waitForIdle(
+ opencodeUrl: string,
+ sessionId: string,
+ headers: Record,
+ timeoutMs: number
+): Promise {
+ const start = Date.now();
+ await new Promise((r) => setTimeout(r, 500));
+ while (Date.now() - start < timeoutMs) {
+ try {
+ const statusRes = await fetch(`${opencodeUrl}/session/status`, { headers });
+ const statuses = await statusRes.json();
+ const sessionStatus = statuses?.[sessionId];
+ if (sessionStatus?.type === "idle" || sessionStatus === undefined) {
+ return;
+ }
+ } catch {}
+ await new Promise((r) => setTimeout(r, 300));
+ }
+ throw new Error("Timed out waiting for session to become idle");
+}
+
+main().catch((err) => {
+ console.error("Fatal error:", err);
+ process.exit(1);
+});
diff --git a/research/opencode-compat/snapshots/native/all-events.json b/research/opencode-compat/snapshots/native/all-events.json
new file mode 100644
index 0000000..7156d8e
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/all-events.json
@@ -0,0 +1,1281 @@
+[
+ {
+ "type": "server.connected",
+ "properties": {}
+ },
+ {
+ "type": "session.created",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "New session - 2026-02-06T06:56:52.806Z",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361012806
+ }
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "New session - 2026-02-06T06:56:52.806Z",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361012806
+ }
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd424c001ICzhibLcSkazYE",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361012812
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd424c002I8ASgZXZGMnUf2",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "type": "text",
+ "text": "Respond with exactly: 'Hello from OpenCode'. Nothing else."
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "New session - 2026-02-06T06:56:52.806Z",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361012825
+ }
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361012832
+ },
+ "parentID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 0,
+ "output": 0,
+ "reasoning": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd424c001ICzhibLcSkazYE",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361012812
+ },
+ "summary": {
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "New session - 2026-02-06T06:56:52.806Z",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361012862
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "Hello from OpenCode",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361012862
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd424c001ICzhibLcSkazYE",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361012812
+ },
+ "summary": {
+ "title": "Hello from OpenCode",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4779001QLU4EXzj63WQ4W",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "step-start",
+ "snapshot": "302d31eedbdd77a5b1eb84e2fbc4e99e8b97e549"
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd477c001Gq3CWQQXR1h7fD",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "text",
+ "text": "Hello from OpenCode",
+ "time": {
+ "start": 1770361014140
+ }
+ },
+ "delta": "Hello from OpenCode"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd477c001Gq3CWQQXR1h7fD",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "text",
+ "text": "Hello from OpenCode",
+ "time": {
+ "start": 1770361014146,
+ "end": 1770361014146
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4793001LdK7WQwiUgzctY",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "step-finish",
+ "reason": "stop",
+ "snapshot": "302d31eedbdd77a5b1eb84e2fbc4e99e8b97e549",
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 13540,
+ "write": 0
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361012832
+ },
+ "parentID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 13540,
+ "write": 0
+ }
+ },
+ "finish": "stop"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361012832,
+ "completed": 1770361014171
+ },
+ "parentID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 13540,
+ "write": 0
+ }
+ },
+ "finish": "stop"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "idle"
+ }
+ }
+ },
+ {
+ "type": "session.idle",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms"
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd424c001ICzhibLcSkazYE",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361012812
+ },
+ "summary": {
+ "title": "Hello from OpenCode",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "Hello from OpenCode",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361014177
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361015323
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4c1b00250iBBBWSNWnE4G",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "type": "text",
+ "text": "List the files in the current directory. Use the list/ls tool. Only list the top-level contents, do not recurse."
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "Hello from OpenCode",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361015323
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361015324
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 0,
+ "output": 0,
+ "reasoning": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361015323
+ },
+ "summary": {
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "Hello from OpenCode",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361015333
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361015323
+ },
+ "summary": {
+ "title": "List directory contents",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4ef7001AOk3Asd0o7j5fD",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "step-start",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3"
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4ef8001ovzy76OXAT5Qin",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "tool",
+ "callID": "toolu_017THj1iZNELroZgmFbqC6Ma",
+ "tool": "bash",
+ "state": {
+ "status": "pending",
+ "input": {},
+ "raw": ""
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4ef8001ovzy76OXAT5Qin",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "tool",
+ "callID": "toolu_017THj1iZNELroZgmFbqC6Ma",
+ "tool": "bash",
+ "state": {
+ "status": "running",
+ "input": {
+ "command": "ls -la",
+ "description": "List files in current directory"
+ },
+ "time": {
+ "start": 1770361016309
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4ef8001ovzy76OXAT5Qin",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "tool",
+ "callID": "toolu_017THj1iZNELroZgmFbqC6Ma",
+ "tool": "bash",
+ "state": {
+ "status": "running",
+ "input": {
+ "command": "ls -la",
+ "description": "List files in current directory"
+ },
+ "metadata": {
+ "output": "",
+ "description": "List files in current directory"
+ },
+ "time": {
+ "start": 1770361016328
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4ef8001ovzy76OXAT5Qin",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "tool",
+ "callID": "toolu_017THj1iZNELroZgmFbqC6Ma",
+ "tool": "bash",
+ "state": {
+ "status": "running",
+ "input": {
+ "command": "ls -la",
+ "description": "List files in current directory"
+ },
+ "metadata": {
+ "output": "total 24\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:56 .\ndrwxr-xr-x 5 nathan nathan 4096 Feb 5 22:44 ..\n-rw-r--r-- 1 nathan nathan 9120 Feb 5 22:56 capture-native.ts\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:45 snapshots\n",
+ "description": "List files in current directory"
+ },
+ "time": {
+ "start": 1770361016329
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd4ef8001ovzy76OXAT5Qin",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "tool",
+ "callID": "toolu_017THj1iZNELroZgmFbqC6Ma",
+ "tool": "bash",
+ "state": {
+ "status": "completed",
+ "input": {
+ "command": "ls -la",
+ "description": "List files in current directory"
+ },
+ "output": "total 24\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:56 .\ndrwxr-xr-x 5 nathan nathan 4096 Feb 5 22:44 ..\n-rw-r--r-- 1 nathan nathan 9120 Feb 5 22:56 capture-native.ts\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:45 snapshots\n",
+ "title": "List files in current directory",
+ "metadata": {
+ "output": "total 24\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:56 .\ndrwxr-xr-x 5 nathan nathan 4096 Feb 5 22:44 ..\n-rw-r--r-- 1 nathan nathan 9120 Feb 5 22:56 capture-native.ts\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:45 snapshots\n",
+ "exit": 0,
+ "description": "List files in current directory",
+ "truncated": false
+ },
+ "time": {
+ "start": 1770361016309,
+ "end": 1770361016330
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd500e001MnhwCXaWI2pfAw",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "step-finish",
+ "reason": "tool-calls",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3",
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 78,
+ "reasoning": 0,
+ "cache": {
+ "read": 13547,
+ "write": 31
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361015324
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 78,
+ "reasoning": 0,
+ "cache": {
+ "read": 13547,
+ "write": 31
+ }
+ },
+ "finish": "tool-calls"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361015324,
+ "completed": 1770361016339
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 78,
+ "reasoning": 0,
+ "cache": {
+ "read": 13547,
+ "write": 31
+ }
+ },
+ "finish": "tool-calls"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361016340
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 0,
+ "output": 0,
+ "reasoning": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361015323
+ },
+ "summary": {
+ "title": "List directory contents",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "Hello from OpenCode",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361016350
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580017z4yaEbtkZX0zx",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "step-start",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3"
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": "Here"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": " are the top"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": "-level contents"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n-",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": " of the current directory:\n\n-"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n- **",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": " **"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n- **capture-native.ts** - A",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": "capture-native.ts** - A"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n- **capture-native.ts** - A TypeScript file",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": " TypeScript file"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n- **capture-native.ts** - A TypeScript file\n- **snapshots/**",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": "\n- **snapshots/**"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n- **capture-native.ts** - A TypeScript file\n- **snapshots/** - A directory",
+ "time": {
+ "start": 1770361017176
+ }
+ },
+ "delta": " - A directory"
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n- **capture-native.ts** - A TypeScript file\n- **snapshots/** - A directory",
+ "time": {
+ "start": 1770361017436,
+ "end": 1770361017436
+ }
+ }
+ }
+ },
+ {
+ "type": "message.part.updated",
+ "properties": {
+ "part": {
+ "id": "prt_c31bd546d001cppsZFrg2ZJy7S",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "step-finish",
+ "reason": "stop",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3",
+ "cost": 0,
+ "tokens": {
+ "input": 5,
+ "output": 38,
+ "reasoning": 0,
+ "cache": {
+ "read": 13578,
+ "write": 207
+ }
+ }
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361016340
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 5,
+ "output": 38,
+ "reasoning": 0,
+ "cache": {
+ "read": 13578,
+ "write": 207
+ }
+ },
+ "finish": "stop"
+ }
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361016340,
+ "completed": 1770361017458
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 5,
+ "output": 38,
+ "reasoning": 0,
+ "cache": {
+ "read": 13578,
+ "write": 207
+ }
+ },
+ "finish": "stop"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "idle"
+ }
+ }
+ },
+ {
+ "type": "session.idle",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms"
+ }
+ },
+ {
+ "type": "message.updated",
+ "properties": {
+ "info": {
+ "id": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361015323
+ },
+ "summary": {
+ "title": "List directory contents",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ }
+ }
+ },
+ {
+ "type": "session.updated",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "Hello from OpenCode",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361017462
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/message-1-response.json b/research/opencode-compat/snapshots/native/message-1-response.json
new file mode 100644
index 0000000..2cfeb88
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/message-1-response.json
@@ -0,0 +1,69 @@
+{
+ "info": {
+ "id": "msg_c31b8e048001p0fSvme0VWmKR0",
+ "sessionID": "ses_3ce471fc8ffeS9ZUpB7rVDen7k",
+ "role": "assistant",
+ "time": {
+ "created": 1770360725576,
+ "completed": 1770360727252
+ },
+ "parentID": "msg_c31b8e040001pIkL4AzVtzdVRd",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 0,
+ "write": 13540
+ }
+ },
+ "finish": "stop"
+ },
+ "parts": [
+ {
+ "id": "prt_c31b8e6b10012vw5mZVWX51UQm",
+ "sessionID": "ses_3ce471fc8ffeS9ZUpB7rVDen7k",
+ "messageID": "msg_c31b8e048001p0fSvme0VWmKR0",
+ "type": "step-start",
+ "snapshot": "f93f1b3f790c9b1fe51007d1b4a46bcb2d528a91"
+ },
+ {
+ "id": "prt_c31b8e6b1002OBaD5M55iOVva6",
+ "sessionID": "ses_3ce471fc8ffeS9ZUpB7rVDen7k",
+ "messageID": "msg_c31b8e048001p0fSvme0VWmKR0",
+ "type": "text",
+ "text": "Hello from OpenCode",
+ "time": {
+ "start": 1770360727218,
+ "end": 1770360727218
+ }
+ },
+ {
+ "id": "prt_c31b8e6cd0012b1geOngJvrf2q",
+ "sessionID": "ses_3ce471fc8ffeS9ZUpB7rVDen7k",
+ "messageID": "msg_c31b8e048001p0fSvme0VWmKR0",
+ "type": "step-finish",
+ "reason": "stop",
+ "snapshot": "f93f1b3f790c9b1fe51007d1b4a46bcb2d528a91",
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 0,
+ "write": 13540
+ }
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/message-2-response.json b/research/opencode-compat/snapshots/native/message-2-response.json
new file mode 100644
index 0000000..19c5b2c
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/message-2-response.json
@@ -0,0 +1,52 @@
+{
+ "info": {
+ "id": "msg_c31b349c3001C3jUz57fj5vRae",
+ "sessionID": "ses_3ce4cbd76ffeHVa3mLvB00FXDV",
+ "role": "assistant",
+ "time": {
+ "created": 1770360359363,
+ "completed": 1770360359565
+ },
+ "error": {
+ "name": "APIError",
+ "data": {
+ "message": "Unauthorized: {\"type\":\"error\",\"error\":{\"type\":\"AuthError\",\"message\":\"Invalid API key.\"}}",
+ "statusCode": 401,
+ "isRetryable": false,
+ "responseHeaders": {
+ "cf-placement": "local-SJC",
+ "cf-ray": "9c98b01658355024-SJC",
+ "connection": "keep-alive",
+ "content-length": "74",
+ "content-type": "text/plain;charset=UTF-8",
+ "date": "Fri, 06 Feb 2026 06:45:59 GMT",
+ "server": "cloudflare"
+ },
+ "responseBody": "{\"type\":\"error\",\"error\":{\"type\":\"AuthError\",\"message\":\"Invalid API key.\"}}",
+ "metadata": {
+ "url": "https://opencode.ai/zen/v1/models/gemini-3-pro:streamGenerateContent?alt=sse"
+ }
+ }
+ },
+ "parentID": "msg_c31b349c2001kJD7I7MRSAVo57",
+ "modelID": "gemini-3-pro",
+ "providerID": "opencode",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 0,
+ "output": 0,
+ "reasoning": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ }
+ },
+ "parts": []
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/messages-after-1.json b/research/opencode-compat/snapshots/native/messages-after-1.json
new file mode 100644
index 0000000..0daa794
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/messages-after-1.json
@@ -0,0 +1,99 @@
+[
+ {
+ "info": {
+ "id": "msg_c31bd424c001ICzhibLcSkazYE",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361012812
+ },
+ "summary": {
+ "title": "Hello from OpenCode",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ },
+ "parts": [
+ {
+ "id": "prt_c31bd424c002I8ASgZXZGMnUf2",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "type": "text",
+ "text": "Respond with exactly: 'Hello from OpenCode'. Nothing else."
+ }
+ ]
+ },
+ {
+ "info": {
+ "id": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361012832,
+ "completed": 1770361014171
+ },
+ "parentID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 13540,
+ "write": 0
+ }
+ },
+ "finish": "stop"
+ },
+ "parts": [
+ {
+ "id": "prt_c31bd4779001QLU4EXzj63WQ4W",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "step-start",
+ "snapshot": "302d31eedbdd77a5b1eb84e2fbc4e99e8b97e549"
+ },
+ {
+ "id": "prt_c31bd477c001Gq3CWQQXR1h7fD",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "text",
+ "text": "Hello from OpenCode",
+ "time": {
+ "start": 1770361014146,
+ "end": 1770361014146
+ }
+ },
+ {
+ "id": "prt_c31bd4793001LdK7WQwiUgzctY",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "step-finish",
+ "reason": "stop",
+ "snapshot": "302d31eedbdd77a5b1eb84e2fbc4e99e8b97e549",
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 13540,
+ "write": 0
+ }
+ }
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/messages-after-2.json b/research/opencode-compat/snapshots/native/messages-after-2.json
new file mode 100644
index 0000000..886ba3d
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/messages-after-2.json
@@ -0,0 +1,281 @@
+[
+ {
+ "info": {
+ "id": "msg_c31bd424c001ICzhibLcSkazYE",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361012812
+ },
+ "summary": {
+ "title": "Hello from OpenCode",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ },
+ "parts": [
+ {
+ "id": "prt_c31bd424c002I8ASgZXZGMnUf2",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "type": "text",
+ "text": "Respond with exactly: 'Hello from OpenCode'. Nothing else."
+ }
+ ]
+ },
+ {
+ "info": {
+ "id": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361012832,
+ "completed": 1770361014171
+ },
+ "parentID": "msg_c31bd424c001ICzhibLcSkazYE",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 13540,
+ "write": 0
+ }
+ },
+ "finish": "stop"
+ },
+ "parts": [
+ {
+ "id": "prt_c31bd4779001QLU4EXzj63WQ4W",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "step-start",
+ "snapshot": "302d31eedbdd77a5b1eb84e2fbc4e99e8b97e549"
+ },
+ {
+ "id": "prt_c31bd477c001Gq3CWQQXR1h7fD",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "text",
+ "text": "Hello from OpenCode",
+ "time": {
+ "start": 1770361014146,
+ "end": 1770361014146
+ }
+ },
+ {
+ "id": "prt_c31bd4793001LdK7WQwiUgzctY",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4260001o9JzwTa1Ops17t",
+ "type": "step-finish",
+ "reason": "stop",
+ "snapshot": "302d31eedbdd77a5b1eb84e2fbc4e99e8b97e549",
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 7,
+ "reasoning": 0,
+ "cache": {
+ "read": 13540,
+ "write": 0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "info": {
+ "id": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "user",
+ "time": {
+ "created": 1770361015323
+ },
+ "summary": {
+ "title": "List directory contents",
+ "diffs": []
+ },
+ "agent": "build",
+ "model": {
+ "providerID": "anthropic",
+ "modelID": "claude-haiku-4-5"
+ }
+ },
+ "parts": [
+ {
+ "id": "prt_c31bd4c1b00250iBBBWSNWnE4G",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "type": "text",
+ "text": "List the files in the current directory. Use the list/ls tool. Only list the top-level contents, do not recurse."
+ }
+ ]
+ },
+ {
+ "info": {
+ "id": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361015324,
+ "completed": 1770361016339
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 78,
+ "reasoning": 0,
+ "cache": {
+ "read": 13547,
+ "write": 31
+ }
+ },
+ "finish": "tool-calls"
+ },
+ "parts": [
+ {
+ "id": "prt_c31bd4ef7001AOk3Asd0o7j5fD",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "step-start",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3"
+ },
+ {
+ "id": "prt_c31bd4ef8001ovzy76OXAT5Qin",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "tool",
+ "callID": "toolu_017THj1iZNELroZgmFbqC6Ma",
+ "tool": "bash",
+ "state": {
+ "status": "completed",
+ "input": {
+ "command": "ls -la",
+ "description": "List files in current directory"
+ },
+ "output": "total 24\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:56 .\ndrwxr-xr-x 5 nathan nathan 4096 Feb 5 22:44 ..\n-rw-r--r-- 1 nathan nathan 9120 Feb 5 22:56 capture-native.ts\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:45 snapshots\n",
+ "title": "List files in current directory",
+ "metadata": {
+ "output": "total 24\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:56 .\ndrwxr-xr-x 5 nathan nathan 4096 Feb 5 22:44 ..\n-rw-r--r-- 1 nathan nathan 9120 Feb 5 22:56 capture-native.ts\ndrwxr-xr-x 3 nathan nathan 4096 Feb 5 22:45 snapshots\n",
+ "exit": 0,
+ "description": "List files in current directory",
+ "truncated": false
+ },
+ "time": {
+ "start": 1770361016309,
+ "end": 1770361016330
+ }
+ }
+ },
+ {
+ "id": "prt_c31bd500e001MnhwCXaWI2pfAw",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd4c1c001iWeGOWfwf5UD2Y",
+ "type": "step-finish",
+ "reason": "tool-calls",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3",
+ "cost": 0,
+ "tokens": {
+ "input": 2,
+ "output": 78,
+ "reasoning": 0,
+ "cache": {
+ "read": 13547,
+ "write": 31
+ }
+ }
+ }
+ ]
+ },
+ {
+ "info": {
+ "id": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "role": "assistant",
+ "time": {
+ "created": 1770361016340,
+ "completed": 1770361017458
+ },
+ "parentID": "msg_c31bd4c1b001xWoyoqqLd1Y28L",
+ "modelID": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "mode": "build",
+ "agent": "build",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent"
+ },
+ "cost": 0,
+ "tokens": {
+ "input": 5,
+ "output": 38,
+ "reasoning": 0,
+ "cache": {
+ "read": 13578,
+ "write": 207
+ }
+ },
+ "finish": "stop"
+ },
+ "parts": [
+ {
+ "id": "prt_c31bd53580017z4yaEbtkZX0zx",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "step-start",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3"
+ },
+ {
+ "id": "prt_c31bd53580021848cNw3geDcGF",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "text",
+ "text": "Here are the top-level contents of the current directory:\n\n- **capture-native.ts** - A TypeScript file\n- **snapshots/** - A directory",
+ "time": {
+ "start": 1770361017436,
+ "end": 1770361017436
+ }
+ },
+ {
+ "id": "prt_c31bd546d001cppsZFrg2ZJy7S",
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "messageID": "msg_c31bd5014001lZUdLPnaNuUzrb",
+ "type": "step-finish",
+ "reason": "stop",
+ "snapshot": "8793fb311ffba7bff79cd1b25f87942c22349ae3",
+ "cost": 0,
+ "tokens": {
+ "input": 5,
+ "output": 38,
+ "reasoning": 0,
+ "cache": {
+ "read": 13578,
+ "write": 207
+ }
+ }
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/metadata-agent.json b/research/opencode-compat/snapshots/native/metadata-agent.json
new file mode 100644
index 0000000..fd13d2a
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/metadata-agent.json
@@ -0,0 +1,605 @@
+[
+ {
+ "name": "build",
+ "description": "The default agent. Executes tools based on configured permissions.",
+ "options": {},
+ "permission": [
+ {
+ "permission": "*",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "doom_loop",
+ "action": "ask",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "*",
+ "action": "ask"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "pattern": "*",
+ "action": "allow"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.*",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.example",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ }
+ ],
+ "mode": "primary",
+ "native": true
+ },
+ {
+ "name": "plan",
+ "description": "Plan mode. Disallows all edit tools.",
+ "options": {},
+ "permission": [
+ {
+ "permission": "*",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "doom_loop",
+ "action": "ask",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "*",
+ "action": "ask"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "pattern": "*",
+ "action": "allow"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.*",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.example",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/plans/*",
+ "action": "allow"
+ },
+ {
+ "permission": "edit",
+ "pattern": "*",
+ "action": "deny"
+ },
+ {
+ "permission": "edit",
+ "pattern": ".opencode/plans/*.md",
+ "action": "allow"
+ },
+ {
+ "permission": "edit",
+ "pattern": "../.local/share/opencode/plans/*.md",
+ "action": "allow"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ }
+ ],
+ "mode": "primary",
+ "native": true
+ },
+ {
+ "name": "general",
+ "description": "General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel.",
+ "permission": [
+ {
+ "permission": "*",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "doom_loop",
+ "action": "ask",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "*",
+ "action": "ask"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "pattern": "*",
+ "action": "allow"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.*",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.example",
+ "action": "allow"
+ },
+ {
+ "permission": "todoread",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "todowrite",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ }
+ ],
+ "options": {},
+ "mode": "subagent",
+ "native": true
+ },
+ {
+ "name": "explore",
+ "permission": [
+ {
+ "permission": "*",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "doom_loop",
+ "action": "ask",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "*",
+ "action": "ask"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "pattern": "*",
+ "action": "allow"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.*",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.example",
+ "action": "allow"
+ },
+ {
+ "permission": "*",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "grep",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "glob",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "list",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "bash",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "webfetch",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "websearch",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "codesearch",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ }
+ ],
+ "description": "Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. \"src/components/**/*.tsx\"), search code for keywords (eg. \"API endpoints\"), or answer questions about the codebase (eg. \"how do API endpoints work?\"). When calling this agent, specify the desired thoroughness level: \"quick\" for basic searches, \"medium\" for moderate exploration, or \"very thorough\" for comprehensive analysis across multiple locations and naming conventions.",
+ "prompt": "You are a file search specialist. You excel at thoroughly navigating and exploring codebases.\n\nYour strengths:\n- Rapidly finding files using glob patterns\n- Searching code and text with powerful regex patterns\n- Reading and analyzing file contents\n\nGuidelines:\n- Use Glob for broad file pattern matching\n- Use Grep for searching file contents with regex\n- Use Read when you know the specific file path you need to read\n- Use Bash for file operations like copying, moving, or listing directory contents\n- Adapt your search approach based on the thoroughness level specified by the caller\n- Return file paths as absolute paths in your final response\n- For clear communication, avoid using emojis\n- Do not create any files, or run bash commands that modify the user's system state in any way\n\nComplete the user's search request efficiently and report your findings clearly.\n",
+ "options": {},
+ "mode": "subagent",
+ "native": true
+ },
+ {
+ "name": "compaction",
+ "mode": "primary",
+ "native": true,
+ "hidden": true,
+ "prompt": "You are a helpful AI assistant tasked with summarizing conversations.\n\nWhen asked to summarize, provide a detailed but concise summary of the conversation. \nFocus on information that would be helpful for continuing the conversation, including:\n- What was done\n- What is currently being worked on\n- Which files are being modified\n- What needs to be done next\n- Key user requests, constraints, or preferences that should persist\n- Important technical decisions and why they were made\n\nYour summary should be comprehensive enough to provide context but concise enough to be quickly understood.\n",
+ "permission": [
+ {
+ "permission": "*",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "doom_loop",
+ "action": "ask",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "*",
+ "action": "ask"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "pattern": "*",
+ "action": "allow"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.*",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.example",
+ "action": "allow"
+ },
+ {
+ "permission": "*",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ }
+ ],
+ "options": {}
+ },
+ {
+ "name": "title",
+ "mode": "primary",
+ "options": {},
+ "native": true,
+ "hidden": true,
+ "temperature": 0.5,
+ "permission": [
+ {
+ "permission": "*",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "doom_loop",
+ "action": "ask",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "*",
+ "action": "ask"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "pattern": "*",
+ "action": "allow"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.*",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.example",
+ "action": "allow"
+ },
+ {
+ "permission": "*",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ }
+ ],
+ "prompt": "You are a title generator. You output ONLY a thread title. Nothing else.\n\n\nGenerate a brief title that would help the user find this conversation later.\n\nFollow all rules in \nUse the so you know what a good title looks like.\nYour output must be:\n- A single line\n- ≤50 characters\n- No explanations\n\n\n\n- you MUST use the same language as the user message you are summarizing\n- Title must be grammatically correct and read naturally - no word salad\n- Never include tool names in the title (e.g. \"read tool\", \"bash tool\", \"edit tool\")\n- Focus on the main topic or question the user needs to retrieve\n- Vary your phrasing - avoid repetitive patterns like always starting with \"Analyzing\"\n- When a file is mentioned, focus on WHAT the user wants to do WITH the file, not just that they shared it\n- Keep exact: technical terms, numbers, filenames, HTTP codes\n- Remove: the, this, my, a, an\n- Never assume tech stack\n- Never use tools\n- NEVER respond to questions, just generate a title for the conversation\n- The title should NEVER include \"summarizing\" or \"generating\" when generating a title\n- DO NOT SAY YOU CANNOT GENERATE A TITLE OR COMPLAIN ABOUT THE INPUT\n- Always output something meaningful, even if the input is minimal.\n- If the user message is short or conversational (e.g. \"hello\", \"lol\", \"what's up\", \"hey\"):\n → create a title that reflects the user's tone or intent (such as Greeting, Quick check-in, Light chat, Intro message, etc.)\n\n\n\n\"debug 500 errors in production\" → Debugging production 500 errors\n\"refactor user service\" → Refactoring user service\n\"why is app.js failing\" → app.js failure investigation\n\"implement rate limiting\" → Rate limiting implementation\n\"how do I connect postgres to my API\" → Postgres API connection\n\"best practices for React hooks\" → React hooks best practices\n\"@src/auth.ts can you add refresh token support\" → Auth refresh token support\n\"@utils/parser.ts this is broken\" → Parser bug fix\n\"look at @config.json\" → Config review\n\"@App.tsx add dark mode toggle\" → Dark mode toggle in App\n\n"
+ },
+ {
+ "name": "summary",
+ "mode": "primary",
+ "options": {},
+ "native": true,
+ "hidden": true,
+ "permission": [
+ {
+ "permission": "*",
+ "action": "allow",
+ "pattern": "*"
+ },
+ {
+ "permission": "doom_loop",
+ "action": "ask",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "*",
+ "action": "ask"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ },
+ {
+ "permission": "question",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_enter",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "plan_exit",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "read",
+ "pattern": "*",
+ "action": "allow"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.*",
+ "action": "ask"
+ },
+ {
+ "permission": "read",
+ "pattern": "*.env.example",
+ "action": "allow"
+ },
+ {
+ "permission": "*",
+ "action": "deny",
+ "pattern": "*"
+ },
+ {
+ "permission": "external_directory",
+ "pattern": "/home/nathan/.local/share/opencode/tool-output/*",
+ "action": "allow"
+ }
+ ],
+ "prompt": "Summarize what was done in this conversation. Write like a pull request description.\n\nRules:\n- 2-3 sentences max\n- Describe the changes made, not the process\n- Do not mention running tests, builds, or other validation steps\n- Do not explain what the user asked for\n- Write in first person (I added..., I fixed...)\n- Never ask questions or add new questions\n- If the conversation ends with an unanswered question to the user, preserve that exact question\n- If the conversation ends with an imperative statement or request to the user (e.g. \"Now please run the command and paste the console output\"), always include that exact request in the summary\n"
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/metadata-config.json b/research/opencode-compat/snapshots/native/metadata-config.json
new file mode 100644
index 0000000..2170fdb
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/metadata-config.json
@@ -0,0 +1,102 @@
+{
+ "agent": {},
+ "mode": {},
+ "plugin": [],
+ "command": {},
+ "username": "nathan",
+ "keybinds": {
+ "leader": "ctrl+x",
+ "app_exit": "ctrl+c,ctrl+d,q",
+ "editor_open": "e",
+ "theme_list": "t",
+ "sidebar_toggle": "b",
+ "scrollbar_toggle": "none",
+ "username_toggle": "none",
+ "status_view": "s",
+ "session_export": "x",
+ "session_new": "n",
+ "session_list": "l",
+ "session_timeline": "g",
+ "session_fork": "none",
+ "session_rename": "ctrl+r",
+ "session_delete": "ctrl+d",
+ "stash_delete": "ctrl+d",
+ "model_provider_list": "ctrl+a",
+ "model_favorite_toggle": "ctrl+f",
+ "session_share": "none",
+ "session_unshare": "none",
+ "session_interrupt": "escape",
+ "session_compact": "c",
+ "messages_page_up": "pageup,ctrl+alt+b",
+ "messages_page_down": "pagedown,ctrl+alt+f",
+ "messages_line_up": "ctrl+alt+y",
+ "messages_line_down": "ctrl+alt+e",
+ "messages_half_page_up": "ctrl+alt+u",
+ "messages_half_page_down": "ctrl+alt+d",
+ "messages_first": "ctrl+g,home",
+ "messages_last": "ctrl+alt+g,end",
+ "messages_next": "none",
+ "messages_previous": "none",
+ "messages_last_user": "none",
+ "messages_copy": "y",
+ "messages_undo": "u",
+ "messages_redo": "r",
+ "messages_toggle_conceal": "h",
+ "tool_details": "none",
+ "model_list": "m",
+ "model_cycle_recent": "f2",
+ "model_cycle_recent_reverse": "shift+f2",
+ "model_cycle_favorite": "none",
+ "model_cycle_favorite_reverse": "none",
+ "command_list": "ctrl+p",
+ "agent_list": "a",
+ "agent_cycle": "tab",
+ "agent_cycle_reverse": "shift+tab",
+ "variant_cycle": "ctrl+t",
+ "input_clear": "ctrl+c",
+ "input_paste": "ctrl+v",
+ "input_submit": "return",
+ "input_newline": "shift+return,ctrl+return,alt+return,ctrl+j",
+ "input_move_left": "left,ctrl+b",
+ "input_move_right": "right,ctrl+f",
+ "input_move_up": "up",
+ "input_move_down": "down",
+ "input_select_left": "shift+left",
+ "input_select_right": "shift+right",
+ "input_select_up": "shift+up",
+ "input_select_down": "shift+down",
+ "input_line_home": "ctrl+a",
+ "input_line_end": "ctrl+e",
+ "input_select_line_home": "ctrl+shift+a",
+ "input_select_line_end": "ctrl+shift+e",
+ "input_visual_line_home": "alt+a",
+ "input_visual_line_end": "alt+e",
+ "input_select_visual_line_home": "alt+shift+a",
+ "input_select_visual_line_end": "alt+shift+e",
+ "input_buffer_home": "home",
+ "input_buffer_end": "end",
+ "input_select_buffer_home": "shift+home",
+ "input_select_buffer_end": "shift+end",
+ "input_delete_line": "ctrl+shift+d",
+ "input_delete_to_line_end": "ctrl+k",
+ "input_delete_to_line_start": "ctrl+u",
+ "input_backspace": "backspace,shift+backspace",
+ "input_delete": "ctrl+d,delete,shift+delete",
+ "input_undo": "ctrl+-,super+z",
+ "input_redo": "ctrl+.,super+shift+z",
+ "input_word_forward": "alt+f,alt+right,ctrl+right",
+ "input_word_backward": "alt+b,alt+left,ctrl+left",
+ "input_select_word_forward": "alt+shift+f,alt+shift+right",
+ "input_select_word_backward": "alt+shift+b,alt+shift+left",
+ "input_delete_word_forward": "alt+d,alt+delete,ctrl+delete",
+ "input_delete_word_backward": "ctrl+w,ctrl+backspace,alt+backspace",
+ "history_previous": "up",
+ "history_next": "down",
+ "session_child_cycle": "right",
+ "session_child_cycle_reverse": "left",
+ "session_parent": "up",
+ "terminal_suspend": "ctrl+z",
+ "terminal_title_toggle": "none",
+ "tips_toggle": "h"
+ }
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/metadata-providers.json b/research/opencode-compat/snapshots/native/metadata-providers.json
new file mode 100644
index 0000000..69e05fc
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/metadata-providers.json
@@ -0,0 +1,3716 @@
+{
+ "providers": [
+ {
+ "id": "opencode",
+ "source": "api",
+ "name": "OpenCode Zen",
+ "env": [
+ "OPENCODE_API_KEY"
+ ],
+ "options": {},
+ "models": {
+ "glm-4.7": {
+ "id": "glm-4.7",
+ "providerID": "opencode",
+ "name": "GLM-4.7",
+ "family": "glm",
+ "api": {
+ "id": "glm-4.7",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.6,
+ "output": 2.2,
+ "cache": {
+ "read": 0.1,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 204800,
+ "output": 131072
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": {
+ "field": "reasoning_content"
+ }
+ },
+ "release_date": "2025-12-22",
+ "variants": {}
+ },
+ "qwen3-coder": {
+ "id": "qwen3-coder",
+ "providerID": "opencode",
+ "name": "Qwen3 Coder",
+ "family": "qwen",
+ "api": {
+ "id": "qwen3-coder",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.45,
+ "output": 1.8,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 262144,
+ "output": 65536
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-07-23",
+ "variants": {}
+ },
+ "claude-opus-4-1": {
+ "id": "claude-opus-4-1",
+ "providerID": "opencode",
+ "name": "Claude Opus 4.1",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-1",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 15,
+ "output": 75,
+ "cache": {
+ "read": 1.5,
+ "write": 18.75
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 32000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-08-05",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 15999
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "kimi-k2": {
+ "id": "kimi-k2",
+ "providerID": "opencode",
+ "name": "Kimi K2",
+ "family": "kimi",
+ "api": {
+ "id": "kimi-k2",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.4,
+ "output": 2.5,
+ "cache": {
+ "read": 0.4,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 262144,
+ "output": 262144
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-09-05",
+ "variants": {}
+ },
+ "gpt-5.2-codex": {
+ "id": "gpt-5.2-codex",
+ "providerID": "opencode",
+ "name": "GPT-5.2 Codex",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.2-codex",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1.75,
+ "output": 14,
+ "cache": {
+ "read": 0.175,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2026-01-14",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "xhigh": {
+ "reasoningEffort": "xhigh",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "gpt-5.1-codex": {
+ "id": "gpt-5.1-codex",
+ "providerID": "opencode",
+ "name": "GPT-5.1 Codex",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.1-codex",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1.07,
+ "output": 8.5,
+ "cache": {
+ "read": 0.107,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-13",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "claude-haiku-4-5": {
+ "id": "claude-haiku-4-5",
+ "providerID": "opencode",
+ "name": "Claude Haiku 4.5",
+ "family": "claude-haiku",
+ "api": {
+ "id": "claude-haiku-4-5",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1,
+ "output": 5,
+ "cache": {
+ "read": 0.1,
+ "write": 1.25
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-10-15",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-opus-4-6": {
+ "id": "claude-opus-4-6",
+ "providerID": "opencode",
+ "name": "Claude Opus 4.6",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-6",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 5,
+ "output": 25,
+ "cache": {
+ "read": 0.5,
+ "write": 6.25
+ },
+ "experimentalOver200K": {
+ "cache": {
+ "read": 1,
+ "write": 12.5
+ },
+ "input": 10,
+ "output": 37.5
+ }
+ },
+ "limit": {
+ "context": 1000000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2026-02-05",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "trinity-large-preview-free": {
+ "id": "trinity-large-preview-free",
+ "providerID": "opencode",
+ "name": "Trinity Large Preview",
+ "family": "trinity",
+ "api": {
+ "id": "trinity-large-preview-free",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 131072,
+ "output": 131072
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2026-01-28",
+ "variants": {}
+ },
+ "claude-opus-4-5": {
+ "id": "claude-opus-4-5",
+ "providerID": "opencode",
+ "name": "Claude Opus 4.5",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-5",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 5,
+ "output": 25,
+ "cache": {
+ "read": 0.5,
+ "write": 6.25
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-24",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "kimi-k2.5": {
+ "id": "kimi-k2.5",
+ "providerID": "opencode",
+ "name": "Kimi K2.5",
+ "family": "kimi",
+ "api": {
+ "id": "kimi-k2.5",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.6,
+ "output": 3,
+ "cache": {
+ "read": 0.08,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 262144,
+ "output": 262144
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": true,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": {
+ "field": "reasoning_content"
+ }
+ },
+ "release_date": "2026-01-27",
+ "variants": {}
+ },
+ "gemini-3-pro": {
+ "id": "gemini-3-pro",
+ "providerID": "opencode",
+ "name": "Gemini 3 Pro",
+ "family": "gemini-pro",
+ "api": {
+ "id": "gemini-3-pro",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/google"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 2,
+ "output": 12,
+ "cache": {
+ "read": 0.2,
+ "write": 0
+ },
+ "experimentalOver200K": {
+ "cache": {
+ "read": 0.4,
+ "write": 0
+ },
+ "input": 4,
+ "output": 18
+ }
+ },
+ "limit": {
+ "context": 1048576,
+ "output": 65536
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": true,
+ "image": true,
+ "video": true,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-18",
+ "variants": {
+ "low": {
+ "includeThoughts": true,
+ "thinkingLevel": "low"
+ },
+ "high": {
+ "includeThoughts": true,
+ "thinkingLevel": "high"
+ }
+ }
+ },
+ "claude-sonnet-4-5": {
+ "id": "claude-sonnet-4-5",
+ "providerID": "opencode",
+ "name": "Claude Sonnet 4.5",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-sonnet-4-5",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 3,
+ "output": 15,
+ "cache": {
+ "read": 0.3,
+ "write": 3.75
+ },
+ "experimentalOver200K": {
+ "cache": {
+ "read": 0.6,
+ "write": 7.5
+ },
+ "input": 6,
+ "output": 22.5
+ }
+ },
+ "limit": {
+ "context": 1000000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": true
+ },
+ "release_date": "2025-09-29",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "gpt-5.1-codex-mini": {
+ "id": "gpt-5.1-codex-mini",
+ "providerID": "opencode",
+ "name": "GPT-5.1 Codex Mini",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.1-codex-mini",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.25,
+ "output": 2,
+ "cache": {
+ "read": 0.025,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-13",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "kimi-k2-thinking": {
+ "id": "kimi-k2-thinking",
+ "providerID": "opencode",
+ "name": "Kimi K2 Thinking",
+ "family": "kimi-thinking",
+ "api": {
+ "id": "kimi-k2-thinking",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.4,
+ "output": 2.5,
+ "cache": {
+ "read": 0.4,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 262144,
+ "output": 262144
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": {
+ "field": "reasoning_content"
+ }
+ },
+ "release_date": "2025-09-05",
+ "variants": {}
+ },
+ "gpt-5.1": {
+ "id": "gpt-5.1",
+ "providerID": "opencode",
+ "name": "GPT-5.1",
+ "family": "gpt",
+ "api": {
+ "id": "gpt-5.1",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1.07,
+ "output": 8.5,
+ "cache": {
+ "read": 0.107,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-13",
+ "variants": {
+ "none": {
+ "reasoningEffort": "none",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "gpt-5-nano": {
+ "id": "gpt-5-nano",
+ "providerID": "opencode",
+ "name": "GPT-5 Nano",
+ "family": "gpt-nano",
+ "api": {
+ "id": "gpt-5-nano",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-08-07",
+ "variants": {
+ "minimal": {
+ "reasoningEffort": "minimal",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "gpt-5-codex": {
+ "id": "gpt-5-codex",
+ "providerID": "opencode",
+ "name": "GPT-5 Codex",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5-codex",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1.07,
+ "output": 8.5,
+ "cache": {
+ "read": 0.107,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-09-15",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "big-pickle": {
+ "id": "big-pickle",
+ "providerID": "opencode",
+ "name": "Big Pickle",
+ "family": "big-pickle",
+ "api": {
+ "id": "big-pickle",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-10-17",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low"
+ },
+ "medium": {
+ "reasoningEffort": "medium"
+ },
+ "high": {
+ "reasoningEffort": "high"
+ }
+ }
+ },
+ "claude-3-5-haiku": {
+ "id": "claude-3-5-haiku",
+ "providerID": "opencode",
+ "name": "Claude Haiku 3.5",
+ "family": "claude-haiku",
+ "api": {
+ "id": "claude-3-5-haiku",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.8,
+ "output": 4,
+ "cache": {
+ "read": 0.08,
+ "write": 1
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 8192
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-10-22",
+ "variants": {}
+ },
+ "glm-4.6": {
+ "id": "glm-4.6",
+ "providerID": "opencode",
+ "name": "GLM-4.6",
+ "family": "glm",
+ "api": {
+ "id": "glm-4.6",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.6,
+ "output": 2.2,
+ "cache": {
+ "read": 0.1,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 204800,
+ "output": 131072
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-09-30",
+ "variants": {}
+ },
+ "glm-4.7-free": {
+ "id": "glm-4.7-free",
+ "providerID": "opencode",
+ "name": "GLM-4.7 Free",
+ "family": "glm-free",
+ "api": {
+ "id": "glm-4.7-free",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 204800,
+ "output": 131072
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": {
+ "field": "reasoning_content"
+ }
+ },
+ "release_date": "2025-12-22",
+ "variants": {}
+ },
+ "gemini-3-flash": {
+ "id": "gemini-3-flash",
+ "providerID": "opencode",
+ "name": "Gemini 3 Flash",
+ "family": "gemini-flash",
+ "api": {
+ "id": "gemini-3-flash",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/google"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.5,
+ "output": 3,
+ "cache": {
+ "read": 0.05,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 1048576,
+ "output": 65536
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": true,
+ "image": true,
+ "video": true,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-12-17",
+ "variants": {
+ "low": {
+ "includeThoughts": true,
+ "thinkingLevel": "low"
+ },
+ "high": {
+ "includeThoughts": true,
+ "thinkingLevel": "high"
+ }
+ }
+ },
+ "gpt-5.1-codex-max": {
+ "id": "gpt-5.1-codex-max",
+ "providerID": "opencode",
+ "name": "GPT-5.1 Codex Max",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.1-codex-max",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1.25,
+ "output": 10,
+ "cache": {
+ "read": 0.125,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-13",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "minimax-m2.1-free": {
+ "id": "minimax-m2.1-free",
+ "providerID": "opencode",
+ "name": "MiniMax M2.1 Free",
+ "family": "minimax-free",
+ "api": {
+ "id": "minimax-m2.1-free",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 204800,
+ "output": 131072
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-12-23",
+ "variants": {}
+ },
+ "kimi-k2.5-free": {
+ "id": "kimi-k2.5-free",
+ "providerID": "opencode",
+ "name": "Kimi K2.5 Free",
+ "family": "kimi-free",
+ "api": {
+ "id": "kimi-k2.5-free",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 262144,
+ "output": 262144
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": true,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": {
+ "field": "reasoning_content"
+ }
+ },
+ "release_date": "2026-01-27",
+ "variants": {}
+ },
+ "claude-sonnet-4": {
+ "id": "claude-sonnet-4",
+ "providerID": "opencode",
+ "name": "Claude Sonnet 4",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-sonnet-4",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 3,
+ "output": 15,
+ "cache": {
+ "read": 0.3,
+ "write": 3.75
+ },
+ "experimentalOver200K": {
+ "cache": {
+ "read": 0.6,
+ "write": 7.5
+ },
+ "input": 6,
+ "output": 22.5
+ }
+ },
+ "limit": {
+ "context": 1000000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-05-22",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "gpt-5": {
+ "id": "gpt-5",
+ "providerID": "opencode",
+ "name": "GPT-5",
+ "family": "gpt",
+ "api": {
+ "id": "gpt-5",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1.07,
+ "output": 8.5,
+ "cache": {
+ "read": 0.107,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-08-07",
+ "variants": {
+ "minimal": {
+ "reasoningEffort": "minimal",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "minimax-m2.1": {
+ "id": "minimax-m2.1",
+ "providerID": "opencode",
+ "name": "MiniMax M2.1",
+ "family": "minimax",
+ "api": {
+ "id": "minimax-m2.1",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai-compatible"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.3,
+ "output": 1.2,
+ "cache": {
+ "read": 0.1,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 204800,
+ "output": 131072
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": {
+ "field": "reasoning_content"
+ }
+ },
+ "release_date": "2025-12-23",
+ "variants": {}
+ },
+ "gpt-5.2": {
+ "id": "gpt-5.2",
+ "providerID": "opencode",
+ "name": "GPT-5.2",
+ "family": "gpt",
+ "api": {
+ "id": "gpt-5.2",
+ "url": "https://opencode.ai/zen/v1",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 1.75,
+ "output": 14,
+ "cache": {
+ "read": 0.175,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-12-11",
+ "variants": {
+ "none": {
+ "reasoningEffort": "none",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "xhigh": {
+ "reasoningEffort": "xhigh",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ }
+ },
+ "key": "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"
+ },
+ {
+ "id": "cerebras",
+ "source": "api",
+ "name": "Cerebras",
+ "env": [
+ "CEREBRAS_API_KEY"
+ ],
+ "options": {
+ "headers": {
+ "X-Cerebras-3rd-Party-Integration": "opencode"
+ }
+ },
+ "models": {
+ "zai-glm-4.7": {
+ "id": "zai-glm-4.7",
+ "providerID": "cerebras",
+ "name": "Z.AI GLM-4.7",
+ "api": {
+ "id": "zai-glm-4.7",
+ "npm": "@ai-sdk/cerebras"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 131072,
+ "output": 40000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2026-01-10",
+ "variants": {}
+ },
+ "qwen-3-235b-a22b-instruct-2507": {
+ "id": "qwen-3-235b-a22b-instruct-2507",
+ "providerID": "cerebras",
+ "name": "Qwen 3 235B Instruct",
+ "family": "qwen",
+ "api": {
+ "id": "qwen-3-235b-a22b-instruct-2507",
+ "npm": "@ai-sdk/cerebras"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.6,
+ "output": 1.2,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 131000,
+ "output": 32000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-07-22",
+ "variants": {}
+ },
+ "gpt-oss-120b": {
+ "id": "gpt-oss-120b",
+ "providerID": "cerebras",
+ "name": "GPT OSS 120B",
+ "family": "gpt-oss",
+ "api": {
+ "id": "gpt-oss-120b",
+ "npm": "@ai-sdk/cerebras"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0.25,
+ "output": 0.69,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 131072,
+ "output": 32768
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": false,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-08-05",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low"
+ },
+ "medium": {
+ "reasoningEffort": "medium"
+ },
+ "high": {
+ "reasoningEffort": "high"
+ }
+ }
+ }
+ },
+ "key": "csk-me9n8whxtf2eekkfxe36569ppxpmk3ewh54d9t29cch5wnyd"
+ },
+ {
+ "id": "openai",
+ "source": "custom",
+ "name": "OpenAI",
+ "env": [
+ "OPENAI_API_KEY"
+ ],
+ "options": {
+ "apiKey": "opencode-oauth-dummy-key"
+ },
+ "models": {
+ "gpt-5.2-codex": {
+ "id": "gpt-5.2-codex",
+ "providerID": "openai",
+ "name": "GPT-5.2 Codex",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.2-codex",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-12-11",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "xhigh": {
+ "reasoningEffort": "xhigh",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "gpt-5.1-codex": {
+ "id": "gpt-5.1-codex",
+ "providerID": "openai",
+ "name": "GPT-5.1 Codex",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.1-codex",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-13",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "gpt-5.1-codex-mini": {
+ "id": "gpt-5.1-codex-mini",
+ "providerID": "openai",
+ "name": "GPT-5.1 Codex mini",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.1-codex-mini",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-13",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "gpt-5.1-codex-max": {
+ "id": "gpt-5.1-codex-max",
+ "providerID": "openai",
+ "name": "GPT-5.1 Codex Max",
+ "family": "gpt-codex",
+ "api": {
+ "id": "gpt-5.1-codex-max",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-13",
+ "variants": {
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ },
+ "gpt-5.2": {
+ "id": "gpt-5.2",
+ "providerID": "openai",
+ "name": "GPT-5.2",
+ "family": "gpt",
+ "api": {
+ "id": "gpt-5.2",
+ "npm": "@ai-sdk/openai"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 400000,
+ "input": 272000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": false,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": false
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-12-11",
+ "variants": {
+ "none": {
+ "reasoningEffort": "none",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "low": {
+ "reasoningEffort": "low",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "medium": {
+ "reasoningEffort": "medium",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "high": {
+ "reasoningEffort": "high",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ },
+ "xhigh": {
+ "reasoningEffort": "xhigh",
+ "reasoningSummary": "auto",
+ "include": [
+ "reasoning.encrypted_content"
+ ]
+ }
+ }
+ }
+ }
+ },
+ {
+ "id": "anthropic",
+ "source": "custom",
+ "name": "Anthropic",
+ "env": [
+ "ANTHROPIC_API_KEY"
+ ],
+ "options": {
+ "apiKey": "",
+ "headers": {
+ "anthropic-beta": "claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
+ }
+ },
+ "models": {
+ "claude-opus-4-0": {
+ "id": "claude-opus-4-0",
+ "providerID": "anthropic",
+ "name": "Claude Opus 4 (latest)",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-0",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 32000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-05-22",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 15999
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-3-5-sonnet-20241022": {
+ "id": "claude-3-5-sonnet-20241022",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 3.5 v2",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-3-5-sonnet-20241022",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 8192
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-10-22",
+ "variants": {}
+ },
+ "claude-opus-4-1": {
+ "id": "claude-opus-4-1",
+ "providerID": "anthropic",
+ "name": "Claude Opus 4.1 (latest)",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-1",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 32000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-08-05",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 15999
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-haiku-4-5": {
+ "id": "claude-haiku-4-5",
+ "providerID": "anthropic",
+ "name": "Claude Haiku 4.5 (latest)",
+ "family": "claude-haiku",
+ "api": {
+ "id": "claude-haiku-4-5",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-10-15",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-3-5-sonnet-20240620": {
+ "id": "claude-3-5-sonnet-20240620",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 3.5",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-3-5-sonnet-20240620",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 8192
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-06-20",
+ "variants": {}
+ },
+ "claude-opus-4-6": {
+ "id": "claude-opus-4-6",
+ "providerID": "anthropic",
+ "name": "Claude Opus 4.6",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-6",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 1000000,
+ "output": 128000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2026-02-05",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-3-5-haiku-latest": {
+ "id": "claude-3-5-haiku-latest",
+ "providerID": "anthropic",
+ "name": "Claude Haiku 3.5 (latest)",
+ "family": "claude-haiku",
+ "api": {
+ "id": "claude-3-5-haiku-latest",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 8192
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-10-22",
+ "variants": {}
+ },
+ "claude-opus-4-5": {
+ "id": "claude-opus-4-5",
+ "providerID": "anthropic",
+ "name": "Claude Opus 4.5 (latest)",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-5",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-24",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-3-opus-20240229": {
+ "id": "claude-3-opus-20240229",
+ "providerID": "anthropic",
+ "name": "Claude Opus 3",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-3-opus-20240229",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 4096
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-02-29",
+ "variants": {}
+ },
+ "claude-opus-4-5-20251101": {
+ "id": "claude-opus-4-5-20251101",
+ "providerID": "anthropic",
+ "name": "Claude Opus 4.5",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-5-20251101",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-11-01",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-sonnet-4-5": {
+ "id": "claude-sonnet-4-5",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 4.5 (latest)",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-sonnet-4-5",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-09-29",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-sonnet-4-5-20250929": {
+ "id": "claude-sonnet-4-5-20250929",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 4.5",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-sonnet-4-5-20250929",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-09-29",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-sonnet-4-20250514": {
+ "id": "claude-sonnet-4-20250514",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 4",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-sonnet-4-20250514",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-05-22",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-opus-4-20250514": {
+ "id": "claude-opus-4-20250514",
+ "providerID": "anthropic",
+ "name": "Claude Opus 4",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-20250514",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 32000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-05-22",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 15999
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-3-5-haiku-20241022": {
+ "id": "claude-3-5-haiku-20241022",
+ "providerID": "anthropic",
+ "name": "Claude Haiku 3.5",
+ "family": "claude-haiku",
+ "api": {
+ "id": "claude-3-5-haiku-20241022",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 8192
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-10-22",
+ "variants": {}
+ },
+ "claude-3-haiku-20240307": {
+ "id": "claude-3-haiku-20240307",
+ "providerID": "anthropic",
+ "name": "Claude Haiku 3",
+ "family": "claude-haiku",
+ "api": {
+ "id": "claude-3-haiku-20240307",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 4096
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-03-13",
+ "variants": {}
+ },
+ "claude-3-7-sonnet-20250219": {
+ "id": "claude-3-7-sonnet-20250219",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 3.7",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-3-7-sonnet-20250219",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-02-19",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-3-7-sonnet-latest": {
+ "id": "claude-3-7-sonnet-latest",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 3.7 (latest)",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-3-7-sonnet-latest",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-02-19",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-sonnet-4-0": {
+ "id": "claude-sonnet-4-0",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 4 (latest)",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-sonnet-4-0",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-05-22",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-opus-4-1-20250805": {
+ "id": "claude-opus-4-1-20250805",
+ "providerID": "anthropic",
+ "name": "Claude Opus 4.1",
+ "family": "claude-opus",
+ "api": {
+ "id": "claude-opus-4-1-20250805",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 32000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-08-05",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 15999
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ },
+ "claude-3-sonnet-20240229": {
+ "id": "claude-3-sonnet-20240229",
+ "providerID": "anthropic",
+ "name": "Claude Sonnet 3",
+ "family": "claude-sonnet",
+ "api": {
+ "id": "claude-3-sonnet-20240229",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 4096
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": false,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2024-03-04",
+ "variants": {}
+ },
+ "claude-haiku-4-5-20251001": {
+ "id": "claude-haiku-4-5-20251001",
+ "providerID": "anthropic",
+ "name": "Claude Haiku 4.5",
+ "family": "claude-haiku",
+ "api": {
+ "id": "claude-haiku-4-5-20251001",
+ "npm": "@ai-sdk/anthropic"
+ },
+ "status": "active",
+ "headers": {},
+ "options": {},
+ "cost": {
+ "input": 0,
+ "output": 0,
+ "cache": {
+ "read": 0,
+ "write": 0
+ }
+ },
+ "limit": {
+ "context": 200000,
+ "output": 64000
+ },
+ "capabilities": {
+ "temperature": true,
+ "reasoning": true,
+ "attachment": true,
+ "toolcall": true,
+ "input": {
+ "text": true,
+ "audio": false,
+ "image": true,
+ "video": false,
+ "pdf": true
+ },
+ "output": {
+ "text": true,
+ "audio": false,
+ "image": false,
+ "video": false,
+ "pdf": false
+ },
+ "interleaved": false
+ },
+ "release_date": "2025-10-15",
+ "variants": {
+ "high": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 16000
+ }
+ },
+ "max": {
+ "thinking": {
+ "type": "enabled",
+ "budgetTokens": 31999
+ }
+ }
+ }
+ }
+ }
+ }
+ ],
+ "default": {
+ "opencode": "gemini-3-pro",
+ "cerebras": "zai-glm-4.7",
+ "openai": "gpt-5.2-codex",
+ "anthropic": "claude-sonnet-4-5-20250929"
+ }
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/session-create.json b/research/opencode-compat/snapshots/native/session-create.json
new file mode 100644
index 0000000..eb38538
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/session-create.json
@@ -0,0 +1,12 @@
+{
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "New session - 2026-02-06T06:56:52.806Z",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361012806
+ }
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/session-details.json b/research/opencode-compat/snapshots/native/session-details.json
new file mode 100644
index 0000000..f3e4a40
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/session-details.json
@@ -0,0 +1,17 @@
+{
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "Hello from OpenCode",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361017462
+ },
+ "summary": {
+ "additions": 0,
+ "deletions": 0,
+ "files": 0
+ }
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/session-events.json b/research/opencode-compat/snapshots/native/session-events.json
new file mode 100644
index 0000000..a6630cc
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/session-events.json
@@ -0,0 +1,156 @@
+[
+ {
+ "type": "session.created",
+ "properties": {
+ "info": {
+ "id": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "slug": "witty-eagle",
+ "version": "1.1.49",
+ "projectID": "c4153c5335dc81f0e622888f1f387c4b84dc54d5",
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "title": "New session - 2026-02-06T06:56:52.806Z",
+ "time": {
+ "created": 1770361012806,
+ "updated": 1770361012806
+ }
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "idle"
+ }
+ }
+ },
+ {
+ "type": "session.idle",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms"
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "busy"
+ }
+ }
+ },
+ {
+ "type": "session.status",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "status": {
+ "type": "idle"
+ }
+ }
+ },
+ {
+ "type": "session.idle",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms"
+ }
+ },
+ {
+ "type": "session.diff",
+ "properties": {
+ "sessionID": "ses_3ce42bdb9ffeEIUUu08AuKTJms",
+ "diff": []
+ }
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/native/session-status.json b/research/opencode-compat/snapshots/native/session-status.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/research/opencode-compat/snapshots/native/session-status.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/all-events.json b/research/opencode-compat/snapshots/sandbox-agent/all-events.json
new file mode 100644
index 0000000..1ff6540
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/all-events.json
@@ -0,0 +1,682 @@
+[
+ {
+ "properties": {},
+ "type": "server.connected"
+ },
+ {
+ "properties": {
+ "branch": "main",
+ "name": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "type": "worktree.ready"
+ },
+ {
+ "properties": {},
+ "type": "server.heartbeat"
+ },
+ {
+ "properties": {
+ "info": {
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "id": "ses_1",
+ "projectID": "proj_1",
+ "slug": "session-ses_1",
+ "time": {
+ "created": 1770362164904,
+ "updated": 1770362164904
+ },
+ "title": "Session ses_1",
+ "version": "0"
+ }
+ },
+ "type": "session.created"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1",
+ "status": {
+ "type": "busy"
+ }
+ },
+ "type": "session.status"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "id": "msg_1",
+ "model": {
+ "modelID": "mock",
+ "providerID": "sandbox-agent"
+ },
+ "role": "user",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362164907,
+ "created": 1770362164907
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_1",
+ "part": {
+ "id": "part_1",
+ "messageID": "msg_1",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165109
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "delta": "echo Hello from sandbox-agent",
+ "messageID": "msg_1_assistant",
+ "part": {
+ "id": "msg_1_assistant_text",
+ "messageID": "msg_1_assistant",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165309
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165511
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "delta": "Hello from sandbox-agent",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "part": {
+ "id": "msg_1_assistant_00000000000000000005_text",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "sessionID": "ses_1",
+ "text": "Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362165511,
+ "created": 1770362165511
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "part": {
+ "id": "msg_1_assistant_00000000000000000005_text",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "sessionID": "ses_1",
+ "text": "Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1",
+ "status": {
+ "type": "idle"
+ }
+ },
+ "type": "session.status"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1"
+ },
+ "type": "session.idle"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1",
+ "status": {
+ "type": "busy"
+ }
+ },
+ "type": "session.status"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "id": "msg_2",
+ "model": {
+ "modelID": "mock",
+ "providerID": "sandbox-agent"
+ },
+ "role": "user",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362166412,
+ "created": 1770362166412
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2",
+ "part": {
+ "id": "part_2",
+ "messageID": "msg_2",
+ "sessionID": "ses_1",
+ "text": "tool",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362166614
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "delta": "tool",
+ "messageID": "msg_2_assistant",
+ "part": {
+ "id": "msg_2_assistant_text",
+ "messageID": "msg_2_assistant",
+ "sessionID": "ses_1",
+ "text": "tool",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362166815
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "raw": "{\"query\":\"example\"}",
+ "status": "pending"
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362167016,
+ "created": 1770362167016
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "status": "running",
+ "time": {
+ "start": 1770362167016
+ }
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362167218
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "status": "running",
+ "time": {
+ "start": 1770362167218
+ }
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362167418,
+ "created": 1770362167418
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "filename": "mock_2/readme.md",
+ "id": "part_4",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/plain",
+ "sessionID": "ses_1",
+ "type": "file",
+ "url": "file://mock_2/readme.md"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "filename": "mock_2/output.txt",
+ "id": "part_5",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/plain",
+ "sessionID": "ses_1",
+ "source": {
+ "path": "mock_2/output.txt",
+ "text": {
+ "end": 13,
+ "start": 0,
+ "value": "+mock output\n"
+ },
+ "type": "file"
+ },
+ "type": "file",
+ "url": "file://mock_2/output.txt"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "file": "mock_2/output.txt"
+ },
+ "type": "file.edited"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "filename": "mock_2/patch.txt",
+ "id": "part_6",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/x-diff",
+ "sessionID": "ses_1",
+ "source": {
+ "path": "mock_2/patch.txt",
+ "text": {
+ "end": 26,
+ "start": 0,
+ "value": "@@ -1,1 +1,1 @@\n-old\n+new\n"
+ },
+ "type": "file"
+ },
+ "type": "file",
+ "url": "file://mock_2/patch.txt"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "file": "mock_2/patch.txt"
+ },
+ "type": "file.edited"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "metadata": {},
+ "output": "mock search results",
+ "status": "error",
+ "time": {
+ "end": 1770362167418,
+ "start": 1770362167418
+ }
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/messages-after-1.json b/research/opencode-compat/snapshots/sandbox-agent/messages-after-1.json
new file mode 100644
index 0000000..432dfe8
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/messages-after-1.json
@@ -0,0 +1,106 @@
+[
+ {
+ "info": {
+ "agent": "build",
+ "id": "msg_1",
+ "model": {
+ "modelID": "mock",
+ "providerID": "sandbox-agent"
+ },
+ "role": "user",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362164907,
+ "created": 1770362164907
+ }
+ },
+ "parts": [
+ {
+ "id": "part_1",
+ "messageID": "msg_1",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ }
+ ]
+ },
+ {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165109
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "parts": [
+ {
+ "id": "msg_1_assistant_text",
+ "messageID": "msg_1_assistant",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ }
+ ]
+ },
+ {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362165511,
+ "created": 1770362165511
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "parts": [
+ {
+ "id": "msg_1_assistant_00000000000000000005_text",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "sessionID": "ses_1",
+ "text": "Hello from sandbox-agent",
+ "type": "text"
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/messages-after-2.json b/research/opencode-compat/snapshots/sandbox-agent/messages-after-2.json
new file mode 100644
index 0000000..778c702
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/messages-after-2.json
@@ -0,0 +1,269 @@
+[
+ {
+ "info": {
+ "agent": "build",
+ "id": "msg_1",
+ "model": {
+ "modelID": "mock",
+ "providerID": "sandbox-agent"
+ },
+ "role": "user",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362164907,
+ "created": 1770362164907
+ }
+ },
+ "parts": [
+ {
+ "id": "part_1",
+ "messageID": "msg_1",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ }
+ ]
+ },
+ {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165109
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "parts": [
+ {
+ "id": "msg_1_assistant_text",
+ "messageID": "msg_1_assistant",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ }
+ ]
+ },
+ {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362165511,
+ "created": 1770362165511
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "parts": [
+ {
+ "id": "msg_1_assistant_00000000000000000005_text",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "sessionID": "ses_1",
+ "text": "Hello from sandbox-agent",
+ "type": "text"
+ }
+ ]
+ },
+ {
+ "info": {
+ "agent": "build",
+ "id": "msg_2",
+ "model": {
+ "modelID": "mock",
+ "providerID": "sandbox-agent"
+ },
+ "role": "user",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362166412,
+ "created": 1770362166412
+ }
+ },
+ "parts": [
+ {
+ "id": "part_2",
+ "messageID": "msg_2",
+ "sessionID": "ses_1",
+ "text": "tool",
+ "type": "text"
+ }
+ ]
+ },
+ {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362166614
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "parts": [
+ {
+ "id": "msg_2_assistant_text",
+ "messageID": "msg_2_assistant",
+ "sessionID": "ses_1",
+ "text": "tool",
+ "type": "text"
+ }
+ ]
+ },
+ {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362167418,
+ "created": 1770362167418
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "parts": [
+ {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "metadata": {},
+ "output": "mock search results",
+ "status": "error",
+ "time": {
+ "end": 1770362167418,
+ "start": 1770362167418
+ }
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ {
+ "filename": "mock_2/readme.md",
+ "id": "part_4",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/plain",
+ "sessionID": "ses_1",
+ "type": "file",
+ "url": "file://mock_2/readme.md"
+ },
+ {
+ "filename": "mock_2/output.txt",
+ "id": "part_5",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/plain",
+ "sessionID": "ses_1",
+ "source": {
+ "path": "mock_2/output.txt",
+ "text": {
+ "end": 13,
+ "start": 0,
+ "value": "+mock output\n"
+ },
+ "type": "file"
+ },
+ "type": "file",
+ "url": "file://mock_2/output.txt"
+ },
+ {
+ "filename": "mock_2/patch.txt",
+ "id": "part_6",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/x-diff",
+ "sessionID": "ses_1",
+ "source": {
+ "path": "mock_2/patch.txt",
+ "text": {
+ "end": 26,
+ "start": 0,
+ "value": "@@ -1,1 +1,1 @@\n-old\n+new\n"
+ },
+ "type": "file"
+ },
+ "type": "file",
+ "url": "file://mock_2/patch.txt"
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/metadata-agent.json b/research/opencode-compat/snapshots/sandbox-agent/metadata-agent.json
new file mode 100644
index 0000000..fc8b612
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/metadata-agent.json
@@ -0,0 +1,11 @@
+[
+ {
+ "description": "Sandbox Agent compatibility layer",
+ "hidden": false,
+ "mode": "all",
+ "name": "Sandbox Agent",
+ "native": false,
+ "options": {},
+ "permission": []
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/metadata-config.json b/research/opencode-compat/snapshots/sandbox-agent/metadata-config.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/metadata-config.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/session-create.json b/research/opencode-compat/snapshots/sandbox-agent/session-create.json
new file mode 100644
index 0000000..36e0784
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/session-create.json
@@ -0,0 +1,12 @@
+{
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "id": "ses_1",
+ "projectID": "proj_1",
+ "slug": "session-ses_1",
+ "time": {
+ "created": 1770362164904,
+ "updated": 1770362164904
+ },
+ "title": "Session ses_1",
+ "version": "0"
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/session-details.json b/research/opencode-compat/snapshots/sandbox-agent/session-details.json
new file mode 100644
index 0000000..36e0784
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/session-details.json
@@ -0,0 +1,12 @@
+{
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "id": "ses_1",
+ "projectID": "proj_1",
+ "slug": "session-ses_1",
+ "time": {
+ "created": 1770362164904,
+ "updated": 1770362164904
+ },
+ "title": "Session ses_1",
+ "version": "0"
+}
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/session-events.json b/research/opencode-compat/snapshots/sandbox-agent/session-events.json
new file mode 100644
index 0000000..66b86ab
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/session-events.json
@@ -0,0 +1,655 @@
+[
+ {
+ "properties": {
+ "info": {
+ "directory": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "id": "ses_1",
+ "projectID": "proj_1",
+ "slug": "session-ses_1",
+ "time": {
+ "created": 1770362164904,
+ "updated": 1770362164904
+ },
+ "title": "Session ses_1",
+ "version": "0"
+ }
+ },
+ "type": "session.created"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1",
+ "status": {
+ "type": "busy"
+ }
+ },
+ "type": "session.status"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "id": "msg_1",
+ "model": {
+ "modelID": "mock",
+ "providerID": "sandbox-agent"
+ },
+ "role": "user",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362164907,
+ "created": 1770362164907
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_1",
+ "part": {
+ "id": "part_1",
+ "messageID": "msg_1",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165109
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "delta": "echo Hello from sandbox-agent",
+ "messageID": "msg_1_assistant",
+ "part": {
+ "id": "msg_1_assistant_text",
+ "messageID": "msg_1_assistant",
+ "sessionID": "ses_1",
+ "text": "echo Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165309
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362165511
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "delta": "Hello from sandbox-agent",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "part": {
+ "id": "msg_1_assistant_00000000000000000005_text",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "sessionID": "ses_1",
+ "text": "Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_1_assistant_00000000000000000005",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_1",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362165511,
+ "created": 1770362165511
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "part": {
+ "id": "msg_1_assistant_00000000000000000005_text",
+ "messageID": "msg_1_assistant_00000000000000000005",
+ "sessionID": "ses_1",
+ "text": "Hello from sandbox-agent",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1",
+ "status": {
+ "type": "idle"
+ }
+ },
+ "type": "session.status"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1"
+ },
+ "type": "session.idle"
+ },
+ {
+ "properties": {
+ "sessionID": "ses_1",
+ "status": {
+ "type": "busy"
+ }
+ },
+ "type": "session.status"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "id": "msg_2",
+ "model": {
+ "modelID": "mock",
+ "providerID": "sandbox-agent"
+ },
+ "role": "user",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362166412,
+ "created": 1770362166412
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2",
+ "part": {
+ "id": "part_2",
+ "messageID": "msg_2",
+ "sessionID": "ses_1",
+ "text": "tool",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362166614
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "delta": "tool",
+ "messageID": "msg_2_assistant",
+ "part": {
+ "id": "msg_2_assistant_text",
+ "messageID": "msg_2_assistant",
+ "sessionID": "ses_1",
+ "text": "tool",
+ "type": "text"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362166815
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "raw": "{\"query\":\"example\"}",
+ "status": "pending"
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362167016,
+ "created": 1770362167016
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "status": "running",
+ "time": {
+ "start": 1770362167016
+ }
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "created": 1770362167218
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "status": "running",
+ "time": {
+ "start": 1770362167218
+ }
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "info": {
+ "agent": "build",
+ "cost": 0,
+ "finish": "stop",
+ "id": "msg_2_assistant_00000000000000000011",
+ "mode": "default",
+ "modelID": "mock",
+ "parentID": "msg_2",
+ "path": {
+ "cwd": "/home/nathan/sandbox-agent/research/opencode-compat",
+ "root": "/home/nathan/sandbox-agent/research/opencode-compat"
+ },
+ "providerID": "sandbox-agent",
+ "role": "assistant",
+ "sessionID": "ses_1",
+ "time": {
+ "completed": 1770362167418,
+ "created": 1770362167418
+ },
+ "tokens": {
+ "cache": {
+ "read": 0,
+ "write": 0
+ },
+ "input": 0,
+ "output": 0,
+ "reasoning": 0
+ }
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "filename": "mock_2/readme.md",
+ "id": "part_4",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/plain",
+ "sessionID": "ses_1",
+ "type": "file",
+ "url": "file://mock_2/readme.md"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "filename": "mock_2/output.txt",
+ "id": "part_5",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/plain",
+ "sessionID": "ses_1",
+ "source": {
+ "path": "mock_2/output.txt",
+ "text": {
+ "end": 13,
+ "start": 0,
+ "value": "+mock output\n"
+ },
+ "type": "file"
+ },
+ "type": "file",
+ "url": "file://mock_2/output.txt"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "filename": "mock_2/patch.txt",
+ "id": "part_6",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "mime": "text/x-diff",
+ "sessionID": "ses_1",
+ "source": {
+ "path": "mock_2/patch.txt",
+ "text": {
+ "end": 26,
+ "start": 0,
+ "value": "@@ -1,1 +1,1 @@\n-old\n+new\n"
+ },
+ "type": "file"
+ },
+ "type": "file",
+ "url": "file://mock_2/patch.txt"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ },
+ {
+ "properties": {
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "part": {
+ "callID": "mock_2_call",
+ "id": "part_3",
+ "messageID": "msg_2_assistant_00000000000000000011",
+ "metadata": {},
+ "sessionID": "ses_1",
+ "state": {
+ "input": {
+ "query": "example"
+ },
+ "metadata": {},
+ "output": "mock search results",
+ "status": "error",
+ "time": {
+ "end": 1770362167418,
+ "start": 1770362167418
+ }
+ },
+ "tool": "mock.search",
+ "type": "tool"
+ },
+ "sessionID": "ses_1"
+ },
+ "type": "message.part.updated"
+ }
+]
\ No newline at end of file
diff --git a/research/opencode-compat/snapshots/sandbox-agent/session-status.json b/research/opencode-compat/snapshots/sandbox-agent/session-status.json
new file mode 100644
index 0000000..8afc386
--- /dev/null
+++ b/research/opencode-compat/snapshots/sandbox-agent/session-status.json
@@ -0,0 +1,5 @@
+{
+ "ses_1": {
+ "type": "idle"
+ }
+}
\ No newline at end of file
diff --git a/research/opencode-tmux-test.md b/research/opencode-tmux-test.md
index ff553c0..96cc3ab 100644
--- a/research/opencode-tmux-test.md
+++ b/research/opencode-tmux-test.md
@@ -9,7 +9,8 @@ This plan captures OpenCode TUI output and sends input via tmux so we can valida
## Environment
- `SANDBOX_AGENT_LOG_DIR=/path` to set server log dir
-- `SANDBOX_AGENT_LOG_STDOUT=1` to keep logs on stdout/stderr
+- `SANDBOX_AGENT_LOG_TO_FILE=1` to redirect logs to files
+- `SANDBOX_AGENT_LOG_STDOUT=1` to force logs on stdout/stderr
- `SANDBOX_AGENT_LOG_HTTP=0` to disable request logs
- `SANDBOX_AGENT_LOG_HTTP_HEADERS=1` to include request headers (Authorization redacted)
- `RUST_LOG=...` for trace filtering
@@ -42,7 +43,7 @@ This plan captures OpenCode TUI output and sends input via tmux so we can valida
```bash
tmux capture-pane -pt opencode:0.0 -S -200 > /tmp/opencode-screen.txt
```
-6. Inspect server logs for requests:
+6. Inspect server logs for requests (when log-to-file is enabled):
```bash
tail -n 200 ~/.local/share/sandbox-agent/logs/log-$(date +%m-%d-%y)
```
diff --git a/scripts/release/promote-artifacts.ts b/scripts/release/promote-artifacts.ts
index 9cfdff2..6d98692 100644
--- a/scripts/release/promote-artifacts.ts
+++ b/scripts/release/promote-artifacts.ts
@@ -35,6 +35,12 @@ export async function promoteArtifacts(opts: ReleaseOpts) {
if (opts.latest) {
await uploadInstallScripts(opts, "latest");
}
+
+ // Upload gigacode install scripts
+ await uploadGigacodeInstallScripts(opts, opts.version);
+ if (opts.latest) {
+ await uploadGigacodeInstallScripts(opts, "latest");
+ }
}
@@ -55,6 +61,23 @@ async function uploadInstallScripts(opts: ReleaseOpts, version: string) {
}
}
+async function uploadGigacodeInstallScripts(opts: ReleaseOpts, version: string) {
+ const installScriptPaths = [
+ path.resolve(opts.root, "scripts/release/static/gigacode-install.sh"),
+ path.resolve(opts.root, "scripts/release/static/gigacode-install.ps1"),
+ ];
+
+ for (const scriptPath of installScriptPaths) {
+ let scriptContent = await fs.readFile(scriptPath, "utf-8");
+ scriptContent = scriptContent.replace(/__VERSION__/g, version);
+
+ const uploadKey = `${PREFIX}/${version}/${scriptPath.split("/").pop() ?? ""}`;
+
+ console.log(`Uploading gigacode install script: ${uploadKey}`);
+ await uploadContentToReleases(scriptContent, uploadKey);
+ }
+}
+
async function copyPath(sourcePrefix: string, targetPrefix: string) {
console.log(`Copying ${sourcePrefix} -> ${targetPrefix}`);
await deleteReleasesPath(targetPrefix);
diff --git a/scripts/release/sdk.ts b/scripts/release/sdk.ts
index 78f3e6a..5248440 100644
--- a/scripts/release/sdk.ts
+++ b/scripts/release/sdk.ts
@@ -12,6 +12,7 @@ const CRATES = [
"universal-agent-schema",
"agent-management",
"sandbox-agent",
+ "gigacode",
] as const;
// NPM CLI packages
@@ -22,15 +23,69 @@ const CLI_PACKAGES = [
"@sandbox-agent/cli-win32-x64",
"@sandbox-agent/cli-darwin-x64",
"@sandbox-agent/cli-darwin-arm64",
+ "@sandbox-agent/gigacode",
+ "@sandbox-agent/gigacode-linux-x64",
+ "@sandbox-agent/gigacode-linux-arm64",
+ "@sandbox-agent/gigacode-win32-x64",
+ "@sandbox-agent/gigacode-darwin-x64",
+ "@sandbox-agent/gigacode-darwin-arm64",
] as const;
// Mapping from npm package name to Rust target and binary extension
-const CLI_PLATFORM_MAP: Record = {
- "@sandbox-agent/cli-linux-x64": { target: "x86_64-unknown-linux-musl", binaryExt: "" },
- "@sandbox-agent/cli-linux-arm64": { target: "aarch64-unknown-linux-musl", binaryExt: "" },
- "@sandbox-agent/cli-win32-x64": { target: "x86_64-pc-windows-gnu", binaryExt: ".exe" },
- "@sandbox-agent/cli-darwin-x64": { target: "x86_64-apple-darwin", binaryExt: "" },
- "@sandbox-agent/cli-darwin-arm64": { target: "aarch64-apple-darwin", binaryExt: "" },
+const CLI_PLATFORM_MAP: Record<
+ string,
+ { target: string; binaryExt: string; binaryName: string }
+> = {
+ "@sandbox-agent/cli-linux-x64": {
+ target: "x86_64-unknown-linux-musl",
+ binaryExt: "",
+ binaryName: "sandbox-agent",
+ },
+ "@sandbox-agent/cli-linux-arm64": {
+ target: "aarch64-unknown-linux-musl",
+ binaryExt: "",
+ binaryName: "sandbox-agent",
+ },
+ "@sandbox-agent/cli-win32-x64": {
+ target: "x86_64-pc-windows-gnu",
+ binaryExt: ".exe",
+ binaryName: "sandbox-agent",
+ },
+ "@sandbox-agent/cli-darwin-x64": {
+ target: "x86_64-apple-darwin",
+ binaryExt: "",
+ binaryName: "sandbox-agent",
+ },
+ "@sandbox-agent/cli-darwin-arm64": {
+ target: "aarch64-apple-darwin",
+ binaryExt: "",
+ binaryName: "sandbox-agent",
+ },
+ "@sandbox-agent/gigacode-linux-x64": {
+ target: "x86_64-unknown-linux-musl",
+ binaryExt: "",
+ binaryName: "gigacode",
+ },
+ "@sandbox-agent/gigacode-linux-arm64": {
+ target: "aarch64-unknown-linux-musl",
+ binaryExt: "",
+ binaryName: "gigacode",
+ },
+ "@sandbox-agent/gigacode-win32-x64": {
+ target: "x86_64-pc-windows-gnu",
+ binaryExt: ".exe",
+ binaryName: "gigacode",
+ },
+ "@sandbox-agent/gigacode-darwin-x64": {
+ target: "x86_64-apple-darwin",
+ binaryExt: "",
+ binaryName: "gigacode",
+ },
+ "@sandbox-agent/gigacode-darwin-arm64": {
+ target: "aarch64-apple-darwin",
+ binaryExt: "",
+ binaryName: "gigacode",
+ },
};
async function npmVersionExists(
@@ -92,7 +147,9 @@ export async function publishCrates(opts: ReleaseOpts) {
console.log("==> Publishing crates to crates.io");
for (const crate of CRATES) {
- const cratePath = join(opts.root, "server/packages", crate);
+ const cratePath = crate === "gigacode"
+ ? join(opts.root, "gigacode")
+ : join(opts.root, "server/packages", crate);
// Read Cargo.toml to get the actual crate name
const cargoTomlPath = join(cratePath, "Cargo.toml");
@@ -246,33 +303,41 @@ export async function publishNpmCli(opts: ReleaseOpts) {
let packagePath: string;
if (packageName === "@sandbox-agent/cli") {
packagePath = join(opts.root, "sdks/cli");
- } else {
+ } else if (packageName === "@sandbox-agent/gigacode") {
+ packagePath = join(opts.root, "sdks/gigacode");
+ } else if (packageName.startsWith("@sandbox-agent/cli-")) {
// Platform-specific packages: @sandbox-agent/cli-linux-x64 -> sdks/cli/platforms/linux-x64
const platform = packageName.replace("@sandbox-agent/cli-", "");
packagePath = join(opts.root, "sdks/cli/platforms", platform);
+ } else if (packageName.startsWith("@sandbox-agent/gigacode-")) {
+ // Platform-specific packages: @sandbox-agent/gigacode-linux-x64 -> sdks/gigacode/platforms/linux-x64
+ const platform = packageName.replace("@sandbox-agent/gigacode-", "");
+ packagePath = join(opts.root, "sdks/gigacode/platforms", platform);
+ } else {
+ throw new Error(`Unknown CLI package: ${packageName}`);
+ }
- // Download binary from R2 for platform-specific packages
- const platformInfo = CLI_PLATFORM_MAP[packageName];
- if (platformInfo) {
- const binDir = join(packagePath, "bin");
- const binaryName = `sandbox-agent${platformInfo.binaryExt}`;
- const localBinaryPath = join(binDir, binaryName);
- const remoteBinaryPath = `${PREFIX}/${sourceCommit}/binaries/sandbox-agent-${platformInfo.target}${platformInfo.binaryExt}`;
+ // Download binary from R2 for platform-specific packages
+ const platformInfo = CLI_PLATFORM_MAP[packageName];
+ if (platformInfo) {
+ const binDir = join(packagePath, "bin");
+ const binaryName = `${platformInfo.binaryName}${platformInfo.binaryExt}`;
+ const localBinaryPath = join(binDir, binaryName);
+ const remoteBinaryPath = `${PREFIX}/${sourceCommit}/binaries/${platformInfo.binaryName}-${platformInfo.target}${platformInfo.binaryExt}`;
- console.log(`==> Downloading binary for ${packageName}`);
- console.log(` From: ${remoteBinaryPath}`);
- console.log(` To: ${localBinaryPath}`);
+ console.log(`==> Downloading binary for ${packageName}`);
+ console.log(` From: ${remoteBinaryPath}`);
+ console.log(` To: ${localBinaryPath}`);
- // Create bin directory
- await fs.mkdir(binDir, { recursive: true });
+ // Create bin directory
+ await fs.mkdir(binDir, { recursive: true });
- // Download binary
- await downloadFromReleases(remoteBinaryPath, localBinaryPath);
+ // Download binary
+ await downloadFromReleases(remoteBinaryPath, localBinaryPath);
- // Make binary executable (not needed on Windows)
- if (!platformInfo.binaryExt) {
- await fs.chmod(localBinaryPath, 0o755);
- }
+ // Make binary executable (not needed on Windows)
+ if (!platformInfo.binaryExt) {
+ await fs.chmod(localBinaryPath, 0o755);
}
}
diff --git a/scripts/release/static/gigacode-install.ps1 b/scripts/release/static/gigacode-install.ps1
new file mode 100644
index 0000000..0b3e6c1
--- /dev/null
+++ b/scripts/release/static/gigacode-install.ps1
@@ -0,0 +1,51 @@
+#!/usr/bin/env pwsh
+
+$ErrorActionPreference = 'Stop'
+
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+
+# Create bin directory for gigacode
+$BinDir = $env:BIN_DIR
+$GigacodeInstall = if ($BinDir) {
+ $BinDir
+} else {
+ "${Home}\.gigacode\bin"
+}
+
+if (!(Test-Path $GigacodeInstall)) {
+ New-Item $GigacodeInstall -ItemType Directory | Out-Null
+}
+
+$GigacodeExe = "$GigacodeInstall\gigacode.exe"
+$Version = '__VERSION__'
+$FileName = 'gigacode-x86_64-pc-windows-gnu.exe'
+
+Write-Host
+Write-Host "> Installing gigacode ${Version}"
+
+# Download binary
+$DownloadUrl = "https://releases.rivet.dev/sandbox-agent/${Version}/binaries/${FileName}"
+Write-Host
+Write-Host "> Downloading ${DownloadUrl}"
+Invoke-WebRequest $DownloadUrl -OutFile $GigacodeExe -UseBasicParsing
+
+# Install to PATH
+Write-Host
+Write-Host "> Installing gigacode"
+$User = [System.EnvironmentVariableTarget]::User
+$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
+if (!(";${Path};".ToLower() -like "*;${GigacodeInstall};*".ToLower())) {
+ [System.Environment]::SetEnvironmentVariable('Path', "${Path};${GigacodeInstall}", $User)
+ $Env:Path += ";${GigacodeInstall}"
+ Write-Host "Please restart your PowerShell session or run the following command to refresh the environment variables:"
+ Write-Host "[System.Environment]::SetEnvironmentVariable('Path', '${Path};${GigacodeInstall}', [System.EnvironmentVariableTarget]::Process)"
+}
+
+Write-Host
+Write-Host "> Checking installation"
+gigacode.exe --version
+
+Write-Host
+Write-Host "gigacode was installed successfully to ${GigacodeExe}."
+Write-Host "Run 'gigacode --help' to get started."
+Write-Host
diff --git a/scripts/release/static/gigacode-install.sh b/scripts/release/static/gigacode-install.sh
new file mode 100644
index 0000000..4c4110c
--- /dev/null
+++ b/scripts/release/static/gigacode-install.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+# shellcheck enable=add-default-case
+# shellcheck enable=avoid-nullary-conditions
+# shellcheck enable=check-unassigned-uppercase
+# shellcheck enable=deprecate-which
+# shellcheck enable=quote-safe-variables
+# shellcheck enable=require-variable-braces
+set -eu
+
+rm -rf /tmp/gigacode_install
+mkdir /tmp/gigacode_install
+cd /tmp/gigacode_install
+
+GIGACODE_VERSION="${GIGACODE_VERSION:-__VERSION__}"
+UNAME="$(uname -s)"
+ARCH="$(uname -m)"
+
+# Find asset suffix
+if [ "$(printf '%s' "$UNAME" | cut -c 1-6)" = "Darwin" ]; then
+ echo
+ echo "> Detected macOS"
+
+ if [ "$ARCH" = "x86_64" ]; then
+ FILE_NAME="gigacode-x86_64-apple-darwin"
+ elif [ "$ARCH" = "arm64" ]; then
+ FILE_NAME="gigacode-aarch64-apple-darwin"
+ else
+ echo "Unknown arch $ARCH" 1>&2
+ exit 1
+ fi
+elif [ "$(printf '%s' "$UNAME" | cut -c 1-5)" = "Linux" ]; then
+ echo
+ echo "> Detected Linux ($(getconf LONG_BIT) bit)"
+
+ FILE_NAME="gigacode-x86_64-unknown-linux-musl"
+else
+ echo "Unable to determine platform" 1>&2
+ exit 1
+fi
+
+# Determine install location
+set +u
+if [ -z "$BIN_DIR" ]; then
+ BIN_DIR="/usr/local/bin"
+fi
+set -u
+INSTALL_PATH="$BIN_DIR/gigacode"
+
+if [ ! -d "$BIN_DIR" ]; then
+ # Find the base parent directory. We're using mkdir -p, which recursively creates directories, so we can't rely on `dirname`.
+ CHECK_DIR="$BIN_DIR"
+ while [ ! -d "$CHECK_DIR" ] && [ "$CHECK_DIR" != "/" ]; do
+ CHECK_DIR=$(dirname "$CHECK_DIR")
+ done
+
+ # Check if the directory is writable
+ if [ ! -w "$CHECK_DIR" ]; then
+ echo
+ echo "> Creating directory $BIN_DIR (requires sudo)"
+ sudo mkdir -p "$BIN_DIR"
+ else
+ echo
+ echo "> Creating directory $BIN_DIR"
+ mkdir -p "$BIN_DIR"
+ fi
+
+fi
+
+# Download binary
+URL="https://releases.rivet.dev/sandbox-agent/${GIGACODE_VERSION}/binaries/${FILE_NAME}"
+echo
+echo "> Downloading $URL"
+curl -fsSL "$URL" -o gigacode
+chmod +x gigacode
+
+# Move binary
+if [ ! -w "$BIN_DIR" ]; then
+ echo
+ echo "> Installing gigacode to $INSTALL_PATH (requires sudo)"
+ sudo mv ./gigacode "$INSTALL_PATH"
+else
+ echo
+ echo "> Installing gigacode to $INSTALL_PATH"
+ mv ./gigacode "$INSTALL_PATH"
+fi
+
+# Check if path may be incorrect
+case ":$PATH:" in
+ *:$BIN_DIR:*) ;;
+ *)
+ echo "WARNING: $BIN_DIR is not in \$PATH"
+ echo "For instructions on how to add it to your PATH, visit:"
+ echo "https://opensource.com/article/17/6/set-path-linux"
+ ;;
+esac
+
+echo
+echo "> Checking installation"
+"$BIN_DIR/gigacode" --version
+
+echo
+echo "gigacode was installed successfully."
+echo "Run 'gigacode --help' to get started."
diff --git a/scripts/release/update_version.ts b/scripts/release/update_version.ts
index e8c4afc..c7c1c60 100644
--- a/scripts/release/update_version.ts
+++ b/scripts/release/update_version.ts
@@ -32,11 +32,21 @@ export async function updateVersion(opts: ReleaseOpts) {
find: /"version": ".*"/,
replace: `"version": "${opts.version}"`,
},
+ {
+ path: "sdks/gigacode/package.json",
+ find: /"version": ".*"/,
+ replace: `"version": "${opts.version}"`,
+ },
{
path: "sdks/cli/platforms/*/package.json",
find: /"version": ".*"/,
replace: `"version": "${opts.version}"`,
},
+ {
+ path: "sdks/gigacode/platforms/*/package.json",
+ find: /"version": ".*"/,
+ replace: `"version": "${opts.version}"`,
+ },
];
// Update internal crate versions in workspace dependencies
diff --git a/sdks/cli-shared/package.json b/sdks/cli-shared/package.json
index 0c041d1..d342db9 100644
--- a/sdks/cli-shared/package.json
+++ b/sdks/cli-shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-shared",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "Shared helpers for sandbox-agent CLI and SDK",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/cli-shared/src/index.ts b/sdks/cli-shared/src/index.ts
index da2773f..c80125e 100644
--- a/sdks/cli-shared/src/index.ts
+++ b/sdks/cli-shared/src/index.ts
@@ -8,6 +8,7 @@ export type NonExecutableBinaryMessageOptions = {
trustPackages: string;
bunInstallBlocks: InstallCommandBlock[];
genericInstallCommands?: string[];
+ binaryName?: string;
};
export type FsSubset = {
@@ -63,10 +64,16 @@ export function assertExecutable(binPath: string, fs: FsSubset): boolean {
export function formatNonExecutableBinaryMessage(
options: NonExecutableBinaryMessageOptions,
): string {
- const { binPath, trustPackages, bunInstallBlocks, genericInstallCommands } =
- options;
+ const {
+ binPath,
+ trustPackages,
+ bunInstallBlocks,
+ genericInstallCommands,
+ binaryName,
+ } = options;
- const lines = [`sandbox-agent binary is not executable: ${binPath}`];
+ const label = binaryName ?? "sandbox-agent";
+ const lines = [`${label} binary is not executable: ${binPath}`];
if (isBunRuntime()) {
lines.push(
diff --git a/sdks/cli/package.json b/sdks/cli/package.json
index fde9b8b..c617a76 100644
--- a/sdks/cli/package.json
+++ b/sdks/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "CLI for sandbox-agent - run AI coding agents in sandboxes",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/cli/platforms/darwin-arm64/package.json b/sdks/cli/platforms/darwin-arm64/package.json
index cfff424..9c07b51 100644
--- a/sdks/cli/platforms/darwin-arm64/package.json
+++ b/sdks/cli/platforms/darwin-arm64/package.json
@@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-darwin-arm64",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "sandbox-agent CLI binary for macOS ARM64",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/cli/platforms/darwin-x64/package.json b/sdks/cli/platforms/darwin-x64/package.json
index 8fa6330..dafe8e9 100644
--- a/sdks/cli/platforms/darwin-x64/package.json
+++ b/sdks/cli/platforms/darwin-x64/package.json
@@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-darwin-x64",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "sandbox-agent CLI binary for macOS x64",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/cli/platforms/linux-arm64/package.json b/sdks/cli/platforms/linux-arm64/package.json
index 41db961..58cad6a 100644
--- a/sdks/cli/platforms/linux-arm64/package.json
+++ b/sdks/cli/platforms/linux-arm64/package.json
@@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-linux-arm64",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "sandbox-agent CLI binary for Linux arm64",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/cli/platforms/linux-x64/package.json b/sdks/cli/platforms/linux-x64/package.json
index 28e3b13..1f6c35b 100644
--- a/sdks/cli/platforms/linux-x64/package.json
+++ b/sdks/cli/platforms/linux-x64/package.json
@@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-linux-x64",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "sandbox-agent CLI binary for Linux x64",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/cli/platforms/win32-x64/package.json b/sdks/cli/platforms/win32-x64/package.json
index e1f3001..726e4aa 100644
--- a/sdks/cli/platforms/win32-x64/package.json
+++ b/sdks/cli/platforms/win32-x64/package.json
@@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-win32-x64",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "sandbox-agent CLI binary for Windows x64",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/gigacode/bin/gigacode b/sdks/gigacode/bin/gigacode
new file mode 100644
index 0000000..0fd87cc
--- /dev/null
+++ b/sdks/gigacode/bin/gigacode
@@ -0,0 +1,66 @@
+#!/usr/bin/env node
+const { execFileSync } = require("child_process");
+const {
+ assertExecutable,
+ formatNonExecutableBinaryMessage,
+} = require("@sandbox-agent/cli-shared");
+const fs = require("fs");
+const path = require("path");
+
+const TRUST_PACKAGES =
+ "@sandbox-agent/gigacode-linux-x64 @sandbox-agent/gigacode-linux-arm64 @sandbox-agent/gigacode-darwin-arm64 @sandbox-agent/gigacode-darwin-x64 @sandbox-agent/gigacode-win32-x64";
+
+function formatHint(binPath) {
+ return formatNonExecutableBinaryMessage({
+ binPath,
+ binaryName: "gigacode",
+ trustPackages: TRUST_PACKAGES,
+ bunInstallBlocks: [
+ {
+ label: "Project install",
+ commands: [
+ `bun pm trust ${TRUST_PACKAGES}`,
+ "bun add @sandbox-agent/gigacode",
+ ],
+ },
+ {
+ label: "Global install",
+ commands: [
+ `bun pm -g trust ${TRUST_PACKAGES}`,
+ "bun add -g @sandbox-agent/gigacode",
+ ],
+ },
+ ],
+ });
+}
+
+const PLATFORMS = {
+ "darwin-arm64": "@sandbox-agent/gigacode-darwin-arm64",
+ "darwin-x64": "@sandbox-agent/gigacode-darwin-x64",
+ "linux-x64": "@sandbox-agent/gigacode-linux-x64",
+ "linux-arm64": "@sandbox-agent/gigacode-linux-arm64",
+ "win32-x64": "@sandbox-agent/gigacode-win32-x64",
+};
+
+const key = `${process.platform}-${process.arch}`;
+const pkg = PLATFORMS[key];
+if (!pkg) {
+ console.error(`Unsupported platform: ${key}`);
+ process.exit(1);
+}
+
+try {
+ const pkgPath = require.resolve(`${pkg}/package.json`);
+ const bin = process.platform === "win32" ? "gigacode.exe" : "gigacode";
+ const binPath = path.join(path.dirname(pkgPath), "bin", bin);
+
+ if (!assertExecutable(binPath, fs)) {
+ console.error(formatHint(binPath));
+ process.exit(1);
+ }
+
+ execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
+} catch (e) {
+ if (e.status !== undefined) process.exit(e.status);
+ throw e;
+}
diff --git a/sdks/gigacode/package.json b/sdks/gigacode/package.json
new file mode 100644
index 0000000..9f4b0a7
--- /dev/null
+++ b/sdks/gigacode/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "@sandbox-agent/gigacode",
+ "version": "0.1.7",
+ "description": "Gigacode CLI (sandbox-agent with OpenCode attach by default)",
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/rivet-dev/sandbox-agent"
+ },
+ "bin": {
+ "gigacode": "bin/gigacode"
+ },
+ "scripts": {
+ "test": "vitest run"
+ },
+ "dependencies": {
+ "@sandbox-agent/cli-shared": "workspace:*"
+ },
+ "devDependencies": {
+ "vitest": "^3.0.0"
+ },
+ "optionalDependencies": {
+ "@sandbox-agent/gigacode-linux-x64": "workspace:*",
+ "@sandbox-agent/gigacode-linux-arm64": "workspace:*",
+ "@sandbox-agent/gigacode-darwin-arm64": "workspace:*",
+ "@sandbox-agent/gigacode-darwin-x64": "workspace:*",
+ "@sandbox-agent/gigacode-win32-x64": "workspace:*"
+ },
+ "files": [
+ "bin"
+ ]
+}
diff --git a/sdks/gigacode/platforms/darwin-arm64/package.json b/sdks/gigacode/platforms/darwin-arm64/package.json
new file mode 100644
index 0000000..49ec4e9
--- /dev/null
+++ b/sdks/gigacode/platforms/darwin-arm64/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@sandbox-agent/gigacode-darwin-arm64",
+ "version": "0.1.7",
+ "description": "gigacode CLI binary for macOS arm64",
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/rivet-dev/sandbox-agent"
+ },
+ "os": [
+ "darwin"
+ ],
+ "cpu": [
+ "arm64"
+ ],
+ "scripts": {
+ "postinstall": "chmod +x bin/gigacode || true"
+ },
+ "files": [
+ "bin"
+ ]
+}
diff --git a/sdks/gigacode/platforms/darwin-x64/package.json b/sdks/gigacode/platforms/darwin-x64/package.json
new file mode 100644
index 0000000..95104af
--- /dev/null
+++ b/sdks/gigacode/platforms/darwin-x64/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@sandbox-agent/gigacode-darwin-x64",
+ "version": "0.1.7",
+ "description": "gigacode CLI binary for macOS x64",
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/rivet-dev/sandbox-agent"
+ },
+ "os": [
+ "darwin"
+ ],
+ "cpu": [
+ "x64"
+ ],
+ "scripts": {
+ "postinstall": "chmod +x bin/gigacode || true"
+ },
+ "files": [
+ "bin"
+ ]
+}
diff --git a/sdks/gigacode/platforms/linux-arm64/package.json b/sdks/gigacode/platforms/linux-arm64/package.json
new file mode 100644
index 0000000..29d9acb
--- /dev/null
+++ b/sdks/gigacode/platforms/linux-arm64/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@sandbox-agent/gigacode-linux-arm64",
+ "version": "0.1.7",
+ "description": "gigacode CLI binary for Linux arm64",
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/rivet-dev/sandbox-agent"
+ },
+ "os": [
+ "linux"
+ ],
+ "cpu": [
+ "arm64"
+ ],
+ "scripts": {
+ "postinstall": "chmod +x bin/gigacode || true"
+ },
+ "files": [
+ "bin"
+ ]
+}
diff --git a/sdks/gigacode/platforms/linux-x64/package.json b/sdks/gigacode/platforms/linux-x64/package.json
new file mode 100644
index 0000000..b3b3298
--- /dev/null
+++ b/sdks/gigacode/platforms/linux-x64/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@sandbox-agent/gigacode-linux-x64",
+ "version": "0.1.7",
+ "description": "gigacode CLI binary for Linux x64",
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/rivet-dev/sandbox-agent"
+ },
+ "os": [
+ "linux"
+ ],
+ "cpu": [
+ "x64"
+ ],
+ "scripts": {
+ "postinstall": "chmod +x bin/gigacode || true"
+ },
+ "files": [
+ "bin"
+ ]
+}
diff --git a/sdks/gigacode/platforms/win32-x64/package.json b/sdks/gigacode/platforms/win32-x64/package.json
new file mode 100644
index 0000000..cec1c0c
--- /dev/null
+++ b/sdks/gigacode/platforms/win32-x64/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "@sandbox-agent/gigacode-win32-x64",
+ "version": "0.1.7",
+ "description": "gigacode CLI binary for Windows x64",
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/rivet-dev/sandbox-agent"
+ },
+ "os": [
+ "win32"
+ ],
+ "cpu": [
+ "x64"
+ ],
+ "files": [
+ "bin"
+ ]
+}
diff --git a/sdks/typescript/package.json b/sdks/typescript/package.json
index 8b135bf..fe9845c 100644
--- a/sdks/typescript/package.json
+++ b/sdks/typescript/package.json
@@ -1,6 +1,6 @@
{
"name": "sandbox-agent",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "Universal API for automatic coding agents in sandboxes. Supprots Claude Code, Codex, OpenCode, and Amp.",
"license": "Apache-2.0",
"repository": {
diff --git a/sdks/typescript/src/client.ts b/sdks/typescript/src/client.ts
index 7f9ad95..f290406 100644
--- a/sdks/typescript/src/client.ts
+++ b/sdks/typescript/src/client.ts
@@ -2,6 +2,7 @@ import type { SandboxAgentSpawnHandle, SandboxAgentSpawnOptions } from "./spawn.
import type {
AgentInstallRequest,
AgentListResponse,
+ AgentModelsResponse,
AgentModesResponse,
CreateSessionRequest,
CreateSessionResponse,
@@ -113,6 +114,10 @@ export class SandboxAgent {
return this.requestJson("GET", `${API_PREFIX}/agents/${encodeURIComponent(agent)}/modes`);
}
+ async getAgentModels(agent: string): Promise {
+ return this.requestJson("GET", `${API_PREFIX}/agents/${encodeURIComponent(agent)}/models`);
+ }
+
async createSession(sessionId: string, request: CreateSessionRequest): Promise {
return this.requestJson("POST", `${API_PREFIX}/sessions/${encodeURIComponent(sessionId)}`, {
body: request,
diff --git a/sdks/typescript/src/generated/openapi.ts b/sdks/typescript/src/generated/openapi.ts
index 52816ad..1e3239e 100644
--- a/sdks/typescript/src/generated/openapi.ts
+++ b/sdks/typescript/src/generated/openapi.ts
@@ -11,6 +11,9 @@ export interface paths {
"/v1/agents/{agent}/install": {
post: operations["install_agent"];
};
+ "/v1/agents/{agent}/models": {
+ get: operations["get_agent_models"];
+ };
"/v1/agents/{agent}/modes": {
get: operations["get_agent_modes"];
};
@@ -73,6 +76,7 @@ export interface components {
textMessages: boolean;
toolCalls: boolean;
toolResults: boolean;
+ variants: boolean;
};
AgentError: {
agent?: string | null;
@@ -100,6 +104,16 @@ export interface components {
id: string;
name: string;
};
+ AgentModelInfo: {
+ defaultVariant?: string | null;
+ id: string;
+ name?: string | null;
+ variants?: string[] | null;
+ };
+ AgentModelsResponse: {
+ defaultModel?: string | null;
+ models: components["schemas"]["AgentModelInfo"][];
+ };
AgentModesResponse: {
modes: components["schemas"]["AgentModeInfo"][];
};
@@ -383,6 +397,26 @@ export interface operations {
};
};
};
+ get_agent_models: {
+ parameters: {
+ path: {
+ /** @description Agent id */
+ agent: string;
+ };
+ };
+ responses: {
+ 200: {
+ content: {
+ "application/json": components["schemas"]["AgentModelsResponse"];
+ };
+ };
+ 400: {
+ content: {
+ "application/json": components["schemas"]["ProblemDetails"];
+ };
+ };
+ };
+ };
get_agent_modes: {
parameters: {
path: {
diff --git a/sdks/typescript/src/index.ts b/sdks/typescript/src/index.ts
index db8b4eb..1d5d349 100644
--- a/sdks/typescript/src/index.ts
+++ b/sdks/typescript/src/index.ts
@@ -10,6 +10,8 @@ export type {
AgentInfo,
AgentInstallRequest,
AgentListResponse,
+ AgentModelInfo,
+ AgentModelsResponse,
AgentModeInfo,
AgentModesResponse,
AgentUnparsedData,
diff --git a/sdks/typescript/src/types.ts b/sdks/typescript/src/types.ts
index e0c43df..350df6b 100644
--- a/sdks/typescript/src/types.ts
+++ b/sdks/typescript/src/types.ts
@@ -6,6 +6,8 @@ export type AgentCapabilities = S["AgentCapabilities"];
export type AgentInfo = S["AgentInfo"];
export type AgentInstallRequest = S["AgentInstallRequest"];
export type AgentListResponse = S["AgentListResponse"];
+export type AgentModelInfo = S["AgentModelInfo"];
+export type AgentModelsResponse = S["AgentModelsResponse"];
export type AgentModeInfo = S["AgentModeInfo"];
export type AgentModesResponse = S["AgentModesResponse"];
export type AgentUnparsedData = S["AgentUnparsedData"];
diff --git a/server/packages/sandbox-agent/Cargo.toml b/server/packages/sandbox-agent/Cargo.toml
index 703c87c..850f4b6 100644
--- a/server/packages/sandbox-agent/Cargo.toml
+++ b/server/packages/sandbox-agent/Cargo.toml
@@ -42,7 +42,7 @@ tempfile = { workspace = true, optional = true }
libc = "0.2"
[target.'cfg(windows)'.dependencies]
-windows = { version = "0.52", features = ["Win32_Foundation", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Console"] }
+windows = { version = "0.52", features = ["Win32_Foundation", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_Threading"] }
[dev-dependencies]
http-body-util.workspace = true
diff --git a/server/packages/sandbox-agent/build.rs b/server/packages/sandbox-agent/build.rs
index 170c05a..515a20c 100644
--- a/server/packages/sandbox-agent/build.rs
+++ b/server/packages/sandbox-agent/build.rs
@@ -19,9 +19,22 @@ fn main() {
println!("cargo:rerun-if-env-changed=SANDBOX_AGENT_VERSION");
println!("cargo:rerun-if-changed={}", dist_dir.display());
+ // Rebuild when the git HEAD changes so BUILD_ID stays current.
+ let git_head = manifest_dir.join(".git/HEAD");
+ if git_head.exists() {
+ println!("cargo:rerun-if-changed={}", git_head.display());
+ } else {
+ // In a workspace the .git dir lives at the repo root.
+ let root_git_head = root_dir.join(".git/HEAD");
+ if root_git_head.exists() {
+ println!("cargo:rerun-if-changed={}", root_git_head.display());
+ }
+ }
+
// Generate version constant from environment variable or fallback to Cargo.toml version
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR"));
generate_version(&out_dir);
+ generate_build_id(&out_dir);
let skip = env::var("SANDBOX_AGENT_SKIP_INSPECTOR").is_ok();
let out_file = out_dir.join("inspector_assets.rs");
@@ -81,3 +94,33 @@ fn generate_version(out_dir: &Path) {
fs::write(&out_file, contents).expect("write version.rs");
}
+
+fn generate_build_id(out_dir: &Path) {
+ use std::process::Command;
+
+ let build_id = Command::new("git")
+ .args(["rev-parse", "--short", "HEAD"])
+ .output()
+ .ok()
+ .filter(|o| o.status.success())
+ .and_then(|o| String::from_utf8(o.stdout).ok())
+ .map(|s| s.trim().to_string())
+ .unwrap_or_else(|| {
+ // Fallback: use the package version + compile-time timestamp
+ let version = env::var("CARGO_PKG_VERSION").unwrap_or_default();
+ let timestamp = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map(|d| d.as_secs().to_string())
+ .unwrap_or_default();
+ format!("{version}-{timestamp}")
+ });
+
+ let out_file = out_dir.join("build_id.rs");
+ let contents = format!(
+ "/// Unique identifier for this build (git short hash or version-timestamp fallback).\n\
+ pub const BUILD_ID: &str = \"{}\";\n",
+ build_id
+ );
+
+ fs::write(&out_file, contents).expect("write build_id.rs");
+}
diff --git a/server/packages/sandbox-agent/src/cli.rs b/server/packages/sandbox-agent/src/cli.rs
new file mode 100644
index 0000000..a838a65
--- /dev/null
+++ b/server/packages/sandbox-agent/src/cli.rs
@@ -0,0 +1,1369 @@
+use std::collections::HashMap;
+use std::io::Write;
+use std::path::PathBuf;
+use std::process::{Command as ProcessCommand, Stdio};
+use std::sync::Arc;
+use std::time::Duration;
+
+use clap::{Args, Parser, Subcommand};
+
+// Include the generated version constant
+mod build_version {
+ include!(concat!(env!("OUT_DIR"), "/version.rs"));
+}
+use crate::router::{build_router_with_state, shutdown_servers};
+use crate::router::{
+ AgentInstallRequest, AppState, AuthConfig, BrandingMode, CreateSessionRequest, MessageRequest,
+ PermissionReply, PermissionReplyRequest, QuestionReplyRequest,
+};
+use crate::router::{
+ AgentListResponse, AgentModelsResponse, AgentModesResponse, CreateSessionResponse,
+ EventsResponse, SessionListResponse,
+};
+use crate::server_logs::ServerLogs;
+use crate::telemetry;
+use crate::ui;
+use reqwest::blocking::Client as HttpClient;
+use reqwest::Method;
+use sandbox_agent_agent_management::agents::{AgentId, AgentManager, InstallOptions};
+use sandbox_agent_agent_management::credentials::{
+ extract_all_credentials, AuthType, CredentialExtractionOptions, ExtractedCredentials,
+ ProviderCredentials,
+};
+use serde::Serialize;
+use serde_json::{json, Value};
+use thiserror::Error;
+use tower_http::cors::{Any, CorsLayer};
+use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
+
+const API_PREFIX: &str = "/v1";
+const DEFAULT_HOST: &str = "127.0.0.1";
+const DEFAULT_PORT: u16 = 2468;
+const LOGS_RETENTION: Duration = Duration::from_secs(7 * 24 * 60 * 60);
+
+#[derive(Parser, Debug)]
+#[command(name = "sandbox-agent", bin_name = "sandbox-agent")]
+#[command(about = "https://sandboxagent.dev", version = build_version::VERSION)]
+#[command(arg_required_else_help = true)]
+pub struct SandboxAgentCli {
+ #[command(subcommand)]
+ command: Command,
+
+ #[arg(long, short = 't', global = true)]
+ token: Option,
+
+ #[arg(long, short = 'n', global = true)]
+ no_token: bool,
+}
+
+#[derive(Parser, Debug)]
+#[command(name = "gigacode", bin_name = "gigacode")]
+#[command(about = "https://sandboxagent.dev", version = build_version::VERSION)]
+pub struct GigacodeCli {
+ #[command(subcommand)]
+ pub command: Option,
+
+ #[arg(long, short = 't', global = true)]
+ pub token: Option,
+
+ #[arg(long, short = 'n', global = true)]
+ pub no_token: bool,
+}
+
+#[derive(Subcommand, Debug)]
+pub enum Command {
+ /// Run the sandbox agent HTTP server.
+ Server(ServerArgs),
+ /// Call the HTTP API without writing client code.
+ Api(ApiArgs),
+ /// EXPERIMENTAL: Start a sandbox-agent server and attach an OpenCode session.
+ Opencode(OpencodeArgs),
+ /// Manage the sandbox-agent background daemon.
+ Daemon(DaemonArgs),
+ /// Install or reinstall an agent without running the server.
+ InstallAgent(InstallAgentArgs),
+ /// Inspect locally discovered credentials.
+ Credentials(CredentialsArgs),
+}
+
+#[derive(Args, Debug)]
+pub struct ServerArgs {
+ #[arg(long, short = 'H', default_value = DEFAULT_HOST)]
+ host: String,
+
+ #[arg(long, short = 'p', default_value_t = DEFAULT_PORT)]
+ port: u16,
+
+ #[arg(long = "cors-allow-origin", short = 'O')]
+ cors_allow_origin: Vec,
+
+ #[arg(long = "cors-allow-method", short = 'M')]
+ cors_allow_method: Vec,
+
+ #[arg(long = "cors-allow-header", short = 'A')]
+ cors_allow_header: Vec,
+
+ #[arg(long = "cors-allow-credentials", short = 'C')]
+ cors_allow_credentials: bool,
+
+ #[arg(long = "no-telemetry")]
+ no_telemetry: bool,
+}
+
+#[derive(Args, Debug)]
+pub struct ApiArgs {
+ #[command(subcommand)]
+ command: ApiCommand,
+}
+
+#[derive(Args, Debug)]
+pub struct OpencodeArgs {
+ #[arg(long, short = 'H', default_value = DEFAULT_HOST)]
+ host: String,
+
+ #[arg(long, short = 'p', default_value_t = DEFAULT_PORT)]
+ port: u16,
+
+ #[arg(long)]
+ session_title: Option,
+
+ #[arg(long)]
+ opencode_bin: Option,
+}
+
+impl Default for OpencodeArgs {
+ fn default() -> Self {
+ Self {
+ host: DEFAULT_HOST.to_string(),
+ port: DEFAULT_PORT,
+ session_title: None,
+ opencode_bin: None,
+ }
+ }
+}
+
+#[derive(Args, Debug)]
+pub struct CredentialsArgs {
+ #[command(subcommand)]
+ command: CredentialsCommand,
+}
+
+#[derive(Args, Debug)]
+pub struct DaemonArgs {
+ #[command(subcommand)]
+ command: DaemonCommand,
+}
+
+#[derive(Subcommand, Debug)]
+pub enum DaemonCommand {
+ /// Start the daemon in the background.
+ Start(DaemonStartArgs),
+ /// Stop a running daemon.
+ Stop(DaemonStopArgs),
+ /// Show daemon status.
+ Status(DaemonStatusArgs),
+}
+
+#[derive(Args, Debug)]
+pub struct DaemonStartArgs {
+ #[arg(long, short = 'H', default_value = DEFAULT_HOST)]
+ host: String,
+
+ #[arg(long, short = 'p', default_value_t = DEFAULT_PORT)]
+ port: u16,
+}
+
+#[derive(Args, Debug)]
+pub struct DaemonStopArgs {
+ #[arg(long, short = 'H', default_value = DEFAULT_HOST)]
+ host: String,
+
+ #[arg(long, short = 'p', default_value_t = DEFAULT_PORT)]
+ port: u16,
+}
+
+#[derive(Args, Debug)]
+pub struct DaemonStatusArgs {
+ #[arg(long, short = 'H', default_value = DEFAULT_HOST)]
+ host: String,
+
+ #[arg(long, short = 'p', default_value_t = DEFAULT_PORT)]
+ port: u16,
+}
+
+#[derive(Subcommand, Debug)]
+pub enum ApiCommand {
+ /// Manage installed agents and their modes.
+ Agents(AgentsArgs),
+ /// Create sessions and interact with session events.
+ Sessions(SessionsArgs),
+}
+
+#[derive(Subcommand, Debug)]
+pub enum CredentialsCommand {
+ /// Extract credentials using local discovery rules.
+ Extract(CredentialsExtractArgs),
+ /// Output credentials as environment variable assignments.
+ #[command(name = "extract-env")]
+ ExtractEnv(CredentialsExtractEnvArgs),
+}
+
+#[derive(Args, Debug)]
+pub struct AgentsArgs {
+ #[command(subcommand)]
+ command: AgentsCommand,
+}
+
+#[derive(Args, Debug)]
+pub struct SessionsArgs {
+ #[command(subcommand)]
+ command: SessionsCommand,
+}
+
+#[derive(Subcommand, Debug)]
+pub enum AgentsCommand {
+ /// List all agents and install status.
+ List(ClientArgs),
+ /// Install or reinstall an agent.
+ Install(ApiInstallAgentArgs),
+ /// Show available modes for an agent.
+ Modes(AgentModesArgs),
+ /// Show available models for an agent.
+ Models(AgentModelsArgs),
+}
+
+#[derive(Subcommand, Debug)]
+pub enum SessionsCommand {
+ /// List active sessions.
+ List(ClientArgs),
+ /// Create a new session for an agent.
+ Create(CreateSessionArgs),
+ #[command(name = "send-message")]
+ /// Send a message to an existing session.
+ SendMessage(SessionMessageArgs),
+ #[command(name = "send-message-stream")]
+ /// Send a message and stream the response for one turn.
+ SendMessageStream(SessionMessageStreamArgs),
+ #[command(name = "terminate")]
+ /// Terminate a session.
+ Terminate(SessionTerminateArgs),
+ #[command(name = "get-messages")]
+ /// Alias for events; returns session events.
+ GetMessages(SessionEventsArgs),
+ #[command(name = "events")]
+ /// Fetch session events with offset/limit.
+ Events(SessionEventsArgs),
+ #[command(name = "events-sse")]
+ /// Stream session events over SSE.
+ EventsSse(SessionEventsSseArgs),
+ #[command(name = "reply-question")]
+ /// Reply to a question event.
+ ReplyQuestion(QuestionReplyArgs),
+ #[command(name = "reject-question")]
+ /// Reject a question event.
+ RejectQuestion(QuestionRejectArgs),
+ #[command(name = "reply-permission")]
+ /// Reply to a permission request.
+ ReplyPermission(PermissionReplyArgs),
+}
+
+#[derive(Args, Debug, Clone)]
+pub struct ClientArgs {
+ #[arg(long, short = 'e')]
+ endpoint: Option,
+}
+
+#[derive(Args, Debug)]
+pub struct ApiInstallAgentArgs {
+ agent: String,
+ #[arg(long, short = 'r')]
+ reinstall: bool,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct InstallAgentArgs {
+ agent: String,
+ #[arg(long, short = 'r')]
+ reinstall: bool,
+}
+
+#[derive(Args, Debug)]
+pub struct AgentModesArgs {
+ agent: String,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct AgentModelsArgs {
+ agent: String,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct CreateSessionArgs {
+ session_id: String,
+ #[arg(long, short = 'a')]
+ agent: String,
+ #[arg(long, short = 'g')]
+ agent_mode: Option,
+ #[arg(long, short = 'p')]
+ permission_mode: Option,
+ #[arg(long, short = 'm')]
+ model: Option,
+ #[arg(long, short = 'v')]
+ variant: Option,
+ #[arg(long, short = 'A')]
+ agent_version: Option,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct SessionMessageArgs {
+ session_id: String,
+ #[arg(long, short = 'm')]
+ message: String,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct SessionMessageStreamArgs {
+ session_id: String,
+ #[arg(long, short = 'm')]
+ message: String,
+ #[arg(long)]
+ include_raw: bool,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct SessionEventsArgs {
+ session_id: String,
+ #[arg(long, short = 'o')]
+ offset: Option,
+ #[arg(long, short = 'l')]
+ limit: Option,
+ #[arg(long)]
+ include_raw: bool,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct SessionEventsSseArgs {
+ session_id: String,
+ #[arg(long, short = 'o')]
+ offset: Option,
+ #[arg(long)]
+ include_raw: bool,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct SessionTerminateArgs {
+ session_id: String,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct QuestionReplyArgs {
+ session_id: String,
+ question_id: String,
+ #[arg(long, short = 'a')]
+ answers: String,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct QuestionRejectArgs {
+ session_id: String,
+ question_id: String,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct PermissionReplyArgs {
+ session_id: String,
+ permission_id: String,
+ #[arg(long, short = 'r')]
+ reply: PermissionReply,
+ #[command(flatten)]
+ client: ClientArgs,
+}
+
+#[derive(Args, Debug)]
+pub struct CredentialsExtractArgs {
+ #[arg(long, short = 'a', value_enum)]
+ agent: Option,
+ #[arg(long, short = 'p')]
+ provider: Option,
+ #[arg(long, short = 'd')]
+ home_dir: Option,
+ #[arg(long)]
+ no_oauth: bool,
+ #[arg(long, short = 'r')]
+ reveal: bool,
+}
+
+#[derive(Args, Debug)]
+pub struct CredentialsExtractEnvArgs {
+ /// Prefix each line with "export " for shell sourcing.
+ #[arg(long, short = 'e')]
+ export: bool,
+ #[arg(long, short = 'd')]
+ home_dir: Option,
+ #[arg(long)]
+ no_oauth: bool,
+}
+
+#[derive(Debug, Error)]
+pub enum CliError {
+ #[error("invalid cors origin: {0}")]
+ InvalidCorsOrigin(String),
+ #[error("invalid cors method: {0}")]
+ InvalidCorsMethod(String),
+ #[error("invalid cors header: {0}")]
+ InvalidCorsHeader(String),
+ #[error("http error: {0}")]
+ Http(#[from] reqwest::Error),
+ #[error("io error: {0}")]
+ Io(#[from] std::io::Error),
+ #[error("json error: {0}")]
+ Json(#[from] serde_json::Error),
+ #[error("server error: {0}")]
+ Server(String),
+ #[error("unexpected http status: {0}")]
+ HttpStatus(reqwest::StatusCode),
+}
+
+pub struct CliConfig {
+ pub token: Option,
+ pub no_token: bool,
+ pub gigacode: bool,
+}
+
+pub fn run_sandbox_agent() -> Result<(), CliError> {
+ let cli = SandboxAgentCli::parse();
+ let SandboxAgentCli {
+ command,
+ token,
+ no_token,
+ } = cli;
+ let config = CliConfig {
+ token,
+ no_token,
+ gigacode: false,
+ };
+ if let Err(err) = init_logging(&command) {
+ eprintln!("failed to init logging: {err}");
+ return Err(err);
+ }
+ run_command(&command, &config)
+}
+
+pub fn init_logging(command: &Command) -> Result<(), CliError> {
+ if matches!(command, Command::Server(_)) {
+ maybe_redirect_server_logs();
+ }
+
+ let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
+ tracing_subscriber::registry()
+ .with(filter)
+ .with(
+ tracing_logfmt::builder()
+ .layer()
+ .with_writer(std::io::stderr),
+ )
+ .init();
+ Ok(())
+}
+
+pub fn run_command(command: &Command, cli: &CliConfig) -> Result<(), CliError> {
+ match command {
+ Command::Server(args) => run_server(cli, args),
+ Command::Api(subcommand) => run_api(&subcommand.command, cli),
+ Command::Opencode(args) => run_opencode(cli, args),
+ Command::Daemon(subcommand) => run_daemon(&subcommand.command, cli),
+ Command::InstallAgent(args) => install_agent_local(args),
+ Command::Credentials(subcommand) => run_credentials(&subcommand.command),
+ }
+}
+
+fn run_server(cli: &CliConfig, server: &ServerArgs) -> Result<(), CliError> {
+ let auth = if let Some(token) = cli.token.clone() {
+ AuthConfig::with_token(token)
+ } else {
+ AuthConfig::disabled()
+ };
+
+ let branding = if cli.gigacode {
+ BrandingMode::Gigacode
+ } else {
+ BrandingMode::SandboxAgent
+ };
+ let agent_manager = AgentManager::new(default_install_dir())
+ .map_err(|err| CliError::Server(err.to_string()))?;
+ let state = Arc::new(AppState::with_branding(auth, agent_manager, branding));
+ let (mut router, state) = build_router_with_state(state);
+
+ let cors = build_cors_layer(server)?;
+ router = router.layer(cors);
+
+ let addr = format!("{}:{}", server.host, server.port);
+ let display_host = match server.host.as_str() {
+ "0.0.0.0" | "::" => "localhost",
+ other => other,
+ };
+ let inspector_url = format!("http://{}:{}/ui", display_host, server.port);
+ let runtime = tokio::runtime::Builder::new_multi_thread()
+ .enable_all()
+ .build()
+ .map_err(|err| CliError::Server(err.to_string()))?;
+
+ let telemetry_enabled = telemetry::telemetry_enabled(server.no_telemetry);
+
+ runtime.block_on(async move {
+ if telemetry_enabled {
+ telemetry::log_enabled_message();
+ telemetry::spawn_telemetry_task();
+ }
+ let listener = tokio::net::TcpListener::bind(&addr).await?;
+ tracing::info!(addr = %addr, "server listening");
+ if ui::is_enabled() {
+ tracing::info!(url = %inspector_url, "inspector ui available");
+ } else {
+ tracing::info!("inspector ui not embedded; set SANDBOX_AGENT_SKIP_INSPECTOR=1 to skip embedding during builds");
+ }
+ let shutdown_state = state.clone();
+ axum::serve(listener, router)
+ .with_graceful_shutdown(async move {
+ let _ = tokio::signal::ctrl_c().await;
+ shutdown_servers(&shutdown_state).await;
+ })
+ .await
+ .map_err(|err| CliError::Server(err.to_string()))
+ })
+}
+
+fn default_install_dir() -> PathBuf {
+ dirs::data_dir()
+ .map(|dir| dir.join("sandbox-agent").join("bin"))
+ .unwrap_or_else(|| PathBuf::from(".").join(".sandbox-agent").join("bin"))
+}
+
+fn default_server_log_dir() -> PathBuf {
+ if let Ok(dir) = std::env::var("SANDBOX_AGENT_LOG_DIR") {
+ return PathBuf::from(dir);
+ }
+ dirs::data_dir()
+ .map(|dir| dir.join("sandbox-agent").join("logs"))
+ .unwrap_or_else(|| PathBuf::from(".").join(".sandbox-agent").join("logs"))
+}
+
+fn maybe_redirect_server_logs() {
+ if std::env::var("SANDBOX_AGENT_LOG_STDOUT").is_ok() {
+ return;
+ }
+
+ let log_dir = default_server_log_dir();
+ if let Err(err) = ServerLogs::new(log_dir, LOGS_RETENTION).start_sync() {
+ eprintln!("failed to redirect logs: {err}");
+ }
+}
+
+fn run_api(command: &ApiCommand, cli: &CliConfig) -> Result<(), CliError> {
+ match command {
+ ApiCommand::Agents(subcommand) => run_agents(&subcommand.command, cli),
+ ApiCommand::Sessions(subcommand) => run_sessions(&subcommand.command, cli),
+ }
+}
+
+fn run_opencode(cli: &CliConfig, args: &OpencodeArgs) -> Result<(), CliError> {
+ let name = if cli.gigacode {
+ "Gigacode"
+ } else {
+ "OpenCode command"
+ };
+ write_stderr_line(&format!("\nEXPERIMENTAL: Please report bugs to:\n- GitHub: https://github.com/rivet-dev/sandbox-agent/issues\n- Discord: https://rivet.dev/discord\n\n{name} is powered by:\n- OpenCode (TUI): https://opencode.ai/\n- Sandbox Agent SDK (multi-agent compatibility): https://sandboxagent.dev/\n\n"))?;
+
+ let token = cli.token.clone();
+
+ let base_url = format!("http://{}:{}", args.host, args.port);
+ crate::daemon::ensure_running(cli, &args.host, args.port, token.as_deref())?;
+
+ let session_id =
+ create_opencode_session(&base_url, token.as_deref(), args.session_title.as_deref())?;
+ write_stdout_line(&format!("OpenCode session: {session_id}"))?;
+
+ let attach_url = format!("{base_url}/opencode");
+ let opencode_bin = resolve_opencode_bin(args.opencode_bin.as_ref())?;
+ let mut opencode_cmd = ProcessCommand::new(opencode_bin);
+ opencode_cmd
+ .arg("attach")
+ .arg(&attach_url)
+ .arg("--session")
+ .arg(&session_id)
+ .stdin(Stdio::inherit())
+ .stdout(Stdio::inherit())
+ .stderr(Stdio::inherit());
+ if let Some(token) = token.as_deref() {
+ opencode_cmd.arg("--password").arg(token);
+ }
+
+ let status = opencode_cmd
+ .status()
+ .map_err(|err| CliError::Server(format!("failed to start opencode: {err}")))?;
+
+ if !status.success() {
+ return Err(CliError::Server(format!(
+ "opencode exited with status {status}"
+ )));
+ }
+
+ Ok(())
+}
+
+fn run_daemon(command: &DaemonCommand, cli: &CliConfig) -> Result<(), CliError> {
+ let token = cli.token.as_deref();
+ match command {
+ DaemonCommand::Start(args) => crate::daemon::start(cli, &args.host, args.port, token),
+ DaemonCommand::Stop(args) => crate::daemon::stop(&args.host, args.port),
+ DaemonCommand::Status(args) => {
+ let st = crate::daemon::status(&args.host, args.port, token)?;
+ write_stderr_line(&st.to_string())?;
+ Ok(())
+ }
+ }
+}
+
+fn run_agents(command: &AgentsCommand, cli: &CliConfig) -> Result<(), CliError> {
+ match command {
+ AgentsCommand::List(args) => {
+ let ctx = ClientContext::new(cli, args)?;
+ let response = ctx.get(&format!("{API_PREFIX}/agents"))?;
+ print_json_response::(response)
+ }
+ AgentsCommand::Install(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let body = AgentInstallRequest {
+ reinstall: if args.reinstall { Some(true) } else { None },
+ };
+ let path = format!("{API_PREFIX}/agents/{}/install", args.agent);
+ let response = ctx.post(&path, &body)?;
+ print_empty_response(response)
+ }
+ AgentsCommand::Modes(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let path = format!("{API_PREFIX}/agents/{}/modes", args.agent);
+ let response = ctx.get(&path)?;
+ print_json_response::(response)
+ }
+ AgentsCommand::Models(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let path = format!("{API_PREFIX}/agents/{}/models", args.agent);
+ let response = ctx.get(&path)?;
+ print_json_response::(response)
+ }
+ }
+}
+
+fn run_sessions(command: &SessionsCommand, cli: &CliConfig) -> Result<(), CliError> {
+ match command {
+ SessionsCommand::List(args) => {
+ let ctx = ClientContext::new(cli, args)?;
+ let response = ctx.get(&format!("{API_PREFIX}/sessions"))?;
+ print_json_response::(response)
+ }
+ SessionsCommand::Create(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let body = CreateSessionRequest {
+ agent: args.agent.clone(),
+ agent_mode: args.agent_mode.clone(),
+ permission_mode: args.permission_mode.clone(),
+ model: args.model.clone(),
+ variant: args.variant.clone(),
+ agent_version: args.agent_version.clone(),
+ };
+ let path = format!("{API_PREFIX}/sessions/{}", args.session_id);
+ let response = ctx.post(&path, &body)?;
+ print_json_response::(response)
+ }
+ SessionsCommand::SendMessage(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let body = MessageRequest {
+ message: args.message.clone(),
+ };
+ let path = format!("{API_PREFIX}/sessions/{}/messages", args.session_id);
+ let response = ctx.post(&path, &body)?;
+ print_empty_response(response)
+ }
+ SessionsCommand::SendMessageStream(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let body = MessageRequest {
+ message: args.message.clone(),
+ };
+ let path = format!("{API_PREFIX}/sessions/{}/messages/stream", args.session_id);
+ let response = ctx.post_with_query(
+ &path,
+ &body,
+ &[(
+ "include_raw",
+ if args.include_raw {
+ Some("true".to_string())
+ } else {
+ None
+ },
+ )],
+ )?;
+ print_text_response(response)
+ }
+ SessionsCommand::Terminate(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let path = format!("{API_PREFIX}/sessions/{}/terminate", args.session_id);
+ let response = ctx.post_empty(&path)?;
+ print_empty_response(response)
+ }
+ SessionsCommand::GetMessages(args) | SessionsCommand::Events(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let path = format!("{API_PREFIX}/sessions/{}/events", args.session_id);
+ let response = ctx.get_with_query(
+ &path,
+ &[
+ ("offset", args.offset.map(|v| v.to_string())),
+ ("limit", args.limit.map(|v| v.to_string())),
+ (
+ "include_raw",
+ if args.include_raw {
+ Some("true".to_string())
+ } else {
+ None
+ },
+ ),
+ ],
+ )?;
+ print_json_response::(response)
+ }
+ SessionsCommand::EventsSse(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let path = format!("{API_PREFIX}/sessions/{}/events/sse", args.session_id);
+ let response = ctx.get_with_query(
+ &path,
+ &[
+ ("offset", args.offset.map(|v| v.to_string())),
+ (
+ "include_raw",
+ if args.include_raw {
+ Some("true".to_string())
+ } else {
+ None
+ },
+ ),
+ ],
+ )?;
+ print_text_response(response)
+ }
+ SessionsCommand::ReplyQuestion(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let answers: Vec> = serde_json::from_str(&args.answers)?;
+ let body = QuestionReplyRequest { answers };
+ let path = format!(
+ "{API_PREFIX}/sessions/{}/questions/{}/reply",
+ args.session_id, args.question_id
+ );
+ let response = ctx.post(&path, &body)?;
+ print_empty_response(response)
+ }
+ SessionsCommand::RejectQuestion(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let path = format!(
+ "{API_PREFIX}/sessions/{}/questions/{}/reject",
+ args.session_id, args.question_id
+ );
+ let response = ctx.post_empty(&path)?;
+ print_empty_response(response)
+ }
+ SessionsCommand::ReplyPermission(args) => {
+ let ctx = ClientContext::new(cli, &args.client)?;
+ let body = PermissionReplyRequest {
+ reply: args.reply.clone(),
+ };
+ let path = format!(
+ "{API_PREFIX}/sessions/{}/permissions/{}/reply",
+ args.session_id, args.permission_id
+ );
+ let response = ctx.post(&path, &body)?;
+ print_empty_response(response)
+ }
+ }
+}
+
+fn create_opencode_session(
+ base_url: &str,
+ token: Option<&str>,
+ title: Option<&str>,
+) -> Result {
+ let client = HttpClient::builder().build()?;
+ let url = format!("{base_url}/opencode/session");
+ let body = if let Some(title) = title {
+ json!({ "title": title })
+ } else {
+ json!({})
+ };
+ let mut request = client.post(&url).json(&body);
+ if let Ok(directory) = std::env::current_dir() {
+ request = request.header(
+ "x-opencode-directory",
+ directory.to_string_lossy().to_string(),
+ );
+ }
+ if let Some(token) = token {
+ request = request.bearer_auth(token);
+ }
+ let response = request.send()?;
+ let status = response.status();
+ let text = response.text()?;
+ if !status.is_success() {
+ print_error_body(&text)?;
+ return Err(CliError::HttpStatus(status));
+ }
+ let body: Value = serde_json::from_str(&text)?;
+ let session_id = body
+ .get("id")
+ .and_then(|value| value.as_str())
+ .ok_or_else(|| CliError::Server("opencode session missing id".to_string()))?;
+ Ok(session_id.to_string())
+}
+
+fn resolve_opencode_bin(explicit: Option<&PathBuf>) -> Result {
+ if let Some(path) = explicit {
+ return Ok(path.clone());
+ }
+ if let Ok(path) = std::env::var("OPENCODE_BIN") {
+ return Ok(PathBuf::from(path));
+ }
+ if let Some(path) = find_in_path("opencode") {
+ write_stderr_line(&format!(
+ "using opencode binary from PATH: {}",
+ path.display()
+ ))?;
+ return Ok(path);
+ }
+
+ let manager = AgentManager::new(default_install_dir())
+ .map_err(|err| CliError::Server(err.to_string()))?;
+ match manager.resolve_binary(AgentId::Opencode) {
+ Ok(path) => Ok(path),
+ Err(_) => {
+ write_stderr_line("opencode not found; installing...")?;
+ let result = manager
+ .install(
+ AgentId::Opencode,
+ InstallOptions {
+ reinstall: false,
+ version: None,
+ },
+ )
+ .map_err(|err| CliError::Server(err.to_string()))?;
+ Ok(result.path)
+ }
+ }
+}
+
+fn find_in_path(binary_name: &str) -> Option {
+ let path_var = std::env::var_os("PATH")?;
+ for path in std::env::split_paths(&path_var) {
+ let candidate = path.join(binary_name);
+ if candidate.exists() {
+ return Some(candidate);
+ }
+ }
+ None
+}
+
+fn run_credentials(command: &CredentialsCommand) -> Result<(), CliError> {
+ match command {
+ CredentialsCommand::Extract(args) => {
+ let mut options = CredentialExtractionOptions::new();
+ if let Some(home_dir) = args.home_dir.clone() {
+ options.home_dir = Some(home_dir);
+ }
+ if args.no_oauth {
+ options.include_oauth = false;
+ }
+
+ let credentials = extract_all_credentials(&options);
+ if let Some(agent) = args.agent.clone() {
+ let token = select_token_for_agent(&credentials, agent, args.provider.as_deref())?;
+ write_stdout_line(&token)?;
+ return Ok(());
+ }
+ if let Some(provider) = args.provider.as_deref() {
+ let token = select_token_for_provider(&credentials, provider)?;
+ write_stdout_line(&token)?;
+ return Ok(());
+ }
+
+ let output = credentials_to_output(credentials, args.reveal);
+ let pretty = serde_json::to_string_pretty(&output)?;
+ write_stdout_line(&pretty)?;
+ Ok(())
+ }
+ CredentialsCommand::ExtractEnv(args) => {
+ let mut options = CredentialExtractionOptions::new();
+ if let Some(home_dir) = args.home_dir.clone() {
+ options.home_dir = Some(home_dir);
+ }
+ if args.no_oauth {
+ options.include_oauth = false;
+ }
+
+ let credentials = extract_all_credentials(&options);
+ let prefix = if args.export { "export " } else { "" };
+
+ if let Some(cred) = &credentials.anthropic {
+ write_stdout_line(&format!("{}ANTHROPIC_API_KEY={}", prefix, cred.api_key))?;
+ write_stdout_line(&format!("{}CLAUDE_API_KEY={}", prefix, cred.api_key))?;
+ }
+ if let Some(cred) = &credentials.openai {
+ write_stdout_line(&format!("{}OPENAI_API_KEY={}", prefix, cred.api_key))?;
+ write_stdout_line(&format!("{}CODEX_API_KEY={}", prefix, cred.api_key))?;
+ }
+ for (provider, cred) in &credentials.other {
+ let var_name = format!("{}_API_KEY", provider.to_uppercase().replace('-', "_"));
+ write_stdout_line(&format!("{}{}={}", prefix, var_name, cred.api_key))?;
+ }
+
+ Ok(())
+ }
+ }
+}
+
+#[derive(Serialize)]
+struct CredentialsOutput {
+ anthropic: Option,
+ openai: Option,
+ other: HashMap,
+}
+
+#[derive(Serialize)]
+struct CredentialSummary {
+ provider: String,
+ source: String,
+ auth_type: String,
+ api_key: String,
+ redacted: bool,
+}
+
+#[derive(clap::ValueEnum, Clone, Debug)]
+enum CredentialAgent {
+ Claude,
+ Codex,
+ Opencode,
+ Amp,
+ Pi,
+}
+
+fn credentials_to_output(credentials: ExtractedCredentials, reveal: bool) -> CredentialsOutput {
+ CredentialsOutput {
+ anthropic: credentials
+ .anthropic
+ .map(|cred| summarize_credential(&cred, reveal)),
+ openai: credentials
+ .openai
+ .map(|cred| summarize_credential(&cred, reveal)),
+ other: credentials
+ .other
+ .into_iter()
+ .map(|(key, cred)| (key, summarize_credential(&cred, reveal)))
+ .collect(),
+ }
+}
+
+fn summarize_credential(credential: &ProviderCredentials, reveal: bool) -> CredentialSummary {
+ let api_key = if reveal {
+ credential.api_key.clone()
+ } else {
+ redact_key(&credential.api_key)
+ };
+ CredentialSummary {
+ provider: credential.provider.clone(),
+ source: credential.source.clone(),
+ auth_type: match credential.auth_type {
+ AuthType::ApiKey => "api_key".to_string(),
+ AuthType::Oauth => "oauth".to_string(),
+ },
+ api_key,
+ redacted: !reveal,
+ }
+}
+
+fn redact_key(key: &str) -> String {
+ let trimmed = key.trim();
+ let len = trimmed.len();
+ if len <= 8 {
+ return "****".to_string();
+ }
+ let prefix = &trimmed[..4];
+ let suffix = &trimmed[len - 4..];
+ format!("{prefix}...{suffix}")
+}
+
+fn install_agent_local(args: &InstallAgentArgs) -> Result<(), CliError> {
+ let agent_id = AgentId::parse(&args.agent)
+ .ok_or_else(|| CliError::Server(format!("unsupported agent: {}", args.agent)))?;
+ let manager = AgentManager::new(default_install_dir())
+ .map_err(|err| CliError::Server(err.to_string()))?;
+ manager
+ .install(
+ agent_id,
+ InstallOptions {
+ reinstall: args.reinstall,
+ version: None,
+ },
+ )
+ .map_err(|err| CliError::Server(err.to_string()))?;
+ Ok(())
+}
+
+fn select_token_for_agent(
+ credentials: &ExtractedCredentials,
+ agent: CredentialAgent,
+ provider: Option<&str>,
+) -> Result {
+ match agent {
+ CredentialAgent::Claude | CredentialAgent::Amp => {
+ if let Some(provider) = provider {
+ if provider != "anthropic" {
+ return Err(CliError::Server(format!(
+ "agent {:?} only supports provider anthropic",
+ agent
+ )));
+ }
+ }
+ select_token_for_provider(credentials, "anthropic")
+ }
+ CredentialAgent::Codex => {
+ if let Some(provider) = provider {
+ if provider != "openai" {
+ return Err(CliError::Server(format!(
+ "agent {:?} only supports provider openai",
+ agent
+ )));
+ }
+ }
+ select_token_for_provider(credentials, "openai")
+ }
+ CredentialAgent::Opencode => {
+ if let Some(provider) = provider {
+ return select_token_for_provider(credentials, provider);
+ }
+ if let Some(openai) = credentials.openai.as_ref() {
+ return Ok(openai.api_key.clone());
+ }
+ if let Some(anthropic) = credentials.anthropic.as_ref() {
+ return Ok(anthropic.api_key.clone());
+ }
+ if credentials.other.len() == 1 {
+ if let Some((_, cred)) = credentials.other.iter().next() {
+ return Ok(cred.api_key.clone());
+ }
+ }
+ let available = available_providers(credentials);
+ if available.is_empty() {
+ Err(CliError::Server(
+ "no credentials found for opencode".to_string(),
+ ))
+ } else {
+ Err(CliError::Server(format!(
+ "multiple providers available for opencode: {} (use --provider)",
+ available.join(", ")
+ )))
+ }
+ }
+ CredentialAgent::Pi => {
+ if let Some(provider) = provider {
+ return select_token_for_provider(credentials, provider);
+ }
+ if let Some(openai) = credentials.openai.as_ref() {
+ return Ok(openai.api_key.clone());
+ }
+ if let Some(anthropic) = credentials.anthropic.as_ref() {
+ return Ok(anthropic.api_key.clone());
+ }
+ if credentials.other.len() == 1 {
+ if let Some((_, cred)) = credentials.other.iter().next() {
+ return Ok(cred.api_key.clone());
+ }
+ }
+ let available = available_providers(credentials);
+ if available.is_empty() {
+ Err(CliError::Server("no credentials found for pi".to_string()))
+ } else {
+ Err(CliError::Server(format!(
+ "multiple providers available for pi: {} (use --provider)",
+ available.join(", ")
+ )))
+ }
+ }
+ }
+}
+
+fn select_token_for_provider(
+ credentials: &ExtractedCredentials,
+ provider: &str,
+) -> Result {
+ if let Some(cred) = provider_credential(credentials, provider) {
+ Ok(cred.api_key.clone())
+ } else {
+ Err(CliError::Server(format!(
+ "no credentials found for provider {provider}"
+ )))
+ }
+}
+
+fn provider_credential<'a>(
+ credentials: &'a ExtractedCredentials,
+ provider: &str,
+) -> Option<&'a ProviderCredentials> {
+ match provider {
+ "openai" => credentials.openai.as_ref(),
+ "anthropic" => credentials.anthropic.as_ref(),
+ _ => credentials.other.get(provider),
+ }
+}
+
+fn available_providers(credentials: &ExtractedCredentials) -> Vec {
+ let mut providers = Vec::new();
+ if credentials.openai.is_some() {
+ providers.push("openai".to_string());
+ }
+ if credentials.anthropic.is_some() {
+ providers.push("anthropic".to_string());
+ }
+ for key in credentials.other.keys() {
+ providers.push(key.clone());
+ }
+ providers.sort();
+ providers.dedup();
+ providers
+}
+
+fn build_cors_layer(server: &ServerArgs) -> Result {
+ let mut cors = CorsLayer::new();
+
+ // Build origins list from provided origins
+ let mut origins = Vec::new();
+ for origin in &server.cors_allow_origin {
+ let value = origin
+ .parse()
+ .map_err(|_| CliError::InvalidCorsOrigin(origin.clone()))?;
+ origins.push(value);
+ }
+ if origins.is_empty() {
+ // No origins allowed - use permissive CORS with no origins (effectively disabled)
+ cors = cors.allow_origin(tower_http::cors::AllowOrigin::predicate(|_, _| false));
+ } else {
+ cors = cors.allow_origin(origins);
+ }
+
+ // Methods: allow any if not specified, otherwise use provided list
+ if server.cors_allow_method.is_empty() {
+ cors = cors.allow_methods(Any);
+ } else {
+ let mut methods = Vec::new();
+ for method in &server.cors_allow_method {
+ let parsed = method
+ .parse()
+ .map_err(|_| CliError::InvalidCorsMethod(method.clone()))?;
+ methods.push(parsed);
+ }
+ cors = cors.allow_methods(methods);
+ }
+
+ // Headers: allow any if not specified, otherwise use provided list
+ if server.cors_allow_header.is_empty() {
+ cors = cors.allow_headers(Any);
+ } else {
+ let mut headers = Vec::new();
+ for header in &server.cors_allow_header {
+ let parsed = header
+ .parse()
+ .map_err(|_| CliError::InvalidCorsHeader(header.clone()))?;
+ headers.push(parsed);
+ }
+ cors = cors.allow_headers(headers);
+ }
+
+ if server.cors_allow_credentials {
+ cors = cors.allow_credentials(true);
+ }
+
+ Ok(cors)
+}
+
+struct ClientContext {
+ endpoint: String,
+ token: Option,
+ client: HttpClient,
+}
+
+impl ClientContext {
+ fn new(cli: &CliConfig, args: &ClientArgs) -> Result {
+ let endpoint = args
+ .endpoint
+ .clone()
+ .unwrap_or_else(|| format!("http://{}:{}", DEFAULT_HOST, DEFAULT_PORT));
+ let token = if cli.no_token {
+ None
+ } else {
+ cli.token.clone()
+ };
+ let client = HttpClient::builder().build()?;
+ Ok(Self {
+ endpoint,
+ token,
+ client,
+ })
+ }
+
+ fn url(&self, path: &str) -> String {
+ format!("{}{}", self.endpoint.trim_end_matches('/'), path)
+ }
+
+ fn request(&self, method: Method, path: &str) -> reqwest::blocking::RequestBuilder {
+ let url = self.url(path);
+ let mut builder = self.client.request(method, url);
+ if let Some(token) = &self.token {
+ builder = builder.bearer_auth(token);
+ }
+ builder
+ }
+
+ fn get(&self, path: &str) -> Result {
+ Ok(self.request(Method::GET, path).send()?)
+ }
+
+ fn get_with_query(
+ &self,
+ path: &str,
+ query: &[(&str, Option)],
+ ) -> Result {
+ let mut request = self.request(Method::GET, path);
+ for (key, value) in query {
+ if let Some(value) = value {
+ request = request.query(&[(key, value)]);
+ }
+ }
+ Ok(request.send()?)
+ }
+
+ fn post(
+ &self,
+ path: &str,
+ body: &T,
+ ) -> Result {
+ Ok(self.request(Method::POST, path).json(body).send()?)
+ }
+
+ fn post_with_query(
+ &self,
+ path: &str,
+ body: &T,
+ query: &[(&str, Option)],
+ ) -> Result {
+ let mut request = self.request(Method::POST, path).json(body);
+ for (key, value) in query {
+ if let Some(value) = value {
+ request = request.query(&[(key, value)]);
+ }
+ }
+ Ok(request.send()?)
+ }
+
+ fn post_empty(&self, path: &str) -> Result {
+ Ok(self.request(Method::POST, path).send()?)
+ }
+}
+
+fn print_json_response(
+ response: reqwest::blocking::Response,
+) -> Result<(), CliError> {
+ let status = response.status();
+ let text = response.text()?;
+
+ if !status.is_success() {
+ print_error_body(&text)?;
+ return Err(CliError::HttpStatus(status));
+ }
+
+ let parsed: T = serde_json::from_str(&text)?;
+ let pretty = serde_json::to_string_pretty(&parsed)?;
+ write_stdout_line(&pretty)?;
+ Ok(())
+}
+
+fn print_text_response(response: reqwest::blocking::Response) -> Result<(), CliError> {
+ let status = response.status();
+ let text = response.text()?;
+
+ if !status.is_success() {
+ print_error_body(&text)?;
+ return Err(CliError::HttpStatus(status));
+ }
+
+ write_stdout(&text)?;
+ Ok(())
+}
+
+fn print_empty_response(response: reqwest::blocking::Response) -> Result<(), CliError> {
+ let status = response.status();
+ if status.is_success() {
+ return Ok(());
+ }
+ let text = response.text()?;
+ print_error_body(&text)?;
+ Err(CliError::HttpStatus(status))
+}
+
+fn print_error_body(text: &str) -> Result<(), CliError> {
+ if let Ok(json) = serde_json::from_str::(text) {
+ let pretty = serde_json::to_string_pretty(&json)?;
+ write_stderr_line(&pretty)?;
+ } else {
+ write_stderr_line(text)?;
+ }
+ Ok(())
+}
+
+fn write_stdout(text: &str) -> Result<(), CliError> {
+ let mut out = std::io::stdout();
+ out.write_all(text.as_bytes())?;
+ out.flush()?;
+ Ok(())
+}
+
+fn write_stdout_line(text: &str) -> Result<(), CliError> {
+ let mut out = std::io::stdout();
+ out.write_all(text.as_bytes())?;
+ out.write_all(b"\n")?;
+ out.flush()?;
+ Ok(())
+}
+
+fn write_stderr_line(text: &str) -> Result<(), CliError> {
+ let mut out = std::io::stderr();
+ out.write_all(text.as_bytes())?;
+ out.write_all(b"\n")?;
+ out.flush()?;
+ Ok(())
+}
diff --git a/server/packages/sandbox-agent/src/daemon.rs b/server/packages/sandbox-agent/src/daemon.rs
new file mode 100644
index 0000000..58bf6b4
--- /dev/null
+++ b/server/packages/sandbox-agent/src/daemon.rs
@@ -0,0 +1,476 @@
+use std::fs;
+use std::path::{Path, PathBuf};
+use std::process::{Child, Command as ProcessCommand, Stdio};
+use std::time::{Duration, Instant};
+
+use reqwest::blocking::Client as HttpClient;
+
+use crate::cli::{CliConfig, CliError};
+
+mod build_id {
+ include!(concat!(env!("OUT_DIR"), "/build_id.rs"));
+}
+
+pub use build_id::BUILD_ID;
+
+const DAEMON_HEALTH_TIMEOUT: Duration = Duration::from_secs(30);
+
+// ---------------------------------------------------------------------------
+// Paths
+// ---------------------------------------------------------------------------
+
+pub fn daemon_state_dir() -> PathBuf {
+ dirs::data_dir()
+ .map(|dir| dir.join("sandbox-agent").join("daemon"))
+ .unwrap_or_else(|| PathBuf::from(".").join(".sandbox-agent").join("daemon"))
+}
+
+pub fn sanitize_host(host: &str) -> String {
+ host.chars()
+ .map(|ch| if ch.is_ascii_alphanumeric() { ch } else { '-' })
+ .collect()
+}
+
+pub fn daemon_pid_path(host: &str, port: u16) -> PathBuf {
+ let name = format!("daemon-{}-{}.pid", sanitize_host(host), port);
+ daemon_state_dir().join(name)
+}
+
+pub fn daemon_log_path(host: &str, port: u16) -> PathBuf {
+ let name = format!("daemon-{}-{}.log", sanitize_host(host), port);
+ daemon_state_dir().join(name)
+}
+
+pub fn daemon_version_path(host: &str, port: u16) -> PathBuf {
+ let name = format!("daemon-{}-{}.version", sanitize_host(host), port);
+ daemon_state_dir().join(name)
+}
+
+// ---------------------------------------------------------------------------
+// PID helpers
+// ---------------------------------------------------------------------------
+
+pub fn read_pid(path: &Path) -> Option {
+ let text = fs::read_to_string(path).ok()?;
+ text.trim().parse::().ok()
+}
+
+pub fn write_pid(path: &Path, pid: u32) -> Result<(), CliError> {
+ if let Some(parent) = path.parent() {
+ fs::create_dir_all(parent)?;
+ }
+ fs::write(path, pid.to_string())?;
+ Ok(())
+}
+
+pub fn remove_pid(path: &Path) -> Result<(), CliError> {
+ if path.exists() {
+ fs::remove_file(path)?;
+ }
+ Ok(())
+}
+
+// ---------------------------------------------------------------------------
+// Version helpers
+// ---------------------------------------------------------------------------
+
+pub fn read_daemon_version(host: &str, port: u16) -> Option {
+ let path = daemon_version_path(host, port);
+ let text = fs::read_to_string(path).ok()?;
+ Some(text.trim().to_string())
+}
+
+pub fn write_daemon_version(host: &str, port: u16) -> Result<(), CliError> {
+ let path = daemon_version_path(host, port);
+ if let Some(parent) = path.parent() {
+ fs::create_dir_all(parent)?;
+ }
+ fs::write(&path, BUILD_ID)?;
+ Ok(())
+}
+
+pub fn remove_version_file(host: &str, port: u16) -> Result<(), CliError> {
+ let path = daemon_version_path(host, port);
+ if path.exists() {
+ fs::remove_file(path)?;
+ }
+ Ok(())
+}
+
+pub fn is_version_current(host: &str, port: u16) -> bool {
+ match read_daemon_version(host, port) {
+ Some(v) => v == BUILD_ID,
+ None => false,
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Process helpers
+// ---------------------------------------------------------------------------
+
+#[cfg(unix)]
+pub fn is_process_running(pid: u32) -> bool {
+ let result = unsafe { libc::kill(pid as i32, 0) };
+ if result == 0 {
+ return true;
+ }
+ match std::io::Error::last_os_error().raw_os_error() {
+ Some(code) if code == libc::EPERM => true,
+ _ => false,
+ }
+}
+
+#[cfg(windows)]
+pub fn is_process_running(pid: u32) -> bool {
+ use windows::Win32::Foundation::CloseHandle;
+ use windows::Win32::System::Threading::{
+ GetExitCodeProcess, OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION,
+ };
+
+ unsafe {
+ let handle = match OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid) {
+ Ok(h) => h,
+ Err(_) => return false,
+ };
+ let mut exit_code = 0u32;
+ let ok = GetExitCodeProcess(handle, &mut exit_code).is_ok();
+ let _ = CloseHandle(handle);
+ ok && exit_code == 259
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Health checks
+// ---------------------------------------------------------------------------
+
+pub fn check_health(base_url: &str, token: Option<&str>) -> Result {
+ let client = HttpClient::builder().build()?;
+ let url = format!("{base_url}/v1/health");
+ let mut request = client.get(url);
+ if let Some(token) = token {
+ request = request.bearer_auth(token);
+ }
+ match request.send() {
+ Ok(response) if response.status().is_success() => Ok(true),
+ Ok(_) => Ok(false),
+ Err(_) => Ok(false),
+ }
+}
+
+pub fn wait_for_health(
+ mut server_child: Option<&mut Child>,
+ base_url: &str,
+ token: Option<&str>,
+ timeout: Duration,
+) -> Result<(), CliError> {
+ let client = HttpClient::builder().build()?;
+ let deadline = Instant::now() + timeout;
+
+ while Instant::now() < deadline {
+ if let Some(child) = server_child.as_mut() {
+ if let Some(status) = child.try_wait()? {
+ return Err(CliError::Server(format!(
+ "sandbox-agent exited before becoming healthy ({status})"
+ )));
+ }
+ }
+
+ let url = format!("{base_url}/v1/health");
+ let mut request = client.get(&url);
+ if let Some(token) = token {
+ request = request.bearer_auth(token);
+ }
+ match request.send() {
+ Ok(response) if response.status().is_success() => return Ok(()),
+ _ => {
+ std::thread::sleep(Duration::from_millis(200));
+ }
+ }
+ }
+
+ Err(CliError::Server(
+ "timed out waiting for sandbox-agent health".to_string(),
+ ))
+}
+
+// ---------------------------------------------------------------------------
+// Spawn
+// ---------------------------------------------------------------------------
+
+pub fn spawn_sandbox_agent_daemon(
+ cli: &CliConfig,
+ host: &str,
+ port: u16,
+ token: Option<&str>,
+ log_path: &Path,
+) -> Result {
+ if let Some(parent) = log_path.parent() {
+ fs::create_dir_all(parent)?;
+ }
+ let log_file = fs::File::create(log_path)?;
+ let log_file_err = log_file.try_clone()?;
+
+ let exe = std::env::current_exe()?;
+ let mut cmd = ProcessCommand::new(exe);
+ cmd.arg("server")
+ .arg("--host")
+ .arg(host)
+ .arg("--port")
+ .arg(port.to_string())
+ .env("SANDBOX_AGENT_LOG_STDOUT", "1")
+ .stdin(Stdio::null())
+ .stdout(Stdio::from(log_file))
+ .stderr(Stdio::from(log_file_err));
+
+ if let Some(token) = token {
+ cmd.arg("--token").arg(token);
+ }
+
+ cmd.spawn().map_err(CliError::from)
+}
+
+// ---------------------------------------------------------------------------
+// DaemonStatus
+// ---------------------------------------------------------------------------
+
+#[derive(Debug)]
+pub enum DaemonStatus {
+ Running {
+ pid: u32,
+ version: Option,
+ version_current: bool,
+ log_path: PathBuf,
+ },
+ NotRunning,
+}
+
+impl std::fmt::Display for DaemonStatus {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ DaemonStatus::Running {
+ pid,
+ version,
+ version_current,
+ log_path,
+ } => {
+ let version_str = version.as_deref().unwrap_or("unknown");
+ let outdated = if *version_current {
+ ""
+ } else {
+ " [outdated, restart recommended]"
+ };
+ write!(
+ f,
+ "Daemon running (PID {pid}, build {version_str}, logs: {}){}",
+ log_path.display(),
+ outdated
+ )
+ }
+ DaemonStatus::NotRunning => write!(f, "Daemon not running"),
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+// High-level commands
+// ---------------------------------------------------------------------------
+
+pub fn status(host: &str, port: u16, token: Option<&str>) -> Result {
+ let pid_path = daemon_pid_path(host, port);
+ let log_path = daemon_log_path(host, port);
+
+ if let Some(pid) = read_pid(&pid_path) {
+ if is_process_running(pid) {
+ let version = read_daemon_version(host, port);
+ let version_current = is_version_current(host, port);
+ return Ok(DaemonStatus::Running {
+ pid,
+ version,
+ version_current,
+ log_path,
+ });
+ }
+ // Stale PID file
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ }
+
+ // Also try a health check in case the daemon is running but we lost the PID file
+ let base_url = format!("http://{host}:{port}");
+ if check_health(&base_url, token)? {
+ return Ok(DaemonStatus::Running {
+ pid: 0,
+ version: read_daemon_version(host, port),
+ version_current: is_version_current(host, port),
+ log_path,
+ });
+ }
+
+ Ok(DaemonStatus::NotRunning)
+}
+
+pub fn start(cli: &CliConfig, host: &str, port: u16, token: Option<&str>) -> Result<(), CliError> {
+ let base_url = format!("http://{host}:{port}");
+ let pid_path = daemon_pid_path(host, port);
+ let log_path = daemon_log_path(host, port);
+
+ // Already healthy?
+ if check_health(&base_url, token)? {
+ eprintln!("daemon already running at {base_url}");
+ return Ok(());
+ }
+
+ // Stale PID?
+ if let Some(pid) = read_pid(&pid_path) {
+ if is_process_running(pid) {
+ eprintln!("daemon process {pid} exists; waiting for health");
+ return wait_for_health(None, &base_url, token, DAEMON_HEALTH_TIMEOUT);
+ }
+ let _ = remove_pid(&pid_path);
+ }
+
+ eprintln!(
+ "starting daemon at {base_url} (logs: {})",
+ log_path.display()
+ );
+
+ let mut child = spawn_sandbox_agent_daemon(cli, host, port, token, &log_path)?;
+ let pid = child.id();
+ write_pid(&pid_path, pid)?;
+ write_daemon_version(host, port)?;
+
+ let result = wait_for_health(Some(&mut child), &base_url, token, DAEMON_HEALTH_TIMEOUT);
+ if result.is_err() {
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ return result;
+ }
+
+ eprintln!("daemon started (PID {pid}, logs: {})", log_path.display());
+ Ok(())
+}
+
+#[cfg(unix)]
+pub fn stop(host: &str, port: u16) -> Result<(), CliError> {
+ let pid_path = daemon_pid_path(host, port);
+
+ let pid = match read_pid(&pid_path) {
+ Some(pid) => pid,
+ None => {
+ eprintln!("daemon is not running (no PID file)");
+ return Ok(());
+ }
+ };
+
+ if !is_process_running(pid) {
+ eprintln!("daemon is not running (stale PID file)");
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ return Ok(());
+ }
+
+ eprintln!("stopping daemon (PID {pid})...");
+
+ // SIGTERM
+ unsafe {
+ libc::kill(pid as i32, libc::SIGTERM);
+ }
+
+ // Wait up to 5 seconds for graceful exit
+ for _ in 0..50 {
+ std::thread::sleep(Duration::from_millis(100));
+ if !is_process_running(pid) {
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ eprintln!("daemon stopped");
+ return Ok(());
+ }
+ }
+
+ // SIGKILL
+ eprintln!("daemon did not stop gracefully, sending SIGKILL...");
+ unsafe {
+ libc::kill(pid as i32, libc::SIGKILL);
+ }
+ std::thread::sleep(Duration::from_millis(100));
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ eprintln!("daemon killed");
+ Ok(())
+}
+
+#[cfg(windows)]
+pub fn stop(host: &str, port: u16) -> Result<(), CliError> {
+ let pid_path = daemon_pid_path(host, port);
+
+ let pid = match read_pid(&pid_path) {
+ Some(pid) => pid,
+ None => {
+ eprintln!("daemon is not running (no PID file)");
+ return Ok(());
+ }
+ };
+
+ if !is_process_running(pid) {
+ eprintln!("daemon is not running (stale PID file)");
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ return Ok(());
+ }
+
+ eprintln!("stopping daemon (PID {pid})...");
+
+ // Use taskkill on Windows
+ let _ = ProcessCommand::new("taskkill")
+ .args(["/PID", &pid.to_string(), "/F"])
+ .status();
+
+ std::thread::sleep(Duration::from_millis(500));
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ eprintln!("daemon stopped");
+ Ok(())
+}
+
+pub fn ensure_running(
+ cli: &CliConfig,
+ host: &str,
+ port: u16,
+ token: Option<&str>,
+) -> Result<(), CliError> {
+ let base_url = format!("http://{host}:{port}");
+ let pid_path = daemon_pid_path(host, port);
+
+ // Check if daemon is already healthy
+ if check_health(&base_url, token)? {
+ // Check build version
+ if !is_version_current(host, port) {
+ let old = read_daemon_version(host, port).unwrap_or_else(|| "unknown".to_string());
+ eprintln!("daemon outdated (build {old} -> {BUILD_ID}), restarting...");
+ stop(host, port)?;
+ return start(cli, host, port, token);
+ }
+ let log_path = daemon_log_path(host, port);
+ if let Some(pid) = read_pid(&pid_path) {
+ eprintln!(
+ "daemon already running at {base_url} (PID {pid}, logs: {})",
+ log_path.display()
+ );
+ } else {
+ eprintln!("daemon already running at {base_url}");
+ }
+ return Ok(());
+ }
+
+ // Not healthy — check for stale PID
+ if let Some(pid) = read_pid(&pid_path) {
+ if is_process_running(pid) {
+ eprintln!("daemon process {pid} running; waiting for health");
+ return wait_for_health(None, &base_url, token, DAEMON_HEALTH_TIMEOUT);
+ }
+ let _ = remove_pid(&pid_path);
+ let _ = remove_version_file(host, port);
+ }
+
+ start(cli, host, port, token)
+}
diff --git a/server/packages/sandbox-agent/src/lib.rs b/server/packages/sandbox-agent/src/lib.rs
index 81dd9ab..9000924 100644
--- a/server/packages/sandbox-agent/src/lib.rs
+++ b/server/packages/sandbox-agent/src/lib.rs
@@ -1,7 +1,9 @@
//! Sandbox agent core utilities.
mod agent_server_logs;
+pub mod cli;
pub mod credentials;
+pub mod daemon;
pub mod http_client;
pub mod opencode_compat;
pub mod router;
diff --git a/server/packages/sandbox-agent/src/main.rs b/server/packages/sandbox-agent/src/main.rs
index 52cc24d..4169fca 100644
--- a/server/packages/sandbox-agent/src/main.rs
+++ b/server/packages/sandbox-agent/src/main.rs
@@ -1,1295 +1,6 @@
-use std::collections::HashMap;
-use std::io::Write;
-use std::path::PathBuf;
-use std::process::{Child, Command as ProcessCommand, Stdio};
-use std::sync::Arc;
-use std::time::{Duration, Instant};
-
-use clap::{Args, Parser, Subcommand};
-
-// Include the generated version constant
-mod build_version {
- include!(concat!(env!("OUT_DIR"), "/version.rs"));
-}
-use reqwest::blocking::Client as HttpClient;
-use reqwest::Method;
-use sandbox_agent::http_client;
-use sandbox_agent::router::{build_router_with_state, shutdown_servers};
-use sandbox_agent::router::{
- AgentInstallRequest, AppState, AuthConfig, CreateSessionRequest, MessageRequest,
- PermissionReply, PermissionReplyRequest, QuestionReplyRequest,
-};
-use sandbox_agent::router::{
- AgentListResponse, AgentModesResponse, CreateSessionResponse, EventsResponse,
- SessionListResponse,
-};
-use sandbox_agent::server_logs::ServerLogs;
-use sandbox_agent::telemetry;
-use sandbox_agent::ui;
-use sandbox_agent_agent_management::agents::{AgentId, AgentManager, InstallOptions};
-use sandbox_agent_agent_management::credentials::{
- extract_all_credentials, AuthType, CredentialExtractionOptions, ExtractedCredentials,
- ProviderCredentials,
-};
-use serde::Serialize;
-use serde_json::{json, Value};
-use thiserror::Error;
-use tower_http::cors::{Any, CorsLayer};
-use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
-
-const API_PREFIX: &str = "/v1";
-const DEFAULT_HOST: &str = "127.0.0.1";
-const DEFAULT_PORT: u16 = 2468;
-const LOGS_RETENTION: Duration = Duration::from_secs(7 * 24 * 60 * 60);
-
-#[derive(Parser, Debug)]
-#[command(name = "sandbox-agent", bin_name = "sandbox-agent")]
-#[command(about = "https://sandboxagent.dev", version = build_version::VERSION)]
-#[command(arg_required_else_help = true)]
-struct Cli {
- #[command(subcommand)]
- command: Command,
-
- #[arg(long, short = 't', global = true)]
- token: Option,
-
- #[arg(long, short = 'n', global = true)]
- no_token: bool,
-}
-
-#[derive(Subcommand, Debug)]
-enum Command {
- /// Run the sandbox agent HTTP server.
- Server(ServerArgs),
- /// Call the HTTP API without writing client code.
- Api(ApiArgs),
- /// EXPERIMENTAL: Start a sandbox-agent server and attach an OpenCode session.
- Opencode(OpencodeArgs),
- /// Install or reinstall an agent without running the server.
- InstallAgent(InstallAgentArgs),
- /// Inspect locally discovered credentials.
- Credentials(CredentialsArgs),
-}
-
-#[derive(Args, Debug)]
-struct ServerArgs {
- #[arg(long, short = 'H', default_value = DEFAULT_HOST)]
- host: String,
-
- #[arg(long, short = 'p', default_value_t = DEFAULT_PORT)]
- port: u16,
-
- #[arg(long = "cors-allow-origin", short = 'O')]
- cors_allow_origin: Vec,
-
- #[arg(long = "cors-allow-method", short = 'M')]
- cors_allow_method: Vec,
-
- #[arg(long = "cors-allow-header", short = 'A')]
- cors_allow_header: Vec,
-
- #[arg(long = "cors-allow-credentials", short = 'C')]
- cors_allow_credentials: bool,
-
- #[arg(long = "no-telemetry")]
- no_telemetry: bool,
-}
-
-#[derive(Args, Debug)]
-struct ApiArgs {
- #[command(subcommand)]
- command: ApiCommand,
-}
-
-#[derive(Args, Debug)]
-struct OpencodeArgs {
- #[arg(long, short = 'H', default_value = DEFAULT_HOST)]
- host: String,
-
- #[arg(long, short = 'p', default_value_t = DEFAULT_PORT)]
- port: u16,
-
- #[arg(long)]
- session_title: Option,
-
- #[arg(long)]
- opencode_bin: Option,
-}
-
-#[derive(Args, Debug)]
-struct CredentialsArgs {
- #[command(subcommand)]
- command: CredentialsCommand,
-}
-
-#[derive(Subcommand, Debug)]
-enum ApiCommand {
- /// Manage installed agents and their modes.
- Agents(AgentsArgs),
- /// Create sessions and interact with session events.
- Sessions(SessionsArgs),
-}
-
-#[derive(Subcommand, Debug)]
-enum CredentialsCommand {
- /// Extract credentials using local discovery rules.
- Extract(CredentialsExtractArgs),
- /// Output credentials as environment variable assignments.
- #[command(name = "extract-env")]
- ExtractEnv(CredentialsExtractEnvArgs),
-}
-
-#[derive(Args, Debug)]
-struct AgentsArgs {
- #[command(subcommand)]
- command: AgentsCommand,
-}
-
-#[derive(Args, Debug)]
-struct SessionsArgs {
- #[command(subcommand)]
- command: SessionsCommand,
-}
-
-#[derive(Subcommand, Debug)]
-enum AgentsCommand {
- /// List all agents and install status.
- List(ClientArgs),
- /// Install or reinstall an agent.
- Install(ApiInstallAgentArgs),
- /// Show available modes for an agent.
- Modes(AgentModesArgs),
-}
-
-#[derive(Subcommand, Debug)]
-enum SessionsCommand {
- /// List active sessions.
- List(ClientArgs),
- /// Create a new session for an agent.
- Create(CreateSessionArgs),
- #[command(name = "send-message")]
- /// Send a message to an existing session.
- SendMessage(SessionMessageArgs),
- #[command(name = "send-message-stream")]
- /// Send a message and stream the response for one turn.
- SendMessageStream(SessionMessageStreamArgs),
- #[command(name = "terminate")]
- /// Terminate a session.
- Terminate(SessionTerminateArgs),
- #[command(name = "get-messages")]
- /// Alias for events; returns session events.
- GetMessages(SessionEventsArgs),
- #[command(name = "events")]
- /// Fetch session events with offset/limit.
- Events(SessionEventsArgs),
- #[command(name = "events-sse")]
- /// Stream session events over SSE.
- EventsSse(SessionEventsSseArgs),
- #[command(name = "reply-question")]
- /// Reply to a question event.
- ReplyQuestion(QuestionReplyArgs),
- #[command(name = "reject-question")]
- /// Reject a question event.
- RejectQuestion(QuestionRejectArgs),
- #[command(name = "reply-permission")]
- /// Reply to a permission request.
- ReplyPermission(PermissionReplyArgs),
-}
-
-#[derive(Args, Debug, Clone)]
-struct ClientArgs {
- #[arg(long, short = 'e')]
- endpoint: Option,
-}
-
-#[derive(Args, Debug)]
-struct ApiInstallAgentArgs {
- agent: String,
- #[arg(long, short = 'r')]
- reinstall: bool,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct InstallAgentArgs {
- agent: String,
- #[arg(long, short = 'r')]
- reinstall: bool,
-}
-
-#[derive(Args, Debug)]
-struct AgentModesArgs {
- agent: String,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct CreateSessionArgs {
- session_id: String,
- #[arg(long, short = 'a')]
- agent: String,
- #[arg(long, short = 'g')]
- agent_mode: Option,
- #[arg(long, short = 'p')]
- permission_mode: Option,
- #[arg(long, short = 'm')]
- model: Option,
- #[arg(long, short = 'v')]
- variant: Option,
- #[arg(long, short = 'A')]
- agent_version: Option,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct SessionMessageArgs {
- session_id: String,
- #[arg(long, short = 'm')]
- message: String,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct SessionMessageStreamArgs {
- session_id: String,
- #[arg(long, short = 'm')]
- message: String,
- #[arg(long)]
- include_raw: bool,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct SessionEventsArgs {
- session_id: String,
- #[arg(long, short = 'o')]
- offset: Option,
- #[arg(long, short = 'l')]
- limit: Option,
- #[arg(long)]
- include_raw: bool,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct SessionEventsSseArgs {
- session_id: String,
- #[arg(long, short = 'o')]
- offset: Option,
- #[arg(long)]
- include_raw: bool,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct SessionTerminateArgs {
- session_id: String,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct QuestionReplyArgs {
- session_id: String,
- question_id: String,
- #[arg(long, short = 'a')]
- answers: String,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct QuestionRejectArgs {
- session_id: String,
- question_id: String,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct PermissionReplyArgs {
- session_id: String,
- permission_id: String,
- #[arg(long, short = 'r')]
- reply: PermissionReply,
- #[command(flatten)]
- client: ClientArgs,
-}
-
-#[derive(Args, Debug)]
-struct CredentialsExtractArgs {
- #[arg(long, short = 'a', value_enum)]
- agent: Option,
- #[arg(long, short = 'p')]
- provider: Option,
- #[arg(long, short = 'd')]
- home_dir: Option,
- #[arg(long)]
- no_oauth: bool,
- #[arg(long, short = 'r')]
- reveal: bool,
-}
-
-#[derive(Args, Debug)]
-struct CredentialsExtractEnvArgs {
- /// Prefix each line with "export " for shell sourcing.
- #[arg(long, short = 'e')]
- export: bool,
- #[arg(long, short = 'd')]
- home_dir: Option,
- #[arg(long)]
- no_oauth: bool,
-}
-
-#[derive(Debug, Error)]
-enum CliError {
- #[error("missing --token or --no-token for server mode")]
- MissingToken,
- #[error("invalid cors origin: {0}")]
- InvalidCorsOrigin(String),
- #[error("invalid cors method: {0}")]
- InvalidCorsMethod(String),
- #[error("invalid cors header: {0}")]
- InvalidCorsHeader(String),
- #[error("http error: {0}")]
- Http(#[from] reqwest::Error),
- #[error("io error: {0}")]
- Io(#[from] std::io::Error),
- #[error("json error: {0}")]
- Json(#[from] serde_json::Error),
- #[error("server error: {0}")]
- Server(String),
- #[error("unexpected http status: {0}")]
- HttpStatus(reqwest::StatusCode),
-}
-
fn main() {
- let cli = Cli::parse();
- if let Err(err) = init_logging(&cli) {
- eprintln!("failed to init logging: {err}");
- std::process::exit(1);
- }
-
- let result = match &cli.command {
- Command::Server(args) => run_server(&cli, args),
- command => run_client(command, &cli),
- };
-
- if let Err(err) = result {
+ if let Err(err) = sandbox_agent::cli::run_sandbox_agent() {
tracing::error!(error = %err, "sandbox-agent failed");
std::process::exit(1);
}
}
-
-fn init_logging(cli: &Cli) -> Result<(), CliError> {
- if matches!(cli.command, Command::Server(_)) {
- maybe_redirect_server_logs();
- }
-
- let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
- tracing_subscriber::registry()
- .with(filter)
- .with(
- tracing_logfmt::builder()
- .layer()
- .with_writer(std::io::stderr),
- )
- .init();
- Ok(())
-}
-
-fn run_server(cli: &Cli, server: &ServerArgs) -> Result<(), CliError> {
- let auth = if cli.no_token {
- AuthConfig::disabled()
- } else if let Some(token) = cli.token.clone() {
- AuthConfig::with_token(token)
- } else {
- return Err(CliError::MissingToken);
- };
-
- let agent_manager = AgentManager::new(default_install_dir())
- .map_err(|err| CliError::Server(err.to_string()))?;
- let state = Arc::new(AppState::new(auth, agent_manager));
- let (mut router, state) = build_router_with_state(state);
-
- let cors = build_cors_layer(server)?;
- router = router.layer(cors);
-
- let addr = format!("{}:{}", server.host, server.port);
- let display_host = match server.host.as_str() {
- "0.0.0.0" | "::" => "localhost",
- other => other,
- };
- let inspector_url = format!("http://{}:{}/ui", display_host, server.port);
- let runtime = tokio::runtime::Builder::new_multi_thread()
- .enable_all()
- .build()
- .map_err(|err| CliError::Server(err.to_string()))?;
-
- let telemetry_enabled = telemetry::telemetry_enabled(server.no_telemetry);
-
- runtime.block_on(async move {
- if telemetry_enabled {
- telemetry::log_enabled_message();
- telemetry::spawn_telemetry_task();
- }
- let listener = tokio::net::TcpListener::bind(&addr).await?;
- tracing::info!(addr = %addr, "server listening");
- if ui::is_enabled() {
- tracing::info!(url = %inspector_url, "inspector ui available");
- } else {
- tracing::info!("inspector ui not embedded; set SANDBOX_AGENT_SKIP_INSPECTOR=1 to skip embedding during builds");
- }
- let shutdown_state = state.clone();
- axum::serve(listener, router)
- .with_graceful_shutdown(async move {
- let _ = tokio::signal::ctrl_c().await;
- shutdown_servers(&shutdown_state).await;
- })
- .await
- .map_err(|err| CliError::Server(err.to_string()))
- })
-}
-
-fn default_install_dir() -> PathBuf {
- dirs::data_dir()
- .map(|dir| dir.join("sandbox-agent").join("bin"))
- .unwrap_or_else(|| PathBuf::from(".").join(".sandbox-agent").join("bin"))
-}
-
-fn default_server_log_dir() -> PathBuf {
- if let Ok(dir) = std::env::var("SANDBOX_AGENT_LOG_DIR") {
- return PathBuf::from(dir);
- }
- dirs::data_dir()
- .map(|dir| dir.join("sandbox-agent").join("logs"))
- .unwrap_or_else(|| PathBuf::from(".").join(".sandbox-agent").join("logs"))
-}
-
-fn maybe_redirect_server_logs() {
- if std::env::var("SANDBOX_AGENT_LOG_STDOUT").is_ok() {
- return;
- }
-
- let log_dir = default_server_log_dir();
- if let Err(err) = ServerLogs::new(log_dir, LOGS_RETENTION).start_sync() {
- eprintln!("failed to redirect logs: {err}");
- }
-}
-
-fn run_client(command: &Command, cli: &Cli) -> Result<(), CliError> {
- match command {
- Command::Server(_) => Err(CliError::Server(
- "server subcommand must be invoked as `sandbox-agent server`".to_string(),
- )),
- Command::Api(subcommand) => run_api(&subcommand.command, cli),
- Command::Opencode(args) => run_opencode(cli, args),
- Command::InstallAgent(args) => install_agent_local(args),
- Command::Credentials(subcommand) => run_credentials(&subcommand.command),
- }
-}
-
-fn run_api(command: &ApiCommand, cli: &Cli) -> Result<(), CliError> {
- match command {
- ApiCommand::Agents(subcommand) => run_agents(&subcommand.command, cli),
- ApiCommand::Sessions(subcommand) => run_sessions(&subcommand.command, cli),
- }
-}
-
-fn run_opencode(cli: &Cli, args: &OpencodeArgs) -> Result<(), CliError> {
- write_stderr_line("experimental: opencode subcommand may change without notice")?;
-
- let token = if cli.no_token {
- None
- } else {
- Some(cli.token.clone().ok_or(CliError::MissingToken)?)
- };
-
- let mut server_child = spawn_sandbox_agent_server(cli, args, token.as_deref())?;
- let base_url = format!("http://{}:{}", args.host, args.port);
- wait_for_health(&mut server_child, &base_url, token.as_deref())?;
-
- let session_id =
- create_opencode_session(&base_url, token.as_deref(), args.session_title.as_deref())?;
- write_stdout_line(&format!("OpenCode session: {session_id}"))?;
-
- let attach_url = format!("{base_url}/opencode");
- let opencode_bin = resolve_opencode_bin(args.opencode_bin.as_ref());
- let mut opencode_cmd = ProcessCommand::new(opencode_bin);
- opencode_cmd
- .arg("attach")
- .arg(&attach_url)
- .arg("--session")
- .arg(&session_id)
- .stdin(Stdio::inherit())
- .stdout(Stdio::inherit())
- .stderr(Stdio::inherit());
- if let Some(token) = token.as_deref() {
- opencode_cmd.arg("--password").arg(token);
- }
-
- let status = opencode_cmd.status().map_err(|err| {
- terminate_child(&mut server_child);
- CliError::Server(format!("failed to start opencode: {err}"))
- })?;
-
- terminate_child(&mut server_child);
-
- if !status.success() {
- return Err(CliError::Server(format!(
- "opencode exited with status {status}"
- )));
- }
-
- Ok(())
-}
-
-fn run_agents(command: &AgentsCommand, cli: &Cli) -> Result<(), CliError> {
- match command {
- AgentsCommand::List(args) => {
- let ctx = ClientContext::new(cli, args)?;
- let response = ctx.get(&format!("{API_PREFIX}/agents"))?;
- print_json_response::(response)
- }
- AgentsCommand::Install(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let body = AgentInstallRequest {
- reinstall: if args.reinstall { Some(true) } else { None },
- };
- let path = format!("{API_PREFIX}/agents/{}/install", args.agent);
- let response = ctx.post(&path, &body)?;
- print_empty_response(response)
- }
- AgentsCommand::Modes(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let path = format!("{API_PREFIX}/agents/{}/modes", args.agent);
- let response = ctx.get(&path)?;
- print_json_response::(response)
- }
- }
-}
-
-fn run_sessions(command: &SessionsCommand, cli: &Cli) -> Result<(), CliError> {
- match command {
- SessionsCommand::List(args) => {
- let ctx = ClientContext::new(cli, args)?;
- let response = ctx.get(&format!("{API_PREFIX}/sessions"))?;
- print_json_response::(response)
- }
- SessionsCommand::Create(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let body = CreateSessionRequest {
- agent: args.agent.clone(),
- agent_mode: args.agent_mode.clone(),
- permission_mode: args.permission_mode.clone(),
- model: args.model.clone(),
- variant: args.variant.clone(),
- agent_version: args.agent_version.clone(),
- };
- let path = format!("{API_PREFIX}/sessions/{}", args.session_id);
- let response = ctx.post(&path, &body)?;
- print_json_response::(response)
- }
- SessionsCommand::SendMessage(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let body = MessageRequest {
- message: args.message.clone(),
- };
- let path = format!("{API_PREFIX}/sessions/{}/messages", args.session_id);
- let response = ctx.post(&path, &body)?;
- print_empty_response(response)
- }
- SessionsCommand::SendMessageStream(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let body = MessageRequest {
- message: args.message.clone(),
- };
- let path = format!("{API_PREFIX}/sessions/{}/messages/stream", args.session_id);
- let response = ctx.post_with_query(
- &path,
- &body,
- &[(
- "include_raw",
- if args.include_raw {
- Some("true".to_string())
- } else {
- None
- },
- )],
- )?;
- print_text_response(response)
- }
- SessionsCommand::Terminate(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let path = format!("{API_PREFIX}/sessions/{}/terminate", args.session_id);
- let response = ctx.post_empty(&path)?;
- print_empty_response(response)
- }
- SessionsCommand::GetMessages(args) | SessionsCommand::Events(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let path = format!("{API_PREFIX}/sessions/{}/events", args.session_id);
- let response = ctx.get_with_query(
- &path,
- &[
- ("offset", args.offset.map(|v| v.to_string())),
- ("limit", args.limit.map(|v| v.to_string())),
- (
- "include_raw",
- if args.include_raw {
- Some("true".to_string())
- } else {
- None
- },
- ),
- ],
- )?;
- print_json_response::(response)
- }
- SessionsCommand::EventsSse(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let path = format!("{API_PREFIX}/sessions/{}/events/sse", args.session_id);
- let response = ctx.get_with_query(
- &path,
- &[
- ("offset", args.offset.map(|v| v.to_string())),
- (
- "include_raw",
- if args.include_raw {
- Some("true".to_string())
- } else {
- None
- },
- ),
- ],
- )?;
- print_text_response(response)
- }
- SessionsCommand::ReplyQuestion(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let answers: Vec> = serde_json::from_str(&args.answers)?;
- let body = QuestionReplyRequest { answers };
- let path = format!(
- "{API_PREFIX}/sessions/{}/questions/{}/reply",
- args.session_id, args.question_id
- );
- let response = ctx.post(&path, &body)?;
- print_empty_response(response)
- }
- SessionsCommand::RejectQuestion(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let path = format!(
- "{API_PREFIX}/sessions/{}/questions/{}/reject",
- args.session_id, args.question_id
- );
- let response = ctx.post_empty(&path)?;
- print_empty_response(response)
- }
- SessionsCommand::ReplyPermission(args) => {
- let ctx = ClientContext::new(cli, &args.client)?;
- let body = PermissionReplyRequest {
- reply: args.reply.clone(),
- };
- let path = format!(
- "{API_PREFIX}/sessions/{}/permissions/{}/reply",
- args.session_id, args.permission_id
- );
- let response = ctx.post(&path, &body)?;
- print_empty_response(response)
- }
- }
-}
-
-fn spawn_sandbox_agent_server(
- cli: &Cli,
- args: &OpencodeArgs,
- token: Option<&str>,
-) -> Result {
- let exe = std::env::current_exe()?;
- let mut cmd = ProcessCommand::new(exe);
- cmd.arg("server")
- .arg("--host")
- .arg(&args.host)
- .arg("--port")
- .arg(args.port.to_string())
- .stdin(Stdio::inherit())
- .stdout(Stdio::inherit())
- .stderr(Stdio::inherit());
-
- if cli.no_token {
- cmd.arg("--no-token");
- } else if let Some(token) = token {
- cmd.arg("--token").arg(token);
- }
-
- cmd.spawn().map_err(CliError::from)
-}
-
-fn wait_for_health(
- server_child: &mut Child,
- base_url: &str,
- token: Option<&str>,
-) -> Result<(), CliError> {
- let client = HttpClient::builder().build()?;
- let deadline = Instant::now() + Duration::from_secs(30);
-
- while Instant::now() < deadline {
- if let Some(status) = server_child.try_wait()? {
- return Err(CliError::Server(format!(
- "sandbox-agent exited before becoming healthy ({status})"
- )));
- }
-
- let url = format!("{base_url}/v1/health");
- let mut request = client.get(&url);
- if let Some(token) = token {
- request = request.bearer_auth(token);
- }
- match request.send() {
- Ok(response) if response.status().is_success() => return Ok(()),
- _ => {
- std::thread::sleep(Duration::from_millis(200));
- }
- }
- }
-
- Err(CliError::Server(
- "timed out waiting for sandbox-agent health".to_string(),
- ))
-}
-
-fn create_opencode_session(
- base_url: &str,
- token: Option<&str>,
- title: Option<&str>,
-) -> Result {
- let client = HttpClient::builder().build()?;
- let url = format!("{base_url}/opencode/session");
- let body = if let Some(title) = title {
- json!({ "title": title })
- } else {
- json!({})
- };
- let mut request = client.post(&url).json(&body);
- if let Ok(directory) = std::env::current_dir() {
- request = request.header(
- "x-opencode-directory",
- directory.to_string_lossy().to_string(),
- );
- }
- if let Some(token) = token {
- request = request.bearer_auth(token);
- }
- let response = request.send()?;
- let status = response.status();
- let text = response.text()?;
- if !status.is_success() {
- print_error_body(&text)?;
- return Err(CliError::HttpStatus(status));
- }
- let body: Value = serde_json::from_str(&text)?;
- let session_id = body
- .get("id")
- .and_then(|value| value.as_str())
- .ok_or_else(|| CliError::Server("opencode session missing id".to_string()))?;
- Ok(session_id.to_string())
-}
-
-fn resolve_opencode_bin(explicit: Option<&PathBuf>) -> PathBuf {
- if let Some(path) = explicit {
- return path.clone();
- }
- if let Ok(path) = std::env::var("OPENCODE_BIN") {
- return PathBuf::from(path);
- }
- PathBuf::from("opencode")
-}
-
-fn terminate_child(child: &mut Child) {
- let _ = child.kill();
- let _ = child.wait();
-}
-
-fn run_credentials(command: &CredentialsCommand) -> Result<(), CliError> {
- match command {
- CredentialsCommand::Extract(args) => {
- let mut options = CredentialExtractionOptions::new();
- if let Some(home_dir) = args.home_dir.clone() {
- options.home_dir = Some(home_dir);
- }
- if args.no_oauth {
- options.include_oauth = false;
- }
-
- let credentials = extract_all_credentials(&options);
- if let Some(agent) = args.agent.clone() {
- let token = select_token_for_agent(&credentials, agent, args.provider.as_deref())?;
- write_stdout_line(&token)?;
- return Ok(());
- }
- if let Some(provider) = args.provider.as_deref() {
- let token = select_token_for_provider(&credentials, provider)?;
- write_stdout_line(&token)?;
- return Ok(());
- }
-
- let output = credentials_to_output(credentials, args.reveal);
- let pretty = serde_json::to_string_pretty(&output)?;
- write_stdout_line(&pretty)?;
- Ok(())
- }
- CredentialsCommand::ExtractEnv(args) => {
- let mut options = CredentialExtractionOptions::new();
- if let Some(home_dir) = args.home_dir.clone() {
- options.home_dir = Some(home_dir);
- }
- if args.no_oauth {
- options.include_oauth = false;
- }
-
- let credentials = extract_all_credentials(&options);
- let prefix = if args.export { "export " } else { "" };
-
- if let Some(cred) = &credentials.anthropic {
- write_stdout_line(&format!("{}ANTHROPIC_API_KEY={}", prefix, cred.api_key))?;
- write_stdout_line(&format!("{}CLAUDE_API_KEY={}", prefix, cred.api_key))?;
- }
- if let Some(cred) = &credentials.openai {
- write_stdout_line(&format!("{}OPENAI_API_KEY={}", prefix, cred.api_key))?;
- write_stdout_line(&format!("{}CODEX_API_KEY={}", prefix, cred.api_key))?;
- }
- for (provider, cred) in &credentials.other {
- let var_name = format!("{}_API_KEY", provider.to_uppercase().replace('-', "_"));
- write_stdout_line(&format!("{}{}={}", prefix, var_name, cred.api_key))?;
- }
-
- Ok(())
- }
- }
-}
-
-#[derive(Serialize)]
-struct CredentialsOutput {
- anthropic: Option,
- openai: Option,
- other: HashMap,
-}
-
-#[derive(Serialize)]
-struct CredentialSummary {
- provider: String,
- source: String,
- auth_type: String,
- api_key: String,
- redacted: bool,
-}
-
-#[derive(clap::ValueEnum, Clone, Debug)]
-enum CredentialAgent {
- Claude,
- Codex,
- Opencode,
- Amp,
- Pi,
-}
-
-fn credentials_to_output(credentials: ExtractedCredentials, reveal: bool) -> CredentialsOutput {
- CredentialsOutput {
- anthropic: credentials
- .anthropic
- .map(|cred| summarize_credential(&cred, reveal)),
- openai: credentials
- .openai
- .map(|cred| summarize_credential(&cred, reveal)),
- other: credentials
- .other
- .into_iter()
- .map(|(key, cred)| (key, summarize_credential(&cred, reveal)))
- .collect(),
- }
-}
-
-fn summarize_credential(credential: &ProviderCredentials, reveal: bool) -> CredentialSummary {
- let api_key = if reveal {
- credential.api_key.clone()
- } else {
- redact_key(&credential.api_key)
- };
- CredentialSummary {
- provider: credential.provider.clone(),
- source: credential.source.clone(),
- auth_type: match credential.auth_type {
- AuthType::ApiKey => "api_key".to_string(),
- AuthType::Oauth => "oauth".to_string(),
- },
- api_key,
- redacted: !reveal,
- }
-}
-
-fn redact_key(key: &str) -> String {
- let trimmed = key.trim();
- let len = trimmed.len();
- if len <= 8 {
- return "****".to_string();
- }
- let prefix = &trimmed[..4];
- let suffix = &trimmed[len - 4..];
- format!("{prefix}...{suffix}")
-}
-
-fn install_agent_local(args: &InstallAgentArgs) -> Result<(), CliError> {
- let agent_id = AgentId::parse(&args.agent)
- .ok_or_else(|| CliError::Server(format!("unsupported agent: {}", args.agent)))?;
- let manager = AgentManager::new(default_install_dir())
- .map_err(|err| CliError::Server(err.to_string()))?;
- manager
- .install(
- agent_id,
- InstallOptions {
- reinstall: args.reinstall,
- version: None,
- },
- )
- .map_err(|err| CliError::Server(err.to_string()))?;
- Ok(())
-}
-
-fn select_token_for_agent(
- credentials: &ExtractedCredentials,
- agent: CredentialAgent,
- provider: Option<&str>,
-) -> Result {
- match agent {
- CredentialAgent::Claude | CredentialAgent::Amp => {
- if let Some(provider) = provider {
- if provider != "anthropic" {
- return Err(CliError::Server(format!(
- "agent {:?} only supports provider anthropic",
- agent
- )));
- }
- }
- select_token_for_provider(credentials, "anthropic")
- }
- CredentialAgent::Codex => {
- if let Some(provider) = provider {
- if provider != "openai" {
- return Err(CliError::Server(format!(
- "agent {:?} only supports provider openai",
- agent
- )));
- }
- }
- select_token_for_provider(credentials, "openai")
- }
- CredentialAgent::Opencode => {
- if let Some(provider) = provider {
- return select_token_for_provider(credentials, provider);
- }
- if let Some(openai) = credentials.openai.as_ref() {
- return Ok(openai.api_key.clone());
- }
- if let Some(anthropic) = credentials.anthropic.as_ref() {
- return Ok(anthropic.api_key.clone());
- }
- if credentials.other.len() == 1 {
- if let Some((_, cred)) = credentials.other.iter().next() {
- return Ok(cred.api_key.clone());
- }
- }
- let available = available_providers(credentials);
- if available.is_empty() {
- Err(CliError::Server(
- "no credentials found for opencode".to_string(),
- ))
- } else {
- Err(CliError::Server(format!(
- "multiple providers available for opencode: {} (use --provider)",
- available.join(", ")
- )))
- }
- }
- CredentialAgent::Pi => {
- if let Some(provider) = provider {
- return select_token_for_provider(credentials, provider);
- }
- if let Some(openai) = credentials.openai.as_ref() {
- return Ok(openai.api_key.clone());
- }
- if let Some(anthropic) = credentials.anthropic.as_ref() {
- return Ok(anthropic.api_key.clone());
- }
- if credentials.other.len() == 1 {
- if let Some((_, cred)) = credentials.other.iter().next() {
- return Ok(cred.api_key.clone());
- }
- }
- let available = available_providers(credentials);
- if available.is_empty() {
- Err(CliError::Server("no credentials found for pi".to_string()))
- } else {
- Err(CliError::Server(format!(
- "multiple providers available for pi: {} (use --provider)",
- available.join(", ")
- )))
- }
- }
- }
-}
-
-fn select_token_for_provider(
- credentials: &ExtractedCredentials,
- provider: &str,
-) -> Result {
- if let Some(cred) = provider_credential(credentials, provider) {
- Ok(cred.api_key.clone())
- } else {
- Err(CliError::Server(format!(
- "no credentials found for provider {provider}"
- )))
- }
-}
-
-fn provider_credential<'a>(
- credentials: &'a ExtractedCredentials,
- provider: &str,
-) -> Option<&'a ProviderCredentials> {
- match provider {
- "openai" => credentials.openai.as_ref(),
- "anthropic" => credentials.anthropic.as_ref(),
- _ => credentials.other.get(provider),
- }
-}
-
-fn available_providers(credentials: &ExtractedCredentials) -> Vec {
- let mut providers = Vec::new();
- if credentials.openai.is_some() {
- providers.push("openai".to_string());
- }
- if credentials.anthropic.is_some() {
- providers.push("anthropic".to_string());
- }
- for key in credentials.other.keys() {
- providers.push(key.clone());
- }
- providers.sort();
- providers.dedup();
- providers
-}
-
-fn build_cors_layer(server: &ServerArgs) -> Result {
- let mut cors = CorsLayer::new();
-
- // Build origins list from provided origins
- let mut origins = Vec::new();
- for origin in &server.cors_allow_origin {
- let value = origin
- .parse()
- .map_err(|_| CliError::InvalidCorsOrigin(origin.clone()))?;
- origins.push(value);
- }
- if origins.is_empty() {
- // No origins allowed - use permissive CORS with no origins (effectively disabled)
- cors = cors.allow_origin(tower_http::cors::AllowOrigin::predicate(|_, _| false));
- } else {
- cors = cors.allow_origin(origins);
- }
-
- // Methods: allow any if not specified, otherwise use provided list
- if server.cors_allow_method.is_empty() {
- cors = cors.allow_methods(Any);
- } else {
- let mut methods = Vec::new();
- for method in &server.cors_allow_method {
- let parsed = method
- .parse()
- .map_err(|_| CliError::InvalidCorsMethod(method.clone()))?;
- methods.push(parsed);
- }
- cors = cors.allow_methods(methods);
- }
-
- // Headers: allow any if not specified, otherwise use provided list
- if server.cors_allow_header.is_empty() {
- cors = cors.allow_headers(Any);
- } else {
- let mut headers = Vec::new();
- for header in &server.cors_allow_header {
- let parsed = header
- .parse()
- .map_err(|_| CliError::InvalidCorsHeader(header.clone()))?;
- headers.push(parsed);
- }
- cors = cors.allow_headers(headers);
- }
-
- if server.cors_allow_credentials {
- cors = cors.allow_credentials(true);
- }
-
- Ok(cors)
-}
-
-struct ClientContext {
- endpoint: String,
- token: Option,
- client: HttpClient,
-}
-
-impl ClientContext {
- fn new(cli: &Cli, args: &ClientArgs) -> Result {
- let endpoint = args
- .endpoint
- .clone()
- .unwrap_or_else(|| format!("http://{}:{}", DEFAULT_HOST, DEFAULT_PORT));
- let token = if cli.no_token {
- None
- } else {
- cli.token.clone()
- };
- let client = http_client::blocking_client_builder().build()?;
- Ok(Self {
- endpoint,
- token,
- client,
- })
- }
-
- fn url(&self, path: &str) -> String {
- format!("{}{}", self.endpoint.trim_end_matches('/'), path)
- }
-
- fn request(&self, method: Method, path: &str) -> reqwest::blocking::RequestBuilder {
- let url = self.url(path);
- let mut builder = self.client.request(method, url);
- if let Some(token) = &self.token {
- builder = builder.bearer_auth(token);
- }
- builder
- }
-
- fn get(&self, path: &str) -> Result {
- Ok(self.request(Method::GET, path).send()?)
- }
-
- fn get_with_query(
- &self,
- path: &str,
- query: &[(&str, Option)],
- ) -> Result {
- let mut request = self.request(Method::GET, path);
- for (key, value) in query {
- if let Some(value) = value {
- request = request.query(&[(key, value)]);
- }
- }
- Ok(request.send()?)
- }
-
- fn post(
- &self,
- path: &str,
- body: &T,
- ) -> Result {
- Ok(self.request(Method::POST, path).json(body).send()?)
- }
-
- fn post_with_query(
- &self,
- path: &str,
- body: &T,
- query: &[(&str, Option)],
- ) -> Result {
- let mut request = self.request(Method::POST, path).json(body);
- for (key, value) in query {
- if let Some(value) = value {
- request = request.query(&[(key, value)]);
- }
- }
- Ok(request.send()?)
- }
-
- fn post_empty(&self, path: &str) -> Result {
- Ok(self.request(Method::POST, path).send()?)
- }
-}
-
-fn print_json_response(
- response: reqwest::blocking::Response,
-) -> Result<(), CliError> {
- let status = response.status();
- let text = response.text()?;
-
- if !status.is_success() {
- print_error_body(&text)?;
- return Err(CliError::HttpStatus(status));
- }
-
- let parsed: T = serde_json::from_str(&text)?;
- let pretty = serde_json::to_string_pretty(&parsed)?;
- write_stdout_line(&pretty)?;
- Ok(())
-}
-
-fn print_text_response(response: reqwest::blocking::Response) -> Result<(), CliError> {
- let status = response.status();
- let text = response.text()?;
-
- if !status.is_success() {
- print_error_body(&text)?;
- return Err(CliError::HttpStatus(status));
- }
-
- write_stdout(&text)?;
- Ok(())
-}
-
-fn print_empty_response(response: reqwest::blocking::Response) -> Result<(), CliError> {
- let status = response.status();
- if status.is_success() {
- return Ok(());
- }
- let text = response.text()?;
- print_error_body(&text)?;
- Err(CliError::HttpStatus(status))
-}
-
-fn print_error_body(text: &str) -> Result<(), CliError> {
- if let Ok(json) = serde_json::from_str::(text) {
- let pretty = serde_json::to_string_pretty(&json)?;
- write_stderr_line(&pretty)?;
- } else {
- write_stderr_line(text)?;
- }
- Ok(())
-}
-
-fn write_stdout(text: &str) -> Result<(), CliError> {
- let mut out = std::io::stdout();
- out.write_all(text.as_bytes())?;
- out.flush()?;
- Ok(())
-}
-
-fn write_stdout_line(text: &str) -> Result<(), CliError> {
- let mut out = std::io::stdout();
- out.write_all(text.as_bytes())?;
- out.write_all(b"\n")?;
- out.flush()?;
- Ok(())
-}
-
-fn write_stderr_line(text: &str) -> Result<(), CliError> {
- let mut out = std::io::stderr();
- out.write_all(text.as_bytes())?;
- out.write_all(b"\n")?;
- out.flush()?;
- Ok(())
-}
diff --git a/server/packages/sandbox-agent/src/opencode_compat.rs b/server/packages/sandbox-agent/src/opencode_compat.rs
index 31fa62b..1393f94 100644
--- a/server/packages/sandbox-agent/src/opencode_compat.rs
+++ b/server/packages/sandbox-agent/src/opencode_compat.rs
@@ -4,11 +4,12 @@
//! stubbed responses with deterministic helpers for snapshot testing. A minimal
//! in-memory state tracks sessions/messages/ptys to keep behavior coherent.
-use std::collections::HashMap;
+use std::collections::{BTreeMap, HashMap, HashSet};
use std::convert::Infallible;
use std::str::FromStr;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
+use std::time::{Duration, Instant};
use axum::extract::{Path, Query, State};
use axum::http::{HeaderMap, StatusCode};
@@ -23,7 +24,7 @@ use tokio::sync::{broadcast, Mutex};
use tokio::time::interval;
use utoipa::{IntoParams, OpenApi, ToSchema};
-use crate::router::{AppState, CreateSessionRequest, PermissionReply};
+use crate::router::{AgentModelInfo, AppState, CreateSessionRequest, PermissionReply};
use sandbox_agent_agent_management::agents::AgentId;
use sandbox_agent_error::SandboxError;
use sandbox_agent_universal_agent_schema::{
@@ -37,10 +38,10 @@ static MESSAGE_COUNTER: AtomicU64 = AtomicU64::new(1);
static PART_COUNTER: AtomicU64 = AtomicU64::new(1);
static PTY_COUNTER: AtomicU64 = AtomicU64::new(1);
static PROJECT_COUNTER: AtomicU64 = AtomicU64::new(1);
-const OPENCODE_PROVIDER_ID: &str = "sandbox-agent";
-const OPENCODE_PROVIDER_NAME: &str = "Sandbox Agent";
const OPENCODE_DEFAULT_MODEL_ID: &str = "mock";
+const OPENCODE_DEFAULT_PROVIDER_ID: &str = "mock";
const OPENCODE_DEFAULT_AGENT_MODE: &str = "build";
+const OPENCODE_MODEL_CACHE_TTL: Duration = Duration::from_secs(30);
#[derive(Clone, Debug)]
struct OpenCodeCompatConfig {
@@ -212,6 +213,30 @@ struct OpenCodeSessionRuntime {
part_id_by_message: HashMap,
tool_part_by_call: HashMap,
tool_message_by_call: HashMap,
+ /// Tool name by call_id, persisted from ToolCall for use in ToolResult events
+ tool_name_by_call: HashMap,
+ /// Tool arguments by call_id, persisted from ToolCall for use in ToolResult events
+ tool_args_by_call: HashMap,
+}
+
+#[derive(Clone, Debug)]
+struct OpenCodeModelEntry {
+ model: AgentModelInfo,
+ group_id: String,
+ group_name: String,
+}
+
+#[derive(Clone, Debug)]
+struct OpenCodeModelCache {
+ entries: Vec,
+ model_lookup: HashMap,
+ group_defaults: HashMap,
+ group_agents: HashMap,
+ group_names: HashMap,
+ default_group: String,
+ default_model: String,
+ cached_at: Instant,
+ had_discovery_errors: bool,
}
pub struct OpenCodeState {
@@ -225,6 +250,7 @@ pub struct OpenCodeState {
session_runtime: Mutex>,
session_streams: Mutex>,
event_broadcaster: broadcast::Sender,
+ model_cache: Mutex