boxed

module
v0.0.0-...-86a0368 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT

README ΒΆ

Boxed Logo

Boxed

The Sovereign Code Execution Engine for AI Agents. Run untrusted code safelyβ€”locally or in the cloudβ€”using Docker, Firecracker, or Wasm.

Go Rust TypeScript Python License


The Story πŸ“–

Building an AI Agent that writes code? You have a problem.

  • Run it locally? 🚨 Security Risk. One rm -rf / and your laptop is gone.
  • Run it in cloud? πŸ’Έ Expensive. AWS instances for every user?
  • Use SaaS sandbox? 🐌 Vendor Lock-in. High latency and data privacy concerns.

Meet Boxed. The open-source, sovereign engine that gives your Agents a safe place to play. It provides a unified API to spawn ephemeral sandboxes, execute arbitrary code, and retrieve results instantly.


✨ Features

  • πŸ”’ Pluggable isolation β€” Docker driver ships today; Firecracker and Wasm drivers stubbed behind a single Driver interface.
  • πŸ›‘οΈ Bring-Your-Own-Key auth β€” operator-chosen API key via X-Boxed-API-Key. No vendor accounts.
  • ⚑ Sub-second cold start β€” 303 ms median create+exec+destroy on a developer laptop (see paper).
  • πŸ“ First-class artifacts β€” in-VM Rust agent streams stdout, stderr, and emitted files (images, PDFs, datasets) over JSON-RPC.
  • πŸ”Œ Polyglot SDKs β€” first-class support for TypeScript and Python.
  • 🌐 Network policy β€” coarse EnableNetworking toggle today (Docker none vs bridge); fine-grained egress allow-lists are on the roadmap.

Honest scoping: the current Docker driver enforces a Memory cgroup (default 512 MiB) and runs /tmp and /output as tmpfs, but leaves the container rootfs writable, retains the default Linux capability set (no CapDrop: ALL), does not set PidsLimit, and permits in-PID-namespace ptrace. We report the full escape probe in the paper and close those gaps in the planned Firecracker driver.


πŸš€ Getting Started

πŸ“‹ Prerequisites

To run Boxed locally, you'll need:

  • Go 1.22+ (for the Control Plane)
  • Rust 1.75+ (for the Agent)
  • Docker Desktop (running and accessible)
  • Standard Images: Ensure you have a base image like python:3.10-slim pulled:
    docker pull python:3.10-slim
    

[!NOTE] First Run: The first sandbox creation may take a few seconds while Docker pulls the required images. Subsequent runs are near-instant.


πŸ—οΈ Local Development

We provide a Makefile to simplify the build process.

# 1. Clone the repository
git clone https://github.com/akshayaggarwal99/boxed.git
cd boxed

# 2. Build everything (Agent + CLI)
make build

# 3. Start the Control Plane with Auth
export BOXED_API_KEY="super-secret-key"
./bin/boxed serve --api-key $BOXED_API_KEY

# Cleanup build artifacts
make clean
πŸ” Security & Auth

Boxed uses a Bring Your Own Key (BYOK) model. Since you run your own instance, you define the secret key yourself at startup.

You can set the key via the --api-key flag or BOXED_API_KEY environment variable:

All CLI commands and SDKs must provide this key:

./bin/boxed list --api-key $BOXED_API_KEY

πŸ’» CLI Usage
# Run interactive REPL (Sticky Session)
./bin/boxed repl <sandbox-id> --lang python

πŸ”Œ SDKs
TypeScript
# Local install
npm install ./sdk/typescript
Python
# Local install
pip install -e ./sdk/python

πŸ’» SDK Examples
Python
from boxed_sdk import Boxed

client = Boxed(base_url="http://localhost:8080", api_key="super-secret-key")

# Create a secure session
session = client.create_session(template="python:3.10-slim")

# Run unsafe code
result = session.run("print('hello from boxed')")
print(result.stdout)

# Cleanup
session.close()

πŸ“š Documentation


πŸ“„ Paper

A preprint describing Boxed's design and an open benchmark harness is available in this repo:

Every performance number in the paper expands from a LaTeX macro in paper-v2/tables/numbers.tex, which is generated by bench/analyze/stats.py from those CSVs β€” the prose cannot drift from the data.

paper/ holds the superseded v1 draft. It states that the in-sandbox agent runs as PID 1 and that large artifacts are handed back via a pre-signed URL; neither is true of the implementation. Both are corrected in v2. Read v2.

Headline numbers (MacBook Pro M1 Pro, 16 GB, macOS, Docker Desktop; n=200 cold-start trials):

Metric Value
Median create+exec+destroy 303 ms
p95 / p99 395 ms / 495 ms
Peak throughput 9.8 sandboxes/s
Idle agent RSS (median) 0.4 MiB
Behavioural escape probe 5/12 denied
HumanEval-style agent trace 20/20 passed

To reproduce:

cd bench && make all   # requires `boxed serve` running and BOXED_API_KEY set
Cite
@misc{boxed2026,
  title  = {Boxed: A Sovereign, Polyglot Sandbox Substrate for Autonomous Code-Generating Agents},
  author = {Kumar, Akshay},
  year   = {2026},
  howpublished = {\url{https://github.com/akshayaggarwal99/boxed/blob/main/paper-v2/Boxed-IEEE.pdf}}
}

πŸ› οΈ Architecture

Boxed uses a Control Plane vs Data Plane architecture.

Architecture Diagram

  • Control Plane (Go): REST API + WebSocket gateway with BYOK API-key auth (Echo, ~2.8k LOC, 12 MiB binary).
  • Agent (Rust): Lightweight 1.32 MiB stripped binary injected into every sandbox; streams stdout/stderr/artifacts over JSON-RPC.

πŸ—ΊοΈ Roadmap

  • Docker driver + Go control plane + Rust in-VM agent
  • Polyglot SDKs (TypeScript, Python)
  • Sticky sessions (REPL mode, WebSocket proxy)
  • API-key auth (Bring-Your-Own-Key)
  • Hardening β€” ReadonlyRootfs, CapDrop: ALL, PidsLimit, tighter seccomp profile, fine-grained egress allow-lists via iptables
  • Firecracker driver β€” MicroVMs for stronger isolation
  • Wasm driver β€” sub-millisecond cold start for compatible workloads
  • Pool-based reuse β€” warm sandboxes for sub-millisecond exec (see paper Β§6)
  • Multi-host scheduler

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide.

πŸ“„ License

MIT License β€” do whatever you want with it.

Directories ΒΆ

Path Synopsis
cmd
boxed command
boxed-server command
Package main is the entry point for the Boxed Control Plane server.
Package main is the entry point for the Boxed Control Plane server.
internal
api
cli
driver
Package driver defines the abstraction layer for sandbox backends.
Package driver defines the abstraction layer for sandbox backends.
proto
Package proto defines the JSON-RPC message types for Control Plane <-> Agent communication.
Package proto defines the JSON-RPC message types for Control Plane <-> Agent communication.

Jump to

Keyboard shortcuts

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