@canonmsg/backend-contracts 1.8.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -1729
- package/dist/bridgeLocal.js +0 -673
- package/dist/cjs/bridgeLocal.js +0 -676
- package/dist/cjs/controlSignals.js +0 -44
- package/dist/cjs/endpointRegistry.js +0 -264
- package/dist/cjs/hitl.js +0 -0
- 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 -298
- 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-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-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 -42
- package/dist/schemas/sse-event-family.schema.json +0 -12
- package/dist/schemas/sse-event-type.schema.json +0 -28
- 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-runtime-updated-payload.schema.json +0 -78
- package/dist/schemas/sse-self-context.schema.json +0 -45
- package/dist/schemas/sse-turn-dispatch.schema.json +0 -29
- package/dist/schemas/sse-turn-updated-payload.schema.json +0 -33
- 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 -494
- package/dist/sseEvents.js +0 -295
package/dist/hitl.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
// Wire contract v1 — HITL (human-in-the-loop) request / resolution records.
|
|
2
|
-
//
|
|
3
|
-
// HITL is durable state, not a held request (bridge-local-api.md): the pending
|
|
4
|
-
// request is a persisted record (message metadata + RTDB node with expiresAt),
|
|
5
|
-
// and the resolution arrives later. These schemas ground the three record
|
|
6
|
-
// families as core's hosts publish/consume them today:
|
|
7
|
-
// approval — approval_request / approval_reply / approval_outcome
|
|
8
|
-
// input — runtime_input_request / runtime_input_reply / runtime_input_outcome
|
|
9
|
-
// card — runtime_card_request / runtime_card_reply / runtime_card_outcome
|
|
10
|
-
// plus the unified bridge-level resolution record (§C6 onHitlResolved).
|
|
11
|
-
import { z } from 'zod';
|
|
12
|
-
import { RuntimeCardFieldChoiceSchema } from './runtimeCardFields.js';
|
|
13
|
-
export const HitlRequestKindSchema = z.enum(['approval', 'input', 'card']);
|
|
14
|
-
export const HitlResolutionStatusSchema = z.enum(['submitted', 'cancelled', 'timeout']);
|
|
15
|
-
// ── Approval records ───────────────────────────────────────────────────
|
|
16
|
-
export const HitlApprovalRiskSchema = z.enum(['low', 'normal', 'high', 'destructive']);
|
|
17
|
-
export const HitlApprovalCategorySchema = z.enum([
|
|
18
|
-
'command',
|
|
19
|
-
'file',
|
|
20
|
-
'network',
|
|
21
|
-
'browser',
|
|
22
|
-
'mcp',
|
|
23
|
-
'plugin',
|
|
24
|
-
'canon',
|
|
25
|
-
'tool',
|
|
26
|
-
]);
|
|
27
|
-
export const HitlApprovalDetailSchema = z.object({
|
|
28
|
-
label: z.string(),
|
|
29
|
-
value: z.string(),
|
|
30
|
-
monospace: z.boolean().optional(),
|
|
31
|
-
});
|
|
32
|
-
export const HitlSessionRuleSchema = z.object({
|
|
33
|
-
type: z.enum(['approve-all', 'approve-tool', 'deny-tool']),
|
|
34
|
-
toolPattern: z.string().optional(),
|
|
35
|
-
expiresAt: z.string().nullable().optional(),
|
|
36
|
-
});
|
|
37
|
-
export const HitlApprovalRequestRecordSchema = z.looseObject({
|
|
38
|
-
type: z.literal('approval_request'),
|
|
39
|
-
approvalId: z.string(),
|
|
40
|
-
responseUserId: z.string().optional(),
|
|
41
|
-
toolName: z.string(),
|
|
42
|
-
/** Pre-computed, redacted summary — raw tool input is never stored. */
|
|
43
|
-
toolSummary: z.string(),
|
|
44
|
-
category: HitlApprovalCategorySchema.optional(),
|
|
45
|
-
risk: HitlApprovalRiskSchema.optional(),
|
|
46
|
-
riskLevel: z.enum(['normal', 'destructive']).optional(),
|
|
47
|
-
runtimeId: z.string().optional(),
|
|
48
|
-
turnId: z.string().optional(),
|
|
49
|
-
/** Native runtime correlation handles — opaque pass-through. */
|
|
50
|
-
native: z.record(z.string(), z.unknown()).optional(),
|
|
51
|
-
details: z.array(HitlApprovalDetailSchema).optional(),
|
|
52
|
-
/** File-change preview (CanonUnifiedDiff) — opaque pass-through. */
|
|
53
|
-
diff: z.record(z.string(), z.unknown()).optional(),
|
|
54
|
-
expiresAt: z.string(),
|
|
55
|
-
});
|
|
56
|
-
export const HitlApprovalReplyRecordSchema = z.looseObject({
|
|
57
|
-
type: z.literal('approval_reply'),
|
|
58
|
-
approvalId: z.string(),
|
|
59
|
-
decision: z.enum(['allow', 'deny']),
|
|
60
|
-
sessionRule: HitlSessionRuleSchema.optional(),
|
|
61
|
-
});
|
|
62
|
-
export const HitlApprovalOutcomeRecordSchema = z.looseObject({
|
|
63
|
-
type: z.literal('approval_outcome'),
|
|
64
|
-
approvalId: z.string().optional(),
|
|
65
|
-
decision: z.enum(['allow', 'deny']).optional(),
|
|
66
|
-
reason: z.enum(['replied', 'timeout', 'session-rule']).optional(),
|
|
67
|
-
});
|
|
68
|
-
// ── Input records ──────────────────────────────────────────────────────
|
|
69
|
-
export const HitlInputKindSchema = z.enum(['clarify', 'sudo', 'secret']);
|
|
70
|
-
export const HitlInputQuestionSchema = z.object({
|
|
71
|
-
id: z.string(),
|
|
72
|
-
question: z.string(),
|
|
73
|
-
header: z.string().optional(),
|
|
74
|
-
choices: z.array(RuntimeCardFieldChoiceSchema).optional(),
|
|
75
|
-
allowOther: z.boolean().optional(),
|
|
76
|
-
isSecret: z.boolean().optional(),
|
|
77
|
-
multiSelect: z.boolean().optional(),
|
|
78
|
-
});
|
|
79
|
-
/** questionId → selected/typed answers. */
|
|
80
|
-
export const HitlInputAnswersSchema = z.record(z.string(), z.object({ answers: z.array(z.string()) }));
|
|
81
|
-
export const HitlInputRequestRecordSchema = z.looseObject({
|
|
82
|
-
type: z.literal('runtime_input_request'),
|
|
83
|
-
inputId: z.string(),
|
|
84
|
-
responseUserId: z.string().optional(),
|
|
85
|
-
kind: HitlInputKindSchema,
|
|
86
|
-
prompt: z.string(),
|
|
87
|
-
title: z.string().optional(),
|
|
88
|
-
choices: z.array(RuntimeCardFieldChoiceSchema).optional(),
|
|
89
|
-
questions: z.array(HitlInputQuestionSchema).optional(),
|
|
90
|
-
secretName: z.string().optional(),
|
|
91
|
-
native: z.record(z.string(), z.unknown()).optional(),
|
|
92
|
-
expiresAt: z.string(),
|
|
93
|
-
sensitive: z.boolean().optional(),
|
|
94
|
-
});
|
|
95
|
-
export const HitlInputReplyRecordSchema = z.looseObject({
|
|
96
|
-
type: z.literal('runtime_input_reply'),
|
|
97
|
-
inputId: z.string(),
|
|
98
|
-
kind: HitlInputKindSchema.optional(),
|
|
99
|
-
status: z.enum(['submitted', 'cancelled']),
|
|
100
|
-
answerSummary: z.string().optional(),
|
|
101
|
-
answersSummary: z.string().optional(),
|
|
102
|
-
sensitive: z.boolean().optional(),
|
|
103
|
-
});
|
|
104
|
-
export const HitlInputOutcomeRecordSchema = z.looseObject({
|
|
105
|
-
type: z.literal('runtime_input_outcome'),
|
|
106
|
-
inputId: z.string(),
|
|
107
|
-
kind: HitlInputKindSchema.optional(),
|
|
108
|
-
status: HitlResolutionStatusSchema,
|
|
109
|
-
reason: z.enum(['submitted', 'cancelled', 'timeout', 'expired', 'interrupted']).optional(),
|
|
110
|
-
});
|
|
111
|
-
// ── Card records ───────────────────────────────────────────────────────
|
|
112
|
-
export const HitlCardRequestRecordSchema = z.looseObject({
|
|
113
|
-
type: z.literal('runtime_card_request'),
|
|
114
|
-
cardId: z.string(),
|
|
115
|
-
cardKind: z.string(),
|
|
116
|
-
schemaVersion: z.literal('canon.card.v1'),
|
|
117
|
-
fallbackText: z.string(),
|
|
118
|
-
responseUserId: z.string().optional(),
|
|
119
|
-
expiresAt: z.string(),
|
|
120
|
-
runtimeId: z.string().optional(),
|
|
121
|
-
turnId: z.string().optional(),
|
|
122
|
-
native: z.record(z.string(), z.unknown()).optional(),
|
|
123
|
-
/** True when the card carries an actions block (agent waits for a response). */
|
|
124
|
-
interactive: z.boolean().optional(),
|
|
125
|
-
/** RuntimeCardPreview — opaque pass-through. */
|
|
126
|
-
cardPreview: z.record(z.string(), z.unknown()),
|
|
127
|
-
turnSemantics: z.literal('control'),
|
|
128
|
-
replyBehavior: z.literal('suppress_auto_reply'),
|
|
129
|
-
});
|
|
130
|
-
export const HitlCardReplyRecordSchema = z.looseObject({
|
|
131
|
-
type: z.literal('runtime_card_reply'),
|
|
132
|
-
cardId: z.string(),
|
|
133
|
-
status: z.enum(['submitted', 'cancelled']),
|
|
134
|
-
actionId: z.string().optional(),
|
|
135
|
-
answerSummary: z.string().optional(),
|
|
136
|
-
sensitive: z.boolean().optional(),
|
|
137
|
-
turnSemantics: z.literal('control'),
|
|
138
|
-
replyBehavior: z.literal('suppress_auto_reply'),
|
|
139
|
-
});
|
|
140
|
-
export const HitlCardOutcomeRecordSchema = z.looseObject({
|
|
141
|
-
type: z.literal('runtime_card_outcome'),
|
|
142
|
-
cardId: z.string(),
|
|
143
|
-
status: HitlResolutionStatusSchema,
|
|
144
|
-
reason: z.enum(['submitted', 'cancelled', 'timeout', 'expired', 'interrupted']).optional(),
|
|
145
|
-
turnSemantics: z.literal('control'),
|
|
146
|
-
replyBehavior: z.literal('suppress_auto_reply'),
|
|
147
|
-
});
|
|
148
|
-
// ── Unified bridge-level records (bridge-local-api §B7/§C6) ────────────
|
|
149
|
-
/** Immediate result of requestApproval/requestInput/requestCard. */
|
|
150
|
-
export const HitlRequestAcceptedSchema = z.object({
|
|
151
|
-
requestId: z.string(),
|
|
152
|
-
expiresAt: z.string(),
|
|
153
|
-
});
|
|
154
|
-
/** `onHitlResolved` — matches an earlier requestId. */
|
|
155
|
-
export const HitlResolutionSchema = z.object({
|
|
156
|
-
requestId: z.string(),
|
|
157
|
-
kind: HitlRequestKindSchema.optional(),
|
|
158
|
-
status: HitlResolutionStatusSchema,
|
|
159
|
-
/** Kind-specific answer payload (decision / answers / card action values). */
|
|
160
|
-
answer: z.record(z.string(), z.unknown()).optional(),
|
|
161
|
-
});
|
|
162
|
-
/** `onHitlPending` — replayed on reconnect for still-open requests. */
|
|
163
|
-
export const HitlPendingSchema = z.object({
|
|
164
|
-
requestId: z.string(),
|
|
165
|
-
kind: HitlRequestKindSchema,
|
|
166
|
-
conversationId: z.string(),
|
|
167
|
-
expiresAt: z.string(),
|
|
168
|
-
});
|
package/dist/inboundFrame.d.ts
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const INBOUND_FRAME_SCHEMA_V1: "canon.inbound_frame.v1";
|
|
3
|
-
export declare const InboundFrameShapeV1Schema: z.ZodEnum<{
|
|
4
|
-
unknown: "unknown";
|
|
5
|
-
group: "group";
|
|
6
|
-
direct_owner: "direct_owner";
|
|
7
|
-
direct_human: "direct_human";
|
|
8
|
-
direct_agent: "direct_agent";
|
|
9
|
-
}>;
|
|
10
|
-
export type InboundFrameShapeV1 = z.infer<typeof InboundFrameShapeV1Schema>;
|
|
11
|
-
export declare const InboundFrameAttachmentV1Schema: z.ZodObject<{
|
|
12
|
-
index: z.ZodNumber;
|
|
13
|
-
kind: z.ZodEnum<{
|
|
14
|
-
file: "file";
|
|
15
|
-
image: "image";
|
|
16
|
-
audio: "audio";
|
|
17
|
-
video: "video";
|
|
18
|
-
}>;
|
|
19
|
-
placeholder: z.ZodString;
|
|
20
|
-
fileName: z.ZodNullable<z.ZodString>;
|
|
21
|
-
mimeType: z.ZodNullable<z.ZodString>;
|
|
22
|
-
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
23
|
-
width: z.ZodNullable<z.ZodNumber>;
|
|
24
|
-
height: z.ZodNullable<z.ZodNumber>;
|
|
25
|
-
durationMs: z.ZodNullable<z.ZodNumber>;
|
|
26
|
-
}, z.core.$strip>;
|
|
27
|
-
export type InboundFrameAttachmentV1 = z.infer<typeof InboundFrameAttachmentV1Schema>;
|
|
28
|
-
export declare const InboundFrameContactCardV1Schema: z.ZodObject<{
|
|
29
|
-
userId: z.ZodString;
|
|
30
|
-
canonContactId: z.ZodNullable<z.ZodString>;
|
|
31
|
-
displayName: z.ZodString;
|
|
32
|
-
userType: z.ZodEnum<{
|
|
33
|
-
human: "human";
|
|
34
|
-
ai_agent: "ai_agent";
|
|
35
|
-
}>;
|
|
36
|
-
ownerName: z.ZodNullable<z.ZodString>;
|
|
37
|
-
about: z.ZodNullable<z.ZodString>;
|
|
38
|
-
}, z.core.$strip>;
|
|
39
|
-
export type InboundFrameContactCardV1 = z.infer<typeof InboundFrameContactCardV1Schema>;
|
|
40
|
-
/** CanonTurnContextReplyContextV2 — the reply-to summary carried by the frame. */
|
|
41
|
-
export declare const InboundFrameReplyContextV1Schema: z.ZodObject<{
|
|
42
|
-
messageId: z.ZodString;
|
|
43
|
-
found: z.ZodBoolean;
|
|
44
|
-
senderId: z.ZodNullable<z.ZodString>;
|
|
45
|
-
senderName: z.ZodNullable<z.ZodString>;
|
|
46
|
-
senderType: z.ZodNullable<z.ZodEnum<{
|
|
47
|
-
human: "human";
|
|
48
|
-
ai_agent: "ai_agent";
|
|
49
|
-
}>>;
|
|
50
|
-
contentType: z.ZodNullable<z.ZodEnum<{
|
|
51
|
-
file: "file";
|
|
52
|
-
image: "image";
|
|
53
|
-
audio: "audio";
|
|
54
|
-
video: "video";
|
|
55
|
-
text: "text";
|
|
56
|
-
contact_card: "contact_card";
|
|
57
|
-
}>>;
|
|
58
|
-
text: z.ZodNullable<z.ZodString>;
|
|
59
|
-
body: z.ZodString;
|
|
60
|
-
replyToPosition: z.ZodNullable<z.ZodNumber>;
|
|
61
|
-
attachments: z.ZodArray<z.ZodObject<{
|
|
62
|
-
index: z.ZodNumber;
|
|
63
|
-
kind: z.ZodEnum<{
|
|
64
|
-
file: "file";
|
|
65
|
-
image: "image";
|
|
66
|
-
audio: "audio";
|
|
67
|
-
video: "video";
|
|
68
|
-
}>;
|
|
69
|
-
placeholder: z.ZodString;
|
|
70
|
-
fileName: z.ZodNullable<z.ZodString>;
|
|
71
|
-
mimeType: z.ZodNullable<z.ZodString>;
|
|
72
|
-
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
73
|
-
width: z.ZodNullable<z.ZodNumber>;
|
|
74
|
-
height: z.ZodNullable<z.ZodNumber>;
|
|
75
|
-
durationMs: z.ZodNullable<z.ZodNumber>;
|
|
76
|
-
}, z.core.$strip>>;
|
|
77
|
-
contactCard: z.ZodNullable<z.ZodObject<{
|
|
78
|
-
userId: z.ZodString;
|
|
79
|
-
canonContactId: z.ZodNullable<z.ZodString>;
|
|
80
|
-
displayName: z.ZodString;
|
|
81
|
-
userType: z.ZodEnum<{
|
|
82
|
-
human: "human";
|
|
83
|
-
ai_agent: "ai_agent";
|
|
84
|
-
}>;
|
|
85
|
-
ownerName: z.ZodNullable<z.ZodString>;
|
|
86
|
-
about: z.ZodNullable<z.ZodString>;
|
|
87
|
-
}, z.core.$strip>>;
|
|
88
|
-
}, z.core.$strip>;
|
|
89
|
-
export type InboundFrameReplyContextV1 = z.infer<typeof InboundFrameReplyContextV1Schema>;
|
|
90
|
-
export declare const InboundFrameGroupContextV1Schema: z.ZodObject<{
|
|
91
|
-
memberCount: z.ZodNumber;
|
|
92
|
-
memberIds: z.ZodArray<z.ZodString>;
|
|
93
|
-
ownerId: z.ZodString;
|
|
94
|
-
ownerName: z.ZodString;
|
|
95
|
-
ownerPresent: z.ZodBoolean;
|
|
96
|
-
knownRecentParticipants: z.ZodArray<z.ZodObject<{
|
|
97
|
-
id: z.ZodString;
|
|
98
|
-
name: z.ZodString;
|
|
99
|
-
userType: z.ZodEnum<{
|
|
100
|
-
human: "human";
|
|
101
|
-
ai_agent: "ai_agent";
|
|
102
|
-
unknown: "unknown";
|
|
103
|
-
}>;
|
|
104
|
-
isOwner: z.ZodBoolean;
|
|
105
|
-
isSelf: z.ZodBoolean;
|
|
106
|
-
}, z.core.$strip>>;
|
|
107
|
-
membershipChange: z.ZodOptional<z.ZodObject<{
|
|
108
|
-
addedMemberIds: z.ZodArray<z.ZodString>;
|
|
109
|
-
removedMemberIds: z.ZodArray<z.ZodString>;
|
|
110
|
-
memberCount: z.ZodNumber;
|
|
111
|
-
}, z.core.$strip>>;
|
|
112
|
-
}, z.core.$strip>;
|
|
113
|
-
export type InboundFrameGroupContextV1 = z.infer<typeof InboundFrameGroupContextV1Schema>;
|
|
114
|
-
export declare const InboundFrameV1Schema: z.ZodObject<{
|
|
115
|
-
schema: z.ZodLiteral<"canon.inbound_frame.v1">;
|
|
116
|
-
shape: z.ZodEnum<{
|
|
117
|
-
unknown: "unknown";
|
|
118
|
-
group: "group";
|
|
119
|
-
direct_owner: "direct_owner";
|
|
120
|
-
direct_human: "direct_human";
|
|
121
|
-
direct_agent: "direct_agent";
|
|
122
|
-
}>;
|
|
123
|
-
sender: z.ZodObject<{
|
|
124
|
-
name: z.ZodString;
|
|
125
|
-
type: z.ZodEnum<{
|
|
126
|
-
human: "human";
|
|
127
|
-
ai_agent: "ai_agent";
|
|
128
|
-
}>;
|
|
129
|
-
isOwner: z.ZodBoolean;
|
|
130
|
-
}, z.core.$strip>;
|
|
131
|
-
conversation: z.ZodObject<{
|
|
132
|
-
type: z.ZodEnum<{
|
|
133
|
-
unknown: "unknown";
|
|
134
|
-
direct: "direct";
|
|
135
|
-
group: "group";
|
|
136
|
-
}>;
|
|
137
|
-
memberCount: z.ZodNullable<z.ZodNumber>;
|
|
138
|
-
}, z.core.$strip>;
|
|
139
|
-
addressed: z.ZodBoolean;
|
|
140
|
-
message: z.ZodObject<{
|
|
141
|
-
text: z.ZodString;
|
|
142
|
-
contentType: z.ZodNullable<z.ZodEnum<{
|
|
143
|
-
file: "file";
|
|
144
|
-
image: "image";
|
|
145
|
-
audio: "audio";
|
|
146
|
-
video: "video";
|
|
147
|
-
text: "text";
|
|
148
|
-
contact_card: "contact_card";
|
|
149
|
-
}>>;
|
|
150
|
-
}, z.core.$strip>;
|
|
151
|
-
replyContext: z.ZodNullable<z.ZodObject<{
|
|
152
|
-
messageId: z.ZodString;
|
|
153
|
-
found: z.ZodBoolean;
|
|
154
|
-
senderId: z.ZodNullable<z.ZodString>;
|
|
155
|
-
senderName: z.ZodNullable<z.ZodString>;
|
|
156
|
-
senderType: z.ZodNullable<z.ZodEnum<{
|
|
157
|
-
human: "human";
|
|
158
|
-
ai_agent: "ai_agent";
|
|
159
|
-
}>>;
|
|
160
|
-
contentType: z.ZodNullable<z.ZodEnum<{
|
|
161
|
-
file: "file";
|
|
162
|
-
image: "image";
|
|
163
|
-
audio: "audio";
|
|
164
|
-
video: "video";
|
|
165
|
-
text: "text";
|
|
166
|
-
contact_card: "contact_card";
|
|
167
|
-
}>>;
|
|
168
|
-
text: z.ZodNullable<z.ZodString>;
|
|
169
|
-
body: z.ZodString;
|
|
170
|
-
replyToPosition: z.ZodNullable<z.ZodNumber>;
|
|
171
|
-
attachments: z.ZodArray<z.ZodObject<{
|
|
172
|
-
index: z.ZodNumber;
|
|
173
|
-
kind: z.ZodEnum<{
|
|
174
|
-
file: "file";
|
|
175
|
-
image: "image";
|
|
176
|
-
audio: "audio";
|
|
177
|
-
video: "video";
|
|
178
|
-
}>;
|
|
179
|
-
placeholder: z.ZodString;
|
|
180
|
-
fileName: z.ZodNullable<z.ZodString>;
|
|
181
|
-
mimeType: z.ZodNullable<z.ZodString>;
|
|
182
|
-
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
183
|
-
width: z.ZodNullable<z.ZodNumber>;
|
|
184
|
-
height: z.ZodNullable<z.ZodNumber>;
|
|
185
|
-
durationMs: z.ZodNullable<z.ZodNumber>;
|
|
186
|
-
}, z.core.$strip>>;
|
|
187
|
-
contactCard: z.ZodNullable<z.ZodObject<{
|
|
188
|
-
userId: z.ZodString;
|
|
189
|
-
canonContactId: z.ZodNullable<z.ZodString>;
|
|
190
|
-
displayName: z.ZodString;
|
|
191
|
-
userType: z.ZodEnum<{
|
|
192
|
-
human: "human";
|
|
193
|
-
ai_agent: "ai_agent";
|
|
194
|
-
}>;
|
|
195
|
-
ownerName: z.ZodNullable<z.ZodString>;
|
|
196
|
-
about: z.ZodNullable<z.ZodString>;
|
|
197
|
-
}, z.core.$strip>>;
|
|
198
|
-
}, z.core.$strip>>;
|
|
199
|
-
groupContext: z.ZodNullable<z.ZodObject<{
|
|
200
|
-
memberCount: z.ZodNumber;
|
|
201
|
-
memberIds: z.ZodArray<z.ZodString>;
|
|
202
|
-
ownerId: z.ZodString;
|
|
203
|
-
ownerName: z.ZodString;
|
|
204
|
-
ownerPresent: z.ZodBoolean;
|
|
205
|
-
knownRecentParticipants: z.ZodArray<z.ZodObject<{
|
|
206
|
-
id: z.ZodString;
|
|
207
|
-
name: z.ZodString;
|
|
208
|
-
userType: z.ZodEnum<{
|
|
209
|
-
human: "human";
|
|
210
|
-
ai_agent: "ai_agent";
|
|
211
|
-
unknown: "unknown";
|
|
212
|
-
}>;
|
|
213
|
-
isOwner: z.ZodBoolean;
|
|
214
|
-
isSelf: z.ZodBoolean;
|
|
215
|
-
}, z.core.$strip>>;
|
|
216
|
-
membershipChange: z.ZodOptional<z.ZodObject<{
|
|
217
|
-
addedMemberIds: z.ZodArray<z.ZodString>;
|
|
218
|
-
removedMemberIds: z.ZodArray<z.ZodString>;
|
|
219
|
-
memberCount: z.ZodNumber;
|
|
220
|
-
}, z.core.$strip>>;
|
|
221
|
-
}, z.core.$strip>>;
|
|
222
|
-
groupContextMode: z.ZodOptional<z.ZodEnum<{
|
|
223
|
-
initial: "initial";
|
|
224
|
-
membership_change: "membership_change";
|
|
225
|
-
}>>;
|
|
226
|
-
selfContexts: z.ZodArray<z.ZodString>;
|
|
227
|
-
behaviorInstructions: z.ZodArray<z.ZodString>;
|
|
228
|
-
}, z.core.$strip>;
|
|
229
|
-
export type InboundFrameV1 = z.infer<typeof InboundFrameV1Schema>;
|
package/dist/inboundFrame.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// Wire contract v1 — the canon.inbound_frame.v1 schema.
|
|
2
|
-
//
|
|
3
|
-
// Mirrors @canonmsg/core's CanonInboundFrameV1 (core/src/inbound-frame.ts),
|
|
4
|
-
// the structured projection every host/adapter renders its inbound prompt
|
|
5
|
-
// from. core keeps building the frame; a follow-up (post-P2 merge) flips core
|
|
6
|
-
// to infer its type from this schema. A compile-time assignability guard
|
|
7
|
-
// between core's type and this schema lives in @canonmsg/test-fixtures.
|
|
8
|
-
import { z } from 'zod';
|
|
9
|
-
import { SerializedContentTypeSchema } from './message.js';
|
|
10
|
-
import { SseMembershipChangeSchema } from './sseEvents.js';
|
|
11
|
-
export const INBOUND_FRAME_SCHEMA_V1 = 'canon.inbound_frame.v1';
|
|
12
|
-
export const InboundFrameShapeV1Schema = z.enum([
|
|
13
|
-
'direct_owner',
|
|
14
|
-
'direct_human',
|
|
15
|
-
'direct_agent',
|
|
16
|
-
'group',
|
|
17
|
-
'unknown',
|
|
18
|
-
]);
|
|
19
|
-
export const InboundFrameAttachmentV1Schema = z.object({
|
|
20
|
-
index: z.number(),
|
|
21
|
-
kind: z.enum(['image', 'audio', 'video', 'file']),
|
|
22
|
-
placeholder: z.string(),
|
|
23
|
-
fileName: z.string().nullable(),
|
|
24
|
-
mimeType: z.string().nullable(),
|
|
25
|
-
sizeBytes: z.number().nullable(),
|
|
26
|
-
width: z.number().nullable(),
|
|
27
|
-
height: z.number().nullable(),
|
|
28
|
-
durationMs: z.number().nullable(),
|
|
29
|
-
});
|
|
30
|
-
export const InboundFrameContactCardV1Schema = z.object({
|
|
31
|
-
userId: z.string(),
|
|
32
|
-
canonContactId: z.string().nullable(),
|
|
33
|
-
displayName: z.string(),
|
|
34
|
-
userType: z.enum(['human', 'ai_agent']),
|
|
35
|
-
ownerName: z.string().nullable(),
|
|
36
|
-
about: z.string().nullable(),
|
|
37
|
-
});
|
|
38
|
-
/** CanonTurnContextReplyContextV2 — the reply-to summary carried by the frame. */
|
|
39
|
-
export const InboundFrameReplyContextV1Schema = z.object({
|
|
40
|
-
messageId: z.string(),
|
|
41
|
-
found: z.boolean(),
|
|
42
|
-
senderId: z.string().nullable(),
|
|
43
|
-
senderName: z.string().nullable(),
|
|
44
|
-
senderType: z.enum(['human', 'ai_agent']).nullable(),
|
|
45
|
-
contentType: SerializedContentTypeSchema.nullable(),
|
|
46
|
-
text: z.string().nullable(),
|
|
47
|
-
body: z.string(),
|
|
48
|
-
replyToPosition: z.number().nullable(),
|
|
49
|
-
attachments: z.array(InboundFrameAttachmentV1Schema),
|
|
50
|
-
contactCard: InboundFrameContactCardV1Schema.nullable(),
|
|
51
|
-
});
|
|
52
|
-
export const InboundFrameGroupContextV1Schema = z.object({
|
|
53
|
-
memberCount: z.number(),
|
|
54
|
-
memberIds: z.array(z.string()),
|
|
55
|
-
ownerId: z.string(),
|
|
56
|
-
ownerName: z.string(),
|
|
57
|
-
ownerPresent: z.boolean(),
|
|
58
|
-
knownRecentParticipants: z.array(z.object({
|
|
59
|
-
id: z.string(),
|
|
60
|
-
name: z.string(),
|
|
61
|
-
userType: z.enum(['human', 'ai_agent', 'unknown']),
|
|
62
|
-
isOwner: z.boolean(),
|
|
63
|
-
isSelf: z.boolean(),
|
|
64
|
-
})),
|
|
65
|
-
membershipChange: SseMembershipChangeSchema.optional(),
|
|
66
|
-
});
|
|
67
|
-
export const InboundFrameV1Schema = z.object({
|
|
68
|
-
schema: z.literal(INBOUND_FRAME_SCHEMA_V1),
|
|
69
|
-
shape: InboundFrameShapeV1Schema,
|
|
70
|
-
sender: z.object({
|
|
71
|
-
name: z.string(),
|
|
72
|
-
type: z.enum(['human', 'ai_agent']),
|
|
73
|
-
isOwner: z.boolean(),
|
|
74
|
-
}),
|
|
75
|
-
conversation: z.object({
|
|
76
|
-
type: z.enum(['direct', 'group', 'unknown']),
|
|
77
|
-
memberCount: z.number().nullable(),
|
|
78
|
-
}),
|
|
79
|
-
addressed: z.boolean(),
|
|
80
|
-
message: z.object({
|
|
81
|
-
text: z.string(),
|
|
82
|
-
contentType: SerializedContentTypeSchema.nullable(),
|
|
83
|
-
}),
|
|
84
|
-
replyContext: InboundFrameReplyContextV1Schema.nullable(),
|
|
85
|
-
groupContext: InboundFrameGroupContextV1Schema.nullable(),
|
|
86
|
-
groupContextMode: z.enum(['initial', 'membership_change']).optional(),
|
|
87
|
-
selfContexts: z.array(z.string()),
|
|
88
|
-
behaviorInstructions: z.array(z.string()),
|
|
89
|
-
});
|