sandbox-agent and its SandboxAgent class.
Install
- npm
- bun
Optional React components
Create a client
SandboxAgent.connect(...) now waits for /v1/health by default before other SDK requests proceed. To disable that gate, pass waitForHealth: false. To keep the default gate but fail after a bounded wait, pass waitForHealth: { timeoutMs: 120_000 }. To cancel the startup wait early, pass signal: abortController.signal.
With a custom fetch handler (for example, proxying requests inside Workers):
SandboxAgent.start(...) requires a sandbox provider. Built-in providers:
| Import | Provider |
|---|---|
sandbox-agent/local | Local subprocess |
sandbox-agent/docker | Docker container |
sandbox-agent/e2b | E2B sandbox |
sandbox-agent/daytona | Daytona workspace |
sandbox-agent/vercel | Vercel Sandbox |
sandbox-agent/cloudflare | Cloudflare Sandbox |
sdk.dispose() to disconnect without changing sandbox state, sdk.pauseSandbox() for graceful suspension when supported, or sdk.killSandbox() for permanent deletion.
Session flow
Session configuration
Set model, mode, or thought level at creation or on an existing session:Events
Subscribe to live events:Control-plane and HTTP helpers
Desktop API
The SDK also wraps the desktop host/runtime HTTP API. Install desktop dependencies first on Linux hosts:Uint8Array PNG bytes. The SDK does not attempt to install OS packages remotely; callers should surface missingDependencies and installCommand from getDesktopStatus().
Error handling
Inspector URL
baseUrl(required unlessfetchis provided): Sandbox Agent server URLtoken(optional): Bearer token for authenticated serversheaders(optional): Additional request headersfetch(optional): Custom fetch implementation used by SDK HTTP and session callsskipHealthCheck(optional): settrueto skip the startup/v1/healthwaitwaitForHealth(optional, defaults to enabled): waits for/v1/healthbefore HTTP helpers and session setup proceed; passfalseto disable or{ timeoutMs }to bound the waitsignal(optional): aborts the startup/v1/healthwait used byconnect()