Orca

2026-08-01 · page · source ↗ · source summary

An open-source Electron desktop app (macOS/Windows/Linux) that orchestrates 20+ CLI AI coding agents — Claude Code, Codex, Pi, Grok, Cursor, and others — in parallel git worktrees, with a mobile companion app for monitoring and steering from a phone. ~590K lines of TypeScript. MIT licensed by stablyai.


Architecture

Orca is a multi-agent orchestrator, not an agent itself. It wraps existing CLI coding agents in persistent terminal sessions, each isolated in its own git worktree or folder workspace, and provides coordination, persistence, and remote access layers.

Process model

  1. Main process (src/main/index.ts, 3,034 lines) — Electron main, wires all services
  2. Renderer (src/renderer/) — React 19 + Tailwind + shadcn/ui + Monaco + xterm.js WebGL
  3. Daemon (forked child) — hosts persistent node-pty sessions so terminals survive renderer crashes and window close
  4. Relay (src/relay/) — long-lived WS process for mobile pairing and SSH tunnel maintenance
  5. CLI (src/cli/) — standalone orca binary for scripting and agent-driven control
  6. Mobile (mobile/) — React Native companion (iOS App Store, Android APK)

The daemon is the key architectural decision

Rather than hosting PTY sessions in the main process (which would die on quit), Orca forks a daemon that owns the actual pseudo-terminals. The main process routes data between daemon and renderer. On restart, the main process reconnects to surviving daemon PTYs and the renderer rehydrates terminal state from persistence. This single decision makes terminal sessions durable across crashes — most Electron apps lose terminal state on crash; Orca treats that as a design constraint to solve.

Agent status via dual-path detection

Orca knows what agents are doing through two channels:

For agents that don't emit visible working-state indicators, Orca injects synthetic title frames directly into the PTY stream — a shared 80ms interval timer drives Unicode spinner characters that appear as OSC titles in the renderer.

SSH multiplexing, not per-channel connections

Instead of opening separate SSH connections for PTY, SFTP, file watching, and git, Orca multiplexes all channels over one ssh2 connection (src/main/ssh/ssh-channel-multiplexer.ts) with backpressure management, lane scheduling, and incarnation tracking for reconnect. The SSH subsystem also handles auto-deploy of the Orca runtime to remote hosts and OpenSSH config file parsing.

Orchestration engine

src/main/runtime/orchestration/coordinator.ts implements a decompose → dispatch → monitor → converge loop backed by SQLite. Key features: - Stale base detection: Before dispatching, probes worktree git drift; if >20 commits behind base, escalates rather than dispatching (opt-out via allow-stale-base: true in spec) - Federation: Cross-worktree dispatch sync via federation-sync.ts - Lifecycle reconciliation: Detects and reconciles split-brain states between coordinator and workers - Legacy worker terminal recovery: Survives and recovers worker terminals from prior sessions

Plugin system

src/main/plugins/ supports filesystem-discovered plugins, bundled bootstrap plugins, a marketplace, consent/enablement management, and a kill list for known-malicious plugins. Plugins run in an isolated child process.

Key Techniques

Persistent PTY via forked daemon

The daemon child process (src/main/daemon/daemon-init.ts) owns the node-pty instances. The main process sends commands and receives data via IPC. On quit, the daemon checkpoints state. On restart, the main process reconnects. This is the most distinguishing technical choice — terminal scrollback, agent state, and running processes survive restart.

Per-agent hook installation

Each of the 20+ supported agents gets its own hook installer in src/main/agent-hooks/. For Claude Code it's via .claude/hooks/, for Codex via .codex/hooks/, for Pi via its native hook protocol. Remote agents relay hooks through the SSH multiplexer back to the local hook server. WSL agents use a WSL hook relay manager that bridges Windows ↔ Linux filesystem boundaries.

Codex session resume — the most complex integration

The Codex integration (src/main/codex/) handles session provenance tracking across real ~/.codex and Orca-managed homes, legacy session migration, project trust pre-marking, and hook installation that varies by whether the user selected system-default or managed-home runtime. The launch prep function is called before every Codex PTY spawn and must be synchronous.

Synthetic title spinners

When an agent is in working state, Orca injects Unicode spinner frames (⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏) at 80ms intervals into the PTY data stream via OSC title escapes. One shared timer drives all spinners (avoiding per-pane interval timers). The spinner stops when the hook server reports a state change to blocked, waiting, or done. Visibility-gating avoids unnecessary work when the window is hidden.

Crash recovery layers

Agent prompt injection via bracketed paste

src/shared/agent-prompt-injection.ts builds paste-mode byte sequences for submitting prompts to agent terminals, avoiding line-by-line typing that would trigger hooks mid-paste. Includes delay management and oversized-input chunking.

Design Decisions

Optimized for: Running many agents in parallel, each in its own worktree. Everything flows from this: daemon-based PTYs, hook-based status, SSH multiplexing, orchestration dispatch.

Optimized for: Crash survival. Daemon PTYs, breadcrumbs, renderer recovery, GPU fallback, update handoff, session resume — enormous engineering investment in making things not break.

Sacrificed: Architectural simplicity. 590K lines, 9,500+ files, 3,000-line entry point, deep coupling between subsystems. The per-agent integration modules follow similar patterns with significant duplication.

Trade-off: JSON file store for core state vs. SQLite for orchestration — two persistence backends that grew organically rather than by design.

Trade-off: Electron's resource cost in exchange for Chromium's browser pane support (Design Mode, offscreen browser) and cross-platform reach.

Comparison Notes


Sources: raw/stablyai-orca Last updated: 2026-08-01