sbox-sdk
v0.2.4
Published
One unified SDK for agent sandbox providers (E2B, Vercel, Daytona, Modal, Fly Sprites, Tensorlake, Superserve, Freestyle, Upstash Box, Boat, Microsandbox, Baseten, Buddy, Luxor, Archil, boxd, Maritime, Agent37, Docker and more) — swap the adapter import,
Maintainers
Readme
sbox-sdk 
One unified SDK for agent sandbox providers. Write your code against a stable
Sandbox / SandboxClient interface. Swap the adapter import to change provider,
and the rest of your code stays the same.
Status: alpha (
0.x). Adapters for every provider in the table below, plus a built-in in-memory provider. Every adapter passes the shared conformance suite offline against a fake of its real SDK.dockerandagentosalso pass it live; the cloud adapters need live verification with real accounts (seepnpm test:live).
📚 Docs: sbox-sdk.vercel.app
Install
npm install sbox-sdk
# then install the provider SDK you use (an optional peer dependency):
npm install @e2b/code-interpreterQuickstart
import { createSandboxClient } from "sbox-sdk";
import { e2b } from "sbox-sdk/e2b";
const client = createSandboxClient({
provider: e2b({ apiKey: process.env.E2B_API_KEY! }),
});
const sandbox = await client.create({
template: "base",
lifecycle: { idleTimeoutMs: 10 * 60_000, onIdle: "pause" },
});
// exec: await for a buffered result (never throws on non-zero exit):
const res = await sandbox.commands.run("echo hi", { cwd: "/tmp" });
console.log(res.exitCode, res.stdout);
// ...or for-await the SAME handle to stream live:
for await (const ev of sandbox.commands.run(["python", "train.py"])) {
if (ev.type === "stdout") process.stdout.write(ev.data);
}
// filesystem (web-standard bodies in, StoredFile out):
await sandbox.files.write("/tmp/data.json", JSON.stringify({ ok: true }));
const text = await (await sandbox.files.read("/tmp/data.json")).text();
await sandbox.destroy();
await client.dispose();Zero config? createSandboxClient() defaults to a built-in in-memory provider,
which is useful for tests and local dev:
const sb = await createSandboxClient().create();
await sb.commands.run("echo works offline");Build a template from a Dockerfile
Templates build in your own provider account and are cached by content hash,
so the second create() boots instantly instead of rebuilding:
const sandbox = await client.create({
template: { source: { dockerfile, context: "./desktop" } },
resources: { vcpus: 2, memoryMB: 4096, shmMB: 1024 },
onTemplateEvent: (e) => console.log(e),
});Previews a browser can open
import { browserUrl } from "sbox-sdk";
const vnc = await sandbox.ports!.expose(6080, { visibility: "private" });
const ws = browserUrl(vnc, { protocol: "ws", path: "/websockify" });browserUrl bakes in query-token or signed-URL auth, and throws when a provider
only supports header auth. Check client.capabilities.flags.previewBrowserAuth.
Swap providers, keep your code
import { daytona } from "sbox-sdk/daytona";
const client = createSandboxClient({
provider: daytona({ apiKey: process.env.DAYTONA_API_KEY! }),
});
// every sandbox.commands / sandbox.files call site above is unchangedEach provider declares a static capability table. Sub-APIs a provider can't
do (code, ports, snapshots, network, pty, ssh, templates, volumes)
are typed undefined (a compile error to call), and unsupported features throw
NotSupportedError before any network call.
Providers
| Provider | Import | Peer SDK | Templates | Browser-safe private previews |
| ------------------ | ----------------------------- | ----------------------------------------- | ---------------------------- | ----------------------------- |
| Docker (local) | sbox-sdk/docker | none (Engine API) | ✅ | n/a (localhost) |
| Rivet agentOS | sbox-sdk/agentos | @rivet-dev/agentos-core (Node 22+) | ❌ | n/a (no ports) |
| E2B | sbox-sdk/e2b | @e2b/code-interpreter | ✅ | ❌ (header token) |
| Daytona | sbox-sdk/daytona | @daytona/sdk | ✅ | ✅ |
| Vercel | sbox-sdk/vercel | @vercel/sandbox | ❌ | ❌ (public only) |
| Modal | sbox-sdk/modal | modal | ✅ | ✅ |
| Tensorlake | sbox-sdk/tensorlake | none (tensorlake for builds) | ✅ | ❌ (header token) |
| Superserve | sbox-sdk/superserve | @superserve/sdk | ✅ | ✅ |
| Fly Sprites | sbox-sdk/sprites | @fly/sprites | ❌ | ❌ |
| Freestyle | sbox-sdk/freestyle | freestyle | ✅ | ❌ |
| Together | sbox-sdk/together | together-sandbox | ✅ | n/a |
| Boat | sbox-sdk/boat | @boatdev/sdk | ✅ (snapshot-only, emulated) | ✅ (query token) |
| Upstash Box | sbox-sdk/upstash-box | @upstash/box | ❌ | ❌ (header token) |
| Styne | sbox-sdk/styne | none (REST) | ✅ (image) | ❌ (header token) |
| Agent37 | sbox-sdk/agent37 | none (REST) | ✅ | ✅ (signed URL) |
| Instabox | sbox-sdk/instabox | @insforge/instabox-sdk | ❌ | ✅ (query token) |
| Microsandbox | sbox-sdk/microsandbox | microsandbox (Node 22+, native runtime) | ❌ | n/a (localhost) |
| Microsandbox Cloud | sbox-sdk/microsandbox-cloud | microsandbox (Node 22+) | ❌ | ❌ (Services not mapped) |
| Baseten | sbox-sdk/baseten | @basetenlabs/[email protected] | ✅ | ⚠️ query; WS unverified |
| Buddy Sandboxes | sbox-sdk/buddy | @buddy-works/[email protected] | ❌ | ❌ (Basic header) |
| Luxor | sbox-sdk/luxor | @luxorai/sandbox (Node 22+) | ✅ (Luxor image/snapshot) | ❌ (public only) |
| Archil | sbox-sdk/archil | disk >=1.15.1 | OCI image | ❌ (header token) |
| boxd | sbox-sdk/boxd | @boxd-sh/sdk | ❌ | public only |
| Maritime | sbox-sdk/maritime | maritime-sdk | ✅ | ✅ (query token) |
| Blaxel | sbox-sdk/blaxel | @blaxel/core | ✅ | ✅ |
| Beam | sbox-sdk/beam | @beamcloud/beam-js | ✅ | n/a |
| Railway | sbox-sdk/railway | railway | ❌ | n/a |
| Northflank | sbox-sdk/northflank | @northflank/js-client | ✅ (image) | ❌ |
| Fly Machines | sbox-sdk/fly | none (REST) | ❌ | n/a |
| AWS Lambda | sbox-sdk/aws-lambda | @aws-sdk/client-lambda-microvms | ✅ | ❌ |
| Morph ⚠️ | sbox-sdk/morph | morphcloud | ✅ | ❌ |
| Cloudflare ⛔ | sbox-sdk/cloudflare | @cloudflare/sandbox ~0.12 | ❌ | n/a |
| CodeSandbox ⛔ | sbox-sdk/codesandbox | @codesandbox/sdk | ❌ | ❌ |
| Runloop ⛔ | sbox-sdk/runloop | @runloop/api-client | ❌ | n/a |
⚠️ maintenance-only (unmaintained upstream TS SDK) · ⛔ deprecated, removed in 0.2. Full capability matrix: sbox-sdk.vercel.app/general/capabilities.
AI agent tools
Turn any sandbox into a framework-shaped tool set with a risk/approval policy:
import { ai } from "sbox-sdk/ai";
import { aiSdk } from "sbox-sdk/ai-sdk";
const client = createSandboxClient({
provider: e2b(),
plugins: [
ai({ framework: aiSdk(), policy: { defaults: { destructive: "ask" } } }),
],
});
const sandbox = await client.create();
// sandbox.tools is typed for the Vercel AI SDK, capability-gated + policy-awareAdapters ship for the Vercel AI SDK, Mastra, OpenAI Agents, Anthropic, and LangChain. See the AI docs.
Microsandbox is beta. microsandbox() selects local microVMs and
microsandboxCloud() selects a retained cloud context. Both factories are also
exported from sbox-sdk/microsandbox. Install a matching native binding as
explained in the adapter guide.
Image references go directly in template; Sandboxfiles are not Dockerfiles and
templates.build() is unsupported. Local previews are public loopback HTTP.
Cloud Services are not mapped because SDK 0.8.3 cannot bind them to a context.
Network policies and whole-second idle/max-age limits apply at creation; live
policy/timeout changes and secrets-vault lookups are unsupported.
CLI
The package ships a sbox bin. Credentials come from the environment
(E2B_API_KEY, DAYTONA_API_KEY, …); caps and doctor run fully offline:
npx sbox caps daytona # print a provider's capability matrix
npx sbox doctor e2b # check node + the provider SDK
npx sbox verify e2b # check credentials without creating anything
npx sbox exec microsandbox -- uname -a # local libkrun microVM; native runtime required
npx sbox exec docker -- uname -a # run one command in a fresh sandbox
npx sbox list e2b # list live sandboxes
npx sbox templates build daytona ./desktop # build ./desktop/Dockerfile as a templateLicense
MIT © Vivek Kornepalli
