@agentvault/agentvault 0.19.5 → 0.19.6

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
@@ -48533,11 +48533,27 @@ var init_channel = __esm({
48533
48533
  for (const ch of channels) {
48534
48534
  if (ch.status === "active" || ch.status === "approved") {
48535
48535
  const otherAddress = ch.initiatorHubAddress === this._persisted.hubAddress ? ch.responderHubAddress : ch.initiatorHubAddress;
48536
- this._persisted.a2aChannels[ch.channelId] = {
48537
- channelId: ch.channelId,
48538
- hubAddress: otherAddress,
48539
- conversationId: ch.conversationId || ""
48540
- };
48536
+ const existing = this._persisted.a2aChannels[ch.channelId];
48537
+ if (existing) {
48538
+ existing.hubAddress = otherAddress;
48539
+ existing.conversationId = ch.conversationId || existing.conversationId;
48540
+ } else {
48541
+ const role = ch.initiatorHubAddress === this._persisted.hubAddress ? "initiator" : "responder";
48542
+ this._persisted.a2aChannels[ch.channelId] = {
48543
+ channelId: ch.channelId,
48544
+ hubAddress: otherAddress,
48545
+ conversationId: ch.conversationId || "",
48546
+ role
48547
+ };
48548
+ }
48549
+ }
48550
+ }
48551
+ const activeIds = new Set(
48552
+ channels.filter((c2) => c2.status === "active" || c2.status === "approved").map((c2) => c2.channelId)
48553
+ );
48554
+ for (const id of Object.keys(this._persisted.a2aChannels)) {
48555
+ if (!activeIds.has(id)) {
48556
+ delete this._persisted.a2aChannels[id];
48541
48557
  }
48542
48558
  }
48543
48559
  await this._persistState();