Introducing a new way to review your PRs.

Read the announcement

gotempsh / temps

AI-native open-source alternative to Vercel + Sentry + PostHog + Pingdom + Resend + E2B. 440+ CLI operations with drop-in skills for Claude Code, Codex & OpenCode — deployments, analytics, session replay, error tracking, OpenTelemetry, email, sandboxes & AI gateway in one self-hosted Rust binary.

View on GitHub

25 documents · Updated Oct 21, 2026

docs / sandbox-platform

Sandbox platform

The sandbox platform gives users and AI workflows isolated places to run code, keep work files, and expose selected services. The control plane owns identity, access, records, placement, and public interfaces. A local host or joined worker runs the sandbox.

Platform model

Sandbox resources

A sandbox is an isolated compute resource with a public identity, a work area, an owner, a life span, and a host node. It may belong to a project or an agent run. Standalone sandboxes remain visible through their own API so clients can list and operate them.

The platform supports these resource roles:

  • Ephemeral sandboxes provide throwaway space for commands or checks.
  • Workspace sandboxes keep files while compute sleeps during idle periods. Later use wakes the workspace.
  • Agent sandboxes run an AI or workflow job. The owning run controls their life cycle.
  • Application workspace sandboxes provide durable work areas for managed AI applications. They stay on the control plane because their work area belongs to that plane. The generic sandbox API hides these workspaces so application routes can apply their own project access rules.

Clients can start a sandbox from a base image, a Git or archive source, or a saved snapshot. The public response also identifies the host node and the isolation backend.

References: crates/…/sandbox_service.rs• L88-205 crates/…/sandbox_service.rs• L690-733 crates/…/sandbox_service.rs• L1812-1823

Provider boundary

The sandbox provider is the shared capability boundary for the standalone API, agent runs, workspace services, and other callers. It gives these callers one model for creating and operating sandboxes without binding them to one isolation system.

The standalone sandbox service joins this boundary during plugin setup. It shares the provider with registry and snapshot services, while optional integrations such as runtime credentials and project access add policy around the common resource model.

The same boundary can use a local provider or a worker provider. A routing layer sends creation to the selected node and sends later actions to the node recorded with the sandbox. This keeps placement out of most consumers and prevents a worker sandbox from being treated as local.

References: crates/…/plugin.rs• L74-155 crates/…/mod.rs• L381-406 crates/…/node_routing.rs• L4-18 crates/…/node_routing.rs• L78-84

Sandbox creation and operation

Creation flow

Sandbox creation turns a user or internal request into a recorded sandbox and an isolated environment. The control plane checks access and request values before it resolves a source or snapshot, selects a host, and asks the provider to create the resource.

The main flow is:

flowchart LR
    A[User or AI workflow] --> B[Sandbox interface]
    B --> C[Access and request checks]
    C --> D[Source or snapshot resolution]
    D --> E[Placement choice]
    E --> F[Local provider]
    E --> G[Worker agent]
    F --> H[Recorded sandbox and response]
    G --> H

Creation can set limits, environment values, a lifecycle class, preview ports, preview protection, an isolation backend, a project, a source, a snapshot, or a node. Sources are checked before fetch. The checks block private or metadata network targets and credentials embedded in URLs. Project and repository access also apply when the platform derives a source from a project or stored Git connection.

Managed application workspaces are a special case. Their durable host work area requires control-plane placement, so a request for another node is rejected rather than silently ignored. Worker creation also includes a live provider check before the sandbox row is written.

Snapshots are reproducible starting states. A snapshot cannot be combined with an image. Snapshot restore is limited to supported backends and is not yet available on worker nodes. If creation or source seeding fails, the platform keeps the record consistent with the host resources.

References: crates/…/sandbox_service.rs• L1790-1842 crates/…/sandbox_service.rs• L2064-2089 crates/…/sandbox_service.rs• L2150-2300 crates/…/sandbox_service.rs• L852-1001

Sandbox operations

The platform exposes a sandbox as a place where a client can run commands and work with files. It also supports background jobs, lifecycle actions, declared service ports, project runtime values, preview access, and an operations timeline.

The main capability groups are:

  • Compute: run commands, stream output, control processes, and destroy the sandbox.
  • Files: inspect paths, browse directories, read files, write files, and upload content.
  • Work: seed content from Git or an archive and attach a project.
  • Lifecycle: stop, resume, restart, extend idle time, and resize supported disks.
  • Exposure: declare ports, build preview routes, protect previews with a password, and mint short-lived share links.
  • History: inspect lifecycle events without mixing shell activity into the record.

An interactive terminal is a separate WebSocket capability. It keeps the shell tab alive when the browser disconnects and replays recent output when a client reconnects. The platform limits terminal sessions and marks an attached terminal as activity so an active session is not suspended.

Directory access is bounded and page based. Listings identify files, directories, symbolic links, and other entries without following links. The console uses this view to move through a sandbox work area and open a selected file.

The sandbox execution and placement page explains the operation paths and node rules in more detail.

References: crates/…/sandboxes.rs• L1000-1133 crates/…/sandboxes.rs• L1222-1271 crates/…/node_routing.rs• L390-430 crates/…/terminal.rs• L4-36 crates/…/fs.rs• L33-94

Snapshot lifecycle

Snapshots turn a running sandbox into a reusable, content-addressed starting state. The service protects the capture flow by removing temporary credentials before it stops and captures the sandbox, then starts it again when needed.

Snapshot storage is owned by the user and subject to a quota. A snapshot is usable only after capture and integrity checks finish. The platform deduplicates shared content and removes artifacts only when no ready snapshot still uses them. Restore requires a ready snapshot with a matching backend and valid companion workspace data.

The standalone API hides snapshots that belong to managed application workspaces. Those snapshots follow the application's access rules and cannot be used to create a generic sandbox through an opaque snapshot ID.

Worker sandboxes cannot take or restore snapshots yet. Local and microsandbox backends also do not provide the snapshot format. These limits are returned as clear API errors instead of silently changing the requested backend.

References: crates/…/snapshot_service.rs• L89-106 crates/…/snapshot_service.rs• L157-195 crates/…/snapshot_service.rs• L704-849 crates/…/snapshot_service.rs• L994-1110

Worker placement

Placement policy

Placement decides where a new sandbox runs while the control plane remains the owner of the decision. By default, automatic placement favors the control plane. If it is excluded, the platform ranks allowed workers by live sandbox count and checks that a worker can serve the request.

Operators control new placement with an allow-list:

ChoiceResult
nullEvery node may receive new sandboxes.
[0, ...]Only the listed nodes may receive new sandboxes. 0 means the control plane.
[]No new sandbox can be created.

An explicit node name or ID is strict. If that node is missing, disallowed, offline, stale, or not ready, creation fails instead of moving the sandbox elsewhere. Automatic placement skips dedicated nodes unless the request names one. It probes only a bounded set of ranked workers before reporting that no ready node exists.

The sandbox execution and placement page gives the detailed placement and remote-execution model.

References: crates/…/placement.rs• L4-17 crates/…/placement.rs• L238-415 crates/…/sandbox_service.rs• L1812-1842

Node registration and health

Workers join the control plane before they can receive sandboxes. Registration establishes identity and connection details. Heartbeats keep status and capabilities current so placement and operators can use live information.

The node view combines:

  • Capacity and labels for scheduling.
  • Container architecture for image compatibility.
  • Network and public-ingress health.
  • Sandbox and container counts for drain and removal decisions.
  • Backend and terminal capability status for operator guidance.

The control plane can require authenticated worker transport. It rejects unsafe or conflicting node identities and records capability changes that affect placement.

References: crates/…/nodes.rs• L132-185 crates/…/nodes.rs• L1588-1707 crates/…/node_service.rs• L175-235 crates/…/placement.rs• L524-566

Node state

The placement view shows whether each node is allowed and ready for new sandboxes. It also shows status, the reason a node is blocked, whether it is dedicated, and the number of live sandboxes.

Draining a worker stops new placement but does not move existing sandboxes. Removing a worker with live sandboxes is blocked. An administrator can evict those sandboxes instead. Eviction first cordons the node so new creates cannot race the cleanup. Its result separates confirmed removals, unconfirmed containers, and sandboxes that need another attempt.

References: crates/…/placement.rs• L212-218 crates/…/placement.rs• L482-521 crates/…/sandbox_service.rs• L1924-2005 crates/…/sandbox_service.rs• L4109-4157 crates/…/placement.rs• L293-465

Remote execution boundary

The control plane reaches a worker through the worker agent. The worker runs the provider action on its local host and returns a bounded result. This keeps the basic sandbox contract consistent while the control plane remains the authority for access and public state.

sequenceDiagram
    participant C as Control plane
    participant A as Worker agent
    participant S as Sandbox
    C->>A: Authenticated sandbox request
    A->>S: Local provider action
    S-->>A: Result or output
    A-->>C: Bounded response
    C-->>C: Apply public state and error rules

Worker nodes do not yet provide every control-plane feature. Current worker limits include previews, interactive terminals, snapshots, disk resize, volumes, and some isolation backends. The platform reports these limits instead of silently moving the sandbox.

References: crates/…/remote.rs• L4-36 crates/…/remote.rs• L443-467 crates/…/sandbox_handlers.rs• L4-25 crates/…/error.rs• L266-340

Lifecycle and persistence

Sandbox states

The sandbox record tracks public identity, ownership, host node, current state, activity time, expiry time, lifecycle class, and settings needed to describe or recover the resource. The record can remain after destruction so the platform can retain history and audit context.

Idle expiry suspends compute. An ephemeral sandbox stays stopped until a caller resumes it. A workspace sandbox wakes on file or command use and keeps its files until explicitly destroyed. A sandbox linked to an agent run follows that run's life cycle, so standalone lifecycle actions do not override the run.

Lifecycle updates are conditional on the state and activity version that the caller read. This prevents a delayed worker result from changing a row after another action has destroyed or resumed the sandbox.

References: crates/…/sandbox_service.rs• L88-137 crates/…/sandbox_service.rs• L1050-1074 crates/…/sandbox_service.rs• L4230-4294 crates/…/row_status.rs• L4-67

Recovery and node loss

The control plane recovers local sandboxes at startup and recovers worker sandboxes when they are first used. This avoids making control-plane startup wait for every worker-owned sandbox. Lifecycle actions can also recover a provider handle by the sandbox's public identity after a process restart.

Recovery uses the node recorded with the sandbox. A worker sandbox that cannot be reached is reported as unavailable rather than missing, because the resource may still exist on that worker. A normal destroy keeps the record when removal cannot be confirmed. An administrator can use node eviction when the worker is gone for good.

The registry also distinguishes planned downtime from an unexpected loss. Snapshot, restart, and disk operations can stop a sandbox without allowing a concurrent liveness check to mark it lost. When a recovered workspace is reused, managed harness processes are fenced before the next managed operation while user processes remain available.

Firecracker and microsandbox VMs run as children of the Temps service. On Linux, startup warns when the service restart policy would kill those VMs. The registry still recovers surviving resources by name, while a stopped VM is reported as an existing sandbox that needs resume or recreation rather than as an unknown ID.

References: crates/…/plugin.rs• L162-345 crates/…/registry.rs• L390-463 crates/…/registry.rs• L537-675 crates/…/registry.rs• L678-780 crates/…/sandbox_service.rs• L504-511

Platform interfaces

HTTP API

The HTTP API is the main contract for creating and operating sandboxes. It uses opaque sandbox IDs, user-scoped access, SDK-shaped responses, and structured problem responses so clients can distinguish invalid input, missing resources, unavailable nodes, and worker-only features.

The sandbox plugin exposes these routes only when the shared provider and service are available. It also publishes the OpenAPI description used by clients and SDK generation. Placement state and administrator controls cover node policy, per-node sandbox views, and eviction. Sandbox responses include the host node. Preview routes appear only when the platform can serve them.

References: crates/…/plugin.rs• L351-397 crates/…/mod.rs• L53-171 crates/…/sandboxes.rs• L4-14 crates/…/placement.rs• L247-291

Access control

The API supports sandbox-specific permissions and legacy project permissions during migration. Project-derived sources and runtime values also check project scope and access. Creating from a project or using a stored Git connection requires repository-read access.

Host-wide storage inspection, placement changes, node views, and eviction are operator actions. Eviction adds a sensitive-action check before it can destroy sandboxes owned by other users. Managed application workspaces are hidden from the generic sandbox routes so their linked-project checks cannot be bypassed through an opaque sandbox ID.

References: crates/…/sandboxes.rs• L44-92 crates/…/sandboxes.rs• L1195-1222 crates/…/mod.rs• L175-209 crates/…/snapshot_service.rs• L743-849

SDK and CLI access

The SDK and CLI use the same API contract as the console. They let clients create sandboxes, run commands, work with files, manage lifecycle, inspect status, choose a node, and operate worker placement.

The console provides REST and SDK examples beside the create action. This gives a human operator, an automation script, and an application client the same platform behavior.

References: web/…/CreateSandboxDocs.tsx• L18-21 web/…/CreateSandboxDocs.tsx• L69-120 apps/…/sandbox-api.ts• L49-110 apps/…/index.ts• L29-38

Operator console

The web console covers sandbox configuration and the sandbox lifecycle from creation to day-to-day work. Operators can choose an isolation backend, runtime, resource limits, workspace-file limits, ports, preview protection, and worker placement. A detail view can browse directories, open and edit small text files, attach a terminal, manage preview access, and explain backend limits.

Workflow settings show host readiness before an operator selects an isolation backend. They also expose runtime presets or a custom image, shared configuration sources, and a streamed image rebuild. Changes use one save boundary so platform-wide sandbox settings do not overwrite provider credentials.

Harness settings are a separate operator surface. A provider connection can be reused across workspaces, while advanced settings control model discovery, the instance default, diagnostics, and autofix turn limits. The interface keeps a saved credential distinct from a verified credential and from a workspace-ready connection.

References: web/…/AgentSandboxSandboxPage.tsx• L126-185 web/…/AgentSandboxSandboxPage.tsx• L187-295 web/…/AgentSandboxSandboxPage.tsx• L473-553 web/…/AgentSandboxProviderDetail.tsx• L117-197 web/…/AgentSandboxProviderDetail.tsx• L222-339 web/…/AgentSandboxProviderDetail.tsx• L462-640

Security boundaries

Control-plane authority

The control plane checks ownership and permissions before it performs a sandbox operation. A worker only executes the request it receives and does not decide which user may access a sandbox.

The worker validates the sandbox identity and container label. It derives work paths on the worker instead of accepting host paths from the control plane. This limits remote calls to the intended sandbox and keeps the worker's host layout private.

References: crates/…/sandbox_service.rs• L4-15 crates/…/sandbox_handlers.rs• L12-20 crates/…/sandbox_handlers.rs• L195-235

Transport and data limits

Worker calls carry tokens, environment values, file data, and command output. The control plane therefore requires authenticated worker transport and fails closed when required sandbox defaults are not available.

Remote output, file reads, uploads, directory listings, WebSocket messages, terminal sessions, and error text have bounds. These limits protect the control plane and the console from large or hostile responses. Worker error text is cleaned and capped before it reaches a client.

References: crates/…/node_routing.rs• L435-446 crates/…/node_routing.rs• L657-717 crates/…/remote.rs• L72-114 crates/…/sandbox_service.rs• L649-665

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the sandbox node and backend aligned across the persisted record, provider handle, API response, SDK, CLI, and console.
  • Keep explicit-node errors strict while preserving fallback only for automatic placement.
  • Keep dedicated-node rules aligned between node labels, automatic ranking, explicit requests, and operator views.
  • Keep worker readiness aligned across status, heartbeat age, transport security, provider probes, and capability messages.
  • Keep worker-only feature limits aligned across provider errors, API problem types, CLI messages, and console warnings.
  • Keep lifecycle ownership aligned between standalone sandboxes, workspaces, agent runs, and application workspaces.
  • Keep conditional lifecycle writes aligned with the state and activity version used to make the provider decision.
  • Keep startup recovery and lazy worker recovery aligned with the node recorded in each sandbox row.
  • Keep planned downtime from being reported as VM loss during restart, resize, and snapshot flows.
  • Keep snapshot backend checks, integrity metadata, quota checks, credential scrubbing, deduplication, and restore rules aligned.
  • Keep preview password, preview route, and share-link behavior aligned with the node that hosts the sandbox.
  • Keep terminal session limits, reconnect behavior, replay handling, and idle-activity updates aligned across the WebSocket server and console.
  • Keep directory page bounds, symlink handling, text-size limits, and file-save mode behavior aligned between the API and console.
  • Keep harness credential verification, model discovery, and workspace readiness separate so a saved credential is not shown as ready before verification.
  • Keep the generic sandbox API from exposing managed application workspaces or their snapshots outside their application access checks.

Important failure modes

TriggerConsequenceGuard
A requested worker is missing, blocked, or not readyCreation fails instead of moving the sandbox to another nodeExplicit placement has no fallback; the API returns a typed node problem.
Automatic placement finds only dedicated workersCreation fails even though those workers are activeDedicated workers require an explicit node request.
Allowed workers fail their provider probeCreation fails after a bounded set of checksAutomatic placement reports tried workers and stops at the probe limit.
A worker loses contact during a lifecycle actionThe sandbox cannot be safely treated as destroyed or movedThe record stays tied to the worker until removal is confirmed or an administrator evicts it.
A worker does not support a requested featureThe request fails with a worker-feature errorThe remote provider reports the limit instead of falling back to the control plane.
A node is being evicted during sandbox creationThe new container can outlive its row or the eviction can miss itThe node is cordoned during eviction and creation confirms the row after provider creation.
A snapshot is combined with an image or uses a different backendThe requested starting state cannot be restoredCreation rejects conflicting fields and restore checks backend and artifact metadata.
Snapshot capture starts on a stopped, unsupported, or worker sandboxCapture fails without producing a usable snapshotThe service checks state, backend, and node before it scrubs or stops the sandbox.
A project source resolves to an internal address or carries URL credentialsSandbox creation could reach private services or expose credentialsThe handler and service validate the final source before cloning.
A preview link is requested without a password or on a worker sandboxNo usable share link is createdThe platform requires preview configuration, a running control-plane sandbox, and a password.
A delayed lifecycle result arrives after destroy or resumeA stale result could resurrect a destroyed row or stop a newly active sandboxConditional row updates require the expected state and activity timestamp.
A recovered harness sandbox still has an old managed processA new managed turn can overlap with work from the prior server generationThe registry fences matching managed process trees before reuse and retries on an incomplete fence.
A saved harness credential is not verifiedThe workspace may start with a credential that cannot serve requestsThe console distinguishes saved, verified, and workspace-ready states.

Key files

FileWhy to read it
crates/…/plugin.rsPlugin wiring, optional route exposure, provider dependencies, startup recovery, and background cleanup.
crates/…/sandboxes.rsPublic sandbox API, request checks, response shape, source validation, preview access, and snapshot restore entry points.
crates/…/mod.rsShared API state, OpenAPI registration, route setup, and protection for managed application workspaces.
crates/…/sandbox_service.rsSandbox ownership, source handling, lifecycle classes, application workspaces, node integration, and operator eviction.
crates/…/row_status.rsConditional state writes that prevent delayed lifecycle work from overwriting newer sandbox state.
crates/…/registry.rsProvider-handle recovery, node-aware lookup, liveness distinction, planned downtime, and post-restart managed-process fencing.
crates/…/snapshot_service.rsSnapshot capture, quota, deduplication, artifact checks, access boundaries, and restore rules.
crates/…/placement.rsNode eligibility, dedicated-node rules, automatic placement, explicit node rules, and provider probes.
crates/…/placement.rsPlacement policy, node inspection, eviction, and structured operator outcomes.
crates/…/mod.rsShared provider contract and isolation capability boundary.
crates/…/node_routing.rsLocal-versus-worker dispatch and worker client resolution.
crates/…/remote.rsControl-plane to worker sandbox contract and bounded remote results.
crates/…/sandbox_handlers.rsWorker-side sandbox boundary and container identity checks.
crates/…/nodes.rsWorker registration, heartbeats, node administration, and capability reports.
web/…/AgentSandboxSandboxPage.tsxOperator settings for isolation, runtime, resources, workspace-file limits, image readiness, and worker placement.
web/…/AgentSandboxProviderDetail.tsxHarness connection, model discovery, instance default, diagnostics, and autofix limits.
web/…/SandboxDirectoryBrowser.tsxConsole directory navigation, paging, refresh, and file selection.
web/…/SandboxFilesCard.tsxConsole file editing, reload-on-open behavior, and save preflight.
web/…/SandboxPreviewPasswordCard.tsxConsole preview password set, rotation, generation, and removal flow.
web/…/SandboxNodesCard.tsxOperator view for placement policy, node health, and worker limits.
apps/…/index.tsCLI contract for sandbox access and node operations.