cox documentation
One event stream behind every surface.
cox is a modular terminal coding agent in Rust. One core state machine turns submissions into typed events; the same stream powers the TUI, headless runs, editor clients (ACP), and MCP.
12 pages from pyrlyn/cox/docs at 8dbc1da, in development
- Build
mise exec -- cargo build -p cox - Check
./target/debug/cox doctor - One turn
./target/debug/cox -p "create hello.txt containing hi" - TUI
./target/debug/cox
How it works
From install to first result.
-
Build it
Rust is pinned with mise. Prefer
mise exec -- cargo …over a global toolchain.git clone https://github.com/pyrlyn/cox && cd cox mise exec -- cargo build -p cox -
Add a key and check
Export
ANTHROPIC_API_KEY(orOPENAI_API_KEY) and runcox doctor— green except prices? You are good../target/debug/cox doctor -
Run a turn
coxopens the TUI:Entersends,Escinterrupts.y/s/nanswer approval prompts,/modelswitches tiers,/compactcompacts context now../target/debug/cox -
Script it
cox run -pis the headless form.--output-format stream-jsonprints the sameEventJSON the TUI renders, one object per line../target/debug/cox run -p "summarise the diff" --output-format stream-json
How it works
Submission in, events out.
A Submission goes into a pure core state machine, a sequence of Events comes out, and every surface renders that same sequence: the TUI, headless cox run -p, the ACP editor server, the MCP server, the JSONL rollout on disk, and the test suite.
Everything the core needs from outside — models, files, shells, stored sessions — arrives through traits (Provider, Tool, Store, Hook, Archive), which is what makes the loop testable without a model.
{"type":"tool_call_requested","call":{"name":"write","input":{"path":"hello.txt","content":"hi\n"}}}
{"type":"tool_call_done","call_id":"…","result":{"ok":true,"visible":"wrote 3 bytes to hello.txt","bytes":3}}
{"type":"text_delta","text":"Created hello.txt."}
{"type":"turn_done","stop":"end_turn"}
Paths into the docs
Pick where to go next.
-
Start2 pages
- Getting started cox is a modular terminal coding agent in Rust. One core state machine turns submissions into typed events; the same stream powers the TUI, headless runs, editor clients (ACP), and MCP.
- How it works One idea explains cox: a Submission goes into a pure core state machine, a sequence of Events comes out, and every surface renders that same sequence.
-
Reference6 pages
- Configuration Every cox configuration key with its default value, generated from config/default.toml.
- Tools Every tool implements one contract (Tool::spec / subject / call): untruncated output goes to the archive first, the model sees the capped visible form plus an expand pointer.
- Editors cox acp serves cox over the Agent Client Protocol on stdio: the same Event stream as the TUI, so prompts, tool calls, approvals, and diffs show up in the editor instead of the terminal.
- Observability
- Remote sessions
- Voice input
-
Extend2 pages
- Writing a plugin A cox plugin is a WebAssembly module plus a plugin.toml manifest. cox loads it with extism, gives it only the capabilities the user approved, and calls the exports it finds.
- Cursor plugin plugins/cursor drives Cursor's own official agent CLI as a subagent — never the Cursor desktop session, never a reverse-engineered proxy (docs/design/external-agents.md, EA§8).
-
More2 pages
- Architecture 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.
- Screens One SVG per TUI state, rendered from the same frames the snapshot tests compare (crates/cox-tui/tests/screenshots.rs; just screenshots regenerates them).
Scriptable exit codes
Headless runs report what happened.
| Exit code | Meaning |
|---|---|
0 | ok |
1 | error |
2 | denied — a call the policy would ask about was refused |
3 | budget |
4 | interrupted |
Questions the docs answer
Good to know.
Can I use cox from my editor?
Yes. cox acp serves cox over the Agent Client Protocol on stdio — the same Event stream as the TUI, so prompts, tool calls, approvals and diffs show up in Zed, JetBrains or Neovim.
How are approvals handled in scripts?
Under the headless default (--approve never), a Write/Exec call the policy would ask about is denied instead, with the reason in the tool result so the model can try another approach; the run exits 2.
What happens to large tool output?
Every tool writes untruncated output to the archive first; the model sees the capped visible form plus an expand pointer.
Where do costs show up?
Costs land in cox stats, and the status line shows the session spend against the session cap (budget.session_usd).
Next steps
Read these first.
- Getting started cox is a modular terminal coding agent in Rust. One core state machine turns submissions into typed events; the same stream powers the TUI, headless runs, editor clients (ACP), and MCP.
- How it works One idea explains cox: a Submission goes into a pure core state machine, a sequence of Events comes out, and every surface renders that same sequence.
- Configuration Every cox configuration key with its default value, generated from config/default.toml.