@agentvault/claude-bridge 0.8.26 → 0.8.27
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 +10 -0
- package/dist/index.js +71 -30
- package/package.json +1 -1
package/dist/bridge.d.ts
CHANGED
|
@@ -12,6 +12,14 @@ export interface RoomMessage {
|
|
|
12
12
|
/** SecureChannel's sender classification. Only an explicit false authorizes
|
|
13
13
|
* room tools; reply eligibility is independently decided by the @ protocol. */
|
|
14
14
|
senderIsAgent?: boolean;
|
|
15
|
+
/** #1459 — SecureChannel: a human in THIS agent's own account. Only this
|
|
16
|
+
* authorizes room tools; `senderIsAgent === false` says only "a human", and
|
|
17
|
+
* a room can hold another account's people. Absent (emitters < 0.23.55)
|
|
18
|
+
* reads as not the owner. */
|
|
19
|
+
senderIsOwner?: boolean;
|
|
20
|
+
/** #1459 — SecureChannel: this turn carries a file from someone other than
|
|
21
|
+
* the owner. Only an explicit `false` lets the turn reach a tool worker. */
|
|
22
|
+
foreignContent?: boolean;
|
|
15
23
|
/** ISO send time from the emit (`data.created_at`). Used to stamp a message
|
|
16
24
|
* held as room context; receipt time stands in when absent. */
|
|
17
25
|
timestamp?: string;
|
|
@@ -250,6 +258,8 @@ export declare function pollApprovalsOnce(arming: ArmingState, dataDir: string,
|
|
|
250
258
|
* A 1:1 DM is deliberately left unlabelled — that path is not broken, and an
|
|
251
259
|
* unmarked turn already reads as a DM, which is what the model assumes.
|
|
252
260
|
*/
|
|
261
|
+
/** #1459 — appended to an owner turn that lost tool access to someone else's file. */
|
|
262
|
+
export declare const FILE_LOCK_NOTE: string;
|
|
253
263
|
export declare function roomTurnPrefix(roomId: string, senderName: string, roomName?: string): string;
|
|
254
264
|
/**
|
|
255
265
|
* What a held (unaddressed) room message contributes as context: the CAPTION
|
package/dist/index.js
CHANGED
|
@@ -11715,11 +11715,11 @@ async function joinWithFirstMatchingKp(welcomeBytes, candidates) {
|
|
|
11715
11715
|
return null;
|
|
11716
11716
|
}
|
|
11717
11717
|
function ownIdentity() {
|
|
11718
|
-
const v22 = true ? "0.23.
|
|
11718
|
+
const v22 = true ? "0.23.55" : FALLBACK;
|
|
11719
11719
|
return `${PACKAGE}@${v22}`;
|
|
11720
11720
|
}
|
|
11721
11721
|
function buildSha() {
|
|
11722
|
-
const raw = true ? "
|
|
11722
|
+
const raw = true ? "45e77bd" : "";
|
|
11723
11723
|
const cleaned = (raw ?? "").trim();
|
|
11724
11724
|
return !cleaned || cleaned === "unknown" ? null : cleaned;
|
|
11725
11725
|
}
|
|
@@ -13095,6 +13095,14 @@ function _isSelfHubAddress(ownHubAddress, target) {
|
|
|
13095
13095
|
const tgt = (target ?? "").trim().toLowerCase();
|
|
13096
13096
|
return own22.length > 0 && own22 === tgt;
|
|
13097
13097
|
}
|
|
13098
|
+
function keepKnownMemberTenants(previous, next) {
|
|
13099
|
+
const known = /* @__PURE__ */ new Map();
|
|
13100
|
+
for (const m22 of previous) if (m22.tenantId) known.set(m22.deviceId, m22.tenantId);
|
|
13101
|
+
return next.map((m22) => {
|
|
13102
|
+
const tenantId = m22.tenantId ? void 0 : known.get(m22.deviceId);
|
|
13103
|
+
return tenantId ? { ...m22, tenantId } : m22;
|
|
13104
|
+
});
|
|
13105
|
+
}
|
|
13098
13106
|
function historyErrorReason(error210) {
|
|
13099
13107
|
let name = "Error";
|
|
13100
13108
|
let status;
|
|
@@ -71100,15 +71108,19 @@ var init_dist = __esm({
|
|
|
71100
71108
|
*/
|
|
71101
71109
|
_recentRoomAttachments = /* @__PURE__ */ new Map();
|
|
71102
71110
|
static RECENT_ROOM_ATTACHMENT_MS = 10 * 60 * 1e3;
|
|
71103
|
-
/** #1181: prefix a room turn that carries no attachment with the one saved in this room recently.
|
|
71111
|
+
/** #1181: prefix a room turn that carries no attachment with the one saved in this room recently.
|
|
71112
|
+
* `from` is who sent that file (#1459), so the turn can be marked as carrying their content. */
|
|
71104
71113
|
_withRecentRoomAttachmentNote(roomId, text) {
|
|
71105
71114
|
const recent = this._recentRoomAttachments.get(roomId);
|
|
71106
|
-
if (!recent) return text;
|
|
71115
|
+
if (!recent) return { text };
|
|
71107
71116
|
const ageMs = Date.now() - recent.at;
|
|
71108
|
-
if (ageMs > _SecureChannel.RECENT_ROOM_ATTACHMENT_MS) return text;
|
|
71109
|
-
return
|
|
71117
|
+
if (ageMs > _SecureChannel.RECENT_ROOM_ATTACHMENT_MS) return { text };
|
|
71118
|
+
return {
|
|
71119
|
+
text: `[Most recent file in this room: ${recent.filePath} (${recent.name}, received ${Math.round(ageMs / 1e3)}s ago). If this message refers to "the file" or "this file", it means that one \u2014 use your Read tool on it.]
|
|
71110
71120
|
|
|
71111
|
-
${text}
|
|
71121
|
+
${text}`,
|
|
71122
|
+
from: recent.senderDeviceId ?? null
|
|
71123
|
+
};
|
|
71112
71124
|
}
|
|
71113
71125
|
/**
|
|
71114
71126
|
* #1161: room attachments whose caption addressed nobody, NOT yet fetched.
|
|
@@ -71122,22 +71134,22 @@ ${text}`;
|
|
|
71122
71134
|
_deferredRoomAttachments = /* @__PURE__ */ new Map();
|
|
71123
71135
|
static DEFERRED_ROOM_ATTACHMENT_MAX = 5;
|
|
71124
71136
|
static DEFERRED_ROOM_ATTACHMENT_MS = 60 * 60 * 1e3;
|
|
71125
|
-
_deferRoomAttachment(roomId, info) {
|
|
71137
|
+
_deferRoomAttachment(roomId, info, senderDeviceId) {
|
|
71126
71138
|
const list = this._deferredRoomAttachments.get(roomId) ?? [];
|
|
71127
|
-
list.push({ info, at: Date.now() });
|
|
71139
|
+
list.push({ info, at: Date.now(), senderDeviceId });
|
|
71128
71140
|
while (list.length > _SecureChannel.DEFERRED_ROOM_ATTACHMENT_MAX) list.shift();
|
|
71129
71141
|
this._deferredRoomAttachments.set(roomId, list);
|
|
71130
71142
|
console.log(
|
|
71131
71143
|
`[SecureChannel] room ${roomId.slice(0, 8)}: attachment ${String(info?.filename ?? "file")} deferred \u2014 caption addresses nobody, fetch on the next @-addressed turn (#1161)`
|
|
71132
71144
|
);
|
|
71133
71145
|
}
|
|
71134
|
-
/** Drain the room's deferred attachments that are still fresh (oldest first). */
|
|
71146
|
+
/** Drain the room's deferred attachments that are still fresh (oldest first), with who sent each. */
|
|
71135
71147
|
_takeDeferredRoomAttachments(roomId) {
|
|
71136
71148
|
const list = this._deferredRoomAttachments.get(roomId);
|
|
71137
71149
|
if (!list?.length) return [];
|
|
71138
71150
|
this._deferredRoomAttachments.delete(roomId);
|
|
71139
71151
|
const cutoff = Date.now() - _SecureChannel.DEFERRED_ROOM_ATTACHMENT_MS;
|
|
71140
|
-
return list.filter((d22) => d22.at >= cutoff).map((d22) => d22.info);
|
|
71152
|
+
return list.filter((d22) => d22.at >= cutoff).map((d22) => ({ info: d22.info, senderDeviceId: d22.senderDeviceId }));
|
|
71141
71153
|
}
|
|
71142
71154
|
/** In-flight roster-refresh promises (per room) — dedup concurrent refreshes. */
|
|
71143
71155
|
_roomRosterRefreshInFlight = /* @__PURE__ */ new Map();
|
|
@@ -73229,7 +73241,7 @@ ${text}`;
|
|
|
73229
73241
|
*/
|
|
73230
73242
|
sendActivitySpan(spanData) {
|
|
73231
73243
|
if (!this._ws || this._ws.readyState !== WebSocket2.OPEN) return;
|
|
73232
|
-
const pluginVersion = true ? "0.23.
|
|
73244
|
+
const pluginVersion = true ? "0.23.55" : "0.0.0-dev";
|
|
73233
73245
|
const agentName = this.config.agentName ?? "Agent";
|
|
73234
73246
|
const resource = {
|
|
73235
73247
|
"service.name": "agentvault-agent",
|
|
@@ -73380,11 +73392,15 @@ ${text}`;
|
|
|
73380
73392
|
}
|
|
73381
73393
|
const existingMlsGroupId = this._persisted.rooms[roomData.roomId]?.mlsGroupId;
|
|
73382
73394
|
const existingMlsTs = this._persisted.rooms[roomData.roomId]?.lastMlsMessageTs;
|
|
73395
|
+
const members22 = keepKnownMemberTenants(
|
|
73396
|
+
this._persisted.rooms[roomData.roomId]?.members ?? [],
|
|
73397
|
+
roomData.members
|
|
73398
|
+
);
|
|
73383
73399
|
this._persisted.rooms[roomData.roomId] = {
|
|
73384
73400
|
roomId: roomData.roomId,
|
|
73385
73401
|
name: roomData.name,
|
|
73386
73402
|
conversationIds,
|
|
73387
|
-
members:
|
|
73403
|
+
members: members22,
|
|
73388
73404
|
...existingMlsGroupId && { mlsGroupId: existingMlsGroupId },
|
|
73389
73405
|
...existingMlsTs && { lastMlsMessageTs: existingMlsTs }
|
|
73390
73406
|
};
|
|
@@ -73889,7 +73905,8 @@ ${text}`;
|
|
|
73889
73905
|
entityType: m22.entity_type,
|
|
73890
73906
|
displayName: m22.display_name,
|
|
73891
73907
|
identityPublicKey: m22.identity_public_key,
|
|
73892
|
-
ephemeralPublicKey: m22.ephemeral_public_key
|
|
73908
|
+
ephemeralPublicKey: m22.ephemeral_public_key,
|
|
73909
|
+
...typeof m22.tenant_id === "string" ? { tenantId: m22.tenant_id } : {}
|
|
73893
73910
|
}));
|
|
73894
73911
|
if (members22.length > 0) {
|
|
73895
73912
|
const roomState = this._persisted.rooms[roomId];
|
|
@@ -75434,7 +75451,7 @@ ${text}`;
|
|
|
75434
75451
|
agentVersion: this.config.agentVersion ?? "0.0.0",
|
|
75435
75452
|
// __AV_VERSION__ is injected by esbuild from package.json at build time.
|
|
75436
75453
|
// Falls back to "0.0.0-dev" in non-bundled contexts (tests).
|
|
75437
|
-
pluginVersion: true ? "0.23.
|
|
75454
|
+
pluginVersion: true ? "0.23.55" : "0.0.0-dev"
|
|
75438
75455
|
});
|
|
75439
75456
|
this._telemetryReporter.startAutoFlush(3e4);
|
|
75440
75457
|
}
|
|
@@ -75590,7 +75607,8 @@ ${text}`;
|
|
|
75590
75607
|
entityType: m22.entity_type,
|
|
75591
75608
|
displayName: m22.display_name,
|
|
75592
75609
|
identityPublicKey: m22.identity_public_key,
|
|
75593
|
-
ephemeralPublicKey: m22.ephemeral_public_key
|
|
75610
|
+
ephemeralPublicKey: m22.ephemeral_public_key,
|
|
75611
|
+
...typeof m22.tenant_id === "string" ? { tenantId: m22.tenant_id } : {}
|
|
75594
75612
|
})),
|
|
75595
75613
|
conversations: (d22.conversations || []).map((c22) => ({
|
|
75596
75614
|
id: c22.id,
|
|
@@ -75765,7 +75783,7 @@ ${text}`;
|
|
|
75765
75783
|
agentVersion: this.config.agentVersion ?? "0.0.0",
|
|
75766
75784
|
// __AV_VERSION__ is injected by esbuild from package.json at build time.
|
|
75767
75785
|
// Falls back to "0.0.0-dev" in non-bundled contexts (tests).
|
|
75768
|
-
pluginVersion: true ? "0.23.
|
|
75786
|
+
pluginVersion: true ? "0.23.55" : "0.0.0-dev"
|
|
75769
75787
|
});
|
|
75770
75788
|
this._telemetryReporter.startAutoFlush(3e4);
|
|
75771
75789
|
}
|
|
@@ -76622,13 +76640,13 @@ ${messageText}`;
|
|
|
76622
76640
|
* Returns the text unchanged when there is no attachment or the fetch fails —
|
|
76623
76641
|
* but a failure is LOGGED and announced in the text, never silent.
|
|
76624
76642
|
*/
|
|
76625
|
-
async _augmentWithAttachment(attachmentInfo, baseText, roomId) {
|
|
76643
|
+
async _augmentWithAttachment(attachmentInfo, baseText, roomId, senderDeviceId) {
|
|
76626
76644
|
if (!attachmentInfo) return baseText;
|
|
76627
76645
|
try {
|
|
76628
76646
|
const { filePath, decrypted } = await this._downloadAndDecryptAttachment(attachmentInfo);
|
|
76629
76647
|
const mime = String(attachmentInfo.mime ?? "application/octet-stream");
|
|
76630
76648
|
const name = String(attachmentInfo.filename ?? "attachment");
|
|
76631
|
-
if (roomId) this._recentRoomAttachments.set(roomId, { filePath, name, at: Date.now() });
|
|
76649
|
+
if (roomId) this._recentRoomAttachments.set(roomId, { filePath, name, at: Date.now(), senderDeviceId });
|
|
76632
76650
|
const textMimes = ["text/", "application/json", "application/xml", "application/csv"];
|
|
76633
76651
|
if (textMimes.some((m22) => mime.startsWith(m22))) {
|
|
76634
76652
|
const content = new TextDecoder().decode(decrypted);
|
|
@@ -77284,22 +77302,34 @@ ${baseText}`;
|
|
|
77284
77302
|
}
|
|
77285
77303
|
const caption = messageText;
|
|
77286
77304
|
const addressed = parseMentions(messageText).length > 0;
|
|
77305
|
+
const foldedFrom = [];
|
|
77287
77306
|
if (roomAttachment && !addressed) {
|
|
77288
|
-
this._deferRoomAttachment(resolvedRoomId, roomAttachment);
|
|
77307
|
+
this._deferRoomAttachment(resolvedRoomId, roomAttachment, senderDeviceId);
|
|
77289
77308
|
} else {
|
|
77290
77309
|
const deferred = addressed ? this._takeDeferredRoomAttachments(resolvedRoomId) : [];
|
|
77291
|
-
for (const
|
|
77292
|
-
messageText = await this._augmentWithAttachment(info, messageText, resolvedRoomId);
|
|
77310
|
+
for (const d22 of deferred) {
|
|
77311
|
+
messageText = await this._augmentWithAttachment(d22.info, messageText, resolvedRoomId, d22.senderDeviceId);
|
|
77312
|
+
foldedFrom.push(d22.senderDeviceId ?? null);
|
|
77293
77313
|
}
|
|
77294
77314
|
if (roomAttachment) {
|
|
77295
|
-
messageText = await this._augmentWithAttachment(roomAttachment, messageText, resolvedRoomId);
|
|
77315
|
+
messageText = await this._augmentWithAttachment(roomAttachment, messageText, resolvedRoomId, senderDeviceId);
|
|
77316
|
+
foldedFrom.push(senderDeviceId ?? null);
|
|
77296
77317
|
} else if (deferred.length === 0) {
|
|
77297
|
-
|
|
77318
|
+
const noted = this._withRecentRoomAttachmentNote(resolvedRoomId, messageText);
|
|
77319
|
+
messageText = noted.text;
|
|
77320
|
+
if (noted.from !== void 0) foldedFrom.push(noted.from);
|
|
77298
77321
|
}
|
|
77299
77322
|
}
|
|
77300
77323
|
const roomMembers = this._persisted?.rooms?.[resolvedRoomId]?.members ?? [];
|
|
77301
77324
|
const senderMember = roomMembers.find((m22) => m22.deviceId === senderDeviceId);
|
|
77302
77325
|
const senderIsAgent = senderMember?.entityType === "agent" ? true : senderMember?.entityType === "owner" || senderMember?.entityType === "human" ? false : void 0;
|
|
77326
|
+
const ownTenantId = this._deviceJwt ? this._decodeTenantIdForRecovery(this._deviceJwt) : null;
|
|
77327
|
+
const isOwnerMember = (deviceId) => {
|
|
77328
|
+
const member = deviceId ? roomMembers.find((m22) => m22.deviceId === deviceId) : void 0;
|
|
77329
|
+
return (member?.entityType === "owner" || member?.entityType === "human") && ownTenantId !== null && typeof member?.tenantId === "string" && member.tenantId.toLowerCase() === ownTenantId;
|
|
77330
|
+
};
|
|
77331
|
+
const senderIsOwner = senderIsAgent === false && isOwnerMember(senderDeviceId);
|
|
77332
|
+
const foreignContent = foldedFrom.some((from) => !isOwnerMember(from));
|
|
77303
77333
|
const metadata = {
|
|
77304
77334
|
messageId: data.message_id ?? "",
|
|
77305
77335
|
conversationId: "",
|
|
@@ -77308,6 +77338,8 @@ ${baseText}`;
|
|
|
77308
77338
|
roomId: resolvedRoomId,
|
|
77309
77339
|
senderDeviceId,
|
|
77310
77340
|
senderIsAgent,
|
|
77341
|
+
senderIsOwner,
|
|
77342
|
+
foreignContent,
|
|
77311
77343
|
senderName: senderMember?.displayName || "unknown",
|
|
77312
77344
|
roomName: this._persisted?.rooms?.[resolvedRoomId]?.name,
|
|
77313
77345
|
caption
|
|
@@ -77333,7 +77365,10 @@ ${baseText}`;
|
|
|
77333
77365
|
timestamp: data.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
77334
77366
|
// Bridges require an explicit human classification for room tools.
|
|
77335
77367
|
// Reply policy separately uses this field for agent-loop prevention.
|
|
77336
|
-
senderIsAgent
|
|
77368
|
+
senderIsAgent,
|
|
77369
|
+
// #1459 — owner-only power keys on these, never on senderIsAgent.
|
|
77370
|
+
senderIsOwner,
|
|
77371
|
+
foreignContent
|
|
77337
77372
|
});
|
|
77338
77373
|
const contextualMessage = senderIsAgent ? messageText : `[${senderLabel}]: ${messageText}`;
|
|
77339
77374
|
Promise.resolve(this.config.onMessage?.(contextualMessage, metadata)).catch((err) => {
|
|
@@ -102165,7 +102200,7 @@ data:
|
|
|
102165
102200
|
await init_policy_enforcer();
|
|
102166
102201
|
init_room_protocol();
|
|
102167
102202
|
init_tool_telemetry();
|
|
102168
|
-
VERSION = true ? "0.23.
|
|
102203
|
+
VERSION = true ? "0.23.55" : "0.0.0-dev";
|
|
102169
102204
|
}
|
|
102170
102205
|
});
|
|
102171
102206
|
await init_index();
|
|
@@ -145605,6 +145640,7 @@ function pollApprovalsOnce(arming, dataDir, onArmed, log = () => {
|
|
|
145605
145640
|
}
|
|
145606
145641
|
}
|
|
145607
145642
|
}
|
|
145643
|
+
var FILE_LOCK_NOTE = "[AgentVault: this turn has no tools, because it includes a file another room member shared. If you were asked to run or change something, say so, and that it will work in a message that doesn't refer to that file, or in a 1:1 chat.]";
|
|
145608
145644
|
function roomTurnPrefix(roomId, senderName, roomName) {
|
|
145609
145645
|
return `[room ${roomLabel(roomId, roomName)} | ${sanitizeLabel(senderName)}]`;
|
|
145610
145646
|
}
|
|
@@ -145714,10 +145750,15 @@ function wireBridge(channel, session, target, opts = {}) {
|
|
|
145714
145750
|
target.setRoom(e7.roomId);
|
|
145715
145751
|
const held = roomContext.peek(e7.roomId);
|
|
145716
145752
|
const contextBlock = formatRoomContext(held.entries, roomLabel(e7.roomId, roomNames.get(e7.roomId)), held.dropped);
|
|
145717
|
-
const
|
|
145753
|
+
const fileLocked = e7.senderIsAgent === false && e7.senderIsOwner === true && e7.foreignContent === true;
|
|
145754
|
+
if (fileLocked) log(`room ${e7.roomId.slice(0, 8)}: owner turn without tools \u2014 it carries a file another member shared (#1459)`);
|
|
145755
|
+
const turnText = `${roomTurnPrefix(e7.roomId, e7.senderName, roomNames.get(e7.roomId))}: ${e7.plaintext}`;
|
|
145756
|
+
const delivered = session.push(fileLocked ? `${turnText}
|
|
145757
|
+
|
|
145758
|
+
${FILE_LOCK_NOTE}` : turnText, target.snapshotReply(channel, log), {
|
|
145718
145759
|
autoReplyOnText: false,
|
|
145719
145760
|
replyExpected: owes,
|
|
145720
|
-
toolEligibleSender: e7.senderIsAgent === false,
|
|
145761
|
+
toolEligibleSender: e7.senderIsAgent === false && e7.senderIsOwner === true && e7.foreignContent === false,
|
|
145721
145762
|
armed: () => arming.isArmed(e7.roomId),
|
|
145722
145763
|
...contextBlock ? { roomContext: contextBlock } : {}
|
|
145723
145764
|
});
|
|
@@ -145902,7 +145943,7 @@ async function main() {
|
|
|
145902
145943
|
"[bridge] warning: passing the invite token on the command line is visible to other local users via 'ps'. Prefer: AV_INVITE_TOKEN=\u2026 npx @agentvault/claude-bridge"
|
|
145903
145944
|
);
|
|
145904
145945
|
}
|
|
145905
|
-
logLine(`[bridge] version: ${true ? "0.8.
|
|
145946
|
+
logLine(`[bridge] version: ${true ? "0.8.27" : "dev"}`);
|
|
145906
145947
|
logLine(`[bridge] data dir: ${cfg.dataDir} (${cfg.dataDirSource})`);
|
|
145907
145948
|
logLine(`[bridge] workspace: ${cfg.workspaceDir} \xB7 permissions: ${cfg.permissionMode} \xB7 enclave dir fenced`);
|
|
145908
145949
|
if (cfg.armRoom) {
|
|
@@ -145934,7 +145975,7 @@ async function main() {
|
|
|
145934
145975
|
// its default would render "@agentvault/agentvault@0.7.x" — the wrong
|
|
145935
145976
|
// package name attached to the bridge's version number, which is worse
|
|
145936
145977
|
// than either alone.
|
|
145937
|
-
clientVersion: `@agentvault/claude-bridge@${true ? "0.8.
|
|
145978
|
+
clientVersion: `@agentvault/claude-bridge@${true ? "0.8.27" : "dev"}`
|
|
145938
145979
|
});
|
|
145939
145980
|
const agentSystemPrompt = cfg.systemPrompt ?? identityPrompt(cfg.agentName);
|
|
145940
145981
|
const deviceJwt = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvault/claude-bridge",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.27",
|
|
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",
|