diff --git a/docs/gateway/protocol.md b/docs/gateway/protocol.md index 393aa7b8d6a..991537243c0 100644 --- a/docs/gateway/protocol.md +++ b/docs/gateway/protocol.md @@ -4,7 +4,7 @@ read_when: - Implementing or updating gateway WS clients - Debugging protocol mismatches or connect failures - Regenerating protocol schema/models -title: "Gateway Protocol" +title: "Gateway protocol" --- # Gateway protocol (WebSocket) @@ -260,199 +260,129 @@ Each client connection keeps its own per-client sequence number so broadcasts pr ## Common RPC method families -This page is not a generated full dump, but the public WS surface is broader -than the handshake/auth examples above. These are the main method families the -Gateway exposes today. +The public WS surface is broader than the handshake/auth examples above. This +is not a generated dump — `hello-ok.features.methods` is a conservative +discovery list built from `src/gateway/server-methods-list.ts` plus loaded +plugin/channel method exports. Treat it as feature discovery, not a full +enumeration of `src/gateway/server-methods/*.ts`. -`hello-ok.features.methods` is a conservative discovery list built from -`src/gateway/server-methods-list.ts` plus loaded plugin/channel method exports. -Treat it as feature discovery, not as a generated dump of every callable helper -implemented in `src/gateway/server-methods/*.ts`. + + + - `health` returns the cached or freshly probed gateway health snapshot. + - `diagnostics.stability` returns the recent bounded diagnostic stability recorder. It keeps operational metadata such as event names, counts, byte sizes, memory readings, queue/session state, channel/plugin names, and session ids. It does not keep chat text, webhook bodies, tool outputs, raw request or response bodies, tokens, cookies, or secret values. Operator read scope is required. + - `status` returns the `/status`-style gateway summary; sensitive fields are included only for admin-scoped operator clients. + - `gateway.identity.get` returns the gateway device identity used by relay and pairing flows. + - `system-presence` returns the current presence snapshot for connected operator/node devices. + - `system-event` appends a system event and can update/broadcast presence context. + - `last-heartbeat` returns the latest persisted heartbeat event. + - `set-heartbeats` toggles heartbeat processing on the gateway. + -### System and identity + + - `models.list` returns the runtime-allowed model catalog. + - `usage.status` returns provider usage windows/remaining quota summaries. + - `usage.cost` returns aggregated cost usage summaries for a date range. + - `doctor.memory.status` returns vector-memory / embedding readiness for the active default agent workspace. + - `sessions.usage` returns per-session usage summaries. + - `sessions.usage.timeseries` returns timeseries usage for one session. + - `sessions.usage.logs` returns usage log entries for one session. + -- `health` returns the cached or freshly probed gateway health snapshot. -- `diagnostics.stability` returns the recent bounded diagnostic stability - recorder. It keeps operational metadata such as event names, counts, byte - sizes, memory readings, queue/session state, channel/plugin names, and session - ids. It does not keep chat text, webhook bodies, tool outputs, raw request or - response bodies, tokens, cookies, or secret values. Operator read scope is - required. -- `status` returns the `/status`-style gateway summary; sensitive fields are - included only for admin-scoped operator clients. -- `gateway.identity.get` returns the gateway device identity used by relay and - pairing flows. -- `system-presence` returns the current presence snapshot for connected - operator/node devices. -- `system-event` appends a system event and can update/broadcast presence - context. -- `last-heartbeat` returns the latest persisted heartbeat event. -- `set-heartbeats` toggles heartbeat processing on the gateway. + + - `channels.status` returns built-in + bundled channel/plugin status summaries. + - `channels.logout` logs out a specific channel/account where the channel supports logout. + - `web.login.start` starts a QR/web login flow for the current QR-capable web channel provider. + - `web.login.wait` waits for that QR/web login flow to complete and starts the channel on success. + - `push.test` sends a test APNs push to a registered iOS node. + - `voicewake.get` returns the stored wake-word triggers. + - `voicewake.set` updates wake-word triggers and broadcasts the change. + -### Models and usage + + - `send` is the direct outbound-delivery RPC for channel/account/thread-targeted sends outside the chat runner. + - `logs.tail` returns the configured gateway file-log tail with cursor/limit and max-byte controls. + -- `models.list` returns the runtime-allowed model catalog. -- `usage.status` returns provider usage windows/remaining quota summaries. -- `usage.cost` returns aggregated cost usage summaries for a date range. -- `doctor.memory.status` returns vector-memory / embedding readiness for the - active default agent workspace. -- `sessions.usage` returns per-session usage summaries. -- `sessions.usage.timeseries` returns timeseries usage for one session. -- `sessions.usage.logs` returns usage log entries for one session. + + - `talk.config` returns the effective Talk config payload; `includeSecrets` requires `operator.talk.secrets` (or `operator.admin`). + - `talk.mode` sets/broadcasts the current Talk mode state for WebChat/Control UI clients. + - `talk.speak` synthesizes speech through the active Talk speech provider. + - `tts.status` returns TTS enabled state, active provider, fallback providers, and provider config state. + - `tts.providers` returns the visible TTS provider inventory. + - `tts.enable` and `tts.disable` toggle TTS prefs state. + - `tts.setProvider` updates the preferred TTS provider. + - `tts.convert` runs one-shot text-to-speech conversion. + -### Channels and login helpers + + - `secrets.reload` re-resolves active SecretRefs and swaps runtime secret state only on full success. + - `secrets.resolve` resolves command-target secret assignments for a specific command/target set. + - `config.get` returns the current config snapshot and hash. + - `config.set` writes a validated config payload. + - `config.patch` merges a partial config update. + - `config.apply` validates + replaces the full config payload. + - `config.schema` returns the live config schema payload used by Control UI and CLI tooling: schema, `uiHints`, version, and generation metadata, including plugin + channel schema metadata when the runtime can load it. The schema includes field `title` / `description` metadata derived from the same labels and help text used by the UI, including nested object, wildcard, array-item, and `anyOf` / `oneOf` / `allOf` composition branches when matching field documentation exists. + - `config.schema.lookup` returns a path-scoped lookup payload for one config path: normalized path, a shallow schema node, matched hint + `hintPath`, and immediate child summaries for UI/CLI drill-down. Lookup schema nodes keep the user-facing docs and common validation fields (`title`, `description`, `type`, `enum`, `const`, `format`, `pattern`, numeric/string/array/object bounds, and flags like `additionalProperties`, `deprecated`, `readOnly`, `writeOnly`). Child summaries expose `key`, normalized `path`, `type`, `required`, `hasChildren`, plus the matched `hint` / `hintPath`. + - `update.run` runs the gateway update flow and schedules a restart only when the update itself succeeded. + - `wizard.start`, `wizard.next`, `wizard.status`, and `wizard.cancel` expose the onboarding wizard over WS RPC. + -- `channels.status` returns built-in + bundled channel/plugin status summaries. -- `channels.logout` logs out a specific channel/account where the channel - supports logout. -- `web.login.start` starts a QR/web login flow for the current QR-capable web - channel provider. -- `web.login.wait` waits for that QR/web login flow to complete and starts the - channel on success. -- `push.test` sends a test APNs push to a registered iOS node. -- `voicewake.get` returns the stored wake-word triggers. -- `voicewake.set` updates wake-word triggers and broadcasts the change. + + - `agents.list` returns configured agent entries. + - `agents.create`, `agents.update`, and `agents.delete` manage agent records and workspace wiring. + - `agents.files.list`, `agents.files.get`, and `agents.files.set` manage the bootstrap workspace files exposed for an agent. + - `agent.identity.get` returns the effective assistant identity for an agent or session. + - `agent.wait` waits for a run to finish and returns the terminal snapshot when available. + -### Messaging and logs + + - `sessions.list` returns the current session index. + - `sessions.subscribe` and `sessions.unsubscribe` toggle session change event subscriptions for the current WS client. + - `sessions.messages.subscribe` and `sessions.messages.unsubscribe` toggle transcript/message event subscriptions for one session. + - `sessions.preview` returns bounded transcript previews for specific session keys. + - `sessions.resolve` resolves or canonicalizes a session target. + - `sessions.create` creates a new session entry. + - `sessions.send` sends a message into an existing session. + - `sessions.steer` is the interrupt-and-steer variant for an active session. + - `sessions.abort` aborts active work for a session. + - `sessions.patch` updates session metadata/overrides. + - `sessions.reset`, `sessions.delete`, and `sessions.compact` perform session maintenance. + - `sessions.get` returns the full stored session row. + - Chat execution still uses `chat.history`, `chat.send`, `chat.abort`, and `chat.inject`. `chat.history` is display-normalized for UI clients: inline directive tags are stripped from visible text, plain-text tool-call XML payloads (including `...`, `...`, `...`, `...`, and truncated tool-call blocks) and leaked ASCII/full-width model control tokens are stripped, pure silent-token assistant rows such as exact `NO_REPLY` / `no_reply` are omitted, and oversized rows can be replaced with placeholders. + -- `send` is the direct outbound-delivery RPC for channel/account/thread-targeted - sends outside the chat runner. -- `logs.tail` returns the configured gateway file-log tail with cursor/limit and - max-byte controls. + + - `device.pair.list` returns pending and approved paired devices. + - `device.pair.approve`, `device.pair.reject`, and `device.pair.remove` manage device-pairing records. + - `device.token.rotate` rotates a paired device token within its approved role and scope bounds. + - `device.token.revoke` revokes a paired device token. + -### Talk and TTS + + - `node.pair.request`, `node.pair.list`, `node.pair.approve`, `node.pair.reject`, and `node.pair.verify` cover node pairing and bootstrap verification. + - `node.list` and `node.describe` return known/connected node state. + - `node.rename` updates a paired node label. + - `node.invoke` forwards a command to a connected node. + - `node.invoke.result` returns the result for an invoke request. + - `node.event` carries node-originated events back into the gateway. + - `node.canvas.capability.refresh` refreshes scoped canvas-capability tokens. + - `node.pending.pull` and `node.pending.ack` are the connected-node queue APIs. + - `node.pending.enqueue` and `node.pending.drain` manage durable pending work for offline/disconnected nodes. + -- `talk.config` returns the effective Talk config payload; `includeSecrets` - requires `operator.talk.secrets` (or `operator.admin`). -- `talk.mode` sets/broadcasts the current Talk mode state for WebChat/Control UI - clients. -- `talk.speak` synthesizes speech through the active Talk speech provider. -- `tts.status` returns TTS enabled state, active provider, fallback providers, - and provider config state. -- `tts.providers` returns the visible TTS provider inventory. -- `tts.enable` and `tts.disable` toggle TTS prefs state. -- `tts.setProvider` updates the preferred TTS provider. -- `tts.convert` runs one-shot text-to-speech conversion. + + - `exec.approval.request`, `exec.approval.get`, `exec.approval.list`, and `exec.approval.resolve` cover one-shot exec approval requests plus pending approval lookup/replay. + - `exec.approval.waitDecision` waits on one pending exec approval and returns the final decision (or `null` on timeout). + - `exec.approvals.get` and `exec.approvals.set` manage gateway exec approval policy snapshots. + - `exec.approvals.node.get` and `exec.approvals.node.set` manage node-local exec approval policy via node relay commands. + - `plugin.approval.request`, `plugin.approval.list`, `plugin.approval.waitDecision`, and `plugin.approval.resolve` cover plugin-defined approval flows. + -### Secrets, config, update, and wizard - -- `secrets.reload` re-resolves active SecretRefs and swaps runtime secret state - only on full success. -- `secrets.resolve` resolves command-target secret assignments for a specific - command/target set. -- `config.get` returns the current config snapshot and hash. -- `config.set` writes a validated config payload. -- `config.patch` merges a partial config update. -- `config.apply` validates + replaces the full config payload. -- `config.schema` returns the live config schema payload used by Control UI and - CLI tooling: schema, `uiHints`, version, and generation metadata, including - plugin + channel schema metadata when the runtime can load it. The schema - includes field `title` / `description` metadata derived from the same labels - and help text used by the UI, including nested object, wildcard, array-item, - and `anyOf` / `oneOf` / `allOf` composition branches when matching field - documentation exists. -- `config.schema.lookup` returns a path-scoped lookup payload for one config - path: normalized path, a shallow schema node, matched hint + `hintPath`, and - immediate child summaries for UI/CLI drill-down. - - Lookup schema nodes keep the user-facing docs and common validation fields: - `title`, `description`, `type`, `enum`, `const`, `format`, `pattern`, - numeric/string/array/object bounds, and boolean flags like - `additionalProperties`, `deprecated`, `readOnly`, `writeOnly`. - - Child summaries expose `key`, normalized `path`, `type`, `required`, - `hasChildren`, plus the matched `hint` / `hintPath`. -- `update.run` runs the gateway update flow and schedules a restart only when - the update itself succeeded. -- `wizard.start`, `wizard.next`, `wizard.status`, and `wizard.cancel` expose the - onboarding wizard over WS RPC. - -### Existing major families - -#### Agent and workspace helpers - -- `agents.list` returns configured agent entries. -- `agents.create`, `agents.update`, and `agents.delete` manage agent records and - workspace wiring. -- `agents.files.list`, `agents.files.get`, and `agents.files.set` manage the - bootstrap workspace files exposed for an agent. -- `agent.identity.get` returns the effective assistant identity for an agent or - session. -- `agent.wait` waits for a run to finish and returns the terminal snapshot when - available. - -#### Session control - -- `sessions.list` returns the current session index. -- `sessions.subscribe` and `sessions.unsubscribe` toggle session change event - subscriptions for the current WS client. -- `sessions.messages.subscribe` and `sessions.messages.unsubscribe` toggle - transcript/message event subscriptions for one session. -- `sessions.preview` returns bounded transcript previews for specific session - keys. -- `sessions.resolve` resolves or canonicalizes a session target. -- `sessions.create` creates a new session entry. -- `sessions.send` sends a message into an existing session. -- `sessions.steer` is the interrupt-and-steer variant for an active session. -- `sessions.abort` aborts active work for a session. -- `sessions.patch` updates session metadata/overrides. -- `sessions.reset`, `sessions.delete`, and `sessions.compact` perform session - maintenance. -- `sessions.get` returns the full stored session row. -- chat execution still uses `chat.history`, `chat.send`, `chat.abort`, and - `chat.inject`. -- `chat.history` is display-normalized for UI clients: inline directive tags are - stripped from visible text, plain-text tool-call XML payloads (including - `...`, `...`, - `...`, `...`, and - truncated tool-call blocks) and leaked ASCII/full-width model control tokens - are stripped, pure silent-token assistant rows such as exact `NO_REPLY` / - `no_reply` are omitted, and oversized rows can be replaced with placeholders. - -#### Device pairing and device tokens - -- `device.pair.list` returns pending and approved paired devices. -- `device.pair.approve`, `device.pair.reject`, and `device.pair.remove` manage - device-pairing records. -- `device.token.rotate` rotates a paired device token within its approved role - and scope bounds. -- `device.token.revoke` revokes a paired device token. - -#### Node pairing, invoke, and pending work - -- `node.pair.request`, `node.pair.list`, `node.pair.approve`, - `node.pair.reject`, and `node.pair.verify` cover node pairing and bootstrap - verification. -- `node.list` and `node.describe` return known/connected node state. -- `node.rename` updates a paired node label. -- `node.invoke` forwards a command to a connected node. -- `node.invoke.result` returns the result for an invoke request. -- `node.event` carries node-originated events back into the gateway. -- `node.canvas.capability.refresh` refreshes scoped canvas-capability tokens. -- `node.pending.pull` and `node.pending.ack` are the connected-node queue APIs. -- `node.pending.enqueue` and `node.pending.drain` manage durable pending work - for offline/disconnected nodes. - -#### Approval families - -- `exec.approval.request`, `exec.approval.get`, `exec.approval.list`, and - `exec.approval.resolve` cover one-shot exec approval requests plus pending - approval lookup/replay. -- `exec.approval.waitDecision` waits on one pending exec approval and returns - the final decision (or `null` on timeout). -- `exec.approvals.get` and `exec.approvals.set` manage gateway exec approval - policy snapshots. -- `exec.approvals.node.get` and `exec.approvals.node.set` manage node-local exec - approval policy via node relay commands. -- `plugin.approval.request`, `plugin.approval.list`, - `plugin.approval.waitDecision`, and `plugin.approval.resolve` cover - plugin-defined approval flows. - -#### Other major families - -- automation: - - `wake` schedules an immediate or next-heartbeat wake text injection - - `cron.list`, `cron.status`, `cron.add`, `cron.update`, `cron.remove`, - `cron.run`, `cron.runs` -- skills/tools: `commands.list`, `skills.*`, `tools.catalog`, `tools.effective` + + - Automation: `wake` schedules an immediate or next-heartbeat wake text injection; `cron.list`, `cron.status`, `cron.add`, `cron.update`, `cron.remove`, `cron.run`, `cron.runs` manage scheduled work. + - Skills and tools: `commands.list`, `skills.*`, `tools.catalog`, `tools.effective`. + + ### Common event families