BoxLite

PyPI npm crates.io codecov Discord GitHub stars License

The compute substrate for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

## What is BoxLite? A **Box** is a hardware-isolated micro-VM that runs any OCI image — and it persists. Agents install packages, write files, and resume across turns, never from cold. **Why BoxLite** - **Real isolation**: its own kernel — stronger than a container, lighter than a full VM. Small footprint, async-first for fleets. - **Daemonless**: embed as a library — no root, no background service. *(optional server mode)* - **OCI-native**: run any Docker image unchanged (`python:slim`, `node:alpine`, …). - **Controlled networking**: restrict egress with `allow_net`; inject real secrets into configured request headers at the host proxy. - **Embed → cloud**: one engine, from your laptop to a multi-tenant cloud. ## Get started One engine. Embed it, run it, deploy it, distribute it. ### 1 · Embed it — a library in your app Import BoxLite and give your agent an isolated VM to run code — no daemon, no binary. *(Python 3.10+)* ```bash pip install boxlite ``` ```python import asyncio import boxlite async def main(): async with boxlite.SimpleBox(image="python:slim") as box: result = await box.exec("python", "-c", "print('Hello from BoxLite!')") print(result.stdout) asyncio.run(main()) ```
Other languages — Node.js, Go, Rust (and the C SDK) **Node.js** (`npm install @boxlite-ai/boxlite`, Node 18+) ```javascript import { SimpleBox } from '@boxlite-ai/boxlite'; const box = new SimpleBox({ image: 'python:slim' }); try { const result = await box.exec('python', '-c', "print('Hello from BoxLite!')"); console.log(result.stdout); } finally { await box.stop(); } ``` **Go** (`go get github.com/boxlite-ai/boxlite/sdks/go`, Go 1.24+ with CGO) ```go ctx := context.Background() rt, _ := boxlite.NewRuntime() defer rt.Close() box, _ := rt.Create(ctx, "alpine:latest") defer box.Close() result, _ := box.Exec(ctx, "echo", "Hello from BoxLite!") fmt.Print(result.Stdout) ``` **Rust** (`cargo add boxlite tokio futures --features tokio/macros,tokio/rt-multi-thread`) ```rust let runtime = BoxliteRuntime::default_runtime(); let litebox = runtime.create(BoxOptions { rootfs: RootfsSpec::Image("alpine:latest".into()), ..Default::default() }, None).await?; let mut execution = litebox.exec(BoxCommand::new("echo").arg("Hello from BoxLite!")).await?; let mut stdout = execution.stdout().unwrap(); while let Some(line) = stdout.next().await { println!("{}", line); } ``` Full runnable versions: [Python](./sdks/python/), [Node](./sdks/node/), [Go](./sdks/go/), [Rust](./docs/reference/rust/), [C](./sdks/c/).
### 2 · Run it — the binary, one command No code needed — one install, then run any OCI image from your terminal. ```console curl -fsSL https://sh.boxlite.ai | sh boxlite run python:slim python -c 'print("Hello from BoxLite!")' ``` Installs to `$HOME/.local/bin/boxlite`, runtime embedded — no extra setup. Alternatives (`cargo install boxlite-cli`, version pinning, verification) → [CLI reference](./docs/reference/cli/README.md#installation--verification). For an organization with App Hosting enabled, the same CLI can deploy a linked project with `boxlite app deploy` and follow its logs with `boxlite app logs --follow`. [Sign in and link a project](./src/cli/README.md#hosted-apps). ### 3 · Deploy it — a standalone server
Run BoxLite as a REST service; drive it from anything that speaks HTTP. ```bash boxlite serve # Listening on 127.0.0.1:8100 (add --host 0.0.0.0 --api-key "$KEY" to expose it) ``` ```bash curl -s -X POST http://localhost:8100/v1/boxes \ -H 'Content-Type: application/json' \ -d '{"image": "alpine:latest"}' ``` REST-capable CLI commands also work against a running server with `--url`: `boxlite --url http://localhost:8100 list`.
### 4 · Distribute it — your own agentic cloud
Deploy into your own AWS account or GCP project, with a shared control plane and a fleet of VM runners. Start with the [architecture graphs](./apps/infra/docs/architecture.md), then follow the [deployment guide](./apps/infra/docs/deployment.md) for stage configuration, bootstrap, preview and verification. Choose the [AWS guide](./apps/infra/docs/aws/README.md) or [GCP guide](./apps/infra/docs/gcp/README.md) for provider-specific setup, operations and costs. Neither cloud is preferred; the stage declaration selects the provider.
## Next steps - More real-world scenarios → [Examples](./examples/) - How images, disks, networking, and isolation work → [Concepts](./docs/concepts/) ## Features | Area | Capabilities | |------|--------------| | **Execution** | run any OCI image · async exec with streamed stdout/stderr + exit codes · interactive PTY with live resize · per-command timeout, workdir, env, run-as-user · entrypoint/cmd override | | **Isolation & security** | a hardware-virtualized VM per box (KVM / Hypervisor.framework) · OS sandbox (seccomp / sandbox-exec) · CPU, memory & resource limits · egress allow-list (`allow_net`) · secret injection — real values never enter the VM · env sanitization | | **Storage & state** | persists across stop/restart · volume mounts (ro/rw) · per-box QCOW2 disk with copy-on-write · bidirectional file copy · clone, or export/import as `.boxlite` archives · detached boxes that outlive the parent process | | **Networking** | outbound internet · local TCP port forwarding · portable local/remote tunnels · network I/O metrics | | **Images** | pull + cache any OCI image · custom & private [registries](./docs/guides/image-registry-configuration.md) · custom rootfs | | **Observability** | per-box & runtime metrics — CPU, memory, network, boot time, commands · console logs · live `stats` | | **Interfaces** | Python · Node.js · Go · Rust · C SDKs · the `boxlite` CLI · a REST API (WebSocket exec, optional auth) | ## Ecosystem Agent frameworks run on BoxLite: - **[Pydantic AI](https://pydantic.dev/docs/ai/harness/boxlite-sandbox/)** — `BoxLiteSandbox` runs agent commands and file edits in a local micro-VM - **[Databricks Omnigent](https://github.com/omnigent-ai/omnigent)** — sandbox option in their agent meta-harness - **[Alibaba AgentScope Runtime](https://runtime.agentscope.io/en/sandbox/sandbox.html)** — sandbox backend (`CONTAINER_DEPLOYMENT=boxlite`) - **[ByteDance deer-flow](https://github.com/bytedance/deer-flow/tree/main/backend/packages/harness/deerflow/community/boxlite)** — sandbox provider in their research agent - **[Qoder better-harness](https://github.com/QoderAI/better-harness/tree/main/packages/better-harness-desktop/rust/box-service)** — micro-VM box service in the desktop app, built on the Rust crate - **[AstrBot](https://github.com/AstrBotDevs/AstrBot/blob/master/astrbot/core/astr_agent_runtime/computer/booters/boxlite.py)** — per-session computer-use sandbox for its agent assistant - **[HKUDS ClawWork](https://github.com/HKUDS/ClawWork)** — optional code-execution sandbox (`CODE_SANDBOX_PROVIDER=boxlite`) Official examples and guides: - **[Moonshot AI Kimi Agent SDK](https://github.com/MoonshotAI/kimi-agent-sdk/tree/main/examples/python/kaos/boxlite)** — example KAOS backend that runs the agent inside a Box - **[Rivet Sandbox Agent](https://github.com/rivet-dev/agents/blob/main/sandbox-agent/docs/content/docs/deploy/boxlite.mdx)** — guide and examples for deploying Sandbox Agent in a BoxLite micro-VM - **[planning-with-files](https://github.com/OthmanAdi/planning-with-files/blob/master/docs/boxlite.md)** — guide and example for running Claude Code with this skill inside a BoxLite micro-VM ## Architecture How BoxLite embeds a runtime and runs OCI containers inside micro-VMs. Details → [Concepts](./docs/concepts/).
Show diagram ``` ┌──────────────────────────────────────────────────────────────┐ │ Your Application │ │ ┌───────────────────────────────────────────────────────┐ │ │ │ BoxLite Runtime (embedded library) │ │ │ │ │ │ │ │ ╔════════════════════════════════════════════════╗ │ │ │ │ ║ Jailer (OS-level sandbox) ║ │ │ │ │ ║ ┌──────────┐ ┌──────────┐ ┌──────────┐ ║ │ │ │ │ ║ │ Box A │ │ Box B │ │ Box C │ ║ │ │ │ │ ║ │ (VM+Shim)│ │ (VM+Shim)│ │ (VM+Shim)│ ║ │ │ │ │ ║ │┌────────┐│ │┌────────┐│ │┌────────┐│ ║ │ │ │ │ ║ ││Container││ ││Container││ ││Container││ ║ │ │ │ │ ║ │└────────┘│ │└────────┘│ │└────────┘│ ║ │ │ │ │ ║ └──────────┘ └──────────┘ └──────────┘ ║ │ │ │ │ ╚════════════════════════════════════════════════╝ │ │ │ └───────────────────────────────────────────────────────┘ │ └──────────────────────────────────────────────────────────────┘ │ Hardware Virtualization + OS Sandboxing (KVM/Hypervisor.framework + seccomp/sandbox-exec) ``` **Security Layers:** - Hardware isolation (KVM/Hypervisor.framework) - OS-level sandboxing (seccomp on Linux, sandbox-exec on macOS) - Resource limits (cgroups, rlimits) - Environment sanitization
## Documentation - [API & CLI Reference](./docs/reference/) — SDK API references (Python, Node.js, Rust, C), the `boxlite` CLI reference, and the REST API contract ([`openapi/box.openapi.yaml`](./openapi/box.openapi.yaml)) - [Using BoxLite with AI agents](./docs/guides/ai-agent-integration.md) — concurrency, timeouts, security, file transfer - [Examples](./examples/) — Sample code for common use cases - [Concepts](./docs/concepts/) — How BoxLite works ## Supported Platforms | Platform | Architecture | Status | |----------------|-----------------------|------------------| | macOS | Apple Silicon (ARM64) | ✅ Supported | | Linux | x86_64 | ✅ Supported | | Linux | ARM64 | ✅ Supported | | Windows (WSL2) | x86_64 | ✅ Supported | ## System Requirements | Platform | Requirements | |----------------|------------------------------------------------| | macOS | Apple Silicon, macOS 12+ | | Linux | KVM enabled (`/dev/kvm` accessible) | | Windows (WSL2) | WSL2 with KVM support, user in `kvm` group | ## Getting Help - [GitHub Issues](https://github.com/boxlite-ai/boxlite/issues) — Bug reports and feature requests - [Discord](https://go.boxlite.ai/discord) — Questions and community support - [Status page](https://status.boxlite.ai) — Live platform status and incident history - [Security Policy](./SECURITY.md) — How to privately report a vulnerability ## Contributing We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines. ## License Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.