Docs Reference
CLI and protocol
The headless quad command and its app-server mode, a JSON-RPC 2.0 protocol over standard input and output for driving the engine from your own programs.
The engine behind the desktop app can also run without a window. This is for advanced use: scripting sessions, building your own front end, or running the agent from another program.
Note. The headless
quadcommand is not part of the app download. It ships separately and is meant for advanced use. Everything below assumes you have it on yourPATH.
The quad command
quad <command> [options]
| Command | What it does |
|---|---|
quad run |
Run one turn, or start an interactive session. --workspace (default: the current folder), a prompt (omit it for an interactive loop), --model (id or label), --permission unrestricted|standard|plan (default unrestricted), -y / --yes to approve every change without asking. |
quad sessions |
List saved sessions. |
quad rewind |
Restore a checkpoint saved before a change. |
quad goal |
Set the goal of a session, or complete it with --done. |
quad models |
List configured models. |
quad search |
Search message text across every session (--limit, default 20). |
quad usage |
Tokens per day and model (--since YYYY-MM-DD). |
quad app-server |
Run the engine as a JSON-RPC 2.0 server over standard input and output. |
quad http-server |
Run the engine as an HTTP server with server-sent events, for clients that cannot use standard input and output. |
quad repair |
Close up sessions whose last turn was cut off by a crash. A session another process is running right now is left alone. |
quad db rebuild |
Discard the search index and rebuild it from the session logs. |
quad db check |
Compare the index with a full read of every log. |
Every command that reads data takes --data-dir. By default it uses the app’s own data folder, ~/Library/Application Support/dev.quad.harness, or the folder in the QUAD_DATA_DIR environment variable. The desktop app and the quad command can share one data folder, but run one build at a time against it if you can.
quad --help and quad <command> --help list every option.
The HTTP server
quad http-server is closed by default:
- It listens on loopback only (
--bind 127.0.0.1, port--port 7878;0picks a free port). - Every call needs a secret token. One is generated and printed at start (
listening on <url>andtoken: <secret>), or set it withQUAD_HTTP_TOKEN(keeps it out of the process list). --allow-originlets a given browser origin call it, for examplehttp://localhost:5173. Repeatable.- Listening on anything but loopback needs
--allow-remote, and still needs the token.
The app-server protocol
quad app-server [--data-dir <dir>]
JSON-RPC 2.0, one JSON value per line, over standard input and output. Standard output carries only protocol messages; diagnostics go to standard error. The server exits when its input closes or after shutdown, ending any running turn, background job and terminal.
Handshake
initialize must be the first request:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1}}
The answer lists the protocol and kernel versions, capabilities (only what this build has; anything absent is unsupported) and limits (largest message, page sizes, search results). rpc/describe lists every method and notification, and may be called before initialize.
Conventions
- Requests are answered in any order: match on
id. A request without anidis a notification and gets no answer. Batches are supported. - Parameters use camelCase. Session data inside results keeps its own field names.
- Sessions are read a page at a time: pass the previous
nextSeqasafterSequntilhasMoreis false.
| Error code | Meaning |
|---|---|
| -32700, -32600, -32601, -32602, -32603 | Parse error, invalid request, method not found, invalid params, internal error |
| -32002 | Called before initialize |
| -32003 | initialize called twice |
| -32010 | Not found (session, event, checkpoint, job, terminal, goal, MCP server) |
| -32011 | Conflict: a turn is already running for that session |
| -32013 | Unavailable: the index is still building or could not be opened |
Methods
| Area | Methods |
|---|---|
| Server | initialize, shutdown, rpc/describe, bootstrap (sessions, models, workspace, permission, skills, MCP, plugins in one call) |
| Sessions | session/start, session/list, session/read, session/resume, session/fork, session/rewind, session/handoff, session/rename, session/setFlags (pinned, archived, completed, read), session/delete, session/clear, session/setPermission, session/compact |
| Turns | turn/start (sessionId, text, optional attachments, model, effort), turn/interrupt |
| Approvals | approval/respond (id, allow, optional choice for a plan: standard or unrestricted) |
| Goals and checkpoints | goal/set, goal/complete, checkpoint/restore |
| Extensions | skills/list, mcp/list, plugin/list, mcp/reconnect, plugin/reload, mcp/probe, mcp/restart, mcp/resources, mcp/readResource, mcp/prompts, mcp/getPrompt, mcp/authorize, mcp/signOut, hooks/list |
| Config | config/get, config/models (never with keys), tools/list |
| Jobs | job/list, job/read, job/stop, job/input |
| Terminals | terminal/open, terminal/write, terminal/resize, terminal/close, terminal/list, terminal/snapshot |
| Search and usage | search/messages, usage/byDay |
Notifications from the server
| Notification | When |
|---|---|
run/status |
A turn starts or finishes, including a turn nobody started with turn/start (a handed-off session’s first turn) |
session/event |
Every event of a turn, in order: streamed text, tool calls and results, approval requests, compaction, errors, done |
approval/request |
A tool needs a decision. Its session_id may be a handed-off session. |
plan/updated |
The agent updated its plan |
goal/updated |
After goal/set or goal/complete |
mcp/status |
After an MCP reconnect, restart, sign-out or finished sign-in |
mcp/auth |
A sign-in started with mcp/authorize ended |
terminal/data, terminal/exit |
Terminal output, and the shell ending |
A minimal session
→ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1}}
→ {"jsonrpc":"2.0","id":2,"method":"session/start","params":{"workspace":"/Users/you/code/my-app","permission":"standard"}}
→ {"jsonrpc":"2.0","id":3,"method":"turn/start","params":{"sessionId":"s_…","text":"Run the tests and summarise failures."}}
← {"jsonrpc":"2.0","method":"run/status","params":{"sessionId":"s_…","status":"running"}}
← {"jsonrpc":"2.0","method":"session/event","params":{"sessionId":"s_…","event":{…}}}
← {"jsonrpc":"2.0","method":"approval/request","params":{"id":"…","session_id":"s_…","tool":"bash","args":{"command":"cargo test"},"description":"…"}}
→ {"jsonrpc":"2.0","id":4,"method":"approval/respond","params":{"id":"…","allow":true}}
← {"jsonrpc":"2.0","method":"run/status","params":{"sessionId":"s_…","status":"finished"}}
Attachments
turn/start takes up to 12 attachments, each with a kind: image (base64 PNG, JPEG, GIF or WebP, at most 5 MB each and 20 MB in all), text (cut at 60,000 characters per file and 200,000 in all), folder or file (an absolute path that must exist; the agent opens it with its tools). Anything refused is an invalid-params error, and nothing is logged or started.
Crashes
A running turn holds a lock on its session that is released the moment its holder dies. At launch, and before any turn starts, the server closes up sessions whose last turn is unfinished and whose lock is free: tool calls with no result get one marked as synthetic (never retried), open approvals are denied, and the turn is ended as interrupted.
Not available yet
Steering a running turn, writing configuration (models, keys, workspaces) and a skills-changed event are not in capabilities. TypeScript bindings are not published.