@canonmsg/agent-sdk 13.2.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.
@@ -6,11 +6,11 @@ import {
6
6
  frame,
7
7
  requireValue,
8
8
  typedNodeMlsDevCustody
9
- } from "./chunk-YJUPKU47.js";
9
+ } from "./chunk-BPSFHEAA.js";
10
10
  import {
11
11
  __name,
12
12
  parseMlsDevDeviceContext
13
- } from "./chunk-5WPAB5MB.js";
13
+ } from "./chunk-VIS5WXNH.js";
14
14
 
15
15
  // src/runner/home.ts
16
16
  import { randomBytes } from "node:crypto";
@@ -8,7 +8,7 @@ import {
8
8
  wasmMlsCustody,
9
9
  windowsAclProblems,
10
10
  writeDurable
11
- } from "./chunk-DTAWEQCM.js";
11
+ } from "./chunk-POBMFS2K.js";
12
12
  import {
13
13
  BoundedFileReadError,
14
14
  CanonApiError,
@@ -31,15 +31,15 @@ import {
31
31
  resolveCanonRuntimeConnection,
32
32
  splitTextWithinBytes,
33
33
  verifyCanonRuntimeConnection
34
- } from "./chunk-5YKGDUJX.js";
34
+ } from "./chunk-HTLKCUQG.js";
35
35
  import {
36
36
  NodeMlsDevCustodyError,
37
37
  createNodeMlsDevCustody,
38
38
  createPortableNodeMlsDevCustody
39
- } from "./chunk-YJUPKU47.js";
39
+ } from "./chunk-BPSFHEAA.js";
40
40
  import {
41
41
  parseMlsDevClientConfiguration
42
- } from "./chunk-YHDDOADK.js";
42
+ } from "./chunk-2NVLVPSG.js";
43
43
  import {
44
44
  CONNECTOR_RELAY_ANSWER_WITHIN_MS,
45
45
  CONNECTOR_RELAY_INSTALLATION_PATTERN,
@@ -70,7 +70,7 @@ import {
70
70
  parseMlsDevGroupRoster,
71
71
  resolveAllowedUploadMimeType,
72
72
  resolveConversationPolicyScope
73
- } from "./chunk-5WPAB5MB.js";
73
+ } from "./chunk-VIS5WXNH.js";
74
74
 
75
75
  // src/runner/types.ts
76
76
  var DriverSessionError = class extends Error {
@@ -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-6FD6KFQN.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-5YKGDUJX.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-6FD6KFQN.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-5YKGDUJX.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,
@@ -7,7 +7,7 @@ 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
13
  import { type EndpointCompletion } from './completions.js';
@@ -55,8 +55,6 @@ export interface EndpointOperation {
55
55
  conversationId?: string;
56
56
  messageId?: string;
57
57
  agentId?: string;
58
- /** Ordering scope for shared-work commands, retained after payload erasure. */
59
- artifactId?: string;
60
58
  status: EndpointLocalStatus;
61
59
  fingerprint: string;
62
60
  preconditions?: EndpointPreconditions;
@@ -185,9 +183,7 @@ export interface Endpoint {
185
183
  observeQuery<T>(query: string, parameters: Record<string, unknown>, listener: (value: T) => void, onError?: (error: unknown) => void): () => void;
186
184
  refreshQueries(): void;
187
185
  observeEvents(listener: (event: EndpointTransportEvent) => void, options?: EndpointEventObserver): () => void;
188
- createMediaPipeline<Source>(bytes: EndpointMediaBytes<Source>, options?: {
189
- background?: EndpointBackgroundMediaAdapter<Source>;
190
- }): EndpointMediaPipeline<Source>;
186
+ createMediaPipeline<Source>(bytes: EndpointMediaBytes<Source>): EndpointMediaPipeline<Source>;
191
187
  registerMessageGroup(input: EndpointMessageGroupInput, options?: {
192
188
  signal?: AbortSignal;
193
189
  }): Promise<EndpointOperation>;
@@ -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. */
@@ -12,12 +12,7 @@ export * from './media.js';
12
12
  export * from './history.js';
13
13
  export * from './ephemeral.js';
14
14
  export * from './transient-publisher.js';
15
- export { createArtifactClient, ArtifactRejectedError, type ArtifactClient, type ArtifactClientOptions, type ArtifactCreateOptions, type ArtifactLibrary, type ArtifactWriteResult, } from './artifacts.js';
16
- export { createArtifactImageClient, type ArtifactImageAddInput, type ArtifactImageClient, type ArtifactImageGenerateInput, type ArtifactImageGenerateResult, type ArtifactImageRegion, } from './artifact-images.js';
17
15
  export { isTerminalImageGenerationError } from './image-generation-errors.js';
18
- 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';
19
- export { reduceArtifactRecord, replayArtifactPage, artifactCommandConflicts, artifactFormConflicts, type ArtifactConflict } from './artifact-reducer.js';
20
- 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';
21
16
  export { eraseEndpointPlaintext } from './retention.js';
22
17
  export type { EndpointOperationRequest, EndpointOperationReceipt, EndpointOperationError, EndpointPreconditions, EndpointEvent, EndpointQueryRequest, EndpointQueryResponse, } from '../backend-contracts/index.js';
23
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-5YKGDUJX.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,
@@ -2,20 +2,20 @@ import {
2
2
  WASM_HOST_CONFIGURE,
3
3
  WASM_HOST_PROVISION,
4
4
  keyFile
5
- } from "./chunks/chunk-DTAWEQCM.js";
5
+ } from "./chunks/chunk-POBMFS2K.js";
6
6
  import {
7
7
  MAX_INPUT,
8
8
  NodeMlsDevCustodyError,
9
9
  parseFrame,
10
10
  rejected,
11
11
  requireValue
12
- } from "./chunks/chunk-YJUPKU47.js";
12
+ } from "./chunks/chunk-BPSFHEAA.js";
13
13
  import {
14
14
  __name,
15
15
  canonicalEndpointJson,
16
16
  isMlsDevReceiptClockSkew,
17
17
  parseMlsDevDeviceContext
18
- } from "./chunks/chunk-5WPAB5MB.js";
18
+ } from "./chunks/chunk-VIS5WXNH.js";
19
19
 
20
20
  // src/mls-wasm-host.ts
21
21
  import { createHash } from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonmsg/agent-sdk",
3
- "version": "13.2.0",
3
+ "version": "13.2.1",
4
4
  "description": "Canon Agent SDK — build AI agents that participate in Canon conversations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,8 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@modelcontextprotocol/sdk": "^1.30.0",
34
- "@noble/curves": "2.4.0",
35
- "chess.js": "1.4.0"
34
+ "@noble/curves": "2.4.0"
36
35
  },
37
36
  "peerDependencies": {
38
37
  "@anthropic-ai/claude-agent-sdk": "^0.3.289"
@@ -1,60 +0,0 @@
1
- import { type ArtifactImageRegion, type ArtifactImageVariant, type MediaAttachment } from '../backend-contracts/index.js';
2
- import type { Endpoint } from './engine.js';
3
- import { type ArtifactClient, type ArtifactWriteResult } from './artifacts.js';
4
- import { isTerminalImageGenerationError } from './image-generation-errors.js';
5
- export { isTerminalImageGenerationError };
6
- export type { ArtifactImageRegion };
7
- export interface ArtifactImageGenerateInput {
8
- prompt: string;
9
- label: string;
10
- /** 'current' edits the current version (or generates new when there is none). */
11
- from: 'current' | 'new' | {
12
- variantId: string;
13
- };
14
- /** Fractions of the source image, origin top-left. */
15
- region?: ArtifactImageRegion;
16
- /** UUID for one deliberate generation; reuse it to collect the same result. */
17
- requestId: string;
18
- /** Cancels the wait. Once the job is submitted, the result is `generating` and nothing is published. */
19
- signal?: AbortSignal;
20
- /** How long to wait for the provider before returning `generating` (default 180 s). */
21
- timeoutMs?: number;
22
- }
23
- export type ArtifactImageGenerateResult = {
24
- status: 'added';
25
- variant: ArtifactImageVariant;
26
- result: ArtifactWriteResult;
27
- attachment: MediaAttachment;
28
- } | {
29
- status: 'generating';
30
- requestId: string;
31
- };
32
- export interface ArtifactImageAddInput {
33
- assetId: string;
34
- label: string;
35
- prompt?: string;
36
- sourceVariantId?: string;
37
- select?: boolean;
38
- }
39
- export interface ArtifactImageClient {
40
- generate(conversationId: string, artifactId: string, input: ArtifactImageGenerateInput): Promise<ArtifactImageGenerateResult>;
41
- add(conversationId: string, artifactId: string, input: ArtifactImageAddInput): Promise<{
42
- variant: ArtifactImageVariant;
43
- result: ArtifactWriteResult;
44
- }>;
45
- }
46
- /** Test hooks; production uses the defaults. */
47
- export interface ArtifactImageClientOptions {
48
- pollIntervalMs?: number;
49
- /** A job may not be visible yet while its request is still being delivered. */
50
- notFoundGraceMs?: number;
51
- now?: () => number;
52
- sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
53
- }
54
- /**
55
- * The provider runs on the server under a durable `image-generation:<requestId>`
56
- * operation; this client only waits for its result, retains it, and adds it as
57
- * the current version. Repeating a call with the same requestId collects the
58
- * same image and never starts a second generation.
59
- */
60
- export declare function createArtifactImageClient(endpoint: Endpoint, artifacts?: ArtifactClient, options?: ArtifactImageClientOptions): ArtifactImageClient;
@@ -1,35 +0,0 @@
1
- import { type ArtifactCommandRecord, type ArtifactFormValue, type ArtifactReadResult, type ArtifactSnapshot } from '../backend-contracts/index.js';
2
- /**
3
- * Integrity failures halt replay: a sequence gap, a changed artifact identity,
4
- * an unsupported codec, or an envelope written by a newer Canon. Nothing else does.
5
- */
6
- export declare class ArtifactReplayError extends Error {
7
- readonly code: 'UNSUPPORTED_VERSION' | 'ARTIFACT_LOG_INVALID';
8
- constructor(code: 'UNSUPPORTED_VERSION' | 'ARTIFACT_LOG_INVALID', message: string);
9
- }
10
- /** FEN without the half-move and full-move clocks. */
11
- export declare const chessPositionKey: (fen: string) => string;
12
- /** A form value that changed since the author looked. */
13
- export interface ArtifactConflict {
14
- path: string[];
15
- label: string;
16
- expected: ArtifactFormValue;
17
- current: ArtifactFormValue;
18
- currentBy?: string;
19
- }
20
- /** Structured conflicts of a form command (form.set or form.fields) against the snapshot it was judged on. */
21
- export declare function artifactCommandConflicts(snapshot: ArtifactSnapshot, command: unknown): ArtifactConflict[];
22
- /** Structured conflicts of form.set changes against the snapshot they were judged on. */
23
- export declare function artifactFormConflicts(snapshot: ArtifactSnapshot, changes: unknown): ArtifactConflict[];
24
- /** Pure reduction of one relay record. Throws only for integrity halts. */
25
- export declare function reduceArtifactRecord(previous: ArtifactReadResult, record: ArtifactCommandRecord, conversationId: string): ArtifactReadResult;
26
- export interface ArtifactReplayPage {
27
- previous: ArtifactReadResult;
28
- commands: ArtifactCommandRecord[];
29
- conversationId: string;
30
- artifactId: string;
31
- /** Stop once this revision is reached (historical read). */
32
- revisionId?: string;
33
- }
34
- /** In-process replay of one log page. Built-in rules only: bounded and synchronous. */
35
- export declare function replayArtifactPage(page: ArtifactReplayPage): ArtifactReadResult;
@@ -1,113 +0,0 @@
1
- import { type ArtifactChessState, type ArtifactFormColumn, type ArtifactFormFieldType, type ArtifactFormRow, type ArtifactFormValue, type ArtifactKind, type ArtifactSnapshot } from '../backend-contracts/index.js';
2
- /** Readable projections of shared work for agents, prompts and compact UI. */
3
- export interface ArtifactPrincipalView {
4
- id: string;
5
- name?: string;
6
- isYou?: boolean;
7
- }
8
- export interface ArtifactViewOptions {
9
- /** The principal reading the view (marks `isYou`, seats and turn). */
10
- viewerId?: string;
11
- names?: Record<string, string>;
12
- /** The snapshot this viewer saw last; adds `changesSinceLastView`. */
13
- previous?: ArtifactSnapshot;
14
- }
15
- export interface ArtifactViewBase {
16
- artifactId: string;
17
- kind: ArtifactKind;
18
- title: string;
19
- revisionId: string;
20
- archived: boolean;
21
- createdBy: ArtifactPrincipalView;
22
- updatedBy: ArtifactPrincipalView;
23
- updatedAt: string;
24
- }
25
- export interface ArtifactChessMoveView {
26
- ply: number;
27
- notation: string;
28
- san: string;
29
- by: ArtifactPrincipalView;
30
- }
31
- export interface ArtifactChessView extends ArtifactViewBase {
32
- kind: 'chess';
33
- fen: string;
34
- /** ASCII, rank 8 first, uppercase White, with file and rank labels. */
35
- board: string;
36
- turn: 'white' | 'black';
37
- /** Full-move number. */
38
- moveNumber: number;
39
- /** e.g. "1. e4 e5 2. Nf3". */
40
- moveList: string;
41
- lastMove?: ArtifactChessMoveView;
42
- players: {
43
- white?: ArtifactPrincipalView;
44
- black?: ArtifactPrincipalView;
45
- };
46
- yourColor?: 'white' | 'black';
47
- yourTurn: boolean;
48
- status: ArtifactChessState['status'];
49
- result?: ArtifactChessState['result'];
50
- resignedBy?: ArtifactPrincipalView;
51
- check: boolean;
52
- /** SAN, while the game is active. */
53
- legalMoves?: string[];
54
- /** Moves since the previous view. */
55
- changesSinceLastView?: ArtifactChessMoveView[];
56
- }
57
- export interface ArtifactFormFieldView {
58
- id: string;
59
- label: string;
60
- type: ArtifactFormFieldType;
61
- value: ArtifactFormValue;
62
- required?: boolean;
63
- options?: string[];
64
- placeholder?: string;
65
- help?: string;
66
- decimals?: number;
67
- }
68
- export interface ArtifactFormChangeView {
69
- label: string;
70
- path: string[];
71
- before: ArtifactFormValue | Record<string, ArtifactFormValue>;
72
- after: ArtifactFormValue | Record<string, ArtifactFormValue>;
73
- }
74
- export interface ArtifactFormView extends ArtifactViewBase {
75
- kind: 'form';
76
- fields: ArtifactFormFieldView[];
77
- /** Labels of required fields that are empty. */
78
- missingRequired: string[];
79
- /**
80
- * `sums` holds each summed column's total, rounded to the column's decimals.
81
- * Form numbers are bounded, so a total is always finite; a total that is not
82
- * (state written outside the shared rules) reads as null instead of failing.
83
- */
84
- table?: {
85
- label?: string;
86
- columns: ArtifactFormColumn[];
87
- rows: ArtifactFormRow[];
88
- sums: Record<string, number | null>;
89
- };
90
- changesSinceLastView?: ArtifactFormChangeView[];
91
- }
92
- export interface ArtifactImageVariantView {
93
- id: string;
94
- label: string;
95
- prompt?: string;
96
- by: ArtifactPrincipalView;
97
- at: string;
98
- sourceVariantId?: string;
99
- assetId: string;
100
- current: boolean;
101
- }
102
- export interface ArtifactImageView extends ArtifactViewBase {
103
- kind: 'image';
104
- variants: ArtifactImageVariantView[];
105
- currentVariantId?: string;
106
- /** Versions added since the previous view. */
107
- changesSinceLastView?: ArtifactImageVariantView[];
108
- }
109
- export type ArtifactView = ArtifactChessView | ArtifactFormView | ArtifactImageView;
110
- export declare function chessBoardAscii(fen: string): string;
111
- export declare function describeArtifact(snapshot: ArtifactSnapshot, options?: ArtifactViewOptions): ArtifactView;
112
- /** One line, viewer-relative: "Chess “Game”: move 12, Black to move (you play Black). Your move. Last: 11...Nf6 by Alice." */
113
- export declare function summarizeArtifact(snapshot: ArtifactSnapshot, options?: Omit<ArtifactViewOptions, 'previous'>): string;