docs/agent-api/jsonl-api.html

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>EzAgent typed JSONL API reference</title><style>
:root{color-scheme:dark;--bg:#0d1319;--panel:#151d26;--panel2:#1b2530;--line:#2b3947;--text:#e7edf3;--muted:#9eacba;--accent:#69d2ff;--req:#9ed477;--sys:#f0ac72;--fnf:#c5a3ff;--bad:#ff8797}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--bg);color:var(--text);font:14px/1.55 system-ui,-apple-system,Segoe UI,sans-serif}code,pre{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}.top{position:sticky;top:0;z-index:20;display:flex;gap:10px;align-items:center;flex-wrap:wrap;padding:10px 16px;background:rgba(21,29,38,.97);border-bottom:1px solid var(--line)}.brand{font-weight:750}.count{color:var(--muted);font-size:12px}.grow{flex:1}.filters{display:flex;gap:5px}.filters button,.menu{border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--muted);padding:5px 10px;cursor:pointer}.filters button.active{background:var(--accent);border-color:var(--accent);color:#071017}.search{width:min(260px,55vw);padding:7px 10px;border:1px solid var(--line);border-radius:7px;background:var(--bg);color:var(--text)}.menu{display:none;border-radius:7px}.shell{display:grid;grid-template-columns:300px minmax(0,1fr);min-height:calc(100vh - 52px)}aside{position:sticky;top:52px;height:calc(100vh - 52px);overflow:auto;padding:14px;background:var(--panel);border-right:1px solid var(--line)}aside h2{font-size:11px;text-transform:uppercase;letter-spacing:.1em;color:var(--muted)}aside a{display:block;padding:5px 8px;border-radius:5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}aside a:hover{background:var(--panel2);color:var(--text);text-decoration:none}main{width:min(1100px,100%);padding:30px clamp(16px,4vw,50px) 80px}.hero,.guide,.schema-intro{padding:24px;border:1px solid var(--line);border-radius:12px;background:var(--panel);margin-bottom:22px}.hero h1{margin:0;font-size:clamp(27px,4vw,43px)}.hero p{max-width:850px;color:var(--muted)}.stats{display:flex;gap:8px;flex-wrap:wrap}.pill,.tag{display:inline-block;border:1px solid var(--line);border-radius:999px;padding:3px 8px;font-size:12px}.guide h2,.schema-intro h2{margin-top:0}.guide-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.guide-grid section{padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--panel2)}.guide-grid h3{margin:0 0 5px;font-size:14px}.guide-grid p{margin:0;color:var(--muted)}.message,.schema{scroll-margin-top:72px;border:1px solid var(--line);border-radius:12px;background:var(--panel);margin:0 0 18px;overflow:hidden}.message[hidden],.schema[hidden],.schema-intro[hidden]{display:none}.head{padding:20px 22px;border-bottom:1px solid var(--line)}.head h2{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:0;font:700 21px ui-monospace,SFMono-Regular,monospace}.wire{color:var(--accent)}.role{font:12px system-ui;color:var(--muted)}.syn{margin:9px 0 0;color:var(--muted)}.meta{display:flex;gap:7px;flex-wrap:wrap;margin-top:10px}.tag.req{color:var(--req)}.tag.sys{color:var(--sys)}.tag.fnf{color:var(--fnf)}.body{padding:20px 22px}.direction{padding:9px 11px;border-left:3px solid var(--accent);background:var(--panel2);margin-bottom:16px}.table-wrap{overflow-x:auto}table{width:100%;border-collapse:collapse;min-width:760px}th,td{padding:8px 9px;border:1px solid var(--line);text-align:left;vertical-align:top}th{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);background:var(--panel2)}td code{color:var(--accent)}.encoding,.validation{white-space:nowrap}.optional{color:var(--muted)}.required{color:var(--req)}.contextual{color:var(--sys)}.cols{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px;margin-top:17px}.box{min-width:0}.box h3{margin:0 0 7px;font-size:13px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}pre{margin:0;padding:13px;overflow:auto;border:1px solid var(--line);border-radius:8px;background:#080d12;color:#dce8f2;font-size:12px}.reply{padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--panel2)}.links{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}.links a{border:1px solid var(--line);border-radius:5px;padding:2px 6px;font-family:ui-monospace,monospace}.notes{margin:15px 0 0;padding-left:20px}.notes li{margin:5px 0}.schema-intro{margin-top:36px}.empty{display:none;padding:30px;color:var(--muted)}footer{color:var(--muted);padding-top:20px}.schema-ref{color:var(--accent)}@media(max-width:840px){.menu{display:block}.shell{grid-template-columns:1fr}aside{display:none;position:fixed;z-index:15;top:52px;left:0;width:min(330px,90vw);height:calc(100vh - 52px);box-shadow:8px 0 30px #000}aside.open{display:block}.cols,.guide-grid{grid-template-columns:1fr}main{padding-top:20px}}@media(max-width:520px){.top{align-items:stretch}.brand{width:100%}.grow{display:none}.search{flex:1;width:auto}.filters{order:3;width:100%;overflow:auto}.head,.body,.hero,.guide,.schema-intro{padding:16px}main{padding-left:10px;padding-right:10px}.count{display:none}}@media print{.top,aside{display:none}.shell{display:block}main{width:100%;padding:0}.message,.schema,.guide,.hero{break-inside:avoid;background:white;color:black}body{background:white;color:black}pre{white-space:pre-wrap;color:black;background:#f5f5f5}}
.addon-intro{padding:24px;border:1px solid var(--line);border-radius:12px;background:var(--panel);margin-bottom:22px}.addon-intro h1,.addon-intro h2{margin-top:0}.addon-intro h1{font-size:clamp(27px,4vw,43px)}.addon-intro h2{font-size:19px}.addon-intro>p{max-width:850px;color:var(--muted)}.intro-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.intro-grid section{padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--panel2)}.intro-grid h3{margin:0 0 5px;font-size:14px}.intro-grid p{margin:0;color:var(--muted)}.shortcut-links{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0 0}.shortcut-links a{border:1px solid var(--line);border-radius:5px;padding:2px 6px;font-family:ui-monospace,monospace}@media(max-width:840px){.intro-grid{grid-template-columns:1fr}}@media(max-width:520px){.addon-intro{padding:16px}}@media print{.addon-intro{break-inside:avoid;background:white;color:black}}
</style></head>
<body><header class="top"><button class="menu" id="menu" type="button">Contents</button><div class="brand">EzAgent JSONL API <span class="count">canonical typed-wire reference</span></div><div class="grow"></div><div class="filters" aria-label="Interaction filter"><button class="active" data-filter="all">All</button><button data-filter="req">RPC</button><button data-filter="sys">Capability exchange</button><button data-filter="fnf">Events / one-way</button></div><input class="search" id="search" type="search" placeholder="Search frames, fields, and schemas…" aria-label="Search frames"><span class="count" id="shown"></span></header>
<div class="shell"><aside id="nav" aria-label="Catalog navigation"></aside><main><section class="addon-intro" id="addon-mesh"><h1>EzAgent typed JSONL wire API</h1><p>This is the complete interactive wire reference for addon authors and other protocol peers. For API selection, start at <a href="index.html">the API hub</a>; for frame ownership and validation, see <a href="../pkg/protocol.md">protocol</a>; for typed startup, dispatch, and RPC helpers, see <a href="../pkg/ezagentapi.md">ezagentapi</a>; for project-wide documentation routing, see <a href="../index.md">the docs index</a>.</p><h2>What mesh am I joining?</h2><div class="intro-grid"><section><h3>Peers and transports</h3><p>The service connects clients and the TUI over its Unix socket, and connects external tools, plugins, and macros over direct-process stdio. The typed frame contract is the same on either transport. Provider-internal model streams are outside this API.</p></section><section><h3>How does my peer become ready?</h3><p>Start with <a href="#hello">hello</a> and <a href="#hello_ack">hello_ack</a>, then exchange normal frames; capability declaration and metadata are separate routing inputs. <a href="../pkg/jsonlpipe.md">JSONL framing</a> owns complete newline-delimited frames, not remote execution order. Correlate replies by <code>request_id</code> or the operation-specific call ID, never stream order.</p></section><section><h3>Implement a client or TUI</h3><p>Send a prompt and consume lifecycle events.</p><div class="shortcut-links"><a href="#prompt">prompt</a><a href="#prompt_accepted">prompt_accepted</a><a href="#message_update">message_update</a><a href="#prompt_completed">prompt_completed</a></div></section><section><h3>Implement a capability provider</h3><p>The daemon calls providers; provider IPC results are distinct from later client-facing events. Working provider examples: <a href="../cmd/ez-agent-builtin.md">builtin capabilities</a> and <a href="../cmd/ez-agent-hello.md">the hello capability</a>.</p><div class="shortcut-links"><a href="#tool_call">tool_call</a><a href="#tool_ack">tool_ack</a><a href="#heartbeat">heartbeat</a><a href="#tool_abort">tool_abort</a><a href="#tool_result">tool_result</a><a href="#plugin_call">plugin_call</a><a href="#plugin_result">plugin_result</a><a href="#macro_call_ipc">macro_call_ipc</a><a href="#macro_result_ipc">macro_result_ipc</a><a href="#macro_info_request">macro_info_request</a><a href="#macro_info_response">macro_info_response</a></div></section><section><h3>Read stored attachments</h3><p>Fetch byte ranges on demand, with two requests in flight. Match replies by request ID and assemble bytes by offset, not arrival order. EOF may arrive before earlier ranges.</p><div class="shortcut-links"><a href="#get_attachment_chunk">get_attachment_chunk</a><a href="#attachment_chunk">attachment_chunk</a><a href="#schema-FileMeta">FileMeta</a></div></section><section><h3>Report progress</h3><p>Describe in-flight work to clients.</p><div class="shortcut-links"><a href="#report_progress">report_progress</a><a href="#leaf_updated">leaf_updated</a></div></section></div><h2>Extension contracts</h2><p>Versioned payload conventions ride these generic frames; they are not additional JSONL frame sets. See <a href="ruby-workflow-0.1.html">Ruby Workflow 0.1</a> for workflow descriptors and macro/progress payloads, and <a href="ez-agent-csv.html">EzAgent CSV</a> for its reply-row encoding. Provider-owned <code>tunnel.llmprovider.&lt;provider&gt;</code> macros use the approved <a href="../internal/provider-exports.md">IFO/LIST/INIT/START application payload contract</a> over existing macro frames and tunnelpipe streams. The export namespace is reserved against inbound capability supply; no new outer frames or fields are introduced. Minimal setup clients use hello/hello_ack, unfiltered list_macros and exact validated per-provider IFO/LIST calls, never leaf creation or inference. Catalogs describe availability, not automatic model selection. Model entries may include an optional <code>access_source</code> from host-known authentication metadata. Version-1 consumers ignore unfamiliar fields; absence from an older host preserves remembered leaf information. Discovery does not start a bridge or refresh credentials. Existing leaf-property APIs expose <code>model_max_context</code> and <code>model_access_source</code>, with <code>model_info_ref</code> and <code>model_info_model</code> identifying the selection and resolved route. See the <a href="../cmd/ez-agent-configurator.md#remote-provider-hosts">configurator workflow</a>.</p></section><section class="hero" id="catalog-scope"><h2>Catalog scope</h2><p>Every current typed EzAgent JSONL frame visible to socket, stdio, client, frontend, tool, plugin, or macro peers. Provider-internal model streaming formats are excluded. Each frame is one JSON object followed by a newline. Navigation identities are role-qualified where one wire discriminator has multiple shapes or directions.</p><p>AgentHub's same-user administration socket has a separate <a href="../internal/agenthub-local-control.md#frozen-private-configuration-contract">private configuration contract</a>. Its configuration includes <code>limits.circuit_admission</code> with required positive int64 <code>global</code>, <code>per_client</code> and <code>per_endpoint</code> policy values, plus the closed resource table. Protected YAML omission defaults each policy to 524,288; complete private objects supply all three. The global policy bounds separate process-wide logical circuit and adapter counters, not storage dimensions. Entry and origin count as logical circuit owners; transit forwarding does not. Shared physical connection admission precedes TLS; identified client and Hub roles have separate configurable budgets. Supported defaults are not universal ceilings, startup allocations or RSS guarantees. See the <a href="../internal/agenthub-config.md#supported-configuration">configuration contract</a> and <a href="../internal/agenthub-service.md#production-capacity-ownership">production ownership map</a>. These are not EzAgent application frames or fields. This catalog and the application JSONL lifecycle remain unchanged.</p><div class="stats"><span class="pill"><strong>127</strong> unique wire types</span><span class="pill"><strong>132</strong> role-specific entries</span><span class="pill"><strong>30</strong> reusable nested schemas</span><span class="pill">Protocol version 1</span></div></section>
<section class="guide" id="how-to-read"><h2>How to read this reference</h2><div class="guide-grid"><section><h3>Outbound stream iteration (<code>itr</code>)</h3><p>Every top-level frame has a direct integer <code>itr</code> field. Senders assign increasing values in enqueue order for each connection and direction. For <code>leaf_updated</code> snapshots and <code>leaf_stats_response</code> replies for one leaf on one connection, a higher <code>itr</code> cannot represent an earlier capture, including across those two frame types. Both hold the same per-leaf gate through capture and enqueue; the handler releases it after enqueue succeeds or fails, without waiting for remote receipt. That narrow guarantee does not make <code>itr</code> an RPC correlation ID, global revision, RPC execution or completion order, callback order, loss signal, or value comparable across connections or directions.</p></section><section><h3>What do the filter buttons mean?</h3><p><strong>RPC</strong> includes client/module requests and their correlated success or error replies; later lifecycle notifications remain events. <strong>Capability exchange</strong> covers daemon-initiated calls plus provider acknowledgements, watchdog signals, metadata, and final results. <strong>Events / one-way</strong> can travel in either direction; every entry states endpoints explicitly.</p></section><section><h3>Encoding vs validation</h3><p><strong>no omitempty</strong> and <strong>omitempty tag</strong> normally report the literal Go JSON tag. A field note identifies custom encoding, such as the required string form of <code>leaf_stats_response.tip_turn_id</code>. Otherwise omission follows Go zero-value rules. Semantic validation is separate: required, optional, or contextual.</p></section><section><h3>How do I match a reply to my request?</h3><p>Correlated requests use <code>request_id</code>. A success reply repeats it; <code>error</code> with the same ID is the alternate failure response. Typed clients consume matched RPC responses. Go and Ruby discard late unmatched response-only frames, including <code>attachment_chunk</code> and <code>turn_content</code> with a nonempty request ID. Lifecycle and explicit dual-role frames still follow their event path after correlation. Every service-sent unsolicited leaf-scoped frame carries <code>leaf_id</code>. Solicited <code>turn_content</code> is an RPC response. The service's unsolicited <code>turn_content</code> has an empty request ID and a required leaf ID. <code>leaf_switched</code> is only an acknowledgement; <code>leaf_updated</code> carries the state.</p></section><section><h3>Examples and links</h3><p>Every canonical example is stored as an object in the strict JSON catalog and rendered with JSON.stringify, so displayed examples remain valid JSON. Related/reply links target unique catalog IDs only.</p></section><section><h3>Concurrency and acknowledgement barriers</h3><p><strong>What the wire guarantees:</strong> Writers preserve complete JSONL line order, not remote execution order. Service handlers across connections execute concurrently, and per-connection callback work has no public FIFO or happens-before guarantee. Replies may be reordered and unsolicited traffic may interleave.</p><p style="margin-top:10px"><strong>What you must do:</strong> For general dependent commands, await the correlated success or error for command A before sending command B; write order and a successful local write are not execution barriers. The narrow exception is connection-default capture around update_cwd: requests capture the applicable default in client send order without waiting for its acknowledgement. Their execution and completion may still overlap or finish out of order.</p></section></div></section>
<div id="empty" class="empty">No frames match this filter.</div><section id="messages" aria-label="Wire frames"></section><section class="schema-intro" id="nested-schemas"><h2>Reusable nested schemas <span class="count" id="schema-shown"></span></h2><p>Custom objects referenced by top-level frames are defined once below. Their field order, Go shape, and JSON tags use the same conventions as frame tables.</p></section><section id="schemas" aria-label="Nested object schemas"></section><footer>Source-backed documentation for the current typed EzAgent API. Surprising current behavior is described neutrally; this page does not define or change implementation behavior.</footer></main></div>
<script id="agent-api-catalog" type="application/json">{
  "meta": {
    "wire_type_count": 127,
    "entry_count": 132,
    "scope": "Every current typed EzAgent JSONL frame visible to socket, stdio, client, frontend, tool, plugin, or macro peers. Provider-internal model streaming formats are excluded.",
    "validated_against": [
      "pkg/protocol/*.go",
      "pkg/ezagentapi/dispatch.go",
      "pkg/ezagentapi/rpc.go",
      "pkg/ezagentapi/startup.go",
      "pkg/ezagentapi/operations.go",
      "pkg/ezagentapi/service_operations.go",
      "pkg/ezagentapi/server_outbound.go",
      "pkg/service/server.go",
      "pkg/service/attachment_chunk.go",
      "pkg/service/session/attachment_chunk.go",
      "pkg/service/ipc.go",
      "pkg/service/progress.go",
      "pkg/service/agent/*"
    ]
  },
  "messages": [
    {
      "id": "update_cwd", "type": "update_cwd", "struct": "UpdateCwd", "source": "pkg/protocol/session.go", "category": "req",
      "synopsis": "Changes the connection default cwd and optionally switches its subscription.",
      "direction": {"from": "client/module", "to": "daemon"},
      "fields": [
        {"name":"type","go_type":"string","json_tag":"always","validation":"required","desc":"Always update_cwd."},
        {"name":"itr","go_type":"int64","json_tag":"always","validation":"optional","desc":"Connection-local sender iteration."},
        {"name":"new_cwd","go_type":"string","json_tag":"always","validation":"optional","desc":"New connection default, accepted under the same rules as hello.cwd, including empty or relative values."},
        {"name":"leaf_id","go_type":"string","json_tag":"omitempty","validation":"optional","desc":"A nonempty existing leaf switches the subscription; omitted or empty leaves it unchanged."},
        {"name":"request_id","go_type":"string","json_tag":"always","validation":"contextual","desc":"Correlation ID echoed in cwd_updated or error."}
      ],
      "example": {"type":"update_cwd","itr":10,"new_cwd":"/workspace/project","leaf_id":"l_0123456789ab","request_id":"req_2"},
      "reply": {"text":"cwd_updated is the sole acknowledgement. Invalid leaf IDs produce a correlated error and change neither cwd nor subscription.","links":["cwd_updated","error-correlated-response"]},
      "related":["cwd_updated","leaf_updated","create_leaf"],
      "notes":["The default does not change a persisted root. A selected leaf's root cwd remains authoritative and may differ from new_cwd.","Requests capture defaults in inbound client order; clients need not wait for acknowledgement. An earlier request retains its old cwd even if it executes after the update. A later request with a higher client itr uses the new default unless explicit or inferred context takes precedence. A subscription switch normally replays leaf_updated and applicable existing replay events, without leaf_switched. If a newer selection or successful drop overtakes a delayed update, the update still changes cwd and is acknowledged but does not replace or replay over that newer selection."]
    },
    {
      "id":"cwd_updated", "type":"cwd_updated", "struct":"CwdUpdated", "source":"pkg/protocol/session.go", "category":"req",
      "synopsis":"Acknowledges the connection cwd update.", "direction":{"from":"daemon","to":"requesting client/module"},
      "fields":[
        {"name":"type","go_type":"string","json_tag":"always","validation":"required","desc":"Always cwd_updated."},
        {"name":"itr","go_type":"int64","json_tag":"always","validation":"optional","desc":"Daemon outbound iteration."},
        {"name":"cwd","go_type":"string","json_tag":"always","validation":"optional","desc":"New connection default."},
        {"name":"leaf_id","go_type":"string","json_tag":"omitempty","validation":"optional","desc":"Requested leaf when supplied and nonempty; a later selection may already have superseded it."},
        {"name":"request_id","go_type":"string","json_tag":"always","validation":"contextual","desc":"Echoed request correlation ID."}
      ],
      "example":{"type":"cwd_updated","itr":8,"cwd":"/workspace/project","leaf_id":"l_0123456789ab","request_id":"req_2"},
      "reply":{"text":"Response to update_cwd.","links":["update_cwd"]}, "related":["update_cwd","leaf_updated"], "notes":[]
    },
    {
      "id":"list_cwd", "type":"list_cwd", "struct":"ListCwd", "source":"pkg/protocol/session.go", "category":"req",
      "synopsis":"Lists distinct persisted root cwd strings.", "direction":{"from":"client/module","to":"daemon"},
      "fields":[
        {"name":"type","go_type":"string","json_tag":"always","validation":"required","desc":"Always list_cwd."},
        {"name":"itr","go_type":"int64","json_tag":"always","validation":"optional","desc":"Connection-local sender iteration."},
        {"name":"request_id","go_type":"string","json_tag":"always","validation":"contextual","desc":"Correlation ID echoed in cwd_list or error."}
      ],
      "example":{"type":"list_cwd","itr":12,"request_id":"req_3"},
      "reply":{"text":"Returns cwd_list or a correlated error.","links":["cwd_list","error-correlated-response"]}, "related":["cwd_list"], "notes":[]
    },
    {
      "id":"cwd_list", "type":"cwd_list", "struct":"CwdList", "source":"pkg/protocol/session.go", "category":"req",
      "synopsis":"Returns unique persisted root cwd strings in lexicographic order.", "direction":{"from":"daemon","to":"requesting client/module"},
      "fields":[
        {"name":"type","go_type":"string","json_tag":"always","validation":"required","desc":"Always cwd_list."},
        {"name":"itr","go_type":"int64","json_tag":"always","validation":"optional","desc":"Daemon outbound iteration."},
        {"name":"cwds","go_type":"[]string","json_tag":"always","validation":"required","desc":"Exact root cwd strings, sorted and deduplicated. Empty results are []."},
        {"name":"cwd_infos","go_type":"[]CwdInfo","json_tag":"omitempty","validation":"optional","desc":"Optional activity summaries aligned one-for-one with cwds in the same order. See CwdInfo for the fields. Older peers may omit this array."},
        {"name":"request_id","go_type":"string","json_tag":"always","validation":"contextual","desc":"Echoed request correlation ID."}
      ],
      "example":{"type":"cwd_list","itr":9,"cwds":["/workspace/project-a","/workspace/project-b"],"request_id":"req_3"},
      "reply":{"text":"Response to list_cwd.","links":["list_cwd"]}, "related":["list_cwd"], "notes":["Includes CWDs with at least one non-temporary leaf with a canonical turn, even if the path is missing or the leaf is unloaded. Temporary leaves, empty leaves, orphan roots and unused connection defaults are excluded."]
    },
    {
      "id": "abort",
      "type": "abort",
      "struct": "Abort",
      "source": "pkg/protocol/agent.go",
      "category": "req",
      "synopsis": "Requests cancellation of active work on a loaded leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"abort\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Existing loaded leaf whose active run should be aborted."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque abort correlation ID. ezagentapi.RPC.Abort generates abort_ plus 16 hex digits and awaits the matching abort_received or correlated error."
        }
      ],
      "example": {
        "type": "abort",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "abort_0123456789abcdef"
      },
      "reply": {
        "text": "The wire service emits abort_received on acceptance or error-correlated-response on rejection. ezagentapi.RPC.Abort returns only after that matching response, context cancellation, timeout, or connection failure.",
        "links": [
          "abort_received",
          "error-correlated-response"
        ]
      },
      "related": [
        "abort_received",
        "error-correlated-response"
      ],
      "notes": [
        "ezagentapi.RPC.Abort registers the request ID before sending and awaits the matching wire response. Unmatched abort_received frames remain available to the event handler.",
        "The service requires an existing loaded leaf with active work. Explicit abort transitions the leaf to aborting and sends tool_abort for pending tool calls while immediately completing their daemon-side pending paths.",
        "Owned background tasks also permit abort when model processing is idle or already terminalizing. A claimed model outcome is not replaced by background-only cancellation. Under the leaf gate, one immutable task/owner/bash-reference snapshot supplies the abort decision, record and cancellation routing; provider delivery occurs outside the gate. The existing synthetic abort record includes cancellation requested and known bash buffer references, without waiting for process exit or invoking the model. Tasks retire active ownership and late bash completion remains suppressed after idle."
      ]
    },
    {
      "id": "abort_received",
      "type": "abort_received",
      "struct": "AbortReceived",
      "source": "pkg/protocol/agent.go",
      "category": "req",
      "synopsis": "Acknowledges that the service accepted an abort request for the leaf.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"abort_received\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the abort frame’s ID; ezagentapi.RPC.Abort uses it to release the matching waiter."
        }
      ],
      "example": {
        "type": "abort_received",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "abort_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to abort; request_id supplies correlation.",
        "links": [
          "abort"
        ]
      },
      "related": [
        "abort"
      ],
      "notes": [
        "ezagentapi.RPC.Abort awaits this matching acknowledgement, while the typed OnAbortReceived event remains available for lifecycle observation."
      ]
    },
    {
      "id": "add_tool",
      "type": "add_tool",
      "struct": "AddTool",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Adds one tool name to a leaf’s active tool selection.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"add_tool\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Tool capability name in this frame’s operation context."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque add_tool correlation ID echoed by tool_added or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "add_tool",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "tool_name": "example.tool",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: tool_added. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "tool_added",
          "error-correlated-response"
        ]
      },
      "related": [
        "tool_added",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "agent_end",
      "type": "agent_end",
      "struct": "AgentEnd",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Signals the terminal end of an agent run with reason and final tip.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"agent_end\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "reason",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Terminal agent-run reason such as stop, error, or abort."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional explanatory text for an error or abnormal terminal run."
        },
        {
          "name": "tip_turn_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Final authoritative leaf-tip turn when one exists."
        }
      ],
      "example": {
        "type": "agent_end",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "reason": "stop"
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [],
      "notes": []
    },
    {
      "id": "agent_start",
      "type": "agent_start",
      "struct": "AgentStart",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Signals that an agent run has started for a leaf.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"agent_start\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        }
      ],
      "example": {
        "type": "agent_start",
        "itr": 1,
        "leaf_id": "l_0123456789ab"
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [],
      "notes": []
    },
    {
      "id": "announce",
      "type": "announce",
      "struct": "Announce",
      "source": "pkg/protocol/lifecycle.go",
      "category": "fnf",
      "synopsis": "Declares tool, plugin, and macro names available through a connection.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"announce\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tools",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Tool names or metadata records, according to Go type."
        },
        {
          "name": "plugins",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Plugin names or metadata records, according to Go type."
        },
        {
          "name": "macros",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Macro capability names provided by this connection."
        }
      ],
      "example": {
        "type": "announce",
        "itr": 1,
        "tools": [
          "run-cmd",
          "buffer"
        ],
        "plugins": [
          "main_systemprompt"
        ],
        "macros": [
          "hello.hello"
        ]
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [],
      "notes": [
        "After registration, the service requests metadata for names that have newly become effective on this connection. A daemon-spawned direct connection combines its launch-configured names with announced names; an overlapping announced name is recorded as that connection's runtime announcement. Self-connecting peers use Announce only. Announce itself carries names, while subsequent info responses supply metadata.",
        "Later announcements can therefore cause tool_info_request, plugin_info_request, or macro_info_request frames for newly effective names; metadata is not limited to names literally present in this frame."
      ]
    },
    {
      "id": "connection_list",
      "type": "connection_list",
      "struct": "ConnectionList",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Returns current connection identities and effective tool, plugin, and macro names.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"connection_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "connections",
          "go_type": "[]ConnectionListEntry",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "All live connection projections, including effective capability names."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_connections request_id; the RPC dispatcher uses it to deliver this connection_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "connection_list",
        "itr": 1,
        "connections": [
          {
            "id": "c_0123456789ab",
            "name": "example",
            "tools": [
              "example"
            ],
            "plugins": [
              "example"
            ],
            "macros": [
              "example"
            ]
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_connections; request_id supplies correlation.",
        "links": [
          "list_connections"
        ]
      },
      "related": [
        "list_connections"
      ],
      "notes": []
    },
    {
      "id": "create_leaf",
      "type": "create_leaf",
      "struct": "CreateLeaf",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Creates a new root/leaf or forks a leaf from an existing source turn.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"create_leaf\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional leaf display name; the service generates a date-based session name when empty."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Canonical provider/model reference applicable to this frame."
        },
        {
          "name": "thinking_level",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Model-specific canonical thinking level after normalization."
        },
        {
          "name": "cwd",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "An explicit cwd creates a root and must satisfy root-cwd validation. If cwd and source_turn_id are both empty, the connection default cwd is used."
        },
        {
          "name": "source_turn_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "The fork point. A nonempty source_turn_id cannot be combined with an explicit cwd."
        },
        {
          "name": "active_tools",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Requested active tool selection; nil/omitted resolves defaults while an explicit empty array selects none."
        },
        {
          "name": "active_plugins",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Requested active plugin selection; nil/omitted resolves defaults while an explicit empty array selects none."
        },
        {
          "name": "tools_explicit",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Makes an omitted/null tool selection explicitly empty."
        },
        {
          "name": "plugins_explicit",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Makes an omitted/null plugin selection explicitly empty."
        },
        {
          "name": "autosubscribe",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "When true, switch the requesting connection feed to the new leaf."
        },
        {
          "name": "is_temp",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Temporary-leaf marker when represented by the current handler."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque create_leaf correlation ID echoed by leaf_created or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "create_leaf",
        "itr": 1,
        "name": "API work",
        "model": "openai/gpt-5",
        "thinking_level": "medium",
        "cwd": "/workspace",
        "active_tools": [
          "run-cmd",
          "buffer"
        ],
        "active_plugins": [
          "main_systemprompt"
        ],
        "tools_explicit": true,
        "plugins_explicit": true,
        "autosubscribe": true,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_created. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_created",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_created",
        "leaf_updated",
        "error-correlated-response"
      ],
      "notes": [
        "An explicit cwd creates a root and source_turn_id creates a fork; supplying both is invalid. When neither is supplied, the connection default cwd creates a root and must pass the existing root-cwd validation. Omitted/null active_tools or active_plugins use resolved configuration defaults unless the corresponding *_explicit flag is true; explicit empty arrays select none.",
        "Fork creation resolves selections and defaults from current configuration; it does not simply clone all parent-leaf configuration.",
        "With autosubscribe true, the daemon selects the new leaf and sends leaf_created as the correlated acknowledgement. If that selection remains current, it then sends a separate complete leaf_updated snapshot. A newer selection or successful feed drop can supersede a delayed autosubscribe. Creation does not send leaf_switched.",
        "is_temp marks a temporary leaf, but temporary leaves are still returned by ordinary list_leaves results. leaf_created includes is_temp when true.",
        "Service-generated root and leaf IDs use r_ and l_ plus 12 lowercase hex digits today, but all identifiers are opaque protocol values."
      ]
    },
    {
      "id": "create_virtual_root",
      "type": "create_virtual_root",
      "struct": "CreateVirtualRoot",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Appends a synthetic virtual-root boundary and optional validated turns to a leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"create_virtual_root\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "reason",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Optional text stored in the synthetic virtual_root turn; empty is accepted."
        },
        {
          "name": "pending_turns",
          "go_type": "[]PendingTurn",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional array; when present every PendingTurn, including optional steer context, must pass storage validation after supported content-reference preflight."
        },
        {
          "name": "metadata",
          "go_type": "map[string]any",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional JSON object, not a JSON-encoded string. Omitted, null, and empty objects add no metadata. Non-object or malformed JSON is rejected. The top-level exit_message key is service-owned and rejected even when null. Stored as serialized JSON in only the synthetic virtual_root turn's other_meta, atomically with the boundary, pending turns, and leaf-tip mutation. Other keys and values are consumer-defined."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque create_virtual_root correlation ID echoed by virtual_root_created or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "create_virtual_root",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "reason": "checkpoint before API reconciliation",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: virtual_root_created. A correlated error echoes the same request_id on failure. Missing leaf_id or invalid boundary metadata, including the service-owned exit_message key even when null, returns parse_error before mutation. Runtime and storage failures remain internal_error.",
        "links": [
          "virtual_root_created",
          "error-correlated-response"
        ]
      },
      "related": [
        "virtual_root_created",
        "error-correlated-response"
      ],
      "notes": [
        "Metadata is an additive optional field with no API version, database schema, or PRAGMA user_version change. Unlike the request's JSON object, returned turn_content.other_meta is a JSON-encoded string. Nil/null and empty metadata preserve the existing empty-object storage behavior.",
        "Manual and automatic builtin compaction send metadata {\"continuation\":true,\"pivot_turn_id\":\"<last source turn summarized>\"}. continuation marks a continuation of source history rather than unrelated replacement context. pivot_turn_id identifies the inclusive end of summarized history, not the first retained turn or generated summary. It does not change the boundary's physical parent, though both IDs can coincide when the whole source was summarized. Consumers interpret these conventions; the daemon does not enforce compaction-specific semantics.",
        "The physical boundary parent remains the old tip, or the old sent tip before a held draft. Pending turns follow the boundary; a held draft keeps its ID and tip role and is reparented once after them. Boundary metadata is not copied onto those turns. Compaction keeps its existing human-readable reason text and adds no version, mode, or anchor metadata."
      ]
    },
    {
      "id": "delete_leaf",
      "type": "delete_leaf",
      "struct": "DeleteLeaf",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Deletes an unused leaf and reports its former tip turn.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"delete_leaf\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque delete_leaf correlation ID echoed by leaf_deleted-response or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "delete_leaf",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_deleted. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_deleted-response",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_deleted-response",
        "leaf_deleted-event",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "delete_leaf_config",
      "type": "delete_leaf_config",
      "struct": "DeleteLeafConfig",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Deletes one opaque leaf configuration key.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"delete_leaf_config\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "key",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque per-leaf configuration key addressed by this operation."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque delete_leaf_config correlation ID echoed by leaf_config_deleted or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "delete_leaf_config",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "key": "example.key",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_config_deleted. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_config_deleted",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_config_deleted",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "drop_feed",
      "type": "drop_feed",
      "struct": "DropFeed",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Unsubscribes the requesting connection from its current leaf feed.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"drop_feed\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque drop_feed correlation ID echoed by feed_dropped or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "drop_feed",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: feed_dropped. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "feed_dropped",
          "error-correlated-response"
        ]
      },
      "related": [
        "feed_dropped",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "effective_config-request",
      "type": "effective_config",
      "struct": "GetEffectiveConfig",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Requests the non-secret effective configuration for a leaf or connection cwd.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"effective_config\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque effective_config-request correlation ID echoed by effective_config-response or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "effective_config",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: effective_config-response. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "effective_config-response",
          "error-correlated-response"
        ]
      },
      "related": [
        "effective_config-response",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "effective_config-response",
      "type": "effective_config",
      "struct": "EffectiveConfig",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Returns the effective non-secret configuration projection.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"effective_config\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "cwd",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Operation working directory; an empty value means no cwd context."
        },
        {
          "name": "config",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque serialized configuration or map of opaque configuration strings, depending on Go type."
        },
        {
          "name": "layers",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Symbolic contributing layer names in precedence order: builtin always, then user and project when their configuration files exist."
        },
        {
          "name": "config_error",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Effective-configuration load error text when the service has one; omitted when clean."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the effective_config-request request_id; the RPC dispatcher uses it to deliver this effective_config-response frame to the waiting call."
        }
      ],
      "example": {
        "type": "effective_config",
        "itr": 1,
        "cwd": "/workspace",
        "config": "defaults:\n  model: openai/gpt-5",
        "layers": [
          "builtin",
          "user",
          "project"
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to effective_config-request; request_id supplies correlation.",
        "links": [
          "effective_config-request"
        ]
      },
      "related": [
        "effective_config-request"
      ],
      "notes": [
        "config is serialized non-secret effective YAML. layers contains symbolic builtin/user/project labels, not filesystem paths; config_error reports a load problem when present."
      ]
    },
    {
      "id": "error-async-event",
      "type": "error",
      "struct": "Error",
      "source": "pkg/protocol/types.go",
      "category": "fnf",
      "synopsis": "Reports an asynchronous, connection-level, one-way, or startup protocol failure without RPC correlation.",
      "direction": {
        "from": "daemon/startup transport",
        "to": "client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"error\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "code",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Machine-readable protocol error code."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Human-readable explanation of the asynchronous or startup failure."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Omitted when no specific RPC request owns the failure; asynchronous handlers commonly send an empty value, which omitempty removes."
        }
      ],
      "example": {
        "type": "error",
        "itr": 1,
        "code": "progress_rejected",
        "message": "progress item \"compile\" is owned by another connection"
      },
      "reply": {
        "text": "No acknowledgement. Handle as an asynchronous protocol/startup error or connection failure.",
        "links": []
      },
      "related": [
        "hello",
        "report_progress",
        "notify_leaf"
      ],
      "notes": [
        "Startup can emit structured not_attached, parse_error, or protocol_mismatch errors before hello_ack. A malformed or unsupported hello closes startup; peers cannot cause an ID collision because the daemon owns connection IDs.",
        "One-way operations such as report_progress and notify_leaf use uncorrelated errors. An error without request_id reaches the protocol-error handler rather than an RPC waiter."
      ]
    },
    {
      "id": "error-correlated-response",
      "type": "error",
      "struct": "Error",
      "source": "pkg/protocol/types.go",
      "category": "req",
      "synopsis": "Returns a request failure to the RPC waiter identified by a non-empty request_id.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"error\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "code",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Machine-readable protocol error code."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Human-readable explanation of why the correlated request failed."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "required",
          "desc": "Non-empty ID of the failed request; the RPC dispatcher routes this error to that request’s waiter."
        }
      ],
      "example": {
        "type": "error",
        "itr": 1,
        "code": "invalid_request",
        "message": "leaf_id is required",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Alternate terminal response to a correlated request; no further acknowledgement is sent.",
        "links": []
      },
      "related": [],
      "notes": [
        "A non-empty request_id makes this the failure-mode response to the same waiter that would receive the request’s success type.",
        "code is handler-specific machine-readable text; message explains the failure."
      ]
    },
    {
      "id": "feed_dropped",
      "type": "feed_dropped",
      "struct": "FeedDropped",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Confirms that the requesting connection left the named leaf feed.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"feed_dropped\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the drop_feed request_id; the RPC dispatcher uses it to deliver this feed_dropped frame to the waiting call."
        }
      ],
      "example": {
        "type": "feed_dropped",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to drop_feed; request_id supplies correlation.",
        "links": [
          "drop_feed"
        ]
      },
      "related": [
        "drop_feed"
      ],
      "notes": []
    },
    {
      "id": "get_leaf_config",
      "type": "get_leaf_config",
      "struct": "GetLeafConfig",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Reads one opaque configuration value from a leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"get_leaf_config\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "key",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque per-leaf configuration key addressed by this operation."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque get_leaf_config correlation ID echoed by leaf_config_value or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "get_leaf_config",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "key": "example.key",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_config_value. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_config_value",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_config_value",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "leaf_files",
      "type": "leaf_files",
      "struct": "LeafFiles",
      "source": "pkg/protocol/leaf_files.go",
      "category": "req",
      "synopsis": "Attach a stable key to a daemon-managed leaf file registration.",
      "direction": {"from": "client/module", "to": "daemon"},
      "fields": [
        {"name": "type", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Always leaf_files."},
        {"name": "itr", "go_type": "int64", "json_tag": "always", "validation": "optional", "desc": "Connection-local outbound iteration."},
        {"name": "operation", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Only attach is supported."},
        {"name": "request_id", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Nonempty opaque request correlation ID."},
        {"name": "leaf_id", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Nonempty leaf ID."},
        {"name": "key", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Nonempty stable key."}
      ],
      "example": {"type": "leaf_files", "itr": 1, "operation": "attach", "request_id": "rpc_0123456789abcdef", "leaf_id": "l_0123456789ab", "key": "state.ruby"},
      "reply": {"text": "leaf_files_result on success, or a correlated error.", "links": ["leaf_files_result", "error-correlated-response"]},
      "related": ["leaf_files_result", "get_leaf_config"],
      "notes": ["Missing or invalid required fields and unsupported operations produce parse_error; an unknown leaf produces leaf_not_found. Storage failures produce provider_error. An older daemon may return unknown_command.", "Same-leaf registration and manual config replacement or deletion are ordered by storage. Await a correlated reply before sending a dependent operation; wire arrival order does not guarantee execution order. Repeating a key returns the existing descriptor. A config read does not allocate; replacing the whole list remains authoritative.", "The owner manages payload contents. Registration creates no payload and a missing payload does not remove the descriptor. Local timeout or disconnect cancels only the waiter and does not promise rollback. No request is automatically retried."]
    },
    {
      "id": "leaf_files_result",
      "type": "leaf_files_result",
      "struct": "LeafFilesResult",
      "source": "pkg/protocol/leaf_files.go",
      "category": "req",
      "synopsis": "Returns the registered leaf file descriptor.",
      "direction": {"from": "daemon", "to": "requesting client/module"},
      "fields": [
        {"name": "type", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Always leaf_files_result."},
        {"name": "itr", "go_type": "int64", "json_tag": "always", "validation": "optional", "desc": "Connection-local outbound iteration."},
        {"name": "operation", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Always attach."},
        {"name": "request_id", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Echoes the request ID."},
        {"name": "leaf_id", "go_type": "string", "json_tag": "always", "validation": "required", "desc": "Echoes the request leaf ID."},
        {"name": "file", "go_type": "LeafFileDescriptor", "json_tag": "always", "validation": "required", "desc": "Object with string file_id, key, and absolute storage-owned path."}
      ],
      "example": {"type": "leaf_files_result", "itr": 2, "operation": "attach", "request_id": "rpc_0123456789abcdef", "leaf_id": "l_0123456789ab", "file": {"file_id": "lf_0123456789ab", "key": "state.ruby", "path": "/state/leaf-files/lf_0123456789ab-state.ruby"}},
      "reply": {"text": "Success response to leaf_files.", "links": ["leaf_files"]},
      "related": ["leaf_files"],
      "notes": ["The path is a registration, not a guarantee that the payload exists."]
    },
    {
      "id": "get_supported_filetypes",
      "type": "get_supported_filetypes",
      "struct": "GetSupportedFiletypes",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Requests the protocol’s supported attachment MIME groups.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"get_supported_filetypes\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque get_supported_filetypes correlation ID echoed by supported_filetypes_response or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "get_supported_filetypes",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: supported_filetypes_response. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "supported_filetypes_response",
          "error-correlated-response"
        ]
      },
      "related": [
        "supported_filetypes_response",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "get_tool_info",
      "type": "get_tool_info",
      "struct": "GetToolInfo",
      "source": "pkg/protocol/tool.go",
      "category": "req",
      "synopsis": "Resolves tool metadata for explicit names or a leaf’s active/default tools.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"get_tool_info\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Required only when names is empty; selects active/default tools for that leaf."
        },
        {
          "name": "names",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Explicit names to resolve; when empty, leaf_id must be non-empty."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque get_tool_info correlation ID echoed by tool_info or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "get_tool_info",
        "itr": 1,
        "names": [
          "run-cmd",
          "buffer"
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: tool_info. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "tool_info",
          "error-correlated-response"
        ]
      },
      "related": [
        "tool_info",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "get_attachment_chunk",
      "type": "get_attachment_chunk",
      "struct": "GetAttachmentChunk",
      "source": "pkg/protocol/attachment.go",
      "category": "req",
      "synopsis": "Reads a bounded byte range from one persisted turn attachment.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"get_attachment_chunk\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Nonempty opaque correlation ID echoed by attachment_chunk or a correlated error. Use a distinct ID for each in-flight request."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Nonempty opaque persisted turn ID. Lookup and access match get_turn; no loaded leaf or leaf_id is required."
        },
        {
          "name": "attachment_index",
          "go_type": "*int",
          "json_tag": "always",
          "validation": "required",
          "desc": "Zero-based index in the turn's meta_files array, not a filename or path. Must be an integer >= 0. Omission and JSON null are invalid; index 0 must be explicit."
        },
        {
          "name": "offset",
          "go_type": "*int64",
          "json_tag": "always",
          "validation": "required",
          "desc": "Decoded-byte offset, an int64 >= 0. Omission and JSON null are invalid; offset 0 must be explicit. Equal to actual size succeeds with an empty EOF chunk; greater than size is attachment_range_error."
        },
        {
          "name": "length",
          "go_type": "*int64",
          "json_tag": "always",
          "validation": "required",
          "desc": "Requested decoded-byte count, an int64 from 1 through 98304 inclusive. Omission and JSON null are invalid. This limit applies before base64 encoding, including for UTF-8 files."
        }
      ],
      "example": {
        "type": "get_attachment_chunk",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef",
        "turn_id": "t_0123456789ab",
        "attachment_index": 0,
        "offset": 0,
        "length": 98304
      },
      "reply": {
        "text": "Requester-only attachment_chunk on success, or error with the same request_id on failure. Neither response is broadcast to subscribers.",
        "links": [
          "attachment_chunk",
          "error-correlated-response"
        ]
      },
      "related": [
        "attachment_chunk",
        "get_turn",
        "turn_content-response",
        "error-correlated-response"
      ],
      "notes": [
        "Invalid fields, types, missing or null numeric members, negative index/offset, and length outside 1..98304 produce parse_error. A missing turn produces turn_not_found under the same access rules as get_turn; a nonexistent attachment index produces attachment_not_found. Missing or corrupt stored blob data produces internal_error.",
        "The returned size is the actual total decoded file size. Existing FileMeta.size needs no metadata extension. For legacy metadata without size, discover it with the first chunk response before scheduling later ranges.",
        "Clients should keep two independent requests in flight and replenish the window as each response arrives. Replies may arrive out of order, so place decoded bytes by offset and track all requested ranges. EOF for the final range can arrive before earlier ranges; it does not mean the download is complete.",
        "This is a single-range RPC, not a batch frame or an instruction for automatic UI downloads. It adds no protocol version bump, SQLite schema change, or PRAGMA user_version change."
      ]
    },
    {
      "id": "get_turn",
      "type": "get_turn",
      "struct": "GetTurn",
      "source": "pkg/protocol/turn.go",
      "category": "req",
      "synopsis": "Requests one persisted turn by opaque turn ID.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"get_turn\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque get_turn correlation ID echoed by turn_content-response or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "get_turn",
        "itr": 1,
        "turn_id": "t_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: turn_content. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "turn_content-response",
          "error-correlated-response"
        ]
      },
      "related": [
        "turn_content-response",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "heartbeat",
      "type": "heartbeat",
      "struct": "OpHeartbeat",
      "source": "pkg/protocol/op.go",
      "category": "sys",
      "synopsis": "Renews a call's inactivity watchdog with a one-way update from the request receiver to its caller; the Go struct remains OpHeartbeat.",
      "direction": {
        "from": "request receiver, daemon or capability/client peer",
        "to": "requesting peer on the same connection"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"heartbeat\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Operation kind: tool, plugin, macro, or rpc. Useful refresh requires the exact outstanding kind on this connection; unknown values are no-ops."
        },
        {
          "name": "call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Outstanding call ID, or request_id when kind is rpc. Empty, unknown, completed, or foreign-connection IDs cannot renew a call."
        }
      ],
      "example": {
        "type": "heartbeat",
        "itr": 1,
        "kind": "tool",
        "call_id": "call_tool_01"
      },
      "reply": {
        "text": "One-way watchdog refresh; neither peer sends a response.",
        "links": [
          "tool_call"
        ]
      },
      "related": [
        "tool_call"
      ],
      "notes": [
        "Matching connection, kind and call_id renew only inactivity, never an explicit caller deadline or max_timeout. Healthy calls have no implicit elapsed-time maximum. RPC heartbeats use kind rpc and call_id=request_id, sent only from the receiver of that request back to its caller. For a client-initiated RPC, the service sends heartbeats to the client. For service-initiated metadata requests, the capability provider sends heartbeats to the service. Heartbeats are never echoed or acknowledged. Disconnect terminally fails every outstanding call owned by that connection. Reconnect has a fresh connection ID and accepts new calls only; no dispatched operation is inherited or replayed. Responses already correlated before EOF remain completed. Local cancellation retires the waiter without asserting remote rollback or requiring an acknowledgement. Existing abort/shutdown replies and tool stop/kill behavior are unchanged.",
        "Receiver ownership begins at admission, including queued work, and ends at the matching terminal reply or connection closure. A registered typed handler may return before publishing its asynchronous result; that return and tool_ack are not terminal. A returned unsupported-message observer does not retain request ownership: if it sent no terminal, the library sends a generic failure. Automatic failures keep handler error details in local diagnostics. Go receivers schedule heartbeats every second; Ruby metadata uses its existing capability scheduler. Unknown or completed keys have no response. Peers without RPC heartbeat support remain subject to inactivity expiry. No cancellation frame or acknowledgement is added."
      ]
    },
    {
      "id": "hello",
      "type": "hello",
      "struct": "Hello",
      "source": "pkg/protocol/lifecycle.go",
      "category": "req",
      "synopsis": "Starts the required version-and-display-label exchange before any normal JSONL frame is accepted.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"hello\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "protocol",
          "go_type": "int",
          "json_tag": "always",
          "validation": "required",
          "desc": "Protocol version. Startup accepts exactly 1."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional display-only connection label. Duplicate names are expected; the daemon never uses this field for connection identity or configured capability selection."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "cwd",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Operation working directory; an empty value means no cwd context."
        }
      ],
      "example": {
        "type": "hello",
        "itr": 1,
        "protocol": 1,
        "name": "Documentation client",
        "leaf_id": "l_0123456789ab",
        "cwd": "/workspace"
      },
      "reply": {
        "text": "Successful startup proceeds directly to hello_ack. There is no request_id field or RPC correlation; failure produces a startup error or connection closure instead.",
        "links": [
          "hello_ack",
          "error-async-event"
        ]
      },
      "related": [
        "hello_ack",
        "error-async-event"
      ],
      "notes": [
        "The daemon assigns the opaque connection ID; peers do not send an id field. name, leaf_id, and cwd are optional context fields, with name used only as a display label. A hello with an unsupported protocol may receive a structured protocol_mismatch error during startup.",
        "After a connection that supplies a valid leaf_id becomes ready, the daemon installs that subscription and replays a complete leaf_updated snapshot. This applies to initial connection and reconnect; hello_ack remains the startup acknowledgement."
      ]
    },
    {
      "id": "hello_ack",
      "type": "hello_ack",
      "struct": "HelloAck",
      "source": "pkg/protocol/lifecycle.go",
      "category": "req",
      "synopsis": "Completes protocol startup with daemon identity and machine-readable readiness; a bootstrap daemon can acknowledge hello as not ready before closing the connection.",
      "direction": {
        "from": "daemon",
        "to": "connecting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"hello_ack\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "protocol",
          "go_type": "int",
          "json_tag": "always",
          "validation": "required",
          "desc": "Protocol version echoed by the daemon. The connecting client rejects an omitted value (decoded as zero) or any value other than 1."
        },
        {
          "name": "server_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Service identity; current daemon uses ez1."
        },
        {
          "name": "state_dir",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Daemon state-directory path exposed to the connecting peer."
        },
        {
          "name": "connection_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque connection ID assigned by the daemon at accept time; peers cannot choose or change it."
        },
        {
          "name": "config_error",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Configuration load error visible at startup; omitted when configuration loaded cleanly."
        },
        {
          "name": "ready",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "required for current daemons",
          "desc": "Machine-readable readiness. true permits normal traffic; false is a normal bootstrap acknowledgement and is followed by connection close. Clients normalize an omitted field from an older daemon to true."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Human-readable readiness phase or reason. Ready daemons conventionally use READY; clients must use ready rather than parsing this field."
        }
      ],
      "example": {
        "type": "hello_ack",
        "itr": 1,
        "protocol": 1,
        "server_id": "ez1",
        "state_dir": "/var/lib/ez-agent",
        "connection_id": "c_0123456789ab",
        "ready": true,
        "message": "READY"
      },
      "reply": {
        "text": "Completes successful startup sequencing after hello; it is not correlated by request_id. Normal frames may follow once the connection is ready.",
        "links": [
          "hello"
        ]
      },
      "related": [
        "hello",
        "error-async-event"
      ],
      "notes": [
        "The client accepts this only as the startup frame following hello and requires protocol 1. server_id and state_dir are decoded without additional non-empty validation.",
        "Current daemon acknowledgements always include ready and message. For compatibility, only an omitted wire ready field is normalized to ready:true and message:READY; an explicit ready:false remains not ready even when message is empty.",
        "This exchange is sequenced by the startup transport and has no request_id."
      ]
    },
    {
      "id": "history_list",
      "type": "history_list",
      "struct": "HistoryList",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns one explicit history cut and its ordered visible summaries.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"history_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Canonical leaf tip in the same stable database read cut as turns. An empty string means no tip. A nonempty value may name a draft omitted from turns."
        },
        {
          "name": "turns",
          "go_type": "[]TurnSummary",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Sent and ready summaries in canonical chain order for this history cut."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_history request_id; the RPC dispatcher uses it to deliver this history_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "history_list",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "tip_turn_id": "t_111111111111",
        "turns": [
          {
            "id": "t_0123456789ab",
            "kind": "user",
            "state": "ready",
            "seq": 1
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_history; request_id supplies correlation.",
        "links": [
          "list_history"
        ]
      },
      "related": [
        "list_history"
      ],
      "notes": [
        "tip_turn_id is required even when turns is empty. The service reads the tip and summaries in one database transaction.",
        "turns contains only sent and ready summaries. A draft can therefore be the cut tip without appearing in the array. Consumers must use tip_turn_id rather than infer the tip from the final summary."
      ]
    },
    {
      "id": "informational",
      "type": "informational",
      "struct": "Informational",
      "source": "pkg/protocol/types.go",
      "category": "fnf",
      "synopsis": "Delivers a non-terminal severity-labelled message to a frontend.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"informational\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "level",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Severity label supplied by the producer, commonly info or warn."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Non-terminal text to display or log for the addressed leaf/global context."
        }
      ],
      "example": {
        "type": "informational",
        "itr": 1,
        "level": "info",
        "message": "Operation completed."
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [],
      "notes": []
    },
    {
      "id": "leaf_config_deleted",
      "type": "leaf_config_deleted",
      "struct": "LeafConfigDeleted",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Confirms deletion of one leaf configuration key.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_config_deleted\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Always serialized but currently emitted as an empty string by the success helper; use request_id for correlation."
        },
        {
          "name": "key",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque per-leaf configuration key addressed by this operation."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the delete_leaf_config request_id; the RPC dispatcher uses it to deliver this leaf_config_deleted frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_config_deleted",
        "itr": 1,
        "leaf_id": "",
        "key": "example.key",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to delete_leaf_config; request_id supplies correlation.",
        "links": [
          "delete_leaf_config"
        ]
      },
      "related": [
        "delete_leaf_config"
      ],
      "notes": [
        "leaf_id is always serialized but current service success helpers emit it as an empty string; correlate by request_id rather than assuming it echoes the request leaf."
      ]
    },
    {
      "id": "leaf_config_list",
      "type": "leaf_config_list",
      "struct": "LeafConfigList",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Returns all opaque leaf configuration key/value entries.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_config_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Always serialized but currently emitted as an empty string by the success helper; use request_id for correlation."
        },
        {
          "name": "configs",
          "go_type": "[]LeafConfigListEntry",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "All stored opaque key/value entries for the requested leaf."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_leaf_config request_id; the RPC dispatcher uses it to deliver this leaf_config_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_config_list",
        "itr": 1,
        "leaf_id": "",
        "configs": [
          {
            "key": "example.key",
            "value": "example value"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_leaf_config; request_id supplies correlation.",
        "links": [
          "list_leaf_config"
        ]
      },
      "related": [
        "list_leaf_config"
      ],
      "notes": [
        "leaf_id is always serialized but current service success helpers emit it as an empty string; correlate by request_id rather than assuming it echoes the request leaf."
      ]
    },
    {
      "id": "leaf_config_set",
      "type": "leaf_config_set",
      "struct": "LeafConfigSet",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Confirms the stored leaf configuration key/value pair.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_config_set\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Always serialized but currently emitted as an empty string by the success helper; use request_id for correlation."
        },
        {
          "name": "key",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque per-leaf configuration key addressed by this operation."
        },
        {
          "name": "value",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque string value stored for the configuration key; list-like settings commonly contain raw JSON arrays."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the set_leaf_config request_id; the RPC dispatcher uses it to deliver this leaf_config_set frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_config_set",
        "itr": 1,
        "leaf_id": "",
        "key": "example.key",
        "value": "example value",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to set_leaf_config; request_id supplies correlation.",
        "links": [
          "set_leaf_config"
        ]
      },
      "related": [
        "set_leaf_config"
      ],
      "notes": [
        "leaf_id is always serialized but current service success helpers emit it as an empty string; correlate by request_id rather than assuming it echoes the request leaf."
      ]
    },
    {
      "id": "leaf_config_value",
      "type": "leaf_config_value",
      "struct": "LeafConfigValue",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Returns one opaque leaf configuration value.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_config_value\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Always serialized but currently emitted as an empty string by the success helper; use request_id for correlation."
        },
        {
          "name": "key",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque per-leaf configuration key addressed by this operation."
        },
        {
          "name": "value",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque string value stored for the configuration key; list-like settings commonly contain raw JSON arrays."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the get_leaf_config request_id; the RPC dispatcher uses it to deliver this leaf_config_value frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_config_value",
        "itr": 1,
        "leaf_id": "",
        "key": "example.key",
        "value": "example value",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to get_leaf_config; request_id supplies correlation.",
        "links": [
          "get_leaf_config"
        ]
      },
      "related": [
        "get_leaf_config"
      ],
      "notes": [
        "leaf_id is always serialized but current service success helpers emit it as an empty string; correlate by request_id rather than assuming it echoes the request leaf."
      ]
    },
    {
      "id": "leaf_created",
      "type": "leaf_created",
      "struct": "LeafCreated",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns the new root, leaf, selected model, and temporary marker.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_created\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Canonical provider/model reference applicable to this frame."
        },
        {
          "name": "is_temp",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Temporary-leaf marker when represented by the current handler."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the create_leaf request_id; the RPC dispatcher uses it to deliver this leaf_created frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_created",
        "itr": 1,
        "root_id": "r_0123456789ab",
        "leaf_id": "l_0123456789ab",
        "model": "openai/gpt-5",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to create_leaf; request_id supplies correlation.",
        "links": [
          "create_leaf"
        ]
      },
      "related": [
        "create_leaf",
        "leaf_updated"
      ],
      "notes": [
        "root_id, leaf_id, and persisted turn IDs are opaque. Current service-generated root/leaf/turn IDs use r_, l_, and t_ plus 12 lowercase hex digits respectively; consumers must not parse or synthesize them.",
        "Client APIs treat leaf_created as dual-role: a correlated frame releases the create request and still reaches the lifecycle event handler. With autosubscribe, a separate leaf_updated event follows with current state."
      ]
    },
    {
      "id": "leaf_deleted-event",
      "type": "leaf_deleted",
      "struct": "LeafDeleted",
      "source": "pkg/protocol/session.go",
      "category": "fnf",
      "synopsis": "Notifies current leaf subscribers that the leaf was deleted.",
      "direction": {
        "from": "daemon",
        "to": "leaf subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_deleted\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Always serialized; current deletion broadcast sets it to the empty string."
        }
      ],
      "example": {
        "type": "leaf_deleted",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab",
        "request_id": ""
      },
      "reply": {
        "text": "One-way subscriber event; no acknowledgement.",
        "links": []
      },
      "related": [
        "delete_leaf",
        "leaf_deleted-response"
      ],
      "notes": [
        "The service enqueues this subscriber broadcast first with an empty request_id, then sends leaf_deleted-response to the requester with the request ID. A requester subscribed to the leaf can therefore observe both frames."
      ]
    },
    {
      "id": "leaf_deleted-response",
      "type": "leaf_deleted",
      "struct": "LeafDeleted",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Confirms deletion to the requester using the delete_leaf request ID.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_deleted\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Echo of the delete_leaf request_id; the RPC dispatcher uses it to deliver this leaf_deleted-response frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_deleted",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Correlated success response to delete_leaf; no acknowledgement follows.",
        "links": [
          "delete_leaf"
        ]
      },
      "related": [
        "delete_leaf",
        "leaf_deleted-event"
      ],
      "notes": [
        "The service first enqueues leaf_deleted-event to current subscribers, then sends this correlated response. Because leaf_deleted also has a frontend handler, a matched response can reach both the RPC waiter and that handler."
      ]
    },
    {
      "id": "leaf_list",
      "type": "leaf_list",
      "struct": "LeafList",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns leaf projections and current runtime status values.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaves",
          "go_type": "[]LeafInfo",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Leaf projections with the current runtime status. See LeafInfo.status for status values."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_leaves request_id; the RPC dispatcher uses it to deliver this leaf_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_list",
        "itr": 1,
        "leaves": [
          {
            "id": "l_0123456789ab",
            "root_id": "r_0123456789ab",
            "name": "API work",
            "turn_id": "t_0123456789ab",
            "model": "openai/gpt-5",
            "status": "idle",
            "updated_at": "2026-07-27T12:00:00Z"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_leaves; request_id supplies correlation.",
        "links": [
          "list_leaves"
        ]
      },
      "related": [
        "list_leaves"
      ],
      "notes": [
        "status is unloaded, idle, background, running, or aborting. Temporary leaves remain in ordinary results and carry is_temp:true."
      ]
    },
    {
      "id": "leaf_meta_updated",
      "type": "leaf_meta_updated",
      "struct": "LeafMetaUpdated",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Reports which leaf metadata mutations were committed.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_meta_updated\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "name_changed",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "True when update_leaf_meta committed a display-name change."
        },
        {
          "name": "new_name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Committed display name when name_changed is true."
        },
        {
          "name": "set_config_keys",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Configuration keys written by the metadata update."
        },
        {
          "name": "deleted_keys",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Configuration keys removed by the metadata update."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the update_leaf_meta request_id; the RPC dispatcher uses it to deliver this leaf_meta_updated frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_meta_updated",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "name_changed": true,
        "new_name": "API documentation",
        "set_config_keys": [
          "owner"
        ],
        "deleted_keys": [
          "obsolete_key"
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to update_leaf_meta; request_id supplies correlation.",
        "links": [
          "update_leaf_meta"
        ]
      },
      "related": [
        "update_leaf_meta"
      ],
      "notes": []
    },
    {
      "id": "leaf_renamed",
      "type": "leaf_renamed",
      "struct": "LeafRenamed",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Confirms a leaf display-name change.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_renamed\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted display name after rename_leaf."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the rename_leaf request_id; the RPC dispatcher uses it to deliver this leaf_renamed frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_renamed",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "name": "example",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to rename_leaf; request_id supplies correlation.",
        "links": [
          "rename_leaf"
        ]
      },
      "related": [
        "rename_leaf"
      ],
      "notes": []
    },
    {
      "id": "leaf_rewound",
      "type": "leaf_rewound",
      "struct": "LeafRewound",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Acknowledges a committed rewind and, when requested, admission of the associated replay run.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_rewound\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "old_tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Canonical nonempty tip matched and replaced by the operation."
        },
        {
          "name": "new_tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Committed canonical tip. Empty means the root boundary before the first turn."
        },
        {
          "name": "replay",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "required",
          "desc": "Echoes whether a replay run was admitted."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of rewind_leaf request_id; the RPC dispatcher uses it to release the waiting RewindLeaf call."
        }
      ],
      "example": {
        "type": "leaf_rewound",
        "itr": 2,
        "leaf_id": "l_0123456789ab",
        "old_tip_turn_id": "t_feedface0002",
        "new_tip_turn_id": "t_feedface0001",
        "replay": true,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Correlated success response to rewind_leaf. This response is consumed by RPC dispatch and is not the canonical leaf snapshot.",
        "links": [
          "rewind_leaf",
          "leaf_updated"
        ]
      },
      "related": [
        "rewind_leaf",
        "leaf_updated",
        "agent_start",
        "prompt_completed"
      ],
      "notes": [
        "The acknowledgement is enqueued before the canonical leaf_updated subscriber snapshot; both precede replay agent_start and later stream events.",
        "replay=true reports accepted generation only. Observe normal agent_end and prompt_completed for terminal success, failure, or abort."
      ]
    },
    {
      "id": "leaf_stats",
      "type": "leaf_stats",
      "struct": "LeafStats",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Requests lifecycle, usage, model, and queue statistics for a leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_stats\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf_stats correlation ID echoed by leaf_stats_response or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "leaf_stats",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_stats_response. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_stats_response",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_stats_response",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "leaf_stats_response",
      "type": "leaf_stats_response",
      "struct": "LeafStatsResponse",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns persistent leaf statistics plus point-in-time Agent run-anchor, outcome, active-tool, and top-level progress RAM projections.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_stats_response\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Current persisted leaf display name, omitted only when empty."
        },
        {
          "name": "state",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Current state for the enclosing leaf or persisted turn."
        },
        {
          "name": "active_turn_id",
          "go_type": "*string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Currently streaming assistant turn, when a loaded agent has one."
        },
        {
          "name": "active_prompt_turn_id",
          "go_type": "*string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Process-local user turn that started the loaded agent's current run; an idle-starting steer is the run-start turn, while mid-run steers do not replace it. Leaf stats combine independently sampled runtime fields, so this optional value and state can be momentarily out of step during admission or another run transition. It is settled before a normal non-recovered on_preplugin trigger and is omitted when the leaf is stably idle or unloaded."
        },
        {
          "name": "tip_turn_id",
          "go_type": "*string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Current persisted leaf tip. The custom wire encoding maps a nil Go pointer to the required empty string, which means no tip."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Canonical provider/model reference applicable to this frame."
        },
        {
          "name": "thinking_level",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Model-specific canonical thinking level after normalization."
        },
        {
          "name": "access_source",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Read-only source: local, openai_subscription, muse_subscription, api_key, unknown, or unavailable. Active runs retain their captured route, using host-reported source information for remote models. Idle/unloaded leaves use known configuration or cached discovery data, falling back to remembered model_access_source for the same resolved model. Muse reports validated subscription-route observations; the saved label survives expiry, unload, and restart without asserting a paid plan or entitlement. Omitted discovery information preserves remembered values; reported unknown replaces them. Missing or unfamiliar wire values remain neutral. No credentials are exposed."
        },
        {
          "name": "is_temp",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Temporary-leaf marker. Omitted when false and present when the stored leaf is temporary."
        },
        {
          "name": "turn_count",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Number of turns reachable in this leaf history."
        },
        {
          "name": "context_tokens",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Token count represented by the current leaf context."
        },
        {
          "name": "input_tokens",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Cumulative input tokens recorded for the leaf."
        },
        {
          "name": "output_tokens",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Cumulative output tokens recorded for the leaf."
        },
        {
          "name": "estimated_cost",
          "go_type": "float64",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Always encoded; current handler emits 0.0."
        },
        {
          "name": "queue_count",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Current queued message count."
        },
        {
          "name": "runtime",
          "go_type": "*AgentRuntime",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Process-local outcome and/or active service-owned tool calls; omitted when both are empty. An unloaded leaf has no Agent outcome."
        },
        {
          "name": "progress",
          "go_type": "*ProgressSnapshot",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Independent top-level leaf-scoped RAM progress snapshot. In this point-in-time response omission means there are no current progress items, including when an unloaded leaf has none."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the leaf_stats request_id; the RPC dispatcher uses it to deliver this leaf_stats_response frame to the waiting call."
        },
        {
          "name": "root_cwd",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Working directory stored on the leaf’s conversation root, when non-empty."
        }
      ],
      "example": {
        "type": "leaf_stats_response",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "state": "idle",
        "tip_turn_id": "t_0123456789ab",
        "model": "openai/gpt-5",
        "thinking_level": "medium",
        "access_source": "api_key",
        "turn_count": 3,
        "context_tokens": 1200,
        "input_tokens": 1100,
        "output_tokens": 100,
        "estimated_cost": 0.0,
        "queue_count": 0,
        "runtime": {
          "outcome": {
            "reason": "error",
            "message": "Provider request failed"
          },
          "active_tool_calls": [
            {
              "tool_call_id": "call_0123456789ab",
              "name": "run-cmd",
              "turn_id": "t_111111111111"
            }
          ]
        },
        "progress": {
          "turn_id": "t_111111111111",
          "items": [
            {
              "update_id": "compact-title",
              "title": "Compacting title",
              "lines": [
                "Reading history"
              ]
            }
          ]
        },
        "request_id": "rpc_0123456789abcdef",
        "name": "API work",
        "root_cwd": "/workspace"
      },
      "reply": {
        "text": "Success response to leaf_stats; request_id supplies correlation.",
        "links": [
          "leaf_stats"
        ]
      },
      "related": [
        "leaf_stats"
      ],
      "notes": [
        "Capture and response enqueue share the same per-leaf gate as leaf_updated. Within one connection, itr orders these captures across both frame types, not request-start or client callback order. Deferred handler cleanup releases the gate after enqueue succeeds or fails, without waiting for remote receipt.",
        "tip_turn_id is always a JSON string. The Go struct keeps a pointer projection for compatibility, but its custom marshaler emits an empty string rather than null or omission when the leaf has no tip.",
        "is_temp has omitempty and is emitted when the stored leaf is temporary.",
        "estimated_cost is always serialized and the current handler emits 0.0; treat it as an unavailable placeholder rather than a calculated estimate.",
        "runtime.outcome is RAM-only and exists only while the Agent remains loaded. It is installed before terminal hooks, survives idle, and is cleared by the next successfully admitted user message or Agent close/unload; provisional admission suppresses rather than erases it.",
        "runtime.active_tool_calls is sorted by tool_call_id and exposes no arguments. Entries disappear on result claim, timeout, abort, cancellation, or unregister; their IDs are never joined to progress update IDs.",
        "progress is top-level because it is independent leaf-scoped service RAM and may exist for an idle or unloaded target while work runs elsewhere. leaf_stats_response may omit progress when there are no current items. In contrast, leaf_updated always includes progress and uses null to clear the previous projection."
      ]
    },
    {
      "id": "leaf_switched",
      "type": "leaf_switched",
      "struct": "LeafSwitched",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Confirms a connection subscription switch before snapshot replay.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_switched\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the switch_leaf request_id; the RPC dispatcher uses it to deliver this leaf_switched frame to the waiting call."
        }
      ],
      "example": {
        "type": "leaf_switched",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to switch_leaf; request_id supplies correlation.",
        "links": [
          "switch_leaf"
        ]
      },
      "related": [
        "switch_leaf",
        "leaf_updated"
      ],
      "notes": [
        "This frame acknowledges only the subscription RPC. It is not a state snapshot and client APIs route it as a response rather than an event.",
        "A switch normally sends a separate complete leaf_updated snapshot, including for an idle or same-leaf switch. If a newer selection or successful feed drop overtakes a delayed switch, the older switch is acknowledged without replaying stale state or replacing that newer selection."
      ]
    },
    {
      "id": "leaf_updated",
      "type": "leaf_updated",
      "struct": "LeafUpdated",
      "source": "pkg/protocol/session.go",
      "category": "fnf",
      "synopsis": "Publishes one complete authoritative current control and head snapshot for a leaf.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"leaf_updated\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID for this complete snapshot. Service-generated IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Authoritative current canonical tip. The required empty string means this leaf has no tip."
        },
        {
          "name": "previous_tip_turn_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Abandoned former canonical tip. When present with tip_turn_id, frontends must discard transient rendering for this turn and reconcile to the new tip."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Current canonical provider/model reference. The empty string replaces the previous model."
        },
        {
          "name": "thinking_level",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Current normalized thinking level. The empty string replaces the previous level."
        },
        {
          "name": "access_source",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Read-only source: local, openai_subscription, muse_subscription, api_key, unknown, or unavailable. Active runs retain their captured route, using host-reported source information for remote models. Idle/unloaded leaves use known configuration or cached discovery data, falling back to remembered model_access_source for the same resolved model. Muse reports validated subscription-route observations; the saved label survives expiry, unload, and restart without asserting a paid plan or entitlement. Omitted discovery information preserves remembered values; reported unknown replaces them. Missing or unfamiliar wire values remain neutral. No credentials are exposed."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Current persisted leaf display name. The empty string replaces the previous name."
        },
        {
          "name": "state",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Current leaf runtime state: idle, background, running, or aborting; unloaded snapshots are normalized to idle here. An empty value still replaces the previous state."
        },
        {
          "name": "queue_count",
          "go_type": "int",
          "json_tag": "always",
          "validation": "required",
          "desc": "Number of queued messages waiting behind current work. Zero clears the previous count."
        },
        {
          "name": "run_started_at",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "UTC RFC3339Nano start of continuous activity, including time waiting for background tasks. Preserved across running/background transitions and resumed model processing until both model work and background tasks have ended. The empty string clears an earlier run start."
        },
        {
          "name": "run_elapsed_ms",
          "go_type": "*int64",
          "json_tag": "always",
          "validation": "required",
          "desc": "Elapsed continuous-activity milliseconds, including background waits, measured from run_started_at. Available in background snapshots as well as running/aborting snapshots. null clears an earlier elapsed-time projection."
        },
        {
          "name": "progress",
          "go_type": "*ProgressSnapshot",
          "json_tag": "always",
          "validation": "required",
          "desc": "Complete progress replacement snapshot. null clears all progress retained from the previous snapshot."
        },
        {
          "name": "pending_questions",
          "go_type": "[]PendingQuestion",
          "json_tag": "always",
          "validation": "required",
          "desc": "Complete daemon-owned pending-question replacement. It is always an array; [] clears all prior questions."
        }
      ],
      "example": {
        "type": "leaf_updated",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "tip_turn_id": "t_0123456789ab",
        "model": "openai/gpt-5",
        "thinking_level": "medium",
        "access_source": "api_key",
        "name": "API docs",
        "state": "running",
        "queue_count": 0,
        "run_started_at": "2026-07-27T12:00:00Z",
        "run_elapsed_ms": 1250,
        "progress": {
          "turn_id": "t_0123456789ab",
          "items": [
            {
              "update_id": "compile",
              "title": "Building documentation",
              "lines": [
                "Validating"
              ]
            }
          ]
        },
        "pending_questions": [
          {
            "kind": "project_config_trust",
            "revision": "sha256:0123456789abcdef",
            "project_config_trust": {
              "path": "/project/.ez-agent/config.yaml",
              "sha256": "0123456789abcdef"
            }
          }
        ]
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [
        "hello",
        "create_leaf",
        "leaf_created",
        "switch_leaf",
        "leaf_switched",
        "history_list"
      ],
      "notes": [
        "This frame is always a complete snapshot, never a patch. Empty tip, model, thinking-level, name, state, and run-start strings, zero queue_count, and null run_elapsed_ms or progress values replace the corresponding values from an older snapshot.",
        "The daemon publishes a fresh snapshot after every committed change represented by these fields. It also replays one for a valid hello subscription, switch_leaf, update_cwd subscription switch, or autosubscribed creation while that selection remains current. An older selection overtaken by a newer selection or successful drop is not replayed.",
        "For leaf_updated and leaf_stats_response captures of this leaf on one connection, a higher itr cannot represent an earlier capture because the service serializes construction and enqueue behind the same per-leaf gate. itr still does not correlate RPCs, identify a global revision, order RPC execution or callbacks, detect loss, or compare state across connections or directions.",
        "previous_tip_turn_id supplies optional backstep context without making the snapshot partial. The backstep is committed before publication. Frontends should invalidate the abandoned turn and reconcile to tip_turn_id; recovery must not depend on a separate informational frame.",
        "pending_questions is captured under the same per-leaf gate as the rest of the snapshot, including hello subscription, reconnect, switch, and autosubscribe replay.",
        "background is derived only when internal Agent state is idle and provider-owned tasks remain. It blocks eviction, not ordinary idle operations. running and aborting retain precedence. Pending admission reservations project running through completion handoff, including before lazy loading, and prevent false idle gaps.",
        "on_success/on_error are per-model-run outcome triggers. After execution retirement, on_background reports stopped model processing with owned tasks remaining; on_idle reports true quiescence with no execution, queued/in-flight input, terminalization, admission reservation or owner. Selection is serialized per leaf and deduplicated. Lifecycle callbacks execute in selection order per leaf, so an earlier background callback finishes before a later idle callback begins. A busy callback queues later notifications without blocking their callers or model terminal frames. Canonical state is published before lifecycle macro invocation outside leaf gates and service/Agent mutexes. Last-task removal or provider loss can publish idle and fire idle macros without another model turn or terminal frame. These are notifications, not instructions for subscribers to terminate."
      ]
    },
    {
      "id": "list_connections",
      "type": "list_connections",
      "struct": "ListConnections",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Lists current connections and their effective capability names.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_connections\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional field accepted by the struct/API helper; the current list-connections service handler ignores it and returns all connections."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_connections correlation ID echoed by connection_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_connections",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: connection_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "connection_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "connection_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_history",
      "type": "list_history",
      "struct": "ListHistory",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Lists the linear turn history visible from a leaf tip.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_history\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_history correlation ID echoed by history_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_history",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: history_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "history_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "history_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_leaf_config",
      "type": "list_leaf_config",
      "struct": "ListLeafConfig",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Lists all opaque configuration key/value pairs stored on a leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_leaf_config\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_leaf_config correlation ID echoed by leaf_config_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_leaf_config",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_config_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_config_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_config_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_leaves",
      "type": "list_leaves",
      "struct": "ListLeaves",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Lists leaves, optionally filtered by root or cwd and projected metadata keys.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_leaves\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "cwd",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Operation working directory; an empty value means no cwd context."
        },
        {
          "name": "metadata_keys",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional leaf metadata keys to project into each returned LeafInfo.metadata map."
        },
        {
          "name": "is_active",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "When true, return only running or aborting leaves using the runtime projection. False or omitted does not filter by status. Temporary leaves are included. Older daemons may ignore this field."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_leaves correlation ID echoed by leaf_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_leaves",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_list",
        "error-correlated-response"
      ],
      "notes": ["cwd takes precedence over root_id when both are provided; is_active combines with the selected location filter."]
    },
    {
      "id": "list_macros",
      "type": "list_macros",
      "struct": "ListMacros",
      "source": "pkg/protocol/macro.go",
      "category": "req",
      "synopsis": "Lists effective macro metadata, optionally filtered by trigger.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_macros\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "filter",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional trigger name used to retain only macros advertising that trigger."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_macros correlation ID echoed by macro_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_macros",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: macro_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "macro_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "macro_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_models",
      "type": "list_models",
      "struct": "ListModels",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Lists configured model selections and limits, refreshing remote availability without importing advertised models.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_models\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_models correlation ID echoed by model_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_models",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: model_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "model_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "model_list",
        "error-correlated-response"
      ],
      "notes": [
        "Remote discovery uses hello/hello_ack, unfiltered list_macros and validated per-provider IFO/LIST macro payloads. It opens no INIT stream and performs no inference, leaf creation or consumer credential lookup. Host-known access-source labels use the host config snapshot without refreshing credentials. Discovery and leaf snapshot reads do not write remembered properties; explicit model selection and execution save them. The whole list refresh has a ten-second budget with four destination workers and stops waiting on client disconnect.",
        "The result contains saved remote references only, preserving host/provider/org/model IDs. Successful discovery with an absent export/model sets the existing ModelEntry.flags value not-found; failed discovery sets unavailable. Local and other healthy entries still return. Saved selections are not rewritten or silently replaced. These are application conventions in existing fields, not new outer JSONL fields or frames."
      ]
    },
    {
      "id": "list_plugins",
      "type": "list_plugins",
      "struct": "ListPlugins",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Lists plugin names from the effective configuration.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_plugins\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_plugins correlation ID echoed by plugin_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_plugins",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: plugin_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "plugin_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "plugin_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_providers",
      "type": "list_providers",
      "struct": "ListProviders",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Lists configured providers and their model metadata.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_providers\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_providers correlation ID echoed by provider_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_providers",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: provider_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "provider_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "provider_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_queued",
      "type": "list_queued",
      "struct": "ListQueued",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Lists pending queued messages for a loaded leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_queued\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_queued correlation ID echoed by queued_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_queued",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: queued_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "queued_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "queued_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_roots",
      "type": "list_roots",
      "struct": "ListRoots",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Lists persisted conversation roots.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_roots\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_roots correlation ID echoed by root_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_roots",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: root_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "root_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "root_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_tools",
      "type": "list_tools",
      "struct": "ListTools",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Lists tool names from the effective configuration.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_tools\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_tools correlation ID echoed by tool_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_tools",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: tool_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "tool_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "tool_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "list_turn_tree",
      "type": "list_turn_tree",
      "struct": "ListTurnTree",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Lists every persisted turn node for one root.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"list_turn_tree\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque list_turn_tree correlation ID echoed by turn_tree_list or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "list_turn_tree",
        "itr": 1,
        "root_id": "r_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: turn_tree_list. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "turn_tree_list",
          "error-correlated-response"
        ]
      },
      "related": [
        "turn_tree_list",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "macro_call",
      "type": "macro_call",
      "struct": "MacroCall",
      "source": "pkg/protocol/macro.go",
      "category": "req",
      "synopsis": "Runs one named macro and returns its text result asynchronously through the correlated RPC.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"macro_call\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "macro_name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Macro capability name to resolve and invoke."
        },
        {
          "name": "param_string",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Raw macro parameter string passed unchanged to the capability."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Non-empty caller correlation ID; the service explicitly rejects an empty value. ezagentapi.RPC uses rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "macro_call",
        "itr": 1,
        "macro_name": "example.macro",
        "param_string": "subject=docs",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: macro_result. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "macro_result",
          "error-correlated-response"
        ]
      },
      "related": [
        "macro_result",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "macro_call_ipc",
      "type": "macro_call_ipc",
      "struct": "MacroCallIPC",
      "source": "pkg/protocol/macro.go",
      "category": "sys",
      "synopsis": "Invokes one macro capability with raw parameters and optional leaf context.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"macro_call_ipc\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "macro_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Daemon-generated macro invocation ID: mc_ plus 16 lowercase hex digits."
        },
        {
          "name": "macro_name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Resolved macro capability name being invoked."
        },
        {
          "name": "param_string",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Raw parameter string copied from the client-facing macro_call."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        }
      ],
      "example": {
        "type": "macro_call_ipc",
        "itr": 1,
        "macro_call_id": "mc_0123456789abcdef",
        "macro_name": "hello.hello",
        "param_string": "name=reader",
        "leaf_id": "l_0123456789ab"
      },
      "reply": {
        "text": "Immediate success: macro_result_ipc.",
        "links": [
          "macro_result_ipc"
        ]
      },
      "related": [
        "macro_result_ipc"
      ],
      "notes": [
        "macro_call_id values generated by the service use mc_ followed by 16 lowercase hexadecimal digits (eight random bytes). leaf_id is always serialized by Go encoding but may be the empty string for a call without leaf context."
      ]
    },
    {
      "id": "macro_info_request",
      "type": "macro_info_request",
      "struct": "MacroInfoRequest",
      "source": "pkg/protocol/macro.go",
      "category": "sys",
      "synopsis": "Requests metadata for named macros from a capability provider.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"macro_info_request\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "names",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Macro names whose metadata the daemon wants from this provider."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Origin correlation value when available; this frame’s notes describe when it may be empty or omitted."
        }
      ],
      "example": {
        "type": "macro_info_request",
        "itr": 1,
        "names": [
          "example"
        ],
        "request_id": "mi_c_0123456789ab"
      },
      "reply": {
        "text": "Immediate success: macro_info_response.",
        "links": [
          "macro_info_response"
        ]
      },
      "related": [
        "macro_info_response"
      ],
      "notes": []
    },
    {
      "id": "macro_info_response",
      "type": "macro_info_response",
      "struct": "MacroInfoResponse",
      "source": "pkg/protocol/macro.go",
      "category": "sys",
      "synopsis": "Returns macro descriptions, watchdog metadata, priority, version, and triggers requested from a capability provider.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"macro_info_response\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "macros",
          "go_type": "[]MacroInfo",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Macro metadata records for this connection; an empty list is accepted and still marks macro metadata received."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Usually echoes the metadata request ID, but the current handler ignores it and updates metadata by sending connection."
        }
      ],
      "example": {
        "type": "macro_info_response",
        "itr": 1,
        "macros": [
          {
            "name": "example"
          }
        ],
        "request_id": "mi_c_0123456789ab"
      },
      "reply": {
        "text": "Capability metadata response to macro_info_request; no further acknowledgement is sent.",
        "links": [
          "macro_info_request"
        ]
      },
      "related": [
        "macro_info_request",
        "announce"
      ],
      "notes": [
        "An omitted triggers array and an empty triggers array have the ordinary encoding distinction implied by omitempty. The current service does not impose an additional nil-versus-empty warning contract.",
        "Live sending connections may update registry metadata. On-demand typed RPC waits additionally require the matching request_id on that exact connection; startup readiness tracks its separately issued startup request IDs."
      ]
    },
    {
      "id": "macro_list",
      "type": "macro_list",
      "struct": "MacroList",
      "source": "pkg/protocol/macro.go",
      "category": "req",
      "synopsis": "Returns effective macro metadata records.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"macro_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "macros",
          "go_type": "[]MacroInfo",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Effective MacroInfo records after optional trigger filtering."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_macros request_id; the RPC dispatcher uses it to deliver this macro_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "macro_list",
        "itr": 1,
        "macros": [
          {
            "name": "example"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_macros; request_id supplies correlation.",
        "links": [
          "list_macros"
        ]
      },
      "related": [
        "list_macros"
      ],
      "notes": []
    },
    {
      "id": "macro_result",
      "type": "macro_result",
      "struct": "MacroResult",
      "source": "pkg/protocol/macro.go",
      "category": "req",
      "synopsis": "Returns the client-facing result of macro_call, including the generated internal macro call ID.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"macro_result\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "macro_call_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "required",
          "desc": "Generated internal macro call ID for every current macro_result frame: mc_ followed by 16 lowercase hex digits. It identifies the capability invocation behind this client-facing result."
        },
        {
          "name": "macro_name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Macro name copied from the admitted macro_call request."
        },
        {
          "name": "result",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Capability result text, or the operation error text when is_error is true."
        },
        {
          "name": "is_error",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "False for successful capability output; true for an error after macro admission or dispatch."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the initiating request_id, used by the RPC dispatcher to deliver this success response to its waiter."
        }
      ],
      "example": {
        "type": "macro_result",
        "itr": 1,
        "macro_name": "example.macro",
        "result": "result",
        "is_error": false,
        "request_id": "rpc_0123456789abcdef",
        "macro_call_id": "mc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to macro_call; request_id supplies correlation.",
        "links": [
          "macro_call"
        ]
      },
      "related": [
        "macro_call"
      ],
      "notes": [
        "Every current macro_result is built after macro admission and contains the generated mc_ plus 16-hex macro_call_id, even when dispatch or execution later fails.",
        "Pre-admission failures (for example an unknown macro or missing request_id) use error-correlated-response instead of macro_result."
      ]
    },
    {
      "id": "macro_result_ipc",
      "type": "macro_result_ipc",
      "struct": "MacroResultIPC",
      "source": "pkg/protocol/macro.go",
      "category": "sys",
      "synopsis": "Returns a macro capability’s text result or error status for one macro_call_ipc.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"macro_result_ipc\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "macro_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Pending macro call to claim. Empty, unknown, duplicate, cancelled, or timed-out IDs are accepted and ignored; useful delivery requires a live ID."
        },
        {
          "name": "result",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Macro result text; empty is accepted."
        },
        {
          "name": "is_error",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "optional",
          "desc": "true reports macro failure; false is the decoded default."
        }
      ],
      "example": {
        "type": "macro_result_ipc",
        "itr": 1,
        "macro_call_id": "mc_0123456789abcdef",
        "result": "result",
        "is_error": false
      },
      "reply": {
        "text": "Final capability response to macro_call_ipc, correlated by owning connection and macro_call_id; no result acknowledgement is sent.",
        "links": [
          "macro_call_ipc"
        ]
      },
      "related": [
        "macro_call_ipc"
      ],
      "notes": [
        "The handler validates the owning connection and macro_call_id before claiming the call and cancelling its watchdog. Unknown, duplicate, cancelled, or timed-out IDs are ignored and receive no acknowledgement.",
        "Timeouts use macro metadata, with a default 5s renewable inactivity watchdog and no implicit maximum. Explicit max_timeout remains terminal; timeout claims the operation. Caller-context cancellation unregisters it. Capability-connection cleanup eagerly aborts visible calls, and each waiter also observes closure of its selected provider connection so calls admitted during that sweep still complete. Results, timeouts, and disconnects share one terminal claim. Registry shutdown preserves pending calls until provider closure or another terminal producer completes them, even with both timers disabled. No macro-abort wire frame is sent; cancellation is local except that connection closure terminates the capability process/connection."
      ]
    },
    {
      "id": "message_end",
      "type": "message_end",
      "struct": "MessageEnd",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Finishes an assistant stream with its complete structured Message.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"message_end\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "message",
          "go_type": "Message",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Structured Message object; see the reusable Message schema for role, content blocks, tool calls, stop reason, usage, model, and provider."
        }
      ],
      "example": {
        "type": "message_end",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab",
        "message": {
          "role": "assistant",
          "content": [
            {
              "type": "thinking",
              "text": "Checked the source."
            },
            {
              "type": "text",
              "text": "Hello"
            }
          ],
          "stop_reason": "stop",
          "usage": {
            "input": 100,
            "output": 20,
            "cacheRead": 0,
            "cacheWrite": 0,
            "totalTokens": 120
          },
          "model": "gpt-5",
          "provider": "openai"
        }
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [
        "turn_start",
        "turn_end",
        "message_start",
        "message_update"
      ],
      "notes": [
        "Current producers set role assistant. content contains an optional thinking block followed by a text block; the complete Message may also carry tool calls, stop reason, usage, model, and provider."
      ]
    },
    {
      "id": "message_start",
      "type": "message_start",
      "struct": "MessageStart",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Starts an assistant stream with an empty structured Message.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"message_start\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "message",
          "go_type": "Message",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Structured Message object; see the reusable Message schema for role, content blocks, tool calls, stop reason, usage, model, and provider."
        }
      ],
      "example": {
        "type": "message_start",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab",
        "message": {
          "role": "assistant",
          "content": [],
          "usage": {
            "input": 0,
            "output": 0,
            "cacheRead": 0,
            "cacheWrite": 0,
            "totalTokens": 0
          }
        }
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [
        "turn_start",
        "turn_end",
        "message_update",
        "message_end"
      ],
      "notes": [
        "Current producers set message.role to assistant and content to an empty array. Subsequent message_update frames fill text/reasoning channels. Because Message.Usage is a non-pointer struct, Go encoding emits a zero-valued usage object despite its omitempty tag."
      ]
    },
    {
      "id": "message_update",
      "type": "message_update",
      "struct": "MessageUpdate",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Adds text or reasoning bytes to an assistant stream.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"message_update\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "delta_type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Stream channel, currently text_delta or reasoning_delta."
        },
        {
          "name": "delta",
          "go_type": "TextDelta",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "TextDelta carrying text for the channel named by delta_type."
        },
        {
          "name": "offset",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "UTF-8 byte offset where delta.text begins in this leaf/turn/channel stream."
        }
      ],
      "example": {
        "type": "message_update",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab",
        "delta_type": "text_delta",
        "delta": {
          "type": "text_delta",
          "text": "Hello"
        },
        "offset": 0
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [
        "turn_start",
        "turn_end",
        "message_start",
        "message_end"
      ],
      "notes": [
        "delta_type and delta.type are text_delta for visible text or reasoning_delta for thinking. offset is a byte index in the corresponding accumulated channel."
      ]
    },
    {
      "id": "model_list",
      "type": "model_list",
      "struct": "ModelList",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Returns effective model references and configured limits.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"model_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "models",
          "go_type": "[]ModelEntry",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Configured model references and their resolved limits/capabilities."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_models request_id; the RPC dispatcher uses it to deliver this model_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "model_list",
        "itr": 1,
        "models": [
          {
            "ref": "openai/gpt-5"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_models; request_id supplies correlation.",
        "links": [
          "list_models"
        ]
      },
      "related": [
        "list_models"
      ],
      "notes": []
    },
    {
      "id": "model_set",
      "type": "model_set",
      "struct": "ModelSet",
      "source": "pkg/protocol/turn.go",
      "category": "req",
      "synopsis": "Confirms the stored model and normalized thinking level.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"model_set\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Canonical provider/model reference applicable to this frame."
        },
        {
          "name": "thinking_level",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Model-specific canonical thinking level after normalization."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the set_model request_id; the RPC dispatcher uses it to deliver this model_set frame to the waiting call."
        }
      ],
      "example": {
        "type": "model_set",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "model": "openai/gpt-5",
        "request_id": "rpc_0123456789abcdef",
        "thinking_level": "medium"
      },
      "reply": {
        "text": "Success response to set_model; request_id supplies correlation.",
        "links": [
          "set_model"
        ]
      },
      "related": [
        "set_model"
      ],
      "notes": []
    },
    {
      "id": "notify_leaf",
      "type": "notify_leaf",
      "struct": "NotifyLeaf",
      "source": "pkg/protocol/session.go",
      "category": "fnf",
      "synopsis": "Publishes a one-way informational message to subscribers of an existing leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"notify_leaf\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Existing leaf whose subscribers receive the informational event."
        },
        {
          "name": "level",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Optional severity label. Empty defaults to info; any non-empty string is passed through."
        },
        {
          "name": "title",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Optional title prepended to message when non-empty; may be empty."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Optional body; may be empty, including when title is also empty."
        }
      ],
      "example": {
        "type": "notify_leaf",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "level": "info",
        "title": "Working",
        "message": "Operation completed."
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": [
          "error-async-event"
        ]
      },
      "related": [
        "error-async-event"
      ],
      "notes": [
        "Only leaf_id is currently validated as required. Empty level defaults to info; title and message may both be empty; any non-empty level is passed through without enum validation.",
        "Title is prepended to message when non-empty. Delivery is an informational broadcast; validation failures are asynchronous errors without request correlation."
      ]
    },
    {
      "id": "plugin_call",
      "type": "plugin_call",
      "struct": "PluginCallIPC",
      "source": "pkg/protocol/plugin.go",
      "category": "sys",
      "synopsis": "Invokes one plugin over pending turns and opaque string configuration.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"plugin_call\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "plugin_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Daemon-generated plugin call ID: pc_ plus 16 lowercase hex digits."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Plugin capability name selected for this pipeline stage."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "cwd",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Operation working directory; an empty value means no cwd context."
        },
        {
          "name": "role",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Kind of the draft entering this plugin stage, such as user or tool_result."
        },
        {
          "name": "pending_turns",
          "go_type": "[]PendingTurn",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Ordered semantic pending turns, including optional steer context from clients or upstream plugins; see PendingTurn."
        },
        {
          "name": "config",
          "go_type": "map[string]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque string values. List-like values are raw JSON-array strings."
        }
      ],
      "example": {
        "type": "plugin_call",
        "itr": 1,
        "plugin_call_id": "pc_0123456789abcdef",
        "name": "main_systemprompt",
        "leaf_id": "l_0123456789ab",
        "root_id": "r_0123456789ab",
        "cwd": "/workspace",
        "role": "user",
        "pending_turns": [
          {
            "kind": "user",
            "content_type": "text",
            "content": "hello"
          }
        ],
        "config": {
          "active_tools": "[\"run-cmd\",\"buffer\"]",
          "active_plugins": "[\"main_systemprompt\"]"
        }
      },
      "reply": {
        "text": "Immediate success: plugin_result.",
        "links": [
          "plugin_result"
        ]
      },
      "related": [
        "plugin_result"
      ],
      "notes": [
        "plugin_call_id values generated by the service use pc_ followed by 16 lowercase hexadecimal digits (eight random bytes).",
        "config is map[string]string at the frame layer. Values are opaque strings; list-like settings are normally raw JSON arrays such as [\"run-cmd\",\"buffer\"], not CSV."
      ]
    },
    {
      "id": "plugin_info_request",
      "type": "plugin_info_request",
      "struct": "PluginInfoRequest",
      "source": "pkg/protocol/plugin.go",
      "category": "sys",
      "synopsis": "Requests metadata for named plugins from a capability provider.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"plugin_info_request\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "names",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Plugin names whose metadata the daemon wants from this provider."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Origin correlation value when available; this frame’s notes describe when it may be empty or omitted."
        }
      ],
      "example": {
        "type": "plugin_info_request",
        "itr": 1,
        "names": [
          "example"
        ],
        "request_id": "pi_c_0123456789ab"
      },
      "reply": {
        "text": "Immediate success: plugin_info_response.",
        "links": [
          "plugin_info_response"
        ]
      },
      "related": [
        "plugin_info_response"
      ],
      "notes": []
    },
    {
      "id": "plugin_info_response",
      "type": "plugin_info_response",
      "struct": "PluginInfoResponse",
      "source": "pkg/protocol/plugin.go",
      "category": "sys",
      "synopsis": "Returns plugin names, descriptions, and priorities requested from a capability provider.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"plugin_info_response\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "plugins",
          "go_type": "[]PluginInfo",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Plugin metadata records for this connection; an empty list is accepted and still marks plugin metadata received."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Usually echoes the metadata request ID, but the current handler ignores it and updates metadata by sending connection."
        }
      ],
      "example": {
        "type": "plugin_info_response",
        "itr": 1,
        "plugins": [
          {
            "name": "example"
          }
        ],
        "request_id": "pi_c_0123456789ab"
      },
      "reply": {
        "text": "Capability metadata response to plugin_info_request; no further acknowledgement is sent.",
        "links": [
          "plugin_info_request"
        ]
      },
      "related": [
        "plugin_info_request",
        "announce"
      ],
      "notes": [
        "Live sending connections may update registry metadata. On-demand typed RPC waits additionally require the matching request_id on that exact connection; startup readiness tracks its separately issued startup request IDs."
      ]
    },
    {
      "id": "plugin_list",
      "type": "plugin_list",
      "struct": "PluginList",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Returns effective plugin names.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"plugin_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "plugins",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Effective plugin names for the selected configuration context."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_plugins request_id; the RPC dispatcher uses it to deliver this plugin_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "plugin_list",
        "itr": 1,
        "plugins": [
          "example"
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_plugins; request_id supplies correlation.",
        "links": [
          "list_plugins"
        ]
      },
      "related": [
        "list_plugins"
      ],
      "notes": []
    },
    {
      "id": "plugin_result",
      "type": "plugin_result",
      "struct": "PluginResultIPC",
      "source": "pkg/protocol/plugin.go",
      "category": "sys",
      "synopsis": "Returns a plugin’s transformed pending turns or error status for one plugin_call.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"plugin_result\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "plugin_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Pending plugin call to claim. Empty, unknown, duplicate, cancelled, or timed-out IDs are accepted and ignored; useful delivery requires a live ID."
        },
        {
          "name": "pending_turns",
          "go_type": "[]PendingTurn",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Transformed pending turns, including optional steer context on synthetic user turns for downstream plugins; an empty or omitted array is accepted at this handler and later use applies pending-turn validation."
        },
        {
          "name": "is_error",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "optional",
          "desc": "true reports plugin failure; false is the decoded default."
        }
      ],
      "example": {
        "type": "plugin_result",
        "itr": 1,
        "plugin_call_id": "pc_0123456789abcdef",
        "pending_turns": [
          {
            "kind": "user"
          }
        ],
        "is_error": false
      },
      "reply": {
        "text": "Final capability response to plugin_call, correlated by owning connection and plugin_call_id; no result acknowledgement is sent.",
        "links": [
          "plugin_call"
        ]
      },
      "related": [
        "plugin_call"
      ],
      "notes": [
        "The handler validates the owning connection and plugin_call_id before claiming the call and cancelling its watchdog. Unknown, duplicate, or already-timed-out IDs are ignored and receive no acknowledgement.",
        "The default watchdog is 5s of inactivity with no implicit elapsed-time maximum. Timeout claims the operation and resumes the pipeline with an error; caller-context cancellation unregisters it. Closure of the captured provider connection also claims a terminal error, without relying on timers. Registry shutdown preserves pending claims until terminal delivery. Plugin failures/timeouts leave the pipeline able to continue with the original turns. No plugin_abort wire frame is sent; cancellation is local to the daemon-side wait.",
        "pending_turns are validated before persistence when used; is_error causes the plugin call to fail rather than admitting the returned list."
      ]
    },
    {
      "id": "prompt",
      "type": "prompt",
      "struct": "Prompt",
      "source": "pkg/protocol/agent.go",
      "category": "req",
      "synopsis": "Submits one validated user turn to a leaf and requests immediate admission into an agent run.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"prompt\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "parent_turn_id",
          "go_type": "*string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Optional placement hint for the user prompt; encoded as a string or null because the field has no omitempty."
        },
        {
          "name": "turn",
          "go_type": "PendingTurn",
          "json_tag": "always",
          "validation": "required",
          "desc": "Must be a valid user PendingTurn: kind user; content_type empty or text; optional steer timing context; no tool identity, synthetic reference, or assistant-only advanced fields. advanced.other_meta is allowed as validated free-form JSON object text; attachment rules still apply."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque prompt correlation ID echoed by prompt_accepted or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "prompt",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "parent_turn_id": null,
        "turn": {
          "kind": "user",
          "content_type": "text",
          "content": "Explain the API."
        },
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success is prompt_accepted; error-correlated-response is immediate failure. prompt_completed is a later event sent to the run origin.",
        "links": [
          "prompt_accepted",
          "error-correlated-response",
          "prompt_completed"
        ]
      },
      "related": [
        "prompt_accepted",
        "error-correlated-response",
        "prompt_completed",
        "agent_start"
      ],
      "notes": [
        "Immediate success is prompt_accepted (or correlated error). prompt_completed is a later terminal lifecycle event, not the immediate RPC success response. Requester acceptance is a liveness check before recovery or mutation. Disconnect before that check rejects the request without appending input or starting an Agent. Once accepted, prompt work belongs to the leaf rather than the requester connection and continues normally after disconnect."
      ]
    },
    {
      "id": "prompt_accepted",
      "type": "prompt_accepted",
      "struct": "PromptAccepted",
      "source": "pkg/protocol/agent.go",
      "category": "req",
      "synopsis": "Confirms prompt admission and returns the created turn IDs and authoritative tip.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"prompt_accepted\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_ids",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted turn IDs created while admitting the prompt."
        },
        {
          "name": "tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Authoritative leaf tip after prompt admission."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the prompt request_id; the RPC dispatcher uses it to deliver this prompt_accepted frame to the waiting call."
        }
      ],
      "example": {
        "type": "prompt_accepted",
        "itr": 1,
        "root_id": "r_0123456789ab",
        "leaf_id": "l_0123456789ab",
        "turn_ids": [
          "t_0123456789ab"
        ],
        "tip_turn_id": "t_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success response to prompt; agent lifecycle and prompt_completed follow later.",
        "links": [
          "prompt",
          "prompt_completed",
          "agent_start"
        ]
      },
      "related": [
        "prompt",
        "prompt_completed",
        "agent_start"
      ],
      "notes": [
        "This is the immediate prompt RPC success. It is also a registered frontend event type, so a matched frame can be delivered to both the RPC waiter and OnPromptAccepted; prompt_completed remains the later terminal origin event."
      ]
    },
    {
      "id": "prompt_completed",
      "type": "prompt_completed",
      "struct": "PromptCompleted",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Reports the later terminal outcome of the run started by an accepted prompt.",
      "direction": {
        "from": "daemon",
        "to": "originating prompt connection"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"prompt_completed\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "reason",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Terminal run reason; normal completion is stop, with error and abort on those paths."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional explanatory text for error or abort completion."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Originating prompt correlation when available; omitted otherwise."
        }
      ],
      "example": {
        "type": "prompt_completed",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "root_id": "r_0123456789ab",
        "reason": "stop",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Later origin event, not the immediate prompt RPC response; no acknowledgement.",
        "links": [
          "prompt",
          "prompt_accepted"
        ]
      },
      "related": [
        "prompt",
        "prompt_accepted",
        "agent_end"
      ],
      "notes": [
        "The normal terminal reason is stop. Other current terminal paths include error and abort.",
        "request_id has omitempty and is included only when correlation remains available; consumers must not require it on every terminal frame."
      ]
    },
    {
      "id": "provider_list",
      "type": "provider_list",
      "struct": "ProviderList",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Returns configured provider endpoints and model metadata.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"provider_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "providers",
          "go_type": "[]ProviderListEntry",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Configured provider records and their optional model metadata."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_providers request_id; the RPC dispatcher uses it to deliver this provider_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "provider_list",
        "itr": 1,
        "providers": [
          {
            "name": "openai",
            "type": "openai",
            "base_url": "https://api.openai.com/v1",
            "models": [
              {
                "name": "gpt-5",
                "max_context": 400000,
                "max_tokens": 128000,
                "thinking_levels": [
                  "low",
                  "medium",
                  "high"
                ],
                "zdr_supported": false
              }
            ]
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_providers; request_id supplies correlation.",
        "links": [
          "list_providers"
        ]
      },
      "related": [
        "list_providers"
      ],
      "notes": []
    },
    {
      "id": "queued_list",
      "type": "queued_list",
      "struct": "QueuedList",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns queued pending messages for a loaded leaf.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"queued_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "messages",
          "go_type": "[]QueuedMessage",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Pending queued messages for the requested loaded leaf. Each nested PendingTurn preserves optional steer timing context; see QueuedMessage and PendingTurn."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_queued request_id; the RPC dispatcher uses it to deliver this queued_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "queued_list",
        "itr": 1,
        "messages": [
          {
            "turn_id": "t_0123456789ab",
            "parent_turn_id": "t_111111111111",
            "turn": {
              "kind": "user"
            },
            "request_id": "rpc_0123456789abcdef",
            "timestamp": "2026-07-27T12:00:00Z"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_queued; request_id supplies correlation.",
        "links": [
          "list_queued"
        ]
      },
      "related": [
        "list_queued"
      ],
      "notes": []
    },
    {
      "id": "remove_tool",
      "type": "remove_tool",
      "struct": "RemoveTool",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Removes one tool name from a leaf’s active tool selection.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"remove_tool\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Tool capability name in this frame’s operation context."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque remove_tool correlation ID echoed by tool_removed or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "remove_tool",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "tool_name": "example.tool",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: tool_removed. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "tool_removed",
          "error-correlated-response"
        ]
      },
      "related": [
        "tool_removed",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "question_reply",
      "type": "question_reply",
      "struct": "QuestionReply",
      "source": "pkg/protocol/question.go",
      "category": "req",
      "synopsis": "Answers the exact revision of one daemon-owned leaf question.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"question_reply\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID whose pending question is being answered."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Question kind. The only accepted value is project_config_trust."
        },
        {
          "name": "revision",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Nonempty opaque question revision copied exactly from the pending snapshot. Stale revisions are rejected by the question owner."
        },
        {
          "name": "reply",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Decision for project_config_trust. Accepted values are trust and reject."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque correlation ID echoed by question_reply_ack or a correlated error."
        }
      ],
      "example": {
        "type": "question_reply",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "kind": "project_config_trust",
        "revision": "sha256:0123456789abcdef",
        "reply": "trust",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: question_reply_ack. Validation or owner rejection returns a correlated error.",
        "links": [
          "question_reply_ack",
          "error-correlated-response"
        ]
      },
      "related": [
        "question_reply_ack",
        "leaf_updated",
        "error-correlated-response"
      ],
      "notes": [
        "The daemon accepts only project_config_trust with a nonempty revision and reply trust or reject. This frame does not create questions and is not routed through tools or macros.",
        "After durably accepting one exact current revision, the daemon enqueues question_reply_ack before the replying leaf's fresh leaf_updated snapshot, releases that leaf gate, then takes one other leaf gate at a time to publish fresh complete snapshots for every loaded or followed leaf with the same canonical current CWD/config identity. If acknowledgement enqueue fails, it still performs fan-out before returning the send error. Dormant leaves reconcile on their next sync; duplicate or concurrent replies after the first decision receive question_not_found. If the project bytes changed before the reply, fresh snapshots replace the stale question for matching loaded or followed leaves. If the config disappeared or current inspection fails, the previously observed leaf-scoped revision selects matching live leaves whose fresh snapshots clear the obsolete question; no decision is persisted."
      ]
    },
    {
      "id": "question_reply_ack",
      "type": "question_reply_ack",
      "struct": "QuestionReplyAck",
      "source": "pkg/protocol/question.go",
      "category": "req",
      "synopsis": "Acknowledges a resolved pending-question revision.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"question_reply_ack\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID whose pending question is being answered."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Question kind. The only accepted value is project_config_trust."
        },
        {
          "name": "revision",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Nonempty opaque question revision copied exactly from the pending snapshot. Stale revisions are rejected by the question owner."
        },
        {
          "name": "reply",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Decision for project_config_trust. Accepted values are trust and reject."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque correlation ID echoed by question_reply_ack or a correlated error."
        }
      ],
      "example": {
        "type": "question_reply_ack",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "kind": "project_config_trust",
        "revision": "sha256:0123456789abcdef",
        "reply": "trust",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to question_reply; request_id supplies correlation.",
        "links": [
          "question_reply"
        ]
      },
      "related": [
        "question_reply",
        "leaf_updated"
      ]
    },
    {
      "id": "rename_leaf",
      "type": "rename_leaf",
      "struct": "RenameLeaf",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Changes a leaf’s display name.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"rename_leaf\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Requested leaf display name; the current handler accepts an empty string."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque rename_leaf correlation ID echoed by leaf_renamed or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "rename_leaf",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "name": "example",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_renamed. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_renamed",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_renamed",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "report_progress",
      "type": "report_progress",
      "struct": "ReportProgress",
      "source": "pkg/protocol/progress.go",
      "category": "fnf",
      "synopsis": "Creates, replaces, or removes one transient connection-owned status item, independent of tool invocation state.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"report_progress\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Positive values order progress ingestion per owner, leaf, current sent turn, and update_id. Omitted or unusable values retain compatibility arrival-order behavior without erasing positive iteration history."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "update_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Connection-owned progress item key within the leaf; validated as non-empty, control-free UTF-8 up to 256 bytes."
        },
        {
          "name": "enabled",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Operation selector. Omission decodes as false and is accepted as a clear/remove operation; true creates or replaces an item and makes title validation applicable."
        },
        {
          "name": "title",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Required only for enabled=true; non-empty, control-free UTF-8 up to 256 bytes."
        },
        {
          "name": "lines",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional display lines for enabled=true: at most five, each valid UTF-8 up to 1024 bytes; tabs are allowed."
        },
        {
          "name": "visualizer_macro",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Optional visualizer macro name. It and visualizer_type are both required or both absent; valid control-free UTF-8, at most 256 bytes. Disabled reports cannot contain a descriptor."
        },
        {
          "name": "visualizer_type",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Opaque visualizer descriptor type paired with visualizer_macro. The TUI recognizes only the exact ruby.workflow//0.1 contract; unknown types retain ordinary progress fallback."
        }
      ],
      "example": {
        "type": "report_progress",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab",
        "update_id": "compile",
        "enabled": true,
        "title": "Building documentation",
        "lines": [
          "Catalog reconciled",
          "Validating links"
        ]
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": [
          "error-async-event"
        ]
      },
      "related": [
        "error-async-event"
      ],
      "notes": [
        "Identifiers are required valid UTF-8, at most 256 bytes, and reject C0/C1 controls. When enabled is true, title is required (256 bytes maximum), up to 5 lines are allowed, and each line is at most 1024 bytes; tabs are allowed only in lines.",
        "There are no item-count caps per leaf, owning connection, or server. Per-item payload limits still apply. update_id is a generic producer-selected status key, not an inferred tool-call ID; an active item's ownership cannot be taken over by another connection.",
        "After current-turn, live-connection, active-item ownership, and visualizer ownership validation, a positive itr at or below the accepted high-water mark for that owner, leaf, sent turn, and update_id is silently ignored. A newer identical replacement or absent clear still advances that mark, so an older delayed enable cannot replace it. Independent keys do not share ordering history; this is progress-local ingestion, not a connection-wide lower-itr rejection, callback FIFO guarantee, or execution barrier.",
        "Omitted, zero, negative, or otherwise unusable itr values keep compatibility arrival-order behavior and do not discard positive high-water history. Ordering records retain only owner, update_id, and iteration, not old summary payloads. Cleared IDs are not reserved against other owners. Records have no count limits or eviction policy and are removed on owner disconnect, leaf deletion, or authoritative sent-turn change, including discovered transitions and gate-held rewind. Records-only changes do not publish redundant snapshots.",
        "An identical replacement or clear of an absent item does not rebuild or publish a leaf snapshot after current-turn and ownership validation. A newly discovered authoritative sent-turn transition still clears old statuses and publishes the complete affected leaf snapshot, even when the triggering report is stale or otherwise redundant.",
        "A status published once remains in service RAM until its producer clears it, its connection disconnects or dies, or the authoritative sent turn changes. No subscriber or periodic refresh is required. Queued drafts do not clear the current sent-turn statuses. leaf_stats, leaf switching, and reconnect replay recover retained current statuses; a late old-turn report cannot resurrect them. Producers must clear statuses when their work ends.",
        "A stale turn_id update is silently dropped. Other rejection is reported as an asynchronous error with code progress_rejected and no request_id; report_progress remains one-way.",
        "A visualizer descriptor is admitted only when visualizer_macro names a currently live runtime macro owned by the reporting connection and visible in ordinary unfiltered macro listing. Missing, wrong-owner, and config-only names are rejected. visualizer_type is otherwise opaque.",
        "Inbound and spawned peers receive fresh connection IDs for each lifetime; IDs are never intentionally reused. Disconnect removes the owner's runtime macros, subscriptions, and transient progress, but does not cancel accepted leaf work. Delayed reports from a disconnected connection are rejected after the leaf-gate wait. Deferred sends retain the old destination and cannot target a restarted provider."
      ]
    },
    {
      "id": "resolve_models",
      "type": "resolve_models",
      "struct": "ResolveModels",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Resolves effective main, small, and audit model references.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"resolve_models\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque resolve_models correlation ID echoed by resolved_models or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "resolve_models",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: resolved_models. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "resolved_models",
          "error-correlated-response"
        ]
      },
      "related": [
        "resolved_models",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "resolved_models",
      "type": "resolved_models",
      "struct": "ResolvedModels",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Returns resolved main, small, and audit model references.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"resolved_models\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "main",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Resolved primary model reference."
        },
        {
          "name": "small",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Resolved lower-cost/smaller-task model reference."
        },
        {
          "name": "audit",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Resolved audit/review model reference."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the resolve_models request_id; the RPC dispatcher uses it to deliver this resolved_models frame to the waiting call."
        }
      ],
      "example": {
        "type": "resolved_models",
        "itr": 1,
        "main": "openai/gpt-5",
        "small": "openai/gpt-5-mini",
        "audit": "anthropic/claude-sonnet-4-5",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to resolve_models; request_id supplies correlation.",
        "links": [
          "resolve_models"
        ]
      },
      "related": [
        "resolve_models"
      ],
      "notes": []
    },
    {
      "id": "rewind_leaf",
      "type": "rewind_leaf",
      "struct": "RewindLeaf",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Atomically compares and moves an idle or unloaded leaf tip to a retained proper ancestor, optionally admitting replay generation.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"rewind_leaf\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "current_tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Expected nonempty canonical tip. A mismatch fails with turn_conflict and does not mutate history."
        },
        {
          "name": "new_tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Retained proper ancestor to select. The required empty string value denotes the earliest legal target: the root boundary before the first turn."
        },
        {
          "name": "replay",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Defaults false. True also admits a fresh generation from retained canonical context with no new input."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque correlation ID echoed by leaf_rewound or a correlated error. ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "rewind_leaf",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "current_tip_turn_id": "t_feedface0002",
        "new_tip_turn_id": "t_feedface0001",
        "replay": true,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success is leaf_rewound; failure is a correlated error. Subscribers separately receive canonical leaf_updated. Replay lifecycle starts only after both are enqueued.",
        "links": [
          "leaf_rewound",
          "error-correlated-response",
          "leaf_updated",
          "agent_start",
          "prompt_completed"
        ]
      },
      "related": [
        "leaf_rewound",
        "leaf_updated",
        "agent_start",
        "agent_end",
        "prompt_completed"
      ],
      "notes": [
        "Only idle, background, or unloaded leaves are accepted. Running, aborting, terminalizing, and prompt- or replay-reserved leaves fail with leaf_busy. Admission is serialized with prompt and load/unload; clients must not rely on a prior state snapshot.",
        "The current tip must match exactly. The new tip must be a proper physical ancestor; the current tip itself, descendants, sibling branches, unrelated roots, and unknown IDs fail with invalid_rewind_target. Stale expected tips fail with turn_conflict.",
        "The operation moves only the leaf tip and timestamps. It retains all turn rows and does not change sibling leaf tips. RPC failure does not mutate history.",
        "With replay false an unloaded leaf stays unloaded. With replay true the service loads if needed, clears provider continuation/native-history caches, uses current model/config, and generates from retained context without a duplicate input or pre-plugin/plugin preprocessing. New tool activity and later input use normal processing.",
        "leaf_rewound acknowledges durable rewind and replay admission, not generation success. Requester acceptance checks liveness under the leaf gate before history mutation. Disconnect before acceptance rejects without changing history or loading an Agent. Once accepted, replay continues normally after requester disconnect. Replay uses normal stream, agent_end, prompt_completed, outcome, and durable failure behavior; no-new-input setup failures append a sent error turn."
      ]
    },
    {
      "id": "root_list",
      "type": "root_list",
      "struct": "RootList",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns persisted root projections.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"root_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "roots",
          "go_type": "[]RootInfo",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted roots with cwd, root-turn identity, timestamps, and optional lifecycle metadata."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_roots request_id; the RPC dispatcher uses it to deliver this root_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "root_list",
        "itr": 1,
        "roots": [
          {
            "id": "r_0123456789ab",
            "cwd": "/workspace",
            "root_turn_id": "t_0123456789ab",
            "created_at": "2026-07-27T11:00:00Z",
            "updated_at": "2026-07-27T12:00:00Z"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_roots; request_id supplies correlation.",
        "links": [
          "list_roots"
        ]
      },
      "related": [
        "list_roots"
      ],
      "notes": []
    },
    {
      "id": "set_leaf_config",
      "type": "set_leaf_config",
      "struct": "SetLeafConfig",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Stores one opaque configuration string on a leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"set_leaf_config\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "key",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque per-leaf configuration key addressed by this operation."
        },
        {
          "name": "value",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Opaque string value stored for the configuration key; list-like settings commonly contain raw JSON arrays."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque set_leaf_config correlation ID echoed by leaf_config_set or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "set_leaf_config",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "key": "example.key",
        "value": "example value",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_config_set. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_config_set",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_config_set",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "set_model",
      "type": "set_model",
      "struct": "SetModel",
      "source": "pkg/protocol/turn.go",
      "category": "req",
      "synopsis": "Validates and stores a new model for a leaf, normalizing its thinking level.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"set_model\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Canonical provider/model reference applicable to this frame."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque set_model correlation ID echoed by model_set or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "set_model",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "model": "openai/gpt-5",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: model_set. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "model_set",
          "error-correlated-response"
        ]
      },
      "related": [
        "model_set",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "set_thinking_level",
      "type": "set_thinking_level",
      "struct": "SetThinkingLevel",
      "source": "pkg/protocol/turn.go",
      "category": "req",
      "synopsis": "Requests a model-specific thinking level for a leaf and normalizes it against that leaf’s current model.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"set_thinking_level\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "level",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Requested model thinking level. Empty or unsupported values are normalized against the leaf’s current model rather than rejected."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque set_thinking_level correlation ID echoed by thinking_level_set or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "set_thinking_level",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "level": "medium",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: thinking_level_set. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "thinking_level_set",
          "error-correlated-response"
        ]
      },
      "related": [
        "thinking_level_set",
        "error-correlated-response"
      ],
      "notes": [
        "level is model thinking configuration, not informational severity. The service normalizes the requested value against the leaf’s current model; empty or unsupported input may therefore return a different canonical value."
      ]
    },
    {
      "id": "shutdown-daemon-request",
      "type": "shutdown",
      "struct": "Shutdown",
      "source": "pkg/protocol/lifecycle.go",
      "category": "fnf",
      "synopsis": "Requests daemon shutdown and relies on connection closure rather than an acknowledgement.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"shutdown\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional shutdown reason/correlation-shaped string. The daemon stop helper sends an empty value, so Go encoding omits the key; no response is correlated."
        }
      ],
      "example": {
        "type": "shutdown",
        "itr": 1
      },
      "reply": {
        "text": "No shutdown acknowledgement frame is defined.",
        "links": []
      },
      "related": [],
      "notes": [
        "The daemon stop client sends this frame and waits for connection closure. request_id is optional and the current stop path does not send a correlated success reply."
      ]
    },
    {
      "id": "shutdown-module-request",
      "type": "shutdown",
      "struct": "Shutdown",
      "source": "pkg/protocol/lifecycle.go",
      "category": "fnf",
      "synopsis": "Requests shutdown of a capability peer using the shared shutdown wire shape.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"shutdown\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional reason value carried in the shared Shutdown struct. No shutdown acknowledgement or request_id correlation is defined."
        }
      ],
      "example": {
        "type": "shutdown",
        "itr": 1
      },
      "reply": {
        "text": "No shutdown acknowledgement frame is defined.",
        "links": []
      },
      "related": [],
      "notes": [
        "The EzAgent API exposes the same Shutdown struct and daemon-to-capability send helper. request_id is optional; no distinct shutdown acknowledgement type exists."
      ]
    },
    {
      "id": "steer",
      "type": "steer",
      "struct": "Steer",
      "source": "pkg/protocol/agent.go",
      "category": "req",
      "synopsis": "Adds a user steer or admits an outstanding tool result against a leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"steer\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "parent_turn_id",
          "go_type": "*string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Optional for a user steer. Required for tool_result steer and must equal the loaded agent’s current tip."
        },
        {
          "name": "turn",
          "go_type": "PendingTurn",
          "json_tag": "always",
          "validation": "required",
          "desc": "Must have kind user or tool_result. User rules match prompt, including optional steer timing context and validated advanced.other_meta. Unspecified user steer becomes true only at active assistant/tool admission; an idle follow-up is not classified solely by endpoint. Explicit true/false is preserved. tool_result is validated against an outstanding tool call."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque steer correlation ID echoed by steer_accepted or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "steer",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "parent_turn_id": null,
        "turn": {
          "kind": "user",
          "content_type": "text",
          "content": "Focus on wire details."
        },
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: steer_accepted. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "steer_accepted",
          "error-correlated-response"
        ]
      },
      "related": [
        "steer_accepted",
        "error-correlated-response"
      ],
      "notes": [
        "Requester acceptance checks liveness before queue or history mutation. Disconnect before that check rejects the request. Accepted steer work retains its existing processing behavior after requester disconnect, including queued work retained after a prompt append failure."
      ]
    },
    {
      "id": "steer_accepted",
      "type": "steer_accepted",
      "struct": "SteerAccepted",
      "source": "pkg/protocol/agent.go",
      "category": "req",
      "synopsis": "Confirms steer/tool-result admission and the resulting turn IDs and tip.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"steer_accepted\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_ids",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted turn IDs created while admitting the steer or tool result."
        },
        {
          "name": "tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Authoritative leaf tip after steer admission."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the steer request_id; the RPC dispatcher uses it to deliver this steer_accepted frame to the waiting call."
        }
      ],
      "example": {
        "type": "steer_accepted",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_ids": [
          "t_0123456789ab"
        ],
        "tip_turn_id": "t_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to steer; request_id supplies correlation.",
        "links": [
          "steer"
        ]
      },
      "related": [
        "steer"
      ],
      "notes": [
        "This is the immediate steer success response and is also delivered through the frontend event handler when configured."
      ]
    },
    {
      "id": "supported_filetypes_response",
      "type": "supported_filetypes_response",
      "struct": "SupportedFiletypesResponse",
      "source": "pkg/protocol/config.go",
      "category": "req",
      "synopsis": "Returns the exact supported attachment MIME groups.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"supported_filetypes_response\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "filetypes",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Current supported groups, exactly image/* and application/pdf."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the get_supported_filetypes request_id; the RPC dispatcher uses it to deliver this supported_filetypes_response frame to the waiting call."
        }
      ],
      "example": {
        "type": "supported_filetypes_response",
        "itr": 1,
        "filetypes": [
          "image/*",
          "application/pdf"
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to get_supported_filetypes; request_id supplies correlation.",
        "links": [
          "get_supported_filetypes"
        ]
      },
      "related": [
        "get_supported_filetypes"
      ],
      "notes": []
    },
    {
      "id": "switch_leaf",
      "type": "switch_leaf",
      "struct": "SwitchLeaf",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Moves the requesting connection’s subscription to another existing leaf.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"switch_leaf\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque switch_leaf correlation ID echoed by leaf_switched or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "switch_leaf",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_switched. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_switched",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_switched",
        "error-correlated-response"
      ],
      "notes": ["If a newer subscription selection or successful feed drop overtakes a delayed switch, the older switch is acknowledged without replacing the newer state or replaying its stale snapshot."]
    },
    {
      "id": "thinking_level_set",
      "type": "thinking_level_set",
      "struct": "ThinkingLevelSet",
      "source": "pkg/protocol/turn.go",
      "category": "req",
      "synopsis": "Returns the canonical model thinking level stored for a leaf.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"thinking_level_set\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "level",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Canonical model thinking level, for example off, low, medium, or high when supported by the selected model."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the set_thinking_level request_id; the RPC dispatcher uses it to deliver this thinking_level_set frame to the waiting call."
        }
      ],
      "example": {
        "type": "thinking_level_set",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "level": "medium",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to set_thinking_level; request_id supplies correlation.",
        "links": [
          "set_thinking_level"
        ]
      },
      "related": [
        "set_thinking_level"
      ],
      "notes": [
        "level is the normalized model thinking level stored for the leaf. It is unrelated to informational/notification levels."
      ]
    },
    {
      "id": "tool_abort",
      "type": "tool_abort",
      "struct": "ToolAbort",
      "source": "pkg/protocol/tool.go",
      "category": "sys",
      "synopsis": "Requests cooperative provider cancellation of one in-flight tool call.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_abort\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "In-flight tool call the provider should cancel cooperatively."
        }
      ],
      "example": {
        "type": "tool_abort",
        "itr": 1,
        "tool_call_id": "call_tool_01"
      },
      "reply": {
        "text": "The provider should stop cooperatively and may send tool_abort_ack; the daemon pending path is already completed on explicit abort.",
        "links": [
          "tool_call",
          "tool_abort_ack"
        ]
      },
      "related": [
        "tool_call",
        "tool_abort_ack"
      ],
      "notes": [
        "This frame is sent for explicit leaf abort, not by the current watchdog-expiry callback. Cancellation is cooperative at the provider process, while the daemon immediately invalidates/completes its pending result path."
      ]
    },
    {
      "id": "tool_abort_ack",
      "type": "tool_abort_ack",
      "struct": "ToolAbortAck",
      "source": "pkg/protocol/tool.go",
      "category": "sys",
      "synopsis": "Acknowledges a tool cancellation request.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_abort_ack\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Outstanding tool call to complete as aborted. Empty, unknown, duplicate, or late IDs are accepted and ignored; useful acknowledgement requires a live pending ID."
        }
      ],
      "example": {
        "type": "tool_abort_ack",
        "itr": 1,
        "tool_call_id": "call_tool_01"
      },
      "reply": {
        "text": "One-way cancellation acknowledgement; the daemon sends no response.",
        "links": [
          "tool_abort",
          "tool_call"
        ]
      },
      "related": [
        "tool_abort",
        "tool_call"
      ],
      "notes": [
        "Handling requires the outstanding tool_call_id and its owning connection. It cancels the watchdog and claims/completes that call as aborted; unknown, duplicate, or already-claimed IDs are silently ignored.",
        "An explicit leaf abort normally already claims/completes the pending path, so a later acknowledgement commonly finds no entry. No acknowledgement is sent for tool_abort_ack."
      ]
    },
    {
      "id": "tool_ack",
      "type": "tool_ack",
      "struct": "ToolAck",
      "source": "pkg/protocol/tool.go",
      "category": "sys",
      "synopsis": "Optionally declares per-call parallel scheduling intent before the result.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_ack\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Outstanding tool call to acknowledge. Empty, unknown, duplicate, or late IDs are accepted and ignored; useful scheduling requires a live pending ID."
        },
        {
          "name": "parallel",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Optional scheduling intent in semantic terms; false (including a decoded zero value) preserves sequential scheduling."
        }
      ],
      "example": {
        "type": "tool_ack",
        "itr": 1,
        "tool_call_id": "call_tool_01",
        "parallel": false
      },
      "reply": {
        "text": "One-way scheduling signal; no acknowledgement. A final tool_result is still required unless cancellation invalidates the call.",
        "links": [
          "tool_call",
          "tool_result"
        ]
      },
      "related": [
        "tool_call",
        "tool_result"
      ],
      "notes": [
        "Admission requires the outstanding tool_call_id and its owning connection. The first ack for an outstanding unclaimed call is accepted; duplicate or late acks and unknown IDs are silently ignored.",
        "parallel:true releases the scheduler to overlap later calls, but does not complete this call; source-order result admission is preserved. No acknowledgement is sent for tool_ack."
      ]
    },
    {
      "id": "tool_added",
      "type": "tool_added",
      "struct": "ToolAdded",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Confirms addition of a tool name to a leaf selection.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_added\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Tool capability name in this frame’s operation context."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the add_tool request_id; the RPC dispatcher uses it to deliver this tool_added frame to the waiting call."
        }
      ],
      "example": {
        "type": "tool_added",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "tool_name": "example.tool",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to add_tool; request_id supplies correlation.",
        "links": [
          "add_tool"
        ]
      },
      "related": [
        "add_tool"
      ],
      "notes": []
    },
    {
      "id": "tool_call",
      "type": "tool_call",
      "struct": "ToolCallIPC",
      "source": "pkg/protocol/tool.go",
      "category": "sys",
      "synopsis": "Invokes one named tool with decoded arguments and leaf/root/cwd context.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_call\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Daemon-generated trusted opaque invocation ID, used to correlate IPC scheduling, result, abort, acknowledgement, heartbeat, watchdog, progress, and runtime-status frames. Capability modules must echo it exactly. It is not the provider/model tool-call ID, which remains conversation data."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Tool capability name selected by the model."
        },
        {
          "name": "arguments",
          "go_type": "map[string]interface{}",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Decoded JSON argument object supplied to a tool."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "cwd",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Operation working directory; an empty value means no cwd context."
        }
      ],
      "example": {
        "type": "tool_call",
        "itr": 1,
        "tool_call_id": "call_tool_01",
        "name": "run-cmd",
        "arguments": {
          "command": "pwd"
        },
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab",
        "root_id": "r_0123456789ab",
        "cwd": "/workspace"
      },
      "reply": {
        "text": "The daemon assigns each admitted invocation a fresh trusted tool_call_id for IPC replies, acknowledgements, aborts, heartbeats, watchdogs, progress, and runtime status. Capability modules must echo it exactly. Provider/model tool-call IDs remain conversation data, preserved in assistant and tool-result history and replay, and are never IPC correlation keys. Provider projections retain duplicate and empty ID occurrences in order; a provider that rejects malformed IDs returns its normal request error rather than silently rewriting history.",
        "links": [
          "tool_ack",
          "tool_result",
          "tool_abort",
          "tool_abort_ack",
          "heartbeat"
        ]
      },
      "related": [
        "tool_ack",
        "tool_result",
        "tool_abort",
        "tool_abort_ack",
        "heartbeat"
      ],
      "notes": [
        "Tool calls are sequential unless tool_ack with parallel:true arrives first. Results are still admitted to the model in source order.",
        "A model-generated call retains the provider connection selected when its definition was offered. If a daemon-launched configured direct service disconnects before dispatch, the daemon can recover that same service once, verify its ownership and offered description/schema, and bind to its replacement connection. Unrelated providers, changed service definitions, and missing bindings produce ordinary tool errors. Calls already sent, including failed sends with uncertain delivery, are never automatically replayed. This private binding is absent from model JSON and persisted history.",
        "Watchdog or absolute-max expiry completes the pending call with a timeout; the current timeout callback does not send tool_abort. heartbeat resets only the watchdog timer, not the absolute maximum. Provider connection closure also completes pre-ack and result waits, including parallel calls and calls with disabled timers.",
        "An explicit leaf abort sends tool_abort and immediately cancels/completes the pending result path. There is no 30-second post-abort result or acknowledgement window."
      ]
    },
    {
      "id": "tool_info",
      "type": "tool_info",
      "struct": "ToolInfoValue",
      "source": "pkg/protocol/tool.go",
      "category": "req",
      "synopsis": "Returns client-facing tool metadata resolved for a leaf or explicit names.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_info\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "tools",
          "go_type": "[]ToolInfo",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Tool names or metadata records, according to Go type."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the get_tool_info request_id; the RPC dispatcher uses it to deliver this tool_info frame to the waiting call."
        }
      ],
      "example": {
        "type": "tool_info",
        "itr": 1,
        "tools": [
          {
            "name": "example"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to get_tool_info; request_id supplies correlation.",
        "links": [
          "get_tool_info"
        ]
      },
      "related": [
        "get_tool_info"
      ],
      "notes": []
    },
    {
      "id": "tool_info_request",
      "type": "tool_info_request",
      "struct": "ToolInfoRequest",
      "source": "pkg/protocol/tool.go",
      "category": "sys",
      "synopsis": "Requests metadata for named tools from a capability provider.",
      "direction": {
        "from": "daemon",
        "to": "capability module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_info_request\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "names",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Tool names whose schemas and timeout metadata the daemon wants from this provider."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Origin correlation value when available; this frame’s notes describe when it may be empty or omitted."
        }
      ],
      "example": {
        "type": "tool_info_request",
        "itr": 1,
        "names": [
          "example"
        ],
        "request_id": "ti_c_0123456789ab"
      },
      "reply": {
        "text": "Immediate success: tool_info_response.",
        "links": [
          "tool_info_response"
        ]
      },
      "related": [
        "tool_info_response"
      ],
      "notes": []
    },
    {
      "id": "tool_info_response",
      "type": "tool_info_response",
      "struct": "ToolInfoResponse",
      "source": "pkg/protocol/tool.go",
      "category": "sys",
      "synopsis": "Returns tool schemas and timeout metadata requested from a capability provider.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_info_response\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tools",
          "go_type": "[]ToolInfo",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Tool metadata records for this connection; an empty list is accepted and still marks tool metadata received."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Usually echoes the metadata request ID, but the current handler ignores it and updates metadata by sending connection."
        }
      ],
      "example": {
        "type": "tool_info_response",
        "itr": 1,
        "tools": [
          {
            "name": "example"
          }
        ],
        "request_id": "ti_c_0123456789ab"
      },
      "reply": {
        "text": "Capability metadata response to tool_info_request; no further acknowledgement is sent.",
        "links": [
          "tool_info_request"
        ]
      },
      "related": [
        "tool_info_request",
        "announce"
      ],
      "notes": [
        "Live sending connections may update registry metadata. On-demand typed RPC waits additionally require the matching request_id on that exact connection; startup readiness tracks its separately issued startup request IDs."
      ]
    },
    {
      "id": "tool_invoke",
      "type": "tool_invoke",
      "struct": "ToolInvoke",
      "source": "pkg/protocol/tool_invoke.go",
      "category": "req",
      "synopsis": "Starts a standalone leaf tool invocation or cancels an invocation by ID.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always tool_invoke."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound iteration."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "RPC correlation ID."
        },
        {
          "name": "operation",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "invoke or cancel."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Required for invoke, the target leaf."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Required for invoke, the tool name."
        },
        {
          "name": "arguments",
          "go_type": "json.RawMessage",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Required for invoke, a JSON object."
        },
        {
          "name": "invocation_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Required for cancel, the live invocation ID."
        }
      ],
      "example": {
        "type": "tool_invoke",
        "itr": 1,
        "request_id": "rpc_1",
        "operation": "invoke",
        "leaf_id": "l1",
        "name": "run-cmd",
        "arguments": {
          "command": "pwd"
        }
      },
      "reply": {
        "text": "tool_invoke_result acknowledges invoke or cancel; a correlated error rejects the request.",
        "links": [
          "tool_invoke_result",
          "error-correlated-response"
        ]
      },
      "related": [
        "tool_invoke_result",
        "tool_invoke_done",
        "error-correlated-response"
      ],
      "notes": [
        "Cancel uses operation cancel and invocation_id. Unknown or already terminal IDs return not_found. Invalid operation or missing required fields returns parse_error; missing leaf returns leaf_not_found; an aborting leaf or shutdown admission returns leaf_busy.",
        "bash and run-cmd arguments with background: true are rejected before dispatch with bad_request. Execution failures, including inactive tools and provider failures, appear in the terminal tool-result turn, not as an RPC error.",
        "The daemon enqueues the invoke acknowledgement before terminal completion. RPC heartbeats cover the request until acknowledgement, not execution. Acceptance does not imply completion; an uncertain RPC is not automatically retried.",
        "The live leaf status projection includes the invocation as an active tool call with an empty source turn. This standalone call does not change model conversation state.",
        "Leaf abort cancels live invocations, including generic-only work. Accepted leaf deletion cancels its invocations; vacuum cancels invocations for removed roots, and shutdown cancels all. Trusted defaults-service origin loss aborts its invocations through queued admission and provider execution. A standalone disconnected requester does not cancel its work; terminal delivery is dropped with a warning."
      ]
    },
    {
      "id": "tool_invoke_done",
      "type": "tool_invoke_done",
      "struct": "ToolInvokeDone",
      "source": "pkg/protocol/tool_invoke.go",
      "category": "fnf",
      "synopsis": "Delivers the terminal canonical tool-result turn to the invoking connection.",
      "direction": {
        "from": "daemon",
        "to": "invoking connection only"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always tool_invoke_done."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound iteration."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Target leaf."
        },
        {
          "name": "invocation_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Matches the accepted invocation."
        },
        {
          "name": "status",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "completed or aborted."
        },
        {
          "name": "turn",
          "go_type": "PendingTurn",
          "json_tag": "always",
          "validation": "required",
          "desc": "Canonical tool-result turn, including content, metadata and any attachments."
        }
      ],
      "example": {
        "type": "tool_invoke_done",
        "itr": 3,
        "leaf_id": "l1",
        "invocation_id": "tc_1",
        "status": "completed",
        "turn": {
          "kind": "tool_result",
          "content_type": "text",
          "content": "/work",
          "tool_call_id": "tc_1",
          "tool_name": "run-cmd"
        }
      },
      "reply": {
        "text": "Terminal event; no reply.",
        "links": []
      },
      "related": [
        "tool_invoke",
        "tool_invoke_result"
      ],
      "notes": [
        "The daemon sends this only to the original requester, not to leaf subscribers. Normal tool errors remain tool-result turns, including their is_error metadata."
      ]
    },
    {
      "id": "tool_invoke_result",
      "type": "tool_invoke_result",
      "struct": "ToolInvokeResult",
      "source": "pkg/protocol/tool_invoke.go",
      "category": "req",
      "synopsis": "Acknowledges a tool invocation start or cancellation.",
      "direction": {
        "from": "daemon",
        "to": "requester"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always tool_invoke_result."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound iteration."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Matches the request."
        },
        {
          "name": "operation",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "invoke or cancel."
        },
        {
          "name": "invocation_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Invocation identifier."
        },
        {
          "name": "state",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "required",
          "desc": "accepted for invoke, cancelled for cancel."
        }
      ],
      "example": {
        "type": "tool_invoke_result",
        "itr": 2,
        "request_id": "rpc_1",
        "operation": "invoke",
        "invocation_id": "tc_1",
        "state": "accepted"
      },
      "reply": {
        "text": "Invoke completion follows separately as tool_invoke_done.",
        "links": [
          "tool_invoke_done"
        ]
      },
      "related": [
        "tool_invoke",
        "tool_invoke_done"
      ],
      "notes": [
        "Cancellation acknowledgement records the cancellation claim, not provider exit."
      ]
    },
    {
      "id": "tool_list",
      "type": "tool_list",
      "struct": "ToolList",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Returns effective tool names.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tools",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Effective tool names for the selected configuration context."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_tools request_id; the RPC dispatcher uses it to deliver this tool_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "tool_list",
        "itr": 1,
        "tools": [
          "example"
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_tools; request_id supplies correlation.",
        "links": [
          "list_tools"
        ]
      },
      "related": [
        "list_tools"
      ],
      "notes": []
    },
    {
      "id": "tool_removed",
      "type": "tool_removed",
      "struct": "ToolRemoved",
      "source": "pkg/protocol/tools.go",
      "category": "req",
      "synopsis": "Confirms removal of a tool name from a leaf selection.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_removed\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Tool capability name in this frame’s operation context."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the remove_tool request_id; the RPC dispatcher uses it to deliver this tool_removed frame to the waiting call."
        }
      ],
      "example": {
        "type": "tool_removed",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "tool_name": "example.tool",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to remove_tool; request_id supplies correlation.",
        "links": [
          "remove_tool"
        ]
      },
      "related": [
        "remove_tool"
      ],
      "notes": []
    },
    {
      "id": "tool_result",
      "type": "tool_result",
      "struct": "ToolResult",
      "source": "pkg/protocol/tool.go",
      "category": "sys",
      "synopsis": "Supplies the single final semantic result for a tool call.",
      "direction": {
        "from": "capability module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"tool_result\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Outstanding tool call claimed by this result; it must belong to the sending connection."
        },
        {
          "name": "turn",
          "go_type": "PendingTurn",
          "json_tag": "always",
          "validation": "required",
          "desc": "Semantic pending turn, carrying optional steer context without changing tool-result semantics; see PendingTurn."
        }
      ],
      "example": {
        "type": "tool_result",
        "itr": 1,
        "tool_call_id": "call_tool_01",
        "turn": {
          "kind": "tool_result",
          "content_type": "text",
          "content": "/workspace",
          "tool_call_id": "call_tool_01",
          "tool_name": "run-cmd"
        }
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": [
          "tool_call",
          "tool_ack"
        ]
      },
      "related": [
        "tool_call",
        "tool_ack"
      ],
      "notes": [
        "The daemon claims an outstanding call only when tool_call_id belongs to the sending connection. Unknown, duplicate, already-claimed, or other-connection IDs produce an uncorrelated parse_error to the submitting connection.",
        "Validation occurs during the atomic claim. Even an invalid owner-valid result claims/removes the pending call, completes its waiter with an invalid-result error, and sends an uncorrelated parse_error. Non-empty inner tool_call_id/tool_name must match the trusted runtime state. The daemon stores the original provider/model call ID with the tool result and normalizes its tool name from pending state.",
        "Exactly one valid final result is admitted. The PendingTurn must be tool_result-compatible and attachments are validated before persistence."
      ]
    },
    {
      "id": "turn_content-event",
      "type": "turn_content",
      "struct": "TurnContent",
      "source": "pkg/protocol/turn.go",
      "category": "fnf",
      "synopsis": "Broadcasts a newly authoritative persisted turn snapshot to subscribers of its leaf.",
      "direction": {
        "from": "daemon",
        "to": "leaf subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"turn_content\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "required for unsolicited event",
          "desc": "Required leaf scope for this unsolicited event. The struct tag permits omission for the separate get_turn response shape."
        },
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque persisted turn ID becoming authoritative for subscribers."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "parent_id",
          "go_type": "*string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Parent persisted-turn ID; omitted when nil."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted semantic turn kind: system, user, assistant, tool_result, virtual_root, or the service-owned terminal error kind."
        },
        {
          "name": "content_type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted content encoding; ordinary text uses text."
        },
        {
          "name": "content",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted primary content string."
        },
        {
          "name": "meta_files",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON attachment metadata when present; TurnContent does not carry attachment payload bytes."
        },
        {
          "name": "thinking",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Persisted assistant reasoning text when present."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Model that produced an assistant turn, when recorded."
        },
        {
          "name": "provider",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Provider that produced an assistant turn, when recorded."
        },
        {
          "name": "stop_reason",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Normally records the provider/model generation stop reason, such as stop, tool_calls, error, or interrupted. The synthetic public-abort assistant is the exception: stop_reason is interrupted while other_meta.exit_message is ABORT. In all cases exit_message, not stop_reason, is the Agent run-level interpretation."
        },
        {
          "name": "usage",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON usage metadata stored with the turn, when present."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Tool-call identity for tool_result turns."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Tool capability name for tool_result turns."
        },
        {
          "name": "other_meta",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON object carrying additional persisted turn metadata. On sent assistant turns the service-owned exit_message key records Agent run interpretation: absent or null means continue, SUCCESS means successful exit, ABORT means public-abort failure, and any other valid nonempty string is an error message."
        },
        {
          "name": "timestamp",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted RFC3339 creation timestamp."
        },
        {
          "name": "state",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted turn state: draft, ready, or sent."
        },
        {
          "name": "seq",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Sequence number within the root turn chain."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Always serialized by the struct; current live broadcasts set it to the empty string."
        }
      ],
      "example": {
        "type": "turn_content",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "id": "t_0123456789ab",
        "root_id": "r_0123456789ab",
        "kind": "assistant",
        "content_type": "text",
        "content": "Review complete.",
        "model": "example/model",
        "provider": "example",
        "stop_reason": "stop",
        "other_meta": "{\"exit_message\":\"SUCCESS\"}",
        "timestamp": "2026-07-27T12:00:00Z",
        "state": "sent",
        "seq": 2,
        "request_id": ""
      },
      "reply": {
        "text": "One-way subscriber event; no acknowledgement.",
        "links": []
      },
      "related": [
        "turns_sent",
        "create_virtual_root"
      ],
      "notes": [
        "Live service broadcasts require leaf_id and encode request_id as an empty string. Go and Ruby discard an unmatched turn_content with a nonempty request_id.",
        "Normal publication sends canonical turn_content events before turns_sent. Held virtual-root creation publishes these events but intentionally omits turns_sent. In-place assistant error translation and exit_message updates publish refreshed canonical turn_content.",
        "exit_message belongs only to sent assistant other_meta and is written by the service; there is no general turn-mutation RPC. Consumers preserve raw other_meta but must reject malformed JSON, non-object metadata, or invalid exit_message values rather than infer success.",
        "A sent kind error turn is service-owned terminal history whose exact content is the bounded normalized failure. It has no assistant metadata or exit_message, remains canonical in history/tree/tip views, and is never projected to a model message or provider source-turn ID. In-place translation requires the exact empty sent streaming-assistant placeholder shape and rejects semantic or finalized assistants without mutation.",
        "Legacy absence and explicit null have identical continue behavior. Structured-output validation remains a consumer layer: SUCCESS records Agent execution even if a caller later rejects the canonical content against its own schema."
      ]
    },
    {
      "id": "turn_content-response",
      "type": "turn_content",
      "struct": "TurnContent",
      "source": "pkg/protocol/turn.go",
      "category": "req",
      "synopsis": "Returns the requested persisted turn snapshot for get_turn.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"turn_content\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque persisted turn ID returned by get_turn."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "parent_id",
          "go_type": "*string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Parent persisted-turn ID; omitted when nil."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted semantic turn kind: system, user, assistant, tool_result, virtual_root, or the service-owned terminal error kind."
        },
        {
          "name": "content_type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted content encoding; ordinary text uses text."
        },
        {
          "name": "content",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted primary content string."
        },
        {
          "name": "meta_files",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON attachment metadata when present; TurnContent does not carry attachment payload bytes."
        },
        {
          "name": "thinking",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Persisted assistant reasoning text when present."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Model that produced an assistant turn, when recorded."
        },
        {
          "name": "provider",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Provider that produced an assistant turn, when recorded."
        },
        {
          "name": "stop_reason",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Normally records the provider/model generation stop reason, such as stop, tool_calls, error, or interrupted. The synthetic public-abort assistant is the exception: stop_reason is interrupted while other_meta.exit_message is ABORT. In all cases exit_message, not stop_reason, is the Agent run-level interpretation."
        },
        {
          "name": "usage",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON usage metadata stored with the turn, when present."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Tool-call identity for tool_result turns."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Tool capability name for tool_result turns."
        },
        {
          "name": "other_meta",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON object carrying additional persisted turn metadata. On sent assistant turns the service-owned exit_message key records Agent run interpretation: absent or null means continue, SUCCESS means successful exit, ABORT means public-abort failure, and any other valid nonempty string is an error message."
        },
        {
          "name": "timestamp",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted RFC3339 creation timestamp."
        },
        {
          "name": "state",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted turn state: draft, ready, or sent."
        },
        {
          "name": "seq",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Sequence number within the root turn chain."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Echo of the get_turn request_id; the RPC dispatcher uses it to deliver this turn_content-response frame to the waiting call."
        }
      ],
      "example": {
        "type": "turn_content",
        "itr": 1,
        "id": "t_0123456789ab",
        "root_id": "r_0123456789ab",
        "kind": "assistant",
        "content_type": "text",
        "content": "Review complete.",
        "model": "example/model",
        "provider": "example",
        "stop_reason": "stop",
        "other_meta": "{\"exit_message\":\"SUCCESS\"}",
        "timestamp": "2026-07-27T12:00:00Z",
        "state": "sent",
        "seq": 2,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Correlated success response to get_turn; no acknowledgement follows.",
        "links": [
          "get_turn"
        ]
      },
      "related": [
        "get_turn"
      ],
      "notes": [
        "parent_id is omitted when nil; meta_files is serialized attachment metadata when present. Canonical text content_type is text, and tool output kind is tool_result.",
        "A matched response is consumed by the RPC requester rather than also delivered as a frontend event. If its waiter is gone, Go and Ruby discard the late nonempty-request_id frame.",
        "exit_message belongs only to sent assistant other_meta and is written by the service; there is no general turn-mutation RPC. Consumers preserve raw other_meta but must reject malformed JSON, non-object metadata, or invalid exit_message values rather than infer success.",
        "A sent kind error turn is service-owned terminal history whose exact content is the bounded normalized failure. It has no assistant metadata or exit_message, remains canonical in history/tree/tip views, and is never projected to a model message or provider source-turn ID. In-place translation requires the exact empty sent streaming-assistant placeholder shape and rejects semantic or finalized assistants without mutation.",
        "Legacy absence and explicit null have identical continue behavior. Structured-output validation remains a consumer layer: SUCCESS records Agent execution even if a caller later rejects the canonical content against its own schema."
      ]
    },
    {
      "id": "turn_end",
      "type": "turn_end",
      "struct": "TurnEnd",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Signals the end of streaming for one assistant turn.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"turn_end\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        }
      ],
      "example": {
        "type": "turn_end",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab"
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [],
      "notes": []
    },
    {
      "id": "turn_start",
      "type": "turn_start",
      "struct": "TurnStart",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Signals the beginning of streaming for one assistant turn.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"turn_start\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque turn ID. Service-generated turn IDs currently use t_ plus 12 lowercase hex digits; consumers must not parse them."
        }
      ],
      "example": {
        "type": "turn_start",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_id": "t_0123456789ab"
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [],
      "notes": []
    },
    {
      "id": "turn_tree_list",
      "type": "turn_tree_list",
      "struct": "TurnTreeList",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns persisted turn-tree nodes for one root.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"turn_tree_list\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turns",
          "go_type": "[]TurnTreeNode",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted nodes belonging to the requested root."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the list_turn_tree request_id; the RPC dispatcher uses it to deliver this turn_tree_list frame to the waiting call."
        }
      ],
      "example": {
        "type": "turn_tree_list",
        "itr": 1,
        "root_id": "r_0123456789ab",
        "turns": [
          {
            "id": "t_0123456789ab",
            "kind": "user",
            "state": "ready",
            "seq": 1,
            "timestamp": "2026-07-27T12:00:00Z"
          }
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to list_turn_tree; request_id supplies correlation.",
        "links": [
          "list_turn_tree"
        ]
      },
      "related": [
        "list_turn_tree"
      ],
      "notes": []
    },
    {
      "id": "turns_sent",
      "type": "turns_sent",
      "struct": "TurnsSent",
      "source": "pkg/protocol/agent.go",
      "category": "fnf",
      "synopsis": "Publishes the committed sent-turn set and authoritative sent tip.",
      "direction": {
        "from": "daemon",
        "to": "subscribers/frontends"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"turns_sent\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "turn_ids",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Committed turns whose state transitioned to sent."
        },
        {
          "name": "tip_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Independently resolved authoritative sent tip; do not infer it from turn_ids ordering."
        }
      ],
      "example": {
        "type": "turns_sent",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "turn_ids": [
          "t_0123456789ab"
        ],
        "tip_turn_id": "t_0123456789ab"
      },
      "reply": {
        "text": "One-way frame; no direct success reply.",
        "links": []
      },
      "related": [],
      "notes": [
        "Normal agent input publication sends turn_content frames before turns_sent. create_virtual_root also publishes canonical turn_content; it sends turns_sent only for non-held creation. Held virtual-root creation intentionally omits turns_sent.",
        "turn_ids is a committed set and is not itself a chain-order guarantee; tip_turn_id is the independently resolved authoritative sent tip."
      ]
    },
    {
      "id": "update_leaf_meta",
      "type": "update_leaf_meta",
      "struct": "UpdateLeafMeta",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Atomically changes a leaf name and/or opaque configuration entries.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"update_leaf_meta\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "name",
          "go_type": "*string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "At least one of name, set_config, or delete_config is required; a provided name must be non-empty."
        },
        {
          "name": "set_config",
          "go_type": "map[string]string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "At least one metadata mutation is required. Values are opaque strings."
        },
        {
          "name": "delete_config",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "At least one metadata mutation is required."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque update_leaf_meta correlation ID echoed by leaf_meta_updated or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "update_leaf_meta",
        "itr": 1,
        "leaf_id": "l_0123456789ab",
        "name": "API documentation",
        "set_config": {
          "owner": "docs"
        },
        "delete_config": [
          "obsolete_key"
        ],
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: leaf_meta_updated. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "leaf_meta_updated",
          "error-correlated-response"
        ]
      },
      "related": [
        "leaf_meta_updated",
        "error-correlated-response"
      ],
      "notes": []
    },
    {
      "id": "vacuum",
      "type": "vacuum",
      "struct": "Vacuum",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Prunes eligible unreachable roots and turns, optionally as a dry run.",
      "direction": {
        "from": "client/module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"vacuum\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "older_than",
          "go_type": "int64",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Positive values are minimum unreachable-root ages in seconds. The existing service applies the filter only when older_than is greater than zero, so omission, zero, and currently negative wire values apply no age filter."
        },
        {
          "name": "dry_run",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "When true, report what would be pruned without deleting it."
        },
        {
          "name": "deep",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "When true, also prune unreachable turns inside retained roots."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque vacuum correlation ID echoed by vacuum_result or a correlated error. Empty is accepted by this handler; ezagentapi.RPC generates rpc_ plus 16 hex digits."
        }
      ],
      "example": {
        "type": "vacuum",
        "itr": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Immediate success: vacuum_result. A correlated error with the same request_id is the alternate failure response.",
        "links": [
          "vacuum_result",
          "error-correlated-response"
        ]
      },
      "related": [
        "vacuum_result",
        "error-correlated-response"
      ],
      "notes": [
        "The typed Ruby API rejects negative older_than ages locally before writing this request; that client validation is stricter than the existing wire/service behavior."
      ]
    },
    {
      "id": "vacuum_result",
      "type": "vacuum_result",
      "struct": "VacuumResult",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns counts of roots and turns selected or pruned by vacuum.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"vacuum_result\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "roots_pruned",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Number of roots selected or deleted by this vacuum operation."
        },
        {
          "name": "turns_pruned",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Number of turns selected or deleted by this vacuum operation."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the vacuum request_id; the RPC dispatcher uses it to deliver this vacuum_result frame to the waiting call."
        }
      ],
      "example": {
        "type": "vacuum_result",
        "itr": 1,
        "roots_pruned": 1,
        "turns_pruned": 1,
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to vacuum; request_id supplies correlation.",
        "links": [
          "vacuum"
        ]
      },
      "related": [
        "vacuum"
      ],
      "notes": []
    },
    {
      "id": "virtual_root_created",
      "type": "virtual_root_created",
      "struct": "VirtualRootCreated",
      "source": "pkg/protocol/session.go",
      "category": "req",
      "synopsis": "Returns IDs and model after a virtual-root mutation commits.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"virtual_root_created\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Service-generated root IDs currently use r_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Service-generated leaf IDs currently use l_ plus 12 lowercase hex digits; consumers must not parse them."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Canonical provider/model reference applicable to this frame."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Echo of the create_virtual_root request_id; the RPC dispatcher uses it to deliver this virtual_root_created frame to the waiting call."
        }
      ],
      "example": {
        "type": "virtual_root_created",
        "itr": 1,
        "root_id": "r_0123456789ab",
        "leaf_id": "l_0123456789ab",
        "model": "openai/gpt-5",
        "request_id": "rpc_0123456789abcdef"
      },
      "reply": {
        "text": "Success response to create_virtual_root; request_id supplies correlation.",
        "links": [
          "create_virtual_root"
        ]
      },
      "related": [
        "create_virtual_root"
      ],
      "notes": []
    },
    {
      "id": "attachment_chunk",
      "type": "attachment_chunk",
      "struct": "AttachmentChunk",
      "source": "pkg/protocol/attachment.go",
      "category": "req",
      "synopsis": "Returns one decoded-byte range as base64 to the requesting peer only.",
      "direction": {
        "from": "daemon",
        "to": "requesting client/module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"attachment_chunk\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration. Senders normally use increasing positive values; recipients accept omitted or unusable values without changing frame semantics."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Echo of the get_attachment_chunk request_id. Correlates this response to exactly one pending call."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Echo of the requested persisted turn ID."
        },
        {
          "name": "attachment_index",
          "go_type": "int",
          "json_tag": "always",
          "validation": "required",
          "desc": "Echo of the requested zero-based attachment index. Zero is encoded explicitly."
        },
        {
          "name": "offset",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "required",
          "desc": "Echo of the requested decoded-byte offset. Zero is encoded explicitly."
        },
        {
          "name": "length",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "required",
          "desc": "Actual decoded-byte count: min(requested length, size - offset), from 0 through 98304. Must equal the byte count after decoding data_b64."
        },
        {
          "name": "size",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "required",
          "desc": "Actual total decoded size of the stored attachment, not an estimate from display metadata."
        },
        {
          "name": "data_b64",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Standard padded base64 for every file, including UTF-8 text. Empty string when length is zero. Decode to bytes before assembling ranges; a chunk need not end on a UTF-8 character boundary."
        },
        {
          "name": "eof",
          "go_type": "bool",
          "json_tag": "always",
          "validation": "required",
          "desc": "True exactly when offset + length == size. Describes this range, not completion of other in-flight ranges. False is encoded explicitly."
        }
      ],
      "example": {
        "type": "attachment_chunk",
        "itr": 2,
        "request_id": "rpc_0123456789abcdef",
        "turn_id": "t_0123456789ab",
        "attachment_index": 0,
        "offset": 0,
        "length": 5,
        "size": 5,
        "data_b64": "SGVsbG8=",
        "eof": true
      },
      "reply": {
        "text": "Terminal success response to get_attachment_chunk. No acknowledgement or leaf event follows.",
        "links": [
          "get_attachment_chunk"
        ]
      },
      "related": [
        "get_attachment_chunk",
        "get_turn",
        "error-correlated-response"
      ],
      "notes": [
        "Offset equal to size succeeds with length 0, data_b64 empty, and eof true, including offset 0 for an empty file. Offset greater than size fails with attachment_range_error instead of returning a chunk.",
        "Go and Ruby route matched responses to the RPC waiter and discard late unmatched attachment_chunk frames. These responses never enter the event or subscriber-broadcast path.",
        "Use request_id for correlation, not itr or arrival order. With two requests in flight, an EOF response can arrive before earlier ranges; wait for every required range before treating the file as complete."
      ]
    },
    {
      "id": "background_task_add",
      "type": "background_task_add",
      "struct": "BackgroundTaskAdd",
      "source": "pkg/protocol/background.go",
      "category": "req",
      "synopsis": "Registration is generic provider ownership, independent of an originating tool call. The existing leaf is loaded and registered atomically under its leaf gate; missing or deleted leaves are never recreated. Registration does not launch model processing.",
      "direction": {
        "from": "module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"background_task_add\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration; not a correlation ID or remote execution barrier."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Required RPC correlation ID, echoed by the acknowledgement or error."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Existing leaf owning the provider task."
        },
        {
          "name": "task_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Provider task ID, globally unique among live ownership entries. Bash uses the trusted originating daemon tool-call ID; generic ownership requires no originating call."
        }
      ],
      "notes": [
        "Registration is generic provider ownership, independent of an originating tool call. The existing leaf is loaded and registered atomically under its leaf gate; missing or deleted leaves are never recreated. Registration does not launch model processing.",
        "Duplicate add from the same connection and leaf is idempotent. A task ID owned by another connection or leaf fails with background_task_conflict. request_id, leaf_id and task_id are required; malformed requests fail with invalid_background_task. Missing leaves fail with leaf_not_found.",
        "Await background_task_add_ack before sending an initial background tool_result. Ownership blocks unloading, but permits ordinary idle operations. running and aborting take precedence over derived background state.",
        "Add/remove admission runs outside the shared provider callback lane. A cancellable request context covers leaf-gate and database waits through acknowledgement enqueue without an implicit elapsed-time cap; disconnect and shutdown cancel admission and join ownership workers so expired requests cannot later register ghost ownership. Lifecycle selection and state publication precede acknowledgement. The worker cancels and joins the admission deadline watcher before invoking selected macros, which remain tracked but run outside the ownership RPC budget. A slow lifecycle macro cannot make a successful ownership acknowledgement time out or close the shared provider connection. Registration is rejected during claimed model-error finalization or shutdown. New leaves and forks persist configured on_background defaults as active_background_triggers."
      ],
      "example": {
        "type": "background_task_add",
        "itr": 1,
        "task_id": "task-1",
        "request_id": "rpc_background_1",
        "leaf_id": "leaf-1"
      },
      "related": [
        "background_task_remove",
        "background_task_add_ack",
        "background_task_remove_ack",
        "background_task_kill"
      ],
      "reply": {
        "text": "Await the correlated acknowledgement or error.",
        "links": [
          "background_task_add_ack",
          "error-correlated-response"
        ]
      }
    },
    {
      "id": "background_task_remove",
      "type": "background_task_remove",
      "struct": "BackgroundTaskRemove",
      "source": "pkg/protocol/background.go",
      "category": "req",
      "synopsis": "Acknowledgement follows ownership release. Removing an absent task is an acknowledged no-op, including after abort or deletion. Removal never reloads or recreates a leaf.",
      "direction": {
        "from": "module",
        "to": "daemon"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"background_task_remove\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration; not a correlation ID or remote execution barrier."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Required RPC correlation ID, echoed by the acknowledgement or error."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Existing leaf owning the provider task."
        },
        {
          "name": "task_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Provider task ID, globally unique among live ownership entries. Bash uses the trusted originating daemon tool-call ID; generic ownership requires no originating call."
        }
      ],
      "notes": [
        "Acknowledgement follows ownership release and state publication, before invoking any selected idle macros outside the ownership RPC deadline. Notification work remains tracked. Removing an absent task is an acknowledged no-op, including after abort or deletion. Removal never reloads or recreates a leaf.",
        "A live task owned by another connection or leaf fails with background_task_conflict. request_id, leaf_id and task_id are required; malformed requests fail with invalid_background_task.",
        "Removal releases only this task contribution; the protocol does not independently prove that provider cleanup or external processes have finished. It does not delete captured output buffers or retained terminal status. Completion producers await steer_accepted or a correlated error before removing ownership. Builtin run-cmd retains ownership and refreshes statistics to retry known terminalization and stale-tip admission conflicts. Abort and missing-leaf rejections drop completion; statistics failures and uncertain admission fail the provider connection rather than silently dropping or duplicating completion. Each RPC wait remains bounded and outside leaf gates."
      ],
      "example": {
        "type": "background_task_remove",
        "itr": 1,
        "task_id": "task-1",
        "request_id": "rpc_background_1",
        "leaf_id": "leaf-1"
      },
      "related": [
        "background_task_add",
        "background_task_add_ack",
        "background_task_remove_ack",
        "background_task_kill"
      ],
      "reply": {
        "text": "Await the correlated acknowledgement or error.",
        "links": [
          "background_task_remove_ack",
          "error-correlated-response"
        ]
      }
    },
    {
      "id": "background_task_add_ack",
      "type": "background_task_add_ack",
      "struct": "BackgroundTaskAddAck",
      "source": "pkg/protocol/background.go",
      "category": "req",
      "synopsis": "Correlated acknowledgement that the sending connection owns this task on the existing loaded leaf. Echoes request_id, leaf_id and task_id. This is not user input or proof of process exit.",
      "direction": {
        "from": "daemon",
        "to": "module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"background_task_add_ack\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration; not a correlation ID or remote execution barrier."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Required RPC correlation ID, echoed by the acknowledgement or error."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Existing leaf owning the provider task."
        },
        {
          "name": "task_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Provider task ID, globally unique among live ownership entries. Bash uses the trusted originating daemon tool-call ID; generic ownership requires no originating call."
        }
      ],
      "notes": [
        "Correlated acknowledgement that the sending connection owns this task on the existing loaded leaf. Echoes request_id, leaf_id and task_id. This is not user input or proof of process exit."
      ],
      "example": {
        "type": "background_task_add_ack",
        "itr": 1,
        "task_id": "task-1",
        "request_id": "rpc_background_1",
        "leaf_id": "leaf-1"
      },
      "related": [
        "background_task_add",
        "background_task_remove",
        "background_task_remove_ack",
        "background_task_kill"
      ],
      "reply": {
        "text": "No direct reply.",
        "links": []
      }
    },
    {
      "id": "background_task_remove_ack",
      "type": "background_task_remove_ack",
      "struct": "BackgroundTaskRemoveAck",
      "source": "pkg/protocol/background.go",
      "category": "req",
      "synopsis": "Correlated acknowledgement that the task contribution has been released or was already absent. Echoes request_id, leaf_id and task_id. Buffers and terminal provider status are not deleted.",
      "direction": {
        "from": "daemon",
        "to": "module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"background_task_remove_ack\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration; not a correlation ID or remote execution barrier."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Required RPC correlation ID, echoed by the acknowledgement or error."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Existing leaf owning the provider task."
        },
        {
          "name": "task_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Provider task ID, globally unique among live ownership entries. Bash uses the trusted originating daemon tool-call ID; generic ownership requires no originating call."
        }
      ],
      "notes": [
        "Correlated acknowledgement that the task contribution has been released or was already absent. Echoes request_id, leaf_id and task_id. Buffers and terminal provider status are not deleted."
      ],
      "example": {
        "type": "background_task_remove_ack",
        "itr": 1,
        "task_id": "task-1",
        "request_id": "rpc_background_1",
        "leaf_id": "leaf-1"
      },
      "related": [
        "background_task_add",
        "background_task_remove",
        "background_task_add_ack",
        "background_task_kill"
      ],
      "reply": {
        "text": "No direct reply.",
        "links": []
      }
    },
    {
      "id": "background_task_kill",
      "type": "background_task_kill",
      "struct": "BackgroundTaskKill",
      "source": "pkg/protocol/background.go",
      "category": "fnf",
      "synopsis": "One-way, non-negotiable cancellation notification. No request_id or acknowledgement; reason is informative, not a closed enum or permission request. Providers must cancel even for unfamiliar reasons.",
      "direction": {
        "from": "daemon",
        "to": "module"
      },
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Always \"background_task_kill\"."
        },
        {
          "name": "itr",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Connection-local outbound stream iteration; not a correlation ID or remote execution barrier."
        },
        {
          "name": "task_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Provider task ID, globally unique among live ownership entries. Bash uses the trusted originating daemon tool-call ID; generic ownership requires no originating call."
        },
        {
          "name": "reason",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Informative lifecycle reason. No closed enum or negotiation semantics."
        }
      ],
      "notes": [
        "One-way, non-negotiable cancellation notification. No request_id or acknowledgement; reason is informative, not a closed enum or permission request. Providers must cancel even for unfamiliar reasons.",
        "The service resolves the owning provider by task ID, independently of a pending tool call. Typical reasons are abort, error, leaf_deleted and shutdown. Delivery is not proof of process exit. The provider reuses its existing signal behavior and later removes ownership by RPC. Model-error cleanup snapshots and retires owned tasks before routing error kills outside the leaf gate, preserving the original model error without calling public abort or appending an ABORT turn.",
        "Abort suppresses completion permanently for that task, including after the leaf returns to idle, and records cancellation facts at the existing abort boundary without invoking the model. Deletion drops completion. Provider loss releases every task owned by the lost connection without sending kill; whole-provider shutdown remains the shutdown mechanism."
      ],
      "example": {
        "type": "background_task_kill",
        "itr": 1,
        "task_id": "task-1",
        "reason": "abort"
      },
      "related": [
        "background_task_add",
        "background_task_remove",
        "background_task_add_ack",
        "background_task_remove_ack"
      ],
      "reply": {
        "text": "No direct reply.",
        "links": []
      }
    }
  ],
  "schemas": [
    {
      "id": "schema-PendingTurn",
      "name": "PendingTurn",
      "source": "pkg/protocol/turn.go",
      "fields": [
        {
          "name": "steer",
          "go_type": "*bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional boolean input-timing context. Omitted is unspecified; explicit true or false survives client/plugin handoffs and queued-message projection. The service supplies true for unspecified user input admitted during assistant/tool processing, not merely because the steer endpoint was used. Plugins may set it on synthetic user turns. Consumers may ignore it; it is not an admission command or independently persisted field."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Semantic turn kind. Required before storage; request boundaries further restrict allowed values. The persisted error kind is service-owned and rejected through every external PendingTurn ingress."
        },
        {
          "name": "content_type",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional semantic encoding. User/tool-result boundaries allow empty or text; storage also recognizes markdown, base64, and json."
        },
        {
          "name": "content",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Turn content. Empty content is allowed in some contexts, including supported content references."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Tool-result identity only; forbidden on user turns and normalized from trusted pending call state for tool results."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Tool-result capability name only; forbidden on user turns and normalized from trusted pending call state."
        },
        {
          "name": "advanced",
          "go_type": "*PendingTurnAdvanced",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional advanced metadata. User turns may carry only other_meta as a validated JSON-encoded object; assistant-only fields remain forbidden. The top-level exit_message key is service-owned."
        },
        {
          "name": "attachment_blob",
          "go_type": "*AttachmentBlobSpec",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional inline attachment payload and matching display metadata."
        },
        {
          "name": "fill_content_from_turn_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Synthetic plugin/virtual-root content reference; forbidden for user and tool-result boundaries and resolved only in supported trusted paths."
        }
      ],
      "notes": [
        "kind is required before storage. User prompt/ordinary steer boundaries require kind user and content_type text when set; tool results use kind tool_result. Plugins, tool results, prompts/steers, pipeline batches, and create_virtual_root cannot forge the service-owned error kind.",
        "attachment_blob payloads are validated before persistence. fill_content_from_turn_id is a synthetic reference resolved only in supported plugin/virtual-root paths and is never persisted as a turn-column value.",
        "steer applies to every containing frame: prompt.turn, steer.turn, plugin_call.pending_turns, plugin_result.pending_turns, create_virtual_root.pending_turns, tool_result.turn, and QueuedMessage.turn in queued_list.messages. It is optional context; role validation and admission rules are unchanged.",
        "The builtin mode plugin writes lasting classification in one leading text tag with independently optional mode and turn-type attributes, for example <mode turn-type=\"steer\" /> or <mode mode=\"plan\" turn-type=\"bash\" />. Existing attributes are merged without a second tag. Steer marks input drafted during the preceding response/tool call and may not account for its completed output. The legacy bash turn-type marks background command completion for both Bash and Ruby, taking precedence over generic steer context without changing the mode; it does not identify the interpreter.",
        "Internal free-form other_meta convention for background command completion user turns: {\"background_bash\":{\"task_id\":\"<trusted originating tool-call ID>\"}}. This legacy key is shared by Bash and Ruby and correlates the task, not the interpreter. Producers merge it with existing metadata and preserve unrelated keys and nested extensions. The daemon checks the sending connection's live task/leaf ownership, cancellation and initial tool-result admission barrier. This uses advanced.other_meta on PendingTurn and other_meta on stored turn_content, not extra wire fields or a new stored kind. TUI presentation uses this metadata, not message prose or the steer endpoint, and renders background → command (<id>) with existing tool-result styling.",
        "The daemon generates boolean background_progress:true in advanced.other_meta only on accepted user-kind steers from a connection with live background ownership for that leaf at queue admission. Supplied claims are scrubbed from unowned steers, prompts, tool results and virtual-root input. Plugins preserve admitted provenance on user-kind descendants but cannot introduce it for ordinary input. Source trust is captured once at pipeline entry and retained across intermediate role changes, including user to system to user; only user-kind output carries the metadata flag. Unrelated metadata is preserved. Legacy background_bash claims are also scrubbed from ordinary ingress and plugin assertions; admitted source correlation and nested extensions survive plugin rewrites. Verified same-root content-reference copies retain the stored source's background_bash correlation, but explicit replacement content cannot inherit it. Stored turn_content.other_meta retains the flag. Workflow may treat it as owned forward progress without broadening external-steer admission. No top-level frame/field, stored kind, SQLite schema or user_version changes."
      ]
    },
    {
      "id": "schema-PendingTurnAdvanced",
      "name": "PendingTurnAdvanced",
      "source": "pkg/protocol/turn.go",
      "fields": [
        {
          "name": "thinking",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Assistant reasoning text carried by trusted plugin/tool-result paths when allowed."
        },
        {
          "name": "other_meta",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON object for auxiliary metadata; validation requires an object when non-empty. exit_message is service-owned persisted metadata for sent assistant turns; external tool, plugin, and create_virtual_root pending turns are rejected if they supply that top-level key."
        },
        {
          "name": "stop_reason",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Normally provider/model generation stop reason metadata such as stop, error, interrupted, or tool_calls. The synthetic public-abort assistant also uses interrupted while exit_message is ABORT; stop_reason never supplies the overall Agent-run classification."
        },
        {
          "name": "usage",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized JSON usage object; validation requires an object when non-empty."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Model reference associated with assistant metadata."
        },
        {
          "name": "provider",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Provider name associated with assistant metadata."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-AttachmentBlobSpec",
      "name": "AttachmentBlobSpec",
      "source": "pkg/protocol/turn.go",
      "fields": [
        {
          "name": "file_array",
          "go_type": "[]FileElement",
          "json_tag": "always",
          "validation": "required",
          "desc": "Non-empty encoded payload array. Must have the same length and pairwise metadata as meta_files."
        },
        {
          "name": "meta_files",
          "go_type": "[]FileMeta",
          "json_tag": "always",
          "validation": "required",
          "desc": "Non-empty display metadata array matching file_array exactly by filename, MIME type, size, and order."
        }
      ],
      "notes": [
        "file_array and meta_files must be non-empty, equal-length, and pairwise identical in filename, MIME type, and actual size. Encodings are b64 or utf8. Binary files have a 32 MiB per-file and 32 MiB aggregate decoded limit; UTF-8 attachments are excluded from that binary aggregate."
      ]
    },
    {
      "id": "schema-FileElement",
      "name": "FileElement",
      "source": "pkg/protocol/turn.go",
      "fields": [
        {
          "name": "filename",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Non-empty caller-supplied filename paired by index with FileMeta."
        },
        {
          "name": "mime_type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Non-empty MIME type paired exactly with FileMeta."
        },
        {
          "name": "size",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Declared byte size. Omission decodes as zero and is valid for an empty payload; otherwise it must be non-negative and exactly equal the UTF-8 or decoded-base64 byte count."
        },
        {
          "name": "encoding",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Exactly utf8 or b64."
        },
        {
          "name": "payload",
          "go_type": "string",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Inline UTF-8 text or standard base64 data. Omission decodes as an empty payload and is valid when size is zero and paired metadata matches."
        }
      ],
      "notes": [
        "size must equal actual UTF-8 bytes or decoded base64 bytes. filename and mime_type are required."
      ]
    },
    {
      "id": "schema-FileMeta",
      "name": "FileMeta",
      "source": "pkg/protocol/turn.go",
      "fields": [
        {
          "name": "filename",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Must exactly match the paired FileElement filename."
        },
        {
          "name": "size",
          "go_type": "int64",
          "json_tag": "always",
          "validation": "optional",
          "desc": "Decoded byte size. Omission decodes as zero and is valid for a zero-byte FileElement; it must otherwise equal the validated payload size. For legacy stored metadata without size, discover the actual total from the first attachment_chunk response."
        },
        {
          "name": "mime_type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Must exactly match the paired FileElement MIME type."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-ToolInfo",
      "name": "ToolInfo",
      "source": "pkg/protocol/tool.go",
      "fields": [
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Tool capability name whose metadata is being supplied. Empty names are accepted but update no registered capability."
        },
        {
          "name": "description",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Human-readable model-facing tool description."
        },
        {
          "name": "parameters",
          "go_type": "map[string]interface{}",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "JSON Schema-like argument object used to validate required tool arguments."
        },
        {
          "name": "timeout",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Idle watchdog duration string; empty uses the 30s tool default and -1 disables the idle limit."
        },
        {
          "name": "max_timeout",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Absolute wall-clock duration string; empty or -1 means no absolute limit."
        },
        {
          "name": "tool_hint",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional user-facing hint about safe or intended tool use."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-PluginInfo",
      "name": "PluginInfo",
      "source": "pkg/protocol/plugin.go",
      "fields": [
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Plugin capability name whose metadata is being supplied. Empty names are accepted but update no registered capability."
        },
        {
          "name": "description",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Human-readable description of the plugin transformation."
        },
        {
          "name": "priority",
          "go_type": "int",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Pipeline ordering value; lower values execute earlier."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-MacroInfo",
      "name": "MacroInfo",
      "source": "pkg/protocol/macro.go",
      "fields": [
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Macro capability name whose metadata is being supplied. Empty names are accepted but update no registered capability."
        },
        {
          "name": "description",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Human-readable explanation of the macro’s operation and parameters."
        },
        {
          "name": "timeout",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Idle watchdog duration string; empty uses the 5s macro default and -1 disables the idle limit."
        },
        {
          "name": "max_timeout",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Absolute duration string; empty defaults to 30s and -1 disables the maximum."
        },
        {
          "name": "priority",
          "go_type": "int",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Ordering priority used where macros are sorted; lower values run first."
        },
        {
          "name": "version",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Provider-supplied macro version metadata."
        },
        {
          "name": "triggers",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Trigger names advertised for filtered discovery, for example on_idle or on_preplugin."
        },
        {
          "name": "internal",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Defaults to false. Purely a TUI visibility hint: internal macros are hidden from general macro selection and slash suggestions. Only this flag controls hiding, never a macro name or done suffix."
        }
      ],
      "notes": [
        "Internal macros remain in complete discovery inventories and API lists. Explicit invocation, daemon execution, and attachment are unchanged.",
        "For each trigger section, the session editor captures which internal macros are attached when the editor opens. Those macros remain listed throughout that visit, including across refreshes, so users can toggle them off and back on. Attachment changes apply immediately. Closing and reopening recomputes this visibility set, so internal macros left off disappear. Sections with no visible macros have no heading."
      ]
    },
    {
      "id": "schema-QueuedMessage",
      "name": "QueuedMessage",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque queued turn ID reserved before admission."
        },
        {
          "name": "parent_turn_id",
          "go_type": "*string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Requested parent placement; encoded as a string or null."
        },
        {
          "name": "turn",
          "go_type": "PendingTurn",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Queued semantic PendingTurn payload, preserving optional steer true/false input-timing context through queueing and plugin handoff. Attachment payload bytes are redacted; steer context is not."
        },
        {
          "name": "request_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Original prompt/steer correlation ID retained with the queued item."
        },
        {
          "name": "timestamp",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "RFC3339 timestamp recorded when the item entered the queue."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-LeafInfo",
      "name": "LeafInfo",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque leaf ID. Current generated IDs use l_ plus 12 hex digits."
        },
        {
          "name": "root_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root containing this leaf."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Current leaf display name."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Current leaf-tip turn ID; empty for a leaf with no turns."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Canonical model reference selected for this leaf."
        },
        {
          "name": "status",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Current runtime status: unloaded, idle, background, running, or aborting."
        },
        {
          "name": "updated_at",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "RFC3339 timestamp of the latest persisted leaf update."
        },
        {
          "name": "is_temp",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Temporary-leaf marker; omitted for ordinary leaves and true for temporary leaves."
        },
        {
          "name": "metadata",
          "go_type": "map[string]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Requested non-secret leaf metadata projection keyed by metadata_keys."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-CwdInfo",
      "name": "CwdInfo",
      "source": "pkg/protocol/session.go",
      "fields": [
        {"name":"cwd","go_type":"string","json_tag":"always","validation":"required","desc":"Exact persisted root cwd string matching the aligned cwds entry."},
        {"name":"leaf_count","go_type":"int","json_tag":"always","validation":"required","desc":"Number of non-temporary leaves with a canonical turn for this cwd, including forks with inherited history."},
        {"name":"active_leaf_count","go_type":"int","json_tag":"always","validation":"required","desc":"Number of qualifying leaves currently running, aborting or background. Idle and unloaded leaves are not active. Unlike list_leaves.is_active, this summary includes background work."},
        {"name":"last_activity_at","go_type":"string","json_tag":"omitempty","validation":"optional","desc":"Current UTC RFC3339 timestamp if any qualifying leaf is running, aborting or background; otherwise maximum qualifying leaf updated_at. Temporary and empty leaves do not contribute. Omitted if unavailable."}
      ],
      "notes": []
    },
    {
      "id": "schema-RootInfo",
      "name": "RootInfo",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque root ID. Current generated IDs use r_ plus 12 hex digits."
        },
        {
          "name": "cwd",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Root working directory; may be empty."
        },
        {
          "name": "root_turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "First/root turn ID when the root has one."
        },
        {
          "name": "created_at",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "RFC3339 root creation timestamp."
        },
        {
          "name": "updated_at",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "RFC3339 timestamp of the latest root mutation."
        },
        {
          "name": "config",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serialized non-secret root lifecycle metadata when present."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-TurnSummary",
      "name": "TurnSummary",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque persisted turn ID. Current generated IDs use t_ plus 12 hex digits."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted semantic turn kind."
        },
        {
          "name": "state",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted turn state: draft, ready, or sent."
        },
        {
          "name": "seq",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Sequence number within the root turn chain."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-TurnTreeNode",
      "name": "TurnTreeNode",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque persisted turn ID. Current generated IDs use t_ plus 12 hex digits."
        },
        {
          "name": "parent_id",
          "go_type": "*string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Parent persisted-turn ID; omitted for the root node."
        },
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted semantic turn kind."
        },
        {
          "name": "state",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Persisted turn state: draft, ready, or sent."
        },
        {
          "name": "seq",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Sequence number within the root turn chain."
        },
        {
          "name": "timestamp",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "RFC3339 persisted turn timestamp."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Model recorded for an assistant turn."
        },
        {
          "name": "provider",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Provider recorded for an assistant turn."
        },
        {
          "name": "stop_reason",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Recorded assistant terminal reason."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Tool capability name on a tool_result turn."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-AgentOutcome",
      "name": "AgentOutcome",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "reason",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Claimed terminal reason, matching agent_end and prompt_completed (for example stop, error, or abort)."
        },
        {
          "name": "message",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Normalized terminal message. Error outcomes use exactly the same non-empty final/fallback message as agent_end and prompt_completed."
        }
      ],
      "notes": [
        "RAM-only loaded-Agent state; it is not reconstructed from the database after unload or restart."
      ]
    },
    {
      "id": "schema-ActiveToolCall",
      "name": "ActiveToolCall",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Provider tool-call identity of a currently pending service-owned call."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Exact dispatched tool capability name."
        },
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Assistant source turn containing this tool call."
        }
      ],
      "notes": [
        "No arguments or internal service pointers are exposed. Lists are sorted by tool_call_id."
      ]
    },
    {
      "id": "schema-AgentRuntime",
      "name": "AgentRuntime",
      "source": "pkg/protocol/session.go",
      "fields": [
        {
          "name": "outcome",
          "go_type": "*AgentOutcome",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Most recently claimed outcome retained by the currently loaded Agent."
        },
        {
          "name": "active_tool_calls",
          "go_type": "[]ActiveToolCall",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Deterministically ordered service-owned pending tool calls for this leaf."
        }
      ],
      "notes": [
        "Progress is deliberately not nested here; it is an independent top-level LeafStatsResponse field owned by the service's leaf progress registry."
      ]
    },
    {
      "id": "schema-ProgressSnapshot",
      "name": "ProgressSnapshot",
      "source": "pkg/protocol/progress.go",
      "fields": [
        {
          "name": "turn_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Authoritative sent turn to which the complete progress snapshot belongs."
        },
        {
          "name": "items",
          "go_type": "[]ProgressItem",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Complete ordered replacement list of active progress items; an empty array clears the projection."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-ProgressItem",
      "name": "ProgressItem",
      "source": "pkg/protocol/progress.go",
      "fields": [
        {
          "name": "update_id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Producer-chosen item key within a leaf."
        },
        {
          "name": "title",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "User-facing title for this active progress operation."
        },
        {
          "name": "lines",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional user-facing detail lines in producer insertion order."
        },
        {
          "name": "visualizer_macro",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional macro name paired with visualizer_type for a consumer-side progress enhancement."
        },
        {
          "name": "visualizer_type",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional opaque descriptor type paired with visualizer_macro; current TUI recognition is exact ruby.workflow//0.1."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-Message",
      "name": "Message",
      "source": "pkg/protocol/types.go",
      "fields": [
        {
          "name": "role",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Structured message role; current stream frames use assistant."
        },
        {
          "name": "content",
          "go_type": "[]ContentBlock",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Ordered ContentBlock array. message_start uses an empty array; message_end carries complete thinking/text blocks."
        },
        {
          "name": "tool_calls",
          "go_type": "[]ToolCall",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Structured provider tool calls emitted by the assistant."
        },
        {
          "name": "tool_call_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Associated tool-call ID when this Message represents a tool result."
        },
        {
          "name": "tool_name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Associated tool capability name for a tool-result message."
        },
        {
          "name": "is_error",
          "go_type": "bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "True when a tool-result message represents failure."
        },
        {
          "name": "stop_reason",
          "go_type": "StopReason",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Terminal reason string: stop, error, tool_calls, streaming, or interrupted when present."
        },
        {
          "name": "usage",
          "go_type": "Usage",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Structured token Usage object. Because it is a non-pointer struct, Go encoding emits its zero-valued object even though the field tag includes omitempty."
        },
        {
          "name": "model",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Serving model reported for the completed assistant message."
        },
        {
          "name": "provider",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Provider that produced the completed assistant message."
        }
      ],
      "notes": [
        "StopReason is a string alias. Current named values are stop, error, tool_calls, streaming, and interrupted."
      ]
    },
    {
      "id": "schema-ContentBlock",
      "name": "ContentBlock",
      "source": "pkg/protocol/types.go",
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Content block kind: text, thinking, file, or image in current producers."
        },
        {
          "name": "text",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Text for text/thinking blocks or UTF-8 file content."
        },
        {
          "name": "data",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Base64 payload for file/image blocks."
        },
        {
          "name": "mimeType",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "MIME type for file/image data; note the wire key is camelCase mimeType."
        },
        {
          "name": "filename",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Original filename for a file block."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-TextDelta",
      "name": "TextDelta",
      "source": "pkg/protocol/types.go",
      "fields": [
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Delta channel discriminator, exactly text_delta or reasoning_delta in current stream producers."
        },
        {
          "name": "text",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Incremental text for the selected delta channel; offsets count its UTF-8 bytes."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-ToolCall",
      "name": "ToolCall",
      "source": "pkg/protocol/types.go",
      "fields": [
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Provider/tool-call identifier; opaque and echoed by the associated tool result."
        },
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Current provider tool calls use function."
        },
        {
          "name": "function",
          "go_type": "struct { Name string `json:\"name\"`; Arguments string `json:\"arguments\"` }",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Anonymous object with name and JSON arguments string; both nested keys are always serialized."
        }
      ],
      "notes": [
        "function.name is the tool name. function.arguments is the provider-supplied JSON argument document encoded as a string."
      ]
    },
    {
      "id": "schema-Usage",
      "name": "Usage",
      "source": "pkg/protocol/types.go",
      "fields": [
        {
          "name": "input",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Input tokens represented by this usage record; current canonical records include cached input."
        },
        {
          "name": "output",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Number of tokens generated in model output."
        },
        {
          "name": "cacheRead",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Input tokens served from provider cache."
        },
        {
          "name": "cacheWrite",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Input tokens written to provider cache."
        },
        {
          "name": "totalTokens",
          "go_type": "int",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Provider-reported or normalized total token count."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-LeafConfigListEntry",
      "name": "LeafConfigListEntry",
      "source": "pkg/protocol/config.go",
      "fields": [
        {
          "name": "key",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque per-leaf configuration key."
        },
        {
          "name": "value",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque string value stored under the key."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-ConnectionListEntry",
      "name": "ConnectionListEntry",
      "source": "pkg/protocol/tools.go",
      "fields": [
        {
          "name": "id",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Opaque live connection ID; assigned by the daemon at accept time and returned in hello_ack.connection_id."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Connection name supplied by hello."
        },
        {
          "name": "leaf_id",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Currently subscribed leaf, omitted when the connection has no leaf feed."
        },
        {
          "name": "tools",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Effective tool names available through this connection."
        },
        {
          "name": "plugins",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Effective plugin names available through this connection."
        },
        {
          "name": "macros",
          "go_type": "[]string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Effective macro names available through this connection, including announced names and launch-configured names for daemon-spawned direct services."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-ModelEntry",
      "name": "ModelEntry",
      "source": "pkg/protocol/tools.go",
      "fields": [
        {
          "name": "ref",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Canonical provider/model reference used for selection."
        },
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional display/model name when supplied by a producer."
        },
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional model type metadata."
        },
        {
          "name": "max_context",
          "go_type": "int",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Maximum context tokens when known."
        },
        {
          "name": "max_tokens",
          "go_type": "int",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Maximum output tokens when known."
        },
        {
          "name": "flags",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional model flags. Remote saved selections use not-found after successful refresh with a missing export/model, or unavailable when discovery fails. Neither removes the selection or permits fallback. Unknown flags may be ignored."
        },
        {
          "name": "thinking_levels",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Model-specific thinking levels accepted by configuration normalization."
        },
        {
          "name": "zdr_supported",
          "go_type": "*bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional zero-data-retention support flag; pointer distinguishes unknown from false."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-ModelInfo",
      "name": "ModelInfo",
      "source": "pkg/protocol/tools.go",
      "fields": [
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Configured model ID within its provider."
        },
        {
          "name": "max_context",
          "go_type": "int",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Maximum context tokens when configured."
        },
        {
          "name": "max_tokens",
          "go_type": "int",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Maximum output tokens when configured."
        },
        {
          "name": "thinking_levels",
          "go_type": "[]string",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Thinking levels supported by this model."
        },
        {
          "name": "zdr_supported",
          "go_type": "*bool",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Optional zero-data-retention support flag; pointer shape distinguishes unknown from false."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-ProviderListEntry",
      "name": "ProviderListEntry",
      "source": "pkg/protocol/tools.go",
      "fields": [
        {
          "name": "name",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Configured provider name used in model references."
        },
        {
          "name": "type",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Configured provider implementation type."
        },
        {
          "name": "base_url",
          "go_type": "string",
          "json_tag": "always",
          "validation": "contextual",
          "desc": "Configured provider base URL; may be empty for provider defaults."
        },
        {
          "name": "models",
          "go_type": "[]ModelInfo",
          "json_tag": "omitempty",
          "validation": "optional",
          "desc": "Configured model metadata for this provider."
        }
      ],
      "notes": []
    },
    {
      "id": "schema-PendingQuestion",
      "name": "PendingQuestion",
      "source": "pkg/protocol/question.go",
      "fields": [
        {
          "name": "kind",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Question kind. The only accepted value is project_config_trust."
        },
        {
          "name": "revision",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Nonempty opaque question revision copied exactly from the pending snapshot. Stale revisions are rejected by the question owner."
        },
        {
          "name": "project_config_trust",
          "go_type": "*ProjectConfigTrustQuestion",
          "json_tag": "omitempty",
          "validation": "contextual",
          "desc": "Required for project_config_trust and contains the exact resolved path and content fingerprint."
        }
      ],
      "notes": [
        "project_config_trust is the only current kind. Questions are daemon-owned and leaf-scoped; external peers cannot create them."
      ]
    },
    {
      "id": "schema-ProjectConfigTrustQuestion",
      "name": "ProjectConfigTrustQuestion",
      "source": "pkg/protocol/question.go",
      "fields": [
        {
          "name": "path",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "Physically resolved project configuration path."
        },
        {
          "name": "sha256",
          "go_type": "string",
          "json_tag": "always",
          "validation": "required",
          "desc": "SHA-256 fingerprint of the exact configuration contents."
        }
      ]
    }
  ]
}</script><script>
const CATALOG=JSON.parse(document.getElementById('agent-api-catalog').textContent);const MESSAGES=CATALOG.messages;const SCHEMAS=CATALOG.schemas;const byId=new Map(MESSAGES.map(x=>[x.id,x]));const schemaByName=new Map(SCHEMAS.map(x=>[x.name,x]));
const esc=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const reEscape=s=>String(s).replace(/[.*+?^${}()|[\]\\]/g,'\\$&');
function typeHTML(t){let out=esc(t);for(const [name,s] of schemaByName){const safe=reEscape(name);out=out.replace(new RegExp('(?<![A-Za-z0-9_])'+safe+'(?![A-Za-z0-9_])','g'),`<a class="schema-ref" href="#${s.id}">${esc(name)}</a>`)}return out}
function fields(fs){return `<div class="table-wrap"><table><thead><tr><th>Field</th><th>Exact Go shape</th><th>JSON encoding</th><th>Semantic validation</th><th>Description</th></tr></thead><tbody>${fs.map(f=>`<tr><td><code>${esc(f.name)}</code></td><td><code>${typeHTML(f.go_type)}</code></td><td class="encoding">${f.json_tag==='omitempty'?'omitempty tag':'no omitempty'}</td><td class="validation ${esc(f.validation)}">${esc(f.validation)}</td><td>${esc(f.desc)}</td></tr>`).join('')}</tbody></table></div>`}
function linkList(xs){return xs.length?`<div class="links">${xs.map(id=>{const x=byId.get(id);if(!x)throw new Error('Unresolved link '+id);return `<a href="#${esc(id)}">${esc(id)}</a>`}).join('')}</div>`:''}
function message(m){return `<article class="message" id="${esc(m.id)}" data-cat="${esc(m.category)}" data-search="${esc(JSON.stringify(m).toLowerCase())}"><header class="head"><h2><span class="wire">${esc(m.type)}</span>${m.id!==m.type?`<span class="role">${esc(m.id)}</span>`:''}</h2><p class="syn">${esc(m.synopsis)}</p><div class="meta"><span class="tag ${esc(m.category)}">${esc(m.category)}</span><span class="tag">${esc(m.struct)}</span><span class="tag">${esc(m.source)}</span></div></header><div class="body"><div class="direction"><strong>${esc(m.direction.from)}</strong> → <strong>${esc(m.direction.to)}</strong></div>${fields(m.fields)}<div class="cols"><section class="box"><h3>Canonical JSON example</h3><pre>${esc(JSON.stringify(m.example,null,2))}</pre></section><section class="box"><h3>Reply and relationships</h3><div class="reply">${esc(m.reply.text)}${linkList(m.reply.links)}</div>${m.related.length?`<h3 style="margin-top:14px">Related</h3>${linkList(m.related)}`:''}</section></div>${m.notes.length?`<ul class="notes">${m.notes.map(n=>`<li>${esc(n)}</li>`).join('')}</ul>`:''}</div></article>`}
function schema(s){return `<article class="schema" id="${esc(s.id)}" data-search="${esc(JSON.stringify(s).toLowerCase())}"><header class="head"><h2><span class="wire">${esc(s.name)}</span></h2><div class="meta"><span class="tag">nested schema</span><span class="tag">${esc(s.source)}</span></div></header><div class="body">${fields(s.fields)}${s.notes.length?`<ul class="notes">${s.notes.map(n=>`<li>${esc(n)}</li>`).join('')}</ul>`:''}</div></article>`}
document.getElementById('messages').innerHTML=MESSAGES.map(message).join('');document.getElementById('schemas').innerHTML=SCHEMAS.map(schema).join('');
const nav=document.getElementById('nav');nav.innerHTML='<h2>Overview</h2><a href="#addon-mesh">Addon mesh</a><a href="#catalog-scope">Catalog scope</a><a href="#how-to-read">How to read</a><a href="#nested-schemas">Nested schemas</a><h2>Frames</h2>'+MESSAGES.map(m=>`<a href="#${esc(m.id)}">${esc(m.id)}${m.id!==m.type?' · '+esc(m.type):''}</a>`).join('')+'<h2>Nested schemas</h2>'+SCHEMAS.map(s=>`<a href="#${esc(s.id)}">${esc(s.name)}</a>`).join('');
let category='all';const search=document.getElementById('search');const schemaIntro=document.getElementById('nested-schemas');function apply(){const q=search.value.trim().toLowerCase();let frameShown=0;document.querySelectorAll('.message').forEach(el=>{const ok=(category==='all'||el.dataset.cat===category)&&(!q||el.dataset.search.includes(q));el.hidden=!ok;if(ok)frameShown++});let schemaShown=0;document.querySelectorAll('.schema').forEach(el=>{const ok=category==='all'&&(!q||el.dataset.search.includes(q));el.hidden=!ok;if(ok)schemaShown++});schemaIntro.hidden=schemaShown===0;document.getElementById('schema-shown').textContent='('+schemaShown+' / '+SCHEMAS.length+' shown)';document.getElementById('empty').style.display=frameShown||schemaShown?'none':'block';document.getElementById('shown').textContent=frameShown+' / '+MESSAGES.length+' frames · '+schemaShown+' / '+SCHEMAS.length+' schemas'}search.addEventListener('input',apply);document.querySelectorAll('[data-filter]').forEach(b=>b.addEventListener('click',()=>{category=b.dataset.filter;document.querySelectorAll('[data-filter]').forEach(x=>x.classList.toggle('active',x===b));apply()}));document.getElementById('menu').addEventListener('click',()=>nav.classList.toggle('open'));nav.addEventListener('click',e=>{if(e.target.tagName==='A')nav.classList.remove('open')});function decodeHash(value){try{return decodeURIComponent(value)}catch{return value}}function revealHash(){const id=decodeHash(location.hash.slice(1));if(!id)return;const el=document.getElementById(id);if(!el||!el.hidden)return;category='all';document.querySelectorAll('[data-filter]').forEach(x=>x.classList.toggle('active',x.dataset.filter==='all'));search.value='';apply()}document.addEventListener('click',e=>{const a=e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;const id=decodeHash(a.getAttribute('href').slice(1));const el=document.getElementById(id);if(el&&el.hidden){category='all';document.querySelectorAll('[data-filter]').forEach(x=>x.classList.toggle('active',x.dataset.filter==='all'));search.value='';apply()}});window.addEventListener('hashchange',revealHash);apply();revealHash();
</script></body></html>