@canonmsg/backend-contracts 1.9.0 → 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.
- package/dist/agentBehaviorPolicy.d.ts +45 -86
- package/dist/agentBehaviorPolicy.js +0 -53
- package/dist/cjs/agentBehaviorPolicy.js +1 -54
- package/dist/cjs/contactRequest.js +0 -30
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/media.js +0 -13
- package/dist/cjs/message.js +0 -64
- package/dist/cjs/runtimeCardFields.js +1 -58
- package/dist/cjs/turnProtocol.js +1 -41
- package/dist/contactRequest.d.ts +23 -42
- package/dist/contactRequest.js +0 -29
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/media.d.ts +11 -24
- package/dist/media.js +0 -12
- package/dist/message.d.ts +50 -133
- package/dist/message.js +1 -64
- package/dist/runtimeCardFields.d.ts +39 -112
- package/dist/runtimeCardFields.js +0 -57
- package/dist/turnProtocol.d.ts +24 -91
- package/dist/turnProtocol.js +0 -40
- package/package.json +5 -8
- package/dist/bridgeLocal.d.ts +0 -1871
- package/dist/bridgeLocal.js +0 -744
- package/dist/cjs/bridgeLocal.js +0 -747
- package/dist/cjs/controlSignals.js +0 -44
- package/dist/cjs/endpointRegistry.js +0 -264
- package/dist/cjs/hitl.js +0 -171
- package/dist/cjs/inboundFrame.js +0 -92
- package/dist/cjs/restEndpoints.js +0 -237
- package/dist/cjs/sendContextual.js +0 -92
- package/dist/cjs/sseEvents.js +0 -281
- package/dist/controlSignals.d.ts +0 -55
- package/dist/controlSignals.js +0 -41
- package/dist/endpointRegistry.d.ts +0 -13
- package/dist/endpointRegistry.js +0 -261
- package/dist/hitl.d.ts +0 -303
- package/dist/hitl.js +0 -168
- package/dist/inboundFrame.d.ts +0 -229
- package/dist/inboundFrame.js +0 -89
- package/dist/restEndpoints.d.ts +0 -531
- package/dist/restEndpoints.js +0 -234
- package/dist/schemas/agent-behavior-settings-record.schema.json +0 -48
- package/dist/schemas/bridge-connection-state-notification.schema.json +0 -19
- package/dist/schemas/bridge-get-attachment-params.schema.json +0 -24
- package/dist/schemas/bridge-get-attachment-result.schema.json +0 -20
- package/dist/schemas/bridge-hello-params.schema.json +0 -42
- package/dist/schemas/bridge-hello-result.schema.json +0 -105
- package/dist/schemas/bridge-hitl-state.schema.json +0 -38
- package/dist/schemas/bridge-ok-result.schema.json +0 -15
- package/dist/schemas/bridge-publish-streaming-event-params.schema.json +0 -138
- package/dist/schemas/bridge-ready-notification.schema.json +0 -79
- package/dist/schemas/bridge-resync-reason.schema.json +0 -9
- package/dist/schemas/bridge-resync.schema.json +0 -18
- package/dist/schemas/bridge-rpc-error.schema.json +0 -19
- package/dist/schemas/bridge-rpc-id.schema.json +0 -12
- package/dist/schemas/bridge-rpc-notification.schema.json +0 -20
- package/dist/schemas/bridge-rpc-request.schema.json +0 -31
- package/dist/schemas/bridge-rpc-response.schema.json +0 -81
- package/dist/schemas/bridge-status-result.schema.json +0 -76
- package/dist/schemas/bridge-stream-clear-event.schema.json +0 -15
- package/dist/schemas/bridge-stream-event.schema.json +0 -112
- package/dist/schemas/bridge-stream-final-event.schema.json +0 -19
- package/dist/schemas/bridge-stream-text-event.schema.json +0 -31
- package/dist/schemas/bridge-stream-thinking-event.schema.json +0 -15
- package/dist/schemas/bridge-stream-tool-event.schema.json +0 -36
- package/dist/schemas/bridge-upload-media-params.schema.json +0 -28
- package/dist/schemas/bridge-upstream-state.schema.json +0 -10
- package/dist/schemas/contacts-response.schema.json +0 -52
- package/dist/schemas/control-channel-key.schema.json +0 -10
- package/dist/schemas/control-primitive-event.schema.json +0 -30
- package/dist/schemas/control-primitive-map.schema.json +0 -15
- package/dist/schemas/control-session-event.schema.json +0 -26
- package/dist/schemas/control-session-node.schema.json +0 -11
- package/dist/schemas/control-signal-event.schema.json +0 -35
- package/dist/schemas/control-signal-node.schema.json +0 -22
- package/dist/schemas/control-signal-type.schema.json +0 -10
- package/dist/schemas/conversations-response.schema.json +0 -167
- package/dist/schemas/create-contact-request-request.schema.json +0 -17
- package/dist/schemas/create-contact-request-response.schema.json +0 -51
- package/dist/schemas/create-conversation-request.schema.json +0 -82
- package/dist/schemas/create-conversation-response.schema.json +0 -29
- package/dist/schemas/delete-message-response.schema.json +0 -11
- package/dist/schemas/delivery-intent.schema.json +0 -11
- package/dist/schemas/forward-message-request.schema.json +0 -25
- package/dist/schemas/forward-message-response.schema.json +0 -35
- package/dist/schemas/forwarded-from.schema.json +0 -18
- package/dist/schemas/get-messages-query.schema.json +0 -17
- package/dist/schemas/hitl-approval-category.schema.json +0 -15
- package/dist/schemas/hitl-approval-detail.schema.json +0 -21
- package/dist/schemas/hitl-approval-outcome-record.schema.json +0 -33
- package/dist/schemas/hitl-approval-reply-record.schema.json +0 -57
- package/dist/schemas/hitl-approval-request-record.schema.json +0 -105
- package/dist/schemas/hitl-approval-risk.schema.json +0 -11
- package/dist/schemas/hitl-card-outcome-record.schema.json +0 -48
- package/dist/schemas/hitl-card-reply-record.schema.json +0 -46
- package/dist/schemas/hitl-card-request-record.schema.json +0 -73
- package/dist/schemas/hitl-input-answers.schema.json +0 -23
- package/dist/schemas/hitl-input-kind.schema.json +0 -10
- package/dist/schemas/hitl-input-outcome-record.schema.json +0 -46
- package/dist/schemas/hitl-input-question.schema.json +0 -54
- package/dist/schemas/hitl-input-reply-record.schema.json +0 -44
- package/dist/schemas/hitl-input-request-record.schema.json +0 -134
- package/dist/schemas/hitl-pending.schema.json +0 -31
- package/dist/schemas/hitl-request-accepted.schema.json +0 -18
- package/dist/schemas/hitl-request-kind.schema.json +0 -10
- package/dist/schemas/hitl-resolution-status.schema.json +0 -10
- package/dist/schemas/hitl-resolution.schema.json +0 -38
- package/dist/schemas/hitl-session-rule.schema.json +0 -32
- package/dist/schemas/inbound-disposition.schema.json +0 -13
- package/dist/schemas/inbound-frame-attachment-v1.schema.json +0 -94
- package/dist/schemas/inbound-frame-contact-card-v1.schema.json +0 -59
- package/dist/schemas/inbound-frame-group-context-v1.schema.json +0 -96
- package/dist/schemas/inbound-frame-reply-context-v1.schema.json +0 -261
- package/dist/schemas/inbound-frame-shape-v1.schema.json +0 -12
- package/dist/schemas/inbound-frame-v1.schema.json +0 -506
- package/dist/schemas/mark-read-response.schema.json +0 -11
- package/dist/schemas/media-attachment-kind.schema.json +0 -11
- package/dist/schemas/media-attachment.schema.json +0 -42
- package/dist/schemas/messages-page-response.schema.json +0 -290
- package/dist/schemas/participation-decision-input.schema.json +0 -44
- package/dist/schemas/participation-history-message.schema.json +0 -23
- package/dist/schemas/participation-history-snapshot.schema.json +0 -37
- package/dist/schemas/participation-style.schema.json +0 -13
- package/dist/schemas/react-request.schema.json +0 -22
- package/dist/schemas/react-response.schema.json +0 -35
- package/dist/schemas/resolve-admission-request.schema.json +0 -30
- package/dist/schemas/resolve-admission-response.schema.json +0 -129
- package/dist/schemas/resolved-agent-behavior-policy-record.schema.json +0 -81
- package/dist/schemas/rest-contact.schema.json +0 -40
- package/dist/schemas/rest-conversation-last-message.schema.json +0 -77
- package/dist/schemas/rest-conversation.schema.json +0 -155
- package/dist/schemas/rest-message.schema.json +0 -252
- package/dist/schemas/rest-ok-response.schema.json +0 -11
- package/dist/schemas/rest-session-selection.schema.json +0 -40
- package/dist/schemas/runtime-card-field-choice.schema.json +0 -23
- package/dist/schemas/runtime-card-field-type.schema.json +0 -17
- package/dist/schemas/runtime-card-field.schema.json +0 -180
- package/dist/schemas/runtime-card-line-item-column-type.schema.json +0 -12
- package/dist/schemas/runtime-card-line-item-column.schema.json +0 -74
- package/dist/schemas/send-contextual-deferred-response.schema.json +0 -39
- package/dist/schemas/send-contextual-messaged-response.schema.json +0 -42
- package/dist/schemas/send-contextual-request.schema.json +0 -103
- package/dist/schemas/send-contextual-response.schema.json +0 -105
- package/dist/schemas/send-contextual-self-context.schema.json +0 -19
- package/dist/schemas/send-contextual-state-response.schema.json +0 -24
- package/dist/schemas/send-message-request.schema.json +0 -106
- package/dist/schemas/send-message-response.schema.json +0 -14
- package/dist/schemas/sender-type.schema.json +0 -9
- package/dist/schemas/serialize-message-input.schema.json +0 -29
- package/dist/schemas/serialized-agent-client-type.schema.json +0 -12
- package/dist/schemas/serialized-contact-card.schema.json +0 -65
- package/dist/schemas/serialized-contact-request-status.schema.json +0 -11
- package/dist/schemas/serialized-contact-request.schema.json +0 -157
- package/dist/schemas/serialized-content-type.schema.json +0 -13
- package/dist/schemas/serialized-message.schema.json +0 -249
- package/dist/schemas/serialized-reactions.schema.json +0 -14
- package/dist/schemas/serialized-sender-type.schema.json +0 -9
- package/dist/schemas/set-streaming-request.schema.json +0 -67
- package/dist/schemas/set-typing-request.schema.json +0 -25
- package/dist/schemas/sse-access-policy.schema.json +0 -10
- package/dist/schemas/sse-agent-context-payload.schema.json +0 -57
- package/dist/schemas/sse-connected-payload.schema.json +0 -18
- package/dist/schemas/sse-contact-payload.schema.json +0 -40
- package/dist/schemas/sse-contact-removed-payload.schema.json +0 -14
- package/dist/schemas/sse-contact-request-payload.schema.json +0 -157
- package/dist/schemas/sse-conversation-updated-payload.schema.json +0 -48
- package/dist/schemas/sse-error-payload.schema.json +0 -23
- package/dist/schemas/sse-event-envelope.schema.json +0 -40
- package/dist/schemas/sse-event-family.schema.json +0 -12
- package/dist/schemas/sse-event-type.schema.json +0 -26
- package/dist/schemas/sse-heartbeat-payload.schema.json +0 -14
- package/dist/schemas/sse-membership-change.schema.json +0 -28
- package/dist/schemas/sse-message-created-payload.schema.json +0 -414
- package/dist/schemas/sse-message-deleted-payload.schema.json +0 -18
- package/dist/schemas/sse-message-updated-payload.schema.json +0 -46
- package/dist/schemas/sse-presence-payload.schema.json +0 -21
- package/dist/schemas/sse-provenance.schema.json +0 -64
- package/dist/schemas/sse-replay-expired-payload.schema.json +0 -21
- package/dist/schemas/sse-runtime-control-kind.schema.json +0 -13
- package/dist/schemas/sse-runtime-control-payload.schema.json +0 -44
- package/dist/schemas/sse-self-context.schema.json +0 -45
- package/dist/schemas/sse-turn-dispatch.schema.json +0 -29
- package/dist/schemas/sse-typing-payload.schema.json +0 -32
- package/dist/schemas/sse-voice-session-event-payload.schema.json +0 -170
- package/dist/schemas/sse-voice-session.schema.json +0 -157
- package/dist/schemas/trigger-decision.schema.json +0 -27
- package/dist/schemas/turn-lifecycle-state.schema.json +0 -14
- package/dist/schemas/turn-message-semantics.schema.json +0 -10
- package/dist/schemas/turn-metadata.schema.json +0 -56
- package/dist/schemas/turn-state-like.schema.json +0 -39
- package/dist/schemas/update-disposition-request.schema.json +0 -22
- package/dist/schemas/upload-media-request.schema.json +0 -25
- package/dist/schemas/upload-media-response.schema.json +0 -55
- package/dist/sendContextual.d.ts +0 -114
- package/dist/sendContextual.js +0 -89
- package/dist/sseEvents.d.ts +0 -474
- package/dist/sseEvents.js +0 -278
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UploadMediaResponseSchema = exports.UploadMediaRequestSchema = exports.SetStreamingRequestSchema = exports.SetTypingRequestSchema = exports.ResolveAdmissionResponseSchema = exports.ResolveAdmissionRequestSchema = exports.ContactsResponseSchema = exports.CreateContactRequestResponseSchema = exports.CreateContactRequestRequestSchema = exports.CreateConversationResponseSchema = exports.CreateConversationRequestSchema = exports.MessagesPageResponseSchema = exports.GetMessagesQuerySchema = exports.ConversationsResponseSchema = exports.UpdateDispositionRequestSchema = exports.MarkReadResponseSchema = exports.DeleteMessageResponseSchema = exports.ForwardMessageResponseSchema = exports.ForwardMessageRequestSchema = exports.ReactResponseSchema = exports.ReactRequestSchema = exports.SendMessageResponseSchema = exports.SendMessageRequestSchema = exports.RestSessionSelectionSchema = exports.RestContactSchema = exports.RestConversationSchema = exports.RestConversationLastMessageSchema = exports.RestMessageSchema = exports.RestOkResponseSchema = void 0;
|
|
4
|
-
// Wire contract v1 — request/response schemas for the agent-facing "Canon op"
|
|
5
|
-
// REST surface the bridge proxies (bridge-local-api.md §B).
|
|
6
|
-
//
|
|
7
|
-
// Grounded in the Functions handlers (functions/src/api/*) and the canonical
|
|
8
|
-
// consumer (@canonmsg/core CanonClient) — request bodies mirror what clients
|
|
9
|
-
// send today, response schemas mirror what the handlers emit. This is a
|
|
10
|
-
// re-expression of current behavior, not a redesign.
|
|
11
|
-
const zod_1 = require("zod");
|
|
12
|
-
const media_js_1 = require("./media.js");
|
|
13
|
-
const message_js_1 = require("./message.js");
|
|
14
|
-
const turnProtocol_js_1 = require("./turnProtocol.js");
|
|
15
|
-
// ── Shared fragments ───────────────────────────────────────────────────
|
|
16
|
-
exports.RestOkResponseSchema = zod_1.z.looseObject({
|
|
17
|
-
success: zod_1.z.boolean().optional(),
|
|
18
|
-
});
|
|
19
|
-
/** GET …/messages items — the serialized message plus the soft-delete flag. */
|
|
20
|
-
exports.RestMessageSchema = message_js_1.SerializedMessageSchema.extend({
|
|
21
|
-
deleted: zod_1.z.boolean().optional(),
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* STRICT WRITES, TOLERANT READS: this is a READ schema over live production
|
|
25
|
-
* data, so it must describe what Firestore actually holds — not what today's
|
|
26
|
-
* writers produce. The GET /conversations serializer
|
|
27
|
-
* (functions/src/api/getConversations.ts) passes `lastMessage` fields through
|
|
28
|
-
* from the conversation doc, and legacy rows (pre-refactor writes,
|
|
29
|
-
* deleted-message repair) hold explicit nulls:
|
|
30
|
-
* - `text` is serialized `?? null` and `timestamp` as
|
|
31
|
-
* `?.toDate?.()?.toISOString() ?? null` — both emit null by construction.
|
|
32
|
-
* - `senderId` / `senderType` / `contentType` are raw pass-throughs; live
|
|
33
|
-
* rows exist with all three null (the getConversations "ghost fix" comment
|
|
34
|
-
* acknowledges null senderId).
|
|
35
|
-
* - conversation `createdAt` is also serialized `?? null`.
|
|
36
|
-
* Writers (onMessageCreated / deletedMessageRepair) stay strict — they always
|
|
37
|
-
* produce the full shape; only the read contract admits the legacy nulls.
|
|
38
|
-
*/
|
|
39
|
-
exports.RestConversationLastMessageSchema = zod_1.z.looseObject({
|
|
40
|
-
text: zod_1.z.string().nullable(),
|
|
41
|
-
messageId: zod_1.z.string().optional(),
|
|
42
|
-
senderId: zod_1.z.string().nullable().optional(),
|
|
43
|
-
senderType: zod_1.z.enum(['human', 'ai_agent']).nullable().optional(),
|
|
44
|
-
contentType: message_js_1.SerializedContentTypeSchema.nullable().optional(),
|
|
45
|
-
timestamp: zod_1.z.string().nullable(),
|
|
46
|
-
});
|
|
47
|
-
exports.RestConversationSchema = zod_1.z.looseObject({
|
|
48
|
-
id: zod_1.z.string(),
|
|
49
|
-
type: zod_1.z.enum(['direct', 'group']),
|
|
50
|
-
name: zod_1.z.string().nullable().optional(),
|
|
51
|
-
topic: zod_1.z.string().nullable().optional(),
|
|
52
|
-
memberIds: zod_1.z.array(zod_1.z.string()),
|
|
53
|
-
isAgentChat: zod_1.z.boolean().optional(),
|
|
54
|
-
/** Resolved agent behavior policy — opaque pass-through. */
|
|
55
|
-
behavior: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
56
|
-
hasUnread: zod_1.z.boolean().optional(),
|
|
57
|
-
lastMessage: exports.RestConversationLastMessageSchema.nullable(),
|
|
58
|
-
createdAt: zod_1.z.string().nullable().optional(),
|
|
59
|
-
});
|
|
60
|
-
exports.RestContactSchema = zod_1.z.object({
|
|
61
|
-
id: zod_1.z.string(),
|
|
62
|
-
source: zod_1.z.string(),
|
|
63
|
-
addedAt: zod_1.z.string().nullable(),
|
|
64
|
-
displayNameOverride: zod_1.z.string().nullable(),
|
|
65
|
-
});
|
|
66
|
-
exports.RestSessionSelectionSchema = zod_1.z.union([
|
|
67
|
-
zod_1.z.object({ mode: zod_1.z.enum(['new', 'continue_latest', 'continue_or_create']) }),
|
|
68
|
-
zod_1.z.object({ mode: zod_1.z.literal('specific'), conversationId: zod_1.z.string() }),
|
|
69
|
-
]);
|
|
70
|
-
// ── POST /messages/send ────────────────────────────────────────────────
|
|
71
|
-
exports.SendMessageRequestSchema = zod_1.z.object({
|
|
72
|
-
conversationId: zod_1.z.string(),
|
|
73
|
-
text: zod_1.z.string().optional(),
|
|
74
|
-
/** Client-supplied idempotency id. */
|
|
75
|
-
messageId: zod_1.z.string().optional(),
|
|
76
|
-
contentType: message_js_1.SerializedContentTypeSchema.optional(),
|
|
77
|
-
replyTo: zod_1.z.string().optional(),
|
|
78
|
-
replyToPosition: zod_1.z.number().optional(),
|
|
79
|
-
attachments: zod_1.z.array(media_js_1.MediaAttachmentSchema).optional(),
|
|
80
|
-
contactCardUserId: zod_1.z.string().optional(),
|
|
81
|
-
mentions: zod_1.z.array(zod_1.z.string()).optional(),
|
|
82
|
-
selfContextId: zod_1.z.string().nullable().optional(),
|
|
83
|
-
/** Structured metadata (turn protocol, approval cards, …). */
|
|
84
|
-
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
85
|
-
});
|
|
86
|
-
exports.SendMessageResponseSchema = zod_1.z.object({
|
|
87
|
-
messageId: zod_1.z.string(),
|
|
88
|
-
});
|
|
89
|
-
// ── POST /messages/react ───────────────────────────────────────────────
|
|
90
|
-
exports.ReactRequestSchema = zod_1.z.object({
|
|
91
|
-
conversationId: zod_1.z.string(),
|
|
92
|
-
messageId: zod_1.z.string(),
|
|
93
|
-
emoji: zod_1.z.string(),
|
|
94
|
-
});
|
|
95
|
-
exports.ReactResponseSchema = zod_1.z.object({
|
|
96
|
-
success: zod_1.z.boolean(),
|
|
97
|
-
action: zod_1.z.enum(['added', 'removed']),
|
|
98
|
-
reactions: message_js_1.SerializedReactionsSchema,
|
|
99
|
-
});
|
|
100
|
-
// ── POST /messages/forward ─────────────────────────────────────────────
|
|
101
|
-
exports.ForwardMessageRequestSchema = zod_1.z.object({
|
|
102
|
-
sourceConversationId: zod_1.z.string(),
|
|
103
|
-
targetConversationId: zod_1.z.string(),
|
|
104
|
-
messageId: zod_1.z.string(),
|
|
105
|
-
text: zod_1.z.string().optional(),
|
|
106
|
-
});
|
|
107
|
-
exports.ForwardMessageResponseSchema = zod_1.z.object({
|
|
108
|
-
messageId: zod_1.z.string(),
|
|
109
|
-
targetConversationId: zod_1.z.string(),
|
|
110
|
-
forwardedFrom: zod_1.z.object({
|
|
111
|
-
sourceConversationId: zod_1.z.string(),
|
|
112
|
-
messageId: zod_1.z.string(),
|
|
113
|
-
}),
|
|
114
|
-
});
|
|
115
|
-
// ── DELETE /conversations/:id/messages/:id, POST …/read, PATCH …/disposition ──
|
|
116
|
-
exports.DeleteMessageResponseSchema = exports.RestOkResponseSchema;
|
|
117
|
-
exports.MarkReadResponseSchema = exports.RestOkResponseSchema;
|
|
118
|
-
exports.UpdateDispositionRequestSchema = zod_1.z.object({
|
|
119
|
-
inboundDisposition: turnProtocol_js_1.InboundDispositionSchema,
|
|
120
|
-
});
|
|
121
|
-
// ── GET /conversations + GET …/messages ────────────────────────────────
|
|
122
|
-
exports.ConversationsResponseSchema = zod_1.z.object({
|
|
123
|
-
conversations: zod_1.z.array(exports.RestConversationSchema),
|
|
124
|
-
});
|
|
125
|
-
/** Query params: limit, before, includeBehavior. */
|
|
126
|
-
exports.GetMessagesQuerySchema = zod_1.z.object({
|
|
127
|
-
limit: zod_1.z.string().optional(),
|
|
128
|
-
before: zod_1.z.string().optional(),
|
|
129
|
-
includeBehavior: zod_1.z.string().optional(),
|
|
130
|
-
});
|
|
131
|
-
exports.MessagesPageResponseSchema = zod_1.z.looseObject({
|
|
132
|
-
messages: zod_1.z.array(exports.RestMessageSchema),
|
|
133
|
-
/** Present with includeBehavior=1. */
|
|
134
|
-
behavior: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
135
|
-
activeSelfContextIdByMessageId: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
|
|
136
|
-
selfContexts: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
|
|
137
|
-
});
|
|
138
|
-
// ── POST /conversations/create ─────────────────────────────────────────
|
|
139
|
-
exports.CreateConversationRequestSchema = zod_1.z.object({
|
|
140
|
-
type: zod_1.z.enum(['direct', 'group']),
|
|
141
|
-
targetUserId: zod_1.z.string().optional(),
|
|
142
|
-
memberIds: zod_1.z.array(zod_1.z.string()).optional(),
|
|
143
|
-
name: zod_1.z.string().optional(),
|
|
144
|
-
/** Initial session config for first-party coding agents — opaque pass-through. */
|
|
145
|
-
sessionConfig: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable().optional(),
|
|
146
|
-
sessionSelection: exports.RestSessionSelectionSchema.optional(),
|
|
147
|
-
});
|
|
148
|
-
exports.CreateConversationResponseSchema = zod_1.z.object({
|
|
149
|
-
conversationId: zod_1.z.string(),
|
|
150
|
-
created: zod_1.z.boolean().optional(),
|
|
151
|
-
reused: zod_1.z.boolean().optional(),
|
|
152
|
-
sessionSelection: zod_1.z.enum(['new', 'continue_latest', 'continue_or_create', 'specific']).optional(),
|
|
153
|
-
});
|
|
154
|
-
// ── Contacts / admission ───────────────────────────────────────────────
|
|
155
|
-
exports.CreateContactRequestRequestSchema = zod_1.z.object({
|
|
156
|
-
targetId: zod_1.z.string(),
|
|
157
|
-
message: zod_1.z.string().optional(),
|
|
158
|
-
});
|
|
159
|
-
exports.CreateContactRequestResponseSchema = zod_1.z.union([
|
|
160
|
-
zod_1.z.looseObject({ status: zod_1.z.literal('open') }),
|
|
161
|
-
zod_1.z.looseObject({ status: zod_1.z.enum(['created', 'duplicate']), requestId: zod_1.z.string() }),
|
|
162
|
-
/** Legacy "already a contact" body. */
|
|
163
|
-
zod_1.z.looseObject({ message: zod_1.z.string() }),
|
|
164
|
-
]);
|
|
165
|
-
exports.ContactsResponseSchema = zod_1.z.object({
|
|
166
|
-
contacts: zod_1.z.array(exports.RestContactSchema),
|
|
167
|
-
});
|
|
168
|
-
exports.ResolveAdmissionRequestSchema = zod_1.z.union([
|
|
169
|
-
zod_1.z.object({ targetUserId: zod_1.z.string() }),
|
|
170
|
-
zod_1.z.object({ canonContactId: zod_1.z.string() }),
|
|
171
|
-
]);
|
|
172
|
-
exports.ResolveAdmissionResponseSchema = zod_1.z.looseObject({
|
|
173
|
-
resolvedTargetUserId: zod_1.z.string().nullable().optional(),
|
|
174
|
-
target: zod_1.z.looseObject({
|
|
175
|
-
id: zod_1.z.string(),
|
|
176
|
-
canonContactId: zod_1.z.string().optional(),
|
|
177
|
-
displayName: zod_1.z.string().optional(),
|
|
178
|
-
avatarUrl: zod_1.z.string().nullable().optional(),
|
|
179
|
-
about: zod_1.z.string().optional(),
|
|
180
|
-
userType: zod_1.z.enum(['human', 'ai_agent']).optional(),
|
|
181
|
-
discoverable: zod_1.z.boolean().optional(),
|
|
182
|
-
inboundPolicy: zod_1.z.enum(['open', 'approval-required', 'owner-only']).optional(),
|
|
183
|
-
groupJoinPolicy: zod_1.z.enum(['open', 'approval-required', 'owner-only']).optional(),
|
|
184
|
-
}).nullable(),
|
|
185
|
-
admission: zod_1.z.looseObject({
|
|
186
|
-
state: zod_1.z.enum([
|
|
187
|
-
'self',
|
|
188
|
-
'not-found',
|
|
189
|
-
'allowed',
|
|
190
|
-
'request-required',
|
|
191
|
-
'pending-outbound',
|
|
192
|
-
'blocked',
|
|
193
|
-
'inactive',
|
|
194
|
-
'owner-only',
|
|
195
|
-
]),
|
|
196
|
-
canMessage: zod_1.z.boolean(),
|
|
197
|
-
canRequestContact: zod_1.z.boolean(),
|
|
198
|
-
isContact: zod_1.z.boolean(),
|
|
199
|
-
pendingRequestId: zod_1.z.string().optional(),
|
|
200
|
-
blockedByViewer: zod_1.z.boolean().optional(),
|
|
201
|
-
blockedByTarget: zod_1.z.boolean().optional(),
|
|
202
|
-
}),
|
|
203
|
-
});
|
|
204
|
-
// ── Typing / streaming ─────────────────────────────────────────────────
|
|
205
|
-
exports.SetTypingRequestSchema = zod_1.z.object({
|
|
206
|
-
conversationId: zod_1.z.string(),
|
|
207
|
-
typing: zod_1.z.boolean(),
|
|
208
|
-
status: zod_1.z.enum(['thinking', 'typing']).optional(),
|
|
209
|
-
});
|
|
210
|
-
/** POST /streaming — the legacy REST facade over the RTDB streaming bubble. */
|
|
211
|
-
exports.SetStreamingRequestSchema = zod_1.z.union([
|
|
212
|
-
zod_1.z.object({
|
|
213
|
-
conversationId: zod_1.z.string(),
|
|
214
|
-
text: zod_1.z.string(),
|
|
215
|
-
status: zod_1.z.string(),
|
|
216
|
-
messageId: zod_1.z.string(),
|
|
217
|
-
turnId: zod_1.z.string().nullable().optional(),
|
|
218
|
-
/** TurnOutputBlock[] — opaque pass-through. */
|
|
219
|
-
blocks: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
|
|
220
|
-
}),
|
|
221
|
-
zod_1.z.object({
|
|
222
|
-
conversationId: zod_1.z.string(),
|
|
223
|
-
streaming: zod_1.z.literal(false),
|
|
224
|
-
}),
|
|
225
|
-
]);
|
|
226
|
-
// ── Media upload ───────────────────────────────────────────────────────
|
|
227
|
-
exports.UploadMediaRequestSchema = zod_1.z.object({
|
|
228
|
-
conversationId: zod_1.z.string(),
|
|
229
|
-
mimeType: zod_1.z.string(),
|
|
230
|
-
/** Base64-encoded file content. */
|
|
231
|
-
data: zod_1.z.string(),
|
|
232
|
-
fileName: zod_1.z.string().optional(),
|
|
233
|
-
});
|
|
234
|
-
exports.UploadMediaResponseSchema = zod_1.z.object({
|
|
235
|
-
url: zod_1.z.string(),
|
|
236
|
-
attachment: media_js_1.MediaAttachmentSchema,
|
|
237
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SEND_CONTEXTUAL_HTTP_STATUS = exports.SendContextualResponseSchema = exports.SendContextualStateResponseSchema = exports.SendContextualDeferredResponseSchema = exports.SendContextualMessagedResponseSchema = exports.SendContextualRequestSchema = exports.SendContextualSelfContextSchema = void 0;
|
|
4
|
-
// Wire contract v1 — POST /messages/send-contextual as a FIRST-CLASS contract
|
|
5
|
-
// (bridge-execution-plan Phase 3; owner decision 2026-07-03: the re-spec rides
|
|
6
|
-
// contract v1, the transport stays as-is and the Bridge proxies it unchanged
|
|
7
|
-
// in Phase 4).
|
|
8
|
-
//
|
|
9
|
-
// Grounded in functions/src/api/sendContextualMessage.ts (the handler's actual
|
|
10
|
-
// parse + emissions) and @canonmsg/core's SendContextualMessageOptions/Result.
|
|
11
|
-
// This mirrors CURRENT behavior — a re-spec, not a redesign.
|
|
12
|
-
const zod_1 = require("zod");
|
|
13
|
-
const restEndpoints_js_1 = require("./restEndpoints.js");
|
|
14
|
-
exports.SendContextualSelfContextSchema = zod_1.z.object({
|
|
15
|
-
type: zod_1.z.literal('cross_session'),
|
|
16
|
-
/** Private agent self-context; server caps at 1000 chars. */
|
|
17
|
-
context: zod_1.z.string(),
|
|
18
|
-
});
|
|
19
|
-
/**
|
|
20
|
-
* Request body. Exactly ONE of targetConversationId (existing conversation) or
|
|
21
|
-
* targetUserId (open/reuse a direct conversation, contact-request fallback)
|
|
22
|
-
* must be present — the refinement enforces the handler's rule.
|
|
23
|
-
*/
|
|
24
|
-
exports.SendContextualRequestSchema = zod_1.z.object({
|
|
25
|
-
sourceConversationId: zod_1.z.string(),
|
|
26
|
-
/** Target arm 1: send into an existing conversation. */
|
|
27
|
-
targetConversationId: zod_1.z.string().optional(),
|
|
28
|
-
/** Target arm 2: resolve/create a direct conversation with this user. */
|
|
29
|
-
targetUserId: zod_1.z.string().optional(),
|
|
30
|
-
text: zod_1.z.string().optional(),
|
|
31
|
-
selfContext: exports.SendContextualSelfContextSchema,
|
|
32
|
-
/** Initial agent session config (agent targets) — opaque pass-through. */
|
|
33
|
-
sessionConfig: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable().optional(),
|
|
34
|
-
sessionSelection: restEndpoints_js_1.RestSessionSelectionSchema.optional(),
|
|
35
|
-
/** Contact-request message when admission requires approval. */
|
|
36
|
-
requestMessage: zod_1.z.string().optional(),
|
|
37
|
-
/**
|
|
38
|
-
* SendMessageOptions passthrough (attachments, replyTo, metadata, …).
|
|
39
|
-
* May NOT carry selfContextId/selfContext — the handler rejects overrides
|
|
40
|
-
* of the self-context linkage fields.
|
|
41
|
-
*/
|
|
42
|
-
messageOptions: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
43
|
-
}).refine((body) => (body.targetConversationId ? 1 : 0) + (body.targetUserId ? 1 : 0) === 1, { message: 'Provide exactly one targetConversationId or targetUserId' }).refine((body) => !body.messageOptions
|
|
44
|
-
|| (!('selfContextId' in body.messageOptions) && !('selfContext' in body.messageOptions)), { message: 'messageOptions may not override self-context linkage fields' });
|
|
45
|
-
// ── Response arms (exactly what the handler emits today) ───────────────
|
|
46
|
-
/** HTTP 201 — message persisted (or idempotent replay) with self-context linked. */
|
|
47
|
-
exports.SendContextualMessagedResponseSchema = zod_1.z.object({
|
|
48
|
-
status: zod_1.z.literal('messaged'),
|
|
49
|
-
messageId: zod_1.z.string(),
|
|
50
|
-
conversationId: zod_1.z.string(),
|
|
51
|
-
selfContextId: zod_1.z.string(),
|
|
52
|
-
/** Present when the target conversation was opened by this call. */
|
|
53
|
-
created: zod_1.z.boolean().optional(),
|
|
54
|
-
reused: zod_1.z.boolean().optional(),
|
|
55
|
-
sessionSelection: zod_1.z.enum(['new', 'continue_latest', 'continue_or_create', 'specific']).optional(),
|
|
56
|
-
});
|
|
57
|
-
/**
|
|
58
|
-
* HTTP 202 — admission requires approval: a contact request was created
|
|
59
|
-
* (`requested`) or already pending (`pending`); the message is deferred as a
|
|
60
|
-
* contextual intent when a request id exists.
|
|
61
|
-
*/
|
|
62
|
-
exports.SendContextualDeferredResponseSchema = zod_1.z.object({
|
|
63
|
-
status: zod_1.z.enum(['requested', 'pending']),
|
|
64
|
-
requestId: zod_1.z.string().nullable(),
|
|
65
|
-
deferredIntentId: zod_1.z.string().nullable().optional(),
|
|
66
|
-
});
|
|
67
|
-
/**
|
|
68
|
-
* Terminal / retryable states:
|
|
69
|
-
* - setup_required (HTTP 202) — agent session setup must complete first.
|
|
70
|
-
* - blocked (HTTP 200) — admission denied (block or policy).
|
|
71
|
-
* - unavailable (HTTP 200) — target cannot be reached right now.
|
|
72
|
-
* - no_session (HTTP 404) — session selection matched nothing.
|
|
73
|
-
*/
|
|
74
|
-
exports.SendContextualStateResponseSchema = zod_1.z.object({
|
|
75
|
-
status: zod_1.z.enum(['setup_required', 'blocked', 'unavailable', 'no_session']),
|
|
76
|
-
reason: zod_1.z.string(),
|
|
77
|
-
});
|
|
78
|
-
exports.SendContextualResponseSchema = zod_1.z.union([
|
|
79
|
-
exports.SendContextualMessagedResponseSchema,
|
|
80
|
-
exports.SendContextualDeferredResponseSchema,
|
|
81
|
-
exports.SendContextualStateResponseSchema,
|
|
82
|
-
]);
|
|
83
|
-
/** HTTP status the handler pairs with each response status. */
|
|
84
|
-
exports.SEND_CONTEXTUAL_HTTP_STATUS = {
|
|
85
|
-
messaged: 201,
|
|
86
|
-
requested: 202,
|
|
87
|
-
pending: 202,
|
|
88
|
-
setup_required: 202,
|
|
89
|
-
blocked: 200,
|
|
90
|
-
unavailable: 200,
|
|
91
|
-
no_session: 404,
|
|
92
|
-
};
|
package/dist/cjs/sseEvents.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.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
|
-
// Wire contract v1 — SSE event envelope + per-family payload schemas.
|
|
5
|
-
//
|
|
6
|
-
// Grounded in what stream-service ACTUALLY emits (stream-service/src/stream.ts
|
|
7
|
-
// + listeners.ts) and what @canonmsg/core's CanonStream consumes — not in
|
|
8
|
-
// design-doc prose. Payload slots that stream-service passes through opaquely
|
|
9
|
-
// (behavior policies, runtime snapshots, raw RTDB values) stay loose objects;
|
|
10
|
-
// slots stream-service constructs field-by-field are closed.
|
|
11
|
-
//
|
|
12
|
-
// The golden fixtures in @canonmsg/test-fixtures parse under these schemas;
|
|
13
|
-
// the future Python framework must pass the same fixtures.
|
|
14
|
-
const zod_1 = require("zod");
|
|
15
|
-
const contactRequest_js_1 = require("./contactRequest.js");
|
|
16
|
-
const message_js_1 = require("./message.js");
|
|
17
|
-
exports.SseAccessPolicySchema = zod_1.z.enum(['open', 'approval-required', 'owner-only']);
|
|
18
|
-
// ── Lifecycle events ───────────────────────────────────────────────────
|
|
19
|
-
exports.SseConnectedPayloadSchema = zod_1.z.object({
|
|
20
|
-
connectionId: zod_1.z.string(),
|
|
21
|
-
agentId: zod_1.z.string(),
|
|
22
|
-
});
|
|
23
|
-
/** Trusted, server-injected identity & access info (stream.ts `agent.context`). */
|
|
24
|
-
exports.SseAgentContextPayloadSchema = zod_1.z.looseObject({
|
|
25
|
-
agentId: zod_1.z.string(),
|
|
26
|
-
canonContactId: zod_1.z.string().optional(),
|
|
27
|
-
clientType: zod_1.z.string().optional(),
|
|
28
|
-
ownerId: zod_1.z.string(),
|
|
29
|
-
ownerName: zod_1.z.string(),
|
|
30
|
-
/** Resolved agent behavior policy — passed through opaquely. */
|
|
31
|
-
defaultBehavior: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
32
|
-
inboundPolicy: exports.SseAccessPolicySchema,
|
|
33
|
-
groupJoinPolicy: exports.SseAccessPolicySchema,
|
|
34
|
-
discoverable: zod_1.z.boolean(),
|
|
35
|
-
});
|
|
36
|
-
exports.SseHeartbeatPayloadSchema = zod_1.z.object({
|
|
37
|
-
timestamp: zod_1.z.string(),
|
|
38
|
-
});
|
|
39
|
-
exports.SseReplayExpiredPayloadSchema = zod_1.z.looseObject({
|
|
40
|
-
lastAvailableId: zod_1.z.string().nullable().optional(),
|
|
41
|
-
message: zod_1.z.string().optional(),
|
|
42
|
-
});
|
|
43
|
-
exports.SseErrorPayloadSchema = zod_1.z.looseObject({
|
|
44
|
-
code: zod_1.z.string().optional(),
|
|
45
|
-
message: zod_1.z.string().optional(),
|
|
46
|
-
retryAfterMs: zod_1.z.number().optional(),
|
|
47
|
-
activeConnections: zod_1.z.number().optional(),
|
|
48
|
-
maxConnections: zod_1.z.number().optional(),
|
|
49
|
-
});
|
|
50
|
-
// ── Messages family ────────────────────────────────────────────────────
|
|
51
|
-
exports.SseSelfContextSchema = zod_1.z.object({
|
|
52
|
-
id: zod_1.z.string(),
|
|
53
|
-
type: zod_1.z.literal('cross_session'),
|
|
54
|
-
context: zod_1.z.string(),
|
|
55
|
-
createdAt: zod_1.z.string().nullable(),
|
|
56
|
-
updatedAt: zod_1.z.string().nullable(),
|
|
57
|
-
});
|
|
58
|
-
exports.SseTurnDispatchSchema = zod_1.z.looseObject({
|
|
59
|
-
kind: zod_1.z.enum(['run_turn', 'observe_only']),
|
|
60
|
-
reason: zod_1.z.string(),
|
|
61
|
-
addressed: zod_1.z.boolean(),
|
|
62
|
-
policyVersion: zod_1.z.string().optional(),
|
|
63
|
-
});
|
|
64
|
-
exports.SseProvenanceSchema = zod_1.z.looseObject({
|
|
65
|
-
conversation: zod_1.z.looseObject({
|
|
66
|
-
id: zod_1.z.string(),
|
|
67
|
-
type: zod_1.z.enum(['direct', 'group', 'unknown']),
|
|
68
|
-
}),
|
|
69
|
-
sender: zod_1.z.looseObject({
|
|
70
|
-
id: zod_1.z.string(),
|
|
71
|
-
name: zod_1.z.string().optional(),
|
|
72
|
-
type: zod_1.z.enum(['human', 'ai_agent']),
|
|
73
|
-
isOwner: zod_1.z.boolean(),
|
|
74
|
-
}),
|
|
75
|
-
mentionedAgent: zod_1.z.boolean(),
|
|
76
|
-
});
|
|
77
|
-
/**
|
|
78
|
-
* `message.created` — the inbound message envelope. `message` is exactly the
|
|
79
|
-
* SerializedMessage the shared serializer emits (the E2EE S1 slot).
|
|
80
|
-
*/
|
|
81
|
-
exports.SseMessageCreatedPayloadSchema = zod_1.z.looseObject({
|
|
82
|
-
conversationId: zod_1.z.string(),
|
|
83
|
-
/** Resolved agent behavior policy — passed through opaquely. */
|
|
84
|
-
behavior: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
85
|
-
activeSelfContextId: zod_1.z.string().nullable().optional(),
|
|
86
|
-
selfContexts: zod_1.z.array(exports.SseSelfContextSchema).optional(),
|
|
87
|
-
provenance: exports.SseProvenanceSchema.optional(),
|
|
88
|
-
turnDispatch: exports.SseTurnDispatchSchema.optional(),
|
|
89
|
-
message: message_js_1.SerializedMessageSchema,
|
|
90
|
-
});
|
|
91
|
-
exports.SseMessageUpdatedPayloadSchema = zod_1.z.object({
|
|
92
|
-
conversationId: zod_1.z.string(),
|
|
93
|
-
messageId: zod_1.z.string(),
|
|
94
|
-
actorId: zod_1.z.string().optional(),
|
|
95
|
-
updatedAt: zod_1.z.string().optional(),
|
|
96
|
-
changes: zod_1.z.looseObject({
|
|
97
|
-
reactions: message_js_1.SerializedReactionsSchema,
|
|
98
|
-
}),
|
|
99
|
-
});
|
|
100
|
-
exports.SseMessageDeletedPayloadSchema = zod_1.z.object({
|
|
101
|
-
conversationId: zod_1.z.string(),
|
|
102
|
-
messageId: zod_1.z.string(),
|
|
103
|
-
});
|
|
104
|
-
exports.SseMembershipChangeSchema = zod_1.z.object({
|
|
105
|
-
addedMemberIds: zod_1.z.array(zod_1.z.string()),
|
|
106
|
-
removedMemberIds: zod_1.z.array(zod_1.z.string()),
|
|
107
|
-
memberCount: zod_1.z.number(),
|
|
108
|
-
});
|
|
109
|
-
exports.SseConversationUpdatedPayloadSchema = zod_1.z.object({
|
|
110
|
-
conversationId: zod_1.z.string(),
|
|
111
|
-
changes: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
112
|
-
membershipChange: exports.SseMembershipChangeSchema.optional(),
|
|
113
|
-
});
|
|
114
|
-
// ── Contacts family ────────────────────────────────────────────────────
|
|
115
|
-
/** `contact.request` / `contact.approved` carry the serialized contact request. */
|
|
116
|
-
exports.SseContactRequestPayloadSchema = contactRequest_js_1.SerializedContactRequestSchema;
|
|
117
|
-
/**
|
|
118
|
-
* `contact.added` / `contact.updated`. `source` is a pass-through string —
|
|
119
|
-
* canonical values today: direct_add, phone_book, contact_request, link, qr,
|
|
120
|
-
* group, open_inbound_message, unknown.
|
|
121
|
-
*/
|
|
122
|
-
exports.SseContactPayloadSchema = zod_1.z.object({
|
|
123
|
-
id: zod_1.z.string(),
|
|
124
|
-
source: zod_1.z.string(),
|
|
125
|
-
addedAt: zod_1.z.string().nullable(),
|
|
126
|
-
displayNameOverride: zod_1.z.string().nullable(),
|
|
127
|
-
});
|
|
128
|
-
exports.SseContactRemovedPayloadSchema = zod_1.z.object({
|
|
129
|
-
id: zod_1.z.string(),
|
|
130
|
-
});
|
|
131
|
-
// ── Typing / presence family ───────────────────────────────────────────
|
|
132
|
-
exports.SseTypingPayloadSchema = zod_1.z.object({
|
|
133
|
-
conversationId: zod_1.z.string(),
|
|
134
|
-
userId: zod_1.z.string(),
|
|
135
|
-
isTyping: zod_1.z.boolean(),
|
|
136
|
-
status: zod_1.z.enum(['thinking', 'typing']).optional(),
|
|
137
|
-
timestamp: zod_1.z.number().optional(),
|
|
138
|
-
});
|
|
139
|
-
exports.SsePresencePayloadSchema = zod_1.z.object({
|
|
140
|
-
userId: zod_1.z.string(),
|
|
141
|
-
online: zod_1.z.boolean(),
|
|
142
|
-
lastSeen: zod_1.z.string().optional(),
|
|
143
|
-
});
|
|
144
|
-
// ── Runtime / turn family ──────────────────────────────────────────────
|
|
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).
|
|
148
|
-
exports.SseRuntimeControlKindSchema = zod_1.z.enum([
|
|
149
|
-
'session',
|
|
150
|
-
'signal',
|
|
151
|
-
'primitive',
|
|
152
|
-
'runtimeInput',
|
|
153
|
-
'runtimeCard',
|
|
154
|
-
'runtimeApproval',
|
|
155
|
-
]);
|
|
156
|
-
exports.SseRuntimeControlPayloadSchema = zod_1.z.object({
|
|
157
|
-
conversationId: zod_1.z.string(),
|
|
158
|
-
agentId: zod_1.z.string(),
|
|
159
|
-
kind: exports.SseRuntimeControlKindSchema,
|
|
160
|
-
requestId: zod_1.z.string().optional(),
|
|
161
|
-
updatedAt: zod_1.z.number().optional(),
|
|
162
|
-
value: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
163
|
-
});
|
|
164
|
-
// ── Voice family ───────────────────────────────────────────────────────
|
|
165
|
-
exports.SseVoiceSessionSchema = zod_1.z.looseObject({
|
|
166
|
-
id: zod_1.z.string(),
|
|
167
|
-
conversationId: zod_1.z.string(),
|
|
168
|
-
roomName: zod_1.z.string(),
|
|
169
|
-
mode: zod_1.z.enum(['human', 'runtime_voice']),
|
|
170
|
-
status: zod_1.z.enum(['active', 'ended', 'error']),
|
|
171
|
-
createdBy: zod_1.z.string(),
|
|
172
|
-
participantIds: zod_1.z.array(zod_1.z.string()),
|
|
173
|
-
participants: zod_1.z.array(zod_1.z.looseObject({
|
|
174
|
-
userId: zod_1.z.string(),
|
|
175
|
-
userType: zod_1.z.enum(['human', 'ai_agent', 'system']),
|
|
176
|
-
displayName: zod_1.z.string().nullable(),
|
|
177
|
-
joinedAt: zod_1.z.string().nullable(),
|
|
178
|
-
leftAt: zod_1.z.string().nullable(),
|
|
179
|
-
})).optional(),
|
|
180
|
-
targetAgentId: zod_1.z.string().nullable().optional(),
|
|
181
|
-
createdAt: zod_1.z.string().nullable().optional(),
|
|
182
|
-
updatedAt: zod_1.z.string().nullable().optional(),
|
|
183
|
-
endedAt: zod_1.z.string().nullable().optional(),
|
|
184
|
-
error: zod_1.z.string().nullable().optional(),
|
|
185
|
-
});
|
|
186
|
-
exports.SseVoiceSessionEventPayloadSchema = zod_1.z.object({
|
|
187
|
-
conversationId: zod_1.z.string(),
|
|
188
|
-
session: exports.SseVoiceSessionSchema,
|
|
189
|
-
});
|
|
190
|
-
// ── Envelope + registry ────────────────────────────────────────────────
|
|
191
|
-
/**
|
|
192
|
-
* Every SSE `event:` name stream-service emits today (stream.ts + listeners.ts;
|
|
193
|
-
* mirrored by CanonStream's dispatch switch in core). NOTE: `contact.updated`
|
|
194
|
-
* is emitted by stream-service but not yet consumed by CanonStream.
|
|
195
|
-
*/
|
|
196
|
-
exports.SSE_EVENT_TYPES = [
|
|
197
|
-
'connected',
|
|
198
|
-
'agent.context',
|
|
199
|
-
'heartbeat',
|
|
200
|
-
'message.created',
|
|
201
|
-
'message.updated',
|
|
202
|
-
'message.deleted',
|
|
203
|
-
'conversation.updated',
|
|
204
|
-
'contact.request',
|
|
205
|
-
'contact.approved',
|
|
206
|
-
'contact.added',
|
|
207
|
-
'contact.updated',
|
|
208
|
-
'contact.removed',
|
|
209
|
-
'typing',
|
|
210
|
-
'presence',
|
|
211
|
-
'runtime.control',
|
|
212
|
-
'voice.session.started',
|
|
213
|
-
'voice.session.ended',
|
|
214
|
-
'replay.expired',
|
|
215
|
-
'error',
|
|
216
|
-
];
|
|
217
|
-
exports.SseEventTypeSchema = zod_1.z.enum(exports.SSE_EVENT_TYPES);
|
|
218
|
-
/** Payload schema for every event type — the machine-readable event registry. */
|
|
219
|
-
exports.SSE_EVENT_PAYLOAD_SCHEMAS = {
|
|
220
|
-
'connected': exports.SseConnectedPayloadSchema,
|
|
221
|
-
'agent.context': exports.SseAgentContextPayloadSchema,
|
|
222
|
-
'heartbeat': exports.SseHeartbeatPayloadSchema,
|
|
223
|
-
'message.created': exports.SseMessageCreatedPayloadSchema,
|
|
224
|
-
'message.updated': exports.SseMessageUpdatedPayloadSchema,
|
|
225
|
-
'message.deleted': exports.SseMessageDeletedPayloadSchema,
|
|
226
|
-
'conversation.updated': exports.SseConversationUpdatedPayloadSchema,
|
|
227
|
-
'contact.request': exports.SseContactRequestPayloadSchema,
|
|
228
|
-
'contact.approved': exports.SseContactRequestPayloadSchema,
|
|
229
|
-
'contact.added': exports.SseContactPayloadSchema,
|
|
230
|
-
'contact.updated': exports.SseContactPayloadSchema,
|
|
231
|
-
'contact.removed': exports.SseContactRemovedPayloadSchema,
|
|
232
|
-
'typing': exports.SseTypingPayloadSchema,
|
|
233
|
-
'presence': exports.SsePresencePayloadSchema,
|
|
234
|
-
'runtime.control': exports.SseRuntimeControlPayloadSchema,
|
|
235
|
-
'voice.session.started': exports.SseVoiceSessionEventPayloadSchema,
|
|
236
|
-
'voice.session.ended': exports.SseVoiceSessionEventPayloadSchema,
|
|
237
|
-
'replay.expired': exports.SseReplayExpiredPayloadSchema,
|
|
238
|
-
'error': exports.SseErrorPayloadSchema,
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* Subscription families (`?events=` filter). Lifecycle events (`connected`,
|
|
242
|
-
* `agent.context`, `heartbeat`, `replay.expired`, `error`) are always sent.
|
|
243
|
-
*/
|
|
244
|
-
exports.SSE_EVENT_FAMILIES = [
|
|
245
|
-
'messages',
|
|
246
|
-
'contacts',
|
|
247
|
-
'typing_presence',
|
|
248
|
-
'runtime_turn',
|
|
249
|
-
'voice',
|
|
250
|
-
];
|
|
251
|
-
exports.SseEventFamilySchema = zod_1.z.enum(exports.SSE_EVENT_FAMILIES);
|
|
252
|
-
exports.SSE_EVENT_FAMILY_BY_TYPE = {
|
|
253
|
-
'connected': 'lifecycle',
|
|
254
|
-
'agent.context': 'lifecycle',
|
|
255
|
-
'heartbeat': 'lifecycle',
|
|
256
|
-
'message.created': 'messages',
|
|
257
|
-
'message.updated': 'messages',
|
|
258
|
-
'message.deleted': 'messages',
|
|
259
|
-
'conversation.updated': 'messages',
|
|
260
|
-
'contact.request': 'contacts',
|
|
261
|
-
'contact.approved': 'contacts',
|
|
262
|
-
'contact.added': 'contacts',
|
|
263
|
-
'contact.updated': 'contacts',
|
|
264
|
-
'contact.removed': 'contacts',
|
|
265
|
-
'typing': 'typing_presence',
|
|
266
|
-
'presence': 'typing_presence',
|
|
267
|
-
'runtime.control': 'runtime_turn',
|
|
268
|
-
'voice.session.started': 'voice',
|
|
269
|
-
'voice.session.ended': 'voice',
|
|
270
|
-
'replay.expired': 'lifecycle',
|
|
271
|
-
'error': 'lifecycle',
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* A parsed SSE frame: `id:` (replay cursor), `event:`, and the JSON-decoded
|
|
275
|
-
* `data:` payload. Validate `data` with SSE_EVENT_PAYLOAD_SCHEMAS[event].
|
|
276
|
-
*/
|
|
277
|
-
exports.SseEventEnvelopeSchema = zod_1.z.object({
|
|
278
|
-
id: zod_1.z.string().optional(),
|
|
279
|
-
event: exports.SseEventTypeSchema,
|
|
280
|
-
data: zod_1.z.unknown(),
|
|
281
|
-
});
|
package/dist/controlSignals.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const ControlSignalTypeSchema: z.ZodEnum<{
|
|
3
|
-
interrupt: "interrupt";
|
|
4
|
-
stop_and_drop: "stop_and_drop";
|
|
5
|
-
new_session: "new_session";
|
|
6
|
-
}>;
|
|
7
|
-
export type ControlSignalType = z.infer<typeof ControlSignalTypeSchema>;
|
|
8
|
-
export declare const ControlChannelKeySchema: z.ZodEnum<{
|
|
9
|
-
session: "session";
|
|
10
|
-
signal: "signal";
|
|
11
|
-
primitive: "primitive";
|
|
12
|
-
}>;
|
|
13
|
-
export type ControlChannelKey = z.infer<typeof ControlChannelKeySchema>;
|
|
14
|
-
/** `/control/{convo}/{agent}/signal` node. Consumed by writing null. */
|
|
15
|
-
export declare const ControlSignalNodeSchema: z.ZodObject<{
|
|
16
|
-
type: z.ZodEnum<{
|
|
17
|
-
interrupt: "interrupt";
|
|
18
|
-
stop_and_drop: "stop_and_drop";
|
|
19
|
-
new_session: "new_session";
|
|
20
|
-
}>;
|
|
21
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
22
|
-
}, z.core.$loose>;
|
|
23
|
-
export type ControlSignalNode = z.infer<typeof ControlSignalNodeSchema>;
|
|
24
|
-
/** `/control/{convo}/{agent}/session` node — the session-control primitive record. */
|
|
25
|
-
export declare const ControlSessionNodeSchema: z.ZodObject<{
|
|
26
|
-
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
27
|
-
}, z.core.$loose>;
|
|
28
|
-
export type ControlSessionNode = z.infer<typeof ControlSessionNodeSchema>;
|
|
29
|
-
/** `/control/{convo}/{agent}/primitive` — map of requestId → request value. */
|
|
30
|
-
export declare const ControlPrimitiveMapSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
31
|
-
export type ControlPrimitiveMap = z.infer<typeof ControlPrimitiveMapSchema>;
|
|
32
|
-
export declare const ControlSignalEventSchema: z.ZodObject<{
|
|
33
|
-
conversationId: z.ZodString;
|
|
34
|
-
type: z.ZodEnum<{
|
|
35
|
-
interrupt: "interrupt";
|
|
36
|
-
stop_and_drop: "stop_and_drop";
|
|
37
|
-
new_session: "new_session";
|
|
38
|
-
}>;
|
|
39
|
-
updatedAt: z.ZodNumber;
|
|
40
|
-
raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
41
|
-
}, z.core.$strip>;
|
|
42
|
-
export type ControlSignalEventRecord = z.infer<typeof ControlSignalEventSchema>;
|
|
43
|
-
export declare const ControlSessionEventSchema: z.ZodObject<{
|
|
44
|
-
conversationId: z.ZodString;
|
|
45
|
-
updatedAt: z.ZodNumber;
|
|
46
|
-
control: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
47
|
-
}, z.core.$strip>;
|
|
48
|
-
export type ControlSessionEventRecord = z.infer<typeof ControlSessionEventSchema>;
|
|
49
|
-
export declare const ControlPrimitiveEventSchema: z.ZodObject<{
|
|
50
|
-
conversationId: z.ZodString;
|
|
51
|
-
requestId: z.ZodString;
|
|
52
|
-
updatedAt: z.ZodNumber;
|
|
53
|
-
value: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
54
|
-
}, z.core.$strip>;
|
|
55
|
-
export type ControlPrimitiveEventRecord = z.infer<typeof ControlPrimitiveEventSchema>;
|