@agentvault/agentvault 0.20.21 → 0.20.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
@@ -63639,6 +63639,9 @@ var init_channel = __esm({
63639
63639
  _mlsKeyPackage = null;
63640
63640
  /** Pending KeyPackage bundle from request-Welcome flow (used by _handleMlsWelcome). */
63641
63641
  _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();
63642
63645
  /** In-memory credential store for renter-provided credentials (never persisted). */
63643
63646
  _credentialStore = new CredentialStore();
63644
63647
  /** Dedup buffer for A2A message IDs (prevents double-delivery via direct + Redis) */
@@ -65199,7 +65202,8 @@ var init_channel = __esm({
65199
65202
  }
65200
65203
  }
65201
65204
  const memberMlsGroup = chState.mlsGroupId ? this._mlsGroups.get(`a2a:${chId}`) : void 0;
65202
- if (chState.role === "member" && !memberMlsGroup?.isInitialized) {
65205
+ if (chState.role === "member" && !memberMlsGroup?.isInitialized && !this._pendingWelcomeChannels.has(chId)) {
65206
+ this._pendingWelcomeChannels.add(chId);
65203
65207
  try {
65204
65208
  let groupId = chState.mlsGroupId;
65205
65209
  let memberIds = [];
@@ -66111,6 +66115,7 @@ var init_channel = __esm({
66111
66115
  clearInterval(this._deliveryHeartbeat);
66112
66116
  this._deliveryHeartbeat = null;
66113
66117
  }
66118
+ this._pendingWelcomeChannels.clear();
66114
66119
  if (this._stopped) return;
66115
66120
  this._setState("disconnected");
66116
66121
  this._scheduleReconnect();
@@ -67100,7 +67105,8 @@ ${messageText}`;
67100
67105
  async _handleMlsWelcome(data) {
67101
67106
  const groupId = data.group_id;
67102
67107
  const conversationId = data.conversation_id;
67103
- console.log(`[SecureChannel] Received MLS welcome for group ${groupId?.slice(0, 8)}${conversationId ? ` conv=${conversationId.slice(0, 8)}` : ""}`);
67108
+ const kpSource = this._pendingMlsKpBundle ? "pending" : this._mlsKeyPackage ? "connect" : "generated";
67109
+ console.log(`[SecureChannel] Received MLS welcome for group ${groupId?.slice(0, 8)}${conversationId ? ` conv=${conversationId.slice(0, 8)}` : ""} kpSource=${kpSource}`);
67104
67110
  try {
67105
67111
  const welcomeBytes = new Uint8Array(Buffer.from(data.payload, "hex"));
67106
67112
  const mgr = new MLSGroupManager();
@@ -67108,6 +67114,7 @@ ${messageText}`;
67108
67114
  const identity = new TextEncoder().encode(this._deviceId);
67109
67115
  return mgr.generateKeyPackage(identity);
67110
67116
  })();
67117
+ console.log(`[SecureChannel] Welcome joinFromWelcome: group=${groupId?.slice(0, 8)} kpSource=${kpSource} welcomeLen=${welcomeBytes.length}`);
67111
67118
  await mgr.joinFromWelcome(welcomeBytes, kp);
67112
67119
  if (conversationId) {
67113
67120
  const key = `conv:${conversationId}`;
@@ -67140,6 +67147,8 @@ ${messageText}`;
67140
67147
  this._mlsGroups.set(`a2a:${channelId}`, mgr);
67141
67148
  await saveMlsState(this.config.dataDir, groupId, JSON.stringify(mgr.exportState()));
67142
67149
  await this._persistState();
67150
+ this._pendingWelcomeChannels.delete(channelId);
67151
+ this._pendingMlsKpBundle = void 0;
67143
67152
  console.log(`[SecureChannel] Joined MLS group for A2A ${channelId.slice(0, 8)} via Welcome (epoch=${mgr.epoch})`);
67144
67153
  if (this.config.onA2AChannelReady && entry.conversationId) {
67145
67154
  const firstPeer = entry.participants?.find((p2) => p2.status === "active" || p2.status === "invited");
@@ -67174,7 +67183,8 @@ ${messageText}`;
67174
67183
  }
67175
67184
  console.warn(`[SecureChannel] MLS welcome for unmatched group ${groupId?.slice(0, 8)} (no room/A2A/conv match)`);
67176
67185
  } catch (err) {
67177
- console.error(`[SecureChannel] MLS welcome processing failed:`, err);
67186
+ console.error(`[SecureChannel] MLS welcome processing failed (kpSource=${kpSource}):`, err);
67187
+ throw err;
67178
67188
  }
67179
67189
  }
67180
67190
  /**
@@ -94804,7 +94814,7 @@ var init_index = __esm({
94804
94814
  init_skill_invoker();
94805
94815
  await init_skill_telemetry();
94806
94816
  await init_policy_enforcer();
94807
- VERSION = true ? "0.20.21" : "0.0.0-dev";
94817
+ VERSION = true ? "0.20.23" : "0.0.0-dev";
94808
94818
  }
94809
94819
  });
94810
94820
  await init_index();