@canonmsg/agent-sdk 13.2.0 → 13.3.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.
- package/dist/chunks/{chunk-5YKGDUJX.js → chunk-AVR7QCHK.js} +369 -416
- package/dist/chunks/{chunk-DTAWEQCM.js → chunk-BQGXOAIW.js} +2 -2
- package/dist/chunks/{chunk-5WPAB5MB.js → chunk-CUPSYLBV.js} +2041 -2049
- package/dist/chunks/{chunk-YJUPKU47.js → chunk-HFT75BNB.js} +2 -2
- package/dist/chunks/{chunk-YHDDOADK.js → chunk-NIORQKUI.js} +1 -1
- package/dist/chunks/{chunk-6FD6KFQN.js → chunk-ZT3TJZAV.js} +400 -270
- package/dist/chunks/{mls-crypto-NZVMSUFU.js → mls-crypto-AW7TY744.js} +2 -2
- package/dist/cli.js +141 -26
- package/dist/index.js +6 -6
- package/dist/internal/agent-tools/communication-tool.d.ts +80 -0
- package/dist/internal/agent-tools/index.d.ts +1 -0
- package/dist/internal/backend-contracts/endpoint.d.ts +25 -0
- package/dist/internal/backend-contracts/mlsDevKeyPackages.d.ts +4 -0
- package/dist/internal/core/client.d.ts +0 -4
- package/dist/internal/core/endpoint-client.d.ts +8 -0
- package/dist/internal/core/index.d.ts +1 -1
- package/dist/internal/core/registration-profile.d.ts +4 -1
- package/dist/internal/core/types.d.ts +3 -1
- package/dist/internal/endpoint/engine.d.ts +34 -9
- package/dist/internal/endpoint/events.d.ts +1 -2
- package/dist/internal/endpoint/index.d.ts +0 -5
- package/dist/internal/endpoint/media.d.ts +4 -63
- package/dist/internal/endpoint/mls-dev-groups.d.ts +9 -1
- package/dist/internal/endpoint/queue.d.ts +1 -3
- package/dist/media.js +4 -4
- package/dist/mls-wasm-host.js +3 -3
- package/dist/runner/mls.d.ts +12 -2
- package/dist/runner/runner.d.ts +5 -2
- package/package.json +2 -3
- package/dist/internal/endpoint/artifact-images.d.ts +0 -60
- package/dist/internal/endpoint/artifact-reducer.d.ts +0 -35
- package/dist/internal/endpoint/artifact-views.d.ts +0 -113
- package/dist/internal/endpoint/artifacts.d.ts +0 -75
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Endpoint } from './engine.js';
|
|
1
|
+
import type { Endpoint, EndpointDeliveryGuard } from './engine.js';
|
|
3
2
|
import { type EndpointStore } from './store.js';
|
|
4
3
|
export interface EndpointMediaDescriptor {
|
|
5
4
|
mimeType: string;
|
|
@@ -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
|
-
/**
|
|
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;
|
|
@@ -82,9 +64,7 @@ export interface EndpointMediaProgress {
|
|
|
82
64
|
export interface EndpointMediaSendOptions {
|
|
83
65
|
signal?: AbortSignal;
|
|
84
66
|
onProgress?: (progress: EndpointMediaProgress) => void;
|
|
85
|
-
beforePublish?:
|
|
86
|
-
/** The caller's bounded preflight choice. Existing flows always keep their persisted mode. */
|
|
87
|
-
handoffMode?: 'background' | 'legacy';
|
|
67
|
+
beforePublish?: EndpointDeliveryGuard;
|
|
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>;
|
|
@@ -48,6 +48,8 @@ export interface MlsDevAdmissionHold {
|
|
|
48
48
|
readonly waitingPrincipalIds: readonly string[];
|
|
49
49
|
/** This device joined after the room's first message, so its history starts later (mls-rooms-by-default.md §2.7). */
|
|
50
50
|
readonly missedEarlier?: true;
|
|
51
|
+
/** The room's group exists and this device is not in it: only a device already there can add it (§2.4). */
|
|
52
|
+
readonly outside?: true;
|
|
51
53
|
}
|
|
52
54
|
export interface MlsDevCurrentAudience {
|
|
53
55
|
readonly version: 1;
|
|
@@ -166,6 +168,8 @@ export interface MlsDevGroupBridge {
|
|
|
166
168
|
/** Reads and applies the room's conversation snapshot from Canon, for openings of members admitted since. */
|
|
167
169
|
readRoom?(conversationId: string): Promise<unknown>;
|
|
168
170
|
}
|
|
171
|
+
/** How many times a refused send is encrypted again by itself before it shows as not sent. */
|
|
172
|
+
export declare const MLS_DEV_RESEND_MAX = 3;
|
|
169
173
|
/** Internal attachment: the engine supplies its existing queue, receipt reducer,
|
|
170
174
|
* event/recovery intake, store and lifetime. Native work never runs inside tx. */
|
|
171
175
|
export declare function createMlsDevGroups(options: MlsDevDeviceClientOptions, context: MlsDevDeviceClientContext, keyPackages: MlsDevKeyPackageClient | undefined, bridge: MlsDevGroupBridge): {
|
|
@@ -175,6 +179,8 @@ export declare function createMlsDevGroups(options: MlsDevDeviceClientOptions, c
|
|
|
175
179
|
* encrypted room (mls-payload-v3.md §4). Items and cards are not forwarded yet. */
|
|
176
180
|
forwardText(value: unknown, operationId: string, guardId?: string): Promise<EndpointOperation>;
|
|
177
181
|
sendText(value: unknown, operationId: string, guardId?: string): Promise<EndpointOperation>;
|
|
182
|
+
/** A person's Retry of a text or item Canon refused: encrypted again for the room as it is now (`resendText`). */
|
|
183
|
+
resendText(operation: EndpointOperation): Promise<EndpointOperation | undefined>;
|
|
178
184
|
/** `sendText` for a person's composer: in a held room the text is kept, not refused (undefined), until `sendHeldTexts`. */
|
|
179
185
|
holdText(value: unknown, operationId: string): Promise<EndpointOperation | undefined>;
|
|
180
186
|
sendHeldTexts(conversationId: string): Promise<{
|
|
@@ -196,6 +202,8 @@ export declare function createMlsDevGroups(options: MlsDevDeviceClientOptions, c
|
|
|
196
202
|
syncText(conversationId: string, options?: EndpointSyncOptions): Promise<EndpointSyncPage>;
|
|
197
203
|
isTextReady: (conversationId: string) => Promise<boolean>;
|
|
198
204
|
readAcceptedReceipt(operation: EndpointOperation): Promise<EndpointOperationReceipt | undefined>;
|
|
199
|
-
settleReceipt(operation: EndpointOperation, receipt: EndpointOperationReceipt
|
|
205
|
+
settleReceipt(operation: EndpointOperation, receipt: EndpointOperationReceipt, options?: {
|
|
206
|
+
reconcileOnly?: boolean;
|
|
207
|
+
}): Promise<boolean>;
|
|
200
208
|
};
|
|
201
209
|
export {};
|
|
@@ -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' | '
|
|
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-
|
|
22
|
-
import "./chunks/chunk-
|
|
23
|
-
import "./chunks/chunk-
|
|
24
|
-
import "./chunks/chunk-
|
|
21
|
+
} from "./chunks/chunk-AVR7QCHK.js";
|
|
22
|
+
import "./chunks/chunk-HFT75BNB.js";
|
|
23
|
+
import "./chunks/chunk-NIORQKUI.js";
|
|
24
|
+
import "./chunks/chunk-CUPSYLBV.js";
|
|
25
25
|
export {
|
|
26
26
|
DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
|
|
27
27
|
DEFAULT_MEDIA_CACHE_DIR,
|
package/dist/mls-wasm-host.js
CHANGED
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
WASM_HOST_CONFIGURE,
|
|
3
3
|
WASM_HOST_PROVISION,
|
|
4
4
|
keyFile
|
|
5
|
-
} from "./chunks/chunk-
|
|
5
|
+
} from "./chunks/chunk-BQGXOAIW.js";
|
|
6
6
|
import {
|
|
7
7
|
MAX_INPUT,
|
|
8
8
|
NodeMlsDevCustodyError,
|
|
9
9
|
parseFrame,
|
|
10
10
|
rejected,
|
|
11
11
|
requireValue
|
|
12
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-HFT75BNB.js";
|
|
13
13
|
import {
|
|
14
14
|
__name,
|
|
15
15
|
canonicalEndpointJson,
|
|
16
16
|
isMlsDevReceiptClockSkew,
|
|
17
17
|
parseMlsDevDeviceContext
|
|
18
|
-
} from "./chunks/chunk-
|
|
18
|
+
} from "./chunks/chunk-CUPSYLBV.js";
|
|
19
19
|
|
|
20
20
|
// src/mls-wasm-host.ts
|
|
21
21
|
import { createHash } from "node:crypto";
|
package/dist/runner/mls.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CanonEndpoint, type CanonMlsDevOptions, type MlsDevCurrentAudience } from '../internal/core/index.js';
|
|
2
2
|
import { type MlsDevDeviceContext } from '../internal/backend-contracts/index.js';
|
|
3
|
+
import { type CommunicateShape } from '../internal/agent-tools/index.js';
|
|
3
4
|
import type { ToolDefinition } from './types.js';
|
|
4
5
|
/**
|
|
5
6
|
* What `createRunner({ mls })` takes: issuer pins and custody, plus the custody's own shutdown. With `provisioned`
|
|
@@ -59,8 +60,17 @@ export declare function requireMlsSupport(input: {
|
|
|
59
60
|
* digit, mark or `_` (`@Cipher A` does not mention `Cipher AB`).
|
|
60
61
|
*/
|
|
61
62
|
export declare function mentionsAgent(text: string, names: ReadonlyArray<string | undefined>): boolean;
|
|
62
|
-
/**
|
|
63
|
+
/** What an encrypted turn's `communicate` offers: listing, and text to its own room, which the runner encrypts. */
|
|
64
|
+
export declare const ENCRYPTED_COMMUNICATE_SHAPE: {
|
|
65
|
+
readonly list_conversations: readonly ["limit"];
|
|
66
|
+
readonly discover_agents: readonly ["limit"];
|
|
67
|
+
readonly message_existing: readonly ["conversationId", "text"];
|
|
68
|
+
};
|
|
69
|
+
/** An encrypted turn's `communicate`, as one flat schema (`communicateInputSchema`). */
|
|
63
70
|
export declare const ENCRYPTED_COMMUNICATE: ToolDefinition;
|
|
71
|
+
/** What an errand turn's `communicate` offers (§12.6): listing, its recipient and its origin, and for a person or agent, a new conversation. */
|
|
72
|
+
export declare const errandShape: (contact: boolean) => CommunicateShape;
|
|
73
|
+
export declare const errandCommunicate: (contact: boolean) => ToolDefinition;
|
|
64
74
|
/**
|
|
65
75
|
* The operator's MLS configuration file: public issuer pins and the custody helper's identity, never credentials or
|
|
66
76
|
* private keys. A canonical, current-user-owned regular file, not group- or other-writable, at most 64 KiB, read once.
|
|
@@ -101,7 +111,7 @@ export declare function runMlsDevSetup(endpoint: CanonEndpoint, action: MlsSetup
|
|
|
101
111
|
principalId: string;
|
|
102
112
|
installationId: string;
|
|
103
113
|
ownershipVersion: number | undefined;
|
|
104
|
-
status: "
|
|
114
|
+
status: "revoked" | "absent" | "identity_committed" | "registered" | "credential_committed";
|
|
105
115
|
deviceId: string | null;
|
|
106
116
|
credentialGeneration: number;
|
|
107
117
|
}>;
|
package/dist/runner/runner.d.ts
CHANGED
|
@@ -4,9 +4,12 @@ import { type CanonEndpoint, type CanonRuntimeDescriptor, type CommunicateInput,
|
|
|
4
4
|
import { type RunnerMlsOptions } from './mls.js';
|
|
5
5
|
import { type RuntimeDriver } from './types.js';
|
|
6
6
|
export interface RunnerOptions {
|
|
7
|
-
/** Canon refused this runner for good (its client floor, mls-cutover-operator.md §2 15b
|
|
7
|
+
/** Canon refused this runner for good (its client floor, mls-cutover-operator.md §2 15b, or the agent's home moved to
|
|
8
|
+
* another installation or Canon's relay); the CLI stops and exits. */
|
|
8
9
|
onFatal?(error: Error): void;
|
|
9
|
-
/**
|
|
10
|
+
/** Move the agent's home back to this installation after another one took it (`canon-agent run --take-over`). */
|
|
11
|
+
takeOver?: boolean;
|
|
12
|
+
/** How the runner names itself to Canon's client floor (`X-Canon-Client`); by default agent-sdk's own version (RUNNER_CLIENT). */
|
|
10
13
|
client?: {
|
|
11
14
|
kind: 'runner';
|
|
12
15
|
version: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonmsg/agent-sdk",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.3.0",
|
|
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;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { type ArtifactAsset, type ArtifactCommand, type ArtifactCommandBody, type ArtifactDefinition, type ArtifactDomainOutcome, type ArtifactOutcomeCode, type ArtifactReadResult, type ArtifactSnapshot } from '../backend-contracts/index.js';
|
|
2
|
-
import type { Endpoint } from './engine.js';
|
|
3
|
-
import { type ArtifactConflict } from './artifact-reducer.js';
|
|
4
|
-
/** The command was rejected by the shared rules; nothing new was accepted. */
|
|
5
|
-
export declare class ArtifactRejectedError extends Error {
|
|
6
|
-
readonly code: ArtifactOutcomeCode | 'UNSUPPORTED_VERSION';
|
|
7
|
-
readonly outcome?: ArtifactDomainOutcome;
|
|
8
|
-
readonly conflicts?: ArtifactConflict[];
|
|
9
|
-
/** The projection the command was evaluated against: the author's fresh state. */
|
|
10
|
-
readonly current?: ArtifactReadResult;
|
|
11
|
-
constructor(message: string, options: {
|
|
12
|
-
code: ArtifactOutcomeCode | 'UNSUPPORTED_VERSION';
|
|
13
|
-
outcome?: ArtifactDomainOutcome;
|
|
14
|
-
conflicts?: ArtifactConflict[];
|
|
15
|
-
current?: ArtifactReadResult;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* `accepted`: the relay stored the command and the shared rules accepted it.
|
|
20
|
-
* `queued`: the durable outbox keeps retrying delivery; snapshot and outcome
|
|
21
|
-
* are a local prediction. Callers must not resend.
|
|
22
|
-
*/
|
|
23
|
-
export interface ArtifactWriteResult extends ArtifactReadResult {
|
|
24
|
-
outcome: ArtifactDomainOutcome;
|
|
25
|
-
status: 'accepted' | 'queued';
|
|
26
|
-
}
|
|
27
|
-
/** `unavailable` codes include NO_DEFINITION and ARTIFACT_LOADING (a long log still replaying; a later listing has it). */
|
|
28
|
-
export interface ArtifactLibrary {
|
|
29
|
-
artifacts: ArtifactSnapshot[];
|
|
30
|
-
unavailable: Array<{
|
|
31
|
-
artifactId: string;
|
|
32
|
-
code: string;
|
|
33
|
-
message: string;
|
|
34
|
-
}>;
|
|
35
|
-
}
|
|
36
|
-
/** The client stamps the schema; a caller-supplied schema must match it. */
|
|
37
|
-
export type ArtifactCommandInput = ArtifactCommandBody | ArtifactCommand;
|
|
38
|
-
export interface ArtifactWriteOptions {
|
|
39
|
-
commandId?: string;
|
|
40
|
-
waitMs?: number;
|
|
41
|
-
}
|
|
42
|
-
export interface ArtifactCreateOptions {
|
|
43
|
-
artifactId?: string;
|
|
44
|
-
commandId?: string;
|
|
45
|
-
waitMs?: number;
|
|
46
|
-
}
|
|
47
|
-
export interface ArtifactClientOptions {
|
|
48
|
-
encoding?: 'json' | 'mls';
|
|
49
|
-
/** How long a listing waits for one work before reporting it as still loading (default 4 s). */
|
|
50
|
-
listItemWaitMs?: number;
|
|
51
|
-
}
|
|
52
|
-
export interface ArtifactClient {
|
|
53
|
-
list(conversationId: string): Promise<ArtifactLibrary>;
|
|
54
|
-
read(conversationId: string, artifactId: string, options?: {
|
|
55
|
-
revisionId?: string;
|
|
56
|
-
}): Promise<ArtifactReadResult>;
|
|
57
|
-
create(conversationId: string, definition: ArtifactDefinition, options?: ArtifactCreateOptions): Promise<ArtifactWriteResult>;
|
|
58
|
-
apply(conversationId: string, artifactId: string, command: ArtifactCommandInput, options?: ArtifactWriteOptions): Promise<ArtifactWriteResult>;
|
|
59
|
-
retainAsset(conversationId: string, artifactId: string, assetId: string): Promise<ArtifactAsset>;
|
|
60
|
-
getAsset(conversationId: string, artifactId: string, assetId: string): Promise<ArtifactAsset>;
|
|
61
|
-
/** Polls the log head only; reads (and replays) when it moves. */
|
|
62
|
-
observe(conversationId: string, artifactId: string, listener: (value: ArtifactReadResult) => void, onError?: (error: unknown) => void): () => void;
|
|
63
|
-
observeList(conversationId: string, listener: (value: ArtifactLibrary) => void, onError?: (error: unknown) => void): () => void;
|
|
64
|
-
/**
|
|
65
|
-
* An opaque command ID for one deliberate request: `cmd-` and 40 hex
|
|
66
|
-
* characters of an HMAC-SHA256 over the canonical JSON of `material`, keyed
|
|
67
|
-
* by this installation's secret. Stable for retries on this installation,
|
|
68
|
-
* unrelated elsewhere, and never a server-testable hash of its content.
|
|
69
|
-
* Throws PREPARATION_INSTALLATION_FENCED on an endpoint another logout fenced.
|
|
70
|
-
*/
|
|
71
|
-
deriveCommandId(material: unknown[]): Promise<string>;
|
|
72
|
-
/** The same derivation (separate domain) as an RFC 4122-shaped UUID, for image request IDs. */
|
|
73
|
-
deriveRequestId(material: unknown[]): Promise<string>;
|
|
74
|
-
}
|
|
75
|
-
export declare function createArtifactClient(endpoint: Endpoint, options?: ArtifactClientOptions): ArtifactClient;
|