Morph

A sandbox per MorphCloud instance. Snapshot-first VMs with instant branching, via the morphcloud SDK.

Installation

morphcloud is an optional peer dependency of sbox-sdk, loaded lazily on first use.

pnpm add sbox-sdk morphcloud

Usage

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

const client = createSandboxClient({
  provider: morph({ apiKey: process.env.MORPH_API_KEY! }),
});

// `template` is a snapshot id (booted directly) or an image to snapshot first.
const sandbox = await client.create({ template: "morphvm-minimal" });
const res = await sandbox.commands.run("uname -a");
console.log(res.stdout);

// Morph's signature move: branch the live instance into N forks.
const forks = await sandbox.snapshots!.fork(3);

Morph is snapshot-first — there's no boot-from-image, so create() either boots a snapshot… template directly or lazily builds a snapshot from an image (imageId, resources) and boots that.

Exec is the buffered instance.exec(cmd) (streaming emulated); it has no per-command cwd/env, so the core folds those into a cd … && KEY=v … wrapper (perCommandEnvCwd: false). Files are read and written via exec + base64. Ports are public HTTP services (exposeHttpService). snapshots.create() is instance.snapshot() and fork() is instance.branch() — both native; in-place restore is not supported (branching makes new instances). destroy() stops the instance; there is no separate pause.

Authentication

A single API key.

Authentication variables for the morph adapter.
OptionEnv varRequiredDescription
apiKeyMORPH_API_KEYrequiredMorphCloud API key.
baseUrloptionalOverride the MorphCloud API base URL.
imageIdoptionalDefault image to snapshot from when `template` is not a snapshot id (default "morphvm-minimal").
vcpusoptionalDefault vCPUs for a lazily-created snapshot.
memoryoptionalDefault memory (MB) for a lazily-created snapshot.
diskSizeoptionalDefault disk size for a lazily-created snapshot.

Morph is snapshot-first: pass a snapshot id as `template` to boot it directly, or any other value as an image to snapshot first.

Options

Prop

Type

Capabilities

CapabilityLevelNotes
listnative
snapshot / forknativeinstance.snapshot() / branch()
streamingemulatedinstance.exec is buffered
filesUploadnativevia exec + base64
exposePortnativeexposeHttpService
codeInterpreterunsupported
pause / stopunsupporteddestroy() = stop instance

perCommandEnvCwd is false (core wraps); previewModel is subdomain. In-place snapshot restore reports NotSupported.

On this page