@agentvault/claude-bridge 0.8.42 → 0.8.43
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 +40 -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 +8372 -1558
- 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 +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code versions whose queue semantics were checked by hand (#1762): a
|
|
3
|
+
* `priority:"later"` prompt is never injected into a running turn, so a
|
|
4
|
+
* message from another room can never land inside an attested turn on the
|
|
5
|
+
* shared listener. Verified in 2.1.141 (SDK 0.2.141): queued input ranks
|
|
6
|
+
* `{now:0, next:1, later:2}` and a running turn absorbs only `ge_("next")`.
|
|
7
|
+
* A listener whose CLI reports any other version is TAINTED (fail closed);
|
|
8
|
+
* sdk-queue-semantics-guard.test.ts trips CI first when the SDK moves.
|
|
9
|
+
*/
|
|
10
|
+
export declare const VERIFIED_CLAUDE_CODE_VERSIONS: ReadonlySet<string>;
|
|
11
|
+
export declare class ListenerTaint {
|
|
12
|
+
private readonly opts;
|
|
13
|
+
/** Tainted until `begin()` proves the session new: fail closed before start. */
|
|
14
|
+
private tainted;
|
|
15
|
+
/**
|
|
16
|
+
* The CLI's `system`/`init` reported a VERIFIED Claude Code version (queue
|
|
17
|
+
* semantics, #1762). Per process, never persisted: until init confirms it
|
|
18
|
+
* the listener does not attest — so an unverified CLI has no first-turn
|
|
19
|
+
* window after a restart (review 04210d3f).
|
|
20
|
+
*/
|
|
21
|
+
private cliVerified;
|
|
22
|
+
private sessionId?;
|
|
23
|
+
/** The record as it stood when this process's session began (what a resume would carry over). */
|
|
24
|
+
private prior?;
|
|
25
|
+
constructor(opts?: {
|
|
26
|
+
file?: string;
|
|
27
|
+
log?: (m: string) => void;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* The listener's query() is starting. `resumeSessionId` set means it
|
|
31
|
+
* RESUMES that SDK session (its transcript carries over): the recorded taint
|
|
32
|
+
* for that id applies, and no record means tainted. Unset means a genuinely
|
|
33
|
+
* new session: clean — unless input is already QUEUED for it (`queued > 0`):
|
|
34
|
+
* that input will be the new session's first content, and anything routed
|
|
35
|
+
* before start may have tainted it, so the current taint is kept.
|
|
36
|
+
* Either way the CLI is unverified until its init says otherwise.
|
|
37
|
+
*/
|
|
38
|
+
begin(o?: {
|
|
39
|
+
resumeSessionId?: string;
|
|
40
|
+
queued?: number;
|
|
41
|
+
}): void;
|
|
42
|
+
/**
|
|
43
|
+
* The SDK reported its session id (the `system`/`init` message). An id equal
|
|
44
|
+
* to the recorded one is a resume, whatever `begin` was told: its recorded
|
|
45
|
+
* taint carries over.
|
|
46
|
+
*/
|
|
47
|
+
noteSessionId(id: unknown, claudeCodeVersion?: unknown): void;
|
|
48
|
+
/** Non-eligible content entered the listener: taint it, durably. */
|
|
49
|
+
taint(reason: string): void;
|
|
50
|
+
/** No room file from the listener: tainted, or the CLI not (yet) confirmed verified. */
|
|
51
|
+
isTainted(): boolean;
|
|
52
|
+
private read;
|
|
53
|
+
private write;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=listener-taint.d.ts.map
|
|
@@ -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
|
@@ -43,6 +43,19 @@ export interface RoomContextEntry {
|
|
|
43
43
|
text: string;
|
|
44
44
|
/** ISO time the message was sent (from the emit), or received if absent. */
|
|
45
45
|
at: string;
|
|
46
|
+
/**
|
|
47
|
+
* #1762 PR-C — opaque to this buffer: the held message's turn authority
|
|
48
|
+
* (a parked FileTurn). Handed back by `take()` when the context is
|
|
49
|
+
* delivered, and to `onDrop` when the entry leaves WITHOUT being delivered
|
|
50
|
+
* (overflow, the room evicted, `clear`) — a true drop.
|
|
51
|
+
*/
|
|
52
|
+
turn?: unknown;
|
|
53
|
+
/**
|
|
54
|
+
* #1762 PR-C: not from this agent's own owner (an agent, another account,
|
|
55
|
+
* an unknown sender, or a foreign file). Delivered to the listener, it
|
|
56
|
+
* taints the session (listener-taint.ts). Absent reads as foreign.
|
|
57
|
+
*/
|
|
58
|
+
foreign?: boolean;
|
|
46
59
|
}
|
|
47
60
|
export interface RoomContextLimits {
|
|
48
61
|
/** Messages kept per room. */
|
|
@@ -70,17 +83,29 @@ export declare function sanitizeLabel(name: string, max?: number): string;
|
|
|
70
83
|
/** A fresh per-turn delimiter id: 12 hex chars from 6 random bytes. */
|
|
71
84
|
export declare function newContextId(): string;
|
|
72
85
|
export declare class RoomContextBuffer {
|
|
86
|
+
/** #1762 PR-C: an entry left without being delivered (overflow, room evicted, `clear`). */
|
|
87
|
+
private readonly onDrop;
|
|
73
88
|
private readonly limits;
|
|
74
89
|
/** Insertion order IS recency order: a touched room is re-inserted at the end. */
|
|
75
90
|
private rooms;
|
|
76
|
-
constructor(limits?: Partial<RoomContextLimits
|
|
91
|
+
constructor(limits?: Partial<RoomContextLimits>,
|
|
92
|
+
/** #1762 PR-C: an entry left without being delivered (overflow, room evicted, `clear`). */
|
|
93
|
+
onDrop?: (entry: RoomContextEntry) => void);
|
|
94
|
+
private dropped;
|
|
77
95
|
add(roomId: string, entry: RoomContextEntry): void;
|
|
78
96
|
/** The held messages for a room, oldest first. Does not clear. */
|
|
79
97
|
peek(roomId: string): {
|
|
80
98
|
entries: readonly RoomContextEntry[];
|
|
81
99
|
dropped: number;
|
|
82
100
|
};
|
|
101
|
+
/** The room's held messages leave WITHOUT being delivered (room left, pruned): a true drop. */
|
|
83
102
|
clear(roomId: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* #1762 PR-C — the room's held messages were DELIVERED with a turn: remove
|
|
105
|
+
* and return them (with their `turn`), so the caller folds each into it.
|
|
106
|
+
* Never calls `onDrop`.
|
|
107
|
+
*/
|
|
108
|
+
take(roomId: string): RoomContextEntry[];
|
|
84
109
|
size(roomId: string): number;
|
|
85
110
|
chars(roomId: string): number;
|
|
86
111
|
roomCount(): number;
|
package/dist/router.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ToolConversation } from "@agentvault/agentvault";
|
|
2
2
|
import type { ReplySink } from "./session.js";
|
|
3
3
|
import type { WorkerTask } from "./worker-queue.js";
|
|
4
|
+
import type { FileTurn } from "./file-turn.js";
|
|
4
5
|
/** The push interface wireBridge drives (matches PersistentClaudeSession.push). */
|
|
5
6
|
export interface PushLike {
|
|
6
7
|
push(text: string, reply?: ReplySink, opts?: {
|
|
@@ -14,6 +15,35 @@ export interface PushLike {
|
|
|
14
15
|
conversation?: ToolConversation;
|
|
15
16
|
/** #1583: true once this room is hushed. */
|
|
16
17
|
hushed?: () => boolean;
|
|
18
|
+
/** #1762 PR-C: the message's turn authority. The router attests it at the lane decision. */
|
|
19
|
+
fileTurn?: FileTurn;
|
|
20
|
+
/**
|
|
21
|
+
* #1762 PR-C (review 04210d3f): the turn text with NO foreign text in
|
|
22
|
+
* its framing — the room named by its short id, never by its name (a
|
|
23
|
+
* room's name is set by its creator, possibly another account). Used
|
|
24
|
+
* instead of `text` exactly when the router attests this turn.
|
|
25
|
+
*/
|
|
26
|
+
textIfAttested?: string;
|
|
27
|
+
/**
|
|
28
|
+
* #1762 PR-C: false ONLY when everything this push puts in front of the
|
|
29
|
+
* model came from this agent's own owner (an eligible room sender with
|
|
30
|
+
* no held foreign context, or an attested owner 1:1). Anything else —
|
|
31
|
+
* or absent — taints the listener session if it lands there.
|
|
32
|
+
*/
|
|
33
|
+
foreignInput?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* #1820 part 2: an owner 1:1's grant, re-decided when the worker queue
|
|
36
|
+
* releases the turn (false: the device is no longer an owner device).
|
|
37
|
+
*/
|
|
38
|
+
confirmOwner?: () => "owner" | Promise<import("./owner-grant.js").OwnerStatus>;
|
|
39
|
+
/**
|
|
40
|
+
* #1826 review round 2 (M4): a 1:1 the channel could not confirm as the
|
|
41
|
+
* owner's (`senderOwnerStatus: "unknown"`). On the worker lane its
|
|
42
|
+
* `confirmOwner` runs at release (ephemeral: no taint needed). If it
|
|
43
|
+
* lands on the PERSISTENT listener instead (Work off), the router runs
|
|
44
|
+
* `confirmOwner` first and taints the listener unless it says "owner".
|
|
45
|
+
*/
|
|
46
|
+
ownerUnconfirmed?: boolean;
|
|
17
47
|
}): unknown;
|
|
18
48
|
}
|
|
19
49
|
export interface RouterDeps {
|
|
@@ -33,16 +63,16 @@ export interface RouterDeps {
|
|
|
33
63
|
queue: {
|
|
34
64
|
enqueue(task: WorkerTask): void;
|
|
35
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* #1762 PR-C: the listener session's taint (listener-taint.ts). The
|
|
68
|
+
* listener is ONE persistent session for every room and the 1:1, so
|
|
69
|
+
* foreign content in any of them taints file authority for all. Absent:
|
|
70
|
+
* the listener never attests (fail closed).
|
|
71
|
+
*/
|
|
72
|
+
listenerTaint?: {
|
|
73
|
+
isTainted(): boolean;
|
|
74
|
+
taint(reason: string): void;
|
|
75
|
+
};
|
|
36
76
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Route each inbound turn to EXACTLY ONE lane (facet B). Tool-eligible turns —
|
|
39
|
-
* owner DMs (autoReplyOnText) and armed room turns — go to an isolated ephemeral
|
|
40
|
-
* worker via the queue; everything else stays on the locked listener. A room
|
|
41
|
-
* turn's `armed` getter is read once here at routing time to pick the lane; the
|
|
42
|
-
* same live getter is threaded to the worker task so a mid-turn disarm still
|
|
43
|
-
* denies the next tool call (Facet A D5). `work_allowed` is the single control
|
|
44
|
-
* gating BOTH lanes: an armed room turn is only routed to the worker queue when
|
|
45
|
-
* workAllowed() is also true, so Work off always falls through to the listener.
|
|
46
|
-
*/
|
|
47
77
|
export declare function makeRouter(deps: RouterDeps): PushLike;
|
|
48
78
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1804 — the ONE place that builds how the Claude Code process behind every
|
|
3
|
+
* `query()` this bridge makes is launched: its environment and the CLI flags
|
|
4
|
+
* the bridge forces.
|
|
5
|
+
*
|
|
6
|
+
* WHY. Claude Code processes user input BEFORE the model runs, and the bridge's
|
|
7
|
+
* user input is room text and 1:1 text. Two of those steps are not tool calls,
|
|
8
|
+
* so `tools: []`, `permissionMode`, `canUseTool` and the PreToolUse hook never
|
|
9
|
+
* see them:
|
|
10
|
+
*
|
|
11
|
+
* - `@path` mentions. The CLI reads the file and puts its contents into the
|
|
12
|
+
* request as a synthetic Read result, with no root limit. In the CLI shipped
|
|
13
|
+
* with SDK 0.2.141 (Claude Code 2.1.141) the attachment builder returns only
|
|
14
|
+
* queued commands when `CLAUDE_CODE_DISABLE_ATTACHMENTS` is truthy, so `@`
|
|
15
|
+
* mentions, `@server:resource` mentions and agent mentions are all skipped,
|
|
16
|
+
* and queued prompts still run.
|
|
17
|
+
* - slash commands (PR #1806 review). Text that starts with `/` runs the
|
|
18
|
+
* command: `/heapdump` writes the process memory, API key included, to
|
|
19
|
+
* `~/Desktop`; `/clear`, `/compact`, `/goal` and `/loop` rewrite the shared
|
|
20
|
+
* listener's session. Room turns always start with a bridge prefix, but a
|
|
21
|
+
* bare 1:1 is pushed as typed. With `--disable-slash-commands` the CLI loads
|
|
22
|
+
* no local commands or skills, and NOTHING shaped like a command runs:
|
|
23
|
+
* - a built-in name (`/heapdump`, `/clear`) is answered locally
|
|
24
|
+
* "`/x` isn't available in this environment";
|
|
25
|
+
* - any other `/name` (a skill, a custom command, a made-up word) is
|
|
26
|
+
* answered locally "Unknown command: /name";
|
|
27
|
+
* neither reaches the model. Only text that is not a command shape (a
|
|
28
|
+
* path such as `/usr/local/bin …`, or a leading space) reaches the model.
|
|
29
|
+
* So an owner 1:1 that starts with `/word` now gets that local reply
|
|
30
|
+
* instead of an answer. The bridge uses no slash commands.
|
|
31
|
+
* THE FLAG DOES NOT COVER MCP PROMPTS. `/mcp__<server>__<prompt>` still
|
|
32
|
+
* runs (the server's `prompts/get` is called before the model and its text
|
|
33
|
+
* injected). Today no server can offer one: the only MCP server is
|
|
34
|
+
* `createSdkMcpServer` (tools only), `settingSources: []` loads no
|
|
35
|
+
* `.mcp.json`, and `withSdkLaunch` below refuses any non-`sdk` server. The
|
|
36
|
+
* test that pins it is slash-commands-1806.test.ts asserting the CLI's
|
|
37
|
+
* `slash_commands` is `[]` on both lanes — keep that assertion.
|
|
38
|
+
*
|
|
39
|
+
* sdk-queue-semantics-guard.test.ts makes every SDK bump re-verify both, and
|
|
40
|
+
* at-mention-inlining-1804.test.ts / slash-commands-1806.test.ts run the real
|
|
41
|
+
* CLI with a control.
|
|
42
|
+
*
|
|
43
|
+
* DEPENDS ON NO SETTINGS BEING LOADED. Settings carry an `env` block that
|
|
44
|
+
* Claude Code applies on top of the process environment, so
|
|
45
|
+
* `"env": {"CLAUDE_CODE_DISABLE_ATTACHMENTS": "0"}` turns inlining back on
|
|
46
|
+
* (both reproduced in the #1806 reviews):
|
|
47
|
+
* - settings FILES, loaded unless `settingSources: []` (both lanes,
|
|
48
|
+
* session.ts buildSdkOptions; the SDK loads ALL sources when it is omitted);
|
|
49
|
+
* - FLAG settings: the SDK's `settings` / `managedSettings` options or an
|
|
50
|
+
* `extraArgs` `settings` key. `settingSources` does not govern these.
|
|
51
|
+
* `withSdkLaunch` therefore REFUSES options without `settingSources: []`, with
|
|
52
|
+
* `settings`/`managedSettings`, or with any `extraArgs` key not on the
|
|
53
|
+
* allowlist (e.g. `setting-sources`, `settings`). Pinned by session.test.ts
|
|
54
|
+
* ("builds capable/locked SDK options …") and sdk-env-1804.test.ts (the options
|
|
55
|
+
* the session actually hands query(), and every refusal). Managed/policy
|
|
56
|
+
* settings on disk can also override; only the operator controls those.
|
|
57
|
+
*
|
|
58
|
+
* WHY A MERGE. The SDK's `env` option REPLACES `process.env` for the child
|
|
59
|
+
* (sdk.mjs 0.2.141: `env ? {...env} : {...process.env}`). Passing only the new
|
|
60
|
+
* variable would drop PATH, HOME, the auth variables and AV_*.
|
|
61
|
+
*
|
|
62
|
+
* WORKER: `ENABLE_TOOL_SEARCH=false`. With attachments off, Claude Code never
|
|
63
|
+
* sends the "deferred tools are available via ToolSearch" reminder (it is an
|
|
64
|
+
* attachment too), so with tool search on the worker would never learn the
|
|
65
|
+
* names of the deferred tools (WebFetch, WebSearch, TodoWrite, NotebookEdit…).
|
|
66
|
+
* Tool search off loads them all up front, which costs prompt tokens but keeps
|
|
67
|
+
* the owner's worker able to use them. The listener runs `tools: []`, so it
|
|
68
|
+
* has no deferred tools and keeps the default.
|
|
69
|
+
*
|
|
70
|
+
* PR-PC (design §13) narrows the worker's base from the whole `process.env`
|
|
71
|
+
* to an allowlist. Do that HERE, so every call site keeps these settings.
|
|
72
|
+
*/
|
|
73
|
+
export type SdkLane = "listener" | "worker";
|
|
74
|
+
export type SdkEnv = Record<string, string | undefined>;
|
|
75
|
+
/** The env settings every lane forces, whatever the operator's environment says. */
|
|
76
|
+
export declare const SDK_ENV_FORCED: Readonly<Record<SdkLane, Readonly<Record<string, string>>>>;
|
|
77
|
+
/**
|
|
78
|
+
* CLI flags every lane forces, as the SDK's `extraArgs` (0.2.141: each entry
|
|
79
|
+
* becomes `--<key>`, plus the value unless it is null).
|
|
80
|
+
*/
|
|
81
|
+
export declare const SDK_EXTRA_ARGS_FORCED: Readonly<Record<string, null>>;
|
|
82
|
+
/**
|
|
83
|
+
* `extraArgs` keys a caller may pass, besides the forced ones. Empty today:
|
|
84
|
+
* any CLI flag can change how input is processed (`settings`,
|
|
85
|
+
* `setting-sources`, `plugin-dir`, `mcp-config` …), so each one needs a review
|
|
86
|
+
* before it goes on this list.
|
|
87
|
+
*/
|
|
88
|
+
export declare const SDK_EXTRA_ARGS_ALLOWED: ReadonlySet<string>;
|
|
89
|
+
/**
|
|
90
|
+
* SDK options `withSdkLaunch` refuses: each can bring settings, commands, MCP
|
|
91
|
+
* prompts or a different CLI past the forced values.
|
|
92
|
+
*/
|
|
93
|
+
export declare const SDK_OPTIONS_REFUSED: readonly string[];
|
|
94
|
+
/** The environment for a Claude Code child on `lane`: the base, then the forced settings. */
|
|
95
|
+
export declare function sdkEnv(lane: SdkLane, base?: NodeJS.ProcessEnv): SdkEnv;
|
|
96
|
+
/** Throws when `options` could undo a forced setting (see "DEPENDS ON" above). */
|
|
97
|
+
export declare function assertLaunchable(options: object): void;
|
|
98
|
+
/**
|
|
99
|
+
* `options` with the lane's environment and the forced CLI flags set. Throws
|
|
100
|
+
* on options that could undo them (`assertLaunchable`). Every `query()` call
|
|
101
|
+
* site takes its options through this.
|
|
102
|
+
*/
|
|
103
|
+
export declare function withSdkLaunch<T extends object>(options: T, lane: SdkLane, base?: NodeJS.ProcessEnv): T & {
|
|
104
|
+
env: SdkEnv;
|
|
105
|
+
extraArgs: Record<string, string | null>;
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=sdk-env.d.ts.map
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../src/service/spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,OAAO,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,gBAAgB,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../src/service/spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,OAAO,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,gBAAgB,GAAG,WAAW,CA8BvF"}
|
package/dist/session.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { type LlmUsage } from "./usage-report.js";
|
|
|
3
3
|
import type { ToolConversation, TurnFailureCode } from "@agentvault/agentvault";
|
|
4
4
|
import { type FailureDeps } from "./turn-failure.js";
|
|
5
5
|
import type { ShutdownWindow } from "./shutdown.js";
|
|
6
|
+
import type { FileTurn, SendFileOutcome } from "./file-turn.js";
|
|
7
|
+
import type { ListenerTaint } from "./listener-taint.js";
|
|
6
8
|
/**
|
|
7
9
|
* The one tool the room session exposes: `room_say`. Speaking to the room is an
|
|
8
10
|
* explicit choice — Claude calls this only when it has something to add, and
|
|
@@ -15,6 +17,19 @@ export declare function makeRoomSayTool(onSay: (text: string) => void | Promise<
|
|
|
15
17
|
}>;
|
|
16
18
|
/** Tool name as Claude sees it: mcp__<server>__<tool>. */
|
|
17
19
|
export declare const ROOM_SAY_TOOL_NAME = "mcp__room__say";
|
|
20
|
+
/**
|
|
21
|
+
* #1762 PR-C — `send_file`, beside `say` on the same in-process `room` server.
|
|
22
|
+
* It sends one staged file (with an optional caption) to the conversation the
|
|
23
|
+
* turn is answering — never one the model names (design §2). The handler
|
|
24
|
+
* AWAITS the real send and answers `isError` unless a frame was written, so a
|
|
25
|
+
* model is never told a file went when it did not (unlike `say`, #1765).
|
|
26
|
+
*/
|
|
27
|
+
export declare function makeSendFileTool(onSendFile: (path: string, caption: string) => Promise<SendFileOutcome>): import("@anthropic-ai/claude-agent-sdk").SdkMcpToolDefinition<{
|
|
28
|
+
path: z.ZodString;
|
|
29
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}>;
|
|
31
|
+
/** Tool name as Claude sees it. */
|
|
32
|
+
export declare const ROOM_SEND_FILE_TOOL_NAME = "mcp__room__send_file";
|
|
18
33
|
/**
|
|
19
34
|
* Minimal local mirror of the SDK's SDKUserMessage shape.
|
|
20
35
|
*
|
|
@@ -129,6 +144,12 @@ export interface SessionOpts {
|
|
|
129
144
|
* posted, with no span.
|
|
130
145
|
*/
|
|
131
146
|
failure?: FailureDeps;
|
|
147
|
+
/**
|
|
148
|
+
* #1762 PR-C: the listener's taint record. start() begins it — this session
|
|
149
|
+
* never resumes an SDK session, so it is genuinely new — and records the
|
|
150
|
+
* SDK's session id from its `system`/`init` message.
|
|
151
|
+
*/
|
|
152
|
+
taint?: ListenerTaint;
|
|
132
153
|
}
|
|
133
154
|
export declare class PersistentClaudeSession {
|
|
134
155
|
private opts;
|
|
@@ -195,11 +216,24 @@ export declare class PersistentClaudeSession {
|
|
|
195
216
|
conversation?: ToolConversation;
|
|
196
217
|
/** #1583: true once this message's room is hushed. */
|
|
197
218
|
hushed?: () => boolean;
|
|
219
|
+
/**
|
|
220
|
+
* #1762 PR-C: the message's turn authority. Its staging line goes in
|
|
221
|
+
* front of the turn's own text (after any held context), and it is ended
|
|
222
|
+
* when the turn is (result, failure, stop). Attested — or not — by the
|
|
223
|
+
* router BEFORE this push, so the line says what the turn may do.
|
|
224
|
+
*/
|
|
225
|
+
fileTurn?: FileTurn;
|
|
198
226
|
}): void;
|
|
199
227
|
/** Route a say-tool message to the reply bound to the in-flight message, falling
|
|
200
228
|
* back to opts.onSay. This is what closes the DM→room leak: the destination is
|
|
201
229
|
* the one captured for the message being answered, not a live global target. */
|
|
202
230
|
deliver(text: string): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* #1762 PR-C — the `send_file` tool. Only the RUNNING turn's authority is
|
|
233
|
+
* used (never the last one's, between turns), under the same gates as say:
|
|
234
|
+
* #1180 (a turn not owed sends nothing) and #392 (a hushed room). Never throws.
|
|
235
|
+
*/
|
|
236
|
+
sendFile(path: string, caption: string): Promise<SendFileOutcome>;
|
|
203
237
|
/** Track a reply until it lands, so stop() can wait for it. */
|
|
204
238
|
private sent;
|
|
205
239
|
/** #1508: the turn now producing output — the oldest pulled message not yet
|
package/dist/worker-queue.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { ToolConversation, TurnFailureCode } from "@agentvault/agentvault";
|
|
|
2
2
|
import type { PersistentClaudeSession, ReplySink } from "./session.js";
|
|
3
3
|
import { type FailureDeps } from "./turn-failure.js";
|
|
4
4
|
import type { ShutdownWindow } from "./shutdown.js";
|
|
5
|
+
import type { FileTurn } from "./file-turn.js";
|
|
6
|
+
import { type OwnerStatus } from "./owner-grant.js";
|
|
5
7
|
/** One tool-eligible turn to run in an isolated ephemeral worker. */
|
|
6
8
|
export type WorkerTask = {
|
|
7
9
|
/** The single instruction that seeds the worker's conversation. */
|
|
@@ -22,6 +24,15 @@ export type WorkerTask = {
|
|
|
22
24
|
conversation?: ToolConversation;
|
|
23
25
|
/** #1583: true once this task's room is hushed. */
|
|
24
26
|
hushed?: () => boolean;
|
|
27
|
+
/** #1762 PR-C: the message's turn authority (attested by the router). Ended when the task is. */
|
|
28
|
+
fileTurn?: FileTurn;
|
|
29
|
+
/**
|
|
30
|
+
* #1820 part 2: an owner 1:1's grant, re-decided HERE when the task is
|
|
31
|
+
* released. false (the sender device is no longer an owner device, or the
|
|
32
|
+
* owner list cannot be read): the task runs without tools and without file
|
|
33
|
+
* authority, still answered in plain text.
|
|
34
|
+
*/
|
|
35
|
+
confirmOwner?: () => "owner" | Promise<OwnerStatus>;
|
|
25
36
|
};
|
|
26
37
|
/**
|
|
27
38
|
* Forensic record of EVERY task the queue runs — clean or not.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvault/claude-bridge",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.43",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AgentVault Claude Bridge — daemon for bridging a Claude agent into secure E2E-encrypted AgentVault 1:1 direct messages and rooms.",
|
|
6
6
|
"main": "dist/index.js",
|