@agentvault/muse-bridge 0.1.45 → 0.1.46

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 CHANGED
@@ -120,6 +120,22 @@ bridge stops. The log line is
120
120
  the answer was already on its way, so nothing more is posted. The bridge waits at
121
121
  most 10 seconds for these sentences and 15 seconds for the whole stop.
122
122
 
123
+ ## Sending files (#1762)
124
+
125
+ The agent can send one file at a time with the `send_file` tool, beside `say`. The file goes to the conversation the agent is answering; the model cannot pick a different one.
126
+
127
+ - **Where files are staged.** Each chat has its own staging folder inside the workspace (default `~/.agentvault/muse-room-bridge/workspaces/<agent>`):
128
+ - for the 1:1 chat: `agentvault-outbox/<agent>-<8 hex>/dm/`;
129
+ - for each room: `agentvault-outbox/<agent>-<8 hex>/rooms/<room id>/`.
130
+
131
+ Every turn starts with one line naming that turn's folder, relative to the workspace, for example `[AgentVault: Files for this chat: stage them in your outbox at agentvault-outbox/rookie-1a2b3c4d/dm/.]`.
132
+ - **Rooms.** A file goes into a room only when your own owner asked for it in that room, on a turn that carries no other member's words, from a muse session that has never seen anyone else's words. It must come from that room's own folder. With full access on (both switches), your room turns run on the owner session, which only you write to, so they can share files even in a busy room.
133
+ - **Sessions that have seen other people's words.** The bridge keeps two muse sessions (the owner's and a shared one) and records, per session, whether anyone else's words ever entered it (`muse-owner-session-taint.json`, `muse-shared-session-taint.json` in the data dir). A session that has seen them cannot share room files until it is replaced. **Sessions from before this version count as having seen them.**
134
+ - **Muse version.** Room files need a muse version the bridge was checked against (today Muse Code 1.4.23). The bridge logs `muse version: …` at start. Any other version marks both sessions as having seen other people's words, and you'll need the reset below after moving to a checked version. Muse's launcher updates itself. If it replaces muse while the bridge is running, the bridge notices before the next turn and marks both sessions the same way.
135
+ - **Reset a session (so it can share room files again).** Stop the bridge, delete `muse-owner-session-id` (the owner session) or `muse-session-id` (the shared one) from the data dir, and start it again. The bridge starts a brand-new session. That session's conversation history is gone.
136
+ - **Never a false "sent".** `send_file` answers `File sent: …` only when the file actually left. Anything else is `File NOT sent: <reason>`, and the chat gets a one-line notice. If a reply says "I've attached …" when nothing was sent, the chat gets `(This reply has no attachment.)`.
137
+ - **Retention.** The bridge never deletes anything in `dm/` or `rooms/<id>/`: those files stay until you remove them. When the agent leaves a room, that room's folder moves to `agentvault-outbox/<agent>-<8 hex>/left/`, where nothing can be sent again. `left/` and the `.stale-*` entries keep only their newest three.
138
+
123
139
  ## Copied-from ledger — REVIEW PERIODICALLY
124
140
 
125
141
  These files were copied once from the Claude bridge and are now owned here. A fix
@@ -127,7 +143,10 @@ there does NOT reach us.
127
143
 
128
144
  | File | Copied from `packages/claude-room-bridge` at | Last reviewed |
129
145
  |---|---|---|
130
- | `src/room-context.ts` | PR #1458 (created there, 2026-10-26) | PR #1458 |
146
+ | `src/room-context.ts` | PR #1458 (created there, 2026-10-26); #1762 PR-C park/take/onDrop at `e4de3c0d` | `e4de3c0d` |
147
+ | `src/file-turn.ts` | `e4de3c0d` (PR-C) — kept byte-identical (a test pins it) | `e4de3c0d` |
148
+ | `src/channel-config.ts` | `e4de3c0d` (PR-C); taint helper differs | `e4de3c0d` |
149
+ | `src/session-taint.ts` | `src/listener-taint.ts` at `e4de3c0d` (PR-C); one record per lane, no CLI gate | `e4de3c0d` |
131
150
 
132
151
  To review one:
133
152
 
package/dist/bridge.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  import { type ToolSpanSink } from "@agentvault/agentvault";
5
5
  import { type RoomSession, type TurnFailedReport } from "./muse-session.js";
6
6
  import { type RoomContextLimits } from "./room-context.js";
7
+ import type { MessageMetadata } from "@agentvault/agentvault";
7
8
  export declare function workAllowed(): boolean;
8
9
  export declare function gatesRemoved(): boolean;
9
10
  export declare function resetOwnerPower(): void;
@@ -14,6 +15,8 @@ export interface RoomMessage {
14
15
  /** #1223 — the text the sender typed, before any attachment was folded into
15
16
  * `plaintext`. The @ gate reads this; absent on emitters < 0.23.42. */
16
17
  caption?: string;
18
+ /** #1800 PR D: `true` for a sender that is not BOUND (`roomSenderView`), so
19
+ * the room protocol never treats an unverified sender as a known human. */
17
20
  senderIsAgent?: boolean;
18
21
  /** #1574 — SecureChannel: the room's audience, "private_pair" or "group".
19
22
  * Passed through to owesRoomReply untyped; anything but "private_pair"
@@ -28,6 +31,10 @@ export interface RoomMessage {
28
31
  /** ISO send time from the emit (`data.created_at`). Used to stamp a message
29
32
  * held as room context; receipt time stands in when absent. */
30
33
  timestamp?: string;
34
+ /** #1762 PR-M: the sender's device id (a neutral label for another account's member). #1800 PR D: bound only. */
35
+ senderDeviceId?: string;
36
+ /** #1800 PR D: the sender is not BOUND to its MLS sender (a missing verdict included). */
37
+ unverifiedSender?: boolean;
31
38
  }
32
39
  export interface MessageMeta {
33
40
  roomId?: string;
@@ -42,6 +49,10 @@ export interface MessageMeta {
42
49
  * places the person even when the conversation is not mapped yet. */
43
50
  conversationGroupId?: string;
44
51
  ownerDm1to1?: boolean;
52
+ /** #1820 part 2 — the sending device, from the server's delivery row. */
53
+ senderDeviceId?: string;
54
+ /** #1820 part 2 — SecureChannel's owner-list generation when `ownerDm1to1` was decided. */
55
+ ownerDevicesGen?: number;
45
56
  }
46
57
  export interface RoomHushed {
47
58
  roomId: string;
@@ -84,7 +95,11 @@ export interface RoomChannel {
84
95
  }
85
96
  /** The part of a SecureChannel history entry a seed uses. */
86
97
  export interface HistoryLine {
98
+ /** `"owner"`, `"agent"`, (#1800 PR B) `"unverified"` for an unbound sender's line, or
99
+ * (#1848 review) `"member"` for a room or 1:1 line from anyone but the bound owner. */
87
100
  sender: string;
101
+ /** #1800 PR D: honoured if an entry ever carries the flag itself. */
102
+ unverified?: boolean;
88
103
  text: string;
89
104
  id?: string;
90
105
  ts?: string;
@@ -182,6 +197,23 @@ export declare function heldText(e: {
182
197
  }): string;
183
198
  /** The room as the model sees it: its name when known, else a short id. */
184
199
  export declare function roomLabel(roomId: string, roomName?: string): string;
200
+ /**
201
+ * #1762 PR-M — how an ATTESTED turn names its sender. An attested turn may
202
+ * send a file into the room, so nothing another account wrote may frame it.
203
+ * Its sender is this agent's own owner (SecureChannel attests only an
204
+ * eligible sender), whose own display name is kept. Anyone else — reachable
205
+ * only if that invariant ever broke — gets a neutral label plus a short id,
206
+ * never the name they chose.
207
+ *
208
+ * #1800 PR D (sink 7): a sender that is not BOUND is "Unverified sender",
209
+ * checked first — never its name, and never a device id from the wire.
210
+ */
211
+ export declare function attestedSenderLabel(e: {
212
+ senderName: string;
213
+ senderIsOwner?: boolean;
214
+ senderDeviceId?: string;
215
+ unverifiedSender?: boolean;
216
+ }): string;
185
217
  /**
186
218
  * Does this agent owe a reply to this room message? (#1107)
187
219
  *
@@ -200,6 +232,15 @@ export declare function roomLabel(roomId: string, roomName?: string): string;
200
232
  export declare function _makeOwesReply(agentName: string | undefined, channel: {
201
233
  ownDisplayName?: string;
202
234
  }, log: (msg: string) => void): (e: RoomMessage) => boolean;
235
+ /**
236
+ * #1800 PR D — the room message this bridge acts on, built from
237
+ * SecureChannel's `onMessage` metadata with every sender field taken through
238
+ * the binding (`roomSenderView`): a sender that is not BOUND (a missing
239
+ * verdict included) is "Unverified sender", never the owner, carries no
240
+ * device id, and is not a known human to the room protocol. Exported so the
241
+ * wiring itself is under test (#1848 review L1).
242
+ */
243
+ export declare function roomMessageFrom(metadata: MessageMetadata): RoomMessage;
203
244
  export declare function wireBridge(channel: RoomChannel, session: RoomSession, target: ActiveTarget, opts?: {
204
245
  /**
205
246
  * #1107: this agent's own name, used to recognise its own @mention. Threaded
@@ -211,5 +252,29 @@ export declare function wireBridge(channel: RoomChannel, session: RoomSession, t
211
252
  log?: (msg: string) => void;
212
253
  /** Test-only: override the room-context bounds (see room-context.ts). */
213
254
  roomContextLimits?: Partial<RoomContextLimits>;
255
+ /**
256
+ * #1762 PR-M — where the ONE turn consumer is attached: production passes
257
+ * the `TurnInbox` whose `onMessage` SecureChannel calls. Turns run ONLY
258
+ * from it; the `room_message` / `message` events are observation only.
259
+ */
260
+ inbox?: {
261
+ attach(consumer: (text: string, metadata: MessageMetadata) => void): void;
262
+ };
263
+ /**
264
+ * #1762 PR-M — each lane's taint (session-taint.ts): the OWNER lane (#1462)
265
+ * and the SHARED lane are each one persistent session for every room and
266
+ * the 1:1. Absent: no room turn is attested (fail closed), and seeds are
267
+ * unchanged.
268
+ */
269
+ laneTaints?: {
270
+ owner: {
271
+ isTainted(): boolean;
272
+ taint(reason: string): void;
273
+ };
274
+ shared: {
275
+ isTainted(): boolean;
276
+ taint(reason: string): void;
277
+ };
278
+ };
214
279
  }): void;
215
280
  //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * #1762 PR-M — the SecureChannel configuration this bridge runs with, in one
3
+ * place, so a test can build the REAL channel exactly as production does and
4
+ * prove the production wiring hands each turn a lease (design §11 R3-4 a′).
5
+ *
6
+ * COPIED from packages/claude-room-bridge/src/channel-config.ts at e4de3c0d
7
+ * (PR-C). Only the taint helper differs: muse's two lane taints, not Claude's
8
+ * listener taint.
9
+ *
10
+ * Two lines here are load-bearing for file sends:
11
+ * - `fileSend` opts in. Without it SecureChannel creates no staging folder and
12
+ * ends every token at mint (`turn_no_consumer`);
13
+ * - `onMessage` is the TurnInbox, the single turn consumer. Without it every
14
+ * token is dropped at mint and `send_file` answers `turn_no_consumer`.
15
+ */
16
+ import type { SecureChannelConfig } from "@agentvault/agentvault";
17
+ import type { TurnInbox } from "./file-turn.js";
18
+ import { type LaneTaints } from "./session-taint.js";
19
+ /** #1762 PR-M: each muse lane's durable taint record, in the data dir. */
20
+ export declare function bridgeLaneTaints(dataDir: string, log?: (m: string) => void): LaneTaints;
21
+ export interface BridgeChannelInputs {
22
+ inviteToken: string;
23
+ dataDir: string;
24
+ apiUrl: string;
25
+ agentName: string;
26
+ /** The agent's workspace: a 1:1 root that holds the outbox. */
27
+ workspaceDir: string;
28
+ /** `@agentvault/muse-bridge@<version>` (#836). */
29
+ clientVersion: string;
30
+ }
31
+ export declare function bridgeChannelConfig(cfg: BridgeChannelInputs, inbox: TurnInbox): SecureChannelConfig;
32
+ //# sourceMappingURL=channel-config.d.ts.map
@@ -0,0 +1,90 @@
1
+ import type { FileSendResult, FileSendTarget, MessageMetadata, TurnToken } from "@agentvault/agentvault";
2
+ /** The capability SecureChannel hands only to `onMessage`. */
3
+ export type TurnLease = NonNullable<MessageMetadata["turnLease"]>;
4
+ /** The SecureChannel surface a file turn uses. */
5
+ export interface FileTurnChannel {
6
+ sendFile(target: FileSendTarget, path: string, caption: string, turn: TurnToken | null): Promise<FileSendResult>;
7
+ stagingPathFor(target: FileSendTarget): string | null;
8
+ attestCleanTurn(lease: TurnLease): boolean;
9
+ parkTurn(lease: TurnLease): boolean;
10
+ foldTurn(folded: TurnLease, into: TurnLease): boolean;
11
+ endTurn(lease: TurnLease, opts?: {
12
+ replies?: readonly string[];
13
+ }): Promise<void>;
14
+ }
15
+ /** Does `ch` implement the file-turn surface (a SecureChannel with file send)? */
16
+ export declare function isFileTurnChannel(ch: unknown): ch is FileTurnChannel;
17
+ /** What a `send_file` call returns to the model. */
18
+ export interface SendFileOutcome {
19
+ ok: boolean;
20
+ /** "File sent: …" or "File NOT sent: …" (never a host path, R3-9). */
21
+ text: string;
22
+ }
23
+ export declare class FileTurn {
24
+ private readonly channel;
25
+ readonly lease: TurnLease;
26
+ readonly target: FileSendTarget;
27
+ private state;
28
+ private attested;
29
+ /** A held message's content entered this turn without a fold the registry accepted. */
30
+ private foreignInput;
31
+ private readonly replies;
32
+ private ending?;
33
+ private constructor();
34
+ /**
35
+ * Take the lease from `onMessage` metadata. Call it FIRST, synchronously,
36
+ * before anything that can throw or await. `null` when there is no lease
37
+ * (file send not opted into) or the channel has no file surface.
38
+ */
39
+ static take(channel: unknown, metadata: MessageMetadata | undefined, target: FileSendTarget): FileTurn | null;
40
+ /** The router's lane decision attested this room turn (and nothing has since cost it that). */
41
+ get isAttested(): boolean;
42
+ /** Not yet ended, dropped or folded. */
43
+ get open(): boolean;
44
+ /**
45
+ * The lane decision attests a clean room turn (§1.4, R3-5): call it ONLY
46
+ * when the lane that will run this turn receives no held context, and
47
+ * before the turn can run a tool. 1:1 turns need no attestation.
48
+ */
49
+ attest(): boolean;
50
+ /** The content is HELD (room context), in no turn's input yet. Later: absorb() or drop(). */
51
+ park(): void;
52
+ /**
53
+ * `held`'s content is delivered into THIS turn (§11 R3-4: content enters a
54
+ * turn only through `foldTurn`). `held` then ends with this turn, and a
55
+ * foreign one downgrades it. A fold the registry refuses still marks this
56
+ * turn as carrying foreign input, so it can never send a room file.
57
+ */
58
+ absorb(held: FileTurn | null | undefined): void;
59
+ /** Something the agent said in this turn (say, or the #416 fallback): read by the §4.4 prose check. */
60
+ noteReply(text: string): void;
61
+ /** The turn is over. Once; never throws. Ends whatever was folded into it. */
62
+ end(): Promise<void>;
63
+ /** A TRUE drop: this message's content never enters any turn. */
64
+ drop(): Promise<void>;
65
+ private endNow;
66
+ /** The `[AgentVault: …]` line that tells the model where this conversation's files go (§2, R3-9). */
67
+ stagingNote(): string;
68
+ /** `send_file`: the turn's own conversation, the turn's own token. Never throws. */
69
+ send(path: unknown, caption: unknown): Promise<SendFileOutcome>;
70
+ }
71
+ /**
72
+ * What `SecureChannelConfig.onMessage` points at. SecureChannel is built
73
+ * before `wireBridge` runs, so the consumer is attached late; until it is, a
74
+ * message is a true drop and its lease is ended (never leaked).
75
+ */
76
+ export declare class TurnInbox {
77
+ private consumer?;
78
+ private channel?;
79
+ /** Pass as `onMessage`. Reads the lease synchronously; never queues. */
80
+ readonly onMessage: (text: string, metadata: MessageMetadata) => void;
81
+ /** The channel, so an unconsumed message's lease can be ended. */
82
+ bindChannel(channel: {
83
+ endTurn(lease: TurnLease, opts?: {
84
+ replies?: readonly string[];
85
+ }): Promise<void>;
86
+ }): void;
87
+ /** wireBridge's one consumer. A second attach replaces the first (there is one claimant). */
88
+ attach(consumer: (text: string, metadata: MessageMetadata) => void): void;
89
+ }
90
+ //# sourceMappingURL=file-turn.d.ts.map
@@ -1,4 +1,9 @@
1
- /** The bridge-controlled agent identity prompt (no workspace file may supply it). */
1
+ /**
2
+ * #1762 PR-M (§4.3) — the file rule, appended to the identity the model runs
3
+ * with, so the model actually receives it: MuseSession prepends this to EVERY
4
+ * turn. `sendFileTool` is the name the MODEL sees (`send_file`). Idempotent.
5
+ */
6
+ export declare function withFileSendRule(identity: string, sendFileTool: string): string;
2
7
  /**
3
8
  * How a room works, as this bridge now delivers it (PR #1458). The old line —
4
9
  * "In a room you see every message" — stopped being true when unaddressed room
package/dist/index.d.ts CHANGED
@@ -26,6 +26,11 @@ export interface MainOpts {
26
26
  agentName: string;
27
27
  platform: string;
28
28
  clientVersion: string;
29
+ /** #1762 PR-M: the production config's file-send opt-in and its one turn consumer. */
30
+ fileSend?: {
31
+ workspaceDir?: string;
32
+ };
33
+ onMessage?: (text: string, metadata: import("@agentvault/agentvault").MessageMetadata) => void;
29
34
  }) => BootChannel;
30
35
  exit?: (code: number) => void;
31
36
  backend?: ServiceBackend;