1234567891011import { Sandbox } from "@opencomputer/sdk"; // Attach a patch to an existing checkpoint const result = await Sandbox.createCheckpointPatch(checkpointId, { script: 'echo "export API_KEY=$1" >> /root/.bashrc', description: "Inject API key at fork time", }); console.log(result.patch.id, result.patch.sequence); // Fork — patch runs automatically const sandbox = await Sandbox.createFromCheckpoint(checkpointId);
12345const result = await Sandbox.createCheckpointPatch(checkpointId, { script: "apt-get update && apt-get install -y redis-server", description: "Install Redis", }); // result.patch.id, result.patch.sequence
| Parameter | Type | Required | Description |
checkpointId | string | Yes | Target checkpoint |
script | string | Yes | Bash script to execute on fork |
description | string | No | Human-readable description |
1234const patches = await Sandbox.listCheckpointPatches(checkpointId); for (const p of patches) { console.log(p.sequence, p.description); }
1await Sandbox.deleteCheckpointPatch(checkpointId, patchId);
Sandbox.createFromCheckpoint() or oc checkpoint spawn). The strategy is always on_wake.sequence number). If you create three patches, they execute as patch 1 → patch 2 → patch 3 every time a sandbox is forked.| Field | Type | Description |
id | string | Patch UUID |
checkpointId | string | Parent checkpoint |
script | string | Bash script content |
description | string | Human-readable description |
strategy | string | Always "on_wake" |
sequence | number | Execution order |
createdAt | string | Timestamp |
1234567891011121314// Base checkpoint has the app installed const cpId = "cp-abc123"; // Patch for staging await Sandbox.createCheckpointPatch(cpId, { script: ` echo 'DATABASE_URL=postgres://staging-db/app' >> /app/.env echo 'LOG_LEVEL=debug' >> /app/.env `, description: "Staging environment config", }); // Every fork now gets staging config const staging = await Sandbox.createFromCheckpoint(cpId);