An open-source, faster Devin alternative
TypeScript
feat/connectUrl fixing (#72)
Mohamed Habib957565c9365c
diff --git a/docs/api-reference/agent/create.mdx b/docs/api-reference/agent/create.mdxnew file mode 100644index 00000000..eb9173e8--- /dev/null+++ b/docs/api-reference/agent/create.mdx@@ -0,0 +1,58 @@+---+title: 'Create Agent Session'+api: 'POST /api/sandboxes/{id}/agent'+---++Create a new agent session running the Claude Agent SDK inside the sandbox. Events stream over the exec session WebSocket transport.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="prompt" type="string">+ Initial prompt+</ParamField>++<ParamField body="model" type="string">+ Claude model name+</ParamField>++<ParamField body="systemPrompt" type="string">+ System prompt+</ParamField>++<ParamField body="allowedTools" type="string[]">+ Restrict available tools+</ParamField>++<ParamField body="permissionMode" type="string">+ Permission mode+</ParamField>++<ParamField body="maxTurns" type="integer">+ Maximum turns+</ParamField>++<ParamField body="cwd" type="string">+ Working directory+</ParamField>++<ParamField body="mcpServers" type="object">+ MCP server configuration+</ParamField>++<ParamField body="resume" type="string">+ Session ID to resume+</ParamField>++<ResponseExample>+```json 201+{+ "sessionID": "as-abc123",+ "sandboxID": "sb-abc123",+ "running": true,+ "startedAt": "2025-01-15T10:30:00Z",+ "claudeSessionID": ""+}+```+</ResponseExample>diff --git a/docs/api-reference/agent/interrupt.mdx b/docs/api-reference/agent/interrupt.mdxnew file mode 100644index 00000000..88c36ac4--- /dev/null+++ b/docs/api-reference/agent/interrupt.mdx@@ -0,0 +1,20 @@+---+title: 'Interrupt Agent'+api: 'POST /api/sandboxes/{id}/agent/{sid}/interrupt'+---++Stop the agent's current turn.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="sid" type="string" required>+ Agent session ID+</ParamField>++<ResponseExample>+```json 200+{}+```+</ResponseExample>diff --git a/docs/api-reference/agent/kill.mdx b/docs/api-reference/agent/kill.mdxnew file mode 100644index 00000000..9fccc4c3--- /dev/null+++ b/docs/api-reference/agent/kill.mdx@@ -0,0 +1,20 @@+---+title: 'Kill Agent Session'+api: 'POST /api/sandboxes/{id}/agent/{sid}/kill'+---++Terminate the agent session.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="sid" type="string" required>+ Agent session ID+</ParamField>++<ResponseExample>+```json 200+{}+```+</ResponseExample>diff --git a/docs/api-reference/agent/list.mdx b/docs/api-reference/agent/list.mdxnew file mode 100644index 00000000..df7bf6fa--- /dev/null+++ b/docs/api-reference/agent/list.mdx@@ -0,0 +1,24 @@+---+title: 'List Agent Sessions'+api: 'GET /api/sandboxes/{id}/agent'+---++List all agent sessions for a sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ResponseExample>+```json 200+[+ {+ "sessionID": "as-abc123",+ "sandboxID": "sb-abc123",+ "running": true,+ "startedAt": "2025-01-15T10:30:00Z",+ "claudeSessionID": ""+ }+]+```+</ResponseExample>diff --git a/docs/api-reference/agent/prompt.mdx b/docs/api-reference/agent/prompt.mdxnew file mode 100644index 00000000..0ce82141--- /dev/null+++ b/docs/api-reference/agent/prompt.mdx@@ -0,0 +1,24 @@+---+title: 'Send Follow-up Prompt'+api: 'POST /api/sandboxes/{id}/agent/{sid}/prompt'+---++Send a follow-up prompt to a running agent session.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="sid" type="string" required>+ Agent session ID+</ParamField>++<ParamField body="text" type="string" required>+ Follow-up prompt text+</ParamField>++<ResponseExample>+```json 200+{}+```+</ResponseExample>diff --git a/docs/api-reference/checkpoints/create.mdx b/docs/api-reference/checkpoints/create.mdxnew file mode 100644index 00000000..e534e147--- /dev/null+++ b/docs/api-reference/checkpoints/create.mdx@@ -0,0 +1,27 @@+---+title: 'Create Checkpoint'+api: 'POST /api/sandboxes/{id}/checkpoints'+---++Create a checkpoint of the sandbox state. Maximum 10 checkpoints per sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="name" type="string" required>+ Checkpoint name (unique per sandbox)+</ParamField>++<ResponseExample>+```json 201+{+ "id": "cp-abc123",+ "sandboxID": "sb-abc123",+ "name": "before-migration",+ "status": "processing",+ "sizeBytes": 0,+ "createdAt": "2025-01-15T10:30:00Z"+}+```+</ResponseExample>diff --git a/docs/api-reference/checkpoints/delete.mdx b/docs/api-reference/checkpoints/delete.mdxnew file mode 100644index 00000000..a3034092--- /dev/null+++ b/docs/api-reference/checkpoints/delete.mdx@@ -0,0 +1,20 @@+---+title: 'Delete Checkpoint'+api: 'DELETE /api/sandboxes/{id}/checkpoints/{checkpointId}'+---++Delete a checkpoint.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="checkpointId" type="string" required>+ Checkpoint ID+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/checkpoints/fork.mdx b/docs/api-reference/checkpoints/fork.mdxnew file mode 100644index 00000000..6e4dc096--- /dev/null+++ b/docs/api-reference/checkpoints/fork.mdx@@ -0,0 +1,25 @@+---+title: 'Fork from Checkpoint'+api: 'POST /api/sandboxes/from-checkpoint/{checkpointId}'+---++Create a new sandbox from a checkpoint.++<ParamField path="checkpointId" type="string" required>+ Checkpoint ID+</ParamField>++<ParamField body="timeout" type="integer">+ Idle timeout for the new sandbox (default: `300`)+</ParamField>++<ResponseExample>+```json 201+{+ "sandboxID": "sb-def456",+ "status": "running",+ "region": "use2",+ "workerID": "w-use2-abc123"+}+```+</ResponseExample>diff --git a/docs/api-reference/checkpoints/list.mdx b/docs/api-reference/checkpoints/list.mdxnew file mode 100644index 00000000..fc03b046--- /dev/null+++ b/docs/api-reference/checkpoints/list.mdx@@ -0,0 +1,25 @@+---+title: 'List Checkpoints'+api: 'GET /api/sandboxes/{id}/checkpoints'+---++List all checkpoints for a sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ResponseExample>+```json 200+[+ {+ "id": "cp-abc123",+ "sandboxID": "sb-abc123",+ "name": "before-migration",+ "status": "ready",+ "sizeBytes": 134217728,+ "createdAt": "2025-01-15T10:30:00Z"+ }+]+```+</ResponseExample>diff --git a/docs/api-reference/checkpoints/restore.mdx b/docs/api-reference/checkpoints/restore.mdxnew file mode 100644index 00000000..31ea59d8--- /dev/null+++ b/docs/api-reference/checkpoints/restore.mdx@@ -0,0 +1,20 @@+---+title: 'Restore Checkpoint'+api: 'POST /api/sandboxes/{id}/checkpoints/{checkpointId}/restore'+---++Revert the sandbox in-place to a checkpoint. All changes since the checkpoint are lost.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="checkpointId" type="string" required>+ Checkpoint ID+</ParamField>++<ResponseExample>+```json 200+{}+```+</ResponseExample>diff --git a/docs/api-reference/exec/create-session.mdx b/docs/api-reference/exec/create-session.mdxnew file mode 100644index 00000000..0b0a6c5a--- /dev/null+++ b/docs/api-reference/exec/create-session.mdx@@ -0,0 +1,49 @@+---+title: 'Create Exec Session'+api: 'POST /api/sandboxes/{id}/exec'+---++Start a long-running command as a session. Attach via WebSocket to stream I/O.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="cmd" type="string" required>+ Command to execute+</ParamField>++<ParamField body="args" type="string[]">+ Command arguments+</ParamField>++<ParamField body="envs" type="object">+ Environment variables+</ParamField>++<ParamField body="cwd" type="string">+ Working directory+</ParamField>++<ParamField body="timeout" type="integer">+ Timeout in seconds+</ParamField>++<ParamField body="maxRunAfterDisconnect" type="integer">+ Seconds to keep running after all clients disconnect+</ParamField>++<ResponseExample>+```json 201+{+ "sessionID": "es-abc123",+ "sandboxID": "sb-abc123",+ "command": "node",+ "args": ["server.js"],+ "running": true,+ "exitCode": null,+ "startedAt": "2025-01-15T10:30:00Z",+ "attachedClients": 0+}+```+</ResponseExample>diff --git a/docs/api-reference/exec/kill-session.mdx b/docs/api-reference/exec/kill-session.mdxnew file mode 100644index 00000000..167cf6c8--- /dev/null+++ b/docs/api-reference/exec/kill-session.mdx@@ -0,0 +1,24 @@+---+title: 'Kill Exec Session'+api: 'POST /api/sandboxes/{id}/exec/{sessionID}/kill'+---++Kill an exec session.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="sessionID" type="string" required>+ Exec session ID+</ParamField>++<ParamField body="signal" type="integer">+ Signal number (default: `9` / SIGKILL)+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/exec/list-sessions.mdx b/docs/api-reference/exec/list-sessions.mdxnew file mode 100644index 00000000..91784e98--- /dev/null+++ b/docs/api-reference/exec/list-sessions.mdx@@ -0,0 +1,27 @@+---+title: 'List Exec Sessions'+api: 'GET /api/sandboxes/{id}/exec'+---++List all exec sessions for a sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ResponseExample>+```json 200+[+ {+ "sessionID": "es-abc123",+ "sandboxID": "sb-abc123",+ "command": "node",+ "args": ["server.js"],+ "running": true,+ "exitCode": null,+ "startedAt": "2025-01-15T10:30:00Z",+ "attachedClients": 0+ }+]+```+</ResponseExample>diff --git a/docs/api-reference/exec/run.mdx b/docs/api-reference/exec/run.mdxnew file mode 100644index 00000000..581808f8--- /dev/null+++ b/docs/api-reference/exec/run.mdx@@ -0,0 +1,40 @@+---+title: 'Run Command'+api: 'POST /api/sandboxes/{id}/exec/run'+---++Execute a command synchronously and return the result.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="cmd" type="string" required>+ Command to execute+</ParamField>++<ParamField body="args" type="string[]">+ Command arguments+</ParamField>++<ParamField body="envs" type="object">+ Environment variables+</ParamField>++<ParamField body="cwd" type="string">+ Working directory+</ParamField>++<ParamField body="timeout" type="integer">+ Timeout in seconds (default: `60`)+</ParamField>++<ResponseExample>+```json 200+{+ "exitCode": 0,+ "stdout": "Hello, World!\n",+ "stderr": ""+}+```+</ResponseExample>diff --git a/docs/api-reference/files/delete.mdx b/docs/api-reference/files/delete.mdxnew file mode 100644index 00000000..ebb76fc1--- /dev/null+++ b/docs/api-reference/files/delete.mdx@@ -0,0 +1,20 @@+---+title: 'Delete File or Directory'+api: 'DELETE /api/sandboxes/{id}/files'+---++Delete a file or directory.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField query="path" type="string" required>+ Path to the file or directory to delete+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/files/list-directory.mdx b/docs/api-reference/files/list-directory.mdxnew file mode 100644index 00000000..ec02d832--- /dev/null+++ b/docs/api-reference/files/list-directory.mdx@@ -0,0 +1,23 @@+---+title: 'List Directory'+api: 'GET /api/sandboxes/{id}/files/list'+---++List contents of a directory.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField query="path" type="string">+ Directory path (default: `/`)+</ParamField>++<ResponseExample>+```json 200+[+ { "name": "app", "isDir": true, "size": 4096, "path": "/app" },+ { "name": "README.md", "isDir": false, "size": 1234, "path": "/README.md" }+]+```+</ResponseExample>diff --git a/docs/api-reference/files/mkdir.mdx b/docs/api-reference/files/mkdir.mdxnew file mode 100644index 00000000..efc85da6--- /dev/null+++ b/docs/api-reference/files/mkdir.mdx@@ -0,0 +1,20 @@+---+title: 'Create Directory'+api: 'POST /api/sandboxes/{id}/files/mkdir'+---++Create a new directory.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField query="path" type="string" required>+ Path for the new directory+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/files/read.mdx b/docs/api-reference/files/read.mdxnew file mode 100644index 00000000..0a6c45c8--- /dev/null+++ b/docs/api-reference/files/read.mdx@@ -0,0 +1,20 @@+---+title: 'Read File'+api: 'GET /api/sandboxes/{id}/files'+---++Returns file content as plain text (not JSON).++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField query="path" type="string" required>+ Absolute path to the file+</ParamField>++<ResponseExample>+```text 200+Hello, World!+```+</ResponseExample>diff --git a/docs/api-reference/files/write.mdx b/docs/api-reference/files/write.mdxnew file mode 100644index 00000000..76d98071--- /dev/null+++ b/docs/api-reference/files/write.mdx@@ -0,0 +1,20 @@+---+title: 'Write File'+api: 'PUT /api/sandboxes/{id}/files'+---++Write content to a file. The request body is written as raw file content (not JSON).++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField query="path" type="string" required>+ Absolute path for the destination file+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/overview.mdx b/docs/api-reference/overview.mdxnew file mode 100644index 00000000..2476206c--- /dev/null+++ b/docs/api-reference/overview.mdx@@ -0,0 +1,48 @@+---+title: "API Reference"+description: "Complete REST API reference for OpenComputer"+---++## Base URL++```+https://app.opencomputer.dev/api+```++## Authentication++All requests require an API key passed via the `X-API-Key` header.++```bash+curl https://app.opencomputer.dev/api/sandboxes \+ -H "X-API-Key: $OPENCOMPUTER_API_KEY"+```++## WebSocket Authentication++WebSocket endpoints accept auth via query parameter:++```+wss://app.opencomputer.dev/api/sandboxes/{id}/exec/{sessionID}?api_key=<key>+```++## Error Format++All errors use a consistent JSON envelope:++```json+{+ "error": "descriptive error message"+}+```++| Status Code | Meaning |+| --- | --- |+| `400` | Invalid request (missing fields, bad values) |+| `401` | Missing or invalid authentication |+| `403` | Insufficient permissions |+| `404` | Resource not found |+| `409` | Conflict (duplicate resource) |+| `429` | Quota exceeded |+| `500` | Internal server error |+| `503` | Feature unavailable in current deployment mode |diff --git a/docs/api-reference/patches/create.mdx b/docs/api-reference/patches/create.mdxnew file mode 100644index 00000000..17dbf015--- /dev/null+++ b/docs/api-reference/patches/create.mdx@@ -0,0 +1,34 @@+---+title: 'Create Patch'+api: 'POST /api/sandboxes/checkpoints/{checkpointId}/patches'+---++Create a patch script that runs when a sandbox is spawned from a checkpoint. Patches apply in sequence order.++<ParamField path="checkpointId" type="string" required>+ Checkpoint ID+</ParamField>++<ParamField body="script" type="string" required>+ Bash script to execute on spawn+</ParamField>++<ParamField body="description" type="string">+ Human-readable description+</ParamField>++<ResponseExample>+```json 201+{+ "patch": {+ "id": "pa-abc123",+ "checkpointId": "cp-abc123",+ "script": "apt install -y curl",+ "description": "Install curl",+ "strategy": "on_wake",+ "sequence": 1,+ "createdAt": "2025-01-15T10:30:00Z"+ }+}+```+</ResponseExample>diff --git a/docs/api-reference/patches/delete.mdx b/docs/api-reference/patches/delete.mdxnew file mode 100644index 00000000..7f28b085--- /dev/null+++ b/docs/api-reference/patches/delete.mdx@@ -0,0 +1,20 @@+---+title: 'Delete Patch'+api: 'DELETE /api/sandboxes/checkpoints/{checkpointId}/patches/{patchId}'+---++Delete a patch.++<ParamField path="checkpointId" type="string" required>+ Checkpoint ID+</ParamField>++<ParamField path="patchId" type="string" required>+ Patch ID+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/patches/list.mdx b/docs/api-reference/patches/list.mdxnew file mode 100644index 00000000..050a9595--- /dev/null+++ b/docs/api-reference/patches/list.mdx@@ -0,0 +1,26 @@+---+title: 'List Patches'+api: 'GET /api/sandboxes/checkpoints/{checkpointId}/patches'+---++List all patches for a checkpoint.++<ParamField path="checkpointId" type="string" required>+ Checkpoint ID+</ParamField>++<ResponseExample>+```json 200+[+ {+ "id": "pa-abc123",+ "checkpointId": "cp-abc123",+ "script": "apt install -y curl",+ "description": "Install curl",+ "strategy": "on_wake",+ "sequence": 1,+ "createdAt": "2025-01-15T10:30:00Z"+ }+]+```+</ResponseExample>diff --git a/docs/api-reference/preview/create.mdx b/docs/api-reference/preview/create.mdxnew file mode 100644index 00000000..d9545385--- /dev/null+++ b/docs/api-reference/preview/create.mdx@@ -0,0 +1,35 @@+---+title: 'Create Preview URL'+api: 'POST /api/sandboxes/{id}/preview'+---++Create a preview URL to expose a port from the sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="port" type="integer" required>+ Container port (1–65535)+</ParamField>++<ParamField body="domain" type="string">+ Custom domain+</ParamField>++<ParamField body="authConfig" type="object">+ Authentication configuration+</ParamField>++<ResponseExample>+```json 201+{+ "id": "pv-abc123",+ "sandboxId": "sb-abc123",+ "hostname": "sb-abc123-p3000.preview.opencomputer.dev",+ "port": 3000,+ "sslStatus": "active",+ "createdAt": "2025-01-15T10:30:00Z"+}+```+</ResponseExample>diff --git a/docs/api-reference/preview/delete.mdx b/docs/api-reference/preview/delete.mdxnew file mode 100644index 00000000..1aeec6ea--- /dev/null+++ b/docs/api-reference/preview/delete.mdx@@ -0,0 +1,20 @@+---+title: 'Delete Preview URL'+api: 'DELETE /api/sandboxes/{id}/preview/{port}'+---++Delete a preview URL.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="port" type="string" required>+ Port number+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/preview/list.mdx b/docs/api-reference/preview/list.mdxnew file mode 100644index 00000000..d4b56a41--- /dev/null+++ b/docs/api-reference/preview/list.mdx@@ -0,0 +1,25 @@+---+title: 'List Preview URLs'+api: 'GET /api/sandboxes/{id}/preview'+---++List all preview URLs for a sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ResponseExample>+```json 200+[+ {+ "id": "pv-abc123",+ "sandboxId": "sb-abc123",+ "hostname": "sb-abc123-p3000.preview.opencomputer.dev",+ "port": 3000,+ "sslStatus": "active",+ "createdAt": "2025-01-15T10:30:00Z"+ }+]+```+</ResponseExample>diff --git a/docs/api-reference/pty/create.mdx b/docs/api-reference/pty/create.mdxnew file mode 100644index 00000000..f6ebe263--- /dev/null+++ b/docs/api-reference/pty/create.mdx@@ -0,0 +1,31 @@+---+title: 'Create PTY Session'+api: 'POST /api/sandboxes/{id}/pty'+---++Create an interactive terminal session.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="cols" type="integer">+ Terminal columns (default: `80`)+</ParamField>++<ParamField body="rows" type="integer">+ Terminal rows (default: `24`)+</ParamField>++<ParamField body="shell" type="string">+ Shell path (default: `/bin/bash`)+</ParamField>++<ResponseExample>+```json 201+{+ "sessionID": "ps-abc123",+ "sandboxID": "sb-abc123"+}+```+</ResponseExample>diff --git a/docs/api-reference/pty/kill.mdx b/docs/api-reference/pty/kill.mdxnew file mode 100644index 00000000..d57a967f--- /dev/null+++ b/docs/api-reference/pty/kill.mdx@@ -0,0 +1,20 @@+---+title: 'Kill PTY Session'+api: 'DELETE /api/sandboxes/{id}/pty/{sessionID}'+---++Terminate a PTY session.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="sessionID" type="string" required>+ PTY session ID+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/pty/resize.mdx b/docs/api-reference/pty/resize.mdxnew file mode 100644index 00000000..d106e65a--- /dev/null+++ b/docs/api-reference/pty/resize.mdx@@ -0,0 +1,32 @@+---+title: 'Resize PTY'+api: 'POST /api/sandboxes/{id}/pty/{sessionID}/resize'+---++Resize a PTY session.++<Note>+ PTY resize is HTTP-only — not exposed in the TypeScript or Python SDKs. The SDKs handle resize automatically for interactive sessions.+</Note>++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField path="sessionID" type="string" required>+ PTY session ID+</ParamField>++<ParamField body="cols" type="integer" required>+ New column count+</ParamField>++<ParamField body="rows" type="integer" required>+ New row count+</ParamField>++<ResponseExample>+```json 200+{}+```+</ResponseExample>diff --git a/docs/api-reference/sandboxes/create.mdx b/docs/api-reference/sandboxes/create.mdxnew file mode 100644index 00000000..12ee183e--- /dev/null+++ b/docs/api-reference/sandboxes/create.mdx@@ -0,0 +1,49 @@+---+title: 'Create Sandbox'+api: 'POST /api/sandboxes'+---++Create a new sandbox.++<ParamField body="templateID" type="string">+ Template name (default: `"base"`)+</ParamField>++<ParamField body="timeout" type="integer">+ Idle timeout in seconds (default: `300`)+</ParamField>++<ParamField body="cpuCount" type="integer">+ CPU cores, 1–4 (default: `1`)+</ParamField>++<ParamField body="memoryMB" type="integer">+ Memory in MB, up to 2048 (default: `512`)+</ParamField>++<ParamField body="envs" type="object">+ Environment variables as key-value pairs+</ParamField>++<ParamField body="metadata" type="object">+ Arbitrary key-value pairs+</ParamField>++<ParamField body="image" type="object">+ Declarative image manifest (see [Image builder](/sandboxes/templates#image-configuration))+</ParamField>++<ParamField body="snapshot" type="string">+ Name of a pre-built snapshot for instant boot+</ParamField>++<ResponseExample>+```json 201+{+ "sandboxID": "sb-abc123",+ "status": "running",+ "region": "use2",+ "workerID": "w-use2-abc123"+}+```+</ResponseExample>diff --git a/docs/api-reference/sandboxes/delete.mdx b/docs/api-reference/sandboxes/delete.mdxnew file mode 100644index 00000000..da2563c6--- /dev/null+++ b/docs/api-reference/sandboxes/delete.mdx@@ -0,0 +1,16 @@+---+title: 'Kill Sandbox'+api: 'DELETE /api/sandboxes/{id}'+---++Terminate and remove a sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/sandboxes/get.mdx b/docs/api-reference/sandboxes/get.mdxnew file mode 100644index 00000000..5a29cd1c--- /dev/null+++ b/docs/api-reference/sandboxes/get.mdx@@ -0,0 +1,21 @@+---+title: 'Get Sandbox'+api: 'GET /api/sandboxes/{id}'+---++Get sandbox details by ID. Available on both control plane and worker.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ResponseExample>+```json 200+{+ "sandboxID": "sb-abc123",+ "status": "running",+ "region": "use2",+ "workerID": "w-use2-abc123"+}+```+</ResponseExample>diff --git a/docs/api-reference/sandboxes/hibernate.mdx b/docs/api-reference/sandboxes/hibernate.mdxnew file mode 100644index 00000000..b35ef49e--- /dev/null+++ b/docs/api-reference/sandboxes/hibernate.mdx@@ -0,0 +1,21 @@+---+title: 'Hibernate Sandbox'+api: 'POST /api/sandboxes/{id}/hibernate'+---++Snapshot VM state and stop the sandbox. Control plane only.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ResponseExample>+```json 200+{+ "sandboxID": "sb-abc123",+ "hibernationKey": "checkpoints/sb-abc123/1234567890.tar.zst",+ "sizeBytes": 134217728,+ "status": "hibernated"+}+```+</ResponseExample>diff --git a/docs/api-reference/sandboxes/list.mdx b/docs/api-reference/sandboxes/list.mdxnew file mode 100644index 00000000..a77f8390--- /dev/null+++ b/docs/api-reference/sandboxes/list.mdx@@ -0,0 +1,19 @@+---+title: 'List Sandboxes'+api: 'GET /api/sandboxes'+---++List all running sandboxes.++<ResponseExample>+```json 200+[+ {+ "sandboxID": "sb-abc123",+ "status": "running",+ "region": "use2",+ "workerID": "w-use2-abc123"+ }+]+```+</ResponseExample>diff --git a/docs/api-reference/sandboxes/set-timeout.mdx b/docs/api-reference/sandboxes/set-timeout.mdxnew file mode 100644index 00000000..310938f6--- /dev/null+++ b/docs/api-reference/sandboxes/set-timeout.mdx@@ -0,0 +1,20 @@+---+title: 'Set Timeout'+api: 'POST /api/sandboxes/{id}/timeout'+---++Update the idle timeout for a sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="timeout" type="integer" required>+ New timeout in seconds (must be > 0)+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/sandboxes/wake.mdx b/docs/api-reference/sandboxes/wake.mdxnew file mode 100644index 00000000..e618ecc3--- /dev/null+++ b/docs/api-reference/sandboxes/wake.mdx@@ -0,0 +1,25 @@+---+title: 'Wake Sandbox'+api: 'POST /api/sandboxes/{id}/wake'+---++Resume a hibernated sandbox. Control plane only.++<ParamField path="id" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="timeout" type="integer">+ Idle timeout after wake (default: `300`)+</ParamField>++<ResponseExample>+```json 200+{+ "sandboxID": "sb-abc123",+ "status": "running",+ "region": "use2",+ "workerID": "w-use2-abc123"+}+```+</ResponseExample>diff --git a/docs/api-reference/snapshots/create.mdx b/docs/api-reference/snapshots/create.mdxnew file mode 100644index 00000000..b239486d--- /dev/null+++ b/docs/api-reference/snapshots/create.mdx@@ -0,0 +1,29 @@+---+title: 'Create Snapshot'+api: 'POST /api/snapshots'+---++Create a pre-built sandbox environment from a declarative image manifest.++<ParamField body="name" type="string" required>+ Unique snapshot name+</ParamField>++<ParamField body="image" type="object" required>+ Declarative image manifest (see [Image builder](/sandboxes/templates#image-configuration))+</ParamField>++<ResponseExample>+```json 201+{+ "id": "snap-abc123",+ "name": "data-science",+ "status": "building",+ "contentHash": "sha256:...",+ "checkpointId": "",+ "manifest": { "steps": [] },+ "createdAt": "2025-01-15T10:30:00Z",+ "lastUsedAt": ""+}+```+</ResponseExample>diff --git a/docs/api-reference/snapshots/delete.mdx b/docs/api-reference/snapshots/delete.mdxnew file mode 100644index 00000000..062f22bd--- /dev/null+++ b/docs/api-reference/snapshots/delete.mdx@@ -0,0 +1,16 @@+---+title: 'Delete Snapshot'+api: 'DELETE /api/snapshots/{name}'+---++Delete a snapshot.++<ParamField path="name" type="string" required>+ Snapshot name+</ParamField>++<ResponseExample>+```json 204+{}+```+</ResponseExample>diff --git a/docs/api-reference/snapshots/get.mdx b/docs/api-reference/snapshots/get.mdxnew file mode 100644index 00000000..93d94a70--- /dev/null+++ b/docs/api-reference/snapshots/get.mdx@@ -0,0 +1,25 @@+---+title: 'Get Snapshot'+api: 'GET /api/snapshots/{name}'+---++Get snapshot details by name.++<ParamField path="name" type="string" required>+ Snapshot name+</ParamField>++<ResponseExample>+```json 200+{+ "id": "snap-abc123",+ "name": "data-science",+ "status": "ready",+ "contentHash": "sha256:...",+ "checkpointId": "cp-abc123",+ "manifest": { "steps": [] },+ "createdAt": "2025-01-15T10:30:00Z",+ "lastUsedAt": "2025-01-16T08:00:00Z"+}+```+</ResponseExample>diff --git a/docs/api-reference/snapshots/list.mdx b/docs/api-reference/snapshots/list.mdxnew file mode 100644index 00000000..a7fd9e07--- /dev/null+++ b/docs/api-reference/snapshots/list.mdx@@ -0,0 +1,23 @@+---+title: 'List Snapshots'+api: 'GET /api/snapshots'+---++List all snapshots.++<ResponseExample>+```json 200+[+ {+ "id": "snap-abc123",+ "name": "data-science",+ "status": "ready",+ "contentHash": "sha256:...",+ "checkpointId": "cp-abc123",+ "manifest": { "steps": [] },+ "createdAt": "2025-01-15T10:30:00Z",+ "lastUsedAt": "2025-01-16T08:00:00Z"+ }+]+```+</ResponseExample>diff --git a/docs/how-it-works.mdx b/docs/how-it-works.mdxindex 4cadfa80..6a1786ac 100644--- a/docs/how-it-works.mdx+++ b/docs/how-it-works.mdx@@ -3,19 +3,16 @@ title: "How It Works"description: "Architecture and key technical decisions"----Your code talks to a **control plane** API, which provisions a Firecracker microVM on a worker node. The response includes a `connectURL` and short-lived JWT for direct worker access. Commands, file operations, and agent sessions run inside that VM — events and I/O stream back over WebSocket.+Your code talks to a **control plane** API, which provisions a Firecracker microVM on a worker node. Commands, file operations, and agent sessions run inside that VM — events and I/O stream back over WebSocket. The control plane transparently proxies data-plane requests to the correct worker.-SDK users only need an API key. The SDK handles worker routing and JWT refresh transparently.+SDK users only need an API key. The SDK handles routing automatically.<Steps><Step title="Create">Your code calls the control plane (`X-API-Key` auth). A Firecracker microVM boots in ~150ms.</Step>- <Step title="Connect">- The response includes `connectURL` and a sandbox-scoped JWT `token`. Subsequent operations go directly to the worker (`Bearer` auth) for lower latency.- </Step><Step title="Operate">- Run commands, read/write files, start agent sessions. All execution happens inside the VM.+ Run commands, read/write files, start agent sessions. All execution happens inside the VM. The control plane routes requests to the correct worker automatically.</Step></Steps>@@ -93,5 +90,5 @@ await session.done;See [Agents](/agents/overview) for the full guide.<Tip>- Connection model details: [HTTP API Reference](/reference/api#base-url--authentication).+ API details: [HTTP API Reference](/reference/api#base-url--authentication).</Tip>diff --git a/docs/mint.json b/docs/mint.jsonindex a7d5238d..d713c9cd 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -33,6 +33,13 @@"modeToggle": {"default": "light"},+ "api": {+ "baseUrl": "https://app.opencomputer.dev",+ "auth": {+ "method": "key",+ "name": "X-API-Key"+ }+ },"topbarLinks": [{"name": "GitHub",@@ -91,12 +98,134 @@"pages": ["guides/build-a-lovable-clone", "guides/agent-skill"]},{- "group": "Reference",+ "group": "TypeScript SDK",+ "pages": [+ "reference/typescript-sdk/overview",+ "reference/typescript-sdk/sandbox",+ "reference/typescript-sdk/exec",+ "reference/typescript-sdk/agent",+ "reference/typescript-sdk/filesystem",+ "reference/typescript-sdk/pty",+ "reference/typescript-sdk/image",+ "reference/typescript-sdk/snapshots",+ "reference/typescript-sdk/secrets"+ ]+ },+ {+ "group": "Python SDK",+ "pages": [+ "reference/python-sdk/overview",+ "reference/python-sdk/sandbox",+ "reference/python-sdk/exec",+ "reference/python-sdk/agent",+ "reference/python-sdk/filesystem",+ "reference/python-sdk/pty",+ "reference/python-sdk/image",+ "reference/python-sdk/snapshots",+ "reference/python-sdk/secrets"+ ]+ },+ {+ "group": "CLI Reference",+ "pages": [+ "reference/cli/overview",+ "reference/cli/sandbox",+ "reference/cli/exec",+ "reference/cli/shell",+ "reference/cli/checkpoint",+ "reference/cli/patch",+ "reference/cli/preview",+ "reference/cli/config"+ ]+ },+ {+ "group": "API Reference","pages": [- "reference/api",- "reference/typescript-sdk",- "reference/python-sdk",- "reference/cli"+ "api-reference/overview",+ {+ "group": "Sandboxes",+ "pages": [+ "api-reference/sandboxes/create",+ "api-reference/sandboxes/list",+ "api-reference/sandboxes/get",+ "api-reference/sandboxes/delete",+ "api-reference/sandboxes/set-timeout",+ "api-reference/sandboxes/hibernate",+ "api-reference/sandboxes/wake"+ ]+ },+ {+ "group": "Commands",+ "pages": [+ "api-reference/exec/run",+ "api-reference/exec/create-session",+ "api-reference/exec/list-sessions",+ "api-reference/exec/kill-session"+ ]+ },+ {+ "group": "Agent Sessions",+ "pages": [+ "api-reference/agent/create",+ "api-reference/agent/list",+ "api-reference/agent/prompt",+ "api-reference/agent/interrupt",+ "api-reference/agent/kill"+ ]+ },+ {+ "group": "Filesystem",+ "pages": [+ "api-reference/files/read",+ "api-reference/files/write",+ "api-reference/files/list-directory",+ "api-reference/files/mkdir",+ "api-reference/files/delete"+ ]+ },+ {+ "group": "Checkpoints",+ "pages": [+ "api-reference/checkpoints/create",+ "api-reference/checkpoints/list",+ "api-reference/checkpoints/restore",+ "api-reference/checkpoints/fork",+ "api-reference/checkpoints/delete"+ ]+ },+ {+ "group": "Patches",+ "pages": [+ "api-reference/patches/create",+ "api-reference/patches/list",+ "api-reference/patches/delete"+ ]+ },+ {+ "group": "Preview URLs",+ "pages": [+ "api-reference/preview/create",+ "api-reference/preview/list",+ "api-reference/preview/delete"+ ]+ },+ {+ "group": "Snapshots",+ "pages": [+ "api-reference/snapshots/create",+ "api-reference/snapshots/list",+ "api-reference/snapshots/get",+ "api-reference/snapshots/delete"+ ]+ },+ {+ "group": "PTY",+ "pages": [+ "api-reference/pty/create",+ "api-reference/pty/resize",+ "api-reference/pty/kill"+ ]+ }]},{diff --git a/docs/reference/api.mdx b/docs/reference/api.mdxindex 50281227..1bc5ae9a 100644--- a/docs/reference/api.mdx+++ b/docs/reference/api.mdx@@ -3,614 +3,19 @@ title: "HTTP API"description: "Complete REST API reference"----## Base URL & Authentication--OpenComputer exposes two API surfaces:--| Surface | Base URL | Auth Header | Use |-| --- | --- | --- | --- |-| **Control plane** | `https://app.opencomputer.dev/api` | `X-API-Key: <key>` | Create/list/kill sandboxes, templates, hibernation |-| **Worker direct** | `connectURL` from create/get response | `Authorization: Bearer <jwt>` | Exec, files, agents, PTY, timeout |--The `connectURL` and `token` fields are returned when you create or get a sandbox. Worker-direct routes have **no `/api` prefix** — for example, `POST {connectURL}/sandboxes/:id/exec/run`.--SDK users only need the API key. The SDK resolves `connectURL` and manages the JWT automatically.--### Route Availability--Most operational routes are available on **both** surfaces. Exceptions:--| Route | Control Plane | Worker |-| --- | --- | --- |-| `POST /api/sandboxes` (create) | Yes | — |-| `GET /api/sandboxes` (list all) | Yes | — |-| `DELETE /api/sandboxes/:id` (kill) | Yes | — |-| `POST .../hibernate`, `.../wake` | Yes | — |-| Checkpoint routes | Yes | — |-| Preview URL routes | Yes | — |-| Snapshot routes | Yes | — |-| `POST .../token/refresh` | — | Yes |-| `POST .../timeout` | — | Yes |-| Exec, filesystem, agent, PTY routes | Yes | Yes |--### Token Refresh--Worker JWTs are short-lived. To refresh:--```bash-curl -X POST {connectURL}/sandboxes/{id}/token/refresh \- -H "Authorization: Bearer $TOKEN"-```--Returns a new JWT. The SDKs handle this automatically.-------## Sandbox Lifecycle--### `POST /api/sandboxes` — Create--Create a new sandbox.--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `templateID` | string | No | Template name (default: `"base"`) |-| `timeout` | int | No | Idle timeout in seconds (default: `300`) |-| `cpuCount` | int | No | CPU cores, 1–4 (default: `1`) |-| `memoryMB` | int | No | Memory in MB, up to 2048 (default: `512`) |-| `envs` | object | No | Environment variables |-| `metadata` | object | No | Arbitrary key-value pairs |-| `image` | object | No | Declarative image manifest (see [Image builder](/sandboxes/templates#image-configuration)) |-| `snapshot` | string | No | Name of a pre-built snapshot (see [Snapshots](#snapshots)) |--**Response** `201`:--```json-{- "sandboxID": "sb-abc123",- "templateID": "base",- "status": "running",- "startedAt": "2025-01-15T10:30:00Z",- "endAt": "2025-01-15T10:35:00Z",- "cpuCount": 1,- "memoryMB": 512,- "metadata": {},- "connectURL": "https://worker-xyz.opencomputer.dev",- "token": "eyJhbG..."-}-```--```bash-curl -X POST https://app.opencomputer.dev/api/sandboxes \- -H "X-API-Key: $OPENCOMPUTER_API_KEY" \- -H "Content-Type: application/json" \- -d '{"templateID": "base", "timeout": 600}'-```--### `GET /api/sandboxes` — List--List all running sandboxes.--**Response** `200`: Array of sandbox objects.--### `GET /api/sandboxes/:id` — Get+The full interactive API reference is available in the [API Reference](/api-reference/sandboxes/create) tab.-Get sandbox details by ID. Available on both control plane and worker.--**Response** `200`: Sandbox object (same shape as create response).--### `DELETE /api/sandboxes/:id` — Kill--Terminate and remove a sandbox.--**Response** `204`: No content.--### `POST /api/sandboxes/:id/timeout` — Set Timeout--Update the idle timeout. **Worker-direct only** — must be sent to the worker via `connectURL` with a Bearer token. The control plane will reject this request.--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `timeout` | int | Yes | New timeout in seconds (must be > 0) |--**Response** `204`: No content.--### `POST /api/sandboxes/:id/hibernate` — Hibernate--Snapshot VM state and stop the sandbox. Control plane only.--**Response** `200`:--```json-{- "sandboxID": "sb-abc123",- "hibernationKey": "checkpoints/sb-abc123/1234567890.tar.zst",- "sizeBytes": 134217728,- "status": "hibernated"-}-```--### `POST /api/sandboxes/:id/wake` — Wake--Resume a hibernated sandbox. Control plane only.--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `timeout` | int | No | Idle timeout after wake (default: `300`) |--**Response** `200`: Sandbox object with updated status.-------## Commands (Exec)--### `POST /api/sandboxes/:id/exec/run` — Run Command--Execute a command synchronously and return the result. Available on both surfaces.--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `cmd` | string | Yes | Command to execute |-| `args` | string[] | No | Command arguments |-| `envs` | object | No | Environment variables |-| `cwd` | string | No | Working directory |-| `timeout` | int | No | Timeout in seconds (default: `60`) |--**Response** `200`:--```json-{- "exitCode": 0,- "stdout": "Hello, World!\n",- "stderr": ""-}-```--```bash-curl -X POST {connectURL}/sandboxes/{id}/exec/run \- -H "Authorization: Bearer $TOKEN" \- -H "Content-Type: application/json" \- -d '{"cmd": "echo", "args": ["Hello, World!"]}'-```--### `POST /api/sandboxes/:id/exec` — Create Exec Session--Start a long-running command as a session. Attach via WebSocket to stream I/O.--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `cmd` | string | Yes | Command to execute |-| `args` | string[] | No | Command arguments |-| `envs` | object | No | Environment variables |-| `cwd` | string | No | Working directory |-| `timeout` | int | No | Timeout in seconds |-| `maxRunAfterDisconnect` | int | No | Seconds to keep running after all clients disconnect |--**Response** `201`:--```json-{- "sessionID": "es-abc123",- "sandboxID": "sb-abc123",- "command": "node",- "args": ["server.js"],- "running": true,- "exitCode": null,- "startedAt": "2025-01-15T10:30:00Z",- "attachedClients": 0-}-```--### `GET /api/sandboxes/:id/exec` — List Sessions--**Response** `200`: Array of `ExecSessionInfo` objects (same shape as create response).--### `GET /api/sandboxes/:id/exec/:sessionID` — WebSocket Attach--Upgrade to WebSocket. Streams I/O using the [binary protocol](#websocket-binary-protocol).--Pass auth via query parameter: `?token=<jwt>`--On connect, the server replays the scrollback buffer, sends a `0x04` end marker, then streams live output.--### `POST /api/sandboxes/:id/exec/:sessionID/kill` — Kill Session--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `signal` | int | No | Signal number (default: `9` / SIGKILL) |--**Response** `204`: No content.-------## Agent Sessions--Agent sessions run the Claude Agent SDK inside the sandbox. Events stream over the exec session WebSocket transport — there is no separate agent WebSocket endpoint.--### `POST /api/sandboxes/:id/agent` — Create--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `prompt` | string | No | Initial prompt |-| `model` | string | No | Claude model name |-| `systemPrompt` | string | No | System prompt |-| `allowedTools` | string[] | No | Restrict available tools |-| `permissionMode` | string | No | Permission mode |-| `maxTurns` | int | No | Maximum turns |-| `cwd` | string | No | Working directory |-| `mcpServers` | object | No | MCP server configuration |-| `resume` | string | No | Session ID to resume |--**Response** `201`:--```json-{- "sessionID": "as-abc123",- "sandboxID": "sb-abc123",- "running": true,- "startedAt": "2025-01-15T10:30:00Z",- "claudeSessionID": ""-}-```--```bash-curl -X POST {connectURL}/sandboxes/{id}/agent \- -H "Authorization: Bearer $TOKEN" \- -H "Content-Type: application/json" \- -d '{"prompt": "Create a hello world app", "model": "claude-sonnet-4-20250514"}'-```--### `GET /api/sandboxes/:id/agent` — List--**Response** `200`: Array of `AgentSessionInfo` objects.--### `POST /api/sandboxes/:id/agent/:sid/prompt` — Send Follow-up--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `text` | string | Yes | Follow-up prompt text |--**Response** `200`: Empty object.--### `POST /api/sandboxes/:id/agent/:sid/interrupt` — Interrupt--Stop the agent's current turn.--**Response** `200`: Empty object.--### `POST /api/sandboxes/:id/agent/:sid/kill` — Kill--Terminate the agent session.--**Response** `200`: Empty object.-------## Filesystem--### `GET /api/sandboxes/:id/files?path=...` — Read File--Returns file content as **plain text** (not JSON). The `path` query parameter is required.--```bash-curl {connectURL}/sandboxes/{id}/files?path=/app/index.js \- -H "Authorization: Bearer $TOKEN"-```--**Response** `200`: Raw file content with `Content-Type: text/plain`.--### `PUT /api/sandboxes/:id/files?path=...` — Write File--The request body is written as raw file content (not JSON). The `path` query parameter specifies the destination.--```bash-curl -X PUT {connectURL}/sandboxes/{id}/files?path=/app/hello.txt \- -H "Authorization: Bearer $TOKEN" \- -H "Content-Type: text/plain" \- -d "Hello, World!"-```--**Response** `204`: No content.--### `GET /api/sandboxes/:id/files/list?path=...` — List Directory--**Query parameter:** `path` (default: `/`)--**Response** `200`:--```json-[- { "name": "app", "isDir": true, "size": 4096, "path": "/app" },- { "name": "README.md", "isDir": false, "size": 1234, "path": "/README.md" }-]-```--Each entry has: `name` (string), `isDir` (boolean), `size` (int64), `path` (string).--### `POST /api/sandboxes/:id/files/mkdir?path=...` — Create Directory--The `path` query parameter specifies the directory to create.--**Response** `204`: No content.--### `DELETE /api/sandboxes/:id/files?path=...` — Remove--Delete a file or directory. The `path` query parameter is required.--**Response** `204`: No content.-------## Checkpoints--Maximum 10 checkpoints per sandbox.--### `POST /api/sandboxes/:id/checkpoints` — Create--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `name` | string | Yes | Checkpoint name (unique per sandbox) |--**Response** `201`:--```json-{- "id": "cp-abc123",- "sandboxID": "sb-abc123",- "name": "before-migration",- "status": "processing",- "sizeBytes": 0,- "createdAt": "2025-01-15T10:30:00Z"-}-```--Status transitions: `processing` → `ready` or `failed`.--### `GET /api/sandboxes/:id/checkpoints` — List--**Response** `200`: Array of `CheckpointInfo` objects.--### `POST /api/sandboxes/:id/checkpoints/:checkpointId/restore` — Restore--Revert the sandbox in-place to a checkpoint. All changes since the checkpoint are lost.--**Response** `200`: Empty object.--### `POST /api/sandboxes/from-checkpoint/:checkpointId` — Fork--Create a new sandbox from a checkpoint.--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `timeout` | int | No | Idle timeout for the new sandbox (default: `300`) |--**Response** `201`: Sandbox object (same shape as create).--```bash-curl -X POST https://app.opencomputer.dev/api/sandboxes/from-checkpoint/cp-abc123 \- -H "X-API-Key: $OPENCOMPUTER_API_KEY" \- -H "Content-Type: application/json" \- -d '{"timeout": 600}'-```--### `DELETE /api/sandboxes/:id/checkpoints/:checkpointId` — Delete--**Response** `204`: No content.-------## Checkpoint Patches--Patches are scripts that run when a sandbox is spawned from a checkpoint. They apply in sequence order.--### `POST /api/sandboxes/checkpoints/:checkpointId/patches` — Create--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `script` | string | Yes | Bash script to execute on spawn |-| `description` | string | No | Human-readable description |--**Response** `201`:--```json-{- "patch": {- "id": "pa-abc123",- "checkpointId": "cp-abc123",- "script": "apt install -y curl",- "description": "Install curl",- "strategy": "on_wake",- "sequence": 1,- "createdAt": "2025-01-15T10:30:00Z"- }-}-```--### `GET /api/sandboxes/checkpoints/:checkpointId/patches` — List--**Response** `200`: Array of `PatchInfo` objects.--### `DELETE /api/sandboxes/checkpoints/:checkpointId/patches/:patchId` — Delete--**Response** `204`: No content.-------## Preview URLs--### `POST /api/sandboxes/:id/preview` — Create--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `port` | int | Yes | Container port (1–65535) |-| `domain` | string | No | Custom domain |-| `authConfig` | object | No | Authentication configuration |--**Response** `201`:--```json-{- "id": "pv-abc123",- "sandboxId": "sb-abc123",- "hostname": "sb-abc123-p3000.preview.opencomputer.dev",- "port": 3000,- "sslStatus": "active",- "createdAt": "2025-01-15T10:30:00Z"-}-```--### `GET /api/sandboxes/:id/preview` — List--**Response** `200`: Array of preview URL objects.--### `DELETE /api/sandboxes/:id/preview/:port` — Delete--**Response** `204`: No content.-------## Snapshots--Snapshots are pre-built sandbox environments created from declarative image manifests. Once built, sandboxes can be created from them instantly.--### `POST /api/snapshots` — Create--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `name` | string | Yes | Unique snapshot name |-| `image` | object | Yes | Declarative image manifest (see [Image builder](/sandboxes/templates#image-configuration)) |--**Response** `201`:--```json-{- "id": "snap-abc123",- "name": "data-science",- "status": "building",- "contentHash": "sha256:...",- "checkpointId": "",- "manifest": { "steps": [...] },- "createdAt": "2025-01-15T10:30:00Z",- "lastUsedAt": ""-}-```--Status transitions: `building` → `ready` or `failed`.--### `GET /api/snapshots` — List--**Response** `200`: Array of snapshot objects.--### `GET /api/snapshots/:name` — Get--**Response** `200`: Snapshot object.--### `DELETE /api/snapshots/:name` — Delete--**Response** `204`: No content.--### Using snapshots and images with `POST /api/sandboxes`--The create sandbox endpoint accepts `snapshot` or `image` fields in addition to `templateID`:--| Field | Type | Description |-| --- | --- | --- |-| `snapshot` | string | Name of a pre-built snapshot — instant boot, no build step |-| `image` | object | Declarative image manifest — built on first use, cached by content hash |--```bash-# From a snapshot (instant)-curl -X POST https://app.opencomputer.dev/api/sandboxes \- -H "X-API-Key: $OPENCOMPUTER_API_KEY" \- -H "Content-Type: application/json" \- -d '{"snapshot": "data-science", "timeout": 600}'--# From a declarative image (built + cached)-curl -X POST https://app.opencomputer.dev/api/sandboxes \- -H "X-API-Key: $OPENCOMPUTER_API_KEY" \- -H "Content-Type: application/json" \- -d '{"image": {"steps": [{"type": "apt_install", "packages": ["curl"]}]}, "timeout": 600}'-```-------## PTY--Terminal sessions for interactive shell access.--### `POST /api/sandboxes/:id/pty` — Create--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `cols` | int | No | Terminal columns (default: `80`) |-| `rows` | int | No | Terminal rows (default: `24`) |-| `shell` | string | No | Shell path (default: `/bin/bash`) |--**Response** `201`:--```json-{- "sessionID": "ps-abc123",- "sandboxID": "sb-abc123"-}-```--### `GET /api/sandboxes/:id/pty/:sessionID` — WebSocket--Upgrade to WebSocket. Raw binary I/O — data from the PTY is sent as-is, data received is written to PTY stdin.--Pass auth via query parameter: `?token=<jwt>`--### `POST /api/sandboxes/:id/pty/:sessionID/resize` — Resize--**Request body:**--| Field | Type | Required | Description |-| --- | --- | --- | --- |-| `cols` | int | Yes | New column count |-| `rows` | int | Yes | New row count |--**Response** `200`: Empty object.--<Note>- PTY resize is HTTP-only — not exposed in the TypeScript or Python SDKs. The SDKs handle resize automatically for interactive sessions.-</Note>+## Base URL & Authentication-### `DELETE /api/sandboxes/:id/pty/:sessionID` — Kill+All API requests go through the control plane:-Terminate a PTY session.+| Base URL | Auth Header |+| --- | --- |+| `https://app.opencomputer.dev/api` | `X-API-Key: <key>` |-**Response** `204`: No content.+The control plane handles sandbox lifecycle (create, list, kill, hibernate, wake) and transparently proxies data-plane requests (exec, files, agents, PTY) to the worker that owns the sandbox.----+SDK users only need the API key.## WebSocket Binary Protocol@@ -626,7 +31,7 @@ Exec and PTY WebSocket sessions use binary frames with a 1-byte stream prefix:**Connection flow:**-1. Client opens WebSocket with `?token=<jwt>`+1. Client opens WebSocket with `?api_key=<key>`2. Server replays scrollback buffer (historical output)3. Server sends `0x04` to mark end of scrollback4. Live output streams as `0x01`/`0x02` frames@@ -637,8 +42,6 @@ Exec and PTY WebSocket sessions use binary frames with a 1-byte stream prefix:**PTY sessions** use the same binary framing but without stream prefixes — raw bidirectional terminal data.-----## Error FormatAll errors use a consistent envelope:diff --git a/docs/reference/cli/checkpoint.mdx b/docs/reference/cli/checkpoint.mdxnew file mode 100644index 00000000..96bd283d--- /dev/null+++ b/docs/reference/cli/checkpoint.mdx@@ -0,0 +1,53 @@+---+title: "oc checkpoint"+description: "Manage sandbox checkpoints"+---++**Alias:** `oc cp`++## `oc checkpoint create <sandbox-id>`++Create a named checkpoint of a running sandbox. [HTTP API →](/api-reference/checkpoints/create)++<ParamField query="--name" type="string" required>+ Checkpoint name+</ParamField>++```bash+oc cp create sb-abc --name before-migration+```++---++## `oc checkpoint list <sandbox-id>`++List checkpoints for a sandbox. [HTTP API →](/api-reference/checkpoints/list)++Output columns: `ID`, `NAME`, `STATUS`, `SIZE`, `CREATED`++---++## `oc checkpoint restore <sandbox-id> <checkpoint-id>`++Revert a sandbox in-place to a checkpoint. All changes since the checkpoint are lost. [HTTP API →](/api-reference/checkpoints/restore)++---++## `oc checkpoint spawn <checkpoint-id>`++Create a new sandbox from a checkpoint (fork). [HTTP API →](/api-reference/checkpoints/fork)++<ParamField query="--timeout" type="int" default="300">+ Idle timeout for the new sandbox+</ParamField>++```bash+ID=$(oc cp spawn cp-xyz --json | jq -r '.sandboxID')+oc exec "$ID" --wait -- echo "forked sandbox ready"+```++---++## `oc checkpoint delete <sandbox-id> <checkpoint-id>`++Delete a checkpoint. [HTTP API →](/api-reference/checkpoints/delete)diff --git a/docs/reference/cli/config.mdx b/docs/reference/cli/config.mdxnew file mode 100644index 00000000..10127020--- /dev/null+++ b/docs/reference/cli/config.mdx@@ -0,0 +1,21 @@+---+title: "oc config"+description: "CLI configuration"+---++Manage CLI configuration. Settings are persisted to a local config file.++## `oc config set <key> <value>`++Supported keys: `api-key`, `api-url`.++```bash+oc config set api-key sk-1234...+oc config set api-url https://app.opencomputer.dev+```++---++## `oc config show`++Display current configuration. The API key is masked (first 4 and last 4 characters shown).diff --git a/docs/reference/cli/exec.mdx b/docs/reference/cli/exec.mdxnew file mode 100644index 00000000..517dc105--- /dev/null+++ b/docs/reference/cli/exec.mdx@@ -0,0 +1,61 @@+---+title: "oc exec"+description: "Execute commands inside a sandbox"+---++## `oc exec <id> [flags] -- <command...>`++By default, creates an **exec session** and prints the session ID with attach instructions. Use `--wait` to run synchronously.++[HTTP API →](/api-reference/exec/run)++<ParamField query="--wait" type="boolean" default="false">+ Wait for completion, stream output, mirror exit code+</ParamField>++<ParamField query="--cwd" type="string">+ Working directory+</ParamField>++<ParamField query="--timeout" type="int" default="0">+ Timeout in seconds (0 = none)+</ParamField>++<ParamField query="--env" type="string">+ Environment variable `KEY=VALUE` (repeatable)+</ParamField>++```bash+# Synchronous — streams output, exits with process exit code+oc exec sb-abc --wait -- npm run build++# Asynchronous — creates session, prints session ID+oc exec sb-abc -- node server.js+# → Session es-xyz created. Attach with: oc exec attach sb-abc es-xyz+```++---++## `oc exec list <id>`++List active exec sessions for a sandbox. [HTTP API →](/api-reference/exec/list-sessions)++Output: session ID, status (`running` or `exited (code)`), command, client count.++---++## `oc exec attach <id> <session-id>`++<Warning>+ Not yet implemented. The command exists but prints guidance to use the SDK or a WebSocket client (`websocat`).+</Warning>++---++## `oc exec kill <id> <session-id>`++Kill an exec session. [HTTP API →](/api-reference/exec/kill-session)++<ParamField query="--signal" type="int" default="9">+ Signal number (default: SIGKILL)+</ParamField>diff --git a/docs/reference/cli/overview.mdx b/docs/reference/cli/overview.mdxnew file mode 100644index 00000000..fd00e480--- /dev/null+++ b/docs/reference/cli/overview.mdx@@ -0,0 +1,46 @@+---+title: "CLI Reference"+description: "Every command, subcommand, and flag"+---++## Global Flags++These flags apply to all commands.++<ParamField query="--api-key" type="string">+ API key for authentication. Env: `OPENCOMPUTER_API_KEY`+</ParamField>++<ParamField query="--api-url" type="string">+ Control plane URL. Env: `OPENCOMPUTER_API_URL`+</ParamField>++<ParamField query="--json" type="boolean">+ Output as JSON+</ParamField>++## Commands++<CardGroup cols={2}>+ <Card title="oc sandbox" icon="box" href="/reference/cli/sandbox">+ Manage sandbox lifecycle+ </Card>+ <Card title="oc exec" icon="terminal" href="/reference/cli/exec">+ Execute commands inside a sandbox+ </Card>+ <Card title="oc shell" icon="rectangle-terminal" href="/reference/cli/shell">+ Interactive terminal access+ </Card>+ <Card title="oc checkpoint" icon="camera" href="/reference/cli/checkpoint">+ Manage sandbox checkpoints+ </Card>+ <Card title="oc patch" icon="file-code" href="/reference/cli/patch">+ Manage checkpoint patches+ </Card>+ <Card title="oc preview" icon="globe" href="/reference/cli/preview">+ Manage preview URLs+ </Card>+ <Card title="oc config" icon="gear" href="/reference/cli/config">+ CLI configuration+ </Card>+</CardGroup>diff --git a/docs/reference/cli/patch.mdx b/docs/reference/cli/patch.mdxnew file mode 100644index 00000000..e11629ba--- /dev/null+++ b/docs/reference/cli/patch.mdx@@ -0,0 +1,37 @@+---+title: "oc patch"+description: "Manage checkpoint patches"+---++Patches are scripts that run when a sandbox is spawned from a checkpoint.++## `oc patch create <checkpoint-id>`++[HTTP API →](/api-reference/patches/create)++<ParamField query="--script" type="string" required>+ Path to script file, or `-` for stdin+</ParamField>++<ParamField query="--description" type="string">+ Patch description+</ParamField>++```bash+oc patch create cp-xyz --script=./setup.sh --description="Install deps"+echo "apt install -y curl" | oc patch create cp-xyz --script=-+```++---++## `oc patch list <checkpoint-id>`++[HTTP API →](/api-reference/patches/list)++Output columns: `ID`, `SEQ`, `DESCRIPTION`, `STRATEGY`, `CREATED`++---++## `oc patch delete <checkpoint-id> <patch-id>`++[HTTP API →](/api-reference/patches/delete)diff --git a/docs/reference/cli/preview.mdx b/docs/reference/cli/preview.mdxnew file mode 100644index 00000000..3929324c--- /dev/null+++ b/docs/reference/cli/preview.mdx@@ -0,0 +1,36 @@+---+title: "oc preview"+description: "Manage preview URLs"+---++Expose sandbox ports to the internet.++## `oc preview create <sandbox-id>`++[HTTP API →](/api-reference/preview/create)++<ParamField query="--port" type="int" required>+ Container port to expose+</ParamField>++<ParamField query="--domain" type="string">+ Custom domain+</ParamField>++```bash+oc preview create sb-abc --port 3000+```++---++## `oc preview list <sandbox-id>`++[HTTP API →](/api-reference/preview/list)++Output columns: `PORT`, `HOSTNAME`, `SSL`, `CREATED`++---++## `oc preview delete <sandbox-id> <port>`++[HTTP API →](/api-reference/preview/delete)diff --git a/docs/reference/cli/sandbox.mdx b/docs/reference/cli/sandbox.mdxnew file mode 100644index 00000000..49985521--- /dev/null+++ b/docs/reference/cli/sandbox.mdx@@ -0,0 +1,89 @@+---+title: "oc sandbox"+description: "Manage sandbox lifecycle"+---++## `oc sandbox create`++Create a new sandbox. **Alias:** `oc create`++[HTTP API →](/api-reference/sandboxes/create)++<ParamField query="--timeout" type="int" default="300">+ Idle timeout in seconds+</ParamField>++<ParamField query="--cpu" type="int" default="0">+ CPU cores (0 = platform default)+</ParamField>++<ParamField query="--memory" type="int" default="0">+ Memory in MB (0 = platform default)+</ParamField>++<ParamField query="--env" type="string">+ Environment variable `KEY=VALUE` (repeatable)+</ParamField>++<ParamField query="--metadata" type="string">+ Metadata `KEY=VALUE` (repeatable)+</ParamField>++```bash+oc create --timeout 600 --cpu 2 --memory 1024 --env NODE_ENV=production+```++---++## `oc sandbox list`++List all running sandboxes. **Alias:** `oc ls`++[HTTP API →](/api-reference/sandboxes/list)++Output columns: `ID`, `TEMPLATE`, `STATUS`, `CPU`, `MEM`, `AGE`++```bash+oc ls+oc ls --json+```++---++## `oc sandbox get <id>`++Show detailed information for a sandbox. [HTTP API →](/api-reference/sandboxes/get)++Output: ID, Template, Status, CPU, Memory, Started, Ends.++---++## `oc sandbox kill <id>`++Terminate and remove a sandbox. [HTTP API →](/api-reference/sandboxes/delete)++---++## `oc sandbox hibernate <id>`++Snapshot VM state and stop the sandbox. Displays snapshot size on success. [HTTP API →](/api-reference/sandboxes/hibernate)++---++## `oc sandbox wake <id>`++Resume a hibernated sandbox. [HTTP API →](/api-reference/sandboxes/wake)++<ParamField query="--timeout" type="int" default="300">+ Idle timeout in seconds after wake+</ParamField>++---++## `oc sandbox set-timeout <id> <seconds>`++Update the idle timeout for a running sandbox. [HTTP API →](/api-reference/sandboxes/set-timeout)++```bash+oc sandbox set-timeout sb-abc123 600+```diff --git a/docs/reference/cli/shell.mdx b/docs/reference/cli/shell.mdxnew file mode 100644index 00000000..0fb2f583--- /dev/null+++ b/docs/reference/cli/shell.mdx@@ -0,0 +1,19 @@+---+title: "oc shell"+description: "Interactive terminal access"+---++## `oc shell <id>`++Open an interactive terminal (PTY) session via WebSocket. [HTTP API →](/api-reference/pty/create)++<ParamField query="--shell" type="string" default="/bin/bash">+ Shell to use+</ParamField>++Terminal size is auto-detected and resize events are forwarded. Press `Ctrl+D` or type `exit` to disconnect. The PTY session is cleaned up automatically on exit.++```bash+oc shell sb-abc123+oc shell sb-abc123 --shell /bin/zsh+```diff --git a/docs/reference/python-sdk/agent.mdx b/docs/reference/python-sdk/agent.mdxnew file mode 100644index 00000000..b93cbce4--- /dev/null+++ b/docs/reference/python-sdk/agent.mdx@@ -0,0 +1,142 @@+---+title: "Agent"+description: "Start and manage Claude agent sessions"+---++Accessed via `sandbox.agent`.++## `await sandbox.agent.start(...)`++Start an agent session. [HTTP API →](/api-reference/agent/create)++<ParamField body="prompt" type="str">+ Initial prompt+</ParamField>++<ParamField body="model" type="str">+ Claude model+</ParamField>++<ParamField body="system_prompt" type="str">+ System prompt+</ParamField>++<ParamField body="allowed_tools" type="list[str]">+ Restrict tools+</ParamField>++<ParamField body="permission_mode" type="str">+ Permission mode+</ParamField>++<ParamField body="max_turns" type="int" default="50">+ Max turns+</ParamField>++<ParamField body="cwd" type="str">+ Working directory+</ParamField>++<ParamField body="mcp_servers" type="dict[str, Any]">+ MCP server configuration+</ParamField>++<ParamField body="on_event" type="Callable[[AgentEvent], None]">+ Event callback+</ParamField>++<ParamField body="on_error" type="Callable[[str], None]">+ Stderr callback+</ParamField>++**Returns:** `AgentSession`++```python+session = await sandbox.agent.start(+ prompt="Build a todo app",+ on_event=lambda e: print(e.type),+)+```++<Note>+ `resume`, `on_exit`, and `on_scrollback_end` are not available in the Python SDK.+</Note>++---++## `await sandbox.agent.attach(session_id, ...)`++Reconnect to a running agent session. Accepts `on_event` and `on_error`.++**Returns:** `AgentSession`++---++## `await sandbox.agent.list()`++List all agent sessions. [HTTP API →](/api-reference/agent/list)++**Returns:** `list[AgentSessionInfo]`++---++## AgentSession++| Member | Type | Description |+| --- | --- | --- |+| `session_id` | `str` | Session ID |+| `sandbox_id` | `str` | Sandbox ID |+| `send_prompt(text)` | method | Send follow-up prompt |+| `interrupt()` | method | Interrupt current turn |+| `configure(...)` | method | Update model, tools, cwd |+| `await kill(signal=9)` | method | Kill agent process |+| `await close()` | method | Close WebSocket |++### `await session.collect_events()`++Collect all events until the agent process exits. Python-unique alternative to callbacks.++**Returns:** `list[AgentEvent]`++```python+session = await sandbox.agent.start(prompt="Fix the tests")+events = await session.collect_events()+for event in events:+ if event.type == "result":+ print(event.data)+```++### `await session.wait()`++Wait for the agent to finish.++**Returns:** `int` (exit code)++---++## Types++<Accordion title="AgentEvent">+```python+@dataclass+class AgentEvent:+ type: str+ data: dict[str, Any]++# Usage:+event["message"] # dict-like access+event.get("message") # safe access with default+event.type # attribute access+```+</Accordion>++<Accordion title="AgentSessionInfo">+```python+@dataclass+class AgentSessionInfo:+ session_id: str+ sandbox_id: str+ running: bool+ started_at: str+```+</Accordion>diff --git a/docs/reference/python-sdk/exec.mdx b/docs/reference/python-sdk/exec.mdxnew file mode 100644index 00000000..8c845a15--- /dev/null+++ b/docs/reference/python-sdk/exec.mdx@@ -0,0 +1,122 @@+---+title: "Exec"+description: "Run commands and manage exec sessions"+---++Accessed via `sandbox.exec`.++## `await sandbox.exec.run(command, ...)`++Run a command synchronously via `sh -c`. [HTTP API →](/api-reference/exec/run)++<ParamField body="command" type="str" required>+ Shell command+</ParamField>++<ParamField body="timeout" type="int" default="60">+ Timeout in seconds+</ParamField>++<ParamField body="env" type="dict[str, str]">+ Environment variables+</ParamField>++<ParamField body="cwd" type="str">+ Working directory+</ParamField>++**Returns:** `ProcessResult`++```python+result = await sandbox.exec.run("npm test", cwd="/app")+```++---++## `await sandbox.exec.start(command, ...)`++Start a long-running command. Returns the **session ID** (not a session object). [HTTP API →](/api-reference/exec/create-session)++<ParamField body="command" type="str" required>+ Command+</ParamField>++<ParamField body="args" type="list[str]">+ Arguments+</ParamField>++<ParamField body="env" type="dict[str, str]">+ Environment variables+</ParamField>++<ParamField body="cwd" type="str">+ Working directory+</ParamField>++<ParamField body="timeout" type="int">+ Timeout in seconds+</ParamField>++**Returns:** `str` (session ID)++```python+session_id = await sandbox.exec.start("node server.js", cwd="/app")+```++<Note>+ Python `exec.start()` returns a session ID string. There are no streaming callbacks, `ExecSession` object, or `max_run_after_disconnect`. For streaming, use the [WebSocket binary protocol](/reference/api#websocket-binary-protocol).+</Note>++---++## `await sandbox.exec.list()`++List all exec sessions. [HTTP API →](/api-reference/exec/list-sessions)++**Returns:** `list[ExecSessionInfo]`++---++## `await sandbox.exec.kill(session_id, signal=9)`++Kill an exec session. [HTTP API →](/api-reference/exec/kill-session)++**Returns:** `None`++---++## Not Available in Python++- `exec.attach()` — reconnect to running session+- Streaming callbacks (`on_stdout`, `on_stderr`, `on_exit`)+- `ExecSession` object with `send_stdin()` and `done`+- `max_run_after_disconnect`++---++## Types++<Accordion title="ProcessResult">+```python+@dataclass+class ProcessResult:+ exit_code: int+ stdout: str+ stderr: str+```+</Accordion>++<Accordion title="ExecSessionInfo">+```python+@dataclass+class ExecSessionInfo:+ session_id: str+ sandbox_id: str+ command: str+ args: list[str]+ running: bool+ exit_code: int | None+ started_at: str+ attached_clients: int+```+</Accordion>diff --git a/docs/reference/python-sdk/filesystem.mdx b/docs/reference/python-sdk/filesystem.mdxnew file mode 100644index 00000000..fc9b8f8f--- /dev/null+++ b/docs/reference/python-sdk/filesystem.mdx@@ -0,0 +1,107 @@+---+title: "Filesystem"+description: "Read, write, and manage files"+---++Accessed via `sandbox.files`.++## `await sandbox.files.read(path)`++Read a file as a UTF-8 string. [HTTP API →](/api-reference/files/read)++<ParamField body="path" type="str" required>+ Absolute path to the file+</ParamField>++**Returns:** `str`++---++## `await sandbox.files.read_bytes(path)`++Read a file as raw bytes.++<ParamField body="path" type="str" required>+ Absolute path to the file+</ParamField>++**Returns:** `bytes`++---++## `await sandbox.files.write(path, content)`++Write content to a file. [HTTP API →](/api-reference/files/write)++<ParamField body="path" type="str" required>+ Absolute path for the destination file+</ParamField>++<ParamField body="content" type="str | bytes" required>+ File content+</ParamField>++**Returns:** `None`++---++## `await sandbox.files.list(path="/")`++List directory contents. [HTTP API →](/api-reference/files/list-directory)++<ParamField body="path" type="str" default="/">+ Directory path+</ParamField>++**Returns:** `list[EntryInfo]`++---++## `await sandbox.files.make_dir(path)`++Create a directory. [HTTP API →](/api-reference/files/mkdir)++<ParamField body="path" type="str" required>+ Directory path+</ParamField>++**Returns:** `None`++---++## `await sandbox.files.remove(path)`++Delete a file or directory. [HTTP API →](/api-reference/files/delete)++<ParamField body="path" type="str" required>+ Path to remove+</ParamField>++**Returns:** `None`++---++## `await sandbox.files.exists(path)`++Check if a path exists. Client-side wrapper — attempts a read and returns `False` on error.++<ParamField body="path" type="str" required>+ Path to check+</ParamField>++**Returns:** `bool`++---++## Types++<Accordion title="EntryInfo">+```python+@dataclass+class EntryInfo:+ name: str+ is_dir: bool+ path: str+ size: int = 0+```+</Accordion>diff --git a/docs/reference/python-sdk/image.mdx b/docs/reference/python-sdk/image.mdxnew file mode 100644index 00000000..24748cf7--- /dev/null+++ b/docs/reference/python-sdk/image.mdx@@ -0,0 +1,120 @@+---+title: "Image"+description: "Declarative sandbox image builder"+---++Fluent, immutable builder for declarative sandbox images. Each method returns a new `Image` instance.++## `Image.base()`++Start from the default OpenSandbox environment (Ubuntu 22.04, Python, Node.js, build tools).++```python+from opencomputer import Image++image = (+ Image.base()+ .apt_install(["curl", "jq"])+ .pip_install(["requests", "pandas"])+ .env({"PROJECT_ROOT": "/workspace"})+ .workdir("/workspace")+)+```++**Returns:** `Image`++---++## Builder Methods++### `image.apt_install(packages)`++<ParamField body="packages" type="list[str]" required>+ System packages to install via apt-get+</ParamField>++**Returns:** `Image`++### `image.pip_install(packages)`++<ParamField body="packages" type="list[str]" required>+ Python packages to install via pip+</ParamField>++**Returns:** `Image`++### `image.run_commands(*cmds)`++<ParamField body="cmds" type="str (variadic)" required>+ Shell commands to run during build+</ParamField>++**Returns:** `Image`++### `image.env(vars)`++<ParamField body="vars" type="dict[str, str]" required>+ Environment variables to set+</ParamField>++**Returns:** `Image`++### `image.workdir(path)`++<ParamField body="path" type="str" required>+ Default working directory+</ParamField>++**Returns:** `Image`++### `image.add_file(remote_path, content)`++<ParamField body="remote_path" type="str" required>+ Destination path in the image+</ParamField>++<ParamField body="content" type="str" required>+ File content+</ParamField>++**Returns:** `Image`++### `image.add_local_file(local_path, remote_path)`++<ParamField body="local_path" type="str" required>+ Path to the local file+</ParamField>++<ParamField body="remote_path" type="str" required>+ Destination path in the image+</ParamField>++**Returns:** `Image`++### `image.add_local_dir(local_path, remote_path)`++<ParamField body="local_path" type="str" required>+ Path to the local directory+</ParamField>++<ParamField body="remote_path" type="str" required>+ Destination path in the image+</ParamField>++**Returns:** `Image`++---++## Utility Methods++### `image.to_dict()`++Returns the image manifest as a plain dict.++**Returns:** `dict`++### `image.cache_key()`++Computes a deterministic SHA-256 hash of the manifest for cache lookups.++**Returns:** `str`diff --git a/docs/reference/python-sdk/overview.mdx b/docs/reference/python-sdk/overview.mdxnew file mode 100644index 00000000..0d2d4e69--- /dev/null+++ b/docs/reference/python-sdk/overview.mdx@@ -0,0 +1,43 @@+---+title: "Python SDK"+description: "Complete Python SDK reference"+---++## Installation++```bash+pip install opencomputer-sdk+```++```python+from opencomputer import Sandbox, Image, Snapshots+```++## Modules++<CardGroup cols={2}>+ <Card title="Sandbox" icon="box" href="/reference/python-sdk/sandbox">+ Create, connect, and manage sandbox lifecycle+ </Card>+ <Card title="Exec" icon="terminal" href="/reference/python-sdk/exec">+ Run commands and manage exec sessions+ </Card>+ <Card title="Agent" icon="robot" href="/reference/python-sdk/agent">+ Start and manage Claude agent sessions+ </Card>+ <Card title="Filesystem" icon="folder" href="/reference/python-sdk/filesystem">+ Read, write, and manage files+ </Card>+ <Card title="PTY" icon="rectangle-terminal" href="/reference/python-sdk/pty">+ Interactive terminal sessions+ </Card>+ <Card title="Image" icon="layer-group" href="/reference/python-sdk/image">+ Declarative sandbox image builder+ </Card>+ <Card title="Snapshots" icon="camera" href="/reference/python-sdk/snapshots">+ Pre-built sandbox environments+ </Card>+ <Card title="Secret Stores" icon="key" href="/reference/python-sdk/secrets">+ Manage secrets and egress control+ </Card>+</CardGroup>diff --git a/docs/reference/python-sdk/pty.mdx b/docs/reference/python-sdk/pty.mdxnew file mode 100644index 00000000..17fe0940--- /dev/null+++ b/docs/reference/python-sdk/pty.mdx@@ -0,0 +1,40 @@+---+title: "PTY"+description: "Interactive terminal sessions"+---++Accessed via `sandbox.pty`.++## `await sandbox.pty.create(cols=80, rows=24, on_output=None)`++Create an interactive terminal session. [HTTP API →](/api-reference/pty/create)++<ParamField body="cols" type="int" default="80">+ Terminal columns+</ParamField>++<ParamField body="rows" type="int" default="24">+ Terminal rows+</ParamField>++<ParamField body="on_output" type="Callable[[bytes], None]">+ Output callback+</ParamField>++**Returns:** `PtySession`++---++## PtySession++| Member | Type | Description |+| --- | --- | --- |+| `session_id` | `str` | Session ID |+| `sandbox_id` | `str` | Sandbox ID |+| `send(data)` | method | Send input (str or bytes) |+| `await recv()` | method | Receive output bytes (Python-unique) |+| `await close()` | method | Close the PTY |++<Note>+ `recv()` is Python-unique — a pull-based alternative to the `on_output` callback. Returns raw `bytes`.+</Note>diff --git a/docs/reference/python-sdk/sandbox.mdx b/docs/reference/python-sdk/sandbox.mdxnew file mode 100644index 00000000..5aef5c8a--- /dev/null+++ b/docs/reference/python-sdk/sandbox.mdx@@ -0,0 +1,252 @@+---+title: "Sandbox"+description: "Create, connect, and manage sandbox lifecycle"+---++## Class Methods++### `await Sandbox.create(...)`++Create a new sandbox. [HTTP API →](/api-reference/sandboxes/create)++<ParamField body="template" type="str" default="base">+ Template name+</ParamField>++<ParamField body="timeout" type="int" default="300">+ Idle timeout in seconds+</ParamField>++<ParamField body="api_key" type="str">+ API key (falls back to `OPENCOMPUTER_API_KEY` env var)+</ParamField>++<ParamField body="api_url" type="str">+ API URL (falls back to `OPENCOMPUTER_API_URL` env var)+</ParamField>++<ParamField body="envs" type="dict[str, str]">+ Environment variables+</ParamField>++<ParamField body="metadata" type="dict[str, str]">+ Arbitrary metadata+</ParamField>++<ParamField body="image" type="Image">+ Declarative image definition (see [Image](/reference/python-sdk/image))+</ParamField>++<ParamField body="snapshot" type="str">+ Name of a pre-built snapshot+</ParamField>++<ParamField body="on_build_log" type="Callable[[str], None]">+ Build log callback (when using `image`)+</ParamField>++**Returns:** `Sandbox`++```python+sandbox = await Sandbox.create(template="my-stack", timeout=600)+```++<Note>+ `cpuCount` and `memoryMB` are not available in the Python SDK. Use the [HTTP API](/api-reference/sandboxes/create) for custom resources.+</Note>++---++### `await Sandbox.connect(sandbox_id, ...)`++Connect to an existing sandbox. [HTTP API →](/api-reference/sandboxes/get)++<ParamField body="sandbox_id" type="str" required>+ Sandbox ID+</ParamField>++**Returns:** `Sandbox`++```python+sandbox = await Sandbox.connect("sb-abc123")+```++---++### `await Sandbox.create_from_checkpoint(checkpoint_id, ...)`++Create a new sandbox from a checkpoint. [HTTP API →](/api-reference/checkpoints/fork)++<ParamField body="checkpoint_id" type="str" required>+ Checkpoint ID+</ParamField>++<ParamField body="timeout" type="int" default="300">+ Idle timeout+</ParamField>++**Returns:** `Sandbox`++```python+forked = await Sandbox.create_from_checkpoint("cp-abc123")+```++---++### `await Sandbox.create_checkpoint_patch(checkpoint_id, script, ...)`++[HTTP API →](/api-reference/patches/create)++<ParamField body="checkpoint_id" type="str" required>+ Target checkpoint+</ParamField>++<ParamField body="script" type="str" required>+ Bash script+</ParamField>++<ParamField body="description" type="str">+ Description+</ParamField>++**Returns:** `dict`++---++### `await Sandbox.list_checkpoint_patches(checkpoint_id, ...)`++[HTTP API →](/api-reference/patches/list) — **Returns:** `list[dict]`++### `await Sandbox.delete_checkpoint_patch(checkpoint_id, patch_id, ...)`++[HTTP API →](/api-reference/patches/delete) — **Returns:** `None`++---++## Context Manager++Auto-kills the sandbox on exit:++```python+async with await Sandbox.create() as sandbox:+ result = await sandbox.exec.run("echo hello")+ print(result.stdout)+# sandbox.kill() called automatically+```++---++## Instance Methods++### `await sandbox.kill()`++Terminate the sandbox. [HTTP API →](/api-reference/sandboxes/delete)++**Returns:** `None`++### `await sandbox.is_running()`++Check if the sandbox is running.++**Returns:** `bool`++### `await sandbox.set_timeout(timeout)`++Update idle timeout. [HTTP API →](/api-reference/sandboxes/set-timeout)++<ParamField body="timeout" type="int" required>+ New timeout in seconds+</ParamField>++**Returns:** `None`++### `await sandbox.create_checkpoint(name)`++Create a named checkpoint. [HTTP API →](/api-reference/checkpoints/create)++**Returns:** `dict`++### `await sandbox.list_checkpoints()`++[HTTP API →](/api-reference/checkpoints/list) — **Returns:** `list[dict]`++### `await sandbox.restore_checkpoint(checkpoint_id)`++Revert in-place to a checkpoint. [HTTP API →](/api-reference/checkpoints/restore)++**Returns:** `None`++### `await sandbox.delete_checkpoint(checkpoint_id)`++[HTTP API →](/api-reference/checkpoints/delete) — **Returns:** `None`++### `await sandbox.create_preview_url(port, domain?, auth_config?)`++[HTTP API →](/api-reference/preview/create)++<ParamField body="port" type="int" required>+ Container port (1–65535)+</ParamField>++<ParamField body="domain" type="str">+ Custom domain+</ParamField>++<ParamField body="auth_config" type="dict">+ Auth configuration+</ParamField>++**Returns:** `dict`++### `await sandbox.list_preview_urls()`++[HTTP API →](/api-reference/preview/list) — **Returns:** `list[dict]`++### `await sandbox.delete_preview_url(port)`++[HTTP API →](/api-reference/preview/delete) — **Returns:** `None`++### `await sandbox.close()`++Close HTTP clients. Called automatically by the context manager.++---++## Not Available in Python++These features are TypeScript-only. Use the [HTTP API](/api-reference/overview) directly:++- `hibernate()` / `wake()`+- `cpuCount` / `memoryMB` on create++---++## Properties++<ParamField body="sandbox_id" type="str">+ Sandbox ID+</ParamField>++<ParamField body="status" type="str">+ Current status+</ParamField>++<ParamField body="agent" type="Agent">+ [Agent sessions](/reference/python-sdk/agent)+</ParamField>++<ParamField body="exec" type="Exec">+ [Command execution](/reference/python-sdk/exec)+</ParamField>++<ParamField body="files" type="Filesystem">+ [File operations](/reference/python-sdk/filesystem)+</ParamField>++<ParamField body="pty" type="Pty">+ [Terminal sessions](/reference/python-sdk/pty)+</ParamField>++<ParamField body="commands" type="Exec">+ **Deprecated** — alias for `exec`+</ParamField>diff --git a/docs/reference/python-sdk/secrets.mdx b/docs/reference/python-sdk/secrets.mdxnew file mode 100644index 00000000..2909cfb0--- /dev/null+++ b/docs/reference/python-sdk/secrets.mdx@@ -0,0 +1,143 @@+---+title: "Secret Stores"+description: "Manage secrets and egress control"+---++## `await SecretStore.create(**kwargs)`++Create a new secret store.++```python+from opencomputer import SecretStore++store = await SecretStore.create(+ name='my-agent-secrets',+ egress_allowlist=['api.anthropic.com'],+)+```++<ParamField body="name" type="str" required>+ Store name (unique per organization)+</ParamField>++<ParamField body="egress_allowlist" type="list[str] | None">+ Allowed egress hosts+</ParamField>++**Returns:** `dict`++---++## `await SecretStore.list(**kwargs)`++**Returns:** `list[dict]`++## `await SecretStore.get(store_id, **kwargs)`++<ParamField body="store_id" type="str" required>+ UUID of the secret store+</ParamField>++**Returns:** `dict`++---++## `await SecretStore.update(store_id, **kwargs)`++Partial updates — only the fields you pass are changed.++```python+updated = await SecretStore.update(+ 'store-uuid',+ name='new-name',+ egress_allowlist=['api.anthropic.com', '*.openai.com'],+)+```++<ParamField body="store_id" type="str" required>+ UUID of the store to update+</ParamField>++<ParamField body="name" type="str">+ New store name+</ParamField>++<ParamField body="egress_allowlist" type="list[str] | None">+ New allowed egress hosts+</ParamField>++**Returns:** `dict`++---++## `await SecretStore.delete(store_id, **kwargs)`++Deletes the store and all its secrets. Running sandboxes are not affected.++**Returns:** `None`++---++## `await SecretStore.set_secret(store_id, name, value, **kwargs)`++Set a secret. Encrypted at rest, never returned by API.++```python+await SecretStore.set_secret('store-uuid', 'ANTHROPIC_API_KEY', 'sk-ant-...')++# Optionally restrict to specific hosts:+await SecretStore.set_secret(+ 'store-uuid', 'ANTHROPIC_API_KEY', 'sk-ant-...',+ allowed_hosts=['api.anthropic.com'],+)+```++<ParamField body="store_id" type="str" required>+ UUID of the secret store+</ParamField>++<ParamField body="name" type="str" required>+ Secret name (env var name in sandboxes)+</ParamField>++<ParamField body="value" type="str" required>+ Secret value+</ParamField>++<ParamField body="allowed_hosts" type="list[str] | None">+ Restrict to specific hosts+</ParamField>++**Returns:** `None`++---++## `await SecretStore.list_secrets(store_id, **kwargs)`++Returns metadata only. Values are never exposed.++**Returns:** `list[dict]`++## `await SecretStore.delete_secret(store_id, name, **kwargs)`++**Returns:** `None`++---++## Using Secrets with Sandboxes++```python+sandbox = await Sandbox.create(+ secret_store='my-agent-secrets',+ timeout=600,+)++# Secrets are available as sealed env vars+result = await sandbox.commands.run('echo $ANTHROPIC_API_KEY')+# stdout: "osb_sealed_abc123..." (sealed, not the real key)++# Outbound HTTPS requests get the real value substituted by the proxy+api_result = await sandbox.commands.run(+ 'curl -s https://api.anthropic.com/v1/messages -H "x-api-key: $ANTHROPIC_API_KEY" ...'+)+```diff --git a/docs/reference/python-sdk/snapshots.mdx b/docs/reference/python-sdk/snapshots.mdxnew file mode 100644index 00000000..34400e7d--- /dev/null+++ b/docs/reference/python-sdk/snapshots.mdx@@ -0,0 +1,87 @@+---+title: "Snapshots"+description: "Pre-built sandbox environments"+---++Standalone class — not a property on Sandbox.++## Constructor++```python+from opencomputer import Snapshots++snapshots = Snapshots()+# or with explicit config:+snapshots = Snapshots(api_key="...", api_url="...")+```++<ParamField body="api_key" type="str">+ API key (falls back to `OPENCOMPUTER_API_KEY` env var)+</ParamField>++<ParamField body="api_url" type="str">+ API URL (falls back to `OPENCOMPUTER_API_URL` env var)+</ParamField>++---++## `await snapshots.create(name, image, on_build_logs=None)`++Create a pre-built snapshot. [HTTP API →](/api-reference/snapshots/create)++<ParamField body="name" type="str" required>+ Unique snapshot name+</ParamField>++<ParamField body="image" type="Image" required>+ Declarative image definition+</ParamField>++<ParamField body="on_build_logs" type="Callable[[str], None]">+ Build log streaming callback+</ParamField>++**Returns:** `dict`++---++## `await snapshots.list()`++[HTTP API →](/api-reference/snapshots/list) — **Returns:** `list[dict]`++## `await snapshots.get(name)`++[HTTP API →](/api-reference/snapshots/get)++<ParamField body="name" type="str" required>+ Snapshot name+</ParamField>++**Returns:** `dict`++## `await snapshots.delete(name)`++Delete a snapshot. Existing sandboxes are not affected. [HTTP API →](/api-reference/snapshots/delete)++**Returns:** `None`++---++## SnapshotInfo++Snapshot methods return dicts with these fields:++<Accordion title="SnapshotInfo fields">+```python+{+ "id": str, # Unique snapshot identifier+ "name": str, # Snapshot name+ "status": str, # "building" | "ready" | "failed"+ "contentHash": str, # SHA-256 hash of the image manifest+ "checkpointId": str, # Linked checkpoint ID+ "manifest": dict, # The declarative image manifest+ "createdAt": str, # ISO 8601 creation timestamp+ "lastUsedAt": str, # ISO 8601 last usage timestamp+}+```+</Accordion>diff --git a/docs/reference/typescript-sdk/agent.mdx b/docs/reference/typescript-sdk/agent.mdxnew file mode 100644index 00000000..9d25e958--- /dev/null+++ b/docs/reference/typescript-sdk/agent.mdx@@ -0,0 +1,124 @@+---+title: "Agent"+description: "Start and manage Claude agent sessions"+---++Accessed via `sandbox.agent`.++## `sandbox.agent.start(opts?)`++Start an agent session. [HTTP API →](/api-reference/agent/create)++<ParamField body="prompt" type="string">+ Initial prompt+</ParamField>++<ParamField body="model" type="string">+ Claude model+</ParamField>++<ParamField body="systemPrompt" type="string">+ System prompt+</ParamField>++<ParamField body="allowedTools" type="string[]">+ Restrict tools+</ParamField>++<ParamField body="permissionMode" type="string">+ Permission mode+</ParamField>++<ParamField body="maxTurns" type="number" default="50">+ Max turns+</ParamField>++<ParamField body="cwd" type="string">+ Working directory+</ParamField>++<ParamField body="mcpServers" type="Record<string, McpServerConfig>">+ MCP servers+</ParamField>++<ParamField body="resume" type="string">+ Resume session ID+</ParamField>++<ParamField body="onEvent" type="(event: AgentEvent) => void">+ Event callback+</ParamField>++<ParamField body="onError" type="(data: string) => void">+ Stderr callback+</ParamField>++<ParamField body="onExit" type="(exitCode: number) => void">+ Exit callback+</ParamField>++<ParamField body="onScrollbackEnd" type="() => void">+ Scrollback done callback+</ParamField>++**Returns:** `Promise<AgentSession>`++```typescript+const session = await sandbox.agent.start({+ prompt: "Build a todo app",+ onEvent: (e) => console.log(e.type),+});+```++---++## `sandbox.agent.attach(sessionId, opts?)`++Reconnect to a running agent session. Accepts `onEvent`, `onError`, `onExit`, `onScrollbackEnd`.++**Returns:** `Promise<AgentSession>`++---++## `sandbox.agent.list()`++List all agent sessions. [HTTP API →](/api-reference/agent/list)++**Returns:** `Promise<AgentSessionInfo[]>`++---++## AgentSession++| Member | Type | Description |+| --- | --- | --- |+| `sessionId` | `string` | Session ID |+| `done` | `Promise<number>` | Resolves with exit code |+| `sendPrompt(text)` | method | Send follow-up prompt |+| `interrupt()` | method | Interrupt current turn |+| `configure(config)` | method | Update agent configuration |+| `kill(signal?)` | `Promise<void>` | Kill agent process |+| `close()` | method | Close WebSocket |++---++## Types++<Accordion title="AgentEvent">+```typescript+interface AgentEvent {+ type: string;+ [key: string]: unknown;+}+```+</Accordion>++<Accordion title="McpServerConfig">+```typescript+interface McpServerConfig {+ command: string;+ args?: string[];+ env?: Record<string, string>;+}+```+</Accordion>diff --git a/docs/reference/typescript-sdk/exec.mdx b/docs/reference/typescript-sdk/exec.mdxnew file mode 100644index 00000000..3f42ae54--- /dev/null+++ b/docs/reference/typescript-sdk/exec.mdx@@ -0,0 +1,167 @@+---+title: "Exec"+description: "Run commands and manage exec sessions"+---++Accessed via `sandbox.exec`.++## `sandbox.exec.run(command, opts?)`++Run a command synchronously. [HTTP API →](/api-reference/exec/run)++<ParamField body="command" type="string" required>+ Shell command+</ParamField>++<ParamField body="timeout" type="number" default="60">+ Timeout in seconds+</ParamField>++<ParamField body="env" type="Record<string, string>">+ Environment variables+</ParamField>++<ParamField body="cwd" type="string">+ Working directory+</ParamField>++**Returns:** `Promise<ProcessResult>`++```typescript+const result = await sandbox.exec.run("npm test", { cwd: "/app" });+```++---++## `sandbox.exec.start(command, opts?)`++Start a long-running command with streaming. [HTTP API →](/api-reference/exec/create-session)++<ParamField body="command" type="string" required>+ Command+</ParamField>++<ParamField body="args" type="string[]">+ Arguments+</ParamField>++<ParamField body="env" type="Record<string, string>">+ Environment variables+</ParamField>++<ParamField body="cwd" type="string">+ Working directory+</ParamField>++<ParamField body="timeout" type="number">+ Timeout in seconds+</ParamField>++<ParamField body="maxRunAfterDisconnect" type="number">+ Seconds to keep running after disconnect+</ParamField>++<ParamField body="onStdout" type="(data: Uint8Array) => void">+ Stdout callback+</ParamField>++<ParamField body="onStderr" type="(data: Uint8Array) => void">+ Stderr callback+</ParamField>++<ParamField body="onExit" type="(exitCode: number) => void">+ Exit callback+</ParamField>++**Returns:** `Promise<ExecSession>`++```typescript+const session = await sandbox.exec.start("node server.js", {+ onStdout: (data) => process.stdout.write(data),+});+```++---++## `sandbox.exec.attach(sessionId, opts?)`++Reconnect to a running exec session.++<ParamField body="sessionId" type="string" required>+ Session ID+</ParamField>++<ParamField body="onStdout" type="(data: Uint8Array) => void">+ Stdout callback+</ParamField>++<ParamField body="onStderr" type="(data: Uint8Array) => void">+ Stderr callback+</ParamField>++<ParamField body="onExit" type="(exitCode: number) => void">+ Exit callback+</ParamField>++<ParamField body="onScrollbackEnd" type="() => void">+ Scrollback replay done+</ParamField>++**Returns:** `Promise<ExecSession>`++---++## `sandbox.exec.list()`++List all exec sessions. [HTTP API →](/api-reference/exec/list-sessions)++**Returns:** `Promise<ExecSessionInfo[]>`++---++## `sandbox.exec.kill(sessionId, signal?)`++Kill an exec session. Default signal: `9` (SIGKILL). [HTTP API →](/api-reference/exec/kill-session)++**Returns:** `Promise<void>`++---++## ExecSession++| Member | Type | Description |+| --- | --- | --- |+| `sessionId` | `string` | Session ID |+| `done` | `Promise<number>` | Resolves with exit code |+| `sendStdin(data)` | method | Send input (string or Uint8Array) |+| `kill(signal?)` | `Promise<void>` | Kill process |+| `close()` | method | Close WebSocket |++---++## Types++<Accordion title="ProcessResult">+```typescript+interface ProcessResult {+ exitCode: number;+ stdout: string;+ stderr: string;+}+```+</Accordion>++<Accordion title="ExecSessionInfo">+```typescript+interface ExecSessionInfo {+ sessionID: string;+ sandboxID: string;+ command: string;+ args: string[];+ running: boolean;+ exitCode?: number;+ startedAt: string;+ attachedClients: number;+}+```+</Accordion>diff --git a/docs/reference/typescript-sdk/filesystem.mdx b/docs/reference/typescript-sdk/filesystem.mdxnew file mode 100644index 00000000..f37b85bd--- /dev/null+++ b/docs/reference/typescript-sdk/filesystem.mdx@@ -0,0 +1,107 @@+---+title: "Filesystem"+description: "Read, write, and manage files"+---++Accessed via `sandbox.files`.++## `sandbox.files.read(path)`++Read a file as a UTF-8 string. [HTTP API →](/api-reference/files/read)++<ParamField body="path" type="string" required>+ Absolute path to the file+</ParamField>++**Returns:** `Promise<string>`++---++## `sandbox.files.readBytes(path)`++Read a file as raw bytes.++<ParamField body="path" type="string" required>+ Absolute path to the file+</ParamField>++**Returns:** `Promise<Uint8Array>`++---++## `sandbox.files.write(path, content)`++Write content to a file. [HTTP API →](/api-reference/files/write)++<ParamField body="path" type="string" required>+ Absolute path for the destination file+</ParamField>++<ParamField body="content" type="string | Uint8Array" required>+ File content+</ParamField>++**Returns:** `Promise<void>`++---++## `sandbox.files.list(path?)`++List directory contents. [HTTP API →](/api-reference/files/list-directory)++<ParamField body="path" type="string" default="/">+ Directory path+</ParamField>++**Returns:** `Promise<EntryInfo[]>`++---++## `sandbox.files.makeDir(path)`++Create a directory (recursive). [HTTP API →](/api-reference/files/mkdir)++<ParamField body="path" type="string" required>+ Directory path+</ParamField>++**Returns:** `Promise<void>`++---++## `sandbox.files.remove(path)`++Delete a file or directory. [HTTP API →](/api-reference/files/delete)++<ParamField body="path" type="string" required>+ Path to remove+</ParamField>++**Returns:** `Promise<void>`++---++## `sandbox.files.exists(path)`++Check if a path exists. Client-side wrapper — attempts a read and returns `false` on error.++<ParamField body="path" type="string" required>+ Path to check+</ParamField>++**Returns:** `Promise<boolean>`++---++## Types++<Accordion title="EntryInfo">+```typescript+interface EntryInfo {+ name: string;+ isDir: boolean;+ path: string;+ size: number;+}+```+</Accordion>diff --git a/docs/reference/typescript-sdk/image.mdx b/docs/reference/typescript-sdk/image.mdxnew file mode 100644index 00000000..a062d229--- /dev/null+++ b/docs/reference/typescript-sdk/image.mdx@@ -0,0 +1,132 @@+---+title: "Image"+description: "Declarative sandbox image builder"+---++Fluent, immutable builder for declarative sandbox images. Each method returns a new `Image` instance.++## `Image.base()`++Start from the default OpenSandbox environment (Ubuntu 22.04, Python, Node.js, build tools).++```typescript+import { Image } from "@opencomputer/sdk";++const image = Image.base()+ .aptInstall(['curl', 'jq'])+ .pipInstall(['requests', 'pandas'])+ .env({ PROJECT_ROOT: '/workspace' })+ .workdir('/workspace');+```++**Returns:** `Image`++---++## Builder Methods++### `image.aptInstall(packages)`++<ParamField body="packages" type="string[]" required>+ System packages to install via apt-get+</ParamField>++**Returns:** `Image`++---++### `image.pipInstall(packages)`++<ParamField body="packages" type="string[]" required>+ Python packages to install via pip+</ParamField>++**Returns:** `Image`++---++### `image.runCommands(...cmds)`++<ParamField body="cmds" type="string[]" required>+ Shell commands to run during build+</ParamField>++**Returns:** `Image`++---++### `image.env(vars)`++<ParamField body="vars" type="Record<string, string>" required>+ Environment variables to set+</ParamField>++**Returns:** `Image`++---++### `image.workdir(path)`++<ParamField body="path" type="string" required>+ Default working directory+</ParamField>++**Returns:** `Image`++---++### `image.addFile(remotePath, content)`++<ParamField body="remotePath" type="string" required>+ Destination path in the image+</ParamField>++<ParamField body="content" type="string" required>+ File content+</ParamField>++**Returns:** `Image`++---++### `image.addLocalFile(localPath, remotePath)`++<ParamField body="localPath" type="string" required>+ Path to the local file+</ParamField>++<ParamField body="remotePath" type="string" required>+ Destination path in the image+</ParamField>++**Returns:** `Image`++---++### `image.addLocalDir(localPath, remotePath)`++<ParamField body="localPath" type="string" required>+ Path to the local directory+</ParamField>++<ParamField body="remotePath" type="string" required>+ Destination path in the image+</ParamField>++**Returns:** `Image`++---++## Utility Methods++### `image.toJSON()`++Returns the image manifest as a plain object.++**Returns:** `ImageManifest`++### `image.cacheKey()`++Computes a deterministic SHA-256 hash of the manifest for cache lookups.++**Returns:** `string`diff --git a/docs/reference/typescript-sdk/overview.mdx b/docs/reference/typescript-sdk/overview.mdxnew file mode 100644index 00000000..6d9b4604--- /dev/null+++ b/docs/reference/typescript-sdk/overview.mdx@@ -0,0 +1,53 @@+---+title: "TypeScript SDK"+description: "Complete TypeScript SDK reference"+---++## Installation++<CodeGroup>+```bash npm+npm install @opencomputer/sdk+```+```bash yarn+yarn add @opencomputer/sdk+```+```bash pnpm+pnpm add @opencomputer/sdk+```+</CodeGroup>++```typescript+import { Sandbox } from "@opencomputer/sdk";+import { Image } from "@opencomputer/sdk/dist/image.js";+import { Snapshots } from "@opencomputer/sdk/dist/snapshot.js";+```++## Modules++<CardGroup cols={2}>+ <Card title="Sandbox" icon="box" href="/reference/typescript-sdk/sandbox">+ Create, connect, and manage sandbox lifecycle+ </Card>+ <Card title="Exec" icon="terminal" href="/reference/typescript-sdk/exec">+ Run commands and manage exec sessions+ </Card>+ <Card title="Agent" icon="robot" href="/reference/typescript-sdk/agent">+ Start and manage Claude agent sessions+ </Card>+ <Card title="Filesystem" icon="folder" href="/reference/typescript-sdk/filesystem">+ Read, write, and manage files+ </Card>+ <Card title="PTY" icon="rectangle-terminal" href="/reference/typescript-sdk/pty">+ Interactive terminal sessions+ </Card>+ <Card title="Image" icon="layer-group" href="/reference/typescript-sdk/image">+ Declarative sandbox image builder+ </Card>+ <Card title="Snapshots" icon="camera" href="/reference/typescript-sdk/snapshots">+ Pre-built sandbox environments+ </Card>+ <Card title="Secret Stores" icon="key" href="/reference/typescript-sdk/secrets">+ Manage secrets and egress control+ </Card>+</CardGroup>diff --git a/docs/reference/typescript-sdk/pty.mdx b/docs/reference/typescript-sdk/pty.mdxnew file mode 100644index 00000000..3910e4b6--- /dev/null+++ b/docs/reference/typescript-sdk/pty.mdx@@ -0,0 +1,34 @@+---+title: "PTY"+description: "Interactive terminal sessions"+---++Accessed via `sandbox.pty`.++## `sandbox.pty.create(opts?)`++Create an interactive terminal session. [HTTP API →](/api-reference/pty/create)++<ParamField body="cols" type="number" default="80">+ Terminal columns+</ParamField>++<ParamField body="rows" type="number" default="24">+ Terminal rows+</ParamField>++<ParamField body="onOutput" type="(data: Uint8Array) => void">+ Output callback+</ParamField>++**Returns:** `Promise<PtySession>`++---++## PtySession++| Member | Type | Description |+| --- | --- | --- |+| `sessionId` | `string` | Session ID |+| `send(data)` | method | Send input (string or Uint8Array) |+| `close()` | method | Close the PTY |diff --git a/docs/reference/typescript-sdk/sandbox.mdx b/docs/reference/typescript-sdk/sandbox.mdxnew file mode 100644index 00000000..52166fc7--- /dev/null+++ b/docs/reference/typescript-sdk/sandbox.mdx@@ -0,0 +1,340 @@+---+title: "Sandbox"+description: "Create, connect, and manage sandbox lifecycle"+---++## Static Methods++### `Sandbox.create(opts?)`++Create a new sandbox. [HTTP API →](/api-reference/sandboxes/create)++<ParamField body="template" type="string" default="base">+ Template name+</ParamField>++<ParamField body="timeout" type="number" default="300">+ Idle timeout in seconds+</ParamField>++<ParamField body="apiKey" type="string">+ API key (falls back to `OPENCOMPUTER_API_KEY` env var)+</ParamField>++<ParamField body="apiUrl" type="string">+ API URL (falls back to `OPENCOMPUTER_API_URL` env var)+</ParamField>++<ParamField body="envs" type="Record<string, string>">+ Environment variables+</ParamField>++<ParamField body="metadata" type="Record<string, string>">+ Arbitrary metadata+</ParamField>++<ParamField body="cpuCount" type="number">+ CPU cores (max 4)+</ParamField>++<ParamField body="memoryMB" type="number">+ Memory in MB (max 2048)+</ParamField>++<ParamField body="image" type="Image">+ Declarative image definition (see [Image](/reference/typescript-sdk/image))+</ParamField>++<ParamField body="snapshot" type="string">+ Name of a pre-built snapshot+</ParamField>++<ParamField body="onBuildLog" type="(log: string) => void">+ Build log callback (when using `image`)+</ParamField>++**Returns:** `Promise<Sandbox>`++```typescript+const sandbox = await Sandbox.create({ template: "my-stack", timeout: 600 });+```++---++### `Sandbox.connect(sandboxId, opts?)`++Connect to an existing sandbox. [HTTP API →](/api-reference/sandboxes/get)++<ParamField body="sandboxId" type="string" required>+ Sandbox ID+</ParamField>++<ParamField body="apiKey" type="string">+ API key+</ParamField>++<ParamField body="apiUrl" type="string">+ API URL+</ParamField>++**Returns:** `Promise<Sandbox>`++```typescript+const sandbox = await Sandbox.connect("sb-abc123");+```++---++### `Sandbox.createFromCheckpoint(checkpointId, opts?)`++Create a new sandbox from a checkpoint. [HTTP API →](/api-reference/checkpoints/fork)++<ParamField body="checkpointId" type="string" required>+ Checkpoint ID+</ParamField>++<ParamField body="timeout" type="number" default="300">+ Idle timeout+</ParamField>++**Returns:** `Promise<Sandbox>`++```typescript+const forked = await Sandbox.createFromCheckpoint("cp-abc123");+```++---++### `Sandbox.createCheckpointPatch(checkpointId, opts)`++Create a patch for a checkpoint. [HTTP API →](/api-reference/patches/create)++<ParamField body="checkpointId" type="string" required>+ Target checkpoint+</ParamField>++<ParamField body="script" type="string" required>+ Bash script+</ParamField>++<ParamField body="description" type="string">+ Description+</ParamField>++**Returns:** `Promise<PatchResult>`++```typescript+const result = await Sandbox.createCheckpointPatch("cp-abc", { script: "apt install -y curl" });+```++---++### `Sandbox.listCheckpointPatches(checkpointId, opts?)`++[HTTP API →](/api-reference/patches/list)++**Returns:** `Promise<PatchInfo[]>`++---++### `Sandbox.deleteCheckpointPatch(checkpointId, patchId, opts?)`++[HTTP API →](/api-reference/patches/delete)++**Returns:** `Promise<void>`++---++## Instance Methods++### `sandbox.kill()`++Terminate the sandbox. [HTTP API →](/api-reference/sandboxes/delete)++**Returns:** `Promise<void>`++### `sandbox.isRunning()`++Check if the sandbox is running.++**Returns:** `Promise<boolean>`++### `sandbox.hibernate()`++Snapshot VM state and stop. No compute cost while hibernated. [HTTP API →](/api-reference/sandboxes/hibernate)++**Returns:** `Promise<void>`++### `sandbox.wake(opts?)`++Resume a hibernated sandbox. [HTTP API →](/api-reference/sandboxes/wake)++<ParamField body="timeout" type="number" default="300">+ Idle timeout after wake+</ParamField>++**Returns:** `Promise<void>`++### `sandbox.setTimeout(timeout)`++Update the idle timeout. [HTTP API →](/api-reference/sandboxes/set-timeout)++<ParamField body="timeout" type="number" required>+ New timeout in seconds+</ParamField>++**Returns:** `Promise<void>`++### `sandbox.createCheckpoint(name)`++Create a named checkpoint. [HTTP API →](/api-reference/checkpoints/create)++<ParamField body="name" type="string" required>+ Checkpoint name (unique per sandbox)+</ParamField>++**Returns:** `Promise<CheckpointInfo>`++### `sandbox.listCheckpoints()`++[HTTP API →](/api-reference/checkpoints/list) — **Returns:** `Promise<CheckpointInfo[]>`++### `sandbox.restoreCheckpoint(checkpointId)`++Revert in-place to a checkpoint. [HTTP API →](/api-reference/checkpoints/restore)++**Returns:** `Promise<void>`++### `sandbox.deleteCheckpoint(checkpointId)`++[HTTP API →](/api-reference/checkpoints/delete) — **Returns:** `Promise<void>`++### `sandbox.createPreviewURL(opts)`++[HTTP API →](/api-reference/preview/create)++<ParamField body="port" type="number" required>+ Container port (1–65535)+</ParamField>++<ParamField body="domain" type="string">+ Custom domain+</ParamField>++<ParamField body="authConfig" type="Record<string, unknown>">+ Auth configuration+</ParamField>++**Returns:** `Promise<PreviewURLResult>`++### `sandbox.listPreviewURLs()`++[HTTP API →](/api-reference/preview/list) — **Returns:** `Promise<PreviewURLResult[]>`++### `sandbox.deletePreviewURL(port)`++[HTTP API →](/api-reference/preview/delete) — **Returns:** `Promise<void>`++---++## Properties++<ParamField body="sandboxId" type="string">+ Sandbox ID (readonly)+</ParamField>++<ParamField body="status" type="string">+ Current status (readonly)+</ParamField>++<ParamField body="agent" type="Agent">+ [Agent sessions](/reference/typescript-sdk/agent)+</ParamField>++<ParamField body="exec" type="Exec">+ [Command execution](/reference/typescript-sdk/exec)+</ParamField>++<ParamField body="files" type="Filesystem">+ [File operations](/reference/typescript-sdk/filesystem)+</ParamField>++<ParamField body="pty" type="Pty">+ [Terminal sessions](/reference/typescript-sdk/pty)+</ParamField>++<ParamField body="commands" type="Exec">+ **Deprecated** — alias for `exec`+</ParamField>++---++## Types++<Accordion title="SandboxOpts">+```typescript+interface SandboxOpts {+ template?: string;+ timeout?: number;+ apiKey?: string;+ apiUrl?: string;+ envs?: Record<string, string>;+ metadata?: Record<string, string>;+ cpuCount?: number;+ memoryMB?: number;+ image?: Image;+ snapshot?: string;+ onBuildLog?: (log: string) => void;+}+```+</Accordion>++<Accordion title="CheckpointInfo">+```typescript+interface CheckpointInfo {+ id: string;+ sandboxId: string;+ orgId: string;+ name: string;+ sandboxConfig: object;+ status: string; // "processing" | "ready" | "failed"+ sizeBytes: number;+ createdAt: string;+}+```+</Accordion>++<Accordion title="PatchInfo / PatchResult">+```typescript+interface PatchInfo {+ id: string;+ checkpointId: string;+ sequence: number;+ script: string;+ description: string;+ strategy: string; // "on_wake"+ createdAt: string;+}++interface PatchResult {+ patch: PatchInfo;+}+```+</Accordion>++<Accordion title="PreviewURLResult">+```typescript+interface PreviewURLResult {+ id: string;+ sandboxId: string;+ orgId: string;+ hostname: string;+ customHostname?: string;+ port: number;+ cfHostnameId?: string;+ sslStatus: string;+ authConfig?: object;+ createdAt: string;+}+```+</Accordion>diff --git a/docs/reference/typescript-sdk/secrets.mdx b/docs/reference/typescript-sdk/secrets.mdxnew file mode 100644index 00000000..a86504ca--- /dev/null+++ b/docs/reference/typescript-sdk/secrets.mdx@@ -0,0 +1,180 @@+---+title: "Secret Stores"+description: "Manage secrets and egress control"+---++## `SecretStore.create(opts)`++Create a new secret store.++```typescript+import { SecretStore } from '@opencomputer/sdk';++const store = await SecretStore.create({+ name: 'my-agent-secrets',+ egressAllowlist: ['api.anthropic.com'],+});+```++<ParamField body="name" type="string" required>+ Store name (unique per organization)+</ParamField>++<ParamField body="egressAllowlist" type="string[]">+ Allowed egress hosts (e.g. `["api.anthropic.com"]`)+</ParamField>++**Returns:** `Promise<SecretStoreInfo>`++---++## `SecretStore.list(opts?)`++List all secret stores.++**Returns:** `Promise<SecretStoreInfo[]>`++---++## `SecretStore.get(storeId, opts?)`++Get a secret store by ID.++<ParamField body="storeId" type="string" required>+ UUID of the secret store+</ParamField>++**Returns:** `Promise<SecretStoreInfo>`++---++## `SecretStore.update(storeId, opts)`++Partial updates — only the fields you pass are changed.++```typescript+const updated = await SecretStore.update('store-uuid', {+ name: 'new-name',+ egressAllowlist: ['api.anthropic.com', '*.openai.com'],+});+```++<ParamField body="storeId" type="string" required>+ UUID of the store to update+</ParamField>++<ParamField body="name" type="string">+ New store name+</ParamField>++<ParamField body="egressAllowlist" type="string[]">+ New allowed egress hosts+</ParamField>++**Returns:** `Promise<SecretStoreInfo>`++---++## `SecretStore.delete(storeId, opts?)`++Deletes the store and all its secrets. Running sandboxes are not affected.++**Returns:** `Promise<void>`++---++## `SecretStore.setSecret(storeId, name, value, opts?)`++Set a secret in a store. Secrets are encrypted at rest. The value is never returned by the API.++```typescript+await SecretStore.setSecret('store-uuid', 'ANTHROPIC_API_KEY', 'sk-ant-...');+```++Optionally restrict which hosts can receive this secret:++```typescript+await SecretStore.setSecret('store-uuid', 'ANTHROPIC_API_KEY', 'sk-ant-...', {+ allowedHosts: ['api.anthropic.com'],+});+```++<ParamField body="storeId" type="string" required>+ UUID of the secret store+</ParamField>++<ParamField body="name" type="string" required>+ Secret name (used as the env var name in sandboxes)+</ParamField>++<ParamField body="value" type="string" required>+ Secret value (encrypted at rest, never returned by API)+</ParamField>++<ParamField body="allowedHosts" type="string[]">+ Restrict this secret to specific hosts only+</ParamField>++**Returns:** `Promise<void>`++---++## `SecretStore.listSecrets(storeId, opts?)`++Returns secret metadata only. Values are never exposed.++**Returns:** `Promise<SecretEntryInfo[]>`++---++## `SecretStore.deleteSecret(storeId, name, opts?)`++**Returns:** `Promise<void>`++---++## Using Secrets with Sandboxes++Pass the `secretStore` option to `Sandbox.create()` to inject the store's secrets:++```typescript+const sandbox = await Sandbox.create({+ secretStore: 'my-agent-secrets',+ timeout: 600,+});++// Secrets are available as sealed env vars+const result = await sandbox.commands.run('echo $ANTHROPIC_API_KEY');+// stdout: "osb_sealed_abc123..." (sealed, not the real key)++// But outbound HTTPS requests get the real value substituted by the proxy+const apiResult = await sandbox.commands.run(+ 'curl -s https://api.anthropic.com/v1/messages -H "x-api-key: $ANTHROPIC_API_KEY" ...'+);+```++---++## Types++<Accordion title="SecretStoreInfo">+| Property | Type | Description |+| --- | --- | --- |+| `id` | `string` | Store UUID |+| `orgId` | `string` | Organization UUID |+| `name` | `string` | Store name |+| `egressAllowlist` | `string[]` | Allowed egress hosts |+| `createdAt` | `string` | ISO 8601 timestamp |+| `updatedAt` | `string` | ISO 8601 timestamp |+</Accordion>++<Accordion title="SecretEntryInfo">+| Property | Type | Description |+| --- | --- | --- |+| `id` | `string` | Entry UUID |+| `storeId` | `string` | Parent store UUID |+| `name` | `string` | Secret name (env var name) |+| `allowedHosts` | `string[]` | Host restrictions |+| `createdAt` | `string` | ISO 8601 timestamp |+| `updatedAt` | `string` | ISO 8601 timestamp |+</Accordion>diff --git a/docs/reference/typescript-sdk/snapshots.mdx b/docs/reference/typescript-sdk/snapshots.mdxnew file mode 100644index 00000000..f8e7b59f--- /dev/null+++ b/docs/reference/typescript-sdk/snapshots.mdx@@ -0,0 +1,95 @@+---+title: "Snapshots"+description: "Pre-built sandbox environments"+---++Standalone class — not a property on Sandbox.++## Constructor++```typescript+import { Snapshots } from "@opencomputer/sdk";++const snapshots = new Snapshots();+// or with explicit config:+const snapshots = new Snapshots({ apiKey: "...", apiUrl: "..." });+```++<ParamField body="apiKey" type="string">+ API key (falls back to `OPENCOMPUTER_API_KEY` env var)+</ParamField>++<ParamField body="apiUrl" type="string">+ API URL (falls back to `OPENCOMPUTER_API_URL` env var)+</ParamField>++---++## `snapshots.create(opts)`++Create a pre-built snapshot from a declarative image. [HTTP API →](/api-reference/snapshots/create)++<ParamField body="name" type="string" required>+ Unique snapshot name+</ParamField>++<ParamField body="image" type="Image" required>+ Declarative image definition+</ParamField>++<ParamField body="onBuildLogs" type="(log: string) => void">+ Build log streaming callback+</ParamField>++**Returns:** `Promise<SnapshotInfo>`++---++## `snapshots.list()`++List all snapshots. [HTTP API →](/api-reference/snapshots/list)++**Returns:** `Promise<SnapshotInfo[]>`++---++## `snapshots.get(name)`++Get a snapshot by name. [HTTP API →](/api-reference/snapshots/get)++<ParamField body="name" type="string" required>+ Snapshot name+</ParamField>++**Returns:** `Promise<SnapshotInfo>`++---++## `snapshots.delete(name)`++Delete a snapshot. Existing sandboxes created from it are not affected. [HTTP API →](/api-reference/snapshots/delete)++<ParamField body="name" type="string" required>+ Snapshot name+</ParamField>++**Returns:** `Promise<void>`++---++## Types++<Accordion title="SnapshotInfo">+```typescript+interface SnapshotInfo {+ id: string;+ name: string;+ status: string; // "building" | "ready" | "failed"+ contentHash: string;+ checkpointId: string;+ manifest: object;+ createdAt: string;+ lastUsedAt: string;+}+```+</Accordion>diff --git a/pkg/types/sandbox.go b/pkg/types/sandbox.goindex 8459ec21..74d3ef75 100644--- a/pkg/types/sandbox.go+++ b/pkg/types/sandbox.go@@ -28,8 +28,11 @@ type Sandbox struct {CpuCount int `json:"cpuCount"`MemoryMB int `json:"memoryMB"`MachineID string `json:"machineID,omitempty"`- ConnectURL string `json:"connectURL,omitempty"` // Direct worker URL for SDK access- Token string `json:"token,omitempty"` // Sandbox-scoped JWT for worker auth+ // ConnectURL and Token are currently unused by SDKs. All data-plane traffic+ // flows through the control plane's SandboxAPIProxy, which proxies to workers+ // over the internal VPC network. Direct worker access support coming in a future release.+ ConnectURL string `json:"connectURL,omitempty"`+ Token string `json:"token,omitempty"`HostPort int `json:"hostPort,omitempty"` // Mapped host port for the sandbox's container port}