@mastra/core 1.2.0 → 1.2.1-alpha.0

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 (406) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +30 -17
  3. package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +10 -7
  4. package/dist/agent/index.cjs +13 -13
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/index.cjs +18 -18
  7. package/dist/agent/message-list/index.js +1 -1
  8. package/dist/{chunk-VBOO4F4D.cjs → chunk-2DMSFLJY.cjs} +5 -5
  9. package/dist/{chunk-VBOO4F4D.cjs.map → chunk-2DMSFLJY.cjs.map} +1 -1
  10. package/dist/{chunk-ARQG4ZSD.cjs → chunk-5SOS47PH.cjs} +37 -37
  11. package/dist/chunk-5SOS47PH.cjs.map +1 -0
  12. package/dist/{chunk-NRMSZFAU.js → chunk-5YVR7B4R.js} +5 -5
  13. package/dist/{chunk-NRMSZFAU.js.map → chunk-5YVR7B4R.js.map} +1 -1
  14. package/dist/{chunk-G5NRZOPO.cjs → chunk-7MDVYPWX.cjs} +4 -4
  15. package/dist/{chunk-G5NRZOPO.cjs.map → chunk-7MDVYPWX.cjs.map} +1 -1
  16. package/dist/{chunk-AP3Z4EAP.cjs → chunk-A5QFWX67.cjs} +53 -53
  17. package/dist/{chunk-AP3Z4EAP.cjs.map → chunk-A5QFWX67.cjs.map} +1 -1
  18. package/dist/{chunk-4XLGMCCQ.js → chunk-AUF6U2BL.js} +3 -3
  19. package/dist/{chunk-4XLGMCCQ.js.map → chunk-AUF6U2BL.js.map} +1 -1
  20. package/dist/{chunk-POKH6N2J.cjs → chunk-AXN5P2GE.cjs} +4 -4
  21. package/dist/{chunk-POKH6N2J.cjs.map → chunk-AXN5P2GE.cjs.map} +1 -1
  22. package/dist/{chunk-YL6ETQ5I.cjs → chunk-B4M33FCS.cjs} +9 -9
  23. package/dist/{chunk-YL6ETQ5I.cjs.map → chunk-B4M33FCS.cjs.map} +1 -1
  24. package/dist/{chunk-DG6C6ZTL.cjs → chunk-CC3OOESY.cjs} +44 -43
  25. package/dist/chunk-CC3OOESY.cjs.map +1 -0
  26. package/dist/{chunk-NYC6PYZF.js → chunk-E3VFKTIA.js} +36 -4
  27. package/dist/chunk-E3VFKTIA.js.map +1 -0
  28. package/dist/{chunk-3LRUJTH3.cjs → chunk-GVLPTDJA.cjs} +50 -13
  29. package/dist/chunk-GVLPTDJA.cjs.map +1 -0
  30. package/dist/{chunk-SS4AZHZW.cjs → chunk-HU2ONA2W.cjs} +9 -9
  31. package/dist/{chunk-SS4AZHZW.cjs.map → chunk-HU2ONA2W.cjs.map} +1 -1
  32. package/dist/chunk-HVG7MWNT.js +439 -0
  33. package/dist/chunk-HVG7MWNT.js.map +1 -0
  34. package/dist/chunk-JCEP2VPF.cjs +441 -0
  35. package/dist/chunk-JCEP2VPF.cjs.map +1 -0
  36. package/dist/{chunk-PPAJGWVW.js → chunk-MSWXEOZC.js} +3 -3
  37. package/dist/{chunk-PPAJGWVW.js.map → chunk-MSWXEOZC.js.map} +1 -1
  38. package/dist/{chunk-AQHO4OC2.cjs → chunk-QOFI2WBM.cjs} +6 -6
  39. package/dist/{chunk-AQHO4OC2.cjs.map → chunk-QOFI2WBM.cjs.map} +1 -1
  40. package/dist/{chunk-EY3WXGUD.js → chunk-RXD5EGQF.js} +43 -6
  41. package/dist/chunk-RXD5EGQF.js.map +1 -0
  42. package/dist/{chunk-XC7WIZBL.js → chunk-S6BH5HHY.js} +4 -3
  43. package/dist/chunk-S6BH5HHY.js.map +1 -0
  44. package/dist/{chunk-IPXNR6RQ.js → chunk-V2MLGA7T.js} +1884 -998
  45. package/dist/chunk-V2MLGA7T.js.map +1 -0
  46. package/dist/{chunk-Z4PGSIZ5.cjs → chunk-VTE2OBKS.cjs} +1890 -1004
  47. package/dist/chunk-VTE2OBKS.cjs.map +1 -0
  48. package/dist/{chunk-ZODRDMZ7.js → chunk-VX7UA3SO.js} +3 -3
  49. package/dist/{chunk-ZODRDMZ7.js.map → chunk-VX7UA3SO.js.map} +1 -1
  50. package/dist/{chunk-5HDIPOLV.js → chunk-WFUNLRQX.js} +6 -6
  51. package/dist/chunk-WFUNLRQX.js.map +1 -0
  52. package/dist/{chunk-V3LENMEW.js → chunk-X5ORARLG.js} +4 -4
  53. package/dist/{chunk-V3LENMEW.js.map → chunk-X5ORARLG.js.map} +1 -1
  54. package/dist/{chunk-Z2OKCLGV.cjs → chunk-XCPEEIHI.cjs} +41 -8
  55. package/dist/chunk-XCPEEIHI.cjs.map +1 -0
  56. package/dist/{chunk-57O4TPB3.js → chunk-Z6NRYYOH.js} +3 -3
  57. package/dist/{chunk-57O4TPB3.js.map → chunk-Z6NRYYOH.js.map} +1 -1
  58. package/dist/{chunk-RUMXBL6P.js → chunk-ZWM2CAIM.js} +5 -5
  59. package/dist/{chunk-RUMXBL6P.js.map → chunk-ZWM2CAIM.js.map} +1 -1
  60. package/dist/docs/SKILL.md +270 -64
  61. package/dist/docs/{SOURCE_MAP.json → assets/SOURCE_MAP.json} +156 -152
  62. package/dist/docs/{agents/10-adding-voice.md → references/docs-agents-adding-voice.md} +6 -5
  63. package/dist/docs/{agents/08-agent-approval.md → references/docs-agents-agent-approval.md} +19 -19
  64. package/dist/docs/{agents/03-agent-memory.md → references/docs-agents-agent-memory.md} +57 -55
  65. package/dist/docs/{agents/07-guardrails.md → references/docs-agents-guardrails.md} +21 -39
  66. package/dist/docs/{agents/09-network-approval.md → references/docs-agents-network-approval.md} +12 -11
  67. package/dist/docs/{agents/05-networks.md → references/docs-agents-networks.md} +7 -9
  68. package/dist/docs/{agents/01-overview.md → references/docs-agents-overview.md} +54 -72
  69. package/dist/docs/{agents/06-processors.md → references/docs-agents-processors.md} +29 -24
  70. package/dist/docs/{agents/04-structured-output.md → references/docs-agents-structured-output.md} +13 -22
  71. package/dist/docs/{agents/02-using-tools.md → references/docs-agents-using-tools.md} +12 -13
  72. package/dist/docs/{evals/02-custom-scorers.md → references/docs-evals-custom-scorers.md} +5 -7
  73. package/dist/docs/{evals/01-overview.md → references/docs-evals-overview.md} +26 -17
  74. package/dist/docs/{evals/03-running-in-ci.md → references/docs-evals-running-in-ci.md} +2 -4
  75. package/dist/docs/{mcp/01-overview.md → references/docs-mcp-overview.md} +135 -140
  76. package/dist/docs/references/docs-mcp-publishing-mcp-server.md +95 -0
  77. package/dist/docs/{memory/05-memory-processors.md → references/docs-memory-memory-processors.md} +6 -8
  78. package/dist/docs/references/docs-memory-observational-memory.md +166 -0
  79. package/dist/docs/{memory/01-overview.md → references/docs-memory-overview.md} +8 -8
  80. package/dist/docs/{memory/04-semantic-recall.md → references/docs-memory-semantic-recall.md} +33 -17
  81. package/dist/docs/{memory/02-storage.md → references/docs-memory-storage.md} +29 -39
  82. package/dist/docs/{memory/03-working-memory.md → references/docs-memory-working-memory.md} +16 -27
  83. package/dist/docs/{observability/02-logging.md → references/docs-observability-logging.md} +6 -10
  84. package/dist/docs/{observability/01-overview.md → references/docs-observability-overview.md} +4 -10
  85. package/dist/docs/{observability/04-otel.md → references/docs-observability-tracing-bridges-otel.md} +31 -14
  86. package/dist/docs/{observability/07-arize.md → references/docs-observability-tracing-exporters-arize.md} +38 -22
  87. package/dist/docs/{observability/08-braintrust.md → references/docs-observability-tracing-exporters-braintrust.md} +24 -6
  88. package/dist/docs/{observability/06-cloud.md → references/docs-observability-tracing-exporters-cloud.md} +7 -7
  89. package/dist/docs/{observability/09-datadog.md → references/docs-observability-tracing-exporters-datadog.md} +26 -8
  90. package/dist/docs/{observability/05-default.md → references/docs-observability-tracing-exporters-default.md} +11 -14
  91. package/dist/docs/{observability/10-laminar.md → references/docs-observability-tracing-exporters-laminar.md} +24 -6
  92. package/dist/docs/{observability/11-langfuse.md → references/docs-observability-tracing-exporters-langfuse.md} +31 -12
  93. package/dist/docs/{observability/12-langsmith.md → references/docs-observability-tracing-exporters-langsmith.md} +29 -11
  94. package/dist/docs/{observability/13-otel.md → references/docs-observability-tracing-exporters-otel.md} +107 -63
  95. package/dist/docs/{observability/14-posthog.md → references/docs-observability-tracing-exporters-posthog.md} +24 -6
  96. package/dist/docs/{observability/03-overview.md → references/docs-observability-tracing-overview.md} +45 -53
  97. package/dist/docs/{rag/02-chunking-and-embedding.md → references/docs-rag-chunking-and-embedding.md} +5 -11
  98. package/dist/docs/{rag/05-graph-rag.md → references/docs-rag-graph-rag.md} +0 -2
  99. package/dist/docs/{rag/01-overview.md → references/docs-rag-overview.md} +2 -7
  100. package/dist/docs/{rag/04-retrieval.md → references/docs-rag-retrieval.md} +26 -53
  101. package/dist/docs/{rag/03-vector-databases.md → references/docs-rag-vector-databases.md} +198 -202
  102. package/dist/docs/{server/13-auth0.md → references/docs-server-auth-auth0.md} +68 -79
  103. package/dist/docs/{server/09-clerk.md → references/docs-server-auth-clerk.md} +41 -52
  104. package/dist/docs/{server/14-composite-auth.md → references/docs-server-auth-composite-auth.md} +1 -3
  105. package/dist/docs/{server/15-custom-auth-provider.md → references/docs-server-auth-custom-auth-provider.md} +13 -15
  106. package/dist/docs/{server/11-firebase.md → references/docs-server-auth-firebase.md} +83 -97
  107. package/dist/docs/{server/08-jwt.md → references/docs-server-auth-jwt.md} +46 -35
  108. package/dist/docs/{server/07-simple-auth.md → references/docs-server-auth-simple-auth.md} +10 -11
  109. package/dist/docs/{server/10-supabase.md → references/docs-server-auth-supabase.md} +33 -44
  110. package/dist/docs/{server/12-workos.md → references/docs-server-auth-workos.md} +45 -56
  111. package/dist/docs/{server/02-custom-adapters.md → references/docs-server-custom-adapters.md} +25 -31
  112. package/dist/docs/{server/05-custom-api-routes.md → references/docs-server-custom-api-routes.md} +7 -7
  113. package/dist/docs/{server/06-mastra-client.md → references/docs-server-mastra-client.md} +32 -20
  114. package/dist/docs/{server/01-mastra-server.md → references/docs-server-mastra-server.md} +5 -11
  115. package/dist/docs/{server/03-middleware.md → references/docs-server-middleware.md} +8 -15
  116. package/dist/docs/{server/04-request-context.md → references/docs-server-request-context.md} +29 -43
  117. package/dist/docs/{streaming/01-events.md → references/docs-streaming-events.md} +9 -16
  118. package/dist/docs/{streaming/02-tool-streaming.md → references/docs-streaming-tool-streaming.md} +6 -11
  119. package/dist/docs/{streaming/03-workflow-streaming.md → references/docs-streaming-workflow-streaming.md} +2 -6
  120. package/dist/docs/{tools-mcp/03-advanced-usage.md → references/docs-tools-mcp-advanced-usage.md} +23 -5
  121. package/dist/docs/{tools-mcp/01-mcp-overview.md → references/docs-tools-mcp-mcp-overview.md} +141 -146
  122. package/dist/docs/{tools-mcp/02-overview.md → references/docs-tools-mcp-overview.md} +4 -12
  123. package/dist/docs/{voice/01-overview.md → references/docs-voice-overview.md} +37 -81
  124. package/dist/docs/{voice/04-speech-to-speech.md → references/docs-voice-speech-to-speech.md} +1 -4
  125. package/dist/docs/{voice/03-speech-to-text.md → references/docs-voice-speech-to-text.md} +8 -11
  126. package/dist/docs/{voice/02-text-to-speech.md → references/docs-voice-text-to-speech.md} +12 -15
  127. package/dist/docs/{workflows/04-agents-and-tools.md → references/docs-workflows-agents-and-tools.md} +11 -21
  128. package/dist/docs/{workflows/03-control-flow.md → references/docs-workflows-control-flow.md} +58 -56
  129. package/dist/docs/{workflows/09-error-handling.md → references/docs-workflows-error-handling.md} +13 -15
  130. package/dist/docs/{workflows/07-human-in-the-loop.md → references/docs-workflows-human-in-the-loop.md} +11 -12
  131. package/dist/docs/{workflows/10-input-data-mapping.md → references/docs-workflows-input-data-mapping.md} +12 -14
  132. package/dist/docs/{workflows/01-overview.md → references/docs-workflows-overview.md} +31 -52
  133. package/dist/docs/{workflows/05-snapshots.md → references/docs-workflows-snapshots.md} +3 -5
  134. package/dist/docs/{workflows/06-suspend-and-resume.md → references/docs-workflows-suspend-and-resume.md} +12 -12
  135. package/dist/docs/{workflows/08-time-travel.md → references/docs-workflows-time-travel.md} +2 -5
  136. package/dist/docs/{workflows/02-workflow-state.md → references/docs-workflows-workflow-state.md} +4 -6
  137. package/dist/docs/{workspace/02-filesystem.md → references/docs-workspace-filesystem.md} +3 -8
  138. package/dist/docs/{workspace/01-overview.md → references/docs-workspace-overview.md} +10 -16
  139. package/dist/docs/{workspace/03-sandbox.md → references/docs-workspace-sandbox.md} +2 -4
  140. package/dist/docs/{workspace/05-search.md → references/docs-workspace-search.md} +20 -22
  141. package/dist/docs/{workspace/04-skills.md → references/docs-workspace-skills.md} +6 -9
  142. package/dist/docs/{guides/01-ai-sdk.md → references/guides-agent-frameworks-ai-sdk.md} +25 -9
  143. package/dist/docs/references/reference-agents-agent.md +142 -0
  144. package/dist/docs/references/reference-agents-generate.md +174 -0
  145. package/dist/docs/references/reference-agents-generateLegacy.md +176 -0
  146. package/dist/docs/references/reference-agents-getDefaultGenerateOptions.md +36 -0
  147. package/dist/docs/references/reference-agents-getDefaultOptions.md +34 -0
  148. package/dist/docs/references/reference-agents-getDefaultStreamOptions.md +36 -0
  149. package/dist/docs/references/reference-agents-getDescription.md +21 -0
  150. package/dist/docs/references/reference-agents-getInstructions.md +34 -0
  151. package/dist/docs/references/reference-agents-getLLM.md +37 -0
  152. package/dist/docs/references/reference-agents-getMemory.md +34 -0
  153. package/dist/docs/references/reference-agents-getModel.md +34 -0
  154. package/dist/docs/references/reference-agents-getTools.md +34 -0
  155. package/dist/docs/references/reference-agents-getVoice.md +34 -0
  156. package/dist/docs/references/reference-agents-listAgents.md +35 -0
  157. package/dist/docs/references/reference-agents-listScorers.md +34 -0
  158. package/dist/docs/references/reference-agents-listTools.md +34 -0
  159. package/dist/docs/references/reference-agents-listWorkflows.md +34 -0
  160. package/dist/docs/references/reference-agents-network.md +136 -0
  161. package/dist/docs/references/reference-ai-sdk-chat-route.md +82 -0
  162. package/dist/docs/references/reference-ai-sdk-network-route.md +74 -0
  163. package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +232 -0
  164. package/dist/docs/references/reference-ai-sdk-with-mastra.md +59 -0
  165. package/dist/docs/references/reference-ai-sdk-workflow-route.md +79 -0
  166. package/dist/docs/references/reference-auth-auth0.md +73 -0
  167. package/dist/docs/references/reference-auth-clerk.md +36 -0
  168. package/dist/docs/references/reference-auth-firebase.md +80 -0
  169. package/dist/docs/references/reference-auth-jwt.md +26 -0
  170. package/dist/docs/references/reference-auth-supabase.md +33 -0
  171. package/dist/docs/references/reference-auth-workos.md +84 -0
  172. package/dist/docs/{cli/01-reference.md → references/reference-cli-mastra.md} +14 -28
  173. package/dist/docs/{client-js/01-reference.md → references/reference-client-js-agents.md} +3 -12
  174. package/dist/docs/{configuration.mdx/01-reference.md → references/reference-configuration.md} +71 -91
  175. package/dist/docs/references/reference-core-addGateway.md +42 -0
  176. package/dist/docs/references/reference-core-getAgent.md +21 -0
  177. package/dist/docs/references/reference-core-getAgentById.md +21 -0
  178. package/dist/docs/references/reference-core-getDeployer.md +22 -0
  179. package/dist/docs/references/reference-core-getGateway.md +38 -0
  180. package/dist/docs/references/reference-core-getGatewayById.md +41 -0
  181. package/dist/docs/references/reference-core-getLogger.md +22 -0
  182. package/dist/docs/references/reference-core-getMCPServer.md +45 -0
  183. package/dist/docs/references/reference-core-getMCPServerById.md +53 -0
  184. package/dist/docs/references/reference-core-getMemory.md +50 -0
  185. package/dist/docs/references/reference-core-getScorer.md +54 -0
  186. package/dist/docs/references/reference-core-getScorerById.md +54 -0
  187. package/dist/docs/references/reference-core-getServer.md +22 -0
  188. package/dist/docs/references/reference-core-getStorage.md +22 -0
  189. package/dist/docs/references/reference-core-getStoredAgentById.md +89 -0
  190. package/dist/docs/references/reference-core-getTelemetry.md +22 -0
  191. package/dist/docs/references/reference-core-getVector.md +22 -0
  192. package/dist/docs/references/reference-core-getWorkflow.md +40 -0
  193. package/dist/docs/references/reference-core-listAgents.md +21 -0
  194. package/dist/docs/references/reference-core-listGateways.md +40 -0
  195. package/dist/docs/references/reference-core-listLogs.md +38 -0
  196. package/dist/docs/references/reference-core-listLogsByRunId.md +36 -0
  197. package/dist/docs/references/reference-core-listMCPServers.md +51 -0
  198. package/dist/docs/references/reference-core-listMemory.md +56 -0
  199. package/dist/docs/references/reference-core-listScorers.md +29 -0
  200. package/dist/docs/references/reference-core-listStoredAgents.md +93 -0
  201. package/dist/docs/references/reference-core-listVectors.md +22 -0
  202. package/dist/docs/references/reference-core-listWorkflows.md +21 -0
  203. package/dist/docs/references/reference-core-mastra-class.md +66 -0
  204. package/dist/docs/references/reference-core-mastra-model-gateway.md +153 -0
  205. package/dist/docs/references/reference-core-setLogger.md +26 -0
  206. package/dist/docs/references/reference-core-setStorage.md +27 -0
  207. package/dist/docs/references/reference-deployer-cloudflare.md +56 -0
  208. package/dist/docs/references/reference-deployer-netlify.md +14 -0
  209. package/dist/docs/references/reference-deployer-vercel.md +39 -0
  210. package/dist/docs/references/reference-evals-answer-relevancy.md +105 -0
  211. package/dist/docs/references/reference-evals-answer-similarity.md +99 -0
  212. package/dist/docs/references/reference-evals-bias.md +120 -0
  213. package/dist/docs/references/reference-evals-completeness.md +137 -0
  214. package/dist/docs/references/reference-evals-content-similarity.md +101 -0
  215. package/dist/docs/references/reference-evals-context-precision.md +196 -0
  216. package/dist/docs/references/reference-evals-create-scorer.md +270 -0
  217. package/dist/docs/references/reference-evals-faithfulness.md +114 -0
  218. package/dist/docs/references/reference-evals-hallucination.md +220 -0
  219. package/dist/docs/references/reference-evals-keyword-coverage.md +128 -0
  220. package/dist/docs/references/reference-evals-mastra-scorer.md +123 -0
  221. package/dist/docs/references/reference-evals-run-evals.md +138 -0
  222. package/dist/docs/references/reference-evals-scorer-utils.md +330 -0
  223. package/dist/docs/references/reference-evals-textual-difference.md +113 -0
  224. package/dist/docs/references/reference-evals-tone-consistency.md +119 -0
  225. package/dist/docs/references/reference-evals-toxicity.md +123 -0
  226. package/dist/docs/{logging/01-reference.md → references/reference-logging-pino-logger.md} +16 -15
  227. package/dist/docs/references/reference-memory-deleteMessages.md +40 -0
  228. package/dist/docs/{memory/06-reference.md → references/reference-memory-memory-class.md} +28 -55
  229. package/dist/docs/references/reference-memory-observational-memory.md +217 -0
  230. package/dist/docs/references/reference-observability-tracing-bridges-otel.md +131 -0
  231. package/dist/docs/references/reference-observability-tracing-configuration.md +178 -0
  232. package/dist/docs/references/reference-observability-tracing-exporters-console-exporter.md +138 -0
  233. package/dist/docs/references/reference-observability-tracing-exporters-datadog.md +116 -0
  234. package/dist/docs/references/reference-observability-tracing-instances.md +109 -0
  235. package/dist/docs/references/reference-observability-tracing-interfaces.md +749 -0
  236. package/dist/docs/references/reference-observability-tracing-processors-sensitive-data-filter.md +144 -0
  237. package/dist/docs/references/reference-observability-tracing-spans.md +224 -0
  238. package/dist/docs/references/reference-processors-batch-parts-processor.md +61 -0
  239. package/dist/docs/references/reference-processors-language-detector.md +81 -0
  240. package/dist/docs/references/reference-processors-message-history-processor.md +85 -0
  241. package/dist/docs/references/reference-processors-moderation-processor.md +104 -0
  242. package/dist/docs/references/reference-processors-pii-detector.md +107 -0
  243. package/dist/docs/references/reference-processors-processor-interface.md +521 -0
  244. package/dist/docs/references/reference-processors-prompt-injection-detector.md +71 -0
  245. package/dist/docs/references/reference-processors-semantic-recall-processor.md +123 -0
  246. package/dist/docs/references/reference-processors-system-prompt-scrubber.md +80 -0
  247. package/dist/docs/references/reference-processors-token-limiter-processor.md +113 -0
  248. package/dist/docs/references/reference-processors-tool-call-filter.md +85 -0
  249. package/dist/docs/references/reference-processors-tool-search-processor.md +113 -0
  250. package/dist/docs/references/reference-processors-unicode-normalizer.md +62 -0
  251. package/dist/docs/references/reference-processors-working-memory-processor.md +154 -0
  252. package/dist/docs/references/reference-rag-database-config.md +264 -0
  253. package/dist/docs/references/reference-rag-embeddings.md +92 -0
  254. package/dist/docs/references/reference-server-mastra-server.md +298 -0
  255. package/dist/docs/references/reference-server-register-api-route.md +249 -0
  256. package/dist/docs/references/reference-storage-cloudflare-d1.md +218 -0
  257. package/dist/docs/references/reference-storage-composite.md +235 -0
  258. package/dist/docs/references/reference-storage-lance.md +131 -0
  259. package/dist/docs/references/reference-storage-libsql.md +135 -0
  260. package/dist/docs/references/reference-storage-mongodb.md +262 -0
  261. package/dist/docs/references/reference-storage-mssql.md +155 -0
  262. package/dist/docs/references/reference-storage-overview.md +121 -0
  263. package/dist/docs/references/reference-storage-postgresql.md +529 -0
  264. package/dist/docs/references/reference-storage-upstash.md +160 -0
  265. package/dist/docs/references/reference-streaming-ChunkType.md +292 -0
  266. package/dist/docs/references/reference-streaming-agents-MastraModelOutput.md +182 -0
  267. package/dist/docs/references/reference-streaming-agents-streamLegacy.md +142 -0
  268. package/dist/docs/references/reference-streaming-workflows-observeStream.md +42 -0
  269. package/dist/docs/references/reference-streaming-workflows-resumeStream.md +61 -0
  270. package/dist/docs/references/reference-streaming-workflows-stream.md +87 -0
  271. package/dist/docs/references/reference-streaming-workflows-timeTravelStream.md +142 -0
  272. package/dist/docs/{templates/01-reference.md → references/reference-templates-overview.md} +8 -17
  273. package/dist/docs/references/reference-tools-client.md +228 -0
  274. package/dist/docs/references/reference-tools-create-tool.md +237 -0
  275. package/dist/docs/references/reference-tools-graph-rag-tool.md +185 -0
  276. package/dist/docs/references/reference-tools-mcp-client.md +964 -0
  277. package/dist/docs/references/reference-tools-mcp-server.md +1275 -0
  278. package/dist/docs/references/reference-tools-vector-query-tool.md +459 -0
  279. package/dist/docs/references/reference-vectors-libsql.md +305 -0
  280. package/dist/docs/references/reference-vectors-mongodb.md +295 -0
  281. package/dist/docs/references/reference-vectors-pg.md +408 -0
  282. package/dist/docs/references/reference-vectors-upstash.md +294 -0
  283. package/dist/docs/references/reference-voice-composite-voice.md +121 -0
  284. package/dist/docs/references/reference-voice-mastra-voice.md +313 -0
  285. package/dist/docs/references/reference-voice-voice.addInstructions.md +56 -0
  286. package/dist/docs/references/reference-voice-voice.addTools.md +67 -0
  287. package/dist/docs/references/reference-voice-voice.connect.md +94 -0
  288. package/dist/docs/references/reference-voice-voice.events.md +37 -0
  289. package/dist/docs/references/reference-voice-voice.listen.md +164 -0
  290. package/dist/docs/references/reference-voice-voice.on.md +111 -0
  291. package/dist/docs/references/reference-voice-voice.speak.md +157 -0
  292. package/dist/docs/references/reference-workflows-run-methods-cancel.md +86 -0
  293. package/dist/docs/references/reference-workflows-run-methods-restart.md +33 -0
  294. package/dist/docs/references/reference-workflows-run-methods-resume.md +59 -0
  295. package/dist/docs/references/reference-workflows-run-methods-start.md +58 -0
  296. package/dist/docs/references/reference-workflows-run-methods-startAsync.md +67 -0
  297. package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +142 -0
  298. package/dist/docs/references/reference-workflows-run.md +59 -0
  299. package/dist/docs/references/reference-workflows-step.md +117 -0
  300. package/dist/docs/references/reference-workflows-workflow-methods-branch.md +25 -0
  301. package/dist/docs/references/reference-workflows-workflow-methods-commit.md +17 -0
  302. package/dist/docs/references/reference-workflows-workflow-methods-create-run.md +63 -0
  303. package/dist/docs/references/reference-workflows-workflow-methods-dountil.md +25 -0
  304. package/dist/docs/references/reference-workflows-workflow-methods-dowhile.md +25 -0
  305. package/dist/docs/references/reference-workflows-workflow-methods-foreach.md +88 -0
  306. package/dist/docs/references/reference-workflows-workflow-methods-map.md +93 -0
  307. package/dist/docs/references/reference-workflows-workflow-methods-parallel.md +21 -0
  308. package/dist/docs/references/reference-workflows-workflow-methods-sleep.md +35 -0
  309. package/dist/docs/references/reference-workflows-workflow-methods-sleepUntil.md +35 -0
  310. package/dist/docs/references/reference-workflows-workflow-methods-then.md +21 -0
  311. package/dist/docs/references/reference-workflows-workflow.md +157 -0
  312. package/dist/docs/references/reference-workspace-filesystem.md +200 -0
  313. package/dist/docs/references/reference-workspace-local-filesystem.md +300 -0
  314. package/dist/docs/references/reference-workspace-local-sandbox.md +283 -0
  315. package/dist/docs/references/reference-workspace-sandbox.md +79 -0
  316. package/dist/docs/references/reference-workspace-workspace-class.md +247 -0
  317. package/dist/docs/references/reference.md +243 -0
  318. package/dist/evals/index.cjs +5 -5
  319. package/dist/evals/index.js +2 -2
  320. package/dist/evals/scoreTraces/index.cjs +3 -3
  321. package/dist/evals/scoreTraces/index.js +1 -1
  322. package/dist/index.cjs +4 -4
  323. package/dist/index.js +2 -2
  324. package/dist/llm/index.cjs +9 -5
  325. package/dist/llm/index.d.ts +1 -1
  326. package/dist/llm/index.d.ts.map +1 -1
  327. package/dist/llm/index.js +1 -1
  328. package/dist/llm/model/index.d.ts +1 -1
  329. package/dist/llm/model/index.d.ts.map +1 -1
  330. package/dist/loop/index.cjs +12 -12
  331. package/dist/loop/index.js +1 -1
  332. package/dist/mastra/index.cjs +2 -2
  333. package/dist/mastra/index.d.ts +17 -0
  334. package/dist/mastra/index.d.ts.map +1 -1
  335. package/dist/mastra/index.js +1 -1
  336. package/dist/memory/index.cjs +14 -14
  337. package/dist/memory/index.js +1 -1
  338. package/dist/memory/types.d.ts +3 -2
  339. package/dist/memory/types.d.ts.map +1 -1
  340. package/dist/processors/index.cjs +41 -41
  341. package/dist/processors/index.js +1 -1
  342. package/dist/relevance/index.cjs +3 -3
  343. package/dist/relevance/index.js +1 -1
  344. package/dist/storage/index.cjs +33 -33
  345. package/dist/storage/index.js +1 -1
  346. package/dist/stream/index.cjs +11 -11
  347. package/dist/stream/index.js +2 -2
  348. package/dist/test-utils/llm-mock.cjs +12 -12
  349. package/dist/test-utils/llm-mock.js +3 -3
  350. package/dist/{token-6GSAFR2W-TOUJCAPY.js → token-APYSY3BW-QJCV2XQG.js} +11 -11
  351. package/dist/token-APYSY3BW-QJCV2XQG.js.map +1 -0
  352. package/dist/{token-6GSAFR2W-GERJXNN5.cjs → token-APYSY3BW-UBKUGJQP.cjs} +14 -14
  353. package/dist/token-APYSY3BW-UBKUGJQP.cjs.map +1 -0
  354. package/dist/token-util-RMHT2CPJ-S2YMG7N3.js +8 -0
  355. package/dist/token-util-RMHT2CPJ-S2YMG7N3.js.map +1 -0
  356. package/dist/token-util-RMHT2CPJ-WV2T74WQ.cjs +10 -0
  357. package/dist/token-util-RMHT2CPJ-WV2T74WQ.cjs.map +1 -0
  358. package/dist/tool-loop-agent/index.cjs +4 -4
  359. package/dist/tool-loop-agent/index.js +1 -1
  360. package/dist/vector/index.cjs +11 -11
  361. package/dist/vector/index.js +3 -3
  362. package/dist/workflows/evented/index.cjs +10 -10
  363. package/dist/workflows/evented/index.js +1 -1
  364. package/dist/workflows/index.cjs +25 -25
  365. package/dist/workflows/index.js +1 -1
  366. package/package.json +4 -5
  367. package/dist/chunk-3LRUJTH3.cjs.map +0 -1
  368. package/dist/chunk-5HDIPOLV.js.map +0 -1
  369. package/dist/chunk-ARQG4ZSD.cjs.map +0 -1
  370. package/dist/chunk-DG6C6ZTL.cjs.map +0 -1
  371. package/dist/chunk-EY3WXGUD.js.map +0 -1
  372. package/dist/chunk-IPXNR6RQ.js.map +0 -1
  373. package/dist/chunk-NYC6PYZF.js.map +0 -1
  374. package/dist/chunk-X5HU5YVN.js +0 -250
  375. package/dist/chunk-X5HU5YVN.js.map +0 -1
  376. package/dist/chunk-XC7WIZBL.js.map +0 -1
  377. package/dist/chunk-Z2OKCLGV.cjs.map +0 -1
  378. package/dist/chunk-Z4PGSIZ5.cjs.map +0 -1
  379. package/dist/chunk-ZZF2IKZJ.cjs +0 -252
  380. package/dist/chunk-ZZF2IKZJ.cjs.map +0 -1
  381. package/dist/docs/README.md +0 -57
  382. package/dist/docs/agents/11-reference.md +0 -854
  383. package/dist/docs/ai-sdk/01-reference.md +0 -490
  384. package/dist/docs/auth/01-reference.md +0 -308
  385. package/dist/docs/core/01-reference.md +0 -1283
  386. package/dist/docs/deployer/01-reference.md +0 -128
  387. package/dist/docs/evals/04-reference.md +0 -2137
  388. package/dist/docs/index.mdx/01-reference.md +0 -14
  389. package/dist/docs/mcp/02-publishing-mcp-server.md +0 -111
  390. package/dist/docs/observability/15-reference.md +0 -1831
  391. package/dist/docs/processors/01-reference.md +0 -1418
  392. package/dist/docs/rag/06-reference.md +0 -342
  393. package/dist/docs/server/16-reference.md +0 -513
  394. package/dist/docs/storage/01-reference.md +0 -2022
  395. package/dist/docs/streaming/04-reference.md +0 -724
  396. package/dist/docs/tools/01-reference.md +0 -3136
  397. package/dist/docs/vectors/01-reference.md +0 -942
  398. package/dist/docs/voice/05-reference.md +0 -1043
  399. package/dist/docs/workflows/11-reference.md +0 -1044
  400. package/dist/docs/workspace/06-reference.md +0 -946
  401. package/dist/token-6GSAFR2W-GERJXNN5.cjs.map +0 -1
  402. package/dist/token-6GSAFR2W-TOUJCAPY.js.map +0 -1
  403. package/dist/token-util-NEHG7TUY-R2XAU2MF.cjs +0 -10
  404. package/dist/token-util-NEHG7TUY-R2XAU2MF.cjs.map +0 -1
  405. package/dist/token-util-NEHG7TUY-TZ426VZB.js +0 -8
  406. package/dist/token-util-NEHG7TUY-TZ426VZB.js.map +0 -1
@@ -1,61 +1,65 @@
1
- > Overview of agents in Mastra, detailing their capabilities and how they interact with tools, workflows, and external systems.
2
-
3
- > **Code References:**
4
- - `Agent`: dist/agent/agent.d.ts → dist/chunk-5HDIPOLV.js:17701
5
- - `Mastra`: dist/mastra/index.d.ts → dist/chunk-EY3WXGUD.js:24
6
-
7
1
  # Using Agents
8
2
 
9
3
  Agents use LLMs and tools to solve open-ended tasks. They reason about goals, decide which tools to use, retain conversation memory, and iterate internally until the model emits a final answer or an optional stop condition is met. Agents produce structured responses you can render in your UI or process programmatically. Use agents directly or compose them into workflows or agent networks.
10
4
 
11
- ![Agents overview](/img/agents/agents-overview.jpg)
5
+ ![Agents overview](/assets/images/agents-overview-1e3bb3b8cf0d13be675394ad41418ea7.jpg)
12
6
 
13
- > **Watch an introduction**
14
-
15
- An introduction to agents, and how they compare to workflows on [YouTube (7 minutes)](https://youtu.be/0jg2g3sNvgw)
7
+ > **Watch an introduction:** An introduction to agents, and how they compare to workflows on [YouTube (7 minutes)](https://youtu.be/0jg2g3sNvgw)
16
8
 
17
9
  ## Setting up agents
10
+
18
11
  ### Installation
19
12
 
20
- ### Step
13
+ 1. Add the Mastra core package to your project:
21
14
 
22
- Add the Mastra core package to your project:
15
+ **npm**:
23
16
 
24
- ```bash npm2yarn
25
- npm install @mastra/core@latest
26
- ```
17
+ ```bash
18
+ npm install @mastra/core@latest
19
+ ```
27
20
 
28
- ### Step
21
+ **pnpm**:
29
22
 
30
- Mastra's model router auto-detects environment variables for your chosen provider. For OpenAI, set `OPENAI_API_KEY`:
23
+ ```bash
24
+ pnpm add @mastra/core@latest
25
+ ```
31
26
 
32
- ```bash title=".env"
33
- OPENAI_API_KEY=<your-api-key>
34
- ```
27
+ **Yarn**:
35
28
 
36
- > **Note:**
29
+ ```bash
30
+ yarn add @mastra/core@latest
31
+ ```
37
32
 
38
- Mastra supports more than 600 models. Choose from the [full list](/models).
33
+ **Bun**:
39
34
 
40
- ### Step
35
+ ```bash
36
+ bun add @mastra/core@latest
37
+ ```
41
38
 
42
- Create an agent by instantiating the `Agent` class with system `instructions` and a `model`:
39
+ 2. Mastra's model router auto-detects environment variables for your chosen provider. For OpenAI, set `OPENAI_API_KEY`:
43
40
 
44
- ```typescript title="src/mastra/agents/test-agent.ts"
45
- import { Agent } from "@mastra/core/agent";
41
+ ```bash
42
+ OPENAI_API_KEY=<your-api-key>
43
+ ```
46
44
 
47
- export const testAgent = new Agent({
48
- id: "test-agent",
49
- name: "Test Agent",
50
- instructions: "You are a helpful assistant.",
51
- model: "openai/gpt-5.1",
52
- });
53
- ```
45
+ > **Note:** Mastra supports more than 600 models. Choose from the [full list](https://mastra.ai/models).
46
+
47
+ 3. Create an agent by instantiating the `Agent` class with system `instructions` and a `model`:
48
+
49
+ ```typescript
50
+ import { Agent } from "@mastra/core/agent";
51
+
52
+ export const testAgent = new Agent({
53
+ id: "test-agent",
54
+ name: "Test Agent",
55
+ instructions: "You are a helpful assistant.",
56
+ model: "openai/gpt-5.1",
57
+ });
58
+ ```
54
59
 
55
60
  ### Instruction formats
56
61
 
57
- Instructions define the agent's behavior, personality, and capabilities.
58
- They are system-level prompts that establish the agent's core identity and expertise.
62
+ Instructions define the agent's behavior, personality, and capabilities. They are system-level prompts that establish the agent's core identity and expertise.
59
63
 
60
64
  Instructions can be provided in multiple formats for greater flexibility. The examples below illustrate the supported shapes:
61
65
 
@@ -94,23 +98,19 @@ instructions: {
94
98
  }
95
99
  ```
96
100
 
97
- > **Note:**
98
-
99
- Visit [Agent reference](https://mastra.ai/reference/agents/agent) for more information.
101
+ > **Info:** Visit [Agent reference](https://mastra.ai/reference/agents/agent) for more information.
100
102
 
101
103
  ### Dynamic instructions
102
104
 
103
105
  Instructions can be provided as an async function, allowing you to resolve prompts at runtime. This enables patterns like personalizing instructions based on user context, fetching prompts from external registry services, and running A/B tests with different variants.
104
106
 
105
- > **Note:**
106
-
107
- See [Dynamic instructions](https://mastra.ai/docs/server/request-context#dynamic-instructions) for examples.
107
+ > **Info:** See [Dynamic instructions](https://mastra.ai/docs/server/request-context) for examples.
108
108
 
109
109
  ### Registering an agent
110
110
 
111
111
  Register your agent in the Mastra instance to make it available throughout your application. Once registered, it can be called from workflows, tools, or other agents, and has access to shared resources such as memory, logging, and observability features:
112
112
 
113
- ```typescript {5} title="src/mastra/index.ts"
113
+ ```typescript
114
114
  import { Mastra } from "@mastra/core";
115
115
  import { testAgent } from "./agents/test-agent";
116
116
 
@@ -127,17 +127,13 @@ You can call agents from workflow steps, tools, the Mastra Client, or the comman
127
127
  const testAgent = mastra.getAgent("testAgent");
128
128
  ```
129
129
 
130
- :> **Note:**
131
-
132
- `mastra.getAgent()` is preferred over a direct import, since it provides access to the Mastra instance configuration (logger, telemetry, storage, registered agents, and vector stores).
133
-
134
- :
130
+ > **Info:** `mastra.getAgent()` is preferred over a direct import, since it provides access to the Mastra instance configuration (logger, telemetry, storage, registered agents, and vector stores).
135
131
 
136
132
  ## Generating responses
137
133
 
138
134
  Agents can return results in two ways: generating the full output before returning it or streaming tokens in real time. Choose the approach that fits your use case: generate for short, internal responses or debugging, and stream to deliver pixels to end users as quickly as possible.
139
135
 
140
- **generate:**
136
+ **Generate**:
141
137
 
142
138
  Pass a single string for simple prompts, an array of strings when providing multiple pieces of context, or an array of message objects with `role` and `content`.
143
139
 
@@ -157,8 +153,7 @@ const response = await testAgent.generate([
157
153
  console.log(response.text);
158
154
  ```
159
155
 
160
-
161
- **stream:**
156
+ **Stream**:
162
157
 
163
158
  Pass a single string for simple prompts, an array of strings when providing multiple pieces of context, or an array of message objects with `role` and `content`.
164
159
 
@@ -180,10 +175,9 @@ for await (const chunk of stream.textStream) {
180
175
  }
181
176
  ```
182
177
 
183
- <h3 id="completion-using-onfinish">Completion using `onFinish()`</h3>
178
+ ### Completion using `onFinish()`
184
179
 
185
- When streaming responses, the `onFinish()` callback runs after the LLM finishes generating its response and all tool executions are complete.
186
- It provides the final `text`, execution `steps`, `finishReason`, token `usage` statistics, and other metadata useful for monitoring or logging.
180
+ When streaming responses, the `onFinish()` callback runs after the LLM finishes generating its response and all tool executions are complete. It provides the final `text`, execution `steps`, `finishReason`, token `usage` statistics, and other metadata useful for monitoring or logging.
187
181
 
188
182
  ```typescript
189
183
  const stream = await testAgent.stream("Help me organize my day", {
@@ -197,19 +191,13 @@ for await (const chunk of stream.textStream) {
197
191
  }
198
192
  ```
199
193
 
200
-
201
-
202
- > **Note:**
203
-
204
- Visit [.generate()](https://mastra.ai/reference/agents/generate) or [.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
194
+ > **Info:** Visit [.generate()](https://mastra.ai/reference/agents/generate) or [.stream()](https://mastra.ai/reference/streaming/agents/stream) for more information.
205
195
 
206
196
  ## Structured output
207
197
 
208
198
  Agents can return structured, type-safe data using Zod or JSON Schema. The parsed result is available on `response.object`.
209
199
 
210
- > **Note:**
211
-
212
- Visit [Structured Output](https://mastra.ai/docs/agents/structured-output) for more information.
200
+ > **Info:** Visit [Structured Output](https://mastra.ai/docs/agents/structured-output) for more information.
213
201
 
214
202
  ## Analyzing images
215
203
 
@@ -266,7 +254,7 @@ const response = await testAgent.generate("Help me organize my day", {
266
254
 
267
255
  Agents can use tools to go beyond language generation, enabling structured interactions with external APIs and services. Tools allow agents to access data and perform clearly defined operations in a reliable, repeatable way.
268
256
 
269
- ```typescript title="src/mastra/agents/test-agent.ts"
257
+ ```typescript
270
258
  export const testAgent = new Agent({
271
259
  id: "test-agent",
272
260
  name: "Test Agent",
@@ -274,15 +262,13 @@ export const testAgent = new Agent({
274
262
  });
275
263
  ```
276
264
 
277
- > **Note:**
278
-
279
- Visit [Using Tools](https://mastra.ai/docs/agents/using-tools) for more information.
265
+ > **Info:** Visit [Using Tools](https://mastra.ai/docs/agents/using-tools) for more information.
280
266
 
281
267
  ## Using `RequestContext`
282
268
 
283
269
  Use `RequestContext` to access request-specific values. This lets you conditionally adjust behavior based on the context of the request.
284
270
 
285
- ```typescript title="src/mastra/agents/test-agent.ts"
271
+ ```typescript
286
272
  export type UserTier = {
287
273
  "user-tier": "enterprise" | "pro";
288
274
  };
@@ -300,13 +286,9 @@ export const testAgent = new Agent({
300
286
  });
301
287
  ```
302
288
 
303
- > **Note:**
304
-
305
- See [Request Context](https://mastra.ai/docs/server/request-context) for more information.
306
-
307
- > **Note:**
289
+ > **Info:** See [Request Context](https://mastra.ai/docs/server/request-context) for more information.
308
290
 
309
- For type-safe request context schema validation, see [Schema Validation](https://mastra.ai/docs/server/request-context#schema-validation).
291
+ > **Tip:** For type-safe request context schema validation, see [Schema Validation](https://mastra.ai/docs/server/request-context).
310
292
 
311
293
  ## Testing with Studio
312
294
 
@@ -1,5 +1,3 @@
1
- > Learn how to use input and output processors to transform, validate, and control messages in Mastra agents.
2
-
3
1
  # Processors
4
2
 
5
3
  Processors transform, validate, or control messages as they pass through an agent. They run at specific points in the agent's execution pipeline, allowing you to modify inputs before they reach the language model or outputs before they're returned to users.
@@ -32,7 +30,7 @@ Mastra includes several processors for common use cases. You can also create cus
32
30
 
33
31
  Import and instantiate the processor, then pass it to the agent's `inputProcessors` or `outputProcessors` array:
34
32
 
35
- ```typescript {2,8-14} title="src/mastra/agents/moderated-agent.ts"
33
+ ```typescript
36
34
  import { Agent } from "@mastra/core/agent";
37
35
  import { ModerationProcessor } from "@mastra/core/processors";
38
36
 
@@ -70,18 +68,22 @@ For output processors, the order determines the sequence of transformations appl
70
68
  When memory is enabled on an agent, memory processors are automatically added to the pipeline:
71
69
 
72
70
  **Input processors:**
73
- ```
71
+
72
+ ```text
74
73
  [Memory Processors] → [Your inputProcessors]
75
74
  ```
75
+
76
76
  Memory loads message history first, then your processors run.
77
77
 
78
78
  **Output processors:**
79
- ```
79
+
80
+ ```text
80
81
  [Your outputProcessors] → [Memory Processors]
81
82
  ```
83
+
82
84
  Your processors run first, then memory persists messages.
83
85
 
84
- This ordering ensures that if your output guardrail calls `abort()`, memory processors are skipped and no messages are saved. See [Memory Processors](https://mastra.ai/docs/memory/memory-processors#processor-execution-order) for details.
86
+ This ordering ensures that if your output guardrail calls `abort()`, memory processors are skipped and no messages are saved. See [Memory Processors](https://mastra.ai/docs/memory/memory-processors) for details.
85
87
 
86
88
  ## Creating custom processors
87
89
 
@@ -89,7 +91,7 @@ Custom processors implement the `Processor` interface:
89
91
 
90
92
  ### Custom input processor
91
93
 
92
- ```typescript title="src/mastra/processors/custom-input.ts"
94
+ ```typescript
93
95
  import type {
94
96
  Processor,
95
97
  MastraDBMessage,
@@ -121,6 +123,7 @@ export class CustomInputProcessor implements Processor {
121
123
  ```
122
124
 
123
125
  The `processInput` method receives:
126
+
124
127
  - `messages`: User and assistant messages (not system messages)
125
128
  - `systemMessages`: All system messages (agent instructions, memory context, user-provided system prompts)
126
129
  - `messageList`: The full MessageList instance for advanced use cases
@@ -128,6 +131,7 @@ The `processInput` method receives:
128
131
  - `requestContext`: Execution metadata like `threadId` and `resourceId`
129
132
 
130
133
  The method can return:
134
+
131
135
  - `MastraDBMessage[]` — Transformed messages array (backward compatible)
132
136
  - `{ messages: MastraDBMessage[]; systemMessages: CoreMessage[] }` — Both messages and modified system messages
133
137
 
@@ -137,7 +141,7 @@ The framework handles both return formats, so modifying system messages is optio
137
141
 
138
142
  To modify system messages (e.g., trim verbose prompts for smaller models), return an object with both `messages` and `systemMessages`:
139
143
 
140
- ```typescript title="src/mastra/processors/system-trimmer.ts"
144
+ ```typescript
141
145
  import type { Processor, CoreMessage, MastraDBMessage } from "@mastra/core";
142
146
 
143
147
  export class SystemTrimmer implements Processor {
@@ -162,6 +166,7 @@ export class SystemTrimmer implements Processor {
162
166
  ```
163
167
 
164
168
  This is useful for:
169
+
165
170
  - Trimming verbose system prompts for models with smaller context windows
166
171
  - Filtering or modifying semantic recall content to prevent "prompt too long" errors
167
172
  - Dynamically adjusting system instructions based on the conversation
@@ -170,7 +175,7 @@ This is useful for:
170
175
 
171
176
  While `processInput` runs once at the start of agent execution, `processInputStep` runs at **each step** of the agentic loop (including tool call continuations). This enables per-step configuration changes like dynamic model switching or tool choice modifications.
172
177
 
173
- ```typescript title="src/mastra/processors/step-processor.ts"
178
+ ```typescript
174
179
  import type { Processor, ProcessInputStepArgs, ProcessInputStepResult } from "@mastra/core";
175
180
 
176
181
  export class DynamicModelProcessor implements Processor {
@@ -199,6 +204,7 @@ export class DynamicModelProcessor implements Processor {
199
204
  ```
200
205
 
201
206
  The `processInputStep` method receives:
207
+
202
208
  - `stepNumber`: Current step in the agentic loop (0-indexed)
203
209
  - `steps`: Results from previous steps
204
210
  - `messages`: Current messages snapshot (read-only)
@@ -213,6 +219,7 @@ The `processInputStep` method receives:
213
219
  - `structuredOutput`: Structured output configuration
214
220
 
215
221
  The method can return any combination of:
222
+
216
223
  - `model`: Change the model for this step
217
224
  - `tools`: Replace or add tools (use spread to merge: `{ tools: { ...tools, newTool } }`)
218
225
  - `toolChoice`: Change tool selection behavior
@@ -227,7 +234,7 @@ The method can return any combination of:
227
234
 
228
235
  When using `maxSteps` to limit agent execution, the agent may return an empty response if it attempts a tool call on the final step. Use `processInputStep` to force a text response on the last step:
229
236
 
230
- ```typescript title="src/mastra/processors/ensure-final-response.ts"
237
+ ```typescript
231
238
  import { Processor, ProcessInputStepArgs, ProcessInputStepResult } from "@mastra/core/processors";
232
239
 
233
240
  export class EnsureFinalResponseProcessor implements Processor {
@@ -262,7 +269,7 @@ export class EnsureFinalResponseProcessor implements Processor {
262
269
 
263
270
  Use it with your agent:
264
271
 
265
- ```typescript title="src/mastra/agents/bounded-agent.ts"
272
+ ```typescript
266
273
  import { Agent } from "@mastra/core/agent";
267
274
  import { EnsureFinalResponseProcessor } from "../processors/ensure-final-response";
268
275
 
@@ -301,7 +308,7 @@ await agent.generate("Complex task", {
301
308
 
302
309
  ### Custom output processor
303
310
 
304
- ```typescript title="src/mastra/processors/custom-output.ts"
311
+ ```typescript
305
312
  import type {
306
313
  Processor,
307
314
  MastraDBMessage,
@@ -339,7 +346,7 @@ export class CustomOutputProcessor implements Processor {
339
346
 
340
347
  You can add custom metadata to messages in `processOutputResult`. This metadata is accessible via the response object:
341
348
 
342
- ```typescript title="src/mastra/processors/metadata-processor.ts"
349
+ ```typescript
343
350
  import type { Processor, MastraDBMessage } from "@mastra/core";
344
351
 
345
352
  export class MetadataProcessor implements Processor {
@@ -403,14 +410,13 @@ console.log(response.uiMessages);
403
410
 
404
411
  Mastra provides utility processors for common tasks:
405
412
 
406
- **For security and validation processors**, see the [Guardrails](https://mastra.ai/docs/agents/guardrails) page for input/output guardrails and moderation processors.
407
- **For memory-specific processors**, see the [Memory Processors](https://mastra.ai/docs/memory/memory-processors) page for processors that handle message history, semantic recall, and working memory.
413
+ **For security and validation processors**, see the [Guardrails](https://mastra.ai/docs/agents/guardrails) page for input/output guardrails and moderation processors. **For memory-specific processors**, see the [Memory Processors](https://mastra.ai/docs/memory/memory-processors) page for processors that handle message history, semantic recall, and working memory.
408
414
 
409
415
  ### TokenLimiter
410
416
 
411
417
  Prevents context window overflow by removing older messages when the total token count exceeds a specified limit.
412
418
 
413
- ```typescript {7-10}
419
+ ```typescript
414
420
  import { Agent } from "@mastra/core/agent";
415
421
  import { TokenLimiter } from "@mastra/core/processors";
416
422
 
@@ -426,7 +432,7 @@ const agent = new Agent({
426
432
 
427
433
  The `TokenLimiter` uses the `o200k_base` encoding by default (suitable for GPT-4o). You can specify other encodings for different models:
428
434
 
429
- ```typescript {6-9}
435
+ ```typescript
430
436
  import cl100k_base from "js-tiktoken/ranks/cl100k_base";
431
437
 
432
438
  const agent = new Agent({
@@ -444,7 +450,7 @@ const agent = new Agent({
444
450
 
445
451
  Removes tool calls from messages sent to the LLM, saving tokens by excluding potentially verbose tool interactions.
446
452
 
447
- ```typescript {7-16}
453
+ ```typescript
448
454
  import { Agent } from "@mastra/core/agent";
449
455
  import { ToolCallFilter, TokenLimiter } from "@mastra/core/processors";
450
456
 
@@ -464,15 +470,13 @@ const agent = new Agent({
464
470
  });
465
471
  ```
466
472
 
467
- > **Note:**
468
-
469
- The example above filters tool calls and limits tokens for the LLM, but these filtered messages will still be saved to memory. To also filter messages before they're saved to memory, manually add memory processors before utility processors. See [Memory Processors](https://mastra.ai/docs/memory/memory-processors#manual-control-and-deduplication) for details.
473
+ > **Note:** The example above filters tool calls and limits tokens for the LLM, but these filtered messages will still be saved to memory. To also filter messages before they're saved to memory, manually add memory processors before utility processors. See [Memory Processors](https://mastra.ai/docs/memory/memory-processors) for details.
470
474
 
471
475
  ### ToolSearchProcessor
472
476
 
473
477
  Enables dynamic tool discovery and loading for agents with large tool libraries. Instead of providing all tools upfront, the agent searches for tools by keyword and loads them on demand, reducing context token usage.
474
478
 
475
- ```typescript {2,9-18}
479
+ ```typescript
476
480
  import { Agent } from "@mastra/core/agent";
477
481
  import { ToolSearchProcessor } from "@mastra/core/processors";
478
482
 
@@ -498,7 +502,7 @@ The processor gives the agent two meta-tools: `search_tools` to find tools by ke
498
502
 
499
503
  You can use Mastra workflows as processors to create complex processing pipelines with parallel execution, conditional branching, and error handling:
500
504
 
501
- ```typescript title="src/mastra/processors/moderation-workflow.ts"
505
+ ```typescript
502
506
  import { createWorkflow, createStep } from "@mastra/core/workflows";
503
507
  import { ProcessorStepSchema } from "@mastra/core/processors";
504
508
  import { Agent } from "@mastra/core/agent";
@@ -531,7 +535,7 @@ When an agent is registered with Mastra, processor workflows are automatically r
531
535
 
532
536
  Processors can request that the LLM retry its response with feedback. This is useful for implementing quality checks, output validation, or iterative refinement:
533
537
 
534
- ```typescript title="src/mastra/processors/quality-checker.ts"
538
+ ```typescript
535
539
  import type { Processor } from "@mastra/core";
536
540
 
537
541
  export class QualityChecker implements Processor {
@@ -562,6 +566,7 @@ const agent = new Agent({
562
566
  ```
563
567
 
564
568
  The retry mechanism:
569
+
565
570
  - Only works in `processOutputStep` and `processInputStep` methods
566
571
  - Replays the step with the abort reason added as context for the LLM
567
572
  - Tracks retry count via the `retryCount` parameter
@@ -1,5 +1,3 @@
1
- > Learn how to generate structured data from agents using schemas and validation.
2
-
3
1
  # Structured Output
4
2
 
5
3
  Structured output lets an agent return an object that matches the shape defined by a schema instead of returning text. The schema tells the model what fields to produce, and the model ensures the final result fits that shape.
@@ -12,7 +10,7 @@ Use structured output when you need an agent to return a data object rather than
12
10
 
13
11
  Agents can return structured data by defining the expected output with either [Zod](https://zod.dev/) or [JSON Schema](https://json-schema.org/). Zod is recommended because it provides TypeScript type inference and runtime validation, while JSON Schema is useful when you need a language agnostic format.
14
12
 
15
- **zod:**
13
+ **Zod**:
16
14
 
17
15
  Define the `output` shape using [Zod](https://zod.dev/):
18
16
 
@@ -33,8 +31,7 @@ const response = await testAgent.generate("Help me plan my day.", {
33
31
  console.log(response.object);
34
32
  ```
35
33
 
36
-
37
- **json-schema:**
34
+ **JSON Schema**:
38
35
 
39
36
  You can also use JSON Schema to define your output structure:
40
37
 
@@ -61,11 +58,7 @@ const response = await testAgent.generate("Help me plan my day.", {
61
58
  console.log(response.object);
62
59
  ```
63
60
 
64
-
65
-
66
- > **Note:**
67
-
68
- Visit [.generate()](https://mastra.ai/reference/agents/generate) for a full list of configuration options.
61
+ > **Info:** Visit [.generate()](https://mastra.ai/reference/agents/generate) for a full list of configuration options.
69
62
 
70
63
  ### Example output
71
64
 
@@ -193,18 +186,16 @@ const response = await testAgent.generate("Help me plan my day.", {
193
186
  console.log(response.object);
194
187
  ```
195
188
 
196
- > **Gemini 2.5 with tools**
197
-
198
- Gemini 2.5 models do not support combining `response_format` (structured output) with function calling (tools) in the same API call. If your agent has tools and you're using `structuredOutput` with a Gemini 2.5 model, you must set `jsonPromptInjection: true` to avoid the error `Function calling with a response mime type: 'application/json' is unsupported`.
199
-
200
- ```typescript
201
- const response = await agentWithTools.generate("Your prompt", {
202
- structuredOutput: {
203
- schema: yourSchema,
204
- jsonPromptInjection: true, // Required for Gemini 2.5 when tools are present
205
- },
206
- });
207
- ```
189
+ > **Gemini 2.5 with tools:** Gemini 2.5 models do not support combining `response_format` (structured output) with function calling (tools) in the same API call. If your agent has tools and you're using `structuredOutput` with a Gemini 2.5 model, you must set `jsonPromptInjection: true` to avoid the error `Function calling with a response mime type: 'application/json' is unsupported`.
190
+ >
191
+ > ```typescript
192
+ > const response = await agentWithTools.generate("Your prompt", {
193
+ > structuredOutput: {
194
+ > schema: yourSchema,
195
+ > jsonPromptInjection: true, // Required for Gemini 2.5 when tools are present
196
+ > },
197
+ > });
198
+ > ```
208
199
 
209
200
  ### Using a separate structuring model
210
201
 
@@ -1,5 +1,3 @@
1
- > Learn how to create tools and add them to agents to extend capabilities beyond text generation.
2
-
3
1
  # Using Tools
4
2
 
5
3
  Agents use tools to call APIs, query databases, or run custom functions from your codebase. Tools give agents capabilities beyond language generation by providing structured access to data and performing clearly defined operations. You can also load tools from remote [MCP servers](https://mastra.ai/docs/mcp/overview) to expand an agent's capabilities.
@@ -14,7 +12,7 @@ When creating tools, keep descriptions simple and focused on what the tool does,
14
12
 
15
13
  This example shows how to create a tool that fetches weather data from an API. When the agent calls the tool, it provides the required input as defined by the tool's `inputSchema`. The tool accesses this data through its `inputData` parameter, which in this example includes the `location` used in the weather API query.
16
14
 
17
- ```typescript title="src/mastra/tools/weather-tool.ts"
15
+ ```typescript
18
16
  import { createTool } from "@mastra/core/tools";
19
17
  import { z } from "zod";
20
18
 
@@ -44,7 +42,7 @@ To make a tool available to an agent, add it to `tools`. Mentioning available to
44
42
 
45
43
  An agent can use multiple tools to handle more complex tasks by delegating specific parts to individual tools. The agent decides which tools to use based on the user's message, the agent's instructions, and the tool descriptions and schemas.
46
44
 
47
- ```typescript {11} title="src/mastra/agents/weather-agent.ts"
45
+ ```typescript
48
46
  import { Agent } from "@mastra/core/agent";
49
47
  import { weatherTool } from "../tools/weather-tool";
50
48
 
@@ -89,10 +87,10 @@ This lets you specify how tools are identified in the stream. If you want the `t
89
87
 
90
88
  Sub-agents and workflows follow the same pattern. They are converted to tools with a prefix followed by your object key:
91
89
 
92
- | Property | Prefix | Example key | `toolName` |
93
- |----------|--------|-------------|------------|
94
- | `agents` | `agent-` | `weather` | `agent-weather` |
95
- | `workflows` | `workflow-` | `research` | `workflow-research` |
90
+ | Property | Prefix | Example key | `toolName` |
91
+ | ----------- | ----------- | ----------- | ------------------- |
92
+ | `agents` | `agent-` | `weather` | `agent-weather` |
93
+ | `workflows` | `workflow-` | `research` | `workflow-research` |
96
94
 
97
95
  ```typescript
98
96
  const orchestrator = new Agent({
@@ -107,6 +105,7 @@ const orchestrator = new Agent({
107
105
  ```
108
106
 
109
107
  Note that for sub-agents, you'll see two different identifiers in stream responses:
108
+
110
109
  - `toolName: "agent-weather"` in tool call events — the generated tool wrapper name
111
110
  - `id: "weather-agent"` in `data-tool-agent` chunks — the sub-agent's actual `id` property
112
111
 
@@ -114,7 +113,7 @@ Note that for sub-agents, you'll see two different identifiers in stream respons
114
113
 
115
114
  The agent uses the tool's `inputSchema` to infer what data the tool expects. In this case, it extracts `London` as the `location` from the message and passes it to the tool's inputData parameter.
116
115
 
117
- ```typescript title="src/test-tool.ts"
116
+ ```typescript
118
117
  import { mastra } from "./mastra";
119
118
 
120
119
  const agent = mastra.getAgent("weatherAgent");
@@ -126,7 +125,7 @@ const result = await agent.generate("What's the weather in London?");
126
125
 
127
126
  When multiple tools are available, the agent may choose to use one, several, or none, depending on what's needed to answer the query.
128
127
 
129
- ```typescript {7} title="src/mastra/agents/weather-agent.ts"
128
+ ```typescript
130
129
  import { weatherTool } from "../tools/weather-tool";
131
130
  import { activitiesTool } from "../tools/activities-tool";
132
131
 
@@ -141,7 +140,7 @@ export const weatherAgent = new Agent({
141
140
 
142
141
  Workflows can be added to agents through the `workflows` configuration. When you add a workflow, Mastra automatically converts it to a tool that the agent can call. The generated tool is named `workflow-<workflowName>` and uses the workflow's `inputSchema` and `outputSchema`.
143
142
 
144
- ```typescript {14-16} title="src/mastra/agents/research-agent.ts"
143
+ ```typescript
145
144
  import { Agent } from "@mastra/core/agent";
146
145
  import { researchWorkflow } from "../workflows/research-workflow";
147
146
 
@@ -163,7 +162,7 @@ export const researchAgent = new Agent({
163
162
 
164
163
  The workflow should include a `description` to help the agent understand when to use it:
165
164
 
166
- ```typescript title="src/mastra/workflows/research-workflow.ts"
165
+ ```typescript
167
166
  import { createWorkflow } from "@mastra/core/workflows";
168
167
  import { z } from "zod";
169
168
 
@@ -194,7 +193,7 @@ When the agent calls the workflow tool, it receives a response containing the wo
194
193
 
195
194
  ## Tools with structured output
196
195
 
197
- When using tools with [structured output](https://mastra.ai/docs/agents/structured-output), some models don't support combining both features in the same API call. If your tools aren't being called when structured output is enabled, or you receive errors about incompatible options, see [Combining tools and structured output](https://mastra.ai/docs/agents/structured-output#combining-tools-and-structured-output) for model compatibility information and workarounds.
196
+ When using tools with [structured output](https://mastra.ai/docs/agents/structured-output), some models don't support combining both features in the same API call. If your tools aren't being called when structured output is enabled, or you receive errors about incompatible options, see [Combining tools and structured output](https://mastra.ai/docs/agents/structured-output) for model compatibility information and workarounds.
198
197
 
199
198
  ## Related
200
199
 
@@ -281,11 +281,9 @@ A custom scorer in Mastra uses `createScorer` with four core components:
281
281
 
282
282
  Together, these components allow you to define custom evaluation logic using LLMs as judges.
283
283
 
284
- > **Note:**
284
+ > **Info:** Visit [createScorer](https://mastra.ai/reference/evals/create-scorer) for the full API and configuration options.
285
285
 
286
- Visit [createScorer](https://mastra.ai/reference/evals/create-scorer) for the full API and configuration options.
287
-
288
- ```typescript title="src/mastra/scorers/gluten-checker.ts"
286
+ ```typescript
289
287
  import { createScorer } from "@mastra/core/evals";
290
288
  import { z } from "zod";
291
289
 
@@ -439,7 +437,7 @@ The reason generation step creates explanations that help users understand why a
439
437
 
440
438
  ## High gluten-free example
441
439
 
442
- ```typescript title="src/example-high-gluten-free.ts"
440
+ ```typescript
443
441
  const result = await glutenCheckerScorer.run({
444
442
  input: [{ role: 'user', content: 'Mix rice, beans, and vegetables' }],
445
443
  output: { text: 'Mix rice, beans, and vegetables' },
@@ -465,7 +463,7 @@ console.log('Reason:', result.reason);
465
463
 
466
464
  ## Partial gluten example
467
465
 
468
- ```typescript title="src/example-partial-gluten.ts"
466
+ ```typescript
469
467
  const result = await glutenCheckerScorer.run({
470
468
  input: [{ role: "user", content: "Mix flour and water to make dough" }],
471
469
  output: { text: "Mix flour and water to make dough" },
@@ -491,7 +489,7 @@ console.log("Reason:", result.reason);
491
489
 
492
490
  ## Low gluten-free example
493
491
 
494
- ```typescript title="src/example-low-gluten-free.ts"
492
+ ```typescript
495
493
  const result = await glutenCheckerScorer.run({
496
494
  input: [{ role: "user", content: "Add soy sauce and noodles" }],
497
495
  output: { text: "Add soy sauce and noodles" },