@agentvault/muse-bridge 0.1.45 → 0.1.47
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 +20 -1
- package/dist/bridge.d.ts +69 -0
- package/dist/channel-config.d.ts +32 -0
- package/dist/file-turn.d.ts +90 -0
- package/dist/identity-prompt.d.ts +6 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8714 -1596
- package/dist/muse-binary.d.ts +36 -0
- package/dist/muse-driver.d.ts +19 -0
- package/dist/muse-room-http.d.ts +3 -0
- package/dist/muse-room-mcp.d.ts +15 -1
- package/dist/muse-session.d.ts +47 -0
- package/dist/muse-spawn.d.ts +6 -0
- package/dist/owner-grant.d.ts +131 -0
- package/dist/room-context.d.ts +26 -1
- package/dist/sender-binding.d.ts +77 -0
- package/dist/session-taint.d.ts +77 -0
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface FileId {
|
|
2
|
+
/** What is re-stat'd (statSync follows links, so a re-pointed link shows as a new inode). */
|
|
3
|
+
path: string;
|
|
4
|
+
/** The realpath at boot. */
|
|
5
|
+
real: string;
|
|
6
|
+
dev: number;
|
|
7
|
+
ino: number;
|
|
8
|
+
mtimeMs: number;
|
|
9
|
+
size: number;
|
|
10
|
+
}
|
|
11
|
+
export interface MuseBinaryIdentity {
|
|
12
|
+
/** The configured command and the launcher PATH it was resolved on — re-resolved at every check (PATH shadowing). */
|
|
13
|
+
command: string;
|
|
14
|
+
searchPath: string;
|
|
15
|
+
/** What `command` resolved to at boot. */
|
|
16
|
+
resolved: string;
|
|
17
|
+
launcher: FileId;
|
|
18
|
+
/** Set when the configured command is a launcher script. */
|
|
19
|
+
versionFile?: FileId;
|
|
20
|
+
active?: FileId;
|
|
21
|
+
}
|
|
22
|
+
/** The identity of the muse the bridge will spawn, or null when it cannot be taken (fails closed). */
|
|
23
|
+
export declare function museBinaryIdentity(command: string, path: string): MuseBinaryIdentity | null;
|
|
24
|
+
/**
|
|
25
|
+
* The boot identity, checked cheaply (`statSync` of the recorded files, no
|
|
26
|
+
* realpath, no spawn). `unchanged()` is false for good once anything moved,
|
|
27
|
+
* or when no identity could be taken at boot.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MuseBinaryGuard {
|
|
30
|
+
private readonly boot;
|
|
31
|
+
private changed;
|
|
32
|
+
constructor(boot: MuseBinaryIdentity | null);
|
|
33
|
+
unchanged(): boolean;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=muse-binary.d.ts.map
|
package/dist/muse-driver.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class MuseDriver {
|
|
|
41
41
|
private readonly turnTimeoutMs;
|
|
42
42
|
private persistedId;
|
|
43
43
|
private ownerId;
|
|
44
|
+
/** #1762 PR-M: which lane's id start() MINTED (no id file): a genuinely new session (session-taint.ts). */
|
|
45
|
+
private minted;
|
|
44
46
|
private current;
|
|
45
47
|
private child;
|
|
46
48
|
private probed;
|
|
@@ -48,6 +50,15 @@ export declare class MuseDriver {
|
|
|
48
50
|
constructor(opts: MuseDriverOpts);
|
|
49
51
|
/** Load or create `<dataDir>/muse-session-id` and the owner lane's id. Does not spawn muse. */
|
|
50
52
|
start(): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* #1762 PR-M: whether start() minted each lane's id — a genuinely new
|
|
55
|
+
* session — or found one to resume. An operator reset (delete the id file
|
|
56
|
+
* while stopped) makes the next start mint.
|
|
57
|
+
*/
|
|
58
|
+
mintedAtStart(): {
|
|
59
|
+
shared: boolean;
|
|
60
|
+
owner: boolean;
|
|
61
|
+
};
|
|
51
62
|
sessionId(): string | null;
|
|
52
63
|
ownerSessionId(): string | null;
|
|
53
64
|
/**
|
|
@@ -70,6 +81,14 @@ export declare class MuseDriver {
|
|
|
70
81
|
/** SIGTERM, then SIGKILL if still alive after 2s. Does not fulfill runTurn. */
|
|
71
82
|
private escalateKill;
|
|
72
83
|
private executeTurn;
|
|
84
|
+
/**
|
|
85
|
+
* #1762 PR-M (#1786 review) — the muse version this process runs, from
|
|
86
|
+
* `muse --version` ("Muse Code 1.4.23 (…)"). Read once, at boot, for the
|
|
87
|
+
* lane taints' version gate (session-taint.ts). Null when it cannot be read
|
|
88
|
+
* (missing binary, odd output, no answer within 10 s) — which fails closed.
|
|
89
|
+
* Never throws.
|
|
90
|
+
*/
|
|
91
|
+
probeVersion(): Promise<string | null>;
|
|
73
92
|
private probeUsable;
|
|
74
93
|
private execJsonl;
|
|
75
94
|
}
|
package/dist/muse-room-http.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SendFileHandler } from "./muse-room-mcp.js";
|
|
1
2
|
export interface RoomHttpTrace {
|
|
2
3
|
httpMethod: string;
|
|
3
4
|
accept: string | undefined;
|
|
@@ -26,6 +27,8 @@ export interface RoomMcpServer {
|
|
|
26
27
|
*/
|
|
27
28
|
export declare function startRoomMcpServer(opts: {
|
|
28
29
|
onSay: (text: string) => void;
|
|
30
|
+
/** #1762 PR-M: the `send_file` route. Its response is sent only once the send settles. */
|
|
31
|
+
onSendFile?: SendFileHandler;
|
|
29
32
|
log?: (m: string) => void;
|
|
30
33
|
}): Promise<RoomMcpServer>;
|
|
31
34
|
//# sourceMappingURL=muse-room-http.d.ts.map
|
package/dist/muse-room-mcp.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP JSON-RPC for the room's tools: `say`, and (#1762 PR-M) `send_file` when
|
|
3
|
+
* the bridge wires a handler for it.
|
|
4
|
+
*
|
|
5
|
+
* Pure: one request frame → one response frame (or null for notifications).
|
|
6
|
+
* The HTTP envelope lives in muse-room-http.ts. A `send_file` call answers
|
|
7
|
+
* with a PROMISE: the listener awaits the real send before it responds, so
|
|
8
|
+
* the model is never told a file went when it did not (unlike `say`, #1765).
|
|
9
|
+
*/
|
|
10
|
+
import type { SendFileOutcome } from "./file-turn.js";
|
|
11
|
+
/** #1762 PR-M: the bridge's `send_file` route (MuseSession.sendFile). Never throws. */
|
|
12
|
+
export type SendFileHandler = (path: unknown, caption: unknown) => Promise<SendFileOutcome>;
|
|
1
13
|
export declare const SAY_TOOL_NAME = "say";
|
|
2
|
-
|
|
14
|
+
/** #1762 PR-M: the model-visible name of the file tool (FILE_SEND_RULE names it). */
|
|
15
|
+
export declare const SEND_FILE_TOOL_NAME = "send_file";
|
|
16
|
+
export declare function handleMcpFrame(frame: any, onSay: (text: string) => void, onSendFile?: SendFileHandler): object | Promise<object> | null;
|
|
3
17
|
//# sourceMappingURL=muse-room-mcp.d.ts.map
|
package/dist/muse-session.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type ToolConversation, type TurnFailureCode } from "@agentvault/agentvault";
|
|
2
|
+
import type { FileTurn, SendFileOutcome } from "./file-turn.js";
|
|
3
|
+
import { type OwnerStatus } from "./owner-grant.js";
|
|
2
4
|
/** A reply sink. `{ notice: true }` marks a #1583 shutdown notice: delivered to
|
|
3
5
|
* the same chat, but not the agent's own `say`. A notice sink that logs its own
|
|
4
6
|
* send failure resolves `false`; anything else counts as sent. */
|
|
@@ -21,6 +23,24 @@ export interface PushOpts {
|
|
|
21
23
|
seed?: string;
|
|
22
24
|
/** #1583: true once this room is hushed. A shutdown notice stays out of it. */
|
|
23
25
|
hushed?: () => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* #1762 PR-M: the message's turn authority (lease + conversation), when file
|
|
28
|
+
* send is on. Attested — or not — by the bridge BEFORE this push. `send_file`
|
|
29
|
+
* uses only the RUNNING turn's; it is ended when the turn is (its last word
|
|
30
|
+
* sent, failure, stop), and at once on a push the session will never run.
|
|
31
|
+
*/
|
|
32
|
+
fileTurn?: FileTurn;
|
|
33
|
+
/**
|
|
34
|
+
* #1820 part 2: an owner 1:1's grant, re-decided when the turn is RELEASED
|
|
35
|
+
* (it reaches the head of the queue). false — the sending device is no
|
|
36
|
+
* longer an owner device, or the owner list cannot be read — and the turn
|
|
37
|
+
* runs as an unattested 1:1: shared lane (no owner power), no plain-text
|
|
38
|
+
* fallback, no file authority, no 1:1 seed, and `onOwnerWithdrawn(status)`
|
|
39
|
+
* (#1826 M3: the bridge taints the shared lane only for `"not_owner"`, never
|
|
40
|
+
* for `"unknown"`: the owner list could not be read).
|
|
41
|
+
*/
|
|
42
|
+
confirmOwner?: () => "owner" | Promise<OwnerStatus>;
|
|
43
|
+
onOwnerWithdrawn?: (status: Exclude<OwnerStatus, "owner">) => void;
|
|
24
44
|
}
|
|
25
45
|
export interface RoomSession {
|
|
26
46
|
push(text: string, reply?: ReplySink, opts?: PushOpts): void;
|
|
@@ -88,6 +108,23 @@ export declare class MuseSession implements RoomSession {
|
|
|
88
108
|
onTurnFailed?: (report: TurnFailedReport) => void;
|
|
89
109
|
/** Test seam: the shared cap on the shutdown notices. */
|
|
90
110
|
noticeTimeoutMs?: number;
|
|
111
|
+
/**
|
|
112
|
+
* #1762 PR-M: a #1560 recovery replaced a lane's stored session with a
|
|
113
|
+
* fresh one (`seeded` when it was given this chat's recent messages).
|
|
114
|
+
* The lane's taint follows it (session-taint.ts: never cleared by a
|
|
115
|
+
* recovery). A throw is swallowed.
|
|
116
|
+
*/
|
|
117
|
+
onFreshSession?: (o: {
|
|
118
|
+
ownerTurn: boolean;
|
|
119
|
+
seeded: boolean;
|
|
120
|
+
}) => void;
|
|
121
|
+
/**
|
|
122
|
+
* #1786 review (LOW 3): the muse binary guard (index.ts). A room turn was
|
|
123
|
+
* attested at PUSH, but the launcher can replace muse before (or while)
|
|
124
|
+
* the turn's child runs, so a room `send_file` re-checks it before any
|
|
125
|
+
* frame is written; false refuses (and the guard taints both lanes).
|
|
126
|
+
*/
|
|
127
|
+
binaryUnchanged?: () => boolean;
|
|
91
128
|
});
|
|
92
129
|
push(text: string, reply?: ReplySink, opts?: PushOpts): void;
|
|
93
130
|
/** Revoke output and future work, before any asynchronous cleanup. */
|
|
@@ -112,9 +149,19 @@ export declare class MuseSession implements RoomSession {
|
|
|
112
149
|
/** The bare sentence for one owed, cancelled turn, raced against the shared
|
|
113
150
|
* cap. Settles, never rejects. */
|
|
114
151
|
private cancelNotice;
|
|
152
|
+
/**
|
|
153
|
+
* #1762 PR-M — the `send_file` tool. Only the RUNNING turn's authority is
|
|
154
|
+
* used (never the last one's, between turns), under the same gates as say:
|
|
155
|
+
* #1180 (a turn not owed sends nothing) and #392 (a hushed room). It AWAITS
|
|
156
|
+
* the real send and reports "File sent" only when a frame was written.
|
|
157
|
+
* Never throws.
|
|
158
|
+
*/
|
|
159
|
+
sendFile(path: unknown, caption: unknown): Promise<SendFileOutcome>;
|
|
115
160
|
sayHandler(): (text: string) => void;
|
|
116
161
|
idle(): Promise<void>;
|
|
117
162
|
private log;
|
|
163
|
+
/** #1820 part 2: the queued 1:1's sender is no longer an owner device, or (#1826 M3) could not be confirmed. */
|
|
164
|
+
private withdrawOwner;
|
|
118
165
|
private run;
|
|
119
166
|
/** The turn's last word, visible to stop() while it goes out. */
|
|
120
167
|
private finishTurn;
|
package/dist/muse-spawn.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ export interface MuseSpawnEnv {
|
|
|
28
28
|
XDG_DATA_HOME: string;
|
|
29
29
|
XDG_STATE_HOME: string;
|
|
30
30
|
PATH: string;
|
|
31
|
+
/**
|
|
32
|
+
* #1786 review (LOW 2): the launcher's own switch (`MUSE_NO_AUTO_UPDATE`,
|
|
33
|
+
* read in ~/.local/bin/muse before `should_check_for_update`) — the bridge's
|
|
34
|
+
* turns never kick off a background self-update. Always "1".
|
|
35
|
+
*/
|
|
36
|
+
MUSE_NO_AUTO_UPDATE: "1";
|
|
31
37
|
META_API_KEY?: string;
|
|
32
38
|
}
|
|
33
39
|
export interface MuseSpawn {
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1820 part 2 (completes #1803) — a queued 1:1 owner turn keeps its owner
|
|
3
|
+
* grant only while the device that sent it is still a current owner device.
|
|
4
|
+
*
|
|
5
|
+
* SecureChannel decides `ownerDm1to1` when it hands the message over, against
|
|
6
|
+
* a fresh owner list, and stamps `senderDeviceId` (from the server's delivery
|
|
7
|
+
* row) and `ownerDevicesGen` (its owner-list generation at that moment). A turn
|
|
8
|
+
* can then wait in this bridge's queue while the owner revokes that device.
|
|
9
|
+
* So the grant is re-decided at RELEASE, when the turn actually starts:
|
|
10
|
+
*
|
|
11
|
+
* - `owner_devices_changed` (content-free) marks every grant taken before it
|
|
12
|
+
* as downgraded: nothing queued keeps owner power on the old answer;
|
|
13
|
+
* - a channel whose owner-list generation moved since the grant (an event, or
|
|
14
|
+
* a reconnect that may have missed one) also counts as downgraded;
|
|
15
|
+
* - a downgraded grant stands only if `isCurrentOwnerDevice(senderDeviceId)`
|
|
16
|
+
* says yes NOW. It fails closed: no sender id, no such method (an older
|
|
17
|
+
* plugin), a throw or a non-`true` answer all mean "not the owner".
|
|
18
|
+
*
|
|
19
|
+
* An older plugin (no generation, no event) changes nothing: its grants are
|
|
20
|
+
* never downgraded unless the event fires.
|
|
21
|
+
*
|
|
22
|
+
* #1826 review M3: "couldn't confirm" is not "confirmed not the owner". A
|
|
23
|
+
* re-check answers a tri-state (`OwnerStatus`): `"not_owner"` only when a
|
|
24
|
+
* fresh, successful owner-list read lacks the device (or there is no sender
|
|
25
|
+
* id); `"unknown"` when the list could not be read (a deploy blip, a timeout,
|
|
26
|
+
* a read overtaken by another change). Both run without the owner grant (tools
|
|
27
|
+
* stay off). `"not_owner"` may abort a running turn; `"unknown"` never does.
|
|
28
|
+
*
|
|
29
|
+
* #1826 review round 2 (M4): a persistent lane (the claude listener, grok's
|
|
30
|
+
* restricted session, muse's shared lane) is tainted by any 1:1 that is not
|
|
31
|
+
* CONFIRMED the owner's after the release re-check — `"not_owner"`, or still
|
|
32
|
+
* `"unknown"` after `confirmStatusRetrying`'s retries. Only a single blip that
|
|
33
|
+
* resolves within the retries avoids the taint. The re-check as a whole is
|
|
34
|
+
* bounded (`UNKNOWN_RECHECK_BUDGET_MS`, L5), so an outage cannot hold a
|
|
35
|
+
* serial queue for long.
|
|
36
|
+
*
|
|
37
|
+
* #1800 PR D (design-1800 §3.3, sink 8): owner power follows the BOUND
|
|
38
|
+
* sender only. A 1:1 whose `senderBinding` is not `"bound"` (a missing
|
|
39
|
+
* verdict included) is `"not_owner"` whatever else its metadata says, its
|
|
40
|
+
* grant carries no sender id, and `confirmStatus` answers `"not_owner"`
|
|
41
|
+
* without asking the channel: an unbound frame is never re-checked, so a
|
|
42
|
+
* re-check can never re-escalate it on the server's claimed id.
|
|
43
|
+
*
|
|
44
|
+
* The same file is in each room bridge (claude, grok, muse, openai); keep the
|
|
45
|
+
* copies identical.
|
|
46
|
+
*/
|
|
47
|
+
export type OwnerStatus = "owner" | "not_owner" | "unknown";
|
|
48
|
+
export interface OwnerGrantChannel {
|
|
49
|
+
ownerDevicesGeneration?: () => number;
|
|
50
|
+
isCurrentOwnerDevice?: (deviceId: string | null | undefined) => Promise<boolean>;
|
|
51
|
+
/** #1826 M3: the tri-state re-check (absent on an older plugin). */
|
|
52
|
+
ownerDeviceStatus?: (deviceId: string | null | undefined) => Promise<OwnerStatus>;
|
|
53
|
+
on?: (event: string, listener: (...args: any[]) => void) => unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface OwnerGrant {
|
|
56
|
+
readonly senderDeviceId?: string;
|
|
57
|
+
/** The channel's owner-list generation when SecureChannel decided `ownerDm1to1`. */
|
|
58
|
+
readonly ownerDevicesGen?: number;
|
|
59
|
+
/** This bridge's count of `owner_devices_changed` events when the grant was taken. */
|
|
60
|
+
readonly changes: number;
|
|
61
|
+
/** #1826 M3: taken from a 1:1 the channel could not confirm (`senderOwnerStatus: "unknown"`): always re-checked. */
|
|
62
|
+
readonly unconfirmed?: boolean;
|
|
63
|
+
/** #1800 PR D: taken from a frame whose sender is not BOUND: never the owner, never re-checked. */
|
|
64
|
+
readonly unbound?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* #1826 M3 — the owner verdict a 1:1 arrived with. `"owner"` only for
|
|
68
|
+
* `ownerDm1to1 === true`; `"unknown"` only when the channel says it could not
|
|
69
|
+
* confirm (`senderOwnerStatus: "unknown"`); anything else, an older plugin
|
|
70
|
+
* included, is `"not_owner"` — today's unattested behaviour.
|
|
71
|
+
*
|
|
72
|
+
* #1800 PR D: both `"owner"` and `"unknown"` also need `senderBinding ===
|
|
73
|
+
* "bound"`. An unbound frame (or one with no verdict) is `"not_owner"`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function handoverOwnerStatus(metadata: unknown): OwnerStatus;
|
|
76
|
+
export declare class OwnerGrants {
|
|
77
|
+
private readonly channel;
|
|
78
|
+
private changes;
|
|
79
|
+
/** `subscribe: false` when the caller registers `owner_devices_changed` itself (to remove it on stop). */
|
|
80
|
+
constructor(channel: OwnerGrantChannel, subscribe?: boolean);
|
|
81
|
+
/** `owner_devices_changed`: every grant taken before now is downgraded. */
|
|
82
|
+
changed(): void;
|
|
83
|
+
/** Record the grant of an owner-attested 1:1 message, at queue time. */
|
|
84
|
+
grant(metadata: unknown): OwnerGrant;
|
|
85
|
+
/** Has the owner list changed since this grant was taken? */
|
|
86
|
+
downgraded(grant: OwnerGrant): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* At release: does the grant still stand? Fails closed. A grant the owner
|
|
89
|
+
* list has not changed under answers `true` SYNCHRONOUSLY, so a caller that
|
|
90
|
+
* skips the await on `true` releases an untouched turn on the same tick it
|
|
91
|
+
* always did; only a downgraded grant waits for the re-check.
|
|
92
|
+
*/
|
|
93
|
+
confirm(grant: OwnerGrant): true | Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* #1826 M3 — the tri-state twin of `confirm()`. `"owner"` synchronously for
|
|
96
|
+
* an untouched grant. Otherwise the channel's `ownerDeviceStatus` (a throw or
|
|
97
|
+
* an unrecognised answer is `"unknown"`: nothing was confirmed). An older
|
|
98
|
+
* plugin with only `isCurrentOwnerDevice` answers `"owner"`/`"not_owner"` as
|
|
99
|
+
* before (a throw there is `"not_owner"`, today's fail-closed behaviour).
|
|
100
|
+
* No sender id is `"not_owner"`.
|
|
101
|
+
*
|
|
102
|
+
* #1800 PR D: an UNBOUND grant is `"not_owner"` before anything else, and
|
|
103
|
+
* the channel is never asked (no re-check of an unbound frame).
|
|
104
|
+
*/
|
|
105
|
+
confirmStatus(grant: OwnerGrant): "owner" | Promise<OwnerStatus>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* #1826 M3 — how long a release waits for an `"unknown"` to become an answer:
|
|
109
|
+
* re-asked after each delay (the plugin retries a failed owner-list read on a
|
|
110
|
+
* short backoff), so a deploy blip costs the owner a few seconds, not a
|
|
111
|
+
* limited turn. Still `"unknown"` after the last one: the turn runs limited.
|
|
112
|
+
*/
|
|
113
|
+
export declare const UNKNOWN_RETRY_MS: readonly number[];
|
|
114
|
+
/**
|
|
115
|
+
* #1826 review round 2 (L5) — the most one release re-check may take in all:
|
|
116
|
+
* every read, every retry delay, every read timeout. Past it the answer is
|
|
117
|
+
* `"unknown"` (limited, and a persistent lane is tainted), so a backend outage
|
|
118
|
+
* costs a serial queue at most this per unconfirmed turn.
|
|
119
|
+
*/
|
|
120
|
+
export declare const UNKNOWN_RECHECK_BUDGET_MS = 5000;
|
|
121
|
+
/**
|
|
122
|
+
* `confirmStatus()`, re-asked while the answer is `"unknown"` (bounded by
|
|
123
|
+
* `delays`, and in total by `budgetMs`). `"owner"` synchronously for an
|
|
124
|
+
* untouched grant, as before.
|
|
125
|
+
*/
|
|
126
|
+
export declare function confirmStatusRetrying(grants: OwnerGrants, grant: OwnerGrant, delays?: readonly number[], budgetMs?: number): "owner" | Promise<OwnerStatus>;
|
|
127
|
+
/** Settle a `confirmStatus()` answer (or a caller's own closure); a rejection is `"unknown"`. */
|
|
128
|
+
export declare function settleOwnerStatus(verdict: "owner" | Promise<OwnerStatus>): Promise<OwnerStatus>;
|
|
129
|
+
/** Settle a `confirm()` answer (or a caller's own confirm closure), failing closed. */
|
|
130
|
+
export declare function settleOwnerGrant(verdict: true | Promise<boolean>): Promise<boolean>;
|
|
131
|
+
//# sourceMappingURL=owner-grant.d.ts.map
|
package/dist/room-context.d.ts
CHANGED
|
@@ -50,6 +50,19 @@ export interface RoomContextEntry {
|
|
|
50
50
|
text: string;
|
|
51
51
|
/** ISO time the message was sent (from the emit), or received if absent. */
|
|
52
52
|
at: string;
|
|
53
|
+
/**
|
|
54
|
+
* #1762 PR-C — opaque to this buffer: the held message's turn authority
|
|
55
|
+
* (a parked FileTurn). Handed back by `take()` when the context is
|
|
56
|
+
* delivered, and to `onDrop` when the entry leaves WITHOUT being delivered
|
|
57
|
+
* (overflow, the room evicted, `clear`) — a true drop.
|
|
58
|
+
*/
|
|
59
|
+
turn?: unknown;
|
|
60
|
+
/**
|
|
61
|
+
* #1762 PR-C: not from this agent's own owner (an agent, another account,
|
|
62
|
+
* an unknown sender, or a foreign file). Delivered to the listener, it
|
|
63
|
+
* taints the lane's session (session-taint.ts). Absent reads as foreign.
|
|
64
|
+
*/
|
|
65
|
+
foreign?: boolean;
|
|
53
66
|
}
|
|
54
67
|
export interface RoomContextLimits {
|
|
55
68
|
/** Messages kept per room. */
|
|
@@ -77,17 +90,29 @@ export declare function sanitizeLabel(name: string, max?: number): string;
|
|
|
77
90
|
/** A fresh per-turn delimiter id: 12 hex chars from 6 random bytes. */
|
|
78
91
|
export declare function newContextId(): string;
|
|
79
92
|
export declare class RoomContextBuffer {
|
|
93
|
+
/** #1762 PR-C: an entry left without being delivered (overflow, room evicted, `clear`). */
|
|
94
|
+
private readonly onDrop;
|
|
80
95
|
private readonly limits;
|
|
81
96
|
/** Insertion order IS recency order: a touched room is re-inserted at the end. */
|
|
82
97
|
private rooms;
|
|
83
|
-
constructor(limits?: Partial<RoomContextLimits
|
|
98
|
+
constructor(limits?: Partial<RoomContextLimits>,
|
|
99
|
+
/** #1762 PR-C: an entry left without being delivered (overflow, room evicted, `clear`). */
|
|
100
|
+
onDrop?: (entry: RoomContextEntry) => void);
|
|
101
|
+
private dropped;
|
|
84
102
|
add(roomId: string, entry: RoomContextEntry): void;
|
|
85
103
|
/** The held messages for a room, oldest first. Does not clear. */
|
|
86
104
|
peek(roomId: string): {
|
|
87
105
|
entries: readonly RoomContextEntry[];
|
|
88
106
|
dropped: number;
|
|
89
107
|
};
|
|
108
|
+
/** The room's held messages leave WITHOUT being delivered (room left, pruned): a true drop. */
|
|
90
109
|
clear(roomId: string): void;
|
|
110
|
+
/**
|
|
111
|
+
* #1762 PR-C — the room's held messages were DELIVERED with a turn: remove
|
|
112
|
+
* and return them (with their `turn`), so the caller folds each into it.
|
|
113
|
+
* Never calls `onDrop`.
|
|
114
|
+
*/
|
|
115
|
+
take(roomId: string): RoomContextEntry[];
|
|
91
116
|
size(roomId: string): number;
|
|
92
117
|
chars(roomId: string): number;
|
|
93
118
|
roomCount(): number;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1800 PR D — this bridge's defence in depth for the sender binding that
|
|
3
|
+
* SecureChannel does (#1800 PR B, design-1800 §3.3, sinks 7-9).
|
|
4
|
+
*
|
|
5
|
+
* SecureChannel binds a frame's server-claimed `sender_device_id` to the MLS
|
|
6
|
+
* leaf that signed it and stamps the verdict as `senderBinding`. Only
|
|
7
|
+
* `"bound"` may carry anything a known sender gets. The channel already strips
|
|
8
|
+
* an unbound frame (no `senderDeviceId`, `ownerDm1to1: false`,
|
|
9
|
+
* `senderOwnerStatus: "not_owner"`, `senderIsAgent` undefined, label
|
|
10
|
+
* "Unverified sender"). This bridge does not rely on that: it keys on the
|
|
11
|
+
* verdict itself, so a future plugin regression that stamps owner fields on an
|
|
12
|
+
* unbound frame still buys that frame nothing here.
|
|
13
|
+
*
|
|
14
|
+
* - A 1:1 is the owner's only when `senderBinding === "bound"`
|
|
15
|
+
* (`owner-grant.ts`: `handoverOwnerStatus`, `grant`, `confirmStatus`).
|
|
16
|
+
* - A room sender that is not bound is NOT a known human: the room protocol
|
|
17
|
+
* (`@all`, a plain-name summon, the private-room rule, the agent-loop brake
|
|
18
|
+
* and so `replyExpected`) sees it as it sees an agent. `@name` still works.
|
|
19
|
+
* - It is labelled "Unverified sender", never by the name the server's claim
|
|
20
|
+
* would resolve to; it is never the owner and carries no device id.
|
|
21
|
+
* - A history line recorded from an unbound sender reads "unverified sender"
|
|
22
|
+
* in any seed built from it, never "owner".
|
|
23
|
+
*
|
|
24
|
+
* A MISSING verdict is unbound (fail closed): this bridge bundles the plugin,
|
|
25
|
+
* so there is no older emitter to be kind to, and a future emit site that
|
|
26
|
+
* forgets the field must not fall back to believing the wire.
|
|
27
|
+
*
|
|
28
|
+
* The same file is in each room bridge (claude, grok, muse, openai); keep the
|
|
29
|
+
* copies identical.
|
|
30
|
+
*/
|
|
31
|
+
/** What an unbound sender is called, everywhere a name would appear. */
|
|
32
|
+
export declare const UNVERIFIED_SENDER = "Unverified sender";
|
|
33
|
+
/** The label a seed gives a history line from an unbound sender. */
|
|
34
|
+
export declare const UNVERIFIED_HISTORY_SENDER = "unverified sender";
|
|
35
|
+
/** True only when SecureChannel bound this frame's claimed sender to its MLS sender. A missing verdict is not bound. */
|
|
36
|
+
export declare function isBoundSender(metadata: unknown): boolean;
|
|
37
|
+
/** The room-sender fields a bridge may act on, after the binding. */
|
|
38
|
+
export interface RoomSenderView {
|
|
39
|
+
/** The name the model and the logs see. */
|
|
40
|
+
senderName: string;
|
|
41
|
+
/**
|
|
42
|
+
* What the room protocol sees. A bound sender keeps SecureChannel's
|
|
43
|
+
* classification (`undefined` for an unknown roster member, as before). An
|
|
44
|
+
* unbound sender is `true`: not a known human, so no `@all`, no plain-name
|
|
45
|
+
* summon, no private-room turn, and it is answered only when it `@names`
|
|
46
|
+
* this agent — exactly as an agent sender is (the plugin's OpenClaw gate
|
|
47
|
+
* does the same, `openclaw-entry.ts`).
|
|
48
|
+
*/
|
|
49
|
+
senderIsAgent: boolean | undefined;
|
|
50
|
+
/** #1459 owner power: never for an unbound sender. */
|
|
51
|
+
senderIsOwner: boolean | undefined;
|
|
52
|
+
/** The bound device id only; never the claim. */
|
|
53
|
+
senderDeviceId?: string;
|
|
54
|
+
/** True when the sender is not bound (a missing verdict included). */
|
|
55
|
+
unverifiedSender: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** One room frame's sender, as this bridge may use it. */
|
|
58
|
+
export declare function roomSenderView(metadata: {
|
|
59
|
+
senderBinding?: unknown;
|
|
60
|
+
senderName?: unknown;
|
|
61
|
+
senderIsAgent?: unknown;
|
|
62
|
+
senderIsOwner?: unknown;
|
|
63
|
+
senderDeviceId?: unknown;
|
|
64
|
+
} | null | undefined): RoomSenderView;
|
|
65
|
+
/**
|
|
66
|
+
* The sender label a seed gives one history line. SecureChannel's read APIs
|
|
67
|
+
* return `"unverified"` for a line recorded from an unbound sender (#1800 PR
|
|
68
|
+
* B); that line reads "unverified sender", never "owner". An `unverified:
|
|
69
|
+
* true` flag on the entry, or a missing or empty sender, reads the same. Any
|
|
70
|
+
* other label (`"owner"`, `"agent"`, and #1848's `"member"` for a room or
|
|
71
|
+
* 1:1 line from anyone but the bound owner) is kept as it was.
|
|
72
|
+
*/
|
|
73
|
+
export declare function historySenderLabel(entry: {
|
|
74
|
+
sender?: unknown;
|
|
75
|
+
unverified?: unknown;
|
|
76
|
+
} | null | undefined): string;
|
|
77
|
+
//# sourceMappingURL=sender-binding.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type Lane = "owner" | "shared";
|
|
2
|
+
/**
|
|
3
|
+
* Muse Code versions the §2.2 facts were measured on (2026-11-17): the fence
|
|
4
|
+
* layout (one HOME for both lanes: `sessions/`, `session-index.db`), the
|
|
5
|
+
* `exec` flags the bridge passes, and `session-message` existing. NOT a proof
|
|
6
|
+
* of session isolation (the binary is closed). Add a version only after
|
|
7
|
+
* re-measuring those facts on it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const VERIFIED_MUSE_VERSIONS: ReadonlySet<string>;
|
|
10
|
+
export declare class LaneTaint {
|
|
11
|
+
private readonly opts;
|
|
12
|
+
/** Tainted until `begin()` proves the session new: fail closed before start. */
|
|
13
|
+
private tainted;
|
|
14
|
+
private sessionId?;
|
|
15
|
+
/** The record as it stood when this lane's session began (what a resume carries over). */
|
|
16
|
+
private prior?;
|
|
17
|
+
/** The muse version read at boot is in the verified set. Per process; never persisted. */
|
|
18
|
+
private cliVerified;
|
|
19
|
+
/**
|
|
20
|
+
* #1786 review (MEDIUM): the in-memory state is on disk. Set only when the
|
|
21
|
+
* rename succeeds; a failed write clears it, so the next taint RETRIES —
|
|
22
|
+
* otherwise disk keeps begin()'s clean record and a restart resumes the
|
|
23
|
+
* lane clean on a dirty transcript. (No file configured: nothing to save.)
|
|
24
|
+
*/
|
|
25
|
+
private saved;
|
|
26
|
+
/**
|
|
27
|
+
* #1786 review — the muse binary guard (muse-binary.ts): true while the muse
|
|
28
|
+
* that boot checked is still the one on disk. Consulted on every
|
|
29
|
+
* `isTainted()` (each push); false — or a throw — taints this lane durably.
|
|
30
|
+
*/
|
|
31
|
+
private guard?;
|
|
32
|
+
private readonly verified;
|
|
33
|
+
constructor(opts: {
|
|
34
|
+
lane: Lane;
|
|
35
|
+
file?: string;
|
|
36
|
+
log?: (m: string) => void;
|
|
37
|
+
verifiedVersions?: ReadonlySet<string>;
|
|
38
|
+
});
|
|
39
|
+
get lane(): Lane;
|
|
40
|
+
/**
|
|
41
|
+
* The lane's session is starting. `resumeSessionId` set means it RESUMES
|
|
42
|
+
* that session (its transcript carries over): the recorded taint for that id
|
|
43
|
+
* applies, and no record means tainted. Unset means a genuinely new session
|
|
44
|
+
* (a minted id): clean — unless input is already QUEUED for it.
|
|
45
|
+
*/
|
|
46
|
+
begin(o?: {
|
|
47
|
+
resumeSessionId?: string;
|
|
48
|
+
sessionId?: string;
|
|
49
|
+
queued?: number;
|
|
50
|
+
}): void;
|
|
51
|
+
/**
|
|
52
|
+
* The lane now runs on session `id` (#1560 recovery replaced a stale one).
|
|
53
|
+
* Never clears the taint: the new session inherits the lane's. An id equal
|
|
54
|
+
* to the recorded tainted one is a resume and stays tainted.
|
|
55
|
+
*/
|
|
56
|
+
noteSessionId(id: unknown): void;
|
|
57
|
+
/**
|
|
58
|
+
* The muse version this process runs (`muse --version`, read at boot). A
|
|
59
|
+
* verified one lets the lane attest; any other — or none — taints it
|
|
60
|
+
* durably (fail closed).
|
|
61
|
+
*/
|
|
62
|
+
noteCliVersion(version: unknown): void;
|
|
63
|
+
/** Non-eligible content entered this lane: taint it, durably. */
|
|
64
|
+
taint(reason: string): void;
|
|
65
|
+
/** #1786 review: install the binary guard (index.ts, at boot). */
|
|
66
|
+
setGuard(guard: () => boolean): void;
|
|
67
|
+
/** No room file from this lane: tainted, the muse version not (yet) confirmed verified, or the binary changed. */
|
|
68
|
+
isTainted(): boolean;
|
|
69
|
+
private read;
|
|
70
|
+
private write;
|
|
71
|
+
}
|
|
72
|
+
/** Both lanes' taints. */
|
|
73
|
+
export interface LaneTaints {
|
|
74
|
+
owner: LaneTaint;
|
|
75
|
+
shared: LaneTaint;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=session-taint.d.ts.map
|
package/package.json
CHANGED