Sandbox.
A lean Rust control plane for disposable coding environments and AI agents—with typed lifecycle APIs, AEGIS risk-aware scheduling, Docker and external runtime adapters, durable state, and one tiny remote CLI.
Quickstart
Install or upgrade the three binaries, the cross-agent skill, and detected MCP client entries in one command. Reruns verify the archive and embedded versions, replace existing binaries, preserve existing MCP entries, and never write SANDBOX_TOKEN into agent configuration.
curl -fsSL https://tools.yshubham.com/sandbox/setup.sh | sh
export SANDBOX_URL=https://sandbox.example.com
export SANDBOX_TOKEN='read-from-your-secret-store'
sandbox doctor
Agents should begin at /docs/sandbox/index.md or discover the complete reference set through /docs/sandbox/llms.txt.
Safe lifecycle
- Verify controller health with
sandbox doctororsandbox_health. - Classify repository trust, generated code, secret use, sensitivity, network, resources, and TTL.
- Create with
isolation: auto. Never weaken a placement decision merely to obtain capacity. - Wait until the create operation succeeds before depending on the workspace.
- Execute argv arrays; inspect operation state, exit code, stderr, and output truncation.
- Delete disposable sandboxes and wait for teardown unless retention was explicitly requested.
sandbox create --tenant engineering --image ubuntu:24.04 \
--cpu-millis 2000 --memory-mib 4096 --ttl 1800 \
--network restricted --untrusted-repo --generated-code
sandbox exec SANDBOX_ID -- cargo test --workspace
sandbox delete SANDBOX_ID --wait
Architecture
sandboxd is one deployable executable that can run as a controller, worker, or both. Production separates controller and worker roles; workers never accept operator traffic directly.
01 / clientshumans, CI, CLI, MCP hosts, and coding agents02 / controllerauth, validation, policy, AEGIS, desired state, and leases03 / statePostgreSQL operations with optional NATS lifecycle events04 / workercapacity, heartbeats, assignment serialization, and bounded output05 / runtimehardened Docker or external VMM-grade adapterAEGIS scheduler
Adaptive Execution Guard and Isolation Scheduler combines workload risk with placement. Capacity pressure cannot silently downgrade the minimum required isolation.
| Phase | Decision | Invariant |
|---|---|---|
| Risk | Sensitivity, network, trust, generated code, secrets, exposure, mounts, privilege, and TTL produce a saturated 0–100 score. | Inputs are explicit and deterministic. |
| Isolation floor | The risk score and hard signals select the minimum eligible runtime tier. | The caller cannot request a weaker tier. |
| Hard filter | Reject stale, pressured, incompatible, undersized, or label-mismatched nodes. | No ranking score can revive an ineligible node. |
| Rank | Compare headroom, fragmentation, pressure, warm images, region, and bin packing. | Stable tie-breaking keeps placement explainable. |
When no node satisfies policy and the isolation floor, creation returns no_capacity. Do not lower security thresholds as an incident shortcut.
Read the complete scoring and placement algorithm in the AEGIS Markdown reference.
Interfaces
| Interface | Best for | Canonical reference |
|---|---|---|
sandbox | Operator terminals, scripts, CI, and agents without native MCP support. | cli.md |
sandbox-mcp | Codex, Claude, OpenCode, Cursor, VS Code, Gemini, Windsurf, Cline, Roo, Goose, and generic MCP hosts. | mcp.md |
| HTTP API | Custom portals, gateways, controllers, SDKs, and worker coordination. | api.md |
MCP surface
The Rust stdio bridge publishes 12 tools, 3 resources, and 2 prompts with closed JSON schemas, structured results, explicit error semantics, and annotations for read-only, destructive, idempotent, and open-world behavior.
codex mcp add sandbox -- sandbox-mcp
claude mcp add --scope user --transport stdio sandbox -- sandbox-mcp
gemini mcp add sandbox sandbox-mcp --scope user
opencode mcp add
Use the complete MCP client matrix for Cursor, VS Code/Copilot, Windsurf, Cline, Roo Code, Claude Desktop, Gemini Code Assist, Goose, and generic configs.
Coding agents
Profiles encode resource, network, sensitivity, risk, image, and executable defaults. They do not embed provider credentials.
sandbox agent list
sandbox agent run codex --tenant engineering
sandbox wait OPERATION_ID
Read agents.md for images, profiles, credentials, custom images, and update policy. Install the workflow skill across supported agents:
npx skills add bas3line/rool-repo \
--skill sandbox-platform --agent '*' --global --yes
Deploy
The baseline self-hosted topology is one or more controllers, PostgreSQL, and dedicated workers. NATS is optional. Start with Compose for development, then split roles and move credentials into the deployment secret mechanism.
export SANDBOX_API_TOKEN="$(openssl rand -hex 32)"
export SANDBOX_NODE_TOKEN="$(openssl rand -hex 32)"
docker compose -f deploy/compose/compose.yaml up --build
Security boundary
The built-in Docker adapter is for dedicated or trusted worker hosts. Containers share the host kernel. Use an external VMM-grade driver when the deployment requires a stronger boundary.
- Prompts, skills, MCP descriptions, and client approval settings are workflow guidance—not authorization.
- Enforcement belongs in API authentication, controller policy, AEGIS, worker eligibility, runtime configuration, host networking, and non-bypassable credentials.
- Never put secrets in prompts, argv, labels, image names, logs, or committed MCP configuration.
- Default network access to
deny; request only the resources and lifetime required. - Keep controller and worker credentials separate and rotate both through the deployment secret system.
Read the full security model and private reporting policy before exposing Sandbox beyond a trusted environment.
Operate and recover
| Signal | Inspect | Do not do |
|---|---|---|
no_capacity | Node freshness, resource headroom, labels, pressure, isolation tiers, and policy score. | Do not lower the isolation floor as a shortcut. |
| Repeated assignment | Lease expiry, worker reachability, operation idempotency, and assignment completion logs. | Do not create a second sandbox blindly. |
| Wait timeout | Read the original operation and current sandbox state. | Do not assume the underlying mutation failed. |
| Truncated output | Exit code, stderr, operation error, and configured output bounds. | Do not report complete output. |
The operations runbook covers health, metrics, logs, backups, restoration, upgrades, cleanup, and capacity drills.
Canonical Markdown
These files are served as raw Markdown with no-cache and nosniff headers. Humans can read them directly; agents can fetch only the reference needed for the current task.