@canonmsg/agent-sdk 12.0.0 → 12.2.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 +97 -7
- package/dist/chunks/chunk-HITMISWV.js +4897 -0
- package/dist/chunks/{chunk-FPQFTTND.js → chunk-J63YVAKA.js} +1627 -1099
- package/dist/chunks/{chunk-OLJ7H4E2.js → chunk-O5C3ZGI4.js} +6363 -7011
- package/dist/chunks/{mls-crypto-NZDNSPAO.js → mls-crypto-ITVGUEP7.js} +3 -3
- package/dist/cli.js +403 -30
- package/dist/drivers/claude.d.ts +8 -2
- package/dist/drivers/codex.d.ts +11 -2
- package/dist/drivers/connector.d.ts +34 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +26 -4
- package/dist/internal/backend-contracts/artifactActions.d.ts +0 -151
- package/dist/internal/backend-contracts/clientFloor.d.ts +52 -0
- package/dist/internal/backend-contracts/communication.d.ts +15 -0
- package/dist/internal/backend-contracts/connectorRelay.d.ts +179 -0
- package/dist/internal/backend-contracts/endpoint.d.ts +17 -0
- package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +15 -4
- package/dist/internal/backend-contracts/index.d.ts +7 -1
- package/dist/internal/backend-contracts/media-url.d.ts +14 -0
- package/dist/internal/backend-contracts/message.d.ts +1 -1
- package/dist/internal/backend-contracts/mlsDevApplication.d.ts +90 -2
- package/dist/internal/backend-contracts/mlsDevCredential.d.ts +5 -2
- package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +2 -1
- package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +6 -2
- package/dist/internal/backend-contracts/mlsDevFeedReceipt.d.ts +43 -0
- package/dist/internal/backend-contracts/mlsDevGroup.d.ts +129 -5
- package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +6 -2
- package/dist/internal/backend-contracts/mlsDevInteraction.d.ts +159 -0
- package/dist/internal/backend-contracts/mlsEnvironment.d.ts +35 -0
- package/dist/internal/backend-contracts/mlsPrincipalAlias.d.ts +26 -0
- package/dist/internal/backend-contracts/runtimeCardFields.d.ts +0 -4
- package/dist/internal/backend-contracts/upload-mime-types.d.ts +17 -0
- package/dist/internal/backend-contracts/verbContract.d.ts +23 -19
- package/dist/internal/backend-contracts/verbSchemas.d.ts +38 -29
- package/dist/internal/core/agent-profiles.d.ts +0 -4
- package/dist/internal/core/approval-format.d.ts +1 -5
- package/dist/internal/core/approval-types.d.ts +1 -2
- package/dist/internal/core/client.d.ts +3 -152
- package/dist/internal/core/constants.d.ts +0 -3
- package/dist/internal/core/endpoint-client.d.ts +14 -1
- package/dist/internal/core/execution-environment-mode.d.ts +0 -2
- package/dist/internal/core/gifs.d.ts +0 -6
- package/dist/internal/core/host-runtime.d.ts +2 -206
- package/dist/internal/core/index.d.ts +22 -63
- package/dist/internal/core/registration.d.ts +1 -17
- package/dist/internal/core/retry.d.ts +0 -9
- package/dist/internal/core/rtdb-rest.d.ts +0 -4
- package/dist/internal/core/runtime-cards.d.ts +0 -45
- package/dist/internal/core/runtime-descriptor.d.ts +1 -60
- package/dist/internal/core/runtime-presentation.d.ts +1 -27
- package/dist/internal/core/runtime-request-manager.d.ts +0 -1
- package/dist/internal/core/self-context.d.ts +0 -39
- package/dist/internal/core/silent-turn.d.ts +1 -38
- package/dist/internal/core/turn-protocol.d.ts +0 -5
- package/dist/internal/core/turn-verbosity.d.ts +5 -23
- package/dist/internal/core/types.d.ts +0 -292
- package/dist/internal/endpoint/engine.d.ts +31 -1
- package/dist/internal/endpoint/index.d.ts +1 -1
- package/dist/internal/endpoint/media.d.ts +5 -0
- package/dist/internal/endpoint/mls-crypto.d.ts +12 -5
- package/dist/internal/endpoint/mls-dev-client.d.ts +9 -1
- package/dist/internal/endpoint/mls-dev-device.d.ts +2 -0
- package/dist/internal/endpoint/mls-dev-groups.d.ts +65 -5
- package/dist/internal/endpoint/mls-dev-interactions.d.ts +99 -0
- package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +13 -0
- package/dist/internal/endpoint/mls-dev-key-packages.d.ts +23 -3
- package/dist/internal/endpoint/mls-dev-text.d.ts +67 -0
- package/dist/internal/endpoint/mls-dev-transport.d.ts +2 -1
- package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +5 -0
- package/dist/internal/endpoint/transport.d.ts +6 -1
- package/dist/media.js +2 -2
- 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 +61 -0
- package/dist/runner/types.d.ts +51 -4
- package/package.json +1 -1
- package/dist/chunks/chunk-6VK4UZHJ.js +0 -2806
- package/dist/internal/backend-contracts/workSessions.d.ts +0 -205
- package/dist/internal/core/agent-resolver.d.ts +0 -49
- package/dist/internal/core/agent-session.d.ts +0 -12
- package/dist/internal/core/artifacts.d.ts +0 -262
- package/dist/internal/core/attached-native-session.d.ts +0 -174
- package/dist/internal/core/attached-session-file-store.d.ts +0 -3
- package/dist/internal/core/control-poller.d.ts +0 -221
- package/dist/internal/core/exclusive-json-file-store.d.ts +0 -7
- package/dist/internal/core/execution-environment.d.ts +0 -55
- package/dist/internal/core/group-context.d.ts +0 -25
- package/dist/internal/core/inbound-frame.d.ts +0 -64
- package/dist/internal/core/local-runtime-catalog.d.ts +0 -131
- package/dist/internal/core/message-format.d.ts +0 -13
- package/dist/internal/core/native-session-interaction.d.ts +0 -44
- package/dist/internal/core/provenance.d.ts +0 -31
- package/dist/internal/core/registration-cli.d.ts +0 -40
- package/dist/internal/core/stream.d.ts +0 -77
- package/dist/internal/core/turn-output-controller.d.ts +0 -69
- package/dist/internal/core/typing-status-publisher.d.ts +0 -14
- package/dist/internal/core/work-session-provider.d.ts +0 -29
- package/dist/internal/core/workspace-discovery.d.ts +0 -17
|
@@ -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>;
|
|
@@ -16,6 +16,13 @@ export interface MlsDevKeyPackageClaimInput {
|
|
|
16
16
|
readonly recipientDeviceId: string;
|
|
17
17
|
readonly preconditions: MlsDevKeyPackageClaimPreconditions;
|
|
18
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
|
+
}
|
|
19
26
|
export interface MlsDevKeyPackageServiceClient {
|
|
20
27
|
/** Revalidates online, including when a historical receipt exists. */
|
|
21
28
|
publish(input: {
|
|
@@ -24,6 +31,12 @@ export interface MlsDevKeyPackageServiceClient {
|
|
|
24
31
|
claim(input: MlsDevKeyPackageClaimInput): Promise<MlsDevKeyPackageClaimView>;
|
|
25
32
|
readPublication(keyPackageId: string): Promise<MlsDevKeyPackagePublicationView | undefined>;
|
|
26
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>;
|
|
27
40
|
}
|
|
28
41
|
/** Uses the same device lifetime/store. Explicit calls only; no second drain loop.
|
|
29
42
|
* Publication reads public committed TLS; no provider ciphertext enters a request. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MlsDevDeviceBinding, type MlsDevDeviceContext, type MlsDevKeyPackageCommand, type MlsDevKeyPackagePayload, type MlsDevKeyPackagePreparation } from '../backend-contracts/index.js';
|
|
2
2
|
import { type MlsDevKeyPackagePrerequisite } from './mls-dev-device.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type MlsDevDeviceClientContext, type MlsDevDeviceClientOptions } from './mls-dev-client.js';
|
|
4
4
|
import { type MlsDevKeyPackageServiceClient } from './mls-dev-key-package-service.js';
|
|
5
5
|
export type { MlsDevKeyPackagePublicationView, MlsDevKeyPackageClaimView, MlsDevKeyPackageClaimInput } from './mls-dev-key-package-service.js';
|
|
6
6
|
import { type EndpointStoreTransaction } from './store.js';
|
|
@@ -10,6 +10,14 @@ export interface MlsDevKeyPackageView {
|
|
|
10
10
|
readonly status: 'prepared';
|
|
11
11
|
readonly payload: MlsDevKeyPackagePayload;
|
|
12
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
|
+
}
|
|
13
21
|
export interface MlsDevKeyPackageClient extends MlsDevKeyPackageServiceClient {
|
|
14
22
|
prepare(input: {
|
|
15
23
|
keyPackageId: string;
|
|
@@ -17,7 +25,19 @@ export interface MlsDevKeyPackageClient extends MlsDevKeyPackageServiceClient {
|
|
|
17
25
|
/** Returns exact committed bytes, including after credential expiry/renewal.
|
|
18
26
|
* Requires a committed registration/credential and no local revocation. */
|
|
19
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>;
|
|
20
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;
|
|
21
41
|
/** Consumed identities survive active-inventory removal until logout resets the
|
|
22
42
|
* installation. A regenerated RefHash must never resurrect a used private key. */
|
|
23
43
|
export declare function assertMlsDevKeyPackageUnconsumed(tx: EndpointStoreTransaction, id: string, ref?: string): Promise<void>;
|
|
@@ -37,6 +57,6 @@ export declare function consumeMlsDevPreparedKeyPackage(tx: EndpointStoreTransac
|
|
|
37
57
|
groupId: string;
|
|
38
58
|
controlSequence: number;
|
|
39
59
|
}): Promise<void>;
|
|
40
|
-
/** Internal endpoint attachment. Uses the device's existing store/lifetime and
|
|
41
|
-
*
|
|
60
|
+
/** Internal endpoint attachment. Uses the device's existing store/lifetime and has
|
|
61
|
+
* no timer or signer generation; only `maintainPool` replenishes, when called. */
|
|
42
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>;
|
|
@@ -27,7 +27,8 @@ export interface MlsDevDeviceHttpOptions {
|
|
|
27
27
|
allowSyntheticLoopbackHttp?: boolean;
|
|
28
28
|
}
|
|
29
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.
|
|
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. */
|
|
31
32
|
export declare function createMlsDevDeviceHttpTransport(config: MlsDevDeviceHttpOptions, dependencies: {
|
|
32
33
|
environmentId: string;
|
|
33
34
|
credentials: EndpointCredentials;
|
|
@@ -14,6 +14,11 @@ export declare class NodeMlsDevCustodyError extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
export declare const MAX_INPUT: number, MAX_OUTPUT: number;
|
|
16
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;
|
|
17
22
|
export declare function requireValue(value: unknown): asserts value;
|
|
18
23
|
export declare function record(value: unknown, fields: string[]): Record<string, unknown>;
|
|
19
24
|
export declare function sealed(value: unknown, maximum: number, nullable?: boolean): string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EndpointContentLane, type EndpointOperationRequest, type EndpointOperationReceipt, type EndpointCapabilities } from '../backend-contracts/index.js';
|
|
1
|
+
import { type CanonClientIdentity, type EndpointContentLane, type EndpointOperationRequest, type EndpointOperationReceipt, type EndpointCapabilities } from '../backend-contracts/index.js';
|
|
2
2
|
import { type EndpointTransportEvent, type EndpointEventFamily } from './events.js';
|
|
3
3
|
import { type MlsDevDeviceHttpOptions, type MlsDevDeviceTransport } from './mls-dev-transport.js';
|
|
4
4
|
export declare class EndpointError extends Error {
|
|
@@ -55,4 +55,9 @@ export declare function createHttpEndpointTransport(options: {
|
|
|
55
55
|
streamId?: string | (() => string | Promise<string>);
|
|
56
56
|
ownershipVersion?: number | (() => number | undefined);
|
|
57
57
|
mlsDevDevice?: MlsDevDeviceHttpOptions;
|
|
58
|
+
/** Names this client on every request and stream (`X-Canon-Client`), so Canon can apply its client floor. */
|
|
59
|
+
client?: CanonClientIdentity;
|
|
60
|
+
/** Canon refused this client as below its floor (`426 CLIENT_UPDATE_REQUIRED`), on any request or stream. Called
|
|
61
|
+
* before the error is thrown, so a host can stop wherever the refusal surfaces. */
|
|
62
|
+
onClientUpdateRequired?(error: EndpointError): void;
|
|
58
63
|
}): EndpointTransport;
|
package/dist/media.js
CHANGED
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
toAnthropicImageBlock,
|
|
19
19
|
toAnthropicImageBlocksWithinBudget,
|
|
20
20
|
uploadMediaFile
|
|
21
|
-
} from "./chunks/chunk-
|
|
22
|
-
import "./chunks/chunk-
|
|
21
|
+
} from "./chunks/chunk-O5C3ZGI4.js";
|
|
22
|
+
import "./chunks/chunk-J63YVAKA.js";
|
|
23
23
|
export {
|
|
24
24
|
DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
|
|
25
25
|
DEFAULT_MEDIA_CACHE_DIR,
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** `tell` and `post` (§12.3, §12.4), `errand` (§12.6) and `cancel`, which ends an errand. */
|
|
2
|
+
export declare const ERRAND_KINDS: readonly ["tell", "post", "errand", "cancel"];
|
|
3
|
+
export type ErrandKind = (typeof ERRAND_KINDS)[number];
|
|
4
|
+
/** At most what one encrypted message holds (§6), so a post is never cut. */
|
|
5
|
+
export declare const ERRAND_TEXT_MAX_BYTES: number;
|
|
6
|
+
/** An errand's why, at most. */
|
|
7
|
+
export declare const ERRAND_WHY_MAX_BYTES: number;
|
|
8
|
+
/** A command not taken within a day is refused, and a note no turn used within a day expires. */
|
|
9
|
+
export declare const ERRAND_TTL_MS: number;
|
|
10
|
+
/** An errand stays open for replies this long after the agent reached its recipient, or after the last reply. */
|
|
11
|
+
export declare const ERRAND_OPEN_MS: number;
|
|
12
|
+
/** What the operator asks for: a note or a post for a room, an errand, or the end of an errand. */
|
|
13
|
+
export type ErrandInput = {
|
|
14
|
+
kind: 'tell' | 'post';
|
|
15
|
+
conversationId: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
/** `to`: a room the agent is in, or a person or agent to start a new conversation with; `text`: the instruction. */
|
|
19
|
+
| {
|
|
20
|
+
kind: 'errand';
|
|
21
|
+
to: string;
|
|
22
|
+
why: string;
|
|
23
|
+
text: string;
|
|
24
|
+
origin?: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'cancel';
|
|
27
|
+
errand: string;
|
|
28
|
+
};
|
|
29
|
+
/** One command, as the CLI writes it into the inbox. */
|
|
30
|
+
export type ErrandCommand = ErrandInput & {
|
|
31
|
+
version: 1;
|
|
32
|
+
id: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* What the runner did with a command. A note: `pending` until its room's next turn marks it `used`. A post: `sending`,
|
|
37
|
+
* then `sent`. An errand: `pending`, `running` (its turn), then `waiting` once the agent reached the recipient, `replied`
|
|
38
|
+
* when a turn ran there on a reply, `done` when its turn ended without reaching them, `failed`, `cancelled` (Stop in the
|
|
39
|
+
* origin, or `cancel`), `interrupted` (the runner stopped during its turn, which never runs again) or `expired`. A cancel
|
|
40
|
+
* is `applied`. Any command: `refused` (valid, but the runner could not apply it), `rejected` (not a valid command file),
|
|
41
|
+
* `expired` (too old).
|
|
42
|
+
*/
|
|
43
|
+
export type ErrandStatus = 'pending' | 'used' | 'sending' | 'sent' | 'running' | 'waiting' | 'replied' | 'done' | 'failed' | 'cancelled' | 'interrupted' | 'applied' | 'refused' | 'rejected' | 'expired';
|
|
44
|
+
export interface ErrandRecord {
|
|
45
|
+
version: 1;
|
|
46
|
+
id: string;
|
|
47
|
+
status: ErrandStatus;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
kind?: ErrandKind;
|
|
50
|
+
createdAt?: string;
|
|
51
|
+
reason?: string;
|
|
52
|
+
/** A note's or a post's room; an errand's once the agent reached its recipient there. */
|
|
53
|
+
conversationId?: string;
|
|
54
|
+
/** The installation scope it was taken under (§5): a note or an errand is acted on only under the same one. */
|
|
55
|
+
scope?: string;
|
|
56
|
+
/** A pending note's text, dropped once the note leaves `pending`; an errand's instruction. */
|
|
57
|
+
text?: string;
|
|
58
|
+
/** The turn that used a note; an errand's turn. */
|
|
59
|
+
turnId?: string;
|
|
60
|
+
/** An errand: its recipient (a room, or a person or agent to start a conversation with), why, and origin room. */
|
|
61
|
+
to?: string;
|
|
62
|
+
target?: 'room' | 'contact';
|
|
63
|
+
why?: string;
|
|
64
|
+
origin?: string;
|
|
65
|
+
/** An errand: when its turn reached the recipient, and the last reply there. */
|
|
66
|
+
reachedAt?: string;
|
|
67
|
+
repliedAt?: string;
|
|
68
|
+
/** An errand: its report kept here, when it may not go to the origin (§12.7), and how the one sent there went. */
|
|
69
|
+
report?: string;
|
|
70
|
+
reported?: 'sending' | 'sent' | 'refused';
|
|
71
|
+
/** A cancel: the errand it ends. */
|
|
72
|
+
errand?: string;
|
|
73
|
+
}
|
|
74
|
+
/** An agent's errands in the home: `runner/<env>/<agentId>/errands/` (spec §5). */
|
|
75
|
+
export declare function errandsDirectory(home: string, environmentId: string, agentId: string): string;
|
|
76
|
+
/** The inbox directory, created private if missing; one that is not this uid's private directory is refused. */
|
|
77
|
+
export declare function errandInbox(directory: string): string;
|
|
78
|
+
/** The operator's side (the CLI, or a library caller): one durable command file in the inbox. Throws on an invalid command. */
|
|
79
|
+
export declare function queueErrand(directory: string, input: ErrandInput): ErrandCommand;
|
|
80
|
+
/** The runner's records, one file per command taken (§12.2). */
|
|
81
|
+
export declare function errandJournal(directory: string): {
|
|
82
|
+
has: (id: string) => boolean;
|
|
83
|
+
get: (id: string) => ErrandRecord | undefined;
|
|
84
|
+
put: (record: ErrandRecord) => void;
|
|
85
|
+
list(): ErrandRecord[];
|
|
86
|
+
};
|
|
87
|
+
export type ErrandJournal = ReturnType<typeof errandJournal>;
|
|
88
|
+
/**
|
|
89
|
+
* `--wait` (§12.1): the command's record once the runner has answered it, or as it stands after `ms`, and whether it was
|
|
90
|
+
* accepted. A post (or an errand's report) Canon has not answered stays `sending` and is not accepted, though the runner
|
|
91
|
+
* keeps it and goes on delivering it: it may yet be refused.
|
|
92
|
+
*/
|
|
93
|
+
export declare function awaitErrand(directory: string, command: Pick<ErrandCommand, 'id' | 'kind'>, ms: number): Promise<{
|
|
94
|
+
record: ErrandRecord | undefined;
|
|
95
|
+
accepted: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
export interface ErrandHandler {
|
|
98
|
+
/** The command was taken already (its record or its journaled output exists): its file is only removed. */
|
|
99
|
+
taken(id: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* The command, or why its file is refused. True once its effect (or refusal) is journaled, so the file may go; false
|
|
102
|
+
* leaves it for the next scan. A throw is logged once per command and reason, and also leaves it.
|
|
103
|
+
*/
|
|
104
|
+
take(id: string, command: ErrandCommand | {
|
|
105
|
+
problem: string;
|
|
106
|
+
}): Promise<boolean>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* §12.1: watches the inbox and scans it every `intervalMs` as a backstop (and at once), one scan at a time, files in
|
|
110
|
+
* name order. A file is removed only after the handler has journaled what it did with it.
|
|
111
|
+
*/
|
|
112
|
+
export declare function watchErrandInbox(directory: string, handler: ErrandHandler, options: {
|
|
113
|
+
log: (line: string) => void;
|
|
114
|
+
intervalMs?: number;
|
|
115
|
+
}): {
|
|
116
|
+
close(): Promise<void>;
|
|
117
|
+
};
|
|
118
|
+
export type ErrandInbox = ReturnType<typeof watchErrandInbox>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type CanonEndpoint, type CanonMlsDevOptions, type MlsDevCurrentAudience } from '../internal/core/index.js';
|
|
2
|
+
import { type MlsDevDeviceContext } from '../internal/backend-contracts/index.js';
|
|
3
|
+
import type { ToolDefinition } from './types.js';
|
|
4
|
+
/** What `createRunner({ mls })` takes: issuer pins and custody, plus the custody's own shutdown. */
|
|
5
|
+
export type RunnerMlsOptions = CanonMlsDevOptions & {
|
|
6
|
+
close?(): Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
/** A closed copy of the public audience (no provider input or key material), in a fixed field order. */
|
|
9
|
+
export declare function snapshotMlsAudience(value: unknown): MlsDevCurrentAudience;
|
|
10
|
+
/**
|
|
11
|
+
* The principals who can read the room, each with its admission (an agent also with its ownership version), sorted: the
|
|
12
|
+
* set the server's device-only re-ask rule compares (encrypted-interactions.md §4), never the devices themselves. A
|
|
13
|
+
* principal reading through a device Canon operates (a class-C relay, §11) counts apart, so a relay device joining or
|
|
14
|
+
* leaving is never a device-only change.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mlsAudiencePrincipals(value: MlsDevCurrentAudience): string[];
|
|
17
|
+
/**
|
|
18
|
+
* The audience's epoch: who can read the room, which is its principals with their admissions, the membership revision
|
|
19
|
+
* and this device's own place in the group. A device-only change (a member adds or removes a device and keeps one) is a
|
|
20
|
+
* re-key, not an audience change (§4), so the group head and the device set are left out, as is the feed cursor, which
|
|
21
|
+
* ordinary text moves.
|
|
22
|
+
*/
|
|
23
|
+
export declare function mlsAudienceEpoch(value: MlsDevCurrentAudience): string;
|
|
24
|
+
/** What an encrypted room's text message is to the runner; Canon never learns it (`MlsIds.text`). */
|
|
25
|
+
export type MlsTextKind = 'final' | 'failed' | 'restart' | 'said' | 'item';
|
|
26
|
+
/**
|
|
27
|
+
* §6 ids. Canon sees the message id of everything the runner sends to an encrypted room, and a card's request id (its
|
|
28
|
+
* public binding), so these are keyed with a secret only this installation holds (`privateKey`): HMAC-SHA256 over
|
|
29
|
+
* domain-separated inputs, cut to 128 bits. Canon can test no guess of the text, question or turn an id names, and every
|
|
30
|
+
* text message (a final, a failure or restart notice, a `communicate` send, an item) has the same shape, `msg-<32 hex>`, so none
|
|
31
|
+
* says what kind it is. The same inputs give the same id after a restart, so journal replay, a repeated `communicate`,
|
|
32
|
+
* a re-asked card and a restart notice keep theirs.
|
|
33
|
+
*/
|
|
34
|
+
export interface MlsIds {
|
|
35
|
+
/** A text message's id: `parts` name it (the turn, or the turn and a `communicate` send's text). */
|
|
36
|
+
text(kind: MlsTextKind, conversationId: string, ...parts: string[]): string;
|
|
37
|
+
/** A card's request id, `ask-<32 hex>` (`MLS_DEV_INTERACTION_ID_PATTERN`), for the runtime's ask `askId` in turn `turnId`. */
|
|
38
|
+
request(conversationId: string, turnId: string, askId: string): string;
|
|
39
|
+
}
|
|
40
|
+
/** The installation's id key: random bytes, created once under CANON_HOME. */
|
|
41
|
+
export declare const MLS_ID_KEY_BYTES = 32;
|
|
42
|
+
export declare function createMlsIds(key: Uint8Array): MlsIds;
|
|
43
|
+
/**
|
|
44
|
+
* Encrypted rooms are for agents whose outbound communication is not closed, in an environment with an MLS profile. Canon
|
|
45
|
+
* decides who joins a room under the invitation policies, as for plaintext rooms, and whether that environment runs MLS.
|
|
46
|
+
*/
|
|
47
|
+
export declare function requireMlsSupport(input: {
|
|
48
|
+
environmentId: string;
|
|
49
|
+
agent: {
|
|
50
|
+
outboundPolicy: string;
|
|
51
|
+
};
|
|
52
|
+
}): void;
|
|
53
|
+
/**
|
|
54
|
+
* Whether `text` @mentions any of `names` (an agent's display name, id or aliases). Encrypted text carries no `mentions[]`,
|
|
55
|
+
* so this is how one agent addresses another there: `@`, not preceded by a letter, digit, `_` or `@` (so no address
|
|
56
|
+
* like `ops@example.com`), then the name in any case, with any run of whitespace for a space, not followed by a letter,
|
|
57
|
+
* digit, mark or `_` (`@Cipher A` does not mention `Cipher AB`).
|
|
58
|
+
*/
|
|
59
|
+
export declare function mentionsAgent(text: string, names: ReadonlyArray<string | undefined>): boolean;
|
|
60
|
+
/** An encrypted turn's `communicate`: listing, and text to its own room, which the runner encrypts. */
|
|
61
|
+
export declare const ENCRYPTED_COMMUNICATE: ToolDefinition;
|
|
62
|
+
/**
|
|
63
|
+
* The operator's MLS configuration file: public issuer pins and the custody helper's identity, never credentials or
|
|
64
|
+
* private keys. A canonical, current-user-owned regular file, not group- or other-writable, at most 64 KiB, read once.
|
|
65
|
+
* Its configuration must be for the environment the runner runs in.
|
|
66
|
+
*/
|
|
67
|
+
export declare function loadMlsDevConfiguration(filePath: string, input: {
|
|
68
|
+
environmentId: string;
|
|
69
|
+
}): Promise<RunnerMlsOptions & {
|
|
70
|
+
provision?: (context: MlsDevDeviceContext) => Promise<void>;
|
|
71
|
+
close(): Promise<void>;
|
|
72
|
+
}>;
|
|
73
|
+
export declare const MLS_SETUP_ACTIONS: readonly ["status", "provision", "enroll", "renew", "publish", "refresh"];
|
|
74
|
+
export type MlsSetupAction = typeof MLS_SETUP_ACTIONS[number];
|
|
75
|
+
/** The KeyPackage an agent publishes for one room: stable for its installation, so a repeated publish is the same intent. */
|
|
76
|
+
export declare function mlsDevRoomPackageId(identity: {
|
|
77
|
+
environmentId: string;
|
|
78
|
+
principalId: string;
|
|
79
|
+
installationId: string;
|
|
80
|
+
ownershipVersion?: number;
|
|
81
|
+
}, room: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* One operator step for the agent's device (`canon-agent mls`), on the same engine store the runner uses. It never
|
|
84
|
+
* starts a model, and prints only public device state: no credentials, proofs, envelopes or history.
|
|
85
|
+
*/
|
|
86
|
+
export declare function runMlsDevSetup(endpoint: CanonEndpoint, action: MlsSetupAction, room?: string, provision?: (context: MlsDevDeviceContext) => Promise<void>): Promise<{
|
|
87
|
+
conversationId?: string | undefined;
|
|
88
|
+
version: number;
|
|
89
|
+
action: "status" | "publish" | "enroll" | "renew" | "provision" | "refresh";
|
|
90
|
+
environmentId: "canon-dev-v1" | "canon-prod-v1";
|
|
91
|
+
principalId: string;
|
|
92
|
+
installationId: string;
|
|
93
|
+
ownershipVersion: number | undefined;
|
|
94
|
+
status: "absent" | "identity_committed" | "registered" | "credential_committed" | "revoked";
|
|
95
|
+
deviceId: string | null;
|
|
96
|
+
credentialGeneration: number;
|
|
97
|
+
}>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type ConnectorRelayCredentialDelivery } from '../internal/backend-contracts/index.js';
|
|
2
|
+
import type { ConnectorInbox } from '../drivers/connector.js';
|
|
3
|
+
import type { Runner } from './runner.js';
|
|
4
|
+
/** What the channel serves: the relay's runner (history and sends) and its connector driver's inbox (pickup). */
|
|
5
|
+
export interface RelayTarget {
|
|
6
|
+
runner: Pick<Runner, 'relayRead' | 'relaySend'>;
|
|
7
|
+
inbox: ConnectorInbox;
|
|
8
|
+
}
|
|
9
|
+
/** Canon's credential for this relay, as delivered: the connection it serves is the delivering request's. */
|
|
10
|
+
export type RelayCredentialDelivery = ConnectorRelayCredentialDelivery & {
|
|
11
|
+
grantId: string;
|
|
12
|
+
};
|
|
13
|
+
export interface RelayChannelOptions {
|
|
14
|
+
/** The runner and inbox to serve from the start; `serve` sets or replaces them. Until then only `credential` is answered. */
|
|
15
|
+
runner?: Pick<Runner, 'relayRead' | 'relaySend'>;
|
|
16
|
+
inbox?: ConnectorInbox;
|
|
17
|
+
/** The relayed agent: requests naming another agent are refused. */
|
|
18
|
+
agentId: string;
|
|
19
|
+
/**
|
|
20
|
+
* The connector connection served: requests naming another are refused. A credential delivery (the owner's approval)
|
|
21
|
+
* names its own connection and moves the relay to it.
|
|
22
|
+
*/
|
|
23
|
+
grantId?: string;
|
|
24
|
+
/** The Standard Webhooks secret (`whsec_…`) Functions signs with: this agent's alone. */
|
|
25
|
+
secret: string;
|
|
26
|
+
/**
|
|
27
|
+
* Canon delivers the relay's credential here when the owner approves, or re-approves, the relay; the channel confirms
|
|
28
|
+
* the delivery once this resolves, so it should keep the credential durably first. Without it, deliveries are refused.
|
|
29
|
+
*/
|
|
30
|
+
onCredential?: (delivery: RelayCredentialDelivery) => void | Promise<void>;
|
|
31
|
+
/** Default 127.0.0.1 and a random port. */
|
|
32
|
+
host?: string;
|
|
33
|
+
port?: number;
|
|
34
|
+
/** Never receives message text. */
|
|
35
|
+
log?: (line: string) => void;
|
|
36
|
+
/** Test seam: the clock signatures are checked against. */
|
|
37
|
+
now?: () => number;
|
|
38
|
+
/** Test seam: how long an exchange may take before it is answered (default `CONNECTOR_RELAY_ANSWER_WITHIN_MS`). */
|
|
39
|
+
answerWithinMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface RelayChannel {
|
|
42
|
+
readonly url: string;
|
|
43
|
+
/** Serves this runner and inbox for `grantId` (default: the connection already served), or nothing (`undefined`). */
|
|
44
|
+
serve(target: RelayTarget | undefined, grantId?: string): void;
|
|
45
|
+
close(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export declare function relaySecretKey(secret: string): Buffer;
|
|
48
|
+
/** The headers Functions sends (as the `standardwebhooks` library signs them); the tests' stand-in for Functions uses it. */
|
|
49
|
+
export declare function signRelayRequest(secret: string, id: string, body: string, nowMs?: number): Record<string, string>;
|
|
50
|
+
/** Starts the channel. Every request is authenticated before its body is parsed; refusals carry no detail. */
|
|
51
|
+
export declare function startRelayChannel(options: RelayChannelOptions): Promise<RelayChannel>;
|
|
52
|
+
export interface RelayConfiguration {
|
|
53
|
+
environmentId: string;
|
|
54
|
+
agentId: string;
|
|
55
|
+
listen: {
|
|
56
|
+
host: string;
|
|
57
|
+
port: number;
|
|
58
|
+
};
|
|
59
|
+
secret: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The operator's relay configuration (`--relay-config`): which agent this process relays, where the channel listens, and
|
|
63
|
+
* the path of the channel secret, itself a private file. The connection, installation and credential come from Canon,
|
|
64
|
+
* with the credential, when the owner approves the relay.
|
|
65
|
+
*/
|
|
66
|
+
export declare function loadRelayConfiguration(path: string, input: {
|
|
67
|
+
environmentId: string;
|
|
68
|
+
}): Promise<RelayConfiguration>;
|
|
69
|
+
/** The relay's credential as it keeps it: `<CANON_HOME>/relay/credential.json`, 0600, written whole or not at all. */
|
|
70
|
+
export interface StoredRelayCredential {
|
|
71
|
+
version: 1;
|
|
72
|
+
environmentId: string;
|
|
73
|
+
agentId: string;
|
|
74
|
+
grantId: string;
|
|
75
|
+
installationId: string;
|
|
76
|
+
generation: number;
|
|
77
|
+
credential: string;
|
|
78
|
+
}
|
|
79
|
+
/** The credential Canon delivered to this relay, if any; one for another agent or environment is refused. */
|
|
80
|
+
export declare function readRelayCredential(home: string, relay: Pick<RelayConfiguration, 'environmentId' | 'agentId'>): Promise<StoredRelayCredential | undefined>;
|
|
81
|
+
/** Keeps a delivered credential durably (fsync, then rename), private to this user, before the delivery is confirmed. */
|
|
82
|
+
export declare function writeRelayCredential(home: string, relay: Pick<RelayConfiguration, 'environmentId' | 'agentId'>, delivery: RelayCredentialDelivery): StoredRelayCredential;
|
|
83
|
+
/**
|
|
84
|
+
* Where the runner for one relay installation keeps its state (engine store, journal, lock): a private directory per
|
|
85
|
+
* installation, so a new approval (a new installation and device) starts clean beside the old one.
|
|
86
|
+
*/
|
|
87
|
+
export declare function relayRunnerHome(home: string, installationId: string): string;
|