Microsandbox CloudBeta
Managed microVMs with native exec streams, stdin, PTY, binary files, volumes and stopped filesystem snapshots. Beta; Node 22 or newer.
Cloud uses its own static capability map. Local pause, retained jobs, memory snapshots, fork and SDK metrics are absent from cloud handles.
Installation and authentication
pnpm add sbox-sdk microsandbox@0.8.3 @microsandbox/remote@0.8.3Node 22 or newer is required. The full 0.8.3 package omitted its native platform dependencies. Import the matching lean remote distribution to register its binding, or install the full platform binding described in the local adapter guide.
An organization API key or stored Microsandbox remote profile.
| Option | Env var | Required | Description |
|---|---|---|---|
apiKey | MSB_API_KEY | optional | Cloud key, required unless a stored profile supplies it. |
apiUrl | MSB_API_URL | optional | API endpoint. Defaults to https://api.microsandbox.dev. |
profile | MSB_PROFILE | optional | Stored remote profile. Pass profile explicitly; cannot combine with explicit key/URL/timeout. |
image | MSB_IMAGE | optional | Default OCI image. |
The SDK reads MSB_API_KEY/MSB_API_URL when options are omitted. profile is explicit in TypeScript and mapped from MSB_PROFILE by the CLI. Cloud has a smaller capability map.
import "@microsandbox/remote";
import { createSandboxClient } from "sbox-sdk";
import { microsandboxCloud } from "sbox-sdk/microsandbox";
const client = createSandboxClient({
provider: microsandboxCloud({
apiKey: process.env.MSB_API_KEY,
apiUrl: process.env.MSB_API_URL,
}),
});
const sandbox = await client.create({ template: "alpine:3.22" });
try {
console.log(await sandbox.commands.run("echo cloud", { cwd: "/tmp" }));
} finally {
await sandbox.destroy();
}The discovery alias sbox-sdk/microsandbox-cloud exports the same cloud factory.
MSB_API_KEY and MSB_API_URL are resolved by the SDK when options are omitted.
The default endpoint is https://api.microsandbox.dev. Use { profile: "work" }
for a stored remote profile. Profile selection cannot combine with explicit
key, URL or timeout options. The CLI maps MSB_PROFILE to that explicit option.
The factory captures a RemoteContext without changing MSB_BACKEND or other
process environment variables.
verify() sends an authenticated list request with limit 1. It never creates
or starts a sandbox. Native transport owns its HTTP requests; client.fetch
does not replace the SDK's transport.
Supported behavior
Cloud provides native stdout/stderr streaming, exit codes, cwd/env/user overrides,
timeouts, stdin, attached PTYs and native binary files. Sandboxes are persistent;
destroy() stops and deletes them. State and labels are fetched afresh, and list
traverses all pages before applying metadata, state and limit filters.
OCI images, CPU/memory/root disk sizes, env, labels, whole-second idle/max-age limits and creation-time network policies follow the local adapter mapping. Create cloud directory volumes before mounting them. Disk-backed volumes and creating a volume as part of a mount are not mapped.
Filesystem snapshots require a stopped persistent source:
await sandbox.stop();
const snapshot = await sandbox.snapshots.create({ mode: "filesystem" });
const restored = await client.create({ fromSnapshot: snapshot });Cloud memory snapshots are rejected, and includesMemory remains false for
filesystem snapshots. Restore creates a new sandbox ID. Snapshots are separate
resources and remain caller-owned after sandbox deletion.
Previews and unsupported features
Microsandbox Services provide public HTTPS, but SDK 0.8.3's Service API has no
retained-context overload. It routes through ambient backend/profile settings.
This adapter does not change process-wide settings or risk routing another
factory's Services to the wrong account, so cloud exposePort is unsupported.
No preview auth mode or browser WebSocket auth is advertised. Use Microsandbox's
Services tooling separately if public URLs are required.
Retained background jobs, process reconnect/list/kill by ID, pause, fork,
memory snapshots and SDK metrics are local-only. Running ExecHandle.kill()
still controls its attached command. SSH credentials, template builds,
file watching, code interpreters, GPU and region are unsupported. Creation-time
network rules and lifecycle limits cannot be changed through network or
setTimeout() after creation.
Inline guest env secrets are accepted. Vault references, egress secret refs and
network.inject are rejected because placeholder substitution has different
semantics from header insertion.
Capabilities
| Capability | Level | Notes |
|---|---|---|
streaming / stdin | native | native exec streams, stderr kept separate, real exit codes |
pty | native | attached PTYs on the same sandbox handle |
filesUpload | native | native binary file streams |
list | native | cursor-paginated, then filtered by state, metadata and limit |
stop | native | disk persists (preservesDiskOnStop) |
snapshot | native | filesystem only, from a stopped sandbox |
volumes | native | named directory volumes |
background / killProcess | unsupported | retained jobs are local-only |
pause / fork / metrics | unsupported | local-only |
exposePort | unsupported | SDK Service API has no retained-context overload |
egressControl | unsupported | no live policy setter; spec.network is applied at create |
setTimeout | unsupported | idle and max-age limits can't change after create |
privatePreview | unsupported | |
templateBuild | unsupported | build OCI images with external tooling |
region / gpu | unsupported | rejected at create |
secretsVault | unsupported | inline env secrets only |
ssh | unsupported | |
codeInterpreter | unsupported | |
statefulKernel | unsupported | |
filesWatch / proxiedFetch | unsupported |
idempotency is exact: an unnamed create gets a name derived from the
idempotency key and the adapter never replaces an existing sandbox, so a
retried create fails with Conflict instead of making a second VM.
How the spec maps
| sbox | Microsandbox Cloud |
|---|---|
template / templateRef.id | image (OCI reference; default alpine:3.22) |
fromSnapshot | sandboxes.restore(checkpoint), a new sandbox |
name / idempotencyKey | sandbox name (sbox-<sha256(key)> when unnamed) |
env, env-mode secrets | envs / env |
metadata | labels |
resources.vcpus | cpus (exact) |
resources.memoryMB | memory MiB (exact) |
resources.diskMB | rootDisk MiB (exact; rejected with fromSnapshot) |
resources.shmMB / gpu / gpuCount | rejected |
lifecycle.idleTimeoutMs | idleTimeoutSeconds (exact; must be whole seconds) |
lifecycle.maxAgeMs | maxDurationSeconds (exact; must be whole seconds) |
lifecycle.onIdle / autoResume | only "stop" / false; other values are rejected |
network | network.policy rules at create |
volumes | named volume mounts |
ports / region | rejected |
There are no fixed size tiers, so spec.size uses the default ladder. The
adapter declares no label limits.
Verification
Offline MiniShell conformance covers cloud with one named skip for the generic running-snapshot check; separate tests enforce stopped-only snapshots. Real SDK tests send requests to a loopback server with fake keys and check auth, pagination, live state and HTTP errors. No paid cloud sandboxes were created, and live account behavior remains unverified.
Live cloud conformance requires explicit opt-in and can incur charges:
MSB_API_KEY=... MSB_CLOUD_LIVE=1 SBOX_LIVE=microsandbox-cloud pnpm --filter sbox-sdk test:liveMicrosandbox
Local libkrun microVMs with native command streams, PTY, files, retained jobs, memory snapshots and forks. Beta; Node 22 or newer.
E2B
The reference cloud adapter. Code interpreter, memory pause/resume, memory or filesystem snapshots, fork, PTY, egress rules with secret injection, volumes, and Dockerfile template builds. Backed by @e2b/code-interpreter.