@agentvault/claude-bridge 0.7.14 → 0.7.16

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/index.js CHANGED
@@ -399,11 +399,20 @@ var subcommand_exports = {};
399
399
  __export(subcommand_exports, {
400
400
  maybeRunServiceSubcommand: () => maybeRunServiceSubcommand
401
401
  });
402
+ function requireAgentName(env) {
403
+ const name = env.AV_AGENT_NAME?.trim();
404
+ if (!name) {
405
+ throw new Error(
406
+ "AV_AGENT_NAME is required \u2014 it names WHICH agent's service to act on. Re-run as: AV_AGENT_NAME=<agent-name> agentvault-claude-bridge <subcommand>"
407
+ );
408
+ }
409
+ return name;
410
+ }
402
411
  function labelFor(env) {
403
- return `dev.agentvault.bridge-${slugify2(env.AV_AGENT_NAME ?? "claude")}`;
412
+ return `dev.agentvault.bridge-${slugify2(requireAgentName(env))}`;
404
413
  }
405
414
  function legacyLabelFor(env) {
406
- return `com.agentvault.claude-bridge.${slugify2(env.AV_AGENT_NAME ?? "claude")}`;
415
+ return `com.agentvault.claude-bridge.${slugify2(requireAgentName(env))}`;
407
416
  }
408
417
  function resolveLabel(backend, env) {
409
418
  const current = labelFor(env);
@@ -414,12 +423,23 @@ function resolveLabel(backend, env) {
414
423
  }
415
424
  function maybeRunServiceSubcommand(argv, env, deps) {
416
425
  const cmd = argv[2];
417
- if (!cmd || !SERVICE_CMDS.has(cmd)) return false;
426
+ if (!cmd) return false;
427
+ if (!SERVICE_CMDS.has(cmd)) {
428
+ const looksLikeToken = cmd.startsWith("av_tok_");
429
+ const looksLikeFlag = cmd.startsWith("-");
430
+ if (!looksLikeToken && !looksLikeFlag) {
431
+ throw new Error(
432
+ `unknown subcommand: ${cmd} \u2014 expected one of ${[...SERVICE_CMDS].join(", ")}, an invite token, or no argument at all`
433
+ );
434
+ }
435
+ return false;
436
+ }
418
437
  const backend = deps?.backend ?? selectBackend(process.platform);
419
438
  const entrypoint = deps?.entrypoint ?? process.argv[1];
420
439
  const log = deps?.log ?? ((m6) => console.error("[bridge] " + m6));
421
440
  try {
422
441
  if (cmd === "install") {
442
+ requireAgentName(env);
423
443
  const cfg = loadConfig(env, []);
424
444
  if (!hasPersistedCreds(cfg.dataDir)) {
425
445
  throw new Error(
@@ -436,7 +456,9 @@ function maybeRunServiceSubcommand(argv, env, deps) {
436
456
  });
437
457
  backend.install(spec);
438
458
  log(`installed service ${spec.label} \u2014 logs: ${spec.logOut}`);
439
- log(`check it with: agentvault-claude-bridge status`);
459
+ log(
460
+ `check it with: AV_AGENT_NAME=${cfg.agentName} agentvault-claude-bridge status`
461
+ );
440
462
  } else if (cmd === "uninstall") {
441
463
  const label = resolveLabel(backend, env);
442
464
  backend.uninstall(label);
@@ -532,6 +554,25 @@ var __toESM = (mod4, isNodeMode, target) => (target = mod4 != null ? __create(__
532
554
  isNodeMode || !mod4 || !mod4.__esModule ? __defProp2(target, "default", { value: mod4, enumerable: true }) : target,
533
555
  mod4
534
556
  ));
557
+ function toEpoch(v22) {
558
+ if (typeof v22 === "bigint") return v22;
559
+ if (typeof v22 === "number") {
560
+ return Number.isFinite(v22) ? BigInt(Math.trunc(v22)) : null;
561
+ }
562
+ if (typeof v22 === "string" && /^\d+$/.test(v22)) return BigInt(v22);
563
+ return null;
564
+ }
565
+ function classifyCommitFailure(messageEpoch, groupEpoch) {
566
+ const msg = toEpoch(messageEpoch);
567
+ const grp = toEpoch(groupEpoch);
568
+ if (msg === null || grp === null) return "count";
569
+ return msg < grp ? "already-applied" : "count";
570
+ }
571
+ var init_mls_commit_classify = __esm2({
572
+ "src/mls-commit-classify.ts"() {
573
+ "use strict";
574
+ }
575
+ });
535
576
  var __filename;
536
577
  var __dirname;
537
578
  var url2;
@@ -63879,7 +63920,7 @@ var init_mls_kp_pool = __esm2({
63879
63920
  }
63880
63921
  });
63881
63922
  function ownIdentity() {
63882
- const v22 = true ? "0.23.22" : FALLBACK;
63923
+ const v22 = true ? "0.23.23" : FALLBACK;
63883
63924
  return `${PACKAGE}@${v22}`;
63884
63925
  }
63885
63926
  function buildClientVersion(override) {
@@ -64791,6 +64832,7 @@ var SecureChannel;
64791
64832
  var init_channel = __esm2({
64792
64833
  async "src/channel.ts"() {
64793
64834
  "use strict";
64835
+ init_mls_commit_classify();
64794
64836
  await init_libsodium_wrappers();
64795
64837
  await init_dist();
64796
64838
  await init_dist();
@@ -65857,7 +65899,7 @@ var init_channel = __esm2({
65857
65899
  */
65858
65900
  sendActivitySpan(spanData) {
65859
65901
  if (!this._ws || this._ws.readyState !== WebSocket2.OPEN) return;
65860
- const pluginVersion = true ? "0.23.22" : "0.0.0-dev";
65902
+ const pluginVersion = true ? "0.23.23" : "0.0.0-dev";
65861
65903
  const agentName = this.config.agentName ?? "Agent";
65862
65904
  const resource = {
65863
65905
  "service.name": "agentvault-agent",
@@ -67767,7 +67809,7 @@ var init_channel = __esm2({
67767
67809
  agentVersion: this.config.agentVersion ?? "0.0.0",
67768
67810
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
67769
67811
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
67770
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
67812
+ pluginVersion: true ? "0.23.23" : "0.0.0-dev"
67771
67813
  });
67772
67814
  this._telemetryReporter.startAutoFlush(3e4);
67773
67815
  }
@@ -68091,7 +68133,7 @@ var init_channel = __esm2({
68091
68133
  agentVersion: this.config.agentVersion ?? "0.0.0",
68092
68134
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
68093
68135
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
68094
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
68136
+ pluginVersion: true ? "0.23.23" : "0.0.0-dev"
68095
68137
  });
68096
68138
  this._telemetryReporter.startAutoFlush(3e4);
68097
68139
  }
@@ -69497,7 +69539,14 @@ ${messageText}`;
69497
69539
  console.log(`[SecureChannel] MLS commit processed for room ${roomId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
69498
69540
  this._mlsCommitFailCounts.delete(roomId);
69499
69541
  } catch (err) {
69500
- await this._onCommitFailure(roomId, groupId, err, `room ${roomId.slice(0, 8)}`);
69542
+ await this._onCommitFailure(
69543
+ roomId,
69544
+ groupId,
69545
+ err,
69546
+ `room ${roomId.slice(0, 8)}`,
69547
+ data.epoch,
69548
+ mlsGroup.epoch
69549
+ );
69501
69550
  }
69502
69551
  } else {
69503
69552
  this._bufferMlsCommit(groupId, epoch, data);
@@ -69517,7 +69566,14 @@ ${messageText}`;
69517
69566
  console.log(`[SecureChannel] MLS commit processed for A2A ${chId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
69518
69567
  this._mlsCommitFailCounts.delete(`a2a:${chId}`);
69519
69568
  } catch (err) {
69520
- await this._onCommitFailure(`a2a:${chId}`, groupId, err, `A2A ${chId.slice(0, 8)}`);
69569
+ await this._onCommitFailure(
69570
+ `a2a:${chId}`,
69571
+ groupId,
69572
+ err,
69573
+ `A2A ${chId.slice(0, 8)}`,
69574
+ data.epoch,
69575
+ mlsGroup.epoch
69576
+ );
69521
69577
  }
69522
69578
  } else {
69523
69579
  this._bufferMlsCommit(groupId, epoch, data);
@@ -69603,7 +69659,13 @@ ${messageText}`;
69603
69659
  * Never re-throws. The caller's only handler logs and drops, so throwing here
69604
69660
  * is indistinguishable from swallowing — it just moves the swallow one frame up.
69605
69661
  */
69606
- async _onCommitFailure(groupKey, mlsGroupId, err, label) {
69662
+ async _onCommitFailure(groupKey, mlsGroupId, err, label, messageEpoch, groupEpoch) {
69663
+ if (classifyCommitFailure(messageEpoch, groupEpoch) === "already-applied") {
69664
+ console.debug(
69665
+ `[SecureChannel] Skipping already-applied MLS commit for ${label} (commit epoch ${String(messageEpoch)} is behind group epoch ${String(groupEpoch)})`
69666
+ );
69667
+ return;
69668
+ }
69607
69669
  const count = (this._mlsCommitFailCounts.get(groupKey) ?? 0) + 1;
69608
69670
  this._mlsCommitFailCounts.set(groupKey, count);
69609
69671
  console.error(
@@ -69951,7 +70013,8 @@ ${messageText}`;
69951
70013
  const candidateCount = candidates.filter(Boolean).length;
69952
70014
  const joined = await joinWithFirstMatchingKp(welcomeBytes, candidates);
69953
70015
  if (!joined) {
69954
- console.error(`[SecureChannel] No matching KeyPackage found for Welcome \u2014 cannot join group ${groupId?.slice(0, 8)}. The Welcome is encrypted to a published KP's public key; none of our ${candidateCount} candidate bundle(s) decrypted it. The existing Welcome recovery mechanism will re-request.`);
70016
+ console.error(`[SecureChannel] No matching KeyPackage found for Welcome \u2014 cannot join group ${groupId?.slice(0, 8)}. The Welcome is encrypted to a published KP's public key; none of our ${candidateCount} candidate bundle(s) decrypted it. Requesting a re-Welcome with a fresh KeyPackage.`);
70017
+ if (groupId) void this._requestWelcomeSelfHeal(groupId);
69955
70018
  return;
69956
70019
  }
69957
70020
  const mgr = joined.mgr;
@@ -71500,7 +71563,7 @@ ${messageText}`;
71500
71563
  return;
71501
71564
  }
71502
71565
  this._authFailedThisSession = true;
71503
- const authReason = data?.reason ?? "device_revoked";
71566
+ const authReason = data?.reason ?? "unknown";
71504
71567
  console.warn(
71505
71568
  `[SecureChannel] connection_rejected (reason=${data?.reason ?? "unknown"}, retryable=false) \u2014 terminal; surfacing auth_failed`
71506
71569
  );
@@ -98081,7 +98144,7 @@ var init_index = __esm2({
98081
98144
  init_skill_invoker();
98082
98145
  await init_skill_telemetry();
98083
98146
  await init_policy_enforcer();
98084
- VERSION = true ? "0.23.22" : "0.0.0-dev";
98147
+ VERSION = true ? "0.23.23" : "0.0.0-dev";
98085
98148
  }
98086
98149
  });
98087
98150
  await init_index();
@@ -134435,7 +134498,7 @@ async function main() {
134435
134498
  "[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"
134436
134499
  );
134437
134500
  }
134438
- logLine(`[bridge] version: ${true ? "0.7.14" : "dev"}`);
134501
+ logLine(`[bridge] version: ${true ? "0.7.16" : "dev"}`);
134439
134502
  logLine(`[bridge] data dir: ${cfg.dataDir} (${cfg.dataDirSource})`);
134440
134503
  logLine(`[bridge] workspace: ${cfg.workspaceDir} \xB7 permissions: ${cfg.permissionMode} \xB7 enclave dir fenced`);
134441
134504
  if (cfg.armRoom) {
@@ -134467,7 +134530,7 @@ async function main() {
134467
134530
  // its default would render "@agentvault/agentvault@0.7.x" — the wrong
134468
134531
  // package name attached to the bridge's version number, which is worse
134469
134532
  // than either alone.
134470
- clientVersion: `@agentvault/claude-bridge@${true ? "0.7.14" : "dev"}`
134533
+ clientVersion: `@agentvault/claude-bridge@${true ? "0.7.16" : "dev"}`
134471
134534
  });
134472
134535
  const agentSystemPrompt = cfg.systemPrompt ?? `You are ${cfg.agentName}, an AI agent on AgentVault. You talk with your owner in 1:1 direct messages and collaborate with other agents in shared rooms. That is your identity \u2014 introduce yourself by that name and do not claim to be any other agent. To speak, call the say tool. In a 1:1 with your owner, reply to what they say. In a room you see every message \u2014 call say only when you have something worth adding, and otherwise stay silent. Keep messages concise.`;
134473
134536
  const deviceJwt = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../src/service/subcommand.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5B;AAiCD;;uFAEuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CA4DT"}
1
+ {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../src/service/subcommand.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5B;AAuDD;;uFAEuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CA0FT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvault/claude-bridge",
3
- "version": "0.7.14",
3
+ "version": "0.7.16",
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",
@@ -26,6 +26,7 @@
26
26
  "build": "npm --prefix ../plugin run build && tsc --emitDeclarationOnly && node build.mjs",
27
27
  "start": "node dist/index.js",
28
28
  "test": "vitest run",
29
+ "typecheck": "tsc -p tsconfig.test.json",
29
30
  "prepublishOnly": "npm run build"
30
31
  },
31
32
  "dependencies": {