Introducing a new way to review your PRs.

Read the announcement

arcboxlabs / arcbox

Run AI agents on real and isolated machines — own kernel, filesystem, and network — with <100ms boot. Local first, OCI compatible, pure Rust.

View on GitHub

32 documents · Updated Nov 6, 2026

docs / client-sdks

Client SDKs

ArcBox provides Rust, Python, and TypeScript SDKs for running and managing isolated sandbox microVMs through the ArcBox daemon. Each SDK gives application code a language-native client and sandbox handle while keeping the core lifecycle, workload, file, network, event, snapshot, and error concepts aligned.

SDK surface

The SDK family supports one broad workflow: connect to a daemon, create or attach to a sandbox, use its workload and data paths, observe its state, and release it. The public surfaces translate the shared ArcBox service model into types and async patterns that fit each language.

CapabilityShared roleLanguage shape
Client entry pointResolve a daemon connection and create sandbox handlesArcBox in Rust, ArcBox or AsyncArcBox in Python, ArcBox in TypeScript
Sandbox accessCreate, attach, inspect, list, pause, and remove sandboxesSandbox handle in all three SDKs
Workload controlRun commands, stream output, manage input, and inspect exit resultscommands surface on each sandbox
File accessRead, write, inspect, change, and watch sandbox filesfiles surface on each sandbox
Network accessWait for guest ports and publish them on the hostports surface on each sandbox
State and reuseObserve lifecycle events and retained storage, then create or restore snapshotsSandbox events, state, and snapshot operations
Template reuseBuild or resolve catalog templates where supportedPython and TypeScript template surfaces; Rust template statics remain deferred
CompatibilitySupport an E2B-shaped API where providedarcbox.e2b in Python and @arcbox/sandbox/e2b in TypeScript

The Rust SDK exposes one async API. Python offers matching synchronous and asynchronous APIs, with the async surface as the source for the synchronous mirror. TypeScript uses promises and async iteration for calls and streams. See Language SDK interfaces for language-level contracts and naming details.

Rust SDK

The Rust SDK is the native async client for local ArcBox use. It exposes ArcBox as the entry point and returns typed sandbox, command, file, port, snapshot, event, capability, and error values without making generated wire types the main application contract. Rust connects through the local Unix socket; applications that need a user-managed daemon proxy use the Python or TypeScript SDK instead. References: sdk/…/README.md• L1-37, sdk/…/lib.rs• L16-50, sdk/…/sandbox.rs• L166-267

Rust groups lifecycle and data-plane actions around a shared async client. A sandbox handle addresses one daemon-owned sandbox and exposes fresh state, workload and file access, port operations, lifecycle events, pausing, and snapshots. The SDK also reports daemon capabilities so an application can choose a supported run location before it creates a sandbox. References: sdk/…/sandbox.rs• L209-267, sdk/…/sandbox.rs• L357-559, sdk/…/sandbox.rs• L662-911, sdk/…/types.rs• L36-163

Python SDK

The Python SDK provides blocking and async ways to use ArcBox. ArcBox and Sandbox serve synchronous programs, while AsyncArcBox and AsyncSandbox provide the matching async workflow; both use the same product concepts and typed error family. Python public types are native data classes and literals rather than generated protocol messages. References: sdk/…/README.md• L1-52, sdk/…/__init__.py• L1-7, sdk/…/__init__.py• L12-55, sdk/…/_types.py• L23-67

Python supports short-lived sandbox entry points and long-lived clients that share a connection across handles. It also provides an E2B-shaped surface for local migrations. The compatibility layer makes unsupported cloud-only behavior explicit instead of presenting it as a local capability. References: sdk/…/README.md• L54-134, sdk/…/sandbox.py• L116-208, sdk/…/sandbox.py• L116-208

Python also exposes the template catalog, snapshots, lifecycle controls, capabilities, and run-location selection through both sync and async surfaces. Time arguments use floating-point seconds, and command exit status remains a result unless the caller opts into raising. References: sdk/…/README.md• L46-52, sdk/…/README.md• L266-292, sdk/…/_types.py• L225-332, sdk/…/test_lifecycle.py• L246-357

TypeScript SDK

The TypeScript SDK provides a promise-based client for Node.js applications. ArcBox manages the shared connection, while Sandbox handles expose commands, files, ports, lifecycle events, snapshots, templates, capabilities, and current sandbox state through typed public interfaces. Its public entry point exports these language-level types and typed errors while keeping generated protocol code private. References: sdk/…/README.md• L1-55, sdk/…/index.ts• L1-103, sdk/…/sandbox.ts• L214-328, sdk/…/sandbox.ts• L661-686

TypeScript uses async iterables for paged lists and long-lived event or output streams. It supports both local socket connections and a user-managed daemon proxy, and its E2B-shaped entry point makes local compatibility limits explicit. References: sdk/…/README.md• L43-111, sdk/…/sandbox.ts• L343-544

The TypeScript surface includes the template catalog as well as lifecycle, snapshot, capability, and run-location controls. Its public state model uses JavaScript dates and millisecond time options, while large wire counters are converted to the package's public number types. References: sdk/…/README.md• L181-203, sdk/…/types.ts• L24-214, sdk/…/types.ts• L433-493

Shared connection model

All three SDKs target the ArcBox daemon through the Connect protocol. Local use resolves a Unix socket from explicit settings or the environment. Python and TypeScript can also use a user-managed daemon proxy through an API URL and optional bearer key, while the Rust SDK supports Unix sockets only. See API and Docker compatibility for the related daemon and image boundaries. References: sdk/…/README.md• L26-37, sdk/…/README.md• L54-75, sdk/…/README.md• L43-55

Each SDK gives explicit connection options priority over environment values and then applies a local default. Python and TypeScript select ARCBOX_API_URL when it is set, while Rust rejects that setting unless an explicit local socket overrides it. This supports zero-configuration local use and lets supported clients select another daemon or transport for tools and tests. References: sdk/…/README.md• L26-37, sdk/…/README.md• L54-75, sdk/…/README.md• L43-55

The clients map daemon and transport failures into public error types. These errors retain operation and machine-readable failure information so application code can distinguish a bad connection, a lost stream, an unsupported capability, and a sandbox failure. References: sdk/…/lib.rs• L16-20, sdk/…/README.md• L46-52, sdk/…/README.md• L37-41

The following diagram shows the common path from application code to a sandbox operation and back to a language-native result.

flowchart LR
    A[Application] --> B[Language SDK client]
    B --> C[Resolved local or proxy connection]
    C --> D[Connect protocol]
    D --> E[ArcBox daemon]
    E --> F[Sandbox service]
    F --> E
    E --> D
    D --> B
    B --> G[Typed result or error]

Sandbox workflow

The main workflow starts with a client entry point and ends with a sandbox handle that represents one sandbox by ID. The handle is an address for a daemon-owned sandbox, so state reads remain fresh rather than becoming a local copy of the sandbox.

When an application creates a sandbox, the SDK can wait until the daemon reports it ready. When it attaches to an existing sandbox, it handles starting, paused, and pausing states before returning a usable handle. All three SDKs expose this lifecycle model in their own async and type conventions. References: sdk/…/sandbox.rs• L256-437, sdk/…/sandbox.py• L268-347, sdk/…/sandbox.ts• L343-464

After a handle is available, the application can use four main data paths:

  • Commands run processes and expose exit results, output, input, and signals.
  • Files move data and inspect or watch paths inside the sandbox.
  • Ports wait for guest services and publish them on the host.
  • Events and state report lifecycle changes, retained storage, and current sandbox information.

Lifecycle events carry a daemon-wide sequence number in all three public models. Because a per-sandbox subscription filters that global sequence, a gap is not proof of a missed event; applications should re-read current state when event history is uncertain. Sandbox state also reports storage_bytes or its language equivalent so paused and running retained data has a visible footprint. References: sdk/…/types.rs• L165-204, sdk/…/_types.py• L225-276, sdk/…/types.ts• L39-114

Snapshots add a reuse path around this workflow. A sandbox can be checkpointed into a catalog entry, then restored as a new ready sandbox with its own identity. Template catalogs extend the same reuse idea for Python and TypeScript clients, while Rust currently leaves template statics deferred. References: sdk/…/sandbox.rs• L472-559, sdk/…/README.md• L286-292, sdk/…/README.md• L200-203

The SDKs treat command exit status as an application result rather than a transport failure. They also distinguish daemon errors, lost streams, and timeouts so callers can choose whether to retry, inspect state, or report a failed operation. References: sdk/…/README.md• L20-24, sdk/…/README.md• L46-52, sdk/…/README.md• L37-41

Public contract boundaries

The SDKs define public language types at the boundary between application code and the wire protocol. Generated protocol types support service calls, but application code uses language-specific names, time units, collections, dates, and error classes. References: sdk/…/types.rs• L1-5, sdk/…/_types.py• L1-9, sdk/…/index.ts• L1-8

The shared concepts stay aligned while their spelling follows each language. Rust uses Duration and SystemTime, Python uses floating-point seconds and Python data types, and TypeScript uses millisecond options and Date values. Engineers moving between SDKs should use Language SDK interfaces for exact names, stream rules, and lifecycle update forms. References: sdk/…/types.rs• L207-233, sdk/…/_types.py• L66-80, sdk/…/sandbox.ts• L127-150

Each SDK exposes capability information from the daemon. This lets an application inspect the daemon version, protocol level, feature flags, run locations, and host support before it depends on a feature. The result is cached per client and can be refreshed when a capability can change during daemon operation. References: sdk/…/sandbox.rs• L209-254, sdk/…/sandbox.py• L133-152, sdk/…/sandbox.ts• L230-262, sdk/…/lifecycle.rs• L448-518

Change checklist

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

  • Keep the Rust, Python, and TypeScript public names aligned with the shared sandbox, snapshot, template, and capability contracts.
  • Update connection precedence and local-versus-proxy behavior in all three SDKs when a connection tier changes.
  • Keep generated wire types behind the public mapping boundary so language users do not depend on protocol-specific shapes.
  • Keep sync and async Python surfaces in lockstep when the async source surface changes.
  • Keep stream lifetime, timeout, and connection-loss behavior consistent with the promise, iterator, and async models of each language.
  • Keep lifecycle event sequence numbers and retained-storage fields aligned across the language mappings.
  • Keep template support differences explicit when a template operation is added to one SDK but not another.
  • Update the E2B compatibility entry points when a supported ArcBox operation or an explicitly unsupported operation changes.

Important failure modes

TriggerConsequenceGuard
A remote API URL is configured for the Rust SDKConnection resolution fails because Rust supports Unix sockets onlyUnset ARCBOX_API_URL or set an explicit local socket; use Python or TypeScript for a user-managed proxy
The daemon socket is missing or the daemon is not reachableThe SDK returns a typed connection error and no sandbox handle is usableStart the daemon or set the socket path for the active profile
A sandbox reaches a terminal state before readinessCreate or connect fails with a typed sandbox-state errorInspect the error and current sandbox state before retrying
A lifecycle event stream ends after events were deliveredThe SDK reports a lost stream rather than treating partial events as completeRe-read sandbox state; re-subscribe only when the application can tolerate missed events
A create or restore response is lost after the daemon may have made the sandboxThe SDK attempts cleanup so an untracked sandbox does not remain aliveKeep the returned handle when successful and inspect or list sandboxes after an uncertain failure
An application assumes all E2B features exist locallyThe compatibility surface raises an unsupported-feature errorCheck the local ArcBox capability and compatibility notes before using cloud-only features
An application requests an unavailable run location or pause operationThe daemon rejects the action with a capability or precondition errorRead capabilities before selecting placement or pause behavior, and refresh when host conditions can change

Key files

FileWhy to read it
sdk/…/lib.rsRust public exports and the native SDK's top-level model
sdk/…/sandbox.rsRust client, sandbox lifecycle, capabilities, snapshots, and event flow
sdk/…/types.rsRust public state, capability, snapshot, and event contracts
sdk/…/README.mdRust connection limits and supported feature scope
sdk/…/__init__.pyPython sync and async public exports
sdk/…/sandbox.pyPython async client, lifecycle, capabilities, and snapshot flow
sdk/…/_types.pyPython public state, capability, snapshot, and event contracts
sdk/…/README.mdPython usage model, E2B surface, template scope, and runtime boundary
sdk/…/test_lifecycle.pyPython lifecycle, capability, event, and wire-contract guarantees
sdk/…/index.tsTypeScript public exports and error contract
sdk/…/sandbox.tsTypeScript client, sandbox lifecycle, capabilities, streams, and snapshots
sdk/…/types.tsTypeScript public state, capability, snapshot, and event contracts
sdk/…/README.mdTypeScript usage model, E2B surface, template scope, and runtime boundary
sdk/…/lifecycle.test.tsTypeScript lifecycle, capability, event, and wire-contract guarantees
docs/language-sdk-interfaces.mdLanguage-specific names, types, and stream details
docs/api-and-docker-compatibility.mdDaemon API and Docker compatibility context for SDK use