@agentvault/agentvault 0.23.22 → 0.23.24

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.24" : 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.24" : "0.0.0-dev";
65074
65096
  const agentName = this.config.agentName ?? "Agent";
65075
65097
  const resource = {
65076
65098
  "service.name": "agentvault-agent",
@@ -65535,7 +65557,7 @@ var init_channel = __esm({
65535
65557
  this._persisted.groupId = primary.group_id;
65536
65558
  this._persisted.primaryConversationId = primary.id;
65537
65559
  const liveGroupIds = new Set(mine.map((r2) => r2.group_id));
65538
- if (!liveGroupIds.has(staleGid)) {
65560
+ if (staleGid && staleMlsGroupId && !liveGroupIds.has(staleGid)) {
65539
65561
  try {
65540
65562
  await deleteMlsState(this.config.dataDir, staleMlsGroupId);
65541
65563
  } catch {
@@ -65549,9 +65571,9 @@ var init_channel = __esm({
65549
65571
  }
65550
65572
  await this._persistState();
65551
65573
  console.log(
65552
- `[SecureChannel] Re-resolved conversation groups after 'unknown group' ${staleMlsGroupId.slice(0, 8)}: primary group ${String(before).slice(0, 8)} \u2192 ${this._persisted.groupId.slice(0, 8)} (${mine.length} active conversation(s))`
65574
+ `[SecureChannel] Re-resolved conversation groups ${staleMlsGroupId ? `after 'unknown group' ${staleMlsGroupId.slice(0, 8)}` : "on connect (#1034)"}: primary group ${String(before).slice(0, 8)} \u2192 ${this._persisted.groupId.slice(0, 8)} (${mine.length} active conversation(s))`
65553
65575
  );
65554
- return this._persisted.groupId !== before && before === staleGid;
65576
+ return staleGid !== void 0 && this._persisted.groupId !== before && before === staleGid;
65555
65577
  }
65556
65578
  /**
65557
65579
  * Resend the message that a now-reconciled `unknown group` refusal killed (#732).
@@ -66953,6 +66975,9 @@ var init_channel = __esm({
66953
66975
  await this._pullDrDeliveryQueue();
66954
66976
  await this._flushOutboundQueue();
66955
66977
  this._setState("ready");
66978
+ void this._reconcileConversationGroups().catch((err) => {
66979
+ console.warn("[SecureChannel] Conversation-group reconcile failed:", err);
66980
+ });
66956
66981
  void this._reconcileRoomsWithServer().catch(
66957
66982
  (err) => console.warn(`[SecureChannel] room reconcile failed (ignored): ${err instanceof Error ? err.message : String(err)}`)
66958
66983
  ).then(() => this._quarantineOrphanedMlsGroups()).catch(
@@ -66980,7 +67005,7 @@ var init_channel = __esm({
66980
67005
  agentVersion: this.config.agentVersion ?? "0.0.0",
66981
67006
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
66982
67007
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
66983
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
67008
+ pluginVersion: true ? "0.23.24" : "0.0.0-dev"
66984
67009
  });
66985
67010
  this._telemetryReporter.startAutoFlush(3e4);
66986
67011
  }
@@ -67304,7 +67329,7 @@ var init_channel = __esm({
67304
67329
  agentVersion: this.config.agentVersion ?? "0.0.0",
67305
67330
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
67306
67331
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
67307
- pluginVersion: true ? "0.23.22" : "0.0.0-dev"
67332
+ pluginVersion: true ? "0.23.24" : "0.0.0-dev"
67308
67333
  });
67309
67334
  this._telemetryReporter.startAutoFlush(3e4);
67310
67335
  }
@@ -68710,7 +68735,14 @@ ${messageText}`;
68710
68735
  console.log(`[SecureChannel] MLS commit processed for room ${roomId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
68711
68736
  this._mlsCommitFailCounts.delete(roomId);
68712
68737
  } catch (err) {
68713
- await this._onCommitFailure(roomId, groupId, err, `room ${roomId.slice(0, 8)}`);
68738
+ await this._onCommitFailure(
68739
+ roomId,
68740
+ groupId,
68741
+ err,
68742
+ `room ${roomId.slice(0, 8)}`,
68743
+ data.epoch,
68744
+ mlsGroup.epoch
68745
+ );
68714
68746
  }
68715
68747
  } else {
68716
68748
  this._bufferMlsCommit(groupId, epoch, data);
@@ -68730,7 +68762,14 @@ ${messageText}`;
68730
68762
  console.log(`[SecureChannel] MLS commit processed for A2A ${chId.slice(0, 8)} (epoch=${mlsGroup.epoch})`);
68731
68763
  this._mlsCommitFailCounts.delete(`a2a:${chId}`);
68732
68764
  } catch (err) {
68733
- await this._onCommitFailure(`a2a:${chId}`, groupId, err, `A2A ${chId.slice(0, 8)}`);
68765
+ await this._onCommitFailure(
68766
+ `a2a:${chId}`,
68767
+ groupId,
68768
+ err,
68769
+ `A2A ${chId.slice(0, 8)}`,
68770
+ data.epoch,
68771
+ mlsGroup.epoch
68772
+ );
68734
68773
  }
68735
68774
  } else {
68736
68775
  this._bufferMlsCommit(groupId, epoch, data);
@@ -68816,7 +68855,13 @@ ${messageText}`;
68816
68855
  * Never re-throws. The caller's only handler logs and drops, so throwing here
68817
68856
  * is indistinguishable from swallowing — it just moves the swallow one frame up.
68818
68857
  */
68819
- async _onCommitFailure(groupKey, mlsGroupId, err, label) {
68858
+ async _onCommitFailure(groupKey, mlsGroupId, err, label, messageEpoch, groupEpoch) {
68859
+ if (classifyCommitFailure(messageEpoch, groupEpoch) === "already-applied") {
68860
+ console.debug(
68861
+ `[SecureChannel] Skipping already-applied MLS commit for ${label} (commit epoch ${String(messageEpoch)} is behind group epoch ${String(groupEpoch)})`
68862
+ );
68863
+ return;
68864
+ }
68820
68865
  const count = (this._mlsCommitFailCounts.get(groupKey) ?? 0) + 1;
68821
68866
  this._mlsCommitFailCounts.set(groupKey, count);
68822
68867
  console.error(
@@ -69164,7 +69209,8 @@ ${messageText}`;
69164
69209
  const candidateCount = candidates.filter(Boolean).length;
69165
69210
  const joined = await joinWithFirstMatchingKp(welcomeBytes, candidates);
69166
69211
  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.`);
69212
+ 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.`);
69213
+ if (groupId) void this._requestWelcomeSelfHeal(groupId);
69168
69214
  return;
69169
69215
  }
69170
69216
  const mgr = joined.mgr;
@@ -70713,7 +70759,7 @@ ${messageText}`;
70713
70759
  return;
70714
70760
  }
70715
70761
  this._authFailedThisSession = true;
70716
- const authReason = data?.reason ?? "device_revoked";
70762
+ const authReason = data?.reason ?? "unknown";
70717
70763
  console.warn(
70718
70764
  `[SecureChannel] connection_rejected (reason=${data?.reason ?? "unknown"}, retryable=false) \u2014 terminal; surfacing auth_failed`
70719
70765
  );
@@ -97734,7 +97780,7 @@ var init_index = __esm({
97734
97780
  init_skill_invoker();
97735
97781
  await init_skill_telemetry();
97736
97782
  await init_policy_enforcer();
97737
- VERSION = true ? "0.23.22" : "0.0.0-dev";
97783
+ VERSION = true ? "0.23.24" : "0.0.0-dev";
97738
97784
  }
97739
97785
  });
97740
97786
  await init_index();