@agentvault/claude-bridge 0.8.42 → 0.8.44
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 +13 -0
- package/dist/bridge.d.ts +44 -1
- package/dist/channel-config.d.ts +28 -0
- package/dist/file-turn.d.ts +90 -0
- package/dist/identity-prompt.d.ts +6 -1
- package/dist/index.js +8395 -1563
- package/dist/listener-taint.d.ts +55 -0
- package/dist/owner-grant.d.ts +131 -0
- package/dist/room-context.d.ts +26 -1
- package/dist/router.d.ts +40 -10
- package/dist/sdk-env.d.ts +107 -0
- package/dist/sender-binding.d.ts +77 -0
- package/dist/service/spec.d.ts.map +1 -1
- package/dist/session.d.ts +34 -0
- package/dist/worker-queue.d.ts +11 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -81,6 +81,19 @@ The local `logs/worker-incidents.jsonl` file records the same code for each fail
|
|
|
81
81
|
|
|
82
82
|
**Saved sessions.** This bridge does not save or resume a Claude Code session between runs, so there is no saved session to lose. Each tool turn runs in a fresh session, and the always-on session starts fresh when the bridge restarts.
|
|
83
83
|
|
|
84
|
+
## Sending files (#1762)
|
|
85
|
+
|
|
86
|
+
The agent can send one file at a time with the `send_file` tool. It sits beside `say` in both the always-on session and the tool worker. The file goes to the conversation the agent is answering. The model cannot pick a different one.
|
|
87
|
+
|
|
88
|
+
- **Where files are staged.** Each chat has its own staging folder inside the workspace (default `~/.agentvault/claude-room-bridge/workspaces/<agent>`):
|
|
89
|
+
- for the 1:1 chat: `agentvault-outbox/<agent>-<8 hex>/dm/`;
|
|
90
|
+
- for each room: `agentvault-outbox/<agent>-<8 hex>/rooms/<room id>/`.
|
|
91
|
+
|
|
92
|
+
Every turn starts with one line that names that turn's folder, relative to the workspace, for example `[AgentVault: Files for this chat: stage them in your outbox at agentvault-outbox/loopita-1a2b3c4d/dm/.]`.
|
|
93
|
+
- **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. It must also come from that room's own folder.
|
|
94
|
+
- **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.)`.
|
|
95
|
+
- **Retention.** The bridge never deletes anything in `dm/` or `rooms/<id>/`. Those files stay until you remove them, because they may be the only copy of a deliverable. When the agent leaves a room, that room's folder moves to `agentvault-outbox/<agent>-<8 hex>/left/`. Nothing in `left/` can be sent again. `left/` and the `.stale-*` entries keep only their newest three.
|
|
96
|
+
|
|
84
97
|
## Security model
|
|
85
98
|
|
|
86
99
|
- Sessions run with `permissionMode: "default"` and `allowedTools: []` — no
|
package/dist/bridge.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { type ToolConversation, type ToolSpanSink } from "@agentvault/agentvault
|
|
|
2
2
|
import { ArmingState } from "./arming.js";
|
|
3
3
|
import { type TerminalVerdict } from "./service/self-uninstall.js";
|
|
4
4
|
import { type RoomContextLimits } from "./room-context.js";
|
|
5
|
+
import { FileTurn } from "./file-turn.js";
|
|
6
|
+
import type { MessageMetadata } from "@agentvault/agentvault";
|
|
5
7
|
export interface RoomMessage {
|
|
6
8
|
roomId: string;
|
|
7
9
|
senderName: string;
|
|
@@ -10,8 +12,14 @@ export interface RoomMessage {
|
|
|
10
12
|
* `plaintext`. The @ gate reads this; absent on emitters < 0.23.42. */
|
|
11
13
|
caption?: string;
|
|
12
14
|
/** SecureChannel's sender classification. Only an explicit false authorizes
|
|
13
|
-
* room tools; reply eligibility is independently decided by the @ protocol.
|
|
15
|
+
* room tools; reply eligibility is independently decided by the @ protocol.
|
|
16
|
+
* #1800 PR D: `true` for a sender that is not BOUND (`roomSenderView`), so
|
|
17
|
+
* the room protocol never treats an unverified sender as a known human. */
|
|
14
18
|
senderIsAgent?: boolean;
|
|
19
|
+
/** #1855 — SecureChannel's binding verdict for this frame, as emitted. Handed
|
|
20
|
+
* to owesRoomReply (9th argument), which refuses @all unless it is "bound";
|
|
21
|
+
* absent (a RoomMessage built without it) reads as unverified there. */
|
|
22
|
+
senderBinding?: unknown;
|
|
15
23
|
/** #1574 — SecureChannel: the room's audience, "private_pair" or "group".
|
|
16
24
|
* Passed through to owesRoomReply untyped; anything but "private_pair"
|
|
17
25
|
* (absent on emitters before #1574) reads as a group room. */
|
|
@@ -60,6 +68,10 @@ export interface MessageMeta {
|
|
|
60
68
|
/** #621 — set by SecureChannel when the message decrypted under the owner's
|
|
61
69
|
* 1:1 material. Gates the full-access DM lane; see the `message` handler. */
|
|
62
70
|
ownerDm1to1?: boolean;
|
|
71
|
+
/** #1820 part 2 — the sending device, from the server's delivery row. */
|
|
72
|
+
senderDeviceId?: string;
|
|
73
|
+
/** #1820 part 2 — SecureChannel's owner-list generation when `ownerDm1to1` was decided. */
|
|
74
|
+
ownerDevicesGen?: number;
|
|
63
75
|
}
|
|
64
76
|
/** #392 room hush (advisory) — emitted by SecureChannel from the backend's
|
|
65
77
|
* `room_hushed` event. ``hushedUntil`` is an ISO string, or null when cleared. */
|
|
@@ -94,6 +106,14 @@ export interface RoomChannel {
|
|
|
94
106
|
* `"disconnected"` (or `"error"`), and a completed reconnect as `"ready"`
|
|
95
107
|
* (both the dedicated `state` value AND the separate `"ready"` event). */
|
|
96
108
|
on(ev: "state", cb: (s: string) => void): unknown;
|
|
109
|
+
/** #1820 part 2: an owner device was revoked, removed, suspended or added (content-free). */
|
|
110
|
+
on(ev: "owner_devices_changed", cb: (e?: {
|
|
111
|
+
generation?: number;
|
|
112
|
+
}) => void): unknown;
|
|
113
|
+
/** #1820 part 2: SecureChannel's owner-list generation (absent on an older plugin). */
|
|
114
|
+
ownerDevicesGeneration?(): number;
|
|
115
|
+
/** #1820 part 2: a fail-closed re-check against a fresh owner list (absent on an older plugin). */
|
|
116
|
+
isCurrentOwnerDevice?(deviceId: string | null | undefined): Promise<boolean>;
|
|
97
117
|
sendToRoom(roomId: string, text: string): Promise<void>;
|
|
98
118
|
send(text: string): Promise<void>;
|
|
99
119
|
/** Optional so legacy/test fakes without arming support don't break wiring. */
|
|
@@ -149,6 +169,12 @@ export interface RoomSession {
|
|
|
149
169
|
conversation?: ToolConversation;
|
|
150
170
|
/** #1583: true once this room is hushed. A shutdown notice stays out of it. */
|
|
151
171
|
hushed?: () => boolean;
|
|
172
|
+
/** #1762 PR-C: this message's turn authority — attested at the router's lane decision. */
|
|
173
|
+
fileTurn?: FileTurn;
|
|
174
|
+
/** #1762 PR-C: the same turn text with the room named by its short id (used only if attested). */
|
|
175
|
+
textIfAttested?: string;
|
|
176
|
+
/** #1762 PR-C: false only when all of this push's content is the owner's own (taints the listener otherwise). */
|
|
177
|
+
foreignInput?: boolean;
|
|
152
178
|
}): unknown;
|
|
153
179
|
}
|
|
154
180
|
/** Where a reply should go: a room (sendToRoom) or a 1:1 DM (send). */
|
|
@@ -313,6 +339,15 @@ export declare function roomLabel(roomId: string, roomName?: string): string;
|
|
|
313
339
|
export declare function _makeOwesReply(agentName: string | undefined, channel: {
|
|
314
340
|
ownDisplayName?: string;
|
|
315
341
|
}, log: (msg: string) => void): (e: RoomMessage) => boolean;
|
|
342
|
+
/**
|
|
343
|
+
* #1800 PR D — the room message this bridge acts on, built from
|
|
344
|
+
* SecureChannel's `onMessage` metadata with every sender field taken through
|
|
345
|
+
* the binding (`roomSenderView`): a sender that is not BOUND (a missing
|
|
346
|
+
* verdict included) is "Unverified sender", never the owner, carries no
|
|
347
|
+
* device id, and is not a known human to the room protocol. Exported so the
|
|
348
|
+
* wiring itself is under test (#1848 review L1).
|
|
349
|
+
*/
|
|
350
|
+
export declare function roomMessageFrom(metadata: MessageMetadata): RoomMessage;
|
|
316
351
|
export declare function wireBridge(channel: RoomChannel, session: RoomSession, target: ActiveTarget, opts?: {
|
|
317
352
|
/**
|
|
318
353
|
* #1107: this agent's own name, used to recognise its own @mention. Threaded
|
|
@@ -372,5 +407,13 @@ export declare function wireBridge(channel: RoomChannel, session: RoomSession, t
|
|
|
372
407
|
trustRoot?: string;
|
|
373
408
|
/** Test-only: override the room-context bounds (see room-context.ts). */
|
|
374
409
|
roomContextLimits?: Partial<RoomContextLimits>;
|
|
410
|
+
/**
|
|
411
|
+
* #1762 PR-C — where the ONE turn consumer is attached: production passes
|
|
412
|
+
* the `TurnInbox` whose `onMessage` SecureChannel calls. Turns run ONLY
|
|
413
|
+
* from it; the `room_message` / `message` events are observation only.
|
|
414
|
+
*/
|
|
415
|
+
inbox?: {
|
|
416
|
+
attach(consumer: (text: string, metadata: MessageMetadata) => void): void;
|
|
417
|
+
};
|
|
375
418
|
}): ArmingState;
|
|
376
419
|
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1762 PR-C — 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
|
+
* Two lines here are load-bearing for file sends:
|
|
7
|
+
* - `fileSend` opts in. Without it SecureChannel creates no staging folder and
|
|
8
|
+
* ends every token at mint (`turn_no_consumer`);
|
|
9
|
+
* - `onMessage` is the TurnInbox, the single turn consumer. Without it every
|
|
10
|
+
* token is dropped at mint and `send_file` answers `turn_no_consumer`.
|
|
11
|
+
*/
|
|
12
|
+
import type { SecureChannelConfig } from "@agentvault/agentvault";
|
|
13
|
+
import type { TurnInbox } from "./file-turn.js";
|
|
14
|
+
import { ListenerTaint } from "./listener-taint.js";
|
|
15
|
+
/** #1762 PR-C: the listener session's durable taint record, in the data dir. */
|
|
16
|
+
export declare function bridgeListenerTaint(dataDir: string, log?: (m: string) => void): ListenerTaint;
|
|
17
|
+
export interface BridgeChannelInputs {
|
|
18
|
+
inviteToken: string;
|
|
19
|
+
dataDir: string;
|
|
20
|
+
apiUrl: string;
|
|
21
|
+
agentName: string;
|
|
22
|
+
/** The agent's workspace: a 1:1 root that holds the outbox, so the confined worker can stage files. */
|
|
23
|
+
workspaceDir: string;
|
|
24
|
+
/** `@agentvault/claude-bridge@<version>` (#836). */
|
|
25
|
+
clientVersion: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function bridgeChannelConfig(cfg: BridgeChannelInputs, inbox: TurnInbox): SecureChannelConfig;
|
|
28
|
+
//# 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
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* #1762 PR-C (§4.3) — the file rule, appended to whatever system prompt the
|
|
3
|
+
* model runs with (the identity prompt or the owner's own), so the model
|
|
4
|
+
* actually receives it. Idempotent.
|
|
5
|
+
*/
|
|
6
|
+
export declare function withFileSendRule(systemPrompt: 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
|