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