@agentvault/agentvault 0.20.23 → 0.20.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
@@ -62726,6 +62726,27 @@ function mlsFileName(groupId) {
62726
62726
  const safe = groupId.replace(/[^a-zA-Z0-9_-]/g, "_");
62727
62727
  return `mls-${safe}.json`;
62728
62728
  }
62729
+ async function hasPendingWelcome(dataDir, groupId) {
62730
+ try {
62731
+ const filePath = join(dataDir, `mls-kp-pending-${groupId.replace(/[^a-zA-Z0-9_-]/g, "_")}.lock`);
62732
+ await readFile(filePath);
62733
+ return true;
62734
+ } catch {
62735
+ return false;
62736
+ }
62737
+ }
62738
+ async function setPendingWelcome(dataDir, groupId) {
62739
+ await mkdir(dataDir, { recursive: true, mode: DIR_MODE });
62740
+ const filePath = join(dataDir, `mls-kp-pending-${groupId.replace(/[^a-zA-Z0-9_-]/g, "_")}.lock`);
62741
+ await writeFile(filePath, (/* @__PURE__ */ new Date()).toISOString(), { encoding: "utf-8", mode: FILE_MODE });
62742
+ }
62743
+ async function clearPendingWelcome(dataDir, groupId) {
62744
+ try {
62745
+ const filePath = join(dataDir, `mls-kp-pending-${groupId.replace(/[^a-zA-Z0-9_-]/g, "_")}.lock`);
62746
+ await rm(filePath);
62747
+ } catch {
62748
+ }
62749
+ }
62729
62750
  async function saveMlsState(dataDir, groupId, state) {
62730
62751
  await mkdir(dataDir, { recursive: true, mode: DIR_MODE });
62731
62752
  const filePath = join(dataDir, mlsFileName(groupId));
@@ -63639,9 +63660,6 @@ var init_channel = __esm({
63639
63660
  _mlsKeyPackage = null;
63640
63661
  /** Pending KeyPackage bundle from request-Welcome flow (used by _handleMlsWelcome). */
63641
63662
  _pendingMlsKpBundle;
63642
- /** Channels that have already had their sync fallback KeyPackage published this connect cycle.
63643
- * Prevents multiple agents from overwriting each other's KP for the same channel. */
63644
- _pendingWelcomeChannels = /* @__PURE__ */ new Set();
63645
63663
  /** In-memory credential store for renter-provided credentials (never persisted). */
63646
63664
  _credentialStore = new CredentialStore();
63647
63665
  /** Dedup buffer for A2A message IDs (prevents double-delivery via direct + Redis) */
@@ -65202,8 +65220,7 @@ var init_channel = __esm({
65202
65220
  }
65203
65221
  }
65204
65222
  const memberMlsGroup = chState.mlsGroupId ? this._mlsGroups.get(`a2a:${chId}`) : void 0;
65205
- if (chState.role === "member" && !memberMlsGroup?.isInitialized && !this._pendingWelcomeChannels.has(chId)) {
65206
- this._pendingWelcomeChannels.add(chId);
65223
+ if (chState.role === "member" && !memberMlsGroup?.isInitialized) {
65207
65224
  try {
65208
65225
  let groupId = chState.mlsGroupId;
65209
65226
  let memberIds = [];
@@ -65237,6 +65254,11 @@ var init_channel = __esm({
65237
65254
  if (memberIds.includes(this._persisted.deviceId)) {
65238
65255
  console.log(`[SecureChannel] A2A ${chId.slice(0, 8)} member in server membership but no local MLS state \u2014 requesting Welcome`);
65239
65256
  }
65257
+ if (await hasPendingWelcome(this.config.dataDir, groupId)) {
65258
+ console.log(`[SecureChannel] A2A ${chId.slice(0, 8)} sync fallback: skipping \u2014 Welcome already pending for group=${groupId.slice(0, 8)}`);
65259
+ continue;
65260
+ }
65261
+ await setPendingWelcome(this.config.dataDir, groupId);
65240
65262
  const mgr = new MLSGroupManager();
65241
65263
  const identity = new TextEncoder().encode(this._persisted.deviceId);
65242
65264
  const kp = await mgr.generateKeyPackage(identity);
@@ -66115,7 +66137,6 @@ var init_channel = __esm({
66115
66137
  clearInterval(this._deliveryHeartbeat);
66116
66138
  this._deliveryHeartbeat = null;
66117
66139
  }
66118
- this._pendingWelcomeChannels.clear();
66119
66140
  if (this._stopped) return;
66120
66141
  this._setState("disconnected");
66121
66142
  this._scheduleReconnect();
@@ -67147,7 +67168,8 @@ ${messageText}`;
67147
67168
  this._mlsGroups.set(`a2a:${channelId}`, mgr);
67148
67169
  await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mgr.exportState()));
67149
67170
  await this._persistState();
67150
- this._pendingWelcomeChannels.delete(channelId);
67171
+ await clearPendingWelcome(this.config.dataDir, groupId).catch(() => {
67172
+ });
67151
67173
  this._pendingMlsKpBundle = void 0;
67152
67174
  console.log(`[SecureChannel] Joined MLS group for A2A ${channelId.slice(0, 8)} via Welcome (epoch=${mgr.epoch})`);
67153
67175
  if (this.config.onA2AChannelReady && entry.conversationId) {
@@ -94814,7 +94836,7 @@ var init_index = __esm({
94814
94836
  init_skill_invoker();
94815
94837
  await init_skill_telemetry();
94816
94838
  await init_policy_enforcer();
94817
- VERSION = true ? "0.20.23" : "0.0.0-dev";
94839
+ VERSION = true ? "0.20.24" : "0.0.0-dev";
94818
94840
  }
94819
94841
  });
94820
94842
  await init_index();