@agentvault/agentvault 0.19.12 → 0.19.14

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
@@ -48562,10 +48562,12 @@ var init_channel = __esm({
48562
48562
  this._persisted.a2aChannels = {};
48563
48563
  }
48564
48564
  const myHub = this._persisted.hubAddress || "";
48565
+ console.log(`[listA2AChannels] myHub=${myHub}, channels=${channels.length}, raw=${JSON.stringify(channels.map((c2) => ({ id: c2.channelId?.slice(0, 8), init: c2.initiatorHubAddress, resp: c2.responderHubAddress, status: c2.status })))}`);
48565
48566
  for (const ch of channels) {
48566
48567
  if (ch.status === "active" || ch.status === "approved") {
48567
48568
  const isInitiator = myHub ? ch.initiatorHubAddress === myHub : ch.responderHubAddress !== myHub;
48568
48569
  const otherAddress = isInitiator ? ch.responderHubAddress : ch.initiatorHubAddress;
48570
+ console.log(`[listA2AChannels] channel=${ch.channelId?.slice(0, 8)} isInitiator=${isInitiator} otherAddress=${otherAddress}`);
48569
48571
  const existing = this._persisted.a2aChannels[ch.channelId];
48570
48572
  if (existing) {
48571
48573
  existing.hubAddress = otherAddress;
@@ -49093,31 +49095,37 @@ var init_channel = __esm({
49093
49095
  }
49094
49096
  if (this._persisted && convId) {
49095
49097
  if (!this._persisted.a2aChannels) this._persisted.a2aChannels = {};
49096
- const a2aEphemeral = await generateEphemeralKeypair();
49097
- const ephPubHex = bytesToHex(a2aEphemeral.publicKey);
49098
- const ephPrivHex = bytesToHex(a2aEphemeral.privateKey);
49099
- this._persisted.a2aChannels[channelId] = {
49100
- channelId,
49101
- hubAddress: peerHub,
49102
- conversationId: convId,
49103
- role,
49104
- pendingEphemeralPrivateKey: ephPrivHex
49105
- };
49106
- if (this._ws) {
49107
- this._ws.send(
49108
- JSON.stringify({
49109
- event: "a2a_key_exchange",
49110
- data: {
49111
- channel_id: channelId,
49112
- ephemeral_key: ephPubHex
49113
- }
49114
- })
49115
- );
49116
- console.log(
49117
- `[SecureChannel] A2A key exchange sent for channel ${channelId.slice(0, 8)}... (role=${role})`
49118
- );
49098
+ const existingNow = this._persisted.a2aChannels[channelId];
49099
+ if (existingNow?.pendingEphemeralPrivateKey || existingNow?.session) {
49100
+ console.log(`[SecureChannel] A2A channel ${channelId.slice(0, 8)}... key exchange already in progress, skipping`);
49101
+ } else {
49102
+ const a2aEphemeral = await generateEphemeralKeypair();
49103
+ const ephPubHex = bytesToHex(a2aEphemeral.publicKey);
49104
+ const ephPrivHex = bytesToHex(a2aEphemeral.privateKey);
49105
+ this._persisted.a2aChannels[channelId] = {
49106
+ ...existingNow,
49107
+ channelId,
49108
+ hubAddress: existingNow?.hubAddress || peerHub,
49109
+ conversationId: convId,
49110
+ role: existingNow?.role || role,
49111
+ pendingEphemeralPrivateKey: ephPrivHex
49112
+ };
49113
+ if (this._ws) {
49114
+ this._ws.send(
49115
+ JSON.stringify({
49116
+ event: "a2a_key_exchange",
49117
+ data: {
49118
+ channel_id: channelId,
49119
+ ephemeral_key: ephPubHex
49120
+ }
49121
+ })
49122
+ );
49123
+ console.log(
49124
+ `[SecureChannel] A2A key exchange sent for channel ${channelId.slice(0, 8)}... (role=${role})`
49125
+ );
49126
+ }
49127
+ await this._persistState();
49119
49128
  }
49120
- await this._persistState();
49121
49129
  }
49122
49130
  this.emit("a2a_channel_approved", channelData);
49123
49131
  if (this.config.onA2AChannelReady && convId) {