@agentvault/agentvault 0.19.14 → 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,16 +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 channel not found for ${target.hubAddress}, re-syncing from server...`);
47950
- await this.listA2AChannels();
47951
- a2aEntries = this._persisted?.a2aChannels ? Object.values(this._persisted.a2aChannels) : [];
47952
- channelEntry = a2aEntries.find((ch) => ch.hubAddress === target.hubAddress);
47949
+ console.log(`[deliver] A2A local miss for ${target.hubAddress}, trying direct API send...`);
47950
+ const channels = await this.listA2AChannels();
47951
+ const myHub = this._persisted?.hubAddress || "";
47952
+ const match = channels.find(
47953
+ (ch) => (ch.status === "active" || ch.status === "approved") && (ch.initiatorHubAddress === target.hubAddress || ch.responderHubAddress === target.hubAddress)
47954
+ );
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 };
47966
+ }
47953
47967
  } catch (syncErr) {
47954
- console.warn("[deliver] A2A re-sync failed:", syncErr);
47968
+ console.warn("[deliver] A2A direct send failed:", syncErr);
47955
47969
  }
47956
47970
  }
47957
47971
  if (!channelEntry) {