Microsandbox Provider
@smthrs/microsandbox is a first-class Smithers
SandboxProvider backed by the open source
Microsandbox SDK. Each run
boots a local microVM with its own Linux kernel, exchanges the Smithers
request and result over a host-to-guest filesystem channel, and runs the
entry command in between. No daemon or hosted sandbox service is required.
The provider id is microsandbox (exported as MICROSANDBOX_PROVIDER_ID).
0.6.6 SDK requires Node 22 or Bun plus hardware virtualization
(Apple Silicon on macOS, KVM on Linux, Windows Hypervisor Platform on
Windows); run msb doctor on every host before accepting work. Its
snapshots contain disk state only: they require a stopped sandbox and
cold-boot on restore, preserving no memory, running processes, sockets, or
device state. Don’t advertise a sticky workspace as memory-preserving
suspend, instant resume, or a live fork.
Install
The provider package declaresmicrosandbox as an optional dependency,
imported only when a session starts. Install it directly if your package
manager omits optional dependencies:
Usage
Pass the provider object directly to<Sandbox>:
oven/bun:1. Default entry command:
bun /workspace/run-smithers-sandbox.js; put that runner in the image or
provide it with setupFiles. A factory-level command wins over the
<Sandbox command> prop; without either, the default runs.
The provider creates its workdir through sandbox.fs() after boot and passes
that path to each command, not through builder.workdir(), which would
require the directory to already exist in the image.
Smithers prop mapping
Provider options can also set
cpus, maxCpus, memoryMib, maxMemoryMib,
maxDurationSecs, idleTimeoutSecs, security, labels, scripts,
setupFiles, pullPolicy, and sandboxName. configureBuilder(builder, request) is the escape hatch for Microsandbox features Smithers does not
model directly: custom network policies, secret substitution, registry
authentication, rootfs patches, and named or tmpfs volumes.
Request and result contract
The shared kit writes the request JSON below the workdir and gives the entry command two env vars:SMITHERS_SANDBOX_REQUEST_PATH: request JSON to read.SMITHERS_SANDBOX_RESULT_PATH: result JSON to write.
{ bundlePath } or a structured { status, output|outputs, patches?, diffBundle?, runId? }. The provider fills
remoteRunId, workspaceId, and containerId with the Microsandbox name
when the entry omits them.
Parent directories are created through sandbox.fs() before files are
written. Command execution uses execStreamWith(), so an abort signal or
timeout kills the guest process instead of leaving it running past task end.
Network and secrets
Microsandbox runs locally, but its network policy is host-controlled:allowNetwork unset or false disables the interface; true allows public
destinations and DNS while blocking private, link-local, host, and cloud
metadata destinations by default.
The Smithers provider kit still projects egress proxy variables and uploads
an inline CA certificate into the guest; use configureBuilder with
Microsandbox’s NetworkPolicy and secret APIs for destination-level
allowlists or host-side secret substitution.
Important 0.6.6 limitation for production secrets: the raw Go SDK
Secret.Env value is persisted in runtime state, while the declared
store-backed secret source is unimplemented. Selecting a secret API alone
doesn’t keep plaintext out of provider state. Use a nonpersisting, operation-scoped
delivery path, and test guest disk, snapshots, logs, errors, command
arguments, and runtime metadata with a sentinel value. When a credential needs
method/path policy, signing, audit, approval, MCP policy, rate limiting, or
response filtering, give the guest a short-lived credential-proxy capability
instead of the upstream secret.
Bind mounts deliberately expose host paths to the guest. Keep them read-only
unless the workflow must write, and never mount a credential directory or the
Microsandbox state directory into an untrusted workload.
Cleanup and persistence
cleanup: "destroy" is the default.
- An ephemeral sandbox is stopped and its state is removed.
- A sticky workspace is stopped but kept on disk, then reopened by
workspace.nameon the next run. cleanup: "keep"creates or starts the sandbox detached, leaving it running after the provider returns; setidleTimeoutSecsormaxDurationSecsso a crashed orchestrator can’t leave compute running forever.
~/.microsandbox database live on the host. Running
it as a fleet provider requires host scheduling, admission control, state
placement, generation fencing, snapshot export, authenticated streaming, and
observability outside this adapter. Plue implements that remote fleet boundary
separately; this package remains a local Smithers provider and does not make
an arbitrary API pod a safe KVM host.
SDK subset used
Published TypeScript SDK surface used:Sandbox.builder(name)with image or snapshot, resource, network, mount, lifecycle, label, and script setters;Sandbox.get(name)plus handleconnect(),start(), andstartDetached()for sticky workspaces;sandbox.fs().write(),readToString(),exists(), andmkdir()for file transport;sandbox.execStreamWith()pluscollect()andkill()for commands;sandbox.stop()andSandbox.remove(name)for teardown.
packages/microsandbox/tests/fixtures/createMockMicrosandboxEnvironment.js
supplies an in-memory SDK double for package tests, is not part of the
public exports, and requires no hypervisor, image pull, or credentials.