herdr exposes a local unix socket api for scripts, tools, and coding agents that want to control a running herdr instance or subscribe to events.
if you are teaching an agent that is already running inside herdr, start with SKILL.md. use this document when you want the direct protocol, or when you want the cli wrapper reference for the commands that sit on top of it.
there are three practical ways to integrate with herdr:
- agent skill —
SKILL.md. best when an agent inside herdr just needs to learn the workflow quickly. - cli wrappers —
herdr server stop,herdr workspace ...,herdr tab ...,herdr pane ...,herdr wait .... best for shell scripts and simple orchestration. - raw socket api — best when you want direct request/response control or long-lived event subscriptions.
these layers are intentionally stacked on top of the same control surface.
important difference: pane.run and wait agent-status are cli conveniences, not raw socket methods.
- transport: unix domain socket
- encoding: newline-delimited json
- request/response: send one json request per line, read one json response per line
- subscriptions: send
events.subscribe, receive an ack, then keep the same connection open and continue reading pushed events
socket path resolution order:
HERDR_SOCKET_PATH$XDG_RUNTIME_DIR/herdr.sock$XDG_CONFIG_HOME/herdr/herdr.sock$HOME/.config/herdr/herdr.sock/tmp/herdr.sock
all socket requests use this envelope:
{
"id": "req_1",
"method": "ping",
"params": {}
}successful responses look like:
{
"id": "req_1",
"result": {
"type": "pong",
"version": "0.1.2"
}
}errors look like:
{
"id": "req_1",
"error": {
"code": "pane_not_found",
"message": "pane 1-99 not found"
}
}workspace ids are opaque, stable ids like:
w64e95948145ed1w64e95948146a82
pane ids are workspace-scoped and stable across workspace reorder:
w64e95948145ed1-1w64e95948145ed1-2w64e95948146a82-1
that means:
- workspace id = stable workspace identity
- pane number = compact pane number within that workspace
workspace ids are durable for the life of the workspace and survive display reordering. pane numbers are still compact public numbers, so if a pane closes, higher pane numbers in that same workspace compact down.
tabs are first-class socket api objects now.
- tab ids look like
w64e95948145ed1:1,w64e95948145ed1:2 - workspace id = stable workspace identity
- tab number = tab number within that workspace
- pane ids still stay workspace-scoped like
w64e95948145ed1-2rather than becomingworkspace-tab-panetriples
for backward compatibility, requests also accept the older positional forms like 1, 1:2, and 1-2 as shorthand for the current session order. responses use the stable ids.
workspace_info responses contain objects like:
{
"workspace_id": "w64e95948145ed1",
"number": 1,
"label": "herdr",
"focused": true,
"pane_count": 1,
"tab_count": 1,
"active_tab_id": "w64e95948145ed1:1",
"agent_status": "unknown"
}tab_info responses contain objects like:
{
"tab_id": "w64e95948145ed1:1",
"workspace_id": "w64e95948145ed1",
"number": 1,
"label": "1",
"focused": true,
"pane_count": 1,
"agent_status": "unknown"
}pane_info responses contain objects like:
{
"pane_id": "w64e95948145ed1-1",
"workspace_id": "w64e95948145ed1",
"tab_id": "w64e95948145ed1:1",
"focused": true,
"cwd": "/home/can/Projects/herdr",
"agent": "pi",
"agent_status": "working",
"revision": 0
}agent is an optional display label string.
- when herdr detects a built-in agent, this is that built-in name like
piorclaude - when a hook or plugin reports a custom agent through
pane.report_agent, this can be any non-empty label likehermes - when no agent identity is known, it is omitted
pane_read responses contain objects like:
{
"pane_id": "w64e95948145ed1-1",
"workspace_id": "w64e95948145ed1",
"tab_id": "w64e95948145ed1:1",
"source": "recent",
"text": "...",
"revision": 0,
"truncated": false
}agent_status is the public agent field:
idleworkingblockeddoneunknown
done means the agent has finished, but you have not looked at that finished pane yet.
| method | purpose | success result type |
|---|---|---|
ping |
health check / version | pong |
server.stop |
gracefully stop the running background server | ok |
workspace.list |
list workspaces | workspace_list |
workspace.get |
inspect one workspace | workspace_info |
workspace.create |
create a workspace | workspace_info |
workspace.focus |
focus a workspace | workspace_info |
workspace.rename |
rename a workspace | workspace_info |
workspace.close |
close a workspace | ok |
tab.list |
list tabs, optionally filtered by workspace | tab_list |
tab.get |
inspect one tab | tab_info |
tab.create |
create a tab in a workspace | tab_info |
tab.focus |
focus a tab | tab_info |
tab.rename |
rename a tab | tab_info |
tab.close |
close a tab | ok |
pane.list |
list panes, optionally filtered by workspace | pane_list |
pane.get |
inspect one pane | pane_info |
pane.read |
read pane output | pane_read |
pane.split |
split a pane and create a sibling pane | pane_info |
pane.send_text |
send literal text without Enter | ok |
pane.send_keys |
send keypresses like Enter |
ok |
pane.send_input |
send literal text plus keypresses in order | ok |
pane.report_agent |
report hook-authoritative agent label and state for a pane | ok |
pane.clear_agent_authority |
clear hook-authoritative agent state for a pane | ok |
pane.release_agent |
release a pane from the reported agent back to shell state | ok |
pane.close |
close a pane | ok |
pane.wait_for_output |
one-shot blocking wait for text | output_matched |
events.subscribe |
start a long-lived subscription stream | subscription_started ack |
request:
{
"id": "req_stop",
"method": "server.stop",
"params": {}
}returns ok and asks the running background server to shut down cleanly.
this is the explicit server-level shutdown path for persistence mode. normal in-app quit actions detach the current client instead of sending this request.
request:
{
"id": "req_list",
"method": "workspace.list",
"params": {}
}returns workspace_list with zero or more workspace objects.
params:
{
"workspace_id": "1"
}returns workspace_info for one workspace.
params:
{
"cwd": "/home/can/Projects/herdr",
"focus": true
}notes:
cwdis optional- if
cwdis omitted, herdr uses its current working directory and falls back to/if needed focusis optional in raw socket requests and defaults tofalse- the cli wrapper is more ergonomic here:
herdr workspace createfocuses by default unless you pass--no-focus
example response:
{
"id": "req_create",
"result": {
"type": "workspace_info",
"workspace": {
"workspace_id": "1",
"number": 1,
"label": "herdr",
"focused": true,
"pane_count": 1,
"tab_count": 1,
"active_tab_id": "1:1",
"agent_status": "unknown"
}
}
}params:
{
"workspace_id": "1"
}returns the focused workspace as workspace_info.
params:
{
"workspace_id": "1",
"label": "api"
}returns updated workspace_info.
params:
{
"workspace_id": "1"
}returns:
{
"id": "req_close",
"result": {
"type": "ok"
}
}request with no filter:
{
"id": "req_tabs",
"method": "tab.list",
"params": {}
}request filtered to one workspace:
{
"id": "req_tabs_ws",
"method": "tab.list",
"params": {
"workspace_id": "1"
}
}returns tab_list.
params:
{
"tab_id": "1:2"
}returns tab_info.
params:
{
"workspace_id": "1",
"cwd": "/home/can/Projects/herdr",
"focus": true
}notes:
workspace_idis optional and defaults to the active workspacecwdis optional; if omitted, herdr uses the focused pane cwd in that workspace when availablefocusis optional in raw socket requests and defaults tofalse- the cli wrapper focuses by default unless you pass
--no-focus
returns tab_info for the new tab.
params:
{
"tab_id": "1:2"
}returns focused tab_info.
params:
{
"tab_id": "1:2",
"label": "logs"
}returns updated tab_info.
params:
{
"tab_id": "1:2"
}returns ok. the last tab in a workspace cannot be closed.
request with no filter:
{
"id": "req_panes",
"method": "pane.list",
"params": {}
}request filtered to one workspace:
{
"id": "req_panes_ws",
"method": "pane.list",
"params": {
"workspace_id": "1"
}
}returns pane_list.
params:
{
"pane_id": "1-1"
}returns pane_info.
params:
{
"pane_id": "1-1",
"source": "recent",
"lines": 80,
"strip_ansi": true
}notes:
sourceis required and must bevisibleorrecentlinesis optional- current implementation defaults to
80lines whenlinesis omitted and caps reads at1000 strip_ansidefaults totrue
source meanings:
visible— current viewportrecent— recent scrollback text
example response:
{
"id": "req_read",
"result": {
"type": "pane_read",
"read": {
"pane_id": "1-1",
"workspace_id": "1",
"tab_id": "1:1",
"source": "recent",
"text": "...",
"revision": 0,
"truncated": false
}
}
}params:
{
"target_pane_id": "1-1",
"direction": "right",
"focus": true
}notes:
directionmust berightordowncwdis optionalfocusis optional in raw socket requests and defaults tofalse- the cli wrapper is more ergonomic here too:
herdr pane split ...focuses by default unless you pass--no-focus
returns pane_info for the new pane.
params:
{
"pane_id": "1-1",
"text": "bun run dev"
}this sends literal text only. it does not press Enter.
params:
{
"pane_id": "1-1",
"keys": ["Enter"]
}use this after pane.send_text when you want to submit a command.
params:
{
"pane_id": "1-1",
"text": "bun run dev",
"keys": ["Enter"]
}this sends text plus encoded keypresses in order within one request. when bracketed paste is enabled in the pane, the text portion is sent as a paste payload before the keys. use this when you need text + Enter to behave more like a real keypress sequence than pane.send_text with a literal trailing \r.
text and keys are both optional, but at least one should usually be present.
use this when an agent hook or plugin wants to report a semantic state directly over the socket api.
params:
{
"pane_id": "1-1",
"source": "custom:hermes",
"agent": "hermes",
"state": "working",
"message": "running tools"
}notes:
sourceis required and identifies the reporting integration instanceagentis required and may be any non-empty label string- built-in names like
piare normalized to their public label form - custom labels like
hermesare accepted as-is - while this authority is active, the reported
agentandstateoverride heuristic display for that pane - process detection still owns pane liveness and fallback when hook authority is cleared or released
messageis optional metadata for the reporting integration
returns ok.
params:
{
"pane_id": "1-1",
"source": "custom:hermes"
}notes:
sourceis optional- when
sourceis omitted, any hook authority for that pane is cleared - when
sourceis present, only that reporting source is cleared
returns ok.
use this when the reported agent is exiting cleanly and wants herdr to drop agent identity immediately instead of waiting for fallback detection.
params:
{
"pane_id": "1-1",
"source": "custom:hermes",
"agent": "hermes"
}notes:
agentuses the same non-empty label rules aspane.report_agent- this clears the pane's effective agent identity immediately when the source and label match the active authority
- for built-in detected agents, herdr also applies its normal short reacquire suppression during graceful release
returns ok.
params:
{
"pane_id": "1-2"
}returns ok.
this is the direct socket-side one-shot blocking wait.
params:
{
"pane_id": "1-1",
"source": "recent",
"lines": 200,
"match": { "type": "substring", "value": "ready" },
"timeout_ms": 30000,
"strip_ansi": true
}matcher forms:
{ "type": "substring", "value": "ready" }{ "type": "regex", "value": "server.*ready" }notes:
sourcemust bevisible,recent, orrecent_unwrappedlinesis optionaltimeout_msis optionalstrip_ansidefaults totrue- for
source = "recent", output matching uses unwrapped recent terminal text so soft wraps do not break matches source = "recent_unwrapped"is also available onpane.readwhen you want to inspect the same unwrapped transcript directly- on success you get
output_matched - on timeout you get an error response with code
timeout
example success response:
{
"id": "req_wait",
"result": {
"type": "output_matched",
"pane_id": "1-1",
"revision": 0,
"matched_line": "server ready",
"read": {
"pane_id": "1-1",
"workspace_id": "1",
"tab_id": "1:1",
"source": "recent_unwrapped",
"text": "...server ready...",
"revision": 0,
"truncated": false
}
}
}events.subscribe is the long-lived pubsub entrypoint.
you send a subscribe request once, get an ack on the same connection, and then keep reading newline-delimited json events from that same socket.
{
"id": "sub_1",
"result": {
"type": "subscription_started"
}
}base lifecycle subscriptions:
workspace.createdworkspace.closedworkspace.focusedtab.createdtab.closedtab.focusedtab.renamedpane.createdpane.closedpane.focusedpane.exitedpane.agent_detected
parameterized subscriptions:
pane.output_matchedpane.agent_status_changed
this part matters because the pushed event names are not all shaped the same.
- when you subscribe to a base lifecycle event, the pushed
eventvalue uses snake_case with underscores:- subscribe with
workspace.created - receive
workspace_created
- subscribe with
- when you subscribe to a parameterized subscription, the pushed
eventvalue keeps the dotted name:- subscribe with
pane.output_matched - receive
pane.output_matched
- subscribe with
examples below show both forms.
request:
{
"id": "sub_life",
"method": "events.subscribe",
"params": {
"subscriptions": [
{ "type": "workspace.created" },
{ "type": "workspace.focused" },
{ "type": "tab.created" },
{ "type": "tab.focused" },
{ "type": "tab.renamed" },
{ "type": "tab.closed" },
{ "type": "pane.created" },
{ "type": "pane.focused" },
{ "type": "pane.agent_detected" },
{ "type": "pane.closed" },
{ "type": "workspace.closed" }
]
}
}example pushed event:
{
"event": "workspace_created",
"data": {
"workspace": {
"workspace_id": "1",
"number": 1,
"label": "herdr",
"focused": true,
"pane_count": 1,
"tab_count": 1,
"active_tab_id": "1:1",
"agent_status": "unknown"
}
}
}request:
{
"id": "sub_1",
"method": "events.subscribe",
"params": {
"subscriptions": [
{
"type": "pane.output_matched",
"pane_id": "1-1",
"source": "recent",
"lines": 200,
"match": { "type": "substring", "value": "ready" }
},
{
"type": "pane.agent_status_changed",
"pane_id": "1-1",
"agent_status": "done"
}
]
}
}notes:
pane.output_matchedsupportssource, optionallines, matcher config, and optionalstrip_ansipane.agent_status_changedaccepts an optionalagent_statusfilter; if omitted, any status transition for that pane can match
example pushed pane.output_matched event:
{
"event": "pane.output_matched",
"data": {
"pane_id": "1-1",
"matched_line": "server ready",
"read": {
"pane_id": "1-1",
"workspace_id": "1",
"tab_id": "1:1",
"source": "recent_unwrapped",
"text": "...server ready...",
"revision": 0,
"truncated": false
}
}
}example pushed pane.agent_status_changed event:
{
"event": "pane.agent_status_changed",
"data": {
"pane_id": "1-1",
"workspace_id": "1",
"agent_status": "done",
"agent": "pi"
}
}agent in pushed events follows the same rules as pane_info.agent: it may be a built-in detected name, a custom hook-reported label, or omitted.
these commands talk to the same local socket surface and are usually the easiest starting point for shell scripts and coding agents.
workspace commands:
herdr workspace list
herdr workspace create [--cwd PATH] [--label TEXT] [--no-focus]
herdr workspace get <workspace_id>
herdr workspace focus <workspace_id>
herdr workspace rename <workspace_id> <label>
herdr workspace close <workspace_id>
tab commands:
herdr tab list [--workspace <workspace_id>]
herdr tab create [--workspace <workspace_id>] [--cwd PATH] [--label TEXT] [--no-focus]
herdr tab get <tab_id>
herdr tab focus <tab_id>
herdr tab rename <tab_id> <label>
herdr tab close <tab_id>
pane commands:
herdr pane list [--workspace <workspace_id>]
herdr pane get <pane_id>
herdr pane read <pane_id> [--source visible|recent|recent-unwrapped] [--lines N] [--raw]
herdr pane split <pane_id> --direction right|down [--cwd PATH] [--no-focus]
herdr pane close <pane_id>
herdr pane send-text <pane_id> <text>
herdr pane send-keys <pane_id> <key> [key ...]
herdr pane run <pane_id> <command>
wait commands:
herdr wait output <pane_id> --match <text> [--source visible|recent|recent-unwrapped] [--lines N] [--timeout MS] [--regex] [--raw]
herdr wait agent-status <pane_id> --status <idle|working|blocked|done|unknown> [--timeout MS]
workspace createfocuses by default; pass--no-focusto keep focus where it isworkspace createwithout--labelkeeps the default cwd-based workspace namingworkspace create --labelapplies the custom workspace name immediatelyworkspace createreturnsresult.workspace,result.tab, andresult.root_panetab createfocuses by default; pass--no-focusto keep focus where it istab createwithout--labelkeeps the default numbered tab namingtab create --labelapplies the custom tab name immediatelytab createreturnsresult.tabandresult.root_panepane splitfocuses the new pane by default; pass--no-focusto keep focus on the original panepane readprints text, not jsonpane read --source recent-unwrappedreturns recent terminal text with soft wraps joined back togetherpane send-text,pane send-keys, andpane runprint nothing on success- list/get/create/split/wait commands print json on success
pane runis a convenience wrapper forpane.send_inputwith the command text followed by a realEnterkeypresswait agent-statusis a cli convenience built on top of event subscriptions- use it when you want the same
done/idledistinction the UI shows --rawdisables ansi stripping forpane readandwait outputwait output --source recentmatches against unwrapped recent terminal text by default, so pane width and soft wrapping do not break matches
create a workspace, split a pane, run a server, and wait for readiness:
herdr workspace create --cwd /path/to/project --label "api server"
herdr pane split 1-1 --direction right --no-focus
herdr pane run 1-2 "npm run dev"
herdr wait output 1-2 --match "ready" --timeout 30000wait for another agent to finish in the same user-facing sense the UI shows:
herdr wait agent-status 1-1 --status done --timeout 60000inspect another pane's output:
herdr pane read 1-1 --source recent --lines 80pane.send_textsends literal text only. if you want to execute a command, follow it withpane.send_keysandEnter, usepane.send_inputfor orderedtext + keypressinput, or use clipane run, which sends the text and then a real Enter key in one request.pane.readandpane.wait_for_outputstrip ansi by default.pane.output_matchedsubscriptions fire on transitions into a matching state; they do not repeatedly spam the same still-visible match on every poll.- closing the socket connection ends the subscription.
- there is no separate event transport.
- the same herdr process can serve regular request/response calls and long-lived subscription connections at the same time.