@agentvault/agentvault 0.19.15 → 0.19.16

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
@@ -47942,31 +47942,30 @@ var init_channel = __esm({
47942
47942
  }
47943
47943
  resolved = { kind: "room", id: target.roomId };
47944
47944
  } else if (target.kind === "a2a") {
47945
- let a2aEntries = this._persisted?.a2aChannels ? Object.values(this._persisted.a2aChannels) : [];
47945
+ const a2aEntries = this._persisted?.a2aChannels ? Object.values(this._persisted.a2aChannels) : [];
47946
47946
  let channelEntry = a2aEntries.find((ch) => ch.hubAddress === target.hubAddress);
47947
- if (!channelEntry) {
47947
+ if (!channelEntry && content.type === "text" && this._ws && this._state === "ready") {
47948
47948
  try {
47949
- console.log(`[deliver] A2A local miss for ${target.hubAddress}, fetching from API...`);
47949
+ console.log(`[deliver] A2A local miss for ${target.hubAddress}, trying direct API send...`);
47950
47950
  const channels = await this.listA2AChannels();
47951
47951
  const myHub = this._persisted?.hubAddress || "";
47952
47952
  const match = channels.find(
47953
47953
  (ch) => (ch.status === "active" || ch.status === "approved") && (ch.initiatorHubAddress === target.hubAddress || ch.responderHubAddress === target.hubAddress)
47954
47954
  );
47955
- if (match) {
47956
- const isInit = match.initiatorHubAddress === myHub;
47957
- const peerId = isInit ? match.responderHubAddress : match.initiatorHubAddress;
47958
- if (this._persisted?.a2aChannels) {
47959
- const entry = this._persisted.a2aChannels[match.channelId];
47960
- if (entry) {
47961
- entry.hubAddress = peerId;
47962
- entry.conversationId = match.conversationId || entry.conversationId;
47963
- }
47964
- }
47965
- a2aEntries = this._persisted?.a2aChannels ? Object.values(this._persisted.a2aChannels) : [];
47966
- channelEntry = a2aEntries.find((ch) => ch.hubAddress === target.hubAddress);
47955
+ if (match?.conversationId) {
47956
+ const payload = {
47957
+ conversation_id: match.conversationId,
47958
+ channel_id: match.channelId,
47959
+ text: content.text,
47960
+ message_type: "a2a"
47961
+ };
47962
+ if (myHub) payload.hub_address = myHub;
47963
+ this._ws.send(JSON.stringify({ event: "a2a_message", data: payload }));
47964
+ console.log(`[deliver] A2A direct send OK \u2192 ${target.hubAddress} via channel ${match.channelId.slice(0, 8)}...`);
47965
+ return { ok: true, destination: { kind: "a2a", id: target.hubAddress }, timestamp: ts };
47967
47966
  }
47968
47967
  } catch (syncErr) {
47969
- console.warn("[deliver] A2A API lookup failed:", syncErr);
47968
+ console.warn("[deliver] A2A direct send failed:", syncErr);
47970
47969
  }
47971
47970
  }
47972
47971
  if (!channelEntry) {