@canonmsg/agent-sdk 11.2.1 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -523
- package/dist/chunks/chunk-7N6OPPW4.js +5430 -0
- package/dist/chunks/chunk-N722GWCP.js +4897 -0
- package/dist/chunks/chunk-QZ4PPRQW.js +14247 -0
- package/dist/chunks/mls-crypto-LMNQZOS6.js +10 -0
- package/dist/cli.js +572 -0
- package/dist/drivers/claude.d.ts +42 -0
- package/dist/drivers/code.d.ts +18 -0
- package/dist/drivers/codex.d.ts +46 -0
- package/dist/drivers/connector.d.ts +34 -0
- package/dist/index.d.ts +20 -25
- package/dist/index.js +91 -13
- package/dist/internal/backend-contracts/agentBehaviorPolicy.d.ts +122 -0
- package/dist/internal/backend-contracts/agentDirectory.d.ts +32 -0
- package/dist/internal/backend-contracts/agentOrigin.d.ts +23 -0
- package/dist/internal/backend-contracts/agentSearch.d.ts +17 -0
- package/dist/internal/backend-contracts/api-origins.generated.d.ts +4 -0
- package/dist/internal/backend-contracts/apiErrors.d.ts +1 -0
- package/dist/internal/backend-contracts/artifactActions.d.ts +8 -0
- package/dist/internal/backend-contracts/artifacts.d.ts +386 -0
- package/dist/internal/backend-contracts/clientFloor.d.ts +41 -0
- package/dist/internal/backend-contracts/communication.d.ts +146 -0
- package/dist/internal/backend-contracts/connectorRelay.d.ts +179 -0
- package/dist/internal/backend-contracts/conversationMembership.d.ts +28 -0
- package/dist/internal/backend-contracts/deliveryObservation.d.ts +23 -0
- package/dist/internal/backend-contracts/diffRedaction.d.ts +6 -0
- package/dist/internal/backend-contracts/endpoint-unread.d.ts +4 -0
- package/dist/internal/backend-contracts/endpoint.d.ts +120 -0
- package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +48 -0
- package/dist/internal/backend-contracts/environment.d.ts +20 -0
- package/dist/internal/backend-contracts/externalInbound.d.ts +24 -0
- package/dist/internal/backend-contracts/firestoreValues.d.ts +9 -0
- package/dist/internal/backend-contracts/index.d.ts +54 -0
- package/dist/internal/backend-contracts/media-url.d.ts +20 -0
- package/dist/internal/backend-contracts/media.d.ts +51 -0
- package/dist/internal/backend-contracts/mediaDelivery.d.ts +46 -0
- package/dist/internal/backend-contracts/mediaTransferProtocol.d.ts +17 -0
- package/dist/internal/backend-contracts/membershipChange.d.ts +21 -0
- package/dist/internal/backend-contracts/message.d.ts +86 -0
- package/dist/internal/backend-contracts/messageText.d.ts +6 -0
- package/dist/internal/backend-contracts/mlsDevApplication.d.ts +161 -0
- package/dist/internal/backend-contracts/mlsDevCredential.d.ts +78 -0
- package/dist/internal/backend-contracts/mlsDevCredentialReconciliation.d.ts +45 -0
- package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +52 -0
- package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +75 -0
- package/dist/internal/backend-contracts/mlsDevFeedReceipt.d.ts +43 -0
- package/dist/internal/backend-contracts/mlsDevGroup.d.ts +321 -0
- package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +51 -0
- package/dist/internal/backend-contracts/mlsDevInteraction.d.ts +159 -0
- package/dist/internal/backend-contracts/mlsDevKeyPackage.d.ts +42 -0
- package/dist/internal/backend-contracts/mlsDevKeyPackages.d.ts +55 -0
- package/dist/internal/backend-contracts/mlsEnvironment.d.ts +35 -0
- package/dist/internal/backend-contracts/mlsPrincipalAlias.d.ts +23 -0
- package/dist/internal/backend-contracts/moderation.d.ts +7 -0
- package/dist/internal/backend-contracts/plaintextProcessors.d.ts +63 -0
- package/dist/internal/backend-contracts/preparedContent.d.ts +54 -0
- package/dist/internal/backend-contracts/replyAuthority.d.ts +14 -0
- package/dist/internal/backend-contracts/runtimeCardFields.d.ts +66 -0
- package/dist/internal/backend-contracts/runtimeCardStorage.d.ts +3 -0
- package/dist/internal/backend-contracts/runtimeDescriptor.d.ts +88 -0
- package/dist/internal/backend-contracts/selfContext.d.ts +9 -0
- package/dist/internal/backend-contracts/turnProtocol.d.ts +43 -0
- package/dist/internal/backend-contracts/upload-mime-types.d.ts +17 -0
- package/dist/internal/backend-contracts/verbContract.d.ts +856 -0
- package/dist/internal/backend-contracts/verbSchemas.d.ts +1717 -0
- package/dist/internal/backend-contracts/verbWire.d.ts +493 -0
- package/dist/internal/backend-contracts/webAuth.d.ts +8 -0
- package/dist/internal/core/agent-profiles.d.ts +65 -0
- package/dist/internal/core/approval-format.d.ts +22 -0
- package/dist/internal/core/approval-manager.d.ts +43 -0
- package/dist/internal/core/approval-types.d.ts +73 -0
- package/dist/internal/core/base-url.d.ts +1 -0
- package/dist/internal/core/cli-metadata.d.ts +13 -0
- package/dist/internal/core/client.d.ts +432 -0
- package/dist/internal/core/completed-output-journal.d.ts +39 -0
- package/dist/internal/core/constants.d.ts +1 -0
- package/dist/internal/core/endpoint-client.d.ts +56 -0
- package/dist/internal/core/execution-environment-mode.d.ts +6 -0
- package/dist/internal/core/gifs.d.ts +29 -0
- package/dist/internal/core/host-runtime.d.ts +53 -0
- package/dist/internal/core/index.d.ts +68 -0
- package/dist/internal/core/node-media.d.ts +6 -0
- package/dist/internal/core/policy.d.ts +2 -0
- package/dist/internal/core/registration-profile.d.ts +10 -0
- package/dist/internal/core/registration-session.d.ts +55 -0
- package/dist/internal/core/registration.d.ts +5 -0
- package/dist/internal/core/retry.d.ts +113 -0
- package/dist/internal/core/rtdb-rest.d.ts +141 -0
- package/dist/internal/core/runtime-cards.d.ts +286 -0
- package/dist/internal/core/runtime-descriptor.d.ts +16 -0
- package/dist/internal/core/runtime-endpoints.d.ts +26 -0
- package/dist/internal/core/runtime-heartbeat.d.ts +29 -0
- package/dist/internal/core/runtime-presentation.d.ts +9 -0
- package/dist/internal/core/runtime-request-manager.d.ts +283 -0
- package/dist/internal/core/runtime-state-publisher.d.ts +42 -0
- package/dist/internal/core/self-context.d.ts +22 -0
- package/dist/internal/core/silent-turn.d.ts +49 -0
- package/dist/internal/core/stream.d.ts +78 -0
- package/dist/internal/core/turn-protocol.d.ts +28 -0
- package/dist/internal/core/turn-verbosity.d.ts +85 -0
- package/dist/internal/core/types.d.ts +964 -0
- package/dist/internal/core/unified-diff.d.ts +35 -0
- package/dist/internal/endpoint/artifact-images.d.ts +60 -0
- package/dist/internal/endpoint/artifact-reducer.d.ts +35 -0
- package/dist/internal/endpoint/artifact-views.d.ts +113 -0
- package/dist/internal/endpoint/artifacts.d.ts +75 -0
- package/dist/internal/endpoint/delivery.d.ts +47 -0
- package/dist/internal/endpoint/engine.d.ts +249 -0
- package/dist/internal/endpoint/ephemeral.d.ts +8 -0
- package/dist/internal/endpoint/events.d.ts +32 -0
- package/dist/internal/endpoint/external-inbound.d.ts +36 -0
- package/dist/internal/endpoint/handoff.d.ts +50 -0
- package/dist/internal/endpoint/history.d.ts +22 -0
- package/dist/internal/endpoint/image-generation-errors.d.ts +2 -0
- package/dist/internal/endpoint/inbound.d.ts +29 -0
- package/dist/internal/endpoint/index.d.ts +32 -0
- package/dist/internal/endpoint/media.d.ts +177 -0
- package/dist/internal/endpoint/migration.d.ts +50 -0
- package/dist/internal/endpoint/mls-crypto.d.ts +32 -0
- package/dist/internal/endpoint/mls-dev-client.d.ts +52 -0
- package/dist/internal/endpoint/mls-dev-device.d.ts +69 -0
- package/dist/internal/endpoint/mls-dev-groups.d.ts +174 -0
- package/dist/internal/endpoint/mls-dev-interactions.d.ts +99 -0
- package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +46 -0
- package/dist/internal/endpoint/mls-dev-key-packages.d.ts +62 -0
- package/dist/internal/endpoint/mls-dev-text.d.ts +67 -0
- package/dist/internal/endpoint/mls-dev-transport.d.ts +38 -0
- package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +29 -0
- package/dist/internal/endpoint/node-mls-custody.d.ts +15 -0
- package/dist/internal/endpoint/node.d.ts +7 -0
- package/dist/internal/endpoint/observe-query.d.ts +17 -0
- package/dist/internal/endpoint/portable-node-mls-custody.d.ts +23 -0
- package/dist/internal/endpoint/queue.d.ts +22 -0
- package/dist/internal/endpoint/recovery.d.ts +27 -0
- package/dist/internal/endpoint/retention.d.ts +7 -0
- package/dist/internal/endpoint/store.d.ts +22 -0
- package/dist/internal/endpoint/sync.d.ts +33 -0
- package/dist/internal/endpoint/transient-publisher.d.ts +8 -0
- package/dist/internal/endpoint/transport.d.ts +63 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.js +42 -541
- package/dist/runner/errands.d.ts +118 -0
- package/dist/runner/mls.d.ts +97 -0
- package/dist/runner/relay.d.ts +87 -0
- package/dist/runner/runner.d.ts +98 -0
- package/dist/runner/types.d.ts +215 -0
- package/package.json +18 -5
- package/dist/attached-session.d.ts +0 -58
- package/dist/attached-session.js +0 -638
- package/dist/bounded-file-read.d.ts +0 -14
- package/dist/bounded-file-read.js +0 -34
- package/dist/canon-agent.d.ts +0 -236
- package/dist/canon-agent.js +0 -2531
- package/dist/debouncer.d.ts +0 -18
- package/dist/debouncer.js +0 -133
- package/dist/inbound-handoff.d.ts +0 -6
- package/dist/inbound-handoff.js +0 -17
- package/dist/managed-session-host.d.ts +0 -27
- package/dist/managed-session-host.js +0 -195
- package/dist/managed-session-setup.d.ts +0 -99
- package/dist/managed-session-setup.js +0 -234
- package/dist/realtime.d.ts +0 -62
- package/dist/realtime.js +0 -193
- package/dist/runtime-card.d.ts +0 -48
- package/dist/runtime-card.js +0 -64
- package/dist/session-manager.d.ts +0 -77
- package/dist/session-manager.js +0 -285
- package/dist/turn-streaming-request.d.ts +0 -17
- package/dist/turn-streaming-request.js +0 -22
- package/dist/turn-verbosity-option.d.ts +0 -33
- package/dist/turn-verbosity-option.js +0 -23
- package/dist/types.d.ts +0 -387
- package/dist/types.js +0 -1
- package/dist/work-session-coordination.d.ts +0 -21
- package/dist/work-session-coordination.js +0 -53
- package/dist/work-session-host.d.ts +0 -31
- package/dist/work-session-host.js +0 -617
- package/dist/work-session-interactions.d.ts +0 -12
- package/dist/work-session-interactions.js +0 -173
- package/dist/work-session-state.d.ts +0 -36
- package/dist/work-session-state.js +0 -62
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isSensitiveDiffPath } from '../backend-contracts/index.js';
|
|
2
|
+
import type { CanonUnifiedDiff } from './types.js';
|
|
3
|
+
export { isSensitiveDiffPath };
|
|
4
|
+
/** Total unified hunk text budget across all files (~96 KB). */
|
|
5
|
+
export declare const UNIFIED_DIFF_MAX_TOTAL_BYTES: number;
|
|
6
|
+
/** Per-file unified hunk text budget (~24 KB). */
|
|
7
|
+
export declare const UNIFIED_DIFF_MAX_FILE_BYTES: number;
|
|
8
|
+
/** Maximum number of file entries carried on one diff payload. */
|
|
9
|
+
export declare const UNIFIED_DIFF_MAX_FILES = 100;
|
|
10
|
+
export interface TruncateUnifiedDiffOptions {
|
|
11
|
+
maxTotalBytes?: number;
|
|
12
|
+
maxFileBytes?: number;
|
|
13
|
+
maxFiles?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Enforce the unified-diff payload budget: clips each file's hunk text at a
|
|
17
|
+
* line boundary to `maxFileBytes`, then drops hunk text entirely once the
|
|
18
|
+
* running total exceeds `maxTotalBytes`. File entries (path, status, counts)
|
|
19
|
+
* always survive — only hunk text is clipped or dropped — and every clip sets
|
|
20
|
+
* the corresponding `truncated` flag.
|
|
21
|
+
*/
|
|
22
|
+
export declare function truncateUnifiedDiff(diff: CanonUnifiedDiff, options?: TruncateUnifiedDiffOptions): CanonUnifiedDiff;
|
|
23
|
+
/**
|
|
24
|
+
* Suppress and redact sensitive content in a diff before it leaves the host.
|
|
25
|
+
* Apply BEFORE truncateUnifiedDiff so byte budgets are spent on hunks that
|
|
26
|
+
* actually ship.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sanitizeUnifiedDiffForSharing(diff: CanonUnifiedDiff): CanonUnifiedDiff;
|
|
29
|
+
/**
|
|
30
|
+
* Parse an untrusted unified-diff payload (message metadata travels through
|
|
31
|
+
* Firestore and arbitrary hosts). Invalid file entries are dropped; the result
|
|
32
|
+
* is re-truncated to the standard budgets so clients never render an
|
|
33
|
+
* oversized payload. Returns undefined when nothing renderable remains.
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeCanonUnifiedDiff(value: unknown): CanonUnifiedDiff | undefined;
|
|
@@ -0,0 +1,60 @@
|
|
|
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;
|
|
@@ -0,0 +1,35 @@
|
|
|
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;
|
|
@@ -0,0 +1,113 @@
|
|
|
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;
|
|
@@ -0,0 +1,75 @@
|
|
|
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;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Endpoint, EndpointIntent, EndpointOperation, EndpointResolvedIdentity } from './engine.js';
|
|
2
|
+
import { type EndpointStore } from './store.js';
|
|
3
|
+
export interface EndpointMessageGroupInput {
|
|
4
|
+
id: string;
|
|
5
|
+
replacesOperationId?: string;
|
|
6
|
+
children: Array<{
|
|
7
|
+
operationId: string;
|
|
8
|
+
intent: EndpointIntent;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export interface EndpointMessageGroup {
|
|
12
|
+
id: string;
|
|
13
|
+
conversationId: string;
|
|
14
|
+
installationId: string;
|
|
15
|
+
fingerprint: string;
|
|
16
|
+
children: Array<{
|
|
17
|
+
operationId: string;
|
|
18
|
+
messageId: string;
|
|
19
|
+
}>;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
cancelled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function messageGroupChildSucceeded(operation: EndpointOperation | undefined): boolean;
|
|
24
|
+
/** Atomic ordered message plans; plaintext remains only in normal operation rows. */
|
|
25
|
+
export declare function createMessageGroupCoordinator(input: {
|
|
26
|
+
store: EndpointStore;
|
|
27
|
+
endpoint(): Endpoint;
|
|
28
|
+
ready(): Promise<EndpointResolvedIdentity>;
|
|
29
|
+
hash(value: string): Promise<string>;
|
|
30
|
+
clock(): number;
|
|
31
|
+
wake(): void;
|
|
32
|
+
preparationGeneration?(): number;
|
|
33
|
+
supportsPreparedContent?(): Promise<boolean>;
|
|
34
|
+
}): {
|
|
35
|
+
allowed(id: string): boolean;
|
|
36
|
+
close(): void;
|
|
37
|
+
settled(operation: EndpointOperation): Promise<void>;
|
|
38
|
+
register(plan: EndpointMessageGroupInput, options?: {
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}): Promise<EndpointOperation>;
|
|
41
|
+
get(id: string): Promise<EndpointOperation | undefined>;
|
|
42
|
+
wait(id: string, options?: {
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
}): Promise<import("../backend-contracts/index.js").EndpointOperationReceipt<unknown>>;
|
|
46
|
+
cancel(id: string): Promise<void>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { type EndpointMessageGroupInput } from './delivery.js';
|
|
2
|
+
import { type PreparedContent, type EndpointEvent, type EndpointOperationReceipt, type EndpointOperationRequest, type EndpointCapabilities, type EndpointPreconditions, type StartDirectInput, type StartDirectResult } from '../backend-contracts/index.js';
|
|
3
|
+
import { type EndpointStore } from './store.js';
|
|
4
|
+
import { type EndpointCredentials, type EndpointTransport } from './transport.js';
|
|
5
|
+
import { type EndpointInboundConsumer, type EndpointInboundConsumerOptions } from './inbound.js';
|
|
6
|
+
import { type EndpointSyncOptions, type EndpointSyncPage } from './sync.js';
|
|
7
|
+
import { type EndpointEventObserver, type EndpointTransportEvent } from './events.js';
|
|
8
|
+
import { type EndpointRecoveryOptions, type EndpointRecoveryBaseline } from './recovery.js';
|
|
9
|
+
import { type EndpointRecoveryMigration, type EndpointMigrationReceipt } from './migration.js';
|
|
10
|
+
import { type EndpointBackgroundMediaAdapter, type EndpointMediaBytes, type EndpointMediaPipeline } from './media.js';
|
|
11
|
+
import { type EndpointOrdering } from './queue.js';
|
|
12
|
+
import { type EndpointInboundHandoff, type EndpointInboundStartResult } from './handoff.js';
|
|
13
|
+
import { type ExternalInboundClaim } from './external-inbound.js';
|
|
14
|
+
import type { EndpointExternalInboundClaimResult, EndpointExternalInboundOutcome } from '../backend-contracts/index.js';
|
|
15
|
+
import { type MlsDevGroupClient } from './mls-dev-groups.js';
|
|
16
|
+
import { type MlsDevDeviceClientOptions, type MlsDevDeviceClient } from './mls-dev-client.js';
|
|
17
|
+
import { type MlsDevKeyPackageClient } from './mls-dev-key-packages.js';
|
|
18
|
+
export interface EndpointIdentity {
|
|
19
|
+
environmentId: string;
|
|
20
|
+
principalId: string;
|
|
21
|
+
installationId?: string;
|
|
22
|
+
ownershipVersion?: number;
|
|
23
|
+
}
|
|
24
|
+
export type EndpointResolvedIdentity = EndpointIdentity & {
|
|
25
|
+
installationId: string;
|
|
26
|
+
};
|
|
27
|
+
export interface EndpointIntent {
|
|
28
|
+
action: string;
|
|
29
|
+
body: Record<string, unknown>;
|
|
30
|
+
envelope?: Record<string, unknown>;
|
|
31
|
+
preconditions?: EndpointPreconditions;
|
|
32
|
+
}
|
|
33
|
+
export interface EndpointExecuteOptions {
|
|
34
|
+
operationId?: string;
|
|
35
|
+
sensitive?: boolean;
|
|
36
|
+
guardId?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface EndpointWaitOptions {
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
}
|
|
42
|
+
export type EndpointLocalStatus = 'queued' | 'sending' | 'deferred' | 'pending' | 'succeeded' | 'rejected' | 'uncertain';
|
|
43
|
+
export interface EndpointOperation {
|
|
44
|
+
operationId: string;
|
|
45
|
+
/** Durable authoring sequence, separate from the random operation identity. */
|
|
46
|
+
queueOrder?: number;
|
|
47
|
+
/** Derived dependency class retained even after the request payload is erased. */
|
|
48
|
+
ordering?: EndpointOrdering;
|
|
49
|
+
installationId: string;
|
|
50
|
+
action: string;
|
|
51
|
+
conversationId?: string;
|
|
52
|
+
messageId?: string;
|
|
53
|
+
agentId?: string;
|
|
54
|
+
/** Ordering scope for shared-work commands, retained after payload erasure. */
|
|
55
|
+
artifactId?: string;
|
|
56
|
+
status: EndpointLocalStatus;
|
|
57
|
+
fingerprint: string;
|
|
58
|
+
preconditions?: EndpointPreconditions;
|
|
59
|
+
sensitive: boolean;
|
|
60
|
+
resultEvicted?: boolean;
|
|
61
|
+
guardId?: string;
|
|
62
|
+
messageGroupId?: string;
|
|
63
|
+
childOperationIds?: string[];
|
|
64
|
+
messagePublished?: boolean;
|
|
65
|
+
request?: EndpointOperationRequest;
|
|
66
|
+
/** Exact sealed JSON bytes; retries do not run content preparation again. */
|
|
67
|
+
preparedContent?: PreparedContent;
|
|
68
|
+
/** Authored-input collision check, never recorded for memory-only answers. */
|
|
69
|
+
inputFingerprint?: string;
|
|
70
|
+
receipt?: EndpointOperationReceipt;
|
|
71
|
+
attempts: number;
|
|
72
|
+
attempted: boolean;
|
|
73
|
+
nextAttemptAt?: number;
|
|
74
|
+
lease?: {
|
|
75
|
+
owner: string;
|
|
76
|
+
expiresAt: number;
|
|
77
|
+
};
|
|
78
|
+
createdAt: string;
|
|
79
|
+
updatedAt: string;
|
|
80
|
+
}
|
|
81
|
+
export type EndpointInboundState = 'observed' | 'deferred' | 'offered' | 'uncertain' | 'settled';
|
|
82
|
+
export interface EndpointInboundRecord {
|
|
83
|
+
event: EndpointEvent;
|
|
84
|
+
queueKey?: string;
|
|
85
|
+
deleted?: boolean;
|
|
86
|
+
state: EndpointInboundState;
|
|
87
|
+
reason?: string;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
updatedAt: string;
|
|
90
|
+
lease?: {
|
|
91
|
+
owner: string;
|
|
92
|
+
expiresAt: number;
|
|
93
|
+
};
|
|
94
|
+
/** Opaque process generation; uncertain effects retain it until reconciliation. */
|
|
95
|
+
handoffGeneration?: string;
|
|
96
|
+
/** Installation epoch in which that handoff was acquired; logout fences replay. */
|
|
97
|
+
handoffInstallationGeneration?: number;
|
|
98
|
+
/** External acceptance survives the request process; it is never reoffered. */
|
|
99
|
+
externalClaim?: ExternalInboundClaim;
|
|
100
|
+
}
|
|
101
|
+
export interface EndpointConversation {
|
|
102
|
+
id: string;
|
|
103
|
+
membershipRevision?: number;
|
|
104
|
+
memberIds?: string[];
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}
|
|
107
|
+
export interface EndpointOptions {
|
|
108
|
+
identity: EndpointIdentity;
|
|
109
|
+
credentials?: EndpointCredentials;
|
|
110
|
+
transport: EndpointTransport;
|
|
111
|
+
store: EndpointStore;
|
|
112
|
+
clock?: () => number;
|
|
113
|
+
ids?: () => string;
|
|
114
|
+
hash?: (value: string) => Promise<string>;
|
|
115
|
+
/** SHA-256 of exact binary protocol frames, returned as lowercase hexadecimal. */
|
|
116
|
+
hashBytes?: (value: Uint8Array) => Promise<string>;
|
|
117
|
+
queryIntervalMs?: number;
|
|
118
|
+
leaseMs?: number;
|
|
119
|
+
/** The admission duty's retry while a member still has no device in an encrypted room (mls-rooms-by-default.md §2.4):
|
|
120
|
+
* the first delay and the most it backs off to. Defaults 30 s and 2 min. */
|
|
121
|
+
mlsAdmissionRetryMs?: {
|
|
122
|
+
initial: number;
|
|
123
|
+
maximum: number;
|
|
124
|
+
};
|
|
125
|
+
/** Must remain shorter than the server's guaranteed receipt retention. */
|
|
126
|
+
retryHorizonMs?: number;
|
|
127
|
+
/** Agent input must pass the same server admission policy as live delivery. */
|
|
128
|
+
admitRecoveredMessages?: boolean;
|
|
129
|
+
/** Disable automatic delivery when inspecting or importing a stopped installation. Explicit execute/drain remains available. */
|
|
130
|
+
autoDrain?: boolean;
|
|
131
|
+
/** Explicit synthetic Dev device identity operations, using this endpoint's store and lifecycle. */
|
|
132
|
+
mlsDevDevice?: MlsDevDeviceClientOptions;
|
|
133
|
+
}
|
|
134
|
+
export type EndpointContentMode = 'plaintext' | 'mls-dev-text' | 'mls-required';
|
|
135
|
+
export interface Endpoint {
|
|
136
|
+
readonly mlsDevDevice?: MlsDevDeviceClient;
|
|
137
|
+
readonly mlsDevKeyPackages?: MlsDevKeyPackageClient;
|
|
138
|
+
readonly mlsDevGroups?: MlsDevGroupClient;
|
|
139
|
+
ready(): Promise<EndpointResolvedIdentity>;
|
|
140
|
+
getConversationContentMode(conversationId: string): Promise<EndpointContentMode>;
|
|
141
|
+
submit(intent: EndpointIntent, options?: EndpointExecuteOptions): Promise<EndpointOperation>;
|
|
142
|
+
execute<T = unknown>(intent: EndpointIntent, options?: EndpointExecuteOptions): Promise<EndpointOperationReceipt<T>>;
|
|
143
|
+
executeResult<T = unknown>(intent: EndpointIntent, options?: EndpointExecuteOptions): Promise<T>;
|
|
144
|
+
/** reconcileOnly reads the server receipt; it never dispatches an operation. */
|
|
145
|
+
retry<T = unknown>(operationId: string, options?: {
|
|
146
|
+
reconcileOnly?: boolean;
|
|
147
|
+
}): Promise<EndpointOperationReceipt<T>>;
|
|
148
|
+
drain(options?: {
|
|
149
|
+
limit?: number;
|
|
150
|
+
}): Promise<void>;
|
|
151
|
+
getOperation(operationId: string): Promise<EndpointOperation | undefined>;
|
|
152
|
+
/** Observe shared delivery without creating an adapter retry loop. */
|
|
153
|
+
waitForOperation<T = unknown>(operationId: string, options?: EndpointWaitOptions): Promise<EndpointOperationReceipt<T>>;
|
|
154
|
+
listOperations(options?: {
|
|
155
|
+
statuses?: EndpointLocalStatus[];
|
|
156
|
+
conversationId?: string;
|
|
157
|
+
after?: string;
|
|
158
|
+
limit?: number;
|
|
159
|
+
}): Promise<EndpointOperation[]>;
|
|
160
|
+
subscribe(listener: (operation: EndpointOperation) => void): () => void;
|
|
161
|
+
query<T>(query: string, parameters?: Record<string, unknown>): Promise<T>;
|
|
162
|
+
capabilities(): Promise<EndpointCapabilities | null>;
|
|
163
|
+
/** This account's MLS principal ID: its alias, checked against its opening, or its account ID while it has none
|
|
164
|
+
* (mls-dev-groups.md, erasure privacy). */
|
|
165
|
+
mlsPrincipalId(): Promise<string>;
|
|
166
|
+
/** The account an MLS principal in this room's group stands for, by the room's checked openings; undefined when nothing
|
|
167
|
+
* opens it as that type (an erased account's alias). */
|
|
168
|
+
mlsAccountOf(conversationId: string, principal: {
|
|
169
|
+
type: string;
|
|
170
|
+
id: string;
|
|
171
|
+
}): Promise<string | undefined>;
|
|
172
|
+
/** The alias an account of this type carries in this room's group, among `admitted` aliases when given; undefined when
|
|
173
|
+
* none or several do (its account ID while it has none, until step 14c). */
|
|
174
|
+
mlsAliasOf(conversationId: string, accountId: string, type: 'human' | 'ai_agent', admitted?: readonly string[]): Promise<string | undefined>;
|
|
175
|
+
publish<T = unknown>(action: string, body: Record<string, unknown>): Promise<T>;
|
|
176
|
+
observeQuery<T>(query: string, parameters: Record<string, unknown>, listener: (value: T) => void, onError?: (error: unknown) => void): () => void;
|
|
177
|
+
refreshQueries(): void;
|
|
178
|
+
observeEvents(listener: (event: EndpointTransportEvent) => void, options?: EndpointEventObserver): () => void;
|
|
179
|
+
createMediaPipeline<Source>(bytes: EndpointMediaBytes<Source>, options?: {
|
|
180
|
+
background?: EndpointBackgroundMediaAdapter<Source>;
|
|
181
|
+
}): EndpointMediaPipeline<Source>;
|
|
182
|
+
registerMessageGroup(input: EndpointMessageGroupInput, options?: {
|
|
183
|
+
signal?: AbortSignal;
|
|
184
|
+
}): Promise<EndpointOperation>;
|
|
185
|
+
getMessageGroup(id: string): Promise<EndpointOperation | undefined>;
|
|
186
|
+
waitForMessageGroup(id: string, options?: EndpointWaitOptions): Promise<EndpointOperationReceipt>;
|
|
187
|
+
cancelMessageGroup(id: string): Promise<void>;
|
|
188
|
+
/** Runtime-specific publication policy; closures are never serialized.
|
|
189
|
+
* Return false to defer, or throw a nonretryable EndpointError to retire an
|
|
190
|
+
* unsent operation. An attempted operation still needs its server receipt. */
|
|
191
|
+
registerDeliveryGuard(id: string, allow: () => Promise<boolean>): () => void;
|
|
192
|
+
/** Keep a start's opening line that Canon did not store, and send it once the room and the request allow (§2a.13). */
|
|
193
|
+
deferOpener(input: {
|
|
194
|
+
conversationId: string;
|
|
195
|
+
messageId: string;
|
|
196
|
+
text: string;
|
|
197
|
+
requestId?: string | null;
|
|
198
|
+
}): Promise<void>;
|
|
199
|
+
/** Persist the opening line before starting a room; recover the start through its durable receipt. */
|
|
200
|
+
startWithheldOpener(input: Omit<StartDirectInput, 'opener'> & {
|
|
201
|
+
messageId: string;
|
|
202
|
+
text: string;
|
|
203
|
+
}): Promise<StartDirectResult>;
|
|
204
|
+
applyConversationSnapshot<T extends EndpointConversation>(snapshot: T): Promise<T>;
|
|
205
|
+
getConversation<T extends EndpointConversation = EndpointConversation>(id: string): Promise<T | null>;
|
|
206
|
+
applyEvent(event: EndpointEvent): Promise<boolean>;
|
|
207
|
+
syncConversation(conversationId: string, options?: EndpointSyncOptions): Promise<EndpointSyncPage>;
|
|
208
|
+
startRecovery(options?: EndpointRecoveryOptions): () => void;
|
|
209
|
+
/** Immutable operator-reviewed or server-proven cutover for new rooms/admissions. */
|
|
210
|
+
configureRecoveryBaseline(config: EndpointRecoveryBaseline): Promise<void>;
|
|
211
|
+
getRecoveryBaseline(): Promise<EndpointRecoveryBaseline | undefined>;
|
|
212
|
+
refreshRecovery(): Promise<void>;
|
|
213
|
+
planRecoveryMigration(baseline: EndpointRecoveryBaseline, conversationIds?: string[]): Promise<EndpointRecoveryMigration>;
|
|
214
|
+
importRecoveryMigration(manifest: EndpointRecoveryMigration, reviewedSha256: string): Promise<EndpointMigrationReceipt>;
|
|
215
|
+
getInbound(id: string): Promise<EndpointInboundRecord | undefined>;
|
|
216
|
+
claimInbound(id: string | string[]): Promise<boolean>;
|
|
217
|
+
claimExternalInbound(id: string, requestId: string, authorizedEvent: EndpointEvent): Promise<EndpointExternalInboundClaimResult>;
|
|
218
|
+
reserveExternalInboundReply(id: string, requestId: string, intent: import('../backend-contracts/index.js').EndpointExternalInboundReplyIntent): Promise<boolean>;
|
|
219
|
+
/** Trusted host preparation; persists fresh admission with the engine's immutable send identity. */
|
|
220
|
+
prepareExternalInboundReply(id: string, requestId: string, operationId: string, prepare: () => Promise<{
|
|
221
|
+
event: EndpointEvent;
|
|
222
|
+
intent: EndpointIntent;
|
|
223
|
+
}>): Promise<{
|
|
224
|
+
event: EndpointEvent;
|
|
225
|
+
replayed: boolean;
|
|
226
|
+
}>;
|
|
227
|
+
settleExternalInbound(id: string, requestId: string, outcome: EndpointExternalInboundOutcome, replyFingerprint?: string): Promise<boolean>;
|
|
228
|
+
acquireInbound(id: string): Promise<EndpointInboundHandoff | null>;
|
|
229
|
+
startInbound<T>(handles: EndpointInboundHandoff | readonly EndpointInboundHandoff[], submit: () => T | Promise<T>): Promise<EndpointInboundStartResult<T>>;
|
|
230
|
+
/** Trusted host only: its durable journal must positively prove the provider
|
|
231
|
+
* submission boundary never ran. Absence of a remote receipt is not proof.
|
|
232
|
+
* Fences an exact uncertain generation; never infers or verifies that proof. */
|
|
233
|
+
reconcileInboundNotSubmitted(id: string, expected: {
|
|
234
|
+
expectedHandoffGeneration: string;
|
|
235
|
+
expectedInstallationId: string;
|
|
236
|
+
}): Promise<boolean>;
|
|
237
|
+
acceptInbound(options: EndpointInboundConsumerOptions): EndpointInboundConsumer;
|
|
238
|
+
setInboundState(id: string, state: EndpointInboundState, reason?: string): Promise<void>;
|
|
239
|
+
listInbound(options?: {
|
|
240
|
+
states?: EndpointInboundState[];
|
|
241
|
+
after?: string;
|
|
242
|
+
limit?: number;
|
|
243
|
+
}): Promise<EndpointInboundRecord[]>;
|
|
244
|
+
discardPending(): Promise<void>;
|
|
245
|
+
logout(): Promise<void>;
|
|
246
|
+
close(): Promise<void>;
|
|
247
|
+
}
|
|
248
|
+
export declare function mergeConversationSnapshot<T extends EndpointConversation>(current: T | undefined, incoming: T): T;
|
|
249
|
+
export declare function createEndpoint(options: EndpointOptions): Endpoint;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Endpoint } from './engine.js';
|
|
2
|
+
export interface EndpointEphemeralObserver {
|
|
3
|
+
observe(path: string, listener: (value: unknown) => void, onError?: (error: unknown) => void): () => void;
|
|
4
|
+
close(): void;
|
|
5
|
+
}
|
|
6
|
+
/** One in-memory transient projection and SSE owner per endpoint. Snapshots
|
|
7
|
+
* bootstrap active scopes; disconnected fallback reads are shared and bounded. */
|
|
8
|
+
export declare function createEndpointEphemeralObserver(endpoint: Pick<Endpoint, 'query' | 'observeEvents'>): EndpointEphemeralObserver;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type EndpointTransport } from './transport.js';
|
|
2
|
+
export interface EndpointTransportEvent {
|
|
3
|
+
id?: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
data: Record<string, unknown>;
|
|
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';
|
|
9
|
+
export interface EndpointEventObserver {
|
|
10
|
+
families?: EndpointEventFamily[];
|
|
11
|
+
/** Explicit principal projections; room projections follow membership. */
|
|
12
|
+
principalScopes?: string[];
|
|
13
|
+
onConnected?(): void;
|
|
14
|
+
onDisconnected?(): void;
|
|
15
|
+
onError?(error: Error): void;
|
|
16
|
+
}
|
|
17
|
+
/** One reconnect loop and replay token per endpoint, shared by every observer. */
|
|
18
|
+
export declare function createEndpointEventHub(input: {
|
|
19
|
+
transport: EndpointTransport;
|
|
20
|
+
invalidate(event?: EndpointTransportEvent): void;
|
|
21
|
+
onEvent?(event: EndpointTransportEvent): Promise<void>;
|
|
22
|
+
onDisconnected?(): void;
|
|
23
|
+
}): {
|
|
24
|
+
isConnected: () => boolean;
|
|
25
|
+
observe(listener: (event: EndpointTransportEvent) => void, hooks?: EndpointEventObserver): () => void;
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
/** Incremental SSE parsing handles CRLF and UTF-8 boundaries without Node APIs. */
|
|
29
|
+
export declare function readEndpointEvents(response: Response, options: {
|
|
30
|
+
signal: AbortSignal;
|
|
31
|
+
idleTimeoutMs?: number;
|
|
32
|
+
}): AsyncGenerator<EndpointTransportEvent>;
|