@canonmsg/backend-contracts 1.7.1 → 1.8.1
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 +86 -45
- package/dist/agentBehaviorPolicy.js +53 -0
- package/dist/bridgeLocal.d.ts +1729 -0
- package/dist/bridgeLocal.js +673 -0
- package/dist/cjs/agentBehaviorPolicy.js +54 -1
- package/dist/cjs/bridgeLocal.js +676 -0
- package/dist/cjs/contactRequest.js +30 -0
- package/dist/cjs/controlSignals.js +44 -0
- package/dist/cjs/endpointRegistry.js +264 -0
- package/dist/cjs/hitl.js +0 -0
- package/dist/cjs/inboundFrame.js +92 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/media.js +13 -0
- package/dist/cjs/message.js +64 -0
- package/dist/cjs/restEndpoints.js +237 -0
- package/dist/cjs/runtimeCardFields.js +58 -1
- package/dist/cjs/sendContextual.js +92 -0
- package/dist/cjs/sseEvents.js +298 -0
- package/dist/cjs/turnProtocol.js +41 -1
- package/dist/contactRequest.d.ts +42 -23
- package/dist/contactRequest.js +29 -0
- package/dist/controlSignals.d.ts +55 -0
- package/dist/controlSignals.js +41 -0
- package/dist/endpointRegistry.d.ts +13 -0
- package/dist/endpointRegistry.js +261 -0
- package/dist/hitl.d.ts +303 -0
- package/dist/hitl.js +168 -0
- package/dist/inboundFrame.d.ts +229 -0
- package/dist/inboundFrame.js +89 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/media.d.ts +24 -11
- package/dist/media.js +12 -0
- package/dist/message.d.ts +133 -50
- package/dist/message.js +64 -1
- package/dist/restEndpoints.d.ts +531 -0
- package/dist/restEndpoints.js +234 -0
- package/dist/runtimeCardFields.d.ts +112 -39
- package/dist/runtimeCardFields.js +57 -0
- package/dist/schemas/agent-behavior-settings-record.schema.json +48 -0
- package/dist/schemas/bridge-connection-state-notification.schema.json +19 -0
- package/dist/schemas/bridge-get-attachment-params.schema.json +24 -0
- package/dist/schemas/bridge-get-attachment-result.schema.json +20 -0
- package/dist/schemas/bridge-hello-params.schema.json +42 -0
- package/dist/schemas/bridge-hello-result.schema.json +105 -0
- package/dist/schemas/bridge-hitl-state.schema.json +38 -0
- package/dist/schemas/bridge-ok-result.schema.json +15 -0
- package/dist/schemas/bridge-ready-notification.schema.json +79 -0
- package/dist/schemas/bridge-resync-reason.schema.json +9 -0
- package/dist/schemas/bridge-resync.schema.json +18 -0
- package/dist/schemas/bridge-rpc-error.schema.json +19 -0
- package/dist/schemas/bridge-rpc-id.schema.json +12 -0
- package/dist/schemas/bridge-rpc-notification.schema.json +20 -0
- package/dist/schemas/bridge-rpc-request.schema.json +31 -0
- package/dist/schemas/bridge-rpc-response.schema.json +81 -0
- package/dist/schemas/bridge-status-result.schema.json +76 -0
- package/dist/schemas/bridge-upload-media-params.schema.json +28 -0
- package/dist/schemas/bridge-upstream-state.schema.json +10 -0
- package/dist/schemas/contacts-response.schema.json +52 -0
- package/dist/schemas/control-channel-key.schema.json +10 -0
- package/dist/schemas/control-primitive-event.schema.json +30 -0
- package/dist/schemas/control-primitive-map.schema.json +15 -0
- package/dist/schemas/control-session-event.schema.json +26 -0
- package/dist/schemas/control-session-node.schema.json +11 -0
- package/dist/schemas/control-signal-event.schema.json +35 -0
- package/dist/schemas/control-signal-node.schema.json +22 -0
- package/dist/schemas/control-signal-type.schema.json +10 -0
- package/dist/schemas/conversations-response.schema.json +167 -0
- package/dist/schemas/create-contact-request-request.schema.json +17 -0
- package/dist/schemas/create-contact-request-response.schema.json +51 -0
- package/dist/schemas/create-conversation-request.schema.json +82 -0
- package/dist/schemas/create-conversation-response.schema.json +29 -0
- package/dist/schemas/delete-message-response.schema.json +11 -0
- package/dist/schemas/delivery-intent.schema.json +11 -0
- package/dist/schemas/forward-message-request.schema.json +25 -0
- package/dist/schemas/forward-message-response.schema.json +35 -0
- package/dist/schemas/forwarded-from.schema.json +18 -0
- package/dist/schemas/get-messages-query.schema.json +17 -0
- package/dist/schemas/hitl-approval-category.schema.json +15 -0
- package/dist/schemas/hitl-approval-detail.schema.json +21 -0
- package/dist/schemas/hitl-approval-outcome-record.schema.json +33 -0
- package/dist/schemas/hitl-approval-reply-record.schema.json +57 -0
- package/dist/schemas/hitl-approval-request-record.schema.json +105 -0
- package/dist/schemas/hitl-approval-risk.schema.json +11 -0
- package/dist/schemas/hitl-card-outcome-record.schema.json +48 -0
- package/dist/schemas/hitl-card-reply-record.schema.json +46 -0
- package/dist/schemas/hitl-card-request-record.schema.json +73 -0
- package/dist/schemas/hitl-input-answers.schema.json +23 -0
- package/dist/schemas/hitl-input-kind.schema.json +10 -0
- package/dist/schemas/hitl-input-outcome-record.schema.json +46 -0
- package/dist/schemas/hitl-input-question.schema.json +54 -0
- package/dist/schemas/hitl-input-reply-record.schema.json +44 -0
- package/dist/schemas/hitl-input-request-record.schema.json +134 -0
- package/dist/schemas/hitl-pending.schema.json +31 -0
- package/dist/schemas/hitl-request-accepted.schema.json +18 -0
- package/dist/schemas/hitl-request-kind.schema.json +10 -0
- package/dist/schemas/hitl-resolution-status.schema.json +10 -0
- package/dist/schemas/hitl-resolution.schema.json +38 -0
- package/dist/schemas/hitl-session-rule.schema.json +32 -0
- package/dist/schemas/inbound-disposition.schema.json +13 -0
- package/dist/schemas/inbound-frame-attachment-v1.schema.json +94 -0
- package/dist/schemas/inbound-frame-contact-card-v1.schema.json +59 -0
- package/dist/schemas/inbound-frame-group-context-v1.schema.json +96 -0
- package/dist/schemas/inbound-frame-reply-context-v1.schema.json +261 -0
- package/dist/schemas/inbound-frame-shape-v1.schema.json +12 -0
- package/dist/schemas/inbound-frame-v1.schema.json +506 -0
- package/dist/schemas/mark-read-response.schema.json +11 -0
- package/dist/schemas/media-attachment-kind.schema.json +11 -0
- package/dist/schemas/media-attachment.schema.json +42 -0
- package/dist/schemas/messages-page-response.schema.json +290 -0
- package/dist/schemas/participation-decision-input.schema.json +44 -0
- package/dist/schemas/participation-history-message.schema.json +23 -0
- package/dist/schemas/participation-history-snapshot.schema.json +37 -0
- package/dist/schemas/participation-style.schema.json +13 -0
- package/dist/schemas/react-request.schema.json +22 -0
- package/dist/schemas/react-response.schema.json +35 -0
- package/dist/schemas/resolve-admission-request.schema.json +30 -0
- package/dist/schemas/resolve-admission-response.schema.json +129 -0
- package/dist/schemas/resolved-agent-behavior-policy-record.schema.json +81 -0
- package/dist/schemas/rest-contact.schema.json +40 -0
- package/dist/schemas/rest-conversation-last-message.schema.json +77 -0
- package/dist/schemas/rest-conversation.schema.json +155 -0
- package/dist/schemas/rest-message.schema.json +252 -0
- package/dist/schemas/rest-ok-response.schema.json +11 -0
- package/dist/schemas/rest-session-selection.schema.json +40 -0
- package/dist/schemas/runtime-card-field-choice.schema.json +23 -0
- package/dist/schemas/runtime-card-field-type.schema.json +17 -0
- package/dist/schemas/runtime-card-field.schema.json +180 -0
- package/dist/schemas/runtime-card-line-item-column-type.schema.json +12 -0
- package/dist/schemas/runtime-card-line-item-column.schema.json +74 -0
- package/dist/schemas/send-contextual-deferred-response.schema.json +39 -0
- package/dist/schemas/send-contextual-messaged-response.schema.json +42 -0
- package/dist/schemas/send-contextual-request.schema.json +103 -0
- package/dist/schemas/send-contextual-response.schema.json +105 -0
- package/dist/schemas/send-contextual-self-context.schema.json +19 -0
- package/dist/schemas/send-contextual-state-response.schema.json +24 -0
- package/dist/schemas/send-message-request.schema.json +106 -0
- package/dist/schemas/send-message-response.schema.json +14 -0
- package/dist/schemas/sender-type.schema.json +9 -0
- package/dist/schemas/serialize-message-input.schema.json +29 -0
- package/dist/schemas/serialized-agent-client-type.schema.json +12 -0
- package/dist/schemas/serialized-contact-card.schema.json +65 -0
- package/dist/schemas/serialized-contact-request-status.schema.json +11 -0
- package/dist/schemas/serialized-contact-request.schema.json +157 -0
- package/dist/schemas/serialized-content-type.schema.json +13 -0
- package/dist/schemas/serialized-message.schema.json +249 -0
- package/dist/schemas/serialized-reactions.schema.json +14 -0
- package/dist/schemas/serialized-sender-type.schema.json +9 -0
- package/dist/schemas/set-streaming-request.schema.json +67 -0
- package/dist/schemas/set-typing-request.schema.json +25 -0
- package/dist/schemas/sse-access-policy.schema.json +10 -0
- package/dist/schemas/sse-agent-context-payload.schema.json +57 -0
- package/dist/schemas/sse-connected-payload.schema.json +18 -0
- package/dist/schemas/sse-contact-payload.schema.json +40 -0
- package/dist/schemas/sse-contact-removed-payload.schema.json +14 -0
- package/dist/schemas/sse-contact-request-payload.schema.json +157 -0
- package/dist/schemas/sse-conversation-updated-payload.schema.json +48 -0
- package/dist/schemas/sse-error-payload.schema.json +23 -0
- package/dist/schemas/sse-event-envelope.schema.json +42 -0
- package/dist/schemas/sse-event-family.schema.json +12 -0
- package/dist/schemas/sse-event-type.schema.json +28 -0
- package/dist/schemas/sse-heartbeat-payload.schema.json +14 -0
- package/dist/schemas/sse-membership-change.schema.json +28 -0
- package/dist/schemas/sse-message-created-payload.schema.json +414 -0
- package/dist/schemas/sse-message-deleted-payload.schema.json +18 -0
- package/dist/schemas/sse-message-updated-payload.schema.json +46 -0
- package/dist/schemas/sse-presence-payload.schema.json +21 -0
- package/dist/schemas/sse-provenance.schema.json +64 -0
- package/dist/schemas/sse-replay-expired-payload.schema.json +21 -0
- package/dist/schemas/sse-runtime-control-kind.schema.json +13 -0
- package/dist/schemas/sse-runtime-control-payload.schema.json +44 -0
- package/dist/schemas/sse-runtime-updated-payload.schema.json +78 -0
- package/dist/schemas/sse-self-context.schema.json +45 -0
- package/dist/schemas/sse-turn-dispatch.schema.json +29 -0
- package/dist/schemas/sse-turn-updated-payload.schema.json +33 -0
- package/dist/schemas/sse-typing-payload.schema.json +32 -0
- package/dist/schemas/sse-voice-session-event-payload.schema.json +170 -0
- package/dist/schemas/sse-voice-session.schema.json +157 -0
- package/dist/schemas/trigger-decision.schema.json +27 -0
- package/dist/schemas/turn-lifecycle-state.schema.json +14 -0
- package/dist/schemas/turn-message-semantics.schema.json +10 -0
- package/dist/schemas/turn-metadata.schema.json +56 -0
- package/dist/schemas/turn-state-like.schema.json +39 -0
- package/dist/schemas/update-disposition-request.schema.json +22 -0
- package/dist/schemas/upload-media-request.schema.json +25 -0
- package/dist/schemas/upload-media-response.schema.json +55 -0
- package/dist/sendContextual.d.ts +114 -0
- package/dist/sendContextual.js +89 -0
- package/dist/sseEvents.d.ts +494 -0
- package/dist/sseEvents.js +295 -0
- package/dist/turnProtocol.d.ts +91 -24
- package/dist/turnProtocol.js +40 -0
- package/package.json +8 -5
|
@@ -0,0 +1,298 @@
|
|
|
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.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;
|
|
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
|
+
/** 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
|
+
});
|
|
159
|
+
exports.SseRuntimeControlKindSchema = zod_1.z.enum([
|
|
160
|
+
'session',
|
|
161
|
+
'signal',
|
|
162
|
+
'primitive',
|
|
163
|
+
'runtimeInput',
|
|
164
|
+
'runtimeCard',
|
|
165
|
+
'runtimeApproval',
|
|
166
|
+
]);
|
|
167
|
+
exports.SseRuntimeControlPayloadSchema = zod_1.z.object({
|
|
168
|
+
conversationId: zod_1.z.string(),
|
|
169
|
+
agentId: zod_1.z.string(),
|
|
170
|
+
kind: exports.SseRuntimeControlKindSchema,
|
|
171
|
+
requestId: zod_1.z.string().optional(),
|
|
172
|
+
updatedAt: zod_1.z.number().optional(),
|
|
173
|
+
value: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
174
|
+
});
|
|
175
|
+
// ── Voice family ───────────────────────────────────────────────────────
|
|
176
|
+
exports.SseVoiceSessionSchema = zod_1.z.looseObject({
|
|
177
|
+
id: zod_1.z.string(),
|
|
178
|
+
conversationId: zod_1.z.string(),
|
|
179
|
+
roomName: zod_1.z.string(),
|
|
180
|
+
mode: zod_1.z.enum(['human', 'runtime_voice']),
|
|
181
|
+
status: zod_1.z.enum(['active', 'ended', 'error']),
|
|
182
|
+
createdBy: zod_1.z.string(),
|
|
183
|
+
participantIds: zod_1.z.array(zod_1.z.string()),
|
|
184
|
+
participants: zod_1.z.array(zod_1.z.looseObject({
|
|
185
|
+
userId: zod_1.z.string(),
|
|
186
|
+
userType: zod_1.z.enum(['human', 'ai_agent', 'system']),
|
|
187
|
+
displayName: zod_1.z.string().nullable(),
|
|
188
|
+
joinedAt: zod_1.z.string().nullable(),
|
|
189
|
+
leftAt: zod_1.z.string().nullable(),
|
|
190
|
+
})).optional(),
|
|
191
|
+
targetAgentId: zod_1.z.string().nullable().optional(),
|
|
192
|
+
createdAt: zod_1.z.string().nullable().optional(),
|
|
193
|
+
updatedAt: zod_1.z.string().nullable().optional(),
|
|
194
|
+
endedAt: zod_1.z.string().nullable().optional(),
|
|
195
|
+
error: zod_1.z.string().nullable().optional(),
|
|
196
|
+
});
|
|
197
|
+
exports.SseVoiceSessionEventPayloadSchema = zod_1.z.object({
|
|
198
|
+
conversationId: zod_1.z.string(),
|
|
199
|
+
session: exports.SseVoiceSessionSchema,
|
|
200
|
+
});
|
|
201
|
+
// ── Envelope + registry ────────────────────────────────────────────────
|
|
202
|
+
/**
|
|
203
|
+
* Every SSE `event:` name stream-service emits today (stream.ts + listeners.ts;
|
|
204
|
+
* mirrored by CanonStream's dispatch switch in core). NOTE: `contact.updated`
|
|
205
|
+
* is emitted by stream-service but not yet consumed by CanonStream.
|
|
206
|
+
*/
|
|
207
|
+
exports.SSE_EVENT_TYPES = [
|
|
208
|
+
'connected',
|
|
209
|
+
'agent.context',
|
|
210
|
+
'heartbeat',
|
|
211
|
+
'message.created',
|
|
212
|
+
'message.updated',
|
|
213
|
+
'message.deleted',
|
|
214
|
+
'conversation.updated',
|
|
215
|
+
'contact.request',
|
|
216
|
+
'contact.approved',
|
|
217
|
+
'contact.added',
|
|
218
|
+
'contact.updated',
|
|
219
|
+
'contact.removed',
|
|
220
|
+
'typing',
|
|
221
|
+
'presence',
|
|
222
|
+
'runtime.updated',
|
|
223
|
+
'turn.updated',
|
|
224
|
+
'runtime.control',
|
|
225
|
+
'voice.session.started',
|
|
226
|
+
'voice.session.ended',
|
|
227
|
+
'replay.expired',
|
|
228
|
+
'error',
|
|
229
|
+
];
|
|
230
|
+
exports.SseEventTypeSchema = zod_1.z.enum(exports.SSE_EVENT_TYPES);
|
|
231
|
+
/** Payload schema for every event type — the machine-readable event registry. */
|
|
232
|
+
exports.SSE_EVENT_PAYLOAD_SCHEMAS = {
|
|
233
|
+
'connected': exports.SseConnectedPayloadSchema,
|
|
234
|
+
'agent.context': exports.SseAgentContextPayloadSchema,
|
|
235
|
+
'heartbeat': exports.SseHeartbeatPayloadSchema,
|
|
236
|
+
'message.created': exports.SseMessageCreatedPayloadSchema,
|
|
237
|
+
'message.updated': exports.SseMessageUpdatedPayloadSchema,
|
|
238
|
+
'message.deleted': exports.SseMessageDeletedPayloadSchema,
|
|
239
|
+
'conversation.updated': exports.SseConversationUpdatedPayloadSchema,
|
|
240
|
+
'contact.request': exports.SseContactRequestPayloadSchema,
|
|
241
|
+
'contact.approved': exports.SseContactRequestPayloadSchema,
|
|
242
|
+
'contact.added': exports.SseContactPayloadSchema,
|
|
243
|
+
'contact.updated': exports.SseContactPayloadSchema,
|
|
244
|
+
'contact.removed': exports.SseContactRemovedPayloadSchema,
|
|
245
|
+
'typing': exports.SseTypingPayloadSchema,
|
|
246
|
+
'presence': exports.SsePresencePayloadSchema,
|
|
247
|
+
'runtime.updated': exports.SseRuntimeUpdatedPayloadSchema,
|
|
248
|
+
'turn.updated': exports.SseTurnUpdatedPayloadSchema,
|
|
249
|
+
'runtime.control': exports.SseRuntimeControlPayloadSchema,
|
|
250
|
+
'voice.session.started': exports.SseVoiceSessionEventPayloadSchema,
|
|
251
|
+
'voice.session.ended': exports.SseVoiceSessionEventPayloadSchema,
|
|
252
|
+
'replay.expired': exports.SseReplayExpiredPayloadSchema,
|
|
253
|
+
'error': exports.SseErrorPayloadSchema,
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Subscription families (`?events=` filter). Lifecycle events (`connected`,
|
|
257
|
+
* `agent.context`, `heartbeat`, `replay.expired`, `error`) are always sent.
|
|
258
|
+
*/
|
|
259
|
+
exports.SSE_EVENT_FAMILIES = [
|
|
260
|
+
'messages',
|
|
261
|
+
'contacts',
|
|
262
|
+
'typing_presence',
|
|
263
|
+
'runtime_turn',
|
|
264
|
+
'voice',
|
|
265
|
+
];
|
|
266
|
+
exports.SseEventFamilySchema = zod_1.z.enum(exports.SSE_EVENT_FAMILIES);
|
|
267
|
+
exports.SSE_EVENT_FAMILY_BY_TYPE = {
|
|
268
|
+
'connected': 'lifecycle',
|
|
269
|
+
'agent.context': 'lifecycle',
|
|
270
|
+
'heartbeat': 'lifecycle',
|
|
271
|
+
'message.created': 'messages',
|
|
272
|
+
'message.updated': 'messages',
|
|
273
|
+
'message.deleted': 'messages',
|
|
274
|
+
'conversation.updated': 'messages',
|
|
275
|
+
'contact.request': 'contacts',
|
|
276
|
+
'contact.approved': 'contacts',
|
|
277
|
+
'contact.added': 'contacts',
|
|
278
|
+
'contact.updated': 'contacts',
|
|
279
|
+
'contact.removed': 'contacts',
|
|
280
|
+
'typing': 'typing_presence',
|
|
281
|
+
'presence': 'typing_presence',
|
|
282
|
+
'runtime.updated': 'runtime_turn',
|
|
283
|
+
'turn.updated': 'runtime_turn',
|
|
284
|
+
'runtime.control': 'runtime_turn',
|
|
285
|
+
'voice.session.started': 'voice',
|
|
286
|
+
'voice.session.ended': 'voice',
|
|
287
|
+
'replay.expired': 'lifecycle',
|
|
288
|
+
'error': 'lifecycle',
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* A parsed SSE frame: `id:` (replay cursor), `event:`, and the JSON-decoded
|
|
292
|
+
* `data:` payload. Validate `data` with SSE_EVENT_PAYLOAD_SCHEMAS[event].
|
|
293
|
+
*/
|
|
294
|
+
exports.SseEventEnvelopeSchema = zod_1.z.object({
|
|
295
|
+
id: zod_1.z.string().optional(),
|
|
296
|
+
event: exports.SseEventTypeSchema,
|
|
297
|
+
data: zod_1.z.unknown(),
|
|
298
|
+
});
|
package/dist/cjs/turnProtocol.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WAITING_INPUT_STALE_THRESHOLD_MS = exports.ACTIVE_TURN_STALE_THRESHOLD_MS = void 0;
|
|
3
|
+
exports.WAITING_INPUT_STALE_THRESHOLD_MS = exports.ACTIVE_TURN_STALE_THRESHOLD_MS = exports.TurnStateLikeSchema = exports.TriggerDecisionSchema = exports.TurnMetadataSchema = exports.InboundDispositionSchema = exports.DeliveryIntentSchema = exports.TurnMessageSemanticsSchema = exports.TurnLifecycleStateSchema = exports.SenderTypeSchema = void 0;
|
|
4
4
|
exports.normalizeTurnMetadata = normalizeTurnMetadata;
|
|
5
5
|
exports.isTurnOpen = isTurnOpen;
|
|
6
6
|
exports.getTurnStateStaleThresholdMs = getTurnStateStaleThresholdMs;
|
|
@@ -9,6 +9,46 @@ exports.resolveTurnMessageSemantics = resolveTurnMessageSemantics;
|
|
|
9
9
|
exports.shouldPromoteConversationMessage = shouldPromoteConversationMessage;
|
|
10
10
|
exports.shouldTriggerAgentTurn = shouldTriggerAgentTurn;
|
|
11
11
|
exports.normalizeRuntimeTurnState = normalizeRuntimeTurnState;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
exports.SenderTypeSchema = zod_1.z.enum(['human', 'ai_agent']);
|
|
14
|
+
exports.TurnLifecycleStateSchema = zod_1.z.enum([
|
|
15
|
+
'idle',
|
|
16
|
+
'thinking',
|
|
17
|
+
'streaming',
|
|
18
|
+
'tool',
|
|
19
|
+
'waiting_input',
|
|
20
|
+
'completed',
|
|
21
|
+
'interrupted',
|
|
22
|
+
]);
|
|
23
|
+
exports.TurnMessageSemanticsSchema = zod_1.z.enum(['progress', 'turn_complete', 'control']);
|
|
24
|
+
exports.DeliveryIntentSchema = zod_1.z.enum(['queue', 'interrupt', 'interleave', 'stop']);
|
|
25
|
+
exports.InboundDispositionSchema = zod_1.z.enum([
|
|
26
|
+
'queued',
|
|
27
|
+
'accepted_now',
|
|
28
|
+
'interleaved',
|
|
29
|
+
'trigger_suppressed',
|
|
30
|
+
'rejected',
|
|
31
|
+
'cancelled',
|
|
32
|
+
]);
|
|
33
|
+
exports.TurnMetadataSchema = zod_1.z.object({
|
|
34
|
+
turnId: zod_1.z.string().nullable().optional(),
|
|
35
|
+
turnSemantics: exports.TurnMessageSemanticsSchema.optional(),
|
|
36
|
+
deliveryIntent: exports.DeliveryIntentSchema.optional(),
|
|
37
|
+
replyBehavior: zod_1.z.enum(['allow_auto_reply', 'suppress_auto_reply']).optional(),
|
|
38
|
+
inboundDisposition: exports.InboundDispositionSchema.optional(),
|
|
39
|
+
requestedTurnMode: zod_1.z.string().optional(),
|
|
40
|
+
});
|
|
41
|
+
exports.TriggerDecisionSchema = zod_1.z.object({
|
|
42
|
+
allow: zod_1.z.boolean(),
|
|
43
|
+
semantics: exports.TurnMessageSemanticsSchema,
|
|
44
|
+
reason: zod_1.z.string(),
|
|
45
|
+
});
|
|
46
|
+
exports.TurnStateLikeSchema = zod_1.z.object({
|
|
47
|
+
state: exports.TurnLifecycleStateSchema,
|
|
48
|
+
openedAt: zod_1.z.number().optional(),
|
|
49
|
+
updatedAt: zod_1.z.number().optional(),
|
|
50
|
+
turnUpdatedAt: zod_1.z.number().nullable().optional(),
|
|
51
|
+
});
|
|
12
52
|
exports.ACTIVE_TURN_STALE_THRESHOLD_MS = 30 * 60 * 1000;
|
|
13
53
|
exports.WAITING_INPUT_STALE_THRESHOLD_MS = 12 * 60 * 60 * 1000;
|
|
14
54
|
const TURN_SEMANTICS = [
|
package/dist/contactRequest.d.ts
CHANGED
|
@@ -1,24 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SerializedContactRequestStatusSchema: z.ZodEnum<{
|
|
3
|
+
rejected: "rejected";
|
|
4
|
+
pending: "pending";
|
|
5
|
+
approved: "approved";
|
|
6
|
+
expired: "expired";
|
|
7
|
+
}>;
|
|
8
|
+
export type SerializedContactRequestStatus = z.infer<typeof SerializedContactRequestStatusSchema>;
|
|
9
|
+
export declare const SerializedContactRequestSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
requesterId: z.ZodString;
|
|
12
|
+
requesterName: z.ZodString;
|
|
13
|
+
requesterAvatarUrl: z.ZodNullable<z.ZodString>;
|
|
14
|
+
targetId: z.ZodString;
|
|
15
|
+
targetName: z.ZodString;
|
|
16
|
+
targetAvatarUrl: z.ZodNullable<z.ZodString>;
|
|
17
|
+
targetUserType: z.ZodEnum<{
|
|
18
|
+
human: "human";
|
|
19
|
+
ai_agent: "ai_agent";
|
|
20
|
+
}>;
|
|
21
|
+
targetOwnerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
approverId: z.ZodString;
|
|
23
|
+
message: z.ZodNullable<z.ZodString>;
|
|
24
|
+
status: z.ZodEnum<{
|
|
25
|
+
rejected: "rejected";
|
|
26
|
+
pending: "pending";
|
|
27
|
+
approved: "approved";
|
|
28
|
+
expired: "expired";
|
|
29
|
+
}>;
|
|
30
|
+
kind: z.ZodEnum<{
|
|
31
|
+
dm: "dm";
|
|
32
|
+
group_invite: "group_invite";
|
|
33
|
+
}>;
|
|
34
|
+
groupContext: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
conversationId: z.ZodString;
|
|
36
|
+
groupName: z.ZodNullable<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
39
|
+
resolvedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type SerializedContactRequest = z.infer<typeof SerializedContactRequestSchema>;
|
|
24
43
|
export declare function serializeContactRequest(requestId: string, data: Record<string, unknown>): SerializedContactRequest | null;
|
package/dist/contactRequest.js
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const SerializedContactRequestStatusSchema = z.enum([
|
|
3
|
+
'pending',
|
|
4
|
+
'approved',
|
|
5
|
+
'rejected',
|
|
6
|
+
'expired',
|
|
7
|
+
]);
|
|
8
|
+
export const SerializedContactRequestSchema = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
requesterId: z.string(),
|
|
11
|
+
requesterName: z.string(),
|
|
12
|
+
requesterAvatarUrl: z.string().nullable(),
|
|
13
|
+
targetId: z.string(),
|
|
14
|
+
targetName: z.string(),
|
|
15
|
+
targetAvatarUrl: z.string().nullable(),
|
|
16
|
+
targetUserType: z.enum(['human', 'ai_agent']),
|
|
17
|
+
targetOwnerId: z.string().nullable().optional(),
|
|
18
|
+
approverId: z.string(),
|
|
19
|
+
message: z.string().nullable(),
|
|
20
|
+
status: SerializedContactRequestStatusSchema,
|
|
21
|
+
kind: z.enum(['dm', 'group_invite']),
|
|
22
|
+
groupContext: z.object({
|
|
23
|
+
conversationId: z.string(),
|
|
24
|
+
groupName: z.string().nullable(),
|
|
25
|
+
}).optional(),
|
|
26
|
+
createdAt: z.string().nullable(),
|
|
27
|
+
resolvedAt: z.string().nullable().optional(),
|
|
28
|
+
expiresAt: z.string().nullable().optional(),
|
|
29
|
+
});
|
|
1
30
|
function isRecord(value) {
|
|
2
31
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
3
32
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Wire contract v1 — RTDB control-channel signal + session-control records.
|
|
2
|
+
//
|
|
3
|
+
// Grounded in @canonmsg/core's ControlChannelPoller (the consumer every host
|
|
4
|
+
// uses for `/control/{conversationId}/{agentId}` reads) and stream-service's
|
|
5
|
+
// `runtime.control` mirror. Three channel keys, read in order:
|
|
6
|
+
// session — human changed a runtime control (model/effort/permission …)
|
|
7
|
+
// signal — interrupt / stop_and_drop / new_session
|
|
8
|
+
// primitive — keyed request map (requestId → value)
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export const ControlSignalTypeSchema = z.enum(['interrupt', 'stop_and_drop', 'new_session']);
|
|
11
|
+
export const ControlChannelKeySchema = z.enum(['session', 'signal', 'primitive']);
|
|
12
|
+
// ── RTDB node records (what is written at /control/{convo}/{agent}/…) ──
|
|
13
|
+
/** `/control/{convo}/{agent}/signal` node. Consumed by writing null. */
|
|
14
|
+
export const ControlSignalNodeSchema = z.looseObject({
|
|
15
|
+
type: ControlSignalTypeSchema,
|
|
16
|
+
updatedAt: z.number().optional(),
|
|
17
|
+
});
|
|
18
|
+
/** `/control/{convo}/{agent}/session` node — the session-control primitive record. */
|
|
19
|
+
export const ControlSessionNodeSchema = z.looseObject({
|
|
20
|
+
updatedAt: z.number().optional(),
|
|
21
|
+
});
|
|
22
|
+
/** `/control/{convo}/{agent}/primitive` — map of requestId → request value. */
|
|
23
|
+
export const ControlPrimitiveMapSchema = z.record(z.string(), z.record(z.string(), z.unknown()));
|
|
24
|
+
// ── Dispatched events (what a runtime's handler receives) ──────────────
|
|
25
|
+
export const ControlSignalEventSchema = z.object({
|
|
26
|
+
conversationId: z.string(),
|
|
27
|
+
type: ControlSignalTypeSchema,
|
|
28
|
+
updatedAt: z.number(),
|
|
29
|
+
raw: z.record(z.string(), z.unknown()),
|
|
30
|
+
});
|
|
31
|
+
export const ControlSessionEventSchema = z.object({
|
|
32
|
+
conversationId: z.string(),
|
|
33
|
+
updatedAt: z.number(),
|
|
34
|
+
control: z.record(z.string(), z.unknown()),
|
|
35
|
+
});
|
|
36
|
+
export const ControlPrimitiveEventSchema = z.object({
|
|
37
|
+
conversationId: z.string(),
|
|
38
|
+
requestId: z.string(),
|
|
39
|
+
updatedAt: z.number(),
|
|
40
|
+
value: z.record(z.string(), z.unknown()),
|
|
41
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export type CanonEndpointSection = 'identity' | 'messaging' | 'conversations' | 'contacts';
|
|
3
|
+
export interface CanonEndpointDescriptor {
|
|
4
|
+
method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
5
|
+
path: string;
|
|
6
|
+
section: CanonEndpointSection;
|
|
7
|
+
/** Public one-line contract note (rendered into docs/agents/contracts.md). */
|
|
8
|
+
note: string;
|
|
9
|
+
request?: z.ZodType;
|
|
10
|
+
response?: z.ZodType;
|
|
11
|
+
}
|
|
12
|
+
export declare const CANON_REST_ENDPOINTS: CanonEndpointDescriptor[];
|
|
13
|
+
export declare const CANON_MEDIA_UPLOAD_ENDPOINT: CanonEndpointDescriptor;
|