@agentvault/claude-bridge 0.8.16 → 0.8.18
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/dist/bridge.d.ts +3 -6
- package/dist/index.js +100522 -99145
- package/dist/recovery.d.ts +5 -0
- package/dist/router.d.ts +1 -0
- package/dist/session.d.ts +15 -26
- package/dist/usage-report.d.ts +23 -0
- package/dist/worker-queue.d.ts +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type HistoryRecoveryCommandInput } from "@agentvault/agentvault";
|
|
2
|
+
type HistoryRecoveryRunner = (input: HistoryRecoveryCommandInput) => Promise<void>;
|
|
3
|
+
export declare function maybeRunRecoverySubcommand(argv?: string[], env?: NodeJS.ProcessEnv, runRecovery?: HistoryRecoveryRunner): Promise<boolean>;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=recovery.d.ts.map
|
package/dist/router.d.ts
CHANGED
package/dist/session.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type LlmUsage } from "./usage-report.js";
|
|
2
3
|
/**
|
|
3
4
|
* The one tool the room session exposes: `room_say`. Speaking to the room is an
|
|
4
5
|
* explicit choice — Claude calls this only when it has something to add, and
|
|
@@ -98,6 +99,12 @@ export interface SessionOpts {
|
|
|
98
99
|
* absent getter ⇒ `?? false` ⇒ gates stay in place.
|
|
99
100
|
*/
|
|
100
101
|
gatesRemoved?: () => boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Health (2026-10-14): per-model LLM usage lifted off each turn's `result`
|
|
104
|
+
* message, with the turn's API time. Fire-and-forget; a throw is swallowed so
|
|
105
|
+
* telemetry can never break a turn.
|
|
106
|
+
*/
|
|
107
|
+
onUsage?: (usage: LlmUsage[], durationApiMs?: number) => void;
|
|
101
108
|
}
|
|
102
109
|
export declare class PersistentClaudeSession {
|
|
103
110
|
private opts;
|
|
@@ -106,34 +113,15 @@ export declare class PersistentClaudeSession {
|
|
|
106
113
|
/** Reply sink bound to the message currently being processed. Set as each
|
|
107
114
|
* message is handed to the model so the say tool routes to the right place. */
|
|
108
115
|
private activeReply?;
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* LOAD-BEARING (one of two tool-enabling signals): `currentAutoReply` is true
|
|
113
|
-
* ONLY on owner DM turns (`autoReplyOnText:true` from wireBridge) and false on
|
|
114
|
-
* room turns (`autoReplyOnText:false`). The gate allows tools when EITHER
|
|
115
|
-
* `currentAutoReply` (owner DM) OR `currentArmedGetter()` (armed room turn, Slice 2)
|
|
116
|
-
* is true. A room-origin turn MUST keep `currentAutoReply` false; an unarmed
|
|
117
|
-
* room turn's `currentArmedGetter()` MUST return false — or untrusted input gains full
|
|
118
|
-
* tool access. See worker-permission.test.ts for the covering assertion.
|
|
119
|
-
*/
|
|
116
|
+
/** Owner-DM attestation also enables its plain-text fallback. Room turns
|
|
117
|
+
* carry separate sender authority and can never become DMs on disarm. */
|
|
120
118
|
private currentAutoReply;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* getter at each tool-call decision (not a boolean captured once), so a mid-turn
|
|
126
|
-
* disarm denies the very next tool call. wireBridge binds it to the ArmingState
|
|
127
|
-
* for this turn's room; an unarmed room turn's getter returns false. */
|
|
119
|
+
private currentToolEligibleSender;
|
|
120
|
+
private currentRoomReplyExpected;
|
|
121
|
+
private currentHasRoomContext;
|
|
122
|
+
/** Called per tool decision so a mid-turn room disarm takes effect live. */
|
|
128
123
|
private currentArmedGetter;
|
|
129
|
-
/**
|
|
130
|
-
* `currentAutoReply` on purpose — it drives ONLY the #416 plain-text fallback
|
|
131
|
-
* (deliver assistant text when the model never calls say), NOT the tool gate.
|
|
132
|
-
* True for owner 1:1 DMs (defaults from autoReplyOnText) AND for a HUMAN/owner
|
|
133
|
-
* speaking in a room (wireBridge sets replyExpected from !senderIsAgent). An
|
|
134
|
-
* agent-authored room turn keeps this false → the agent may still stay silent,
|
|
135
|
-
* which also prevents agent↔agent reply loops. Tool access is unaffected: it
|
|
136
|
-
* stays gated on currentAutoReply (owner DM) OR currentArmedGetter (armed room). */
|
|
124
|
+
/** Effective prose fallback policy, including the separate owner-DM default. */
|
|
137
125
|
private currentReplyExpected;
|
|
138
126
|
/** #1180: whether the say tool may deliver on this turn. Rooms pass an explicit
|
|
139
127
|
* `replyExpected` (#1107: no @ → nobody replies) and that decides it; a 1:1 DM
|
|
@@ -190,6 +178,7 @@ export declare class PersistentClaudeSession {
|
|
|
190
178
|
push(text: string, reply?: ReplySink, opts?: {
|
|
191
179
|
autoReplyOnText?: boolean;
|
|
192
180
|
replyExpected?: boolean;
|
|
181
|
+
toolEligibleSender?: boolean;
|
|
193
182
|
armed?: () => boolean;
|
|
194
183
|
}): void;
|
|
195
184
|
/** Route a say-tool message to the reply bound to the in-flight message, falling
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM usage off the Claude Agent SDK `result` message, for Health (2026-10-14).
|
|
3
|
+
*
|
|
4
|
+
* The SDK already reports exact per-model usage and cost on every turn —
|
|
5
|
+
* `modelUsage: { [model]: { inputTokens, outputTokens, cacheReadInputTokens,
|
|
6
|
+
* cacheCreationInputTokens, costUSD } }`, plus the aggregate `usage` and
|
|
7
|
+
* `total_cost_usd`. The bridge used to discard all of it. This turns one
|
|
8
|
+
* result into one entry per model so the backend ledger can show cost per
|
|
9
|
+
* model without the bridge keeping a pricing table of its own.
|
|
10
|
+
*
|
|
11
|
+
* Read defensively: the result is untyped here, and an absent number must
|
|
12
|
+
* stay absent rather than become 0 (cost especially — "unknown" is not "free").
|
|
13
|
+
*/
|
|
14
|
+
export interface LlmUsage {
|
|
15
|
+
model: string;
|
|
16
|
+
inputTokens: number;
|
|
17
|
+
outputTokens: number;
|
|
18
|
+
costUsd?: number;
|
|
19
|
+
cacheReadTokens?: number;
|
|
20
|
+
cacheCreationTokens?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function usageFromResult(result: Record<string, unknown>, fallbackModel?: string): LlmUsage[];
|
|
23
|
+
//# sourceMappingURL=usage-report.d.ts.map
|
package/dist/worker-queue.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ export type WorkerTask = {
|
|
|
7
7
|
reply: ReplySink;
|
|
8
8
|
/** Owner-DM turns want a plain-text reply fallback (#416). */
|
|
9
9
|
autoReplyOnText: boolean;
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* autoReplyOnText so it delivers on a tool-capable room turn WITHOUT enabling
|
|
13
|
-
* tools (arming governs tools). Absent/false for agent-authored turns. */
|
|
10
|
+
/** Shared reply policy: deliver prose when this turn owes a reply. Room
|
|
11
|
+
* tools require this too, alongside sender authority and room arming. */
|
|
14
12
|
replyExpected?: boolean;
|
|
13
|
+
/** Verified human room sender; never inferred from reply eligibility. */
|
|
14
|
+
toolEligibleSender?: boolean;
|
|
15
15
|
/** Armed-room turns: live getter the gate reads per tool decision (mid-turn
|
|
16
16
|
* disarm denies the next call). Absent for owner DMs. */
|
|
17
17
|
armed?: () => boolean;
|
|
@@ -54,7 +54,7 @@ export type WorkerIncident = {
|
|
|
54
54
|
instructionChars: number;
|
|
55
55
|
/**
|
|
56
56
|
* Whether a reply was expected of this turn — mirrors `WorkerTask.replyExpected`,
|
|
57
|
-
* i.e.
|
|
57
|
+
* i.e. the shared @mention policy upstream. Without it a silent turn
|
|
58
58
|
* (composed=0, said=false) is unattributable: it could be agent-authored traffic
|
|
59
59
|
* that was never going to answer, or a turn that waited so long the previous one
|
|
60
60
|
* already answered. Ballroom2 on 2026-08-06 produced both readings and the record
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvault/claude-bridge",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.18",
|
|
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",
|