HTTP API¶
The daemon exposes HTTP routes for the dashboard, hooks, CLI helpers, and external integrations. The stable public client surfaces are the CLI and MCP tools; raw HTTP routes may move faster.
Primary route groups¶
/healthand status routes for daemon checks./peersfor peer registration, listing, lookup, and lifecycle operations. Peer records include optionalmodel, the last observed runtime model reported by the backend, and flattened provenance:source(hook,codex-app-server,unknown),initiator(user,agent,system, or absent),parent_runtime_id,parent_peer_id(resolved at read time,nullwhen the parent is not registered),ephemeral,addressable, andaddressable_reason.GET /peersis a complete inventory;?source=,?addressable=true|false, and?listed=true|false(the routing view's rule: addressable, notsystem, parent live if any) narrow it.POST /peersaccepts an optionalnative_name, the runtime's own session name, which becomes the display name before the response (see native session names).POST /session/update({peer_name | pane_id, status?, turn_state?, model?, metadata?, native_name?, native_title?}) reports a session's status;native_namerenames the peer when the runtime's session name changed and the response then carries the resultingdisplay_name, andnative_titlefills an empty description.POST /peersalso accepts an optionalprovenanceobject as a fresh classification (omitting it preserves what the daemon knows, and only an unknownsourceis inferred frommetadata.transport/hook_version).POST /peers/{id}/provenancereplaces a live peer's provenance and emits apeer_updatedevent; the codex bridge uses it to demote a thread whose direct input the App Server denied. A peer withaddressable=falseis inbound-only:POST /askandPOST /notifyto it return 409{"error"|"reason": "peer_not_addressable", "peer_id", "parent_peer_id" (null when the parent is not registered), "hint"}before anything is registered or queued, broadcasts skip it, and scheduled asks fail the same way. It can still ack, reply, notify, and broadcast. When a live peer loses addressability the daemon closes its open inbound asks with reasonpeer_not_addressable, drops its queued deliveries, notifies each asker, and records onepeer_not_addressableevent with the counts. Durable replay obeys the same gate: the WebSocket flush-on-connect andGET /deliveries/pendingcheck the live verdict, replay nothing to a non-addressable peer, drop whatever is still queued (dropped_not_addressablein the drain response), and record the drop, so a row queued before demotion can never land after it. IncludesGET /peers/{id}/doctor(read-only diagnostic report with contradiction detection) andPOST /peers/{id}/rehook(non-destructive inbound ws-hook recovery, same-host, dry-run by default).POST /peers/{id}/restart({fresh, dry_run, message, wait, circle, from_peer};waitdefaults to true) stops and relaunches the peer with resume and always answers 200 with a typed result (outcome,failed.stage,would_run, ...); only an unknown or ambiguous peer or missing spawn wiring is an HTTP error.GET /peers/{id}/restartreturns the latest result;DELETE /peers/{id}/restartcancels an in-flight one. Every stage is journaled with itsrestart_id(peer_restart_started,peer_restart_launched,peer_restart_restarted,peer_restart_failed,peer_restart_offline_ignored); commands in results and the journal redact every value except the daemon-supplied resume argument, listed permission words, and model ids from the daemon's spawn config.POST /peers/{id}/offlineaccepts optionalpane_idandagent_pid; a post whose pane and pid both match an execution a restart replaced is ignored (in memory, until the daemon restarts).GET /peers/{id}includes arestartblock (restartability preview and last result).POST /peers/{id}/offlineaccepts an optional body{reason, source, detail, terminal}recording the truthful cause in the event log (e.g.session_end,agent_exited,pane_takeover).terminal: trueretires the peer: its websocket is severed and reconnects claiming that peer_id are rejected (HTTP 409 / ws errorpeer_retired) unless they carry a liveagent_pid. An operator close (kill_peer,DELETE /peers/{name}) is final: reconnects get HTTP 409 (peer_closedin the detail) or the ws errorpeer_retiredwithfinal: true, whatever proof they carry. An empty body keeps the legacy plain-offline behavior.POST /peers/identity/validatechecks a runtime birth certificate and rehydrates its peer;POST /peers/identity/renew({birth_certificate, backend, path}) exchanges a matching certificate that names a runtime session, expired or not, for a fresh one only while its peer is connected on that same session (409 otherwise). The Codex bridge renews long-lived threads this way.GET /panes/orphanslists local tmux panes not bound to any registered peer (with a display-only backend hint);POST /panes/{pane_id}/linkadopts one — registers the peer AND establishes its inbound ws-hook, rolling the registration back if no live transport connects (fail-closed against ghosts). Driven byrepowire link./ask,/ack,/decline, and/asks/pendingfor ask lifecycle.GET /asks/history?pane_id=|peer_id=&since=RFC3339lists the closed ask threads a peer took part in (as asker or recipient) aftersince, read from the durable trace ledger rather than the in-memory tracker, plus the peer'srepowire_session_id. Backs the git-trailer hook andrepowire why.POST /declinecloses an unhandled ask withclose_reason="declined"and returns the reason to its asker.POST /ackfrom the sender rather than the holder closes what it sent (#732): its own open ask'scorrelation_id(cancelled on the asker's authority;messageis the reason) or its own notice to the human bydelivery_idor inbox item id (resolved). The reply is{ok, closed: "withdrawn"|"resolved"}. Acking someone else's notice is a 403; a notice already answered or closed is a 409. The human's item then carriesresolution,resolved_at,resolved_byandresolution_reason, readsread: true(read_surface: sender, ordaemonfor the daemon's own closes, #733:resolutionexpired,closedorlostwithresolved_by: daemon) andanswerable: false, andinbox_updatednames theresolution; each inbox surface that rendered it gets aninbox_resolvedframe with its own message refs.POST /asks/{correlation_id}/delegate({to_peer, note, from_peer, circle}) hands an open ask to another peer, keeping its correlation id and asker. Afrom_peerthat resolves to a registered peer must be the current recipient (403not_the_recipient). Refusals: unknown target 404, the asker or current recipient 422, a circle or addressability rejection 403/409, a cross-machine ask or target 422, a live job's dispatch ask 409job_ask, a closed ask 410, 8 hops 422. A delivery that fails (503) returns the ask to the delegator. The response is{correlation_id, delegated_to, transport, message_id, delegations: [{from, to, note, at}]};/asks/pendingand/asks/{cid}/waitinclude the samedelegations. After delegation,/ack,/decline, and/answerfrom a former recipient return 409ask_delegated, and two racing replies on one ask deliver once (the other gets 409 or 410).POST /asks/{correlation_id}/waitblocks (bounded, ~50s per call) until the ask is answered or acked, returning a resolution snapshot{status, reply, outcome, close_reason, ...}or{status: "pending"}on timeout with nothing recorded. While a wait is in progress the ask is in pull reply delivery, so a reply is returned to the waiter instead of injected at the asker. When the last wait ends with the ask still open, the ask returns to the delivery it was opened with, and a later reply is pushed to the asker like any message (#719). Backs the MCPwait_on_acktool./answerrecords a typed answer to a structured question;POST /questions/ask-blockingregisters a blocking structured question (tool permission) and holds the connection open until it is answered or the daemon's wait cap elapses, then returns the typed answer (fail-closed: a tool-permission question denies on timeout). Used by blocking transports such as the ACP broker and the Claude CodePreToolUseapproval hook./queryis a legacy blocking compatibility route. It opens a structured text ask through the ask lifecycle, waits for the recipient's answer/ack, and returns the old{text, error, status}response shape for existing clients./inboxroutes read and answer the human inbox./traces/{trace_id}returns the recorded delivery stages for an ask (correlation_id) or notify (delivery_id) from the local delivery trace ledger./messagesreads agent peers' messages by id:GET /messages?peer=Plists P's messages newest first (?unread=1,?limit=N; previews, no bodies; with P'sdeliverymode). Withlimitorcursorit is a page withnext_cursor, as described in Pages,GET /messages/{id}returns one with its body and leaves it unread, andPOST /messages/{id}/readreturns it and marks it read. Either read takes?peer=Pto answer only when P is the recipient.POST /peers/{id}/message-delivery({"mode": "push" | "pull"}) sets a peer's delivery mode.POST /notify,POST /ask, andPOST /asks/{cid}/delegateresponses carry the recipient'smessage_id, and so do thenotify/askWebSocket frames andGET /deliveries/pendingrows. The human's messages are/inboxinstead.GET /wire/threadslists ask and notify threads, newest activity first, as{threads, cursor}. Filters:circle,peer,kind,state,stuck_only=true,since(90m,24h,7d),limit(default 50, at most 100),cursor.GET /wire/threads/{thread_id}returns one thread with itsstages. A thread carriesprotectedandprotected_by(why), andprovenance: each party as the stage that named it recorded it (peer_id,display_name,circle,role,private,unknown), oldest first. A party withknown: falseis gone from the daemon; itsdisplay_nameis the last one its thread recorded, historical and not an address, since another peer may hold that name now. Both are metadata only (no message text) and sit behind the daemon token like/traces(so a local request passes when the token is not required); a badcursororsinceis 422. Seewire_query.POST /wire/threads/{thread_id}/reassign({to, reason}),/nudge({note?}) and/cancel({reason}) are the operator's actions on an open ask (rfcs/wire-actions.md). They require the daemon token asAuthorization: Bearer, with no other way in: no tokenless pass and no local-dashboard pass, and a daemon without a token answers 403. A reassign moves the ask to another peer (never back to a former holder), drops the old holder's queued copies, and tells the old holder and the asker. A cancel closes it, delivers the reason to the asker as the ask's outcome, and tells the holder. A nudge reminds the holder, at most once per 10 minutes per ask (429 otherwise). The reason or note is at most 200 characters. Each returns{correlation_id, action, holder, notified, dropped_queued}. Orchestrators take the same actions over MCP (reassign,nudge,cancel_ask), bound by the protected-thread and circle rules; the operator is not.POST /peers/{name}/wire-visibility({mode: "visible" | "private"}) sets a peer's wire visibility (seeset_wire_visibility). Operator only, with the same token rule as the actions; a peer sets its own over MCP./wsfor live delivery./schedulesfor one-shot and recurring scheduled messages.POST /schedulesresolvesto_peeras a send would: 404 for a peer this daemon has never known (one known only by its durable record, offline, is accepted), 403 across a circle boundary, 409 for an ambiguous name or a target that takes no input. A scheduled send that fails when it fires is reported to its sender as a notify fromrepowire:schedulerand journaled asschedule_failed./jobs/ work routes for durable tracked work./spawncreates tmux-backed peers (an optionalmessageis held, for up to 30 minutes, and delivered as a notify fromfrom_peerwhen the spawned runtime connects on its pane, with a notice tofrom_peerafter 90 seconds;seed_statein the response reportsawaiting_registrationorundeliverable);GET /spawn/configreports whether spawning is enabled, configured commands/profiles, allowed paths, and the activecircle_boundary(sessionorwindow). In window mode the CLI supplies its current pane internally so the daemon can split the peer into that window.GET /swarm/snapshot(experiments.swarm_snapshot; 404 naming the setting when off) returns the read-only swarm manifest described underrepowire swarm. Restore's daemon half, under the same experiment, never touches tmux (the CLI does):POST /swarm/plantakes a manifest and returns each pane, in its place, aslaunch(the agent's registered path and its backend's resume command, with the permissions recorded at snapshot time) orshellwith askipreason. Agents that are online, closed by an operator, a live job's executor, whose session is bound to another peer, without a resumable session file, or with unmodeled permissions are never relaunched. The plan carries aplan_id, valid for 30 minutes in this daemon's memory.POST /swarm/placed({plan_id, pane_id, peer_id, tmux_session}) records a pane the CLI launched as spawn records one, from the daemon's own mapping, and only for an issued plan's launch slot, once, with the pane in the session and window the plan gave it: an ownership record is kill and restart proof.POST /swarm/verify({placed}; Codex is read from the daemon's own record of the backend) reports each agent asback,twin(another identity in its pane),awaits_first_turn(Codex) ormissing; it never rebinds.POST /peers/{id}/fork-backendnon-destructively starts an agent-role sibling on another configured backend in the source peer's project and circle. The source stays live and its backend-native conversation history is not copied./attachmentsfor upload and download./dashboardfor the static dashboard bundle.
Jobs Execution Policy¶
POST /jobs accepts process_scope and continuity for path/backend durable
jobs. Unassigned path/backend jobs default to process_scope=per_fire, so each
run uses a daemon-spawned or backend-resumed executor process that is released
after terminal completion. Reused persistent executors and explicitly assigned
peers are not killed by per-fire cleanup. One-shot jobs default to
continuity=fresh; recurring jobs default to continuity=resume, so the next
fire resumes backend-native runtime context when a runtime session id is
available. Use continuity=fresh to avoid backend resume.
Jobs State Semantics¶
Fire completion is structural: dispatch asks come from the built-in @jobs
service peer, the daemon arms the fire when the executor's prompt turn is
observed (running / phase turn_started), and the executor's next assistant
turn completes it with the final message as result_summary. Executor death
(terminal peer offline or daemon-restart reconcile) fails in-flight fires with
executor_died. Only the runner's dispatching phase is lease-bounded —
delivered fires are never reaped by a wall clock. Every state transition
emits a job_state_changed event, and terminal states best-effort notify the
owner (owner → creator → circle orchestrator). PATCH /jobs/{id} remains
available for progress enrichment and the explicit hold-open escape hatch.
Jobs List Views¶
GET /jobs returns the full durable-work list by default. Dashboard-style clients that only need row data can use:
The summary view keeps the same { "work": [...], "recurring": [...] } envelope and preserves ids, state, timestamps, ownership/routing fields, result summaries, and trimmed execution target/delivery metadata. It omits heavier detail fields such as full requests, provenance, runner state, prompt bodies, and progress history. Fetch GET /jobs/{id}/status for the selected job or recurring cal-* template when full detail is needed.
Pages¶
The list is complete unless the request asks for a page. A request with limit or cursor gets one page, newest first by updated_at (ties broken by id), and a next_cursor:
GET /jobs?view=summary&limit=100
GET /jobs?view=summary&limit=100&group=attention
GET /jobs?view=summary&limit=100&cursor=<next_cursor>
limit: 1 to 500, clamped; a value that is not a number means 100. With onlycursor, the page holds 100.cursor: thenext_cursorof the previous page; opaque. A malformed one is a 400.next_cursor: on every paged response,nullon the last page. A daemon that does not page ignoreslimitand returns the complete list without this key, so clients check for the key, not its value.group(paged requests only, not together withstate) selects a list view. The dashboard tabs use these groups:
group |
Work states | Recurring entries |
|---|---|---|
all (default) |
all | all |
attention |
failed, unavailable |
none |
active |
not terminal | not cancelled |
recurring |
none | all |
closed |
completed, cancelled, expired |
cancelled |
stateon a paged request filters as it does on the complete list.recurringentries are not paged. They come only on a page withoutcursor.- A page is a live view: a job updated while a client pages moves to the top and shows up on the next refresh.
GET /inbox and GET /messages page the same way: limit (default 50), cursor and next_cursor, newest first by (created_at, id). Without limit or cursor they return the newest 50 as before, with no next_cursor.
The design is in rfcs/bounded-lists.md.
Message text limit¶
A message is at most 64,000 bytes of UTF-8 text, everything its sender wrote taken together. That is the same limit relay MCP applies. It covers:
- the text of a notify, an ask (with its structured question) and a broadcast;
- an ack, an answer, and a decline's or cancel's reason;
- a delegation's note, each
ask_manytext and an inbox reply; - a schedule's text, a job's prompt (inline, from
prompt_file, or its title) and a spawn's opening message.
A longer message is refused before anything is recorded or sent:
HTTP/1.1 413 Request Entity Too Large
{"detail": "message text is 90000 bytes; the limit is 64000. Split it, or attach the rest as a file.", "limit": 64000, "size": 90000}
A JSON request body over 1 MiB, on any control route and on /mcp, is also a 413. Chat events (/events/chat, /events/chat_delta) are not messages and are not refused for length.
- The sender bounds each post to 1 MiB of JSON. The senders are the Stop hook, the streaming poster and the codex bridge. A longer post keeps the head of
textand as manytool_callsas fit, and is marked: text_truncated: truewithtext_bytes, the original length;tool_calls_omitted, the number dropped.
The chat_turn and chat_turn_delta events carry the same marks, so a cut turn never looks complete. The transcript file keeps the full turn. A durable job's turn is never long enough to be cut, so job completion always sees its markers.
- The daemon reads a chat body as one JSON value of up to 16 MiB. It answers 413 only above that, and 422 for anything malformed or trailing.
- The hooks log any post the daemon does not accept (POST /events/chat: daemon answered …).
The design is in rfcs/text-limits.md.
Who wrote a transcript turn¶
GET /peers/{peer}/transcript, GET /peers/{peer}/timeline and timeline search
(/timeline/search) return each user turn with a provenance object. The
daemon reads its own delivery envelopes back, so clients need not parse the text.
The design is in rfcs/transcript-provenance.md.
"provenance": {
"sender": {"kind": "peer", "name": "orchestrator-claude-code", "peer_id": "repow-1-1915fb4c"},
"verified": true,
"message_kind": "ask", "message_id": "msg-53b7d6a1", "correlation_id": "ask-703aac08",
"delivered_as": "push",
"body": "Run the gates & push",
"attachments": [{"id": "att-1", "filename": "plan.pdf"}]
}
sender.kind:
- peer: another agent.
- human: the human, through the mesh; surface is set when the record names
one.
- terminal: typed into the session itself.
- system, with a system_kind:
- compaction;
- task_notification;
- meta (skill bodies, local caveats);
- recall (an old in-body recall block).
- unknown: anything else, such as a message from another producer in the
runtime's inbox, or a live-only timeline row.
How a turn is classified. From the runtime's own fields, never from what the
text says. For Claude Code these are origin.kind, isMeta and
isCompactSummary; for Codex, whether the item carries the daemon's envelope.
Every transport delivers the same envelope: the hooks (Claude Code's inbox,
origin.kind: peer), the codex bridge, ACP prompts and the experimental channel (origin.kind: channel, inside the
runtime's <channel> element). Claude Code marks a prompt that starts with
a peer envelope peer by reading its text, which is how an ACP delivery
appears; that label is not authentication. A turn is bound to its sender only
by the record check below. An ask over ACP carries no ack(…) line, since
the prompt's reply answers it, and verifies without it.
verified: true means the envelope's message id names a stored message, and
the envelope carries exactly that message's wire body:
- the message itself (delivered_as: push); or
- its pull pointer (delivered_as: nudge). In that case body is the pointer,
and the full text is fetched by message_id.
Otherwise the sender is the envelope's own claim, and clients should show it as
unverified. For an ask in the peer form, body drops the router's trailing
↳ ack(…) or ↳ answer(…) line when it names that envelope's own
correlation-id. A human line carries no type or ask id, so its body is shown
as delivered, hint included, until it verifies. That covers older history without ids, an expired record, or an
edited body.
Field present means a current daemon. On a current daemon every user turn
carries provenance, so a missing field means an older one. The human's
message line now carries its id as well: @telegram → @backend [msg-…]: text.
Auth¶
When daemon.auth_token is configured, clients send:
The dashboard served from the daemon's localhost origin is the exception: its same-origin browser requests are accepted without exposing the token to JavaScript.
Peer lifecycle¶
DELETE /peers/{name-or-id} is the explicit operator-close route used by the
dashboard's Unregister peer action and the CLI. It resolves the target to an
immutable peer_id, records a hard retirement tombstone, and removes it from the
registry. A still-running bridge cannot reclaim that closed identity. A peer
whose execution a container plug owns is stopped through the plug first, as
kill_peer does; if that stop fails the route answers 500 kill_failed and the
peer stays registered.
POST /peer/unregister is intentionally non-terminal. Transport and service
clients use it to drop a registration before reconnecting the same session.
Viewing a peer's pane¶
A read-only view of a peer's tmux pane (#665, step 1). Owner auth only: share links never reach it. Typing into a pane is not part of this.
GET /peers/{name-or-id}/panereturns{pane_id, cols, rows, captured_at, text}. The text is the visible screen, exactlyrowslines joined by\n, with SGR colour (ESC[…m) kept and every other control removed. tmux trims trailing blanks within a line.GET /peers/{name-or-id}/pane/streamis the same as server-sent events. Eachdata:frame is a snapshot: the first at once, then one whenever the screen changes. The pane is captured only while the stream is open, at most every 500 ms, with a: keepalivecomment every 15 s. A failure arrives as one{error, hint}frame, then the stream closes. At most 8 streams are open at once; the next gets 429too_many_viewers.
Every view proves pane ownership as kill and restart do, and captures the
proven pane. A screen is shown only if the pane's root process, read just
before and just after the screen, is the one the proof checked; otherwise the
view proves the pane again, and a snapshot that still cannot be bound answers
409 pane_changed. A stream also proves the pane again every 10 s. A refused
view answers {error, hint}:
- 404: peer_not_found, missing_pane;
- 409: ambiguous_peer, cross_host, and the proof's codes (pane_not_live,
pane_metadata_mismatch, missing_pane_metadata, pane_metadata_stale,
agent_not_in_pane, and the durable-ownership codes);
- 413: too_large (over 500 × 200 cells or 256 KiB);
- 502: tmux_failed.
Each snapshot, and each stream when it opens, writes a pane_viewed delivery
trace row (kind pane) with the peer, the pane, the mode and the outcome. Its
principal is what the daemon can prove: local_dashboard, or token (the
daemon token, whether the owner's app through the relay or a local agent). It
does not claim to know who looked.
Through the hosted relay the snapshot is an ordinary tunneled GET. The stream needs the relay to tunnel it, which comes with a relay release.
Related¶
Human inbox¶
POST /notify and POST /ask accept a name@machine address for a peer on another machine in a shared circle (circles across machines). A remote notify answers 200 with delivery_state delivered, queued (held for the peer's next turn), uncertain (outcome unknown, never resent) or not_delivered (the other machine refused it), and its delivery_id, which /traces/{id} shows; an unknown remote peer is 404 and attachments are 422. POST /broadcast adds remote_sent, remote_queued, remote_failed and remote_uncertain (name@machine lists), and partial (machines that did not answer, omitted when empty), when cross-machine circles are on and the sender is a registered peer in a shared circle; exclude and bypass_circle apply to local peers only.
Messages to the human peer (its name, telegram, or slack) are stored in the human inbox. POST /notify to it adds inbox_item_id and surfaces to the response. It also accepts an optional correlation_id, an ask between the sender and the human that the notify reports progress on. The item is filed under that ask's thread while the ask is open and the sender asked it or holds it, and the response then carries thread_id. Otherwise it is filed unthreaded and thread_id is omitted. The notify never answers, acks or closes the ask. A correlation_id on a notify to anyone else is 422 thread_not_human, and on a name@machine address it is 422; POST /ask to it adds inbox: {item_id, surfaces}. POST /ask accepts an optional origin: {surface, ref} naming the surface message an ask from the human was typed in, so the reply threads under it.
| Route | Purpose |
|---|---|
GET /inbox?unread=1&limit=N |
Inbound items, newest first, with per-surface pushes (surface, status, surface_ref). With limit or cursor (and no surface), it is a page with next_cursor, as described in Pages. Returns {human, human_peer_id, items, surfaces} (surfaces: each surface's presence, with quiet, quiet_until and held under quiet hours). A push status is pushed, failed, held (waiting for the surface's quiet hours to end), releasing or skipped (released after the human had handled it). surface=S keeps items successfully pushed to S, listed in S's delivery order (newest rendered first, by numeric ref) rather than creation order; with it, through_ref=N keeps those whose first message on S has a numeric ref at or below N (Telegram message ids, which grow with every message in a chat). A surface's list is not paged: it has no next_cursor, and cursor with surface or through_ref is a 400. needs_reply=1 lists every ask that waits on the human instead: unreplied, still answerable by the human (answerable: true), read or not, newest first and unpaged; it takes no limit, cursor, unread or surface (400). Open asks survive a daemon restart (schema 23), so they stay on this list, except blocking questions such as tool permissions, which settle within a minute. |
GET /inbox/{id} |
One item. An item the human answered carries replied_at, reply_surface (api when the answer came through /answer or /ack directly), reply_text (their words, or the chosen option's title) and, for an option answer, reply_option_id. Items answered before schema 21 have no reply_text. |
POST /inbox/{id}/read |
{surface}. Marks the item read for every surface (idempotent). |
POST /inbox/{id}/reply |
{surface, text, option_id?, ref?, answer_only?}. On an open ask: acks it with text (or answers a structured question). Otherwise opens a new ask from the human to the item's sender. Returns {action: acked\|answered\|asked\|read, correlation_id}. An empty text on a non-ask only marks it read. With answer_only: true, the item must hold an ask the human can answer now with this reply (text alone does not answer a choice), or point at one (below), or it is a 404 and nothing is sent; /inbox/reply then takes only the item rendered as that exact surface_ref. |
POST /inbox/reply |
Same, finding the item by {surface, surface_ref} (for example a Telegram reply-to). 404 when no item was rendered as that ref. |
All routes return 503 when no human peer is registered.
Inbox surfaces connect over /ws with capabilities: ["inbox_surface"]. The daemon pushes {type: "inbox_item", delivery_id, item, reply_to_ref}. The surface answers with {type: "delivery_ack", delivery_id, status: "pushed", surface_ref, surface_refs} or {..., status: "failed", error_class}. surface_ref is the first message rendered and anchors later replies on the thread; surface_refs lists every message rendered (a long item is split), and a failed push still lists what was sent, so a reply to any of them finds the item. A bridge without the capability gets the item as a plain notify/ask frame, which proves only the socket write (verified: false).
The dashboard is a surface without a socket of its own. GET /events/stream?surface=dashboard marks the stream as the dashboard: the dashboard is live while one such stream is open, and a push to it is receipted (surface_pushed, surface: dashboard) once a stream has flushed the item's inbox_item event. The event stream carries inbox_item (item_id, kind, from, from_peer_id, correlation_id) and inbox_updated (item_id, read, replied, surface), never the text; the dashboard reads the item from GET /inbox. Relay share streams never carry inbox events.
GET /events/stream?since=<event id> resumes a stream. Its first batch is only the events after that one, as with GET /events?since. An id the daemon no longer holds returns the whole window, so nothing is skipped; drop events already seen by id. Through the hosted relay a stream is closed after an hour at most, and a client reopens it with since set to the last event it received.
Reply links¶
POST /ask and POST /notify (and the MCP ask and notify_peer tools) accept an optional in_reply_to: the id of the message this one answers, such as a message_id (msg-...), an inbox item id (inb-...), an ask's correlation_id or a turn id. For an agent's message the daemon stores it as given and never resolves it (the human's replies are the exception below); it is at most 128 bytes with no whitespace (else 422), and it closes nothing (reply_to on an ask is what closes a prior thread). It is returned as in_reply_to on GET /messages and GET /messages/{id}, on inbox items, and in a user turn's provenance in the transcript. A human's reply to an inbox item that opens a new ask links back to that item on its own. Cross-machine sends do not carry it. One exception (#734): when the human sends POST /ask with in_reply_to naming an open ask they hold, or a note from that ask's asker that points at it, and to_peer is omitted or names that asker, the message answers that ask instead of opening one. The response is then {correlation_id: <that ask>, answered: "acked"|"answered"}.
A message from the human also records where it was sent from, as surface on GET /messages and GET /messages/{id} (schema 23): the ask's origin.surface when one is given (an inbox reply passes its own), otherwise the surface bridge it came through (telegram, slack). Names are stored as sent, so ios and dashboard may appear. It is empty for agents, for the human addressed by name, and for messages from before schema 23.
Pull-delivery asks¶
POST /ask accepts optional reply_delivery: "pull" (default "push"). Pull
mode is set before delivery so an immediate recipient reply is retained for
POST /asks/{correlation_id}/wait, whether the recipient acks or an ACP
runtime answers on the daemon's side (a runtime failure closes the ask as
send_failed with the error as its reply). Callers without a registered peer may list
their outstanding asks with GET /asks/pending?peer_id=<sender>&direction=outbound.
The wait endpoint still requires the original sender identity.
The reply is also recorded as a reply message to the asker, unread and never pushed, so an asker that stopped waiting reads it in full with GET /messages/{id} (or read_message); it carries the ask's correlation_id. A reply message's text is the reply body (a decline reads Declined: <reason>). The [ack #cid from @x] frame is only on the wire, and its facts are the message's kind, correlation_id and from. For a cross-machine ask it is recorded on the asker's machine when the result settles there.
GET /health advertises capabilities.ask_pull_delivery when ask handling is wired.
Targetless asks and routing¶
to_peer names the recipient. Under the default routing.strategy: static, an ask must name one. If the to_peer key is left out, the ask is refused with 400 {"error": "no_target", "hint"}, and nothing is registered or recorded.
When routing.strategy names an arm, an ask with no to_peer key is routed: the arm picks the recipient, and the pick is authorized like a named target. Optional fallback_to names the peer used if the arm fails or its pick is refused. A strategy never delivers to a service- or human-role peer unless routing.allow_service_targets is set. A fallback_to naming one returns 403 {"error": "service_excluded", "peer", "role", "hint"}. The response adds routing: {arm, routed_to, routed_to_peer_id, confidence, fallback, fallback_reason}. A routing failure with no fallback_to returns 503 {"error": "router_unavailable", "arm", "reason", "hint"}, and nothing is registered or delivered.
Only an absent key routes. "to_peer": "", whitespace and "to_peer": null are named asks to nobody. They return 404 Unknown peer: … under every strategy, as before. Keys match case-insensitively, as JSON decoding always has, so TO_PEER names a target. A key that only resembles to_peer (for example toPeer or to-peer) is rejected with 400, so a misspelled target never routes. A named ask is never rerouted, and responses to named asks carry no routing key. @route is an ordinary name. See routing.
The hosted relay has a separate OAuth-authenticated MCP surface;
it does not tunnel the daemon's administrative /mcp endpoint.