@canonmsg/agent-sdk 11.2.1 → 12.1.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.
Files changed (181) hide show
  1. package/README.md +248 -523
  2. package/dist/chunks/chunk-7N6OPPW4.js +5430 -0
  3. package/dist/chunks/chunk-N722GWCP.js +4897 -0
  4. package/dist/chunks/chunk-QZ4PPRQW.js +14247 -0
  5. package/dist/chunks/mls-crypto-LMNQZOS6.js +10 -0
  6. package/dist/cli.js +572 -0
  7. package/dist/drivers/claude.d.ts +42 -0
  8. package/dist/drivers/code.d.ts +18 -0
  9. package/dist/drivers/codex.d.ts +46 -0
  10. package/dist/drivers/connector.d.ts +34 -0
  11. package/dist/index.d.ts +20 -25
  12. package/dist/index.js +91 -13
  13. package/dist/internal/backend-contracts/agentBehaviorPolicy.d.ts +122 -0
  14. package/dist/internal/backend-contracts/agentDirectory.d.ts +32 -0
  15. package/dist/internal/backend-contracts/agentOrigin.d.ts +23 -0
  16. package/dist/internal/backend-contracts/agentSearch.d.ts +17 -0
  17. package/dist/internal/backend-contracts/api-origins.generated.d.ts +4 -0
  18. package/dist/internal/backend-contracts/apiErrors.d.ts +1 -0
  19. package/dist/internal/backend-contracts/artifactActions.d.ts +8 -0
  20. package/dist/internal/backend-contracts/artifacts.d.ts +386 -0
  21. package/dist/internal/backend-contracts/clientFloor.d.ts +41 -0
  22. package/dist/internal/backend-contracts/communication.d.ts +146 -0
  23. package/dist/internal/backend-contracts/connectorRelay.d.ts +179 -0
  24. package/dist/internal/backend-contracts/conversationMembership.d.ts +28 -0
  25. package/dist/internal/backend-contracts/deliveryObservation.d.ts +23 -0
  26. package/dist/internal/backend-contracts/diffRedaction.d.ts +6 -0
  27. package/dist/internal/backend-contracts/endpoint-unread.d.ts +4 -0
  28. package/dist/internal/backend-contracts/endpoint.d.ts +120 -0
  29. package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +48 -0
  30. package/dist/internal/backend-contracts/environment.d.ts +20 -0
  31. package/dist/internal/backend-contracts/externalInbound.d.ts +24 -0
  32. package/dist/internal/backend-contracts/firestoreValues.d.ts +9 -0
  33. package/dist/internal/backend-contracts/index.d.ts +54 -0
  34. package/dist/internal/backend-contracts/media-url.d.ts +20 -0
  35. package/dist/internal/backend-contracts/media.d.ts +51 -0
  36. package/dist/internal/backend-contracts/mediaDelivery.d.ts +46 -0
  37. package/dist/internal/backend-contracts/mediaTransferProtocol.d.ts +17 -0
  38. package/dist/internal/backend-contracts/membershipChange.d.ts +21 -0
  39. package/dist/internal/backend-contracts/message.d.ts +86 -0
  40. package/dist/internal/backend-contracts/messageText.d.ts +6 -0
  41. package/dist/internal/backend-contracts/mlsDevApplication.d.ts +161 -0
  42. package/dist/internal/backend-contracts/mlsDevCredential.d.ts +78 -0
  43. package/dist/internal/backend-contracts/mlsDevCredentialReconciliation.d.ts +45 -0
  44. package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +52 -0
  45. package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +75 -0
  46. package/dist/internal/backend-contracts/mlsDevFeedReceipt.d.ts +43 -0
  47. package/dist/internal/backend-contracts/mlsDevGroup.d.ts +321 -0
  48. package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +51 -0
  49. package/dist/internal/backend-contracts/mlsDevInteraction.d.ts +159 -0
  50. package/dist/internal/backend-contracts/mlsDevKeyPackage.d.ts +42 -0
  51. package/dist/internal/backend-contracts/mlsDevKeyPackages.d.ts +55 -0
  52. package/dist/internal/backend-contracts/mlsEnvironment.d.ts +35 -0
  53. package/dist/internal/backend-contracts/mlsPrincipalAlias.d.ts +23 -0
  54. package/dist/internal/backend-contracts/moderation.d.ts +7 -0
  55. package/dist/internal/backend-contracts/plaintextProcessors.d.ts +63 -0
  56. package/dist/internal/backend-contracts/preparedContent.d.ts +54 -0
  57. package/dist/internal/backend-contracts/replyAuthority.d.ts +14 -0
  58. package/dist/internal/backend-contracts/runtimeCardFields.d.ts +66 -0
  59. package/dist/internal/backend-contracts/runtimeCardStorage.d.ts +3 -0
  60. package/dist/internal/backend-contracts/runtimeDescriptor.d.ts +88 -0
  61. package/dist/internal/backend-contracts/selfContext.d.ts +9 -0
  62. package/dist/internal/backend-contracts/turnProtocol.d.ts +43 -0
  63. package/dist/internal/backend-contracts/upload-mime-types.d.ts +17 -0
  64. package/dist/internal/backend-contracts/verbContract.d.ts +856 -0
  65. package/dist/internal/backend-contracts/verbSchemas.d.ts +1717 -0
  66. package/dist/internal/backend-contracts/verbWire.d.ts +493 -0
  67. package/dist/internal/backend-contracts/webAuth.d.ts +8 -0
  68. package/dist/internal/core/agent-profiles.d.ts +65 -0
  69. package/dist/internal/core/approval-format.d.ts +22 -0
  70. package/dist/internal/core/approval-manager.d.ts +43 -0
  71. package/dist/internal/core/approval-types.d.ts +73 -0
  72. package/dist/internal/core/base-url.d.ts +1 -0
  73. package/dist/internal/core/cli-metadata.d.ts +13 -0
  74. package/dist/internal/core/client.d.ts +432 -0
  75. package/dist/internal/core/completed-output-journal.d.ts +39 -0
  76. package/dist/internal/core/constants.d.ts +1 -0
  77. package/dist/internal/core/endpoint-client.d.ts +56 -0
  78. package/dist/internal/core/execution-environment-mode.d.ts +6 -0
  79. package/dist/internal/core/gifs.d.ts +29 -0
  80. package/dist/internal/core/host-runtime.d.ts +53 -0
  81. package/dist/internal/core/index.d.ts +68 -0
  82. package/dist/internal/core/node-media.d.ts +6 -0
  83. package/dist/internal/core/policy.d.ts +2 -0
  84. package/dist/internal/core/registration-profile.d.ts +10 -0
  85. package/dist/internal/core/registration-session.d.ts +55 -0
  86. package/dist/internal/core/registration.d.ts +5 -0
  87. package/dist/internal/core/retry.d.ts +113 -0
  88. package/dist/internal/core/rtdb-rest.d.ts +141 -0
  89. package/dist/internal/core/runtime-cards.d.ts +286 -0
  90. package/dist/internal/core/runtime-descriptor.d.ts +16 -0
  91. package/dist/internal/core/runtime-endpoints.d.ts +26 -0
  92. package/dist/internal/core/runtime-heartbeat.d.ts +29 -0
  93. package/dist/internal/core/runtime-presentation.d.ts +9 -0
  94. package/dist/internal/core/runtime-request-manager.d.ts +283 -0
  95. package/dist/internal/core/runtime-state-publisher.d.ts +42 -0
  96. package/dist/internal/core/self-context.d.ts +22 -0
  97. package/dist/internal/core/silent-turn.d.ts +49 -0
  98. package/dist/internal/core/stream.d.ts +78 -0
  99. package/dist/internal/core/turn-protocol.d.ts +28 -0
  100. package/dist/internal/core/turn-verbosity.d.ts +85 -0
  101. package/dist/internal/core/types.d.ts +964 -0
  102. package/dist/internal/core/unified-diff.d.ts +35 -0
  103. package/dist/internal/endpoint/artifact-images.d.ts +60 -0
  104. package/dist/internal/endpoint/artifact-reducer.d.ts +35 -0
  105. package/dist/internal/endpoint/artifact-views.d.ts +113 -0
  106. package/dist/internal/endpoint/artifacts.d.ts +75 -0
  107. package/dist/internal/endpoint/delivery.d.ts +47 -0
  108. package/dist/internal/endpoint/engine.d.ts +249 -0
  109. package/dist/internal/endpoint/ephemeral.d.ts +8 -0
  110. package/dist/internal/endpoint/events.d.ts +32 -0
  111. package/dist/internal/endpoint/external-inbound.d.ts +36 -0
  112. package/dist/internal/endpoint/handoff.d.ts +50 -0
  113. package/dist/internal/endpoint/history.d.ts +22 -0
  114. package/dist/internal/endpoint/image-generation-errors.d.ts +2 -0
  115. package/dist/internal/endpoint/inbound.d.ts +29 -0
  116. package/dist/internal/endpoint/index.d.ts +32 -0
  117. package/dist/internal/endpoint/media.d.ts +177 -0
  118. package/dist/internal/endpoint/migration.d.ts +50 -0
  119. package/dist/internal/endpoint/mls-crypto.d.ts +32 -0
  120. package/dist/internal/endpoint/mls-dev-client.d.ts +52 -0
  121. package/dist/internal/endpoint/mls-dev-device.d.ts +69 -0
  122. package/dist/internal/endpoint/mls-dev-groups.d.ts +174 -0
  123. package/dist/internal/endpoint/mls-dev-interactions.d.ts +99 -0
  124. package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +46 -0
  125. package/dist/internal/endpoint/mls-dev-key-packages.d.ts +62 -0
  126. package/dist/internal/endpoint/mls-dev-text.d.ts +67 -0
  127. package/dist/internal/endpoint/mls-dev-transport.d.ts +38 -0
  128. package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +29 -0
  129. package/dist/internal/endpoint/node-mls-custody.d.ts +15 -0
  130. package/dist/internal/endpoint/node.d.ts +7 -0
  131. package/dist/internal/endpoint/observe-query.d.ts +17 -0
  132. package/dist/internal/endpoint/portable-node-mls-custody.d.ts +23 -0
  133. package/dist/internal/endpoint/queue.d.ts +22 -0
  134. package/dist/internal/endpoint/recovery.d.ts +27 -0
  135. package/dist/internal/endpoint/retention.d.ts +7 -0
  136. package/dist/internal/endpoint/store.d.ts +22 -0
  137. package/dist/internal/endpoint/sync.d.ts +33 -0
  138. package/dist/internal/endpoint/transient-publisher.d.ts +8 -0
  139. package/dist/internal/endpoint/transport.d.ts +63 -0
  140. package/dist/media.d.ts +1 -1
  141. package/dist/media.js +42 -541
  142. package/dist/runner/errands.d.ts +118 -0
  143. package/dist/runner/mls.d.ts +97 -0
  144. package/dist/runner/relay.d.ts +87 -0
  145. package/dist/runner/runner.d.ts +98 -0
  146. package/dist/runner/types.d.ts +215 -0
  147. package/package.json +18 -5
  148. package/dist/attached-session.d.ts +0 -58
  149. package/dist/attached-session.js +0 -638
  150. package/dist/bounded-file-read.d.ts +0 -14
  151. package/dist/bounded-file-read.js +0 -34
  152. package/dist/canon-agent.d.ts +0 -236
  153. package/dist/canon-agent.js +0 -2531
  154. package/dist/debouncer.d.ts +0 -18
  155. package/dist/debouncer.js +0 -133
  156. package/dist/inbound-handoff.d.ts +0 -6
  157. package/dist/inbound-handoff.js +0 -17
  158. package/dist/managed-session-host.d.ts +0 -27
  159. package/dist/managed-session-host.js +0 -195
  160. package/dist/managed-session-setup.d.ts +0 -99
  161. package/dist/managed-session-setup.js +0 -234
  162. package/dist/realtime.d.ts +0 -62
  163. package/dist/realtime.js +0 -193
  164. package/dist/runtime-card.d.ts +0 -48
  165. package/dist/runtime-card.js +0 -64
  166. package/dist/session-manager.d.ts +0 -77
  167. package/dist/session-manager.js +0 -285
  168. package/dist/turn-streaming-request.d.ts +0 -17
  169. package/dist/turn-streaming-request.js +0 -22
  170. package/dist/turn-verbosity-option.d.ts +0 -33
  171. package/dist/turn-verbosity-option.js +0 -23
  172. package/dist/types.d.ts +0 -387
  173. package/dist/types.js +0 -1
  174. package/dist/work-session-coordination.d.ts +0 -21
  175. package/dist/work-session-coordination.js +0 -53
  176. package/dist/work-session-host.d.ts +0 -31
  177. package/dist/work-session-host.js +0 -617
  178. package/dist/work-session-interactions.d.ts +0 -12
  179. package/dist/work-session-interactions.js +0 -173
  180. package/dist/work-session-state.d.ts +0 -36
  181. package/dist/work-session-state.js +0 -62
@@ -0,0 +1,386 @@
1
+ import type { MediaAttachment } from './media.js';
2
+ /**
3
+ * Shared work beside a conversation (protocol v2). The relay sequences opaque
4
+ * command envelopes; every endpoint reduces the same log with the same rules.
5
+ * Nothing a member writes may make the work unreadable for other members: only
6
+ * integrity failures and a newer envelope version halt replay. Everything else
7
+ * becomes a precise rejected outcome.
8
+ */
9
+ export declare const ARTIFACT_PROTOCOL_VERSION = 2;
10
+ /** Older envelopes were written by the retired v1 preview; they are rejected, not halted. */
11
+ export declare const ARTIFACT_PROTOCOL_MIN_VERSION = 2;
12
+ export declare const artifactSchemaName: (version: number) => string;
13
+ /** Message metadata reference protocol. The wire name is unchanged in v2. */
14
+ export declare const ARTIFACT_CONTEXT_PROTOCOL: "canon.artifact-context.v1";
15
+ export declare const ARTIFACT_COMMAND_MAX_BYTES: number;
16
+ /** Checked after every accepted command. */
17
+ export declare const ARTIFACT_STATE_MAX_BYTES: number;
18
+ /** Artifact, command, variant and asset identifiers. */
19
+ export declare const ARTIFACT_ID_PATTERN: RegExp;
20
+ /** Form field, column and row identifiers. */
21
+ export declare const ARTIFACT_KEY_PATTERN: RegExp;
22
+ export declare const ARTIFACT_KINDS: readonly ["chess", "form", "image"];
23
+ export declare const ARTIFACT_COMMAND_TYPES: readonly ["create", "chess.move", "chess.resign", "form.set", "form.fields", "image.add", "image.select", "archive"];
24
+ export declare const ARTIFACT_FORM_FIELD_TYPES: readonly ["text", "textarea", "number", "date", "select", "checkbox", "email", "tel", "url"];
25
+ export declare const ARTIFACT_LIMITS: Readonly<{
26
+ titleChars: 120;
27
+ chessMaxPlies: 600;
28
+ formFields: 60;
29
+ formOptions: 40;
30
+ formOptionChars: 120;
31
+ formColumns: 10;
32
+ formRows: 200;
33
+ formLabelChars: 120;
34
+ formHintChars: 300;
35
+ formValueChars: 1000;
36
+ formChanges: 200;
37
+ formMaxDecimals: 6;
38
+ /**
39
+ * Largest magnitude of a form number. 200 rows of it still sum to a finite,
40
+ * exactly representable whole number (below Number.MAX_SAFE_INTEGER).
41
+ */
42
+ formNumberMax: 10000000000000;
43
+ imageVariants: 50;
44
+ imageLabelChars: 120;
45
+ imagePromptChars: 1000;
46
+ outcomes: 200;
47
+ outcomeMessageChars: 500;
48
+ }>;
49
+ export declare function isArtifactId(value: unknown): value is string;
50
+ export declare function isArtifactKey(value: unknown): value is string;
51
+ /** Shared work is a Dev-only preview. */
52
+ export declare function isCanonArtifactEnvironmentEnabled(environmentId: string | null | undefined): boolean;
53
+ export type ArtifactJson = null | boolean | number | string | ArtifactJson[] | {
54
+ [key: string]: ArtifactJson;
55
+ };
56
+ export type ArtifactKind = typeof ARTIFACT_KINDS[number];
57
+ export type ArtifactCommandType = typeof ARTIFACT_COMMAND_TYPES[number];
58
+ /** `title` is 1..120 characters after trimming. `initialState` is the kind's create input. */
59
+ export interface ArtifactDefinition {
60
+ kind: ArtifactKind;
61
+ title: string;
62
+ initialState: ArtifactJson;
63
+ }
64
+ /** Principal IDs. A set seat restricts who may move that colour. */
65
+ export interface ArtifactChessPlayers {
66
+ white?: string;
67
+ black?: string;
68
+ }
69
+ export interface ArtifactChessMove {
70
+ san: string;
71
+ from: string;
72
+ to: string;
73
+ by: string;
74
+ }
75
+ export interface ArtifactChessState {
76
+ fen: string;
77
+ initialFen: string;
78
+ moves: ArtifactChessMove[];
79
+ players?: ArtifactChessPlayers;
80
+ turn: 'w' | 'b';
81
+ check: boolean;
82
+ status: 'active' | 'checkmate' | 'stalemate' | 'draw' | 'resigned';
83
+ result?: '1-0' | '0-1' | '1/2-1/2';
84
+ resignedBy?: string;
85
+ /** Position key (FEN without clocks) -> count; reset on captures and pawn moves. */
86
+ repetition: Record<string, number>;
87
+ }
88
+ export interface ArtifactChessCreateInput {
89
+ fen?: string;
90
+ players?: ArtifactChessPlayers;
91
+ }
92
+ export type ArtifactFormFieldType = typeof ARTIFACT_FORM_FIELD_TYPES[number];
93
+ export type ArtifactFormValue = string | number | boolean | null;
94
+ export interface ArtifactFormField {
95
+ id: string;
96
+ label: string;
97
+ type: ArtifactFormFieldType;
98
+ options?: string[];
99
+ required?: boolean;
100
+ placeholder?: string;
101
+ help?: string;
102
+ decimals?: number;
103
+ }
104
+ export interface ArtifactFormColumn {
105
+ id: string;
106
+ label: string;
107
+ type: Exclude<ArtifactFormFieldType, 'textarea'>;
108
+ options?: string[];
109
+ decimals?: number;
110
+ sum?: boolean;
111
+ }
112
+ export interface ArtifactFormTable {
113
+ label?: string;
114
+ columns: ArtifactFormColumn[];
115
+ }
116
+ export interface ArtifactFormRow {
117
+ id: string;
118
+ cells: Record<string, ArtifactFormValue>;
119
+ }
120
+ /** `values` holds every field (null when empty); every row holds every column. */
121
+ export interface ArtifactFormState {
122
+ fields: ArtifactFormField[];
123
+ values: Record<string, ArtifactFormValue>;
124
+ table?: ArtifactFormTable;
125
+ rows: ArtifactFormRow[];
126
+ }
127
+ /** Row IDs are optional on input and generated deterministically (`r-<index + 1>`). */
128
+ export interface ArtifactFormCreateInput {
129
+ fields: ArtifactFormField[];
130
+ values?: Record<string, ArtifactFormValue>;
131
+ table?: ArtifactFormTable;
132
+ rows?: Array<{
133
+ id?: string;
134
+ cells: Record<string, ArtifactFormValue>;
135
+ }>;
136
+ }
137
+ /** `assetId` refers to a retained Canon upload, never a remote or bearer URL. */
138
+ export interface ArtifactImageVariant {
139
+ id: string;
140
+ assetId: string;
141
+ label: string;
142
+ prompt?: string;
143
+ sourceVariantId?: string;
144
+ by: string;
145
+ at: string;
146
+ }
147
+ export interface ArtifactImageState {
148
+ variants: ArtifactImageVariant[];
149
+ currentVariantId?: string;
150
+ }
151
+ export type ArtifactImageCreateInput = Record<string, never>;
152
+ export type ArtifactFormChange = {
153
+ field: string;
154
+ before: ArtifactFormValue;
155
+ after: ArtifactFormValue;
156
+ } | {
157
+ row: string;
158
+ column: string;
159
+ before: ArtifactFormValue;
160
+ after: ArtifactFormValue;
161
+ } | {
162
+ row: string;
163
+ add: Record<string, ArtifactFormValue>;
164
+ } | {
165
+ row: string;
166
+ remove: {
167
+ before: Record<string, ArtifactFormValue>;
168
+ };
169
+ };
170
+ /** A field to remove with the value its author last saw: a newer value is a CONFLICT, never silently discarded. */
171
+ export interface ArtifactFormFieldRemoval {
172
+ id: string;
173
+ before: ArtifactFormValue;
174
+ }
175
+ export type ArtifactCommandBody = {
176
+ type: 'create';
177
+ definition: ArtifactDefinition;
178
+ }
179
+ /** SAN or UCI. */
180
+ | {
181
+ type: 'chess.move';
182
+ baseRevisionId: string;
183
+ move: string;
184
+ } | {
185
+ type: 'chess.resign';
186
+ }
187
+ /** 1..200 changes, all-or-nothing. */
188
+ | {
189
+ type: 'form.set';
190
+ changes: ArtifactFormChange[];
191
+ } | {
192
+ type: 'form.fields';
193
+ add?: ArtifactFormField[];
194
+ remove?: ArtifactFormFieldRemoval[];
195
+ } | {
196
+ type: 'image.add';
197
+ variant: {
198
+ id: string;
199
+ assetId: string;
200
+ label: string;
201
+ prompt?: string;
202
+ sourceVariantId?: string;
203
+ };
204
+ select?: boolean;
205
+ } | {
206
+ type: 'image.select';
207
+ variantId: string;
208
+ } | {
209
+ type: 'archive';
210
+ archived: boolean;
211
+ };
212
+ export type ArtifactCommand = {
213
+ schema: string;
214
+ } & ArtifactCommandBody;
215
+ export interface ArtifactContent {
216
+ encoding: 'json';
217
+ version: number;
218
+ data: string;
219
+ }
220
+ export interface AppendArtifactCommandBody {
221
+ conversationId: string;
222
+ artifactId: string;
223
+ commandId: string;
224
+ content: ArtifactContent;
225
+ }
226
+ export interface ArtifactStoredReceipt {
227
+ artifactId: string;
228
+ commandId: string;
229
+ sequence: number;
230
+ status: 'stored';
231
+ }
232
+ export interface ArtifactCommandRecord extends ArtifactStoredReceipt {
233
+ actorId: string;
234
+ actorAdmissionId: string;
235
+ createdAt: string;
236
+ content: ArtifactContent;
237
+ }
238
+ export interface ArtifactCatalogEntry {
239
+ artifactId: string;
240
+ sequence: number;
241
+ createdAt: string;
242
+ updatedAt: string;
243
+ }
244
+ export interface ArtifactCatalogPage {
245
+ artifacts: ArtifactCatalogEntry[];
246
+ nextCursor?: string;
247
+ }
248
+ export interface ArtifactLogPage {
249
+ headSequence?: number;
250
+ commands: ArtifactCommandRecord[];
251
+ nextCursor?: string;
252
+ }
253
+ export interface ArtifactAsset {
254
+ assetId: string;
255
+ attachment: MediaAttachment;
256
+ }
257
+ export interface ArtifactSnapshot {
258
+ conversationId: string;
259
+ artifactId: string;
260
+ revisionId: string;
261
+ sequence: number;
262
+ definition: ArtifactDefinition;
263
+ state: ArtifactJson;
264
+ archived: boolean;
265
+ createdBy: string;
266
+ createdAt: string;
267
+ updatedBy: string;
268
+ updatedAt: string;
269
+ }
270
+ export type ArtifactOutcomeCode = 'INVALID_COMMAND' | 'CONFLICT' | 'UNAUTHORIZED' | 'RETIRED_PROTOCOL';
271
+ export interface ArtifactDomainOutcome {
272
+ commandId: string;
273
+ sequence: number;
274
+ status: 'accepted' | 'rejected';
275
+ actorId: string;
276
+ /** A known command type, or 'unknown'. */
277
+ type: string;
278
+ at: string;
279
+ revisionId?: string;
280
+ code?: ArtifactOutcomeCode;
281
+ message?: string;
282
+ }
283
+ /** `outcomes` keeps the newest 200. */
284
+ export interface ArtifactReadResult {
285
+ snapshot: ArtifactSnapshot | null;
286
+ outcomes: ArtifactDomainOutcome[];
287
+ sequence: number;
288
+ }
289
+ export type ArtifactSelection = {
290
+ kind: 'artifact';
291
+ variantId?: string;
292
+ }
293
+ /** ['fields', id] | ['rows', rowId, columnId] */
294
+ | {
295
+ kind: 'field';
296
+ path: string[];
297
+ } | {
298
+ kind: 'position';
299
+ ply: number;
300
+ square?: string;
301
+ }
302
+ /** Fractions of the image, origin top-left. */
303
+ | {
304
+ kind: 'region';
305
+ assetId: string;
306
+ variantId?: string;
307
+ x: number;
308
+ y: number;
309
+ width: number;
310
+ height: number;
311
+ };
312
+ export type ArtifactReferenceOrigin = 'open' | 'selected' | 'activity';
313
+ export interface ArtifactReference {
314
+ artifactId: string;
315
+ revisionId: string;
316
+ /** Always 1 in v2; kept for wire compatibility. */
317
+ definitionVersion: number;
318
+ label?: string;
319
+ origin?: ArtifactReferenceOrigin;
320
+ selection: ArtifactSelection;
321
+ }
322
+ export interface ArtifactContext {
323
+ schema: typeof ARTIFACT_CONTEXT_PROTOCOL;
324
+ references: ArtifactReference[];
325
+ }
326
+ /** A precise, author-facing validation failure. Messages never echo unbounded input. */
327
+ export declare class ArtifactValidationError extends Error {
328
+ constructor(message: string);
329
+ }
330
+ /**
331
+ * Quote an attacker-controlled identifier or label for a message, truncated to
332
+ * 80 characters. Only strings, numbers and booleans are quoted; other values
333
+ * are described by their type and never converted with String().
334
+ */
335
+ export declare function quoteArtifactText(value: unknown): string;
336
+ /**
337
+ * Titles, labels, options and hints are one line: they are embedded in
338
+ * one-line summaries, prompts and messages. Each run of control characters
339
+ * (including newlines) becomes one space; the result is trimmed.
340
+ */
341
+ export declare function artifactSingleLine(value: string): string;
342
+ /**
343
+ * Round half away from zero to `decimals` places, without binary-fraction
344
+ * surprises such as 1.005 -> 1.00. Non-finite input (or invalid `decimals`)
345
+ * is returned unchanged.
346
+ */
347
+ export declare function roundFormNumber(value: number, decimals: number): number;
348
+ export type ArtifactFormValueSpec = Pick<ArtifactFormField, 'type'> & {
349
+ options?: string[];
350
+ decimals?: number;
351
+ label?: string;
352
+ };
353
+ /**
354
+ * Normalize one typed value. '' (and undefined) become null for every type and
355
+ * null is always allowed: `required` is a hint, not enforced.
356
+ */
357
+ export declare function validateFormValue(spec: ArtifactFormValueSpec, value: unknown): ArtifactFormValue;
358
+ /** Missing, '' and null are the same empty value. */
359
+ export declare function formValuesEqual(a: unknown, b: unknown): boolean;
360
+ /** Readable value for messages and summaries. */
361
+ export declare function formatFormValue(value: unknown): string;
362
+ /** Validate one field definition (used for create and form.fields). */
363
+ export declare function normalizeFormField(value: unknown): ArtifactFormField;
364
+ /** Validate a table definition: an optional label and 1..10 uniquely identified columns. */
365
+ export declare function normalizeFormTable(value: unknown): ArtifactFormTable;
366
+ /** Validate a row's cells against the table; every column is present (null when empty). */
367
+ export declare function normalizeFormCells(table: ArtifactFormTable, value: unknown, where: string): Record<string, ArtifactFormValue>;
368
+ /** Create input -> state. Generated row IDs are `r-<index + 1>`; duplicate IDs are rejected. */
369
+ export declare function normalizeFormInput(input: unknown): ArtifactFormState;
370
+ /** Human label for a change against the form it applies to. */
371
+ export declare function formChangeLabel(state: Pick<ArtifactFormState, 'fields' | 'rows'> & {
372
+ table?: ArtifactFormTable;
373
+ }, change: ArtifactFormChange): string;
374
+ /** Strict (server and composer): reject malformed known metadata instead of dropping it. Returns a clean copy. */
375
+ export declare function parseArtifactContext(value: unknown): ArtifactContext;
376
+ /** Lenient (prompt projection, rendering): keeps valid references and never throws. */
377
+ export declare function readArtifactContext(value: unknown): ArtifactContext | undefined;
378
+ /** Activity text stays well inside the 4 KiB message text limit, leaving metadata room. */
379
+ export declare const ARTIFACT_ACTIVITY_TEXT_MAX_BYTES = 2048;
380
+ /** Text for an ordinary chat message a person posts after acting on shared work. */
381
+ export declare function artifactActivityText(input: {
382
+ action: 'created' | 'chess.move' | 'chess.resign' | 'form.updated';
383
+ kind: ArtifactKind;
384
+ title: string;
385
+ detail?: string;
386
+ }): string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Which client is calling, and the oldest version Canon still serves (mls-cutover-operator.md §2 15b). Every client names
3
+ * itself on its endpoint requests with `X-Canon-Client: <kind>/<version>`. While a floor exists, Canon refuses a kind
4
+ * below its minimum, and any request without a valid header, with `426 CLIENT_UPDATE_REQUIRED`.
5
+ */
6
+ export declare const CANON_CLIENT_HEADER = "X-Canon-Client";
7
+ export declare const CLIENT_UPDATE_REQUIRED = "CLIENT_UPDATE_REQUIRED";
8
+ /**
9
+ * - `app-ios`, `app-android`: the native build's version (an OTA update cannot add native code, so the bundle's does not count);
10
+ * - `web`, `runner` (`@canonmsg/agent-sdk`), `hermes` (the plugin), and `core` for other first-party tools (the CLIs);
11
+ * - `connector`: Canon's hosted MCP connector, which deploys with Functions. Like `web`, it ships one build at a time and
12
+ * names itself `0.0.0`; neither gets a minimum.
13
+ */
14
+ export declare const CANON_CLIENT_KINDS: readonly ["app-ios", "app-android", "web", "runner", "hermes", "core", "connector"];
15
+ export type CanonClientKind = typeof CANON_CLIENT_KINDS[number];
16
+ export interface CanonClientIdentity {
17
+ readonly kind: CanonClientKind;
18
+ readonly version: string;
19
+ }
20
+ /** `major.minor.patch`, each at most six digits: no prerelease or build suffix, so versions compare exactly. */
21
+ export declare function isCanonClientVersion(value: unknown): value is string;
22
+ export declare function formatCanonClientHeader(client: CanonClientIdentity): string;
23
+ /** A malformed header is treated as absent. */
24
+ export declare function parseCanonClientHeader(value: unknown): CanonClientIdentity | null;
25
+ export declare function compareCanonClientVersions(left: string, right: string): number;
26
+ /** `mlsRollout/clientFloor`: per-kind minimums. A kind it does not name has none. */
27
+ export interface CanonClientFloor {
28
+ readonly minimum: Readonly<Partial<Record<CanonClientKind, string>>>;
29
+ }
30
+ /** The server-only record, in its exact shape; anything else is a broken floor, which the caller refuses rather than ignore. */
31
+ export declare function parseCanonClientFloor(data: unknown): CanonClientFloor;
32
+ /** The refusal's message, naming the minimum, so a runner or plugin log says what to install. */
33
+ export declare function canonClientUpdateMessage(refusal: {
34
+ kind: CanonClientKind | null;
35
+ minimum: string | null;
36
+ }): string;
37
+ /** The refusal a request gets under a floor, or null when it passes: no valid header, or a version below its kind's minimum. */
38
+ export declare function canonClientBelowFloor(floor: CanonClientFloor, header: unknown): {
39
+ kind: CanonClientKind | null;
40
+ minimum: string | null;
41
+ } | null;
@@ -0,0 +1,146 @@
1
+ import type { ListConversationsResult } from './verbContract.js';
2
+ import type { DiscoverAgentsInput, DiscoverAgentsResult } from './agentDirectory.js';
3
+ /** The deliberately small policy vocabulary for principal communication. */
4
+ export type CommunicationRule = 'open' | 'approval-required' | 'closed';
5
+ /** Missing or invalid policy never widens access. */
6
+ export declare function readCommunicationRule(value: unknown): CommunicationRule;
7
+ /** Canon conversation selection is principal-neutral; a conversation is a runtime session boundary. */
8
+ export type DirectConversationSelection = {
9
+ mode: 'latest_or_new';
10
+ } | {
11
+ mode: 'new';
12
+ } | {
13
+ mode: 'specific';
14
+ conversationId: string;
15
+ };
16
+ export type CommunicateInput = ({
17
+ action: 'discover_agents';
18
+ } & DiscoverAgentsInput) | {
19
+ action: 'message_existing';
20
+ conversationId: string;
21
+ text: string;
22
+ messageId?: string;
23
+ /** Private note for the resident Codex's next ordinary room turn. */
24
+ privateContext?: string;
25
+ /** Optional short private description of this local Codex task. */
26
+ sourceLabel?: string;
27
+ } | {
28
+ action: 'start_direct' | 'start_conversation';
29
+ principalId: string;
30
+ text: string;
31
+ selection?: DirectConversationSelection;
32
+ messageId?: string;
33
+ } | {
34
+ action: 'create_group' | 'create_conversation';
35
+ name?: string;
36
+ memberIds: string[];
37
+ } | {
38
+ action: 'forward_message';
39
+ sourceConversationId: string;
40
+ targetConversationId: string;
41
+ messageId: string;
42
+ selfContextId?: string;
43
+ text?: string;
44
+ } | {
45
+ action: 'share_contact';
46
+ conversationId: string;
47
+ contactUserId: string;
48
+ text?: string;
49
+ messageId?: string;
50
+ } | {
51
+ action: 'manage_group_members' | 'manage_participants';
52
+ conversationId: string;
53
+ userId: string;
54
+ operation: 'add' | 'remove';
55
+ } | {
56
+ action: 'list_conversations';
57
+ limit?: number;
58
+ } | {
59
+ action: 'leave_conversation';
60
+ conversationId: string;
61
+ };
62
+ export type CommunicateResult = ({
63
+ status: 'listed';
64
+ } & ListConversationsResult) | {
65
+ status: 'left';
66
+ conversationId: string;
67
+ } | ({
68
+ status: 'discovered';
69
+ } & DiscoverAgentsResult) | {
70
+ status: 'messaged';
71
+ conversationId: string;
72
+ messageId: string;
73
+ created?: boolean;
74
+ reused?: boolean;
75
+ } | {
76
+ status: 'requested' | 'pending';
77
+ requestId: string;
78
+ } | {
79
+ status: 'created';
80
+ conversationId: string;
81
+ added: string[];
82
+ pending: Array<{
83
+ userId: string;
84
+ requestId: string;
85
+ }>;
86
+ skipped: Array<{
87
+ userId: string;
88
+ reason: string;
89
+ }>;
90
+ } | {
91
+ status: 'forwarded';
92
+ messageId: string;
93
+ targetConversationId: string;
94
+ } | {
95
+ status: 'shared';
96
+ conversationId: string;
97
+ messageId: string;
98
+ } | {
99
+ status: 'added' | 'removed';
100
+ conversationId: string;
101
+ userId: string;
102
+ } | {
103
+ status: 'approval_required';
104
+ reason: string;
105
+ } | {
106
+ status: 'blocked' | 'unavailable';
107
+ reason: string;
108
+ };
109
+ /** Principal-neutral app/SDK command. Humans may open a composer before sending. */
110
+ export interface StartDirectInput {
111
+ targetUserId: string;
112
+ /** `withheld`: the client holds a line it sends only encrypted. Canon reserves `messageId` and answers
113
+ * `openingText: 'deferred'` for an encrypted room, and `opening-text-required` (writing nothing) for a plaintext one,
114
+ * which the client then starts again with its text (mls-rooms-by-default.md §2a.9). */
115
+ opener?: {
116
+ text: string;
117
+ messageId?: string;
118
+ } | {
119
+ withheld: true;
120
+ messageId: string;
121
+ } | null;
122
+ selection?: DirectConversationSelection;
123
+ }
124
+ export type StartDirectResult = {
125
+ status: 'opened' | 'messaged';
126
+ conversationId: string;
127
+ messageId?: string;
128
+ created?: boolean;
129
+ reused?: boolean;
130
+ /** The room is encrypted, so Canon stored no opening text: the requester's client sends it encrypted, under
131
+ * `messageId` (mls-rooms-by-default.md §2a.9). */
132
+ openingText?: 'deferred';
133
+ } | {
134
+ status: 'requested' | 'pending';
135
+ requestId: string;
136
+ /** The room the request made, which the requester may open and write in (§2a.2). An encrypted room stores no
137
+ * opener: the requester's client sends it into `conversationId` under `messageId` once the request's other
138
+ * approvers have approved and the target's device is in (§2a.4, §2a.9). */
139
+ conversationId?: string;
140
+ messageId?: string;
141
+ openingText?: 'deferred';
142
+ } | {
143
+ status: 'blocked' | 'unavailable';
144
+ reason: string;
145
+ };
146
+ export declare function parseDirectConversationSelection(value: unknown): DirectConversationSelection;