@mastra/mcp-docs-server 0.13.39 → 1.0.0-beta.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 (480) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +1 -0
  2. package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +0 -10
  3. package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +0 -10
  4. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +36 -36
  5. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +0 -10
  6. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +70 -70
  7. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +40 -40
  8. package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
  9. package/.docs/organized/changelogs/%40mastra%2Fauth.md +4 -14
  10. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +18 -18
  11. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +199 -199
  12. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +223 -223
  13. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +190 -190
  14. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +199 -199
  15. package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +7 -0
  16. package/.docs/organized/changelogs/%40mastra%2Fcore.md +214 -214
  17. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +16 -16
  18. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +74 -74
  19. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +67 -67
  20. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +70 -70
  21. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +67 -67
  22. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +209 -209
  23. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +191 -191
  24. package/.docs/organized/changelogs/%40mastra%2Fevals.md +34 -34
  25. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +5 -13
  26. package/.docs/organized/changelogs/%40mastra%2Flance.md +182 -182
  27. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +199 -199
  28. package/.docs/organized/changelogs/%40mastra%2Floggers.md +20 -20
  29. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +58 -58
  30. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +20 -20
  31. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +65 -65
  32. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +228 -228
  33. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +199 -199
  34. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +206 -206
  35. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
  36. package/.docs/organized/changelogs/%40mastra%2Fpg.md +197 -197
  37. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +16 -16
  38. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +217 -217
  39. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +16 -16
  40. package/.docs/organized/changelogs/%40mastra%2Frag.md +61 -61
  41. package/.docs/organized/changelogs/%40mastra%2Freact.md +70 -70
  42. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -17
  43. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -30
  44. package/.docs/organized/changelogs/%40mastra%2Fserver.md +206 -206
  45. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +16 -16
  46. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +190 -190
  47. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +18 -18
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +21 -21
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +20 -20
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +20 -20
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +20 -20
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -20
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +56 -56
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +20 -20
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
  56. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +56 -56
  57. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +20 -20
  58. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +20 -20
  59. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +20 -20
  60. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +20 -20
  61. package/.docs/organized/changelogs/create-mastra.md +33 -33
  62. package/.docs/organized/changelogs/mastra.md +86 -86
  63. package/.docs/organized/code-examples/a2a.md +4 -2
  64. package/.docs/organized/code-examples/agui.md +12 -9
  65. package/.docs/organized/code-examples/ai-sdk-useChat.md +12 -18
  66. package/.docs/organized/code-examples/ai-sdk-v5.md +4 -2
  67. package/.docs/organized/code-examples/bird-checker-with-express.md +5 -4
  68. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +4 -3
  69. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +4 -3
  70. package/.docs/organized/code-examples/client-side-tools.md +1 -0
  71. package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
  72. package/.docs/organized/code-examples/experimental-auth-weather-agent.md +8 -177
  73. package/.docs/organized/code-examples/fireworks-r1.md +2 -2
  74. package/.docs/organized/code-examples/heads-up-game.md +10 -7
  75. package/.docs/organized/code-examples/mcp-configuration.md +5 -3
  76. package/.docs/organized/code-examples/mcp-registry-registry.md +3 -2
  77. package/.docs/organized/code-examples/memory-per-resource-example.md +4 -2
  78. package/.docs/organized/code-examples/memory-todo-agent.md +1 -0
  79. package/.docs/organized/code-examples/memory-with-context.md +2 -1
  80. package/.docs/organized/code-examples/memory-with-libsql.md +4 -2
  81. package/.docs/organized/code-examples/memory-with-mongodb.md +4 -2
  82. package/.docs/organized/code-examples/memory-with-pg.md +4 -2
  83. package/.docs/organized/code-examples/memory-with-processors.md +13 -8
  84. package/.docs/organized/code-examples/memory-with-upstash.md +5 -3
  85. package/.docs/organized/code-examples/openapi-spec-writer.md +32 -41
  86. package/.docs/organized/code-examples/quick-start.md +5 -32
  87. package/.docs/organized/code-examples/stock-price-tool.md +6 -5
  88. package/.docs/organized/code-examples/weather-agent.md +21 -16
  89. package/.docs/organized/code-examples/workflow-ai-recruiter.md +3 -2
  90. package/.docs/organized/code-examples/workflow-with-inline-steps.md +9 -12
  91. package/.docs/organized/code-examples/workflow-with-memory.md +16 -15
  92. package/.docs/organized/code-examples/workflow-with-separate-steps.md +2 -2
  93. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +3 -2
  94. package/.docs/raw/agents/adding-voice.mdx +27 -22
  95. package/.docs/raw/agents/agent-memory.mdx +23 -15
  96. package/.docs/raw/agents/guardrails.mdx +33 -12
  97. package/.docs/raw/agents/networks.mdx +8 -4
  98. package/.docs/raw/agents/overview.mdx +21 -15
  99. package/.docs/raw/agents/using-tools.mdx +11 -8
  100. package/.docs/raw/auth/auth0.mdx +8 -8
  101. package/.docs/raw/auth/clerk.mdx +6 -6
  102. package/.docs/raw/auth/firebase.mdx +8 -8
  103. package/.docs/raw/auth/index.mdx +6 -6
  104. package/.docs/raw/auth/jwt.mdx +6 -6
  105. package/.docs/raw/auth/supabase.mdx +7 -7
  106. package/.docs/raw/auth/workos.mdx +8 -8
  107. package/.docs/raw/community/contributing-templates.mdx +3 -3
  108. package/.docs/raw/community/discord.mdx +1 -1
  109. package/.docs/raw/course/01-first-agent/08-exporting-your-agent.md +2 -1
  110. package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +2 -1
  111. package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -0
  112. package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -0
  113. package/.docs/raw/course/03-agent-memory/10-storage-configuration.md +2 -3
  114. package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +2 -0
  115. package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +2 -0
  116. package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -0
  117. package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -0
  118. package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +1 -0
  119. package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -0
  120. package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +1 -0
  121. package/.docs/raw/course/04-workflows/08-running-workflows-programmatically.md +2 -2
  122. package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +5 -5
  123. package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +7 -5
  124. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +3 -3
  125. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +4 -4
  126. package/.docs/raw/deployment/cloud-providers/index.mdx +11 -8
  127. package/.docs/raw/deployment/monorepo.mdx +2 -2
  128. package/.docs/raw/deployment/overview.mdx +2 -2
  129. package/.docs/raw/deployment/server-deployment.mdx +2 -10
  130. package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +4 -4
  131. package/.docs/raw/deployment/serverless-platforms/index.mdx +10 -7
  132. package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +4 -4
  133. package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +4 -4
  134. package/.docs/raw/deployment/web-framework.mdx +8 -8
  135. package/.docs/raw/{scorers → evals}/custom-scorers.mdx +6 -6
  136. package/.docs/raw/evals/off-the-shelf-scorers.mdx +50 -0
  137. package/.docs/raw/{scorers → evals}/overview.mdx +8 -8
  138. package/.docs/raw/evals/running-in-ci.mdx +113 -0
  139. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +22 -21
  140. package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +8 -8
  141. package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +3 -0
  142. package/.docs/raw/frameworks/servers/express.mdx +10 -9
  143. package/.docs/raw/frameworks/web-frameworks/astro.mdx +6 -6
  144. package/.docs/raw/frameworks/web-frameworks/next-js.mdx +3 -3
  145. package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
  146. package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +2 -2
  147. package/.docs/raw/getting-started/installation.mdx +13 -12
  148. package/.docs/raw/getting-started/mcp-docs-server.mdx +1 -1
  149. package/.docs/raw/getting-started/project-structure.mdx +4 -4
  150. package/.docs/raw/getting-started/studio.mdx +8 -8
  151. package/.docs/raw/getting-started/templates.mdx +1 -1
  152. package/.docs/raw/guides/guide/ai-recruiter.mdx +264 -0
  153. package/.docs/raw/guides/guide/chef-michel.mdx +271 -0
  154. package/.docs/raw/guides/guide/notes-mcp-server.mdx +450 -0
  155. package/.docs/raw/guides/guide/research-assistant.mdx +389 -0
  156. package/.docs/raw/guides/guide/stock-agent.mdx +185 -0
  157. package/.docs/raw/guides/guide/web-search.mdx +291 -0
  158. package/.docs/raw/guides/index.mdx +43 -0
  159. package/.docs/raw/guides/migrations/agentnetwork.mdx +114 -0
  160. package/.docs/raw/guides/migrations/upgrade-to-v1/_template.mdx +50 -0
  161. package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +265 -0
  162. package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +48 -0
  163. package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +153 -0
  164. package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +230 -0
  165. package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +171 -0
  166. package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +114 -0
  167. package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +241 -0
  168. package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +83 -0
  169. package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +62 -0
  170. package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +270 -0
  171. package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +115 -0
  172. package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +280 -0
  173. package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +23 -0
  174. package/.docs/raw/guides/migrations/upgrade-to-v1/voice.mdx +39 -0
  175. package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +178 -0
  176. package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +367 -0
  177. package/.docs/raw/index.mdx +9 -9
  178. package/.docs/raw/{observability/logging.mdx → logging.mdx} +4 -4
  179. package/.docs/raw/mastra-cloud/dashboard.mdx +2 -2
  180. package/.docs/raw/mastra-cloud/observability.mdx +6 -6
  181. package/.docs/raw/mastra-cloud/overview.mdx +2 -2
  182. package/.docs/raw/mastra-cloud/setting-up.mdx +4 -4
  183. package/.docs/raw/memory/conversation-history.mdx +1 -0
  184. package/.docs/raw/memory/memory-processors.mdx +4 -3
  185. package/.docs/raw/memory/overview.mdx +9 -5
  186. package/.docs/raw/memory/semantic-recall.mdx +12 -7
  187. package/.docs/raw/memory/storage/memory-with-libsql.mdx +10 -5
  188. package/.docs/raw/memory/storage/memory-with-pg.mdx +9 -4
  189. package/.docs/raw/memory/storage/memory-with-upstash.mdx +9 -4
  190. package/.docs/raw/memory/threads-and-resources.mdx +11 -13
  191. package/.docs/raw/memory/working-memory.mdx +30 -14
  192. package/.docs/raw/observability/overview.mdx +13 -30
  193. package/.docs/raw/observability/{ai-tracing → tracing}/exporters/arize.mdx +10 -18
  194. package/.docs/raw/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +7 -16
  195. package/.docs/raw/observability/{ai-tracing → tracing}/exporters/cloud.mdx +11 -17
  196. package/.docs/raw/observability/{ai-tracing → tracing}/exporters/default.mdx +16 -20
  197. package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +7 -16
  198. package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +7 -16
  199. package/.docs/raw/observability/{ai-tracing → tracing}/exporters/otel.mdx +9 -18
  200. package/.docs/raw/observability/{ai-tracing → tracing}/overview.mdx +107 -142
  201. package/.docs/raw/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +14 -13
  202. package/.docs/raw/rag/chunking-and-embedding.mdx +5 -5
  203. package/.docs/raw/rag/overview.mdx +3 -13
  204. package/.docs/raw/rag/retrieval.mdx +24 -12
  205. package/.docs/raw/rag/vector-databases.mdx +7 -1
  206. package/.docs/raw/reference/agents/agent.mdx +33 -28
  207. package/.docs/raw/reference/agents/generate.mdx +10 -10
  208. package/.docs/raw/reference/agents/generateLegacy.mdx +8 -8
  209. package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +21 -15
  210. package/.docs/raw/reference/agents/getDefaultOptions.mdx +69 -0
  211. package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +22 -16
  212. package/.docs/raw/reference/agents/getDescription.mdx +1 -1
  213. package/.docs/raw/reference/agents/getInstructions.mdx +8 -8
  214. package/.docs/raw/reference/agents/getLLM.mdx +9 -9
  215. package/.docs/raw/reference/agents/getMemory.mdx +9 -9
  216. package/.docs/raw/reference/agents/getModel.mdx +10 -10
  217. package/.docs/raw/reference/agents/getVoice.mdx +8 -8
  218. package/.docs/raw/reference/agents/listAgents.mdx +9 -9
  219. package/.docs/raw/reference/agents/listScorers.mdx +7 -7
  220. package/.docs/raw/reference/agents/listTools.mdx +7 -7
  221. package/.docs/raw/reference/agents/listWorkflows.mdx +7 -7
  222. package/.docs/raw/reference/agents/network.mdx +11 -10
  223. package/.docs/raw/reference/auth/auth0.mdx +4 -4
  224. package/.docs/raw/reference/auth/clerk.mdx +4 -4
  225. package/.docs/raw/reference/auth/firebase.mdx +6 -6
  226. package/.docs/raw/reference/auth/jwt.mdx +4 -4
  227. package/.docs/raw/reference/auth/supabase.mdx +4 -4
  228. package/.docs/raw/reference/auth/workos.mdx +4 -4
  229. package/.docs/raw/reference/cli/mastra.mdx +7 -7
  230. package/.docs/raw/reference/client-js/agents.mdx +6 -2
  231. package/.docs/raw/reference/client-js/mastra-client.mdx +7 -7
  232. package/.docs/raw/reference/client-js/memory.mdx +24 -16
  233. package/.docs/raw/reference/client-js/observability.mdx +11 -11
  234. package/.docs/raw/reference/client-js/workflows.mdx +6 -34
  235. package/.docs/raw/reference/core/getAgent.mdx +1 -1
  236. package/.docs/raw/reference/core/getAgentById.mdx +1 -1
  237. package/.docs/raw/reference/core/getDeployer.mdx +2 -2
  238. package/.docs/raw/reference/core/getLogger.mdx +2 -2
  239. package/.docs/raw/reference/core/getMCPServer.mdx +31 -15
  240. package/.docs/raw/reference/core/getMCPServerById.mdx +81 -0
  241. package/.docs/raw/reference/core/getScorer.mdx +3 -3
  242. package/.docs/raw/reference/core/getScorerById.mdx +79 -0
  243. package/.docs/raw/reference/core/getServer.mdx +2 -2
  244. package/.docs/raw/reference/core/getStorage.mdx +2 -2
  245. package/.docs/raw/reference/core/getTelemetry.mdx +2 -2
  246. package/.docs/raw/reference/core/getVector.mdx +2 -2
  247. package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
  248. package/.docs/raw/reference/core/listAgents.mdx +1 -1
  249. package/.docs/raw/reference/core/listLogs.mdx +2 -2
  250. package/.docs/raw/reference/core/listLogsByRunId.mdx +2 -2
  251. package/.docs/raw/reference/core/listMCPServers.mdx +65 -0
  252. package/.docs/raw/reference/core/listScorers.mdx +3 -3
  253. package/.docs/raw/reference/core/listVectors.mdx +36 -0
  254. package/.docs/raw/reference/core/listWorkflows.mdx +6 -6
  255. package/.docs/raw/reference/core/mastra-class.mdx +3 -2
  256. package/.docs/raw/reference/core/setLogger.mdx +2 -2
  257. package/.docs/raw/reference/core/setStorage.mdx +3 -2
  258. package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
  259. package/.docs/raw/reference/deployer/cloudflare.mdx +2 -2
  260. package/.docs/raw/reference/deployer/deployer.mdx +0 -6
  261. package/.docs/raw/reference/deployer/netlify.mdx +2 -2
  262. package/.docs/raw/reference/deployer/vercel.mdx +3 -3
  263. package/.docs/raw/reference/evals/answer-relevancy.mdx +164 -126
  264. package/.docs/raw/reference/{scorers → evals}/answer-similarity.mdx +27 -27
  265. package/.docs/raw/reference/evals/bias.mdx +149 -115
  266. package/.docs/raw/reference/evals/completeness.mdx +148 -117
  267. package/.docs/raw/reference/evals/content-similarity.mdx +126 -113
  268. package/.docs/raw/reference/evals/context-precision.mdx +290 -133
  269. package/.docs/raw/reference/{scorers → evals}/context-relevance.mdx +6 -6
  270. package/.docs/raw/reference/{scorers → evals}/create-scorer.mdx +11 -11
  271. package/.docs/raw/reference/evals/faithfulness.mdx +163 -121
  272. package/.docs/raw/reference/evals/hallucination.mdx +159 -132
  273. package/.docs/raw/reference/evals/keyword-coverage.mdx +169 -125
  274. package/.docs/raw/reference/{scorers → evals}/mastra-scorer.mdx +5 -5
  275. package/.docs/raw/reference/{scorers → evals}/noise-sensitivity.mdx +9 -9
  276. package/.docs/raw/reference/evals/prompt-alignment.mdx +604 -182
  277. package/.docs/raw/reference/{scorers/run-experiment.mdx → evals/run-evals.mdx} +17 -18
  278. package/.docs/raw/reference/evals/textual-difference.mdx +149 -117
  279. package/.docs/raw/reference/evals/tone-consistency.mdx +149 -125
  280. package/.docs/raw/reference/{scorers → evals}/tool-call-accuracy.mdx +8 -6
  281. package/.docs/raw/reference/evals/toxicity.mdx +152 -96
  282. package/.docs/raw/reference/{observability/logging → logging}/pino-logger.mdx +2 -2
  283. package/.docs/raw/reference/memory/createThread.mdx +5 -5
  284. package/.docs/raw/reference/memory/deleteMessages.mdx +7 -7
  285. package/.docs/raw/reference/memory/getThreadById.mdx +4 -4
  286. package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +110 -0
  287. package/.docs/raw/reference/memory/memory-class.mdx +13 -9
  288. package/.docs/raw/reference/memory/query.mdx +58 -57
  289. package/.docs/raw/reference/memory/recall.mdx +185 -0
  290. package/.docs/raw/reference/observability/tracing/configuration.mdx +245 -0
  291. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/arize.mdx +13 -13
  292. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +11 -8
  293. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/cloud-exporter.mdx +21 -19
  294. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/console-exporter.mdx +49 -17
  295. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/default-exporter.mdx +42 -41
  296. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +10 -7
  297. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +10 -7
  298. package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/otel.mdx +5 -5
  299. package/.docs/raw/reference/observability/tracing/instances.mdx +168 -0
  300. package/.docs/raw/reference/observability/{ai-tracing → tracing}/interfaces.mdx +115 -89
  301. package/.docs/raw/reference/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +3 -3
  302. package/.docs/raw/reference/observability/{ai-tracing/span.mdx → tracing/spans.mdx} +59 -41
  303. package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
  304. package/.docs/raw/reference/processors/language-detector.mdx +1 -1
  305. package/.docs/raw/reference/processors/moderation-processor.mdx +1 -1
  306. package/.docs/raw/reference/processors/pii-detector.mdx +1 -1
  307. package/.docs/raw/reference/processors/prompt-injection-detector.mdx +1 -1
  308. package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +1 -1
  309. package/.docs/raw/reference/processors/token-limiter-processor.mdx +1 -1
  310. package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
  311. package/.docs/raw/reference/rag/chunk.mdx +1 -8
  312. package/.docs/raw/reference/rag/database-config.mdx +7 -7
  313. package/.docs/raw/reference/rag/metadata-filters.mdx +14 -11
  314. package/.docs/raw/reference/storage/libsql.mdx +2 -0
  315. package/.docs/raw/reference/storage/mssql.mdx +5 -0
  316. package/.docs/raw/reference/storage/postgresql.mdx +6 -0
  317. package/.docs/raw/reference/storage/upstash.mdx +1 -0
  318. package/.docs/raw/reference/streaming/agents/stream.mdx +12 -12
  319. package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +8 -8
  320. package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -3
  321. package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +3 -3
  322. package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +6 -6
  323. package/.docs/raw/reference/streaming/workflows/stream.mdx +10 -10
  324. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +11 -11
  325. package/.docs/raw/reference/templates/overview.mdx +2 -2
  326. package/.docs/raw/reference/tools/create-tool.mdx +52 -35
  327. package/.docs/raw/reference/tools/graph-rag-tool.mdx +15 -15
  328. package/.docs/raw/reference/tools/mcp-client.mdx +1 -1
  329. package/.docs/raw/reference/tools/mcp-server.mdx +119 -35
  330. package/.docs/raw/reference/tools/vector-query-tool.mdx +27 -26
  331. package/.docs/raw/reference/vectors/libsql.mdx +1 -0
  332. package/.docs/raw/reference/vectors/pg.mdx +3 -0
  333. package/.docs/raw/reference/vectors/upstash.mdx +1 -0
  334. package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
  335. package/.docs/raw/reference/voice/voice.addTools.mdx +3 -3
  336. package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -4
  337. package/.docs/raw/reference/workflows/run-methods/resume.mdx +14 -14
  338. package/.docs/raw/reference/workflows/run-methods/start.mdx +17 -17
  339. package/.docs/raw/reference/workflows/run.mdx +1 -8
  340. package/.docs/raw/reference/workflows/step.mdx +5 -5
  341. package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +2 -2
  342. package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
  343. package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +7 -13
  344. package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
  345. package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
  346. package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
  347. package/.docs/raw/reference/workflows/workflow-methods/map.mdx +5 -0
  348. package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
  349. package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
  350. package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +1 -1
  351. package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +1 -1
  352. package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
  353. package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +1 -1
  354. package/.docs/raw/reference/workflows/workflow.mdx +1 -1
  355. package/.docs/raw/server-db/custom-api-routes.mdx +2 -2
  356. package/.docs/raw/server-db/mastra-client.mdx +19 -18
  357. package/.docs/raw/server-db/middleware.mdx +7 -7
  358. package/.docs/raw/server-db/production-server.mdx +4 -4
  359. package/.docs/raw/server-db/{runtime-context.mdx → request-context.mdx} +46 -45
  360. package/.docs/raw/server-db/storage.mdx +29 -21
  361. package/.docs/raw/streaming/events.mdx +3 -3
  362. package/.docs/raw/streaming/overview.mdx +5 -5
  363. package/.docs/raw/streaming/tool-streaming.mdx +18 -17
  364. package/.docs/raw/streaming/workflow-streaming.mdx +1 -1
  365. package/.docs/raw/tools-mcp/advanced-usage.mdx +5 -4
  366. package/.docs/raw/tools-mcp/mcp-overview.mdx +32 -19
  367. package/.docs/raw/tools-mcp/overview.mdx +11 -11
  368. package/.docs/raw/voice/overview.mdx +63 -43
  369. package/.docs/raw/voice/speech-to-speech.mdx +5 -3
  370. package/.docs/raw/voice/speech-to-text.mdx +9 -8
  371. package/.docs/raw/voice/text-to-speech.mdx +12 -11
  372. package/.docs/raw/workflows/agents-and-tools.mdx +9 -5
  373. package/.docs/raw/workflows/control-flow.mdx +3 -3
  374. package/.docs/raw/workflows/error-handling.mdx +2 -21
  375. package/.docs/raw/workflows/human-in-the-loop.mdx +7 -4
  376. package/.docs/raw/workflows/inngest-workflow.mdx +2 -2
  377. package/.docs/raw/workflows/input-data-mapping.mdx +107 -0
  378. package/.docs/raw/workflows/overview.mdx +17 -16
  379. package/.docs/raw/workflows/snapshots.mdx +13 -11
  380. package/.docs/raw/workflows/suspend-and-resume.mdx +23 -15
  381. package/CHANGELOG.md +52 -57
  382. package/README.md +11 -2
  383. package/dist/{chunk-TUAHUTTB.js → chunk-5NJC7NRO.js} +3 -0
  384. package/dist/index.d.ts.map +1 -1
  385. package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
  386. package/dist/prepare-docs/prepare.js +1 -1
  387. package/dist/prompts/migration.d.ts +6 -0
  388. package/dist/prompts/migration.d.ts.map +1 -0
  389. package/dist/stdio.js +402 -30
  390. package/dist/tools/migration.d.ts +40 -0
  391. package/dist/tools/migration.d.ts.map +1 -0
  392. package/package.json +8 -12
  393. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +0 -302
  394. package/.docs/raw/observability/nextjs-tracing.mdx +0 -109
  395. package/.docs/raw/observability/otel-tracing.mdx +0 -189
  396. package/.docs/raw/reference/agents/getScorers.mdx +0 -69
  397. package/.docs/raw/reference/agents/getTools.mdx +0 -69
  398. package/.docs/raw/reference/agents/getWorkflows.mdx +0 -69
  399. package/.docs/raw/reference/client-js/workflows-legacy.mdx +0 -143
  400. package/.docs/raw/reference/core/getAgents.mdx +0 -35
  401. package/.docs/raw/reference/core/getLogs.mdx +0 -96
  402. package/.docs/raw/reference/core/getLogsByRunId.mdx +0 -87
  403. package/.docs/raw/reference/core/getMCPServers.mdx +0 -36
  404. package/.docs/raw/reference/core/getMemory.mdx +0 -36
  405. package/.docs/raw/reference/core/getScorerByName.mdx +0 -78
  406. package/.docs/raw/reference/core/getScorers.mdx +0 -43
  407. package/.docs/raw/reference/core/getVectors.mdx +0 -36
  408. package/.docs/raw/reference/core/getWorkflows.mdx +0 -45
  409. package/.docs/raw/reference/evals/context-position.mdx +0 -197
  410. package/.docs/raw/reference/evals/context-relevancy.mdx +0 -196
  411. package/.docs/raw/reference/evals/contextual-recall.mdx +0 -196
  412. package/.docs/raw/reference/evals/summarization.mdx +0 -212
  413. package/.docs/raw/reference/legacyWorkflows/after.mdx +0 -89
  414. package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +0 -79
  415. package/.docs/raw/reference/legacyWorkflows/commit.mdx +0 -33
  416. package/.docs/raw/reference/legacyWorkflows/createRun.mdx +0 -76
  417. package/.docs/raw/reference/legacyWorkflows/else.mdx +0 -68
  418. package/.docs/raw/reference/legacyWorkflows/events.mdx +0 -305
  419. package/.docs/raw/reference/legacyWorkflows/execute.mdx +0 -110
  420. package/.docs/raw/reference/legacyWorkflows/if.mdx +0 -108
  421. package/.docs/raw/reference/legacyWorkflows/resume.mdx +0 -158
  422. package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +0 -133
  423. package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +0 -207
  424. package/.docs/raw/reference/legacyWorkflows/start.mdx +0 -87
  425. package/.docs/raw/reference/legacyWorkflows/step-class.mdx +0 -100
  426. package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +0 -137
  427. package/.docs/raw/reference/legacyWorkflows/step-function.mdx +0 -93
  428. package/.docs/raw/reference/legacyWorkflows/step-options.mdx +0 -69
  429. package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +0 -196
  430. package/.docs/raw/reference/legacyWorkflows/suspend.mdx +0 -70
  431. package/.docs/raw/reference/legacyWorkflows/then.mdx +0 -72
  432. package/.docs/raw/reference/legacyWorkflows/until.mdx +0 -168
  433. package/.docs/raw/reference/legacyWorkflows/watch.mdx +0 -124
  434. package/.docs/raw/reference/legacyWorkflows/while.mdx +0 -168
  435. package/.docs/raw/reference/legacyWorkflows/workflow.mdx +0 -234
  436. package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +0 -79
  437. package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +0 -110
  438. package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +0 -185
  439. package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +0 -238
  440. package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +0 -117
  441. package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +0 -81
  442. package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +0 -121
  443. package/.docs/raw/reference/observability/otel-tracing/providers/braintrust.mdx +0 -40
  444. package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +0 -40
  445. package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +0 -20
  446. package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +0 -73
  447. package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +0 -41
  448. package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +0 -84
  449. package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +0 -48
  450. package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +0 -43
  451. package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +0 -40
  452. package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +0 -40
  453. package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +0 -40
  454. package/.docs/raw/reference/scorers/answer-relevancy.mdx +0 -227
  455. package/.docs/raw/reference/scorers/bias.mdx +0 -228
  456. package/.docs/raw/reference/scorers/completeness.mdx +0 -214
  457. package/.docs/raw/reference/scorers/content-similarity.mdx +0 -197
  458. package/.docs/raw/reference/scorers/context-precision.mdx +0 -352
  459. package/.docs/raw/reference/scorers/faithfulness.mdx +0 -241
  460. package/.docs/raw/reference/scorers/hallucination.mdx +0 -252
  461. package/.docs/raw/reference/scorers/keyword-coverage.mdx +0 -229
  462. package/.docs/raw/reference/scorers/prompt-alignment.mdx +0 -668
  463. package/.docs/raw/reference/scorers/textual-difference.mdx +0 -203
  464. package/.docs/raw/reference/scorers/tone-consistency.mdx +0 -211
  465. package/.docs/raw/reference/scorers/toxicity.mdx +0 -228
  466. package/.docs/raw/reference/workflows/run-methods/watch.mdx +0 -73
  467. package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +0 -24
  468. package/.docs/raw/scorers/evals-old-api/overview.mdx +0 -106
  469. package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +0 -85
  470. package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +0 -58
  471. package/.docs/raw/scorers/off-the-shelf-scorers.mdx +0 -50
  472. package/.docs/raw/workflows-legacy/control-flow.mdx +0 -774
  473. package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +0 -239
  474. package/.docs/raw/workflows-legacy/error-handling.mdx +0 -187
  475. package/.docs/raw/workflows-legacy/nested-workflows.mdx +0 -360
  476. package/.docs/raw/workflows-legacy/overview.mdx +0 -182
  477. package/.docs/raw/workflows-legacy/runtime-variables.mdx +0 -156
  478. package/.docs/raw/workflows-legacy/steps.mdx +0 -115
  479. package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +0 -406
  480. package/.docs/raw/workflows-legacy/variables.mdx +0 -318
@@ -1,360 +0,0 @@
1
- ---
2
- title: "Nested Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
3
- sidebar_position: 4
4
- sidebar_label: "Nested Workflows"
5
- ---
6
-
7
- # Nested Workflows (Legacy)
8
-
9
- Mastra allows you to use workflows as steps within other workflows, enabling you to create modular and reusable workflow components. This feature helps in organizing complex workflows into smaller, manageable pieces and promotes code reuse.
10
-
11
- It is also visually easier to understand the flow of a workflow when you can see the nested workflows as steps in the parent workflow.
12
-
13
- ## Basic Usage
14
-
15
- You can use a workflow as a step directly in another workflow using the `step()` method:
16
-
17
- ```typescript
18
- import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
19
-
20
- // Create a nested workflow
21
- const nestedWorkflow = new LegacyWorkflow({ name: "nested-workflow" })
22
- .step(stepA)
23
- .then(stepB)
24
- .commit();
25
-
26
- // Use the nested workflow in a parent workflow
27
- const parentWorkflow = new LegacyWorkflow({ name: "parent-workflow" })
28
- .step(nestedWorkflow, {
29
- variables: {
30
- city: {
31
- step: "trigger",
32
- path: "myTriggerInput",
33
- },
34
- },
35
- })
36
- .then(stepC)
37
- .commit();
38
- ```
39
-
40
- When a workflow is used as a step:
41
-
42
- - It is automatically converted to a step using the workflow's name as the step ID
43
- - The workflow's results are available in the parent workflow's context
44
- - The nested workflow's steps are executed in their defined order
45
-
46
- ## Accessing Results
47
-
48
- Results from a nested workflow are available in the parent workflow's context under the nested workflow's name. The results include all step outputs from the nested workflow:
49
-
50
- ```typescript
51
- const { results } = await parentWorkflow.start();
52
- // Access nested workflow results
53
- const nestedWorkflowResult = results["nested-workflow"];
54
- if (nestedWorkflowResult.status === "success") {
55
- const nestedResults = nestedWorkflowResult.output.results;
56
- }
57
- ```
58
-
59
- ## Control Flow with Nested Workflows
60
-
61
- Nested workflows support all the control flow features available to regular steps:
62
-
63
- ### Parallel Execution
64
-
65
- Multiple nested workflows can be executed in parallel:
66
-
67
- ```typescript
68
- parentWorkflow
69
- .step(nestedWorkflowA)
70
- .step(nestedWorkflowB)
71
- .after([nestedWorkflowA, nestedWorkflowB])
72
- .step(finalStep);
73
- ```
74
-
75
- Or using `step()` with an array of workflows:
76
-
77
- ```typescript
78
- parentWorkflow.step([nestedWorkflowA, nestedWorkflowB]).then(finalStep);
79
- ```
80
-
81
- In this case, `then()` will implicitly wait for all the workflows to finish before executing the final step.
82
-
83
- ### If-Else Branching
84
-
85
- Nested workflows can be used in if-else branches using the new syntax that accepts both branches as arguments:
86
-
87
- ```typescript
88
- // Create nested workflows for different paths
89
- const workflowA = new LegacyWorkflow({ name: "workflow-a" })
90
- .step(stepA1)
91
- .then(stepA2)
92
- .commit();
93
-
94
- const workflowB = new LegacyWorkflow({ name: "workflow-b" })
95
- .step(stepB1)
96
- .then(stepB2)
97
- .commit();
98
-
99
- // Use the new if-else syntax with nested workflows
100
- parentWorkflow
101
- .step(initialStep)
102
- .if(
103
- async ({ context }) => {
104
- // Your condition here
105
- return someCondition;
106
- },
107
- workflowA, // if branch
108
- workflowB, // else branch
109
- )
110
- .then(finalStep)
111
- .commit();
112
- ```
113
-
114
- The new syntax is more concise and clearer when working with nested workflows. When the condition is:
115
-
116
- - `true`: The first workflow (if branch) is executed
117
- - `false`: The second workflow (else branch) is executed
118
-
119
- The skipped workflow will have a status of `skipped` in the results:
120
-
121
- The `.then(finalStep)` call following the if-else block will merge the if and else branches back into a single execution path.
122
-
123
- ### Looping
124
-
125
- Nested workflows can use `.until()` and `.while()` loops same as any other step. One interesting new pattern is to pass a workflow directly as the loop-back argument to keep executing that nested workflow until something is true about its results:
126
-
127
- ```typescript
128
- parentWorkflow
129
- .step(firstStep)
130
- .while(
131
- ({ context }) =>
132
- context.getStepResult("nested-workflow").output.results.someField ===
133
- "someValue",
134
- nestedWorkflow,
135
- )
136
- .step(finalStep)
137
- .commit();
138
- ```
139
-
140
- ## Watching Nested Workflows
141
-
142
- You can watch the state changes of nested workflows using the `watch` method on the parent workflow. This is useful for monitoring the progress and state transitions of complex workflows:
143
-
144
- ```typescript
145
- const parentWorkflow = new LegacyWorkflow({ name: "parent-workflow" })
146
- .step([nestedWorkflowA, nestedWorkflowB])
147
- .then(finalStep)
148
- .commit();
149
-
150
- const run = parentWorkflow.createRun();
151
- const unwatch = parentWorkflow.watch((state) => {
152
- console.log("Current state:", state.value);
153
- // Access nested workflow states in state.context
154
- });
155
-
156
- await run.start();
157
- unwatch(); // Stop watching when done
158
- ```
159
-
160
- ## Suspending and Resuming
161
-
162
- Nested workflows support suspension and resumption, allowing you to pause and continue workflow execution at specific points. You can suspend either the entire nested workflow or specific steps within it:
163
-
164
- ```typescript
165
- // Define a step that may need to suspend
166
- const suspendableStep = new LegacyStep({
167
- id: "other",
168
- description: "Step that may need to suspend",
169
- execute: async ({ context, suspend }) => {
170
- if (!wasSuspended) {
171
- wasSuspended = true;
172
- await suspend();
173
- }
174
- return { other: 26 };
175
- },
176
- });
177
-
178
- // Create a nested workflow with suspendable steps
179
- const nestedWorkflow = new LegacyWorkflow({ name: "nested-workflow-a" })
180
- .step(startStep)
181
- .then(suspendableStep)
182
- .then(finalStep)
183
- .commit();
184
-
185
- // Use in parent workflow
186
- const parentWorkflow = new LegacyWorkflow({ name: "parent-workflow" })
187
- .step(beginStep)
188
- .then(nestedWorkflow)
189
- .then(lastStep)
190
- .commit();
191
-
192
- // Start the workflow
193
- const run = parentWorkflow.createRun();
194
- const { runId, results } = await run.start({ triggerData: { startValue: 1 } });
195
-
196
- // Check if a specific step in the nested workflow is suspended
197
- if (results["nested-workflow-a"].output.results.other.status === "suspended") {
198
- // Resume the specific suspended step using dot notation
199
- const resumedResults = await run.resume({
200
- stepId: "nested-workflow-a.other",
201
- context: { startValue: 1 },
202
- });
203
-
204
- // The resumed results will contain the completed nested workflow
205
- expect(resumedResults.results["nested-workflow-a"].output.results).toEqual({
206
- start: { output: { newValue: 1 }, status: "success" },
207
- other: { output: { other: 26 }, status: "success" },
208
- final: { output: { finalValue: 27 }, status: "success" },
209
- });
210
- }
211
- ```
212
-
213
- When resuming a nested workflow:
214
-
215
- - Use the nested workflow's name as the `stepId` when calling `resume()` to resume the entire workflow
216
- - Use dot notation (`nested-workflow.step-name`) to resume a specific step within the nested workflow
217
- - The nested workflow will continue from the suspended step with the provided context
218
- - You can check the status of specific steps in the nested workflow's results using `results["nested-workflow"].output.results`
219
-
220
- ## Result Schemas and Mapping
221
-
222
- Nested workflows can define their result schema and mapping, which helps in type safety and data transformation. This is particularly useful when you want to ensure the nested workflow's output matches a specific structure or when you need to transform the results before they're used in the parent workflow.
223
-
224
- ```typescript
225
- // Create a nested workflow with result schema and mapping
226
- const nestedWorkflow = new LegacyWorkflow({
227
- name: "nested-workflow",
228
- result: {
229
- schema: z.object({
230
- total: z.number(),
231
- items: z.array(
232
- z.object({
233
- id: z.string(),
234
- value: z.number(),
235
- }),
236
- ),
237
- }),
238
- mapping: {
239
- // Map values from step results using variables syntax
240
- total: { step: "step-a", path: "count" },
241
- items: { step: "step-b", path: "items" },
242
- },
243
- },
244
- })
245
- .step(stepA)
246
- .then(stepB)
247
- .commit();
248
-
249
- // Use in parent workflow with type-safe results
250
- const parentWorkflow = new LegacyWorkflow({ name: "parent-workflow" })
251
- .step(nestedWorkflow)
252
- .then(async ({ context }) => {
253
- const result = context.getStepResult("nested-workflow");
254
- // TypeScript knows the structure of result
255
- console.log(result.total); // number
256
- console.log(result.items); // Array<{ id: string, value: number }>
257
- return { success: true };
258
- })
259
- .commit();
260
- ```
261
-
262
- ## Best Practices
263
-
264
- 1. **Modularity**: Use nested workflows to encapsulate related steps and create reusable workflow components.
265
- 2. **Naming**: Give nested workflows descriptive names as they will be used as step IDs in the parent workflow.
266
- 3. **Error Handling**: Nested workflows propagate their errors to the parent workflow, so handle errors appropriately.
267
- 4. **State Management**: Each nested workflow maintains its own state but can access the parent workflow's context.
268
- 5. **Suspension**: When using suspension in nested workflows, consider the entire workflow's state and handle resumption appropriately.
269
-
270
- ## Example
271
-
272
- Here's a complete example showing various features of nested workflows:
273
-
274
- ```typescript
275
- const workflowA = new LegacyWorkflow({
276
- name: "workflow-a",
277
- result: {
278
- schema: z.object({
279
- activities: z.string(),
280
- }),
281
- mapping: {
282
- activities: {
283
- step: planActivities,
284
- path: "activities",
285
- },
286
- },
287
- },
288
- })
289
- .step(fetchWeather)
290
- .then(planActivities)
291
- .commit();
292
-
293
- const workflowB = new LegacyWorkflow({
294
- name: "workflow-b",
295
- result: {
296
- schema: z.object({
297
- activities: z.string(),
298
- }),
299
- mapping: {
300
- activities: {
301
- step: planActivities,
302
- path: "activities",
303
- },
304
- },
305
- },
306
- })
307
- .step(fetchWeather)
308
- .then(planActivities)
309
- .commit();
310
-
311
- const weatherWorkflow = new LegacyWorkflow({
312
- name: "weather-workflow",
313
- triggerSchema: z.object({
314
- cityA: z.string().describe("The city to get the weather for"),
315
- cityB: z.string().describe("The city to get the weather for"),
316
- }),
317
- result: {
318
- schema: z.object({
319
- activitiesA: z.string(),
320
- activitiesB: z.string(),
321
- }),
322
- mapping: {
323
- activitiesA: {
324
- step: workflowA,
325
- path: "result.activities",
326
- },
327
- activitiesB: {
328
- step: workflowB,
329
- path: "result.activities",
330
- },
331
- },
332
- },
333
- })
334
- .step(workflowA, {
335
- variables: {
336
- city: {
337
- step: "trigger",
338
- path: "cityA",
339
- },
340
- },
341
- })
342
- .step(workflowB, {
343
- variables: {
344
- city: {
345
- step: "trigger",
346
- path: "cityB",
347
- },
348
- },
349
- });
350
-
351
- weatherWorkflow.commit();
352
- ```
353
-
354
- In this example:
355
-
356
- 1. We define schemas for type safety across all workflows
357
- 2. Each step has proper input and output schemas
358
- 3. The nested workflows have their own trigger schemas and result mappings
359
- 4. Data is passed through using variables syntax in the `.step()` calls
360
- 5. The main workflow combines data from both nested workflows
@@ -1,182 +0,0 @@
1
- ---
2
- title: "Handling Complex LLM Operations with Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
3
- sidebar_position: 1
4
- sidebar_label: "Overview"
5
- description: "Workflows in Mastra help you orchestrate complex sequences of operations with features like branching, parallel execution, resource suspension, and more."
6
- ---
7
-
8
- # Handling Complex LLM Operations with Workflows (Legacy)
9
-
10
- All the legacy workflow documentation is available on the links below.
11
-
12
- - [Steps](/docs/workflows-legacy/steps)
13
- - [Control Flow](/docs/workflows-legacy/control-flow)
14
- - [Variables](/docs/workflows-legacy/variables)
15
- - [Suspend & Resume](/docs/workflows-legacy/suspend-and-resume)
16
- - [Dynamic Workflows](/docs/workflows-legacy/dynamic-workflows)
17
- - [Error Handling](/docs/workflows-legacy/error-handling)
18
- - [Nested Workflows](/docs/workflows-legacy/nested-workflows)
19
- - [Runtime/Dynamic Variables](/docs/workflows-legacy/runtime-variables)
20
-
21
- Workflows in Mastra help you orchestrate complex sequences of operations with features like branching, parallel execution, resource suspension, and more.
22
-
23
- ## When to use workflows
24
-
25
- Most AI applications need more than a single call to a language model. You may want to run multiple steps, conditionally skip certain paths, or even pause execution altogether until you receive user input. Sometimes your agent tool calling is not accurate enough.
26
-
27
- Mastra's workflow system provides:
28
-
29
- - A standardized way to define steps and link them together.
30
- - Support for both simple (linear) and advanced (branching, parallel) paths.
31
- - Debugging and observability features to track each workflow run.
32
-
33
- ## Example
34
-
35
- To create a workflow, you define one or more steps, link them, and then commit the workflow before starting it.
36
-
37
- ### Breaking Down the Workflow (Legacy)
38
-
39
- Let's examine each part of the workflow creation process:
40
-
41
- #### 1. Creating the Workflow
42
-
43
- Here's how you define a workflow in Mastra. The `name` field determines the workflow's API endpoint (`/workflows/$NAME/`), while the `triggerSchema` defines the structure of the workflow's trigger data:
44
-
45
- ```ts title="src/mastra/workflow/index.ts"
46
- import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
47
-
48
- const myWorkflow = new LegacyWorkflow({
49
- name: "my-workflow",
50
- triggerSchema: z.object({
51
- inputValue: z.number(),
52
- }),
53
- });
54
- ```
55
-
56
- #### 2. Defining Steps
57
-
58
- Now, we'll define the workflow's steps. Each step can have its own input and output schemas. Here, `stepOne` doubles an input value, and `stepTwo` increments that result if `stepOne` was successful. (To keep things simple, we aren't making any LLM calls in this example):
59
-
60
- ```ts title="src/mastra/workflow/index.ts"
61
- const stepOne = new LegacyStep({
62
- id: "stepOne",
63
- outputSchema: z.object({
64
- doubledValue: z.number(),
65
- }),
66
- execute: async ({ context }) => {
67
- const doubledValue = context.triggerData.inputValue * 2;
68
- return { doubledValue };
69
- },
70
- });
71
-
72
- const stepTwo = new LegacyStep({
73
- id: "stepTwo",
74
- execute: async ({ context }) => {
75
- const doubledValue = context.getStepResult(stepOne)?.doubledValue;
76
- if (!doubledValue) {
77
- return { incrementedValue: 0 };
78
- }
79
- return {
80
- incrementedValue: doubledValue + 1,
81
- };
82
- },
83
- });
84
- ```
85
-
86
- #### 3. Linking Steps
87
-
88
- Now, let's create the control flow, and "commit" (finalize the workflow). In this case, `stepOne` runs first and is followed by `stepTwo`.
89
-
90
- ```ts title="src/mastra/workflow/index.ts"
91
- myWorkflow.step(stepOne).then(stepTwo).commit();
92
- ```
93
-
94
- ### Register the Workflow
95
-
96
- Register your workflow with Mastra to enable logging and telemetry:
97
-
98
- ```ts showLineNumbers title="src/mastra/index.ts"
99
- import { Mastra } from "@mastra/core";
100
-
101
- export const mastra = new Mastra({
102
- legacy_workflows: { myWorkflow },
103
- });
104
- ```
105
-
106
- The workflow can also have the mastra instance injected into the context in the case where you need to create dynamic workflows:
107
-
108
- ```ts title="src/mastra/workflow/index.ts"
109
- import { Mastra } from "@mastra/core";
110
- import { LegacyWorkflow } from "@mastra/core/workflows/legacy";
111
-
112
- const mastra = new Mastra();
113
-
114
- const myWorkflow = new LegacyWorkflow({
115
- name: "my-workflow",
116
- mastra,
117
- });
118
- ```
119
-
120
- ### Executing the Workflow
121
-
122
- Execute your workflow programmatically or via API:
123
-
124
- ```ts showLineNumbers title="src/mastra/run-workflow.ts" copy
125
- import { mastra } from "./index";
126
-
127
- // Get the workflow
128
- const myWorkflow = mastra.legacy_getWorkflow("myWorkflow");
129
- const { runId, start } = myWorkflow.createRun();
130
-
131
- // Start the workflow execution
132
- await start({ triggerData: { inputValue: 45 } });
133
- ```
134
-
135
- Or use the API (requires running `mastra dev`):
136
-
137
- // Create workflow run
138
-
139
- ```bash
140
- curl --location 'http://localhost:4111/api/workflows/myWorkflow/start-async' \
141
- --header 'Content-Type: application/json' \
142
- --data '{
143
- "inputValue": 45
144
- }'
145
- ```
146
-
147
- This example shows the essentials: define your workflow, add steps, commit the workflow, then execute it.
148
-
149
- ## Defining Steps
150
-
151
- The basic building block of a workflow [is a step](./steps). Steps are defined using schemas for inputs and outputs, and can fetch prior step results.
152
-
153
- ## Control Flow
154
-
155
- Workflows let you define a [control flow](./control-flow) to chain steps together in with parallel steps, branching paths, and more.
156
-
157
- ## Workflow Variables
158
-
159
- When you need to map data between steps or create dynamic data flows, [workflow variables](./variables) provide a powerful mechanism for passing information from one step to another and accessing nested properties within step outputs.
160
-
161
- ## Suspend and Resume
162
-
163
- When you need to pause execution for external data, user input, or asynchronous events, Mastra [supports suspension at any step](./suspend-and-resume), persisting the state of the workflow so you can resume it later.
164
-
165
- ## Observability and Debugging
166
-
167
- Mastra workflows automatically [log the input and output of each step within a workflow run](/docs/observability/otel-tracing), allowing you to send this data to your preferred logging, telemetry, or observability tools.
168
-
169
- You can:
170
-
171
- - Track the status of each step (e.g., `success`, `error`, or `suspended`).
172
- - Store run-specific metadata for analysis.
173
- - Integrate with third-party observability platforms like Datadog or New Relic by forwarding logs.
174
-
175
- ## More Resources
176
-
177
- - [Sequential Steps workflow example](/examples/workflows_legacy/sequential-steps)
178
- - [Parallel Steps workflow example](/examples/workflows_legacy/parallel-steps)
179
- - [Branching Paths workflow example](/examples/workflows_legacy/branching-paths)
180
- - [Workflow Variables example](/examples/workflows_legacy/workflow-variables)
181
- - [Cyclical Dependencies workflow example](/examples/workflows_legacy/cyclical-dependencies)
182
- - [Suspend and Resume workflow example](/examples/workflows_legacy/suspend-and-resume)
@@ -1,156 +0,0 @@
1
- ---
2
- title: "Workflow Runtime Variables (Legacy) | Workflows (Legacy) | Mastra Docs"
3
- sidebar_position: 6
4
- sidebar_label: "Runtime/Dynamic Variables"
5
- description: Learn how to use Mastra's dependency injection system to provide runtime configuration to workflows and steps.
6
- ---
7
-
8
- # Workflow Runtime Variables (Legacy)
9
-
10
- Mastra provides a powerful dependency injection system that enables you to configure your workflows and steps with runtime variables. This feature is essential for creating flexible and reusable workflows that can adapt their behavior based on runtime configuration.
11
-
12
- ## Overview
13
-
14
- The dependency injection system allows you to:
15
-
16
- 1. Pass runtime configuration variables to workflows through a type-safe runtimeContext
17
- 2. Access these variables within step execution contexts
18
- 3. Modify workflow behavior without changing the underlying code
19
- 4. Share configuration across multiple steps within the same workflow
20
-
21
- ## Basic Usage
22
-
23
- ```typescript
24
- const myWorkflow = mastra.legacy_getWorkflow("myWorkflow");
25
- const { runId, start, resume } = myWorkflow.createRun();
26
-
27
- // Define your runtimeContext's type structure
28
- type WorkflowRuntimeContext = {
29
- multiplier: number;
30
- };
31
-
32
- const runtimeContext = new RuntimeContext<WorkflowRuntimeContext>();
33
- runtimeContext.set("multiplier", 5);
34
-
35
- // Start the workflow execution with runtimeContext
36
- await start({
37
- triggerData: { inputValue: 45 },
38
- runtimeContext,
39
- });
40
- ```
41
-
42
- ## Using with REST API
43
-
44
- Here's how to dynamically set a multiplier value from an HTTP header:
45
-
46
- ```typescript title="src/index.ts"
47
- import { Mastra } from "@mastra/core";
48
- import { RuntimeContext } from "@mastra/core/di";
49
- import { workflow as myWorkflow } from "./workflows";
50
-
51
- // Define runtimeContext type with clear, descriptive types
52
- type WorkflowRuntimeContext = {
53
- multiplier: number;
54
- };
55
-
56
- export const mastra = new Mastra({
57
- legacy_workflows: {
58
- myWorkflow,
59
- },
60
- server: {
61
- middleware: [
62
- async (c, next) => {
63
- const multiplier = c.req.header("x-multiplier");
64
- const runtimeContext = c.get<WorkflowRuntimeContext>("runtimeContext");
65
-
66
- // Parse and validate the multiplier value
67
- const multiplierValue = parseInt(multiplier || "1", 10);
68
- if (isNaN(multiplierValue)) {
69
- throw new Error("Invalid multiplier value");
70
- }
71
-
72
- runtimeContext.set("multiplier", multiplierValue);
73
-
74
- await next(); // Don't forget to call next()
75
- },
76
- ],
77
- },
78
- });
79
- ```
80
-
81
- ## Creating Steps with Variables
82
-
83
- Steps can access runtimeContext variables and must conform to the workflow's runtimeContext type:
84
-
85
- ```typescript
86
- import { LegacyStep } from "@mastra/core/workflows/legacy";
87
- import { z } from "zod";
88
-
89
- // Define step input/output types
90
- interface StepInput {
91
- inputValue: number;
92
- }
93
-
94
- interface StepOutput {
95
- incrementedValue: number;
96
- }
97
-
98
- const stepOne = new LegacyStep({
99
- id: "stepOne",
100
- description: "Multiply the input value by the configured multiplier",
101
- execute: async ({ context, runtimeContext }) => {
102
- try {
103
- // Type-safe access to runtimeContext variables
104
- const multiplier = runtimeContext.get("multiplier");
105
- if (multiplier === undefined) {
106
- throw new Error("Multiplier not configured in runtimeContext");
107
- }
108
-
109
- // Get and validate input
110
- const inputValue =
111
- context.getStepResult<StepInput>("trigger")?.inputValue;
112
- if (inputValue === undefined) {
113
- throw new Error("Input value not provided");
114
- }
115
-
116
- const result: StepOutput = {
117
- incrementedValue: inputValue * multiplier,
118
- };
119
-
120
- return result;
121
- } catch (error) {
122
- console.error(`Error in stepOne: ${error.message}`);
123
- throw error;
124
- }
125
- },
126
- });
127
- ```
128
-
129
- ## Error Handling
130
-
131
- When working with runtime variables in workflows, it's important to handle potential errors:
132
-
133
- 1. **Missing Variables**: Always check if required variables exist in the runtimeContext
134
- 2. **Type Mismatches**: Use TypeScript's type system to catch type errors at compile time
135
- 3. **Invalid Values**: Validate variable values before using them in your steps
136
-
137
- ```typescript
138
- // Example of defensive programming with runtimeContext variables
139
- const multiplier = runtimeContext.get("multiplier");
140
- if (multiplier === undefined) {
141
- throw new Error("Multiplier not configured in runtimeContext");
142
- }
143
-
144
- // Type and value validation
145
- if (typeof multiplier !== "number" || multiplier <= 0) {
146
- throw new Error(`Invalid multiplier value: ${multiplier}`);
147
- }
148
- ```
149
-
150
- ## Best Practices
151
-
152
- 1. **Type Safety**: Always define proper types for your runtimeContext and step inputs/outputs
153
- 2. **Validation**: Validate all inputs and runtimeContext variables before using them
154
- 3. **Error Handling**: Implement proper error handling in your steps
155
- 4. **Documentation**: Document the expected runtimeContext variables for each workflow
156
- 5. **Default Values**: Provide sensible defaults when possible