Instabox

Firecracker Linux machines with persistent disks, memory-preserving pause, native files, disk snapshots and private browser previews via @insforge/instabox-sdk.

Installation

The adapter lazily imports the optional peer @insforge/instabox-sdk. It targets 0.11.x, with a verified minimum of 0.11.0. The dev dependency is pinned to 0.11.0. Install the matching version because this API changes often.

pnpm add sbox-sdk @insforge/instabox-sdk@~0.11.0

Usage

import { createSandboxClient } from "sbox-sdk";
import { instabox } from "sbox-sdk/instabox";

const client = createSandboxClient({
  provider: instabox({
    apiKey: process.env.INSTABOX_API_KEY,
    vault: false,
  }),
});

const sandbox = await client.create({
  template: "agent-browser",
  metadata: { team: "agents" },
  env: { TASK: "build" },
});
try {
  const result = await sandbox.commands.run("echo $TASK; echo diagnostic >&2", {
    cwd: "/tmp",
    timeoutMs: 60_000,
  });
  console.log(result.stdout, result.stderr, result.exitCode);
  await sandbox.files.write("/data/result.bin", new Uint8Array([0, 255, 42]));
} finally {
  await sandbox.destroy();
}

destroy() calls kill(), which deletes the machine and its disks. stop() keeps disks and ends processes. pause() keeps memory and processes, and resume() keeps the machine ID. connect() inspects without waking; pass { resume: true } to client.connect() to wake it explicitly.

Authentication

OptionEnvironmentNotes
apiKeyINSTABOX_API_KEYScoped API key, sent as X-API-Key
apiUrlINSTABOX_API_URLDefault https://api.instabox.sh
requestTimeoutMsNoneHTTP request deadline, distinct from command timeout
operationTimeoutMsNoneWait limit for lifecycle operations
vaultNoneSDK default is enabled; use false to prevent account Vault delivery
queueNoneGPU capacity queue, true or { maxWaitMs }

client.verify() lists machines using machines:read. It never creates, resumes or deletes anything. Other operations require their respective scopes, including machines:write, snapshot images:* and SSH certificate access.

Vault items may expose account credentials inside a machine by default. The quickstart and live config set vault:false. Named secret references and egress secret injection are rejected by this adapter; inline environment secrets are accepted.

Commands and background jobs

Foreground commands.run() uses the SDK's streaming callbacks, keeps stdout and stderr separate, reports nonzero exits, and accepts fixed text or binary stdin. Stream input is buffered before calling the SDK. The SDK stages binary or large input in a temporary file. Foreground timeout is passed as timeoutMs, in whole seconds, with the provider's 10-minute maximum. kill() aborts the request, which the SDK documents as killing the command. The SDK exposes no foreground PID, so the handle's PID is an empty string.

Background commands.spawn() uses the native job handle. Its stdout and stderr are merged by Instabox and delivered as stdout events. Native jobs take no stdin, so fixed background stdin is piped into the command through the shell (printf <base64> | base64 -d), which bounds it by the command-line size limit. The returned process ID is the process-group shell PID. The native job ID is used internally by the SDK. Killing uses the native job kill(), which sends SIGTERM to the process group. Other requested signals are rejected. An explicit timeout is passed to job waiting, and abort or wait timeout also kills the job rather than leaving it detached. Process listing and killing by ID cover active jobs started by that adapter handle; reconnecting to arbitrary jobs is unsupported. Interactive writeStdin() and PTY sessions are unavailable.

Capabilities

CapabilityLevelNotes
streaming / backgroundnativeforeground stderr kept separate; background output merged
killProcessnativeSIGTERM to the job's process group; other signals rejected
stdinnativefixed input sent natively (stdinNative); piped through the shell for background jobs
filesUploadnativenative streamed file transfers, up to 5 GiB per file
listnativeSandbox.list, all pages; metadata filtered server-side
stopnativedisks persist (preservesDiskOnStop)
pausenativememory and processes persist (preservesMemoryOnPause)
snapshotnativedisk only (includesMemory: false)
forkemulatedtemporary snapshot plus sequential creates
exposePort / privatePreviewnativeports.publish(); private previews use _token query auth (previewBrowserAuth)
sshnativeshort-lived OpenSSH certificate
gpunativeTYPE[:COUNT], paid plans
metricsnativenewest host sample
pty / setTimeoutunsupportedno PTY in the SDK; lifetime timeouts were retired
templateBuildunsupportedimport images with the Instabox CLI, then use fromSnapshot
egressControl / region / volumesunsupported
codeInterpreter / statefulKernelunsupported
filesWatch / proxiedFetch / secretsVaultunsupportedVault items stay available through the SDK's own vault option

perCommandEnvCwd and exitCodeNative are true: cwd, env and timeoutMs go to commands.run natively.

Create contract

FlagValueWhy
idempotencyexactThe core's key is sent as the machine-create Idempotency-Key, which the API honours, and the request body, including a name derived from the key, is identical on every retry
specSupport.vcpus, memoryMBexactPassed through as given (both or neither); fixed-size services such as api.instabox.sh refuse them with spec_not_allowed
specSupport.diskMBapproximateRounded up to whole GiB of the persistent /data disk
specSupport.gpuexactgpu plus gpuCount becomes TYPE:COUNT
specSupport.idleTimeoutMsexactSent as whole seconds; fractional seconds throw Validation
specSupport.maxAgeMs, shmMBrejectedcreate() throws Validation
limitsnone declaredThe server validates metadata keys and idle times; the adapter enforces no numeric limit itself
sizesdefault ladderInstabox sizes depend on the deployment and plan, so presets expand to the default ladder and the server accepts or refuses them

On api.instabox.sh every machine is 4 vCPU, 8 GiB memory and a 20 GiB /data disk, and any explicit size (including one from spec.size) fails with a non-retryable QuotaExceeded (spec_not_allowed). Leave resources and size unset there.

How the spec maps

FieldInstabox mapping
templateSDK template ID or private snapshot name/ID, default agent-browser
templateRefSame-provider reference ID passed as the SDK create source
fromSnapshotPrivate snapshot ID passed to Sandbox.create(snapshotId, options)
name, metadataNative name and string metadata; provider validation and limits apply
env, inline secretsSDK envs, merged into commands on the creating handle
resources.vcpus, memoryMBNative vcpus, memMiB; supply both, with a size your plan allows
resources.diskMBPersistent /data disk, rounded up to whole GiB; root disk stays at its template default
resources.gpu, gpuCountSDK GPU type and optional count, e.g. h100:2; paid plan/capacity limits apply
resources.shmMBRejected
lifecycle.idleTimeoutMsautoSuspendMs, nonnegative whole seconds; server plan limits apply
lifecycle.onIdleOnly pause is accepted
lifecycle.autoResumetrue uses native idle-pause wake behavior; false is rejected
lifecycle.maxAgeMs, ttlMsRejected: lifetime timeouts were retired in SDK 0.6.0
networkPlain allow-all accepted; restrictions, deny rules and injection rejected
region, volumes, named secretsRejected
ports, previewVisibilityPublish ports after creation; default visibility public
idempotencyKeyCore retry key becomes the machine-create Idempotency-Key; stable derived name when omitted

envs are client-side SDK defaults, not persisted machine configuration. Reconnecting creates a new SDK object without the creating handle's defaults. Files and installed software persist. Forks made from the creating handle carry its defaults; forks after reconnect cannot recover those values.

The hosted free size is 4 vCPUs / 8192 MiB. Current official docs list other sizes for paid plans. Both size availability and /data disk sizes are enforced by the server; the adapter passes requests through rather than promising a size. GPU templates/types can be inspected through the native SDK.

The server currently documents a default 30-minute idle pause, with 5–30 minutes or disabled on paid plans. The SDK declaration's broader idle range does not override hosted plan limits. Only an automatically paused machine wakes on inbound traffic. A manually paused or stopped machine needs explicit resume/start. There is no adapter setTimeout() method. New REST delete deadlines and archive behavior do not implement lifecycle.maxAgeMs through this SDK.

Previews and browser authentication

import { browserUrl } from "sbox-sdk";

const preview = await sandbox.ports!.expose(3000, { visibility: "private" });
const httpUrl = browserUrl(preview);
const wsUrl = browserUrl(preview, { protocol: "ws" });

Ports 1024–65535 use native ports.publish(). Public previews have auth: { type: "public" }. Private previews use auth: { type: "query", param: "_token", token }. The gateway documents token query authentication for HTTP and WebSockets, so previewBrowserAuth is true. URLs remain usable only while the machine is online or can automatically wake.

Tokens are returned only when a private port is first published or rotated. The adapter caches tokens on that handle, including ports requested at creation. A reconnected handle cannot recover them: its port list omits private ports without known credentials, and exposing an existing private port raises Conflict. Explicitly unexpose and re-expose to issue new credentials; the adapter never silently rotates a private token. A sandbox created private stays private when ports are exposed, even when the core passes its default public visibility.

Snapshots and forks

const snapshot = await sandbox.snapshots!.create({ name: "prepared" });
const copy = await client.create({ fromSnapshot: snapshot });
const children = await sandbox.fork({ count: 2 });

Snapshots contain disks, not memory, and return includesMemory:false. Memory mode is rejected. A running snapshot may be pending; the SDK waits for it when creating a machine from it. A live snapshot may omit unflushed application writes. Snapshot creation is refused while paused; resume first. The adapter does not stop your machine automatically.

The 0.11 SDK has no native fork method, so fork is emulated with a temporary snapshot and sequential creates. Children boot fresh, keep metadata, size, GPU selection, Vault setting and idle timeout, and copy known client-side env defaults. They do not inherit published ports or process memory. A connected handle cannot recover prior env defaults. Failed child creation deletes already-created children, and the temporary snapshot is deleted. Server cleanup failures can still require manual cleanup. Snapshot listing is filtered to this machine; deletion uses the native snapshot API. SDK restore-in-place is unavailable; create a new machine from the snapshot.

Custom Docker/OCI image import exists in the Instabox CLI, which starts a temporary machine, overlays the image and saves a snapshot. The SDK has no equivalent image-import or Dockerfile build method, so templateBuild is unsupported. Import separately, then pass the private snapshot ID to fromSnapshot.

SSH, files and metrics

sandbox.ssh!.create() generates an RSA key locally and requests a short-lived native SSH certificate. This path requires Node.js. Save privateKey to instabox-key with mode 0600, certificate to instabox-key-cert.pub, and knownHosts to instabox-known-hosts. The returned command uses those filenames and enforces that gateway trust entry. Keep all credentials private. No account API key is returned as an SSH password.

Binary reads request { format: "bytes", maxBytes: 5 GiB }; upload/download use native file streams. files.read() still buffers the file because the core returns a stored file. Stream upload and download use bounded-memory native transfers. Hosted file routes support up to 5 GiB per file; the SDK's fallback for older servers without file routes is capped at 10 MiB. Native directory listing is used; missing filesystem operations use the core shell helpers. The native directory tar helpers remain available through raw().files.

Metrics select the newest native sample and convert byte counts to MiB. Samples arrive about 30 seconds apart; an empty response raises a retryable Provider error rather than fabricating a sample. Missing disk usage remains absent.

Limits and verification

No PTY, code interpreter, egress controls, region placement, volume registry or template builds are declared. Desktop and computer-use APIs remain available through the typed sandbox.raw() escape hatch.

Errors normalize auth, not-found, conflict, quota/plan limits, timeouts and validation failures. Every SDK limit code maps to QuotaExceeded, even on HTTP 400/403, as the SDK's quota class specifies. Only rate and concurrency limits (HTTP 429, rate_limited, concurrency_limit) are retryable; plan limits such as spec_not_allowed, template_not_allowed or credit_exhausted are not, because waiting does not clear them.

The adapter was checked against the published 0.11.0 declarations, implementation and current official docs on 2026-12-01. Offline tests use a typed fake SDK backed by MiniShell and run the full conformance battery with live:true. These tests do not prove hosted runtime behavior, SSH gateway access, browser WebSocket auth or billing limits. Live tests require an authorized account and may create billable machines and snapshots:

SBOX_LIVE=instabox INSTABOX_API_KEY=... pnpm --filter sbox-sdk test:live

The live config disables Vault delivery and optionally accepts INSTABOX_TEMPLATE. No credentials or live resources were used for this implementation.

On this page