@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,1075 @@
1
+ import type { AgentOrigin, AgentOriginDeclaration, ArtifactContext } from '../backend-contracts/index.js';
2
+ import type { CanonControlValue, CanonRuntimeStreamingMode, CanonRuntimeDetailTier, CanonRuntimeVisibility, CanonRuntimeCommandDescriptor } from '../backend-contracts/index.js';
3
+ export type { AgentOrigin, AgentOriginDeclaration, CanonControlValue, CanonRuntimeStreamingMode, CanonRuntimeDetailTier, CanonRuntimeVisibility, CanonRuntimeActionAvailability, CanonRuntimeActionPlacement, CanonRuntimeActionCategory, CanonRuntimePrimitiveId, CanonRuntimeCommandArgumentKind, CanonRuntimeCommandArgumentChoice, CanonRuntimeCommandArgumentDescriptor, CanonRuntimeActionDispatch, CanonRuntimeActionDescriptor, CanonRuntimeCommandDescriptor, } from '../backend-contracts/index.js';
4
+ import type { ExecutionEnvironmentMode } from './execution-environment-mode.js';
5
+ import type { ResolvedAgentBehaviorPolicy } from './policy.js';
6
+ import type { DeliveryIntent, RuntimeCapabilities, TurnLifecycleState } from './turn-protocol.js';
7
+ import type { CanonSelfContext } from './self-context.js';
8
+ import type { RuntimeCardFieldType, RuntimeCardV1 } from './runtime-cards.js';
9
+ import type { CommunicationRule, SerializedAgentClientType } from '../backend-contracts/index.js';
10
+ export type { ExecutionEnvironmentMode };
11
+ export type MediaAttachmentKind = 'image' | 'audio' | 'video' | 'file';
12
+ export type VideoProcessingStatus = 'processing' | 'ready' | 'failed';
13
+ export type VideoProcessingErrorCode = 'invalid_video' | 'video_limits_exceeded' | 'video_processing_failed';
14
+ export interface MediaAttachment {
15
+ kind: MediaAttachmentKind;
16
+ url: string;
17
+ /** Server-issued identity used to retain a finalized resumable upload. */
18
+ uploadId?: string;
19
+ mimeType?: string;
20
+ fileName?: string;
21
+ sizeBytes?: number;
22
+ width?: number;
23
+ height?: number;
24
+ durationMs?: number;
25
+ thumbnailUrl?: string;
26
+ processingStatus?: VideoProcessingStatus;
27
+ processingErrorCode?: VideoProcessingErrorCode;
28
+ }
29
+ export interface ForwardedFrom {
30
+ sourceConversationId: string;
31
+ messageId: string;
32
+ }
33
+ /**
34
+ * Server-serialized contact-card payload. Emitted on messages with
35
+ * `contentType: 'contact_card'` so agents receive the referenced user's
36
+ * identity alongside the card. The referenced `userId` is addressable, but the
37
+ * recipient's communication policy still controls whether a direct message is
38
+ * delivered, requires approval, or is closed.
39
+ */
40
+ export interface ContactCardPayload {
41
+ userId: string;
42
+ canonContactId?: string;
43
+ displayName: string;
44
+ avatarUrl: string | null;
45
+ userType: 'human' | 'ai_agent';
46
+ clientType?: AgentClientType;
47
+ about?: string;
48
+ isActive?: boolean;
49
+ ownerId?: string;
50
+ ownerName?: string;
51
+ lifecycleState?: string;
52
+ }
53
+ export type InteractionKind = 'contact' | 'approval' | 'input' | 'plan' | 'card';
54
+ export interface InteractionEnvelope {
55
+ kind: InteractionKind;
56
+ requestId: string;
57
+ interactive: boolean;
58
+ responseUserId?: string;
59
+ expiresAt?: string;
60
+ schemaVersion?: string;
61
+ preview?: {
62
+ title?: string;
63
+ blockKinds?: string[];
64
+ };
65
+ response?: {
66
+ actionIds?: string[];
67
+ actionFields?: Record<string, unknown>;
68
+ questions?: Array<{
69
+ id: string;
70
+ sensitive?: boolean;
71
+ }>;
72
+ };
73
+ }
74
+ export interface CanonMessage {
75
+ id: string;
76
+ senderId: string;
77
+ senderName?: string;
78
+ senderType: 'human' | 'ai_agent';
79
+ /** Whether the sender is this agent's owner (server-computed, trusted) */
80
+ isOwner: boolean;
81
+ contentType: 'text' | 'image' | 'audio' | 'video' | 'file' | 'contact_card' | 'interaction';
82
+ text: string | null;
83
+ attachments: MediaAttachment[];
84
+ mentions: string[];
85
+ reactions?: Record<string, string[]>;
86
+ replyTo: string | null;
87
+ replyToPosition: number | null;
88
+ forwarded?: boolean;
89
+ forwardedFrom?: ForwardedFrom;
90
+ metadata?: Record<string, unknown> & {
91
+ artifactContext?: ArtifactContext;
92
+ };
93
+ contactCard?: ContactCardPayload;
94
+ /** Durable canon.card.v1 runtime card content (persists in chat history). */
95
+ runtimeCard?: RuntimeCardV1;
96
+ /** Plaintext, server-authorized interaction envelope (contentType 'interaction'). */
97
+ interaction?: InteractionEnvelope;
98
+ /** Opaque interaction payload (JSON string or ciphertext); never parsed by transport. */
99
+ body?: string;
100
+ status: 'sent' | 'read';
101
+ /** REST responses omit this field on non-deleted messages; CanonClient normalizes it to `false`. */
102
+ deleted: boolean;
103
+ createdAt: string;
104
+ /** Ephemeral SSE-only reply capability; absent from stored REST history. */
105
+ replyAuthority?: import('../backend-contracts/index.js').AgentReplyAuthorityV1;
106
+ }
107
+ export interface CanonConversation {
108
+ id: string;
109
+ type: 'direct' | 'group';
110
+ name: string | null;
111
+ topic: string | null;
112
+ memberIds: string[];
113
+ /** Compatibility routing namespace; never determines membership or permissions. */
114
+ runtimeSessionKind?: 'direct' | 'group';
115
+ membershipModel?: 'unified';
116
+ membershipRevision?: number;
117
+ participantTypes?: Record<string, 'human' | 'ai_agent'>;
118
+ participantSummary?: {
119
+ humanCount: number;
120
+ agentCount: number;
121
+ totalCount: number;
122
+ };
123
+ /** Presentation-only start for this admission; historical replay remains possible. */
124
+ historyStartAt?: string | null;
125
+ admissionId?: string | null;
126
+ isAgentChat: boolean;
127
+ behavior?: ResolvedAgentBehaviorPolicy;
128
+ hasUnread?: boolean;
129
+ lastMessage: {
130
+ text: string;
131
+ messageId: string;
132
+ senderId: string;
133
+ senderType: 'human' | 'ai_agent';
134
+ contentType: CanonMessage['contentType'];
135
+ timestamp: string;
136
+ } | null;
137
+ /**
138
+ * Live call in this conversation, or null. Optional for tolerance of
139
+ * pre-rollout serializers; the documented REST-polling call-state contract.
140
+ */
141
+ activeCall?: CanonActiveCallSummary | null;
142
+ createdAt: string;
143
+ }
144
+ /** Opt-in paging for `GET /conversations`. Omit both fields for the full list. */
145
+ export interface CanonConversationsPageOptions {
146
+ /** Page size, 1..100 (server default 50 when the parameter is present). */
147
+ limit?: number;
148
+ /** Cursor from a previous page's `nextBefore`. */
149
+ before?: string;
150
+ }
151
+ /**
152
+ * One page of conversations. Pages are cut in conversation-id order (stable
153
+ * under live traffic); each page's array is still sorted most-recent-first
154
+ * *within the page*, so concatenating pages is not globally recency-sorted.
155
+ * `nextBefore` is null when the sweep is exhausted — a short page is not a
156
+ * reliable end signal, because hidden conversations are filtered after the
157
+ * page is read.
158
+ */
159
+ export interface CanonConversationsPage {
160
+ conversations: CanonConversation[];
161
+ nextBefore: string | null;
162
+ }
163
+ export interface CanonMessagesPage {
164
+ messages: CanonMessage[];
165
+ nextBefore?: string | null;
166
+ behavior?: ResolvedAgentBehaviorPolicy;
167
+ activeSelfContextIdByMessageId?: Record<string, string>;
168
+ selfContexts?: CanonSelfContext[];
169
+ }
170
+ export interface CanonRuntimeProvenance {
171
+ conversation: {
172
+ id: string;
173
+ type: CanonConversation['type'] | 'unknown';
174
+ memberCount?: number | null;
175
+ };
176
+ sender: {
177
+ id: string;
178
+ name?: string | null;
179
+ type: CanonMessage['senderType'];
180
+ isOwner: boolean;
181
+ };
182
+ mentionedAgent: boolean;
183
+ activeSelfContext?: {
184
+ id: string;
185
+ type?: CanonSelfContext['type'] | string | null;
186
+ } | null;
187
+ }
188
+ /**
189
+ * Outcome of `CanonClient.addMember` / `agent.addMember`. The REST endpoint
190
+ * returns 201 on immediate add and 202 when a group invite is waiting for
191
+ * policy approval.
192
+ * Both are success from the protocol's perspective — distinct outcomes for
193
+ * the caller.
194
+ */
195
+ export type AddMemberResult = {
196
+ status: 'added';
197
+ } | {
198
+ status: 'pending';
199
+ requestId: string;
200
+ };
201
+ export type ContactSource = 'direct_add' | 'phone_book' | 'contact_request' | 'link' | 'qr' | 'group' | 'open_inbound_message'
202
+ /** Sentinel value emitted by stream-service when a doc lacks a source field. */
203
+ | 'unknown';
204
+ /** A single entry from the agent's `users/{agentId}/contacts/` subcollection. */
205
+ export interface CanonContact {
206
+ /** The contact's userId. */
207
+ id: string;
208
+ source: ContactSource;
209
+ addedAt: string | null;
210
+ displayNameOverride: string | null;
211
+ }
212
+ export type ContactAddedPayload = CanonContact;
213
+ export type ContactRemovedPayload = {
214
+ id: string;
215
+ };
216
+ export type ResolvedAdmissionState = 'self' | 'not-found' | 'allowed' | 'request-required' | 'pending-outbound' | 'blocked' | 'inactive';
217
+ export interface ResolvedAdmissionTargetSummary {
218
+ id: string;
219
+ canonContactId?: string;
220
+ displayName?: string;
221
+ avatarUrl?: string | null;
222
+ about?: string;
223
+ userType?: 'human' | 'ai_agent';
224
+ discoverable?: boolean;
225
+ shareable?: boolean;
226
+ inboundPolicy?: CommunicationRule;
227
+ outboundPolicy?: CommunicationRule;
228
+ groupJoinPolicy?: CommunicationRule;
229
+ }
230
+ export interface ResolvedTargetAdmissionPayload {
231
+ state: ResolvedAdmissionState;
232
+ canMessage: boolean;
233
+ canRequestContact: boolean;
234
+ isContact: boolean;
235
+ pendingRequestId?: string;
236
+ blockedByViewer?: boolean;
237
+ blockedByTarget?: boolean;
238
+ }
239
+ export type ResolveAdmissionTargetInput = {
240
+ targetUserId: string;
241
+ canonContactId?: never;
242
+ } | {
243
+ canonContactId: string;
244
+ targetUserId?: never;
245
+ };
246
+ export interface CanonResolveAdmissionResult {
247
+ resolvedTargetUserId?: string | null;
248
+ target: ResolvedAdmissionTargetSummary | null;
249
+ admission: ResolvedTargetAdmissionPayload;
250
+ }
251
+ export type AgentClientType = SerializedAgentClientType;
252
+ export interface ResolvedAdmission {
253
+ discoverable: boolean;
254
+ inboundPolicy: CommunicationRule;
255
+ outboundPolicy?: CommunicationRule;
256
+ groupJoinPolicy: CommunicationRule;
257
+ }
258
+ /** Declares what session controls an agent type supports. */
259
+ export interface AgentCapabilities {
260
+ supportsModelSwitch: boolean;
261
+ supportsPermissionMode: boolean;
262
+ /**
263
+ * Whether permissionMode can be changed mid-session. When undefined,
264
+ * defaults to `supportsPermissionMode` — keep the UI chip non-interactive
265
+ * for agents whose approval mode is locked at session creation.
266
+ */
267
+ supportsRuntimePermissionMode?: boolean;
268
+ supportsEffort: boolean;
269
+ supportsSessionState: boolean;
270
+ supportsInterrupt: boolean;
271
+ supportsQueue?: boolean;
272
+ supportsInterleave?: boolean;
273
+ /**
274
+ * Whether the agent can present a plan for approval before executing
275
+ * (Mac-app "plan mode"). First-class so clients can advertise/query it
276
+ * instead of inferring it from the descriptor's turnModes shape.
277
+ */
278
+ supportsPlanMode?: boolean;
279
+ /** Whether the agent asks the user structured questions (AskUserQuestion-style). */
280
+ supportsQuestions?: boolean;
281
+ }
282
+ export interface ModelOption {
283
+ value: string;
284
+ label: string;
285
+ description?: string;
286
+ /** This option may only be selected by the agent owner or the agent itself. */
287
+ ownerOnly?: boolean;
288
+ workspaceRootId?: string;
289
+ workspaceRelativePath?: string;
290
+ source?: WorkspaceOptionSource;
291
+ }
292
+ export type WorkspaceOptionSource = 'default' | 'explicit' | 'discovered';
293
+ export interface WorkspaceOption {
294
+ id: string;
295
+ label: string;
296
+ description?: string;
297
+ workspaceRootId?: string;
298
+ workspaceRelativePath?: string;
299
+ source?: WorkspaceOptionSource;
300
+ }
301
+ export interface CanonWorkspaceRootMetadata {
302
+ id: string;
303
+ label: string;
304
+ description?: string;
305
+ defaultRelativePath?: string | null;
306
+ }
307
+ export type RuntimeControlValueSource = 'applied' | 'requested' | 'host-default' | 'route-default' | 'unknown';
308
+ export interface RuntimeControlState {
309
+ value: CanonControlValue | null;
310
+ source: RuntimeControlValueSource;
311
+ appliedAt?: number;
312
+ }
313
+ export type CanonControlAvailability = 'setup' | 'live' | 'setup_and_live';
314
+ export type CanonControlLiveBehavior = 'immediate' | 'next_turn' | 'none';
315
+ export type CanonControlSelectionPolicy = 'inherit' | 'required_explicit';
316
+ export type CanonRuntimeVoiceMode = 'realtime';
317
+ export type CanonRuntimeSurfaceMode = 'host' | 'channel' | 'limited_channel' | 'operator';
318
+ export type CanonRuntimePresentationPreset = 'normal' | 'minimal' | 'full';
319
+ export type CanonRuntimePresentationField = 'model' | 'permissionMode' | 'effort' | 'workspace' | 'executionMode' | 'contextUsage' | 'cwd' | 'branch' | 'worktreePath' | 'workspaceRoot' | 'workspaceRelativePath' | 'fallbackReason';
320
+ export interface CanonRuntimePresentationHint {
321
+ visibility?: CanonRuntimeVisibility;
322
+ tier?: CanonRuntimeDetailTier;
323
+ sensitive?: boolean;
324
+ }
325
+ export interface CanonRuntimePresentationPolicy {
326
+ preset?: CanonRuntimePresentationPreset;
327
+ fields?: Partial<Record<CanonRuntimePresentationField, CanonRuntimePresentationHint>>;
328
+ }
329
+ export type CanonRuntimeFactGroup = 'connection' | 'route' | 'runtime' | 'model' | 'session' | 'account' | 'limits';
330
+ export type CanonRuntimeInventoryStatus = 'ready' | 'auth_needed' | 'unknown' | 'configured' | 'running' | 'error';
331
+ export type CanonRuntimeStatusTone = 'default' | 'success' | 'warning' | 'danger';
332
+ export type CanonRuntimeTurnModeScope = 'next_turn' | 'session';
333
+ export type CanonRuntimeTurnModeActivation = {
334
+ kind: 'message_metadata';
335
+ value: string;
336
+ } | {
337
+ kind: 'control';
338
+ controlId: string;
339
+ value: CanonControlValue;
340
+ };
341
+ export interface CanonRuntimeTurnModeDescriptor {
342
+ id: string;
343
+ label: string;
344
+ description?: string;
345
+ scope: CanonRuntimeTurnModeScope;
346
+ default?: boolean;
347
+ ownerOnly?: boolean;
348
+ aliases?: ReadonlyArray<string>;
349
+ activation?: CanonRuntimeTurnModeActivation;
350
+ }
351
+ export interface CanonControlDescriptor {
352
+ id: string;
353
+ label: string;
354
+ options?: ReadonlyArray<ModelOption>;
355
+ defaultValue?: CanonControlValue | null;
356
+ availability: CanonControlAvailability;
357
+ liveBehavior: CanonControlLiveBehavior;
358
+ selectionPolicy: CanonControlSelectionPolicy;
359
+ description?: string;
360
+ visibility?: CanonRuntimeVisibility;
361
+ tier?: CanonRuntimeDetailTier;
362
+ sensitive?: boolean;
363
+ }
364
+ export interface CanonRuntimeRichCardCapability {
365
+ schema: 'canon.card.v1';
366
+ lifecycle?: 'blocking_requires_action';
367
+ responder?: 'agent_owner';
368
+ result?: 'action_or_values';
369
+ maxTimeoutMs?: number;
370
+ blockKinds: ReadonlyArray<'summary' | 'metricGrid' | 'chart' | 'table' | 'list' | 'callout' | 'actions' | 'mediaPreview' | 'details'>;
371
+ actionFieldTypes?: ReadonlyArray<RuntimeCardFieldType>;
372
+ native?: boolean;
373
+ }
374
+ export interface CanonRuntimeCardCapabilities {
375
+ rich?: CanonRuntimeRichCardCapability;
376
+ }
377
+ export interface CanonRuntimeVoiceCapabilities {
378
+ modes: ReadonlyArray<CanonRuntimeVoiceMode>;
379
+ provider?: string;
380
+ supportsTranscript?: boolean;
381
+ supportsAudioOutput?: boolean;
382
+ supportsBargeIn?: boolean;
383
+ }
384
+ export interface CanonRuntimeDescriptor {
385
+ coreControls: ReadonlyArray<CanonControlDescriptor>;
386
+ runtimeControls?: ReadonlyArray<CanonControlDescriptor>;
387
+ commands?: ReadonlyArray<CanonRuntimeCommandDescriptor>;
388
+ turnModes?: ReadonlyArray<CanonRuntimeTurnModeDescriptor>;
389
+ runtimeCards?: CanonRuntimeCardCapabilities;
390
+ voice?: CanonRuntimeVoiceCapabilities;
391
+ /**
392
+ * Optional setup-time local roots advertised by a runtime. These are
393
+ * metadata only for now; existing session config still selects concrete
394
+ * workspace IDs until root-relative directory selection lands.
395
+ */
396
+ workspaceRoots?: ReadonlyArray<CanonWorkspaceRootMetadata>;
397
+ writableRoots?: ReadonlyArray<CanonWorkspaceRootMetadata>;
398
+ supportsInterrupt?: boolean;
399
+ supportsInputInterrupt?: boolean;
400
+ /**
401
+ * Fidelity of live text exposed through Canon's streaming bubble path.
402
+ * `delta` means token/content deltas, `block` means chunked live previews,
403
+ * `snapshot` means completed assistant-message snapshots, and `status`
404
+ * means activity/tool state without live assistant text.
405
+ */
406
+ streamingTextMode?: CanonRuntimeStreamingMode;
407
+ /**
408
+ * Runtime-owned presentation policy for built-in Canon detail fields.
409
+ * Hidden fields are redacted before public/member-readable runtime payloads
410
+ * are published; clients only render what remains.
411
+ */
412
+ presentation?: CanonRuntimePresentationPolicy;
413
+ /**
414
+ * Contact-graph and admission actions this runtime exposes through the
415
+ * agent SDK. Plugins set this to advertise which tools they will surface
416
+ * to the LLM (e.g., block-user, request-contact). When omitted, no
417
+ * admission actions are advertised.
418
+ */
419
+ admissionActions?: import('./turn-protocol.js').HostAdmissionActionCapabilities;
420
+ }
421
+ export interface CanonRuntimeExecutionMetadata {
422
+ resolvedWorkspaceLabel?: string | null;
423
+ resolvedCwd?: string | null;
424
+ workspaceRootId?: string | null;
425
+ workspaceRelativePath?: string | null;
426
+ executionMode?: ExecutionEnvironmentMode | null;
427
+ executionBranch?: string | null;
428
+ worktreePath?: string | null;
429
+ fallbackReason?: string | null;
430
+ }
431
+ export interface CanonRuntimeStatusItem {
432
+ id: string;
433
+ label: string;
434
+ value: string;
435
+ tone?: CanonRuntimeStatusTone;
436
+ tier?: CanonRuntimeDetailTier;
437
+ sensitive?: boolean;
438
+ visibility?: CanonRuntimeVisibility;
439
+ source?: RuntimeControlValueSource;
440
+ }
441
+ export interface CanonRuntimeFact {
442
+ id: string;
443
+ label: string;
444
+ value: string;
445
+ group: CanonRuntimeFactGroup;
446
+ tier?: CanonRuntimeDetailTier;
447
+ sensitive?: boolean;
448
+ visibility?: CanonRuntimeVisibility;
449
+ tone?: 'neutral' | 'good' | 'warning' | 'danger';
450
+ copyable?: boolean;
451
+ updatedAt?: number;
452
+ }
453
+ export type CanonRuntimeActivityKind = 'run' | 'tool' | 'command_output' | 'plan' | 'approval' | 'artifact' | 'compaction' | 'status';
454
+ export type CanonRuntimeActivityStatus = 'running' | 'completed' | 'failed' | 'blocked' | 'pending';
455
+ export interface CanonRuntimeActivityItem {
456
+ id: string;
457
+ runId?: string;
458
+ kind: CanonRuntimeActivityKind;
459
+ title: string;
460
+ status: CanonRuntimeActivityStatus;
461
+ summary?: string;
462
+ detail?: string;
463
+ progressText?: string;
464
+ startedAt?: number;
465
+ updatedAt: number;
466
+ endedAt?: number;
467
+ visibility?: CanonRuntimeVisibility;
468
+ tier?: CanonRuntimeDetailTier;
469
+ sensitive?: boolean;
470
+ actions?: ReadonlyArray<CanonRuntimeCommandDescriptor>;
471
+ }
472
+ export type TurnOutputBlockKind = 'text' | 'tool' | 'plan' | 'approval' | 'input' | 'status';
473
+ export type TurnOutputBlockStatus = 'running' | 'completed' | 'failed' | 'pending' | 'blocked';
474
+ export interface TurnOutputBlock {
475
+ id: string;
476
+ turnId: string;
477
+ kind: TurnOutputBlockKind;
478
+ status: TurnOutputBlockStatus;
479
+ sequence: number;
480
+ title?: string;
481
+ text?: string;
482
+ summary?: string;
483
+ detail?: string;
484
+ createdAt?: number;
485
+ updatedAt?: number;
486
+ }
487
+ export type CanonUnifiedDiffFileStatus = 'modified' | 'created' | 'deleted' | 'renamed';
488
+ export interface CanonUnifiedDiffFile {
489
+ /** New path of the file (repo-relative where possible). */
490
+ path: string;
491
+ /** Previous path — only meaningful for `renamed` files. */
492
+ oldPath?: string;
493
+ status: CanonUnifiedDiffFileStatus;
494
+ /**
495
+ * Unified hunk text (`@@ … @@` headers plus +/-/context lines). Absent when
496
+ * the hunk text was dropped to honor the payload budget — the file entry
497
+ * still renders as a path + counts header.
498
+ */
499
+ diff?: string;
500
+ /** True when this file's hunk text was clipped or dropped for size. */
501
+ truncated?: boolean;
502
+ /**
503
+ * True when hunk text was withheld because the path or content looked
504
+ * secret-bearing (.env-style files, private-key blocks). Clients label the
505
+ * entry instead of rendering an empty diff.
506
+ */
507
+ suppressed?: boolean;
508
+ additions?: number;
509
+ deletions?: number;
510
+ }
511
+ /**
512
+ * File-change preview attached to runtime approval requests so Canon clients
513
+ * can show the full diff before the owner approves — parity with native
514
+ * habitats (Claude Code TUI, Codex Mac app). Size-disciplined via
515
+ * {@link truncateUnifiedDiff}; renderers must honor the `truncated` flags.
516
+ */
517
+ export interface CanonUnifiedDiff {
518
+ files: CanonUnifiedDiffFile[];
519
+ /** True when files were dropped or clipped to honor the payload budget. */
520
+ truncated?: boolean;
521
+ }
522
+ export interface CanonRuntimeInventoryEntry {
523
+ id: string;
524
+ label: string;
525
+ status?: CanonRuntimeInventoryStatus;
526
+ description?: string;
527
+ tier?: CanonRuntimeDetailTier;
528
+ sensitive?: boolean;
529
+ visibility?: CanonRuntimeVisibility;
530
+ }
531
+ export interface CanonRuntimeInventory {
532
+ id: string;
533
+ label: string;
534
+ entries: ReadonlyArray<CanonRuntimeInventoryEntry>;
535
+ tier?: CanonRuntimeDetailTier;
536
+ sensitive?: boolean;
537
+ visibility?: CanonRuntimeVisibility;
538
+ }
539
+ export interface RuntimeInfoPayload {
540
+ descriptor: CanonRuntimeDescriptor;
541
+ surfaceMode?: CanonRuntimeSurfaceMode;
542
+ surfaceLabel?: string;
543
+ /**
544
+ * Prominent capability warning surfaced in the session strip (not just the
545
+ * details panel) — e.g. a degraded transport that silently disables
546
+ * approval gates. Keep it one sentence with a concrete remedy.
547
+ */
548
+ warning?: string;
549
+ facts?: ReadonlyArray<CanonRuntimeFact>;
550
+ statusItems?: ReadonlyArray<CanonRuntimeStatusItem>;
551
+ inventories?: ReadonlyArray<CanonRuntimeInventory>;
552
+ execution?: CanonRuntimeExecutionMetadata | null;
553
+ notes?: ReadonlyArray<string>;
554
+ updatedAt?: number;
555
+ }
556
+ /** Capability map keyed by clientType. Add new agent types here. */
557
+ export declare const AGENT_CAPABILITIES: Record<AgentClientType, AgentCapabilities>;
558
+ /** Trusted agent identity & access context, provided by the server */
559
+ export interface AgentContext {
560
+ agentId: string;
561
+ /** Authenticated ownership generation; rotation within a generation is stable. */
562
+ ownershipVersion: number;
563
+ /** Server-created new-principal marker; initialization still binds the installation atomically. */
564
+ endpointBootstrapEligible?: boolean;
565
+ canonContactId?: string;
566
+ displayName?: string;
567
+ avatarUrl?: string | null;
568
+ description?: string | null;
569
+ ownerId: string;
570
+ ownerName: string;
571
+ discoverable: boolean;
572
+ inboundPolicy: CommunicationRule;
573
+ outboundPolicy: CommunicationRule;
574
+ groupJoinPolicy: CommunicationRule;
575
+ /** Self-reported source attribution, never an identity or permission. */
576
+ origin?: AgentOrigin;
577
+ /** Identifies the agent's client platform for UI feature detection */
578
+ clientType?: AgentClientType;
579
+ defaultBehavior?: ResolvedAgentBehaviorPolicy;
580
+ }
581
+ export interface UpdateAgentProfileOptions {
582
+ name?: string;
583
+ avatarUrl?: string | null;
584
+ description?: string;
585
+ }
586
+ export interface CanonTurnDispatch {
587
+ kind: 'run_turn' | 'observe_only';
588
+ reason: string;
589
+ addressed: boolean;
590
+ policyVersion?: string;
591
+ }
592
+ export interface MessageCreatedPayload {
593
+ conversationId: string;
594
+ /**
595
+ * Server-issued, one-shot authority for replying to this exact inbound
596
+ * message. Hosts must keep it out of model-visible input and attach it only
597
+ * to the reply produced by this turn.
598
+ */
599
+ replyAuthority?: import('../backend-contracts/index.js').AgentReplyAuthorityV1;
600
+ behavior?: ResolvedAgentBehaviorPolicy;
601
+ activeSelfContextId?: string | null;
602
+ selfContexts?: CanonSelfContext[];
603
+ provenance?: CanonRuntimeProvenance;
604
+ /** Server-computed turn dispatch decision. Runtimes should only start turns for `run_turn`. */
605
+ turnDispatch?: CanonTurnDispatch;
606
+ message: {
607
+ id: string;
608
+ senderId: string;
609
+ senderName?: string;
610
+ senderType?: 'human' | 'ai_agent';
611
+ /** Whether the sender is this agent's owner (server-computed, trusted) */
612
+ isOwner?: boolean;
613
+ text?: string;
614
+ contentType?: 'text' | 'image' | 'audio' | 'video' | 'file' | 'contact_card' | 'interaction';
615
+ attachments?: MediaAttachment[];
616
+ replyTo?: string;
617
+ replyToPosition?: number;
618
+ forwarded?: boolean;
619
+ forwardedFrom?: ForwardedFrom;
620
+ mentions?: string[];
621
+ reactions?: Record<string, string[]>;
622
+ createdAt?: string;
623
+ /** Structured metadata for rich UI (approval cards, etc.) */
624
+ metadata?: Record<string, unknown> & {
625
+ artifactContext?: ArtifactContext;
626
+ };
627
+ /** Populated when `contentType === 'contact_card'`. */
628
+ contactCard?: ContactCardPayload;
629
+ };
630
+ }
631
+ export interface MessageUpdatedPayload {
632
+ conversationId: string;
633
+ messageId: string;
634
+ actorId?: string;
635
+ updatedAt?: string;
636
+ changes: {
637
+ reactions?: Record<string, string[]>;
638
+ /** Canonical ready attachments after asynchronous media processing. */
639
+ attachments?: MediaAttachment[];
640
+ [key: string]: unknown;
641
+ };
642
+ }
643
+ export interface TypingPayload {
644
+ conversationId: string;
645
+ userId: string;
646
+ isTyping: boolean;
647
+ status?: 'thinking' | 'typing';
648
+ timestamp?: number;
649
+ }
650
+ export interface PresencePayload {
651
+ userId: string;
652
+ online: boolean;
653
+ }
654
+ export interface RuntimeUpdatedPayload {
655
+ conversationId: string;
656
+ agentId: string;
657
+ runtime: AgentRuntime | null;
658
+ runtimeInfo?: RuntimeInfoPayload | null;
659
+ agentSession: AgentSessionSnapshot | null;
660
+ }
661
+ export interface TurnUpdatedPayload {
662
+ conversationId: string;
663
+ agentId: string;
664
+ turn: import('./turn-protocol.js').TurnState | null;
665
+ }
666
+ /**
667
+ * Observe-only notice that the participation gate suppressed a turn this
668
+ * agent would otherwise have been dispatched (cap reached, mention required,
669
+ * agent-to-agent disabled). Hosts must not run a turn off this event; it
670
+ * exists so a benched agent can tell deliberate policy from a dead stream.
671
+ */
672
+ export interface ParticipationSuppressedPayload {
673
+ conversationId: string;
674
+ /** The triggering message whose dispatch was suppressed. */
675
+ messageId: string;
676
+ /** Machine code, e.g. 'agent_turn_limit_reached' | 'group_mention_required'. */
677
+ reasonCode: string;
678
+ /** Human-readable form of the same reason. */
679
+ reason: string;
680
+ /** ISO timestamp stamped by stream-service at suppression time. */
681
+ suppressedAt: string;
682
+ }
683
+ export type RuntimeControlEventKind = 'interaction_response' | 'session' | 'signal' | 'primitive' | 'runtimeInput' | 'runtimeCard' | 'runtimeApproval';
684
+ export interface RuntimeControlEventPayload {
685
+ conversationId: string;
686
+ agentId: string;
687
+ kind: RuntimeControlEventKind;
688
+ requestId?: string;
689
+ updatedAt?: number;
690
+ value: Record<string, unknown>;
691
+ /** Conversation-scoped reply capability for an accepted interaction receipt. */
692
+ replyAuthority?: import('../backend-contracts/index.js').AgentReplyAuthorityV1;
693
+ }
694
+ export interface CanonMembershipChange {
695
+ addedMemberIds: string[];
696
+ removedMemberIds: string[];
697
+ memberCount: number;
698
+ }
699
+ export interface CanonKnownRecentParticipant {
700
+ id: string;
701
+ name: string;
702
+ userType: 'human' | 'ai_agent' | 'unknown';
703
+ isOwner: boolean;
704
+ isSelf: boolean;
705
+ }
706
+ export interface CanonGroupContext {
707
+ memberCount: number;
708
+ memberIds: string[];
709
+ ownerId: string;
710
+ ownerName: string;
711
+ ownerPresent: boolean;
712
+ knownRecentParticipants: CanonKnownRecentParticipant[];
713
+ /** Complete current roster, including participants who have not spoken. */
714
+ participants?: CanonKnownRecentParticipant[];
715
+ membershipChange?: CanonMembershipChange;
716
+ }
717
+ export type CanonGroupContextMode = 'initial' | 'membership_change';
718
+ export interface ConversationUpdatedPayload {
719
+ conversationId: string;
720
+ changes: Record<string, unknown>;
721
+ membershipChange?: CanonMembershipChange;
722
+ }
723
+ export interface VoiceSessionEventPayload {
724
+ conversationId: string;
725
+ session: CanonVoiceSession;
726
+ /**
727
+ * True when this call targets the receiving agent (runtime_voice aimed at
728
+ * it). Voice events are conversation-scoped — group and human-mode calls
729
+ * arrive with targetsMe false; never auto-join on a bare 'started'.
730
+ * Absent on streams older than the media/video rollout: treat as targeted
731
+ * (the legacy filter only delivered targeted sessions).
732
+ */
733
+ targetsMe?: boolean;
734
+ }
735
+ export type CanonStreamEvent = {
736
+ type: 'agent.context';
737
+ payload: AgentContext;
738
+ } | {
739
+ type: 'message.created';
740
+ payload: MessageCreatedPayload;
741
+ } | {
742
+ type: 'message.updated';
743
+ payload: MessageUpdatedPayload;
744
+ } | {
745
+ type: 'contact.added';
746
+ payload: ContactAddedPayload;
747
+ } | {
748
+ type: 'contact.removed';
749
+ payload: ContactRemovedPayload;
750
+ } | {
751
+ type: 'typing';
752
+ payload: TypingPayload;
753
+ } | {
754
+ type: 'presence';
755
+ payload: PresencePayload;
756
+ } | {
757
+ type: 'runtime.updated';
758
+ payload: RuntimeUpdatedPayload;
759
+ } | {
760
+ type: 'turn.updated';
761
+ payload: TurnUpdatedPayload;
762
+ } | {
763
+ type: 'runtime.control';
764
+ payload: RuntimeControlEventPayload;
765
+ } | {
766
+ type: 'message.deleted';
767
+ payload: {
768
+ conversationId: string;
769
+ messageId: string;
770
+ };
771
+ } | {
772
+ type: 'conversation.updated';
773
+ payload: ConversationUpdatedPayload;
774
+ } | {
775
+ type: 'voice.session.started';
776
+ payload: VoiceSessionEventPayload;
777
+ } | {
778
+ type: 'voice.session.ended';
779
+ payload: VoiceSessionEventPayload;
780
+ };
781
+ export interface SendMessageOptions {
782
+ messageId?: string;
783
+ contentType?: 'text' | 'audio' | 'image' | 'video' | 'file' | 'contact_card';
784
+ replyTo?: string;
785
+ replyToPosition?: number;
786
+ attachments?: MediaAttachment[];
787
+ contactCardUserId?: string;
788
+ mentions?: string[];
789
+ selfContextId?: string | null;
790
+ /** Structured metadata for rich UI (approval cards, etc.) */
791
+ metadata?: Record<string, unknown> & {
792
+ artifactContext?: ArtifactContext;
793
+ };
794
+ /** Trusted transport context injected by the host, never by the model. */
795
+ replyAuthority?: import('../backend-contracts/index.js').AgentReplyAuthorityV1;
796
+ }
797
+ export interface CreateGroupOptions {
798
+ memberIds: string[];
799
+ name: string;
800
+ }
801
+ export interface CreateGroupResult {
802
+ conversationId: string;
803
+ }
804
+ export type CanonVoiceSessionMode = 'human' | 'runtime_voice';
805
+ export type CanonVoiceSessionStatus = 'active' | 'ended' | 'error';
806
+ /** Call media. Absent anywhere in the wire always means 'audio'. */
807
+ export type CanonVoiceSessionMedia = 'audio' | 'video';
808
+ /** GET /conversations call-state summary for REST-polling consumers. */
809
+ export interface CanonActiveCallSummary {
810
+ sessionId: string;
811
+ media: CanonVoiceSessionMedia;
812
+ mode: CanonVoiceSessionMode;
813
+ startedAt: string | null;
814
+ }
815
+ export interface CanonVoiceSessionParticipant {
816
+ userId: string;
817
+ userType: 'human' | 'ai_agent' | 'system';
818
+ displayName?: string | null;
819
+ joinedAt?: string | null;
820
+ leftAt?: string | null;
821
+ }
822
+ export interface CanonVoiceSession {
823
+ id: string;
824
+ conversationId: string;
825
+ roomName: string;
826
+ mode: CanonVoiceSessionMode;
827
+ media?: CanonVoiceSessionMedia;
828
+ status: CanonVoiceSessionStatus;
829
+ createdBy: string;
830
+ participantIds: string[];
831
+ participants?: CanonVoiceSessionParticipant[];
832
+ declinedUserIds?: string[];
833
+ targetAgentId?: string | null;
834
+ createdAt?: string | null;
835
+ updatedAt?: string | null;
836
+ endedAt?: string | null;
837
+ error?: string | null;
838
+ }
839
+ export interface CanonVoiceSessionToken {
840
+ sessionId: string;
841
+ conversationId: string;
842
+ roomName: string;
843
+ url: string;
844
+ token: string;
845
+ identity: string;
846
+ mode: CanonVoiceSessionMode;
847
+ media?: CanonVoiceSessionMedia;
848
+ targetAgentId?: string | null;
849
+ expiresAt: string;
850
+ }
851
+ export interface CreateVoiceSessionOptions {
852
+ conversationId: string;
853
+ targetAgentId?: string | null;
854
+ /** Requested call media; the server defaults absent/unknown to 'audio'. */
855
+ media?: CanonVoiceSessionMedia;
856
+ }
857
+ export type CanonMemoStreamStatus = 'live' | 'finalizing' | 'finalized' | 'aborted';
858
+ export interface CreateMemoStreamOptions {
859
+ conversationId: string;
860
+ /** v1 accepts 'wav' only (byte-append decodable and seekable everywhere). */
861
+ container: 'wav';
862
+ codec: {
863
+ mimeType: string;
864
+ sampleRate: number;
865
+ channels: number;
866
+ bitsPerSample: number;
867
+ };
868
+ /** Byte offset of PCM data in the sender's file (RIFF headers precede it). */
869
+ dataOffset?: number;
870
+ /** Pre-allocated durable message id, for the live→durable timeline handoff. */
871
+ messageId?: string | null;
872
+ }
873
+ export interface CreateMemoStreamResult {
874
+ streamId: string;
875
+ bucket: string;
876
+ }
877
+ export interface AppendMemoStreamChunkOptions {
878
+ /** Zero-based, strictly sequential. Retries of the last chunk are acked. */
879
+ seq: number;
880
+ /** Base64 chunk bytes; may be empty when only carrying the final marker. */
881
+ data: string;
882
+ /** Normalized 0..1 amplitude bars for live waveforms. */
883
+ peaks?: number[];
884
+ /** Running duration of the recording in milliseconds. */
885
+ durationMs?: number;
886
+ /** Marks the recording finished; the stream leaves the live window. */
887
+ final?: boolean;
888
+ }
889
+ export interface MemoStreamChunkAck {
890
+ chunkCount: number;
891
+ totalBytes: number;
892
+ applied: boolean;
893
+ }
894
+ export interface JoinVoiceSessionOptions {
895
+ conversationId: string;
896
+ }
897
+ export type StreamingStatus = 'thinking' | 'streaming' | 'tool' | 'waiting_input';
898
+ export interface SetStreamingOptions {
899
+ conversationId: string;
900
+ text: string;
901
+ status: StreamingStatus;
902
+ messageId: string;
903
+ turnId?: string | null;
904
+ blocks?: TurnOutputBlock[];
905
+ }
906
+ export interface SetRuntimeTurnOptions {
907
+ conversationId: string;
908
+ state: TurnLifecycleState;
909
+ turnId?: string | null;
910
+ queueDepth?: number;
911
+ currentSpeakerId?: string | null;
912
+ lastAcceptedIntent?: DeliveryIntent | null;
913
+ activeMessageIds?: string[];
914
+ capabilities?: Partial<RuntimeCapabilities>;
915
+ openedAt?: number | null;
916
+ /**
917
+ * Set when this publish represents real turn progress. Omit for heartbeat or
918
+ * status-only refreshes so Canon can preserve stale-turn recovery semantics.
919
+ */
920
+ turnUpdatedAt?: number | null;
921
+ }
922
+ export interface RuntimeControlError {
923
+ value: string;
924
+ message: string;
925
+ updatedAt: number;
926
+ }
927
+ /** Runtime-applied state projected into the canonical agent-session snapshot. */
928
+ export interface SessionState {
929
+ lastError?: string;
930
+ model?: string;
931
+ permissionMode?: string;
932
+ effort?: string;
933
+ runtimeControlValues?: Record<string, CanonControlValue>;
934
+ controlState?: Record<string, RuntimeControlState>;
935
+ runtimeControlErrors?: Record<string, RuntimeControlError> | null;
936
+ cwd?: string;
937
+ /** Stable local workspace identifier selected by the runtime. */
938
+ workspaceId?: string;
939
+ executionMode?: 'worktree' | 'locked';
940
+ executionBranch?: string;
941
+ worktreePath?: string;
942
+ executionFallbackReason?: string;
943
+ clientType?: AgentClientType;
944
+ /** True when the agent is running under the host wrapper (host.ts) which can apply control signals */
945
+ hostMode?: boolean;
946
+ isActive: boolean;
947
+ /** Runtimes that cannot report a context window (e.g. Codex) publish totalTokens only. */
948
+ contextUsage?: {
949
+ percentage?: number;
950
+ totalTokens: number;
951
+ maxTokens?: number;
952
+ };
953
+ availableModels?: ModelOption[];
954
+ updatedAt: number;
955
+ }
956
+ export interface PermissionModeOption {
957
+ value: string;
958
+ label: string;
959
+ description?: string;
960
+ /** Runtime-owned risk marker; Canon enforces owner-only selection generically. */
961
+ ownerOnly?: boolean;
962
+ }
963
+ export declare const CLAUDE_PERMISSION_MODE_OPTIONS: readonly [{
964
+ readonly value: "default";
965
+ readonly label: "Default";
966
+ }, {
967
+ readonly value: "acceptEdits";
968
+ readonly label: "Auto-edit";
969
+ }, {
970
+ readonly value: "plan";
971
+ readonly label: "Plan";
972
+ }, {
973
+ readonly value: "dontAsk";
974
+ readonly label: "Don't ask";
975
+ readonly ownerOnly: true;
976
+ }, {
977
+ readonly value: "bypassPermissions";
978
+ readonly label: "Bypass";
979
+ readonly ownerOnly: true;
980
+ }, {
981
+ readonly value: "auto";
982
+ readonly label: "Auto";
983
+ readonly ownerOnly: true;
984
+ }];
985
+ export interface AgentRuntime {
986
+ clientType?: AgentClientType;
987
+ hostMode?: boolean;
988
+ defaultModel?: string;
989
+ defaultPermissionMode?: string;
990
+ availablePermissionModes?: PermissionModeOption[];
991
+ runtimeDescriptor?: CanonRuntimeDescriptor;
992
+ defaultWorkspaceId?: string;
993
+ /**
994
+ * Execution modes the host will accept. The runtime advertises this so the
995
+ * local adapter can choose a default for new conversation sessions.
996
+ */
997
+ availableExecutionModes?: ExecutionEnvironmentMode[];
998
+ /**
999
+ * Reference default surfaced to UI. Treated as advisory only — callers must
1000
+ * still have the user confirm a selection before persisting.
1001
+ */
1002
+ defaultExecutionMode?: ExecutionEnvironmentMode;
1003
+ availableModels?: ModelOption[];
1004
+ availableWorkspaces?: WorkspaceOption[];
1005
+ updatedAt?: number;
1006
+ }
1007
+ export interface AgentSessionSnapshot {
1008
+ conversationId: string;
1009
+ agentId: string;
1010
+ clientType?: AgentClientType;
1011
+ hostMode?: boolean;
1012
+ model?: string;
1013
+ modelOptions?: ModelOption[];
1014
+ permissionMode?: string;
1015
+ permissionModeOptions?: PermissionModeOption[];
1016
+ effort?: string;
1017
+ runtimeControlValues?: Record<string, CanonControlValue>;
1018
+ controlState?: Record<string, RuntimeControlState>;
1019
+ runtimeControlErrors?: Record<string, RuntimeControlError> | null;
1020
+ runtimeDescriptor?: CanonRuntimeDescriptor | null;
1021
+ runtimeInfo?: RuntimeInfoPayload | null;
1022
+ runtimeActivity?: Record<string, CanonRuntimeActivityItem> | ReadonlyArray<CanonRuntimeActivityItem> | null;
1023
+ workspaceId?: string;
1024
+ workspaceOptions?: WorkspaceOption[];
1025
+ executionMode?: ExecutionEnvironmentMode;
1026
+ availableExecutionModes?: ExecutionEnvironmentMode[];
1027
+ executionBranch?: string;
1028
+ resolvedWorkspaceLabel?: string | null;
1029
+ resolvedCwd?: string | null;
1030
+ worktreePath?: string | null;
1031
+ executionFallbackReason?: string | null;
1032
+ turnState?: TurnLifecycleState;
1033
+ turnId?: string | null;
1034
+ turnOpenedAt?: number | null;
1035
+ turnUpdatedAt?: number | null;
1036
+ supportsQueue?: boolean;
1037
+ supportsInputInterrupt?: boolean;
1038
+ queueDepth: number;
1039
+ waitingForInput: boolean;
1040
+ contextUsage?: SessionState['contextUsage'];
1041
+ lastError?: string;
1042
+ /** Local adapter readiness only; Canon never stores the missing configuration. */
1043
+ configurationStatus?: 'ready' | 'configuration_required' | null;
1044
+ lastHeartbeatAt?: number;
1045
+ updatedAt?: number;
1046
+ }
1047
+ export interface RegistrationInput {
1048
+ /** Optional public source attribution reviewed with registration. */
1049
+ origin?: AgentOriginDeclaration;
1050
+ name: string;
1051
+ description: string;
1052
+ ownerPhone: string;
1053
+ developerInfo?: string;
1054
+ avatarUrl?: string;
1055
+ baseUrl?: string;
1056
+ clientType?: AgentClientType;
1057
+ requestedAgentId?: string;
1058
+ localRegistrationId?: string;
1059
+ }
1060
+ export interface RegistrationResult {
1061
+ status: 'approved' | 'rejected' | 'timeout';
1062
+ apiKey?: string;
1063
+ agentId?: string;
1064
+ agentName?: string;
1065
+ requestId?: string;
1066
+ pollToken?: string;
1067
+ }
1068
+ export interface RegistrationStatus {
1069
+ status: 'pending' | 'approving' | 'approved' | 'rejected';
1070
+ agentName: string;
1071
+ agentId?: string;
1072
+ apiKey?: string;
1073
+ apiKeyDelivered?: boolean;
1074
+ apiKeyExpired?: boolean;
1075
+ }