coxcox
docs

Architecture

One event stream

At the center of cox is a pure state machine in cox-core. A Submission enters the core; a sequence of typed Event values leaves it. The terminal UI, headless stream-JSON mode, ACP server, MCP server, session rollout, and tests all consume that same sequence.

This makes the hard part of an agent observable: a test can replay a scripted provider response and assert on the events without opening a network connection or terminal.

Clear crate boundaries

CrateResponsibility
coxCLI parsing and surface dispatch
cox-protocolCross-crate types and traits
cox-coreTurns, context, routing, budgets, permissions, compaction
cox-providerModel-provider adapters and replay fixtures
cox-toolsBuilt-in tools, path confinement, and sandboxing
cox-mcpMCP client and server support
cox-storeSQLite sessions, rollouts, archived output, and cost ledger
cox-extInstructions, skills, commands, agents, and hooks
cox-tuiTerminal presentation
cox-acpAgent Client Protocol adapter

The core owns no direct filesystem, process, or network I/O. Those operations are defined as traits in cox-protocol and implemented at the edge of the system.

Trust boundaries

Everything produced outside cox is untrusted input: model output, tool results, MCP responses, hooks, skills, and repository instruction files. The important guards are centralized rather than copied into individual tools:

  1. The permission engine authorizes, denies, or escalates every tool call.
  2. Path confinement rejects workspace escapes.
  3. The sandbox restricts shell commands unless a user selects full access.
  4. Terminal rendering sanitizes escape sequences and bidi overrides.

Lossless context management

Long tool output is archived before the model receives a shortened representation. A later expand action can retrieve the complete result by ID. This preserves evidence for users while avoiding needless context growth.