@agentvault/agentvault 0.23.71 → 0.23.73
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 +3 -1
- package/dist/atomic-file.d.ts +11 -0
- package/dist/atomic-file.d.ts.map +1 -0
- package/dist/channel.d.ts +677 -46
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +8169 -2405
- package/dist/cli.js.map +4 -4
- package/dist/dm-group-pins.d.ts +190 -0
- package/dist/dm-group-pins.d.ts.map +1 -0
- package/dist/dr-refusal.d.ts +54 -0
- package/dist/dr-refusal.d.ts.map +1 -0
- package/dist/file-send-failure.d.ts +115 -0
- package/dist/file-send-failure.d.ts.map +1 -0
- package/dist/file-send-policy.d.ts +251 -0
- package/dist/file-send-policy.d.ts.map +1 -0
- package/dist/full-permissions.d.ts +479 -0
- package/dist/full-permissions.d.ts.map +1 -0
- package/dist/gateway-send.d.ts +8 -0
- package/dist/gateway-send.d.ts.map +1 -1
- package/dist/harness-compat.d.ts +12 -0
- package/dist/harness-compat.d.ts.map +1 -1
- package/dist/http-handlers.d.ts +5 -1
- package/dist/http-handlers.d.ts.map +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8672 -2421
- package/dist/index.js.map +4 -4
- package/dist/local-api-server.d.ts +71 -0
- package/dist/local-api-server.d.ts.map +1 -0
- package/dist/local-api.d.ts +107 -0
- package/dist/local-api.d.ts.map +1 -0
- package/dist/mcp-handlers.d.ts +15 -1
- package/dist/mcp-handlers.d.ts.map +1 -1
- package/dist/mcp-server.d.ts +4 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/off-sequence-report.d.ts +74 -0
- package/dist/off-sequence-report.d.ts.map +1 -0
- package/dist/onturn-stop.d.ts +253 -0
- package/dist/onturn-stop.d.ts.map +1 -0
- package/dist/openclaw-entry.d.ts +44 -6
- package/dist/openclaw-entry.d.ts.map +1 -1
- package/dist/openclaw-entry.js +1384 -177
- package/dist/openclaw-entry.js.map +4 -4
- package/dist/openclaw-file-send.d.ts +308 -0
- package/dist/openclaw-file-send.d.ts.map +1 -0
- package/dist/openclaw-plugin.d.ts +7 -2
- package/dist/openclaw-plugin.d.ts.map +1 -1
- package/dist/openclaw-room-taint.d.ts +43 -0
- package/dist/openclaw-room-taint.d.ts.map +1 -0
- package/dist/openclaw-sender.d.ts +47 -0
- package/dist/openclaw-sender.d.ts.map +1 -0
- package/dist/openclaw-types.d.ts +7 -1
- package/dist/openclaw-types.d.ts.map +1 -1
- package/dist/owner-devices.d.ts +71 -0
- package/dist/owner-devices.d.ts.map +1 -0
- package/dist/owner-epoch.d.ts +36 -0
- package/dist/owner-epoch.d.ts.map +1 -0
- package/dist/room-protocol.d.ts +22 -2
- package/dist/room-protocol.d.ts.map +1 -1
- package/dist/room-send-error.d.ts +17 -0
- package/dist/room-send-error.d.ts.map +1 -0
- package/dist/sender-binding.d.ts +130 -0
- package/dist/sender-binding.d.ts.map +1 -0
- package/dist/tool-telemetry.d.ts +1 -1
- package/dist/tool-telemetry.d.ts.map +1 -1
- package/dist/turn-token.d.ts +168 -0
- package/dist/turn-token.d.ts.map +1 -0
- package/dist/types.d.ts +162 -6
- package/dist/types.d.ts.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/workspace-handlers.d.ts +0 -62
- package/dist/workspace-handlers.d.ts.map +0 -1
package/dist/room-protocol.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
*
|
|
29
29
|
* no @ -> NOBODY replies (speak IN the room, not TO anyone)
|
|
30
30
|
* @wren / @a @b -> those named
|
|
31
|
-
* @all / @everyone -> everyone, HUMANS ONLY
|
|
31
|
+
* @all / @everyone -> everyone, HUMANS ONLY, and only a BOUND sender (#1855)
|
|
32
32
|
*
|
|
33
33
|
* PRIVATE ROOM (#1574) -> the agent, from its person, with no @
|
|
34
34
|
*
|
|
@@ -75,8 +75,28 @@ export declare function parseMentions(text: string): string[];
|
|
|
75
75
|
*
|
|
76
76
|
* `roomTurnNote` is the ONE wording of the private-turn note; every TypeScript
|
|
77
77
|
* family prepends it rather than writing its own.
|
|
78
|
+
*
|
|
79
|
+
* SENDER BINDING (#1855) — `senderBinding` is the frame's verdict exactly as
|
|
80
|
+
* SecureChannel emits it (`room_message` / `onMessage` metadata). An unverified
|
|
81
|
+
* sender never broadcasts, in any family:
|
|
82
|
+
*
|
|
83
|
+
* - `"bound"`: the rules above, unchanged. That includes the documented L2
|
|
84
|
+
* residual — a bound sender this agent's roster cannot place
|
|
85
|
+
* (`senderIsAgent === undefined`) may still @all; it proved membership of
|
|
86
|
+
* the room's MLS group.
|
|
87
|
+
* - any other value (`"mismatch"`, `"duplicate"`, `"unavailable"`, `null`,
|
|
88
|
+
* …): the sender is read as an AGENT sender — no @all, no plain-name
|
|
89
|
+
* summon, no private-room turn; only an @mention of this agent's own name
|
|
90
|
+
* (or the unresolved-self fail-open) earns a reply. The same mapping the
|
|
91
|
+
* OpenClaw entry and the bridges apply before calling this.
|
|
92
|
+
* - omitted (`undefined`): @all / @everyone FAILS CLOSED — the only
|
|
93
|
+
* privilege an unknown roster member (`senderIsAgent === undefined`, which
|
|
94
|
+
* is what the channel emits for an unbound frame) could otherwise reach.
|
|
95
|
+
* A plain-name summon and a private-room turn already need
|
|
96
|
+
* `senderIsAgent === false`, which the channel never emits for an unbound
|
|
97
|
+
* frame, so they stay keyed on `senderIsAgent` for a caller that omits it.
|
|
78
98
|
*/
|
|
79
|
-
export declare function owesRoomReply(plaintext: string, agentName: string, accountId: string, senderIsAgent?: boolean, roomDisplayName?: string, ownDisplayName?: string, selfResolved?: boolean, roomAudience?: unknown): boolean;
|
|
99
|
+
export declare function owesRoomReply(plaintext: string, agentName: string, accountId: string, senderIsAgent?: boolean, roomDisplayName?: string, ownDisplayName?: string, selfResolved?: boolean, roomAudience?: unknown, senderBinding?: unknown): boolean;
|
|
80
100
|
/** #1574 — is this a person's message in a private (one person + one agent)
|
|
81
101
|
* room? Strict on both inputs: the sender must be a KNOWN human
|
|
82
102
|
* (`=== false`, so an unknown roster member fails closed) and the audience
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-protocol.d.ts","sourceRoot":"","sources":["../src/room-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAeH,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUpD;AAwBD
|
|
1
|
+
{"version":3,"file":"room-protocol.d.ts","sourceRoot":"","sources":["../src/room-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAeH,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUpD;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,eAAe,CAAC,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,MAAM,EACvB,YAAY,GAAE,OAAc,EAC5B,YAAY,CAAC,EAAE,OAAO,EACtB,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CA+DT;AAED;;;;gFAIgF;AAChF,wBAAgB,yBAAyB,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAElG;AAED;0CAC0C;AAC1C,eAAO,MAAM,sBAAsB,6FACoD,CAAC;AAExF;;mEAEmE;AACnE,wBAAgB,YAAY,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,CAEpF;AAED;;sEAEsE;AACtE,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,MAAM,GACtB,GAAG,CAAC,MAAM,CAAC,CAiBb;AAKD;;;+EAG+E;AAC/E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAgBT;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,CAiBR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAiBR"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1762 (design §1.3, H1/N8) — a room send that wrote NO frame.
|
|
3
|
+
*
|
|
4
|
+
* `sendToRoom` throws this instead of returning normally when the relay is not
|
|
5
|
+
* ready, there is no socket, or the socket was not open after the write. A
|
|
6
|
+
* flag on the return value could be ignored; a throw lands in every caller's
|
|
7
|
+
* existing `catch` (14 call sites across the plugin and the four bridges).
|
|
8
|
+
*
|
|
9
|
+
* The message carries a short room prefix only, never the full id, and always
|
|
10
|
+
* contains "relay socket is not open" so the text classifier
|
|
11
|
+
* (`ERROR_TEXT_CODES`) maps a stringified copy to `relay_not_connected` too.
|
|
12
|
+
*/
|
|
13
|
+
export declare class RoomSendNotWritten extends Error {
|
|
14
|
+
readonly code: "relay_not_connected";
|
|
15
|
+
constructor(roomId: string);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=room-send-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-send-error.d.ts","sourceRoot":"","sources":["../src/room-send-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAG,qBAAqB,CAAU;gBACnC,MAAM,EAAE,MAAM;CAI3B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1800 PR B — the plugin side of binding a frame's server-claimed
|
|
3
|
+
* `sender_device_id` to its cryptographic MLS sender (design-1800 §3.1/§3.3).
|
|
4
|
+
*
|
|
5
|
+
* `@agentvault/crypto`'s `bindMlsSender` is the predicate. This module adds
|
|
6
|
+
* what the plugin needs around it:
|
|
7
|
+
*
|
|
8
|
+
* - `bindFrameSender` — the predicate, failing closed while the start-up
|
|
9
|
+
* self-test says the bundled ts-mls cannot report senders;
|
|
10
|
+
* - `runSenderBindingSelfTest` — the runtime canary (obligation 5): a
|
|
11
|
+
* locally built MLS frame must decrypt with a populated, bound sender.
|
|
12
|
+
* A publish built with `--ignore-scripts` (patch-package skipped) ships an
|
|
13
|
+
* unpatched ts-mls; every frame would then read `unavailable` and no owner
|
|
14
|
+
* would ever be recognised. The canary makes that LOUD at start instead of
|
|
15
|
+
* a silent lock-out, and keeps owner power off (fail closed) when the
|
|
16
|
+
* patch is missing or answers wrongly;
|
|
17
|
+
* - the log-safe forms of a claimed id used in SenderIds and logs.
|
|
18
|
+
*
|
|
19
|
+
* Imported from the crypto SUBPATH, not the package root: the root pulls in
|
|
20
|
+
* ts-mls and is wholesale-mocked by many suites (see channel.ts's
|
|
21
|
+
* `mls-presend-epoch` import for the same reason).
|
|
22
|
+
*/
|
|
23
|
+
import { type MlsSender, type SenderBinding } from "@agentvault/crypto/mls-sender-binding";
|
|
24
|
+
export type { SenderBinding } from "@agentvault/crypto/mls-sender-binding";
|
|
25
|
+
/** Why a frame is not bound: `mismatch`, `duplicate`, or the `unavailable` reason. */
|
|
26
|
+
export type UnverifiedReason = "mismatch" | "duplicate" | Extract<SenderBinding, {
|
|
27
|
+
verdict: "unavailable";
|
|
28
|
+
}>["reason"] | "self_test_failed";
|
|
29
|
+
/** The plugin's verdict: the crypto verdict, or `unavailable` because the self-test failed. */
|
|
30
|
+
export type SenderVerdict = SenderBinding | {
|
|
31
|
+
verdict: "unavailable";
|
|
32
|
+
reason: "self_test_failed";
|
|
33
|
+
};
|
|
34
|
+
/** `"unknown"` until the self-test has run in this process; `"failed"` turns every verdict off. */
|
|
35
|
+
export type SenderBindingHealth = "unknown" | "ok" | "failed";
|
|
36
|
+
/** The self-test's outcome in this process. */
|
|
37
|
+
export declare function senderBindingHealth(): {
|
|
38
|
+
health: SenderBindingHealth;
|
|
39
|
+
detail: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The §3.1 verdict for one decrypted MLS frame. Never throws. While the
|
|
43
|
+
* self-test has FAILED, every frame is `unavailable` (`self_test_failed`):
|
|
44
|
+
* a ts-mls that reports senders wrongly must not be believed even when a
|
|
45
|
+
* particular frame happens to look bound.
|
|
46
|
+
*/
|
|
47
|
+
export declare function bindFrameSender(result: {
|
|
48
|
+
isHandshake: boolean;
|
|
49
|
+
sender?: MlsSender;
|
|
50
|
+
} | null | undefined, claimed: unknown): SenderVerdict;
|
|
51
|
+
/** The bound device id, or `undefined` for every other verdict. The ONLY id a sink may take. */
|
|
52
|
+
export declare function boundDeviceId(v: SenderVerdict): string | undefined;
|
|
53
|
+
/** The counter/log reason for an unbound verdict (`undefined` when bound). */
|
|
54
|
+
export declare function unverifiedReason(v: SenderVerdict): UnverifiedReason | undefined;
|
|
55
|
+
/** A claimed id made safe for a log line or an id fragment: `[0-9a-f-]` only, then 8 characters (§3.4). */
|
|
56
|
+
export declare function claimed8(id: unknown): string;
|
|
57
|
+
/** The whole claimed id, sanitized for display (`[0-9a-f-]`, at most 36 characters), or `undefined`. */
|
|
58
|
+
export declare function sanitizedClaim(id: unknown): string | undefined;
|
|
59
|
+
/** The subset of `MLSGroupManager` the self-test drives. */
|
|
60
|
+
interface SelfTestManager {
|
|
61
|
+
generateKeyPackage(identity: Uint8Array): Promise<{
|
|
62
|
+
publicPackage: unknown;
|
|
63
|
+
privatePackage: unknown;
|
|
64
|
+
}>;
|
|
65
|
+
createGroup(groupId: Uint8Array, kp: {
|
|
66
|
+
publicPackage: unknown;
|
|
67
|
+
privatePackage: unknown;
|
|
68
|
+
}): Promise<unknown>;
|
|
69
|
+
addMembers(kps: unknown[]): Promise<{
|
|
70
|
+
welcome?: Uint8Array;
|
|
71
|
+
}>;
|
|
72
|
+
joinFromWelcome(welcome: Uint8Array, kp: {
|
|
73
|
+
publicPackage: unknown;
|
|
74
|
+
privatePackage: unknown;
|
|
75
|
+
}): Promise<unknown>;
|
|
76
|
+
encrypt(plaintext: Uint8Array): Promise<Uint8Array>;
|
|
77
|
+
decrypt(bytes: Uint8Array): Promise<{
|
|
78
|
+
isHandshake: boolean;
|
|
79
|
+
plaintext?: Uint8Array;
|
|
80
|
+
sender?: MlsSender;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
export interface SelfTestDeps {
|
|
84
|
+
/** `MLSGroupManager` from `@agentvault/crypto` (passed in so this module stays off the crypto root). */
|
|
85
|
+
Manager: new () => SelfTestManager;
|
|
86
|
+
/** Re-encode a KeyPackage the way it travels (serialize → deserialize), when available. */
|
|
87
|
+
roundTripKeyPackage?: (pub: unknown) => unknown;
|
|
88
|
+
/** Test seam: what the decrypt step returns (e.g. strip `sender`, as an unpatched ts-mls would). */
|
|
89
|
+
transformDecrypt?: (r: {
|
|
90
|
+
isHandshake: boolean;
|
|
91
|
+
plaintext?: Uint8Array;
|
|
92
|
+
sender?: MlsSender;
|
|
93
|
+
}, ids: {
|
|
94
|
+
sender: string;
|
|
95
|
+
other: string;
|
|
96
|
+
}) => {
|
|
97
|
+
isHandshake: boolean;
|
|
98
|
+
plaintext?: Uint8Array;
|
|
99
|
+
sender?: MlsSender;
|
|
100
|
+
};
|
|
101
|
+
log?: {
|
|
102
|
+
info: (m: string) => void;
|
|
103
|
+
error: (m: string) => void;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The runtime canary (obligation 5). Builds a two-member MLS group in memory,
|
|
108
|
+
* has member B send one application frame, decrypts it at A and requires:
|
|
109
|
+
* - `sender` is populated (patch 003 is present);
|
|
110
|
+
* - claiming B binds to B with exactly one leaf;
|
|
111
|
+
* - claiming A (the other member) is a mismatch.
|
|
112
|
+
* Anything else — including a throw — is `"failed"`: logged loudly, and every
|
|
113
|
+
* later verdict in this process is `unavailable` (no owner power anywhere).
|
|
114
|
+
* Runs once per process; later calls return the first outcome.
|
|
115
|
+
*/
|
|
116
|
+
export declare function runSenderBindingSelfTest(deps: SelfTestDeps): Promise<SenderBindingHealth>;
|
|
117
|
+
/** The `tool.error_kind` of the Admin-incident span for a failed self-test (docs/contracts/agent-tool-error-codes.json). */
|
|
118
|
+
export declare const SENDER_BINDING_SELF_TEST_FAILED_CODE = "sender_binding_self_test_failed";
|
|
119
|
+
/** The `tool.name` of that span. Not a send tool: it delivers nothing. */
|
|
120
|
+
export declare const SENDER_BINDING_SELF_TEST_TOOL = "sender_binding_self_test";
|
|
121
|
+
/**
|
|
122
|
+
* #1800 PR B (#1560: failures are shown, never swallowed) — true exactly ONCE
|
|
123
|
+
* per process, and only after the self-test FAILED: the caller then raises
|
|
124
|
+
* the Admin incident. Call it only when the incident can actually be sent, so
|
|
125
|
+
* a call made before the telemetry reporter exists does not spend the one shot.
|
|
126
|
+
*/
|
|
127
|
+
export declare function takeSenderBindingIncident(): boolean;
|
|
128
|
+
/** @internal Tests only: forget the self-test so the next run starts fresh. */
|
|
129
|
+
export declare function _resetSenderBindingSelfTestForTests(): void;
|
|
130
|
+
//# sourceMappingURL=sender-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sender-binding.d.ts","sourceRoot":"","sources":["../src/sender-binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE1G,YAAY,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E,sFAAsF;AACtF,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,WAAW,GACX,OAAO,CAAC,aAAa,EAAE;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,GAC5D,kBAAkB,CAAC;AAEvB,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEnG,mGAAmG;AACnG,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,IAAI,GAAG,QAAQ,CAAC;AAM9D,+CAA+C;AAC/C,wBAAgB,mBAAmB,IAAI;IAAE,MAAM,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAErF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,EACvE,OAAO,EAAE,OAAO,GACf,aAAa,CAOf;AAED,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAElE;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,CAAC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oGAAoG;IACpG,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,WAAW,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,UAAU,CAAC;QAAC,MAAM,CAAC,EAAE,SAAS,CAAA;KAAE,EAAE,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK;QACtI,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,CAAC,EAAE,UAAU,CAAC;QACvB,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,CAAC;IACF,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;CACjE;AAMD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA4CzF;AAED,4HAA4H;AAC5H,eAAO,MAAM,oCAAoC,oCAAoC,CAAC;AACtF,0EAA0E;AAC1E,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AAIxE;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,CAInD;AAED,+EAA+E;AAC/E,wBAAgB,mCAAmC,IAAI,IAAI,CAK1D"}
|
package/dist/tool-telemetry.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const UNCLASSIFIED_ERROR = "unclassified";
|
|
|
30
30
|
* call site or the text classifier below produces a code missing here.
|
|
31
31
|
* Mirrors `docs/contracts/agent-tool-error-codes.json` (code → kind).
|
|
32
32
|
*/
|
|
33
|
-
export declare const KNOWN_TOOL_ERROR_CODES: readonly ["relay_not_connected", "mls_group_not_initialized", "mls_encrypt_failed", "room_not_found", "a2a_channel_not_found", "channel_not_ready", "channel_not_started", "no_active_sessions", "no_conversation_ready", "blocked_by_policy", "unknown_target", "unsupported_destination", "delivery_timeout", "delivery_cancelled", "delivery_failed", "ambiguous_target", "no_receipt", "invalid_request", "plan_limit_reached", "model_rate_limited", "model_error", "provider_auth_failed", "provider_billing", "model_unavailable", "provider_unreachable", "ai_tool_unsupported", "unclassified"];
|
|
33
|
+
export declare const KNOWN_TOOL_ERROR_CODES: readonly ["relay_not_connected", "mls_group_not_initialized", "mls_encrypt_failed", "room_not_found", "a2a_channel_not_found", "channel_not_ready", "channel_not_started", "no_active_sessions", "no_conversation_ready", "blocked_by_policy", "unknown_target", "unsupported_destination", "delivery_timeout", "delivery_cancelled", "delivery_failed", "ambiguous_target", "no_receipt", "invalid_request", "plan_limit_reached", "model_rate_limited", "model_error", "provider_auth_failed", "provider_billing", "model_unavailable", "provider_unreachable", "ai_tool_unsupported", "file_not_allowed", "file_not_found", "file_too_large", "upload_failed", "room_file_not_permitted", "file_target_mismatch", "file_send_disabled", "workspace_required", "unclaimed_attachment", "turn_ended", "turn_no_consumer", "off_sequence_failed", "sender_binding_self_test_failed", "unclassified"];
|
|
34
34
|
export type ToolErrorCode = (typeof KNOWN_TOOL_ERROR_CODES)[number];
|
|
35
35
|
export type ToolConversationKind = "room" | "direct" | "unknown";
|
|
36
36
|
export interface ToolConversation {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-telemetry.d.ts","sourceRoot":"","sources":["../src/tool-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-telemetry.d.ts","sourceRoot":"","sources":["../src/tool-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,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AE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,CAK3H;AAYD;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,EAC7C,YAAY,EAAE,gBAAgB,EAC9B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,gBAAgB,CAI1D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GACrC,gBAAgB,CAclB;AAID,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAuC3E;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAOtG"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** Opaque to families. Only SecureChannel can resolve it. */
|
|
2
|
+
export type TurnToken = {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
};
|
|
5
|
+
/** Why SecureChannel dropped a token itself (no lease was ever used). */
|
|
6
|
+
export type TurnDropReason = "not_opted_in" | "no_consumer" | "handoff_failed";
|
|
7
|
+
/** The capability to end (or fold) one token, handed only to its first claimant. */
|
|
8
|
+
export type TurnLease = {
|
|
9
|
+
readonly token: TurnToken;
|
|
10
|
+
readonly key: string;
|
|
11
|
+
};
|
|
12
|
+
export type TurnTokenKind = "dm" | "room";
|
|
13
|
+
/** What SecureChannel knows about a token. Never handed to a family. */
|
|
14
|
+
export interface TurnTokenRecord {
|
|
15
|
+
readonly kind: TurnTokenKind;
|
|
16
|
+
/** 1:1: the conversation the message came from (may be absent for an unmapped group). */
|
|
17
|
+
readonly convId?: string;
|
|
18
|
+
/** 1:1: the group the message DECRYPTED under (#1418, attested). */
|
|
19
|
+
readonly groupId?: string;
|
|
20
|
+
/** Room: the room the message arrived in. */
|
|
21
|
+
readonly roomId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Room: the sender was a human of this agent's own account, not an agent,
|
|
24
|
+
* and the message folded no other member's file (#1459). Fixed at mint.
|
|
25
|
+
*/
|
|
26
|
+
readonly eligible: boolean;
|
|
27
|
+
/** Room: true only after a successful `attestCleanTurn`. A 1:1 token ignores it. */
|
|
28
|
+
ownerTurn: boolean;
|
|
29
|
+
/** Room: a non-eligible arrival in this room happened after the mint (N2). Permanent. */
|
|
30
|
+
downgraded: boolean;
|
|
31
|
+
/** False once the turn ended (`endTurn`) — or, read through the registry, past the TTL. */
|
|
32
|
+
active: boolean;
|
|
33
|
+
readonly mintedAt: number;
|
|
34
|
+
/** Mint order (a counter, never a clock): R3-4 compares tokens by it. */
|
|
35
|
+
readonly seq: number;
|
|
36
|
+
/** Explicitly ended by its claimant (a lapsed TTL is NOT an end). */
|
|
37
|
+
ended: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Set when SecureChannel itself dropped the token because no family will
|
|
40
|
+
* ever run it: file sending not opted into (`not_opted_in`), no `onMessage`
|
|
41
|
+
* consumer (`no_consumer`), or a throw between mint and hand-off
|
|
42
|
+
* (`handoff_failed`). Absent for a token its claimant ended.
|
|
43
|
+
*/
|
|
44
|
+
endReason?: TurnDropReason;
|
|
45
|
+
/** The claim's key, once claimed (first claim wins). */
|
|
46
|
+
leaseKey?: string;
|
|
47
|
+
/** The turn this message was folded into: it ends when that turn ends. */
|
|
48
|
+
absorber?: TurnTokenRecord;
|
|
49
|
+
/**
|
|
50
|
+
* #1762 PR-C — the family holds this message's content and it is in no
|
|
51
|
+
* turn's input yet. Parked tokens do not block R3-4 and never report
|
|
52
|
+
* unended. Cleared only by `fold` or by an end.
|
|
53
|
+
*/
|
|
54
|
+
parked: boolean;
|
|
55
|
+
/** A non-eligible token reached 2 × TTL without an end, and that was reported. */
|
|
56
|
+
unendedReported?: boolean;
|
|
57
|
+
/** A `sendFile` under this token returned ok (the §4.4 prose check reads it). */
|
|
58
|
+
fileSent: boolean;
|
|
59
|
+
/** Failed file sends under this token, for the one notice per turn per conversation (§4.2). */
|
|
60
|
+
readonly failures: Array<{
|
|
61
|
+
filename?: string;
|
|
62
|
+
code: string;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
/** The longest family turn budget. A token is inactive after this even if `endTurn` never ran. */
|
|
66
|
+
export declare const TURN_TOKEN_TTL_MS: number;
|
|
67
|
+
export declare class TurnTokenRegistry {
|
|
68
|
+
private readonly now;
|
|
69
|
+
private readonly ttlMs;
|
|
70
|
+
/** Called once when a non-eligible token reaches 2 × TTL with no end (a family broke the contract). */
|
|
71
|
+
private readonly onUnended;
|
|
72
|
+
private readonly records;
|
|
73
|
+
/**
|
|
74
|
+
* Parked tokens pruned at expiry, id → lease key and eligibility. Their held
|
|
75
|
+
* content may still be folded into a turn later, and that fold must still
|
|
76
|
+
* downgrade it: an expired parked token is never a way to launder foreign
|
|
77
|
+
* text into an attested turn.
|
|
78
|
+
*/
|
|
79
|
+
private readonly parkedTombstones;
|
|
80
|
+
private seq;
|
|
81
|
+
constructor(now?: () => number, ttlMs?: number,
|
|
82
|
+
/** Called once when a non-eligible token reaches 2 × TTL with no end (a family broke the contract). */
|
|
83
|
+
onUnended?: (rec: TurnTokenRecord) => void);
|
|
84
|
+
/** The first claimant gets the lease; any later claim gets null. */
|
|
85
|
+
claim(token: TurnToken | null | undefined): TurnLease | null;
|
|
86
|
+
/** The record behind a lease, only if the lease is the token's real claim. */
|
|
87
|
+
leased(lease: TurnLease | null | undefined): TurnTokenRecord | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* The family folded `folded`'s message into `into`'s turn: `folded` now ends
|
|
90
|
+
* only when `into` ends, and a non-eligible message downgrades `into`.
|
|
91
|
+
*/
|
|
92
|
+
fold(folded: TurnLease | null | undefined, into: TurnLease | null | undefined): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* #1762 PR-C — the family declares it HOLDS this message's content and the
|
|
95
|
+
* content is in no turn's input yet. A parked non-eligible token no longer
|
|
96
|
+
* blocks R3-4 and never reports unended; it ends silently on a true drop
|
|
97
|
+
* (`endTurn`) or at expiry. Its content may enter a turn ONLY through `fold`
|
|
98
|
+
* (which downgrades the absorber). Lease only. Parking an ended or folded
|
|
99
|
+
* token is a no-op (returns false); nothing but fold or end un-parks.
|
|
100
|
+
*/
|
|
101
|
+
park(lease: TurnLease | null | undefined): boolean;
|
|
102
|
+
/** A fold of a parked token that expired and was pruned: the absorber is still downgraded. */
|
|
103
|
+
private foldExpiredParked;
|
|
104
|
+
mintDm(from: {
|
|
105
|
+
convId?: string;
|
|
106
|
+
groupId?: string;
|
|
107
|
+
}): TurnToken;
|
|
108
|
+
mintRoom(from: {
|
|
109
|
+
roomId: string;
|
|
110
|
+
eligible: boolean;
|
|
111
|
+
}): TurnToken;
|
|
112
|
+
/**
|
|
113
|
+
* The live record for a token, or `undefined` for a token this registry did
|
|
114
|
+
* not mint (a forged `{ id }` resolves to nothing). A token past its TTL is
|
|
115
|
+
* returned INACTIVE — it is never revived.
|
|
116
|
+
*/
|
|
117
|
+
get(token: TurnToken | null | undefined): TurnTokenRecord | undefined;
|
|
118
|
+
isActive(token: TurnToken | null | undefined): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* The family positively attests a clean owner turn in a room (N3): the turn
|
|
121
|
+
* that runs this message carries no other member's words. Accepted only for
|
|
122
|
+
* an eligible, active, not-downgraded room token — and refused while any
|
|
123
|
+
* NON-ELIGIBLE token for that room minted BEFORE it is still active: that
|
|
124
|
+
* message may still be waiting in a family queue to be folded into this
|
|
125
|
+
* turn (R3-4). It stops blocking when the family ends it (ran, dropped or
|
|
126
|
+
* folded it) or at its TTL.
|
|
127
|
+
*/
|
|
128
|
+
attestCleanTurn(lease: TurnLease | null | undefined): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Decrypted APPLICATION content arrived in a room (N2). A non-eligible one
|
|
131
|
+
* downgrades every active token for that room, for good, whatever the family
|
|
132
|
+
* does with the message — folds it into a running turn, queues it, drops it.
|
|
133
|
+
* Call BEFORE minting the arriving message's own token.
|
|
134
|
+
*/
|
|
135
|
+
noteRoomArrival(roomId: string, eligible: boolean): void;
|
|
136
|
+
/**
|
|
137
|
+
* The claimant ends the turn (or drops the message): the token stops
|
|
138
|
+
* authorizing anything and stops blocking R3-4. Only the token's lease can
|
|
139
|
+
* do it. Returns the record the FIRST time; `undefined` for a second end, a
|
|
140
|
+
* wrong or missing lease, or a folded token whose absorbing turn is still
|
|
141
|
+
* running (it ends with that turn). Ending a turn ends what was folded in.
|
|
142
|
+
*/
|
|
143
|
+
endTurn(lease: TurnLease | null | undefined): TurnTokenRecord | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* SecureChannel's own end for a token no family will run: no lease is used
|
|
146
|
+
* or handed out, the reason is recorded (sendFile answers
|
|
147
|
+
* `turn_no_consumer`), and an ended token is never reported as unended.
|
|
148
|
+
*/
|
|
149
|
+
dropUnowned(token: TurnToken | null | undefined, reason: TurnDropReason): void;
|
|
150
|
+
private finish;
|
|
151
|
+
/**
|
|
152
|
+
* Still blocks R3-4: not ended, and inside 2 × TTL. The turn budget (TTL)
|
|
153
|
+
* lapsing while the message is still queued does NOT unblock it. At 2 × TTL
|
|
154
|
+
* a never-ended token is reported once as a contract violation.
|
|
155
|
+
*/
|
|
156
|
+
private pending;
|
|
157
|
+
private reportUnended;
|
|
158
|
+
private mint;
|
|
159
|
+
/**
|
|
160
|
+
* Forget tokens past 2 × TTL, and cap the map. A LIVE non-eligible token
|
|
161
|
+
* (not ended, inside 2 × TTL) is never evicted: dropping it would silently
|
|
162
|
+
* unblock R3-4. Such tokens may push the map past the cap; they leave by
|
|
163
|
+
* ending or by 2 × TTL.
|
|
164
|
+
*/
|
|
165
|
+
private prune;
|
|
166
|
+
private tombstone;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=turn-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-token.d.ts","sourceRoot":"","sources":["../src/turn-token.ts"],"names":[],"mappings":"AA0CA,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAE/E,oFAAoF;AACpF,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1C,wEAAwE;AACxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,yFAAyF;IACzF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,oFAAoF;IACpF,SAAS,EAAE,OAAO,CAAC;IACnB,yFAAyF;IACzF,UAAU,EAAE,OAAO,CAAC;IACpB,2FAA2F;IAC3F,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,KAAK,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,SAAS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
|
3
|
+
/**
|
|
4
|
+
* #1762 — turns agent file sending ON. Absent (the default), SecureChannel
|
|
5
|
+
* creates no staging folder and writes nothing to disk for it, and
|
|
6
|
+
* `sendFile` answers `file_send_disabled`. A family sets it when it wires a
|
|
7
|
+
* file-send tool. `workspaceDir` is the agent's workspace, if it has one: a
|
|
8
|
+
* 1:1 root (minus `agentvault-outbox/`) that holds the outbox
|
|
9
|
+
* (`<workspace>/agentvault-outbox/<agentName>/`) so a workspace-confined
|
|
10
|
+
* worker can stage files. It is refused as a root if it is `/` or $HOME,
|
|
11
|
+
* contains the data dir or a protected folder, or sits in a credential folder.
|
|
12
|
+
*/
|
|
13
|
+
fileSend?: {
|
|
14
|
+
workspaceDir?: string;
|
|
15
|
+
};
|
|
3
16
|
/** Optional enrollment framework assertion; omitted by legacy clients. */
|
|
4
17
|
expectedFramework?: string;
|
|
5
18
|
dataDir: string;
|
|
@@ -23,6 +36,10 @@ export interface SecureChannelConfig {
|
|
|
23
36
|
* Local HTTP port (127.0.0.1 only) for proactive sends — POST /send,
|
|
24
37
|
* /decision, /action, GET /status, /targets. When set, start() opens it once
|
|
25
38
|
* the channel is ready (equivalent to calling startHttpServer(port)).
|
|
39
|
+
* #1791: every request must send the `X-AgentVault-Local-Token` header
|
|
40
|
+
* (the contents of `<dataDir>/local-api.token`, a 0600 file created at
|
|
41
|
+
* start), no `Origin` header, and a `Host` of `127.0.0.1:<port>` (call it as http://127.0.0.1:<port>,
|
|
42
|
+
* not localhost). Bodies are capped at 64 KB.
|
|
26
43
|
* Default: none.
|
|
27
44
|
*/
|
|
28
45
|
httpPort?: number;
|
|
@@ -90,20 +107,77 @@ export interface MessageMetadata {
|
|
|
90
107
|
roomId?: string;
|
|
91
108
|
/**
|
|
92
109
|
* The owner's answer to a decision_request this message carries (an option
|
|
93
|
-
* selected, or action defer / cancel). Set by
|
|
110
|
+
* selected, or action defer / cancel). Set by the MLS 1:1 receive path;
|
|
94
111
|
* `messageType` is then "decision_response". waitForDecision() reads it.
|
|
112
|
+
* #1836: never set over Double Ratchet, which refuses decision answers.
|
|
95
113
|
*/
|
|
96
114
|
decision?: DecisionResponse;
|
|
97
115
|
/**
|
|
98
116
|
* #621 — POSITIVE assertion that this message decrypted under the owner's 1:1
|
|
99
|
-
* material: an MLS group found in the `1to1-group:` map
|
|
100
|
-
*
|
|
117
|
+
* material: an MLS group found in the `1to1-group:` map. Never set over
|
|
118
|
+
* Double Ratchet (#1836), which has no owner verdict. Consumers key owner
|
|
119
|
+
* power on it: the bridges' full-access DM lane, and OpenClaw's
|
|
120
|
+
* `CommandAuthorized` for a 1:1 (#1836). #1800 PR B: set only when the
|
|
121
|
+
* frame's claimed sender is BOUND to its MLS sender; OpenClaw routes every
|
|
122
|
+
* other 1:1 (and DR) to its own unverified session. The bridge lane requires this rather than
|
|
101
123
|
* inferring 1:1 from the ABSENCE of `roomId`, so a future emit site that
|
|
102
124
|
* forgets to set it lands on the locked listener instead of an open shell.
|
|
125
|
+
*
|
|
126
|
+
* #1807: every emit site that sets this MUST also set `caption` to the text
|
|
127
|
+
* the owner TYPED (before any attachment fold). The grok bridge keeps `@`
|
|
128
|
+
* file references only in that caption; a path that omits it gets the
|
|
129
|
+
* owner's references neutralized — safe, but surprising to the owner.
|
|
103
130
|
*/
|
|
104
131
|
ownerDm1to1?: boolean;
|
|
105
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Device ID of the sender. #1800 PR B: only ever the BOUND sender — the
|
|
134
|
+
* server's claimed `sender_device_id` after it matched the frame's MLS
|
|
135
|
+
* sender (`senderBinding === "bound"`). Absent for every unbound frame
|
|
136
|
+
* (room or 1:1) and for Double Ratchet: no sink, and no owner-list re-check
|
|
137
|
+
* (#1820 part 2), may key on the wire's claim.
|
|
138
|
+
*/
|
|
106
139
|
senderDeviceId?: string;
|
|
140
|
+
/**
|
|
141
|
+
* #1800 PR B — the §3.1 verdict for this frame's claimed sender. `"bound"`
|
|
142
|
+
* is the only value that may carry owner power; Double Ratchet is
|
|
143
|
+
* `"unavailable"` (reason `"dr"`). A family gates owner power on
|
|
144
|
+
* `senderBinding === "bound"` as well as on its owner flag. #1855: a room
|
|
145
|
+
* consumer passes it to `owesRoomReply` as the 9th argument, which refuses
|
|
146
|
+
* @all / @everyone unless it is `"bound"`.
|
|
147
|
+
*/
|
|
148
|
+
senderBinding?: "bound" | "mismatch" | "duplicate" | "unavailable";
|
|
149
|
+
/** #1800 PR B — why the frame is not bound (`mismatch`, `duplicate`, or the `unavailable` reason). */
|
|
150
|
+
senderBindingReason?: string;
|
|
151
|
+
/**
|
|
152
|
+
* #1800 PR B — the server's claimed sender of an UNBOUND frame, sanitized to
|
|
153
|
+
* `[0-9a-f-]`, for display as "unverified" only. Never an identity.
|
|
154
|
+
*/
|
|
155
|
+
claimedSenderDeviceId?: string;
|
|
156
|
+
/**
|
|
157
|
+
* #1820 part 2 — 1:1 only: the sender was one of the account's CURRENT owner
|
|
158
|
+
* devices when the channel handed this message over (a fresh, fail-closed
|
|
159
|
+
* owner-list read; false while a re-read is pending or failed). On the
|
|
160
|
+
* attested 1:1 paths `ownerDm1to1` equals it. #1800 PR B: read for the
|
|
161
|
+
* BOUND sender only; false on every unbound frame and on Double Ratchet.
|
|
162
|
+
*/
|
|
163
|
+
senderIsOwnerDevice?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* #1826 review M3 — 1:1 only: why `senderIsOwnerDevice` is what it is.
|
|
166
|
+
* `"not_owner"` is confirmed by a fresh owner-list read; `"unknown"` means
|
|
167
|
+
* the channel could not confirm (a failed/timed-out read, e.g. a backend
|
|
168
|
+
* deploy). Neither is the owner. A family may spare an `"unknown"` turn
|
|
169
|
+
* lasting taint, never give it owner power. #1800 PR B: an unbound frame
|
|
170
|
+
* (and Double Ratchet) is always `"not_owner"` — never `"unknown"`, so no
|
|
171
|
+
* family re-checks it at release.
|
|
172
|
+
*/
|
|
173
|
+
senderOwnerStatus?: "owner" | "not_owner" | "unknown";
|
|
174
|
+
/**
|
|
175
|
+
* #1820 part 2 — 1:1 only: the channel's owner-list generation when
|
|
176
|
+
* `senderIsOwnerDevice` was decided. A family that holds the turn compares
|
|
177
|
+
* it with `channel.ownerDevicesGeneration()` at release and, when they
|
|
178
|
+
* differ, re-checks with `channel.isCurrentOwnerDevice(senderDeviceId)`.
|
|
179
|
+
*/
|
|
180
|
+
ownerDevicesGen?: number;
|
|
107
181
|
/** Whether the sender is an agent (vs owner) — room messages only */
|
|
108
182
|
senderIsAgent?: boolean;
|
|
109
183
|
/**
|
|
@@ -126,8 +200,10 @@ export interface MessageMetadata {
|
|
|
126
200
|
* #1223 — the text the sender TYPED, before any attachment was folded into
|
|
127
201
|
* the plaintext (`_augmentWithAttachment` prepends a banner + the file's
|
|
128
202
|
* contents). The @ gate must read THIS, never the folded text: a pasted chat
|
|
129
|
-
* log containing "@wren" is not an address.
|
|
130
|
-
* emitters older than 0.23.42, so consumers fall back to the plaintext
|
|
203
|
+
* log containing "@wren" is not an address. Set on room messages (absent on
|
|
204
|
+
* emitters older than 0.23.42, so consumers fall back to the plaintext), on
|
|
205
|
+
* the Double Ratchet `message` path, and (#1807) on the MLS owner 1:1, where
|
|
206
|
+
* a bridge keeps `@` file references in this typed text only.
|
|
131
207
|
*/
|
|
132
208
|
caption?: string;
|
|
133
209
|
/**
|
|
@@ -137,6 +213,25 @@ export interface MessageMetadata {
|
|
|
137
213
|
* messages only; pass it as `owesRoomReply`'s 8th argument.
|
|
138
214
|
*/
|
|
139
215
|
roomAudience?: "private_pair" | "group";
|
|
216
|
+
/**
|
|
217
|
+
* #1762 — the authority for a file send made on this message's turn (design
|
|
218
|
+
* §1.4). Opaque: minted by SecureChannel from the decrypt and the roster;
|
|
219
|
+
* pass it back to `sendFile` / `attestCleanTurn` / `endTurn` unchanged.
|
|
220
|
+
*/
|
|
221
|
+
turnToken?: import("./turn-token.js").TurnToken;
|
|
222
|
+
/**
|
|
223
|
+
* #1762 (round 3, item 3) — the capability to attest, end or fold this turn.
|
|
224
|
+
* Present ONLY in the metadata `onMessage` receives (the single consumer),
|
|
225
|
+
* never on the `message` / `room_message` events.
|
|
226
|
+
*/
|
|
227
|
+
turnLease?: import("./turn-token.js").TurnLease;
|
|
228
|
+
/**
|
|
229
|
+
* #1782 (round 1, item 2a) — rooms: the message text WITHOUT the "[Name]: "
|
|
230
|
+
* prefix the `onMessage` text argument carries, exactly `room_message`'s
|
|
231
|
+
* `plaintext`. With it, `onMessage` metadata carries every gating field
|
|
232
|
+
* `room_message` does, so a bridge drives its turns from `onMessage` alone.
|
|
233
|
+
*/
|
|
234
|
+
plaintext?: string;
|
|
140
235
|
/** Set when this message is a coordinator task (AES job dispatch) */
|
|
141
236
|
coordinatorTask?: boolean;
|
|
142
237
|
/** Coordinator job ID */
|
|
@@ -211,7 +306,35 @@ export interface HistoryEntry {
|
|
|
211
306
|
text: string;
|
|
212
307
|
ts: string;
|
|
213
308
|
topicId?: string;
|
|
309
|
+
/**
|
|
310
|
+
* #1762 (design §1.5) — files the agent SENT with this entry, written only
|
|
311
|
+
* after a frame was written. Returned by the history getters; stored beside
|
|
312
|
+
* the entry (`PersistedState.historyFiles`), never inside it, so the
|
|
313
|
+
* encrypted history backup's entry format is unchanged. Render it with
|
|
314
|
+
* `renderHistoryFiles` as a line the model cannot forge.
|
|
315
|
+
*/
|
|
316
|
+
files?: Array<{
|
|
317
|
+
filename: string;
|
|
318
|
+
size: number;
|
|
319
|
+
}>;
|
|
214
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* #1800 PR B — a history entry as the read APIs return it
|
|
323
|
+
* (`getRoomHistory`, `getConversationHistory`): an entry recorded from an
|
|
324
|
+
* UNBOUND sender (an unverified MLS frame, or Double Ratchet) reads
|
|
325
|
+
* `sender: "unverified"`, never `"owner"`, so no seed or prompt renders it as
|
|
326
|
+
* the owner's words. Stored as `"owner"` plus `PersistedState.historyUnverified`.
|
|
327
|
+
*
|
|
328
|
+
* #1848 review — a ROOM or 1:1 entry not written by this agent reads `"owner"`
|
|
329
|
+
* only when it came from the bound owner (`PersistedState.historyOwner`): in a
|
|
330
|
+
* room, a bound human in this agent's own account; in a 1:1, a bound current
|
|
331
|
+
* owner device. Every other such entry (another account's person, another
|
|
332
|
+
* agent, a bound 1:1 device that is not a current owner device, an entry
|
|
333
|
+
* restored from a backup or written before the flag) reads `"member"`.
|
|
334
|
+
*/
|
|
335
|
+
export type HistoryReadEntry = Omit<HistoryEntry, "sender"> & {
|
|
336
|
+
sender: HistoryEntry["sender"] | "unverified" | "member";
|
|
337
|
+
};
|
|
215
338
|
export interface DeviceSession {
|
|
216
339
|
ownerDeviceId: string;
|
|
217
340
|
ratchetState: string;
|
|
@@ -235,6 +358,27 @@ export interface PersistedState {
|
|
|
235
358
|
lastMessageTimestamp?: string;
|
|
236
359
|
messageHistory?: HistoryEntry[];
|
|
237
360
|
historyBackupSalt?: string;
|
|
361
|
+
/** #1762 — `HistoryEntry.files` by entry id, for entries still in `messageHistory`. */
|
|
362
|
+
historyFiles?: Record<string, Array<{
|
|
363
|
+
filename: string;
|
|
364
|
+
size: number;
|
|
365
|
+
}>>;
|
|
366
|
+
/**
|
|
367
|
+
* #1800 PR B — ids of `messageHistory` entries recorded from an UNBOUND
|
|
368
|
+
* sender (`unverified: true`). Kept beside the entry, like `historyFiles`,
|
|
369
|
+
* because the encrypted history archive's validator rejects any unknown entry
|
|
370
|
+
* key; these entries are also left out of the backup, so a restore can never
|
|
371
|
+
* bring one back as the owner's.
|
|
372
|
+
*/
|
|
373
|
+
historyUnverified?: Record<string, true>;
|
|
374
|
+
/**
|
|
375
|
+
* #1848 review — ids of room and 1:1 `messageHistory` entries recorded from
|
|
376
|
+
* the bound OWNER (room: a bound human in this agent's own account; 1:1: a
|
|
377
|
+
* bound current owner device). Kept beside the entry like
|
|
378
|
+
* `historyUnverified`. Not backed up: a restored entry reads `"member"` (a
|
|
379
|
+
* downgrade, never an owner claim).
|
|
380
|
+
*/
|
|
381
|
+
historyOwner?: Record<string, true>;
|
|
238
382
|
restoredHistoryGenerationId?: string;
|
|
239
383
|
historyRecoveryState?: "pending" | "complete";
|
|
240
384
|
/**
|
|
@@ -327,6 +471,14 @@ export interface PersistedState {
|
|
|
327
471
|
}>;
|
|
328
472
|
/** Maps conversationId → conversation.group_id for shared MLS group lookup on reconnect */
|
|
329
473
|
conversationGroupIds?: Record<string, string>;
|
|
474
|
+
/**
|
|
475
|
+
* #1800 PR C — Tier 1 pins: the MLS group each 1:1 routing key is bound to,
|
|
476
|
+
* keyed `cg:<conversationGroupId>` / `conv:<conversationId>`. Separate from
|
|
477
|
+
* `mlsGroups` / `mlsConversations` on purpose: the #1034 reconcile prune and
|
|
478
|
+
* the `conversation deleted` prune delete mappings, and a pruned key's pin
|
|
479
|
+
* stays as a tombstone. Never removed short of a full re-enrolment.
|
|
480
|
+
*/
|
|
481
|
+
dmGroupPins?: Record<string, string>;
|
|
330
482
|
}
|
|
331
483
|
/** Legacy state format for backward compatibility */
|
|
332
484
|
export interface LegacyPersistedState {
|
|
@@ -353,6 +505,10 @@ export interface RoomMemberInfo {
|
|
|
353
505
|
ephemeralPublicKey?: string;
|
|
354
506
|
/** #1459 — the member device's own account, as the server reports it. */
|
|
355
507
|
tenantId?: string;
|
|
508
|
+
/** #1803 — the server reports this member's DEVICE as revoked (its row stays). Never the owner. */
|
|
509
|
+
deviceRevoked?: boolean;
|
|
510
|
+
/** #1803 — `false` when the server reports this member's DEVICE as not ACTIVE (e.g. suspended). Never the owner. */
|
|
511
|
+
deviceActive?: boolean;
|
|
356
512
|
}
|
|
357
513
|
export interface RoomConversationInfo {
|
|
358
514
|
id: string;
|