@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,174 @@
|
|
|
1
|
+
import { type MlsDevEnrollmentPrincipal, type MlsDevDeviceContext, type MlsDevGroupContext, type MlsDevGroupCommand, type MlsDevGroupPreparation, type MlsDevGroupHead, type MlsDevGroupRosterEntry, type MlsDevGroupQuery, type MlsDevGroupQueryResult, type MlsDevGroupFeedQuery, type MlsDevGroupFeedResult, type MlsDevTextProtocol, type MlsDevInteractionAnswer, type MlsDevInteractionRequestBody, type MlsDevInteractionWithdrawReason, type EndpointOperationReceipt } from '../backend-contracts/index.js';
|
|
2
|
+
import type { EndpointOperation } from './engine.js';
|
|
3
|
+
import type { MlsDevDeviceClientContext, MlsDevDeviceClientOptions } from './mls-dev-client.js';
|
|
4
|
+
import { type MlsDevKeyPackageClient } from './mls-dev-key-packages.js';
|
|
5
|
+
import { type EndpointStoreTransaction } from './store.js';
|
|
6
|
+
import { EndpointError } from './transport.js';
|
|
7
|
+
import { type MlsDevInteractionView } from './mls-dev-interactions.js';
|
|
8
|
+
import type { EndpointSyncPage, EndpointSyncOptions } from './sync.js';
|
|
9
|
+
export type MlsDevProtectedGroupPreparer = (identityContext: MlsDevDeviceContext, groupContext: MlsDevGroupContext, command: MlsDevGroupCommand, wrappedIdentity: string, wrappedGroup: string | null, wrappedKeyPackage: string | null) => Promise<MlsDevGroupPreparation>;
|
|
10
|
+
export interface MlsDevGroupView {
|
|
11
|
+
readonly status: 'pending' | 'active' | 'removed';
|
|
12
|
+
readonly conversationId: string;
|
|
13
|
+
readonly groupId: string;
|
|
14
|
+
readonly head: MlsDevGroupHead | null;
|
|
15
|
+
readonly roster: readonly MlsDevGroupRosterEntry[];
|
|
16
|
+
readonly pendingOperationId: string | null;
|
|
17
|
+
}
|
|
18
|
+
declare const roomRecoveryCodes: readonly ["MLS_DEV_GROUP_PREPARATION_FAILED", "MLS_DEV_GROUP_CREDENTIAL_EXPIRED", "MLS_DEV_CREDENTIAL_EXPIRED"];
|
|
19
|
+
export interface MlsDevGroupRecoveryFailure {
|
|
20
|
+
readonly version: 1;
|
|
21
|
+
readonly conversationId: string;
|
|
22
|
+
readonly code: typeof roomRecoveryCodes[number];
|
|
23
|
+
readonly lastAppliedSequence: number;
|
|
24
|
+
readonly observedAtMs: number;
|
|
25
|
+
}
|
|
26
|
+
/** Only these fixed room-local failures may let the shared stream continue. */
|
|
27
|
+
export declare function isMlsDevGroupRoomRecoveryFailure(error: unknown): error is EndpointError;
|
|
28
|
+
/** Derived exclusively from an atomically committed, native-verified application. */
|
|
29
|
+
export interface MlsDevVerifiedMessageBinding {
|
|
30
|
+
readonly version: 1;
|
|
31
|
+
readonly protocol: MlsDevTextProtocol;
|
|
32
|
+
readonly conversationId: string;
|
|
33
|
+
readonly messageId: string;
|
|
34
|
+
readonly groupId: string;
|
|
35
|
+
readonly operationId: string;
|
|
36
|
+
readonly feedOrdinal: number;
|
|
37
|
+
readonly envelopeHash: string;
|
|
38
|
+
readonly senderDeviceId: string;
|
|
39
|
+
readonly senderPrincipal: MlsDevEnrollmentPrincipal;
|
|
40
|
+
readonly head: MlsDevGroupHead;
|
|
41
|
+
readonly acceptedAtMs: number;
|
|
42
|
+
/** The account the sender's alias opens to in this room, or the erased sender (mls-dev-groups.md, erasure privacy). */
|
|
43
|
+
readonly senderId: string;
|
|
44
|
+
}
|
|
45
|
+
/** An online, fully caught-up audience snapshot for a model turn and its delivery guard. */
|
|
46
|
+
export interface MlsDevAdmissionHold {
|
|
47
|
+
readonly held: boolean;
|
|
48
|
+
readonly waitingPrincipalIds: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
export interface MlsDevCurrentAudience {
|
|
51
|
+
readonly version: 1;
|
|
52
|
+
readonly protocol: MlsDevTextProtocol;
|
|
53
|
+
readonly conversationId: string;
|
|
54
|
+
readonly groupId: string;
|
|
55
|
+
readonly ownDeviceId: string;
|
|
56
|
+
readonly head: MlsDevGroupHead;
|
|
57
|
+
readonly membershipRevision: number;
|
|
58
|
+
readonly admissionId: string;
|
|
59
|
+
readonly roster: readonly MlsDevGroupRosterEntry[];
|
|
60
|
+
readonly feedOrdinal: number;
|
|
61
|
+
}
|
|
62
|
+
/** One encrypted card operation in a v2 room (encrypted-interactions.md §2.3): exactly one of `request` (agents),
|
|
63
|
+
* `response` (the responder; a secret's plaintext goes in `secret`, which native seals and the endpoint never stores)
|
|
64
|
+
* or `withdraw` (the requesting device). */
|
|
65
|
+
export interface MlsDevInteractionInput {
|
|
66
|
+
readonly conversationId: string;
|
|
67
|
+
readonly messageId?: string;
|
|
68
|
+
readonly operationId?: string;
|
|
69
|
+
readonly guardId?: string;
|
|
70
|
+
readonly request?: Omit<MlsDevInteractionRequestBody, 'secretKey'>;
|
|
71
|
+
readonly response?: {
|
|
72
|
+
readonly requestId: string;
|
|
73
|
+
readonly agentId: string;
|
|
74
|
+
readonly answer: MlsDevInteractionAnswer;
|
|
75
|
+
} | {
|
|
76
|
+
readonly requestId: string;
|
|
77
|
+
readonly agentId: string;
|
|
78
|
+
readonly secret: string;
|
|
79
|
+
};
|
|
80
|
+
readonly withdraw?: {
|
|
81
|
+
readonly requestId: string;
|
|
82
|
+
readonly reason: MlsDevInteractionWithdrawReason;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export interface MlsDevGroupClient {
|
|
86
|
+
createRoom(input: {
|
|
87
|
+
conversationId: string;
|
|
88
|
+
name: string;
|
|
89
|
+
memberIds: string[];
|
|
90
|
+
operationId?: string;
|
|
91
|
+
protocol?: MlsDevTextProtocol;
|
|
92
|
+
}): Promise<EndpointOperation>;
|
|
93
|
+
create(input: {
|
|
94
|
+
conversationId: string;
|
|
95
|
+
operationId?: string;
|
|
96
|
+
}): Promise<EndpointOperation>;
|
|
97
|
+
add(input: {
|
|
98
|
+
conversationId: string;
|
|
99
|
+
claimRequestId: string;
|
|
100
|
+
operationId?: string;
|
|
101
|
+
}): Promise<EndpointOperation>;
|
|
102
|
+
remove(input: {
|
|
103
|
+
conversationId: string;
|
|
104
|
+
removedDeviceId: string;
|
|
105
|
+
operationId?: string;
|
|
106
|
+
}): Promise<EndpointOperation>;
|
|
107
|
+
refresh(conversationId: string): Promise<MlsDevGroupView | undefined>;
|
|
108
|
+
read(conversationId: string): Promise<MlsDevGroupView | undefined>;
|
|
109
|
+
readVerifiedMessageBinding(input: {
|
|
110
|
+
conversationId: string;
|
|
111
|
+
messageId: string;
|
|
112
|
+
}): Promise<MlsDevVerifiedMessageBinding | undefined>;
|
|
113
|
+
readCurrentAudience(conversationId: string): Promise<MlsDevCurrentAudience>;
|
|
114
|
+
/** D2 (mls-rooms-by-default.md §2.7): in a room Canon made, the current members with no device in this device's group;
|
|
115
|
+
* while there are any, the room sends nothing. Local state only, as of the last refresh. */
|
|
116
|
+
readAdmissionHold(conversationId: string): Promise<MlsDevAdmissionHold>;
|
|
117
|
+
assertCurrentAudience(expected: MlsDevCurrentAudience): Promise<void>;
|
|
118
|
+
readRecoveryFailure(conversationId: string): Promise<MlsDevGroupRecoveryFailure | undefined>;
|
|
119
|
+
/** Encrypts, journals and queues one card operation from this device; never inbox input for anyone. */
|
|
120
|
+
sendInteraction(input: MlsDevInteractionInput): Promise<EndpointOperation>;
|
|
121
|
+
/** The local reduction of one request, with its derived state (the local deadline is authoritative). */
|
|
122
|
+
readInteraction(input: {
|
|
123
|
+
conversationId: string;
|
|
124
|
+
agentId: string;
|
|
125
|
+
requestId: string;
|
|
126
|
+
}): Promise<MlsDevInteractionView | undefined>;
|
|
127
|
+
/** The requester opens its answered secret once, in memory; the one-time key is deleted in the same commit. */
|
|
128
|
+
openSecretAnswer(input: {
|
|
129
|
+
conversationId: string;
|
|
130
|
+
requestId: string;
|
|
131
|
+
}): Promise<string>;
|
|
132
|
+
}
|
|
133
|
+
export interface MlsDevGroupBridge {
|
|
134
|
+
hash(value: string): Promise<string>;
|
|
135
|
+
hashBytes?(value: Uint8Array): Promise<string>;
|
|
136
|
+
resolveProtocol?(conversationId: string): Promise<MlsDevTextProtocol | undefined>;
|
|
137
|
+
queryFeed?(request: MlsDevGroupFeedQuery): Promise<MlsDevGroupFeedResult>;
|
|
138
|
+
query(request: MlsDevGroupQuery): Promise<MlsDevGroupQueryResult>;
|
|
139
|
+
queue(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<EndpointOperation>;
|
|
140
|
+
settle(tx: EndpointStoreTransaction, operation: EndpointOperation, receipt: EndpointOperationReceipt, acceptedEcho: boolean): Promise<EndpointOperation>;
|
|
141
|
+
afterReceipt(operation: EndpointOperation): Promise<void>;
|
|
142
|
+
submitted(operation: EndpointOperation): void;
|
|
143
|
+
lookup(operationId: string, installationId: string): Promise<EndpointOperationReceipt | null>;
|
|
144
|
+
/** Renews this device's credential when due, before an operation captures it. Best effort: the operation's own
|
|
145
|
+
* credential checks still decide. */
|
|
146
|
+
ensureDevice?(): Promise<unknown>;
|
|
147
|
+
/** A Welcome used up one of this device's KeyPackages; called after its commit. */
|
|
148
|
+
keyPackageConsumed?(): void;
|
|
149
|
+
/** A control of this device's settled, accepted or lost to another device's: what waited on it can go on now. A hint
|
|
150
|
+
* announcing the room's change may have come while it was pending, and none may follow (D2 holds the room's sends). */
|
|
151
|
+
controlSettled?(conversationId: string): void;
|
|
152
|
+
/** Reads and applies the room's conversation snapshot from Canon, for openings of members admitted since. */
|
|
153
|
+
readRoom?(conversationId: string): Promise<unknown>;
|
|
154
|
+
}
|
|
155
|
+
/** Internal attachment: the engine supplies its existing queue, receipt reducer,
|
|
156
|
+
* event/recovery intake, store and lifetime. Native work never runs inside tx. */
|
|
157
|
+
export declare function createMlsDevGroups(options: MlsDevDeviceClientOptions, context: MlsDevDeviceClientContext, keyPackages: MlsDevKeyPackageClient | undefined, bridge: MlsDevGroupBridge): {
|
|
158
|
+
client: MlsDevGroupClient;
|
|
159
|
+
commitHeldRemoval(conversationId: string): Promise<EndpointOperation | undefined>;
|
|
160
|
+
/** Forwards an encrypted text by re-encryption: this device's own decrypted copy, sent as new text to another
|
|
161
|
+
* encrypted room (mls-payload-v3.md §4). Items and cards are not forwarded yet. */
|
|
162
|
+
forwardText(value: unknown, operationId: string, guardId?: string): Promise<EndpointOperation>;
|
|
163
|
+
sendText(value: unknown, operationId: string, guardId?: string): Promise<EndpointOperation>;
|
|
164
|
+
queryTextHistory(conversationId: string, name: string, parameters: Record<string, unknown>): Promise<{
|
|
165
|
+
messages: Record<string, unknown>[];
|
|
166
|
+
nextBefore?: string | null;
|
|
167
|
+
missingMessageIds?: string[];
|
|
168
|
+
}>;
|
|
169
|
+
syncText(conversationId: string, options?: EndpointSyncOptions): Promise<EndpointSyncPage>;
|
|
170
|
+
isTextReady(conversationId: string): Promise<boolean>;
|
|
171
|
+
readAcceptedReceipt(operation: EndpointOperation): Promise<EndpointOperationReceipt | undefined>;
|
|
172
|
+
settleReceipt(operation: EndpointOperation, receipt: EndpointOperationReceipt): Promise<boolean>;
|
|
173
|
+
};
|
|
174
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { MlsDevGroupHead, MlsDevInteractionAnswer, MlsDevInteractionKind, MlsDevInteractionRequestBody, MlsDevInteractionWithdrawReason } from '../backend-contracts/index.js';
|
|
2
|
+
import type { MlsDevLocalTextMessage } from './mls-dev-text.js';
|
|
3
|
+
/**
|
|
4
|
+
* The local reduction of encrypted approvals and questions in a v2 room (docs/design/encrypted-interactions.md §2.3,
|
|
5
|
+
* §5): one record per (agent, request), built only from MLS-verified feed entries in feed order. Responses and
|
|
6
|
+
* withdrawals update it; only the request is a history bubble. Never include these records in an HTTP request.
|
|
7
|
+
*/
|
|
8
|
+
export interface MlsDevLocalInteraction {
|
|
9
|
+
readonly version: 1;
|
|
10
|
+
readonly conversationId: string;
|
|
11
|
+
readonly agentId: string;
|
|
12
|
+
readonly requestId: string;
|
|
13
|
+
readonly requesterDeviceId: string;
|
|
14
|
+
/** Includes a secret request's one-time public key; never an answer's plaintext. */
|
|
15
|
+
readonly request: MlsDevInteractionRequestBody;
|
|
16
|
+
readonly requestMessageId: string;
|
|
17
|
+
readonly requestOrdinal: number;
|
|
18
|
+
/** The audience the request was sent to: the group head and membership revision it was encrypted under. */
|
|
19
|
+
readonly head: MlsDevGroupHead;
|
|
20
|
+
readonly membershipRevision: number;
|
|
21
|
+
readonly acceptedAtMs: number;
|
|
22
|
+
readonly status: 'pending' | 'answered' | 'withdrawn';
|
|
23
|
+
readonly response?: {
|
|
24
|
+
readonly responderId: string;
|
|
25
|
+
readonly responderDeviceId: string;
|
|
26
|
+
readonly messageId: string;
|
|
27
|
+
readonly ordinal: number;
|
|
28
|
+
/** A secret answer stays sealed here; only `openSecretAnswer` opens it, once, in memory. */
|
|
29
|
+
readonly answer: MlsDevInteractionAnswer;
|
|
30
|
+
/** This device's clock when the verified answer was applied: the local deadline is authoritative (§6). */
|
|
31
|
+
readonly appliedAtMs: number;
|
|
32
|
+
};
|
|
33
|
+
readonly withdrawal?: {
|
|
34
|
+
readonly reason: MlsDevInteractionWithdrawReason;
|
|
35
|
+
readonly messageId: string;
|
|
36
|
+
readonly ordinal: number;
|
|
37
|
+
};
|
|
38
|
+
/** Set when the requester opened a sealed answer; its key is gone. */
|
|
39
|
+
readonly opened?: true;
|
|
40
|
+
}
|
|
41
|
+
/** `voided`: the room's audience changed after the request (§4); `expired`: the local deadline passed first. */
|
|
42
|
+
export type MlsDevInteractionState = 'pending' | 'answered' | 'withdrawn' | 'expired' | 'voided';
|
|
43
|
+
export interface MlsDevInteractionView {
|
|
44
|
+
readonly conversationId: string;
|
|
45
|
+
readonly agentId: string;
|
|
46
|
+
readonly requestId: string;
|
|
47
|
+
readonly kind: MlsDevInteractionKind;
|
|
48
|
+
readonly state: MlsDevInteractionState;
|
|
49
|
+
readonly requestMessageId: string;
|
|
50
|
+
readonly responderIds: readonly [string];
|
|
51
|
+
readonly expiresAtMs: number;
|
|
52
|
+
readonly answer?: MlsDevInteractionAnswer;
|
|
53
|
+
readonly respondedBy?: string;
|
|
54
|
+
readonly withdrawReason?: MlsDevInteractionWithdrawReason;
|
|
55
|
+
readonly opened?: true;
|
|
56
|
+
/** Still pending, with this device's own answer committed and on its way (never set by `viewMlsDevInteraction`). */
|
|
57
|
+
readonly sending?: true;
|
|
58
|
+
}
|
|
59
|
+
export declare const mlsDevInteractionKey: (conversationId: string, agentId: string, requestId: string) => string;
|
|
60
|
+
export declare const mlsDevInteractionIntegrityKey: (conversationId: string, ordinal: number) => string;
|
|
61
|
+
export declare function viewMlsDevInteraction(value: MlsDevLocalInteraction, now: number, audience: {
|
|
62
|
+
readonly head: MlsDevGroupHead | null;
|
|
63
|
+
readonly membershipRevision: number;
|
|
64
|
+
} | undefined): MlsDevInteractionView;
|
|
65
|
+
/** A view for an account-facing caller: its agent, responders and answerer as accounts (mls-dev-groups.md, erasure privacy). */
|
|
66
|
+
export declare function accountMlsDevInteractionView(view: MlsDevInteractionView, account: (principal: {
|
|
67
|
+
type: string;
|
|
68
|
+
id: string;
|
|
69
|
+
}) => string): MlsDevInteractionView;
|
|
70
|
+
/**
|
|
71
|
+
* The card's outcome as clients render it (§5), shared by the history projection and `get_runtime_card_state`: an
|
|
72
|
+
* approval's decision, a question's or secret's answer (`submitted`; never its content) or the responder's Cancel/Skip,
|
|
73
|
+
* the local deadline, and `withdrawn` for a withdrawal or a card voided by an audience change (§4); `sending` while this
|
|
74
|
+
* device's own answer is committed and on its way (only its responder's device sees it).
|
|
75
|
+
*/
|
|
76
|
+
export type MlsDevInteractionCardStatus = 'pending' | 'sending' | 'allow' | 'deny' | 'submitted' | 'cancelled' | 'expired' | 'withdrawn';
|
|
77
|
+
export declare function mlsDevInteractionCardStatus(view: Pick<MlsDevInteractionView, 'state' | 'answer' | 'sending'>): MlsDevInteractionCardStatus;
|
|
78
|
+
/**
|
|
79
|
+
* Maps the answer a card sends as `respond_interaction` (the shapes `ApprovalCard` and `RuntimeInputCard` already send)
|
|
80
|
+
* onto this request's encrypted answer (§5): an approval's Allow once, Allow for this session (only when the request
|
|
81
|
+
* offered it) or Deny; a question's option ids, several only when it allows several, or its free text; a secret's
|
|
82
|
+
* plaintext, which only native custody seals; and Cancel/Skip as `{ cancelled: true }`. Anything else (a plaintext
|
|
83
|
+
* session rule, a plan or rich-card answer, a kind that does not match the request) is refused before encryption.
|
|
84
|
+
*/
|
|
85
|
+
export declare function mlsDevInteractionResponse(request: MlsDevInteractionRequestBody, body: Readonly<Record<string, unknown>>): {
|
|
86
|
+
readonly answer: MlsDevInteractionAnswer;
|
|
87
|
+
} | {
|
|
88
|
+
readonly secret: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Projects a decrypted request into the plaintext interaction shape (`contentType: 'interaction'`, the `interaction`
|
|
92
|
+
* envelope and `metadata.type`), so `classifyChatMessage`, `buildBubbleModel`, `ApprovalCard` and `RuntimeInputCard`
|
|
93
|
+
* render it unchanged; `mlsInteraction` carries the local reduction (state, the card status, a non-secret answer, who
|
|
94
|
+
* answered).
|
|
95
|
+
*/
|
|
96
|
+
export declare function projectMlsDevInteractionMessage(local: MlsDevLocalTextMessage, view: MlsDevInteractionView | undefined, account: (principal: {
|
|
97
|
+
type: string;
|
|
98
|
+
id: string;
|
|
99
|
+
}) => string): Record<string, unknown>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type MlsDevDeviceBinding, type MlsDevKeyPackagePayload, type MlsDevKeyPackagePublicationReceipt, type MlsDevKeyPackageClaimReceipt, type MlsDevKeyPackageClaimPreconditions } from '../backend-contracts/index.js';
|
|
2
|
+
import type { createMlsDevDeviceCoordinator, MlsDevKeyPackagePrerequisite } from './mls-dev-device.js';
|
|
3
|
+
import type { MlsDevDeviceClientContext, MlsDevDeviceClientOptions } from './mls-dev-client.js';
|
|
4
|
+
import { type EndpointStore, type EndpointStoreTransaction } from './store.js';
|
|
5
|
+
/** Historical authenticated receipt; neither view grants current room authority. */
|
|
6
|
+
export interface MlsDevKeyPackagePublicationView {
|
|
7
|
+
readonly status: 'published';
|
|
8
|
+
readonly receipt: MlsDevKeyPackagePublicationReceipt;
|
|
9
|
+
}
|
|
10
|
+
export interface MlsDevKeyPackageClaimView {
|
|
11
|
+
readonly status: 'claimed';
|
|
12
|
+
readonly receipt: MlsDevKeyPackageClaimReceipt;
|
|
13
|
+
}
|
|
14
|
+
export interface MlsDevKeyPackageClaimInput {
|
|
15
|
+
readonly requestId: string;
|
|
16
|
+
readonly recipientDeviceId: string;
|
|
17
|
+
readonly preconditions: MlsDevKeyPackageClaimPreconditions;
|
|
18
|
+
}
|
|
19
|
+
/** A claim in this device's journal; `claimedAtMs` is null while Canon's answer is not known. */
|
|
20
|
+
export interface MlsDevKeyPackageRoomClaim {
|
|
21
|
+
readonly requestId: string;
|
|
22
|
+
readonly recipientDeviceId: string;
|
|
23
|
+
readonly preconditions: MlsDevKeyPackageClaimPreconditions;
|
|
24
|
+
readonly claimedAtMs: number | null;
|
|
25
|
+
}
|
|
26
|
+
export interface MlsDevKeyPackageServiceClient {
|
|
27
|
+
/** Revalidates online, including when a historical receipt exists. */
|
|
28
|
+
publish(input: {
|
|
29
|
+
keyPackageId: string;
|
|
30
|
+
}): Promise<MlsDevKeyPackagePublicationView>;
|
|
31
|
+
claim(input: MlsDevKeyPackageClaimInput): Promise<MlsDevKeyPackageClaimView>;
|
|
32
|
+
readPublication(keyPackageId: string): Promise<MlsDevKeyPackagePublicationView | undefined>;
|
|
33
|
+
readClaim(requestId: string): Promise<MlsDevKeyPackageClaimView | undefined>;
|
|
34
|
+
/** This device's journaled claims in the conversation. Through a claim's lease Canon holds its recipient's slot for it
|
|
35
|
+
* and lists the device to no one, so a claim whose Add did not go is resumed from here, not claimed afresh. */
|
|
36
|
+
readRoomClaims(conversationId: string): Promise<readonly MlsDevKeyPackageRoomClaim[]>;
|
|
37
|
+
/** Forgets answered claims made before `beforeMs`. A claim matters only until its Add is accepted or its slot's lease
|
|
38
|
+
* ends, so the journal's 32 rows hold only recent claims. Returns how many it removed. */
|
|
39
|
+
pruneClaims(beforeMs: number): Promise<number>;
|
|
40
|
+
}
|
|
41
|
+
/** Uses the same device lifetime/store. Explicit calls only; no second drain loop.
|
|
42
|
+
* Publication reads public committed TLS; no provider ciphertext enters a request. */
|
|
43
|
+
export declare function createMlsDevKeyPackageService(options: MlsDevDeviceClientOptions, context: MlsDevDeviceClientContext, store: EndpointStore, initialized: () => Promise<{
|
|
44
|
+
binding: MlsDevDeviceBinding;
|
|
45
|
+
device: ReturnType<typeof createMlsDevDeviceCoordinator>;
|
|
46
|
+
}>, readPrepared: (tx: EndpointStoreTransaction, binding: MlsDevDeviceBinding, id: string, current: MlsDevKeyPackagePrerequisite, historical?: boolean) => Promise<MlsDevKeyPackagePayload | undefined>): MlsDevKeyPackageServiceClient;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type MlsDevDeviceBinding, type MlsDevDeviceContext, type MlsDevKeyPackageCommand, type MlsDevKeyPackagePayload, type MlsDevKeyPackagePreparation } from '../backend-contracts/index.js';
|
|
2
|
+
import { type MlsDevKeyPackagePrerequisite } from './mls-dev-device.js';
|
|
3
|
+
import { type MlsDevDeviceClientContext, type MlsDevDeviceClientOptions } from './mls-dev-client.js';
|
|
4
|
+
import { type MlsDevKeyPackageServiceClient } from './mls-dev-key-package-service.js';
|
|
5
|
+
export type { MlsDevKeyPackagePublicationView, MlsDevKeyPackageClaimView, MlsDevKeyPackageClaimInput } from './mls-dev-key-package-service.js';
|
|
6
|
+
import { type EndpointStoreTransaction } from './store.js';
|
|
7
|
+
export type MlsDevProtectedKeyPackagePreparer = (context: MlsDevDeviceContext, command: MlsDevKeyPackageCommand, wrappedIdentityState: string) => Promise<MlsDevKeyPackagePreparation>;
|
|
8
|
+
/** A committed local preparation, never a current publication authorization. */
|
|
9
|
+
export interface MlsDevKeyPackageView {
|
|
10
|
+
readonly status: 'prepared';
|
|
11
|
+
readonly payload: MlsDevKeyPackagePayload;
|
|
12
|
+
}
|
|
13
|
+
export interface MlsDevKeyPackagePoolView {
|
|
14
|
+
/** Published, unconsumed packages in the first half of their lifetime. */
|
|
15
|
+
readonly fresh: number;
|
|
16
|
+
/** Published by this call. */
|
|
17
|
+
readonly published: number;
|
|
18
|
+
/** Consumed or expired packages whose local records this call removed. */
|
|
19
|
+
readonly retired: number;
|
|
20
|
+
}
|
|
21
|
+
export interface MlsDevKeyPackageClient extends MlsDevKeyPackageServiceClient {
|
|
22
|
+
prepare(input: {
|
|
23
|
+
keyPackageId: string;
|
|
24
|
+
}): Promise<MlsDevKeyPackageView>;
|
|
25
|
+
/** Returns exact committed bytes, including after credential expiry/renewal.
|
|
26
|
+
* Requires a committed registration/credential and no local revocation. */
|
|
27
|
+
read(keyPackageId: string): Promise<MlsDevKeyPackageView | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Keeps this device admissible without anyone typing its ID: at least `MLS_DEV_KEY_PACKAGE_POOL_SIZE` published,
|
|
30
|
+
* room-independent packages in the first half of their lifetime, so any room can claim one (the server picks the
|
|
31
|
+
* oldest available). It retires the pool's consumed packages and, a lifetime after expiry, its expired ones with
|
|
32
|
+
* their private state, so the local caps of 32 never fill. Needs a ready device (`mlsDevDevice.ensureReady()`).
|
|
33
|
+
* Calls share one run. Packages prepared by `prepare` outside the pool are left alone.
|
|
34
|
+
*/
|
|
35
|
+
maintainPool(): Promise<MlsDevKeyPackagePoolView>;
|
|
36
|
+
}
|
|
37
|
+
export declare const MLS_DEV_KEY_PACKAGE_POOL_SIZE = 4;
|
|
38
|
+
export declare const MLS_DEV_KEY_PACKAGE_RETENTION_MS: number;
|
|
39
|
+
/** Every private package this device may hold: the live inventory and the retained ones. */
|
|
40
|
+
export declare const MLS_DEV_KEY_PACKAGE_STORE_MAX: number;
|
|
41
|
+
/** Consumed identities survive active-inventory removal until logout resets the
|
|
42
|
+
* installation. A regenerated RefHash must never resurrect a used private key. */
|
|
43
|
+
export declare function assertMlsDevKeyPackageUnconsumed(tx: EndpointStoreTransaction, id: string, ref?: string): Promise<void>;
|
|
44
|
+
export interface MlsDevPreparedKeyPackageSnapshot {
|
|
45
|
+
readonly binding: MlsDevDeviceBinding;
|
|
46
|
+
readonly command: MlsDevKeyPackageCommand;
|
|
47
|
+
readonly payload: MlsDevKeyPackagePayload;
|
|
48
|
+
readonly wrappedState: string;
|
|
49
|
+
readonly fingerprint: string;
|
|
50
|
+
}
|
|
51
|
+
/** Internal private-provider capture for Welcome, never exported on Endpoint. */
|
|
52
|
+
export declare function captureMlsDevPreparedKeyPackage(tx: EndpointStoreTransaction, binding: MlsDevDeviceBinding, id: string, current: MlsDevKeyPackagePrerequisite): Promise<MlsDevPreparedKeyPackageSnapshot | undefined>;
|
|
53
|
+
/** The caller has already verified the accepted Welcome and group snapshot.
|
|
54
|
+
* Consumption shares that transaction; failure rolls back private state erasure. */
|
|
55
|
+
export declare function consumeMlsDevPreparedKeyPackage(tx: EndpointStoreTransaction, captured: MlsDevPreparedKeyPackageSnapshot, current: MlsDevKeyPackagePrerequisite, control: {
|
|
56
|
+
conversationId: string;
|
|
57
|
+
groupId: string;
|
|
58
|
+
controlSequence: number;
|
|
59
|
+
}): Promise<void>;
|
|
60
|
+
/** Internal endpoint attachment. Uses the device's existing store/lifetime and has
|
|
61
|
+
* no timer or signer generation; only `maintainPool` replenishes, when called. */
|
|
62
|
+
export declare function createMlsDevKeyPackageClient(options: MlsDevDeviceClientOptions, context: MlsDevDeviceClientContext): MlsDevKeyPackageClient;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { MLS_DEV_TEXT_PROTOCOL, type MlsDevApplicationPayload } from '../backend-contracts/index.js';
|
|
2
|
+
import type { EndpointOperation } from './engine.js';
|
|
3
|
+
import type { EndpointStoreTransaction } from './store.js';
|
|
4
|
+
/** Local authorized plaintext cache, independent of MLS epoch keys and the
|
|
5
|
+
* business-inbox lifetime. Never include these records in an HTTP request. */
|
|
6
|
+
export interface MlsDevLocalTextMessage {
|
|
7
|
+
version: 1;
|
|
8
|
+
/** Text, or in a v2 room an encrypted card payload (a secret answer only in its sealed form). */
|
|
9
|
+
message: MlsDevApplicationPayload;
|
|
10
|
+
senderId: string;
|
|
11
|
+
senderType: 'human' | 'ai_agent';
|
|
12
|
+
status: 'queued' | 'sent' | 'rejected' | 'uncertain';
|
|
13
|
+
createdAtMs: number;
|
|
14
|
+
feedOrdinal: number | null;
|
|
15
|
+
/** Its sender deleted it for everyone: the decrypted text is erased, and the row stays only to keep feed order. */
|
|
16
|
+
deleted?: true;
|
|
17
|
+
}
|
|
18
|
+
export declare const mlsDevTextProtocolKey: (conversationId: string) => string;
|
|
19
|
+
export { MLS_DEV_TEXT_PROTOCOL };
|
|
20
|
+
export declare const mlsDevTextMessageKey: (conversationId: string, messageId: string) => string;
|
|
21
|
+
/** This device's own latest answer to a card: a pointer to its authored (never secret) copy. */
|
|
22
|
+
export declare const mlsDevOwnAnswerKey: (conversationId: string, agentId: string, requestId: string) => string;
|
|
23
|
+
/** Whether this device's answer to a card is committed and still on its way: queued, or its outcome uncertain, and not
|
|
24
|
+
* yet applied from the feed (where the reduction takes over) nor refused. The card waits for it rather than answer twice. */
|
|
25
|
+
export declare function isMlsDevOwnAnswerSending(tx: EndpointStoreTransaction, conversationId: string, agentId: string, requestId: string): Promise<boolean>;
|
|
26
|
+
/** A deletion for everyone that reached this device, before or after the message itself (mls-payload-v3.md §4). */
|
|
27
|
+
export declare const mlsDevTextDeletedKey: (conversationId: string, messageId: string) => string;
|
|
28
|
+
/** The reactions Canon holds for a message's public stub, which the history shows beside its decrypted text. */
|
|
29
|
+
export declare const mlsDevTextReactionsKey: (conversationId: string, messageId: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Its sender deleted a message for everyone. The decrypted text is erased now, and the tombstone keeps it erased if the
|
|
32
|
+
* feed brings the message again, on catch-up or replay. An own send whose echo is not applied yet keeps its text until
|
|
33
|
+
* the echo applies (the echo is checked against it); the history already shows it deleted. Cards are not deleted this
|
|
34
|
+
* way: Canon refuses to delete an encrypted card, which is withdrawn instead. Returns whether anything changed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function deleteMlsDevTextMessage(tx: EndpointStoreTransaction, conversationId: string, messageId: string): Promise<boolean>;
|
|
37
|
+
/** The stub's reactions, as Canon reports them; an empty set clears them. Returns whether they changed. */
|
|
38
|
+
export declare function setMlsDevTextReactions(tx: EndpointStoreTransaction, conversationId: string, messageId: string, reactions: Readonly<Record<string, readonly string[]>> | undefined): Promise<boolean>;
|
|
39
|
+
export declare function putMlsDevTextMessage(tx: EndpointStoreTransaction, value: MlsDevLocalTextMessage): Promise<void>;
|
|
40
|
+
/** What a v3 reply quotes from this device's copy of the message it answers, trimmed to the payload's bound: a text, or
|
|
41
|
+
* an item's caption or else what it is. Nothing for a card, a message deleted for everyone, or one not held here. */
|
|
42
|
+
export declare function mlsDevReplyQuote(value: MlsDevLocalTextMessage | undefined, maximum: number): string | undefined;
|
|
43
|
+
/** `account` opens the stored sender alias to its account (mls-dev-groups.md, erasure privacy). */
|
|
44
|
+
export declare function projectMlsDevTextMessage(value: MlsDevLocalTextMessage, account: MlsDevAccountResolver): Record<string, unknown>;
|
|
45
|
+
/** Opens a stored principal (an alias, with the type its credential gave) to its account. */
|
|
46
|
+
export type MlsDevAccountResolver = (principal: {
|
|
47
|
+
type: string;
|
|
48
|
+
id: string;
|
|
49
|
+
}) => string;
|
|
50
|
+
export interface MlsDevHistoryAudience {
|
|
51
|
+
readonly now: number;
|
|
52
|
+
/** Opens a stored alias to its account, or to the erased sender (mls-dev-groups.md, erasure privacy). */
|
|
53
|
+
readonly account: MlsDevAccountResolver;
|
|
54
|
+
readonly current: {
|
|
55
|
+
readonly head: import('../backend-contracts/index.js').MlsDevGroupHead | null;
|
|
56
|
+
readonly membershipRevision: number;
|
|
57
|
+
} | undefined;
|
|
58
|
+
}
|
|
59
|
+
/** Existing UI history queries read only this endpoint's accepted plaintext
|
|
60
|
+
* reduction. Feed recovery, authorization and lifecycle fencing are caller-owned. */
|
|
61
|
+
export declare function queryMlsDevTextHistory(tx: EndpointStoreTransaction, conversationId: string, name: string, parameters: Record<string, unknown>, audience?: MlsDevHistoryAudience): Promise<{
|
|
62
|
+
messages: Record<string, unknown>[];
|
|
63
|
+
nextBefore?: string | null;
|
|
64
|
+
missingMessageIds?: string[];
|
|
65
|
+
}>;
|
|
66
|
+
/** Rendering-only transition; an unsuccessful send never rewinds MLS state. */
|
|
67
|
+
export declare function settleMlsDevTextOperation(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<void>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type MlsDevKeyPackagePublishRequest, type MlsDevKeyPackagePublicationReceipt, type MlsDevKeyPackageClaimRequest, type MlsDevKeyPackageClaimReceipt, type MlsDevEnrollmentBeginRequest, type MlsDevEnrollmentCompleteRequest, type MlsDevEnrollmentChallenge, type MlsDevEnrollmentResult, type MlsDevCredentialBeginRequest, type MlsDevCredentialCompleteRequest, type MlsDevCredentialChallenge, type MlsDevCredentialReceipt, type MlsDevCredentialRevokeRequest, type MlsDevCredentialRevocationReceipt, type MlsDevCredentialReconciliationBeginRequest, type MlsDevCredentialReconciliationCompleteRequest, type MlsDevCredentialReconciliationChallenge, type MlsDevCredentialReconciliationReceipt } from '../backend-contracts/index.js';
|
|
2
|
+
import { type EndpointCredentials } from './transport.js';
|
|
3
|
+
export interface MlsDevKeyPackageTransport {
|
|
4
|
+
publish(request: MlsDevKeyPackagePublishRequest, signal?: AbortSignal): Promise<MlsDevKeyPackagePublicationReceipt>;
|
|
5
|
+
claim(request: MlsDevKeyPackageClaimRequest, signal?: AbortSignal): Promise<MlsDevKeyPackageClaimReceipt>;
|
|
6
|
+
}
|
|
7
|
+
/** Authenticated Dev registration/issuance only; no room or history authority. */
|
|
8
|
+
export interface MlsDevDeviceTransport {
|
|
9
|
+
readonly keyPackages?: MlsDevKeyPackageTransport;
|
|
10
|
+
beginEnrollment(request: MlsDevEnrollmentBeginRequest, signal?: AbortSignal): Promise<MlsDevEnrollmentChallenge>;
|
|
11
|
+
completeEnrollment(request: MlsDevEnrollmentCompleteRequest, signal?: AbortSignal): Promise<MlsDevEnrollmentResult>;
|
|
12
|
+
beginCredential(request: MlsDevCredentialBeginRequest, signal?: AbortSignal): Promise<MlsDevCredentialChallenge>;
|
|
13
|
+
completeCredential(request: MlsDevCredentialCompleteRequest, signal?: AbortSignal): Promise<MlsDevCredentialReceipt>;
|
|
14
|
+
beginReconciliation(request: MlsDevCredentialReconciliationBeginRequest, signal?: AbortSignal): Promise<MlsDevCredentialReconciliationChallenge>;
|
|
15
|
+
completeReconciliation(request: MlsDevCredentialReconciliationCompleteRequest, signal?: AbortSignal): Promise<MlsDevCredentialReconciliationReceipt>;
|
|
16
|
+
revokeCredential(request: MlsDevCredentialRevokeRequest, signal?: AbortSignal): Promise<MlsDevCredentialRevocationReceipt>;
|
|
17
|
+
verifyGenerationObservation(receipt: MlsDevCredentialReconciliationReceipt): boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface MlsDevDeviceHttpOptions {
|
|
20
|
+
enrollmentUrl: string;
|
|
21
|
+
credentialUrl: string;
|
|
22
|
+
reconciliationUrl: string;
|
|
23
|
+
keyPackagesUrl?: string;
|
|
24
|
+
/** Explicit origins trusted to receive the endpoint's login/API-key bearer. */
|
|
25
|
+
trustedOrigins: readonly string[];
|
|
26
|
+
/** Synthetic tests only: literal 127.0.0.1 or [::1], never DNS/remote HTTP. */
|
|
27
|
+
allowSyntheticLoopbackHttp?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Internal constructor. The ordinary endpoint and Dev capability share credentials,
|
|
30
|
+
* fetch and ownership settings; the Dev deadline also covers auth and body reads.
|
|
31
|
+
* Only a declared MLS environment, and only responses that name that environment. */
|
|
32
|
+
export declare function createMlsDevDeviceHttpTransport(config: MlsDevDeviceHttpOptions, dependencies: {
|
|
33
|
+
environmentId: string;
|
|
34
|
+
credentials: EndpointCredentials;
|
|
35
|
+
fetch: typeof globalThis.fetch;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
ownershipHeaders(): Record<string, string>;
|
|
38
|
+
}): MlsDevDeviceTransport;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MlsDevProtectedPreparer } from './mls-dev-device.js';
|
|
2
|
+
import type { MlsDevProtectedKeyPackagePreparer } from './mls-dev-key-packages.js';
|
|
3
|
+
import type { MlsDevProtectedGroupPreparer } from './mls-dev-groups.js';
|
|
4
|
+
export interface NodeMlsDevCustody {
|
|
5
|
+
readonly prepareProtected: MlsDevProtectedPreparer;
|
|
6
|
+
readonly prepareProtectedKeyPackage: MlsDevProtectedKeyPackagePreparer;
|
|
7
|
+
readonly prepareProtectedGroup: MlsDevProtectedGroupPreparer;
|
|
8
|
+
/** Cancels owned processes; never destroys custody or committed wrapped state. */
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare class NodeMlsDevCustodyError extends Error {
|
|
12
|
+
readonly code = "MLS_NODE_CUSTODY_REJECTED";
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export declare const MAX_INPUT: number, MAX_OUTPUT: number;
|
|
16
|
+
export declare function rejected(): never;
|
|
17
|
+
/** A helper's result value. Its one non-result the endpoint sees is native's fixed clock pause (mls-signed-acceptance.md
|
|
18
|
+
* §2.9), which only a group operation (4) can return: a retryable error, never a custody failure. */
|
|
19
|
+
export declare function custodyValue(output: Buffer, operation: number): unknown;
|
|
20
|
+
/** A job's failure: the clock pause passes through, everything else is the fixed custody rejection. */
|
|
21
|
+
export declare function custodyFailure(error: unknown): never;
|
|
22
|
+
export declare function requireValue(value: unknown): asserts value;
|
|
23
|
+
export declare function record(value: unknown, fields: string[]): Record<string, unknown>;
|
|
24
|
+
export declare function sealed(value: unknown, maximum: number, nullable?: boolean): string | null;
|
|
25
|
+
export declare function frame(operation: number, values: readonly (string | null)[]): Buffer;
|
|
26
|
+
/** JSON.parse supplies grammar validation; this pass rejects duplicate object
|
|
27
|
+
* names (including escaped aliases) before the closed contract parsers run. */
|
|
28
|
+
export declare function parseJson(bytes: Buffer): unknown;
|
|
29
|
+
export declare function typedNodeMlsDevCustody(job: <T>(work: (signal: AbortSignal) => Promise<T>) => Promise<T>, invoke: (operation: number, values: readonly (string | null)[], signal: AbortSignal) => Promise<unknown>, close: () => Promise<void>): NodeMlsDevCustody;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type NodeMlsDevCustody } from './node-mls-custody-protocol.js';
|
|
2
|
+
export interface NodeMlsDevCustodyOptions {
|
|
3
|
+
/** Canonical absolute path to the installed, signed .app (no symlink components). */
|
|
4
|
+
readonly bundlePath: string;
|
|
5
|
+
/** SHA-256 of the adjacent <bundlePath>.manifest.json; provision independently. */
|
|
6
|
+
readonly manifestSha256: string;
|
|
7
|
+
readonly executableSha256: string;
|
|
8
|
+
readonly bundleIdentifier: string;
|
|
9
|
+
readonly teamIdentifier: string;
|
|
10
|
+
/** Whole preparation, including signature checks and initialization. Default 30s. */
|
|
11
|
+
readonly timeoutMs?: number;
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
export { NodeMlsDevCustodyError, type NodeMlsDevCustody } from './node-mls-custody-protocol.js';
|
|
15
|
+
export declare function createNodeMlsDevCustody(options: NodeMlsDevCustodyOptions): NodeMlsDevCustody;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EndpointStore } from './store.js';
|
|
2
|
+
export declare function createNodeEndpointStore(options: {
|
|
3
|
+
directory: string;
|
|
4
|
+
namespace: string;
|
|
5
|
+
}): Promise<EndpointStore>;
|
|
6
|
+
export { createNodeMlsDevCustody, NodeMlsDevCustodyError, type NodeMlsDevCustody, type NodeMlsDevCustodyOptions } from './node-mls-custody.js';
|
|
7
|
+
export { createPortableNodeMlsDevCustody, type PortableNodeMlsDevCustody, type PortableNodeMlsDevCustodyOptions } from './portable-node-mls-custody.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface EndpointQueryObserver {
|
|
2
|
+
observe<T>(query: string, parameters: Record<string, unknown>, listener: (value: T) => void, onError?: (error: unknown) => void): () => void;
|
|
3
|
+
invalidate(affected?: (query: string, parameters: Record<string, unknown>) => boolean): void;
|
|
4
|
+
/** Re-arm idle subscriptions when the connection changes their polling cadence. */
|
|
5
|
+
reschedule(): void;
|
|
6
|
+
close(): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One temporary polling subscription per query per endpoint. UI components only
|
|
10
|
+
* subscribe; the endpoint owns fetching, coalescing, retry and lifecycle. A
|
|
11
|
+
* durable change-feed can call invalidate without changing any consumers.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createEndpointQueryObserver(options: {
|
|
14
|
+
query: <T>(query: string, parameters: Record<string, unknown>) => Promise<T>;
|
|
15
|
+
intervalMs?: number;
|
|
16
|
+
getPollInterval?: () => number;
|
|
17
|
+
}): EndpointQueryObserver;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type MlsDevDeviceContext } from '../backend-contracts/index.js';
|
|
2
|
+
import { type NodeMlsDevCustody } from './node-mls-custody-protocol.js';
|
|
3
|
+
export interface PortableNodeMlsDevCustodyOptions {
|
|
4
|
+
readonly executablePath: string;
|
|
5
|
+
readonly executableSha256: string;
|
|
6
|
+
/** Independently provisioned public identity, vault location and issuer pins. */
|
|
7
|
+
readonly configurationPath: string;
|
|
8
|
+
readonly configurationSha256: string;
|
|
9
|
+
/** An operator-managed credential mount, separate from the vault. JS opens but never reads it. */
|
|
10
|
+
readonly secretSource: {
|
|
11
|
+
readonly kind: 'managed-file';
|
|
12
|
+
readonly path: string;
|
|
13
|
+
};
|
|
14
|
+
readonly timeoutMs?: number;
|
|
15
|
+
readonly signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
export interface PortableNodeMlsDevCustody extends NodeMlsDevCustody {
|
|
18
|
+
/** Deliberate first provisioning only. An existing or missing-on-restart vault is never replaced. */
|
|
19
|
+
provision(context: MlsDevDeviceContext): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** Portable software custody. Qualification currently covers Unix descriptor
|
|
22
|
+
* inheritance only; Windows must get its own ACL/handle acceptance before use. */
|
|
23
|
+
export declare function createPortableNodeMlsDevCustody(options: PortableNodeMlsDevCustodyOptions): PortableNodeMlsDevCustody;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EndpointInboundRecord, EndpointIntent, EndpointOperation } from './engine.js';
|
|
2
|
+
import type { EndpointStoreTransaction } from './store.js';
|
|
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';
|
|
5
|
+
/** Derived here, never an adapter override. Unknown/state-changing actions stay ordered. */
|
|
6
|
+
export declare function endpointIntentOrdering(intent: EndpointIntent): EndpointOrdering;
|
|
7
|
+
/** Transaction sequence is ordering metadata, never an idempotency identity. */
|
|
8
|
+
export declare function nextQueueSequence(tx: EndpointStoreTransaction, name: string): Promise<number>;
|
|
9
|
+
export declare function orderOperation(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<EndpointOperation>;
|
|
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
|
+
export declare const operationOrderingKey: (operation: EndpointOperation) => string | undefined;
|
|
14
|
+
export declare function trackOperationOrder(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<void>;
|
|
15
|
+
export declare function enqueueOperation(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<void>;
|
|
16
|
+
export declare function removeOperationOutbox(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<void>;
|
|
17
|
+
export declare function settleOperationOrder(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<void>;
|
|
18
|
+
export declare function isFirstOrderedOperation(tx: EndpointStoreTransaction, operation: EndpointOperation): Promise<boolean>;
|
|
19
|
+
export declare const inboundReadyKey: (record: EndpointInboundRecord) => string;
|
|
20
|
+
export declare function orderInbound(tx: EndpointStoreTransaction, record: EndpointInboundRecord): Promise<EndpointInboundRecord>;
|
|
21
|
+
export declare function enqueueInbound(tx: EndpointStoreTransaction, record: EndpointInboundRecord): Promise<void>;
|
|
22
|
+
export declare function removeInboundReady(tx: EndpointStoreTransaction, record: EndpointInboundRecord): Promise<void>;
|