@agentvault/agentvault 0.19.21 → 0.19.23

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
@@ -47958,15 +47958,10 @@ var init_channel = __esm({
47958
47958
  this._persisted.a2aChannels[match.channelId].hubAddress = peerAddress;
47959
47959
  this._persisted.a2aChannels[match.channelId].conversationId = match.conversationId;
47960
47960
  await this._persistState();
47961
- console.log(`[deliver] A2A force-fixed: peer=${peerAddress} conv=${match.conversationId.slice(0, 8)}...`);
47962
- }
47963
- try {
47964
- await this.sendToAgent(peerAddress, content.text || "");
47965
- console.log(`[deliver] A2A sendToAgent OK \u2192 ${peerAddress}`);
47966
- return { ok: true, destination: { kind: "a2a", id: peerAddress }, timestamp: ts };
47967
- } catch (sendErr) {
47968
- console.warn(`[deliver] A2A sendToAgent failed after fix: ${sendErr}`);
47969
47961
  }
47962
+ channelEntry = Object.values(this._persisted?.a2aChannels ?? {}).find(
47963
+ (ch) => ch.hubAddress === peerAddress
47964
+ );
47970
47965
  }
47971
47966
  } catch (syncErr) {
47972
47967
  console.warn("[deliver] A2A direct send failed:", syncErr);
@@ -48493,7 +48488,7 @@ var init_channel = __esm({
48493
48488
  messageNumber: encrypted.header.messageNumber
48494
48489
  };
48495
48490
  const headerBlobHex = Buffer.from(JSON.stringify(headerObj)).toString("hex");
48496
- const payload2 = {
48491
+ const payload = {
48497
48492
  channel_id: channelEntry.channelId,
48498
48493
  conversation_id: channelEntry.conversationId,
48499
48494
  header_blob: headerBlobHex,
@@ -48503,7 +48498,7 @@ var init_channel = __esm({
48503
48498
  parent_span_id: opts?.parentSpanId
48504
48499
  };
48505
48500
  if (this._persisted.hubAddress) {
48506
- payload2.hub_address = this._persisted.hubAddress;
48501
+ payload.hub_address = this._persisted.hubAddress;
48507
48502
  }
48508
48503
  if (channelEntry.observerSession?.ratchetState) {
48509
48504
  try {
@@ -48514,9 +48509,9 @@ var init_channel = __esm({
48514
48509
  previousChainLength: obsEncrypted.header.previousChainLength,
48515
48510
  messageNumber: obsEncrypted.header.messageNumber
48516
48511
  };
48517
- payload2.observer_header_blob = Buffer.from(JSON.stringify(obsHeaderObj)).toString("hex");
48518
- payload2.observer_ciphertext = bytesToHex(obsEncrypted.ciphertext);
48519
- payload2.observer_nonce = bytesToHex(obsEncrypted.nonce);
48512
+ payload.observer_header_blob = Buffer.from(JSON.stringify(obsHeaderObj)).toString("hex");
48513
+ payload.observer_ciphertext = bytesToHex(obsEncrypted.ciphertext);
48514
+ payload.observer_nonce = bytesToHex(obsEncrypted.nonce);
48520
48515
  channelEntry.observerSession.ratchetState = obsRatchet.serialize();
48521
48516
  } catch (obsErr) {
48522
48517
  console.error("[SecureChannel] Observer encryption failed (sending without observer copy):", obsErr);
@@ -48527,34 +48522,14 @@ var init_channel = __esm({
48527
48522
  this._ws.send(
48528
48523
  JSON.stringify({
48529
48524
  event: "a2a_message",
48530
- data: payload2
48525
+ data: payload
48531
48526
  })
48532
48527
  );
48533
48528
  return;
48534
48529
  }
48535
- const payload = {
48536
- conversation_id: channelEntry.conversationId,
48537
- channel_id: channelEntry.channelId,
48538
- text,
48539
- message_type: "a2a",
48540
- parent_span_id: opts?.parentSpanId
48541
- };
48542
- if (this._persisted.hubAddress) {
48543
- payload.hub_address = this._persisted.hubAddress;
48544
- }
48545
- const a2aJson = JSON.stringify({ event: "a2a_message", data: payload });
48546
- console.log(`[sendToAgent] Sending A2A plaintext: conv=${payload.conversation_id} wsReady=${this._ws.readyState} bytes=${a2aJson.length}`);
48547
- await new Promise((resolve3, reject) => {
48548
- this._ws.send(a2aJson, (err) => {
48549
- if (err) {
48550
- console.error(`[sendToAgent] WS send failed:`, err);
48551
- reject(err);
48552
- } else {
48553
- console.log(`[sendToAgent] WS send confirmed`);
48554
- resolve3();
48555
- }
48556
- });
48557
- });
48530
+ throw new Error(
48531
+ `A2A channel ${channelEntry.channelId.slice(0, 8)}... has no encryption session. Key exchange must complete before messages can be sent. Role: ${channelEntry.role ?? "unknown"}.`
48532
+ );
48558
48533
  }
48559
48534
  /**
48560
48535
  * List all A2A channels for this agent.
@@ -49121,8 +49096,8 @@ var init_channel = __esm({
49121
49096
  if (this._persisted && convId) {
49122
49097
  if (!this._persisted.a2aChannels) this._persisted.a2aChannels = {};
49123
49098
  const existingNow = this._persisted.a2aChannels[channelId];
49124
- if (existingNow?.pendingEphemeralPrivateKey || existingNow?.session) {
49125
- console.log(`[SecureChannel] A2A channel ${channelId.slice(0, 8)}... key exchange already in progress, skipping`);
49099
+ if (existingNow?.session) {
49100
+ console.log(`[SecureChannel] A2A channel ${channelId.slice(0, 8)}... session already active, skipping key exchange`);
49126
49101
  } else {
49127
49102
  const a2aEphemeral = await generateEphemeralKeypair();
49128
49103
  const ephPubHex = bytesToHex(a2aEphemeral.publicKey);
@@ -49324,6 +49299,11 @@ var init_channel = __esm({
49324
49299
  }
49325
49300
  this.emit("a2a_channel_revoked", channelData);
49326
49301
  }
49302
+ if (data.event === "error") {
49303
+ const detail = data.data?.detail || data.detail || "Unknown server error";
49304
+ console.error(`[SecureChannel] Server error: ${detail}`);
49305
+ this.emit("error", new Error(`Server: ${detail}`));
49306
+ }
49327
49307
  if (data.event === "a2a_message") {
49328
49308
  const msgData = data.data || data;
49329
49309
  const a2aMsgId = msgData.message_id;