@mastra/core 1.87.0-alpha.21 → 1.87.0-alpha.22

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 (116) hide show
  1. package/dist/agent/durable/index.cjs +1 -1
  2. package/dist/agent/durable/index.js +1 -1
  3. package/dist/agent/index.cjs +2 -2
  4. package/dist/agent/index.js +2 -2
  5. package/dist/agent-builder/ee/index.cjs +1 -1
  6. package/dist/agent-builder/ee/index.js +1 -1
  7. package/dist/agent-controller/index.cjs +2 -2
  8. package/dist/agent-controller/index.js +2 -2
  9. package/dist/{agent-controller-Cw5t1dkE.js → agent-controller-WGML_NKp.js} +6 -6
  10. package/dist/{agent-controller-4dz2FE2a.cjs → agent-controller-mS3CgzwJ.cjs} +6 -6
  11. package/dist/background-tasks/index.cjs +1 -1
  12. package/dist/background-tasks/index.js +1 -1
  13. package/dist/{background-tasks-DFDfV-FJ.js → background-tasks-CbBbS-g3.js} +1 -1
  14. package/dist/{background-tasks-fjEu5kC8.cjs → background-tasks-DEBc9BBP.cjs} +1 -1
  15. package/dist/browser/index.cjs +1 -1
  16. package/dist/browser/index.js +1 -1
  17. package/dist/{builder-la4Jv6di.js → builder-BOIUFJTC.js} +2 -2
  18. package/dist/{builder-DrBUrE-F.cjs → builder-DBori4UC.cjs} +2 -2
  19. package/dist/channels/index.cjs +2 -2
  20. package/dist/channels/index.js +2 -2
  21. package/dist/{channels-BUa-51eD.js → channels-BwOQwN3M.js} +1 -1
  22. package/dist/{channels-CqwRfJzZ.cjs → channels-DrLMv8qW.cjs} +1 -1
  23. package/dist/coding-agent/index.cjs +1 -1
  24. package/dist/coding-agent/index.js +1 -1
  25. package/dist/datasets/index.cjs +2 -2
  26. package/dist/datasets/index.js +2 -2
  27. package/dist/docs/SKILL.md +1 -1
  28. package/dist/docs/assets/SOURCE_MAP.json +511 -511
  29. package/dist/docs/references/docs-agents-tools.md +2 -2
  30. package/dist/evals/index.cjs +1 -1
  31. package/dist/evals/index.js +1 -1
  32. package/dist/evals/scoreTraces/index.cjs +1 -1
  33. package/dist/evals/scoreTraces/index.js +1 -1
  34. package/dist/{execution-fence-DeR5VB54.cjs → execution-fence-C-wa17Wr.cjs} +11 -11
  35. package/dist/{execution-fence-Yl_-iJxn.js → execution-fence-DvN3Fwm3.js} +11 -11
  36. package/dist/harness/index.cjs +2 -2
  37. package/dist/harness/index.js +2 -2
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/knowledge/index.cjs +1 -1
  41. package/dist/knowledge/index.js +1 -1
  42. package/dist/llm/index.cjs +3 -3
  43. package/dist/llm/index.js +3 -3
  44. package/dist/llm/model/mastra-gateway-provider-tools.d.ts +7 -0
  45. package/dist/{llm-DVQKutUM.cjs → llm-dX0y0atH.cjs} +4 -2
  46. package/dist/{llm-BZQdtNe1.js → llm-hWZGKDUy.js} +4 -2
  47. package/dist/loop/index.cjs +2 -2
  48. package/dist/loop/index.js +2 -2
  49. package/dist/{manager-CxN9r6o4.js → manager-9pUbVmmS.js} +2 -2
  50. package/dist/{manager-Cr0lJZSV.cjs → manager-CUoAGxcN.cjs} +2 -2
  51. package/dist/mastra/index.cjs +1 -1
  52. package/dist/mastra/index.js +1 -1
  53. package/dist/{mastra-D4Q2NPsZ.cjs → mastra-B6Fw2ZIW.cjs} +16 -16
  54. package/dist/{mastra-CsuV_iVH.js → mastra-CliUSn4-.js} +16 -16
  55. package/dist/mastra-gateway-provider-tools-C-AjGZis.js +58 -0
  56. package/dist/mastra-gateway-provider-tools-WpH3Tmu4.cjs +81 -0
  57. package/dist/memory/index.cjs +2 -2
  58. package/dist/memory/index.js +2 -2
  59. package/dist/{model-CIV_1-kW.js → model-CAp-mgCd.js} +1 -1
  60. package/dist/{model-DOqga9dt.cjs → model-DEnu3A8A.cjs} +1 -1
  61. package/dist/{netlify-KyTDrIQP.cjs → netlify-BMhDN9E8.cjs} +1 -1
  62. package/dist/{netlify-CoThk6uD.js → netlify-xMA06xL8.js} +1 -1
  63. package/dist/notifications/index.cjs +1 -1
  64. package/dist/notifications/index.js +1 -1
  65. package/dist/processor-provider/index.cjs +1 -1
  66. package/dist/processor-provider/index.js +1 -1
  67. package/dist/processors/index.cjs +2 -2
  68. package/dist/processors/index.js +2 -2
  69. package/dist/{provider-registry-BsphJbPb.cjs → provider-registry-CcMAUHdH.cjs} +8 -51
  70. package/dist/{provider-registry-BIXG21H8.js → provider-registry-DsK3rXeU.js} +7 -50
  71. package/dist/{registry-generator-BXZzqm-j.js → registry-generator-CXDt3yuY.js} +1 -1
  72. package/dist/{registry-generator-BBmRjrp4.cjs → registry-generator-DRFJTQ2Q.cjs} +1 -1
  73. package/dist/{rehydrate-BwfL5GuU.js → rehydrate-C_fSTYcV.js} +2 -2
  74. package/dist/{rehydrate-tjUWtbB-.cjs → rehydrate-DNf3nk5t.cjs} +2 -2
  75. package/dist/relevance/index.cjs +2 -2
  76. package/dist/relevance/index.js +2 -2
  77. package/dist/storage/index.cjs +2 -2
  78. package/dist/storage/index.js +2 -2
  79. package/dist/stream/index.cjs +2 -2
  80. package/dist/stream/index.js +2 -2
  81. package/dist/{stream-C4XcOMuS.cjs → stream-BKEfY3-X.cjs} +1 -1
  82. package/dist/{stream-Dgsrva80.js → stream-CyaGm-DI.js} +1 -1
  83. package/dist/test-utils/llm-mock.cjs +1 -1
  84. package/dist/test-utils/llm-mock.js +1 -1
  85. package/dist/tool-loop-agent/index.cjs +1 -1
  86. package/dist/tool-loop-agent/index.js +1 -1
  87. package/dist/{tool-loop-agent-DN4C3VpR.js → tool-loop-agent-BYrNEcU_.js} +3 -3
  88. package/dist/{tool-loop-agent-Dze-IJOx.cjs → tool-loop-agent-Du3Vm65W.cjs} +3 -3
  89. package/dist/tools/builtin/web-search.d.ts +8 -0
  90. package/dist/tools/index.cjs +1 -1
  91. package/dist/tools/index.js +1 -1
  92. package/dist/{tools-C2q0ougI.cjs → tools-DZoVfKPl.cjs} +42 -17
  93. package/dist/{tools-ybbz1YKg.js → tools-FwJyNoyg.js} +41 -10
  94. package/dist/{utils-AfuTYtPM.cjs → utils-Ag63fN_T.cjs} +1 -1
  95. package/dist/{utils-B-UrrqES.js → utils-Dl5BqcZO.js} +1 -1
  96. package/dist/utils.cjs +1 -1
  97. package/dist/utils.js +1 -1
  98. package/dist/{validate-zLPo00kk.js → validate-CYqPJX3z.js} +1 -1
  99. package/dist/{validate-GzP07CVb.cjs → validate-bRsKfPrD.cjs} +1 -1
  100. package/dist/vector/index.cjs +1 -1
  101. package/dist/vector/index.js +1 -1
  102. package/dist/worker/index.cjs +1 -1
  103. package/dist/worker/index.js +1 -1
  104. package/dist/{worker-ChLwyYHR.cjs → worker-DPjo5pv_.cjs} +2 -2
  105. package/dist/{worker-J6-CpZ0n.cjs → worker-Dvt_y5ra.cjs} +2 -2
  106. package/dist/{worker-DP_A9d7f.js → worker-RbY0GNay.js} +2 -2
  107. package/dist/{worker-BYQGN5Lh.js → worker-oSqtPcV6.js} +2 -2
  108. package/dist/{workflow-COgwqQxL.cjs → workflow-B6Xdy2Ck.cjs} +3 -3
  109. package/dist/{workflow-DqV0r2P-.js → workflow-X6iwBizX.js} +3 -3
  110. package/dist/workflows/builder/index.cjs +1 -1
  111. package/dist/workflows/builder/index.js +1 -1
  112. package/dist/workflows/evented/index.cjs +1 -1
  113. package/dist/workflows/evented/index.js +1 -1
  114. package/dist/workflows/index.cjs +4 -4
  115. package/dist/workflows/index.js +4 -4
  116. package/package.json +5 -5
@@ -1,13 +1,13 @@
1
- import { $c as createConcurrencyLimiter, Bc as createNestedRunParentStatusLookup, Bl as hasDurableExecution, Fo as getStorageSource, Fs as WorkflowEventProcessor, Hc as nestedRunRecoveryAction, Hl as isDurableAgentLike, Jc as WORKFLOW_RUN_LEASE_TTL_MS, Ll as assertDrainTimeout, Lr as dispatchDueNotifications, Ls as computeScheduleDefinitionHash, Ns as createStep, Po as augmentWithInit, Ps as createWorkflow, Rl as waitMs, Uc as nestedRunStatusOf, Vc as nestedRunParentOf, Xc as repeatAfterSettled, Yc as renewWorkflowLease, Zc as runFenceConflictOf, br as WorkflowsInMemory, bu as runOutsideRunFenceScope, el as normalizeConcurrency, i as agentThreadStreamRuntime, mt as __registerMastraCtor, n as getExecutionClaimScope, na as BackgroundTasksInMemory, oc as getActiveDurableAgentWorkflowExecutions, rc as abandonDurableAgentExecutions, sc as getExecutingInstances, tl as runWithConcurrency, u as createOnScorerHook, uc as isDurableAgentExecutionDetached, vr as InMemoryStore, yn as AgentChannels, zc as cancelNestedRun } from "./execution-fence-Yl_-iJxn.js";
2
- import { l as BackgroundTaskManager } from "./background-tasks-DFDfV-FJ.js";
1
+ import { $c as createConcurrencyLimiter, Bc as createNestedRunParentStatusLookup, Bl as hasDurableExecution, Fo as getStorageSource, Fs as WorkflowEventProcessor, Hc as nestedRunRecoveryAction, Hl as isDurableAgentLike, Jc as WORKFLOW_RUN_LEASE_TTL_MS, Ll as assertDrainTimeout, Lr as dispatchDueNotifications, Ls as computeScheduleDefinitionHash, Ns as createStep, Po as augmentWithInit, Ps as createWorkflow, Rl as waitMs, Uc as nestedRunStatusOf, Vc as nestedRunParentOf, Xc as repeatAfterSettled, Yc as renewWorkflowLease, Zc as runFenceConflictOf, br as WorkflowsInMemory, bu as runOutsideRunFenceScope, el as normalizeConcurrency, i as agentThreadStreamRuntime, mt as __registerMastraCtor, n as getExecutionClaimScope, na as BackgroundTasksInMemory, oc as getActiveDurableAgentWorkflowExecutions, rc as abandonDurableAgentExecutions, sc as getExecutingInstances, tl as runWithConcurrency, u as createOnScorerHook, uc as isDurableAgentExecutionDetached, vr as InMemoryStore, yn as AgentChannels, zc as cancelNestedRun } from "./execution-fence-DvN3Fwm3.js";
2
+ import { l as BackgroundTaskManager } from "./background-tasks-CbBbS-g3.js";
3
3
  import { t as InMemoryServerCache } from "./inmemory-BK3zLwvM.js";
4
- import { t as DatasetsManager } from "./manager-CxN9r6o4.js";
4
+ import { t as DatasetsManager } from "./manager-9pUbVmmS.js";
5
5
  import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "./error-oh2DLsP2.js";
6
6
  import { d as isRunLocalTopic, v as EventEmitterPubSub } from "./output-helpers-k2-48ssH.js";
7
7
  import { a as registerHook, r as deregisterHook } from "./hooks-Bth8Cjpj.js";
8
8
  import { LicenseClient } from "./license/index.js";
9
- import { g as getGatewayId } from "./netlify-CoThk6uD.js";
10
- import { l as defaultGateways } from "./llm-BZQdtNe1.js";
9
+ import { g as getGatewayId } from "./netlify-xMA06xL8.js";
10
+ import { l as defaultGateways } from "./llm-hWZGKDUy.js";
11
11
  import { l as isAdaptableLogger, n as LogLevel, t as ConsoleLogger, u as noopLogger } from "./logger-BwbmRqfc.js";
12
12
  import { DualLogger, createExportSuppressedLogger, isObservabilityExportSuppressed, resolveTraceFields } from "./logger/index.js";
13
13
  import { c as fsAgentScheduleRowId, g as toEpochMs, h as computeNextFireAt, l as parseFsAgentScheduleRowId, m as computeNextFire, t as Schedules } from "./schedules-DZfSx-7P.js";
@@ -17,14 +17,14 @@ import { f as resolveCurrentSpan } from "./utils-DU_pU5SK.js";
17
17
  import { u as RequestContext } from "./request-context-COnZHt2-.js";
18
18
  import { r as InMemoryDB } from "./source-B3He4_mz.js";
19
19
  import { r as trackFeatureUsage } from "./feature-telemetry-DdR8J_5o.js";
20
- import { r as isToolLoopAgentLike, t as toolLoopAgentToMastraAgent } from "./tool-loop-agent-DN4C3VpR.js";
20
+ import { r as isToolLoopAgentLike, t as toolLoopAgentToMastraAgent } from "./tool-loop-agent-BYrNEcU_.js";
21
21
  import { r as normalizeToolPayloadTransformPolicy } from "./payload-transform-Dj3HUeD4.js";
22
- import { v as readPositiveIntEnv } from "./utils-B-UrrqES.js";
23
- import { a as OrchestrationWorker, i as ORCHESTRATION_GROUP, n as BackgroundTaskWorker, r as SchedulerWorker } from "./worker-BYQGN5Lh.js";
24
- import { n as normalizeWorkflowBuilderDefinition } from "./builder-la4Jv6di.js";
25
- import { d as toJsonSchemaOrUndefined, p as collectNestedWorkflowIds, t as assertValidDynamicWorkflow } from "./validate-zLPo00kk.js";
26
- import { t as rehydrateWorkflow } from "./rehydrate-BwfL5GuU.js";
27
- import { Rn as createRunScope } from "./stream-Dgsrva80.js";
22
+ import { v as readPositiveIntEnv } from "./utils-Dl5BqcZO.js";
23
+ import { a as OrchestrationWorker, i as ORCHESTRATION_GROUP, n as BackgroundTaskWorker, r as SchedulerWorker } from "./worker-oSqtPcV6.js";
24
+ import { n as normalizeWorkflowBuilderDefinition } from "./builder-BOIUFJTC.js";
25
+ import { d as toJsonSchemaOrUndefined, p as collectNestedWorkflowIds, t as assertValidDynamicWorkflow } from "./validate-CYqPJX3z.js";
26
+ import { t as rehydrateWorkflow } from "./rehydrate-C_fSTYcV.js";
27
+ import { Rn as createRunScope } from "./stream-CyaGm-DI.js";
28
28
  import { z } from "zod/v4";
29
29
  // src/notifications/workflow.ts
30
30
  const NOTIFICATION_DISPATCH_WORKFLOW_ID = "__mastra_notification_dispatcher";
@@ -2874,7 +2874,7 @@ var Mastra = class Mastra {
2874
2874
  */
2875
2875
  async __ensureExperimentWorkflow() {
2876
2876
  if (this.__hasInternalWorkflow("__mastra-experiment")) return;
2877
- const { buildExperimentWorkflow } = await import("./manager-CxN9r6o4.js").then((n) => n.b);
2877
+ const { buildExperimentWorkflow } = await import("./manager-9pUbVmmS.js").then((n) => n.b);
2878
2878
  if (this.__hasInternalWorkflow("__mastra-experiment")) return;
2879
2879
  this.__registerInternalWorkflow(buildExperimentWorkflow(), void 0, { distributed: true });
2880
2880
  }
@@ -5075,7 +5075,7 @@ var Mastra = class Mastra {
5075
5075
  if (!this.#workerFilter || this.#workerFilter.has("agent-schedule")) {
5076
5076
  let agentScheduleWorker = this.#findAgentScheduleWorker();
5077
5077
  if (!agentScheduleWorker) {
5078
- const { AgentScheduleWorker } = await import("./worker-DP_A9d7f.js");
5078
+ const { AgentScheduleWorker } = await import("./worker-RbY0GNay.js");
5079
5079
  agentScheduleWorker = new AgentScheduleWorker();
5080
5080
  agentScheduleWorker.__registerMastra(this);
5081
5081
  this.#workers.push(agentScheduleWorker);
@@ -5760,7 +5760,7 @@ var Mastra = class Mastra {
5760
5760
  this.#workers.push(sw);
5761
5761
  }
5762
5762
  if (!this.#findAgentScheduleWorker()) {
5763
- const { AgentScheduleWorker } = await import("./worker-DP_A9d7f.js");
5763
+ const { AgentScheduleWorker } = await import("./worker-RbY0GNay.js");
5764
5764
  const asw = new AgentScheduleWorker();
5765
5765
  asw.__registerMastra(this);
5766
5766
  this.#workers.push(asw);
@@ -6210,7 +6210,7 @@ var Mastra = class Mastra {
6210
6210
  #syncGatewayRegistry() {
6211
6211
  try {
6212
6212
  if (process.env.MASTRA_DEV !== "true" && process.env.MASTRA_DEV !== "1") return;
6213
- import("./provider-registry-BIXG21H8.js").then((n) => n.d).then(async ({ GatewayRegistry }) => {
6213
+ import("./provider-registry-DsK3rXeU.js").then((n) => n.d).then(async ({ GatewayRegistry }) => {
6214
6214
  const registry = GatewayRegistry.getInstance();
6215
6215
  const customGateways = Object.values(this.#gateways || {});
6216
6216
  registry.registerCustomGateways(customGateways);
@@ -0,0 +1,58 @@
1
+ import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "./error-oh2DLsP2.js";
2
+ // src/llm/model/mastra-gateway-provider-tools.ts
3
+ const OPENROUTER_WEB_SEARCH_TOOL_ID = "openrouter.web_search";
4
+ const MASTRA_GATEWAY_CHAT_MODEL = Symbol.for("mastra.gateway.chatModel");
5
+ /**
6
+ * Marks a model whose requests go to the Mastra gateway's chat endpoint. Such a model reports
7
+ * `openrouter` as its provider, so the mark is how callers know its tools are gateway tools.
8
+ */
9
+ function markMastraGatewayChatModel(model) {
10
+ Object.defineProperty(model, MASTRA_GATEWAY_CHAT_MODEL, { value: true });
11
+ return model;
12
+ }
13
+ function isMastraGatewayChatModel(model) {
14
+ return typeof model === "object" && model !== null && model[MASTRA_GATEWAY_CHAT_MODEL] === true;
15
+ }
16
+ const NATIVE_WEB_SEARCH_TOOL_IDS = {
17
+ "openai.web_search": true,
18
+ "anthropic.web_search_20250305": true,
19
+ "google.google_search": true,
20
+ "xai.web_search": true
21
+ };
22
+ /**
23
+ * The Mastra gateway's chat endpoint only runs `openrouter:*` server tools. Another provider's
24
+ * native tool is rejected with a 400 (OpenAI, xAI models) or dropped without an error (Anthropic,
25
+ * Google models), so the model silently loses the tool.
26
+ *
27
+ * A native web search tool with no arguments is swapped for the gateway's web search, which works
28
+ * for every tool-calling model. Any other native tool fails here with an actionable message.
29
+ */
30
+ function prepareToolsForMastraGateway(options, routerId) {
31
+ const isProviderTool = (tool) => tool.type === "provider-defined" || tool.type === "provider";
32
+ if (!options.tools?.some(isProviderTool)) return options;
33
+ const tools = options.tools.map((tool) => {
34
+ if (!isProviderTool(tool)) return tool;
35
+ const { id, args } = tool;
36
+ if (id.startsWith("openrouter.")) return tool;
37
+ const isWebSearch = id in NATIVE_WEB_SEARCH_TOOL_IDS;
38
+ if (isWebSearch && Object.keys(args ?? {}).length === 0) return {
39
+ ...tool,
40
+ id: OPENROUTER_WEB_SEARCH_TOOL_ID
41
+ };
42
+ throw new MastraError({
43
+ id: "MASTRA_GATEWAY_UNSUPPORTED_PROVIDER_TOOL",
44
+ domain: ErrorDomain.LLM,
45
+ category: ErrorCategory.USER,
46
+ details: {
47
+ toolId: id,
48
+ model: routerId
49
+ },
50
+ text: `The provider tool "${id}" cannot be used with "${routerId}". The Mastra gateway only runs its own server tools. ` + (isWebSearch ? `Its web search does not accept "${id}" options: use webSearchTool from @mastra/core/tools, or call the provider directly to keep them.` : `Call the provider directly to use this tool.`)
51
+ });
52
+ });
53
+ return {
54
+ ...options,
55
+ tools
56
+ };
57
+ }
58
+ export { prepareToolsForMastraGateway as i, isMastraGatewayChatModel as n, markMastraGatewayChatModel as r, OPENROUTER_WEB_SEARCH_TOOL_ID as t };
@@ -0,0 +1,81 @@
1
+ const require_error = require("./error-D90lJ6M7.cjs");
2
+ // src/llm/model/mastra-gateway-provider-tools.ts
3
+ const OPENROUTER_WEB_SEARCH_TOOL_ID = "openrouter.web_search";
4
+ const MASTRA_GATEWAY_CHAT_MODEL = Symbol.for("mastra.gateway.chatModel");
5
+ /**
6
+ * Marks a model whose requests go to the Mastra gateway's chat endpoint. Such a model reports
7
+ * `openrouter` as its provider, so the mark is how callers know its tools are gateway tools.
8
+ */
9
+ function markMastraGatewayChatModel(model) {
10
+ Object.defineProperty(model, MASTRA_GATEWAY_CHAT_MODEL, { value: true });
11
+ return model;
12
+ }
13
+ function isMastraGatewayChatModel(model) {
14
+ return typeof model === "object" && model !== null && model[MASTRA_GATEWAY_CHAT_MODEL] === true;
15
+ }
16
+ const NATIVE_WEB_SEARCH_TOOL_IDS = {
17
+ "openai.web_search": true,
18
+ "anthropic.web_search_20250305": true,
19
+ "google.google_search": true,
20
+ "xai.web_search": true
21
+ };
22
+ /**
23
+ * The Mastra gateway's chat endpoint only runs `openrouter:*` server tools. Another provider's
24
+ * native tool is rejected with a 400 (OpenAI, xAI models) or dropped without an error (Anthropic,
25
+ * Google models), so the model silently loses the tool.
26
+ *
27
+ * A native web search tool with no arguments is swapped for the gateway's web search, which works
28
+ * for every tool-calling model. Any other native tool fails here with an actionable message.
29
+ */
30
+ function prepareToolsForMastraGateway(options, routerId) {
31
+ const isProviderTool = (tool) => tool.type === "provider-defined" || tool.type === "provider";
32
+ if (!options.tools?.some(isProviderTool)) return options;
33
+ const tools = options.tools.map((tool) => {
34
+ if (!isProviderTool(tool)) return tool;
35
+ const { id, args } = tool;
36
+ if (id.startsWith("openrouter.")) return tool;
37
+ const isWebSearch = id in NATIVE_WEB_SEARCH_TOOL_IDS;
38
+ if (isWebSearch && Object.keys(args ?? {}).length === 0) return {
39
+ ...tool,
40
+ id: OPENROUTER_WEB_SEARCH_TOOL_ID
41
+ };
42
+ throw new require_error.MastraError({
43
+ id: "MASTRA_GATEWAY_UNSUPPORTED_PROVIDER_TOOL",
44
+ domain: require_error.ErrorDomain.LLM,
45
+ category: require_error.ErrorCategory.USER,
46
+ details: {
47
+ toolId: id,
48
+ model: routerId
49
+ },
50
+ text: `The provider tool "${id}" cannot be used with "${routerId}". The Mastra gateway only runs its own server tools. ` + (isWebSearch ? `Its web search does not accept "${id}" options: use webSearchTool from @mastra/core/tools, or call the provider directly to keep them.` : `Call the provider directly to use this tool.`)
51
+ });
52
+ });
53
+ return {
54
+ ...options,
55
+ tools
56
+ };
57
+ }
58
+ Object.defineProperty(exports, "OPENROUTER_WEB_SEARCH_TOOL_ID", {
59
+ enumerable: true,
60
+ get: function() {
61
+ return OPENROUTER_WEB_SEARCH_TOOL_ID;
62
+ }
63
+ });
64
+ Object.defineProperty(exports, "isMastraGatewayChatModel", {
65
+ enumerable: true,
66
+ get: function() {
67
+ return isMastraGatewayChatModel;
68
+ }
69
+ });
70
+ Object.defineProperty(exports, "markMastraGatewayChatModel", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return markMastraGatewayChatModel;
74
+ }
75
+ });
76
+ Object.defineProperty(exports, "prepareToolsForMastraGateway", {
77
+ enumerable: true,
78
+ get: function() {
79
+ return prepareToolsForMastraGateway;
80
+ }
81
+ });
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_stream = require("../stream-C4XcOMuS.cjs");
3
- const require_execution_fence = require("../execution-fence-DeR5VB54.cjs");
2
+ const require_stream = require("../stream-BKEfY3-X.cjs");
3
+ const require_execution_fence = require("../execution-fence-C-wa17Wr.cjs");
4
4
  const require_message_list = require("../message-list-C0F2sDNC.cjs");
5
5
  exports.AUTHORED_USER_TURN = require_message_list.AUTHORED_USER_TURN;
6
6
  exports.DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS = require_execution_fence.DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS;
@@ -1,4 +1,4 @@
1
- import { Jt as getThreadOMMetadata, Qt as setThreadOMMetadata, Xt as isThreadTitlePinned, Yt as isObservationalMemoryEnabled, Zt as parseMemoryRequestContext, qt as TITLE_PINNED_THREAD_METADATA_KEY } from "../stream-Dgsrva80.js";
2
- import { Ao as MemoryProcessor, Co as buildMessageEmbeddingRows, Do as resolveMaxChunkChars, Eo as messageVectorId, Jn as getMemoryRunState, Mo as filterSystemReminderMessages, No as isSystemReminderMessage, Oo as upsertMessageVectors, So as MESSAGE_EMBEDDING_CHARS_PER_TOKEN, To as extractMessageEmbeddingText, Yn as MockMemory, as as normalizeMessageHistoryConfig, es as groupLinkedToolMessages, is as isAfterMemoryTokenBoundary, jo as memoryDefaultOptions, ko as MastraMemory, ns as advanceMemoryTokenBoundary, qn as MemoryRunState, rs as getMemoryTokenBoundary, ts as loadMessageHistory, wo as chunkMessageText, xo as DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS } from "../execution-fence-Yl_-iJxn.js";
1
+ import { Jt as getThreadOMMetadata, Qt as setThreadOMMetadata, Xt as isThreadTitlePinned, Yt as isObservationalMemoryEnabled, Zt as parseMemoryRequestContext, qt as TITLE_PINNED_THREAD_METADATA_KEY } from "../stream-CyaGm-DI.js";
2
+ import { Ao as MemoryProcessor, Co as buildMessageEmbeddingRows, Do as resolveMaxChunkChars, Eo as messageVectorId, Jn as getMemoryRunState, Mo as filterSystemReminderMessages, No as isSystemReminderMessage, Oo as upsertMessageVectors, So as MESSAGE_EMBEDDING_CHARS_PER_TOKEN, To as extractMessageEmbeddingText, Yn as MockMemory, as as normalizeMessageHistoryConfig, es as groupLinkedToolMessages, is as isAfterMemoryTokenBoundary, jo as memoryDefaultOptions, ko as MastraMemory, ns as advanceMemoryTokenBoundary, qn as MemoryRunState, rs as getMemoryTokenBoundary, ts as loadMessageHistory, wo as chunkMessageText, xo as DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS } from "../execution-fence-DvN3Fwm3.js";
3
3
  import { $ as AUTHORED_USER_TURN, C as extractWorkingMemoryTags, D as removeWorkingMemoryToolInvocationParts, E as removeWorkingMemoryTags, O as removeWorkingMemoryToolInvocations, S as extractWorkingMemoryContent, T as removeSystemReminderTags, _ as SYSTEM_REMINDER_START_TAG, at as stripClientAuthoredTurnMarks, b as WORKING_MEMORY_START_TAG, et as asUserTurn, g as SYSTEM_REMINDER_END_TAG, h as SET_WORKING_MEMORY_TOOL_NAME, it as sealUserTurnMessage, nt as messageDeclaresAuthoredTurn, rt as sealTurnMarkup, tt as escapeTurnMarkup, v as UPDATE_WORKING_MEMORY_TOOL_NAME, w as isWorkingMemoryToolName, x as WORKING_MEMORY_TOOL_NAMES, y as WORKING_MEMORY_END_TAG } from "../message-list-RgFlLrxG.js";
4
4
  export { AUTHORED_USER_TURN, DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS, MESSAGE_EMBEDDING_CHARS_PER_TOKEN, MastraMemory, MemoryProcessor, MemoryRunState, MockMemory, SET_WORKING_MEMORY_TOOL_NAME, SYSTEM_REMINDER_END_TAG, SYSTEM_REMINDER_START_TAG, TITLE_PINNED_THREAD_METADATA_KEY, UPDATE_WORKING_MEMORY_TOOL_NAME, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, WORKING_MEMORY_TOOL_NAMES, advanceMemoryTokenBoundary, asUserTurn, buildMessageEmbeddingRows, chunkMessageText, escapeTurnMarkup, extractMessageEmbeddingText, extractWorkingMemoryContent, extractWorkingMemoryTags, filterSystemReminderMessages, getMemoryRunState, getMemoryTokenBoundary, getThreadOMMetadata, groupLinkedToolMessages, isAfterMemoryTokenBoundary, isObservationalMemoryEnabled, isSystemReminderMessage, isThreadTitlePinned, isWorkingMemoryToolName, loadMessageHistory, memoryDefaultOptions, messageDeclaresAuthoredTurn, messageVectorId, normalizeMessageHistoryConfig, parseMemoryRequestContext, removeSystemReminderTags, removeWorkingMemoryTags, removeWorkingMemoryToolInvocationParts, removeWorkingMemoryToolInvocations, resolveMaxChunkChars, sealTurnMarkup, sealUserTurnMessage, setThreadOMMetadata, stripClientAuthoredTurnMarks, upsertMessageVectors };
@@ -4,7 +4,7 @@ import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "./error-
4
4
  import { n as executeWithContextSync, t as executeWithContext } from "./utils-DU_pU5SK.js";
5
5
  import { _ as resolveObservabilityContext } from "./observability-DPDWibyH.js";
6
6
  import { isStandardSchemaWithJSON, standardSchemaToJSONSchema, toStandardSchema } from "./schema/index.js";
7
- import { i as delay, u as isZodType$1 } from "./utils-B-UrrqES.js";
7
+ import { i as delay, u as isZodType$1 } from "./utils-Dl5BqcZO.js";
8
8
  import { i as isZodArray, t as getZodDef } from "./zod-utils-BDDS_mxU.js";
9
9
  import { AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, GoogleSchemaCompatLayer, MetaSchemaCompatLayer, OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, applyCompatLayer, jsonSchema } from "@mastra/schema-compat";
10
10
  // src/stream/aisdk/v4/usage.ts
@@ -3,7 +3,7 @@ const require_base = require("./base-BIzR1D3_.cjs");
3
3
  const require_error = require("./error-D90lJ6M7.cjs");
4
4
  const require_utils = require("./utils-D-eNsgDM.cjs");
5
5
  const require_observability = require("./observability-VaoaeadK.cjs");
6
- const require_utils$1 = require("./utils-AfuTYtPM.cjs");
6
+ const require_utils$1 = require("./utils-Ag63fN_T.cjs");
7
7
  const require_zod_utils = require("./zod-utils-Cl5jw5N_.cjs");
8
8
  let _mastra_schema_compat = require("@mastra/schema-compat");
9
9
  let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
@@ -29127,7 +29127,7 @@ function createOpenRouter(options = {}) {
29127
29127
  }
29128
29128
  createOpenRouter({ compatibility: "strict" });
29129
29129
  // src/llm/model/gateways/constants.ts
29130
- const MASTRA_USER_AGENT = `mastra/1.87.0-alpha.21`;
29130
+ const MASTRA_USER_AGENT = `mastra/1.87.0-alpha.22`;
29131
29131
  const PROVIDERS_WITH_INSTALLED_PACKAGES = [
29132
29132
  "anthropic",
29133
29133
  "cerebras",
@@ -29126,7 +29126,7 @@ function createOpenRouter(options = {}) {
29126
29126
  }
29127
29127
  createOpenRouter({ compatibility: "strict" });
29128
29128
  // src/llm/model/gateways/constants.ts
29129
- const MASTRA_USER_AGENT = `mastra/1.87.0-alpha.21`;
29129
+ const MASTRA_USER_AGENT = `mastra/1.87.0-alpha.22`;
29130
29130
  const PROVIDERS_WITH_INSTALLED_PACKAGES = [
29131
29131
  "anthropic",
29132
29132
  "cerebras",
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_execution_fence = require("../execution-fence-DeR5VB54.cjs");
2
+ const require_execution_fence = require("../execution-fence-C-wa17Wr.cjs");
3
3
  const require_tool = require("../tool-Dn9WSDVn.cjs");
4
4
  let zod_v4 = require("zod/v4");
5
5
  // src/notifications/tool.ts
@@ -1,4 +1,4 @@
1
- import { Br as notificationSignalAttributes, Fr as InMemoryNotificationsStorage, Gr as readNotificationRoutingRequirement, Hr as notificationSummaryContents, Ir as NotificationsStorage, Jr as resolveDeliveryFailureUpdate, Kr as MAX_NOTIFICATION_DELIVERY_ATTEMPTS, Lr as dispatchDueNotifications, Rr as createNotificationSignal, Ur as notificationSummarySignalMetadata, Vr as notificationSignalMetadata, Wr as summarizeNotifications, Yr as resolveNotificationDeliveryDecision, qr as defaultNotificationDeliveryDecision, zr as createNotificationSummarySignal } from "../execution-fence-Yl_-iJxn.js";
1
+ import { Br as notificationSignalAttributes, Fr as InMemoryNotificationsStorage, Gr as readNotificationRoutingRequirement, Hr as notificationSummaryContents, Ir as NotificationsStorage, Jr as resolveDeliveryFailureUpdate, Kr as MAX_NOTIFICATION_DELIVERY_ATTEMPTS, Lr as dispatchDueNotifications, Rr as createNotificationSignal, Ur as notificationSummarySignalMetadata, Vr as notificationSignalMetadata, Wr as summarizeNotifications, Yr as resolveNotificationDeliveryDecision, qr as defaultNotificationDeliveryDecision, zr as createNotificationSummarySignal } from "../execution-fence-DvN3Fwm3.js";
2
2
  import { r as createTool } from "../tool-DIFduuTw.js";
3
3
  import { z } from "zod/v4";
4
4
  // src/notifications/tool.ts
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_execution_fence = require("../execution-fence-DeR5VB54.cjs");
2
+ const require_execution_fence = require("../execution-fence-C-wa17Wr.cjs");
3
3
  let zod_v4 = require("zod/v4");
4
4
  // src/processor-provider/types.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { $o as TokenLimiterProcessor, Jo as ToolCallFilter, Qo as SystemPromptScrubber, ds as PIIDetector, fs as PromptInjectionDetector, ms as UnicodeNormalizer, os as BatchPartsProcessor, ps as ModerationProcessor, us as LanguageDetector } from "../execution-fence-Yl_-iJxn.js";
1
+ import { $o as TokenLimiterProcessor, Jo as ToolCallFilter, Qo as SystemPromptScrubber, ds as PIIDetector, fs as PromptInjectionDetector, ms as UnicodeNormalizer, os as BatchPartsProcessor, ps as ModerationProcessor, us as LanguageDetector } from "../execution-fence-DvN3Fwm3.js";
2
2
  import { z } from "zod/v4";
3
3
  // src/processor-provider/types.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_stream = require("../stream-C4XcOMuS.cjs");
3
- const require_execution_fence = require("../execution-fence-DeR5VB54.cjs");
2
+ const require_stream = require("../stream-BKEfY3-X.cjs");
3
+ const require_execution_fence = require("../execution-fence-C-wa17Wr.cjs");
4
4
  exports.AgentsMDInjector = require_execution_fence.AgentsMDInjector;
5
5
  exports.BaseProcessor = require_execution_fence.BaseProcessor;
6
6
  exports.BatchPartsProcessor = require_execution_fence.BatchPartsProcessor;
@@ -1,3 +1,3 @@
1
- import { H as anthropicToolIdFormat, K as REPROCESS_PART_KEY, M as ProcessorRunner, N as ProcessorState, U as cerebrasStripReasoningContent, V as ProviderHistoryCompat, W as openaiOrphanItemId, it as createProcessorSendSignal, ln as isProcessorWorkflow } from "../stream-Dgsrva80.js";
2
- import { $l as ProcessorOutputStreamPhaseSchema, $o as TokenLimiterProcessor, Bo as ResponseCache, Cs as isRetryableOpenAIResponsesStreamError, Gl as MessageContentSchema, Gn as WorkingMemory, Go as formatSkillsCatalog, Hn as MemoryInputFilter, Ho as WorkspaceInstructionsProcessor, Io as createBackgroundWorkSignalProcessor, Jl as ProcessorInputStepPhaseSchema, Jo as ToolCallFilter, Kl as MessagePartSchema, Kn as MessageHistory, Ko as ToolSearchProcessor, Lo as CyberRefusalHandler, Ql as ProcessorOutputStepPhaseSchema, Qo as SystemPromptScrubber, Ro as DEFAULT_RESPONSE_CACHE_TTL_SECONDS, Ss as isBadRequestError, Ul as FilePartSchema, Un as SemanticRecall, Uo as SkillSearchProcessor, Vn as BaseProcessor, Vo as buildResponseCacheKey, Wl as ImagePartSchema, Wn as globalEmbeddingCache, Wo as SkillsProcessor, Xl as ProcessorMessageSchema, Xo as CostGuardProcessor, Yl as ProcessorMessageContentSchema, Yo as RegexFilterProcessor, Zl as ProcessorOutputResultPhaseSchema, Zo as TokenCostControl, _s as isMalformedFunctionCallError, au as StepStartPartSchema, bs as FILE_UPLOAD_ERROR_CODES, cs as ClassifierProcessor, ds as PIIDetector, eu as ProcessorStepInputSchema, fs as PromptInjectionDetector, gs as defaultStabilityErrorProcessors, hs as STABILITY_ERROR_PROCESSOR_IDS, iu as SourcePartSchema, ls as StructuredOutputProcessor, ms as UnicodeNormalizer, nu as ProcessorStepSchema, os as BatchPartsProcessor, ou as TextPartSchema, ps as ModerationProcessor, ql as ProcessorInputPhaseSchema, qo as AgentsMDInjector, ru as ReasoningPartSchema, ss as ModelSelectionProcessor, su as ToolInvocationPartSchema, tu as ProcessorStepOutputSchema, us as LanguageDetector, vs as UnsupportedFileHandler, ws as PrefillErrorHandler, xs as StreamErrorRetryProcessor, ys as FileUploadProcessor, zo as RESPONSE_CACHE_CONTEXT_KEY } from "../execution-fence-Yl_-iJxn.js";
1
+ import { H as anthropicToolIdFormat, K as REPROCESS_PART_KEY, M as ProcessorRunner, N as ProcessorState, U as cerebrasStripReasoningContent, V as ProviderHistoryCompat, W as openaiOrphanItemId, it as createProcessorSendSignal, ln as isProcessorWorkflow } from "../stream-CyaGm-DI.js";
2
+ import { $l as ProcessorOutputStreamPhaseSchema, $o as TokenLimiterProcessor, Bo as ResponseCache, Cs as isRetryableOpenAIResponsesStreamError, Gl as MessageContentSchema, Gn as WorkingMemory, Go as formatSkillsCatalog, Hn as MemoryInputFilter, Ho as WorkspaceInstructionsProcessor, Io as createBackgroundWorkSignalProcessor, Jl as ProcessorInputStepPhaseSchema, Jo as ToolCallFilter, Kl as MessagePartSchema, Kn as MessageHistory, Ko as ToolSearchProcessor, Lo as CyberRefusalHandler, Ql as ProcessorOutputStepPhaseSchema, Qo as SystemPromptScrubber, Ro as DEFAULT_RESPONSE_CACHE_TTL_SECONDS, Ss as isBadRequestError, Ul as FilePartSchema, Un as SemanticRecall, Uo as SkillSearchProcessor, Vn as BaseProcessor, Vo as buildResponseCacheKey, Wl as ImagePartSchema, Wn as globalEmbeddingCache, Wo as SkillsProcessor, Xl as ProcessorMessageSchema, Xo as CostGuardProcessor, Yl as ProcessorMessageContentSchema, Yo as RegexFilterProcessor, Zl as ProcessorOutputResultPhaseSchema, Zo as TokenCostControl, _s as isMalformedFunctionCallError, au as StepStartPartSchema, bs as FILE_UPLOAD_ERROR_CODES, cs as ClassifierProcessor, ds as PIIDetector, eu as ProcessorStepInputSchema, fs as PromptInjectionDetector, gs as defaultStabilityErrorProcessors, hs as STABILITY_ERROR_PROCESSOR_IDS, iu as SourcePartSchema, ls as StructuredOutputProcessor, ms as UnicodeNormalizer, nu as ProcessorStepSchema, os as BatchPartsProcessor, ou as TextPartSchema, ps as ModerationProcessor, ql as ProcessorInputPhaseSchema, qo as AgentsMDInjector, ru as ReasoningPartSchema, ss as ModelSelectionProcessor, su as ToolInvocationPartSchema, tu as ProcessorStepOutputSchema, us as LanguageDetector, vs as UnsupportedFileHandler, ws as PrefillErrorHandler, xs as StreamErrorRetryProcessor, ys as FileUploadProcessor, zo as RESPONSE_CACHE_CONTEXT_KEY } from "../execution-fence-DvN3Fwm3.js";
3
3
  export { AgentsMDInjector, BaseProcessor, BatchPartsProcessor, ClassifierProcessor, CostGuardProcessor, CyberRefusalHandler, DEFAULT_RESPONSE_CACHE_TTL_SECONDS, FILE_UPLOAD_ERROR_CODES, FilePartSchema, FileUploadProcessor, ImagePartSchema, LanguageDetector, MemoryInputFilter, MessageContentSchema, MessageHistory, MessagePartSchema, ModelSelectionProcessor, ModerationProcessor, PIIDetector, PrefillErrorHandler, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ProviderHistoryCompat, REPROCESS_PART_KEY, RESPONSE_CACHE_CONTEXT_KEY, ReasoningPartSchema, RegexFilterProcessor, ResponseCache, STABILITY_ERROR_PROCESSOR_IDS, SemanticRecall, SkillSearchProcessor, SkillsProcessor, SourcePartSchema, StepStartPartSchema, StreamErrorRetryProcessor, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenCostControl, TokenLimiterProcessor as TokenLimiter, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, ToolSearchProcessor, UnicodeNormalizer, UnsupportedFileHandler, WorkingMemory, WorkspaceInstructionsProcessor, anthropicToolIdFormat, buildResponseCacheKey, cerebrasStripReasoningContent, createBackgroundWorkSignalProcessor, createProcessorSendSignal, defaultStabilityErrorProcessors, formatSkillsCatalog, globalEmbeddingCache, isBadRequestError, isMalformedFunctionCallError, isProcessorWorkflow, isRetryableOpenAIResponsesStreamError, openaiOrphanItemId };
@@ -1,6 +1,7 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BrhgMLW6.cjs");
2
- const require_netlify = require("./netlify-KyTDrIQP.cjs");
2
+ const require_netlify = require("./netlify-BMhDN9E8.cjs");
3
3
  const require_error = require("./error-D90lJ6M7.cjs");
4
+ const require_mastra_gateway_provider_tools = require("./mastra-gateway-provider-tools-WpH3Tmu4.cjs");
4
5
  let os = require("os");
5
6
  os = require_rolldown_runtime.__toESM(os, 1);
6
7
  let fs = require("fs");
@@ -8,50 +9,6 @@ fs = require_rolldown_runtime.__toESM(fs, 1);
8
9
  let module$1 = require("module");
9
10
  let path = require("path");
10
11
  path = require_rolldown_runtime.__toESM(path, 1);
11
- // src/llm/model/mastra-gateway-provider-tools.ts
12
- const OPENROUTER_WEB_SEARCH_TOOL_ID = "openrouter.web_search";
13
- const NATIVE_WEB_SEARCH_TOOL_IDS = {
14
- "openai.web_search": true,
15
- "anthropic.web_search_20250305": true,
16
- "google.google_search": true,
17
- "xai.web_search": true
18
- };
19
- /**
20
- * The Mastra gateway's chat endpoint only runs `openrouter:*` server tools. Another provider's
21
- * native tool is rejected with a 400 (OpenAI, xAI models) or dropped without an error (Anthropic,
22
- * Google models), so the model silently loses the tool.
23
- *
24
- * A native web search tool with no arguments is swapped for the gateway's web search, which works
25
- * for every tool-calling model. Any other native tool fails here with an actionable message.
26
- */
27
- function prepareToolsForMastraGateway(options, routerId) {
28
- const isProviderTool = (tool) => tool.type === "provider-defined" || tool.type === "provider";
29
- if (!options.tools?.some(isProviderTool)) return options;
30
- const tools = options.tools.map((tool) => {
31
- if (!isProviderTool(tool)) return tool;
32
- const { id, args } = tool;
33
- if (id.startsWith("openrouter.")) return tool;
34
- const isWebSearch = id in NATIVE_WEB_SEARCH_TOOL_IDS;
35
- if (isWebSearch && Object.keys(args ?? {}).length === 0) return {
36
- ...tool,
37
- id: OPENROUTER_WEB_SEARCH_TOOL_ID
38
- };
39
- throw new require_error.MastraError({
40
- id: "MASTRA_GATEWAY_UNSUPPORTED_PROVIDER_TOOL",
41
- domain: require_error.ErrorDomain.LLM,
42
- category: require_error.ErrorCategory.USER,
43
- details: {
44
- toolId: id,
45
- model: routerId
46
- },
47
- text: `The provider tool "${id}" cannot be used with "${routerId}". The Mastra gateway only runs its own server tools. ` + (isWebSearch ? `Its web search does not accept "${id}" options: use webSearchTool from @mastra/core/tools, or call the provider directly to keep them.` : `Call the provider directly to use this tool.`)
48
- });
49
- });
50
- return {
51
- ...options,
52
- tools
53
- };
54
- }
55
12
  // src/llm/model/gateways/mastra.ts
56
13
  var mastra_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ MastraGateway: () => MastraGateway });
57
14
  /**
@@ -92,9 +49,9 @@ function gatewayServesObservationalMemory(apiKey) {
92
49
  function withGatewayProviderTools(model, routerId) {
93
50
  const doGenerate = model.doGenerate.bind(model);
94
51
  const doStream = model.doStream.bind(model);
95
- model.doGenerate = async (options) => doGenerate(prepareToolsForMastraGateway(options, routerId));
96
- model.doStream = async (options) => doStream(prepareToolsForMastraGateway(options, routerId));
97
- return model;
52
+ model.doGenerate = async (options) => doGenerate(require_mastra_gateway_provider_tools.prepareToolsForMastraGateway(options, routerId));
53
+ model.doStream = async (options) => doStream(require_mastra_gateway_provider_tools.prepareToolsForMastraGateway(options, routerId));
54
+ return require_mastra_gateway_provider_tools.markMastraGatewayChatModel(model);
98
55
  }
99
56
  var MastraGateway = class extends require_netlify.MastraModelGateway {
100
57
  config;
@@ -24350,10 +24307,10 @@ var GatewayRegistry = class GatewayRegistry {
24350
24307
  if (this.isRefreshing && !forceRefresh) return;
24351
24308
  this.isRefreshing = true;
24352
24309
  try {
24353
- const { ModelsDevGateway } = await Promise.resolve().then(() => require("./netlify-KyTDrIQP.cjs")).then((n) => n.models_dev_exports);
24354
- const { NetlifyGateway } = await Promise.resolve().then(() => require("./netlify-KyTDrIQP.cjs")).then((n) => n.netlify_exports);
24310
+ const { ModelsDevGateway } = await Promise.resolve().then(() => require("./netlify-BMhDN9E8.cjs")).then((n) => n.models_dev_exports);
24311
+ const { NetlifyGateway } = await Promise.resolve().then(() => require("./netlify-BMhDN9E8.cjs")).then((n) => n.netlify_exports);
24355
24312
  const { MastraGateway } = await Promise.resolve().then(() => mastra_exports);
24356
- const { fetchProvidersFromGateways, writeRegistryFiles } = await Promise.resolve().then(() => require("./registry-generator-BBmRjrp4.cjs"));
24313
+ const { fetchProvidersFromGateways, writeRegistryFiles } = await Promise.resolve().then(() => require("./registry-generator-DRFJTQ2Q.cjs"));
24357
24314
  const { providers, models, attachmentCapabilities, temperatureCapabilities, structuredOutputCapabilities, reasoningCapabilities, failedGateways } = await fetchProvidersFromGateways([...[
24358
24315
  new ModelsDevGateway({}),
24359
24316
  new NetlifyGateway(),
@@ -1,54 +1,11 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-tIEjjQTE.js";
2
- import { d as GATEWAY_AUTH_HEADER, f as MASTRA_USER_AGENT, g as getGatewayId, m as createAnthropic, p as createOpenRouter, r as ModelsDevGateway, t as NetlifyGateway, v as shouldEnableGateway, x as MastraModelGateway, y as getCapabilityFileName } from "./netlify-CoThk6uD.js";
3
- import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "./error-oh2DLsP2.js";
2
+ import { d as GATEWAY_AUTH_HEADER, f as MASTRA_USER_AGENT, g as getGatewayId, m as createAnthropic, p as createOpenRouter, r as ModelsDevGateway, t as NetlifyGateway, v as shouldEnableGateway, x as MastraModelGateway, y as getCapabilityFileName } from "./netlify-xMA06xL8.js";
3
+ import { i as MastraError } from "./error-oh2DLsP2.js";
4
+ import { i as prepareToolsForMastraGateway, r as markMastraGatewayChatModel } from "./mastra-gateway-provider-tools-C-AjGZis.js";
4
5
  import { createRequire } from "module";
5
6
  import os from "os";
6
7
  import fs from "fs";
7
8
  import path from "path";
8
- // src/llm/model/mastra-gateway-provider-tools.ts
9
- const OPENROUTER_WEB_SEARCH_TOOL_ID = "openrouter.web_search";
10
- const NATIVE_WEB_SEARCH_TOOL_IDS = {
11
- "openai.web_search": true,
12
- "anthropic.web_search_20250305": true,
13
- "google.google_search": true,
14
- "xai.web_search": true
15
- };
16
- /**
17
- * The Mastra gateway's chat endpoint only runs `openrouter:*` server tools. Another provider's
18
- * native tool is rejected with a 400 (OpenAI, xAI models) or dropped without an error (Anthropic,
19
- * Google models), so the model silently loses the tool.
20
- *
21
- * A native web search tool with no arguments is swapped for the gateway's web search, which works
22
- * for every tool-calling model. Any other native tool fails here with an actionable message.
23
- */
24
- function prepareToolsForMastraGateway(options, routerId) {
25
- const isProviderTool = (tool) => tool.type === "provider-defined" || tool.type === "provider";
26
- if (!options.tools?.some(isProviderTool)) return options;
27
- const tools = options.tools.map((tool) => {
28
- if (!isProviderTool(tool)) return tool;
29
- const { id, args } = tool;
30
- if (id.startsWith("openrouter.")) return tool;
31
- const isWebSearch = id in NATIVE_WEB_SEARCH_TOOL_IDS;
32
- if (isWebSearch && Object.keys(args ?? {}).length === 0) return {
33
- ...tool,
34
- id: OPENROUTER_WEB_SEARCH_TOOL_ID
35
- };
36
- throw new MastraError({
37
- id: "MASTRA_GATEWAY_UNSUPPORTED_PROVIDER_TOOL",
38
- domain: ErrorDomain.LLM,
39
- category: ErrorCategory.USER,
40
- details: {
41
- toolId: id,
42
- model: routerId
43
- },
44
- text: `The provider tool "${id}" cannot be used with "${routerId}". The Mastra gateway only runs its own server tools. ` + (isWebSearch ? `Its web search does not accept "${id}" options: use webSearchTool from @mastra/core/tools, or call the provider directly to keep them.` : `Call the provider directly to use this tool.`)
45
- });
46
- });
47
- return {
48
- ...options,
49
- tools
50
- };
51
- }
52
9
  // src/llm/model/gateways/mastra.ts
53
10
  var mastra_exports = /* @__PURE__ */ __exportAll({ MastraGateway: () => MastraGateway });
54
11
  /**
@@ -91,7 +48,7 @@ function withGatewayProviderTools(model, routerId) {
91
48
  const doStream = model.doStream.bind(model);
92
49
  model.doGenerate = async (options) => doGenerate(prepareToolsForMastraGateway(options, routerId));
93
50
  model.doStream = async (options) => doStream(prepareToolsForMastraGateway(options, routerId));
94
- return model;
51
+ return markMastraGatewayChatModel(model);
95
52
  }
96
53
  var MastraGateway = class extends MastraModelGateway {
97
54
  config;
@@ -24347,10 +24304,10 @@ var GatewayRegistry = class GatewayRegistry {
24347
24304
  if (this.isRefreshing && !forceRefresh) return;
24348
24305
  this.isRefreshing = true;
24349
24306
  try {
24350
- const { ModelsDevGateway } = await import("./netlify-CoThk6uD.js").then((n) => n.i);
24351
- const { NetlifyGateway } = await import("./netlify-CoThk6uD.js").then((n) => n.n);
24307
+ const { ModelsDevGateway } = await import("./netlify-xMA06xL8.js").then((n) => n.i);
24308
+ const { NetlifyGateway } = await import("./netlify-xMA06xL8.js").then((n) => n.n);
24352
24309
  const { MastraGateway } = await Promise.resolve().then(() => mastra_exports);
24353
- const { fetchProvidersFromGateways, writeRegistryFiles } = await import("./registry-generator-BXZzqm-j.js");
24310
+ const { fetchProvidersFromGateways, writeRegistryFiles } = await import("./registry-generator-CXDt3yuY.js");
24354
24311
  const { providers, models, attachmentCapabilities, temperatureCapabilities, structuredOutputCapabilities, reasoningCapabilities, failedGateways } = await fetchProvidersFromGateways([...[
24355
24312
  new ModelsDevGateway({}),
24356
24313
  new NetlifyGateway(),
@@ -1,4 +1,4 @@
1
- import { g as getGatewayId, v as shouldEnableGateway, y as getCapabilityFileName } from "./netlify-CoThk6uD.js";
1
+ import { g as getGatewayId, v as shouldEnableGateway, y as getCapabilityFileName } from "./netlify-xMA06xL8.js";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
4
  // src/llm/model/registry-generator.ts
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BrhgMLW6.cjs");
2
- const require_netlify = require("./netlify-KyTDrIQP.cjs");
2
+ const require_netlify = require("./netlify-BMhDN9E8.cjs");
3
3
  let path = require("path");
4
4
  path = require_rolldown_runtime.__toESM(path, 1);
5
5
  let fs_promises = require("fs/promises");
@@ -1,6 +1,6 @@
1
- import { Ds as createEventedWorkflow, Es as cloneWorkflow, Ic as mapVariable, Lc as predicateToCondition, Os as createWorkflow, al as createStepFromTool, rl as createStepFromAgent, yl as getSingleStepEntryId } from "./execution-fence-Yl_-iJxn.js";
1
+ import { Ds as createEventedWorkflow, Es as cloneWorkflow, Ic as mapVariable, Lc as predicateToCondition, Os as createWorkflow, al as createStepFromTool, rl as createStepFromAgent, yl as getSingleStepEntryId } from "./execution-fence-DvN3Fwm3.js";
2
2
  import { derivePredicateLabel } from "./predicate/index.js";
3
- import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-zLPo00kk.js";
3
+ import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-CYqPJX3z.js";
4
4
  import { standardSchemaToJSONSchema, toStandardSchema } from "./schema/index.js";
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- const require_execution_fence = require("./execution-fence-DeR5VB54.cjs");
1
+ const require_execution_fence = require("./execution-fence-C-wa17Wr.cjs");
2
2
  const require_predicate_index = require("./predicate/index.cjs");
3
- const require_validate = require("./validate-GzP07CVb.cjs");
3
+ const require_validate = require("./validate-bRsKfPrD.cjs");
4
4
  let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_execution_fence = require("../execution-fence-DeR5VB54.cjs");
3
- const require_stream = require("../stream-C4XcOMuS.cjs");
2
+ const require_execution_fence = require("../execution-fence-C-wa17Wr.cjs");
3
+ const require_stream = require("../stream-BKEfY3-X.cjs");
4
4
  // src/relevance/relevance-score-provider.ts
5
5
  function createSimilarityPrompt(query, text) {
6
6
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -1,5 +1,5 @@
1
- import { T as Agent } from "../execution-fence-Yl_-iJxn.js";
2
- import { un as isSupportedLanguageModel } from "../stream-Dgsrva80.js";
1
+ import { T as Agent } from "../execution-fence-DvN3Fwm3.js";
2
+ import { un as isSupportedLanguageModel } from "../stream-CyaGm-DI.js";
3
3
  // src/relevance/relevance-score-provider.ts
4
4
  function createSimilarityPrompt(query, text) {
5
5
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_stream = require("../stream-C4XcOMuS.cjs");
3
- const require_execution_fence = require("../execution-fence-DeR5VB54.cjs");
2
+ const require_stream = require("../stream-BKEfY3-X.cjs");
3
+ const require_execution_fence = require("../execution-fence-C-wa17Wr.cjs");
4
4
  const require_observability = require("../observability-VaoaeadK.cjs");
5
5
  const require_storage = require("../storage-CfG0I2aF.cjs");
6
6
  const require_constants = require("../constants-B2FVV_2e.cjs");