sandbox0

module
v0.1.0-rc.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2026 License: Apache-2.0

README

Sandbox0 logo

Docs Self-hosted License

Sandbox0 is a Kubernetes-native sandbox runtime for AI agents and interactive workloads that need a real bash environment, durable workspace state, and private deployment boundaries.

Modern AI agents need more than a disposable container or a toy code interpreter. They need to run shell commands, install dependencies, keep working directories warm across turns, persist workspace data across restarts, and manage interactive runtimes such as shells, language interpreters, database consoles, and custom REPLs through one consistent runtime layer.

Sandbox0 is built for that operational reality. It combines warm sandbox pools, in-pod process management, persistent volumes with snapshot workflows, node-level network enforcement, and runtime-agnostic deployment choices. Through template-level runtimeClassName, teams can use a standard Kubernetes runtime in development and move to stricter isolation such as gVisor or Kata in production. The result is an agent runtime that feels closer to a reusable machine than a throwaway container.

Some enterprise capabilities are protected by built-in license-based feature gates for operators running Sandbox0 in production environments.

Why It Exists

Most teams hit the same wall when they try to ship AI agents on top of containers:

  • Cold starts are too slow for agent loops that need sub-second to low-second feedback.
  • A plain container is not enough when the agent needs bash, long-lived processes, REPL sessions, database and cache CLIs, and file operations in one environment.
  • Filesystem state disappears as soon as the pod is recycled, which breaks multi-turn workflows and human handoff.
  • Network and tenant isolation become fragile once many agents and users share a cluster.
  • The operational model collapses under real production requirements such as private deployment, regional isolation, and upgrades.

Sandbox0 is built to solve those problems as one system, not as a pile of disconnected components.

What Makes It Different

  • Warm sandbox pools managed by manager, so agent claims can come from pre-created idle pods instead of waiting for a fresh boot on every task.
  • procd inside each sandbox pod, giving Sandbox0 a first-class runtime for command execution, stateful contexts, file I/O, directory watches, and webhook-triggered workflows.
  • Sandbox0 REPL contexts are a unified abstraction for interactive runtimes, so the same interface can back shells, language interpreters, database consoles, and custom REPLs, for example bash, python, sqlite, or redis-cli.
  • Persistent volumes decoupled from sandbox lifetime through storage-proxy, so agent workspaces, caches, checkpoints, and generated artifacts can outlive any single pod.
  • Snapshot, restore, and fork-oriented volume workflows built on JuiceFS plus object storage and PostgreSQL metadata, which is exactly what long-running agent systems need for recovery and reuse.
  • Node-level network control through netd, which watches sandbox policy, transparently redirects traffic, and applies L4/L7 enforcement close to the workload.
  • Runtime-agnostic sandboxing via template runtimeClassName, so the same system can run on a standard Kubernetes runtime in development and move to stronger isolation such as gVisor or Kata in production.
  • A deployment model that scales from a simple single-cluster setup to multi-cluster regional routing with edge-gateway and scheduler.
  • Operator-first lifecycle management, so installation, reconciliation, and upgrades follow a repeatable Kubernetes-native path instead of bespoke scripts.

Built For

  • Coding agents that need a real shell, writable filesystem, package installs, REPL sessions, and multi-step task execution.
  • Agent products that need durable workspaces, checkpoints, and generated artifacts to survive across turns, retries, and pod replacement.
  • Browser automation and interactive runtimes where startup delay is directly visible to end users.
  • Internal developer platforms that want reusable sandbox templates and persistent workspaces without building the infrastructure layer from scratch.
  • Enterprise or regional deployments that need private control over storage, networking, and cluster topology.

Architecture

flowchart TD
    client[Client / API SDK] --> igw[internal-gateway]

    subgraph cluster[Kubernetes Cluster - single cluster full mode]
        direction TB

        subgraph s0[Sandbox0 Services]
            direction LR
            igw --> mgr[manager]
            igw --> pods[Sandbox Pods - procd inside]
            mgr --> pods
            mgr --> netd[netd]
            mgr --> sp[storage-proxy]
        end

        subgraph mw[Middleware Dependencies]
            direction LR
            pg[(PostgreSQL - metadata and state)]
            s3[(S3 / OSS - volume data)]
            reg[(Image Registry - optional)]
        end

        igw --> pg
        sp --> pg
        sp --> s3
        mgr --> reg
    end

Most users start with a single-cluster deployment and only move to multi-cluster when they need regional scale-out. For deeper architecture and deployment details, see https://sandbox0.ai/docs/self-hosted.

Claim A Sandbox

All examples below assume:

  • SANDBOX0_TOKEN contains a valid API token
  • SANDBOX0_BASE_URL optionally overrides the default endpoint for self-hosted deployments

Python

Install:

pip install sandbox0
import os

from sandbox0 import Client
from sandbox0.apispec.models.sandbox_config import SandboxConfig

client = Client(
    token=os.environ["SANDBOX0_TOKEN"],
    base_url=os.environ.get("SANDBOX0_BASE_URL", "http://localhost:30080"),
)

with client.sandboxes.open(
    "default",
    config=SandboxConfig(ttl=300, hard_ttl=3600),
) as sandbox:
    print(f"Sandbox ID: {sandbox.id}")
    print(f"Status: {sandbox.status}")

For Go, TypeScript, CLI, and full getting-started guides, see https://sandbox0.ai/docs/get-started.

Self-Hosted Quickstart

The example below is a minimal kind installation for local evaluation.

Prerequisites:

  • kind
  • kubectl
  • helm

Create a local cluster with the same Kind config used by infra/tests/e2e:

kind create cluster --config kind-config.yaml

kind-config.yaml:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: sandbox0
nodes:
- role: control-plane
  image: kindest/node:v1.35.0
  kubeadmConfigPatches:
  - |
    kind: ClusterConfiguration
    apiServer:
      extraArgs:
        enable-aggregator-routing: "true"
  extraPortMappings:
  # internal-gateway HTTP port
  - containerPort: 30080
    hostPort: 30080
  # registry port for template image push
  - containerPort: 30500
    hostPort: 30500

Install infra-operator:

helm repo add sandbox0 https://charts.sandbox0.ai
helm repo update

helm install infra-operator sandbox0/infra-operator \
    --namespace sandbox0-system \
    --create-namespace \
    --version 0.1.0-rc.5

Apply the minimal single-cluster sample:

It does not include netd or storage-proxy, so it does not provide network policy enforcement or volume capabilities.

kubectl apply -f https://raw.githubusercontent.com/sandbox0-ai/sandbox0/main/infra-operator/chart/samples/single-cluster/minimal.yaml
kubectl get sandbox0infra -n sandbox0-system -w

Get the initial admin credentials:

ADMIN_PASSWORD="$(kubectl get secret admin-password -n sandbox0-system -o jsonpath='{.data.password}' | base64 -d)"
printf 'username: %s\npassword: %s\n' 'admin@example.com' "$ADMIN_PASSWORD"

Configure the local API URL and create a token:

The local kind setup above exposes internal-gateway at http://localhost:30080.

export SANDBOX0_BASE_URL="http://localhost:30080"

s0 auth login

export SANDBOX0_TOKEN="$(s0 apikey create --name test-apikey --role admin --expires-in 30d --raw)"

Production Notes

  • kind is for evaluation only and is not a production deployment shape.
  • Most teams should start with the operator-managed single-cluster setup.
  • Full architecture, configuration, and production deployment guidance live in the self-hosted docs.

For full deployment guidance, see https://sandbox0.ai/docs/self-hosted.

Directories

Path Synopsis
edge-gateway
infra-operator
api/config
+kubebuilder:object:generate=true
+kubebuilder:object:generate=true
api/v1alpha1
Package v1alpha1 contains API Schema definitions for the infra v1alpha1 API group +kubebuilder:object:generate=true +groupName=infra.sandbox0.ai
Package v1alpha1 contains API Schema definitions for the infra v1alpha1 API group +kubebuilder:object:generate=true +groupName=infra.sandbox0.ai
internal-gateway
manager
cmd/manager command
cmd/procd command
Package main is the entry point for the Procd service.
Package main is the entry point for the Procd service.
pkg/apis/sandbox0/v1alpha1
Package v1alpha1 is the v1alpha1 version of the API.
Package v1alpha1 is the v1alpha1 version of the API.
pkg/generated/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
pkg/generated/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
pkg/generated/clientset/versioned/typed/sandbox0/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
pkg/generated/clientset/versioned/typed/sandbox0/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
procd/pkg/context
Package context provides context management for Procd.
Package context provides context management for Procd.
procd/pkg/file
Package file provides file system operations for Procd.
Package file provides file system operations for Procd.
procd/pkg/http
Package http provides the HTTP server for Procd.
Package http provides the HTTP server for Procd.
procd/pkg/http/handlers
Package handlers provides HTTP handlers for Procd.
Package handlers provides HTTP handlers for Procd.
procd/pkg/process
Package process provides process management for Procd.
Package process provides process management for Procd.
procd/pkg/process/cmd
Package cmd provides one-time command execution.
Package cmd provides one-time command execution.
procd/pkg/process/repl
Package repl provides configurable REPL process implementations.
Package repl provides configurable REPL process implementations.
netd
cmd/netd command
pkg
apispec
Package apispec provides primitives to interact with the openapi HTTP API.
Package apispec provides primitives to interact with the openapi HTTP API.
auth
Package auth provides authentication context and utilities for the sandbox0 gateway.
Package auth provides authentication context and utilities for the sandbox0 gateway.
cache
Package cache provides a thread-safe in-memory cache with TTL and LRU eviction.
Package cache provides a thread-safe in-memory cache with TTL and LRU eviction.
clock
Package clock provides a synchronized clock across multiple clusters by periodically syncing with a shared PostgreSQL database.
Package clock provides a synchronized clock across multiple clusters by periodically syncing with a shared PostgreSQL database.
internalauth
Package internalauth provides internal token-based authentication for inter-service communication within the sandbox0 infrastructure.
Package internalauth provides internal token-based authentication for inter-service communication within the sandbox0 infrastructure.
k8s
migrate
Package migrate provides a universal database migration solution for sandbox0 services.
Package migrate provides a universal database migration solution for sandbox0 services.
observability
Package observability provides unified observability (tracing, metrics, logging) for all types of clients used in the infra codebase.
Package observability provides unified observability (tracing, metrics, logging) for all types of clients used in the infra codebase.
sandbox0-ui
scheduler
cmd/scheduler command
scripts
license-sign command
storage-proxy
pkg/coordinator
Package coordinator handles distributed coordination for snapshot operations across multiple storage-proxy instances using PostgreSQL LISTEN/NOTIFY.
Package coordinator handles distributed coordination for snapshot operations across multiple storage-proxy instances using PostgreSQL LISTEN/NOTIFY.
pkg/watcher
Package watcher provides Kubernetes resource watchers for storage-proxy.
Package watcher provides Kubernetes resource watchers for storage-proxy.
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL