@canonmsg/backend-contracts 1.8.1 → 1.9.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.
@@ -175,6 +175,111 @@ export interface BridgeLocalMethodContract {
175
175
  params: z.ZodType;
176
176
  result: z.ZodType;
177
177
  }
178
+ /** A single tool-trail item forwarded raw; the bridge folds it into `blocks`. */
179
+ export declare const BridgeStreamToolEventSchema: z.ZodObject<{
180
+ kind: z.ZodLiteral<"tool">;
181
+ id: z.ZodString;
182
+ status: z.ZodOptional<z.ZodEnum<{
183
+ completed: "completed";
184
+ running: "running";
185
+ failed: "failed";
186
+ }>>;
187
+ title: z.ZodOptional<z.ZodString>;
188
+ summary: z.ZodOptional<z.ZodString>;
189
+ detail: z.ZodOptional<z.ZodString>;
190
+ }, z.core.$strip>;
191
+ /**
192
+ * A visible-text segment. `mode:'append'` concatenates onto the segment's
193
+ * running text; `mode:'replace'` overwrites it (the adapter already holds the
194
+ * full segment). The bridge rebuilds the bubble text from its text segments in
195
+ * sequence order, exactly as the core turn-output-controller does today.
196
+ */
197
+ export declare const BridgeStreamTextEventSchema: z.ZodObject<{
198
+ kind: z.ZodLiteral<"text">;
199
+ id: z.ZodString;
200
+ mode: z.ZodEnum<{
201
+ replace: "replace";
202
+ append: "append";
203
+ }>;
204
+ text: z.ZodString;
205
+ }, z.core.$strip>;
206
+ /** A thinking tick (onset or keepalive) — no content; keeps the bubble warm. */
207
+ export declare const BridgeStreamThinkingEventSchema: z.ZodObject<{
208
+ kind: z.ZodLiteral<"thinking">;
209
+ }, z.core.$strip>;
210
+ /**
211
+ * Final compose: the assembled reply text is written one last time (status
212
+ * settles to `streaming`) and the node is LEFT in place for the final-message
213
+ * handoff. Clearing is a separate `clear` event / `clearStreaming`.
214
+ */
215
+ export declare const BridgeStreamFinalEventSchema: z.ZodObject<{
216
+ kind: z.ZodLiteral<"final">;
217
+ text: z.ZodString;
218
+ }, z.core.$strip>;
219
+ /** Clear the streaming node (turn ended / interrupted). */
220
+ export declare const BridgeStreamClearEventSchema: z.ZodObject<{
221
+ kind: z.ZodLiteral<"clear">;
222
+ }, z.core.$strip>;
223
+ export declare const BridgeStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
224
+ kind: z.ZodLiteral<"text">;
225
+ id: z.ZodString;
226
+ mode: z.ZodEnum<{
227
+ replace: "replace";
228
+ append: "append";
229
+ }>;
230
+ text: z.ZodString;
231
+ }, z.core.$strip>, z.ZodObject<{
232
+ kind: z.ZodLiteral<"tool">;
233
+ id: z.ZodString;
234
+ status: z.ZodOptional<z.ZodEnum<{
235
+ completed: "completed";
236
+ running: "running";
237
+ failed: "failed";
238
+ }>>;
239
+ title: z.ZodOptional<z.ZodString>;
240
+ summary: z.ZodOptional<z.ZodString>;
241
+ detail: z.ZodOptional<z.ZodString>;
242
+ }, z.core.$strip>, z.ZodObject<{
243
+ kind: z.ZodLiteral<"thinking">;
244
+ }, z.core.$strip>, z.ZodObject<{
245
+ kind: z.ZodLiteral<"final">;
246
+ text: z.ZodString;
247
+ }, z.core.$strip>, z.ZodObject<{
248
+ kind: z.ZodLiteral<"clear">;
249
+ }, z.core.$strip>], "kind">;
250
+ export type BridgeStreamEvent = z.infer<typeof BridgeStreamEventSchema>;
251
+ export declare const BridgePublishStreamingEventParamsSchema: z.ZodObject<{
252
+ conversationId: z.ZodString;
253
+ turnId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
254
+ messageId: z.ZodOptional<z.ZodString>;
255
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
256
+ kind: z.ZodLiteral<"text">;
257
+ id: z.ZodString;
258
+ mode: z.ZodEnum<{
259
+ replace: "replace";
260
+ append: "append";
261
+ }>;
262
+ text: z.ZodString;
263
+ }, z.core.$strip>, z.ZodObject<{
264
+ kind: z.ZodLiteral<"tool">;
265
+ id: z.ZodString;
266
+ status: z.ZodOptional<z.ZodEnum<{
267
+ completed: "completed";
268
+ running: "running";
269
+ failed: "failed";
270
+ }>>;
271
+ title: z.ZodOptional<z.ZodString>;
272
+ summary: z.ZodOptional<z.ZodString>;
273
+ detail: z.ZodOptional<z.ZodString>;
274
+ }, z.core.$strip>, z.ZodObject<{
275
+ kind: z.ZodLiteral<"thinking">;
276
+ }, z.core.$strip>, z.ZodObject<{
277
+ kind: z.ZodLiteral<"final">;
278
+ text: z.ZodString;
279
+ }, z.core.$strip>, z.ZodObject<{
280
+ kind: z.ZodLiteral<"clear">;
281
+ }, z.core.$strip>], "kind">;
282
+ }, z.core.$strip>;
178
283
  export declare const BRIDGE_LOCAL_METHODS: {
179
284
  readonly hello: {
180
285
  readonly params: z.ZodObject<{
@@ -867,6 +972,43 @@ export declare const BRIDGE_LOCAL_METHODS: {
867
972
  ok: z.ZodLiteral<true>;
868
973
  }, z.core.$strip>;
869
974
  };
975
+ readonly publishStreamingEvent: {
976
+ readonly params: z.ZodObject<{
977
+ conversationId: z.ZodString;
978
+ turnId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
979
+ messageId: z.ZodOptional<z.ZodString>;
980
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
981
+ kind: z.ZodLiteral<"text">;
982
+ id: z.ZodString;
983
+ mode: z.ZodEnum<{
984
+ replace: "replace";
985
+ append: "append";
986
+ }>;
987
+ text: z.ZodString;
988
+ }, z.core.$strip>, z.ZodObject<{
989
+ kind: z.ZodLiteral<"tool">;
990
+ id: z.ZodString;
991
+ status: z.ZodOptional<z.ZodEnum<{
992
+ completed: "completed";
993
+ running: "running";
994
+ failed: "failed";
995
+ }>>;
996
+ title: z.ZodOptional<z.ZodString>;
997
+ summary: z.ZodOptional<z.ZodString>;
998
+ detail: z.ZodOptional<z.ZodString>;
999
+ }, z.core.$strip>, z.ZodObject<{
1000
+ kind: z.ZodLiteral<"thinking">;
1001
+ }, z.core.$strip>, z.ZodObject<{
1002
+ kind: z.ZodLiteral<"final">;
1003
+ text: z.ZodString;
1004
+ }, z.core.$strip>, z.ZodObject<{
1005
+ kind: z.ZodLiteral<"clear">;
1006
+ }, z.core.$strip>], "kind">;
1007
+ }, z.core.$strip>;
1008
+ readonly result: z.ZodObject<{
1009
+ ok: z.ZodLiteral<true>;
1010
+ }, z.core.$strip>;
1011
+ };
870
1012
  readonly publishRuntimeDescriptor: {
871
1013
  readonly params: z.ZodObject<{
872
1014
  descriptor: z.ZodRecord<z.ZodString, z.ZodUnknown>;
@@ -153,6 +153,71 @@ const messageScoped = z.object({ conversationId: z.string(), messageId: z.string
153
153
  */
154
154
  const ServerTimestampSentinelSchema = z.object({ '.sv': z.literal('timestamp') });
155
155
  const EpochOrServerTimestampSchema = z.union([z.number(), ServerTimestampSentinelSchema]);
156
+ // ─────────────────────────────────────────────────────────────────────────
157
+ // W2-A4 REGION START — bridge-owned streaming assembly (raw event surface).
158
+ // ADDITIVE: `publishStreamingEvent` lets a channel adapter forward RAW turn
159
+ // events (a text segment begin/append/replace, a tool-trail item, a thinking
160
+ // tick, a final compose, or a clear). The BRIDGE owns snapshot assembly, the
161
+ // single write cadence, thinking keepalive, final compose, and node clear —
162
+ // so adapters stop reimplementing turn-output-controller + a keepalive loop
163
+ // (T1: they also stop swallowing the write failure). The pre-existing
164
+ // snapshot `publishStreaming` (below) is UNTOUCHED — coding hosts still call
165
+ // it via agent-host/runtime-writers.
166
+ // ─────────────────────────────────────────────────────────────────────────
167
+ /** A single tool-trail item forwarded raw; the bridge folds it into `blocks`. */
168
+ export const BridgeStreamToolEventSchema = z.object({
169
+ kind: z.literal('tool'),
170
+ /** Stable block id (adapter-scoped, e.g. `tool:{turnId}`). */
171
+ id: z.string(),
172
+ status: z.enum(['running', 'completed', 'failed']).optional(),
173
+ title: z.string().optional(),
174
+ summary: z.string().optional(),
175
+ detail: z.string().optional(),
176
+ });
177
+ /**
178
+ * A visible-text segment. `mode:'append'` concatenates onto the segment's
179
+ * running text; `mode:'replace'` overwrites it (the adapter already holds the
180
+ * full segment). The bridge rebuilds the bubble text from its text segments in
181
+ * sequence order, exactly as the core turn-output-controller does today.
182
+ */
183
+ export const BridgeStreamTextEventSchema = z.object({
184
+ kind: z.literal('text'),
185
+ /** Segment id (adapter-scoped, e.g. `text:{turnId}:{n}`). */
186
+ id: z.string(),
187
+ mode: z.enum(['append', 'replace']),
188
+ text: z.string(),
189
+ });
190
+ /** A thinking tick (onset or keepalive) — no content; keeps the bubble warm. */
191
+ export const BridgeStreamThinkingEventSchema = z.object({
192
+ kind: z.literal('thinking'),
193
+ });
194
+ /**
195
+ * Final compose: the assembled reply text is written one last time (status
196
+ * settles to `streaming`) and the node is LEFT in place for the final-message
197
+ * handoff. Clearing is a separate `clear` event / `clearStreaming`.
198
+ */
199
+ export const BridgeStreamFinalEventSchema = z.object({
200
+ kind: z.literal('final'),
201
+ text: z.string(),
202
+ });
203
+ /** Clear the streaming node (turn ended / interrupted). */
204
+ export const BridgeStreamClearEventSchema = z.object({
205
+ kind: z.literal('clear'),
206
+ });
207
+ export const BridgeStreamEventSchema = z.discriminatedUnion('kind', [
208
+ BridgeStreamTextEventSchema,
209
+ BridgeStreamToolEventSchema,
210
+ BridgeStreamThinkingEventSchema,
211
+ BridgeStreamFinalEventSchema,
212
+ BridgeStreamClearEventSchema,
213
+ ]);
214
+ export const BridgePublishStreamingEventParamsSchema = conversationScoped.extend({
215
+ /** New turnId resets the bridge's accumulation for this conversation. */
216
+ turnId: z.string().nullable().optional(),
217
+ messageId: z.string().optional(),
218
+ event: BridgeStreamEventSchema,
219
+ });
220
+ // W2-A4 REGION END — bridge-owned streaming assembly.
156
221
  export const BRIDGE_LOCAL_METHODS = {
157
222
  // §A lifecycle
158
223
  hello: { params: BridgeHelloParamsSchema, result: BridgeHelloResultSchema },
@@ -305,6 +370,12 @@ export const BRIDGE_LOCAL_METHODS = {
305
370
  result: OkResultSchema,
306
371
  },
307
372
  clearStreaming: { params: conversationScoped, result: OkResultSchema },
373
+ // W2-A4 additive: raw streaming events (bridge owns assembly/cadence/
374
+ // keepalive/final/clear). Coexists with the snapshot publishStreaming above.
375
+ publishStreamingEvent: {
376
+ params: BridgePublishStreamingEventParamsSchema,
377
+ result: OkResultSchema,
378
+ },
308
379
  // §B6 runtime presentation (adapter owns content, bridge publishes)
309
380
  publishRuntimeDescriptor: {
310
381
  params: z.object({
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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;
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.BridgePublishStreamingEventParamsSchema = exports.BridgeStreamEventSchema = exports.BridgeStreamClearEventSchema = exports.BridgeStreamFinalEventSchema = exports.BridgeStreamThinkingEventSchema = exports.BridgeStreamTextEventSchema = exports.BridgeStreamToolEventSchema = 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
4
  // Bridge ⇄ runtime-adapter LOCAL JSON-RPC contract v1 (types + schemas ONLY —
5
5
  // no runtime, no transport; Phase 4 builds the bridge against these).
6
6
  //
@@ -156,6 +156,71 @@ const messageScoped = zod_1.z.object({ conversationId: zod_1.z.string(), message
156
156
  */
157
157
  const ServerTimestampSentinelSchema = zod_1.z.object({ '.sv': zod_1.z.literal('timestamp') });
158
158
  const EpochOrServerTimestampSchema = zod_1.z.union([zod_1.z.number(), ServerTimestampSentinelSchema]);
159
+ // ─────────────────────────────────────────────────────────────────────────
160
+ // W2-A4 REGION START — bridge-owned streaming assembly (raw event surface).
161
+ // ADDITIVE: `publishStreamingEvent` lets a channel adapter forward RAW turn
162
+ // events (a text segment begin/append/replace, a tool-trail item, a thinking
163
+ // tick, a final compose, or a clear). The BRIDGE owns snapshot assembly, the
164
+ // single write cadence, thinking keepalive, final compose, and node clear —
165
+ // so adapters stop reimplementing turn-output-controller + a keepalive loop
166
+ // (T1: they also stop swallowing the write failure). The pre-existing
167
+ // snapshot `publishStreaming` (below) is UNTOUCHED — coding hosts still call
168
+ // it via agent-host/runtime-writers.
169
+ // ─────────────────────────────────────────────────────────────────────────
170
+ /** A single tool-trail item forwarded raw; the bridge folds it into `blocks`. */
171
+ exports.BridgeStreamToolEventSchema = zod_1.z.object({
172
+ kind: zod_1.z.literal('tool'),
173
+ /** Stable block id (adapter-scoped, e.g. `tool:{turnId}`). */
174
+ id: zod_1.z.string(),
175
+ status: zod_1.z.enum(['running', 'completed', 'failed']).optional(),
176
+ title: zod_1.z.string().optional(),
177
+ summary: zod_1.z.string().optional(),
178
+ detail: zod_1.z.string().optional(),
179
+ });
180
+ /**
181
+ * A visible-text segment. `mode:'append'` concatenates onto the segment's
182
+ * running text; `mode:'replace'` overwrites it (the adapter already holds the
183
+ * full segment). The bridge rebuilds the bubble text from its text segments in
184
+ * sequence order, exactly as the core turn-output-controller does today.
185
+ */
186
+ exports.BridgeStreamTextEventSchema = zod_1.z.object({
187
+ kind: zod_1.z.literal('text'),
188
+ /** Segment id (adapter-scoped, e.g. `text:{turnId}:{n}`). */
189
+ id: zod_1.z.string(),
190
+ mode: zod_1.z.enum(['append', 'replace']),
191
+ text: zod_1.z.string(),
192
+ });
193
+ /** A thinking tick (onset or keepalive) — no content; keeps the bubble warm. */
194
+ exports.BridgeStreamThinkingEventSchema = zod_1.z.object({
195
+ kind: zod_1.z.literal('thinking'),
196
+ });
197
+ /**
198
+ * Final compose: the assembled reply text is written one last time (status
199
+ * settles to `streaming`) and the node is LEFT in place for the final-message
200
+ * handoff. Clearing is a separate `clear` event / `clearStreaming`.
201
+ */
202
+ exports.BridgeStreamFinalEventSchema = zod_1.z.object({
203
+ kind: zod_1.z.literal('final'),
204
+ text: zod_1.z.string(),
205
+ });
206
+ /** Clear the streaming node (turn ended / interrupted). */
207
+ exports.BridgeStreamClearEventSchema = zod_1.z.object({
208
+ kind: zod_1.z.literal('clear'),
209
+ });
210
+ exports.BridgeStreamEventSchema = zod_1.z.discriminatedUnion('kind', [
211
+ exports.BridgeStreamTextEventSchema,
212
+ exports.BridgeStreamToolEventSchema,
213
+ exports.BridgeStreamThinkingEventSchema,
214
+ exports.BridgeStreamFinalEventSchema,
215
+ exports.BridgeStreamClearEventSchema,
216
+ ]);
217
+ exports.BridgePublishStreamingEventParamsSchema = conversationScoped.extend({
218
+ /** New turnId resets the bridge's accumulation for this conversation. */
219
+ turnId: zod_1.z.string().nullable().optional(),
220
+ messageId: zod_1.z.string().optional(),
221
+ event: exports.BridgeStreamEventSchema,
222
+ });
223
+ // W2-A4 REGION END — bridge-owned streaming assembly.
159
224
  exports.BRIDGE_LOCAL_METHODS = {
160
225
  // §A lifecycle
161
226
  hello: { params: exports.BridgeHelloParamsSchema, result: exports.BridgeHelloResultSchema },
@@ -308,6 +373,12 @@ exports.BRIDGE_LOCAL_METHODS = {
308
373
  result: OkResultSchema,
309
374
  },
310
375
  clearStreaming: { params: conversationScoped, result: OkResultSchema },
376
+ // W2-A4 additive: raw streaming events (bridge owns assembly/cadence/
377
+ // keepalive/final/clear). Coexists with the snapshot publishStreaming above.
378
+ publishStreamingEvent: {
379
+ params: exports.BridgePublishStreamingEventParamsSchema,
380
+ result: OkResultSchema,
381
+ },
311
382
  // §B6 runtime presentation (adapter owns content, bridge publishes)
312
383
  publishRuntimeDescriptor: {
313
384
  params: zod_1.z.object({
package/dist/cjs/hitl.js CHANGED
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HitlPendingSchema = exports.HitlResolutionSchema = exports.HitlRequestAcceptedSchema = exports.HitlCardOutcomeRecordSchema = exports.HitlCardReplyRecordSchema = exports.HitlCardRequestRecordSchema = exports.HitlInputOutcomeRecordSchema = exports.HitlInputReplyRecordSchema = exports.HitlInputRequestRecordSchema = exports.HitlInputAnswersSchema = exports.HitlInputQuestionSchema = exports.HitlInputKindSchema = exports.HitlApprovalOutcomeRecordSchema = exports.HitlApprovalReplyRecordSchema = exports.HitlApprovalRequestRecordSchema = exports.HitlSessionRuleSchema = exports.HitlApprovalDetailSchema = exports.HitlApprovalCategorySchema = exports.HitlApprovalRiskSchema = exports.HitlResolutionStatusSchema = exports.HitlRequestKindSchema = void 0;
4
+ // Wire contract v1 — HITL (human-in-the-loop) request / resolution records.
5
+ //
6
+ // HITL is durable state, not a held request (bridge-local-api.md): the pending
7
+ // request is a persisted record (message metadata + RTDB node with expiresAt),
8
+ // and the resolution arrives later. These schemas ground the three record
9
+ // families as core's hosts publish/consume them today:
10
+ // approval — approval_request / approval_reply / approval_outcome
11
+ // input — runtime_input_request / runtime_input_reply / runtime_input_outcome
12
+ // card — runtime_card_request / runtime_card_reply / runtime_card_outcome
13
+ // plus the unified bridge-level resolution record (§C6 onHitlResolved).
14
+ const zod_1 = require("zod");
15
+ const runtimeCardFields_js_1 = require("./runtimeCardFields.js");
16
+ exports.HitlRequestKindSchema = zod_1.z.enum(['approval', 'input', 'card']);
17
+ exports.HitlResolutionStatusSchema = zod_1.z.enum(['submitted', 'cancelled', 'timeout']);
18
+ // ── Approval records ───────────────────────────────────────────────────
19
+ exports.HitlApprovalRiskSchema = zod_1.z.enum(['low', 'normal', 'high', 'destructive']);
20
+ exports.HitlApprovalCategorySchema = zod_1.z.enum([
21
+ 'command',
22
+ 'file',
23
+ 'network',
24
+ 'browser',
25
+ 'mcp',
26
+ 'plugin',
27
+ 'canon',
28
+ 'tool',
29
+ ]);
30
+ exports.HitlApprovalDetailSchema = zod_1.z.object({
31
+ label: zod_1.z.string(),
32
+ value: zod_1.z.string(),
33
+ monospace: zod_1.z.boolean().optional(),
34
+ });
35
+ exports.HitlSessionRuleSchema = zod_1.z.object({
36
+ type: zod_1.z.enum(['approve-all', 'approve-tool', 'deny-tool']),
37
+ toolPattern: zod_1.z.string().optional(),
38
+ expiresAt: zod_1.z.string().nullable().optional(),
39
+ });
40
+ exports.HitlApprovalRequestRecordSchema = zod_1.z.looseObject({
41
+ type: zod_1.z.literal('approval_request'),
42
+ approvalId: zod_1.z.string(),
43
+ responseUserId: zod_1.z.string().optional(),
44
+ toolName: zod_1.z.string(),
45
+ /** Pre-computed, redacted summary — raw tool input is never stored. */
46
+ toolSummary: zod_1.z.string(),
47
+ category: exports.HitlApprovalCategorySchema.optional(),
48
+ risk: exports.HitlApprovalRiskSchema.optional(),
49
+ riskLevel: zod_1.z.enum(['normal', 'destructive']).optional(),
50
+ runtimeId: zod_1.z.string().optional(),
51
+ turnId: zod_1.z.string().optional(),
52
+ /** Native runtime correlation handles — opaque pass-through. */
53
+ native: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
54
+ details: zod_1.z.array(exports.HitlApprovalDetailSchema).optional(),
55
+ /** File-change preview (CanonUnifiedDiff) — opaque pass-through. */
56
+ diff: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
57
+ expiresAt: zod_1.z.string(),
58
+ });
59
+ exports.HitlApprovalReplyRecordSchema = zod_1.z.looseObject({
60
+ type: zod_1.z.literal('approval_reply'),
61
+ approvalId: zod_1.z.string(),
62
+ decision: zod_1.z.enum(['allow', 'deny']),
63
+ sessionRule: exports.HitlSessionRuleSchema.optional(),
64
+ });
65
+ exports.HitlApprovalOutcomeRecordSchema = zod_1.z.looseObject({
66
+ type: zod_1.z.literal('approval_outcome'),
67
+ approvalId: zod_1.z.string().optional(),
68
+ decision: zod_1.z.enum(['allow', 'deny']).optional(),
69
+ reason: zod_1.z.enum(['replied', 'timeout', 'session-rule']).optional(),
70
+ });
71
+ // ── Input records ──────────────────────────────────────────────────────
72
+ exports.HitlInputKindSchema = zod_1.z.enum(['clarify', 'sudo', 'secret']);
73
+ exports.HitlInputQuestionSchema = zod_1.z.object({
74
+ id: zod_1.z.string(),
75
+ question: zod_1.z.string(),
76
+ header: zod_1.z.string().optional(),
77
+ choices: zod_1.z.array(runtimeCardFields_js_1.RuntimeCardFieldChoiceSchema).optional(),
78
+ allowOther: zod_1.z.boolean().optional(),
79
+ isSecret: zod_1.z.boolean().optional(),
80
+ multiSelect: zod_1.z.boolean().optional(),
81
+ });
82
+ /** questionId → selected/typed answers. */
83
+ exports.HitlInputAnswersSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.object({ answers: zod_1.z.array(zod_1.z.string()) }));
84
+ exports.HitlInputRequestRecordSchema = zod_1.z.looseObject({
85
+ type: zod_1.z.literal('runtime_input_request'),
86
+ inputId: zod_1.z.string(),
87
+ responseUserId: zod_1.z.string().optional(),
88
+ kind: exports.HitlInputKindSchema,
89
+ prompt: zod_1.z.string(),
90
+ title: zod_1.z.string().optional(),
91
+ choices: zod_1.z.array(runtimeCardFields_js_1.RuntimeCardFieldChoiceSchema).optional(),
92
+ questions: zod_1.z.array(exports.HitlInputQuestionSchema).optional(),
93
+ secretName: zod_1.z.string().optional(),
94
+ native: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
95
+ expiresAt: zod_1.z.string(),
96
+ sensitive: zod_1.z.boolean().optional(),
97
+ });
98
+ exports.HitlInputReplyRecordSchema = zod_1.z.looseObject({
99
+ type: zod_1.z.literal('runtime_input_reply'),
100
+ inputId: zod_1.z.string(),
101
+ kind: exports.HitlInputKindSchema.optional(),
102
+ status: zod_1.z.enum(['submitted', 'cancelled']),
103
+ answerSummary: zod_1.z.string().optional(),
104
+ answersSummary: zod_1.z.string().optional(),
105
+ sensitive: zod_1.z.boolean().optional(),
106
+ });
107
+ exports.HitlInputOutcomeRecordSchema = zod_1.z.looseObject({
108
+ type: zod_1.z.literal('runtime_input_outcome'),
109
+ inputId: zod_1.z.string(),
110
+ kind: exports.HitlInputKindSchema.optional(),
111
+ status: exports.HitlResolutionStatusSchema,
112
+ reason: zod_1.z.enum(['submitted', 'cancelled', 'timeout', 'expired', 'interrupted']).optional(),
113
+ });
114
+ // ── Card records ───────────────────────────────────────────────────────
115
+ exports.HitlCardRequestRecordSchema = zod_1.z.looseObject({
116
+ type: zod_1.z.literal('runtime_card_request'),
117
+ cardId: zod_1.z.string(),
118
+ cardKind: zod_1.z.string(),
119
+ schemaVersion: zod_1.z.literal('canon.card.v1'),
120
+ fallbackText: zod_1.z.string(),
121
+ responseUserId: zod_1.z.string().optional(),
122
+ expiresAt: zod_1.z.string(),
123
+ runtimeId: zod_1.z.string().optional(),
124
+ turnId: zod_1.z.string().optional(),
125
+ native: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
126
+ /** True when the card carries an actions block (agent waits for a response). */
127
+ interactive: zod_1.z.boolean().optional(),
128
+ /** RuntimeCardPreview — opaque pass-through. */
129
+ cardPreview: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
130
+ turnSemantics: zod_1.z.literal('control'),
131
+ replyBehavior: zod_1.z.literal('suppress_auto_reply'),
132
+ });
133
+ exports.HitlCardReplyRecordSchema = zod_1.z.looseObject({
134
+ type: zod_1.z.literal('runtime_card_reply'),
135
+ cardId: zod_1.z.string(),
136
+ status: zod_1.z.enum(['submitted', 'cancelled']),
137
+ actionId: zod_1.z.string().optional(),
138
+ answerSummary: zod_1.z.string().optional(),
139
+ sensitive: zod_1.z.boolean().optional(),
140
+ turnSemantics: zod_1.z.literal('control'),
141
+ replyBehavior: zod_1.z.literal('suppress_auto_reply'),
142
+ });
143
+ exports.HitlCardOutcomeRecordSchema = zod_1.z.looseObject({
144
+ type: zod_1.z.literal('runtime_card_outcome'),
145
+ cardId: zod_1.z.string(),
146
+ status: exports.HitlResolutionStatusSchema,
147
+ reason: zod_1.z.enum(['submitted', 'cancelled', 'timeout', 'expired', 'interrupted']).optional(),
148
+ turnSemantics: zod_1.z.literal('control'),
149
+ replyBehavior: zod_1.z.literal('suppress_auto_reply'),
150
+ });
151
+ // ── Unified bridge-level records (bridge-local-api §B7/§C6) ────────────
152
+ /** Immediate result of requestApproval/requestInput/requestCard. */
153
+ exports.HitlRequestAcceptedSchema = zod_1.z.object({
154
+ requestId: zod_1.z.string(),
155
+ expiresAt: zod_1.z.string(),
156
+ });
157
+ /** `onHitlResolved` — matches an earlier requestId. */
158
+ exports.HitlResolutionSchema = zod_1.z.object({
159
+ requestId: zod_1.z.string(),
160
+ kind: exports.HitlRequestKindSchema.optional(),
161
+ status: exports.HitlResolutionStatusSchema,
162
+ /** Kind-specific answer payload (decision / answers / card action values). */
163
+ answer: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
164
+ });
165
+ /** `onHitlPending` — replayed on reconnect for still-open requests. */
166
+ exports.HitlPendingSchema = zod_1.z.object({
167
+ requestId: zod_1.z.string(),
168
+ kind: exports.HitlRequestKindSchema,
169
+ conversationId: zod_1.z.string(),
170
+ expiresAt: zod_1.z.string(),
171
+ });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SseEventEnvelopeSchema = exports.SSE_EVENT_FAMILY_BY_TYPE = exports.SseEventFamilySchema = exports.SSE_EVENT_FAMILIES = exports.SSE_EVENT_PAYLOAD_SCHEMAS = exports.SseEventTypeSchema = exports.SSE_EVENT_TYPES = exports.SseVoiceSessionEventPayloadSchema = exports.SseVoiceSessionSchema = exports.SseRuntimeControlPayloadSchema = exports.SseRuntimeControlKindSchema = exports.SseTurnUpdatedPayloadSchema = exports.SseRuntimeUpdatedPayloadSchema = exports.SsePresencePayloadSchema = exports.SseTypingPayloadSchema = exports.SseContactRemovedPayloadSchema = exports.SseContactPayloadSchema = exports.SseContactRequestPayloadSchema = exports.SseConversationUpdatedPayloadSchema = exports.SseMembershipChangeSchema = exports.SseMessageDeletedPayloadSchema = exports.SseMessageUpdatedPayloadSchema = exports.SseMessageCreatedPayloadSchema = exports.SseProvenanceSchema = exports.SseTurnDispatchSchema = exports.SseSelfContextSchema = exports.SseErrorPayloadSchema = exports.SseReplayExpiredPayloadSchema = exports.SseHeartbeatPayloadSchema = exports.SseAgentContextPayloadSchema = exports.SseConnectedPayloadSchema = exports.SseAccessPolicySchema = void 0;
3
+ exports.SseEventEnvelopeSchema = exports.SSE_EVENT_FAMILY_BY_TYPE = exports.SseEventFamilySchema = exports.SSE_EVENT_FAMILIES = exports.SSE_EVENT_PAYLOAD_SCHEMAS = exports.SseEventTypeSchema = exports.SSE_EVENT_TYPES = exports.SseVoiceSessionEventPayloadSchema = exports.SseVoiceSessionSchema = exports.SseRuntimeControlPayloadSchema = exports.SseRuntimeControlKindSchema = exports.SsePresencePayloadSchema = exports.SseTypingPayloadSchema = exports.SseContactRemovedPayloadSchema = exports.SseContactPayloadSchema = exports.SseContactRequestPayloadSchema = exports.SseConversationUpdatedPayloadSchema = exports.SseMembershipChangeSchema = exports.SseMessageDeletedPayloadSchema = exports.SseMessageUpdatedPayloadSchema = exports.SseMessageCreatedPayloadSchema = exports.SseProvenanceSchema = exports.SseTurnDispatchSchema = exports.SseSelfContextSchema = exports.SseErrorPayloadSchema = exports.SseReplayExpiredPayloadSchema = exports.SseHeartbeatPayloadSchema = exports.SseAgentContextPayloadSchema = exports.SseConnectedPayloadSchema = exports.SseAccessPolicySchema = void 0;
4
4
  // Wire contract v1 — SSE event envelope + per-family payload schemas.
5
5
  //
6
6
  // Grounded in what stream-service ACTUALLY emits (stream-service/src/stream.ts
@@ -142,20 +142,9 @@ exports.SsePresencePayloadSchema = zod_1.z.object({
142
142
  lastSeen: zod_1.z.string().optional(),
143
143
  });
144
144
  // ── Runtime / turn family ──────────────────────────────────────────────
145
- /** Aggregated RTDB runtime snapshot — nodes are passed through opaquely. */
146
- exports.SseRuntimeUpdatedPayloadSchema = zod_1.z.object({
147
- conversationId: zod_1.z.string(),
148
- agentId: zod_1.z.string(),
149
- runtime: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable(),
150
- runtimeInfo: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable(),
151
- sessionState: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable(),
152
- sessionConfig: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable(),
153
- });
154
- exports.SseTurnUpdatedPayloadSchema = zod_1.z.object({
155
- conversationId: zod_1.z.string(),
156
- agentId: zod_1.z.string(),
157
- turn: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable(),
158
- });
145
+ // `runtime.updated` / `turn.updated` were retired 2026-07 (zero consumers;
146
+ // the bridge reads RTDB directly). `runtime.control` remains — it is the
147
+ // planned event-push control transport (housecleaning plan §6 W2-A2).
159
148
  exports.SseRuntimeControlKindSchema = zod_1.z.enum([
160
149
  'session',
161
150
  'signal',
@@ -219,8 +208,6 @@ exports.SSE_EVENT_TYPES = [
219
208
  'contact.removed',
220
209
  'typing',
221
210
  'presence',
222
- 'runtime.updated',
223
- 'turn.updated',
224
211
  'runtime.control',
225
212
  'voice.session.started',
226
213
  'voice.session.ended',
@@ -244,8 +231,6 @@ exports.SSE_EVENT_PAYLOAD_SCHEMAS = {
244
231
  'contact.removed': exports.SseContactRemovedPayloadSchema,
245
232
  'typing': exports.SseTypingPayloadSchema,
246
233
  'presence': exports.SsePresencePayloadSchema,
247
- 'runtime.updated': exports.SseRuntimeUpdatedPayloadSchema,
248
- 'turn.updated': exports.SseTurnUpdatedPayloadSchema,
249
234
  'runtime.control': exports.SseRuntimeControlPayloadSchema,
250
235
  'voice.session.started': exports.SseVoiceSessionEventPayloadSchema,
251
236
  'voice.session.ended': exports.SseVoiceSessionEventPayloadSchema,
@@ -279,8 +264,6 @@ exports.SSE_EVENT_FAMILY_BY_TYPE = {
279
264
  'contact.removed': 'contacts',
280
265
  'typing': 'typing_presence',
281
266
  'presence': 'typing_presence',
282
- 'runtime.updated': 'runtime_turn',
283
- 'turn.updated': 'runtime_turn',
284
267
  'runtime.control': 'runtime_turn',
285
268
  'voice.session.started': 'voice',
286
269
  'voice.session.ended': 'voice',
@@ -0,0 +1,138 @@
1
+ {
2
+ "$id": "canon:BridgePublishStreamingEventParamsSchema",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "conversationId": {
7
+ "type": "string"
8
+ },
9
+ "turnId": {
10
+ "anyOf": [
11
+ {
12
+ "type": "string"
13
+ },
14
+ {
15
+ "type": "null"
16
+ }
17
+ ]
18
+ },
19
+ "messageId": {
20
+ "type": "string"
21
+ },
22
+ "event": {
23
+ "oneOf": [
24
+ {
25
+ "type": "object",
26
+ "properties": {
27
+ "kind": {
28
+ "type": "string",
29
+ "const": "text"
30
+ },
31
+ "id": {
32
+ "type": "string"
33
+ },
34
+ "mode": {
35
+ "type": "string",
36
+ "enum": [
37
+ "append",
38
+ "replace"
39
+ ]
40
+ },
41
+ "text": {
42
+ "type": "string"
43
+ }
44
+ },
45
+ "required": [
46
+ "kind",
47
+ "id",
48
+ "mode",
49
+ "text"
50
+ ],
51
+ "additionalProperties": false
52
+ },
53
+ {
54
+ "type": "object",
55
+ "properties": {
56
+ "kind": {
57
+ "type": "string",
58
+ "const": "tool"
59
+ },
60
+ "id": {
61
+ "type": "string"
62
+ },
63
+ "status": {
64
+ "type": "string",
65
+ "enum": [
66
+ "running",
67
+ "completed",
68
+ "failed"
69
+ ]
70
+ },
71
+ "title": {
72
+ "type": "string"
73
+ },
74
+ "summary": {
75
+ "type": "string"
76
+ },
77
+ "detail": {
78
+ "type": "string"
79
+ }
80
+ },
81
+ "required": [
82
+ "kind",
83
+ "id"
84
+ ],
85
+ "additionalProperties": false
86
+ },
87
+ {
88
+ "type": "object",
89
+ "properties": {
90
+ "kind": {
91
+ "type": "string",
92
+ "const": "thinking"
93
+ }
94
+ },
95
+ "required": [
96
+ "kind"
97
+ ],
98
+ "additionalProperties": false
99
+ },
100
+ {
101
+ "type": "object",
102
+ "properties": {
103
+ "kind": {
104
+ "type": "string",
105
+ "const": "final"
106
+ },
107
+ "text": {
108
+ "type": "string"
109
+ }
110
+ },
111
+ "required": [
112
+ "kind",
113
+ "text"
114
+ ],
115
+ "additionalProperties": false
116
+ },
117
+ {
118
+ "type": "object",
119
+ "properties": {
120
+ "kind": {
121
+ "type": "string",
122
+ "const": "clear"
123
+ }
124
+ },
125
+ "required": [
126
+ "kind"
127
+ ],
128
+ "additionalProperties": false
129
+ }
130
+ ]
131
+ }
132
+ },
133
+ "required": [
134
+ "conversationId",
135
+ "event"
136
+ ],
137
+ "additionalProperties": false
138
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$id": "canon:BridgeStreamClearEventSchema",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "kind": {
7
+ "type": "string",
8
+ "const": "clear"
9
+ }
10
+ },
11
+ "required": [
12
+ "kind"
13
+ ],
14
+ "additionalProperties": false
15
+ }
@@ -0,0 +1,112 @@
1
+ {
2
+ "$id": "canon:BridgeStreamEventSchema",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "oneOf": [
5
+ {
6
+ "type": "object",
7
+ "properties": {
8
+ "kind": {
9
+ "type": "string",
10
+ "const": "text"
11
+ },
12
+ "id": {
13
+ "type": "string"
14
+ },
15
+ "mode": {
16
+ "type": "string",
17
+ "enum": [
18
+ "append",
19
+ "replace"
20
+ ]
21
+ },
22
+ "text": {
23
+ "type": "string"
24
+ }
25
+ },
26
+ "required": [
27
+ "kind",
28
+ "id",
29
+ "mode",
30
+ "text"
31
+ ],
32
+ "additionalProperties": false
33
+ },
34
+ {
35
+ "type": "object",
36
+ "properties": {
37
+ "kind": {
38
+ "type": "string",
39
+ "const": "tool"
40
+ },
41
+ "id": {
42
+ "type": "string"
43
+ },
44
+ "status": {
45
+ "type": "string",
46
+ "enum": [
47
+ "running",
48
+ "completed",
49
+ "failed"
50
+ ]
51
+ },
52
+ "title": {
53
+ "type": "string"
54
+ },
55
+ "summary": {
56
+ "type": "string"
57
+ },
58
+ "detail": {
59
+ "type": "string"
60
+ }
61
+ },
62
+ "required": [
63
+ "kind",
64
+ "id"
65
+ ],
66
+ "additionalProperties": false
67
+ },
68
+ {
69
+ "type": "object",
70
+ "properties": {
71
+ "kind": {
72
+ "type": "string",
73
+ "const": "thinking"
74
+ }
75
+ },
76
+ "required": [
77
+ "kind"
78
+ ],
79
+ "additionalProperties": false
80
+ },
81
+ {
82
+ "type": "object",
83
+ "properties": {
84
+ "kind": {
85
+ "type": "string",
86
+ "const": "final"
87
+ },
88
+ "text": {
89
+ "type": "string"
90
+ }
91
+ },
92
+ "required": [
93
+ "kind",
94
+ "text"
95
+ ],
96
+ "additionalProperties": false
97
+ },
98
+ {
99
+ "type": "object",
100
+ "properties": {
101
+ "kind": {
102
+ "type": "string",
103
+ "const": "clear"
104
+ }
105
+ },
106
+ "required": [
107
+ "kind"
108
+ ],
109
+ "additionalProperties": false
110
+ }
111
+ ]
112
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$id": "canon:BridgeStreamFinalEventSchema",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "kind": {
7
+ "type": "string",
8
+ "const": "final"
9
+ },
10
+ "text": {
11
+ "type": "string"
12
+ }
13
+ },
14
+ "required": [
15
+ "kind",
16
+ "text"
17
+ ],
18
+ "additionalProperties": false
19
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$id": "canon:BridgeStreamTextEventSchema",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "kind": {
7
+ "type": "string",
8
+ "const": "text"
9
+ },
10
+ "id": {
11
+ "type": "string"
12
+ },
13
+ "mode": {
14
+ "type": "string",
15
+ "enum": [
16
+ "append",
17
+ "replace"
18
+ ]
19
+ },
20
+ "text": {
21
+ "type": "string"
22
+ }
23
+ },
24
+ "required": [
25
+ "kind",
26
+ "id",
27
+ "mode",
28
+ "text"
29
+ ],
30
+ "additionalProperties": false
31
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$id": "canon:BridgeStreamThinkingEventSchema",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "kind": {
7
+ "type": "string",
8
+ "const": "thinking"
9
+ }
10
+ },
11
+ "required": [
12
+ "kind"
13
+ ],
14
+ "additionalProperties": false
15
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "$id": "canon:BridgeStreamToolEventSchema",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "kind": {
7
+ "type": "string",
8
+ "const": "tool"
9
+ },
10
+ "id": {
11
+ "type": "string"
12
+ },
13
+ "status": {
14
+ "type": "string",
15
+ "enum": [
16
+ "running",
17
+ "completed",
18
+ "failed"
19
+ ]
20
+ },
21
+ "title": {
22
+ "type": "string"
23
+ },
24
+ "summary": {
25
+ "type": "string"
26
+ },
27
+ "detail": {
28
+ "type": "string"
29
+ }
30
+ },
31
+ "required": [
32
+ "kind",
33
+ "id"
34
+ ],
35
+ "additionalProperties": false
36
+ }
@@ -23,8 +23,6 @@
23
23
  "contact.removed",
24
24
  "typing",
25
25
  "presence",
26
- "runtime.updated",
27
- "turn.updated",
28
26
  "runtime.control",
29
27
  "voice.session.started",
30
28
  "voice.session.ended",
@@ -17,8 +17,6 @@
17
17
  "contact.removed",
18
18
  "typing",
19
19
  "presence",
20
- "runtime.updated",
21
- "turn.updated",
22
20
  "runtime.control",
23
21
  "voice.session.started",
24
22
  "voice.session.ended",
@@ -304,22 +304,6 @@ export declare const SsePresencePayloadSchema: z.ZodObject<{
304
304
  lastSeen: z.ZodOptional<z.ZodString>;
305
305
  }, z.core.$strip>;
306
306
  export type SsePresencePayload = z.infer<typeof SsePresencePayloadSchema>;
307
- /** Aggregated RTDB runtime snapshot — nodes are passed through opaquely. */
308
- export declare const SseRuntimeUpdatedPayloadSchema: z.ZodObject<{
309
- conversationId: z.ZodString;
310
- agentId: z.ZodString;
311
- runtime: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
312
- runtimeInfo: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
313
- sessionState: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
314
- sessionConfig: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
315
- }, z.core.$strip>;
316
- export type SseRuntimeUpdatedPayload = z.infer<typeof SseRuntimeUpdatedPayloadSchema>;
317
- export declare const SseTurnUpdatedPayloadSchema: z.ZodObject<{
318
- conversationId: z.ZodString;
319
- agentId: z.ZodString;
320
- turn: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
321
- }, z.core.$strip>;
322
- export type SseTurnUpdatedPayload = z.infer<typeof SseTurnUpdatedPayloadSchema>;
323
307
  export declare const SseRuntimeControlKindSchema: z.ZodEnum<{
324
308
  session: "session";
325
309
  signal: "signal";
@@ -419,7 +403,7 @@ export type SseVoiceSessionEventPayload = z.infer<typeof SseVoiceSessionEventPay
419
403
  * mirrored by CanonStream's dispatch switch in core). NOTE: `contact.updated`
420
404
  * is emitted by stream-service but not yet consumed by CanonStream.
421
405
  */
422
- export declare const SSE_EVENT_TYPES: readonly ["connected", "agent.context", "heartbeat", "message.created", "message.updated", "message.deleted", "conversation.updated", "contact.request", "contact.approved", "contact.added", "contact.updated", "contact.removed", "typing", "presence", "runtime.updated", "turn.updated", "runtime.control", "voice.session.started", "voice.session.ended", "replay.expired", "error"];
406
+ export declare const SSE_EVENT_TYPES: readonly ["connected", "agent.context", "heartbeat", "message.created", "message.updated", "message.deleted", "conversation.updated", "contact.request", "contact.approved", "contact.added", "contact.updated", "contact.removed", "typing", "presence", "runtime.control", "voice.session.started", "voice.session.ended", "replay.expired", "error"];
423
407
  export declare const SseEventTypeSchema: z.ZodEnum<{
424
408
  typing: "typing";
425
409
  error: "error";
@@ -436,8 +420,6 @@ export declare const SseEventTypeSchema: z.ZodEnum<{
436
420
  "contact.updated": "contact.updated";
437
421
  "contact.removed": "contact.removed";
438
422
  presence: "presence";
439
- "runtime.updated": "runtime.updated";
440
- "turn.updated": "turn.updated";
441
423
  "runtime.control": "runtime.control";
442
424
  "voice.session.started": "voice.session.started";
443
425
  "voice.session.ended": "voice.session.ended";
@@ -482,8 +464,6 @@ export declare const SseEventEnvelopeSchema: z.ZodObject<{
482
464
  "contact.updated": "contact.updated";
483
465
  "contact.removed": "contact.removed";
484
466
  presence: "presence";
485
- "runtime.updated": "runtime.updated";
486
- "turn.updated": "turn.updated";
487
467
  "runtime.control": "runtime.control";
488
468
  "voice.session.started": "voice.session.started";
489
469
  "voice.session.ended": "voice.session.ended";
package/dist/sseEvents.js CHANGED
@@ -139,20 +139,9 @@ export const SsePresencePayloadSchema = z.object({
139
139
  lastSeen: z.string().optional(),
140
140
  });
141
141
  // ── Runtime / turn family ──────────────────────────────────────────────
142
- /** Aggregated RTDB runtime snapshot — nodes are passed through opaquely. */
143
- export const SseRuntimeUpdatedPayloadSchema = z.object({
144
- conversationId: z.string(),
145
- agentId: z.string(),
146
- runtime: z.record(z.string(), z.unknown()).nullable(),
147
- runtimeInfo: z.record(z.string(), z.unknown()).nullable(),
148
- sessionState: z.record(z.string(), z.unknown()).nullable(),
149
- sessionConfig: z.record(z.string(), z.unknown()).nullable(),
150
- });
151
- export const SseTurnUpdatedPayloadSchema = z.object({
152
- conversationId: z.string(),
153
- agentId: z.string(),
154
- turn: z.record(z.string(), z.unknown()).nullable(),
155
- });
142
+ // `runtime.updated` / `turn.updated` were retired 2026-07 (zero consumers;
143
+ // the bridge reads RTDB directly). `runtime.control` remains — it is the
144
+ // planned event-push control transport (housecleaning plan §6 W2-A2).
156
145
  export const SseRuntimeControlKindSchema = z.enum([
157
146
  'session',
158
147
  'signal',
@@ -216,8 +205,6 @@ export const SSE_EVENT_TYPES = [
216
205
  'contact.removed',
217
206
  'typing',
218
207
  'presence',
219
- 'runtime.updated',
220
- 'turn.updated',
221
208
  'runtime.control',
222
209
  'voice.session.started',
223
210
  'voice.session.ended',
@@ -241,8 +228,6 @@ export const SSE_EVENT_PAYLOAD_SCHEMAS = {
241
228
  'contact.removed': SseContactRemovedPayloadSchema,
242
229
  'typing': SseTypingPayloadSchema,
243
230
  'presence': SsePresencePayloadSchema,
244
- 'runtime.updated': SseRuntimeUpdatedPayloadSchema,
245
- 'turn.updated': SseTurnUpdatedPayloadSchema,
246
231
  'runtime.control': SseRuntimeControlPayloadSchema,
247
232
  'voice.session.started': SseVoiceSessionEventPayloadSchema,
248
233
  'voice.session.ended': SseVoiceSessionEventPayloadSchema,
@@ -276,8 +261,6 @@ export const SSE_EVENT_FAMILY_BY_TYPE = {
276
261
  'contact.removed': 'contacts',
277
262
  'typing': 'typing_presence',
278
263
  'presence': 'typing_presence',
279
- 'runtime.updated': 'runtime_turn',
280
- 'turn.updated': 'runtime_turn',
281
264
  'runtime.control': 'runtime_turn',
282
265
  'voice.session.started': 'voice',
283
266
  'voice.session.ended': 'voice',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonmsg/backend-contracts",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "description": "Canon backend contract helpers shared by Functions and stream-service",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
@@ -1,78 +0,0 @@
1
- {
2
- "$id": "canon:SseRuntimeUpdatedPayloadSchema",
3
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4
- "type": "object",
5
- "properties": {
6
- "conversationId": {
7
- "type": "string"
8
- },
9
- "agentId": {
10
- "type": "string"
11
- },
12
- "runtime": {
13
- "anyOf": [
14
- {
15
- "type": "object",
16
- "propertyNames": {
17
- "type": "string"
18
- },
19
- "additionalProperties": {}
20
- },
21
- {
22
- "type": "null"
23
- }
24
- ]
25
- },
26
- "runtimeInfo": {
27
- "anyOf": [
28
- {
29
- "type": "object",
30
- "propertyNames": {
31
- "type": "string"
32
- },
33
- "additionalProperties": {}
34
- },
35
- {
36
- "type": "null"
37
- }
38
- ]
39
- },
40
- "sessionState": {
41
- "anyOf": [
42
- {
43
- "type": "object",
44
- "propertyNames": {
45
- "type": "string"
46
- },
47
- "additionalProperties": {}
48
- },
49
- {
50
- "type": "null"
51
- }
52
- ]
53
- },
54
- "sessionConfig": {
55
- "anyOf": [
56
- {
57
- "type": "object",
58
- "propertyNames": {
59
- "type": "string"
60
- },
61
- "additionalProperties": {}
62
- },
63
- {
64
- "type": "null"
65
- }
66
- ]
67
- }
68
- },
69
- "required": [
70
- "conversationId",
71
- "agentId",
72
- "runtime",
73
- "runtimeInfo",
74
- "sessionState",
75
- "sessionConfig"
76
- ],
77
- "additionalProperties": false
78
- }
@@ -1,33 +0,0 @@
1
- {
2
- "$id": "canon:SseTurnUpdatedPayloadSchema",
3
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4
- "type": "object",
5
- "properties": {
6
- "conversationId": {
7
- "type": "string"
8
- },
9
- "agentId": {
10
- "type": "string"
11
- },
12
- "turn": {
13
- "anyOf": [
14
- {
15
- "type": "object",
16
- "propertyNames": {
17
- "type": "string"
18
- },
19
- "additionalProperties": {}
20
- },
21
- {
22
- "type": "null"
23
- }
24
- ]
25
- }
26
- },
27
- "required": [
28
- "conversationId",
29
- "agentId",
30
- "turn"
31
- ],
32
- "additionalProperties": false
33
- }