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