Skip to content

Build on nerdr

nerdr has an API for programs you write yourself. A program connected to it sees what nerdr sees: the tabs, each agent’s state and screen, the waiting list, and what nerdr asks you. It can also act the way you do: send an agent a message, press keys in its pane, answer nerdr’s questions, make and close tabs, open terminals, start more agents, and start code reviews.

nerdr keeps running as usual while a program is connected, with its window open or closed. Several programs can be connected at once.

A notifier

A desktop or phone notification when an agent asks something or finishes. It takes ten lines of shell; see Examples.

A phone app

A connector on your machine that serves a small web app: the waiting list, an agent’s screen, a box to reply. It can be reached over Tailscale or another private network.

A chat bot

Agents that ask something post to Slack or Matrix, and your reply is typed in to the agent.

Automation

A script that makes a tab for each new issue with a label, or that reports each tab’s pull request and CI to a dashboard.

How a program reaches the agentsYour program talks to nerdr api over standard input and output. nerdr api connects to the API socket, which is private and needs a key. Behind it is nerdr's core, which runs while the window is closed and runs the agents.your programany languagenerdr apisays hello for youAPI socketprivate, keyedcorewindow open or notagentsin their tabsJSON lines onstdin and stdout
One JSON object per line, each way: requests and answers, and events once your program subscribes.

nerdr’s core is the part that runs the tabs and agents. It lives on when you close nerdr’s window and stops when you quit (see how it works). The core listens on an API socket of its own, beside the socket its window connects to.

The protocol is JSON lines: one JSON object per line, each way. Your program sends requests and gets answers, and once it subscribes, it is also sent events as things happen. Any language that can start a process and read lines can use it.

Start nerdr in a folder, then run this from another terminal:

Terminal window
echo '{"id":1,"op":"state"}' | nerdr api ~/develop

The first line is the welcome, and the second is the answer: every tab, its agents and their states. To watch what happens, subscribe and leave it running:

Terminal window
echo '{"op":"subscribe"}' | nerdr api ~/develop

Then make a tab in nerdr, or give an agent some work, and see the events come in.

  • Connecting: nerdr api, over SSH, or straight to the socket; and how the API is guarded.
  • Requests: everything a program can ask, with examples.
  • Events: what a subscribed program is told.
  • Schema: all of it as JSON Schema, to generate a program’s types from.
  • Examples: a notifier in shell and a client in Python to start from.

The API’s version is 1, and nerdr sends it in the welcome. New requests, fields and events may be added without changing the version, so ignore what you do not know. A change that would break a program written for version 1 raises the version, and a program says which version it was written for when it connects. The schema says which version it describes.