Skip to main content
Capture the disk state of a stopped sandbox through the active backend, then boot fresh sandboxes from it. Local snapshots are portable artifacts; cloud snapshots use managed storage or the organization’s host volume.
Snapshots are disk-only and require a sandbox that is not running (stopped or crashed). listDir, reindex, save/saveTo, load, and verify keep the same API on every backend, but currently reject with UnsupportedError in cloud.

Capture and boot

These entry points live on SandboxBuilder and SandboxHandle; they are the bridge between sandboxes and snapshot artifacts.

.fromSnapshot()

Boot a fresh sandbox from a snapshot. Mutually exclusive with .image(); the snapshot already pins the image. Passing a Snapshot or SnapshotHandle preserves its backend-relative reference automatically.

Parameters

snapshotstring | Snapshot | SnapshotHandle
Backend-relative string or snapshot object returned by this SDK.

Returns

The same builder, for chaining.

handle.snapshot()

Snapshot this sandbox under a bare name. The local backend uses its default snapshot directory; cloud uses managed storage. The sandbox must be stopped or crashed.

Parameters

namestring
Snapshot name. Local stores it in the default snapshot directory; cloud creates a managed snapshot.

Returns

The created snapshot artifact.

Snapshot static methods

Snapshot.builder()

Begin building a new snapshot named name through the active backend. With no destination, local uses its default snapshot directory and cloud uses managed storage. .destDir() selects a local parent or cloud host-volume directory.

Parameters

namestring
Snapshot name. Its storage location is selected by the active backend.

Returns

Builder for configuring the snapshot.

Snapshot.open()

Open an existing snapshot through the active backend. Locally, bare names resolve under the default snapshot directory and other values are artifact paths. In cloud, bare values identify managed snapshots and path-like values identify host-volume artifacts. Cheap metadata validation only; use verify() for content checks where supported.

Parameters

pathOrNamestring
Backend-relative snapshot name, ID, or path.

Returns

The opened snapshot.

Snapshot.get()

Look up a snapshot through the active backend and return a lightweight SnapshotHandle.

Parameters

nameOrDigeststring
Public identifier understood by the active backend, such as a local name/digest or cloud snapshot ID.

Returns

Lightweight handle returned by the active backend.

Snapshot.list()

List snapshots visible through the active backend. Cloud lists managed snapshots; host-volume artifacts are opened explicitly by reference.

Returns

All indexed snapshot handles.

Snapshot.listDir()

Walk a local directory and parse each subdirectory’s manifest. Does not touch the local index, which makes it useful for inspecting external snapshot collections that were never loaded. Skips entries that don’t look like snapshot artifacts. Cloud returns UnsupportedError.

Parameters

dirstring
Directory to scan for artifact subdirectories.

Returns

Parsed snapshots found in the directory.

Snapshot.remove()

Remove a snapshot through the active backend. Locally, the string may be a path, name, or digest and removal refuses indexed children unless force is set. In cloud, the string identifies a managed or host-volume snapshot.

Parameters

pathOrNamestring
Path, name, or digest of the snapshot to remove.
opts.forceboolean
Remove even if the snapshot has indexed children. Defaults to false.

Snapshot.reindex()

Walk a local snapshots directory (default: the configured snapshots dir) and rebuild the local index. Returns the number of artifacts indexed. Cloud returns UnsupportedError.

Parameters

dirstring
Directory to scan. Defaults to the configured snapshots dir.

Returns

Promise<number>
Count of artifacts indexed.

Snapshot.save()

staticasync
Bundle a local snapshot into a .tar.zst archive. The recorded manifest is archived as-is, so create the snapshot with recordIntegrity() if receivers must verify content. See SaveOpts for bundling options. Cloud returns UnsupportedError.

Parameters

nameOrPathstring
Name or path of the snapshot to bundle.
outstring
Output archive path.
Bundling options. All fields default to false.

Snapshot.load()

staticasync
Unpack a snapshot archive (.tar.zst or .tar) into the local snapshots directory. Structural and archive-entry checks run during import; recorded payload integrity is preserved for explicit verify(). Compression is detected from magic bytes. Cloud returns UnsupportedError.

Parameters

archivestring
Path to the archive to unpack.
deststring
Destination directory. Defaults to the snapshots directory.

Returns

Handle to the loaded snapshot.

Snapshot instance members

A Snapshot represents a backend-neutral disk snapshot and retains the backend that created or opened it. Returned by Snapshot.builder().create(), Snapshot.open(), and handle.snapshot().

snap.reference

Stable value accepted by SandboxBuilder.fromSnapshot().

snap.referenceKind

How the selected backend resolves reference. Most callers can pass the snapshot object directly and never inspect this value.

snap.digest

Canonical content digest (sha256:hex). The snapshot’s identity.

snap.sizeBytes

Backend-reported stored payload size in bytes.

snap.imageRef

Image reference the snapshot was taken from.

snap.imageManifestDigest

OCI manifest digest of the pinned image.

snap.format

On-disk format of the upper layer.

snap.scope

getter
Snapshot scope: "disk" for a disk-only snapshot, "resumable" once resumable snapshots land. Always "disk" today. See SnapshotScope.

snap.fstype

Filesystem type inside the upper (e.g. "ext4").

snap.parent

Manifest digest of the parent snapshot, or null for a root.

snap.createdAt

RFC 3339 timestamp when the snapshot was created.

snap.labels

User-supplied labels (sorted by key in canonical form), as [key, value] pairs.

snap.sourceSandbox

Best-effort source-sandbox name, if recorded. null when the manifest has no source recorded.

snap.saveTo()

Bundle this snapshot into an archive through the backend retained when it was created or opened. This avoids resolving its reference through a possibly different current default backend. Cloud returns UnsupportedError.

snap.verify()

Recompute the upper layer’s recorded content integrity and compare against the descriptor. Current BLAKE3 Merkle integrity skips known all-hole subtrees and hashes allocated leaves in batches; released SHA descriptors retain their exact, potentially O(logical size), verifier. The report’s upper.kind is "notRecorded" when no integrity was recorded. The cloud backend currently rejects this operation with UnsupportedError.

Returns

Verification result.

SnapshotBuilder

Fluent builder for a snapshot, returned by Snapshot.builder(name). Every setter mutates in place and returns this, so calls chain. The source sandbox is required: call .fromSandbox() before .create().

.fromSandbox()

builder
Set the sandbox to capture. Required; .create() fails without it.

Parameters

sourceSandboxstring
Name of the stopped sandbox to capture.

.destDir()

builder
Create the artifact under this parent directory instead of the default snapshots store. The artifact directory is destDir/<name>; the name stays the snapshot’s identity either way.

Parameters

destDirstring
Parent directory to create the artifact in (e.g. a larger volume).

.label()

Add a key=value label to the snapshot manifest. May be called repeatedly.

Parameters

keystring
Label key.
valuestring
Label value.

.force()

Overwrite an existing artifact with the same name instead of failing on conflict.

.recordIntegrity()

Compute and record a content-integrity hash of the upper layer at creation time, so the snapshot can be verified later or across a trust boundary.

.resumable()

builder
Request a "resumable" snapshot (disk plus VM state). Accepted by the builder, but .create() currently returns an Unsupported error; resumable snapshots have not landed yet.

.create()

Capture the configured snapshot and return the resulting artifact.

Returns

The created snapshot artifact.

Types

SnapshotHandle class

Lightweight handle returned by the active backend. Values are snapshotted at construction time; call Snapshot.get() again for a fresh reading if needed. Handles from Snapshot.list() are read-only; fetch a live handle via Snapshot.get() for lifecycle methods.

Returned by Snapshot.get(), Snapshot.list(), Snapshot.load()

snapshotHandle.open()

Open and metadata-validate the underlying artifact. Throws if this handle is read-only (came from Snapshot.list()); fetch a live handle via Snapshot.get() first.

snapshotHandle.remove()

Remove the artifact and its index row. Refuses if the snapshot has indexed children unless force is set. Throws if this handle is read-only.

snapshotHandle.saveTo()

Bundle the referenced snapshot through the backend retained by the handle. Handles returned by Snapshot.list() are metadata-only; fetch a live handle with Snapshot.get() first. Cloud returns UnsupportedError.

SaveOpts interface

Bundle options for Snapshot.save() and instance saveTo() methods. All fields default to false.

Used by Snapshot.save() and instance saveTo() methods


SnapshotScope type

Scope of what a snapshot captures. Every snapshot today is "disk"; "resumable" (disk plus VM state) is reserved for resumable snapshots.

Returned by snap.scope · SnapshotHandle.scope


SnapshotVerifyReport union

Result of snap.verify(). The upper discriminant is "notRecorded" when no integrity hash was stored at create time, or "verified" when the recorded hash matched the recomputed one.

Returned by snap.verify()