@canonmsg/backend-contracts 2.1.0 → 2.3.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.
@@ -0,0 +1,367 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://canonmsg.com/schemas/canon.verb-wire.v1.json",
4
+ "title": "Canon Verb Wire v1",
5
+ "description": "The remote wire contract for agent verbs: authenticated envelope + json-or-mls body. The semantic intent contract (canon.verbs.v1) is local; this is what crosses the network.",
6
+ "type": "object",
7
+ "required": [
8
+ "wire",
9
+ "verb",
10
+ "envelope",
11
+ "body"
12
+ ],
13
+ "additionalProperties": false,
14
+ "properties": {
15
+ "wire": {
16
+ "const": "canon.verb-wire.v1"
17
+ },
18
+ "verb": {
19
+ "enum": [
20
+ "send_to",
21
+ "request_input",
22
+ "request_approval",
23
+ "check_approval",
24
+ "send_card",
25
+ "request_card",
26
+ "share_contact",
27
+ "react",
28
+ "forward",
29
+ "create_group",
30
+ "add_member",
31
+ "remove_member",
32
+ "leave_conversation",
33
+ "list_contacts",
34
+ "list_contact_requests",
35
+ "list_conversations"
36
+ ]
37
+ },
38
+ "envelope": {
39
+ "$ref": "#/$defs/envelope"
40
+ },
41
+ "body": {
42
+ "$ref": "#/$defs/body"
43
+ }
44
+ },
45
+ "$defs": {
46
+ "body": {
47
+ "description": "The verb body: plaintext JSON for temporary/plaintext conversations, MLS ciphertext for encrypted ones. In json mode the server may read value to execute legacy behavior; in mls mode it is opaque.",
48
+ "oneOf": [
49
+ {
50
+ "type": "object",
51
+ "required": [
52
+ "encoding",
53
+ "value"
54
+ ],
55
+ "additionalProperties": false,
56
+ "properties": {
57
+ "encoding": {
58
+ "const": "json"
59
+ },
60
+ "value": {
61
+ "type": "object"
62
+ }
63
+ }
64
+ },
65
+ {
66
+ "type": "object",
67
+ "required": [
68
+ "encoding",
69
+ "epoch",
70
+ "ciphertext",
71
+ "aadHash"
72
+ ],
73
+ "additionalProperties": false,
74
+ "properties": {
75
+ "encoding": {
76
+ "const": "mls"
77
+ },
78
+ "epoch": {
79
+ "type": "integer",
80
+ "minimum": 0
81
+ },
82
+ "ciphertext": {
83
+ "type": "string",
84
+ "minLength": 1
85
+ },
86
+ "aadHash": {
87
+ "type": "string",
88
+ "minLength": 1,
89
+ "description": "Hash binding the envelope (AAD) to the ciphertext."
90
+ }
91
+ }
92
+ }
93
+ ]
94
+ },
95
+ "envelope": {
96
+ "type": "object",
97
+ "description": "Authenticated public envelope: routing/policy metadata only, never content. Per-verb field discipline: VERB_WIRE_ENVELOPE_FIELDS.",
98
+ "additionalProperties": false,
99
+ "properties": {
100
+ "conversationId": {
101
+ "type": "string",
102
+ "pattern": "^[A-Za-z0-9_.:-]{1,160}$"
103
+ },
104
+ "targetUserId": {
105
+ "type": "string",
106
+ "minLength": 1
107
+ },
108
+ "canonContactId": {
109
+ "type": "string",
110
+ "minLength": 1
111
+ },
112
+ "sourceConversationId": {
113
+ "type": "string",
114
+ "pattern": "^[A-Za-z0-9_.:-]{1,160}$"
115
+ },
116
+ "contactUserId": {
117
+ "type": "string",
118
+ "minLength": 1
119
+ },
120
+ "requestId": {
121
+ "type": "string",
122
+ "pattern": "^[A-Za-z0-9_.:-]{1,160}$"
123
+ },
124
+ "responseUserId": {
125
+ "type": "string",
126
+ "pattern": "^[A-Za-z0-9_.:-]{1,160}$"
127
+ },
128
+ "expiresAt": {
129
+ "type": "integer",
130
+ "minimum": 0
131
+ },
132
+ "mode": {
133
+ "enum": [
134
+ "blocking",
135
+ "detached"
136
+ ]
137
+ },
138
+ "kind": {
139
+ "enum": [
140
+ "clarify",
141
+ "sudo",
142
+ "secret"
143
+ ]
144
+ },
145
+ "sensitive": {
146
+ "type": "boolean"
147
+ },
148
+ "allowSessionRule": {
149
+ "type": "boolean"
150
+ },
151
+ "riskLevel": {
152
+ "enum": [
153
+ "normal",
154
+ "destructive"
155
+ ]
156
+ },
157
+ "risk": {
158
+ "enum": [
159
+ "low",
160
+ "normal",
161
+ "high",
162
+ "destructive"
163
+ ]
164
+ },
165
+ "category": {
166
+ "enum": [
167
+ "command",
168
+ "file",
169
+ "network",
170
+ "browser",
171
+ "mcp",
172
+ "plugin",
173
+ "canon",
174
+ "tool"
175
+ ]
176
+ },
177
+ "sessionSelection": {
178
+ "oneOf": [
179
+ {
180
+ "type": "object",
181
+ "required": [
182
+ "mode"
183
+ ],
184
+ "additionalProperties": false,
185
+ "properties": {
186
+ "mode": {
187
+ "enum": [
188
+ "new",
189
+ "continue_latest",
190
+ "continue_or_create"
191
+ ]
192
+ }
193
+ }
194
+ },
195
+ {
196
+ "type": "object",
197
+ "required": [
198
+ "mode",
199
+ "conversationId"
200
+ ],
201
+ "additionalProperties": false,
202
+ "properties": {
203
+ "mode": {
204
+ "const": "specific"
205
+ },
206
+ "conversationId": {
207
+ "type": "string",
208
+ "pattern": "^[A-Za-z0-9_.:-]{1,160}$"
209
+ }
210
+ }
211
+ }
212
+ ]
213
+ },
214
+ "sessionConfig": {
215
+ "type": [
216
+ "object",
217
+ "null"
218
+ ]
219
+ },
220
+ "idempotencyKey": {
221
+ "type": "string",
222
+ "pattern": "^[A-Za-z0-9_.:-]{1,160}$",
223
+ "not": {
224
+ "pattern": "^(\\.{1,2}|__.*__)$"
225
+ }
226
+ },
227
+ "messageId": {
228
+ "type": "string",
229
+ "minLength": 1
230
+ },
231
+ "replyTo": {
232
+ "type": "string"
233
+ },
234
+ "replyToPosition": {
235
+ "type": "integer"
236
+ },
237
+ "mentions": {
238
+ "type": "array",
239
+ "items": {
240
+ "type": "string"
241
+ },
242
+ "description": "Plaintext by decision D3 (routing + mention-piercing pushes)."
243
+ },
244
+ "memberIds": {
245
+ "type": "array",
246
+ "items": {
247
+ "type": "string"
248
+ },
249
+ "minItems": 1,
250
+ "description": "Group-membership routing ids (create_group). Plaintext like mentions (D3 rationale) but a distinct field — membership operations must not overload the mention slot."
251
+ },
252
+ "turn": {
253
+ "$ref": "#/$defs/turn"
254
+ },
255
+ "native": {
256
+ "type": "object"
257
+ },
258
+ "runtimeId": {
259
+ "type": "string",
260
+ "maxLength": 128
261
+ },
262
+ "limit": {
263
+ "type": "integer",
264
+ "minimum": 1
265
+ }
266
+ }
267
+ },
268
+ "turn": {
269
+ "type": "object",
270
+ "additionalProperties": false,
271
+ "properties": {
272
+ "turnId": {
273
+ "type": [
274
+ "string",
275
+ "null"
276
+ ]
277
+ },
278
+ "turnSemantics": {
279
+ "enum": [
280
+ "progress",
281
+ "turn_complete",
282
+ "control"
283
+ ]
284
+ },
285
+ "deliveryIntent": {
286
+ "enum": [
287
+ "queue",
288
+ "interrupt",
289
+ "interleave",
290
+ "stop"
291
+ ]
292
+ },
293
+ "replyBehavior": {
294
+ "enum": [
295
+ "allow_auto_reply",
296
+ "suppress_auto_reply"
297
+ ]
298
+ }
299
+ }
300
+ },
301
+ "accepted": {
302
+ "type": "object",
303
+ "required": [
304
+ "status",
305
+ "requestId"
306
+ ],
307
+ "additionalProperties": true,
308
+ "properties": {
309
+ "status": {
310
+ "const": "accepted"
311
+ },
312
+ "requestId": {
313
+ "type": "string"
314
+ },
315
+ "expiresAt": {
316
+ "type": "integer"
317
+ },
318
+ "messageId": {
319
+ "type": "string"
320
+ },
321
+ "responseUserId": {
322
+ "type": "string"
323
+ },
324
+ "interactive": {
325
+ "type": "boolean"
326
+ }
327
+ }
328
+ },
329
+ "response": {
330
+ "type": "object",
331
+ "required": [
332
+ "wire",
333
+ "verb",
334
+ "result"
335
+ ],
336
+ "additionalProperties": true,
337
+ "properties": {
338
+ "wire": {
339
+ "const": "canon.verb-wire.v1"
340
+ },
341
+ "verb": {
342
+ "enum": [
343
+ "send_to",
344
+ "request_input",
345
+ "request_approval",
346
+ "check_approval",
347
+ "send_card",
348
+ "request_card",
349
+ "share_contact",
350
+ "react",
351
+ "forward",
352
+ "create_group",
353
+ "add_member",
354
+ "remove_member",
355
+ "leave_conversation",
356
+ "list_contacts",
357
+ "list_contact_requests",
358
+ "list_conversations"
359
+ ]
360
+ },
361
+ "result": {
362
+ "$ref": "#/$defs/body"
363
+ }
364
+ }
365
+ }
366
+ }
367
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "schemaVersion": "canon.verbs.v1",
3
+ "limits": {
4
+ "messageTextBytes": 4096,
5
+ "messageMetadataJsonChars": 4096,
6
+ "messageAttachments": 10,
7
+ "messageIdChars": 160,
8
+ "messageIdBytes": 256,
9
+ "selfContextChars": 1000,
10
+ "contactRequestNoteChars": 500,
11
+ "groupMembers": 50,
12
+ "inputTitleChars": 160,
13
+ "inputPromptChars": 4000,
14
+ "inputChoices": 12,
15
+ "inputChoiceLabelChars": 120,
16
+ "inputChoiceValueChars": 200,
17
+ "inputChoiceDescriptionChars": 300,
18
+ "inputQuestions": 12,
19
+ "inputQuestionChars": 1000,
20
+ "inputQuestionHeaderChars": 120,
21
+ "inputSecretNameChars": 160,
22
+ "inputAnswerChars": 8192,
23
+ "toolNameChars": 128,
24
+ "toolSummaryChars": 1000,
25
+ "approvalDetails": 8,
26
+ "approvalDetailLabelChars": 80,
27
+ "approvalDetailValueChars": 500,
28
+ "diffFiles": 100,
29
+ "diffPathChars": 1024,
30
+ "diffFileBytes": 24576,
31
+ "diffTotalBytes": 98304,
32
+ "cardEnvelopeBytes": 32768,
33
+ "cardServerTitleChars": 200,
34
+ "cardServerFallbackTextChars": 2000,
35
+ "cardServerBlocks": 64,
36
+ "cardValuesBytes": 8192,
37
+ "cardValuesDepth": 8,
38
+ "nativeKeys": 24,
39
+ "nativeValueChars": 256,
40
+ "nativeHandles": 16,
41
+ "minTimeoutMs": 1000,
42
+ "maxTimeoutMs": 1800000,
43
+ "maxApprovalTimeoutMs": 259200000,
44
+ "turnIdChars": 128,
45
+ "reactionEmojiChars": 64,
46
+ "groupNameChars": 100
47
+ },
48
+ "rateLimits": {
49
+ "senderMessagesPer5Min": 300,
50
+ "conversationMessagesPer5Min": 120,
51
+ "agentPeerMessagesPerHour": 30
52
+ },
53
+ "idPatterns": {
54
+ "runtimeId": "^[A-Za-z0-9_.:-]{1,160}$",
55
+ "cardId": "^[A-Za-z0-9_.:-]{1,80}$",
56
+ "actionId": "^[A-Za-z0-9_.:-]{1,80}$",
57
+ "questionId": "^[A-Za-z0-9_.:-]{1,120}$",
58
+ "sessionRuleToolPattern": "^[\\w.*:-]{1,128}$"
59
+ },
60
+ "byteSemantics": {
61
+ "send_to.text": "utf8_bytes<=messageTextBytes",
62
+ "share_contact.text": "utf8_bytes<=messageTextBytes",
63
+ "forward.text": "utf8_bytes<=messageTextBytes",
64
+ "send_to.messageOptions.messageId": "utf8_bytes<=messageIdBytes",
65
+ "share_contact.messageId": "utf8_bytes<=messageIdBytes",
66
+ "send_to.messageOptions.metadata": "json_stringify_chars<=messageMetadataJsonChars",
67
+ "send_card.card": "json_utf8_bytes<=cardEnvelopeBytes",
68
+ "request_card.card": "json_utf8_bytes<=cardEnvelopeBytes"
69
+ }
70
+ }