@agent-native/core 0.7.30 → 0.7.31

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.
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat-plugin.d.ts","sourceRoot":"","sources":["../../src/server/agent-chat-plugin.ts"],"names":[],"mappings":"AASA,OAAO,EASL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,gBAAgB,EAUjB,MAAM,wBAAwB,CAAC;AAknChC,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,+DAA+D;IAC/D,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,CAAC,MACG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9C,wCAAwC;IACxC,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,CAAC,MACG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9C,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EACH,OAAO,0BAA0B,EAAE,WAAW,GAC9C,MAAM,GACN;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MA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,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAClD,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtE;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,EAAE,CACb,KAAK,EAAE,GAAG,EACV,KAAK,EAAE,MAAM,KACV,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5C;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AA6vBD,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,cAAc,CA88EhB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,cAAwC,CAAC;AAa9E,yEAAyE;AACzE,wBAAgB,mBAAmB,IAAI,gBAAgB,GAAG,IAAI,CAE7D"}
@@ -18,6 +18,8 @@ import nodePath from "node:path";
18
18
  import { readBody } from "./h3-helpers.js";
19
19
  import { getBuilderBrowserConnectUrl } from "./builder-browser.js";
20
20
  import { captureCliOutput } from "./cli-capture.js";
21
+ import { withConfiguredAppBasePath } from "./app-base-path.js";
22
+ import { appendA2AArtifactLinks } from "../a2a/artifact-response.js";
21
23
  // Lazy fs — loaded via dynamic import() on first use.
22
24
  // This avoids require() which bundlers convert to createRequire(import.meta.url)
23
25
  // that crashes on CF Workers where import.meta.url is undefined.
@@ -51,6 +53,22 @@ function wrapCliScript(tool, cliDefault, opts) {
51
53
  },
52
54
  };
53
55
  }
56
+ function resolveArtifactBaseUrl(event) {
57
+ const fromEnv = process.env.APP_URL ||
58
+ process.env.URL ||
59
+ process.env.DEPLOY_URL ||
60
+ process.env.BETTER_AUTH_URL;
61
+ if (fromEnv)
62
+ return withConfiguredAppBasePath(String(fromEnv));
63
+ try {
64
+ const proto = getHeader(event, "x-forwarded-proto") || "https";
65
+ const host = getHeader(event, "host");
66
+ if (host)
67
+ return withConfiguredAppBasePath(`${proto}://${host}`);
68
+ }
69
+ catch { }
70
+ return undefined;
71
+ }
54
72
  /**
55
73
  * Creates the `get-framework-context` tool. Returns detailed instructions
56
74
  * for framework capabilities that are summarized in the compact prompt.
@@ -2240,6 +2258,7 @@ export function createAgentChatPlugin(options) {
2240
2258
  ];
2241
2259
  // Run the SAME agent loop, collect text events, yield as A2A messages
2242
2260
  let accumulatedText = "";
2261
+ const a2aToolResults = [];
2243
2262
  const controller = new AbortController();
2244
2263
  console.log(`[A2A] Starting agent loop: ${a2aTools.length} tools, prompt ${systemPrompt.length} chars`);
2245
2264
  await runAgentLoop({
@@ -2256,6 +2275,12 @@ export function createAgentChatPlugin(options) {
2256
2275
  else if (event.type === "tool_start") {
2257
2276
  console.log(`[A2A] Tool call: ${event.tool}`);
2258
2277
  }
2278
+ else if (event.type === "tool_done") {
2279
+ a2aToolResults.push({
2280
+ tool: event.tool,
2281
+ result: event.result,
2282
+ });
2283
+ }
2259
2284
  else if (event.type === "error") {
2260
2285
  console.error(`[A2A] Error: ${event.error}`);
2261
2286
  }
@@ -2266,13 +2291,14 @@ export function createAgentChatPlugin(options) {
2266
2291
  signal: controller.signal,
2267
2292
  });
2268
2293
  console.log(`[A2A] Loop complete. Text: ${accumulatedText.slice(0, 100)}...`);
2294
+ const finalText = appendA2AArtifactLinks(accumulatedText, a2aToolResults, { baseUrl: resolveArtifactBaseUrl(context.event) });
2269
2295
  // Yield the final accumulated text
2270
2296
  yield {
2271
2297
  role: "agent",
2272
2298
  parts: [
2273
2299
  {
2274
2300
  type: "text",
2275
- text: accumulatedText || "(no response)",
2301
+ text: finalText || "(no response)",
2276
2302
  },
2277
2303
  ],
2278
2304
  };