Architecture
OpenRig is a local control plane built as a three-package monorepo: daemon, CLI, and UI. The daemon manages state, the CLI drives it, and the UI observes it.
System Stack
CLI / UI / MCP
|
v
Hono daemon routes
|
+-- dual-format route adapters
| - legacy v1 rigs / package bundles
| - rebooted v0.2 rigs / v2 pod bundles
|
v
Framework-free domain services
|
+-- SQLite state
+-- tmux / cmux / resume adapters
+-- runtime adapters (Claude Code / Codex)Three packages: @openrig/daemon,@openrig/cli,@openrig/ui. The daemon is a Hono HTTP server with SQLite persistence. The CLI is the primary interface for both humans and agents. The UI is a React application for monitoring.
tmux: The Session Substrate
Every agent session in OpenRig is a tmux session. This is the foundational architectural decision — not an implementation detail. tmux provides the universal control surface that makes everything else possible.
Session naming convention {pod}-{member}@{rig} gives every agent a human-readable address. rig whoami resolves identity from tmux pane metadata when all else fails.
rig send injects text via tmux send-keys. rig capture reads pane output via capture-pane. No custom IPC, no message queues — the terminal is the protocol.
tmux pipe-pane captures entire session transcripts to disk. rig transcript and rig ask query this evidence store. Every agent action is auditable without the agent opting in.
rig discover scans tmux sessions to find unmanaged agents. rig adopt brings them under management. Agents don't need to know OpenRig exists.
Because every terminal-based coding agent already runs in a terminal, OpenRig can manage Claude Code, Codex CLI, or any future agent without requiring integration, plugins, or agent-side changes. The agent is unmodified. tmux is the interface.
Packages
- 65 domain files
- 14 route files
- 9 adapters
- 15 migrations
- Command handlers
- MCP server
- Output formatting
- Dashboard
- Topology graph view
- Import/bootstrap wizards
- Bundle inspector
HTTP Routes
The daemon mounts the following route groups via createApp():
/api/rigs/import,/validate,/preflightare dual-format (legacy + pod-aware)- Pod-aware import and preflight require
X-Rig-Rootheader /api/bundles/*routes detect schema version automatically/api/upaccepts both direct rig specs and v2 bundles
Domain Services
All domain services live under packages/daemon/src/domain/. Architecture rule: zero Hono imports in domain code. Routes depend on the domain; the domain never depends on routes.
Parsing and Validation
agent-manifest.tsrigspec-schema.tsrigspec-codec.tsstartup-validation.tsResolution Pipeline
agent-resolver.tsprofile-resolver.tsprojection-planner.tsstartup-resolver.tsStartup and Runtime
runtime-adapter.tsstartup-orchestrator.tsrigspec-instantiator.tsrigspec-exporter.tsSnapshot and Restore
snapshot-capture.tsrestore-orchestrator.tscheckpoint-store.tspod-repository.tsRuntime Adapter Contract
The RuntimeAdapter interface is the four-method contract between OpenRig and a harness runtime:
interface RuntimeAdapter {
listInstalled(binding): InstalledResource[]
project(plan, binding): ProjectionResult
deliverStartup(files, binding): DeliveryResult
checkReady(binding): ReadinessResult
}Projects to .claude/, merges into CLAUDE.md
Projects to .agents/, merges into AGENTS.md
No-op project/deliver, immediate readiness
Database Schema
SQLite with 15 migrations. Core state tables:
rigsnodesedgesbindingssessionseventssnapshotscheckpointspodscontinuity_statenode_startup_contextExecution Flows
Import / Validate / Preflight
Startup Sequence
Snapshot / Restore
- Reads newest session by monotonic ULID, not timestamp alone
- Consults live continuity_state before replaying startup
- Preserves state when a node is already restoring
- Replays restore-safe startup using persisted context
- Prefilters missing optional artifacts into warnings
- Hard-fails a node if a required startup file is missing
Architecture Rules
Event System
Append-only, SQLite-backed. The RigEvent union includes:
Test Coverage
Total: 127 Vitest files, 1,558 tests. All suites passing.