@agentvault/agentvault 0.19.9 → 0.19.11

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
@@ -49053,9 +49053,15 @@ var init_channel = __esm({
49053
49053
  const channelData = data.data || data;
49054
49054
  const channelId = channelData.channel_id;
49055
49055
  const convId = channelData.conversation_id;
49056
+ const existingEntry = this._persisted?.a2aChannels?.[channelId];
49056
49057
  const myHub = this._persisted?.hubAddress || "";
49057
- const role = channelData.role || (channelData.initiator_hub_address === myHub ? "initiator" : "responder");
49058
- const peerHub = role === "initiator" ? channelData.responder_hub_address || "" : channelData.initiator_hub_address || "";
49058
+ const role = existingEntry?.role || channelData.role || (myHub && channelData.initiator_hub_address === myHub ? "initiator" : "responder");
49059
+ const peerHub = existingEntry?.hubAddress || (role === "initiator" ? channelData.responder_hub_address || "" : channelData.initiator_hub_address || "");
49060
+ if (!myHub && !existingEntry?.hubAddress) {
49061
+ console.warn(
49062
+ `[SecureChannel] WARNING: hubAddress not set during a2a_channel_approved \u2014 peer address may be wrong (role=${role} peer=${peerHub})`
49063
+ );
49064
+ }
49059
49065
  if (this._persisted && convId) {
49060
49066
  if (!this._persisted.a2aChannels) this._persisted.a2aChannels = {};
49061
49067
  const a2aEphemeral = await generateEphemeralKeypair();