An open-source, faster Devin alternative
TypeScript
add docs for checkpoint
Brian Reardon8b2f6d52e8c2
diff --git a/docs/mint.json b/docs/mint.jsonindex 602651e8..11d1a5e4 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -57,7 +57,9 @@"sdks/typescript/commands","sdks/typescript/filesystem","sdks/typescript/pty",- "sdks/typescript/templates"+ "sdks/typescript/templates",+ "sdks/typescript/checkpoints",+ "sdks/typescript/patches"]},{@@ -68,7 +70,9 @@"sdks/python/commands","sdks/python/filesystem","sdks/python/pty",- "sdks/python/templates"+ "sdks/python/templates",+ "sdks/python/checkpoints",+ "sdks/python/patches"]}],diff --git a/docs/sdks/python/checkpoints.mdx b/docs/sdks/python/checkpoints.mdxnew file mode 100644index 00000000..ca826290--- /dev/null+++ b/docs/sdks/python/checkpoints.mdx@@ -0,0 +1,77 @@+---+title: "Checkpoints"+description: "Snapshot, fork, and restore sandboxes"+---++Checkpoints capture a sandbox's full state (filesystem + memory). Fork new sandboxes from any checkpoint, or restore a sandbox to a previous point in time.++## Create a Checkpoint++```python+checkpoint = await sandbox.create_checkpoint("my-checkpoint")+# {"id": "uuid", "name": "my-checkpoint", "status": "processing"}+```++### `await sandbox.create_checkpoint(name)`++<ParamField body="name" type="str" required>+ A name for this checkpoint.+</ParamField>++**Returns:** `dict` — status transitions from `"processing"` to `"ready"` once the snapshot is uploaded.++## List Checkpoints++```python+checkpoints = await sandbox.list_checkpoints()+```++**Returns:** `list[dict]`++## Fork from a Checkpoint++Create a new sandbox from a checkpoint. The new sandbox boots with the checkpointed filesystem state.++```python+fork = await Sandbox.create_from_checkpoint(+ checkpoint["id"],+ timeout=600,+)++result = await fork.commands.run("cat /root/data.txt")+```++### `Sandbox.create_from_checkpoint(checkpoint_id, **kwargs)`++<ParamField body="checkpoint_id" type="str" required>+ UUID of the checkpoint to fork from.+</ParamField>+<ParamField body="timeout" type="int" default="300">+ Sandbox TTL in seconds.+</ParamField>+<ParamField body="api_key" type="str | None" default="None">+ API key override.+</ParamField>+<ParamField body="api_url" type="str | None" default="None">+ API URL override.+</ParamField>++**Returns:** `Sandbox`++## Restore a Checkpoint++Revert a running sandbox to a previous checkpoint. The VM reboots with the checkpointed drives.++```python+await sandbox.restore_checkpoint(checkpoint["id"])+```++**Returns:** `None`++## Delete a Checkpoint++```python+await sandbox.delete_checkpoint(checkpoint["id"])+```++**Returns:** `None`diff --git a/docs/sdks/python/patches.mdx b/docs/sdks/python/patches.mdxnew file mode 100644index 00000000..2d853098--- /dev/null+++ b/docs/sdks/python/patches.mdx@@ -0,0 +1,59 @@+---+title: "Patches"+description: "Rolling updates for forked sandboxes"+---++Patches attach bash scripts to a checkpoint. When a sandbox boots from that checkpoint or wakes from hibernation, all pending patches run automatically in sequence order.++## Create a Patch++```python+result = await Sandbox.create_checkpoint_patch(+ checkpoint["id"],+ script="pip install requests==2.31.0",+ description="Pin requests version",+)++print(result["patch"]["sequence"]) # 1+```++### `Sandbox.create_checkpoint_patch(checkpoint_id, script, **kwargs)`++<ParamField body="checkpoint_id" type="str" required>+ UUID of the checkpoint to patch.+</ParamField>+<ParamField body="script" type="str" required>+ Bash script to execute inside the sandbox.+</ParamField>+<ParamField body="description" type="str" default="''">+ Human-readable description.+</ParamField>+<ParamField body="api_key" type="str | None" default="None">+ API key override.+</ParamField>+<ParamField body="api_url" type="str | None" default="None">+ API URL override.+</ParamField>++**Returns:** `dict`++## List Patches++```python+patches = await Sandbox.list_checkpoint_patches(checkpoint["id"])+# [{"id": "...", "sequence": 1, "script": "...", "description": "..."}, ...]+```++### `Sandbox.list_checkpoint_patches(checkpoint_id, **kwargs)`++**Returns:** `list[dict]` — ordered by sequence number.++## How Patches Apply++| Event | Patches run? |+| --- | --- |+| `Sandbox.create_from_checkpoint()` | Yes — after boot |+| `await sandbox.wake()` | Yes — after restore |+| Sandbox already running | No — next wake/boot |++Patches run sequentially by sequence number. If a patch fails (non-zero exit), the chain stops. Progress is tracked per-sandbox, so the next wake retries from the last successful patch.diff --git a/docs/sdks/typescript/checkpoints.mdx b/docs/sdks/typescript/checkpoints.mdxnew file mode 100644index 00000000..89b2d4b2--- /dev/null+++ b/docs/sdks/typescript/checkpoints.mdx@@ -0,0 +1,80 @@+---+title: "Checkpoints"+description: "Snapshot, fork, and restore sandboxes"+---++Checkpoints capture a sandbox's full state (filesystem + memory). Fork new sandboxes from any checkpoint, or restore a sandbox to a previous point in time.++## Create a Checkpoint++```typescript+const checkpoint = await sandbox.createCheckpoint("my-checkpoint");+// { id: "uuid", name: "my-checkpoint", status: "processing" }+```++### `sandbox.createCheckpoint(name)`++<ParamField body="name" type="string" required>+ A name for this checkpoint.+</ParamField>++**Returns:** `Promise<CheckpointInfo>` — status transitions from `"processing"` to `"ready"` once the snapshot is uploaded.++## List Checkpoints++```typescript+const checkpoints = await sandbox.listCheckpoints();+```++**Returns:** `Promise<CheckpointInfo[]>`++## Fork from a Checkpoint++Create a new sandbox from a checkpoint. The new sandbox boots with the checkpointed filesystem state.++```typescript+const fork = await Sandbox.createFromCheckpoint(checkpoint.id, {+ timeout: 600,+});++const result = await fork.commands.run("cat /root/data.txt");+```++### `Sandbox.createFromCheckpoint(checkpointId, opts?)`++<ParamField body="checkpointId" type="string" required>+ UUID of the checkpoint to fork from.+</ParamField>+<ParamField body="opts" type="object" optional>+ <Expandable title="properties">+ <ParamField body="timeout" type="number" default="300">+ Sandbox TTL in seconds.+ </ParamField>+ <ParamField body="apiKey" type="string" optional>+ API key override.+ </ParamField>+ <ParamField body="apiUrl" type="string" optional>+ API URL override.+ </ParamField>+ </Expandable>+</ParamField>++**Returns:** `Promise<Sandbox>`++## Restore a Checkpoint++Revert a running sandbox to a previous checkpoint. The VM reboots with the checkpointed drives.++```typescript+await sandbox.restoreCheckpoint(checkpoint.id);+```++**Returns:** `Promise<void>`++## Delete a Checkpoint++```typescript+await sandbox.deleteCheckpoint(checkpoint.id);+```++**Returns:** `Promise<void>`diff --git a/docs/sdks/typescript/patches.mdx b/docs/sdks/typescript/patches.mdxnew file mode 100644index 00000000..2a89572f--- /dev/null+++ b/docs/sdks/typescript/patches.mdx@@ -0,0 +1,62 @@+---+title: "Patches"+description: "Rolling updates for forked sandboxes"+---++Patches attach bash scripts to a checkpoint. When a sandbox boots from that checkpoint or wakes from hibernation, all pending patches run automatically in sequence order.++## Create a Patch++```typescript+const result = await Sandbox.createCheckpointPatch(checkpoint.id, {+ script: "npm install [email protected]",+ description: "Pin lodash version",+});++console.log(result.patch.sequence); // 1+```++### `Sandbox.createCheckpointPatch(checkpointId, opts)`++<ParamField body="checkpointId" type="string" required>+ UUID of the checkpoint to patch.+</ParamField>+<ParamField body="opts" type="object" required>+ <Expandable title="properties">+ <ParamField body="script" type="string" required>+ Bash script to execute inside the sandbox.+ </ParamField>+ <ParamField body="description" type="string" optional>+ Human-readable description.+ </ParamField>+ <ParamField body="apiKey" type="string" optional>+ API key override.+ </ParamField>+ <ParamField body="apiUrl" type="string" optional>+ API URL override.+ </ParamField>+ </Expandable>+</ParamField>++**Returns:** `Promise<PatchResult>`++## List Patches++```typescript+const patches = await Sandbox.listCheckpointPatches(checkpoint.id);+// [{ id: "...", sequence: 1, script: "...", description: "..." }, ...]+```++### `Sandbox.listCheckpointPatches(checkpointId, opts?)`++**Returns:** `Promise<PatchInfo[]>` — ordered by sequence number.++## How Patches Apply++| Event | Patches run? |+| --- | --- |+| `Sandbox.createFromCheckpoint()` | Yes — after boot |+| `sandbox.wake()` | Yes — after restore |+| Sandbox already running | No — next wake/boot |++Patches run sequentially by sequence number. If a patch fails (non-zero exit), the chain stops. Progress is tracked per-sandbox, so the next wake retries from the last successful patch.