@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,286 @@
1
+ import { RUNTIME_CARD_FIELD_TYPES, RUNTIME_CARD_LIMITS, RUNTIME_CARD_LINE_ITEM_COLUMN_TYPES, validateRuntimeCardFieldValues, type RuntimeCardField, type RuntimeCardFieldChoice, type RuntimeCardFieldType, type RuntimeCardLineItemColumn, type RuntimeCardLineItemColumnType, type VerbNativeMetadata } from '../backend-contracts/index.js';
2
+ export { RUNTIME_CARD_FIELD_TYPES, RUNTIME_CARD_LIMITS, RUNTIME_CARD_LINE_ITEM_COLUMN_TYPES, validateRuntimeCardFieldValues, };
3
+ export type { RuntimeCardField, RuntimeCardFieldChoice, RuntimeCardFieldType, RuntimeCardLineItemColumn, RuntimeCardLineItemColumnType, };
4
+ export interface PlanApprovalMetadata {
5
+ type: 'plan_approval';
6
+ planId: string;
7
+ /** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */
8
+ responseUserId?: string;
9
+ title?: string;
10
+ summary?: string;
11
+ body?: string;
12
+ allowedPrompts?: ReadonlyArray<{
13
+ tool: string;
14
+ prompt: string;
15
+ }>;
16
+ }
17
+ /**
18
+ * Plan approval decision.
19
+ * - `approve`: proceed with the plan.
20
+ * - `revise`: request changes (carries free-text `feedback`).
21
+ * - `reject`: decline / keep planning — the Mac-app "No, keep planning" path,
22
+ * distinct from a feedback-bearing revision.
23
+ */
24
+ export type PlanApprovalDecision = 'approve' | 'revise' | 'reject';
25
+ export interface PlanApprovalReplyMetadata {
26
+ type: 'plan_approval_reply';
27
+ planId: string;
28
+ decision: PlanApprovalDecision;
29
+ feedback?: string;
30
+ /**
31
+ * When the plan card showed `allowedPrompts`, the subset the user granted on
32
+ * approval. The host pre-approves these as session rules. Absent = grant all
33
+ * (legacy/full-approve behavior).
34
+ */
35
+ grantedPrompts?: ReadonlyArray<{
36
+ tool: string;
37
+ prompt: string;
38
+ }>;
39
+ }
40
+ export type RuntimeInputKind = 'clarify' | 'sudo' | 'secret';
41
+ export type RuntimeInputReplyStatus = 'submitted' | 'cancelled';
42
+ export type RuntimeInputResolutionStatus = RuntimeInputReplyStatus | 'timeout';
43
+ export interface RuntimeInputChoice {
44
+ label: string;
45
+ value?: string;
46
+ description?: string;
47
+ /**
48
+ * Optional preview content rendered when this option is focused/expanded —
49
+ * mockups, code snippets, or comparisons. Matches the Mac-app
50
+ * AskUserQuestion option preview.
51
+ */
52
+ preview?: string;
53
+ }
54
+ export interface RuntimeInputQuestion {
55
+ id: string;
56
+ question: string;
57
+ header?: string;
58
+ choices?: RuntimeInputChoice[];
59
+ allowOther?: boolean;
60
+ isSecret?: boolean;
61
+ multiSelect?: boolean;
62
+ }
63
+ export type RuntimeInputAnswers = Record<string, {
64
+ answers: string[];
65
+ }>;
66
+ export type RuntimeInputNativeMetadata = Pick<VerbNativeMetadata, 'runtime' | 'method' | 'requestId' | 'sessionKey' | 'turnId' | 'handles'>;
67
+ export interface RuntimeInputRequestMetadata {
68
+ type: 'runtime_input_request';
69
+ inputId: string;
70
+ /** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */
71
+ responseUserId?: string;
72
+ kind: RuntimeInputKind;
73
+ prompt: string;
74
+ title?: string;
75
+ choices?: RuntimeInputChoice[];
76
+ questions?: RuntimeInputQuestion[];
77
+ secretName?: string;
78
+ native?: RuntimeInputNativeMetadata;
79
+ expiresAt: string;
80
+ sensitive?: boolean;
81
+ }
82
+ export interface RuntimeInputReplyMetadata {
83
+ type: 'runtime_input_reply';
84
+ inputId: string;
85
+ kind?: RuntimeInputKind;
86
+ status: RuntimeInputReplyStatus;
87
+ answerSummary?: string;
88
+ answersSummary?: string;
89
+ sensitive?: boolean;
90
+ }
91
+ export interface RuntimeInputOutcomeMetadata {
92
+ type: 'runtime_input_outcome';
93
+ inputId: string;
94
+ kind?: RuntimeInputKind;
95
+ status: RuntimeInputResolutionStatus;
96
+ reason?: 'submitted' | 'cancelled' | 'timeout' | 'expired' | 'interrupted';
97
+ }
98
+ export declare const RUNTIME_CARD_SCHEMA_V1: "canon.card.v1";
99
+ export type RuntimeCardSchemaV1 = typeof RUNTIME_CARD_SCHEMA_V1;
100
+ export type RuntimeCardBlockKind = 'summary' | 'metricGrid' | 'chart' | 'table' | 'list' | 'callout' | 'actions' | 'mediaPreview' | 'details';
101
+ export type RuntimeCardTone = 'neutral' | 'primary' | 'positive' | 'warning' | 'negative' | 'danger' | 'critical' | 'welcome';
102
+ export type RuntimeCardReplyStatus = 'submitted' | 'cancelled';
103
+ export type RuntimeCardResolutionStatus = RuntimeCardReplyStatus | 'timeout';
104
+ export interface RuntimeCardSummaryBlock {
105
+ kind: 'summary';
106
+ title?: string;
107
+ text: string;
108
+ }
109
+ export interface RuntimeCardMetric {
110
+ label: string;
111
+ value: string;
112
+ delta?: string;
113
+ tone?: RuntimeCardTone;
114
+ }
115
+ export interface RuntimeCardMetricGridBlock {
116
+ kind: 'metricGrid';
117
+ title?: string;
118
+ metrics: RuntimeCardMetric[];
119
+ }
120
+ export interface RuntimeCardChartPoint {
121
+ x: string;
122
+ y: number;
123
+ }
124
+ export interface RuntimeCardChartSeries {
125
+ name?: string;
126
+ points: RuntimeCardChartPoint[];
127
+ }
128
+ export interface RuntimeCardChartBlock {
129
+ kind: 'chart';
130
+ chart: 'line' | 'bar';
131
+ title?: string;
132
+ yLabel?: string;
133
+ series: RuntimeCardChartSeries[];
134
+ }
135
+ export interface RuntimeCardTableBlock {
136
+ kind: 'table';
137
+ title?: string;
138
+ columns: string[];
139
+ rows: string[][];
140
+ }
141
+ export interface RuntimeCardListItem {
142
+ label: string;
143
+ detail?: string;
144
+ status?: 'pending' | 'done' | 'blocked' | 'warning';
145
+ }
146
+ export interface RuntimeCardListBlock {
147
+ kind: 'list';
148
+ title?: string;
149
+ items: RuntimeCardListItem[];
150
+ }
151
+ export interface RuntimeCardCalloutBlock {
152
+ kind: 'callout';
153
+ title?: string;
154
+ text: string;
155
+ tone?: RuntimeCardTone;
156
+ }
157
+ export type RuntimeCardMediaKind = 'image' | 'file';
158
+ export interface RuntimeCardMediaPreviewMedia {
159
+ /** 'file' covers application/pdf and other documents. */
160
+ kind: RuntimeCardMediaKind;
161
+ /** REQUIRED. Canon Storage URL only (server enforces). */
162
+ url: string;
163
+ /** Resumable-upload identity for the primary media, when applicable. */
164
+ uploadId?: string;
165
+ /** REQUIRED. Allowlist enforced server-side: image/*, application/pdf. */
166
+ mimeType: string;
167
+ fileName?: string;
168
+ sizeBytes?: number;
169
+ /** Canon Storage URL; inline preview for non-image media (e.g. pdf page render). */
170
+ thumbnailUrl?: string;
171
+ /** Resumable-upload identity for thumbnailUrl, when it is a separate upload. */
172
+ thumbnailUploadId?: string;
173
+ /** 1-based page the thumbnail shows. */
174
+ page?: number;
175
+ pageCount?: number;
176
+ }
177
+ export interface RuntimeCardMediaPreviewBlock {
178
+ kind: 'mediaPreview';
179
+ title?: string;
180
+ media: RuntimeCardMediaPreviewMedia;
181
+ /** Recommended — old clients render this; should contain the open-link text. */
182
+ fallbackText?: string;
183
+ }
184
+ export interface RuntimeCardDetailsRow {
185
+ label: string;
186
+ value: string;
187
+ tone?: RuntimeCardTone;
188
+ /** 0..1 inclusive. */
189
+ confidence?: number;
190
+ hint?: string;
191
+ }
192
+ export interface RuntimeCardDetailsBlock {
193
+ kind: 'details';
194
+ title?: string;
195
+ rows: RuntimeCardDetailsRow[];
196
+ }
197
+ /**
198
+ * Block preserved when a renderer/normalizer does not recognize `kind`. Forward
199
+ * compatibility: unknown blocks are kept (not dropped) so renderers can degrade
200
+ * to `fallbackText` instead of silently losing content.
201
+ */
202
+ export interface RuntimeCardUnknownBlock {
203
+ kind: string;
204
+ fallbackText?: string;
205
+ }
206
+ export interface RuntimeCardAction {
207
+ id: string;
208
+ label: string;
209
+ tone?: RuntimeCardTone;
210
+ fields?: RuntimeCardField[];
211
+ }
212
+ export interface RuntimeCardActionsBlock {
213
+ kind: 'actions';
214
+ title?: string;
215
+ actions: RuntimeCardAction[];
216
+ }
217
+ export type RuntimeCardBlock = RuntimeCardSummaryBlock | RuntimeCardMetricGridBlock | RuntimeCardChartBlock | RuntimeCardTableBlock | RuntimeCardListBlock | RuntimeCardCalloutBlock | RuntimeCardActionsBlock | RuntimeCardMediaPreviewBlock | RuntimeCardDetailsBlock | RuntimeCardUnknownBlock;
218
+ export interface RuntimeCardV1 {
219
+ schema: RuntimeCardSchemaV1;
220
+ cardId?: string;
221
+ template?: string;
222
+ tone?: RuntimeCardTone;
223
+ title: string;
224
+ fallbackText: string;
225
+ blocks: RuntimeCardBlock[];
226
+ }
227
+ export interface RuntimeCardPreview {
228
+ title?: string;
229
+ tone?: RuntimeCardTone;
230
+ template?: string;
231
+ blockKinds: RuntimeCardBlockKind[];
232
+ }
233
+ export type RuntimeCardNativeMetadata = RuntimeInputNativeMetadata;
234
+ export interface RuntimeCardRequestMetadata {
235
+ type: 'runtime_card_request';
236
+ cardId: string;
237
+ cardKind: string;
238
+ schemaVersion: RuntimeCardSchemaV1;
239
+ fallbackText: string;
240
+ responseUserId?: string;
241
+ expiresAt: string;
242
+ runtimeId?: string;
243
+ turnId?: string;
244
+ native?: RuntimeCardNativeMetadata;
245
+ /** True when the card carries an actions block (the agent waits for a
246
+ * response); false/absent for display/report cards shown to all members. */
247
+ interactive?: boolean;
248
+ cardPreview: RuntimeCardPreview;
249
+ turnSemantics: 'control';
250
+ replyBehavior: 'suppress_auto_reply';
251
+ }
252
+ export interface RuntimeCardReplyMetadata {
253
+ type: 'runtime_card_reply';
254
+ cardId: string;
255
+ status: RuntimeCardReplyStatus;
256
+ actionId?: string;
257
+ answerSummary?: string;
258
+ sensitive?: boolean;
259
+ turnSemantics: 'control';
260
+ replyBehavior: 'suppress_auto_reply';
261
+ }
262
+ export interface RuntimeCardOutcomeMetadata {
263
+ type: 'runtime_card_outcome';
264
+ cardId: string;
265
+ status: RuntimeCardResolutionStatus;
266
+ reason?: 'submitted' | 'cancelled' | 'timeout' | 'expired' | 'interrupted';
267
+ turnSemantics: 'control';
268
+ replyBehavior: 'suppress_auto_reply';
269
+ }
270
+ /** Block kinds this version of core knows how to fully normalize/render. */
271
+ export type RuntimeCardKnownBlockKind = 'summary' | 'metricGrid' | 'chart' | 'table' | 'list' | 'callout' | 'actions' | 'mediaPreview' | 'details';
272
+ export declare function parseRuntimeCardV1(value: unknown): RuntimeCardV1 | null;
273
+ export declare function buildRuntimeCardPreview(card: RuntimeCardV1): RuntimeCardPreview;
274
+ export declare function buildRuntimeInputOutcome(inputId: string, status: RuntimeInputResolutionStatus, details?: {
275
+ kind?: RuntimeInputKind;
276
+ reason?: RuntimeInputOutcomeMetadata['reason'];
277
+ }): {
278
+ text: string;
279
+ metadata: RuntimeInputOutcomeMetadata;
280
+ };
281
+ export declare function buildRuntimeCardOutcome(cardId: string, status: RuntimeCardResolutionStatus, details?: {
282
+ reason?: RuntimeCardOutcomeMetadata['reason'];
283
+ }): {
284
+ text: string;
285
+ metadata: RuntimeCardOutcomeMetadata;
286
+ };
@@ -0,0 +1,16 @@
1
+ export { normalizeRuntimeCommandAlias, normalizeRuntimeCommandAliases } from '../backend-contracts/index.js';
2
+ import type { ExecutionEnvironmentMode } from './execution-environment-mode.js';
3
+ import type { CanonRuntimeCommandDescriptor } from './types.js';
4
+ export interface NormalizeRuntimeCommandDescriptorsOptions {
5
+ reservedAliases?: Iterable<string>;
6
+ maxCommands?: number;
7
+ }
8
+ export declare function normalizeRuntimeCommandDescriptors(commands: ReadonlyArray<CanonRuntimeCommandDescriptor>, options?: NormalizeRuntimeCommandDescriptorsOptions): CanonRuntimeCommandDescriptor[];
9
+ export declare const EXECUTION_MODE_CONTROL_OPTIONS: ReadonlyArray<{
10
+ value: ExecutionEnvironmentMode;
11
+ label: string;
12
+ description: string;
13
+ }>;
14
+ export declare const RUNTIME_STOP_ACTION: CanonRuntimeCommandDescriptor;
15
+ export declare const RUNTIME_STOP_AND_DROP_ACTION: CanonRuntimeCommandDescriptor;
16
+ export declare const RUNTIME_NEW_SESSION_ACTION: CanonRuntimeCommandDescriptor;
@@ -0,0 +1,26 @@
1
+ import { type CanonEnvironmentId } from '../backend-contracts/index.js';
2
+ export interface CanonRuntimeEndpointDefaults {
3
+ apiBaseUrl: string;
4
+ streamUrl: string;
5
+ rtdbUrl: string;
6
+ firebaseWebApiKey: string;
7
+ }
8
+ export interface CanonRuntimeConnectionOptions {
9
+ environmentId: string;
10
+ apiBaseUrl?: string | null;
11
+ streamUrl?: string | null;
12
+ rtdbUrl?: string | null;
13
+ firebaseWebApiKey?: string | null;
14
+ }
15
+ export interface CanonRuntimeConnection extends CanonRuntimeEndpointDefaults {
16
+ environmentId: CanonEnvironmentId;
17
+ projectId: string;
18
+ region: string;
19
+ }
20
+ export declare const CANON_RUNTIME_ENDPOINT_DEFAULTS: Readonly<Partial<Record<CanonEnvironmentId, CanonRuntimeEndpointDefaults>>>;
21
+ export declare const DEFAULT_CANON_ENVIRONMENT_ID: "canon-dev-v1" | "canon-prod-v1";
22
+ export declare function getCanonRuntimeEndpointDefaults(environmentId: string): CanonRuntimeEndpointDefaults | null;
23
+ export declare function requireCanonRuntimeEndpointDefaults(environmentId: string): CanonRuntimeEndpointDefaults;
24
+ export declare function resolveCanonRuntimeConnection(options: CanonRuntimeConnectionOptions): CanonRuntimeConnection;
25
+ export declare function verifyCanonRuntimeConnection(connection: CanonRuntimeConnection, fetchImpl?: typeof fetch): Promise<void>;
26
+ export declare const DEFAULT_CANON_RUNTIME_ENDPOINTS: CanonRuntimeEndpointDefaults;
@@ -0,0 +1,29 @@
1
+ import type { RuntimeStatePublisher } from './runtime-state-publisher.js';
2
+ import type { AgentRuntime } from './types.js';
3
+ export type RuntimeHeartbeatOperation = 'publish' | 'refresh-details' | 'clear' | 'clear-details';
4
+ export interface RuntimeHeartbeatOptions {
5
+ /** Retain one publisher so clearing preserves its last public descriptor. */
6
+ publisher: Pick<RuntimeStatePublisher, 'publishAgentRuntime' | 'clearAgentRuntime'>;
7
+ getRuntime: () => AgentRuntime;
8
+ intervalMs?: number;
9
+ /** Slow work has its own serialized lane; observe cancellation before writing. */
10
+ refreshDetails?: (signal: AbortSignal) => Promise<void>;
11
+ /** Runs after any in-flight detail refresh, including during disposal. */
12
+ clearDetails?: () => Promise<void>;
13
+ onError: (error: unknown, operation: RuntimeHeartbeatOperation) => void;
14
+ }
15
+ export interface RuntimeHeartbeat {
16
+ connect(): void;
17
+ disconnect(): Promise<void>;
18
+ /** Publish a changed descriptor and request fresh details while connected. */
19
+ refresh(): void;
20
+ /** Terminal, idempotent cleanup. Create a new controller to restart. */
21
+ dispose(): Promise<void>;
22
+ }
23
+ /**
24
+ * Connection-scoped publication over a retained runtime publisher. Liveness
25
+ * and slow details have independent lanes, each with at most one queued refresh.
26
+ * Connection generations discard obsolete queued work; in-flight writes finish
27
+ * before the next clear/publish so a late write cannot restore stale liveness.
28
+ */
29
+ export declare function createRuntimeHeartbeat(options: RuntimeHeartbeatOptions): RuntimeHeartbeat;
@@ -0,0 +1,9 @@
1
+ import type { AgentSessionSnapshot, CanonRuntimeActivityItem, CanonRuntimeDescriptor, CanonRuntimePresentationField, RuntimeInfoPayload } from './types.js';
2
+ export declare function isRuntimePresentationFieldHidden(descriptor: CanonRuntimeDescriptor | null | undefined, field: CanonRuntimePresentationField): boolean;
3
+ export declare function redactRuntimeActivityItemForConversation(item: CanonRuntimeActivityItem): CanonRuntimeActivityItem | null;
4
+ export declare function redactRuntimeInfoForConversation<T extends Partial<Omit<RuntimeInfoPayload, 'updatedAt'>> | RuntimeInfoPayload>(payload: T, options?: {
5
+ descriptor?: CanonRuntimeDescriptor | null;
6
+ }): T;
7
+ export declare function redactAgentSessionSnapshotForConversation(descriptor: CanonRuntimeDescriptor | null | undefined, snapshot: Partial<AgentSessionSnapshot> & Record<string, unknown>, options?: {
8
+ patch?: boolean;
9
+ }): Partial<AgentSessionSnapshot> & Record<string, unknown>;
@@ -0,0 +1,283 @@
1
+ import type { CanonClient } from './client.js';
2
+ import type { SessionRule } from './approval-types.js';
3
+ import type { RuntimeCardV1, RuntimeCardNativeMetadata, RuntimeInputAnswers, RuntimeInputChoice, RuntimeInputKind, RuntimeInputNativeMetadata, RuntimeInputQuestion } from './runtime-cards.js';
4
+ /**
5
+ * The five runtime request families. `contact` is non-interactive (no pending
6
+ * node / no manager loop); the other four flow through {@link RuntimeRequestManager}.
7
+ */
8
+ export type RuntimeRequestKind = 'contact' | 'approval' | 'input' | 'plan' | 'card';
9
+ export interface RuntimeRequestContext {
10
+ agentId: string;
11
+ ownerId: string;
12
+ }
13
+ /** Normalized outcome of a single consume poll. */
14
+ export type RuntimeConsumeOutcome<Result> = {
15
+ state: 'pending';
16
+ } | {
17
+ state: 'resolved';
18
+ result: Result;
19
+ } | {
20
+ state: 'timeout';
21
+ };
22
+ /** Outcome message the host emits after a request settles (via `onOutcome`). */
23
+ export interface RuntimeOutcomeMessage {
24
+ text: string;
25
+ metadata: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Everything the descriptor's create step surfaced to the host, handed to
29
+ * `onCreated`. Hosts that must sequence side effects on the server response
30
+ * (turn blocks, streaming state, display-vs-poll control flow) read these
31
+ * instead of re-deriving them.
32
+ */
33
+ export interface RuntimeCreateResult {
34
+ requestId: string;
35
+ messageId?: string;
36
+ /** Card family: whether the created card is interactive (a response is pending). */
37
+ interactive?: boolean;
38
+ expiresAt?: number;
39
+ }
40
+ /**
41
+ * How the built-in input/card descriptors pick `responseUserId` when the payload
42
+ * does not set it explicitly. An explicit `payload.responseUserId` always wins.
43
+ * - `'owner'` — fall back to `ctx.ownerId` (omit when that is empty).
44
+ * - `'infer'` — omit, so the backend targets the owner if present else the sole
45
+ * other member (correct for agent→user DMs where the owner is not a member).
46
+ */
47
+ export type ResponderPolicy = 'owner' | 'infer';
48
+ export interface RuntimeRequestOptions {
49
+ /** Caller-chosen request id. When omitted the descriptor generates one. */
50
+ requestId?: string;
51
+ /** Absolute deadline (epoch ms). Overrides `timeoutMs`. */
52
+ expiresAt?: number;
53
+ timeoutMs?: number;
54
+ pollMs?: number;
55
+ signal?: AbortSignal;
56
+ /** Responder fallback for the built-in input/card create (see {@link ResponderPolicy}). */
57
+ responderPolicy?: ResponderPolicy;
58
+ /** Host side effects immediately after the server request is created (turn block, typing). */
59
+ onCreated?: (created: RuntimeCreateResult) => void | Promise<void>;
60
+ /** Host emits the durable outcome message after the request settles. */
61
+ onOutcome?: (outcome: RuntimeOutcomeMessage) => void | Promise<void>;
62
+ }
63
+ /** Error used to reject an in-flight request that is explicitly cancelled. */
64
+ export declare class RuntimeRequestCancelledError extends Error {
65
+ constructor(message?: string);
66
+ }
67
+ export interface RuntimeRequestCallInput<Payload, State> {
68
+ client: CanonClient;
69
+ ctx: RuntimeRequestContext;
70
+ conversationId: string;
71
+ requestId: string;
72
+ payload: Payload;
73
+ /** Resolved absolute deadline (epoch ms). */
74
+ expiresAt: number;
75
+ state: State | undefined;
76
+ }
77
+ export interface RuntimeRequestPreflightInput<Payload> {
78
+ client: CanonClient;
79
+ ctx: RuntimeRequestContext;
80
+ conversationId: string;
81
+ payload: Payload;
82
+ options: RuntimeRequestOptions;
83
+ }
84
+ export interface RuntimeRequestPushInput {
85
+ conversationId: string;
86
+ message: {
87
+ senderId: string;
88
+ metadata?: Record<string, unknown>;
89
+ };
90
+ ctx: RuntimeRequestContext;
91
+ }
92
+ export interface RuntimeRequestPushMatch {
93
+ requestId: string;
94
+ }
95
+ /**
96
+ * Everything that varies per request family. The engine ({@link RuntimeRequestManager})
97
+ * owns the pending map, timers, poll/notify/abort loop and cancellation; the
98
+ * descriptor supplies only the family-specific pieces.
99
+ */
100
+ export interface KindDescriptor<Payload = unknown, Result = unknown, State = unknown> {
101
+ readonly kind: RuntimeRequestKind;
102
+ /** Fresh request id when the caller supplies none. */
103
+ generateId(payload: Payload): string;
104
+ /** Deadline for this request (epoch ms). Falls back to options / default when omitted. */
105
+ resolveExpiry?(input: {
106
+ payload: Payload;
107
+ options: RuntimeRequestOptions;
108
+ }): number | undefined;
109
+ /** Poll cadence (ms). Defaults to the manager default. */
110
+ pollMs?(payload: Payload): number;
111
+ /**
112
+ * Optional immediate resolution BEFORE any server request is created (e.g. the
113
+ * approval session-rule fast path). Returning a result skips create + poll.
114
+ */
115
+ preflight?(input: RuntimeRequestPreflightInput<Payload>): Result | null;
116
+ /**
117
+ * Create the server-side request; returns the effective id + optional per-request
118
+ * state, plus any create-response fields the host needs back (surfaced via
119
+ * {@link RuntimeCreateResult} to `onCreated`).
120
+ */
121
+ create(input: RuntimeRequestCallInput<Payload, State> & {
122
+ options: RuntimeRequestOptions;
123
+ }): Promise<{
124
+ requestId: string;
125
+ expiresAt?: number;
126
+ state?: State;
127
+ messageId?: string;
128
+ interactive?: boolean;
129
+ }>;
130
+ /** Poll the server once and interpret the response. */
131
+ consume(input: RuntimeRequestCallInput<Payload, State>): Promise<RuntimeConsumeOutcome<Result>>;
132
+ /** Best-effort cancellation (abort / explicit cancel / dispose). */
133
+ cancel?(input: RuntimeRequestCallInput<Payload, State>): Promise<void>;
134
+ /** Result produced when the local deadline fires. */
135
+ timeoutResult(input: RuntimeRequestCallInput<Payload, State>): Result;
136
+ /**
137
+ * Finalization side effects + optional result override. Runs on `replied` /
138
+ * `timeout` (never `aborted`). Approval uses this to store the accepted session
139
+ * rule and emit its own outcome messages; returning a result lets it narrow the
140
+ * accepted rule into the returned value.
141
+ */
142
+ finalize?(input: RuntimeRequestCallInput<Payload, State> & {
143
+ result: Result;
144
+ reason: 'replied' | 'timeout';
145
+ }): Result | void;
146
+ /** Outcome message for the host to emit via `onOutcome` (input/card families). */
147
+ buildOutcome?(input: RuntimeRequestCallInput<Payload, State> & {
148
+ result: Result;
149
+ reason: 'replied' | 'timeout';
150
+ }): RuntimeOutcomeMessage | null;
151
+ /** Map an inbound push message to a pending request that should poll now. */
152
+ matchPush?(input: RuntimeRequestPushInput): RuntimeRequestPushMatch | null;
153
+ }
154
+ /**
155
+ * Platform-agnostic engine for Canon's interactive runtime requests.
156
+ *
157
+ * Generalizes the former `ApprovalManager`: it owns the pending map, deadline
158
+ * timers, the poll-with-abort loop that races an inbound push wakeup, and
159
+ * cancellation — all keyed by {@link KindDescriptor}. Approval, runtime input,
160
+ * runtime card, and plan families register over the same primitive; the former
161
+ * hand-written await-loops collapse into `request()`.
162
+ *
163
+ * Session-rule storage lives here because the approval descriptor's preflight /
164
+ * finalize read and write it; other families ignore it.
165
+ */
166
+ export declare class RuntimeRequestManager {
167
+ protected client: CanonClient;
168
+ protected ctx: RuntimeRequestContext;
169
+ private descriptors;
170
+ private pending;
171
+ private rules;
172
+ constructor(client: CanonClient, ctx: RuntimeRequestContext);
173
+ /** Register (or override) the descriptor for a kind. */
174
+ register<Payload, Result, State>(kind: RuntimeRequestKind, descriptor: KindDescriptor<Payload, Result, State>): void;
175
+ /** Built-in input, card, and plan descriptors. Subclasses add approval policy. */
176
+ protected registerBuiltins(): void;
177
+ get pendingCount(): number;
178
+ /**
179
+ * Run one interactive runtime request end to end:
180
+ * preflight → create → onCreated → register pending → poll (racing push wakeup
181
+ * and abort) → post-deadline consume → finalize → onOutcome → resolve.
182
+ */
183
+ request<Payload, Result, State = unknown>(kind: RuntimeRequestKind, conversationId: string, payload: Payload, options?: RuntimeRequestOptions): Promise<Result>;
184
+ /** Push short-circuit: wake the pending request's poll to consume immediately. */
185
+ notify(kind: RuntimeRequestKind, conversationId: string, requestId: string): void;
186
+ /**
187
+ * Feed an inbound message to the manager. Returns true when a matching pending
188
+ * request was woken to consume canonical state. Receipt metadata never settles
189
+ * the request directly. Fails closed on unknown / mismatched ids.
190
+ */
191
+ handleMessage(conversationId: string, message: {
192
+ senderId: string;
193
+ metadata?: Record<string, unknown>;
194
+ }): boolean;
195
+ /** Cancel a specific pending request (rejects its promise, best-effort server cancel). */
196
+ cancel(kind: RuntimeRequestKind, conversationId: string, requestId: string): Promise<void>;
197
+ checkSessionRules(toolName: string, conversationId?: string): SessionRule | null;
198
+ addSessionRule(conversationId: string, rule: SessionRule): void;
199
+ getSessionRules(): SessionRule[];
200
+ clearSessionRules(): void;
201
+ dispose(): void;
202
+ protected pruneExpiredRules(): void;
203
+ /** Sleep that resolves on timeout, on `notify()` wakeup, or when the request settles. */
204
+ private sleep;
205
+ }
206
+ /** Interactive runtime input (`AskUserQuestion`, secret prompts, choices). */
207
+ export interface RuntimeInputRequestPayload {
208
+ kind: RuntimeInputKind;
209
+ title?: string;
210
+ prompt?: string;
211
+ choices?: RuntimeInputChoice[];
212
+ questions?: RuntimeInputQuestion[];
213
+ secretName?: string;
214
+ native?: RuntimeInputNativeMetadata;
215
+ sensitive?: boolean;
216
+ responseUserId?: string;
217
+ turnId?: string;
218
+ }
219
+ export type RuntimeInputRequestResult = {
220
+ status: 'submitted';
221
+ inputId: string;
222
+ value: string;
223
+ answers?: RuntimeInputAnswers;
224
+ } | {
225
+ status: 'cancelled';
226
+ inputId: string;
227
+ } | {
228
+ status: 'timeout';
229
+ inputId: string;
230
+ };
231
+ export declare const runtimeInputDescriptor: KindDescriptor<RuntimeInputRequestPayload, RuntimeInputRequestResult>;
232
+ /** Interactive runtime card (canon.card.v1 with an actions block). */
233
+ export interface RuntimeCardRequestPayload {
234
+ card: RuntimeCardV1;
235
+ responseUserId?: string;
236
+ runtimeId?: string;
237
+ turnId?: string;
238
+ native?: RuntimeCardNativeMetadata;
239
+ }
240
+ export type RuntimeCardRequestResult = {
241
+ status: 'submitted';
242
+ cardId: string;
243
+ actionId?: string;
244
+ values?: Record<string, unknown>;
245
+ respondedBy?: string;
246
+ } | {
247
+ status: 'cancelled';
248
+ cardId: string;
249
+ respondedBy?: string;
250
+ } | {
251
+ status: 'timeout';
252
+ cardId: string;
253
+ };
254
+ export declare const runtimeCardDescriptor: KindDescriptor<RuntimeCardRequestPayload, RuntimeCardRequestResult>;
255
+ /** Blocking plan review produced by coding runtimes. */
256
+ export interface RuntimePlanRequestPayload {
257
+ title?: string;
258
+ summary?: string;
259
+ body?: string;
260
+ allowedPrompts?: ReadonlyArray<{
261
+ tool: string;
262
+ prompt: string;
263
+ }>;
264
+ responseUserId?: string;
265
+ turnId?: string;
266
+ }
267
+ export type RuntimePlanRequestResult = {
268
+ status: 'approve' | 'revise' | 'reject';
269
+ planId: string;
270
+ feedback?: string;
271
+ grantedPrompts?: Array<{
272
+ tool: string;
273
+ prompt: string;
274
+ }>;
275
+ receiptId?: string;
276
+ } | {
277
+ status: 'cancelled';
278
+ planId: string;
279
+ } | {
280
+ status: 'timeout';
281
+ planId: string;
282
+ };
283
+ export declare const runtimePlanDescriptor: KindDescriptor<RuntimePlanRequestPayload, RuntimePlanRequestResult>;