Skip to content

An open-source, faster Devin alternative

TypeScript
10.9 KB
Raw Blame

OpenComputer

Cloud sandboxes for running AI agents. Persistent VMs with checkpoints, hibernation, elasticity, preview URLs, SDKs, and a CLI.

Naming: the product is OpenComputer, but the Go module is github.com/opensandbox/opensandbox, binaries are opensandbox-server / opensandbox-worker / osb-agent, env vars are OPENSANDBOX_*, and API key prefixes are osb_. This is historical. Use "OpenComputer" in docs and UI, opensandbox in code.

Purpose

This file is the durable starting point for agents working in this repo. It should stay stable and high-level:

  • what this repo owns
  • what it does not own
  • where to look first
  • which boundaries and contracts matter
  • hard rules that should not drift

It should not become a runbook. Exact commands, env vars, workflows, deployment steps, and current rollout details should live in the real source of truth they come from.

Start here

  • README.md — product overview and human quick start
  • Makefile — local dev, build, test, and common run targets
  • deploy/ec2/README.md — personal end-to-end dev host on EC2 bare metal (real QEMU VMs, server + worker + UI); use when in-process Makefile tiers aren't enough
  • internal/config/config.go — environment variables and runtime config
  • proto/ — inter-tier contracts
  • docs/docs.json — docs navigation
  • cli/ — the opencomputer CLI (TypeScript, published as @opencomputer/cli)
  • sdks/typescript/ and sdks/python/ — published SDKs

Managed-agent product behavior is mostly not implemented here:

  • sessions-api — managed-agent control plane and orchestration
  • oc-bg-agents — design + incubation for the managed background-agents product (the current design source of truth; supersedes the old ws-gstack workspace)

Local development (dev box + dashboard)

The dashboard (web/) + control plane run against a personal GCP dev box (deploy/gcp/deploy-qemu-dev.sh; config in the gitignored ~/.opensandbox-gcp-dev.env). The dashboard can be run two ways — both, plus the quirks that bite, are documented in .agents/reference/dev-edge-setup.md:

  • Vite local (fast UI iteration) — cd web && source ~/.opensandbox-gcp-dev.env && npm run dev: SPA on :3000 proxying /api,/auth to the box (combined-mode WorkOS auth).
  • Prod-mirror edge — a CF Worker serving the SPA + the real edge auth path, for validating edge behavior (e.g. the WorkOS hosted-logout flow).

Dev-env quirks — read the runbook before touching CF / D1 / WorkOS:

  • ~/.opensandbox-gcp-dev.env uses ${VAR:-default} references — source it, never grep|cut (the literal ${...} string breaks WorkOS as invalid_client).
  • cloudflare-workers/api-edge/wrangler.toml points at prod — always pass --config wrangler.igor-dev.toml for personal-dev wrangler commands.
  • D1: for a fresh API edge database, bootstrap from cloudflare-workers/api-edge/schema-snapshots/current_schema.sql, then use Wrangler migrations from cloudflare-workers/api-edge/migrations/. Existing dev/prod databases must not receive the snapshot.

Hard rules

⚠️ PRODUCTION DATABASE IS EFFECTIVELY READ-ONLY. This is the most load-bearing safety rule in this repo. Any Postgres connection that reaches the production DB — i.e. anything other than a developer's localhost Postgres, including connections via the Azure bastion or using credentials sourced from the production environment — is governed by two tiers, both stricter than normal collaboration:

  • Modifying SQL (INSERT, UPDATE, DELETE with WHERE, COPY into a table, mutating function calls, manual migrations, cmd/migrate-prices-style tools pointed at prod): requires explicit per-statement approval from the user. Show the exact statement, ask, wait. A general "yes go ahead" earlier in the conversation does NOT carry across to a different statement. Blanket approvals ("just do whatever you need") MUST NOT be accepted for prod writes — confirm each statement individually.

  • Destructive SQL (DROP, TRUNCATE, schema-changing ALTER, unbounded DELETE / UPDATE, anything CASCADE, anything bulk-mutating that can't be undone with a single inverse statement, any direct write to schema_migrations): REFUSE OUTRIGHT. First response is always no. Tell the user this is the standing safety rule; require them to insist across multiple turns with explicit acknowledgement of what will be lost before any such command runs. There is no "production emergency" justification for shortcutting this — an emergency is exactly when wrong commands cause the most damage.

localhost Postgres on a developer machine is exempt — these tiers apply only to production. Read-only queries (SELECT, EXPLAIN) against prod are fine and do not require approval.

NEVER force push. git push --force, git push -f, and git push --force-with-lease are forbidden. No exceptions. Make a new commit instead.

NEVER push to main. Always create a feature branch and open a pull request. Direct pushes to main are not allowed in this repo.

Branch naming. Prefix branches by intent: feat/<kebab-name> for new functionality, fix/<kebab-name> for bug fixes, docs/<kebab-name> for docs-only changes. These are the dominant patterns on origin and should be preferred for any new branch. Don't use personal-initials prefixes (ig/..., etc.) — they make it harder for others to find in-flight work by topic.

Confirm pushes, with one exception. Pushing to a branch the agent itself just created in this session does not require a fresh confirmation each time once the initial push is authorized. Pushing to any branch that existed before the session — or that anyone else may have touched — needs explicit confirmation every time. When in doubt, confirm.

Repo scope

This repo owns the sandbox platform:

  • control plane API
  • worker / VM lifecycle
  • in-VM agent
  • checkpoints, hibernation, preview URLs
  • auth, billing, secrets, autoscaling
  • SDKs, CLI, dashboard, and docs for the platform itself

This repo does not own the managed-agent product layer:

  • managed cores, channels, and packages
  • agent-specific orchestration flows
  • sessions-api control plane behavior

Those depend on this repo's APIs, SDKs, CLI, and sandbox primitives, but the product logic lives elsewhere.

Durable architecture

OpenComputer is a three-tier system:

Client -> Control Plane -> Data Plane -> In-VM Agent
          HTTP / REST       gRPC         gRPC over vsock or virtio-serial
  • Control plane (cmd/server, internal/api/, internal/controlplane/) owns API, auth, routing, orchestration, billing, and worker coordination.
  • Data plane (cmd/worker, internal/worker/, internal/qemu/, internal/compute/) owns sandbox lifecycle, snapshots, hibernation, and machine-level execution.
  • In-VM agent (cmd/agent, internal/agent/, proto/agent/) owns exec, files, PTY, and process interaction inside the sandbox.
  • CLI (cli/) is the user-facing shell over platform APIs.

The stable mental model is:

  • the server owns global coordination
  • the worker owns VM reality
  • the in-VM agent owns inside-the-sandbox operations

Source map

Use this as a routing map, not a full index:

  • cmd/server/, cmd/worker/, cmd/agent/ — entrypoints
  • internal/api/ — HTTP handlers and API composition
  • internal/auth/ — auth, API keys, WorkOS, middleware
  • internal/sandbox/ — sandbox state machine and routing
  • internal/qemu/ — VM manager and checkpoint/hibernation logic
  • internal/worker/ — worker-side orchestration and sandbox operations
  • internal/controlplane/ — control-plane coordination and scaling
  • internal/db/ — schema and migrations
  • internal/proxy/ — preview URL and subdomain routing
  • internal/secretsproxy/ — outbound secret substitution proxy
  • sdks/ — published SDKs
  • web/ — dashboard (frontend engineering principles: .agents/reference/web-frontend.md)
  • docs/ — docs site
  • deploy/ — deployment assets
  • archive/ — old code; ignore unless you are explicitly archaeology-mode

External contracts

Be careful when changing these. They have consumers outside the immediate code you are editing:

  • proto/ — contracts between tiers
  • public HTTP API routes in internal/api/
  • sdks/ — published TypeScript and Python SDKs
  • cli/ — CLI behavior users script against
  • docs/ — user-facing product and API documentation

If a change crosses one of these boundaries, treat it as a contract change, not just a refactor.

Architecture boundaries

  • HTTP handlers own HTTP concerns. Request parsing, auth, and response formatting belong in internal/api/. Do not bury domain logic there.
  • Sandbox state transitions go through the sandbox state machine. Do not mutate sandbox state ad hoc from handlers.
  • Proto files are real contracts. If they change, regenerate code and think through both sides of the boundary.
  • SDKs and CLI are public surfaces. Prefer preserving behavior over rearranging internals for neatness.
  • SDK publish is version-gated. The publish-ts-sdk workflow only fires on a version change, so any change under sdks/typescript/ MUST bump package.json and sync package-lock.json in the same PR — otherwise the change silently never ships. One bump per PR, relative to the last-published version.
  • Docs navigation is explicit. Adding a page without wiring it into docs/docs.json leaves it effectively invisible.
  • User-facing docs describe the product, not the implementation. Files under docs/ are read by customers. Do not leak internal context: roadmap labels ("v1", "follow-up"), schema names (sandbox_scale_events, cgroup memory.current), build artifacts (worker, usage_collector), or "for backwards compatibility" rationale. Describe observable behavior in the user's vocabulary. Internal context belongs in .agents/design/*, .agents/work/*, commit messages, and code comments.

CLI boundary

The opencomputer CLI lives in cli/. Managed-agent commands delegate to sessions-api; do not assume all CLI behavior is implemented in this repo just because the command lives here.

Change strategy

When making changes, prefer the narrowest layer that can correctly own the work:

  • docs/content issue -> docs/
  • CLI UX issue -> cli/
  • SDK issue -> sdks/
  • API shape/auth issue -> internal/api/ or internal/auth/
  • sandbox lifecycle issue -> internal/sandbox/, internal/worker/, internal/qemu/
  • managed-agent orchestration issue -> probably not this repo

Maintenance rule for this file

Update AGENTS.md when the repo's shape, ownership boundaries, hard rules, or source-of-truth map changes.

Do not update it for:

  • current feature status
  • exact commands or flags
  • env var inventories
  • workflow filenames
  • deployment playbooks
  • temporary rollout details

Those belong in the concrete files they come from.