Language SDK interfaces
This page explains the language-specific SDK interface and packaging responsibilities across Rust, Python, and TypeScript clients. The SDKs give application code a typed way to create and manage ArcBox sandboxes while adapting names, types, async models, and package rules to each language. For the wider SDK model, see client-sdks and api-and-docker-compatibility.
Shared SDK boundary
Each SDK separates the public sandbox interface from the daemon wire contract. An application uses language-native sandbox handles, result types, and errors. The SDK maps those values to the Connect protocol and returns typed values again.
The shared boundary turns one daemon service into three language-native packages without making generated protocol types part of the user-facing API. The daemon's precise error registry takes precedence when the SDK maps failures. Unknown or newer codes fall back to a broader typed error while keeping their machine-readable details. sdk/…/errors.py• L182-260 sdk/…/error.rs• L19-25 sdk/…/errors.ts• L172-233 sdk/…/errors_pb.ts• L72-78
flowchart LR
A[Application] --> B[Language SDK interface]
B --> C[Connection and transport]
C --> D[ArcBox daemon]
D --> C
C --> E[Typed results and errors]
E --> A
The common product surface covers sandbox lifecycle, command execution, file access, port forwarding, events, capabilities, snapshots, and template use. The clients also share run-location selection and lifecycle updates that can leave a setting unchanged, restore its default, or replace it. Recent client releases expose a monotonic sequence number on sandbox events and a storage_bytes measure for retained footprint. Unknown future wire values remain representable as unknown values instead of breaking older clients. sdk/…/_types.py• L23-63 sdk/…/types.rs• L13-27 sdk/…/types.ts• L24-34 sdk/…/README.md• L266-292 sdk/…/README.md• L181-203
Language surfaces
The three SDKs expose the same sandbox goals through interfaces that match their host language. The main differences are the call style, data types, and package entry points rather than the daemon capabilities.
Rust interface
The Rust SDK is the arcbox crate. It presents an async API built around ArcBox as the client entry point and Sandbox as a handle to one sandbox. Public models use Rust enums, structs, Duration, streams, lifecycle update types, and a typed Error result model. sdk/…/lib.rs• L16-50 sdk/…/types.rs• L13-27 sdk/…/types.rs• L207-233
The crate targets the local daemon through its Unix socket. It resolves an explicit socket first, then supported environment settings, and rejects a remote URL because the Rust remote tier is not available yet. sdk/…/connection.rs• L1-12 sdk/…/connection.rs• L46-82
Rust publishes as part of the workspace. Its release must remain compatible with the companion arcbox-connect crate that it publishes in the same workspace release flow. sdk/…/Cargo.toml• L1-24 sdk/…/README.md• L54-63
References: sdk/…/lib.rs• L16-50 sdk/…/sandbox.rs• L47-120 sdk/…/sandbox.rs• L166-355 sdk/…/types.rs• L13-27 sdk/…/types.rs• L207-233 sdk/…/connection.rs• L18-82 sdk/…/Cargo.toml• L1-24 sdk/…/README.md• L54-63
Python interface
The Python package is arcbox and supports Python 3.10 or newer. It provides matching synchronous and asynchronous surfaces through Sandbox and AsyncSandbox, plus ArcBox and AsyncArcBox for programs that keep one client connection for many handles. Context-manager use gives sandbox ownership a clear lifetime. sdk/…/pyproject.toml• L1-13 sdk/…/__init__.py• L1-7 sdk/…/sandbox.py• L116-207
Python uses native seconds, exceptions, mappings, iterators, and async iterators. Its public types cover lifecycle state, capabilities, run locations, snapshots, templates, and typed event data. It also has an E2B-shaped compatibility package so applications can move to the local ArcBox daemon with a small import change. Unsupported E2B features fail as explicit unsupported operations instead of appearing to work with incomplete behavior. sdk/…/_types.py• L7-9 sdk/…/_types.py• L225-390 sdk/…/README.md• L46-52 sdk/…/README.md• L77-134
The async tree is the source for the sync tree. The sync surface is generated and committed, so the two interfaces stay aligned without maintaining two independent feature designs. sdk/…/gen_sync.py• L1-7 sdk/…/gen_sync.py• L96-145 sdk/…/sandbox.py• L1-7
The current Python package release is 0.1.4. Its lock file records the package version and the runtime and development dependency sets used to build and check the package. sdk/…/CHANGELOG.md• L3-14 sdk/…/pyproject.toml• L1-20 sdk/…/uv.lock• L1-58
References: sdk/…/__init__.py• L1-7 sdk/…/__init__.py• L25-55 sdk/…/sandbox.py• L116-207 sdk/…/sandbox.py• L621-913 sdk/…/sandbox.py• L1-7 sdk/…/_types.py• L7-9 sdk/…/_types.py• L225-390 sdk/…/gen_sync.py• L1-7 sdk/…/README.md• L46-52 sdk/…/pyproject.toml• L1-20 sdk/…/uv.lock• L1-58 sdk/…/CHANGELOG.md• L3-14
TypeScript interface
The TypeScript package is @arcbox/sandbox. It exposes ArcBox and Sandbox with promise-based calls, async iterables, typed public interfaces, and JavaScript disposal support. The package also exposes templates and an /e2b entry point for the compatibility surface. sdk/…/index.ts• L1-19 sdk/…/index.ts• L52-79 sdk/…/package.json• L11-25
TypeScript uses JavaScript-friendly names and units such as ttlMs, requestTimeoutMs, Date, and numeric result fields. Public models include capability, run-location, lifecycle, snapshot, and template types. Public models and errors remain hand-written, while generated protocol code stays behind the package entry point. sdk/…/types.ts• L24-214 sdk/…/sandbox.ts• L54-178 sdk/…/index.ts• L4-7
The package targets Node 22 or newer and publishes the built dist package. Its exports define the supported root and E2B entry points, so consumers should not depend on internal source paths. The current package release is 0.1.6. The 0.1.6 release archives older runtime integrations. The 0.1.5 release updates dependencies for disclosed vulnerabilities, while the 0.1.4 release added the event sequence and retained-storage fields. sdk/…/package.json• L11-25 sdk/…/package.json• L57-59 sdk/…/package-lock.json• L1-35 sdk/…/CHANGELOG.md• L3-29
References: sdk/…/index.ts• L1-19 sdk/…/index.ts• L52-79 sdk/…/types.ts• L24-214 sdk/…/sandbox.ts• L54-178 sdk/…/sandbox.ts• L214-341 sdk/…/package.json• L1-25 sdk/…/package.json• L26-35 sdk/…/package.json• L57-59 sdk/…/package-lock.json• L1-35 sdk/…/CHANGELOG.md• L3-29
Connection and transport
All three SDKs let callers select a local daemon connection and leave the wire details to the SDK. The local path is the default, while the Python and TypeScript interfaces also accept a remote URL and API key for a user-managed daemon proxy.
Connection selection
The normal local connection uses the daemon Unix socket. An explicit connection option takes priority over environment values, and the default socket is derived from the ArcBox data directory and profile. Python and TypeScript reject a connection that sets both local and remote targets. Rust currently treats a remote URL as an unsupported choice. sdk/…/_connection.py• L28-46 sdk/…/_connection.py• L87-113 sdk/…/connection.ts• L15-33 sdk/…/connection.ts• L91-120
The connection choice affects how the SDK reaches the same sandbox service, not what a sandbox handle means. Unary requests use the configured request deadline, while long-lived streams remain open without that default deadline. A truncated stream is surfaced as a connection-loss error instead of a successful result. sdk/…/_client.py• L59-71 sdk/…/_client.py• L102-179 sdk/…/transport.ts• L7-17 sdk/…/transport.ts• L72-80
References: sdk/…/_connection.py• L28-46 sdk/…/_connection.py• L87-113 sdk/…/connection.ts• L15-33 sdk/…/connection.ts• L91-120 sdk/…/connection.rs• L46-82 sdk/…/_client.py• L102-179 sdk/…/transport.ts• L7-17
Wire mapping
The protocol messages are an internal transport concern. Rust maps them into public structs and enums, Python keeps generated protobuf modules private, and TypeScript keeps generated modules out of its package exports. This preserves a stable language-level interface when wire details change. sdk/…/types.rs• L1-5 sdk/…/__init__.py• L1-7 sdk/…/index.ts• L1-7
Protocol generation is therefore part of the contract boundary rather than the public package surface. Python regenerates its private protobuf modules from the repository protocol definitions, and TypeScript generates its private modules from the same source tree. The generated models carry fields such as run location and lifecycle presence, while the hand-written layers decide how those fields appear in each language. sdk/…/sandbox_pb2.py• L1-5 sdk/python/src/arcbox/_gen/sandbox_pb2.pyi#L14-L24 sdk/…/sandbox_pb.ts• L1-23 sdk/…/gen_proto.py• L1-9 sdk/…/buf.gen.yaml• L1-19
References: sdk/…/types.rs• L1-5 sdk/…/__init__.py• L1-7 sdk/…/sandbox_pb2.py• L1-5 sdk/…/sandbox_pb2.pyi• L14-24 sdk/…/gen_proto.py• L1-9 sdk/…/index.ts• L1-7 sdk/…/sandbox_pb.ts• L1-23 sdk/…/buf.gen.yaml• L1-19 sdk/…/errors.py• L233-260 sdk/…/error.rs• L113-139 sdk/…/errors.ts• L197-233
Package and release responsibilities
Each language SDK has its own package identity and release path. Package metadata, generated artifacts, public exports, and release workflow together define what users install and which version they receive.
Package identities
The package responsibilities are split by ecosystem:
| SDK | Install identity | Main runtime contract | Distribution target |
|---|---|---|---|
| Rust | arcbox crate | Async Rust API with typed results | crates.io through the workspace release |
| Python | arcbox package, version 0.1.4 | Sync and async Python APIs | PyPI |
| TypeScript | @arcbox/sandbox package, version 0.1.6 | Node 22+ promise and async-iterator API | npm |
Python and TypeScript keep generated wire code in the source tree but exclude it from their supported public exports. TypeScript publishes the built dist output, while Python builds a wheel from its package source. The lock files keep the resolved package graph aligned with each package manifest. sdk/…/Cargo.toml• L1-17 sdk/…/pyproject.toml• L1-20 sdk/…/uv.lock• L19-58 sdk/…/package.json• L11-25 sdk/…/package-lock.json• L1-35
References: sdk/…/Cargo.toml• L1-17 sdk/…/pyproject.toml• L1-20 sdk/…/uv.lock• L19-58 sdk/…/__init__.py• L64-117 sdk/…/index.ts• L10-102 sdk/…/package.json• L1-25 sdk/…/package.json• L57-59 sdk/…/package-lock.json• L1-35
Release channels
Python and TypeScript release independently from the main ArcBox release train. Release tags select the package tree, verify that the package version matches the tag, run the package gates, build the artifact, and publish through trusted registry credentials. .github/…/release-sdk-python.yml• L1-14 .github/…/release-sdk-python.yml• L94-168 .github/…/release-sdk-typescript.yml• L1-13 .github/…/release-sdk-typescript.yml• L95-153
The current package versions are Python 0.1.4 and TypeScript 0.1.6. The TypeScript 0.1.6 release archives older runtime integrations. Its changelog also records the dependency update in 0.1.5 and the shared event and retained-storage additions from 0.1.4. sdk/…/CHANGELOG.md• L3-14 sdk/…/CHANGELOG.md• L3-29
Rust follows the workspace release path because its package version and its Connect dependency must move together. This makes Rust packaging a workspace concern, while Python and TypeScript packaging are component concerns. sdk/…/README.md• L56-63
References: .github/…/release-sdk-python.yml• L1-14 .github/…/release-sdk-python.yml• L94-168 .github/…/release-sdk-typescript.yml• L1-13 .github/…/release-sdk-typescript.yml• L95-153 sdk/…/CHANGELOG.md• L3-14 sdk/…/CHANGELOG.md• L3-29 sdk/…/README.md• L56-63
Change checklist
When these files or sections are changed, remember to consider these:
- A protocol change must update the generated Python and TypeScript wire layers, then update the public mapping and export layers for Rust, Python, and TypeScript.
- A Python async API change must be made in the async tree first, then reflected in both generated sync trees, including the E2B compatibility tree.
- A public name, error, state, event field, storage measure, run location, capability, template field, or time-unit change must be checked against all three language surfaces and the E2B entry points.
- A lifecycle update change must preserve the distinction between omitted, cleared, and replaced values in each language's public API and on the wire.
- A connection option change must preserve explicit-option precedence, environment precedence, local socket behavior, remote-proxy behavior, and each language's time unit.
- A package version change must stay aligned with the matching release tag, changelog, manifest, and lock file. Rust changes also require the workspace Connect dependency to remain publishable with the SDK.
- A generated-file or export change must keep wire types private unless the public interface intentionally changes.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A Python developer edits _sync code as the source | The sync API drifts from the async API and the lockstep check fails | Edit _async and regenerate the sync trees with scripts/gen_sync.py |
| A protocol field changes without updating public mappers | Applications receive stale, missing, or incorrectly typed values | Regenerate Python and TypeScript wire code and update all language mapping layers |
| A new event, storage, capability, run-location, or template field is released in only one SDK | Applications see different sandbox state or controls based on language | Carry the public model change through all three SDKs and match the package release versions |
| A lifecycle update maps omission to clear or replacement | A caller silently changes a deadline or idle policy that it meant to preserve | Keep omitted, cleared, and set values distinct in the public type and request presence |
Rust receives ARCBOX_API_URL without a socket override | Connection setup returns a typed invalid-argument error because Rust has no remote implementation | Use a local socket or use the Python/TypeScript proxy options when a remote service exists |
| A consumer imports generated modules or internal source paths | The application depends on files that the package does not promise to export | Use the documented package root or the documented /e2b entry point |
| A release tag, manifest, or lock file has a different version | The package release workflow stops before publishing or installs the wrong package revision | Keep the component version, changelog, manifest, and lock file synchronized |
Key files
| File | Why to read it |
|---|---|
| sdk/…/lib.rs | Shows the Rust public API boundary and exported types |
| sdk/…/sandbox.rs | Shows Rust client ownership, lifecycle flow, capability access, and sandbox handles |
| sdk/…/types.rs | Defines Rust public state, event, capability, and lifecycle update models |
| sdk/…/connection.rs | Defines Rust connection selection and local-only behavior |
| sdk/…/error.rs | Defines Rust error classes and registry mapping |
| sdk/…/__init__.py | Shows Python's public sync and async exports |
| sdk/…/sandbox.py | Shows the Python client and sandbox relationship |
| sdk/…/sandbox.py | Shows the generated synchronous mirror of the sandbox surface |
| sdk/…/_types.py | Defines Python's public models and wire mappings |
| sdk/…/_connection.py | Defines Python local and proxy connection selection |
| sdk/…/errors.py | Defines Python error classes and registry mapping |
| sdk/…/gen_sync.py | Defines the async-to-sync packaging and parity rule |
| sdk/…/gen_proto.py | Defines Python wire-code generation from the shared protocol |
| sdk/…/pyproject.toml | Defines the PyPI package identity, Python version floor, and build contract |
| sdk/…/uv.lock | Records the resolved Python package and tool dependencies for the current release |
| sdk/…/index.ts | Defines TypeScript's supported package exports |
| sdk/…/sandbox.ts | Shows the TypeScript client and sandbox interface |
| sdk/…/types.ts | Defines TypeScript's public models and wire mappings |
| sdk/…/connection.ts | Defines TypeScript connection selection and options |
| sdk/…/transport.ts | Defines transport creation and unary deadline behavior |
| sdk/…/errors.ts | Defines TypeScript error classes and registry mapping |
| sdk/…/package.json | Defines npm exports, build output, scripts, and runtime requirement |
| sdk/…/package-lock.json | Records the resolved npm package graph and current package version |
| .github/…/release-sdk-python.yml | Shows the PyPI release checks and publish path |
| .github/…/release-sdk-typescript.yml | Shows the npm release checks and publish path |