@computesdk/createos-sandbox
ComputeSDK provider for CreateOS —
NodeOps' createos-sandbox VM sandbox service. Thin adapter over the
official @nodeops-createos/sandbox.
Install
npm install computesdk @computesdk/createos-sandbox
Usage
import { compute } from "computesdk";
import { createosSandbox } from "@computesdk/createos-sandbox";
compute.setConfig({
provider: createosSandbox({
apiKey: process.env.CREATEOS_SANDBOX_API_KEY,
baseUrl: process.env.CREATEOS_SANDBOX_BASE_URL,
}),
});
const sandbox = await compute.instances.create({ memoryMb: 1024, image: "devbox:1" });
const { stdout } = await sandbox.runCommand("echo hello");
await sandbox.filesystem.writeFile("/tmp/x.txt", "hi");
await sandbox.destroy();
Configuration
| Field | Env fallback | Notes |
|---|---|---|
apiKey | CREATEOS_SANDBOX_API_KEY | Required. createos-sandbox API key. |
baseUrl | CREATEOS_SANDBOX_BASE_URL | Control-plane URL. Optional; defaults to the production control plane. |
shape | — | Default VM shape (e.g. s-1vcpu-1gb). |
rootfs | — | Default rootfs catalog name / template. |
timeout | — | Reported getInfo().timeout (ms). Informational. |
Capability mapping
createos-sandbox sizes VMs from a shape catalog (not free-form cpu/mem), so
create() fetches the live catalog (GET /v1/shapes) and maps ComputeSDK's
cpus/memoryMb onto the smallest shape that fits. Pass a provider-specific
shape to pin one exactly (skips the catalog fetch). With no size pinned, the
default is the smallest live shape with ≥1 GiB RAM. image/runtime map to
rootfs; ephemeralDiskMb is passed straight through to disk_mib (the
control plane validates it; 0/omitted = the shape's default disk).
| ComputeSDK | createos-sandbox |
|---|---|
| shape selection | GET /v1/shapes (live catalog, nearest fit) |
sandbox.create / getById / list / destroy | POST/GET/DELETE /v1/sandboxes |
sandbox.runCommand | POST /v1/sandboxes/:id/exec (wrapped in sh -c) |
sandbox.getInfo | GET /v1/sandboxes/:id |
sandbox.getUrl({port}) | per-sandbox ingress URL |
filesystem.readFile / writeFile | GET/PUT /v1/sandboxes/:id/files |
filesystem.mkdir / readdir / exists / remove | synthesised via runCommand |
snapshot.create / list / delete | pause → fork({ start_paused: true }) → resume / list paused / destroy |
Template builds (/v1/templates) are not exposed through the ComputeSDK
provider surface — ComputeSDK's public Provider type can't carry the
createos-specific dockerfile create option type-safely. Build templates with
the native @nodeops-createos/sandbox client (client.templates.create)
directly.
Native escape hatch
ComputeSDK's core surface has no pause/resume/fork. Reach the full
@nodeops-createos/sandbox Sandbox handle via getInstance():
const native = sandbox.getInstance();
await native.pause();
await native.waitUntilPaused(); // pause() returns while the VM is still "pausing"
const clone = await native.fork();
await native.resume();
await native.attachDisk({ diskId: "my-bucket", mountPath: "/mnt/data" });
Known limitations
runCommandenv/cwd are synthesised — createos-sandbox drops per-exec env server-side, soenv/cwdare injected by wrapping the command in an inlinesh -cscript. Sandbox-level env should be set at create time (envs).- Snapshots are paused forks — createos forks only from a paused sandbox,
so
snapshot.createbriefly pauses the source, forks it into a paused copy (the snapshot, with its own id) and resumes the source.create({ snapshotId })forks that copy into a fresh sandbox;snapshot.deletedestroys it. A snapshot taken while a process is running captures its memory state too. getUrlturns on ingress — sandboxes are created with ingress off (passingressEnabled: trueto enable it at create);getUrlenables it on demand the first time a URL is requested. Ingress currently serves a non-CA TLS cert and strips theAuthorizationheader upstream — useprotocol: "http"/curl -kand don't rely on HTTP auth behind ingress.readdirparseslsoutput — relies on coreutilslsin the rootfs.
License
MIT