@agentvault/agentvault 0.19.11 → 0.19.13

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,8 +47942,18 @@ var init_channel = __esm({
47942
47942
  }
47943
47943
  resolved = { kind: "room", id: target.roomId };
47944
47944
  } else if (target.kind === "a2a") {
47945
- const a2aEntries = this._persisted?.a2aChannels ? Object.values(this._persisted.a2aChannels) : [];
47946
- const channelEntry = a2aEntries.find((ch) => ch.hubAddress === target.hubAddress);
47945
+ let a2aEntries = this._persisted?.a2aChannels ? Object.values(this._persisted.a2aChannels) : [];
47946
+ let channelEntry = a2aEntries.find((ch) => ch.hubAddress === target.hubAddress);
47947
+ if (!channelEntry) {
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);
47953
+ } catch (syncErr) {
47954
+ console.warn("[deliver] A2A re-sync failed:", syncErr);
47955
+ }
47956
+ }
47947
47957
  if (!channelEntry) {
47948
47958
  const storedAddresses = a2aEntries.map((ch) => ch.hubAddress).join(", ") || "(none)";
47949
47959
  const err = `No A2A channel found for hub address: ${target.hubAddress} (stored: ${storedAddresses})`;
@@ -48412,12 +48422,31 @@ var init_channel = __esm({
48412
48422
  */
48413
48423
  async sendToAgent(hubAddress, text, opts) {
48414
48424
  if (!this._persisted?.a2aChannels) {
48415
- throw new Error("No A2A channels established");
48425
+ try {
48426
+ await this.listA2AChannels();
48427
+ } catch {
48428
+ }
48429
+ if (!this._persisted?.a2aChannels) {
48430
+ throw new Error("No A2A channels established");
48431
+ }
48416
48432
  }
48417
- const allMatches = Object.values(this._persisted.a2aChannels).filter(
48433
+ const a2a = this._persisted.a2aChannels;
48434
+ let allMatches = Object.values(a2a).filter(
48418
48435
  (ch) => ch.hubAddress === hubAddress
48419
48436
  );
48420
- const channelEntry = allMatches.find((ch) => ch.conversationId) ?? allMatches[0];
48437
+ let channelEntry = allMatches.find((ch) => ch.conversationId) ?? allMatches[0];
48438
+ if (!channelEntry) {
48439
+ try {
48440
+ console.log(`[sendToAgent] Channel not found for ${hubAddress}, re-syncing from server...`);
48441
+ await this.listA2AChannels();
48442
+ allMatches = Object.values(this._persisted.a2aChannels ?? {}).filter(
48443
+ (ch) => ch.hubAddress === hubAddress
48444
+ );
48445
+ channelEntry = allMatches.find((ch) => ch.conversationId) ?? allMatches[0];
48446
+ } catch (syncErr) {
48447
+ console.warn("[sendToAgent] A2A re-sync failed:", syncErr);
48448
+ }
48449
+ }
48421
48450
  if (!channelEntry) {
48422
48451
  throw new Error(`No A2A channel found for hub address: ${hubAddress}`);
48423
48452
  }
@@ -48533,10 +48562,12 @@ var init_channel = __esm({
48533
48562
  this._persisted.a2aChannels = {};
48534
48563
  }
48535
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 })))}`);
48536
48566
  for (const ch of channels) {
48537
48567
  if (ch.status === "active" || ch.status === "approved") {
48538
48568
  const isInitiator = myHub ? ch.initiatorHubAddress === myHub : ch.responderHubAddress !== myHub;
48539
48569
  const otherAddress = isInitiator ? ch.responderHubAddress : ch.initiatorHubAddress;
48570
+ console.log(`[listA2AChannels] channel=${ch.channelId?.slice(0, 8)} isInitiator=${isInitiator} otherAddress=${otherAddress}`);
48540
48571
  const existing = this._persisted.a2aChannels[ch.channelId];
48541
48572
  if (existing) {
48542
48573
  existing.hubAddress = otherAddress;