@agentvault/agentvault 0.23.71 → 0.23.72
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 +675 -44
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +8162 -2403
- 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 +8653 -2417
- 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 +32 -2
- package/dist/openclaw-entry.d.ts.map +1 -1
- package/dist/openclaw-entry.js +1377 -171
- 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-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 +160 -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/channel.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
import { type OwnerDeviceStatus } from "./owner-devices.js";
|
|
1
2
|
import { EventEmitter } from "node:events";
|
|
2
3
|
import { TelemetryReporter } from "@agentvault/crypto";
|
|
3
|
-
import
|
|
4
|
+
import { type TurnLease, type TurnToken } from "./turn-token.js";
|
|
5
|
+
import { type FileSendHostOptions, type FileSendTarget } from "./file-send-policy.js";
|
|
6
|
+
import { type FileSendResult } from "./file-send-failure.js";
|
|
7
|
+
import type { SecureChannelConfig, ChannelState, PersistedState, HistoryReadEntry, SendOptions, OwnerAudience, DecisionRequest, DecisionResponse, HeartbeatStatus, StatusAlert, RoomMemberInfo, RoomConversationInfo, RoomInfo, A2AChannel, DeliveryTarget, DeliveryContent, DeliveryOptions, DeliveryReceipt, TargetInfo } from "./types.js";
|
|
4
8
|
import { messageKindFor } from "./message-kind.js";
|
|
9
|
+
import { type LocalApiRefusal } from "./local-api.js";
|
|
10
|
+
import { type OffSequenceCallback } from "./full-permissions.js";
|
|
5
11
|
export { messageKindFor };
|
|
12
|
+
/** #1762 — the outcome of the authority check (design §1.2 step 1). */
|
|
13
|
+
export type TurnAuthority = {
|
|
14
|
+
ok: true;
|
|
15
|
+
via?: "effective";
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
code: "room_file_not_permitted" | "file_target_mismatch" | "no_conversation_ready" | "turn_ended" | "turn_no_consumer";
|
|
19
|
+
};
|
|
6
20
|
/**
|
|
7
21
|
* #1418 — where an owner-bound helper (decision, alert, artifact, attachment…)
|
|
8
22
|
* sends. A `conversationId` names the person; without one it goes to the
|
|
@@ -31,10 +45,20 @@ interface InternalSendOptions extends SendOptions {
|
|
|
31
45
|
*/
|
|
32
46
|
bypassMlsHold?: boolean;
|
|
33
47
|
/**
|
|
34
|
-
* #1771: never put this send in the in-memory re-seal queue. Set
|
|
35
|
-
* LOST notice
|
|
48
|
+
* #1771: never put this send in the in-memory re-seal queue. Set on the
|
|
49
|
+
* #1771 LOST notice and on #1762 file notices, so a notice that cannot go
|
|
50
|
+
* out cannot queue another. It covers ONLY the re-seal queue: a Double
|
|
51
|
+
* Ratchet copy still goes to the offline queue, and an MLS send to a group
|
|
52
|
+
* awaiting its Welcome still waits in the #952 hold.
|
|
36
53
|
*/
|
|
37
54
|
noReseal?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* #1782 (round 1, item 5): a file notice is sent NOW or not at all, like the
|
|
57
|
+
* file it is about ("files never queue"). No #952 hold, no Double Ratchet
|
|
58
|
+
* offline queue, no re-seal; each destination dropped calls `onNotQueued`.
|
|
59
|
+
*/
|
|
60
|
+
noQueue?: boolean;
|
|
61
|
+
onNotQueued?: () => void;
|
|
38
62
|
}
|
|
39
63
|
export declare function migrateDefaultTopics(state: PersistedState): PersistedState;
|
|
40
64
|
export declare function migratePersistedState(raw: any): PersistedState;
|
|
@@ -54,6 +78,14 @@ export declare function _isSelfHubAddress(ownHubAddress: string, target: string)
|
|
|
54
78
|
* value always wins.
|
|
55
79
|
*/
|
|
56
80
|
export declare function keepKnownMemberTenants(previous: readonly RoomMemberInfo[], next: readonly RoomMemberInfo[]): RoomMemberInfo[];
|
|
81
|
+
/**
|
|
82
|
+
* #1803 — carry a member's `deviceRevoked` / `deviceActive: false` across a
|
|
83
|
+
* roster replacement whose payload omits them (a `room_joined` frame). Errs
|
|
84
|
+
* closed: a flag kept here only ever denies owner power, and the replacement
|
|
85
|
+
* also drops the room's owner trust, so the next message re-reads the
|
|
86
|
+
* authoritative values. A payload that carries a value always wins.
|
|
87
|
+
*/
|
|
88
|
+
export declare function keepKnownDeviceFlags(previous: readonly RoomMemberInfo[], next: readonly RoomMemberInfo[]): RoomMemberInfo[];
|
|
57
89
|
export declare class SecureChannel extends EventEmitter {
|
|
58
90
|
private config;
|
|
59
91
|
private _state;
|
|
@@ -77,9 +109,36 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
77
109
|
private _ownDisplayName;
|
|
78
110
|
private _resolvingOwnDisplayName;
|
|
79
111
|
private _httpServer;
|
|
112
|
+
/** #1791: the local API token, read or created once per process. */
|
|
113
|
+
private _localApiToken;
|
|
114
|
+
private _localApiPort;
|
|
115
|
+
/** #1791 review M1: the [::1]:<port> listener, so nobody can squat `localhost`. */
|
|
116
|
+
private _httpServer6;
|
|
117
|
+
/** #1791 review L2: when the token file last failed its checks. */
|
|
118
|
+
private _localApiTokenFailedAt;
|
|
119
|
+
private _localApiRefusals;
|
|
80
120
|
private _mcpServer;
|
|
81
121
|
private _pollFallbackTimer;
|
|
82
122
|
private _heartbeatTimer;
|
|
123
|
+
/**
|
|
124
|
+
* #1762 PR-P1c-1: the Full permissions tri-state. Internal to the plugin
|
|
125
|
+
* core — families read only `effective()` and register `onOffSequence`
|
|
126
|
+
* (design doc §13.1). See full-permissions.ts. Built in the constructor
|
|
127
|
+
* body, not as a field initializer, so it receives `config.dataDir` (for
|
|
128
|
+
* PR-P1c-2's `was_effective` marker, read when the core is constructed).
|
|
129
|
+
*/
|
|
130
|
+
private readonly _fullPermissions;
|
|
131
|
+
/**
|
|
132
|
+
* #1762 PR-P1c-2: the on-turn processes of this agent (§13.13 step 2) — the
|
|
133
|
+
* roots families register, the groups recorded under them, the `AV_ONTURN`
|
|
134
|
+
* nonce. Shared per data dir, so a reloaded channel still finds the
|
|
135
|
+
* on-turns started under the old one. See onturn-stop.ts.
|
|
136
|
+
*/
|
|
137
|
+
private readonly _onTurns;
|
|
138
|
+
/** #1762 PR-P1c-2: the last on period whose failed stop was told to the owner (one notice per period). */
|
|
139
|
+
private _offFailNoticePeriod;
|
|
140
|
+
/** #1762 PR-P1c-2 (review M1): a failed stop that could not be told yet (relay down): told at the next "ready". */
|
|
141
|
+
private _offFailNoticePending;
|
|
83
142
|
private _heartbeatCallback;
|
|
84
143
|
private _heartbeatIntervalSeconds;
|
|
85
144
|
/** #798: report the A2A channel set only when it CHANGES. This line polls
|
|
@@ -129,6 +188,12 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
129
188
|
private _roomFulfilCooldown;
|
|
130
189
|
/** #1428: per (group, device) KeyPackage backoff for the pending-Welcome pulls. */
|
|
131
190
|
private _welcomeKpBackoff;
|
|
191
|
+
/** #1800 PR C: in-memory security counters (`name{reason}` → count). */
|
|
192
|
+
private _securityCounters;
|
|
193
|
+
/** #1800 PR C / §3.4: per-conversation + global notice rate limit. */
|
|
194
|
+
private _securityNoticeLimiter;
|
|
195
|
+
/** #1800 PR C (review LOW 3): per (group, device) backoff after a KeyPackage identity mismatch. */
|
|
196
|
+
private _kpIdentityBackoff;
|
|
132
197
|
/** Maps conversationId -> conversation_group_id for shared 1:1 MLS groups */
|
|
133
198
|
private _sessionGroupIds;
|
|
134
199
|
/** Consecutive MLS decrypt failure count per group key for epoch recovery. */
|
|
@@ -214,9 +279,25 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
214
279
|
/** In-memory credential store for renter-provided credentials (never persisted). */
|
|
215
280
|
private _credentialStore;
|
|
216
281
|
/** Rooms whose roster has been refreshed from the backend at least once in
|
|
217
|
-
* this process (GH #366). Cleared on (re)join so the next
|
|
218
|
-
* re-fetches the authoritative roster. Prevents per-message
|
|
282
|
+
* this process (GH #366), and when. Cleared on (re)join so the next
|
|
283
|
+
* first message re-fetches the authoritative roster. Prevents per-message
|
|
284
|
+
* refetch storms. #1803: only a roster in here, and younger than
|
|
285
|
+
* ROOM_ROSTER_OWNER_MAX_AGE_MS, may name the owner; `owner_devices_changed`
|
|
286
|
+
* and every (re)connect clear it for every room. */
|
|
219
287
|
private _roomRosterRefreshed;
|
|
288
|
+
/**
|
|
289
|
+
* #1803 — bumped by every owner-roster invalidation. `_refreshRoomRoster`
|
|
290
|
+
* captures it before its GET; a body that lands after a bump may predate a
|
|
291
|
+
* revoke, so it does not mark the roster trusted. Never persisted.
|
|
292
|
+
*/
|
|
293
|
+
private _ownerRosterGen;
|
|
294
|
+
/**
|
|
295
|
+
* #1820 part 2 — the account's CURRENT owner devices, for the 1:1 lane.
|
|
296
|
+
* Every 1:1 emit site asks it when it hands a message over (release time),
|
|
297
|
+
* so a message a since-revoked device sent is never `ownerDm1to1`. Dropped
|
|
298
|
+
* with the rosters on `owner_devices_changed` and every (re)connect.
|
|
299
|
+
*/
|
|
300
|
+
private _ownerDevices;
|
|
220
301
|
/**
|
|
221
302
|
* #1181: the last attachment saved per room, so the NEXT room turn can name
|
|
222
303
|
* it. wren saved an un-mentioned file (no reply, #1107), was asked "@wren can
|
|
@@ -316,6 +397,26 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
316
397
|
private _lastInboundDm;
|
|
317
398
|
/** #1418: turns in progress (`runForConversation`). */
|
|
318
399
|
private _activeTurns;
|
|
400
|
+
/**
|
|
401
|
+
* #1762 (design §1.4) — every turn token this channel minted. A non-eligible
|
|
402
|
+
* token that reaches 2 × TTL with no end is a family contract violation: it
|
|
403
|
+
* is reported as a span (visible in room 007's telemetry) and stops blocking.
|
|
404
|
+
*/
|
|
405
|
+
private _turnTokens;
|
|
406
|
+
/** #1762 (design §3) — the file-send path policy and its staging folders. Created once, at start. */
|
|
407
|
+
private _fileSendPolicy;
|
|
408
|
+
/** #1762 — turns whose end-of-turn file checks already ran (endTurn is idempotent). */
|
|
409
|
+
private _turnsChecked;
|
|
410
|
+
/** #1762 (§6.3) — set by `503 {error: agent_uploads_disabled}` only (N9). */
|
|
411
|
+
private _fileSendDisabledUntil;
|
|
412
|
+
/** #1762 (M6) — ok file sends, by SHA-256(bytes) + target + caption. Recorded only after ok. */
|
|
413
|
+
private _fileSendDedupe;
|
|
414
|
+
/**
|
|
415
|
+
* #1762 (M7, review F) — 1:1 file sends just written, by their
|
|
416
|
+
* client_message_id, until the server acks or refuses them (or the window
|
|
417
|
+
* passes). The server echoes the id on a refusal, so only THAT file is named.
|
|
418
|
+
*/
|
|
419
|
+
private _pendingFileFrames;
|
|
319
420
|
/**
|
|
320
421
|
* #1418: recent owner 1:1 messages that decrypted, keyed by
|
|
321
422
|
* conversation|group — evidence of which conversation, group and browser
|
|
@@ -574,6 +675,176 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
574
675
|
runForConversation<T>(conversationId: string | undefined, fn: () => Promise<T>, opts?: {
|
|
575
676
|
groupId?: string;
|
|
576
677
|
}): Promise<T>;
|
|
678
|
+
/**
|
|
679
|
+
* The family attests that the turn running `token`'s room message carries no
|
|
680
|
+
* other member's words (N3). Room tokens are minted with `ownerTurn = false`;
|
|
681
|
+
* this is the only way to raise it, and it succeeds only for a token whose
|
|
682
|
+
* sender was this agent's own owner, with no foreign content, still active,
|
|
683
|
+
* never downgraded, and with no non-eligible arrival in the room since the
|
|
684
|
+
* last turn there ended (R3-4). Call it from the SAME variable that decides
|
|
685
|
+
* whether room context is attached. A family that never calls it gets room
|
|
686
|
+
* files refused — the safe failure. Takes the LEASE (`metadata.turnLease`
|
|
687
|
+
* from `onMessage`), never the bare token: a listener holding only the
|
|
688
|
+
* token cannot attest.
|
|
689
|
+
*/
|
|
690
|
+
attestCleanTurn(lease: TurnLease | null | undefined): boolean;
|
|
691
|
+
/**
|
|
692
|
+
* The turn is over (or the message was dropped): the token stops
|
|
693
|
+
* authorizing anything, immediately. Only the token's lease can end it. Call
|
|
694
|
+
* it in a `finally` around the whole turn (held-payload releases included).
|
|
695
|
+
* A folded token ends with the turn that absorbed it.
|
|
696
|
+
*/
|
|
697
|
+
endTurn(lease: TurnLease | null | undefined, opts?: {
|
|
698
|
+
replies?: readonly string[];
|
|
699
|
+
}): Promise<void>;
|
|
700
|
+
/**
|
|
701
|
+
* The family folded `folded`'s message into the running turn `into`: the
|
|
702
|
+
* folded token ends only when `into` ends, and folding a non-eligible
|
|
703
|
+
* message downgrades `into` (it now carries another member's words).
|
|
704
|
+
*/
|
|
705
|
+
foldTurn(folded: TurnLease | null | undefined, into: TurnLease | null | undefined): boolean;
|
|
706
|
+
/**
|
|
707
|
+
* #1762 PR-C — the family HOLDS this message's content (e.g. the claude
|
|
708
|
+
* bridge's room context) and it is in no turn's input yet. A parked foreign
|
|
709
|
+
* token does not block `attestCleanTurn` and never reports unended; it ends
|
|
710
|
+
* on a true drop (`endTurn`) or at expiry. The content may then enter a turn
|
|
711
|
+
* ONLY through `foldTurn`, which downgrades that turn. Lease only.
|
|
712
|
+
*/
|
|
713
|
+
parkTurn(lease: TurnLease | null | undefined): boolean;
|
|
714
|
+
/**
|
|
715
|
+
* #1762 (round 3, item 3) — a null or malformed lease reaching attest/end/
|
|
716
|
+
* fold means the family's wiring did not take `metadata.turnLease` from
|
|
717
|
+
* `onMessage`: a contract violation, reported as a span (not a log line).
|
|
718
|
+
*/
|
|
719
|
+
private _leaseShaped;
|
|
720
|
+
/**
|
|
721
|
+
* #1762 (round 3, item 3) — leases claimed AT MINT, waiting for their one
|
|
722
|
+
* hand-off to `onMessage`. Bounded: a mint whose hand-off never ran (a
|
|
723
|
+
* throw between them) is forgotten oldest-first, and its token ends at TTL.
|
|
724
|
+
*/
|
|
725
|
+
private _mintedLeases;
|
|
726
|
+
private _claimAtMint;
|
|
727
|
+
/**
|
|
728
|
+
* #1782 (round 1, item 9): something threw between mint and hand-off (a
|
|
729
|
+
* `message`/`room_message` listener, a history write). Nobody will run this
|
|
730
|
+
* turn: end it as a drop so its lease cannot leak and block R3-4.
|
|
731
|
+
*/
|
|
732
|
+
private _dropMinted;
|
|
733
|
+
/** #1836 — run a Double Ratchet turn's hand-off inside the DR marker (see `_drTurnStore`). */
|
|
734
|
+
private _runAsDrTurn;
|
|
735
|
+
/**
|
|
736
|
+
* #1800 PR B (obligation 1) — run `fn` inside the non-owner marker
|
|
737
|
+
* (`_drTurnStore`): no turnless file authority anywhere in its call chain.
|
|
738
|
+
* Public so a family can RE-ASSERT it where a turn resumes in a fresh async
|
|
739
|
+
* context — OpenClaw's `handleInbound` does, because a message queued before
|
|
740
|
+
* the runtime was ready is drained by `_setRuntime` outside the hand-off's
|
|
741
|
+
* context (the same reason the turn token is re-asserted there). The marker
|
|
742
|
+
* only refuses; it never grants.
|
|
743
|
+
*/
|
|
744
|
+
runAsNonOwnerTurn<T>(fn: () => T): T;
|
|
745
|
+
/** #1800 PR B — is this call chain inside a non-owner turn (`runAsNonOwnerTurn` / `_runAsDrTurn`)? @internal */
|
|
746
|
+
inNonOwnerTurn(): boolean;
|
|
747
|
+
/** Emit a turn's event; a synchronous throw from a listener drops the minted token (item 9). */
|
|
748
|
+
private _emitTurnEvent;
|
|
749
|
+
/**
|
|
750
|
+
* Hand the message to `onMessage`, the SINGLE consumer, with the lease in its
|
|
751
|
+
* own copy of the metadata (`turnLease`). The `message` / `room_message`
|
|
752
|
+
* events carry only the opaque token. With no `onMessage`, nobody runs the
|
|
753
|
+
* turn: the token is ended at once (a drop).
|
|
754
|
+
*/
|
|
755
|
+
private _handToOnMessage;
|
|
756
|
+
/** A non-eligible token reached 2 × TTL with no end: a family broke the R3-4 contract. */
|
|
757
|
+
private _reportUnendedTurn;
|
|
758
|
+
/** Run `fn` with `token` as this call chain's turn token (see `currentTurnToken`). */
|
|
759
|
+
runWithTurnToken<T>(token: TurnToken | null | undefined, fn: () => Promise<T>): Promise<T>;
|
|
760
|
+
/** The turn token of this async call chain, or `null` outside any turn. */
|
|
761
|
+
currentTurnToken(): TurnToken | null;
|
|
762
|
+
/**
|
|
763
|
+
* #1762 (design §1.2 step 1) — may a file go to `target` on `turn`?
|
|
764
|
+
* - a token must be one this channel minted, and still active;
|
|
765
|
+
* - the target must equal the token's conversation (its room, or its person);
|
|
766
|
+
* - a room target needs `ownerTurn` (attested, never downgraded);
|
|
767
|
+
* - no token (turnless) is allowed only for the owner, and only when the
|
|
768
|
+
* channel POSITIVELY knows there is exactly one person
|
|
769
|
+
* (`_dmPeople()?.count === 1`, N5). Unknown refuses: `_isMultiPerson()`
|
|
770
|
+
* treats unknown as one, so it is deliberately not used;
|
|
771
|
+
* - #1836: never turnless inside a Double Ratchet turn (`_drTurnStore`).
|
|
772
|
+
* DR has no owner verdict, so its sender is not "the owner" a turnless
|
|
773
|
+
* send stands for.
|
|
774
|
+
*/
|
|
775
|
+
private _turnAuthority;
|
|
776
|
+
/** Is `convId` the same person as the 1:1 token's (same conversation, or the same person per `_dmPeople`)? */
|
|
777
|
+
private _tokenNamesPerson;
|
|
778
|
+
/** #1762 — a 1:1 token for an owner message that just decrypted (#1418 attested pair). */
|
|
779
|
+
private _mintDmTurn;
|
|
780
|
+
/**
|
|
781
|
+
* #1762 (design §2, R3-2) — create the outbox, `dm/` and every persisted
|
|
782
|
+
* room's folder, freshly, once per process at start — and ONLY when the
|
|
783
|
+
* family turned file sending on (`config.fileSend`); otherwise nothing is
|
|
784
|
+
* written to disk. Nothing else creates them, and `sendFile` never does.
|
|
785
|
+
*/
|
|
786
|
+
private _initFileSendPolicy;
|
|
787
|
+
/**
|
|
788
|
+
* #1762 (C, R3-9) — the staging folder to show the model for `target`,
|
|
789
|
+
* relative to the one base a relative `send_file` path resolves against
|
|
790
|
+
* (the workspace, else the outbox). `null` when file send is off or the
|
|
791
|
+
* target can have no folder. Pass it to `stagingLineFor` / `fileSendToolResult`.
|
|
792
|
+
*/
|
|
793
|
+
stagingPathFor(target: FileSendTarget): string | null;
|
|
794
|
+
/** #1762 — a room is now known: give it a folder, unless this process already made one that is intact. */
|
|
795
|
+
private _ensureRoomFolder;
|
|
796
|
+
/** #1762 (R3-1) — a room went away: its folder moves to `<outbox>/left/`, outside every root. */
|
|
797
|
+
private _retireRoomFolder;
|
|
798
|
+
/**
|
|
799
|
+
* #1459 / #1762 — is `deviceId` a human of THIS agent's own account in
|
|
800
|
+
* `roomId`'s roster? A foreign human is also `entityType: "owner"`, so the
|
|
801
|
+
* account check is what makes it the owner. Unknown → false (fail closed).
|
|
802
|
+
*/
|
|
803
|
+
private _isOwnRoomHuman;
|
|
804
|
+
/** #1459 — what the stored roster says, however old. Use `_isOwnRoomHuman` to grant power. */
|
|
805
|
+
private _rosterNamesOwnHuman;
|
|
806
|
+
/** #1803 — has `roomId`'s roster been re-read since the last owner-devices change, recently enough? */
|
|
807
|
+
private _ownerRosterTrusted;
|
|
808
|
+
/**
|
|
809
|
+
* #1803 — the account's owner devices changed (`owner_devices_changed`), or
|
|
810
|
+
* this process (re)connected and may have missed that event. No cached
|
|
811
|
+
* roster names the owner until it is re-read; a GET already in flight does
|
|
812
|
+
* not count. Each room's next message re-reads it before deciding.
|
|
813
|
+
*/
|
|
814
|
+
private _invalidateOwnerRosters;
|
|
815
|
+
/**
|
|
816
|
+
* #1820 part 2 — the owner-list generation. Bumped by every
|
|
817
|
+
* `owner_devices_changed` and every (re)connect. A family that queued a
|
|
818
|
+
* turn with `metadata.ownerDevicesGen` re-checks the sender with
|
|
819
|
+
* `isCurrentOwnerDevice` when the two differ at release.
|
|
820
|
+
*/
|
|
821
|
+
ownerDevicesGeneration(): number;
|
|
822
|
+
/**
|
|
823
|
+
* #1820 part 2 — is `deviceId` one of the account's current owner devices?
|
|
824
|
+
* Reads the list when it is stale or was dropped. Fails closed: a missing
|
|
825
|
+
* id, a failed read, or a read overtaken by an owner-devices change is
|
|
826
|
+
* "no". Never throws.
|
|
827
|
+
*/
|
|
828
|
+
isCurrentOwnerDevice(deviceId: string | null | undefined): Promise<boolean>;
|
|
829
|
+
/**
|
|
830
|
+
* #1826 review M3 — the three-way answer: `"owner"`, `"not_owner"`
|
|
831
|
+
* (confirmed by a fresh read) or `"unknown"` (could not confirm: a failed,
|
|
832
|
+
* timed-out or overtaken read, or its short backoff). Only `"owner"` is the
|
|
833
|
+
* owner; a family may spare an `"unknown"` turn lasting taint or an abort.
|
|
834
|
+
*/
|
|
835
|
+
ownerDeviceStatus(deviceId: string | null | undefined): Promise<OwnerDeviceStatus>;
|
|
836
|
+
/**
|
|
837
|
+
* #1820 part 2 — the owner fields every 1:1 emit site sets, decided now
|
|
838
|
+
* (the release point) from the server delivery row's sender device id.
|
|
839
|
+
*/
|
|
840
|
+
private _dmOwnerFields;
|
|
841
|
+
/**
|
|
842
|
+
* #1784 round 2 (item 4) — this agent's own account (tenant), from its
|
|
843
|
+
* device JWT, lowercased; `null` when unknown. The ONE source for "own
|
|
844
|
+
* account": the owner check above and the families' roster redaction
|
|
845
|
+
* (OpenClaw's attested preamble) both use it, so they always agree.
|
|
846
|
+
*/
|
|
847
|
+
ownTenantId(): string | null;
|
|
577
848
|
/**
|
|
578
849
|
* The turn this call chain belongs to (#1418) — running, or ended but
|
|
579
850
|
* still within the window in which work it left behind is for its person.
|
|
@@ -681,14 +952,6 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
681
952
|
private _audienceTag;
|
|
682
953
|
/** Does conversation `convId` belong to `person`? A conversation nothing ties to them fails closed. */
|
|
683
954
|
private _isPersonsConversation;
|
|
684
|
-
/**
|
|
685
|
-
* #1418: the Double Ratchet sessions an owner-bound FILE (attachment or
|
|
686
|
-
* artifact) goes to, bucketed by the conversation its blob is uploaded
|
|
687
|
-
* under. The blob is uploaded under a conversation of the person who gets
|
|
688
|
-
* it — the backend only lets that conversation's participants download it —
|
|
689
|
-
* so an explicit "everyone" uploads once per person.
|
|
690
|
-
*/
|
|
691
|
-
private _ownerFileRecipients;
|
|
692
955
|
/** The group a DM history entry belongs to (see the forms above). */
|
|
693
956
|
private _dmEntryScope;
|
|
694
957
|
/**
|
|
@@ -706,7 +969,7 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
706
969
|
private _captureHistoryApplication;
|
|
707
970
|
/** Select a context before applying the optional lower bound and final cap. */
|
|
708
971
|
private _historyForCatchup;
|
|
709
|
-
/**
|
|
972
|
+
/** Exact routing selector for catch-up (#1836: the Double Ratchet session_init replay is gone). */
|
|
710
973
|
private _selectHistoryContext;
|
|
711
974
|
private _markHistoryDirty;
|
|
712
975
|
/** Deliver one application frame only while the socket remains OPEN. */
|
|
@@ -775,7 +1038,18 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
775
1038
|
* Get recent message history for a specific room, for LLM context injection.
|
|
776
1039
|
* Returns the last N messages tagged with `room:{roomId}`.
|
|
777
1040
|
*/
|
|
778
|
-
getRoomHistory(roomId: string, maxMessages?: number):
|
|
1041
|
+
getRoomHistory(roomId: string, maxMessages?: number): HistoryReadEntry[];
|
|
1042
|
+
/**
|
|
1043
|
+
* #1762 — attach each entry's sent `files` (stored beside it) to a copy.
|
|
1044
|
+
* #1800 PR B — and an entry recorded from an unbound sender reads
|
|
1045
|
+
* `sender: "unverified"` (`historyUnverified`, stored beside it too).
|
|
1046
|
+
* #1848 review — a ROOM or 1:1 entry not written by this agent reads
|
|
1047
|
+
* `"owner"` only when it carries the owner flag (`historyOwner`); every
|
|
1048
|
+
* other one — another account's person, another agent, a bound 1:1 device
|
|
1049
|
+
* that is not a current owner device, and any entry restored from a backup
|
|
1050
|
+
* or written before the flag existed — reads `"member"`.
|
|
1051
|
+
*/
|
|
1052
|
+
private _withHistoryFiles;
|
|
779
1053
|
/**
|
|
780
1054
|
* #1560 — recent history of one person's 1:1 chat, for LLM context
|
|
781
1055
|
* injection by a bridge. Scoped by the group the inbound frame DECRYPTED
|
|
@@ -785,7 +1059,7 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
785
1059
|
*/
|
|
786
1060
|
getConversationHistory(conversationId: string, maxMessages?: number, opts?: {
|
|
787
1061
|
groupId?: string;
|
|
788
|
-
}):
|
|
1062
|
+
}): HistoryReadEntry[];
|
|
789
1063
|
/** Every conversation mapped to `groupId` (one per browser of its person). */
|
|
790
1064
|
private _conversationsOfGroup;
|
|
791
1065
|
/**
|
|
@@ -976,6 +1250,86 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
976
1250
|
* legacy activity_span paths produce resource-less span rows.
|
|
977
1251
|
*/
|
|
978
1252
|
sendActivitySpan(spanData: Record<string, unknown>): void;
|
|
1253
|
+
/**
|
|
1254
|
+
* The ONE value a family reads about Full permissions: true only while the
|
|
1255
|
+
* server's latest snapshot ON THIS CONNECTION said `full_permissions: "on"`.
|
|
1256
|
+
* False before the first snapshot of a connection (the reconnect window),
|
|
1257
|
+
* after a disconnect, while `"pending"`, and on `"off"` or a missing field.
|
|
1258
|
+
*
|
|
1259
|
+
* Read it when a turn STARTS RUNNING, never when it was queued (T45).
|
|
1260
|
+
* Today's backend never sends the field, so this is false for every agent.
|
|
1261
|
+
*/
|
|
1262
|
+
effective(): boolean;
|
|
1263
|
+
/**
|
|
1264
|
+
* Register a family's part of the off sequence (kill its on-turns' work,
|
|
1265
|
+
* rotate its owner 1:1; §13.13 steps 2–4). Called ONLY on an explicit off
|
|
1266
|
+
* snapshot (`"off"`, or the field missing) after the agent was on — never on
|
|
1267
|
+
* a disconnect, never on `"pending"`. `effective()` already reads false when
|
|
1268
|
+
* the callbacks run. Returns an unregister function.
|
|
1269
|
+
*/
|
|
1270
|
+
onOffSequence(cb: OffSequenceCallback): () => void;
|
|
1271
|
+
/**
|
|
1272
|
+
* A family declares what it enforces (§13.13): `supportsOn` once it has its
|
|
1273
|
+
* on branch, `enforcesOff` once rooms are limited. Fixed per family build.
|
|
1274
|
+
* Nothing is reported until a family calls this, so a family that has not
|
|
1275
|
+
* been built for #1762 claims nothing. Once declared, the
|
|
1276
|
+
* `permissions_heartbeat` frame goes out at every served connect and on
|
|
1277
|
+
* every `"pending"` snapshot — and right now, if the socket is open.
|
|
1278
|
+
*/
|
|
1279
|
+
declarePermissionsSupport(s: {
|
|
1280
|
+
supportsOn?: boolean;
|
|
1281
|
+
enforcesOff?: boolean;
|
|
1282
|
+
}): void;
|
|
1283
|
+
/**
|
|
1284
|
+
* The `permissions_heartbeat` frame. A separate event, not a field on
|
|
1285
|
+
* `worker_heartbeat`: only claude sends that one, and today's backend
|
|
1286
|
+
* handler reads its absent keys as false and would overwrite claude's
|
|
1287
|
+
* `worker_capable` / armed rooms / host trust if the core sent it.
|
|
1288
|
+
* `contract` carries AV_EFFECTIVE_V1 — which also keeps the marker in every
|
|
1289
|
+
* bundle that has this emitter (the bridges' builds require it).
|
|
1290
|
+
*/
|
|
1291
|
+
private _sendPermissionsHeartbeat;
|
|
1292
|
+
/**
|
|
1293
|
+
* The environment EVERY process an on-turn spawns must carry
|
|
1294
|
+
* (`AV_ONTURN=<per-agent nonce>`, §13.13 C2). Merge it into the spawn's env.
|
|
1295
|
+
* On Linux the descendant-tree stop finds orphans of finished turns by it;
|
|
1296
|
+
* on macOS the environment of another process cannot be read, and orphans
|
|
1297
|
+
* are found through the groups recorded while the turn ran.
|
|
1298
|
+
*/
|
|
1299
|
+
onTurnEnv(): Record<string, string>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Register a process an on-turn spawned (the turn's root: a CLI child, a
|
|
1302
|
+
* worker). Await it right after the spawn. Its tree — and every group and
|
|
1303
|
+
* session led by a descendant — is stopped at an explicit off and at the
|
|
1304
|
+
* not-"on" bound; its groups are recorded every 5 s while it runs, so what
|
|
1305
|
+
* it leaves behind is still found after it ends. Call the returned function
|
|
1306
|
+
* when the turn's process has exited. Never throws.
|
|
1307
|
+
*/
|
|
1308
|
+
registerOnTurnProcess(pid: number): Promise<() => void>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Stop every on-turn process NOW, whatever the switch says — for a terminal
|
|
1311
|
+
* exit (device revoked or gone, self-uninstall), where the family calls
|
|
1312
|
+
* `stop()` and then `process.exit`, so no off sequence or bound would ever
|
|
1313
|
+
* run. Call it BEFORE `stop()`/`process.exit`. Bounded (20 s), never throws.
|
|
1314
|
+
* An agent that registered no on-turn has nothing to stop.
|
|
1315
|
+
*/
|
|
1316
|
+
stopOnTurnsNow(): Promise<{
|
|
1317
|
+
ok: boolean;
|
|
1318
|
+
killed: number;
|
|
1319
|
+
}>;
|
|
1320
|
+
/** #1762 PR-P1c-2 (§13.6, §13.20): every off-sequence run is reported; a failed one is surfaced. */
|
|
1321
|
+
private _onOffSequenceDone;
|
|
1322
|
+
/** #1762 PR-P1c-2 (§13.6 `av.gates.unknown_kill`): a stop at the not-"on" bound. No rotation, no system line. */
|
|
1323
|
+
private _onBoundStopReport;
|
|
1324
|
+
/**
|
|
1325
|
+
* #1762 PR-P1c-2 (§13.20 "Surface a failed run"): its own event, plus — once
|
|
1326
|
+
* per on period — a plain notice in the owner's 1:1 chat (#1560). The
|
|
1327
|
+
* `ai.agent.tool.invoke` failure span was already sent with the run span.
|
|
1328
|
+
*/
|
|
1329
|
+
private _surfaceOffSequenceFailure;
|
|
1330
|
+
/** #1762 PR-P1c-2 (review M1): a held failed-stop notice, told once the relay is up. */
|
|
1331
|
+
private _flushOffSequenceNotice;
|
|
1332
|
+
private _sendOffSequenceNotice;
|
|
979
1333
|
/**
|
|
980
1334
|
* Send a worker-capability heartbeat to the backend (Slice 2 Plan C).
|
|
981
1335
|
* Reports whether this device can run the native tool-capable worker and
|
|
@@ -1034,6 +1388,11 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
1034
1388
|
priority?: string;
|
|
1035
1389
|
metadata?: Record<string, unknown>;
|
|
1036
1390
|
}): Promise<void>;
|
|
1391
|
+
/**
|
|
1392
|
+
* The room send itself. `history` overrides what a written TEXT frame
|
|
1393
|
+
* records (a file envelope records its caption plus `files`, never the JSON).
|
|
1394
|
+
*/
|
|
1395
|
+
private _sendToRoomFrame;
|
|
1037
1396
|
/**
|
|
1038
1397
|
* Leave a room: remove sessions and persisted room state.
|
|
1039
1398
|
*/
|
|
@@ -1161,6 +1520,11 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
1161
1520
|
* Best-effort: on any error (offline, 404, auth) the existing roster is kept.
|
|
1162
1521
|
* Concurrent calls for the same room are deduped via _roomRosterRefreshInFlight.
|
|
1163
1522
|
*/
|
|
1523
|
+
/**
|
|
1524
|
+
* Resolves `true` when the body was set aside because the room or the
|
|
1525
|
+
* owner devices changed while the GET was in flight (#1574, #1803): the
|
|
1526
|
+
* caller may issue ONE fresh GET. `false` otherwise, success or failure.
|
|
1527
|
+
*/
|
|
1164
1528
|
private _refreshRoomRoster;
|
|
1165
1529
|
/**
|
|
1166
1530
|
* #1574 — set a room's in-memory audience from a server payload. Only the
|
|
@@ -1191,6 +1555,12 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
1191
1555
|
startHeartbeat(intervalSeconds: number, statusCallback: () => HeartbeatStatus): void;
|
|
1192
1556
|
stopHeartbeat(): Promise<void>;
|
|
1193
1557
|
sendStatusAlert(alert: StatusAlert, routing?: OwnerRouting): Promise<void>;
|
|
1558
|
+
/**
|
|
1559
|
+
* #1762 (design §1.3) — an artifact is a file send with its description as
|
|
1560
|
+
* the caption. Title and type metadata are dropped (receivers keep parsing
|
|
1561
|
+
* `type: "artifact"`). It goes to ONE person: the conversation named, else
|
|
1562
|
+
* the turn's person; `audience: "everyone"` no longer fans a file out.
|
|
1563
|
+
*/
|
|
1194
1564
|
sendArtifact(artifact: {
|
|
1195
1565
|
filePath: string;
|
|
1196
1566
|
filename: string;
|
|
@@ -1228,7 +1598,40 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
1228
1598
|
startTrustTokenRefresh(): void;
|
|
1229
1599
|
stopTrustTokenRefresh(): void;
|
|
1230
1600
|
stop(): Promise<void>;
|
|
1231
|
-
|
|
1601
|
+
/**
|
|
1602
|
+
* Open the local HTTP API on 127.0.0.1:<port> AND [::1]:<port>. Returns
|
|
1603
|
+
* false — and serves nothing — when the agent's token file is unsafe
|
|
1604
|
+
* (#1791): wrong mode or owner, a symlink, or not a token. Every request
|
|
1605
|
+
* must then carry that token, no Origin, and an exact loopback Host (see
|
|
1606
|
+
* local-api.ts).
|
|
1607
|
+
*
|
|
1608
|
+
* Why ::1 too (review M1): curl and Node `fetch` try `localhost` as ::1
|
|
1609
|
+
* first. Holding only 127.0.0.1 let another user bind [::1]:<port> and
|
|
1610
|
+
* collect the token from every `localhost` caller. If ::1 is already held by
|
|
1611
|
+
* someone else the server shuts both down and emits `http-failed`; a host
|
|
1612
|
+
* with no IPv6 loopback (EADDRNOTAVAIL / EAFNOSUPPORT) serves on 127.0.0.1
|
|
1613
|
+
* alone. `http-ready` fires once both binds settled.
|
|
1614
|
+
*/
|
|
1615
|
+
startHttpServer(port: number): boolean;
|
|
1616
|
+
/**
|
|
1617
|
+
* This agent's local API token (#1791), created on first use as a 0600 file
|
|
1618
|
+
* in the data folder. Null when that file is unsafe — the caller must not
|
|
1619
|
+
* serve; the reason is logged and reported as `av.local_send.unavailable`.
|
|
1620
|
+
* A failure is remembered for a minute (review L2): no disk read, log line
|
|
1621
|
+
* or span per call in between, so nothing can loop it.
|
|
1622
|
+
*/
|
|
1623
|
+
localApiToken(): string | null;
|
|
1624
|
+
/** True while the local HTTP API is up or starting (#1791). */
|
|
1625
|
+
get localApiServing(): boolean;
|
|
1626
|
+
/** The port the local HTTP API was opened on, if it was. */
|
|
1627
|
+
get localApiPort(): number | null;
|
|
1628
|
+
/**
|
|
1629
|
+
* #1791 — one `av.local_send.rejected` span per refusal, throttled per
|
|
1630
|
+
* (route, reason) so a hostile page looping requests cannot flood telemetry
|
|
1631
|
+
* or the log: at most one span per 5 s carrying the count it stands for,
|
|
1632
|
+
* and one log line per minute.
|
|
1633
|
+
*/
|
|
1634
|
+
reportLocalApiRefusal(route: string, reason: LocalApiRefusal): void;
|
|
1232
1635
|
private _stopHttpServer;
|
|
1233
1636
|
/**
|
|
1234
1637
|
* Attach an MCP server instance to this channel.
|
|
@@ -1379,38 +1782,124 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
1379
1782
|
*/
|
|
1380
1783
|
private _augmentWithAttachment;
|
|
1381
1784
|
private _downloadAndDecryptAttachment;
|
|
1382
|
-
/**
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1785
|
+
/** M4: an upload that does not answer is abandoned (static so a test can shorten it). */
|
|
1786
|
+
static FILE_UPLOAD_TIMEOUT_MS: number;
|
|
1787
|
+
/** §6.3: how long `agent_uploads_disabled` stops sends without asking the server again. */
|
|
1788
|
+
private static readonly FILE_SEND_DISABLED_MS;
|
|
1789
|
+
/** M3: text content beyond this is not scanned (best effort, never a control). */
|
|
1790
|
+
private static readonly FILE_SCAN_MAX_BYTES;
|
|
1791
|
+
/** M7: a refusal names a file frame written this recently to the same group. */
|
|
1792
|
+
private static readonly FILE_LOST_WINDOW_MS;
|
|
1793
|
+
/** M: at most one turnless failure notice per conversation in this window. */
|
|
1794
|
+
private static readonly TURNLESS_NOTICE_INTERVAL_MS;
|
|
1795
|
+
private _turnlessNoticeAt;
|
|
1796
|
+
/**
|
|
1797
|
+
* #1762 (design §1) — send ONE local file, with an optional caption, to the
|
|
1798
|
+
* owner's 1:1 or to a room, on the authority of `turn` (the token minted for
|
|
1799
|
+
* the inbound message whose turn this is; `null` = turnless).
|
|
1800
|
+
*
|
|
1801
|
+
* The result is `sent` (at least one frame was WRITTEN to the socket) or
|
|
1802
|
+
* `failed(code)`. Files never queue: no #952 hold, no offline queue, no MLS
|
|
1803
|
+
* re-seal (decision 1). Never throws for an expected failure, and an error
|
|
1804
|
+
* never names a path or echoes a server body.
|
|
1805
|
+
*
|
|
1806
|
+
* Order (§1.2): authority → kill switch → path policy (one read) → dedupe →
|
|
1807
|
+
* scan → plan the route → upload once per recipient bucket (all uploads
|
|
1808
|
+
* before any seal) → re-check the turn is active → seal and write → history.
|
|
1809
|
+
*/
|
|
1810
|
+
sendFile(target: FileSendTarget, path: string, caption: string, turn: TurnToken | null, opts?: FileSendHostOptions): Promise<FileSendResult>;
|
|
1811
|
+
private _sendFile;
|
|
1812
|
+
/** M6: a prior OK send of the same key inside the #475 sliding window and cap. */
|
|
1813
|
+
private _fileSendDedupeHit;
|
|
1814
|
+
/** A dedupe tag for the 1:1 person a token names (turnless: the one known person). */
|
|
1815
|
+
private _tokenPersonTag;
|
|
1816
|
+
/**
|
|
1817
|
+
* #1762 (H3) — the owner route, per PERSON bucket, from the same planner and
|
|
1818
|
+
* #1418 audience as `send()`: shared 1:1 MLS groups, then per-conversation
|
|
1819
|
+
* MLS, then an ONLINE Double Ratchet session. A conversation whose only
|
|
1820
|
+
* route is the #952 hold or the offline queue contributes nothing. Every
|
|
1821
|
+
* bucket needs an upload scope the server mapped to that person
|
|
1822
|
+
* (`_sessionGroupIds`); a joined but unmapped group is skipped.
|
|
1823
|
+
*/
|
|
1824
|
+
private _planOwnerFileRoutes;
|
|
1825
|
+
/** A conversation the server mapped to `gid` — the preferred one when it maps there. */
|
|
1826
|
+
private _uploadScopeForGroup;
|
|
1827
|
+
/** #1762 — a room's file route: its initialized MLS group, uploaded under the room as this device. */
|
|
1828
|
+
private _planRoomFileRoute;
|
|
1829
|
+
/**
|
|
1830
|
+
* #1762 (§1.2 step 8) — encrypt the bytes with a fresh key and upload the
|
|
1831
|
+
* ciphertext once. 413 → file_too_large; 503 with body `error =
|
|
1832
|
+
* agent_uploads_disabled` → file_send_disabled and a 5-minute back-off (N9:
|
|
1833
|
+
* no other 503 trips it); anything else, or the 60 s timeout → upload_failed.
|
|
1834
|
+
* The response body is never echoed.
|
|
1835
|
+
*/
|
|
1836
|
+
private _uploadFileBlob;
|
|
1837
|
+
/**
|
|
1838
|
+
* #1762 (§1.2 step 9) — seal and write every frame of every uploaded bucket,
|
|
1839
|
+
* checking readiness before each seal. A frame not written is NOT queued: no
|
|
1840
|
+
* re-seal, no DR offline queue, no hold. Returns how many were written.
|
|
1841
|
+
*
|
|
1842
|
+
* Round 2, item 16: EVERY frame carries its own client_message_id (inner
|
|
1843
|
+
* envelope == outer frame), so one frame's delivery_ack can never clear
|
|
1844
|
+
* another frame's pending refusal. The first frame keeps the send's id (the
|
|
1845
|
+
* result and the history entry name it). Safe: the server dedupes per
|
|
1846
|
+
* (group, sender device, id) and receivers do not dedupe on it.
|
|
1847
|
+
*/
|
|
1848
|
+
private _writeFileFrames;
|
|
1849
|
+
/** M7: remember a written file frame (1:1 or room) for a short while, by its client_message_id. */
|
|
1850
|
+
private _noteFileFrame;
|
|
1851
|
+
/** M7: the server delivered it to a device — never report it lost. */
|
|
1852
|
+
private _noteFileFrameDelivered;
|
|
1853
|
+
/**
|
|
1854
|
+
* #1762 (M7, review F, round 2 items 12-13) — the server refused a frame
|
|
1855
|
+
* (`error`) or its policy gate blocked it (`policy_blocked`), and echoed its
|
|
1856
|
+
* client_message_id. Only a pending FILE frame with exactly that id is
|
|
1857
|
+
* reported (#1560: never silent): in 1:1 a notice naming the file, in a
|
|
1858
|
+
* room the bare room line (never the filename: other accounts read the
|
|
1859
|
+
* room), and a `delivery_failed` span either way. A refusal with no id
|
|
1860
|
+
* (a commit, a welcome, an older server) or another id (a text frame) is
|
|
1861
|
+
* not a file refusal and is ignored.
|
|
1862
|
+
*/
|
|
1863
|
+
private _noteFileFrameRejected;
|
|
1864
|
+
/** After every attempt: the span, the token's bookkeeping, a turnless failure's notice. */
|
|
1865
|
+
private _afterFileSendAttempt;
|
|
1866
|
+
/**
|
|
1867
|
+
* #1762 (§4.2, §4.4) — at the end of a turn: one notice per conversation for
|
|
1868
|
+
* the files that did not go, and, when a reply claims a file and none went,
|
|
1869
|
+
* the neutral "(This reply has no attachment.)" line plus a span.
|
|
1870
|
+
*/
|
|
1871
|
+
private _checkTurnFiles;
|
|
1872
|
+
/** Did an earlier turn send a file into this conversation (the last 20 entries)? */
|
|
1873
|
+
private _recentFileSendIn;
|
|
1874
|
+
/**
|
|
1875
|
+
* Post a file notice NOW or not at all (#1782 round 1, item 5): `noQueue`
|
|
1876
|
+
* keeps it out of the #952 hold, the Double Ratchet offline queue and the
|
|
1877
|
+
* re-seal queue, like the file it is about. A notice that cannot go now is
|
|
1878
|
+
* dropped with one `av.file_notice.dropped` span — the failed send already
|
|
1879
|
+
* recorded its own `send_file` span, so no failure signal is lost. A 1:1
|
|
1880
|
+
* notice whose conversation cannot be resolved is NOT posted: an untargeted
|
|
1881
|
+
* send() would pick the last person (L).
|
|
1882
|
+
*/
|
|
1883
|
+
private _postFileNotice;
|
|
1884
|
+
/**
|
|
1885
|
+
* PR-O item 2 — the "(This reply has no attachment.)" correction goes on the
|
|
1886
|
+
* SAME route as the reply it corrects, not "now or never": the false claim
|
|
1887
|
+
* is ordinary reply text, which may be waiting in the #952 hold, the Double
|
|
1888
|
+
* Ratchet offline queue or the re-seal queue. Sent the same way, the
|
|
1889
|
+
* correction waits right behind it (those queues are FIFO), so the person
|
|
1890
|
+
* never reads the claim without the correction. A room reply is never
|
|
1891
|
+
* queued (sendToRoom writes now or throws), so the room case is unchanged.
|
|
1892
|
+
* A 1:1 correction whose conversation cannot be resolved is not posted (L).
|
|
1893
|
+
*/
|
|
1894
|
+
private _postCorrection;
|
|
1895
|
+
private _reportFileNoticeDropped;
|
|
1896
|
+
/** The agent's name as the person reads it in a notice. */
|
|
1897
|
+
private _agentLabel;
|
|
1394
1898
|
/**
|
|
1395
1899
|
* Relay an owner's message to all sibling sessions as encrypted sync messages.
|
|
1396
1900
|
* This allows all owner devices to see messages from any single device.
|
|
1397
1901
|
*/
|
|
1398
1902
|
private _relaySyncToSiblings;
|
|
1399
|
-
/**
|
|
1400
|
-
* Resolve the agent's workspace directory.
|
|
1401
|
-
* Looks for OpenClaw workspace config, falls back to default path.
|
|
1402
|
-
*/
|
|
1403
|
-
private _resolveWorkspaceDir;
|
|
1404
|
-
/**
|
|
1405
|
-
* Send a structured JSON reply to a specific conversation.
|
|
1406
|
-
* Encrypts the payload via the conversation's ratchet and sends via WebSocket.
|
|
1407
|
-
*/
|
|
1408
|
-
private _sendStructuredReply;
|
|
1409
|
-
/**
|
|
1410
|
-
* Send stored message history to a newly-activated session.
|
|
1411
|
-
* Batches all history into a single encrypted message.
|
|
1412
|
-
*/
|
|
1413
|
-
private _replayHistoryToSession;
|
|
1414
1903
|
/**
|
|
1415
1904
|
* Handle a device_linked event: a new owner device has joined.
|
|
1416
1905
|
* Fetches the new device's public keys, performs X3DH, and initializes
|
|
@@ -1457,6 +1946,15 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
1457
1946
|
* Only the elected agent (smallest device_id among agents) responds.
|
|
1458
1947
|
*/
|
|
1459
1948
|
private _handleHistoryCatchupRequest;
|
|
1949
|
+
/**
|
|
1950
|
+
* #1762 (N, round 2 item 11) — the catch-up messages for BOTH responders
|
|
1951
|
+
* (1:1 and room). A sent file's key is never kept, so a new device sees a
|
|
1952
|
+
* line instead; an entry with no text at all is left out, never sent as an
|
|
1953
|
+
* empty bubble. No wire change: the web decoder takes exactly these keys.
|
|
1954
|
+
*/
|
|
1955
|
+
private _catchupMessages;
|
|
1956
|
+
/** #1762 (N) — an entry's catch-up text: its caption, plus one line per file sent with it. Never empty for a file. */
|
|
1957
|
+
private _catchupText;
|
|
1460
1958
|
/**
|
|
1461
1959
|
* Apply an inbound MLS commit to whichever group it addresses.
|
|
1462
1960
|
*
|
|
@@ -1946,6 +2444,139 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
1946
2444
|
* must not be able to take the channel down.
|
|
1947
2445
|
*/
|
|
1948
2446
|
private _replenishKpPoolFromServer;
|
|
2447
|
+
/** #1800 PR C — the in-memory security counters (`name{reason}` → count). @internal */
|
|
2448
|
+
securityCounters(): Record<string, number>;
|
|
2449
|
+
/** The conversation group a conversation belongs to, as this agent last heard it. */
|
|
2450
|
+
private _groupOfConversation;
|
|
2451
|
+
/**
|
|
2452
|
+
* #1800 PR C — the Tier 1 pre-join decision for a 1:1 Welcome. Returns the
|
|
2453
|
+
* accept verdict, or `null` after refusing (log, counter, notice). Never
|
|
2454
|
+
* throws: an unexpected error here refuses (fails closed) rather than
|
|
2455
|
+
* escaping the receive path.
|
|
2456
|
+
*/
|
|
2457
|
+
private _decideDmWelcomeOrRefuse;
|
|
2458
|
+
/**
|
|
2459
|
+
* #1800 PR C (review MEDIUM): a group Tier 1 refused is not asked for again
|
|
2460
|
+
* by self-heal in this process (`_welcomeRefusedGroups`), or each owner frame
|
|
2461
|
+
* in it would trigger a re-admit we then refuse — a commit-and-KeyPackage
|
|
2462
|
+
* churn loop. NOT when one of our own routing keys holds the group (a T1-b
|
|
2463
|
+
* refusal names a room's, an A2A channel's or another 1:1's group): that key
|
|
2464
|
+
* still needs its own self-heal, and a forged frame must not switch it off.
|
|
2465
|
+
*/
|
|
2466
|
+
private _noteTier1RefusedGroup;
|
|
2467
|
+
/**
|
|
2468
|
+
* #1800 PR C (review LOW 1, the reverse of T1-b): a room, A2A or unmatched
|
|
2469
|
+
* Welcome naming a group a 1:1 key pins or maps is refused before the join —
|
|
2470
|
+
* its `saveMlsState` would overwrite that 1:1's state file. Server group ids
|
|
2471
|
+
* are unique rows, so no honest room shares one with a 1:1. Never throws.
|
|
2472
|
+
*/
|
|
2473
|
+
private _refuseNonDmWelcomeOnDmGroup;
|
|
2474
|
+
/**
|
|
2475
|
+
* #1800 PR C fulfilment guard, ONE helper for every re-admit path (room,
|
|
2476
|
+
* shared 1:1, per-conversation, A2A re-Welcome, A2A participant_joined):
|
|
2477
|
+
* does this KeyPackage's basic credential name `deviceId`? A drop is counted
|
|
2478
|
+
* and backed off per (group, device) — 5 min doubling to 1 h, one WARN per
|
|
2479
|
+
* window — so the pulls stop spending that device's KeyPackages.
|
|
2480
|
+
*/
|
|
2481
|
+
private _kpAdmissible;
|
|
2482
|
+
/** #1800 PR C: is this (group, device) inside an identity-mismatch backoff window? */
|
|
2483
|
+
private _kpIdentityBlocked;
|
|
2484
|
+
/** #1800 PR C (review LOW 4): one summary line while a security counter is non-zero. */
|
|
2485
|
+
private _logSecurityCounterSummary;
|
|
2486
|
+
/**
|
|
2487
|
+
* The conversation to carry a notice into the PINNED group, or `null` when
|
|
2488
|
+
* that group is not live here (a pruned key's tombstone pin, no pin at all,
|
|
2489
|
+
* or a group we hold no manager for) — the notice goes into the group the
|
|
2490
|
+
* agent trusts, never anywhere the refused Welcome named.
|
|
2491
|
+
*/
|
|
2492
|
+
private _dmNoticeConversation;
|
|
2493
|
+
/**
|
|
2494
|
+
* A claimed device's display name for the notice: the room roster is the
|
|
2495
|
+
* only place this agent holds device names. Unknown → UNKNOWN_DEVICE_LABEL.
|
|
2496
|
+
*/
|
|
2497
|
+
private _claimedDeviceLabel;
|
|
2498
|
+
/**
|
|
2499
|
+
* #1800 §3.4 main notice — "A message here that claimed to be from {label}
|
|
2500
|
+
* could not be verified, so it ran without owner permissions." For PR B's
|
|
2501
|
+
* mismatch / duplicate / DR triggers (not used by PR C itself).
|
|
2502
|
+
*/
|
|
2503
|
+
private _sendUnverifiedSenderNotice;
|
|
2504
|
+
/** #1800 §3.4 remap variant — sent on a Tier 1 refused remap. */
|
|
2505
|
+
private _sendRemapRefusedNotice;
|
|
2506
|
+
/**
|
|
2507
|
+
* One §3.4 status alert. Rate-limited (first event per `noticeKey` per hour,
|
|
2508
|
+
* global cap per hour, shared by every trigger), fire-and-forget, and never
|
|
2509
|
+
* throws.
|
|
2510
|
+
*/
|
|
2511
|
+
private _sendSecurityNotice;
|
|
2512
|
+
/**
|
|
2513
|
+
* #1800 PR B — one §3.4 notice into a ROOM, sharing `_sendSecurityNotice`'s
|
|
2514
|
+
* limiter (per-conversation and global caps). The plaintext carries
|
|
2515
|
+
* `type: "status_alert"`, so no agent in the room treats it as a turn
|
|
2516
|
+
* (`status_alert` is not in ROOM_AGENT_TYPES). Fire-and-forget; never throws.
|
|
2517
|
+
*/
|
|
2518
|
+
private _sendRoomSecurityNotice;
|
|
2519
|
+
/**
|
|
2520
|
+
* #1800 PR B (obligation 5, #1560) — a failed sender-binding self-test is
|
|
2521
|
+
* an Admin incident, not just a console line: one `ai.agent.tool.invoke`
|
|
2522
|
+
* span with `tool.error_kind = sender_binding_self_test_failed` (the agent
|
|
2523
|
+
* error path the owner's "Recent problems" and Admin read), and a
|
|
2524
|
+
* `sender_binding_self_test_failed` channel event. Once per PROCESS
|
|
2525
|
+
* (`takeSenderBindingIncident`), and only once a telemetry reporter exists
|
|
2526
|
+
* to carry it — called after the self-test and after each place one is
|
|
2527
|
+
* created. Never throws.
|
|
2528
|
+
*/
|
|
2529
|
+
/**
|
|
2530
|
+
* Create the telemetry reporter once the device JWT and hub id are known (the
|
|
2531
|
+
* open handler, or the later hub-identity sync). Unchanged from the two
|
|
2532
|
+
* inline copies it replaces; #1800 PR B adds the pending self-test incident,
|
|
2533
|
+
* which needs a reporter to carry it.
|
|
2534
|
+
*/
|
|
2535
|
+
private _ensureTelemetryReporter;
|
|
2536
|
+
private _reportSenderBindingIncident;
|
|
2537
|
+
/** #1800 — the notice limiter's key for a 1:1: its conversation group (PR C's key), else the conversation. */
|
|
2538
|
+
private _dmNoticeKey;
|
|
2539
|
+
/**
|
|
2540
|
+
* #1800 PR B — THE owner gate for a 1:1 MLS frame (design §3.1/§3.3). The
|
|
2541
|
+
* only place a 1:1 MLS verdict becomes owner metadata; every sink reads the
|
|
2542
|
+
* id it returns (`boundSender`), never the wire's `sender_device_id`.
|
|
2543
|
+
*
|
|
2544
|
+
* - bound → owner: `ownerDm1to1`, and `senderDeviceId` = the bound id.
|
|
2545
|
+
* - unbound → `ownerDm1to1: false`, `senderIsOwnerDevice: false`,
|
|
2546
|
+
* `senderOwnerStatus: "not_owner"` (never "unknown"), no `senderDeviceId`,
|
|
2547
|
+
* the verdict and a sanitized `claimedSenderDeviceId` for display. The
|
|
2548
|
+
* owner list is never consulted for an unbound frame.
|
|
2549
|
+
*
|
|
2550
|
+
* The gate WRAPS #1826's owner-list check: a 1:1 is the owner's only when
|
|
2551
|
+
* it is bound AND the bound id is a current owner device
|
|
2552
|
+
* (`_dmOwnerFields(bound)`, decided at release). `senderOwnerStatus`, the
|
|
2553
|
+
* `senderDeviceId` a bridge re-checks at release, and `ownerDevicesGen` all
|
|
2554
|
+
* come from the BOUND id; an unbound frame never reaches the read, so a
|
|
2555
|
+
* failing owner list can only make it "not_owner", never "unknown".
|
|
2556
|
+
*/
|
|
2557
|
+
private _dmOwnerVerdict;
|
|
2558
|
+
/**
|
|
2559
|
+
* #1800 PR B §3.4 — an MLS frame whose sender is not bound: the WARN (ids
|
|
2560
|
+
* sanitized to `[0-9a-f-]` and cut to 8), the counter
|
|
2561
|
+
* `sender_binding_unverified{reason}`, the `sender_binding_unverified`
|
|
2562
|
+
* event, and — for `mismatch` / `duplicate` only — the rate-limited notice
|
|
2563
|
+
* (`unverifiedSenderNotice`, via the shared limiter). Never throws.
|
|
2564
|
+
*/
|
|
2565
|
+
private _noteUnverifiedSender;
|
|
2566
|
+
/**
|
|
2567
|
+
* #1800 PR B — a Double Ratchet text frame (DR is never bound, §3.6): the
|
|
2568
|
+
* counter `sender_binding_unverified{dr}` and the event on every one (the
|
|
2569
|
+
* WARN is #1836's `warnDrNonOwner`), and the DR-variant notice when the
|
|
2570
|
+
* frame claims to come from this conversation's owner device (#1560:
|
|
2571
|
+
* visible failures). Never throws.
|
|
2572
|
+
*
|
|
2573
|
+
* "An owner device" here is the device this DR conversation was set up with
|
|
2574
|
+
* (its session's `ownerDeviceId`): main has no owner-list read. #1826's
|
|
2575
|
+
* `isCurrentOwnerDevice` may replace it when the two meet.
|
|
2576
|
+
*/
|
|
2577
|
+
private _noteDrFrame;
|
|
2578
|
+
/** #1800 PR B — the metadata every Double Ratchet text frame carries: never bound, never the owner. */
|
|
2579
|
+
private _drSenderFields;
|
|
1949
2580
|
private _handleMlsWelcome;
|
|
1950
2581
|
/**
|
|
1951
2582
|
* Self-bootstrap a room entry + MLS group mapping from a Welcome whose room is
|