Styne
Linux microVMs from Styne, restored from warm pools. Streamed exec with native cwd, env and user, background commands with stdin and signals, pause with memory, named snapshots, fork, volumes, token-gated ports and egress rules you can change live, over Styne's REST API with no peer SDK.
Installation
The adapter calls Styne's sandbox REST API (https://api.styne.ai) with fetch, so it needs no peer dependency and runs on Node 20+, Bun, Deno and edge runtimes.
pnpm add sbox-sdkIt doesn't wrap the official styne-sdk package. That package targets Styne's /v1 API, which has no volumes, no container images on create, and no calls to signal a command, write its stdin, set an absolute timeout or read metrics.
Usage
import { createSandboxClient } from "sbox-sdk";
import { styne } from "sbox-sdk/styne";
const client = createSandboxClient({
provider: styne({ apiKey: process.env.STYNE_API_KEY! }),
});
const sandbox = await client.create({
size: "large",
lifecycle: { maxAgeMs: 30 * 60_000 },
network: {
mode: "allow-list",
domains: ["pypi.org", "files.pythonhosted.org"],
},
});
for await (const ev of sandbox.commands.run("pip install requests", {
cwd: "/tmp",
})) {
if (ev.type === "stdout") process.stdout.write(ev.data);
}
// Memory and disk, under a name that seeds new sandboxes.
const ref = await sandbox.snapshots!.create({ name: "with-requests" });
const copy = await client.create({ fromSnapshot: ref });
// Children copy the running parent, memory included.
const [a, b] = await sandbox.fork({ count: 2 });Authentication
| Option | Env var | Required | Notes |
|---|---|---|---|
apiKey | STYNE_API_KEY | yes | From the styne.ai dashboard; sent as Authorization: Bearer |
region | STYNE_REGION | no | ash (US East). ams is accepted and served in Ashburn |
client.verify() lists one sandbox (GET /sandboxes?limit=1); it never creates anything.
Options
Prop
Type
Spec mapping
SandboxSpec field | Styne |
|---|---|
template (an id or alias, such as base or code) | templateID; resources.vcpus / memoryMB become vcpus / memory_mib |
template (an image reference such as python:3.12) | image: any public image on Docker Hub, ghcr.io or quay.io |
template (a ref from client.templates.build()) | the image or snapshot it names, plus its env, startCmd and readyCmd |
fromSnapshot | snapshot (the snapshot name) |
size / resources with no template | smallest fitting size: small 2 vCPU/4 GiB, default 4/8, large 8/16, xlarge 16/32 |
env, secrets (inline value) | envVars |
metadata, name | metadata (the name is stored as sbox-name) |
lifecycle.maxAgeMs (or idleTimeoutMs, ttlMs) | timeout, whole seconds, at most 86 400 |
lifecycle.idleTimeoutMs | also idleTimeout: the sandbox sleeps after that long without traffic (at most 3600 s) |
lifecycle.onIdle: "pause" or "stop", autoResume | lifecycle: { onTimeout: "pause", autoResume } |
network | allow_internet_access plus network.allowOut / denyOut (hosts, IPs and CIDRs) |
volumes | volumeMounts (name is the volume id or name) |
region | region |
idempotencyKey | Idempotency-Key header, plus a sbox-idem metadata tag looked up before a retried create |
GPUs, secrets without a value or with mode: "egress", network.inject, autoResume without pausing, volumes with onIdle: "pause" | rejected with a Validation error |
With a template, snapshot or image, the sandbox keeps that source's size, so resources are only sent with a template id.
Styne prepares a container image the first time you boot it and answers 202 until it's ready. The adapter repeats the create, honoring Retry-After, for up to imageWaitMs (10 minutes by default).
Lifecycle and states
pause() keeps memory, running processes and files; resume() (or the next connect) brings the sandbox back with the same id. The pauseTier option picks where a paused sandbox is kept: memory (the default, fastest), standby or archived. setTimeout(ms) sets a new lifetime counted from now. A sandbox with a volume attached can't be paused, snapshotted or forked.
| Styne state | SandboxState |
|---|---|
starting, resuming | creating |
running | running |
pausing | suspending |
paused | paused |
| killed or timed out | destroyed |
Previews and browser auth
ports.expose(port) makes the port public at https://<port>-<sandbox-id>.<domain>. With { visibility: "private" } the port stays token-gated, and the preview carries auth: { type: "header", headers: { "e2b-traffic-access-token": "<token>" } }. Styne documents a ?token= query only for WebSocket upgrades, so previewBrowserAuth is false. ports.fetch(port, path) calls the port directly with the token, without exposing it. Up to 32 ports per sandbox.
Capabilities
| Capability | Level | Notes |
|---|---|---|
list | native | running and paused sandboxes; metadata filtered server-side |
streaming | native | NDJSON exec stream, stdout and stderr kept separate |
background / killProcess | native | detached commands, followed by pid and reattachable; TERM or KILL |
stdin | native | text written to a spawned command's stdin |
filesUpload | native | raw-byte file API; list, stat, mkdir and rename use the shell |
exposePort / privatePreview | native | per-port public URLs, or the traffic token in a header |
proxiedFetch | native | requests to a port with the traffic token |
egressControl | native | internet on or off, allow and deny lists, replaced on a running sandbox |
pause | native | memory, processes and files kept |
setTimeout | native | a new lifetime from now |
snapshot | native | memory and disk, named; restore() rewinds in place (Pro and Scale plans) |
fork | native | 1 to 1000 children of a running sandbox |
volumes | native | ext4 volumes that outlive sandboxes, 1 to 100 GiB |
templateBuild | native | public images and snapshots; Styne prepares the image on the first create |
region | native | ash |
metrics | native | newest CPU, memory and disk sample |
pty | unsupported | exec takes a PTY, but typing into it needs a streamed request body |
stop | unsupported | use pause |
codeInterpreter / statefulKernel | unsupported | |
ssh / filesWatch / gpu / secretsVault | unsupported |
Flags: perCommandEnvCwd: true, exitCodeNative: true, preservesMemoryOnPause: true, preservesDiskOnStop: false, previewModel: "subdomain", previewBrowserAuth: false, templateSources: ["image", "snapshot"], idempotency: "best-effort", plus the specSupport, limits and sizes values in Create contract.
Create contract
- Idempotency is
best-effort. Every create sends anIdempotency-Keyheader (sbox-<hash of the key>) and tags the sandbox with the same hash insbox-idemmetadata. A retried create first looks that tag up among running and paused sandboxes and connects to a match. If Styne answers409because a create with the same key is still running, the adapter waits for it (up to 60 s) and adopts the sandbox it made instead of failing. Styne doesn't document what it answers to a repeated key once the first request has finished, so this isn't declaredexact: a retry that misses the tag (the sandbox is not listed yet, or already gone) can still make a second sandbox. Each202 image_buildingrepeat sends a fresh key (<key>-<n>), since a202made no sandbox. - Sizing snaps to Styne's sizes. With no template,
vcpus,memoryMBanddiskMBpick the smallest size that fits all three, and a request pastxlargethrowsValidation. With a template id onlyvcpusandmemoryMBare sent: Styne refuses more than the template has and serves the template's size otherwise. A snapshot or image keeps its own size, andresourcesare not sent. - Timeouts are rounded up to whole seconds.
maxAgeMsbecomestimeout(at most 86 400 s).idleTimeoutMsbecomesidleTimeout(at most 3600 s), and alsotimeoutwhen nomaxAgeMsis set, so Styne's 300 s default doesn't end the sandbox first. Longer values throwValidation. - Rejected and ignored fields. GPUs throw
Validation.shmMBis ignored, sostrictSpec: trueturns it into aNotSupportederror. - Limits. At most 32 exposed ports. Styne documents no cap on
metadataentries; the adapter reservessbox-nameandsbox-idem.
| Field | Value |
|---|---|
idempotency | best-effort |
specSupport.vcpus | approximate |
specSupport.memoryMB | approximate |
specSupport.diskMB | approximate |
specSupport.shmMB | ignored |
specSupport.gpu | rejected |
specSupport.idleTimeoutMs | approximate |
specSupport.maxAgeMs | approximate |
limits.maxPorts | 32 |
limits.idleTimeoutStepMs | 1000 (minimum 1000) |
limits.maxAgeStepMs | 1000 (minimum 1000) |
sizes | small 2/4/51, medium 4/8/51, large 8/16/111, xlarge 16/32/251 (vCPU / GiB memory / GiB disk); medium is Styne's default |
Known limitations
client.templates.build()takes{ image }(public registries only) or{ snapshot }. Dockerfile sources throwNotSupported;workdir,user, templateresourcesandregistryAuththrowValidation. Push the image to a public registry and set those in the image instead.killProcesssendsSIGTERMorSIGKILLonly; other signals throwValidation.stdinis text: bytes that aren't valid UTF-8 are replaced.snapshots.list()is not available, because Styne doesn't document the list answer.- The idempotency tag only finds a sandbox that is still running or paused. Styne doesn't document what it answers to a repeated
Idempotency-Keyonce the first request has finished. fork()throws if any child fails to start, after killing the children that did start.
Upstash Box
Persistent and TTL-bound ephemeral Linux containers from Upstash, with streamed exec, native files and filesystem snapshots via @upstash/box.
Agent37
Always-on Linux instances from Agent37 that sleep when idle and wake on the next request. Signed previews, fork, disk snapshots, egress allow lists and Dockerfile builds, over the REST API with no SDK.