@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.
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +1 -0
- package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +36 -36
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +0 -10
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +40 -40
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +4 -14
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +223 -223
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +214 -214
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +74 -74
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +209 -209
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +191 -191
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +5 -13
- package/.docs/organized/changelogs/%40mastra%2Flance.md +182 -182
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +228 -228
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +206 -206
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +197 -197
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +217 -217
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Frag.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Freact.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -17
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -30
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +206 -206
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +20 -20
- package/.docs/organized/changelogs/create-mastra.md +33 -33
- package/.docs/organized/changelogs/mastra.md +86 -86
- package/.docs/organized/code-examples/a2a.md +4 -2
- package/.docs/organized/code-examples/agui.md +12 -9
- package/.docs/organized/code-examples/ai-sdk-useChat.md +12 -18
- package/.docs/organized/code-examples/ai-sdk-v5.md +4 -2
- package/.docs/organized/code-examples/bird-checker-with-express.md +5 -4
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +4 -3
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +4 -3
- package/.docs/organized/code-examples/client-side-tools.md +1 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +8 -177
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +10 -7
- package/.docs/organized/code-examples/mcp-configuration.md +5 -3
- package/.docs/organized/code-examples/mcp-registry-registry.md +3 -2
- package/.docs/organized/code-examples/memory-per-resource-example.md +4 -2
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -0
- package/.docs/organized/code-examples/memory-with-context.md +2 -1
- package/.docs/organized/code-examples/memory-with-libsql.md +4 -2
- package/.docs/organized/code-examples/memory-with-mongodb.md +4 -2
- package/.docs/organized/code-examples/memory-with-pg.md +4 -2
- package/.docs/organized/code-examples/memory-with-processors.md +13 -8
- package/.docs/organized/code-examples/memory-with-upstash.md +5 -3
- package/.docs/organized/code-examples/openapi-spec-writer.md +32 -41
- package/.docs/organized/code-examples/quick-start.md +5 -32
- package/.docs/organized/code-examples/stock-price-tool.md +6 -5
- package/.docs/organized/code-examples/weather-agent.md +21 -16
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +3 -2
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +9 -12
- package/.docs/organized/code-examples/workflow-with-memory.md +16 -15
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +2 -2
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +3 -2
- package/.docs/raw/agents/adding-voice.mdx +27 -22
- package/.docs/raw/agents/agent-memory.mdx +23 -15
- package/.docs/raw/agents/guardrails.mdx +33 -12
- package/.docs/raw/agents/networks.mdx +8 -4
- package/.docs/raw/agents/overview.mdx +21 -15
- package/.docs/raw/agents/using-tools.mdx +11 -8
- package/.docs/raw/auth/auth0.mdx +8 -8
- package/.docs/raw/auth/clerk.mdx +6 -6
- package/.docs/raw/auth/firebase.mdx +8 -8
- package/.docs/raw/auth/index.mdx +6 -6
- package/.docs/raw/auth/jwt.mdx +6 -6
- package/.docs/raw/auth/supabase.mdx +7 -7
- package/.docs/raw/auth/workos.mdx +8 -8
- package/.docs/raw/community/contributing-templates.mdx +3 -3
- package/.docs/raw/community/discord.mdx +1 -1
- package/.docs/raw/course/01-first-agent/08-exporting-your-agent.md +2 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +2 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -0
- package/.docs/raw/course/03-agent-memory/10-storage-configuration.md +2 -3
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +2 -0
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -0
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -0
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +1 -0
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -0
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +1 -0
- package/.docs/raw/course/04-workflows/08-running-workflows-programmatically.md +2 -2
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +5 -5
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +7 -5
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +3 -3
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +4 -4
- package/.docs/raw/deployment/cloud-providers/index.mdx +11 -8
- package/.docs/raw/deployment/monorepo.mdx +2 -2
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/server-deployment.mdx +2 -10
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +4 -4
- package/.docs/raw/deployment/serverless-platforms/index.mdx +10 -7
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +4 -4
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +4 -4
- package/.docs/raw/deployment/web-framework.mdx +8 -8
- package/.docs/raw/{scorers → evals}/custom-scorers.mdx +6 -6
- package/.docs/raw/evals/off-the-shelf-scorers.mdx +50 -0
- package/.docs/raw/{scorers → evals}/overview.mdx +8 -8
- package/.docs/raw/evals/running-in-ci.mdx +113 -0
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +22 -21
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +8 -8
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +3 -0
- package/.docs/raw/frameworks/servers/express.mdx +10 -9
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +6 -6
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +3 -3
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +2 -2
- package/.docs/raw/getting-started/installation.mdx +13 -12
- package/.docs/raw/getting-started/mcp-docs-server.mdx +1 -1
- package/.docs/raw/getting-started/project-structure.mdx +4 -4
- package/.docs/raw/getting-started/studio.mdx +8 -8
- package/.docs/raw/getting-started/templates.mdx +1 -1
- package/.docs/raw/guides/guide/ai-recruiter.mdx +264 -0
- package/.docs/raw/guides/guide/chef-michel.mdx +271 -0
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +450 -0
- package/.docs/raw/guides/guide/research-assistant.mdx +389 -0
- package/.docs/raw/guides/guide/stock-agent.mdx +185 -0
- package/.docs/raw/guides/guide/web-search.mdx +291 -0
- package/.docs/raw/guides/index.mdx +43 -0
- package/.docs/raw/guides/migrations/agentnetwork.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/_template.mdx +50 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +265 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +48 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +153 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +230 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +171 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +241 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +83 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +62 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +270 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +115 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +280 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +23 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/voice.mdx +39 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +178 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +367 -0
- package/.docs/raw/index.mdx +9 -9
- package/.docs/raw/{observability/logging.mdx → logging.mdx} +4 -4
- package/.docs/raw/mastra-cloud/dashboard.mdx +2 -2
- package/.docs/raw/mastra-cloud/observability.mdx +6 -6
- package/.docs/raw/mastra-cloud/overview.mdx +2 -2
- package/.docs/raw/mastra-cloud/setting-up.mdx +4 -4
- package/.docs/raw/memory/conversation-history.mdx +1 -0
- package/.docs/raw/memory/memory-processors.mdx +4 -3
- package/.docs/raw/memory/overview.mdx +9 -5
- package/.docs/raw/memory/semantic-recall.mdx +12 -7
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +10 -5
- package/.docs/raw/memory/storage/memory-with-pg.mdx +9 -4
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +9 -4
- package/.docs/raw/memory/threads-and-resources.mdx +11 -13
- package/.docs/raw/memory/working-memory.mdx +30 -14
- package/.docs/raw/observability/overview.mdx +13 -30
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/arize.mdx +10 -18
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +7 -16
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/cloud.mdx +11 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/default.mdx +16 -20
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +7 -16
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +7 -16
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/otel.mdx +9 -18
- package/.docs/raw/observability/{ai-tracing → tracing}/overview.mdx +107 -142
- package/.docs/raw/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +14 -13
- package/.docs/raw/rag/chunking-and-embedding.mdx +5 -5
- package/.docs/raw/rag/overview.mdx +3 -13
- package/.docs/raw/rag/retrieval.mdx +24 -12
- package/.docs/raw/rag/vector-databases.mdx +7 -1
- package/.docs/raw/reference/agents/agent.mdx +33 -28
- package/.docs/raw/reference/agents/generate.mdx +10 -10
- package/.docs/raw/reference/agents/generateLegacy.mdx +8 -8
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +21 -15
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +69 -0
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +22 -16
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +8 -8
- package/.docs/raw/reference/agents/getLLM.mdx +9 -9
- package/.docs/raw/reference/agents/getMemory.mdx +9 -9
- package/.docs/raw/reference/agents/getModel.mdx +10 -10
- package/.docs/raw/reference/agents/getVoice.mdx +8 -8
- package/.docs/raw/reference/agents/listAgents.mdx +9 -9
- package/.docs/raw/reference/agents/listScorers.mdx +7 -7
- package/.docs/raw/reference/agents/listTools.mdx +7 -7
- package/.docs/raw/reference/agents/listWorkflows.mdx +7 -7
- package/.docs/raw/reference/agents/network.mdx +11 -10
- package/.docs/raw/reference/auth/auth0.mdx +4 -4
- package/.docs/raw/reference/auth/clerk.mdx +4 -4
- package/.docs/raw/reference/auth/firebase.mdx +6 -6
- package/.docs/raw/reference/auth/jwt.mdx +4 -4
- package/.docs/raw/reference/auth/supabase.mdx +4 -4
- package/.docs/raw/reference/auth/workos.mdx +4 -4
- package/.docs/raw/reference/cli/mastra.mdx +7 -7
- package/.docs/raw/reference/client-js/agents.mdx +6 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +7 -7
- package/.docs/raw/reference/client-js/memory.mdx +24 -16
- package/.docs/raw/reference/client-js/observability.mdx +11 -11
- package/.docs/raw/reference/client-js/workflows.mdx +6 -34
- package/.docs/raw/reference/core/getAgent.mdx +1 -1
- package/.docs/raw/reference/core/getAgentById.mdx +1 -1
- package/.docs/raw/reference/core/getDeployer.mdx +2 -2
- package/.docs/raw/reference/core/getLogger.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServer.mdx +31 -15
- package/.docs/raw/reference/core/getMCPServerById.mdx +81 -0
- package/.docs/raw/reference/core/getScorer.mdx +3 -3
- package/.docs/raw/reference/core/getScorerById.mdx +79 -0
- package/.docs/raw/reference/core/getServer.mdx +2 -2
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getTelemetry.mdx +2 -2
- package/.docs/raw/reference/core/getVector.mdx +2 -2
- package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
- package/.docs/raw/reference/core/listAgents.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +2 -2
- package/.docs/raw/reference/core/listLogsByRunId.mdx +2 -2
- package/.docs/raw/reference/core/listMCPServers.mdx +65 -0
- package/.docs/raw/reference/core/listScorers.mdx +3 -3
- package/.docs/raw/reference/core/listVectors.mdx +36 -0
- package/.docs/raw/reference/core/listWorkflows.mdx +6 -6
- package/.docs/raw/reference/core/mastra-class.mdx +3 -2
- package/.docs/raw/reference/core/setLogger.mdx +2 -2
- package/.docs/raw/reference/core/setStorage.mdx +3 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
- package/.docs/raw/reference/deployer/cloudflare.mdx +2 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -6
- package/.docs/raw/reference/deployer/netlify.mdx +2 -2
- package/.docs/raw/reference/deployer/vercel.mdx +3 -3
- package/.docs/raw/reference/evals/answer-relevancy.mdx +164 -126
- package/.docs/raw/reference/{scorers → evals}/answer-similarity.mdx +27 -27
- package/.docs/raw/reference/evals/bias.mdx +149 -115
- package/.docs/raw/reference/evals/completeness.mdx +148 -117
- package/.docs/raw/reference/evals/content-similarity.mdx +126 -113
- package/.docs/raw/reference/evals/context-precision.mdx +290 -133
- package/.docs/raw/reference/{scorers → evals}/context-relevance.mdx +6 -6
- package/.docs/raw/reference/{scorers → evals}/create-scorer.mdx +11 -11
- package/.docs/raw/reference/evals/faithfulness.mdx +163 -121
- package/.docs/raw/reference/evals/hallucination.mdx +159 -132
- package/.docs/raw/reference/evals/keyword-coverage.mdx +169 -125
- package/.docs/raw/reference/{scorers → evals}/mastra-scorer.mdx +5 -5
- package/.docs/raw/reference/{scorers → evals}/noise-sensitivity.mdx +9 -9
- package/.docs/raw/reference/evals/prompt-alignment.mdx +604 -182
- package/.docs/raw/reference/{scorers/run-experiment.mdx → evals/run-evals.mdx} +17 -18
- package/.docs/raw/reference/evals/textual-difference.mdx +149 -117
- package/.docs/raw/reference/evals/tone-consistency.mdx +149 -125
- package/.docs/raw/reference/{scorers → evals}/tool-call-accuracy.mdx +8 -6
- package/.docs/raw/reference/evals/toxicity.mdx +152 -96
- package/.docs/raw/reference/{observability/logging → logging}/pino-logger.mdx +2 -2
- package/.docs/raw/reference/memory/createThread.mdx +5 -5
- package/.docs/raw/reference/memory/deleteMessages.mdx +7 -7
- package/.docs/raw/reference/memory/getThreadById.mdx +4 -4
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +110 -0
- package/.docs/raw/reference/memory/memory-class.mdx +13 -9
- package/.docs/raw/reference/memory/query.mdx +58 -57
- package/.docs/raw/reference/memory/recall.mdx +185 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +245 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/arize.mdx +13 -13
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +11 -8
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/cloud-exporter.mdx +21 -19
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/console-exporter.mdx +49 -17
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/default-exporter.mdx +42 -41
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/otel.mdx +5 -5
- package/.docs/raw/reference/observability/tracing/instances.mdx +168 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/interfaces.mdx +115 -89
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/reference/observability/{ai-tracing/span.mdx → tracing/spans.mdx} +59 -41
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
- package/.docs/raw/reference/processors/language-detector.mdx +1 -1
- package/.docs/raw/reference/processors/moderation-processor.mdx +1 -1
- package/.docs/raw/reference/processors/pii-detector.mdx +1 -1
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +1 -1
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +1 -1
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +1 -1
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
- package/.docs/raw/reference/rag/chunk.mdx +1 -8
- package/.docs/raw/reference/rag/database-config.mdx +7 -7
- package/.docs/raw/reference/rag/metadata-filters.mdx +14 -11
- package/.docs/raw/reference/storage/libsql.mdx +2 -0
- package/.docs/raw/reference/storage/mssql.mdx +5 -0
- package/.docs/raw/reference/storage/postgresql.mdx +6 -0
- package/.docs/raw/reference/storage/upstash.mdx +1 -0
- package/.docs/raw/reference/streaming/agents/stream.mdx +12 -12
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +8 -8
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +6 -6
- package/.docs/raw/reference/streaming/workflows/stream.mdx +10 -10
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +11 -11
- package/.docs/raw/reference/templates/overview.mdx +2 -2
- package/.docs/raw/reference/tools/create-tool.mdx +52 -35
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +15 -15
- package/.docs/raw/reference/tools/mcp-client.mdx +1 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +119 -35
- package/.docs/raw/reference/tools/vector-query-tool.mdx +27 -26
- package/.docs/raw/reference/vectors/libsql.mdx +1 -0
- package/.docs/raw/reference/vectors/pg.mdx +3 -0
- package/.docs/raw/reference/vectors/upstash.mdx +1 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -4
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +14 -14
- package/.docs/raw/reference/workflows/run-methods/start.mdx +17 -17
- package/.docs/raw/reference/workflows/run.mdx +1 -8
- package/.docs/raw/reference/workflows/step.mdx +5 -5
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +7 -13
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +5 -0
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow.mdx +1 -1
- package/.docs/raw/server-db/custom-api-routes.mdx +2 -2
- package/.docs/raw/server-db/mastra-client.mdx +19 -18
- package/.docs/raw/server-db/middleware.mdx +7 -7
- package/.docs/raw/server-db/production-server.mdx +4 -4
- package/.docs/raw/server-db/{runtime-context.mdx → request-context.mdx} +46 -45
- package/.docs/raw/server-db/storage.mdx +29 -21
- package/.docs/raw/streaming/events.mdx +3 -3
- package/.docs/raw/streaming/overview.mdx +5 -5
- package/.docs/raw/streaming/tool-streaming.mdx +18 -17
- package/.docs/raw/streaming/workflow-streaming.mdx +1 -1
- package/.docs/raw/tools-mcp/advanced-usage.mdx +5 -4
- package/.docs/raw/tools-mcp/mcp-overview.mdx +32 -19
- package/.docs/raw/tools-mcp/overview.mdx +11 -11
- package/.docs/raw/voice/overview.mdx +63 -43
- package/.docs/raw/voice/speech-to-speech.mdx +5 -3
- package/.docs/raw/voice/speech-to-text.mdx +9 -8
- package/.docs/raw/voice/text-to-speech.mdx +12 -11
- package/.docs/raw/workflows/agents-and-tools.mdx +9 -5
- package/.docs/raw/workflows/control-flow.mdx +3 -3
- package/.docs/raw/workflows/error-handling.mdx +2 -21
- package/.docs/raw/workflows/human-in-the-loop.mdx +7 -4
- package/.docs/raw/workflows/inngest-workflow.mdx +2 -2
- package/.docs/raw/workflows/input-data-mapping.mdx +107 -0
- package/.docs/raw/workflows/overview.mdx +17 -16
- package/.docs/raw/workflows/snapshots.mdx +13 -11
- package/.docs/raw/workflows/suspend-and-resume.mdx +23 -15
- package/CHANGELOG.md +52 -57
- package/README.md +11 -2
- package/dist/{chunk-TUAHUTTB.js → chunk-5NJC7NRO.js} +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/prompts/migration.d.ts +6 -0
- package/dist/prompts/migration.d.ts.map +1 -0
- package/dist/stdio.js +402 -30
- package/dist/tools/migration.d.ts +40 -0
- package/dist/tools/migration.d.ts.map +1 -0
- package/package.json +8 -12
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +0 -302
- package/.docs/raw/observability/nextjs-tracing.mdx +0 -109
- package/.docs/raw/observability/otel-tracing.mdx +0 -189
- package/.docs/raw/reference/agents/getScorers.mdx +0 -69
- package/.docs/raw/reference/agents/getTools.mdx +0 -69
- package/.docs/raw/reference/agents/getWorkflows.mdx +0 -69
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +0 -143
- package/.docs/raw/reference/core/getAgents.mdx +0 -35
- package/.docs/raw/reference/core/getLogs.mdx +0 -96
- package/.docs/raw/reference/core/getLogsByRunId.mdx +0 -87
- package/.docs/raw/reference/core/getMCPServers.mdx +0 -36
- package/.docs/raw/reference/core/getMemory.mdx +0 -36
- package/.docs/raw/reference/core/getScorerByName.mdx +0 -78
- package/.docs/raw/reference/core/getScorers.mdx +0 -43
- package/.docs/raw/reference/core/getVectors.mdx +0 -36
- package/.docs/raw/reference/core/getWorkflows.mdx +0 -45
- package/.docs/raw/reference/evals/context-position.mdx +0 -197
- package/.docs/raw/reference/evals/context-relevancy.mdx +0 -196
- package/.docs/raw/reference/evals/contextual-recall.mdx +0 -196
- package/.docs/raw/reference/evals/summarization.mdx +0 -212
- package/.docs/raw/reference/legacyWorkflows/after.mdx +0 -89
- package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +0 -79
- package/.docs/raw/reference/legacyWorkflows/commit.mdx +0 -33
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +0 -76
- package/.docs/raw/reference/legacyWorkflows/else.mdx +0 -68
- package/.docs/raw/reference/legacyWorkflows/events.mdx +0 -305
- package/.docs/raw/reference/legacyWorkflows/execute.mdx +0 -110
- package/.docs/raw/reference/legacyWorkflows/if.mdx +0 -108
- package/.docs/raw/reference/legacyWorkflows/resume.mdx +0 -158
- package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +0 -133
- package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +0 -207
- package/.docs/raw/reference/legacyWorkflows/start.mdx +0 -87
- package/.docs/raw/reference/legacyWorkflows/step-class.mdx +0 -100
- package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +0 -137
- package/.docs/raw/reference/legacyWorkflows/step-function.mdx +0 -93
- package/.docs/raw/reference/legacyWorkflows/step-options.mdx +0 -69
- package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +0 -196
- package/.docs/raw/reference/legacyWorkflows/suspend.mdx +0 -70
- package/.docs/raw/reference/legacyWorkflows/then.mdx +0 -72
- package/.docs/raw/reference/legacyWorkflows/until.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/watch.mdx +0 -124
- package/.docs/raw/reference/legacyWorkflows/while.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/workflow.mdx +0 -234
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +0 -79
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +0 -110
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +0 -185
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +0 -238
- package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +0 -117
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +0 -81
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +0 -121
- package/.docs/raw/reference/observability/otel-tracing/providers/braintrust.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +0 -20
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +0 -73
- package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +0 -41
- package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +0 -84
- package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +0 -48
- package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +0 -43
- package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +0 -40
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +0 -227
- package/.docs/raw/reference/scorers/bias.mdx +0 -228
- package/.docs/raw/reference/scorers/completeness.mdx +0 -214
- package/.docs/raw/reference/scorers/content-similarity.mdx +0 -197
- package/.docs/raw/reference/scorers/context-precision.mdx +0 -352
- package/.docs/raw/reference/scorers/faithfulness.mdx +0 -241
- package/.docs/raw/reference/scorers/hallucination.mdx +0 -252
- package/.docs/raw/reference/scorers/keyword-coverage.mdx +0 -229
- package/.docs/raw/reference/scorers/prompt-alignment.mdx +0 -668
- package/.docs/raw/reference/scorers/textual-difference.mdx +0 -203
- package/.docs/raw/reference/scorers/tone-consistency.mdx +0 -211
- package/.docs/raw/reference/scorers/toxicity.mdx +0 -228
- package/.docs/raw/reference/workflows/run-methods/watch.mdx +0 -73
- package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +0 -24
- package/.docs/raw/scorers/evals-old-api/overview.mdx +0 -106
- package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +0 -85
- package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +0 -58
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +0 -50
- package/.docs/raw/workflows-legacy/control-flow.mdx +0 -774
- package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +0 -239
- package/.docs/raw/workflows-legacy/error-handling.mdx +0 -187
- package/.docs/raw/workflows-legacy/nested-workflows.mdx +0 -360
- package/.docs/raw/workflows-legacy/overview.mdx +0 -182
- package/.docs/raw/workflows-legacy/runtime-variables.mdx +0 -156
- package/.docs/raw/workflows-legacy/steps.mdx +0 -115
- package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +0 -406
- package/.docs/raw/workflows-legacy/variables.mdx +0 -318
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Dynamic Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
|
|
3
|
-
sidebar_position: 3
|
|
4
|
-
sidebar_label: "Dynamic Workflows"
|
|
5
|
-
description: "Learn how to create dynamic workflows within legacy workflow steps, allowing for flexible workflow creation based on runtime conditions."
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Dynamic Workflows (Legacy)
|
|
9
|
-
|
|
10
|
-
This guide demonstrates how to create dynamic workflows within a workflow step. This advanced pattern allows you to create and execute workflows on the fly based on runtime conditions.
|
|
11
|
-
|
|
12
|
-
## Overview
|
|
13
|
-
|
|
14
|
-
Dynamic workflows are useful when you need to create workflows based on runtime data.
|
|
15
|
-
|
|
16
|
-
## Implementation
|
|
17
|
-
|
|
18
|
-
The key to creating dynamic workflows is accessing the Mastra instance from within a step's `execute` function and using it to create and run a new workflow.
|
|
19
|
-
|
|
20
|
-
### Basic Example
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Mastra } from "@mastra/core";
|
|
24
|
-
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
25
|
-
import { z } from "zod";
|
|
26
|
-
|
|
27
|
-
const isMastra = (mastra: any): mastra is Mastra => {
|
|
28
|
-
return mastra && typeof mastra === "object" && mastra instanceof Mastra;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// Step that creates and runs a dynamic workflow
|
|
32
|
-
const createDynamicWorkflow = new LegacyStep({
|
|
33
|
-
id: "createDynamicWorkflow",
|
|
34
|
-
outputSchema: z.object({
|
|
35
|
-
dynamicWorkflowResult: z.any(),
|
|
36
|
-
}),
|
|
37
|
-
execute: async ({ context, mastra }) => {
|
|
38
|
-
if (!mastra) {
|
|
39
|
-
throw new Error("Mastra instance not available");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (!isMastra(mastra)) {
|
|
43
|
-
throw new Error("Invalid Mastra instance");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const inputData = context.triggerData.inputData;
|
|
47
|
-
|
|
48
|
-
// Create a new dynamic workflow
|
|
49
|
-
const dynamicWorkflow = new LegacyWorkflow({
|
|
50
|
-
name: "dynamic-workflow",
|
|
51
|
-
mastra, // Pass the mastra instance to the new workflow
|
|
52
|
-
triggerSchema: z.object({
|
|
53
|
-
dynamicInput: z.string(),
|
|
54
|
-
}),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Define steps for the dynamic workflow
|
|
58
|
-
const dynamicStep = new LegacyStep({
|
|
59
|
-
id: "dynamicStep",
|
|
60
|
-
execute: async ({ context }) => {
|
|
61
|
-
const dynamicInput = context.triggerData.dynamicInput;
|
|
62
|
-
return {
|
|
63
|
-
processedValue: `Processed: ${dynamicInput}`,
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Build and commit the dynamic workflow
|
|
69
|
-
dynamicWorkflow.step(dynamicStep).commit();
|
|
70
|
-
|
|
71
|
-
// Create a run and execute the dynamic workflow
|
|
72
|
-
const run = dynamicWorkflow.createRun();
|
|
73
|
-
const result = await run.start({
|
|
74
|
-
triggerData: {
|
|
75
|
-
dynamicInput: inputData,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
let dynamicWorkflowResult;
|
|
80
|
-
|
|
81
|
-
if (result.results["dynamicStep"]?.status === "success") {
|
|
82
|
-
dynamicWorkflowResult =
|
|
83
|
-
result.results["dynamicStep"]?.output.processedValue;
|
|
84
|
-
} else {
|
|
85
|
-
throw new Error("Dynamic workflow failed");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Return the result from the dynamic workflow
|
|
89
|
-
return {
|
|
90
|
-
dynamicWorkflowResult,
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Main workflow that uses the dynamic workflow creator
|
|
96
|
-
const mainWorkflow = new LegacyWorkflow({
|
|
97
|
-
name: "main-workflow",
|
|
98
|
-
triggerSchema: z.object({
|
|
99
|
-
inputData: z.string(),
|
|
100
|
-
}),
|
|
101
|
-
mastra: new Mastra(),
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
mainWorkflow.step(createDynamicWorkflow).commit();
|
|
105
|
-
|
|
106
|
-
// Register the workflow with Mastra
|
|
107
|
-
export const mastra = new Mastra({
|
|
108
|
-
legacy_workflows: { mainWorkflow },
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const run = mainWorkflow.createRun();
|
|
112
|
-
const result = await run.start({
|
|
113
|
-
triggerData: {
|
|
114
|
-
inputData: "test",
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Advanced Example: Workflow Factory
|
|
120
|
-
|
|
121
|
-
You can create a workflow factory that generates different workflows based on input parameters:
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
const isMastra = (mastra: any): mastra is Mastra => {
|
|
125
|
-
return mastra && typeof mastra === "object" && mastra instanceof Mastra;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const workflowFactory = new LegacyStep({
|
|
129
|
-
id: "workflowFactory",
|
|
130
|
-
inputSchema: z.object({
|
|
131
|
-
workflowType: z.enum(["simple", "complex"]),
|
|
132
|
-
inputData: z.string(),
|
|
133
|
-
}),
|
|
134
|
-
outputSchema: z.object({
|
|
135
|
-
result: z.any(),
|
|
136
|
-
}),
|
|
137
|
-
execute: async ({ context, mastra }) => {
|
|
138
|
-
if (!mastra) {
|
|
139
|
-
throw new Error("Mastra instance not available");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (!isMastra(mastra)) {
|
|
143
|
-
throw new Error("Invalid Mastra instance");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Create a new dynamic workflow based on the type
|
|
147
|
-
const dynamicWorkflow = new LegacyWorkflow({
|
|
148
|
-
name: `dynamic-${context.workflowType}-workflow`,
|
|
149
|
-
mastra,
|
|
150
|
-
triggerSchema: z.object({
|
|
151
|
-
input: z.string(),
|
|
152
|
-
}),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (context.workflowType === "simple") {
|
|
156
|
-
// Simple workflow with a single step
|
|
157
|
-
const simpleStep = new Step({
|
|
158
|
-
id: "simpleStep",
|
|
159
|
-
execute: async ({ context }) => {
|
|
160
|
-
return {
|
|
161
|
-
result: `Simple processing: ${context.triggerData.input}`,
|
|
162
|
-
};
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
dynamicWorkflow.step(simpleStep).commit();
|
|
167
|
-
} else {
|
|
168
|
-
// Complex workflow with multiple steps
|
|
169
|
-
const step1 = new LegacyStep({
|
|
170
|
-
id: "step1",
|
|
171
|
-
outputSchema: z.object({
|
|
172
|
-
intermediateResult: z.string(),
|
|
173
|
-
}),
|
|
174
|
-
execute: async ({ context }) => {
|
|
175
|
-
return {
|
|
176
|
-
intermediateResult: `First processing: ${context.triggerData.input}`,
|
|
177
|
-
};
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const step2 = new LegacyStep({
|
|
182
|
-
id: "step2",
|
|
183
|
-
execute: async ({ context }) => {
|
|
184
|
-
const intermediate = context.getStepResult(step1).intermediateResult;
|
|
185
|
-
return {
|
|
186
|
-
finalResult: `Second processing: ${intermediate}`,
|
|
187
|
-
};
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
dynamicWorkflow.step(step1).then(step2).commit();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Execute the dynamic workflow
|
|
195
|
-
const run = dynamicWorkflow.createRun();
|
|
196
|
-
const result = await run.start({
|
|
197
|
-
triggerData: {
|
|
198
|
-
input: context.inputData,
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
// Return the appropriate result based on workflow type
|
|
203
|
-
if (context.workflowType === "simple") {
|
|
204
|
-
return {
|
|
205
|
-
// @ts-ignore
|
|
206
|
-
result: result.results["simpleStep"]?.output,
|
|
207
|
-
};
|
|
208
|
-
} else {
|
|
209
|
-
return {
|
|
210
|
-
// @ts-ignore
|
|
211
|
-
result: result.results["step2"]?.output,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## Important Considerations
|
|
219
|
-
|
|
220
|
-
1. **Mastra Instance**: The `mastra` parameter in the `execute` function provides access to the Mastra instance, which is essential for creating dynamic workflows.
|
|
221
|
-
|
|
222
|
-
2. **Error Handling**: Always check if the Mastra instance is available before attempting to create a dynamic workflow.
|
|
223
|
-
|
|
224
|
-
3. **Resource Management**: Dynamic workflows consume resources, so be mindful of creating too many workflows in a single execution.
|
|
225
|
-
|
|
226
|
-
4. **Workflow Lifecycle**: Dynamic workflows are not automatically registered with the main Mastra instance. They exist only for the duration of the step execution unless you explicitly register them.
|
|
227
|
-
|
|
228
|
-
5. **Debugging**: Debugging dynamic workflows can be challenging. Consider adding detailed logging to track their creation and execution.
|
|
229
|
-
|
|
230
|
-
## Use Cases
|
|
231
|
-
|
|
232
|
-
- **Conditional Workflow Selection**: Choose different workflow patterns based on input data
|
|
233
|
-
- **Parameterized Workflows**: Create workflows with dynamic configurations
|
|
234
|
-
- **Workflow Templates**: Use templates to generate specialized workflows
|
|
235
|
-
- **Multi-tenant Applications**: Create isolated workflows for different tenants
|
|
236
|
-
|
|
237
|
-
## Conclusion
|
|
238
|
-
|
|
239
|
-
Dynamic workflows provide a powerful way to create flexible, adaptable workflow systems. By leveraging the Mastra instance within step execution, you can create workflows that respond to runtime conditions and requirements.
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Error Handling in Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
|
|
3
|
-
sidebar_position: 8
|
|
4
|
-
sidebar_label: "Error Handling"
|
|
5
|
-
description: "Learn how to handle errors in Mastra legacy workflows using step retries, conditional branching, and monitoring."
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Error Handling in Workflows (Legacy)
|
|
9
|
-
|
|
10
|
-
Robust error handling is essential for production workflows. Mastra provides several mechanisms to handle errors gracefully, allowing your workflows to recover from failures or gracefully degrade when necessary.
|
|
11
|
-
|
|
12
|
-
## Overview
|
|
13
|
-
|
|
14
|
-
Error handling in Mastra workflows can be implemented using:
|
|
15
|
-
|
|
16
|
-
1. **Step Retries** - Automatically retry failed steps
|
|
17
|
-
2. **Conditional Branching** - Create alternative paths based on step success or failure
|
|
18
|
-
3. **Error Monitoring** - Watch workflows for errors and handle them programmatically
|
|
19
|
-
4. **Result Status Checks** - Check the status of previous steps in subsequent steps
|
|
20
|
-
|
|
21
|
-
## Step Retries
|
|
22
|
-
|
|
23
|
-
Mastra provides a built-in retry mechanism for steps that fail due to transient errors. This is particularly useful for steps that interact with external services or resources that might experience temporary unavailability.
|
|
24
|
-
|
|
25
|
-
### Basic Retry Configuration
|
|
26
|
-
|
|
27
|
-
You can configure retries at the workflow level or for individual steps:
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
31
|
-
|
|
32
|
-
// Workflow-level retry configuration
|
|
33
|
-
const workflow = new LegacyWorkflow({
|
|
34
|
-
name: "my-workflow",
|
|
35
|
-
retryConfig: {
|
|
36
|
-
attempts: 3, // Number of retry attempts
|
|
37
|
-
delay: 1000, // Delay between retries in milliseconds
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Step-level retry configuration (overrides workflow-level)
|
|
42
|
-
const apiStep = new LegacyStep({
|
|
43
|
-
id: "callApi",
|
|
44
|
-
execute: async () => {
|
|
45
|
-
// API call that might fail
|
|
46
|
-
},
|
|
47
|
-
retryConfig: {
|
|
48
|
-
attempts: 5, // This step will retry up to 5 times
|
|
49
|
-
delay: 2000, // With a 2-second delay between retries
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
For more details about step retries, see the [Step Retries](/reference/legacyWorkflows/step-retries) reference.
|
|
55
|
-
|
|
56
|
-
## Conditional Branching
|
|
57
|
-
|
|
58
|
-
You can create alternative workflow paths based on the success or failure of previous steps using conditional logic:
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
// Create a workflow with conditional branching
|
|
62
|
-
const workflow = new LegacyWorkflow({
|
|
63
|
-
name: "error-handling-workflow",
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
workflow
|
|
67
|
-
.step(fetchDataStep)
|
|
68
|
-
.then(processDataStep, {
|
|
69
|
-
// Only execute processDataStep if fetchDataStep was successful
|
|
70
|
-
when: ({ context }) => {
|
|
71
|
-
return context.steps.fetchDataStep?.status === "success";
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
.then(fallbackStep, {
|
|
75
|
-
// Execute fallbackStep if fetchDataStep failed
|
|
76
|
-
when: ({ context }) => {
|
|
77
|
-
return context.steps.fetchDataStep?.status === "failed";
|
|
78
|
-
},
|
|
79
|
-
})
|
|
80
|
-
.commit();
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Error Monitoring
|
|
84
|
-
|
|
85
|
-
You can monitor workflows for errors using the `watch` method:
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
const { start, watch } = workflow.createRun();
|
|
89
|
-
|
|
90
|
-
watch(async ({ results }) => {
|
|
91
|
-
// Check for any failed steps
|
|
92
|
-
const failedSteps = Object.entries(results)
|
|
93
|
-
.filter(([_, step]) => step.status === "failed")
|
|
94
|
-
.map(([stepId]) => stepId);
|
|
95
|
-
|
|
96
|
-
if (failedSteps.length > 0) {
|
|
97
|
-
console.error(`Workflow has failed steps: ${failedSteps.join(", ")}`);
|
|
98
|
-
// Take remedial action, such as alerting or logging
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
await start();
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Handling Errors in Steps
|
|
106
|
-
|
|
107
|
-
Within a step's execution function, you can handle errors programmatically:
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
const robustStep = new LegacyStep({
|
|
111
|
-
id: "robustStep",
|
|
112
|
-
execute: async ({ context }) => {
|
|
113
|
-
try {
|
|
114
|
-
// Attempt the primary operation
|
|
115
|
-
const result = await someRiskyOperation();
|
|
116
|
-
return { success: true, data: result };
|
|
117
|
-
} catch (error) {
|
|
118
|
-
// Log the error
|
|
119
|
-
console.error("Operation failed:", error);
|
|
120
|
-
|
|
121
|
-
// Return a graceful fallback result instead of throwing
|
|
122
|
-
return {
|
|
123
|
-
success: false,
|
|
124
|
-
error: error.message,
|
|
125
|
-
fallbackData: "Default value",
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Checking Previous Step Results
|
|
133
|
-
|
|
134
|
-
You can make decisions based on the results of previous steps:
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
const finalStep = new LegacyStep({
|
|
138
|
-
id: "finalStep",
|
|
139
|
-
execute: async ({ context }) => {
|
|
140
|
-
// Check results of previous steps
|
|
141
|
-
const step1Success = context.steps.step1?.status === "success";
|
|
142
|
-
const step2Success = context.steps.step2?.status === "success";
|
|
143
|
-
|
|
144
|
-
if (step1Success && step2Success) {
|
|
145
|
-
// All steps succeeded
|
|
146
|
-
return { status: "complete", result: "All operations succeeded" };
|
|
147
|
-
} else if (step1Success) {
|
|
148
|
-
// Only step1 succeeded
|
|
149
|
-
return { status: "partial", result: "Partial completion" };
|
|
150
|
-
} else {
|
|
151
|
-
// Critical failure
|
|
152
|
-
return { status: "failed", result: "Critical steps failed" };
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## Best Practices for Error Handling
|
|
159
|
-
|
|
160
|
-
1. **Use retries for transient failures**: Configure retry policies for steps that might experience temporary issues.
|
|
161
|
-
|
|
162
|
-
2. **Provide fallback paths**: Design workflows with alternative paths for when critical steps fail.
|
|
163
|
-
|
|
164
|
-
3. **Be specific about error scenarios**: Use different handling strategies for different types of errors.
|
|
165
|
-
|
|
166
|
-
4. **Log errors comprehensively**: Include context information when logging errors to aid in debugging.
|
|
167
|
-
|
|
168
|
-
5. **Return meaningful data on failure**: When a step fails, return structured data about the failure to help downstream steps make decisions.
|
|
169
|
-
|
|
170
|
-
6. **Consider idempotency**: Ensure steps can be safely retried without causing duplicate side effects.
|
|
171
|
-
|
|
172
|
-
7. **Monitor workflow execution**: Use the `watch` method to actively monitor workflow execution and detect errors early.
|
|
173
|
-
|
|
174
|
-
## Advanced Error Handling
|
|
175
|
-
|
|
176
|
-
For more complex error handling scenarios, consider:
|
|
177
|
-
|
|
178
|
-
- **Implementing circuit breakers**: If a step fails repeatedly, stop retrying and use a fallback strategy
|
|
179
|
-
- **Adding timeout handling**: Set time limits for steps to prevent workflows from hanging indefinitely
|
|
180
|
-
- **Creating dedicated error recovery workflows**: For critical workflows, create separate recovery workflows that can be triggered when the main workflow fails
|
|
181
|
-
|
|
182
|
-
## Related
|
|
183
|
-
|
|
184
|
-
- [Step Retries Reference](/reference/legacyWorkflows/step-retries)
|
|
185
|
-
- [Watch Method Reference](/reference/legacyWorkflows/watch)
|
|
186
|
-
- [Step Conditions](/reference/legacyWorkflows/step-condition)
|
|
187
|
-
- [Control Flow](./control-flow)
|