@canonmsg/agent-sdk 13.1.0 → 13.2.1

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.
@@ -5089,11 +5089,6 @@ function prepareJsonContent(input) {
5089
5089
  return freeze(content);
5090
5090
  }
5091
5091
  __name(prepareJsonContent, "prepareJsonContent");
5092
- function logicalMediaBlobId(conversationId, messageId2, index) {
5093
- if (!identity(conversationId) || !identity(messageId2) || !revision(index)) invalid12();
5094
- return JSON.stringify([conversationId, messageId2, index]);
5095
- }
5096
- __name(logicalMediaBlobId, "logicalMediaBlobId");
5097
5092
 
5098
5093
  // ../backend-contracts/src/endpoint.ts
5099
5094
  var CANON_ENDPOINT_PROTOCOL = "canon.endpoint.v1";
@@ -5242,22 +5237,6 @@ function parseConnectorRelayRequest(value) {
5242
5237
  }
5243
5238
  __name(parseConnectorRelayRequest, "parseConnectorRelayRequest");
5244
5239
 
5245
- // ../backend-contracts/src/deliveryObservation.ts
5246
- var isTerminalDeliveryOutcome = /* @__PURE__ */ __name((outcome) => !["unknown", "pending"].includes(outcome), "isTerminalDeliveryOutcome");
5247
- function mergeDeliveryObservation(current, next, expected) {
5248
- if (next.schemaVersion !== 2 || !Number.isSafeInteger(next.revision) || next.revision < 0 || !["unknown", "pending", "published", "cancelled", "expired", "rejected"].includes(next.outcome) || Object.entries(expected).some(([key, value]) => next[key] !== value)) return current;
5249
- if (current && (next.revision < current.revision || Object.keys(expected).length < 5 && (current.installationId !== next.installationId || current.environmentId !== next.environmentId) || isTerminalDeliveryOutcome(current.outcome) && next.outcome !== current.outcome || next.revision === current.revision && next.outcome !== current.outcome)) return current;
5250
- return next;
5251
- }
5252
- __name(mergeDeliveryObservation, "mergeDeliveryObservation");
5253
- function projectDeliveryStatus(outcome, phase) {
5254
- if (outcome === "published") return "succeeded";
5255
- if (outcome === "cancelled") return "cancelled";
5256
- if (outcome === "expired" || outcome === "rejected") return "rejected";
5257
- return phase === "sending" ? "sending" : "pending";
5258
- }
5259
- __name(projectDeliveryStatus, "projectDeliveryStatus");
5260
-
5261
5240
  // ../backend-contracts/src/mediaTransferProtocol.ts
5262
5241
  function classifyTransferHttpFailure(status) {
5263
5242
  return status >= 400 && status <= 499 && ![408, 409, 429].includes(status) ? "attention" : "retry";
@@ -5600,7 +5579,6 @@ export {
5600
5579
  canonicalEndpointJson,
5601
5580
  decodePreparedJsonContent,
5602
5581
  prepareJsonContent,
5603
- logicalMediaBlobId,
5604
5582
  CANON_ENDPOINT_PROTOCOL,
5605
5583
  ENDPOINT_ID_PATTERN,
5606
5584
  ENDPOINT_ACTION_PATTERN,
@@ -5615,8 +5593,6 @@ export {
5615
5593
  connectorRelayResponseBytes,
5616
5594
  ConnectorRelayRequestError,
5617
5595
  parseConnectorRelayRequest,
5618
- mergeDeliveryObservation,
5619
- projectDeliveryStatus,
5620
5596
  classifyTransferHttpFailure,
5621
5597
  classifyTransferReceipt,
5622
5598
  MLS_DEV_CREDENTIAL_RECONCILIATION_MAX_BYTES,
@@ -2,8 +2,8 @@ import {
2
2
  createMlsDevCredentialVerifier,
3
3
  mlsDevDeviceHttpConfiguration,
4
4
  parseMlsDevClientConfiguration
5
- } from "./chunk-YHDDOADK.js";
6
- import "./chunk-5WPAB5MB.js";
5
+ } from "./chunk-2NVLVPSG.js";
6
+ import "./chunk-VIS5WXNH.js";
7
7
  export {
8
8
  createMlsDevCredentialVerifier,
9
9
  mlsDevDeviceHttpConfiguration,
package/dist/cli.js CHANGED
@@ -25,11 +25,11 @@ import {
25
25
  runMlsDevSetup,
26
26
  startRelayChannel,
27
27
  writeRelayCredential
28
- } from "./chunks/chunk-IEKVS7AN.js";
28
+ } from "./chunks/chunk-TJBG6NKF.js";
29
29
  import {
30
30
  assertPrivateHome,
31
31
  runnerLockName
32
- } from "./chunks/chunk-DTAWEQCM.js";
32
+ } from "./chunks/chunk-POBMFS2K.js";
33
33
  import {
34
34
  CanonApiError,
35
35
  CanonClient,
@@ -40,13 +40,13 @@ import {
40
40
  resolveCanonRuntimeConnection,
41
41
  runCli,
42
42
  verifyCanonRuntimeConnection
43
- } from "./chunks/chunk-ZPBOGOAD.js";
44
- import "./chunks/chunk-YJUPKU47.js";
45
- import "./chunks/chunk-YHDDOADK.js";
43
+ } from "./chunks/chunk-HTLKCUQG.js";
44
+ import "./chunks/chunk-BPSFHEAA.js";
45
+ import "./chunks/chunk-2NVLVPSG.js";
46
46
  import {
47
47
  __name,
48
48
  isCanonClientVersion
49
- } from "./chunks/chunk-5WPAB5MB.js";
49
+ } from "./chunks/chunk-VIS5WXNH.js";
50
50
 
51
51
  // src/cli.ts
52
52
  import { realpathSync } from "node:fs";
package/dist/index.js CHANGED
@@ -26,8 +26,8 @@ import {
26
26
  runMlsDevSetup,
27
27
  runtimeDescriptor,
28
28
  startRelayChannel
29
- } from "./chunks/chunk-IEKVS7AN.js";
30
- import "./chunks/chunk-DTAWEQCM.js";
29
+ } from "./chunks/chunk-TJBG6NKF.js";
30
+ import "./chunks/chunk-POBMFS2K.js";
31
31
  import {
32
32
  CanonApiError,
33
33
  DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
@@ -52,10 +52,10 @@ import {
52
52
  toAnthropicImageBlock,
53
53
  toAnthropicImageBlocksWithinBudget,
54
54
  uploadMediaFile
55
- } from "./chunks/chunk-ZPBOGOAD.js";
56
- import "./chunks/chunk-YJUPKU47.js";
57
- import "./chunks/chunk-YHDDOADK.js";
58
- import "./chunks/chunk-5WPAB5MB.js";
55
+ } from "./chunks/chunk-HTLKCUQG.js";
56
+ import "./chunks/chunk-BPSFHEAA.js";
57
+ import "./chunks/chunk-2NVLVPSG.js";
58
+ import "./chunks/chunk-VIS5WXNH.js";
59
59
  export {
60
60
  CanonApiError,
61
61
  ConnectorRelayError,
@@ -1,11 +1,6 @@
1
1
  import type { AgentWakeConfiguration } from '../backend-contracts/index.js';
2
- import { type CanonMessage, type CanonConversation, type CanonUnifiedDiff, type CanonMessagesPage, type AgentContext, type MediaAttachment, type SendMessageOptions, type RegistrationStatus, type AgentOriginDeclaration, type SetRuntimeTurnOptions, type SetStreamingOptions } from './types.js';
3
- import type { RuntimeInputKind } from './runtime-cards.js';
4
- import type { ApprovalNativeRequestMetadata, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalRisk, SessionRule } from './approval-types.js';
5
- import type { RuntimeInputAnswers, RuntimeInputChoice, RuntimeInputNativeMetadata, RuntimeInputQuestion, RuntimeCardNativeMetadata, RuntimeCardV1 } from './runtime-cards.js';
6
- import type { InboundDisposition } from './turn-protocol.js';
2
+ import { type CanonMessage, type CanonConversation, type CanonMessagesPage, type AgentContext, type MediaAttachment, type SendMessageOptions, type RegistrationStatus, type AgentOriginDeclaration, type SetRuntimeTurnOptions } from './types.js';
7
3
  import { type CanonVerbWireRequest, type CanonVerbWireResponse, type CommunicateInput, type CommunicateResult, type DiscoverAgentsInput, type DiscoverAgentsResult } from '../backend-contracts/index.js';
8
- import { type EndpointOperation } from '../endpoint/index.js';
9
4
  import { type CanonClientEndpointOptions, type CanonEndpoint } from './endpoint-client.js';
10
5
  export interface ResumableMediaUploadResult {
11
6
  uploadId: string;
@@ -53,28 +48,6 @@ export declare class CanonClient {
53
48
  }): Promise<{
54
49
  messageId: string;
55
50
  }>;
56
- /** Inspect a trusted reply's durable delivery without rebuilding its body. */
57
- getMessageOperation(conversationId: string, messageId: string, delivery?: {
58
- operationId?: string;
59
- }): Promise<EndpointOperation | undefined>;
60
- /** Core's chunker records all ordered message intents before publishing any part. */
61
- prepareMessageGroup(conversationId: string, messageId: string, parts: Array<{
62
- text: string;
63
- options: SendMessageOptions;
64
- }>, delivery?: {
65
- operationId?: string;
66
- signal?: AbortSignal;
67
- replacesOperationId?: string;
68
- }): Promise<{
69
- id: string;
70
- sendPart(index: number, options?: {
71
- signal?: AbortSignal;
72
- timeoutMs?: number;
73
- }): Promise<{
74
- messageId: string;
75
- }>;
76
- }>;
77
- cancelMessageGroup(id: string): Promise<void>;
78
51
  /**
79
52
  * Execute a canonical verb over the wire contract (canon.verb-wire.v1).
80
53
  * Bindings build the request with projectVerbIntentToWire; the endpoint
@@ -99,13 +72,10 @@ export declare class CanonClient {
99
72
  private startWithheld;
100
73
  blockUser(userId: string): Promise<void>;
101
74
  deleteMessage(conversationId: string, messageId: string): Promise<void>;
102
- updateMessageDisposition(conversationId: string, messageId: string, inboundDisposition: InboundDisposition): Promise<void>;
103
75
  markAsRead(conversationId: string): Promise<void>;
104
76
  react(conversationId: string, messageId: string, emoji: string): Promise<void>;
105
- setStreaming(options: SetStreamingOptions): Promise<void>;
106
77
  clearStreaming(conversationId: string): Promise<void>;
107
78
  setRuntimeTurn(options: SetRuntimeTurnOptions): Promise<void>;
108
- setTyping(conversationId: string, typing: boolean, status?: 'thinking' | 'typing'): Promise<void>;
109
79
  peekRuntimeSignal(conversationId: string): Promise<Record<string, unknown>>;
110
80
  /** Acknowledge exactly the signal observed before the native handler ran. */
111
81
  acknowledgeRuntimeSignal(conversationId: string, signalId: string): Promise<Record<string, unknown>>;
@@ -124,190 +94,6 @@ export declare class CanonClient {
124
94
  mode: 'clear';
125
95
  }): Promise<void>;
126
96
  patchRuntimeStreaming(conversationId: string, patch: Record<string, unknown>): Promise<void>;
127
- createRuntimeInputRequest(options: {
128
- conversationId: string;
129
- inputId: string;
130
- kind: RuntimeInputKind;
131
- expiresAt: number;
132
- title?: string;
133
- prompt?: string;
134
- choices?: RuntimeInputChoice[];
135
- questions?: RuntimeInputQuestion[];
136
- secretName?: string;
137
- native?: RuntimeInputNativeMetadata;
138
- sensitive?: boolean;
139
- responseUserId?: string;
140
- turnId?: string;
141
- }): Promise<{
142
- success: true;
143
- inputId: string;
144
- expiresAt: number;
145
- messageId?: string;
146
- }>;
147
- consumeRuntimeInputResponse(options: {
148
- conversationId: string;
149
- inputId: string;
150
- cancel?: boolean;
151
- }): Promise<{
152
- status: 'pending';
153
- inputId: string;
154
- expiresAt?: number;
155
- } | {
156
- status: 'submitted';
157
- inputId: string;
158
- kind: RuntimeInputKind;
159
- value: string;
160
- answers?: RuntimeInputAnswers;
161
- } | {
162
- status: 'cancelled';
163
- inputId: string;
164
- kind: RuntimeInputKind;
165
- } | {
166
- status: 'timeout';
167
- inputId: string;
168
- kind: RuntimeInputKind;
169
- }>;
170
- createRuntimeApprovalRequest(options: {
171
- conversationId: string;
172
- approvalId?: string;
173
- toolName: string;
174
- toolSummary: string;
175
- expiresAt: number;
176
- responseUserId?: string;
177
- riskLevel?: 'normal' | 'destructive';
178
- risk?: ApprovalRisk;
179
- category?: ApprovalRequestCategory;
180
- runtimeId?: string;
181
- turnId?: string;
182
- native?: ApprovalNativeRequestMetadata;
183
- details?: ApprovalRequestDetail[];
184
- /** File-change preview rendered inline on the approval card. Truncate via truncateUnifiedDiff before sending. */
185
- diff?: CanonUnifiedDiff;
186
- allowSessionRule?: boolean;
187
- }): Promise<{
188
- success: true;
189
- approvalId: string;
190
- expiresAt: number;
191
- messageId?: string;
192
- responseUserId: string;
193
- allowSessionRule: boolean;
194
- }>;
195
- consumeRuntimeApprovalResponse(options: {
196
- conversationId: string;
197
- approvalId: string;
198
- cancel?: boolean;
199
- }): Promise<{
200
- status: 'pending';
201
- approvalId: string;
202
- expiresAt?: number;
203
- } | {
204
- status: 'allow';
205
- approvalId: string;
206
- sessionRule?: SessionRule;
207
- respondedBy?: string;
208
- } | {
209
- status: 'deny';
210
- approvalId: string;
211
- sessionRule?: SessionRule;
212
- respondedBy?: string;
213
- } | {
214
- status: 'timeout';
215
- approvalId: string;
216
- }>;
217
- createRuntimeCardRequest(options: {
218
- conversationId: string;
219
- card: RuntimeCardV1;
220
- cardId?: string;
221
- expiresAt?: number;
222
- responseUserId?: string;
223
- runtimeId?: string;
224
- turnId?: string;
225
- native?: RuntimeCardNativeMetadata;
226
- }): Promise<{
227
- success: true;
228
- cardId: string;
229
- messageId: string;
230
- /** True when the card has actions and a response is pending; false for display cards. */
231
- interactive: boolean;
232
- /** Effective human responder selected by Canon. */
233
- responseUserId?: string;
234
- /** Present only for interactive cards. */
235
- expiresAt?: number;
236
- }>;
237
- consumeRuntimeCardResponse(options: {
238
- conversationId: string;
239
- cardId: string;
240
- cancel?: boolean;
241
- }): Promise<{
242
- status: 'pending';
243
- cardId: string;
244
- expiresAt?: number;
245
- } | {
246
- status: 'submitted';
247
- cardId: string;
248
- actionId?: string;
249
- values?: Record<string, unknown>;
250
- respondedBy?: string;
251
- } | {
252
- status: 'cancelled';
253
- cardId: string;
254
- respondedBy?: string;
255
- } | {
256
- status: 'timeout';
257
- cardId: string;
258
- }>;
259
- /**
260
- * Create a server-owned plan-approval interaction.
261
- *
262
- * Seeds the pending node + attention + runtime-card state and authors the
263
- * `plan_approval` card message, mirroring the other `createRuntime*Request`
264
- * spine methods. Hosts resolve it through `consumeRuntimePlanResponse()` so
265
- * the canonical pending state, rather than a timeline receipt, is authoritative.
266
- */
267
- createRuntimePlanRequest(options: {
268
- conversationId: string;
269
- planId?: string;
270
- title?: string;
271
- summary?: string;
272
- body?: string;
273
- allowedPrompts?: ReadonlyArray<{
274
- tool: string;
275
- prompt: string;
276
- }>;
277
- responseUserId?: string;
278
- turnId?: string;
279
- expiresAt?: number;
280
- }): Promise<{
281
- success: true;
282
- planId: string;
283
- expiresAt: number;
284
- messageId?: string;
285
- interactive: boolean;
286
- }>;
287
- consumeRuntimePlanResponse(options: {
288
- conversationId: string;
289
- planId: string;
290
- cancel?: boolean;
291
- }): Promise<{
292
- status: 'pending';
293
- planId: string;
294
- expiresAt?: number;
295
- } | {
296
- status: 'approve' | 'revise' | 'reject';
297
- planId: string;
298
- feedback?: string;
299
- grantedPrompts?: Array<{
300
- tool: string;
301
- prompt: string;
302
- }>;
303
- receiptId?: string;
304
- } | {
305
- status: 'cancelled';
306
- planId: string;
307
- } | {
308
- status: 'timeout';
309
- planId: string;
310
- }>;
311
97
  updateRuntimeStatus(options: {
312
98
  runtime: string;
313
99
  hostMode?: boolean;
@@ -57,4 +57,3 @@ export { CANON_VERB_NAMES, CANON_VERB_NAMESPACE, CANON_VERBS_SCHEMA_ID, CANON_VE
57
57
  export { DEFAULT_DISCOVER_AGENTS_LIMIT, MAX_DISCOVER_AGENTS_LIMIT, MAX_DISCOVER_AGENTS_QUERY_LENGTH, type CanonAgentDirectoryEntry, type DiscoverAgentsInput, type DiscoverAgentsResult, } from '../backend-contracts/index.js';
58
58
  export { parseDirectConversationSelection, readCommunicationRule, type CommunicateInput, type CommunicateResult, type CommunicationRule, type DirectConversationSelection, type StartDirectInput, type StartDirectResult, } from '../backend-contracts/index.js';
59
59
  export { canonMediaDownloadUrl, sanitizeDownloadFileName, buildMediaContentDisposition, getStoredFileExtension } from '../backend-contracts/index.js';
60
- export * from './completed-output-journal.js';
@@ -0,0 +1,45 @@
1
+ import { type EndpointStore, type EndpointStoreTransaction } from './store.js';
2
+ /**
3
+ * A runtime's finished output, recorded before it is published: a turn's answer, or text a host sends with no turn. A
4
+ * host that dies between the answer and Canon's acceptance publishes exactly that output on restart and never runs the
5
+ * turn again. One record holds the answer, the inputs it answers and the audience it may reach, in the engine's own
6
+ * store, so recording it and settling its inputs once it is durable are each one transaction with the inbox.
7
+ */
8
+ export interface EndpointCompletion<T = unknown> {
9
+ version: 1;
10
+ id: string;
11
+ conversationId: string;
12
+ /** The inbox inputs it answers. They settle with it (`finishCompletion`); an uncertain input that no completion names is an orphan. */
13
+ inputIds: string[];
14
+ /** The audience its publication may reach (an encrypted room's group head, roster and admissions), or null. */
15
+ fence: unknown;
16
+ /** What the runtime answered, as its host records it. */
17
+ output: T;
18
+ createdAt: string;
19
+ }
20
+ /** Completions in the engine's store. Every write checks the current installation, as content writes do. */
21
+ export declare function createCompletions(input: {
22
+ store: EndpointStore;
23
+ ready(): Promise<unknown>;
24
+ assertOpen(): void;
25
+ assertCurrent(tx: EndpointStoreTransaction): Promise<void>;
26
+ /** Settles one inbox input inside the caller's transaction, as `setInboundState` does. */
27
+ settleInbound(tx: EndpointStoreTransaction, id: string, reason: string): Promise<void>;
28
+ }): {
29
+ save(record: EndpointCompletion): Promise<void>;
30
+ get<T>(id: string): Promise<EndpointCompletion<T> | undefined>;
31
+ /** Oldest first. */
32
+ list<T>(): Promise<Array<EndpointCompletion<T>>>;
33
+ /** One record for another, in one step: a Stop's cut keeps only what was already queued. */
34
+ replace(previousId: string, next: EndpointCompletion): Promise<void>;
35
+ /**
36
+ * The output is durable or withdrawn: its record goes, and in the same step `settle`'s inputs settle. An input already
37
+ * settled, or no longer in the inbox, is left as it is.
38
+ */
39
+ finish(id: string, settle?: {
40
+ inputIds: readonly string[];
41
+ reason: string;
42
+ }): Promise<void>;
43
+ /** The input ids every completion names, read inside the caller's transaction. */
44
+ answered(tx: EndpointStoreTransaction): Promise<Set<string>>;
45
+ };
@@ -7,9 +7,10 @@ import { type EndpointSyncOptions, type EndpointSyncPage } from './sync.js';
7
7
  import { type EndpointEventObserver, type EndpointTransportEvent } from './events.js';
8
8
  import { type EndpointRecoveryOptions, type EndpointRecoveryBaseline } from './recovery.js';
9
9
  import { type EndpointRecoveryMigration, type EndpointMigrationReceipt } from './migration.js';
10
- import { type EndpointBackgroundMediaAdapter, type EndpointMediaBytes, type EndpointMediaPipeline } from './media.js';
10
+ import { type EndpointMediaBytes, type EndpointMediaPipeline } from './media.js';
11
11
  import { type EndpointOrdering } from './queue.js';
12
12
  import { type EndpointInboundHandoff, type EndpointInboundStartResult } from './handoff.js';
13
+ import { type EndpointCompletion } from './completions.js';
13
14
  import { type ExternalInboundClaim } from './external-inbound.js';
14
15
  import type { EndpointExternalInboundClaimResult, EndpointExternalInboundOutcome } from '../backend-contracts/index.js';
15
16
  import { type MlsDevGroupClient } from './mls-dev-groups.js';
@@ -54,8 +55,6 @@ export interface EndpointOperation {
54
55
  conversationId?: string;
55
56
  messageId?: string;
56
57
  agentId?: string;
57
- /** Ordering scope for shared-work commands, retained after payload erasure. */
58
- artifactId?: string;
59
58
  status: EndpointLocalStatus;
60
59
  fingerprint: string;
61
60
  preconditions?: EndpointPreconditions;
@@ -184,9 +183,7 @@ export interface Endpoint {
184
183
  observeQuery<T>(query: string, parameters: Record<string, unknown>, listener: (value: T) => void, onError?: (error: unknown) => void): () => void;
185
184
  refreshQueries(): void;
186
185
  observeEvents(listener: (event: EndpointTransportEvent) => void, options?: EndpointEventObserver): () => void;
187
- createMediaPipeline<Source>(bytes: EndpointMediaBytes<Source>, options?: {
188
- background?: EndpointBackgroundMediaAdapter<Source>;
189
- }): EndpointMediaPipeline<Source>;
186
+ createMediaPipeline<Source>(bytes: EndpointMediaBytes<Source>): EndpointMediaPipeline<Source>;
190
187
  registerMessageGroup(input: EndpointMessageGroupInput, options?: {
191
188
  signal?: AbortSignal;
192
189
  }): Promise<EndpointOperation>;
@@ -246,11 +243,25 @@ export interface Endpoint {
246
243
  }): Promise<boolean>;
247
244
  acceptInbound(options: EndpointInboundConsumerOptions): EndpointInboundConsumer;
248
245
  setInboundState(id: string, state: EndpointInboundState, reason?: string): Promise<void>;
246
+ /** `unanswered`: only inputs no completion names (`completions.ts`), read in the same transaction. */
249
247
  listInbound(options?: {
250
248
  states?: EndpointInboundState[];
251
249
  after?: string;
252
250
  limit?: number;
251
+ unanswered?: boolean;
253
252
  }): Promise<EndpointInboundRecord[]>;
253
+ /** A runtime's finished output, recorded before it is published (`completions.ts`). The same record again is a no-op. */
254
+ saveCompletion(record: EndpointCompletion): Promise<void>;
255
+ getCompletion<T = unknown>(id: string): Promise<EndpointCompletion<T> | undefined>;
256
+ /** Every recorded completion, oldest first. */
257
+ listCompletions<T = unknown>(): Promise<Array<EndpointCompletion<T>>>;
258
+ /** One completion for another, in one transaction. */
259
+ replaceCompletion(previousId: string, next: EndpointCompletion): Promise<void>;
260
+ /** The output is durable or withdrawn: the completion goes, and `settle`'s inputs settle, in one transaction. */
261
+ finishCompletion(id: string, settle?: {
262
+ inputIds: readonly string[];
263
+ reason: string;
264
+ }): Promise<void>;
254
265
  discardPending(): Promise<void>;
255
266
  logout(): Promise<void>;
256
267
  close(): Promise<void>;
@@ -4,8 +4,7 @@ export interface EndpointTransportEvent {
4
4
  kind: string;
5
5
  data: Record<string, unknown>;
6
6
  }
7
- /** `artifacts` streams `artifact.changed` hints for rooms the principal belongs to. */
8
- export type EndpointEventFamily = 'messages' | 'contacts' | 'typing_presence' | 'runtime_turn' | 'voice' | 'artifacts';
7
+ export type EndpointEventFamily = 'messages' | 'contacts' | 'typing_presence' | 'runtime_turn' | 'voice';
9
8
  export interface EndpointEventObserver {
10
9
  families?: EndpointEventFamily[];
11
10
  /** Explicit principal projections; room projections follow membership. */
@@ -1,4 +1,5 @@
1
1
  export * from './engine.js';
2
+ export type { EndpointCompletion } from './completions.js';
2
3
  export * from './store.js';
3
4
  export * from './transport.js';
4
5
  export * from './observe-query.js';
@@ -11,12 +12,7 @@ export * from './media.js';
11
12
  export * from './history.js';
12
13
  export * from './ephemeral.js';
13
14
  export * from './transient-publisher.js';
14
- export { createArtifactClient, ArtifactRejectedError, type ArtifactClient, type ArtifactClientOptions, type ArtifactCreateOptions, type ArtifactLibrary, type ArtifactWriteResult, } from './artifacts.js';
15
- export { createArtifactImageClient, type ArtifactImageAddInput, type ArtifactImageClient, type ArtifactImageGenerateInput, type ArtifactImageGenerateResult, type ArtifactImageRegion, } from './artifact-images.js';
16
15
  export { isTerminalImageGenerationError } from './image-generation-errors.js';
17
- export { describeArtifact, summarizeArtifact, type ArtifactChessMoveView, type ArtifactChessView, type ArtifactFormChangeView, type ArtifactFormFieldView, type ArtifactFormView, type ArtifactImageVariantView, type ArtifactImageView, type ArtifactPrincipalView, type ArtifactView, type ArtifactViewOptions, } from './artifact-views.js';
18
- export { reduceArtifactRecord, replayArtifactPage, artifactCommandConflicts, artifactFormConflicts, type ArtifactConflict } from './artifact-reducer.js';
19
- export type { ArtifactAsset, ArtifactChessMove, ArtifactChessPlayers, ArtifactChessState, ArtifactCommand, ArtifactCommandBody, ArtifactCommandRecord, ArtifactContext, ArtifactDefinition, ArtifactDomainOutcome, ArtifactFormChange, ArtifactFormColumn, ArtifactFormField, ArtifactFormFieldRemoval, ArtifactFormRow, ArtifactFormState, ArtifactFormTable, ArtifactFormValue, ArtifactImageState, ArtifactImageVariant, ArtifactJson, ArtifactKind, ArtifactOutcomeCode, ArtifactReadResult, ArtifactReference, ArtifactSelection, ArtifactSnapshot, } from '../backend-contracts/index.js';
20
16
  export { eraseEndpointPlaintext } from './retention.js';
21
17
  export type { EndpointOperationRequest, EndpointOperationReceipt, EndpointOperationError, EndpointPreconditions, EndpointEvent, EndpointQueryRequest, EndpointQueryResponse, } from '../backend-contracts/index.js';
22
18
  export { CANON_ENDPOINT_PROTOCOL } from '../backend-contracts/index.js';
@@ -1,4 +1,3 @@
1
- import { type DeliveryObservation, type DeliveryAttention, type PreparedContent } from '../backend-contracts/index.js';
2
1
  import type { Endpoint } from './engine.js';
3
2
  import { type EndpointStore } from './store.js';
4
3
  export interface EndpointMediaDescriptor {
@@ -8,15 +7,6 @@ export interface EndpointMediaDescriptor {
8
7
  width?: number;
9
8
  height?: number;
10
9
  durationMs?: number;
11
- /** Local-only source cleanup; never sent in a stage manifest. */
12
- cleanupAfterSend?: boolean;
13
- /** Native-only normalization to apply after durable handoff, before staging. */
14
- normalization?: {
15
- kind: 'jpeg';
16
- maxDimension: 1600;
17
- quality: 0.85;
18
- fileName: 'photo.jpg';
19
- };
20
10
  }
21
11
  export interface EndpointUploadSession {
22
12
  uploadId: string;
@@ -57,17 +47,9 @@ export interface EndpointMediaFlow {
57
47
  }>;
58
48
  purpose?: 'prepare';
59
49
  publicationGeneration?: number;
60
- /** Frozen at initial staging; an upgrade must never move an uncertain delivery to another publisher. */
50
+ /** Written by versions before background delivery was retired (plaintext-retirement.md slice 6e): `background` marks a
51
+ * flow handed to it, which `resume` now ends. */
61
52
  deliveryMode?: 'legacy' | 'background';
62
- observation?: DeliveryObservation;
63
- /** Sealed at initial staging; session renewal never changes these bytes. */
64
- preparedContent?: PreparedContent;
65
- attention?: DeliveryAttention;
66
- background?: {
67
- phase: EndpointBackgroundMediaSnapshot['status'];
68
- uploadedBytes: number;
69
- totalBytes: number;
70
- };
71
53
  status: 'pending' | 'sending' | 'prepared' | 'succeeded' | 'cancelled' | 'rejected';
72
54
  error?: {
73
55
  message: string;
@@ -83,8 +65,6 @@ export interface EndpointMediaSendOptions {
83
65
  signal?: AbortSignal;
84
66
  onProgress?: (progress: EndpointMediaProgress) => void;
85
67
  beforePublish?: () => Promise<boolean>;
86
- /** The caller's bounded preflight choice. Existing flows always keep their persisted mode. */
87
- handoffMode?: 'background' | 'legacy';
88
68
  }
89
69
  export interface EndpointMediaInput<Source> {
90
70
  conversationId: string;
@@ -95,38 +75,6 @@ export interface EndpointMediaInput<Source> {
95
75
  descriptor: EndpointMediaDescriptor;
96
76
  }>;
97
77
  }
98
- export interface EndpointBackgroundMediaSnapshot {
99
- identity?: Pick<DeliveryObservation, 'messageId' | 'conversationId' | 'installationId' | 'environmentId'>;
100
- schemaVersion?: 2;
101
- observation?: DeliveryObservation;
102
- attention?: DeliveryAttention;
103
- deliveryId: string;
104
- status: 'preparing' | 'uploading' | 'waiting_for_connection' | 'sending' | 'cancelling' | 'published' | 'cancelled' | 'expired' | 'rejected';
105
- uploadedBytes: number;
106
- totalBytes: number;
107
- errorCode?: string;
108
- errorMessage?: string;
109
- }
110
- /** Native owns remote work once enqueue persists the request. Implementations
111
- * must treat enqueue as idempotent for a deliveryId and survive missing JS callbacks. */
112
- export interface EndpointBackgroundMediaAdapter<Source> {
113
- observationVersion?: 2;
114
- preparedContentVersion?: 1;
115
- available(): Promise<boolean>;
116
- sourceIdentity(source: Source): string;
117
- enqueue(input: EndpointMediaInput<Source> & {
118
- deliveryId: string;
119
- installationId: string;
120
- preparedContent?: PreparedContent;
121
- }): Promise<EndpointBackgroundMediaSnapshot>;
122
- inspect(): Promise<EndpointBackgroundMediaSnapshot[]>;
123
- /** Query server state only. Must never enqueue/renew/start transfers. */
124
- reconcile?(deliveryId: string): Promise<EndpointBackgroundMediaSnapshot>;
125
- subscribe(listener: (snapshot: EndpointBackgroundMediaSnapshot) => void): () => void;
126
- cancel(deliveryId: string): Promise<void>;
127
- cleanup(): Promise<void>;
128
- cleanupSource?(source: Source): Promise<void>;
129
- }
130
78
  export interface EndpointMediaPipeline<Source> {
131
79
  /** Prepare durable attachments for a later policy-controlled message publication. */
132
80
  prepare(input: {
@@ -146,12 +94,6 @@ export interface EndpointMediaPipeline<Source> {
146
94
  descriptor: EndpointMediaDescriptor;
147
95
  }>;
148
96
  }, options?: EndpointMediaSendOptions): Promise<string>;
149
- /** With `conversationId`, false for an encrypted room (or one whose mode is unknown): its files are prepared on the
150
- * device and sent without the background handoff, so a caller decides before building their descriptors. */
151
- canSendInBackground(options?: {
152
- maxProbeWaitMs?: number;
153
- conversationId?: string;
154
- }): Promise<boolean>;
155
97
  resume(id: string, options?: EndpointMediaSendOptions): Promise<string>;
156
98
  resumePending(): Promise<void>;
157
99
  setForeground?(active: boolean): void;
@@ -173,5 +115,4 @@ export declare function createEndpointMediaPipeline<Source>(options: {
173
115
  ids?: () => string;
174
116
  clock?: () => number;
175
117
  leaseMs?: number;
176
- background?: EndpointBackgroundMediaAdapter<Source>;
177
118
  }): EndpointMediaPipeline<Source>;
@@ -1,15 +1,13 @@
1
1
  import type { EndpointInboundRecord, EndpointIntent, EndpointOperation } from './engine.js';
2
2
  import type { EndpointStoreTransaction } from './store.js';
3
3
  /** `provider`: a job the server runs inline for as long as its provider takes; unordered, and never awaited by a drain. */
4
- export type EndpointOrdering = 'conversation' | 'message' | 'signal' | 'artifact' | 'independent' | 'provider';
4
+ export type EndpointOrdering = 'conversation' | 'message' | 'signal' | 'independent' | 'provider';
5
5
  /** Derived here, never an adapter override. Unknown/state-changing actions stay ordered. */
6
6
  export declare function endpointIntentOrdering(intent: EndpointIntent): EndpointOrdering;
7
7
  /** Transaction sequence is ordering metadata, never an idempotency identity. */
8
8
  export declare function nextQueueSequence(tx: EndpointStoreTransaction, name: string): Promise<number>;
9
9
  export declare function orderOperation(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<EndpointOperation>;
10
10
  export declare const outboxKey: (operation: EndpointOperation) => string;
11
- /** Per-work lane of non-terminal shared-work operations, in authoring order. */
12
- export declare const artifactOrderingPrefix: (conversationId: string, artifactId: string) => string;
13
11
  export declare const operationOrderingKey: (operation: EndpointOperation) => string | undefined;
14
12
  export declare function trackOperationOrder(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<void>;
15
13
  export declare function enqueueOperation(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<void>;
package/dist/media.js CHANGED
@@ -18,10 +18,10 @@ import {
18
18
  toAnthropicImageBlock,
19
19
  toAnthropicImageBlocksWithinBudget,
20
20
  uploadMediaFile
21
- } from "./chunks/chunk-ZPBOGOAD.js";
22
- import "./chunks/chunk-YJUPKU47.js";
23
- import "./chunks/chunk-YHDDOADK.js";
24
- import "./chunks/chunk-5WPAB5MB.js";
21
+ } from "./chunks/chunk-HTLKCUQG.js";
22
+ import "./chunks/chunk-BPSFHEAA.js";
23
+ import "./chunks/chunk-2NVLVPSG.js";
24
+ import "./chunks/chunk-VIS5WXNH.js";
25
25
  export {
26
26
  DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
27
27
  DEFAULT_MEDIA_CACHE_DIR,