@agentvault/grok-bridge 0.3.1 → 0.3.2

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
@@ -490,14 +490,17 @@ var subcommand_exports = {};
490
490
  __export(subcommand_exports, {
491
491
  maybeRunServiceSubcommand: () => maybeRunServiceSubcommand
492
492
  });
493
- function labelFor(env) {
493
+ function requireAgentName(env) {
494
494
  const name = env.AV_AGENT_NAME?.trim();
495
495
  if (!name) {
496
496
  throw new Error(
497
497
  "AV_AGENT_NAME is required \u2014 it names WHICH agent's service to act on. Re-run as: AV_AGENT_NAME=<agent-name> agentvault-grok-bridge <subcommand>"
498
498
  );
499
499
  }
500
- return `dev.agentvault.grok-${slugify2(name)}`;
500
+ return name;
501
+ }
502
+ function labelFor(env) {
503
+ return `dev.agentvault.grok-${slugify2(requireAgentName(env))}`;
501
504
  }
502
505
  function maybeRunServiceSubcommand(argv, env, deps) {
503
506
  const cmd = argv[2];
@@ -517,6 +520,7 @@ function maybeRunServiceSubcommand(argv, env, deps) {
517
520
  const log = deps?.log ?? ((m2) => logLine("[grok-bridge] " + m2));
518
521
  try {
519
522
  if (cmd === "install") {
523
+ requireAgentName(env);
520
524
  const cfg = loadConfig(env, []);
521
525
  const firstBoot = !hasPersistedCreds(cfg.dataDir) && !!cfg.inviteToken;
522
526
  if (firstBoot) {
@@ -730,6 +734,25 @@ var __toESM = (mod4, isNodeMode, target) => (target = mod4 != null ? __create(__
730
734
  isNodeMode || !mod4 || !mod4.__esModule ? __defProp2(target, "default", { value: mod4, enumerable: true }) : target,
731
735
  mod4
732
736
  ));
737
+ function toEpoch(v2) {
738
+ if (typeof v2 === "bigint") return v2;
739
+ if (typeof v2 === "number") {
740
+ return Number.isFinite(v2) ? BigInt(Math.trunc(v2)) : null;
741
+ }
742
+ if (typeof v2 === "string" && /^\d+$/.test(v2)) return BigInt(v2);
743
+ return null;
744
+ }
745
+ function classifyCommitFailure(messageEpoch, groupEpoch) {
746
+ const msg = toEpoch(messageEpoch);
747
+ const grp = toEpoch(groupEpoch);
748
+ if (msg === null || grp === null) return "count";
749
+ return msg < grp ? "already-applied" : "count";
750
+ }
751
+ var init_mls_commit_classify = __esm2({
752
+ "src/mls-commit-classify.ts"() {
753
+ "use strict";
754
+ }
755
+ });
733
756
  var __filename;
734
757
  var __dirname;
735
758
  var url2;
@@ -64077,7 +64100,7 @@ var init_mls_kp_pool = __esm2({
64077
64100
  }
64078
64101
  });
64079
64102
  function ownIdentity() {
64080
- const v2 = true ? "0.23.22" : FALLBACK;
64103
+ const v2 = true ? "0.23.23" : FALLBACK;
64081
64104
  return `${PACKAGE}@${v2}`;
64082
64105
  }
64083
64106
  function buildClientVersion(override) {
@@ -64989,6 +65012,7 @@ var SecureChannel;
64989
65012
  var init_channel = __esm2({
64990
65013
  async "src/channel.ts"() {
64991
65014
  "use strict";
65015
+ init_mls_commit_classify();
64992
65016
  await init_libsodium_wrappers();
64993
65017
  await init_dist();
64994
65018
  await init_dist();
@@ -66055,7 +66079,7 @@ var init_channel = __esm2({
66055
66079
  */
66056
66080
  sendActivitySpan(spanData) {
66057
66081
  if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
66058
- const pluginVersion = true ? "0.23.22" : "0.0.0-dev";
66082
+ const pluginVersion = true ? "0.23.23" : "0.0.0-dev";
66059
66083
  const agentName = this.config.agentName ?? "Agent";
66060
66084
  const resource = {
66061
66085
  "service.name": "agentvault-agent",
@@ -67965,7 +67989,7 @@ var init_channel = __esm2({
67965
67989
  agentVersion: this.config.agentVersion ?? "0.0.0",
67966
67990
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
67967
67991
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
67968
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
67992
+ pluginVersion: true ? "0.23.23" : "0.0.0-dev"
67969
67993
  });
67970
67994
  this._telemetryReporter.startAutoFlush(3e4);
67971
67995
  }
@@ -68289,7 +68313,7 @@ var init_channel = __esm2({
68289
68313
  agentVersion: this.config.agentVersion ?? "0.0.0",
68290
68314
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
68291
68315
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
68292
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
68316
+ pluginVersion: true ? "0.23.23" : "0.0.0-dev"
68293
68317
  });
68294
68318
  this._telemetryReporter.startAutoFlush(3e4);
68295
68319
  }
@@ -69695,7 +69719,14 @@ ${messageText}`;
69695
69719
  console.log(`[SecureChannel] MLS commit processed for room ${roomId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
69696
69720
  this._mlsCommitFailCounts.delete(roomId);
69697
69721
  } catch (err) {
69698
- await this._onCommitFailure(roomId, groupId, err, `room ${roomId.slice(0, 8)}`);
69722
+ await this._onCommitFailure(
69723
+ roomId,
69724
+ groupId,
69725
+ err,
69726
+ `room ${roomId.slice(0, 8)}`,
69727
+ data.epoch,
69728
+ mlsGroup.epoch
69729
+ );
69699
69730
  }
69700
69731
  } else {
69701
69732
  this._bufferMlsCommit(groupId, epoch, data);
@@ -69715,7 +69746,14 @@ ${messageText}`;
69715
69746
  console.log(`[SecureChannel] MLS commit processed for A2A ${chId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
69716
69747
  this._mlsCommitFailCounts.delete(`a2a:${chId}`);
69717
69748
  } catch (err) {
69718
- await this._onCommitFailure(`a2a:${chId}`, groupId, err, `A2A ${chId.slice(0, 8)}`);
69749
+ await this._onCommitFailure(
69750
+ `a2a:${chId}`,
69751
+ groupId,
69752
+ err,
69753
+ `A2A ${chId.slice(0, 8)}`,
69754
+ data.epoch,
69755
+ mlsGroup.epoch
69756
+ );
69719
69757
  }
69720
69758
  } else {
69721
69759
  this._bufferMlsCommit(groupId, epoch, data);
@@ -69801,7 +69839,13 @@ ${messageText}`;
69801
69839
  * Never re-throws. The caller's only handler logs and drops, so throwing here
69802
69840
  * is indistinguishable from swallowing — it just moves the swallow one frame up.
69803
69841
  */
69804
- async _onCommitFailure(groupKey, mlsGroupId, err, label) {
69842
+ async _onCommitFailure(groupKey, mlsGroupId, err, label, messageEpoch, groupEpoch) {
69843
+ if (classifyCommitFailure(messageEpoch, groupEpoch) === "already-applied") {
69844
+ console.debug(
69845
+ `[SecureChannel] Skipping already-applied MLS commit for ${label} (commit epoch ${String(messageEpoch)} is behind group epoch ${String(groupEpoch)})`
69846
+ );
69847
+ return;
69848
+ }
69805
69849
  const count = (this._mlsCommitFailCounts.get(groupKey) ?? 0) + 1;
69806
69850
  this._mlsCommitFailCounts.set(groupKey, count);
69807
69851
  console.error(
@@ -71699,7 +71743,7 @@ ${messageText}`;
71699
71743
  return;
71700
71744
  }
71701
71745
  this._authFailedThisSession = true;
71702
- const authReason = data?.reason ?? "device_revoked";
71746
+ const authReason = data?.reason ?? "unknown";
71703
71747
  console.warn(
71704
71748
  `[SecureChannel] connection_rejected (reason=${data?.reason ?? "unknown"}, retryable=false) \u2014 terminal; surfacing auth_failed`
71705
71749
  );
@@ -98280,7 +98324,7 @@ var init_index = __esm2({
98280
98324
  init_skill_invoker();
98281
98325
  await init_skill_telemetry();
98282
98326
  await init_policy_enforcer();
98283
- VERSION = true ? "0.23.22" : "0.0.0-dev";
98327
+ VERSION = true ? "0.23.23" : "0.0.0-dev";
98284
98328
  }
98285
98329
  });
98286
98330
  await init_index();
@@ -99143,7 +99187,7 @@ async function main() {
99143
99187
  const info = parseInfoFlags(process.argv.slice(2));
99144
99188
  if (info.showVersion || info.showHelp) {
99145
99189
  const version2 = buildClientVersion2(
99146
- true ? "0.3.1" : void 0
99190
+ true ? "0.3.2" : void 0
99147
99191
  );
99148
99192
  if (info.showVersion) printLine(version2);
99149
99193
  if (info.showHelp) {
@@ -99201,7 +99245,7 @@ async function main() {
99201
99245
  agentName: cfg.agentName,
99202
99246
  platform: "node",
99203
99247
  clientVersion: buildClientVersion2(
99204
- true ? "0.3.1" : void 0
99248
+ true ? "0.3.2" : void 0
99205
99249
  )
99206
99250
  });
99207
99251
  channelRef = channel;
@@ -1 +1 @@
1
- {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../src/service/subcommand.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAkCD;;uFAEuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAkHT"}
1
+ {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../src/service/subcommand.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAiDD;;uFAEuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAqHT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvault/grok-bridge",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "AgentVault Grok Bridge — daemon bridging a Grok agent into E2E-encrypted AgentVault direct messages and rooms.",
6
6
  "main": "dist/index.js",