@canonmsg/backend-contracts 1.8.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/agentBehaviorPolicy.d.ts +45 -86
  2. package/dist/agentBehaviorPolicy.js +0 -53
  3. package/dist/cjs/agentBehaviorPolicy.js +1 -54
  4. package/dist/cjs/contactRequest.js +0 -30
  5. package/dist/cjs/index.js +0 -8
  6. package/dist/cjs/media.js +0 -13
  7. package/dist/cjs/message.js +0 -64
  8. package/dist/cjs/runtimeCardFields.js +1 -58
  9. package/dist/cjs/turnProtocol.js +1 -41
  10. package/dist/contactRequest.d.ts +23 -42
  11. package/dist/contactRequest.js +0 -29
  12. package/dist/index.d.ts +0 -8
  13. package/dist/index.js +0 -8
  14. package/dist/media.d.ts +11 -24
  15. package/dist/media.js +0 -12
  16. package/dist/message.d.ts +50 -133
  17. package/dist/message.js +1 -64
  18. package/dist/runtimeCardFields.d.ts +39 -112
  19. package/dist/runtimeCardFields.js +0 -57
  20. package/dist/turnProtocol.d.ts +24 -91
  21. package/dist/turnProtocol.js +0 -40
  22. package/package.json +5 -8
  23. package/dist/bridgeLocal.d.ts +0 -1729
  24. package/dist/bridgeLocal.js +0 -673
  25. package/dist/cjs/bridgeLocal.js +0 -676
  26. package/dist/cjs/controlSignals.js +0 -44
  27. package/dist/cjs/endpointRegistry.js +0 -264
  28. package/dist/cjs/hitl.js +0 -0
  29. package/dist/cjs/inboundFrame.js +0 -92
  30. package/dist/cjs/restEndpoints.js +0 -237
  31. package/dist/cjs/sendContextual.js +0 -92
  32. package/dist/cjs/sseEvents.js +0 -298
  33. package/dist/controlSignals.d.ts +0 -55
  34. package/dist/controlSignals.js +0 -41
  35. package/dist/endpointRegistry.d.ts +0 -13
  36. package/dist/endpointRegistry.js +0 -261
  37. package/dist/hitl.d.ts +0 -303
  38. package/dist/hitl.js +0 -168
  39. package/dist/inboundFrame.d.ts +0 -229
  40. package/dist/inboundFrame.js +0 -89
  41. package/dist/restEndpoints.d.ts +0 -531
  42. package/dist/restEndpoints.js +0 -234
  43. package/dist/schemas/agent-behavior-settings-record.schema.json +0 -48
  44. package/dist/schemas/bridge-connection-state-notification.schema.json +0 -19
  45. package/dist/schemas/bridge-get-attachment-params.schema.json +0 -24
  46. package/dist/schemas/bridge-get-attachment-result.schema.json +0 -20
  47. package/dist/schemas/bridge-hello-params.schema.json +0 -42
  48. package/dist/schemas/bridge-hello-result.schema.json +0 -105
  49. package/dist/schemas/bridge-hitl-state.schema.json +0 -38
  50. package/dist/schemas/bridge-ok-result.schema.json +0 -15
  51. package/dist/schemas/bridge-ready-notification.schema.json +0 -79
  52. package/dist/schemas/bridge-resync-reason.schema.json +0 -9
  53. package/dist/schemas/bridge-resync.schema.json +0 -18
  54. package/dist/schemas/bridge-rpc-error.schema.json +0 -19
  55. package/dist/schemas/bridge-rpc-id.schema.json +0 -12
  56. package/dist/schemas/bridge-rpc-notification.schema.json +0 -20
  57. package/dist/schemas/bridge-rpc-request.schema.json +0 -31
  58. package/dist/schemas/bridge-rpc-response.schema.json +0 -81
  59. package/dist/schemas/bridge-status-result.schema.json +0 -76
  60. package/dist/schemas/bridge-upload-media-params.schema.json +0 -28
  61. package/dist/schemas/bridge-upstream-state.schema.json +0 -10
  62. package/dist/schemas/contacts-response.schema.json +0 -52
  63. package/dist/schemas/control-channel-key.schema.json +0 -10
  64. package/dist/schemas/control-primitive-event.schema.json +0 -30
  65. package/dist/schemas/control-primitive-map.schema.json +0 -15
  66. package/dist/schemas/control-session-event.schema.json +0 -26
  67. package/dist/schemas/control-session-node.schema.json +0 -11
  68. package/dist/schemas/control-signal-event.schema.json +0 -35
  69. package/dist/schemas/control-signal-node.schema.json +0 -22
  70. package/dist/schemas/control-signal-type.schema.json +0 -10
  71. package/dist/schemas/conversations-response.schema.json +0 -167
  72. package/dist/schemas/create-contact-request-request.schema.json +0 -17
  73. package/dist/schemas/create-contact-request-response.schema.json +0 -51
  74. package/dist/schemas/create-conversation-request.schema.json +0 -82
  75. package/dist/schemas/create-conversation-response.schema.json +0 -29
  76. package/dist/schemas/delete-message-response.schema.json +0 -11
  77. package/dist/schemas/delivery-intent.schema.json +0 -11
  78. package/dist/schemas/forward-message-request.schema.json +0 -25
  79. package/dist/schemas/forward-message-response.schema.json +0 -35
  80. package/dist/schemas/forwarded-from.schema.json +0 -18
  81. package/dist/schemas/get-messages-query.schema.json +0 -17
  82. package/dist/schemas/hitl-approval-category.schema.json +0 -15
  83. package/dist/schemas/hitl-approval-detail.schema.json +0 -21
  84. package/dist/schemas/hitl-approval-outcome-record.schema.json +0 -33
  85. package/dist/schemas/hitl-approval-reply-record.schema.json +0 -57
  86. package/dist/schemas/hitl-approval-request-record.schema.json +0 -105
  87. package/dist/schemas/hitl-approval-risk.schema.json +0 -11
  88. package/dist/schemas/hitl-card-outcome-record.schema.json +0 -48
  89. package/dist/schemas/hitl-card-reply-record.schema.json +0 -46
  90. package/dist/schemas/hitl-card-request-record.schema.json +0 -73
  91. package/dist/schemas/hitl-input-answers.schema.json +0 -23
  92. package/dist/schemas/hitl-input-kind.schema.json +0 -10
  93. package/dist/schemas/hitl-input-outcome-record.schema.json +0 -46
  94. package/dist/schemas/hitl-input-question.schema.json +0 -54
  95. package/dist/schemas/hitl-input-reply-record.schema.json +0 -44
  96. package/dist/schemas/hitl-input-request-record.schema.json +0 -134
  97. package/dist/schemas/hitl-pending.schema.json +0 -31
  98. package/dist/schemas/hitl-request-accepted.schema.json +0 -18
  99. package/dist/schemas/hitl-request-kind.schema.json +0 -10
  100. package/dist/schemas/hitl-resolution-status.schema.json +0 -10
  101. package/dist/schemas/hitl-resolution.schema.json +0 -38
  102. package/dist/schemas/hitl-session-rule.schema.json +0 -32
  103. package/dist/schemas/inbound-disposition.schema.json +0 -13
  104. package/dist/schemas/inbound-frame-attachment-v1.schema.json +0 -94
  105. package/dist/schemas/inbound-frame-contact-card-v1.schema.json +0 -59
  106. package/dist/schemas/inbound-frame-group-context-v1.schema.json +0 -96
  107. package/dist/schemas/inbound-frame-reply-context-v1.schema.json +0 -261
  108. package/dist/schemas/inbound-frame-shape-v1.schema.json +0 -12
  109. package/dist/schemas/inbound-frame-v1.schema.json +0 -506
  110. package/dist/schemas/mark-read-response.schema.json +0 -11
  111. package/dist/schemas/media-attachment-kind.schema.json +0 -11
  112. package/dist/schemas/media-attachment.schema.json +0 -42
  113. package/dist/schemas/messages-page-response.schema.json +0 -290
  114. package/dist/schemas/participation-decision-input.schema.json +0 -44
  115. package/dist/schemas/participation-history-message.schema.json +0 -23
  116. package/dist/schemas/participation-history-snapshot.schema.json +0 -37
  117. package/dist/schemas/participation-style.schema.json +0 -13
  118. package/dist/schemas/react-request.schema.json +0 -22
  119. package/dist/schemas/react-response.schema.json +0 -35
  120. package/dist/schemas/resolve-admission-request.schema.json +0 -30
  121. package/dist/schemas/resolve-admission-response.schema.json +0 -129
  122. package/dist/schemas/resolved-agent-behavior-policy-record.schema.json +0 -81
  123. package/dist/schemas/rest-contact.schema.json +0 -40
  124. package/dist/schemas/rest-conversation-last-message.schema.json +0 -77
  125. package/dist/schemas/rest-conversation.schema.json +0 -155
  126. package/dist/schemas/rest-message.schema.json +0 -252
  127. package/dist/schemas/rest-ok-response.schema.json +0 -11
  128. package/dist/schemas/rest-session-selection.schema.json +0 -40
  129. package/dist/schemas/runtime-card-field-choice.schema.json +0 -23
  130. package/dist/schemas/runtime-card-field-type.schema.json +0 -17
  131. package/dist/schemas/runtime-card-field.schema.json +0 -180
  132. package/dist/schemas/runtime-card-line-item-column-type.schema.json +0 -12
  133. package/dist/schemas/runtime-card-line-item-column.schema.json +0 -74
  134. package/dist/schemas/send-contextual-deferred-response.schema.json +0 -39
  135. package/dist/schemas/send-contextual-messaged-response.schema.json +0 -42
  136. package/dist/schemas/send-contextual-request.schema.json +0 -103
  137. package/dist/schemas/send-contextual-response.schema.json +0 -105
  138. package/dist/schemas/send-contextual-self-context.schema.json +0 -19
  139. package/dist/schemas/send-contextual-state-response.schema.json +0 -24
  140. package/dist/schemas/send-message-request.schema.json +0 -106
  141. package/dist/schemas/send-message-response.schema.json +0 -14
  142. package/dist/schemas/sender-type.schema.json +0 -9
  143. package/dist/schemas/serialize-message-input.schema.json +0 -29
  144. package/dist/schemas/serialized-agent-client-type.schema.json +0 -12
  145. package/dist/schemas/serialized-contact-card.schema.json +0 -65
  146. package/dist/schemas/serialized-contact-request-status.schema.json +0 -11
  147. package/dist/schemas/serialized-contact-request.schema.json +0 -157
  148. package/dist/schemas/serialized-content-type.schema.json +0 -13
  149. package/dist/schemas/serialized-message.schema.json +0 -249
  150. package/dist/schemas/serialized-reactions.schema.json +0 -14
  151. package/dist/schemas/serialized-sender-type.schema.json +0 -9
  152. package/dist/schemas/set-streaming-request.schema.json +0 -67
  153. package/dist/schemas/set-typing-request.schema.json +0 -25
  154. package/dist/schemas/sse-access-policy.schema.json +0 -10
  155. package/dist/schemas/sse-agent-context-payload.schema.json +0 -57
  156. package/dist/schemas/sse-connected-payload.schema.json +0 -18
  157. package/dist/schemas/sse-contact-payload.schema.json +0 -40
  158. package/dist/schemas/sse-contact-removed-payload.schema.json +0 -14
  159. package/dist/schemas/sse-contact-request-payload.schema.json +0 -157
  160. package/dist/schemas/sse-conversation-updated-payload.schema.json +0 -48
  161. package/dist/schemas/sse-error-payload.schema.json +0 -23
  162. package/dist/schemas/sse-event-envelope.schema.json +0 -42
  163. package/dist/schemas/sse-event-family.schema.json +0 -12
  164. package/dist/schemas/sse-event-type.schema.json +0 -28
  165. package/dist/schemas/sse-heartbeat-payload.schema.json +0 -14
  166. package/dist/schemas/sse-membership-change.schema.json +0 -28
  167. package/dist/schemas/sse-message-created-payload.schema.json +0 -414
  168. package/dist/schemas/sse-message-deleted-payload.schema.json +0 -18
  169. package/dist/schemas/sse-message-updated-payload.schema.json +0 -46
  170. package/dist/schemas/sse-presence-payload.schema.json +0 -21
  171. package/dist/schemas/sse-provenance.schema.json +0 -64
  172. package/dist/schemas/sse-replay-expired-payload.schema.json +0 -21
  173. package/dist/schemas/sse-runtime-control-kind.schema.json +0 -13
  174. package/dist/schemas/sse-runtime-control-payload.schema.json +0 -44
  175. package/dist/schemas/sse-runtime-updated-payload.schema.json +0 -78
  176. package/dist/schemas/sse-self-context.schema.json +0 -45
  177. package/dist/schemas/sse-turn-dispatch.schema.json +0 -29
  178. package/dist/schemas/sse-turn-updated-payload.schema.json +0 -33
  179. package/dist/schemas/sse-typing-payload.schema.json +0 -32
  180. package/dist/schemas/sse-voice-session-event-payload.schema.json +0 -170
  181. package/dist/schemas/sse-voice-session.schema.json +0 -157
  182. package/dist/schemas/trigger-decision.schema.json +0 -27
  183. package/dist/schemas/turn-lifecycle-state.schema.json +0 -14
  184. package/dist/schemas/turn-message-semantics.schema.json +0 -10
  185. package/dist/schemas/turn-metadata.schema.json +0 -56
  186. package/dist/schemas/turn-state-like.schema.json +0 -39
  187. package/dist/schemas/update-disposition-request.schema.json +0 -22
  188. package/dist/schemas/upload-media-request.schema.json +0 -25
  189. package/dist/schemas/upload-media-response.schema.json +0 -55
  190. package/dist/sendContextual.d.ts +0 -114
  191. package/dist/sendContextual.js +0 -89
  192. package/dist/sseEvents.d.ts +0 -494
  193. package/dist/sseEvents.js +0 -295
@@ -1,676 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BridgeRpcResponseSchema = exports.BridgeRpcErrorSchema = exports.BridgeRpcNotificationSchema = exports.BridgeRpcRequestSchema = exports.BridgeRpcIdSchema = exports.BRIDGE_LOCAL_NOTIFICATION_FAMILIES = exports.BRIDGE_LOCAL_NOTIFICATION_NAMES = exports.BRIDGE_LOCAL_NOTIFICATIONS = exports.BRIDGE_LOCAL_METHOD_NAMES = exports.BRIDGE_LOCAL_METHODS = exports.BridgeGetAttachmentResultSchema = exports.BridgeGetAttachmentParamsSchema = exports.BridgeUploadMediaParamsSchema = exports.BridgeHitlStateSchema = exports.BridgeStatusResultSchema = exports.BridgeConnectionStateNotificationSchema = exports.BridgeReadyNotificationSchema = exports.BridgeUpstreamStateSchema = exports.BridgeHelloResultSchema = exports.BRIDGE_EVENT_CURSOR_SHAPE = exports.BridgeResyncSchema = exports.BridgeResyncReasonSchema = exports.BridgeHelloParamsSchema = exports.BridgeOkResultSchema = exports.BRIDGE_LOCAL_PROTOCOL_VERSION = void 0;
4
- // Bridge ⇄ runtime-adapter LOCAL JSON-RPC contract v1 (types + schemas ONLY —
5
- // no runtime, no transport; Phase 4 builds the bridge against these).
6
- //
7
- // Source spec: docs/design/bridge-local-api.md §A–§C. Where that draft
8
- // conflicts with code-grounded wire shapes (event names, REST payloads), the
9
- // code-grounded schemas in this package win — payload slots below COMPOSE
10
- // restEndpoints.ts / hitl.ts / sseEvents.ts / controlSignals.ts so every
11
- // shape is defined once.
12
- //
13
- // Protocol: JSON-RPC 2.0 over one duplex channel (stdio pipe or unix
14
- // socket / named pipe), NDJSON framing. Requests adapter→bridge (replied),
15
- // notifications bridge→adapter (never awaited). `hello` carries
16
- // protocolVersion — the local contract is version-guarded from v1.
17
- const zod_1 = require("zod");
18
- const contactRequest_js_1 = require("./contactRequest.js");
19
- const turnProtocol_js_1 = require("./turnProtocol.js");
20
- const controlSignals_js_1 = require("./controlSignals.js");
21
- const hitl_js_1 = require("./hitl.js");
22
- const restEndpoints_js_1 = require("./restEndpoints.js");
23
- const sendContextual_js_1 = require("./sendContextual.js");
24
- const sseEvents_js_1 = require("./sseEvents.js");
25
- exports.BRIDGE_LOCAL_PROTOCOL_VERSION = 1;
26
- const OkResultSchema = zod_1.z.object({ ok: zod_1.z.literal(true) });
27
- exports.BridgeOkResultSchema = OkResultSchema;
28
- // ── §A Session lifecycle ───────────────────────────────────────────────
29
- exports.BridgeHelloParamsSchema = zod_1.z.object({
30
- protocolVersion: zod_1.z.number(),
31
- /** Adapter self-identification (claude-code | codex | openclaw | hermes | …). */
32
- clientType: zod_1.z.string(),
33
- /** Event families to deliver; [] = pure-request adapter, no C-notifications. */
34
- wantFamilies: zod_1.z.array(sseEvents_js_1.SseEventFamilySchema),
35
- /** Replay C-notifications missed while disconnected. */
36
- resumeCursor: zod_1.z.string().optional(),
37
- /** Publish the runtime descriptor in the same round trip. */
38
- runtimeDescriptor: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
39
- });
40
- // ── §G resume cursor / resync ───────────────────────────────────────────
41
- //
42
- // The bridge keeps a bounded, locally-sequenced event log. Every replayable
43
- // §C event notification carries the OPAQUE `cursor` token that produced it;
44
- // adapters persist the last cursor they fully processed and present it as
45
- // `hello.resumeCursor` on reconnect to replay exactly the gap. When the
46
- // cursor cannot be honored the hello result answers `sinceCursor: null`
47
- // PLUS a `resync` field — the adapter must treat the gap as lost locally and
48
- // recover out-of-band (REST backfill / state refresh). Never silent loss.
49
- exports.BridgeResyncReasonSchema = zod_1.z.enum([
50
- /** Cursor was valid but its events were evicted from the bounded log. */
51
- 'cursor-expired',
52
- /** Cursor was never issued by this bridge run (restart or corruption). */
53
- 'unknown-cursor',
54
- ]);
55
- exports.BridgeResyncSchema = zod_1.z.object({
56
- reason: exports.BridgeResyncReasonSchema,
57
- });
58
- /**
59
- * Shape mixin for replayable §C notification params (`.extend(...)` onto the
60
- * payload schema). `cursor` is optional in the schema for compatibility, but
61
- * the bridge always sends it on log-delivered notifications. `ready` and
62
- * `connectionState` are connection-scoped (never replayed) and carry none.
63
- */
64
- exports.BRIDGE_EVENT_CURSOR_SHAPE = {
65
- cursor: zod_1.z.string().optional(),
66
- };
67
- exports.BridgeHelloResultSchema = zod_1.z.object({
68
- protocolVersion: zod_1.z.number(),
69
- agentId: zod_1.z.string(),
70
- agentName: zod_1.z.string(),
71
- agentContext: sseEvents_js_1.SseAgentContextPayloadSchema,
72
- /** Cursor the delivered replay starts from; null = no replay. */
73
- sinceCursor: zod_1.z.string().nullable(),
74
- /**
75
- * Present when resumeCursor could not be honored (§G): delivery starts at
76
- * the live head and the adapter must recover the gap out-of-band.
77
- */
78
- resync: exports.BridgeResyncSchema.optional(),
79
- });
80
- exports.BridgeUpstreamStateSchema = zod_1.z.enum(['connected', 'reconnecting', 'down']);
81
- exports.BridgeReadyNotificationSchema = zod_1.z.object({
82
- agentId: zod_1.z.string(),
83
- agentContext: sseEvents_js_1.SseAgentContextPayloadSchema,
84
- upstreamState: exports.BridgeUpstreamStateSchema,
85
- });
86
- exports.BridgeConnectionStateNotificationSchema = zod_1.z.object({
87
- upstream: exports.BridgeUpstreamStateSchema,
88
- });
89
- /**
90
- * `status` result (B4.6 observability): a live snapshot of the daemon
91
- * process, its upstream health, and the B4.2 hub counters. Additive to
92
- * contract v1 — served by the daemon and rendered by `canon-bridge status`.
93
- */
94
- exports.BridgeStatusResultSchema = zod_1.z.object({
95
- /** Daemon process id. */
96
- pid: zod_1.z.number(),
97
- /** canon-bridge binary (package) version. */
98
- version: zod_1.z.string(),
99
- /** bridgeLocal contract version the daemon speaks. */
100
- protocolVersion: zod_1.z.number(),
101
- /** ISO timestamp of daemon start. */
102
- startedAt: zod_1.z.string(),
103
- uptimeMs: zod_1.z.number(),
104
- /** Lifecycle profile served (one identity per daemon). */
105
- profile: zod_1.z.string(),
106
- /** Socket / named-pipe path; null in stdio (spawned-child) mode. */
107
- socketPath: zod_1.z.string().nullable(),
108
- agentId: zod_1.z.string(),
109
- agentName: zod_1.z.string(),
110
- upstream: exports.BridgeUpstreamStateSchema,
111
- /** Adapter connections currently subscribed to the fan-out. */
112
- connectedClients: zod_1.z.number(),
113
- /** Non-zero B4.2 hub counters (upstream.* / fanout.*). */
114
- counters: zod_1.z.record(zod_1.z.string(), zod_1.z.number()),
115
- });
116
- // ── §B7 HITL state (durable; resolution arrives via onHitlResolved) ────
117
- exports.BridgeHitlStateSchema = zod_1.z.object({
118
- status: zod_1.z.union([zod_1.z.literal('pending'), hitl_js_1.HitlResolutionStatusSchema]),
119
- answer: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
120
- expiresAt: zod_1.z.string(),
121
- });
122
- // ── §B8 media (named schemas so the bridge + Framework share the types) ──
123
- //
124
- // Byte transfer is bridge-owned (adapter-interface §1): adapters hand the
125
- // bridge a {path} (streamed from disk — preferred for anything big) or
126
- // inline {bytes} (base64, size-capped so a frame never breaches the NDJSON
127
- // line limit). getAttachment returns the bridge-cached materialization.
128
- exports.BridgeUploadMediaParamsSchema = zod_1.z.object({
129
- /** Absolute file path — the bridge streams it (exactly one of path | bytes). */
130
- path: zod_1.z.string().optional(),
131
- /** Base64 bytes — size-capped by the bridge; prefer `path` for large files. */
132
- bytes: zod_1.z.string().optional(),
133
- mime: zod_1.z.string(),
134
- fileName: zod_1.z.string(),
135
- conversationId: zod_1.z.string(),
136
- });
137
- exports.BridgeGetAttachmentParamsSchema = zod_1.z.object({
138
- /** Storage download URL from a MediaAttachment (exactly one of url | attachmentId). */
139
- url: zod_1.z.string().optional(),
140
- attachmentId: zod_1.z.string().optional(),
141
- as: zod_1.z.enum(['path', 'bytes']),
142
- });
143
- exports.BridgeGetAttachmentResultSchema = zod_1.z.object({
144
- /** Stable bridge-cache path — present when as:'path'. */
145
- path: zod_1.z.string().optional(),
146
- /** Base64 — present when as:'bytes'; capped by the bridge's bytes ceiling. */
147
- bytes: zod_1.z.string().optional(),
148
- mime: zod_1.z.string(),
149
- });
150
- const conversationScoped = zod_1.z.object({ conversationId: zod_1.z.string() });
151
- const messageScoped = zod_1.z.object({ conversationId: zod_1.z.string(), messageId: zod_1.z.string() });
152
- /**
153
- * RTDB server-timestamp sentinel — code-grounded pass-through (hosts write
154
- * `{'.sv':'timestamp'}` for openedAt/completedAt today; the bridge forwards
155
- * it to the RTDB REST API untouched).
156
- */
157
- const ServerTimestampSentinelSchema = zod_1.z.object({ '.sv': zod_1.z.literal('timestamp') });
158
- const EpochOrServerTimestampSchema = zod_1.z.union([zod_1.z.number(), ServerTimestampSentinelSchema]);
159
- exports.BRIDGE_LOCAL_METHODS = {
160
- // §A lifecycle
161
- hello: { params: exports.BridgeHelloParamsSchema, result: exports.BridgeHelloResultSchema },
162
- /** Liveness probe — the bridge answers without touching upstream. */
163
- ping: { params: zod_1.z.object({}), result: OkResultSchema },
164
- shutdown: { params: zod_1.z.object({}), result: OkResultSchema },
165
- /** Daemon snapshot (B4.6): process, upstream health, hub counters. */
166
- status: { params: zod_1.z.object({}), result: exports.BridgeStatusResultSchema },
167
- // §B1 messaging (outbound)
168
- sendMessage: {
169
- params: restEndpoints_js_1.SendMessageRequestSchema,
170
- // B4.3 additive: the bridge chunks oversized text (core retry/chunking);
171
- // messageId is the FINAL chunk (carries the caller's metadata/turn
172
- // semantics), messageIds lists every part in send order.
173
- result: restEndpoints_js_1.SendMessageResponseSchema.extend({
174
- messageIds: zod_1.z.array(zod_1.z.string()).optional(),
175
- }),
176
- },
177
- sendContextualMessage: {
178
- params: sendContextual_js_1.SendContextualRequestSchema,
179
- result: sendContextual_js_1.SendContextualResponseSchema,
180
- },
181
- reactToMessage: { params: restEndpoints_js_1.ReactRequestSchema, result: restEndpoints_js_1.ReactResponseSchema },
182
- forwardMessage: { params: restEndpoints_js_1.ForwardMessageRequestSchema, result: restEndpoints_js_1.ForwardMessageResponseSchema },
183
- deleteMessage: { params: messageScoped, result: OkResultSchema },
184
- markRead: { params: conversationScoped, result: OkResultSchema },
185
- setDisposition: {
186
- params: messageScoped.extend(restEndpoints_js_1.UpdateDispositionRequestSchema.shape),
187
- result: OkResultSchema,
188
- },
189
- // §B2 reading / history
190
- getMessages: {
191
- params: zod_1.z.object({
192
- conversationId: zod_1.z.string(),
193
- limit: zod_1.z.number().optional(),
194
- before: zod_1.z.string().optional(),
195
- includeBehavior: zod_1.z.boolean().optional(),
196
- }),
197
- // B4.3 additive: nextCursor is the bridge-derived `before` token for the
198
- // next page (oldest returned message id), present when the page filled
199
- // the requested limit. The REST surface itself emits no cursor.
200
- result: restEndpoints_js_1.MessagesPageResponseSchema.extend({
201
- nextCursor: zod_1.z.string().optional(),
202
- }),
203
- },
204
- getConversations: { params: zod_1.z.object({}), result: restEndpoints_js_1.ConversationsResponseSchema },
205
- // §B3 conversation / group management
206
- createConversation: {
207
- params: restEndpoints_js_1.CreateConversationRequestSchema,
208
- result: restEndpoints_js_1.CreateConversationResponseSchema,
209
- },
210
- updateTopic: {
211
- params: conversationScoped.extend({ topic: zod_1.z.string() }),
212
- result: OkResultSchema,
213
- },
214
- updateName: {
215
- params: conversationScoped.extend({ name: zod_1.z.string() }),
216
- result: OkResultSchema,
217
- },
218
- updateAvatar: {
219
- params: conversationScoped.extend({ avatarUrl: zod_1.z.string().nullable().optional() }),
220
- result: OkResultSchema,
221
- },
222
- addMember: {
223
- params: conversationScoped.extend({ userId: zod_1.z.string() }),
224
- result: zod_1.z.union([
225
- zod_1.z.object({ status: zod_1.z.literal('added') }),
226
- zod_1.z.object({ status: zod_1.z.literal('pending'), requestId: zod_1.z.string() }),
227
- ]),
228
- },
229
- removeMember: {
230
- params: conversationScoped.extend({ userId: zod_1.z.string() }),
231
- result: OkResultSchema,
232
- },
233
- leaveConversation: { params: conversationScoped, result: OkResultSchema },
234
- muteConversation: {
235
- params: conversationScoped.extend({ until: zod_1.z.number().optional() }),
236
- result: OkResultSchema,
237
- },
238
- unmuteConversation: { params: conversationScoped, result: OkResultSchema },
239
- hideConversation: { params: conversationScoped, result: OkResultSchema },
240
- // §B4 contacts / admission / blocking
241
- createContactRequest: {
242
- params: restEndpoints_js_1.CreateContactRequestRequestSchema,
243
- result: restEndpoints_js_1.CreateContactRequestResponseSchema,
244
- },
245
- listContacts: { params: zod_1.z.object({}), result: restEndpoints_js_1.ContactsResponseSchema },
246
- getContact: {
247
- params: zod_1.z.object({ contactId: zod_1.z.string() }),
248
- result: restEndpoints_js_1.RestContactSchema.nullable(),
249
- },
250
- removeContact: { params: zod_1.z.object({ contactId: zod_1.z.string() }), result: OkResultSchema },
251
- listContactRequests: {
252
- params: zod_1.z.object({}),
253
- result: zod_1.z.object({ requests: zod_1.z.array(contactRequest_js_1.SerializedContactRequestSchema) }),
254
- },
255
- resolveAdmission: {
256
- params: restEndpoints_js_1.ResolveAdmissionRequestSchema,
257
- result: restEndpoints_js_1.ResolveAdmissionResponseSchema,
258
- },
259
- reachOut: {
260
- // B6.1 additive (P6 openclaw): the optional fields mirror core
261
- // reachOutToCanonContact options — contact-request message, agent
262
- // session config/selection, and SendMessageOptions passthrough — so
263
- // channel adapters keep today's reach-out fidelity through the bridge.
264
- params: zod_1.z.object({
265
- targetId: zod_1.z.string(),
266
- /**
267
- * Optional (B6.1): core reach-out treats a missing text as
268
- * "resolve/open the conversation only" — the openclaw media path
269
- * reaches out first and sends the uploaded attachment separately.
270
- */
271
- text: zod_1.z.string().optional(),
272
- selfContext: zod_1.z.string().optional(),
273
- /** Contact-request message when admission requires approval. */
274
- requestMessage: zod_1.z.string().optional(),
275
- /** Initial agent session config — opaque pass-through. */
276
- sessionConfig: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable().optional(),
277
- /** Same union as the REST send surfaces (incl. mode: 'specific'). */
278
- sessionSelection: restEndpoints_js_1.RestSessionSelectionSchema.optional(),
279
- /** SendMessageOptions passthrough (replyTo, selfContextId, metadata, …). */
280
- sendMessageOptions: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
281
- }),
282
- result: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
283
- },
284
- blockUser: { params: zod_1.z.object({ userId: zod_1.z.string() }), result: OkResultSchema },
285
- unblockUser: { params: zod_1.z.object({ userId: zod_1.z.string() }), result: OkResultSchema },
286
- // §B5 live presence / streaming (bridge throttles internally)
287
- setTyping: {
288
- params: conversationScoped.extend({ state: zod_1.z.enum(['typing', 'thinking', 'clear']) }),
289
- result: OkResultSchema,
290
- },
291
- publishStreaming: {
292
- params: conversationScoped.extend({
293
- turnId: zod_1.z.string().nullable().optional(),
294
- messageId: zod_1.z.string().optional(),
295
- text: zod_1.z.string().optional(),
296
- delta: zod_1.z.string().optional(),
297
- /** TurnOutputBlock[] — opaque pass-through. */
298
- blocks: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
299
- /**
300
- * Explicit bubble/presentation status override (union of B6.1 openclaw
301
- * + P6 host surface): 'tool' / 'waiting_input' cannot be derived from
302
- * text/blocks. Omitted: the bridge derives thinking/streaming from
303
- * content as before.
304
- */
305
- status: zod_1.z.enum(['thinking', 'streaming', 'tool', 'waiting_input']).optional(),
306
- done: zod_1.z.boolean().optional(),
307
- }),
308
- result: OkResultSchema,
309
- },
310
- clearStreaming: { params: conversationScoped, result: OkResultSchema },
311
- // §B6 runtime presentation (adapter owns content, bridge publishes)
312
- publishRuntimeDescriptor: {
313
- params: zod_1.z.object({
314
- descriptor: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
315
- /**
316
- * B6.1 additive (P6 openclaw): rides into the published /agent-runtime
317
- * payload — hosts and host-mode channel plugins publish hostMode: true
318
- * today and the field is app-visible. Latched for subsequent publishes;
319
- * defaults to false (bridge-adapter split is not a host process).
320
- */
321
- hostMode: zod_1.z.boolean().optional(),
322
- }),
323
- result: OkResultSchema,
324
- },
325
- publishRuntimeStatus: {
326
- // Code-grounded correction (B4.3): RTDB runtime-info lives per
327
- // conversation (/runtime-info/{convoId}/{agentId}), so the publish is
328
- // conversation-scoped. `presentation` carries the remaining
329
- // RuntimeInfoPayload fields (surfaceMode, facts, inventories, notes, …)
330
- // as an opaque pass-through.
331
- params: conversationScoped.extend({
332
- statusItems: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
333
- presentation: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
334
- }),
335
- result: OkResultSchema,
336
- },
337
- publishTurnState: {
338
- // B6.1 additive (P6 openclaw): the remaining CanonTurnStatePayload
339
- // fields hosts publish today. `completedAt: true` asks the bridge to
340
- // stamp the server timestamp (the RTDB sentinel is bridge-owned).
341
- params: conversationScoped.extend({
342
- turnId: zod_1.z.string().nullable().optional(),
343
- state: turnProtocol_js_1.TurnLifecycleStateSchema,
344
- queueDepth: zod_1.z.number().optional(),
345
- capabilities: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
346
- // Union of B6.1 (openclaw) + P6 host surface — the remaining
347
- // code-grounded TurnStatePayload fields (rtdb-rest.ts).
348
- currentSpeakerId: zod_1.z.string().nullable().optional(),
349
- lastAcceptedIntent: turnProtocol_js_1.DeliveryIntentSchema.nullable().optional(),
350
- activeMessageIds: zod_1.z.array(zod_1.z.string()).optional(),
351
- openedAt: EpochOrServerTimestampSchema.optional(),
352
- turnUpdatedAt: EpochOrServerTimestampSchema.nullable().optional(),
353
- // `true` (B6.1 openclaw) asks the bridge to stamp the server-timestamp
354
- // sentinel; hosts (P6) pass an epoch or the sentinel through directly.
355
- completedAt: zod_1.z
356
- .union([zod_1.z.boolean(), EpochOrServerTimestampSchema])
357
- .nullable()
358
- .optional(),
359
- }),
360
- result: OkResultSchema,
361
- },
362
- clearTurnState: { params: conversationScoped, result: OkResultSchema },
363
- publishActivity: {
364
- params: conversationScoped.extend({
365
- activityItems: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())),
366
- }),
367
- result: OkResultSchema,
368
- },
369
- clearActivity: {
370
- // B6.1 additive (P6 openclaw): remove activity blocks. `all` wipes the
371
- // conversation's node; `itemIds` removes specific blocks; neither falls
372
- // back to the publisher's terminal-only sweep semantics.
373
- params: conversationScoped.extend({
374
- all: zod_1.z.boolean().optional(),
375
- itemIds: zod_1.z.array(zod_1.z.string()).optional(),
376
- }),
377
- result: OkResultSchema,
378
- },
379
- /** B6.1 additive: clear the per-conversation runtime-info node. */
380
- clearRuntimeStatus: { params: conversationScoped, result: OkResultSchema },
381
- /**
382
- * B6.1 additive: clear /agent-runtime for this identity (preserves
383
- * descriptor-bearing payloads with updatedAt: 0, like hosts do today).
384
- */
385
- clearRuntimeDescriptor: { params: zod_1.z.object({}), result: OkResultSchema },
386
- // §B7 HITL (durable; returns requestId, resolves via onHitlResolved).
387
- //
388
- // P6 host surface (additive): process-executing hosts publish the SAME
389
- // rich records channel runtimes create today (approval cards with
390
- // diff/details/native handles, titled input cards, card ids the runtime
391
- // correlates on). All new fields are optional — the narrow Phase-4 shape
392
- // still parses. `requestId`/`inputId`/`cardId`-style explicit ids become
393
- // the bridge record's requestId so adapters keep their own correlation.
394
- // `responseUserId: null` means "let the server pick a reachable responder"
395
- // (codex cards today); absent keeps the Phase-4 default (agent owner).
396
- requestApproval: {
397
- // B6.1 additive (P6 openclaw): optional approval-card fidelity fields
398
- // (core createRuntimeApprovalRequest passthrough) so native runtime
399
- // approvals keep their tool name, detail rows, correlation handles and
400
- // allow-always affordance through the bridge.
401
- params: conversationScoped.extend({
402
- detail: zod_1.z.string(),
403
- risk: hitl_js_1.HitlApprovalRiskSchema,
404
- category: hitl_js_1.HitlApprovalCategorySchema,
405
- expiresAt: zod_1.z.string().optional(),
406
- approvalId: zod_1.z.string().optional(),
407
- /** Card header tool name; defaults to the category. */
408
- toolName: zod_1.z.string().optional(),
409
- riskLevel: zod_1.z.enum(['normal', 'destructive']).optional(),
410
- details: zod_1.z.array(hitl_js_1.HitlApprovalDetailSchema).optional(),
411
- /** File-change preview (CanonUnifiedDiff) — opaque pass-through. */
412
- diff: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
413
- /** Native runtime correlation handles — opaque pass-through. */
414
- native: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
415
- turnId: zod_1.z.string().optional(),
416
- runtimeId: zod_1.z.string().optional(),
417
- /** Offer the "always allow" session-rule affordance on the card. */
418
- allowSessionRule: zod_1.z.boolean().optional(),
419
- responseUserId: zod_1.z.string().nullable().optional(),
420
- }),
421
- result: hitl_js_1.HitlRequestAcceptedSchema,
422
- },
423
- requestInput: {
424
- params: conversationScoped.extend({
425
- questions: zod_1.z.array(hitl_js_1.HitlInputQuestionSchema),
426
- expiresAt: zod_1.z.string().optional(),
427
- inputId: zod_1.z.string().optional(),
428
- title: zod_1.z.string().optional(),
429
- prompt: zod_1.z.string().optional(),
430
- kind: hitl_js_1.HitlInputKindSchema.optional(),
431
- sensitive: zod_1.z.boolean().optional(),
432
- native: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
433
- turnId: zod_1.z.string().optional(),
434
- responseUserId: zod_1.z.string().nullable().optional(),
435
- }),
436
- result: hitl_js_1.HitlRequestAcceptedSchema,
437
- },
438
- requestCard: {
439
- params: conversationScoped.extend({
440
- /** canon.card.v1 content — opaque pass-through. */
441
- card: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
442
- expiresAt: zod_1.z.string().optional(),
443
- cardId: zod_1.z.string().optional(),
444
- native: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
445
- turnId: zod_1.z.string().optional(),
446
- responseUserId: zod_1.z.string().nullable().optional(),
447
- }),
448
- result: hitl_js_1.HitlRequestAcceptedSchema,
449
- },
450
- getHitlState: {
451
- params: zod_1.z.object({ requestId: zod_1.z.string() }),
452
- result: exports.BridgeHitlStateSchema,
453
- },
454
- cancelHitl: { params: zod_1.z.object({ requestId: zod_1.z.string() }), result: OkResultSchema },
455
- // §B8 media (named schemas above — the bridge + Framework share them)
456
- uploadMedia: {
457
- params: exports.BridgeUploadMediaParamsSchema,
458
- result: restEndpoints_js_1.UploadMediaResponseSchema,
459
- },
460
- getAttachment: {
461
- params: exports.BridgeGetAttachmentParamsSchema,
462
- result: exports.BridgeGetAttachmentResultSchema,
463
- },
464
- // §B9 voice (media stays client↔LiveKit; bridge brokers the token).
465
- // Code-grounded correction (B4.3): every /voice/sessions/:id REST op
466
- // requires the conversationId (body or query) — the session doc lives
467
- // under the conversation — so the session-scoped methods carry it too.
468
- createVoiceSession: {
469
- params: conversationScoped.extend({ targetAgentId: zod_1.z.string().optional() }),
470
- result: zod_1.z.looseObject({ sessionId: zod_1.z.string() }),
471
- },
472
- joinVoiceSession: {
473
- params: zod_1.z.object({ sessionId: zod_1.z.string(), conversationId: zod_1.z.string() }),
474
- result: zod_1.z.looseObject({ url: zod_1.z.string(), token: zod_1.z.string() }),
475
- },
476
- endVoiceSession: {
477
- params: zod_1.z.object({ sessionId: zod_1.z.string(), conversationId: zod_1.z.string() }),
478
- result: OkResultSchema,
479
- },
480
- getVoiceSession: {
481
- params: zod_1.z.object({ sessionId: zod_1.z.string(), conversationId: zod_1.z.string() }),
482
- result: sseEvents_js_1.SseVoiceSessionEventPayloadSchema,
483
- },
484
- // §B10 registration / identity
485
- getAgent: {
486
- params: zod_1.z.object({}),
487
- result: zod_1.z.object({
488
- agentId: zod_1.z.string(),
489
- agentName: zod_1.z.string(),
490
- context: sseEvents_js_1.SseAgentContextPayloadSchema,
491
- }),
492
- },
493
- register: {
494
- params: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
495
- // pollToken (when issued) authorizes subsequent status polls.
496
- result: zod_1.z.object({ requestId: zod_1.z.string(), pollToken: zod_1.z.string().optional() }),
497
- },
498
- getRegistrationStatus: {
499
- // `baseUrl` (B6.1 additive) supports the pre-identity bootstrap: the
500
- // registration statics are unauthenticated, so a stub-identity bridge
501
- // can serve them with an explicit endpoint.
502
- params: zod_1.z.object({
503
- requestId: zod_1.z.string(),
504
- pollToken: zod_1.z.string().optional(),
505
- baseUrl: zod_1.z.string().optional(),
506
- }),
507
- result: zod_1.z.looseObject({ status: zod_1.z.string() }),
508
- },
509
- /**
510
- * Acknowledge one-time API-key delivery after an approved registration
511
- * (POST /agents/status/:id/ack). Best-effort on the wire; failures surface
512
- * as upstream-band errors. Additive union of Phase 5 + P6 openclaw: the
513
- * Hermes port consumed it through the GENERIC Python escape hatch first
514
- * (a bridge-side method addition with zero framework-py release), and
515
- * `baseUrl` (B6.1) supports the wizard's per-call pre-identity bootstrap.
516
- */
517
- ackRegistrationStatus: {
518
- params: zod_1.z.object({
519
- requestId: zod_1.z.string(),
520
- pollToken: zod_1.z.string().optional(),
521
- baseUrl: zod_1.z.string().optional(),
522
- }),
523
- result: OkResultSchema,
524
- },
525
- // §5b host-profile surface (bridge-execution-plan Phase 4 step 5b) —
526
- // additive methods for process-executing (host-mode) adapters, beyond §B.
527
- // Shapes mirror @canonmsg/core host-runtime-wire.ts; runtime payloads are
528
- // opaque pass-through (AgentRuntime).
529
- publishHostAgentRuntime: {
530
- params: zod_1.z.object({
531
- /** Defaults to the hello clientType. */
532
- clientType: zod_1.z.string().optional(),
533
- /** AgentRuntime — opaque pass-through. */
534
- runtime: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
535
- }),
536
- result: OkResultSchema,
537
- },
538
- publishHostSessionSnapshots: {
539
- params: zod_1.z.object({
540
- conversationIds: zod_1.z.array(zod_1.z.string()),
541
- /** Defaults to the hello clientType. */
542
- clientType: zod_1.z.string().optional(),
543
- /** AgentRuntime — opaque pass-through. */
544
- runtime: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
545
- workspaceOptions: zod_1.z.array(zod_1.z.object({ id: zod_1.z.string(), cwd: zod_1.z.string() })).optional(),
546
- defaultCwd: zod_1.z.string().optional(),
547
- extraSessionConfigFields: zod_1.z.array(zod_1.z.string()).optional(),
548
- /** conversationId → live session-config overrides (JSON'd Map). */
549
- liveSessionConfigByConversation: zod_1.z
550
- .record(zod_1.z.string(), zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()))
551
- .optional(),
552
- }),
553
- result: OkResultSchema,
554
- },
555
- // §5b host-profile surface, P6 additions (bridge-execution-plan Phase 6) —
556
- // the remaining RTDB planes the process-executing hosts touched directly
557
- // until now: the per-conversation session-state node, its config read, and
558
- // the terminal clears. Payloads mirror @canonmsg/core rtdb-rest.ts shapes
559
- // as opaque pass-through; the bridge executes them through the core
560
- // runtime-state publisher (hostMode) over its single RTDB handle.
561
- getSessionConfig: {
562
- params: conversationScoped,
563
- /** Raw `/session-config/{convoId}/{agentId}` node; adapters parse locally. */
564
- result: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable(),
565
- },
566
- publishSessionState: {
567
- params: conversationScoped.extend({
568
- /** SessionStatePayload minus updatedAt — opaque pass-through. */
569
- state: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
570
- }),
571
- result: OkResultSchema,
572
- },
573
- clearSessionState: { params: conversationScoped, result: OkResultSchema },
574
- // clearTurnState is defined once under §B6 above (both legs added it; the
575
- // clear is publisher-agnostic so channel adapters and hosts share it).
576
- /**
577
- * Terminal /agent-runtime clear through the HOST publisher. Same RTDB
578
- * effect as §B6.1 clearRuntimeDescriptor (preserve descriptor-bearing
579
- * payloads with updatedAt: 0) — kept as a distinct §5b name because host
580
- * consumers correlate it with the publishHostAgentRuntime plane.
581
- */
582
- clearAgentRuntime: { params: zod_1.z.object({}), result: OkResultSchema },
583
- };
584
- exports.BRIDGE_LOCAL_METHOD_NAMES = Object.keys(exports.BRIDGE_LOCAL_METHODS);
585
- // ── §C Notification registry (bridge → adapter, one-way) ───────────────
586
- exports.BRIDGE_LOCAL_NOTIFICATIONS = {
587
- // §A — connection-scoped, never replayed, no cursor
588
- ready: exports.BridgeReadyNotificationSchema,
589
- connectionState: exports.BridgeConnectionStateNotificationSchema,
590
- // §C1 inbound messages (pre-filtered: deduped, self/control stripped)
591
- onMessage: sseEvents_js_1.SseMessageCreatedPayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
592
- onMessageUpdated: sseEvents_js_1.SseMessageUpdatedPayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
593
- onMessageDeleted: sseEvents_js_1.SseMessageDeletedPayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
594
- onConversationUpdated: sseEvents_js_1.SseConversationUpdatedPayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
595
- // §C2 control (bridge consumed from RTDB — adapters never poll)
596
- onControlSignal: controlSignals_js_1.ControlSignalEventSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
597
- onSessionControl: controlSignals_js_1.ControlSessionEventSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
598
- // §C2 addition (P6, both legs): `/control/.../primitive` runtime command
599
- // dispatch (/status, /compact, …) consumed by the bridge poller — adapters
600
- // (openclaw handlers, codex compact) never poll RTDB themselves.
601
- onControlPrimitive: controlSignals_js_1.ControlPrimitiveEventSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
602
- // §C6 HITL resolution (durable; matches a §B7 requestId)
603
- onHitlResolved: hitl_js_1.HitlResolutionSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
604
- onHitlPending: hitl_js_1.HitlPendingSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
605
- /**
606
- * §C6 addition (P6 host surface): a stripped HITL control-reply message
607
- * (metadata.type approval_reply / plan_approval_reply) that matched NO
608
- * bridge-owned HITL record fans out here instead of being dropped —
609
- * process-executing hosts run reply flows the bridge did not raise
610
- * (claude plan approval is a plain sendMessage + metadata-reply waiter).
611
- * `message` is the serialized Canon message, opaque pass-through.
612
- */
613
- onControlReply: zod_1.z.object({
614
- conversationId: zod_1.z.string(),
615
- message: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
616
- }).extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
617
- // §C3 contacts
618
- onContactChanged: zod_1.z.object({
619
- kind: zod_1.z.enum(['request', 'approved', 'added', 'updated', 'removed']),
620
- contact: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
621
- }).extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
622
- // §C4 typing / presence
623
- onTyping: sseEvents_js_1.SseTypingPayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
624
- onPresence: sseEvents_js_1.SsePresencePayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
625
- // §C5 voice
626
- onVoiceSessionStarted: sseEvents_js_1.SseVoiceSessionEventPayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
627
- onVoiceSessionEnded: sseEvents_js_1.SseVoiceSessionEventPayloadSchema.extend(exports.BRIDGE_EVENT_CURSOR_SHAPE),
628
- };
629
- exports.BRIDGE_LOCAL_NOTIFICATION_NAMES = Object.keys(exports.BRIDGE_LOCAL_NOTIFICATIONS);
630
- /**
631
- * Event family per §C notification, mirroring SSE_EVENT_FAMILY_BY_TYPE.
632
- * `lifecycle` notifications are connection-scoped and delivered to every
633
- * client; family notifications are filtered by `hello.wantFamilies`
634
- * (`wantFamilies: []` = pure-request adapter, no §C events at all).
635
- */
636
- exports.BRIDGE_LOCAL_NOTIFICATION_FAMILIES = {
637
- ready: 'lifecycle',
638
- connectionState: 'lifecycle',
639
- onMessage: 'messages',
640
- onMessageUpdated: 'messages',
641
- onMessageDeleted: 'messages',
642
- onConversationUpdated: 'messages',
643
- onControlSignal: 'runtime_turn',
644
- onSessionControl: 'runtime_turn',
645
- onControlPrimitive: 'runtime_turn',
646
- onHitlResolved: 'runtime_turn',
647
- onHitlPending: 'runtime_turn',
648
- onControlReply: 'runtime_turn',
649
- onContactChanged: 'contacts',
650
- onTyping: 'typing_presence',
651
- onPresence: 'typing_presence',
652
- onVoiceSessionStarted: 'voice',
653
- onVoiceSessionEnded: 'voice',
654
- };
655
- // ── JSON-RPC 2.0 framing ───────────────────────────────────────────────
656
- exports.BridgeRpcIdSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number()]);
657
- exports.BridgeRpcRequestSchema = zod_1.z.object({
658
- jsonrpc: zod_1.z.literal('2.0'),
659
- id: exports.BridgeRpcIdSchema,
660
- method: zod_1.z.string(),
661
- params: zod_1.z.unknown().optional(),
662
- });
663
- exports.BridgeRpcNotificationSchema = zod_1.z.object({
664
- jsonrpc: zod_1.z.literal('2.0'),
665
- method: zod_1.z.string(),
666
- params: zod_1.z.unknown().optional(),
667
- });
668
- exports.BridgeRpcErrorSchema = zod_1.z.object({
669
- code: zod_1.z.number(),
670
- message: zod_1.z.string(),
671
- data: zod_1.z.unknown().optional(),
672
- });
673
- exports.BridgeRpcResponseSchema = zod_1.z.union([
674
- zod_1.z.object({ jsonrpc: zod_1.z.literal('2.0'), id: exports.BridgeRpcIdSchema, result: zod_1.z.unknown() }),
675
- zod_1.z.object({ jsonrpc: zod_1.z.literal('2.0'), id: exports.BridgeRpcIdSchema.nullable(), error: exports.BridgeRpcErrorSchema }),
676
- ]);