Requests
A request is one line of JSON with an op, what to do, and the
parameters it takes. id is optional and can be any JSON value: the
answer carries it back, so a program can match answers to requests.
{"id": 7, "op": "read", "target": "9f3c01aa", "lines": 20}The answer is {"id": …, "result": …}, or {"id": …, "error": "…"}
when the request could not be done. The error is a sentence meant for
people. Requests are answered one at a time, in the order they were
sent, and an answer can be interleaved with events.
Tabs, agents and terminals are identified by the IDs in
state. A tab’s and an agent’s ID stay the same for as long
as it is there, across restarts of nerdr too; a terminal’s for as long
as nerdr runs. A tab’s ID is also the ID of its first agent.
op |
Parameters | Does |
|---|---|---|
state |
Everything at once | |
subscribe |
Events from now on | |
read |
target, lines |
What an agent or terminal shows |
send |
agent, text |
Queue a message for an agent |
type |
target, text, keys |
Type into an agent or terminal now |
answer |
question, yes |
Answer one of nerdr’s questions |
seen |
agent |
Look at an agent, as visiting it does |
wake |
tab |
Wake a sleeping tab |
repos |
The repositories a tab can be made in | |
new_tab |
repos, branch, agent, model, task |
Make a tab |
new_terminal |
tab |
Open a terminal in a tab |
new_agent |
tab, agent, model, task |
Start another agent in a tab |
review |
agent, by, model |
Have an agent’s work reviewed |
close_tab |
tab, remove |
Close a tab |
quit |
Stop nerdr and its agents |
Every tab with its agents, terminals and branches; the agents that need you; nerdr’s open questions; and the agents that can be started.
{"id":1,"op":"state"}{"id":1,"result":{ "root": "/home/you/develop", "tabs": [{ "id": "9f3c01aa", "name": "fix-login", "dir": "/home/you/.nerdr/worktrees/fix-login", "task": "Fix the login redirect", "status": "tests pass, writing the PR", "agents": [ {"id": "9f3c01aa", "num": 1, "kind": "claude", "model": "opus", "state": "blocked", "context_percent": 41}, {"id": "1b2e77d0", "num": 2, "kind": "codex", "state": "working", "reviewer": true, "messages_waiting": 1} ], "terminals": [{"id": "c4d5e6f7", "name": "terminal", "command": "make test", "running": true}], "branches": [{"repo": "web", "branch": "fix-login", "ahead": 3, "behind": 0, "lines_added": 40, "lines_deleted": 12, "files_changed": 3, "pushed": true, "pr": 412, "pr_state": "OPEN", "ci": "pass", "pr_url": "https://github.com/you/web/pull/412"}] }], "waiting": ["9f3c01aa"], "questions": [], "agents": ["claude", "codex"]}}A tab has its name and the folder it works in (dir). It may also
have a group, the task it was given, and a status: what its agent
last said of where the work stands (nerdr status).
An agent has its num, the number the tab shows it by (“2:codex”),
and its kind and model. reviewer is set for an agent that reviews
another’s work, and messages_waiting counts the messages waiting to
be typed in to it. Its state is one of:
state |
The agent |
|---|---|
starting |
is starting |
working |
is at work |
background |
has finished its turn, with commands it started still running |
blocked |
asks you something, on its screen |
done |
has finished, and you have not looked at it yet |
idle |
waits at its prompt |
asleep |
was put to sleep while its tab was not looked at (sleep_after) |
exited |
has stopped |
waiting lists the agents that need you, in the same order as
nerdr’s waiting list: the ones asking first, then the ones that are done,
oldest first.
A terminal has its name, as nerdr read calls it (“terminal”,
“terminal 2”), and command, the last command an agent ran in it.
A branch shows each repository’s branch: how far it is ahead of or
behind its base, its changes, and its pull request and CI once nerdr has
looked them up. pr_state is GitHub’s (OPEN, CLOSED, MERGED), and
ci is fail, pending or pass.
Questions
Section titled “Questions”questions are what nerdr asks you, waiting for a yes or no. They are
not what an agent asks on its screen; that is an agent in the blocked
state, which you answer with type.
{"id": 4, "kind": "plugin_run", "text": "fix-login would run the plugin deploy", "agent": "9f3c01aa", "plugin": "deploy", "values": {"env": "staging"}, "dir": "/home/you/.nerdr/worktrees/fix-login", "until": "2026-11-14T21:03:00+01:00"}kind |
Asks |
|---|---|
repo_setup |
May the setup in .nerdr.toml of repos run in new worktrees? A tab being made waits for the answer; with no, it is made without the setup |
plugin_run |
May agent run plugin with values in dir? If not answered by until, the answer is no |
text asks the question in one sentence, ready to show.
subscribe
Section titled “subscribe”From now on, the program is also sent events. The answer
is {"id":…,"result":{}}. Ask for state after subscribing, and follow
the events from there.
The last lines lines (80 if not given) of what an agent or a terminal
shows, as plain text:
{"id":2,"op":"read","target":"9f3c01aa","lines":15}{"id":2,"result":{"text":"Do you want to proceed?\n❯ 1. Yes\n 2. No, and tell Claude what to do differently\n"}}target is an agent’s or a terminal’s ID (agent works too, for an
agent). An agent that is not running is an error.
Queues text as a message for agent. nerdr types it in, and presses
enter, once the agent is at its prompt, never while it is asking
something, the same way messages between agents work. Use this for
anything you would tell the agent in words.
{"id":3,"op":"send","agent":"9f3c01aa","text":"Also cover the logout redirect"}The answer comes as soon as the message is queued. The agent’s
messages_waiting counts it until it is typed in.
Types into an agent or a terminal right away: first text, as a paste,
then keys. Use it to answer what an agent asks on its screen, to
interrupt it, or to run a command in a terminal.
{"id":4,"op":"type","target":"9f3c01aa","keys":["1","enter"]}{"id":5,"op":"type","target":"c4d5e6f7","text":"make test","keys":["enter"]}{"id":6,"op":"type","target":"9f3c01aa","keys":["esc"]}A key is a single character, typed as it is, or one of: enter, esc,
tab, shift-tab, backspace, space, up, down, left, right,
home, end, pageup, pagedown, ctrl-a, ctrl-c, ctrl-d,
ctrl-e, ctrl-l, ctrl-o, ctrl-r, ctrl-t, ctrl-u, ctrl-z.
answer
Section titled “answer”Answers one of nerdr’s questions: yes true or false.
nerdr goes on as if you had answered in its window, and the question
goes from every client.
{"id":7,"op":"answer","question":4,"yes":true}A question already answered, or timed out, is an error.
Counts as you looking at the agent, as visiting its tab does: a done
agent turns idle, and messages that were held back because you typed
to it go on. A phone app sends this when you open an agent.
{"id":8,"op":"seen","agent":"9f3c01aa"}Wakes the agents of a tab that were put to sleep while it was not
looked at (sleep_after).
{"id":9,"op":"wake","tab":"9f3c01aa"}The repositories nerdr finds, to make a tab in:
{"id":10,"op":"repos"}{"id":10,"result":[{"name":"api","path":"/home/you/develop/api"},{"name":"web","path":"/home/you/develop/web"}]}new_tab
Section titled “new_tab”Makes a tab on a new branch branch in the repositories named in
repos, the same way nerdr tab new does for an agent. Its agent is
started with task.
{"id":11,"op":"new_tab","repos":["api"],"branch":"fix-timeout", "agent":"claude","task":"The /orders call times out on large carts; find out why and fix it"}agentis one ofstate’sagents, the first of them if not given;modelis optional.- The answer,
{"branch":"fix-timeout"}, says the tab is being made. Making its worktrees takes a moment. The tab then arrives with atab_openedevent, or anoticesays why it was not made, for example a branch of that name already being there. - If a repository has a setup in
.nerdr.tomlthat you have not allowed, arepo_setupquestion comes first, and the tab is made once it is answered.
The request is refused at once if the branch name is not valid, a
repository or agent is not there, or the tab limit (max_tabs) is
reached.
new_terminal
Section titled “new_terminal”Opens a terminal in the tab’s worktree, in a new pane after the others, as the TUI’s new-terminal key does. nerdr’s window keeps the keyboard where it is.
{"id":12,"op":"new_terminal","tab":"9f3c01aa"}{"id":12,"result":{"id":"c4d5e6f7"}}The result is the terminal’s ID, to type a command into and
read. The tab’s terminals have it, and a tab
event says so.
new_agent
Section titled “new_agent”Starts another agent beside the tab’s own, in a new pane after the others, working in the same worktree. nerdr’s window keeps the keyboard where it is.
{"id":13,"op":"new_agent","tab":"9f3c01aa","agent":"codex","task":"Write the tests for the redirect"}{"id":13,"result":{"id":"1b2e77d0"}}agentis one ofstate’sagents, and must be given.modelis optional.task, if given, is the agent’s first message, typed in once it is at its prompt, as withsend.- The result is the new agent’s ID. It comes with an
agentevent, and has the nextnumin the tab.
review
Section titled “review”Starts a code review of an agent’s work, the same way the TUI’s review pane does, or adds a reviewer to the review going on.
{"id":14,"op":"review","agent":"9f3c01aa","by":"codex"}byis the kind of agent to review with, one ofstate’sagents. If not given, it is the one the config gives ([review] agent).modelis optional; without it the reviewer runs the model the config gives it ([review.models]), if any.- The answer comes at once. nerdr then looks at the worktree, and the
reviewer arrives as an agent with
reviewerset, or anoticesays why not, for example that nothing has changed to review.
The request is refused if the agent is itself a reviewer, if a reviewer of the same kind is reviewing already, if the agent is busy with the findings of a review, or if the agent runs in a sandbox and the reviewer would not.
close_tab
Section titled “close_tab”Closes a tab, stopping every agent, terminal and reviewer in it, as the TUI’s close dialog does.
{"id":15,"op":"close_tab","tab":"9f3c01aa","remove":true}{"id":15,"result":{"text":"closed fix-login and deleted its worktree"}}- Without
remove, the worktrees and branches are kept, and the tab can be opened again from them. - With
remove, the worktrees are deleted too, but never by force. The request is refused, and the tab stays open, if a worktree has changes that are not committed, or commits that are on no remote and not in a merged pull request. The error says where. Commit or push them, or close withoutremove. - The branches are kept, unless the pull request of every one is merged on GitHub with the head the branch has: then they are deleted as well, as pressing enter in the close dialog does.
tabmust be the tab’s own ID, not the ID of another agent in it.
The answer comes once the tab’s programs have stopped and its worktrees
are gone; text says what was done. A tab_closed event
follows. If an agent committed after the worktrees were looked at, and
before it was stopped, the tab is closed but the worktrees are kept, and
the answer is an error saying so.
Stops nerdr for its folder, as quitting in its window does: every agent,
terminal and plugin stops, and the tabs are kept for the next time nerdr
starts there. A window open on it closes. nerdr stop sends this.
{"id":16,"op":"quit"}The answer, {"id":16,"result":{}}, says nerdr is quitting, and the
connection then closes. While the agents stop it can close before the
answer comes: a program that sent quit can take the connection closing
as the same answer. A quit to a nerdr already quitting is answered
with an error, nerdr is quitting.