@canonmsg/backend-contracts 1.7.0 → 1.8.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 +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 +171 -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 +220 -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 -2
- 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 +496 -0
- package/dist/restEndpoints.js +217 -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 +127 -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.schema.json +115 -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 -1
- package/package.json +8 -5
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Wire contract v1 — request/response schemas for the agent-facing "Canon op"
|
|
2
|
+
// REST surface the bridge proxies (bridge-local-api.md §B).
|
|
3
|
+
//
|
|
4
|
+
// Grounded in the Functions handlers (functions/src/api/*) and the canonical
|
|
5
|
+
// consumer (@canonmsg/core CanonClient) — request bodies mirror what clients
|
|
6
|
+
// send today, response schemas mirror what the handlers emit. This is a
|
|
7
|
+
// re-expression of current behavior, not a redesign.
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { MediaAttachmentSchema } from './media.js';
|
|
10
|
+
import { SerializedContentTypeSchema, SerializedMessageSchema, SerializedReactionsSchema, } from './message.js';
|
|
11
|
+
import { InboundDispositionSchema } from './turnProtocol.js';
|
|
12
|
+
// ── Shared fragments ───────────────────────────────────────────────────
|
|
13
|
+
export const RestOkResponseSchema = z.looseObject({
|
|
14
|
+
success: z.boolean().optional(),
|
|
15
|
+
});
|
|
16
|
+
/** GET …/messages items — the serialized message plus the soft-delete flag. */
|
|
17
|
+
export const RestMessageSchema = SerializedMessageSchema.extend({
|
|
18
|
+
deleted: z.boolean().optional(),
|
|
19
|
+
});
|
|
20
|
+
export const RestConversationSchema = z.looseObject({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
type: z.enum(['direct', 'group']),
|
|
23
|
+
name: z.string().nullable().optional(),
|
|
24
|
+
topic: z.string().nullable().optional(),
|
|
25
|
+
memberIds: z.array(z.string()),
|
|
26
|
+
isAgentChat: z.boolean().optional(),
|
|
27
|
+
/** Resolved agent behavior policy — opaque pass-through. */
|
|
28
|
+
behavior: z.record(z.string(), z.unknown()).optional(),
|
|
29
|
+
hasUnread: z.boolean().optional(),
|
|
30
|
+
lastMessage: z.looseObject({
|
|
31
|
+
text: z.string(),
|
|
32
|
+
messageId: z.string().optional(),
|
|
33
|
+
senderId: z.string(),
|
|
34
|
+
senderType: z.enum(['human', 'ai_agent']),
|
|
35
|
+
contentType: SerializedContentTypeSchema.optional(),
|
|
36
|
+
timestamp: z.string(),
|
|
37
|
+
}).nullable(),
|
|
38
|
+
createdAt: z.string().optional(),
|
|
39
|
+
});
|
|
40
|
+
export const RestContactSchema = z.object({
|
|
41
|
+
id: z.string(),
|
|
42
|
+
source: z.string(),
|
|
43
|
+
addedAt: z.string().nullable(),
|
|
44
|
+
displayNameOverride: z.string().nullable(),
|
|
45
|
+
});
|
|
46
|
+
export const RestSessionSelectionSchema = z.union([
|
|
47
|
+
z.object({ mode: z.enum(['new', 'continue_latest', 'continue_or_create']) }),
|
|
48
|
+
z.object({ mode: z.literal('specific'), conversationId: z.string() }),
|
|
49
|
+
]);
|
|
50
|
+
// ── POST /messages/send ────────────────────────────────────────────────
|
|
51
|
+
export const SendMessageRequestSchema = z.object({
|
|
52
|
+
conversationId: z.string(),
|
|
53
|
+
text: z.string().optional(),
|
|
54
|
+
/** Client-supplied idempotency id. */
|
|
55
|
+
messageId: z.string().optional(),
|
|
56
|
+
contentType: SerializedContentTypeSchema.optional(),
|
|
57
|
+
replyTo: z.string().optional(),
|
|
58
|
+
replyToPosition: z.number().optional(),
|
|
59
|
+
attachments: z.array(MediaAttachmentSchema).optional(),
|
|
60
|
+
contactCardUserId: z.string().optional(),
|
|
61
|
+
mentions: z.array(z.string()).optional(),
|
|
62
|
+
selfContextId: z.string().nullable().optional(),
|
|
63
|
+
/** Structured metadata (turn protocol, approval cards, …). */
|
|
64
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
65
|
+
});
|
|
66
|
+
export const SendMessageResponseSchema = z.object({
|
|
67
|
+
messageId: z.string(),
|
|
68
|
+
});
|
|
69
|
+
// ── POST /messages/react ───────────────────────────────────────────────
|
|
70
|
+
export const ReactRequestSchema = z.object({
|
|
71
|
+
conversationId: z.string(),
|
|
72
|
+
messageId: z.string(),
|
|
73
|
+
emoji: z.string(),
|
|
74
|
+
});
|
|
75
|
+
export const ReactResponseSchema = z.object({
|
|
76
|
+
success: z.boolean(),
|
|
77
|
+
action: z.enum(['added', 'removed']),
|
|
78
|
+
reactions: SerializedReactionsSchema,
|
|
79
|
+
});
|
|
80
|
+
// ── POST /messages/forward ─────────────────────────────────────────────
|
|
81
|
+
export const ForwardMessageRequestSchema = z.object({
|
|
82
|
+
sourceConversationId: z.string(),
|
|
83
|
+
targetConversationId: z.string(),
|
|
84
|
+
messageId: z.string(),
|
|
85
|
+
text: z.string().optional(),
|
|
86
|
+
});
|
|
87
|
+
export const ForwardMessageResponseSchema = z.object({
|
|
88
|
+
messageId: z.string(),
|
|
89
|
+
targetConversationId: z.string(),
|
|
90
|
+
forwardedFrom: z.object({
|
|
91
|
+
sourceConversationId: z.string(),
|
|
92
|
+
messageId: z.string(),
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
// ── DELETE /conversations/:id/messages/:id, POST …/read, PATCH …/disposition ──
|
|
96
|
+
export const DeleteMessageResponseSchema = RestOkResponseSchema;
|
|
97
|
+
export const MarkReadResponseSchema = RestOkResponseSchema;
|
|
98
|
+
export const UpdateDispositionRequestSchema = z.object({
|
|
99
|
+
inboundDisposition: InboundDispositionSchema,
|
|
100
|
+
});
|
|
101
|
+
// ── GET /conversations + GET …/messages ────────────────────────────────
|
|
102
|
+
export const ConversationsResponseSchema = z.object({
|
|
103
|
+
conversations: z.array(RestConversationSchema),
|
|
104
|
+
});
|
|
105
|
+
/** Query params: limit, before, includeBehavior. */
|
|
106
|
+
export const GetMessagesQuerySchema = z.object({
|
|
107
|
+
limit: z.string().optional(),
|
|
108
|
+
before: z.string().optional(),
|
|
109
|
+
includeBehavior: z.string().optional(),
|
|
110
|
+
});
|
|
111
|
+
export const MessagesPageResponseSchema = z.looseObject({
|
|
112
|
+
messages: z.array(RestMessageSchema),
|
|
113
|
+
/** Present with includeBehavior=1. */
|
|
114
|
+
behavior: z.record(z.string(), z.unknown()).optional(),
|
|
115
|
+
activeSelfContextIdByMessageId: z.record(z.string(), z.string()).optional(),
|
|
116
|
+
selfContexts: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
117
|
+
});
|
|
118
|
+
// ── POST /conversations/create ─────────────────────────────────────────
|
|
119
|
+
export const CreateConversationRequestSchema = z.object({
|
|
120
|
+
type: z.enum(['direct', 'group']),
|
|
121
|
+
targetUserId: z.string().optional(),
|
|
122
|
+
memberIds: z.array(z.string()).optional(),
|
|
123
|
+
name: z.string().optional(),
|
|
124
|
+
/** Initial session config for first-party coding agents — opaque pass-through. */
|
|
125
|
+
sessionConfig: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
126
|
+
sessionSelection: RestSessionSelectionSchema.optional(),
|
|
127
|
+
});
|
|
128
|
+
export const CreateConversationResponseSchema = z.object({
|
|
129
|
+
conversationId: z.string(),
|
|
130
|
+
created: z.boolean().optional(),
|
|
131
|
+
reused: z.boolean().optional(),
|
|
132
|
+
sessionSelection: z.enum(['new', 'continue_latest', 'continue_or_create', 'specific']).optional(),
|
|
133
|
+
});
|
|
134
|
+
// ── Contacts / admission ───────────────────────────────────────────────
|
|
135
|
+
export const CreateContactRequestRequestSchema = z.object({
|
|
136
|
+
targetId: z.string(),
|
|
137
|
+
message: z.string().optional(),
|
|
138
|
+
});
|
|
139
|
+
export const CreateContactRequestResponseSchema = z.union([
|
|
140
|
+
z.looseObject({ status: z.literal('open') }),
|
|
141
|
+
z.looseObject({ status: z.enum(['created', 'duplicate']), requestId: z.string() }),
|
|
142
|
+
/** Legacy "already a contact" body. */
|
|
143
|
+
z.looseObject({ message: z.string() }),
|
|
144
|
+
]);
|
|
145
|
+
export const ContactsResponseSchema = z.object({
|
|
146
|
+
contacts: z.array(RestContactSchema),
|
|
147
|
+
});
|
|
148
|
+
export const ResolveAdmissionRequestSchema = z.union([
|
|
149
|
+
z.object({ targetUserId: z.string() }),
|
|
150
|
+
z.object({ canonContactId: z.string() }),
|
|
151
|
+
]);
|
|
152
|
+
export const ResolveAdmissionResponseSchema = z.looseObject({
|
|
153
|
+
resolvedTargetUserId: z.string().nullable().optional(),
|
|
154
|
+
target: z.looseObject({
|
|
155
|
+
id: z.string(),
|
|
156
|
+
canonContactId: z.string().optional(),
|
|
157
|
+
displayName: z.string().optional(),
|
|
158
|
+
avatarUrl: z.string().nullable().optional(),
|
|
159
|
+
about: z.string().optional(),
|
|
160
|
+
userType: z.enum(['human', 'ai_agent']).optional(),
|
|
161
|
+
discoverable: z.boolean().optional(),
|
|
162
|
+
inboundPolicy: z.enum(['open', 'approval-required', 'owner-only']).optional(),
|
|
163
|
+
groupJoinPolicy: z.enum(['open', 'approval-required', 'owner-only']).optional(),
|
|
164
|
+
}).nullable(),
|
|
165
|
+
admission: z.looseObject({
|
|
166
|
+
state: z.enum([
|
|
167
|
+
'self',
|
|
168
|
+
'not-found',
|
|
169
|
+
'allowed',
|
|
170
|
+
'request-required',
|
|
171
|
+
'pending-outbound',
|
|
172
|
+
'blocked',
|
|
173
|
+
'inactive',
|
|
174
|
+
'owner-only',
|
|
175
|
+
]),
|
|
176
|
+
canMessage: z.boolean(),
|
|
177
|
+
canRequestContact: z.boolean(),
|
|
178
|
+
isContact: z.boolean(),
|
|
179
|
+
pendingRequestId: z.string().optional(),
|
|
180
|
+
blockedByViewer: z.boolean().optional(),
|
|
181
|
+
blockedByTarget: z.boolean().optional(),
|
|
182
|
+
}),
|
|
183
|
+
});
|
|
184
|
+
// ── Typing / streaming ─────────────────────────────────────────────────
|
|
185
|
+
export const SetTypingRequestSchema = z.object({
|
|
186
|
+
conversationId: z.string(),
|
|
187
|
+
typing: z.boolean(),
|
|
188
|
+
status: z.enum(['thinking', 'typing']).optional(),
|
|
189
|
+
});
|
|
190
|
+
/** POST /streaming — the legacy REST facade over the RTDB streaming bubble. */
|
|
191
|
+
export const SetStreamingRequestSchema = z.union([
|
|
192
|
+
z.object({
|
|
193
|
+
conversationId: z.string(),
|
|
194
|
+
text: z.string(),
|
|
195
|
+
status: z.string(),
|
|
196
|
+
messageId: z.string(),
|
|
197
|
+
turnId: z.string().nullable().optional(),
|
|
198
|
+
/** TurnOutputBlock[] — opaque pass-through. */
|
|
199
|
+
blocks: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
200
|
+
}),
|
|
201
|
+
z.object({
|
|
202
|
+
conversationId: z.string(),
|
|
203
|
+
streaming: z.literal(false),
|
|
204
|
+
}),
|
|
205
|
+
]);
|
|
206
|
+
// ── Media upload ───────────────────────────────────────────────────────
|
|
207
|
+
export const UploadMediaRequestSchema = z.object({
|
|
208
|
+
conversationId: z.string(),
|
|
209
|
+
mimeType: z.string(),
|
|
210
|
+
/** Base64-encoded file content. */
|
|
211
|
+
data: z.string(),
|
|
212
|
+
fileName: z.string().optional(),
|
|
213
|
+
});
|
|
214
|
+
export const UploadMediaResponseSchema = z.object({
|
|
215
|
+
url: z.string(),
|
|
216
|
+
attachment: MediaAttachmentSchema,
|
|
217
|
+
});
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RuntimeCardFieldTypeSchema: z.ZodEnum<{
|
|
3
|
+
number: "number";
|
|
4
|
+
boolean: "boolean";
|
|
5
|
+
date: "date";
|
|
6
|
+
text: "text";
|
|
7
|
+
textarea: "textarea";
|
|
8
|
+
select: "select";
|
|
9
|
+
multiSelect: "multiSelect";
|
|
10
|
+
currency: "currency";
|
|
11
|
+
searchSelect: "searchSelect";
|
|
12
|
+
lineItems: "lineItems";
|
|
13
|
+
}>;
|
|
14
|
+
export type RuntimeCardFieldType = z.infer<typeof RuntimeCardFieldTypeSchema>;
|
|
2
15
|
/**
|
|
3
16
|
* Caps shared across runtime-card normalizers, response validation, and
|
|
4
17
|
* authoring tools. Keep these backend-safe so Functions can import them.
|
|
@@ -9,44 +22,104 @@ export declare const RUNTIME_CARD_LIMITS: {
|
|
|
9
22
|
readonly lineItemColumns: 8;
|
|
10
23
|
readonly searchSelectChoices: 100;
|
|
11
24
|
};
|
|
12
|
-
export
|
|
13
|
-
label:
|
|
14
|
-
value
|
|
15
|
-
description
|
|
16
|
-
preview
|
|
17
|
-
}
|
|
18
|
-
export type
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
choices
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
25
|
+
export declare const RuntimeCardFieldChoiceSchema: z.ZodObject<{
|
|
26
|
+
label: z.ZodString;
|
|
27
|
+
value: z.ZodOptional<z.ZodString>;
|
|
28
|
+
description: z.ZodOptional<z.ZodString>;
|
|
29
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type RuntimeCardFieldChoice = z.infer<typeof RuntimeCardFieldChoiceSchema>;
|
|
32
|
+
export declare const RuntimeCardLineItemColumnTypeSchema: z.ZodEnum<{
|
|
33
|
+
number: "number";
|
|
34
|
+
date: "date";
|
|
35
|
+
text: "text";
|
|
36
|
+
select: "select";
|
|
37
|
+
currency: "currency";
|
|
38
|
+
}>;
|
|
39
|
+
export type RuntimeCardLineItemColumnType = z.infer<typeof RuntimeCardLineItemColumnTypeSchema>;
|
|
40
|
+
export declare const RuntimeCardLineItemColumnSchema: z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
label: z.ZodString;
|
|
43
|
+
type: z.ZodEnum<{
|
|
44
|
+
number: "number";
|
|
45
|
+
date: "date";
|
|
46
|
+
text: "text";
|
|
47
|
+
select: "select";
|
|
48
|
+
currency: "currency";
|
|
49
|
+
}>;
|
|
50
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
52
|
+
label: z.ZodString;
|
|
53
|
+
value: z.ZodOptional<z.ZodString>;
|
|
54
|
+
description: z.ZodOptional<z.ZodString>;
|
|
55
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>>>;
|
|
57
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
precision: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
currencyCode: z.ZodOptional<z.ZodString>;
|
|
62
|
+
allowOther: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type RuntimeCardLineItemColumn = z.infer<typeof RuntimeCardLineItemColumnSchema>;
|
|
65
|
+
export declare const RuntimeCardFieldSchema: z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
label: z.ZodString;
|
|
68
|
+
type: z.ZodEnum<{
|
|
69
|
+
number: "number";
|
|
70
|
+
boolean: "boolean";
|
|
71
|
+
date: "date";
|
|
72
|
+
text: "text";
|
|
73
|
+
textarea: "textarea";
|
|
74
|
+
select: "select";
|
|
75
|
+
multiSelect: "multiSelect";
|
|
76
|
+
currency: "currency";
|
|
77
|
+
searchSelect: "searchSelect";
|
|
78
|
+
lineItems: "lineItems";
|
|
79
|
+
}>;
|
|
80
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
82
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
83
|
+
label: z.ZodString;
|
|
84
|
+
value: z.ZodOptional<z.ZodString>;
|
|
85
|
+
description: z.ZodOptional<z.ZodString>;
|
|
86
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>>>;
|
|
88
|
+
allowOther: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
sensitive: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
+
min: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
91
|
+
max: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
92
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
precision: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
currencyCode: z.ZodOptional<z.ZodString>;
|
|
95
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
96
|
+
id: z.ZodString;
|
|
97
|
+
label: z.ZodString;
|
|
98
|
+
type: z.ZodEnum<{
|
|
99
|
+
number: "number";
|
|
100
|
+
date: "date";
|
|
101
|
+
text: "text";
|
|
102
|
+
select: "select";
|
|
103
|
+
currency: "currency";
|
|
104
|
+
}>;
|
|
105
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
107
|
+
label: z.ZodString;
|
|
108
|
+
value: z.ZodOptional<z.ZodString>;
|
|
109
|
+
description: z.ZodOptional<z.ZodString>;
|
|
110
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>>>;
|
|
112
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
precision: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
currencyCode: z.ZodOptional<z.ZodString>;
|
|
117
|
+
allowOther: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
}, z.core.$strip>>>;
|
|
119
|
+
minRows: z.ZodOptional<z.ZodNumber>;
|
|
120
|
+
maxRows: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
export type RuntimeCardField = z.infer<typeof RuntimeCardFieldSchema>;
|
|
50
123
|
export declare function validateRuntimeCardFieldValues(input: {
|
|
51
124
|
actionId: string | undefined;
|
|
52
125
|
actionFields: ReadonlyArray<RuntimeCardField> | undefined;
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const RuntimeCardFieldTypeSchema = z.enum([
|
|
3
|
+
'text',
|
|
4
|
+
'textarea',
|
|
5
|
+
'select',
|
|
6
|
+
'multiSelect',
|
|
7
|
+
'boolean',
|
|
8
|
+
'date',
|
|
9
|
+
'number',
|
|
10
|
+
'currency',
|
|
11
|
+
'searchSelect',
|
|
12
|
+
'lineItems',
|
|
13
|
+
]);
|
|
1
14
|
/**
|
|
2
15
|
* Caps shared across runtime-card normalizers, response validation, and
|
|
3
16
|
* authoring tools. Keep these backend-safe so Functions can import them.
|
|
@@ -8,6 +21,50 @@ export const RUNTIME_CARD_LIMITS = {
|
|
|
8
21
|
lineItemColumns: 8,
|
|
9
22
|
searchSelectChoices: 100,
|
|
10
23
|
};
|
|
24
|
+
export const RuntimeCardFieldChoiceSchema = z.object({
|
|
25
|
+
label: z.string(),
|
|
26
|
+
value: z.string().optional(),
|
|
27
|
+
description: z.string().optional(),
|
|
28
|
+
preview: z.string().optional(),
|
|
29
|
+
});
|
|
30
|
+
export const RuntimeCardLineItemColumnTypeSchema = z.enum([
|
|
31
|
+
'text',
|
|
32
|
+
'number',
|
|
33
|
+
'currency',
|
|
34
|
+
'date',
|
|
35
|
+
'select',
|
|
36
|
+
]);
|
|
37
|
+
export const RuntimeCardLineItemColumnSchema = z.object({
|
|
38
|
+
id: z.string(),
|
|
39
|
+
label: z.string(),
|
|
40
|
+
type: RuntimeCardLineItemColumnTypeSchema,
|
|
41
|
+
required: z.boolean().optional(),
|
|
42
|
+
choices: z.array(RuntimeCardFieldChoiceSchema).optional(),
|
|
43
|
+
min: z.number().optional(),
|
|
44
|
+
max: z.number().optional(),
|
|
45
|
+
step: z.number().optional(),
|
|
46
|
+
precision: z.number().optional(),
|
|
47
|
+
currencyCode: z.string().optional(),
|
|
48
|
+
allowOther: z.boolean().optional(),
|
|
49
|
+
});
|
|
50
|
+
export const RuntimeCardFieldSchema = z.object({
|
|
51
|
+
id: z.string(),
|
|
52
|
+
label: z.string(),
|
|
53
|
+
type: RuntimeCardFieldTypeSchema,
|
|
54
|
+
required: z.boolean().optional(),
|
|
55
|
+
placeholder: z.string().optional(),
|
|
56
|
+
choices: z.array(RuntimeCardFieldChoiceSchema).optional(),
|
|
57
|
+
allowOther: z.boolean().optional(),
|
|
58
|
+
sensitive: z.boolean().optional(),
|
|
59
|
+
min: z.union([z.number(), z.string()]).optional(),
|
|
60
|
+
max: z.union([z.number(), z.string()]).optional(),
|
|
61
|
+
step: z.number().optional(),
|
|
62
|
+
precision: z.number().optional(),
|
|
63
|
+
currencyCode: z.string().optional(),
|
|
64
|
+
columns: z.array(RuntimeCardLineItemColumnSchema).optional(),
|
|
65
|
+
minRows: z.number().optional(),
|
|
66
|
+
maxRows: z.number().optional(),
|
|
67
|
+
});
|
|
11
68
|
const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
12
69
|
function isRecord(value) {
|
|
13
70
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "canon:AgentBehaviorSettingsRecordSchema",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"participationStyle": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"enum": [
|
|
9
|
+
"natural",
|
|
10
|
+
"collaborative",
|
|
11
|
+
"mention-first",
|
|
12
|
+
"approval-gated",
|
|
13
|
+
"handoff-only",
|
|
14
|
+
"observer"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"allowAgentToAgent": {
|
|
18
|
+
"type": "boolean"
|
|
19
|
+
},
|
|
20
|
+
"allowLongRunningCollaboration": {
|
|
21
|
+
"type": "boolean"
|
|
22
|
+
},
|
|
23
|
+
"requireMentionForGroupReplies": {
|
|
24
|
+
"type": "boolean"
|
|
25
|
+
},
|
|
26
|
+
"maxConsecutiveAgentTurns": {
|
|
27
|
+
"anyOf": [
|
|
28
|
+
{
|
|
29
|
+
"type": "number"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "null"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"instructions": {
|
|
37
|
+
"anyOf": [
|
|
38
|
+
{
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"type": "null"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"additionalProperties": false
|
|
48
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "canon:BridgeConnectionStateNotificationSchema",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"upstream": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"enum": [
|
|
9
|
+
"connected",
|
|
10
|
+
"reconnecting",
|
|
11
|
+
"down"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": [
|
|
16
|
+
"upstream"
|
|
17
|
+
],
|
|
18
|
+
"additionalProperties": false
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "canon:BridgeGetAttachmentParamsSchema",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"url": {
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"attachmentId": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"as": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"enum": [
|
|
15
|
+
"path",
|
|
16
|
+
"bytes"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"required": [
|
|
21
|
+
"as"
|
|
22
|
+
],
|
|
23
|
+
"additionalProperties": false
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "canon:BridgeGetAttachmentResultSchema",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"path": {
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"bytes": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"mime": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"required": [
|
|
17
|
+
"mime"
|
|
18
|
+
],
|
|
19
|
+
"additionalProperties": false
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "canon:BridgeHelloParamsSchema",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"protocolVersion": {
|
|
7
|
+
"type": "number"
|
|
8
|
+
},
|
|
9
|
+
"clientType": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"wantFamilies": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"items": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": [
|
|
17
|
+
"messages",
|
|
18
|
+
"contacts",
|
|
19
|
+
"typing_presence",
|
|
20
|
+
"runtime_turn",
|
|
21
|
+
"voice"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"resumeCursor": {
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"runtimeDescriptor": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"propertyNames": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
},
|
|
33
|
+
"additionalProperties": {}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": [
|
|
37
|
+
"protocolVersion",
|
|
38
|
+
"clientType",
|
|
39
|
+
"wantFamilies"
|
|
40
|
+
],
|
|
41
|
+
"additionalProperties": false
|
|
42
|
+
}
|