@agent-native/core 0.98.11 → 0.98.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.
Files changed (26) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +12 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +45 -6
  5. package/corpus/core/src/server/agent-chat-plugin.ts +17 -3
  6. package/corpus/templates/analytics/actions/create-session-replay-agent-link.ts +4 -0
  7. package/corpus/templates/analytics/changelog/2026-07-12-incident-lookups-include-network-and-stuck-run-evidence-even.md +6 -0
  8. package/corpus/templates/analytics/changelog/2026-07-12-named-session-incident-investigations-now-start-with-session.md +6 -0
  9. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +10 -3
  10. package/corpus/templates/analytics/server/plugins/agent-chat.ts +1 -1
  11. package/dist/collab/awareness.d.ts +2 -2
  12. package/dist/collab/awareness.d.ts.map +1 -1
  13. package/dist/collab/routes.d.ts +2 -2
  14. package/dist/collab/struct-routes.d.ts +1 -1
  15. package/dist/notifications/routes.d.ts +2 -2
  16. package/dist/resources/handlers.d.ts +2 -2
  17. package/dist/server/agent-chat/action-filters-a2a.d.ts +6 -0
  18. package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
  19. package/dist/server/agent-chat/action-filters-a2a.js +15 -4
  20. package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
  21. package/dist/server/agent-chat-plugin.d.ts +2 -1
  22. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  23. package/dist/server/agent-chat-plugin.js +17 -4
  24. package/dist/server/agent-chat-plugin.js.map +1 -1
  25. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  26. package/package.json +1 -1
package/corpus/README.md CHANGED
@@ -28,4 +28,4 @@ rg -n "defineAction|useActionQuery" node_modules/@agent-native/core/corpus
28
28
  ## Generated Counts
29
29
 
30
30
  - core files: 2239
31
- - template files: 5513
31
+ - template files: 5515
@@ -1,5 +1,17 @@
1
1
  # @agent-native/core
2
2
 
3
+ ## 0.98.13
4
+
5
+ ### Patch Changes
6
+
7
+ - c61d923: Keep delegated A2A and MCP agent turns explicitly bound to the authenticated owner/org scope and Act execution mode.
8
+
9
+ ## 0.98.12
10
+
11
+ ### Patch Changes
12
+
13
+ - 29a77ab: Keep MCP-local `ask_app` turns on the same app-level final-response guard as A2A turns.
14
+
3
15
  ## 0.98.11
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.98.11",
3
+ "version": "0.98.13",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -148,6 +148,25 @@ function formatA2ATerminalError(
148
148
 
149
149
  type A2AAgentLoopRunner = typeof runAgentLoopDirectWithSoftTimeout;
150
150
 
151
+ function runDelegatedAgentLoop(
152
+ runOptions: Parameters<A2AAgentLoopRunner>[0],
153
+ pluginOptions: Pick<
154
+ AgentChatPluginOptions,
155
+ "finalResponseGuard" | "runSoftTimeoutMs"
156
+ >,
157
+ timeoutOptions: Parameters<A2AAgentLoopRunner>[2],
158
+ runner: A2AAgentLoopRunner,
159
+ ) {
160
+ return runner(
161
+ {
162
+ ...runOptions,
163
+ finalResponseGuard: pluginOptions.finalResponseGuard,
164
+ },
165
+ pluginOptions.runSoftTimeoutMs,
166
+ timeoutOptions,
167
+ );
168
+ }
169
+
151
170
  /**
152
171
  * Run an A2A-delegated agent turn with the same final-response guard used by
153
172
  * the app's interactive chat surface.
@@ -165,13 +184,33 @@ export function runA2AAgentLoop(
165
184
  timeoutOptions: Parameters<A2AAgentLoopRunner>[2],
166
185
  runner: A2AAgentLoopRunner = runAgentLoopDirectWithSoftTimeout,
167
186
  ) {
168
- return runner(
169
- {
170
- ...runOptions,
171
- finalResponseGuard: pluginOptions.finalResponseGuard,
172
- },
173
- pluginOptions.runSoftTimeoutMs,
187
+ return runDelegatedAgentLoop(
188
+ runOptions,
189
+ pluginOptions,
190
+ timeoutOptions,
191
+ runner,
192
+ );
193
+ }
194
+
195
+ /**
196
+ * Run the MCP-local ask_app turn with the same app-level response guard as
197
+ * A2A. Keeping this seam shared prevents hosted MCP callers from bypassing
198
+ * template guarantees when the request cannot use the self-A2A route.
199
+ */
200
+ export function runMCPAgentLoop(
201
+ runOptions: Parameters<A2AAgentLoopRunner>[0],
202
+ pluginOptions: Pick<
203
+ AgentChatPluginOptions,
204
+ "finalResponseGuard" | "runSoftTimeoutMs"
205
+ >,
206
+ timeoutOptions: Parameters<A2AAgentLoopRunner>[2],
207
+ runner: A2AAgentLoopRunner = runAgentLoopDirectWithSoftTimeout,
208
+ ) {
209
+ return runDelegatedAgentLoop(
210
+ runOptions,
211
+ pluginOptions,
174
212
  timeoutOptions,
213
+ runner,
175
214
  );
176
215
  }
177
216
 
@@ -57,7 +57,6 @@ import {
57
57
  subscribeToRun,
58
58
  type ActionEntry,
59
59
  } from "../agent/production-agent.js";
60
- import { runAgentLoopDirectWithSoftTimeout } from "../agent/run-loop-with-resume.js";
61
60
  import {
62
61
  callerHasRunAccess,
63
62
  callerHasThreadAccess,
@@ -202,6 +201,7 @@ import {
202
201
  filterReadOnlyActions,
203
202
  resolveInitialToolNames,
204
203
  runA2AAgentLoop,
204
+ runMCPAgentLoop,
205
205
  assembleA2AFinalResponse,
206
206
  buildPublicAgentA2ASkills,
207
207
  resolveArtifactBaseUrl,
@@ -257,6 +257,7 @@ export { buildPublicAgentA2ASkills };
257
257
  export { assembleA2AFinalResponse };
258
258
  export type { AgentChatPluginOptions };
259
259
  export { runA2AAgentLoop };
260
+ export { runMCPAgentLoop };
260
261
  export { createA2AEngineToolSurface };
261
262
  export { shouldBlockInProductCodeEditingSurface };
262
263
  export { loadRunCodeToolEntries };
@@ -1370,6 +1371,13 @@ export function createAgentChatPlugin(
1370
1371
  availableTools: a2aToolSurface.availableTools,
1371
1372
  messages: a2aMessages,
1372
1373
  actions: a2aActions,
1374
+ // A2A already establishes these values in request context. Pass
1375
+ // them explicitly too so delegated tool execution and template
1376
+ // final-response guards cannot lose the authenticated caller's
1377
+ // scope when a processor hop or alternate runner is involved.
1378
+ ownerEmail: userEmail,
1379
+ orgId: getRequestOrgId() ?? null,
1380
+ executionMode: "act",
1373
1381
  send: (event) => {
1374
1382
  a2aEvents.push(event);
1375
1383
  if (event.type === "tool_start") {
@@ -1618,7 +1626,7 @@ export function createAgentChatPlugin(
1618
1626
  let accumulatedText = "";
1619
1627
  const controller = new AbortController();
1620
1628
 
1621
- await runAgentLoopDirectWithSoftTimeout(
1629
+ await runMCPAgentLoop(
1622
1630
  {
1623
1631
  engine: mcpEngine,
1624
1632
  model,
@@ -1639,6 +1647,9 @@ export function createAgentChatPlugin(
1639
1647
  },
1640
1648
  ],
1641
1649
  actions: mcpActions,
1650
+ ownerEmail: getRequestUserEmail(),
1651
+ orgId: getRequestOrgId() ?? null,
1652
+ executionMode: "act",
1642
1653
  send: (event) => {
1643
1654
  accumulatedText = applyAgentTextEventToBuffer(
1644
1655
  accumulatedText,
@@ -1647,7 +1658,10 @@ export function createAgentChatPlugin(
1647
1658
  },
1648
1659
  signal: controller.signal,
1649
1660
  },
1650
- options?.runSoftTimeoutMs,
1661
+ {
1662
+ finalResponseGuard: options?.finalResponseGuard,
1663
+ runSoftTimeoutMs: options?.runSoftTimeoutMs,
1664
+ },
1651
1665
  {
1652
1666
  backgroundFunction:
1653
1667
  options?.durableBackgroundRuns === true &&
@@ -27,4 +27,8 @@ export default defineAction({
27
27
  origin: getRequestContext()?.requestOrigin,
28
28
  });
29
29
  },
30
+ // Minting this scoped, expiring read link does not mutate the recording or
31
+ // expose data outside the caller's existing access scope, so it is safe for
32
+ // Plan mode's read-only investigation workflow.
33
+ readOnly: true,
30
34
  });
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-07-12
4
+ ---
5
+
6
+ Incident lookups include network and stuck-run evidence even when no JavaScript error is recorded
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: improved
3
+ date: 2026-07-12
4
+ ---
5
+
6
+ Named session incident investigations now start with session, replay, and error evidence
@@ -3,11 +3,19 @@ import type { ActionEntry } from "@agent-native/core/server";
3
3
  export const INITIAL_TOOL_NAMES = [
4
4
  "view-screen",
5
5
  "data-source-status",
6
+ // Keep the first-party observability workflow on the initial surface so a
7
+ // named user's session/error question does not depend on an indirect
8
+ // tool-search round before the agent can inspect its evidence.
9
+ "get-error-issue",
10
+ "create-session-replay-agent-link",
11
+ "get-session-replay-events",
12
+ "get-session-replay-summary",
13
+ "get-session-replay-timeline",
14
+ "list-error-issues",
15
+ "list-session-recordings",
6
16
  "list-analyses",
7
17
  "get-analysis",
8
18
  "save-analysis",
9
- "rename-analysis",
10
- "delete-analysis",
11
19
  "get-sql-dashboard",
12
20
  "mutate-dashboard",
13
21
  "generate-chart",
@@ -35,7 +43,6 @@ export const INITIAL_TOOL_NAMES = [
35
43
  "slack-messages",
36
44
  "sentry",
37
45
  "list-data-dictionary",
38
- "save-data-dictionary-entry",
39
46
  "navigate",
40
47
  ];
41
48
 
@@ -31,7 +31,7 @@ export const SIMPLE_TIME_BOUNDED_METRIC_FAST_PATH_GUIDANCE =
31
31
  "SIMPLE TIME-BOUNDED METRIC FAST PATH — When the data dictionary or a known canonical source identifies the metric, run one bounded aggregate. Once it returns a valid result, answer the explicit question immediately with the source, time window, row count, and only necessary caveats. Do not schema-discover, retry, enrich, cross-check, or add breakdowns after that successful result unless the query failed or the result conflicts with the known metric definition. This does not waive the real-data requirement: never answer from a guess, stale value, or unverified result. ";
32
32
 
33
33
  export const ANALYTICS_OBSERVABILITY_INCIDENT_GUIDANCE =
34
- "OBSERVABILITY INCIDENT WORKFLOW — For a named user's session or error question, resolve the user's email from context, then use list-session-recordings with userId and hasErrors=true over a bounded recent window. Use list-error-issues with userId or sessionRecordingId to identify the grouped issue, then get-error-issue for stack, breadcrumbs, occurrences, and linked recordings. When the timeline, page navigation, console diagnostics, failed network requests, or clicks are needed, use create-session-replay-agent-link and follow its bounded diagnostics/context APIs. Prefer these first-party actions over generic SQL; use query-agent-native-analytics only to correlate first-party events. Report the matching evidence and do not claim a root cause without a corroborating error or replay signal. ";
34
+ "OBSERVABILITY INCIDENT WORKFLOW — For a named user's session or error question, resolve the user's email from context, then use list-session-recordings with userId over a bounded recent window to discover the relevant sessions. Do not require hasErrors=true for this initial lookup: replay/network/stuck-run evidence can exist while the recording's JavaScript errorCount is zero. Use hasErrors=true only when the user specifically asks for recordings with captured JavaScript errors or the recording metadata confirms that filter is appropriate. Use list-error-issues with userId or sessionRecordingId to identify a grouped issue, then get-error-issue for stack, breadcrumbs, occurrences, and linked recordings. For console diagnostics or failed network requests, create-session-replay-agent-link first and use its scoped diagnostics endpoint for detailed error text, stacks, request metadata, and bounded 5xx snippets; enumerate with kind/limit and fromMs/toMs or offset when needed. Use get-session-replay-summary and get-session-replay-timeline for the page-navigation and click sequence, and use get-session-replay-events only for additional bounded replay-event details. If no grouped error exists, correlate first-party observability events such as agent_chat_stuck_detected with query-agent-native-analytics in execution mode. In Plan mode, query-agent-native-analytics is intentionally unavailable: do not claim a live event correlation or root cause from it, and describe the event lookup as a planned next step. Prefer these first-party actions over generic SQL. Report the matching evidence and do not claim a root cause without a corroborating error, event, or replay signal. ";
35
35
 
36
36
  export const NON_ANALYTICS_REQUEST_GUIDANCE =
37
37
  "NON-ANALYTICS REQUESTS — If the user is not asking for a live metric, source record, or derived analytics claim, answer normally in chat. Greetings, general-knowledge questions, math, writing, coding, and conceptual questions do not need a data-source call. Do not use the no-grounded-data fallback for those requests. ";
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
62
62
  error: string;
63
63
  states?: undefined;
64
64
  } | {
65
+ error?: undefined;
65
66
  states: {
66
67
  clientId: number;
67
68
  state: string;
68
69
  }[];
69
- error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,10 +77,10 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
+ error?: undefined;
80
81
  users: {
81
82
  clientId: number;
82
83
  lastSeen: number;
83
84
  }[];
84
- error?: undefined;
85
85
  }>>;
86
86
  //# sourceMappingURL=awareness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"awareness.d.ts","sourceRoot":"","sources":["../../src/collab/awareness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgB3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAOD,eAAO,MAAM,sBAAsB,EAAG,kBAA2B,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,MAAM,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAOD,wBAAgB,mB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1E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAOnE;AAkCD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;;kBAwDa,MAAM;eAAS,MAAM;;GAoB1D,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;kBAYM,MAAM;kBAAY,MAAM;;GAMvD,CAAC"}
@@ -26,8 +26,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
26
26
  * Body: { update: string (base64), requestSource?: string }
27
27
  */
28
28
  export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
29
- error: string;
30
29
  ok?: undefined;
30
+ error: string;
31
31
  } | {
32
32
  error?: undefined;
33
33
  ok: boolean;
@@ -41,8 +41,8 @@ export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import
41
41
  * Body: { text: string, fieldName?: string, requestSource?: string }
42
42
  */
43
43
  export declare const postCollabText: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
44
- text?: undefined;
45
44
  ok?: undefined;
45
+ text?: undefined;
46
46
  error: string;
47
47
  } | {
48
48
  error?: undefined;
@@ -13,8 +13,8 @@
13
13
  * Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
14
14
  */
15
15
  export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
16
- error: string;
17
16
  ok?: undefined;
17
+ error: string;
18
18
  } | {
19
19
  error?: undefined;
20
20
  ok: boolean;
@@ -13,13 +13,13 @@
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
14
  count: number;
15
15
  updated?: undefined;
16
- error?: undefined;
17
16
  ok?: undefined;
17
+ error?: undefined;
18
18
  } | {
19
19
  count?: undefined;
20
20
  updated: number;
21
- error?: undefined;
22
21
  ok?: undefined;
22
+ error?: undefined;
23
23
  } | {
24
24
  count?: undefined;
25
25
  updated?: undefined;
@@ -52,8 +52,8 @@ export declare function handleDeleteResource(event: any): Promise<{
52
52
  error: string;
53
53
  ok?: undefined;
54
54
  } | {
55
- ok: boolean;
56
55
  error?: undefined;
56
+ ok: boolean;
57
57
  }>;
58
58
  /** POST /_agent-native/resources/upload — upload a file as a resource */
59
59
  export declare function handleUploadResource(event: any): Promise<import("./store.js").Resource | {
@@ -74,10 +74,10 @@ export declare function handleUploadResource(event: any): Promise<import("./stor
74
74
  runId: string | null;
75
75
  expiresAt: number | null;
76
76
  metadata: string | null;
77
+ error?: undefined;
77
78
  url: string;
78
79
  provider: string;
79
80
  storageSetupRequired?: undefined;
80
- error?: undefined;
81
81
  } | {
82
82
  error: string;
83
83
  storageSetupRequired: boolean;
@@ -35,6 +35,12 @@ type A2AAgentLoopRunner = typeof runAgentLoopDirectWithSoftTimeout;
35
35
  * before presenting metrics or exhaustive provider conclusions.
36
36
  */
37
37
  export declare function runA2AAgentLoop(runOptions: Parameters<A2AAgentLoopRunner>[0], pluginOptions: Pick<AgentChatPluginOptions, "finalResponseGuard" | "runSoftTimeoutMs">, timeoutOptions: Parameters<A2AAgentLoopRunner>[2], runner?: A2AAgentLoopRunner): Promise<import("../../agent/production-agent.js").AgentLoopUsage>;
38
+ /**
39
+ * Run the MCP-local ask_app turn with the same app-level response guard as
40
+ * A2A. Keeping this seam shared prevents hosted MCP callers from bypassing
41
+ * template guarantees when the request cannot use the self-A2A route.
42
+ */
43
+ export declare function runMCPAgentLoop(runOptions: Parameters<A2AAgentLoopRunner>[0], pluginOptions: Pick<AgentChatPluginOptions, "finalResponseGuard" | "runSoftTimeoutMs">, timeoutOptions: Parameters<A2AAgentLoopRunner>[2], runner?: A2AAgentLoopRunner): Promise<import("../../agent/production-agent.js").AgentLoopUsage>;
38
44
  /**
39
45
  * Keep delegated A2A turns on the same compact initial tool surface as
40
46
  * interactive chat. `tool-search` remains in the initial set, while the
@@ -1 +1 @@
1
- {"version":3,"file":"action-filters-a2a.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/action-filters-a2a.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAQlE,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAI7B;AAED;;;;2DAI2D;AAC3D,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAI7B;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAY7B;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,KAAK,CAAC;IACP,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC,CASD;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,GAAG,GAAG,SAAS,GACrB,MAAM,GAAG,SAAS,CAepB;AAED,wBAAgB,wBAAwB,CAC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AC,CAAC,CAAC,CAAC,EAC7C,aAAa,EAAE,IAAI,CACjB,sBAAsB,EACtB,oBAAoB,GAAG,kBAAkB,CAC1C,EACD,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EACjD,MAAM,GAAE,kBAAsD,qEAQ/D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAC7C,aAAa,EAAE,IAAI,CACjB,sBAAsB,EACtB,oBAAoB,GAAG,kBAAkB,CAC1C,EACD,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EACjD,MAAM,GAAE,kBAAsD,qEAQ/D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,UAAU,EAAE,EAC5B,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,cAAc,EAAE,UAAU,EAAE,CAAA;CAAE,CAKvD;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAC5C,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,MAAM,EAAE,CAEV"}
@@ -95,6 +95,12 @@ function formatA2ATerminalError(event) {
95
95
  ].filter(Boolean);
96
96
  return parts.join("\n");
97
97
  }
98
+ function runDelegatedAgentLoop(runOptions, pluginOptions, timeoutOptions, runner) {
99
+ return runner({
100
+ ...runOptions,
101
+ finalResponseGuard: pluginOptions.finalResponseGuard,
102
+ }, pluginOptions.runSoftTimeoutMs, timeoutOptions);
103
+ }
98
104
  /**
99
105
  * Run an A2A-delegated agent turn with the same final-response guard used by
100
106
  * the app's interactive chat surface.
@@ -104,10 +110,15 @@ function formatA2ATerminalError(event) {
104
110
  * before presenting metrics or exhaustive provider conclusions.
105
111
  */
106
112
  export function runA2AAgentLoop(runOptions, pluginOptions, timeoutOptions, runner = runAgentLoopDirectWithSoftTimeout) {
107
- return runner({
108
- ...runOptions,
109
- finalResponseGuard: pluginOptions.finalResponseGuard,
110
- }, pluginOptions.runSoftTimeoutMs, timeoutOptions);
113
+ return runDelegatedAgentLoop(runOptions, pluginOptions, timeoutOptions, runner);
114
+ }
115
+ /**
116
+ * Run the MCP-local ask_app turn with the same app-level response guard as
117
+ * A2A. Keeping this seam shared prevents hosted MCP callers from bypassing
118
+ * template guarantees when the request cannot use the self-A2A route.
119
+ */
120
+ export function runMCPAgentLoop(runOptions, pluginOptions, timeoutOptions, runner = runAgentLoopDirectWithSoftTimeout) {
121
+ return runDelegatedAgentLoop(runOptions, pluginOptions, timeoutOptions, runner);
111
122
  }
112
123
  /**
113
124
  * Keep delegated A2A turns on the same compact initial tool surface as
@@ -1 +1 @@
1
- {"version":3,"file":"action-filters-a2a.js","sourceRoot":"","sources":["../../../src/server/agent-chat/action-filters-a2a.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,EACL,sBAAsB,GAGvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AAErF,OAAO,EACL,wBAAwB,GAEzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,8EAA8E;AAC9E,4EAA4E;AAC5E,uEAAuE;AACvE,oCAAoC;AACpC,8EAA8E;AAE9E,MAAM,UAAU,qBAAqB,CACnC,OAAoC;IAEpC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC,CACvE,CAAC;AACJ,C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3B,OAAO;QACL,KAAK,EAAE,wBAAwB,CAAC,cAAc,EAAE,gBAAgB,CAAC;QACjE,cAAc;KACf,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,eAA4C,EAC5C,UAAqB;IAErB,OAAO,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { getHeader } from \"h3\";\n\nimport {\n appendA2AArtifactLinks,\n type A2AArtifactResponseOptions,\n type A2AToolResultSummary,\n} from \"../../a2a/artifact-response.js\";\nimport { collectFinalResponseTextFromAgentEvents } from \"../../a2a/response-text.js\";\nimport type { EngineTool } from \"../../agent/engine/types.js\";\nimport {\n filterInitialEngineTools,\n type ActionEntry,\n} from \"../../agent/production-agent.js\";\nimport { runAgentLoopDirectWithSoftTimeout } from \"../../agent/run-loop-with-resume.js\";\nimport type { AgentChatEvent } from \"../../agent/types.js\";\nimport { withConfiguredAppBasePath } from \"../app-base-path.js\";\nimport type { AgentChatPluginOptions } from \"./plugin-options.js\";\n\n// ---------------------------------------------------------------------------\n// Action-visibility filters (read-only / agent-exposed / public-agent-safe)\n// and the A2A (agent-to-agent) final-response assembly + delegated-run\n// helpers that share those filters.\n// ---------------------------------------------------------------------------\n\nexport function filterReadOnlyActions(\n actions: Record<string, ActionEntry>,\n): Record<string, ActionEntry> {\n return Object.fromEntries(\n Object.entries(actions).filter(([, entry]) => entry.readOnly === true),\n );\n}\n\n/** Drop actions that opted out of agent exposure via `agentTool: false`. They\n * remain callable from the frontend / HTTP (mounted separately from this\n * agent tool surface — see `httpActions`) but never appear in any agent tool\n * list (in-app assistant, MCP, A2A, job/trigger runners) or actions prompt.\n * Default-allow: only an explicit `false` is excluded. */\nexport function filterAgentTools(\n actions: Record<string, ActionEntry>,\n): Record<string, ActionEntry> {\n return Object.fromEntries(\n Object.entries(actions).filter(([, entry]) => entry.agentTool !== false),\n );\n}\n\nexport function filterPublicAgentActions(\n actions: Record<string, ActionEntry>,\n): Record<string, ActionEntry> {\n return Object.fromEntries(\n Object.entries(actions).filter(([, entry]) => {\n const config = entry.publicAgent;\n return (\n config?.expose === true &&\n config.readOnly === true &&\n config.requiresAuth !== true &&\n config.isConsequential !== true\n );\n }),\n );\n}\n\nexport function buildPublicAgentA2ASkills(\n actions: Record<string, ActionEntry>,\n): Array<{\n id: string;\n name: string;\n description: string;\n publicAgent: ActionEntry[\"publicAgent\"];\n}> {\n return Object.entries(filterPublicAgentActions(actions)).map(\n ([name, entry]) => ({\n id: name,\n name,\n description: entry.tool.description,\n publicAgent: entry.publicAgent,\n }),\n );\n}\n\nexport function resolveArtifactBaseUrl(\n event: any | undefined,\n): string | undefined {\n const fromEnv =\n process.env.APP_URL ||\n process.env.URL ||\n process.env.DEPLOY_URL ||\n process.env.BETTER_AUTH_URL;\n if (fromEnv) return withConfiguredAppBasePath(String(fromEnv));\n\n try {\n const proto = getHeader(event, \"x-forwarded-proto\") || \"https\";\n const host = getHeader(event, \"host\");\n if (host) return withConfiguredAppBasePath(`${proto}://${host}`);\n } catch {}\n\n return undefined;\n}\n\nexport function assembleA2AFinalResponse(\n events: readonly AgentChatEvent[],\n toolResults: readonly A2AToolResultSummary[],\n options: A2AArtifactResponseOptions & { event?: any } = {},\n): { responseText: string; finalText: string } {\n const terminalError = getA2ATerminalErrorEvent(events);\n const responseText = collectFinalResponseTextFromAgentEvents(events, {\n fallbackToPreToolText: !terminalError,\n });\n const finalText = appendA2AArtifactLinks(responseText, [...toolResults], {\n baseUrl: options.baseUrl ?? resolveArtifactBaseUrl(options.event),\n includeReferencedArtifacts: true,\n });\n if (terminalError && !finalText.trim()) {\n throw new Error(formatA2ATerminalError(terminalError));\n }\n return { responseText, finalText };\n}\n\nfunction getA2ATerminalErrorEvent(\n events: readonly AgentChatEvent[],\n): Extract<AgentChatEvent, { type: \"error\" }> | null {\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n if (event.type === \"clear\") continue;\n if (event.type === \"done\") return null;\n if (event.type === \"error\") return event;\n if (event.type === \"auto_continue\") {\n return {\n type: \"error\",\n error: `Agent stopped before finishing (${event.reason}).`,\n errorCode: event.reason,\n recoverable: true,\n };\n }\n }\n return null;\n}\n\nfunction formatA2ATerminalError(\n event: Extract<AgentChatEvent, { type: \"error\" }>,\n): string {\n const parts = [\n event.error || \"Agent failed before producing a final response.\",\n event.errorCode ? `code: ${event.errorCode}` : \"\",\n event.details ? `details: ${event.details}` : \"\",\n ].filter(Boolean);\n return parts.join(\"\\n\");\n}\n\ntype A2AAgentLoopRunner = typeof runAgentLoopDirectWithSoftTimeout;\n\n/**\n * Run an A2A-delegated agent turn with the same final-response guard used by\n * the app's interactive chat surface.\n *\n * Keeping this in one helper prevents delegated calls from silently bypassing\n * template guarantees such as Analytics' requirement to query real data\n * before presenting metrics or exhaustive provider conclusions.\n */\nexport function runA2AAgentLoop(\n runOptions: Parameters<A2AAgentLoopRunner>[0],\n pluginOptions: Pick<\n AgentChatPluginOptions,\n \"finalResponseGuard\" | \"runSoftTimeoutMs\"\n >,\n timeoutOptions: Parameters<A2AAgentLoopRunner>[2],\n runner: A2AAgentLoopRunner = runAgentLoopDirectWithSoftTimeout,\n) {\n return runner(\n {\n ...runOptions,\n finalResponseGuard: pluginOptions.finalResponseGuard,\n },\n pluginOptions.runSoftTimeoutMs,\n timeoutOptions,\n );\n}\n\n/**\n * Keep delegated A2A turns on the same compact initial tool surface as\n * interactive chat. `tool-search` remains in the initial set, while the\n * complete registry is supplied separately so the run loop can load a matched\n * schema after a tool-search result.\n */\nexport function createA2AEngineToolSurface(\n availableTools: EngineTool[],\n initialToolNames?: string[],\n): { tools: EngineTool[]; availableTools: EngineTool[] } {\n return {\n tools: filterInitialEngineTools(availableTools, initialToolNames),\n availableTools,\n };\n}\n\nexport function resolveInitialToolNames(\n templateActions: Record<string, ActionEntry>,\n configured?: string[],\n): string[] {\n return configured ?? Object.keys(templateActions);\n}\n"]}
1
+ {"version":3,"file":"action-filters-a2a.js","sourceR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AAI,CAAC,eAAe,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { getHeader } from \"h3\";\n\nimport {\n appendA2AArtifactLinks,\n type A2AArtifactResponseOptions,\n type A2AToolResultSummary,\n} from \"../../a2a/artifact-response.js\";\nimport { collectFinalResponseTextFromAgentEvents } from \"../../a2a/response-text.js\";\nimport type { EngineTool } from \"../../agent/engine/types.js\";\nimport {\n filterInitialEngineTools,\n type ActionEntry,\n} from \"../../agent/production-agent.js\";\nimport { runAgentLoopDirectWithSoftTimeout } from \"../../agent/run-loop-with-resume.js\";\nimport type { AgentChatEvent } from \"../../agent/types.js\";\nimport { withConfiguredAppBasePath } from \"../app-base-path.js\";\nimport type { AgentChatPluginOptions } from \"./plugin-options.js\";\n\n// ---------------------------------------------------------------------------\n// Action-visibility filters (read-only / agent-exposed / public-agent-safe)\n// and the A2A (agent-to-agent) final-response assembly + delegated-run\n// helpers that share those filters.\n// ---------------------------------------------------------------------------\n\nexport function filterReadOnlyActions(\n actions: Record<string, ActionEntry>,\n): Record<string, ActionEntry> {\n return Object.fromEntries(\n Object.entries(actions).filter(([, entry]) => entry.readOnly === true),\n );\n}\n\n/** Drop actions that opted out of agent exposure via `agentTool: false`. They\n * remain callable from the frontend / HTTP (mounted separately from this\n * agent tool surface — see `httpActions`) but never appear in any agent tool\n * list (in-app assistant, MCP, A2A, job/trigger runners) or actions prompt.\n * Default-allow: only an explicit `false` is excluded. */\nexport function filterAgentTools(\n actions: Record<string, ActionEntry>,\n): Record<string, ActionEntry> {\n return Object.fromEntries(\n Object.entries(actions).filter(([, entry]) => entry.agentTool !== false),\n );\n}\n\nexport function filterPublicAgentActions(\n actions: Record<string, ActionEntry>,\n): Record<string, ActionEntry> {\n return Object.fromEntries(\n Object.entries(actions).filter(([, entry]) => {\n const config = entry.publicAgent;\n return (\n config?.expose === true &&\n config.readOnly === true &&\n config.requiresAuth !== true &&\n config.isConsequential !== true\n );\n }),\n );\n}\n\nexport function buildPublicAgentA2ASkills(\n actions: Record<string, ActionEntry>,\n): Array<{\n id: string;\n name: string;\n description: string;\n publicAgent: ActionEntry[\"publicAgent\"];\n}> {\n return Object.entries(filterPublicAgentActions(actions)).map(\n ([name, entry]) => ({\n id: name,\n name,\n description: entry.tool.description,\n publicAgent: entry.publicAgent,\n }),\n );\n}\n\nexport function resolveArtifactBaseUrl(\n event: any | undefined,\n): string | undefined {\n const fromEnv =\n process.env.APP_URL ||\n process.env.URL ||\n process.env.DEPLOY_URL ||\n process.env.BETTER_AUTH_URL;\n if (fromEnv) return withConfiguredAppBasePath(String(fromEnv));\n\n try {\n const proto = getHeader(event, \"x-forwarded-proto\") || \"https\";\n const host = getHeader(event, \"host\");\n if (host) return withConfiguredAppBasePath(`${proto}://${host}`);\n } catch {}\n\n return undefined;\n}\n\nexport function assembleA2AFinalResponse(\n events: readonly AgentChatEvent[],\n toolResults: readonly A2AToolResultSummary[],\n options: A2AArtifactResponseOptions & { event?: any } = {},\n): { responseText: string; finalText: string } {\n const terminalError = getA2ATerminalErrorEvent(events);\n const responseText = collectFinalResponseTextFromAgentEvents(events, {\n fallbackToPreToolText: !terminalError,\n });\n const finalText = appendA2AArtifactLinks(responseText, [...toolResults], {\n baseUrl: options.baseUrl ?? resolveArtifactBaseUrl(options.event),\n includeReferencedArtifacts: true,\n });\n if (terminalError && !finalText.trim()) {\n throw new Error(formatA2ATerminalError(terminalError));\n }\n return { responseText, finalText };\n}\n\nfunction getA2ATerminalErrorEvent(\n events: readonly AgentChatEvent[],\n): Extract<AgentChatEvent, { type: \"error\" }> | null {\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n if (event.type === \"clear\") continue;\n if (event.type === \"done\") return null;\n if (event.type === \"error\") return event;\n if (event.type === \"auto_continue\") {\n return {\n type: \"error\",\n error: `Agent stopped before finishing (${event.reason}).`,\n errorCode: event.reason,\n recoverable: true,\n };\n }\n }\n return null;\n}\n\nfunction formatA2ATerminalError(\n event: Extract<AgentChatEvent, { type: \"error\" }>,\n): string {\n const parts = [\n event.error || \"Agent failed before producing a final response.\",\n event.errorCode ? `code: ${event.errorCode}` : \"\",\n event.details ? `details: ${event.details}` : \"\",\n ].filter(Boolean);\n return parts.join(\"\\n\");\n}\n\ntype A2AAgentLoopRunner = typeof runAgentLoopDirectWithSoftTimeout;\n\nfunction runDelegatedAgentLoop(\n runOptions: Parameters<A2AAgentLoopRunner>[0],\n pluginOptions: Pick<\n AgentChatPluginOptions,\n \"finalResponseGuard\" | \"runSoftTimeoutMs\"\n >,\n timeoutOptions: Parameters<A2AAgentLoopRunner>[2],\n runner: A2AAgentLoopRunner,\n) {\n return runner(\n {\n ...runOptions,\n finalResponseGuard: pluginOptions.finalResponseGuard,\n },\n pluginOptions.runSoftTimeoutMs,\n timeoutOptions,\n );\n}\n\n/**\n * Run an A2A-delegated agent turn with the same final-response guard used by\n * the app's interactive chat surface.\n *\n * Keeping this in one helper prevents delegated calls from silently bypassing\n * template guarantees such as Analytics' requirement to query real data\n * before presenting metrics or exhaustive provider conclusions.\n */\nexport function runA2AAgentLoop(\n runOptions: Parameters<A2AAgentLoopRunner>[0],\n pluginOptions: Pick<\n AgentChatPluginOptions,\n \"finalResponseGuard\" | \"runSoftTimeoutMs\"\n >,\n timeoutOptions: Parameters<A2AAgentLoopRunner>[2],\n runner: A2AAgentLoopRunner = runAgentLoopDirectWithSoftTimeout,\n) {\n return runDelegatedAgentLoop(\n runOptions,\n pluginOptions,\n timeoutOptions,\n runner,\n );\n}\n\n/**\n * Run the MCP-local ask_app turn with the same app-level response guard as\n * A2A. Keeping this seam shared prevents hosted MCP callers from bypassing\n * template guarantees when the request cannot use the self-A2A route.\n */\nexport function runMCPAgentLoop(\n runOptions: Parameters<A2AAgentLoopRunner>[0],\n pluginOptions: Pick<\n AgentChatPluginOptions,\n \"finalResponseGuard\" | \"runSoftTimeoutMs\"\n >,\n timeoutOptions: Parameters<A2AAgentLoopRunner>[2],\n runner: A2AAgentLoopRunner = runAgentLoopDirectWithSoftTimeout,\n) {\n return runDelegatedAgentLoop(\n runOptions,\n pluginOptions,\n timeoutOptions,\n runner,\n );\n}\n\n/**\n * Keep delegated A2A turns on the same compact initial tool surface as\n * interactive chat. `tool-search` remains in the initial set, while the\n * complete registry is supplied separately so the run loop can load a matched\n * schema after a tool-search result.\n */\nexport function createA2AEngineToolSurface(\n availableTools: EngineTool[],\n initialToolNames?: string[],\n): { tools: EngineTool[]; availableTools: EngineTool[] } {\n return {\n tools: filterInitialEngineTools(availableTools, initialToolNames),\n availableTools,\n };\n}\n\nexport function resolveInitialToolNames(\n templateActions: Record<string, ActionEntry>,\n configured?: string[],\n): string[] {\n return configured ?? Object.keys(templateActions);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { handleSharedThreadRequest, type SharedThreadRouteDependencies } from "./agent-chat/shared-thread.js";
2
2
  export { handleSharedThreadRequest };
3
3
  export type { SharedThreadRouteDependencies };
4
- import { createA2AEngineToolSurface, runA2AAgentLoop, assembleA2AFinalResponse, buildPublicAgentA2ASkills } from "./agent-chat/action-filters-a2a.js";
4
+ import { createA2AEngineToolSurface, runA2AAgentLoop, runMCPAgentLoop, assembleA2AFinalResponse, buildPublicAgentA2ASkills } from "./agent-chat/action-filters-a2a.js";
5
5
  import { _agentChatPromptSectionsForTests } from "./agent-chat/framework-prompts.js";
6
6
  import { type AgentChatPluginOptions, type NitroPluginDef } from "./agent-chat/plugin-options.js";
7
7
  import { finalizeClaimedAgentChatProcessRunFailure } from "./agent-chat/process-run-failure.js";
@@ -15,6 +15,7 @@ export { buildPublicAgentA2ASkills };
15
15
  export { assembleA2AFinalResponse };
16
16
  export type { AgentChatPluginOptions };
17
17
  export { runA2AAgentLoop };
18
+ export { runMCPAgentLoop };
18
19
  export { createA2AEngineToolSurface };
19
20
  export { shouldBlockInProductCodeEditingSurface };
20
21
  export { loadRunCodeToolEntries };
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat-plugin.d.ts","sourceRoot":"","sources":["../../src/server/agent-chat-plugin.ts"],"names":[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AAC;AAC3B,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,OAAO,EAAE,sCAAsC,EAAE,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,OAAO,EAAE,iCAAiC,EAAE,CAAC;AAC7C,OAAO,EAAE,yCAAyC,EAAE,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,uCAAuC,CAC3D,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC,CAUlB;AAaD,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,cAAc,CAi6JhB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,cAAwC,CAAC;AAE9E,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EAGxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -9,7 +9,6 @@ import { DEFAULT_ANTHROPIC_MODEL } from "../agent/default-model.js";
9
9
  import { AGENT_CHAT_BACKGROUND_RUN_FIELD, AGENT_CHAT_PROCESS_RUN_PATH, backgroundRunMarkerExpectsBackgroundRuntime, isInBackgroundFunctionRuntime, prepareProcessRunRequest, } from "../agent/durable-background.js";
10
10
  import { resolveEngine, createAnthropicEngine, getStoredModelForEngine, normalizeModelForEngine, getAgentEngineEntry, isAgentEnginePackageInstalled, isStoredEngineUsableForRequest, listAgentEngines, registerBuiltinEngines, } from "../agent/engine/index.js";
11
11
  import { createProductionAgentHandler, actionsToEngineTools, executeAgentToolCall, getActiveRunForThreadAsync, abortRunDurably, subscribeToRun, } from "../agent/production-agent.js";
12
- import { runAgentLoopDirectWithSoftTimeout } from "../agent/run-loop-with-resume.js";
13
12
  import { callerHasRunAccess, callerHasThreadAccess, } from "../agent/run-ownership.js";
14
13
  import { readBackgroundRunClaim } from "../agent/run-store.js";
15
14
  import { buildCurrentTimeUserContext, buildRuntimeContextPrompt, } from "../agent/runtime-context.js";
@@ -55,7 +54,7 @@ async function lazyFs() {
55
54
  // the ones that were already part of the public surface) so
56
55
  // `createAgentChatPlugin` below stays a thinner orchestrator.
57
56
  // ---------------------------------------------------------------------------
58
- import { createA2AEngineToolSurface, filterAgentTools, filterPublicAgentActions, filterReadOnlyActions, resolveInitialToolNames, runA2AAgentLoop, assembleA2AFinalResponse, buildPublicAgentA2ASkills, resolveArtifactBaseUrl, } from "./agent-chat/action-filters-a2a.js";
57
+ import { createA2AEngineToolSurface, filterAgentTools, filterPublicAgentActions, filterReadOnlyActions, resolveInitialToolNames, runA2AAgentLoop, runMCPAgentLoop, assembleA2AFinalResponse, buildPublicAgentA2ASkills, resolveArtifactBaseUrl, } from "./agent-chat/action-filters-a2a.js";
59
58
  import { createBuilderBrowserTool, createTeamTools, } from "./agent-chat/browser-team-tools.js";
60
59
  import { createDataWidgetActionEntries, createFrameworkContextEntry, createRefreshScreenEntry, createUrlTools, } from "./agent-chat/context-tools.js";
61
60
  import { _agentChatPromptSectionsForTests, buildFrameworkPrompts, buildSchemaBlock, collectFiles, corpusToolNamesTaughtByPrompt, generateActionsPrompt, generateCorpusToolsPrompt, } from "./agent-chat/framework-prompts.js";
@@ -71,6 +70,7 @@ export { _agentChatPromptSectionsForTests };
71
70
  export { buildPublicAgentA2ASkills };
72
71
  export { assembleA2AFinalResponse };
73
72
  export { runA2AAgentLoop };
73
+ export { runMCPAgentLoop };
74
74
  export { createA2AEngineToolSurface };
75
75
  export { shouldBlockInProductCodeEditingSurface };
76
76
  export { loadRunCodeToolEntries };
@@ -1044,6 +1044,13 @@ export function createAgentChatPlugin(options) {
1044
1044
  availableTools: a2aToolSurface.availableTools,
1045
1045
  messages: a2aMessages,
1046
1046
  actions: a2aActions,
1047
+ // A2A already establishes these values in request context. Pass
1048
+ // them explicitly too so delegated tool execution and template
1049
+ // final-response guards cannot lose the authenticated caller's
1050
+ // scope when a processor hop or alternate runner is involved.
1051
+ ownerEmail: userEmail,
1052
+ orgId: getRequestOrgId() ?? null,
1053
+ executionMode: "act",
1047
1054
  send: (event) => {
1048
1055
  a2aEvents.push(event);
1049
1056
  if (event.type === "tool_start") {
@@ -1246,7 +1253,7 @@ export function createAgentChatPlugin(options) {
1246
1253
  buildRuntimeContextPrompt();
1247
1254
  let accumulatedText = "";
1248
1255
  const controller = new AbortController();
1249
- await runAgentLoopDirectWithSoftTimeout({
1256
+ await runMCPAgentLoop({
1250
1257
  engine: mcpEngine,
1251
1258
  model,
1252
1259
  systemPrompt,
@@ -1266,11 +1273,17 @@ export function createAgentChatPlugin(options) {
1266
1273
  },
1267
1274
  ],
1268
1275
  actions: mcpActions,
1276
+ ownerEmail: getRequestUserEmail(),
1277
+ orgId: getRequestOrgId() ?? null,
1278
+ executionMode: "act",
1269
1279
  send: (event) => {
1270
1280
  accumulatedText = applyAgentTextEventToBuffer(accumulatedText, event);
1271
1281
  },
1272
1282
  signal: controller.signal,
1273
- }, options?.runSoftTimeoutMs, {
1283
+ }, {
1284
+ finalResponseGuard: options?.finalResponseGuard,
1285
+ runSoftTimeoutMs: options?.runSoftTimeoutMs,
1286
+ }, {
1274
1287
  backgroundFunction: options?.durableBackgroundRuns === true &&
1275
1288
  isInBackgroundFunctionRuntime(),
1276
1289
  });