@agentvault/agentvault 0.23.22 → 0.23.23

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
@@ -31,6 +31,27 @@ var __toESM = (mod4, isNodeMode, target) => (target = mod4 != null ? __create(__
31
31
  mod4
32
32
  ));
33
33
 
34
+ // src/mls-commit-classify.ts
35
+ function toEpoch(v2) {
36
+ if (typeof v2 === "bigint") return v2;
37
+ if (typeof v2 === "number") {
38
+ return Number.isFinite(v2) ? BigInt(Math.trunc(v2)) : null;
39
+ }
40
+ if (typeof v2 === "string" && /^\d+$/.test(v2)) return BigInt(v2);
41
+ return null;
42
+ }
43
+ function classifyCommitFailure(messageEpoch, groupEpoch) {
44
+ const msg = toEpoch(messageEpoch);
45
+ const grp = toEpoch(groupEpoch);
46
+ if (msg === null || grp === null) return "count";
47
+ return msg < grp ? "already-applied" : "count";
48
+ }
49
+ var init_mls_commit_classify = __esm({
50
+ "src/mls-commit-classify.ts"() {
51
+ "use strict";
52
+ }
53
+ });
54
+
34
55
  // ../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs
35
56
  var __filename, __dirname, url2, path, Module, Module, root, window_, crypto_, randomValuesStandard, crypto4, randomValueNodeJS, _Module, libsodium_sumo_default;
36
57
  var init_libsodium_sumo = __esm({
@@ -63078,7 +63099,7 @@ var init_mls_kp_pool = __esm({
63078
63099
 
63079
63100
  // src/client-version.ts
63080
63101
  function ownIdentity() {
63081
- const v2 = true ? "0.23.22" : FALLBACK;
63102
+ const v2 = true ? "0.23.23" : FALLBACK;
63082
63103
  return `${PACKAGE}@${v2}`;
63083
63104
  }
63084
63105
  function buildClientVersion(override) {
@@ -64004,6 +64025,7 @@ var ROOM_AGENT_TYPES, CREDENTIAL_MESSAGE_TYPES, CATCHUP_MESSAGE_TYPES, POLL_INTE
64004
64025
  var init_channel = __esm({
64005
64026
  async "src/channel.ts"() {
64006
64027
  "use strict";
64028
+ init_mls_commit_classify();
64007
64029
  await init_libsodium_wrappers();
64008
64030
  await init_dist();
64009
64031
  await init_dist();
@@ -65070,7 +65092,7 @@ var init_channel = __esm({
65070
65092
  */
65071
65093
  sendActivitySpan(spanData) {
65072
65094
  if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
65073
- const pluginVersion = true ? "0.23.22" : "0.0.0-dev";
65095
+ const pluginVersion = true ? "0.23.23" : "0.0.0-dev";
65074
65096
  const agentName = this.config.agentName ?? "Agent";
65075
65097
  const resource = {
65076
65098
  "service.name": "agentvault-agent",
@@ -66980,7 +67002,7 @@ var init_channel = __esm({
66980
67002
  agentVersion: this.config.agentVersion ?? "0.0.0",
66981
67003
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
66982
67004
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
66983
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
67005
+ pluginVersion: true ? "0.23.23" : "0.0.0-dev"
66984
67006
  });
66985
67007
  this._telemetryReporter.startAutoFlush(3e4);
66986
67008
  }
@@ -67304,7 +67326,7 @@ var init_channel = __esm({
67304
67326
  agentVersion: this.config.agentVersion ?? "0.0.0",
67305
67327
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
67306
67328
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
67307
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
67329
+ pluginVersion: true ? "0.23.23" : "0.0.0-dev"
67308
67330
  });
67309
67331
  this._telemetryReporter.startAutoFlush(3e4);
67310
67332
  }
@@ -68710,7 +68732,14 @@ ${messageText}`;
68710
68732
  console.log(`[SecureChannel] MLS commit processed for room ${roomId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
68711
68733
  this._mlsCommitFailCounts.delete(roomId);
68712
68734
  } catch (err) {
68713
- await this._onCommitFailure(roomId, groupId, err, `room ${roomId.slice(0, 8)}`);
68735
+ await this._onCommitFailure(
68736
+ roomId,
68737
+ groupId,
68738
+ err,
68739
+ `room ${roomId.slice(0, 8)}`,
68740
+ data.epoch,
68741
+ mlsGroup.epoch
68742
+ );
68714
68743
  }
68715
68744
  } else {
68716
68745
  this._bufferMlsCommit(groupId, epoch, data);
@@ -68730,7 +68759,14 @@ ${messageText}`;
68730
68759
  console.log(`[SecureChannel] MLS commit processed for A2A ${chId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
68731
68760
  this._mlsCommitFailCounts.delete(`a2a:${chId}`);
68732
68761
  } catch (err) {
68733
- await this._onCommitFailure(`a2a:${chId}`, groupId, err, `A2A ${chId.slice(0, 8)}`);
68762
+ await this._onCommitFailure(
68763
+ `a2a:${chId}`,
68764
+ groupId,
68765
+ err,
68766
+ `A2A ${chId.slice(0, 8)}`,
68767
+ data.epoch,
68768
+ mlsGroup.epoch
68769
+ );
68734
68770
  }
68735
68771
  } else {
68736
68772
  this._bufferMlsCommit(groupId, epoch, data);
@@ -68816,7 +68852,13 @@ ${messageText}`;
68816
68852
  * Never re-throws. The caller's only handler logs and drops, so throwing here
68817
68853
  * is indistinguishable from swallowing — it just moves the swallow one frame up.
68818
68854
  */
68819
- async _onCommitFailure(groupKey, mlsGroupId, err, label) {
68855
+ async _onCommitFailure(groupKey, mlsGroupId, err, label, messageEpoch, groupEpoch) {
68856
+ if (classifyCommitFailure(messageEpoch, groupEpoch) === "already-applied") {
68857
+ console.debug(
68858
+ `[SecureChannel] Skipping already-applied MLS commit for ${label} (commit epoch ${String(messageEpoch)} is behind group epoch ${String(groupEpoch)})`
68859
+ );
68860
+ return;
68861
+ }
68820
68862
  const count = (this._mlsCommitFailCounts.get(groupKey) ?? 0) + 1;
68821
68863
  this._mlsCommitFailCounts.set(groupKey, count);
68822
68864
  console.error(
@@ -69164,7 +69206,8 @@ ${messageText}`;
69164
69206
  const candidateCount = candidates.filter(Boolean).length;
69165
69207
  const joined = await joinWithFirstMatchingKp(welcomeBytes, candidates);
69166
69208
  if (!joined) {
69167
- 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.`);
69209
+ 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.`);
69210
+ if (groupId) void this._requestWelcomeSelfHeal(groupId);
69168
69211
  return;
69169
69212
  }
69170
69213
  const mgr = joined.mgr;
@@ -70713,7 +70756,7 @@ ${messageText}`;
70713
70756
  return;
70714
70757
  }
70715
70758
  this._authFailedThisSession = true;
70716
- const authReason = data?.reason ?? "device_revoked";
70759
+ const authReason = data?.reason ?? "unknown";
70717
70760
  console.warn(
70718
70761
  `[SecureChannel] connection_rejected (reason=${data?.reason ?? "unknown"}, retryable=false) \u2014 terminal; surfacing auth_failed`
70719
70762
  );
@@ -97734,7 +97777,7 @@ var init_index = __esm({
97734
97777
  init_skill_invoker();
97735
97778
  await init_skill_telemetry();
97736
97779
  await init_policy_enforcer();
97737
- VERSION = true ? "0.23.22" : "0.0.0-dev";
97780
+ VERSION = true ? "0.23.23" : "0.0.0-dev";
97738
97781
  }
97739
97782
  });
97740
97783
  await init_index();