Skip to content

An open-source, faster Devin alternative

TypeScript

Update docs to use default template, add test scripts and deploy-rootfs

motatoesa711d3eff4e7
diff --git a/deploy/ec2/deploy-rootfs.sh b/deploy/ec2/deploy-rootfs.sh
new file mode 100755
index 00000000..12ff9db3
--- /dev/null
+++ b/deploy/ec2/deploy-rootfs.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Deploy rootfs images to the EC2 worker instance.
+# Run from the repo root: ./deploy/ec2/deploy-rootfs.sh [default|ubuntu|python|node|all]
+#
+# This script:
+# 1. Cross-compiles osb-agent for Linux ARM64
+# 2. Uploads the agent, Dockerfile(s), and build script to the worker
+# 3. Runs build-rootfs.sh remotely to build the ext4 image(s)
+# 4. Cleans up temporary files on the worker
+#
+# Environment variables:
+# WORKER_IP (required) — EC2 instance public IP
+# SSH_KEY (optional) — path to SSH key (default: ~/.ssh/opensandbox-worker.pem)
+# SSH_USER (optional) — SSH user (default: ubuntu)
+# IMAGES_DIR (optional) — remote images dir (default: /data/sandboxes/firecracker/images)
+# GOARCH (optional) — target arch (default: arm64)
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
+
+SSH_KEY="${SSH_KEY:-$HOME/.ssh/opensandbox-worker.pem}"
+WORKER_IP="${WORKER_IP:?Set WORKER_IP to the EC2 instance public IP}"
+SSH_USER="${SSH_USER:-ubuntu}"
+IMAGES_DIR="${IMAGES_DIR:-/data/sandboxes/firecracker/images}"
+GOARCH="${GOARCH:-arm64}"
+
+SSH="ssh -o StrictHostKeyChecking=no -i $SSH_KEY $SSH_USER@$WORKER_IP"
+SCP="scp -o StrictHostKeyChecking=no -i $SSH_KEY"
+
+TARGETS=("${@:-default}")
+
+cd "$REPO_ROOT"
+
+echo "==> Building osb-agent (linux/${GOARCH})..."
+CGO_ENABLED=0 GOOS=linux GOARCH="$GOARCH" go build -o bin/osb-agent-rootfs ./cmd/agent/
+echo " Built: $(du -h bin/osb-agent-rootfs | cut -f1)"
+
+# Determine which Dockerfiles to upload
+DOCKERFILES=()
+for target in "${TARGETS[@]}"; do
+ if [ "$target" = "all" ]; then
+ DOCKERFILES=(deploy/firecracker/rootfs/Dockerfile.*)
+ break
+ else
+ df="deploy/firecracker/rootfs/Dockerfile.${target}"
+ if [ ! -f "$df" ]; then
+ echo "ERROR: Dockerfile not found: $df"
+ exit 1
+ fi
+ DOCKERFILES+=("$df")
+ fi
+done
+
+echo "==> Uploading build files to $WORKER_IP..."
+REMOTE_DIR="/tmp/osb-rootfs-build"
+$SSH "rm -rf $REMOTE_DIR && mkdir -p $REMOTE_DIR/deploy/firecracker/rootfs $REMOTE_DIR/bin $REMOTE_DIR/scripts"
+
+$SCP bin/osb-agent-rootfs "$SSH_USER@$WORKER_IP:$REMOTE_DIR/bin/osb-agent"
+$SSH "chmod +x $REMOTE_DIR/bin/osb-agent"
+
+$SCP scripts/build-rootfs.sh "$SSH_USER@$WORKER_IP:$REMOTE_DIR/scripts/build-rootfs.sh"
+$SSH "chmod +x $REMOTE_DIR/scripts/build-rootfs.sh"
+
+for df in "${DOCKERFILES[@]}"; do
+ $SCP "$df" "$SSH_USER@$WORKER_IP:$REMOTE_DIR/deploy/firecracker/rootfs/$(basename "$df")"
+done
+
+echo "==> Building rootfs image(s) on worker: ${TARGETS[*]}..."
+$SSH "sudo IMAGES_DIR=$IMAGES_DIR AGENT_BIN=$REMOTE_DIR/bin/osb-agent $REMOTE_DIR/scripts/build-rootfs.sh ${TARGETS[*]}"
+
+echo "==> Verifying images..."
+$SSH "ls -lh $IMAGES_DIR/*.ext4"
+
+echo "==> Cleaning up..."
+$SSH "rm -rf $REMOTE_DIR"
+rm -f bin/osb-agent-rootfs
+
+echo "==> Done! Deployed rootfs for: ${TARGETS[*]}"
diff --git a/docs/guides/build-a-lovable-clone.mdx b/docs/guides/build-a-lovable-clone.mdx
new file mode 100644
index 00000000..f7fa3208
--- /dev/null
+++ b/docs/guides/build-a-lovable-clone.mdx
@@ -0,0 +1,177 @@
+---
+title: "Build a Lovable Clone"
+description: "Build an open-source AI app builder using OpenComputer sandboxes"
+---
+
+In this guide you'll build a fully functional **Lovable clone** — an AI-powered web app builder where users describe an app in plain English and get a live, running React application in seconds. The entire project is open-source and uses OpenComputer sandboxes as the execution engine.
+
+<CardGroup cols={2}>
+ <Card title="GitHub Repository" icon="github" href="https://github.com/diggerhq/osslovable">
+ Source code for the complete project.
+ </Card>
+ <Card title="Live Demo" icon="globe" href="https://openlovable.cc">
+ Try the running app at openlovable.cc.
+ </Card>
+</CardGroup>
+
+---
+
+## Prerequisites
+
+- **Node.js 20+** installed locally
+- An **Anthropic API key** (for Claude)
+- An **OpenComputer API key**
+
+---
+
+## Step 1: Sign Up for OpenComputer
+
+Go to [app.opencomputer.dev](https://app.opencomputer.dev) and create an account.
+
+## Step 2: Generate an API Token
+
+From the OpenComputer dashboard, generate an API token. You'll use this to authenticate SDK calls that create and manage sandboxes.
+
+## Step 3: (Optional) Add a Custom Domain
+
+If you want deployed apps to be accessible on your own domain (e.g. `*.mycompany.com`) instead of the default OpenComputer hostnames:
+
+1. In the OpenComputer dashboard, add your domain (e.g. `mycompany.com`).
+2. Create a **TXT** record on your domain to verify ownership — the dashboard will show you the exact record to add.
+3. Create a **CNAME** record for `*.mycompany.com` pointing to the value provided by OpenComputer. This routes all subdomain traffic to your sandboxes.
+
+Once verified, preview URLs for your sandboxes will be served under your custom domain.
+
+## Step 4: Set Up the Project
+
+Clone the repository and install dependencies:
+
+```bash
+git clone https://github.com/diggerhq/osslovable.git
+cd osslovable
+npm run install:all
+```
+
+Create a `.env` file at the project root with your API keys:
+
+```bash
+ANTHROPIC_API_KEY=sk-ant-...
+OPENCOMPUTER_API_KEY=your-opencomputer-token
+DEPLOY_DOMAIN=mycompany.com # optional — defaults to openlovable.cc
+```
+
+If you configured a custom domain in Step 3, set `DEPLOY_DOMAIN` to that domain so that deployed apps are served under it (e.g. `https://<id>.mycompany.com`). If you skip this, deploy URLs will use the default `openlovable.cc` domain.
+
+Start the development server:
+
+```bash
+npm run dev
+```
+
+This starts both the Express backend (port 3001) and the Vite frontend (port 5173). Open `http://localhost:5173` in your browser, type a prompt, and watch your app get built.
+
+---
+
+## How It Works
+
+The architecture is straightforward: a React frontend sends a user prompt to an Express backend, which orchestrates Claude and an OpenComputer sandbox to generate, write, and run the code.
+
+### Generation Flow
+
+1. **User submits a prompt** — The frontend sends the prompt to `POST /api/generate`.
+2. **Sandbox is created** — The server calls `Sandbox.create()` from the OpenComputer SDK to spin up an isolated Node.js environment.
+3. **Claude generates code** — The prompt is sent to Claude with a system prompt that instructs it to output complete file contents in a structured XML format (`<file path="...">...</file>`).
+4. **Files are streamed and written** — As Claude streams its response, the server parses file blocks in real-time. Each file is written into the sandbox's filesystem using `sandbox.files.write()`.
+5. **Dev server starts** — Once all files are written, the server runs `npm install` and starts a Vite dev server inside the sandbox.
+6. **Preview URL is returned** — The server calls `sandbox.createPreviewURL({ port: 80 })` to get a public URL, which is sent to the frontend and displayed in an iframe.
+
+### Sandbox as Tool Calls
+
+The key idea is that **every interaction with the sandbox is a tool call** from the server to the OpenComputer SDK. The server uses these SDK methods as its "tools":
+
+```typescript
+import { Sandbox } from "@opencomputer/sdk";
+
+// Create an isolated environment
+const sandbox = await Sandbox.create({ template: "node", timeout: 600 });
+
+// Write files
+await sandbox.files.write("/workspace/src/App.tsx", code);
+
+// Run commands
+await sandbox.commands.run("cd /workspace && npm install");
+
+// Get a public URL
+const preview = await sandbox.createPreviewURL({ port: 80 });
+```
+
+This is a simple but effective pattern: Claude generates the code as text, and the server uses the sandbox SDK to make it real. There are no actual LLM tool-use calls involved — the server orchestrates everything itself.
+
+### Limitations of This Approach
+
+- **No iterative editing** — Claude generates the entire project in one shot. There's no back-and-forth where the LLM can see errors, fix them, and retry. A more robust version would use Claude's tool-use capability to let it write files, run commands, see output, and iterate.
+- **No persistent state** — The development sandbox is ephemeral. If the server restarts, in-memory sandbox references are lost. There's no git history or checkpoint system to restore previous states.
+- **Single-turn only** — Each prompt creates a fresh generation. Follow-up prompts create a new sandbox rather than iterating on the existing code.
+
+---
+
+## Deployment Model
+
+The app includes a **Deploy** button that creates a shareable, publicly accessible URL for the generated app.
+
+### How Deployment Works
+
+1. **A new sandbox is created** — Deployment does _not_ reuse the development sandbox. A fresh sandbox is spun up specifically for the deployed version.
+2. **Files are copied over** — All source files (excluding `node_modules`) are copied from the dev sandbox to the deploy sandbox using the SDK's file APIs.
+3. **Dependencies are installed and the server starts** — The deploy sandbox runs `npm install` and starts the Vite dev server, just like the dev sandbox.
+4. **A fixed deploy URL is created** — The server calls `sandbox.createPreviewURL()` with a custom domain configuration, producing a stable URL (e.g. `https://<id>.openlovable.cc`) that can be shared with others.
+
+```typescript
+const domain = process.env.DEPLOY_DOMAIN || "openlovable.cc";
+const url = await sandbox.createPreviewURL({
+ port: 80,
+ domain,
+ authConfig: {},
+});
+```
+
+### Why a Separate Sandbox?
+
+The deploy sandbox is intentionally separate from the dev sandbox so that:
+
+- The developer can keep iterating in the dev sandbox without affecting the deployed version.
+- The deployed version has a fixed, shareable URL that doesn't change.
+- Each deployment is a clean, reproducible build.
+
+### Hibernation and Wake-Up
+
+OpenComputer sandboxes have a built-in **hibernation model**. When a deployed sandbox receives no traffic, it is automatically hibernated to save resources. When someone visits the deploy URL, the sandbox is woken up on demand. This means:
+
+- **Deploy URLs are persistent** — they continue to work even after the sandbox hibernates.
+- **Cold starts are fast** — sandboxes resume from hibernation in seconds.
+- **No always-on cost** — you're not paying for idle compute.
+
+This makes the deployment model practical for sharing prototypes and demos without running up a large bill.
+
+---
+
+## Limitations and What's Coming
+
+### Current Limitations
+
+- **No version control** — There is no git server backing the sandbox, so there's no way to checkpoint, diff, or roll back changes. If you want to restore a previous version, you'd need to regenerate it.
+- **No secret management** — API keys and environment variables are passed in plain text. There's no built-in mechanism for securely sealing secrets that the sandbox needs at runtime.
+- **Ephemeral dev state** — The development sandbox lives only as long as the server process. A server restart or crash loses all active sandbox references.
+- **Single-turn generation** — The current architecture doesn't support multi-turn conversations where Claude can iterate on its output based on build errors or user feedback.
+- **No private link sharing** — Deploy URLs are either fully public or not accessible at all. There's no way to share a preview link with specific team members or collaborators behind authentication.
+
+### Coming Soon to OpenComputer
+
+OpenComputer is building features that directly address these limitations:
+
+- **Built-in git server** — Each sandbox will have a native git server, enabling checkpoint/restore workflows and git-based deployments. You'll be able to commit the sandbox state at any point, roll back to a previous commit, and deploy from a specific git ref.
+- **Secret sealing** — A secure mechanism for injecting secrets into sandboxes without exposing them in plain text. Sealed secrets will be encrypted at rest and only decrypted inside the sandbox at runtime, making it safe to pass API keys, database credentials, and other sensitive configuration.
+- **In-sandbox agent loop** — Instead of orchestrating the LLM from an external server (where every file write and command execution is a round-trip over the network), the agent loop will run _inside_ the sandbox itself. This dramatically reduces latency — the agent can read files, run commands, and iterate on errors locally without leaving the sandbox. It's also a simpler deployment model: you ship a single sandbox image with the agent baked in, rather than coordinating between an external server and a remote sandbox.
+- **Private link sharing** — The ability to share deploy preview URLs with specific people. You'll be able to grant access to individual team members or collaborators, so preview links aren't fully public but still don't require the recipient to have an OpenComputer account.
+
+These additions will make it possible to build a production-grade app builder with full version history, secure secret handling, and robust deployment pipelines — all on top of OpenComputer sandboxes.
diff --git a/docs/introduction.mdx b/docs/introduction.mdx
index 52647ee5..f34d0556 100644
--- a/docs/introduction.mdx
+++ b/docs/introduction.mdx
@@ -47,7 +47,7 @@ pip install opencomputer
```typescript TypeScript
import { Sandbox } from '@opencomputer/sdk';
-const sandbox = await Sandbox.create({ template: 'base' });
+const sandbox = await Sandbox.create({ template: 'default' });
const result = await sandbox.commands.run('echo "Hello from OpenSandbox!"');
console.log(result.stdout); // Hello from OpenSandbox!
@@ -60,7 +60,7 @@ import asyncio
from opencomputer import Sandbox
async def main():
- sandbox = await Sandbox.create(template='base')
+ sandbox = await Sandbox.create(template='default')
result = await sandbox.commands.run('echo "Hello from OpenSandbox!"')
print(result.stdout) # Hello from OpenSandbox!
await sandbox.kill()
diff --git a/docs/mint.json b/docs/mint.json
index 0757a984..f47fde88 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -43,6 +43,12 @@
"quickstart"
]
},
+ {
+ "group": "Guides",
+ "pages": [
+ "guides/build-a-lovable-clone"
+ ]
+ },
{
"group": "TypeScript SDK",
"pages": [
diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx
index 4a2a4dc4..fb14eff2 100644
--- a/docs/quickstart.mdx
+++ b/docs/quickstart.mdx
@@ -35,7 +35,7 @@ export OPENCOMPUTER_API_KEY="your-api-key"
import { Sandbox } from '@opencomputer/sdk';
const sandbox = await Sandbox.create({
- template: 'base',
+ template: 'default',
timeout: 300,
});
@@ -45,7 +45,7 @@ console.log(`Sandbox created: ${sandbox.sandboxId}`);
```python Python
from opencomputer import Sandbox
-sandbox = await Sandbox.create(template='base', timeout=300)
+sandbox = await Sandbox.create(template='default', timeout=300)
print(f"Sandbox created: {sandbox.sandbox_id}")
```
diff --git a/docs/sdks/python/overview.mdx b/docs/sdks/python/overview.mdx
index 7ea03b5c..699797bf 100644
--- a/docs/sdks/python/overview.mdx
+++ b/docs/sdks/python/overview.mdx
@@ -32,7 +32,7 @@ import asyncio
from opencomputer import Sandbox
async def main():
- sandbox = await Sandbox.create(template='base')
+ sandbox = await Sandbox.create(template='default')
# Run a command
result = await sandbox.commands.run('python3 --version')
diff --git a/docs/sdks/python/sandbox.mdx b/docs/sdks/python/sandbox.mdx
index cd92fe93..fe30fc7b 100644
--- a/docs/sdks/python/sandbox.mdx
+++ b/docs/sdks/python/sandbox.mdx
@@ -11,7 +11,7 @@ The `Sandbox` class is the main entry point to OpenSandbox. It supports both man
from opencomputer import Sandbox
sandbox = await Sandbox.create(
- template='base',
+ template='default',
timeout=300,
envs={'NODE_ENV': 'production'},
metadata={'owner': 'my-agent'},
@@ -22,7 +22,7 @@ sandbox = await Sandbox.create(
Creates a new sandbox and returns a connected `Sandbox` instance.
-<ParamField body="template" type="str" default="base">
+<ParamField body="template" type="str" default="default">
Container template to use.
</ParamField>
<ParamField body="timeout" type="int" default="300">
@@ -46,7 +46,7 @@ Creates a new sandbox and returns a connected `Sandbox` instance.
## Usage
```python
-sandbox = await Sandbox.create(template='base')
+sandbox = await Sandbox.create(template='default')
result = await sandbox.commands.run('echo "hello"')
print(result.stdout)
await sandbox.kill()
diff --git a/docs/sdks/typescript/overview.mdx b/docs/sdks/typescript/overview.mdx
index 72962f79..3cbf5ff3 100644
--- a/docs/sdks/typescript/overview.mdx
+++ b/docs/sdks/typescript/overview.mdx
@@ -27,7 +27,7 @@ The TypeScript SDK provides five main modules:
import { Sandbox } from '@opencomputer/sdk';
// Create a sandbox
-const sandbox = await Sandbox.create({ template: 'base' });
+const sandbox = await Sandbox.create({ template: 'default' });
// Run a command
const result = await sandbox.commands.run('node --version');
diff --git a/docs/sdks/typescript/sandbox.mdx b/docs/sdks/typescript/sandbox.mdx
index f37d99f9..7dda023d 100644
--- a/docs/sdks/typescript/sandbox.mdx
+++ b/docs/sdks/typescript/sandbox.mdx
@@ -11,7 +11,7 @@ The `Sandbox` class is the main entry point to OpenSandbox. Use it to create new
import { Sandbox } from '@opencomputer/sdk';
const sandbox = await Sandbox.create({
- template: 'base',
+ template: 'default',
timeout: 300,
envs: { NODE_ENV: 'production' },
metadata: { owner: 'my-agent' },
@@ -24,7 +24,7 @@ Creates a new sandbox and returns a connected `Sandbox` instance.
<ParamField body="opts" type="SandboxOpts" optional>
<Expandable title="properties">
- <ParamField body="template" type="string" default="base">
+ <ParamField body="template" type="string" default="default">
Container template to use.
</ParamField>
<ParamField body="timeout" type="number" default="300">
diff --git a/sdks/python/examples/test_default_template.py b/sdks/python/examples/test_default_template.py
new file mode 100644
index 00000000..ddf43bed
--- /dev/null
+++ b/sdks/python/examples/test_default_template.py
@@ -0,0 +1,253 @@
+#!/usr/bin/env python3
+"""
+Default Template Verification Test
+
+Verifies that the "default" template image contains all expected packages:
+ 1. Python 3 + pip + venv
+ 2. Node.js 20 + npm
+ 3. Build tools (gcc, g++, make, cmake)
+ 4. Git + git-lfs
+ 5. Common utilities (curl, wget, jq, tar, zip, unzip, etc.)
+ 6. System libraries (libssl, libffi, zlib, sqlite3)
+ 7. Locale (en_US.UTF-8 available)
+ 8. Workspace directory
+
+Usage:
+ python examples/test_default_template.py
+"""
+
+import asyncio
+import os
+import sys
+
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
+from opencomputer import Sandbox
+
+GREEN = "\033[32m"
+RED = "\033[31m"
+BOLD = "\033[1m"
+DIM = "\033[2m"
+RESET = "\033[0m"
+
+passed = 0
+failed = 0
+
+
+def green(msg: str) -> None:
+ print(f"{GREEN}✓ {msg}{RESET}")
+
+
+def red(msg: str) -> None:
+ print(f"{RED}✗ {msg}{RESET}")
+
+
+def bold(msg: str) -> None:
+ print(f"{BOLD}{msg}{RESET}")
+
+
+def dim(msg: str) -> None:
+ print(f"{DIM} {msg}{RESET}")
+
+
+def check(desc: str, condition: bool, detail: str = "") -> None:
+ global passed, failed
+ if condition:
+ green(desc)
+ passed += 1
+ else:
+ red(f"{desc} ({detail})" if detail else desc)
+ failed += 1
+
+
+async def expect_command(
+ sandbox: Sandbox,
+ desc: str,
+ cmd: str,
+ contains: str | None = None,
+) -> str:
+ """Run a command and check it exits 0 and stdout contains expected substring."""
+ result = await sandbox.commands.run(cmd)
+ out = (result.stdout.strip() or result.stderr.strip())
+ dim(f"$ {cmd}")
+ dim(f" → {out}")
+
+ if result.exit_code != 0:
+ check(desc, False, f"exit code {result.exit_code}")
+ return out
+
+ if contains is not None:
+ check(desc, contains.lower() in out.lower(),
+ f'expected "{contains}" in output')
+ else:
+ check(desc, True)
+ return out
+
+
+async def main() -> None:
+ global passed, failed
+
+ bold("\n╔══════════════════════════════════════════════════╗")
+ bold("║ Default Template Verification Test ║")
+ bold("╚══════════════════════════════════════════════════╝\n")
+
+ sandbox = None
+
+ try:
+ sandbox = await Sandbox.create(template="default", timeout=120)
+ green(f"Created sandbox: {sandbox.sandbox_id}")
+ print()
+
+ # ── 1. Python ──
+ bold("━━━ 1. Python 3 ━━━\n")
+
+ await expect_command(sandbox, "python3 is installed",
+ "python3 --version", contains="Python 3")
+ await expect_command(sandbox, "python symlink works",
+ "python --version", contains="Python 3")
+ await expect_command(sandbox, "pip3 is installed",
+ "pip3 --version", contains="pip")
+ await expect_command(sandbox, "python3-venv is available",
+ "python3 -m venv --help 2>&1 | head -1", contains="usage")
+
+ pip_install = await sandbox.commands.run(
+ "pip3 install --no-cache-dir cowsay 2>&1", timeout=30)
+ check("pip install works", pip_install.exit_code == 0,
+ f"exit {pip_install.exit_code}")
+ cowsay = await sandbox.commands.run(
+ "python3 -c 'import cowsay; print(\"pip-ok\")'")
+ check("installed Python package importable",
+ "pip-ok" in cowsay.stdout.strip())
+ print()
+
+ # ── 2. Node.js ──
+ bold("━━━ 2. Node.js 20 + npm ━━━\n")
+
+ node_version = await expect_command(sandbox, "node is installed",
+ "node --version")
+ check("Node.js is v20.x", node_version.startswith("v20"),
+ f"got {node_version}")
+ await expect_command(sandbox, "npm is installed", "npm --version")
+
+ await sandbox.commands.run(
+ "mkdir -p /tmp/npm-test && cd /tmp/npm-test && npm init -y 2>&1",
+ timeout=10)
+ npm_install = await sandbox.commands.run(
+ "cd /tmp/npm-test && npm install is-odd 2>&1", timeout=30)
+ check("npm install works", npm_install.exit_code == 0,
+ f"exit {npm_install.exit_code}")
+ node_run = await sandbox.commands.run(
+ """node -e "console.log(require('is-odd')(3))" """,
+ cwd="/tmp/npm-test")
+ check("installed npm package works",
+ node_run.stdout.strip() == "true",
+ f'got "{node_run.stdout.strip()}"')
+ print()
+
+ # ── 3. Build tools ──
+ bold("━━━ 3. Build tools ━━━\n")
+
+ await expect_command(sandbox, "gcc is installed",
+ "gcc --version 2>&1 | head -1", contains="gcc")
+ await expect_command(sandbox, "g++ is installed",
+ "g++ --version 2>&1 | head -1", contains="g++")
+ await expect_command(sandbox, "make is installed",
+ "make --version 2>&1 | head -1", contains="make")
+ await expect_command(sandbox, "cmake is installed",
+ "cmake --version 2>&1 | head -1", contains="cmake")
+ await expect_command(sandbox, "pkg-config is installed",
+ "pkg-config --version")
+
+ await sandbox.files.write("/tmp/hello.c",
+ '#include <stdio.h>\nint main() { printf("compiled-ok\\n"); return 0; }')
+ compile_result = await sandbox.commands.run(
+ "gcc -o /tmp/hello /tmp/hello.c && /tmp/hello")
+ check("C compilation + execution works",
+ compile_result.stdout.strip() == "compiled-ok",
+ f'got "{compile_result.stdout.strip()}"')
+ print()
+
+ # ── 4. Git ──
+ bold("━━━ 4. Git ━━━\n")
+
+ await expect_command(sandbox, "git is installed",
+ "git --version", contains="git version")
+ await expect_command(sandbox, "git-lfs is installed",
+ "git lfs version 2>&1 | head -1", contains="git-lfs")
+ print()
+
+ # ── 5. Networking & utilities ──
+ bold("━━━ 5. Networking & common utilities ━━━\n")
+
+ await expect_command(sandbox, "curl is installed",
+ "curl --version 2>&1 | head -1", contains="curl")
+ await expect_command(sandbox, "wget is installed",
+ "wget --version 2>&1 | head -1", contains="wget")
+ await expect_command(sandbox, "ssh client is installed",
+ "ssh -V 2>&1", contains="OpenSSH")
+ await expect_command(sandbox, "jq is installed",
+ "jq --version", contains="jq")
+ await expect_command(sandbox, "tar is installed",
+ "tar --version 2>&1 | head -1", contains="tar")
+ await expect_command(sandbox, "zip is installed",
+ "zip --version 2>&1 | head -2 | tail -1", contains="zip")
+ await expect_command(sandbox, "unzip is installed",
+ "unzip -v 2>&1 | head -1", contains="unzip")
+ await expect_command(sandbox, "rsync is installed",
+ "rsync --version 2>&1 | head -1", contains="rsync")
+ await expect_command(sandbox, "htop is installed",
+ "htop --version 2>&1 | head -1", contains="htop")
+ await expect_command(sandbox, "tree is installed",
+ "tree --version 2>&1", contains="tree")
+ print()
+
+ # ── 6. System libraries ──
+ bold("━━━ 6. System libraries ━━━\n")
+
+ await expect_command(sandbox, "sqlite3 is installed",
+ "sqlite3 --version 2>&1 | head -1")
+ await expect_command(sandbox, "libssl headers present",
+ "test -f /usr/include/openssl/ssl.h && echo ok",
+ contains="ok")
+ await expect_command(
+ sandbox, "libffi headers present",
+ "test -f /usr/include/ffi.h && echo ok "
+ "|| (dpkg -L libffi-dev 2>/dev/null | grep ffi.h | head -1)",
+ contains="ffi")
+ await expect_command(sandbox, "zlib headers present",
+ "test -f /usr/include/zlib.h && echo ok",
+ contains="ok")
+ print()
+
+ # ── 7. Locale ──
+ bold("━━━ 7. Locale ━━━\n")
+
+ await expect_command(sandbox, "en_US.UTF-8 locale is available",
+ "locale -a 2>&1 | grep -i en_US.utf8",
+ contains="en_US")
+ print()
+
+ # ── 8. Workspace ──
+ bold("━━━ 8. Workspace directory ━━━\n")
+
+ await expect_command(sandbox, "/workspace exists",
+ "test -d /workspace && echo ok", contains="ok")
+ print()
+
+ except Exception as e:
+ red(f"Fatal error: {e}")
+ failed += 1
+ finally:
+ if sandbox:
+ await sandbox.kill()
+ green("Sandbox killed")
+
+ # --- Summary ---
+ bold("========================================")
+ bold(f" Results: {passed} passed, {failed} failed")
+ bold("========================================\n")
+ if failed > 0:
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ asyncio.run(main())
diff --git a/sdks/typescript/examples/test-default-template.ts b/sdks/typescript/examples/test-default-template.ts
new file mode 100644
index 00000000..181fbcfd
--- /dev/null
+++ b/sdks/typescript/examples/test-default-template.ts
@@ -0,0 +1,184 @@
+/**
+ * Default Template Verification Test
+ *
+ * Verifies that the "default" template image contains all expected packages:
+ * 1. Python 3 + pip + venv
+ * 2. Node.js 20 + npm
+ * 3. Build tools (gcc, g++, make, cmake)
+ * 4. Git + git-lfs
+ * 5. Common utilities (curl, wget, jq, tar, zip, unzip, etc.)
+ * 6. System libraries (libssl, libffi, zlib, sqlite3)
+ * 7. Locale is set to en_US.UTF-8
+ *
+ * Usage:
+ * npx tsx examples/test-default-template.ts
+ */
+
+import { Sandbox } from "../src/index";
+
+function green(msg: string) { console.log(`\x1b[32m✓ ${msg}\x1b[0m`); }
+function red(msg: string) { console.log(`\x1b[31m✗ ${msg}\x1b[0m`); }
+function bold(msg: string) { console.log(`\x1b[1m${msg}\x1b[0m`); }
+function dim(msg: string) { console.log(`\x1b[2m ${msg}\x1b[0m`); }
+
+let passed = 0;
+let failed = 0;
+
+function check(desc: string, condition: boolean, detail?: string) {
+ if (condition) {
+ green(desc);
+ passed++;
+ } else {
+ red(`${desc}${detail ? ` (${detail})` : ""}`);
+ failed++;
+ }
+}
+
+/** Run a command and check it exits 0 and stdout contains expected substring */
+async function expectCommand(
+ sandbox: Sandbox,
+ desc: string,
+ cmd: string,
+ opts?: { contains?: string; versionMin?: string },
+) {
+ const result = await sandbox.commands.run(cmd);
+ const out = result.stdout.trim() || result.stderr.trim();
+ dim(`$ ${cmd}`);
+ dim(` → ${out}`);
+
+ if (result.exitCode !== 0) {
+ check(desc, false, `exit code ${result.exitCode}`);
+ return out;
+ }
+
+ if (opts?.contains) {
+ check(desc, out.toLowerCase().includes(opts.contains.toLowerCase()),
+ `expected "${opts.contains}" in output`);
+ } else {
+ check(desc, true);
+ }
+ return out;
+}
+
+async function main() {
+ bold("\n╔══════════════════════════════════════════════════╗");
+ bold("║ Default Template Verification Test ║");
+ bold("╚══════════════════════════════════════════════════╝\n");
+
+ let sandbox: Sandbox | null = null;
+
+ try {
+ sandbox = await Sandbox.create({ template: "default", timeout: 120 });
+ green(`Created sandbox: ${sandbox.sandboxId}`);
+ console.log();
+
+ // ── 1. Python ───────────────────────────────────────────────────
+ bold("━━━ 1. Python 3 ━━━\n");
+
+ await expectCommand(sandbox, "python3 is installed", "python3 --version", { contains: "Python 3" });
+ await expectCommand(sandbox, "python symlink works", "python --version", { contains: "Python 3" });
+ await expectCommand(sandbox, "pip3 is installed", "pip3 --version", { contains: "pip" });
+ await expectCommand(sandbox, "python3-venv is available", "python3 -m venv --help 2>&1 | head -1", { contains: "usage" });
+
+ // Verify pip can install a package
+ const pipInstall = await sandbox.commands.run("pip3 install --no-cache-dir cowsay 2>&1", { timeout: 30 });
+ check("pip install works", pipInstall.exitCode === 0, `exit ${pipInstall.exitCode}`);
+ const cowsay = await sandbox.commands.run("python3 -c 'import cowsay; print(\"pip-ok\")'");
+ check("installed Python package importable", cowsay.stdout.trim().includes("pip-ok"));
+ console.log();
+
+ // ── 2. Node.js ──────────────────────────────────────────────────
+ bold("━━━ 2. Node.js 20 + npm ━━━\n");
+
+ const nodeVersion = await expectCommand(sandbox, "node is installed", "node --version");
+ check("Node.js is v20.x", nodeVersion.startsWith("v20"), `got ${nodeVersion}`);
+ await expectCommand(sandbox, "npm is installed", "npm --version");
+
+ // Verify npm can install a package
+ await sandbox.commands.run("mkdir -p /tmp/npm-test && cd /tmp/npm-test && npm init -y 2>&1", { timeout: 10 });
+ const npmInstall = await sandbox.commands.run("cd /tmp/npm-test && npm install is-odd 2>&1", { timeout: 30 });
+ check("npm install works", npmInstall.exitCode === 0, `exit ${npmInstall.exitCode}`);
+ const nodeRun = await sandbox.commands.run('node -e "console.log(require(\'is-odd\')(3))"', { cwd: "/tmp/npm-test" });
+ check("installed npm package works", nodeRun.stdout.trim() === "true", `got "${nodeRun.stdout.trim()}"`);
+ console.log();
+
+ // ── 3. Build tools ──────────────────────────────────────────────
+ bold("━━━ 3. Build tools ━━━\n");
+
+ await expectCommand(sandbox, "gcc is installed", "gcc --version 2>&1 | head -1", { contains: "gcc" });
+ await expectCommand(sandbox, "g++ is installed", "g++ --version 2>&1 | head -1", { contains: "g++" });
+ await expectCommand(sandbox, "make is installed", "make --version 2>&1 | head -1", { contains: "make" });
+ await expectCommand(sandbox, "cmake is installed", "cmake --version 2>&1 | head -1", { contains: "cmake" });
+ await expectCommand(sandbox, "pkg-config is installed", "pkg-config --version");
+
+ // Verify compilation works end-to-end
+ await sandbox.files.write("/tmp/hello.c", '#include <stdio.h>\nint main() { printf("compiled-ok\\n"); return 0; }');
+ const compile = await sandbox.commands.run("gcc -o /tmp/hello /tmp/hello.c && /tmp/hello");
+ check("C compilation + execution works", compile.stdout.trim() === "compiled-ok", `got "${compile.stdout.trim()}"`);
+ console.log();
+
+ // ── 4. Git ──────────────────────────────────────────────────────
+ bold("━━━ 4. Git ━━━\n");
+
+ await expectCommand(sandbox, "git is installed", "git --version", { contains: "git version" });
+ await expectCommand(sandbox, "git-lfs is installed", "git lfs version 2>&1 | head -1", { contains: "git-lfs" });
+ console.log();
+
+ // ── 5. Networking & utilities ────────────────────────────────────
+ bold("━━━ 5. Networking & common utilities ━━━\n");
+
+ await expectCommand(sandbox, "curl is installed", "curl --version 2>&1 | head -1", { contains: "curl" });
+ await expectCommand(sandbox, "wget is installed", "wget --version 2>&1 | head -1", { contains: "wget" });
+ await expectCommand(sandbox, "ssh client is installed", "ssh -V 2>&1", { contains: "OpenSSH" });
+ await expectCommand(sandbox, "jq is installed", "jq --version", { contains: "jq" });
+ await expectCommand(sandbox, "tar is installed", "tar --version 2>&1 | head -1", { contains: "tar" });
+ await expectCommand(sandbox, "zip is installed", "zip --version 2>&1 | head -2 | tail -1", { contains: "zip" });
+ await expectCommand(sandbox, "unzip is installed", "unzip -v 2>&1 | head -1", { contains: "unzip" });
+ await expectCommand(sandbox, "rsync is installed", "rsync --version 2>&1 | head -1", { contains: "rsync" });
+ await expectCommand(sandbox, "htop is installed", "htop --version 2>&1 | head -1", { contains: "htop" });
+ await expectCommand(sandbox, "tree is installed", "tree --version 2>&1", { contains: "tree" });
+ console.log();
+
+ // ── 6. System libraries ─────────────────────────────────────────
+ bold("━━━ 6. System libraries ━━━\n");
+
+ await expectCommand(sandbox, "sqlite3 is installed", "sqlite3 --version 2>&1 | head -1");
+ await expectCommand(sandbox, "libssl headers present", "test -f /usr/include/openssl/ssl.h && echo ok", { contains: "ok" });
+ await expectCommand(sandbox, "libffi headers present", "test -f /usr/include/ffi.h && echo ok || (test -d /usr/include/*/ffi.h 2>/dev/null && echo ok || dpkg -L libffi-dev 2>/dev/null | grep ffi.h | head -1)", { contains: "ffi" });
+ await expectCommand(sandbox, "zlib headers present", "test -f /usr/include/zlib.h && echo ok", { contains: "ok" });
+ console.log();
+
+ // ── 7. Locale ───────────────────────────────────────────────────
+ bold("━━━ 7. Locale ━━━\n");
+
+ await expectCommand(sandbox, "en_US.UTF-8 locale is available", "locale -a 2>&1 | grep -i en_US.utf8", { contains: "en_US" });
+ console.log();
+
+ // ── 8. Workspace ────────────────────────────────────────────────
+ bold("━━━ 8. Workspace directory ━━━\n");
+
+ await expectCommand(sandbox, "/workspace exists", "test -d /workspace && echo ok", { contains: "ok" });
+ console.log();
+
+ } catch (err: any) {
+ red(`Fatal error: ${err.message}`);
+ if (err.stack) dim(err.stack);
+ failed++;
+ } finally {
+ if (sandbox) {
+ await sandbox.kill();
+ green("Sandbox killed");
+ }
+ }
+
+ // --- Summary ---
+ bold("========================================");
+ bold(` Results: ${passed} passed, ${failed} failed`);
+ bold("========================================\n");
+ if (failed > 0) process.exit(1);
+}
+
+main().catch((err) => {
+ console.error("Fatal error:", err);
+ process.exit(1);
+});