@agentvault/agentvault 0.19.5 → 0.19.7

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
@@ -48530,14 +48530,37 @@ var init_channel = __esm({
48530
48530
  if (!this._persisted.a2aChannels) {
48531
48531
  this._persisted.a2aChannels = {};
48532
48532
  }
48533
+ const myHub = this._persisted.hubAddress || "";
48533
48534
  for (const ch of channels) {
48534
48535
  if (ch.status === "active" || ch.status === "approved") {
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 isInitiator = myHub ? ch.initiatorHubAddress === myHub : ch.responderHubAddress !== myHub;
48537
+ const otherAddress = isInitiator ? ch.responderHubAddress : ch.initiatorHubAddress;
48538
+ const existing = this._persisted.a2aChannels[ch.channelId];
48539
+ if (existing) {
48540
+ existing.hubAddress = otherAddress;
48541
+ existing.conversationId = ch.conversationId || existing.conversationId;
48542
+ if (!existing.role) {
48543
+ existing.role = isInitiator ? "initiator" : "responder";
48544
+ }
48545
+ } else {
48546
+ this._persisted.a2aChannels[ch.channelId] = {
48547
+ channelId: ch.channelId,
48548
+ hubAddress: otherAddress,
48549
+ conversationId: ch.conversationId || "",
48550
+ role: isInitiator ? "initiator" : "responder"
48551
+ };
48552
+ console.log(
48553
+ `[SecureChannel] Discovered A2A channel ${ch.channelId.slice(0, 8)}... peer=${otherAddress} role=${isInitiator ? "initiator" : "responder"}`
48554
+ );
48555
+ }
48556
+ }
48557
+ }
48558
+ const activeIds = new Set(
48559
+ channels.filter((c2) => c2.status === "active" || c2.status === "approved").map((c2) => c2.channelId)
48560
+ );
48561
+ for (const id of Object.keys(this._persisted.a2aChannels)) {
48562
+ if (!activeIds.has(id)) {
48563
+ delete this._persisted.a2aChannels[id];
48541
48564
  }
48542
48565
  }
48543
48566
  await this._persistState();
@@ -48752,7 +48775,10 @@ var init_channel = __esm({
48752
48775
  await this._fetchScanRules();
48753
48776
  }
48754
48777
  try {
48778
+ console.log(`[SecureChannel] Syncing A2A channels (hubAddress=${this._persisted?.hubAddress ?? "NOT SET"})`);
48755
48779
  await this.listA2AChannels();
48780
+ const a2aCount = Object.keys(this._persisted?.a2aChannels ?? {}).length;
48781
+ console.log(`[SecureChannel] A2A sync complete: ${a2aCount} channels`);
48756
48782
  } catch (err) {
48757
48783
  console.warn("[SecureChannel] A2A channel sync failed (non-fatal):", err);
48758
48784
  }