@agentvault/agentvault 0.19.13 → 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
@@ -49095,31 +49095,37 @@ var init_channel = __esm({
49095
49095
  }
49096
49096
  if (this._persisted && convId) {
49097
49097
  if (!this._persisted.a2aChannels) this._persisted.a2aChannels = {};
49098
- const a2aEphemeral = await generateEphemeralKeypair();
49099
- const ephPubHex = bytesToHex(a2aEphemeral.publicKey);
49100
- const ephPrivHex = bytesToHex(a2aEphemeral.privateKey);
49101
- this._persisted.a2aChannels[channelId] = {
49102
- channelId,
49103
- hubAddress: peerHub,
49104
- conversationId: convId,
49105
- role,
49106
- pendingEphemeralPrivateKey: ephPrivHex
49107
- };
49108
- if (this._ws) {
49109
- this._ws.send(
49110
- JSON.stringify({
49111
- event: "a2a_key_exchange",
49112
- data: {
49113
- channel_id: channelId,
49114
- ephemeral_key: ephPubHex
49115
- }
49116
- })
49117
- );
49118
- console.log(
49119
- `[SecureChannel] A2A key exchange sent for channel ${channelId.slice(0, 8)}... (role=${role})`
49120
- );
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();
49121
49128
  }
49122
- await this._persistState();
49123
49129
  }
49124
49130
  this.emit("a2a_channel_approved", channelData);
49125
49131
  if (this.config.onA2AChannelReady && convId) {