@canonmsg/agent-sdk 11.2.1 → 12.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.
Files changed (188) hide show
  1. package/README.md +171 -536
  2. package/dist/chunks/chunk-6VK4UZHJ.js +2806 -0
  3. package/dist/chunks/chunk-FPQFTTND.js +4899 -0
  4. package/dist/chunks/chunk-OLJ7H4E2.js +14705 -0
  5. package/dist/chunks/mls-crypto-NZDNSPAO.js +10 -0
  6. package/dist/cli.js +198 -0
  7. package/dist/drivers/claude.d.ts +36 -0
  8. package/dist/drivers/code.d.ts +18 -0
  9. package/dist/drivers/codex.d.ts +37 -0
  10. package/dist/index.d.ts +12 -25
  11. package/dist/index.js +69 -13
  12. package/dist/internal/backend-contracts/agentBehaviorPolicy.d.ts +122 -0
  13. package/dist/internal/backend-contracts/agentDirectory.d.ts +32 -0
  14. package/dist/internal/backend-contracts/agentOrigin.d.ts +23 -0
  15. package/dist/internal/backend-contracts/agentSearch.d.ts +17 -0
  16. package/dist/internal/backend-contracts/api-origins.generated.d.ts +4 -0
  17. package/dist/internal/backend-contracts/apiErrors.d.ts +1 -0
  18. package/dist/internal/backend-contracts/artifactActions.d.ts +159 -0
  19. package/dist/internal/backend-contracts/artifacts.d.ts +386 -0
  20. package/dist/internal/backend-contracts/communication.d.ts +131 -0
  21. package/dist/internal/backend-contracts/conversationMembership.d.ts +28 -0
  22. package/dist/internal/backend-contracts/deliveryObservation.d.ts +23 -0
  23. package/dist/internal/backend-contracts/diffRedaction.d.ts +6 -0
  24. package/dist/internal/backend-contracts/endpoint-unread.d.ts +4 -0
  25. package/dist/internal/backend-contracts/endpoint.d.ts +103 -0
  26. package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +37 -0
  27. package/dist/internal/backend-contracts/environment.d.ts +20 -0
  28. package/dist/internal/backend-contracts/externalInbound.d.ts +24 -0
  29. package/dist/internal/backend-contracts/firestoreValues.d.ts +9 -0
  30. package/dist/internal/backend-contracts/index.d.ts +48 -0
  31. package/dist/internal/backend-contracts/media-url.d.ts +6 -0
  32. package/dist/internal/backend-contracts/media.d.ts +51 -0
  33. package/dist/internal/backend-contracts/mediaDelivery.d.ts +46 -0
  34. package/dist/internal/backend-contracts/mediaTransferProtocol.d.ts +17 -0
  35. package/dist/internal/backend-contracts/membershipChange.d.ts +21 -0
  36. package/dist/internal/backend-contracts/message.d.ts +86 -0
  37. package/dist/internal/backend-contracts/messageText.d.ts +6 -0
  38. package/dist/internal/backend-contracts/mlsDevApplication.d.ts +73 -0
  39. package/dist/internal/backend-contracts/mlsDevCredential.d.ts +75 -0
  40. package/dist/internal/backend-contracts/mlsDevCredentialReconciliation.d.ts +45 -0
  41. package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +51 -0
  42. package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +74 -0
  43. package/dist/internal/backend-contracts/mlsDevGroup.d.ts +197 -0
  44. package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +47 -0
  45. package/dist/internal/backend-contracts/mlsDevKeyPackage.d.ts +42 -0
  46. package/dist/internal/backend-contracts/mlsDevKeyPackages.d.ts +55 -0
  47. package/dist/internal/backend-contracts/moderation.d.ts +7 -0
  48. package/dist/internal/backend-contracts/plaintextProcessors.d.ts +63 -0
  49. package/dist/internal/backend-contracts/preparedContent.d.ts +54 -0
  50. package/dist/internal/backend-contracts/replyAuthority.d.ts +14 -0
  51. package/dist/internal/backend-contracts/runtimeCardFields.d.ts +66 -0
  52. package/dist/internal/backend-contracts/runtimeCardStorage.d.ts +3 -0
  53. package/dist/internal/backend-contracts/runtimeDescriptor.d.ts +88 -0
  54. package/dist/internal/backend-contracts/selfContext.d.ts +9 -0
  55. package/dist/internal/backend-contracts/turnProtocol.d.ts +43 -0
  56. package/dist/internal/backend-contracts/verbContract.d.ts +848 -0
  57. package/dist/internal/backend-contracts/verbSchemas.d.ts +1707 -0
  58. package/dist/internal/backend-contracts/verbWire.d.ts +493 -0
  59. package/dist/internal/backend-contracts/webAuth.d.ts +8 -0
  60. package/dist/internal/backend-contracts/workSessions.d.ts +205 -0
  61. package/dist/internal/core/agent-profiles.d.ts +69 -0
  62. package/dist/internal/core/agent-resolver.d.ts +49 -0
  63. package/dist/internal/core/agent-session.d.ts +12 -0
  64. package/dist/internal/core/approval-format.d.ts +26 -0
  65. package/dist/internal/core/approval-manager.d.ts +43 -0
  66. package/dist/internal/core/approval-types.d.ts +74 -0
  67. package/dist/internal/core/artifacts.d.ts +262 -0
  68. package/dist/internal/core/attached-native-session.d.ts +174 -0
  69. package/dist/internal/core/attached-session-file-store.d.ts +3 -0
  70. package/dist/internal/core/base-url.d.ts +1 -0
  71. package/dist/internal/core/cli-metadata.d.ts +13 -0
  72. package/dist/internal/core/client.d.ts +486 -0
  73. package/dist/internal/core/completed-output-journal.d.ts +39 -0
  74. package/dist/internal/core/constants.d.ts +4 -0
  75. package/dist/internal/core/control-poller.d.ts +221 -0
  76. package/dist/internal/core/endpoint-client.d.ts +43 -0
  77. package/dist/internal/core/exclusive-json-file-store.d.ts +7 -0
  78. package/dist/internal/core/execution-environment-mode.d.ts +8 -0
  79. package/dist/internal/core/execution-environment.d.ts +55 -0
  80. package/dist/internal/core/gifs.d.ts +35 -0
  81. package/dist/internal/core/group-context.d.ts +25 -0
  82. package/dist/internal/core/host-runtime.d.ts +257 -0
  83. package/dist/internal/core/inbound-frame.d.ts +64 -0
  84. package/dist/internal/core/index.d.ts +107 -0
  85. package/dist/internal/core/local-runtime-catalog.d.ts +131 -0
  86. package/dist/internal/core/message-format.d.ts +13 -0
  87. package/dist/internal/core/native-session-interaction.d.ts +44 -0
  88. package/dist/internal/core/node-media.d.ts +6 -0
  89. package/dist/internal/core/policy.d.ts +2 -0
  90. package/dist/internal/core/provenance.d.ts +31 -0
  91. package/dist/internal/core/registration-cli.d.ts +40 -0
  92. package/dist/internal/core/registration-profile.d.ts +10 -0
  93. package/dist/internal/core/registration-session.d.ts +55 -0
  94. package/dist/internal/core/registration.d.ts +21 -0
  95. package/dist/internal/core/retry.d.ts +122 -0
  96. package/dist/internal/core/rtdb-rest.d.ts +145 -0
  97. package/dist/internal/core/runtime-cards.d.ts +331 -0
  98. package/dist/internal/core/runtime-descriptor.d.ts +75 -0
  99. package/dist/internal/core/runtime-endpoints.d.ts +26 -0
  100. package/dist/internal/core/runtime-heartbeat.d.ts +29 -0
  101. package/dist/internal/core/runtime-presentation.d.ts +35 -0
  102. package/dist/internal/core/runtime-request-manager.d.ts +284 -0
  103. package/dist/internal/core/runtime-state-publisher.d.ts +42 -0
  104. package/dist/internal/core/self-context.d.ts +61 -0
  105. package/dist/internal/core/silent-turn.d.ts +86 -0
  106. package/dist/internal/core/stream.d.ts +77 -0
  107. package/dist/internal/core/turn-output-controller.d.ts +69 -0
  108. package/dist/internal/core/turn-protocol.d.ts +33 -0
  109. package/dist/internal/core/turn-verbosity.d.ts +97 -0
  110. package/dist/internal/core/types.d.ts +1075 -0
  111. package/dist/internal/core/typing-status-publisher.d.ts +14 -0
  112. package/dist/internal/core/unified-diff.d.ts +35 -0
  113. package/dist/internal/core/work-session-provider.d.ts +29 -0
  114. package/dist/internal/core/workspace-discovery.d.ts +17 -0
  115. package/dist/internal/endpoint/artifact-images.d.ts +60 -0
  116. package/dist/internal/endpoint/artifact-reducer.d.ts +35 -0
  117. package/dist/internal/endpoint/artifact-views.d.ts +113 -0
  118. package/dist/internal/endpoint/artifacts.d.ts +75 -0
  119. package/dist/internal/endpoint/delivery.d.ts +47 -0
  120. package/dist/internal/endpoint/engine.d.ts +219 -0
  121. package/dist/internal/endpoint/ephemeral.d.ts +8 -0
  122. package/dist/internal/endpoint/events.d.ts +32 -0
  123. package/dist/internal/endpoint/external-inbound.d.ts +36 -0
  124. package/dist/internal/endpoint/handoff.d.ts +50 -0
  125. package/dist/internal/endpoint/history.d.ts +22 -0
  126. package/dist/internal/endpoint/image-generation-errors.d.ts +2 -0
  127. package/dist/internal/endpoint/inbound.d.ts +29 -0
  128. package/dist/internal/endpoint/index.d.ts +32 -0
  129. package/dist/internal/endpoint/media.d.ts +172 -0
  130. package/dist/internal/endpoint/migration.d.ts +50 -0
  131. package/dist/internal/endpoint/mls-crypto.d.ts +25 -0
  132. package/dist/internal/endpoint/mls-dev-client.d.ts +44 -0
  133. package/dist/internal/endpoint/mls-dev-device.d.ts +67 -0
  134. package/dist/internal/endpoint/mls-dev-groups.d.ts +114 -0
  135. package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +33 -0
  136. package/dist/internal/endpoint/mls-dev-key-packages.d.ts +42 -0
  137. package/dist/internal/endpoint/mls-dev-transport.d.ts +37 -0
  138. package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +24 -0
  139. package/dist/internal/endpoint/node-mls-custody.d.ts +15 -0
  140. package/dist/internal/endpoint/node.d.ts +7 -0
  141. package/dist/internal/endpoint/observe-query.d.ts +17 -0
  142. package/dist/internal/endpoint/portable-node-mls-custody.d.ts +23 -0
  143. package/dist/internal/endpoint/queue.d.ts +22 -0
  144. package/dist/internal/endpoint/recovery.d.ts +27 -0
  145. package/dist/internal/endpoint/retention.d.ts +7 -0
  146. package/dist/internal/endpoint/store.d.ts +22 -0
  147. package/dist/internal/endpoint/sync.d.ts +33 -0
  148. package/dist/internal/endpoint/transient-publisher.d.ts +8 -0
  149. package/dist/internal/endpoint/transport.d.ts +58 -0
  150. package/dist/media.d.ts +1 -1
  151. package/dist/media.js +42 -541
  152. package/dist/runner/runner.d.ts +37 -0
  153. package/dist/runner/types.d.ts +168 -0
  154. package/package.json +18 -5
  155. package/dist/attached-session.d.ts +0 -58
  156. package/dist/attached-session.js +0 -638
  157. package/dist/bounded-file-read.d.ts +0 -14
  158. package/dist/bounded-file-read.js +0 -34
  159. package/dist/canon-agent.d.ts +0 -236
  160. package/dist/canon-agent.js +0 -2531
  161. package/dist/debouncer.d.ts +0 -18
  162. package/dist/debouncer.js +0 -133
  163. package/dist/inbound-handoff.d.ts +0 -6
  164. package/dist/inbound-handoff.js +0 -17
  165. package/dist/managed-session-host.d.ts +0 -27
  166. package/dist/managed-session-host.js +0 -195
  167. package/dist/managed-session-setup.d.ts +0 -99
  168. package/dist/managed-session-setup.js +0 -234
  169. package/dist/realtime.d.ts +0 -62
  170. package/dist/realtime.js +0 -193
  171. package/dist/runtime-card.d.ts +0 -48
  172. package/dist/runtime-card.js +0 -64
  173. package/dist/session-manager.d.ts +0 -77
  174. package/dist/session-manager.js +0 -285
  175. package/dist/turn-streaming-request.d.ts +0 -17
  176. package/dist/turn-streaming-request.js +0 -22
  177. package/dist/turn-verbosity-option.d.ts +0 -33
  178. package/dist/turn-verbosity-option.js +0 -23
  179. package/dist/types.d.ts +0 -387
  180. package/dist/types.js +0 -1
  181. package/dist/work-session-coordination.d.ts +0 -21
  182. package/dist/work-session-coordination.js +0 -53
  183. package/dist/work-session-host.d.ts +0 -31
  184. package/dist/work-session-host.js +0 -617
  185. package/dist/work-session-interactions.d.ts +0 -12
  186. package/dist/work-session-interactions.js +0 -173
  187. package/dist/work-session-state.d.ts +0 -36
  188. package/dist/work-session-state.js +0 -62
@@ -0,0 +1,159 @@
1
+ import { type ArtifactCommandType, type ArtifactFormField, type ArtifactFormTable, type ArtifactFormValue } from './artifacts.js';
2
+ /**
3
+ * The agent-facing vocabulary of shared work: what a model, an SDK handler or
4
+ * a person asks for. An endpoint turns an action into a protocol command
5
+ * against what its author last saw; agents never write commands, revision IDs
6
+ * or command IDs. The parsers check everything that does not need the work
7
+ * itself; the shared rules (the endpoint reducer) decide the rest.
8
+ */
9
+ /** A form value as an author gives it. Core turns numeric text for number inputs (and "true"/"false" for checkboxes) into typed values. */
10
+ export type ArtifactActionValue = ArtifactFormValue;
11
+ export interface ArtifactCellAction {
12
+ row: string;
13
+ column: string;
14
+ value: ArtifactActionValue;
15
+ }
16
+ /** Without `id`, a stable row ID is generated and returned as `addedRowIds`. */
17
+ export interface ArtifactRowAction {
18
+ id?: string;
19
+ cells: Record<string, ArtifactActionValue>;
20
+ }
21
+ export declare const ARTIFACT_UPDATE_ACTION_TYPES: readonly ["chess.move", "chess.resign", "form.set", "form.fields", "image.select", "archive"];
22
+ export type ArtifactUpdateActionType = typeof ARTIFACT_UPDATE_ACTION_TYPES[number];
23
+ export type ArtifactUpdateAction =
24
+ /** SAN ("Nf3") or UCI ("g1f3"); trimmed, at most 16 characters. */
25
+ {
26
+ type: 'chess.move';
27
+ move: string;
28
+ } | {
29
+ type: 'chess.resign';
30
+ } | {
31
+ type: 'form.set';
32
+ values?: Record<string, ArtifactActionValue>;
33
+ cells?: ArtifactCellAction[];
34
+ addRows?: ArtifactRowAction[];
35
+ removeRows?: string[];
36
+ }
37
+ /** `remove` names fields; the endpoint sends each one's last-seen value, so a newer value conflicts instead of being discarded. */
38
+ | {
39
+ type: 'form.fields';
40
+ add?: ArtifactFormField[];
41
+ remove?: string[];
42
+ } | {
43
+ type: 'image.select';
44
+ variantId: string;
45
+ } | {
46
+ type: 'archive';
47
+ archived: boolean;
48
+ };
49
+ /** `opponent` (a participant ID) is host-owned: tools fill it with the person whose message started the turn. */
50
+ export type ArtifactCreateAction = {
51
+ kind: 'chess';
52
+ title: string;
53
+ playAs?: 'white' | 'black';
54
+ opponent?: string;
55
+ fen?: string;
56
+ } | {
57
+ kind: 'form';
58
+ title: string;
59
+ fields: ArtifactFormField[];
60
+ values?: Record<string, ArtifactActionValue>;
61
+ table?: ArtifactFormTable;
62
+ rows?: ArtifactRowAction[];
63
+ } | {
64
+ kind: 'image';
65
+ title: string;
66
+ };
67
+ /** The model-facing create input (`artifact_create`): kind-specific options nest under `chess` or `form`. */
68
+ export interface ArtifactCreateToolInput {
69
+ kind: 'chess' | 'form' | 'image';
70
+ title: string;
71
+ chess?: {
72
+ playAs?: 'white' | 'black';
73
+ fen?: string;
74
+ };
75
+ form?: {
76
+ fields: ArtifactFormField[];
77
+ values?: Record<string, ArtifactActionValue>;
78
+ table?: ArtifactFormTable;
79
+ rows?: ArtifactRowAction[];
80
+ };
81
+ }
82
+ /** Fractions of the image, origin top-left. */
83
+ export interface ArtifactImageRegion {
84
+ x: number;
85
+ y: number;
86
+ width: number;
87
+ height: number;
88
+ }
89
+ /** 'current' edits the current version (or starts fresh when there is none); 'new' uses the prompt alone. */
90
+ export type ArtifactImageSource = 'current' | 'new' | {
91
+ variantId: string;
92
+ };
93
+ /** Models may also give a bare version ID as `from`; the parser turns it into `{ variantId }`. */
94
+ export interface ArtifactGenerateImageAction {
95
+ prompt: string;
96
+ label: string;
97
+ from: ArtifactImageSource;
98
+ region?: ArtifactImageRegion;
99
+ }
100
+ /**
101
+ * At most one source: a local file (`path`, only where the host allows local
102
+ * files) or a message attachment (`messageId`, `attachmentIndex`). With
103
+ * neither, hosts use the image on the message that started the turn.
104
+ */
105
+ export interface ArtifactAddImageAction {
106
+ label: string;
107
+ prompt?: string;
108
+ sourceVariantId?: string;
109
+ path?: string;
110
+ messageId?: string;
111
+ attachmentIndex?: number;
112
+ }
113
+ export type ArtifactJsonSchema = Record<string, unknown>;
114
+ export interface ArtifactActionSchemas {
115
+ create: ArtifactJsonSchema;
116
+ update: ArtifactJsonSchema;
117
+ generateImage: ArtifactJsonSchema;
118
+ addImage: ArtifactJsonSchema;
119
+ }
120
+ /** The model-facing input of each action (without the work's artifactId). */
121
+ export declare function artifactActionSchemas(): ArtifactActionSchemas;
122
+ export declare const ARTIFACT_TOOL_NAMES: readonly ["artifact_list", "artifact_read", "artifact_create", "artifact_update", "artifact_generate_image", "artifact_add_image"];
123
+ export type ArtifactToolName = typeof ARTIFACT_TOOL_NAMES[number];
124
+ /** The complete model-facing input of each shared-work tool. */
125
+ export declare function artifactToolInputSchemas(): Record<ArtifactToolName, ArtifactJsonSchema>;
126
+ /** The model-facing create input (`artifact_create`). `opponent` is never taken from it. */
127
+ export declare function parseArtifactCreateToolInput(input: unknown): ArtifactCreateAction;
128
+ /** The flat create action (SDK callers), including the host-owned `opponent`. */
129
+ export declare function parseArtifactCreateAction(input: unknown): ArtifactCreateAction;
130
+ /** An `artifact_update` action, or an SDK `update` action. */
131
+ export declare function parseArtifactUpdateAction(input: unknown): ArtifactUpdateAction;
132
+ export declare function parseArtifactImageRegion(input: unknown): ArtifactImageRegion;
133
+ export declare function parseArtifactImageSource(input: unknown): ArtifactImageSource;
134
+ /** An `artifact_generate_image` input (without the work's artifactId), or an SDK `generateImage` input. */
135
+ export declare function parseArtifactGenerateImageAction(input: unknown): ArtifactGenerateImageAction;
136
+ /** An `artifact_add_image` input (without the work's artifactId). Hosts check that `path` is absolute and allowed. */
137
+ export declare function parseArtifactAddImageAction(input: unknown): ArtifactAddImageAction;
138
+ export type ArtifactActionName = 'create' | ArtifactUpdateActionType | 'image.generate' | 'image.add';
139
+ export interface ArtifactActionSemantics {
140
+ /** Who sees the result: every current member of the conversation (no narrower audience exists). */
141
+ audience: 'conversation-members';
142
+ /** What the change is judged against: the revision the author saw, the values the author saw, or nothing. */
143
+ base: 'current-revision' | 'before-values' | 'none';
144
+ conflict: string;
145
+ /** How a retried request maps to the same change. */
146
+ idempotency: string;
147
+ persistence: string;
148
+ /** What a receipt means and what decides the outcome. */
149
+ completion: string;
150
+ /** Member-authored input (action paths) that future encryption must cover: never in IDs, receipts, logs or other server-visible metadata. */
151
+ privateFields: readonly string[];
152
+ /** Server-visible routing the action needs. IDs are opaque (random or keyed per installation). */
153
+ routing: readonly string[];
154
+ /** Content a processor outside the audience receives by design. */
155
+ processorDisclosure?: readonly string[];
156
+ /** Protocol commands the action becomes. */
157
+ commands: readonly ArtifactCommandType[];
158
+ }
159
+ export declare const ARTIFACT_ACTION_SEMANTICS: Readonly<Record<ArtifactActionName, ArtifactActionSemantics>>;
@@ -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,131 @@
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
+ opener?: {
113
+ text: string;
114
+ messageId?: string;
115
+ } | null;
116
+ selection?: DirectConversationSelection;
117
+ }
118
+ export type StartDirectResult = {
119
+ status: 'opened' | 'messaged';
120
+ conversationId: string;
121
+ messageId?: string;
122
+ created?: boolean;
123
+ reused?: boolean;
124
+ } | {
125
+ status: 'requested' | 'pending';
126
+ requestId: string;
127
+ } | {
128
+ status: 'blocked' | 'unavailable';
129
+ reason: string;
130
+ };
131
+ export declare function parseDirectConversationSelection(value: unknown): DirectConversationSelection;