@mastra/mcp-docs-server 0.13.37 → 0.13.39-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +2 -0
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +2 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +38 -38
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +88 -88
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +59 -59
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +48 -48
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Freact.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +40 -40
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +11 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
- package/.docs/organized/changelogs/create-mastra.md +11 -11
- package/.docs/organized/changelogs/mastra.md +34 -34
- package/.docs/raw/agents/adding-voice.mdx +20 -9
- package/.docs/raw/agents/agent-memory.mdx +55 -39
- package/.docs/raw/agents/guardrails.mdx +68 -61
- package/.docs/raw/agents/networks.mdx +50 -46
- package/.docs/raw/agents/overview.mdx +126 -89
- package/.docs/raw/agents/using-tools.mdx +14 -15
- package/.docs/raw/auth/auth0.mdx +28 -27
- package/.docs/raw/auth/clerk.mdx +22 -20
- package/.docs/raw/auth/firebase.mdx +42 -39
- package/.docs/raw/auth/index.mdx +1 -1
- package/.docs/raw/auth/jwt.mdx +18 -16
- package/.docs/raw/auth/supabase.mdx +20 -18
- package/.docs/raw/auth/workos.mdx +32 -26
- package/.docs/raw/community/contributing-templates.mdx +7 -7
- package/.docs/raw/community/discord.mdx +2 -2
- package/.docs/raw/community/licensing.mdx +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/04-initializing-mcp-tools.md +2 -2
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
- package/.docs/raw/course/03-agent-memory/26-updating-mastra-export-comprehensive.md +0 -32
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +41 -22
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +48 -29
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +52 -24
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +86 -55
- package/.docs/raw/deployment/cloud-providers/index.mdx +16 -13
- package/.docs/raw/deployment/monorepo.mdx +32 -42
- package/.docs/raw/deployment/overview.mdx +15 -15
- package/.docs/raw/deployment/server-deployment.mdx +18 -23
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +16 -17
- package/.docs/raw/deployment/serverless-platforms/index.mdx +15 -12
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +14 -23
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +16 -23
- package/.docs/raw/deployment/web-framework.mdx +14 -14
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +130 -121
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +54 -43
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +51 -36
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +161 -120
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +60 -49
- package/.docs/raw/frameworks/servers/express.mdx +46 -45
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +245 -162
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +112 -69
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +171 -130
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +94 -81
- package/.docs/raw/getting-started/installation.mdx +165 -134
- package/.docs/raw/getting-started/mcp-docs-server.mdx +36 -39
- package/.docs/raw/getting-started/project-structure.mdx +34 -42
- package/.docs/raw/getting-started/studio.mdx +42 -50
- package/.docs/raw/getting-started/templates.mdx +18 -15
- package/.docs/raw/index.mdx +9 -9
- package/.docs/raw/mastra-cloud/dashboard.mdx +12 -12
- package/.docs/raw/mastra-cloud/observability.mdx +9 -10
- package/.docs/raw/mastra-cloud/overview.mdx +17 -23
- package/.docs/raw/mastra-cloud/setting-up.mdx +33 -20
- package/.docs/raw/memory/conversation-history.mdx +2 -2
- package/.docs/raw/memory/overview.mdx +22 -24
- package/.docs/raw/memory/semantic-recall.mdx +16 -17
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +27 -28
- package/.docs/raw/memory/storage/memory-with-pg.mdx +26 -26
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +26 -27
- package/.docs/raw/memory/threads-and-resources.mdx +24 -21
- package/.docs/raw/memory/working-memory.mdx +27 -38
- package/.docs/raw/observability/ai-tracing/exporters/arize.mdx +30 -29
- package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +8 -9
- package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +17 -16
- package/.docs/raw/observability/ai-tracing/exporters/default.mdx +37 -38
- package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +18 -17
- package/.docs/raw/observability/ai-tracing/exporters/langsmith.mdx +14 -14
- package/.docs/raw/observability/ai-tracing/exporters/otel.mdx +56 -46
- package/.docs/raw/observability/ai-tracing/overview.mdx +151 -128
- package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +57 -36
- package/.docs/raw/observability/logging.mdx +14 -17
- package/.docs/raw/observability/nextjs-tracing.mdx +5 -5
- package/.docs/raw/observability/otel-tracing.mdx +17 -18
- package/.docs/raw/observability/overview.mdx +15 -11
- package/.docs/raw/rag/chunking-and-embedding.mdx +10 -8
- package/.docs/raw/rag/overview.mdx +5 -5
- package/.docs/raw/rag/retrieval.mdx +125 -107
- package/.docs/raw/rag/vector-databases.mdx +232 -223
- package/.docs/raw/reference/agents/agent.mdx +56 -43
- package/.docs/raw/reference/agents/generate.mdx +367 -261
- package/.docs/raw/reference/agents/generateLegacy.mdx +260 -178
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +7 -5
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +7 -5
- package/.docs/raw/reference/agents/getDescription.mdx +3 -2
- package/.docs/raw/reference/agents/getInstructions.mdx +7 -5
- package/.docs/raw/reference/agents/getLLM.mdx +11 -7
- package/.docs/raw/reference/agents/getMemory.mdx +7 -5
- package/.docs/raw/reference/agents/getModel.mdx +7 -5
- package/.docs/raw/reference/agents/getScorers.mdx +7 -5
- package/.docs/raw/reference/agents/getTools.mdx +7 -5
- package/.docs/raw/reference/agents/getVoice.mdx +7 -5
- package/.docs/raw/reference/agents/getWorkflows.mdx +7 -5
- package/.docs/raw/reference/agents/listAgents.mdx +6 -4
- package/.docs/raw/reference/agents/listScorers.mdx +69 -0
- package/.docs/raw/reference/agents/listTools.mdx +69 -0
- package/.docs/raw/reference/agents/listWorkflows.mdx +69 -0
- package/.docs/raw/reference/agents/network.mdx +171 -116
- package/.docs/raw/reference/auth/auth0.mdx +18 -14
- package/.docs/raw/reference/auth/clerk.mdx +15 -12
- package/.docs/raw/reference/auth/firebase.mdx +23 -16
- package/.docs/raw/reference/auth/jwt.mdx +7 -6
- package/.docs/raw/reference/auth/supabase.mdx +13 -10
- package/.docs/raw/reference/auth/workos.mdx +17 -13
- package/.docs/raw/reference/cli/create-mastra.mdx +61 -44
- package/.docs/raw/reference/cli/mastra.mdx +11 -11
- package/.docs/raw/reference/client-js/agents.mdx +41 -44
- package/.docs/raw/reference/client-js/error-handling.mdx +1 -1
- package/.docs/raw/reference/client-js/logs.mdx +2 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +28 -20
- package/.docs/raw/reference/client-js/memory.mdx +7 -3
- package/.docs/raw/reference/client-js/observability.mdx +10 -9
- package/.docs/raw/reference/client-js/telemetry.mdx +1 -1
- package/.docs/raw/reference/client-js/tools.mdx +2 -2
- package/.docs/raw/reference/client-js/vectors.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +8 -8
- package/.docs/raw/reference/core/getAgent.mdx +6 -5
- package/.docs/raw/reference/core/getAgentById.mdx +5 -4
- package/.docs/raw/reference/core/getAgents.mdx +3 -3
- package/.docs/raw/reference/core/getDeployer.mdx +4 -3
- package/.docs/raw/reference/core/getLogger.mdx +4 -3
- package/.docs/raw/reference/core/getLogs.mdx +10 -6
- package/.docs/raw/reference/core/getLogsByRunId.mdx +8 -5
- package/.docs/raw/reference/core/getMCPServer.mdx +8 -5
- package/.docs/raw/reference/core/getMCPServers.mdx +4 -3
- package/.docs/raw/reference/core/getMemory.mdx +4 -3
- package/.docs/raw/reference/core/getScorer.mdx +15 -12
- package/.docs/raw/reference/core/getScorerByName.mdx +13 -10
- package/.docs/raw/reference/core/getScorers.mdx +3 -2
- package/.docs/raw/reference/core/getServer.mdx +4 -3
- package/.docs/raw/reference/core/getStorage.mdx +4 -3
- package/.docs/raw/reference/core/getTelemetry.mdx +4 -3
- package/.docs/raw/reference/core/getVector.mdx +6 -4
- package/.docs/raw/reference/core/getVectors.mdx +4 -3
- package/.docs/raw/reference/core/getWorkflow.mdx +7 -4
- package/.docs/raw/reference/core/getWorkflows.mdx +5 -3
- package/.docs/raw/reference/core/listAgents.mdx +35 -0
- package/.docs/raw/reference/core/listLogs.mdx +96 -0
- package/.docs/raw/reference/core/listLogsByRunId.mdx +87 -0
- package/.docs/raw/reference/core/listScorers.mdx +43 -0
- package/.docs/raw/reference/core/listWorkflows.mdx +45 -0
- package/.docs/raw/reference/core/mastra-class.mdx +16 -16
- package/.docs/raw/reference/core/setLogger.mdx +6 -4
- package/.docs/raw/reference/core/setStorage.mdx +4 -4
- package/.docs/raw/reference/core/setTelemetry.mdx +4 -3
- package/.docs/raw/reference/deployer/cloudflare.mdx +11 -7
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -4
- package/.docs/raw/reference/deployer/vercel.mdx +6 -6
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -5
- package/.docs/raw/reference/evals/bias.mdx +4 -5
- package/.docs/raw/reference/evals/completeness.mdx +4 -5
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -5
- package/.docs/raw/reference/evals/context-position.mdx +4 -5
- package/.docs/raw/reference/evals/context-precision.mdx +4 -5
- package/.docs/raw/reference/evals/context-relevancy.mdx +4 -5
- package/.docs/raw/reference/evals/contextual-recall.mdx +4 -5
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -5
- package/.docs/raw/reference/evals/hallucination.mdx +4 -6
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -5
- package/.docs/raw/reference/evals/prompt-alignment.mdx +4 -6
- package/.docs/raw/reference/evals/summarization.mdx +4 -6
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -5
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -7
- package/.docs/raw/reference/evals/toxicity.mdx +4 -5
- package/.docs/raw/reference/index.mdx +3 -3
- package/.docs/raw/reference/legacyWorkflows/after.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/commit.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/else.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/events.mdx +7 -7
- package/.docs/raw/reference/legacyWorkflows/execute.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/if.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/resume.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/start.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/step-class.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/step-function.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/step-options.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/suspend.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/then.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/until.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/watch.mdx +3 -3
- package/.docs/raw/reference/legacyWorkflows/while.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/workflow.mdx +7 -7
- package/.docs/raw/reference/memory/createThread.mdx +10 -10
- package/.docs/raw/reference/memory/deleteMessages.mdx +7 -5
- package/.docs/raw/reference/memory/getThreadById.mdx +6 -5
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +11 -10
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +10 -9
- package/.docs/raw/reference/memory/{Memory.mdx → memory-class.mdx} +55 -47
- package/.docs/raw/reference/memory/query.mdx +39 -25
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +9 -6
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +26 -22
- package/.docs/raw/reference/observability/ai-tracing/exporters/arize.mdx +16 -12
- package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +14 -14
- package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +16 -11
- package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +10 -6
- package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +23 -15
- package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +6 -6
- package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +13 -13
- package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +44 -36
- package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +116 -107
- package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +37 -32
- package/.docs/raw/reference/observability/ai-tracing/span.mdx +29 -26
- package/.docs/raw/reference/observability/logging/pino-logger.mdx +13 -15
- package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +2 -2
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +3 -3
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +2 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +12 -14
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +4 -4
- package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +4 -4
- package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +2 -2
- package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +3 -4
- package/.docs/raw/reference/processors/language-detector.mdx +6 -8
- package/.docs/raw/reference/processors/moderation-processor.mdx +36 -11
- package/.docs/raw/reference/processors/pii-detector.mdx +34 -9
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +6 -8
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +14 -10
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +3 -5
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +3 -4
- package/.docs/raw/reference/rag/chunk.mdx +41 -23
- package/.docs/raw/reference/rag/database-config.mdx +56 -38
- package/.docs/raw/reference/rag/embeddings.mdx +1 -1
- package/.docs/raw/reference/rag/extract-params.mdx +1 -1
- package/.docs/raw/reference/rag/graph-rag.mdx +1 -1
- package/.docs/raw/reference/rag/metadata-filters.mdx +23 -26
- package/.docs/raw/reference/rag/rerank.mdx +1 -1
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -2
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +35 -17
- package/.docs/raw/reference/scorers/answer-similarity.mdx +84 -68
- package/.docs/raw/reference/scorers/bias.mdx +22 -19
- package/.docs/raw/reference/scorers/completeness.mdx +21 -16
- package/.docs/raw/reference/scorers/content-similarity.mdx +12 -10
- package/.docs/raw/reference/scorers/context-precision.mdx +73 -64
- package/.docs/raw/reference/scorers/context-relevance.mdx +142 -126
- package/.docs/raw/reference/scorers/create-scorer.mdx +93 -61
- package/.docs/raw/reference/scorers/faithfulness.mdx +21 -13
- package/.docs/raw/reference/scorers/hallucination.mdx +17 -12
- package/.docs/raw/reference/scorers/keyword-coverage.mdx +32 -27
- package/.docs/raw/reference/scorers/mastra-scorer.mdx +39 -33
- package/.docs/raw/reference/scorers/noise-sensitivity.mdx +203 -152
- package/.docs/raw/reference/scorers/prompt-alignment.mdx +186 -132
- package/.docs/raw/reference/scorers/run-experiment.mdx +41 -32
- package/.docs/raw/reference/scorers/textual-difference.mdx +25 -26
- package/.docs/raw/reference/scorers/tone-consistency.mdx +29 -26
- package/.docs/raw/reference/scorers/tool-call-accuracy.mdx +180 -176
- package/.docs/raw/reference/scorers/toxicity.mdx +35 -31
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +1 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/dynamodb.mdx +1 -1
- package/.docs/raw/reference/storage/lance.mdx +1 -1
- package/.docs/raw/reference/storage/libsql.mdx +2 -2
- package/.docs/raw/reference/storage/mongodb.mdx +4 -5
- package/.docs/raw/reference/storage/mssql.mdx +8 -7
- package/.docs/raw/reference/storage/postgresql.mdx +35 -33
- package/.docs/raw/reference/storage/upstash.mdx +6 -5
- package/.docs/raw/reference/streaming/ChunkType.mdx +788 -314
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +265 -109
- package/.docs/raw/reference/streaming/agents/stream.mdx +375 -266
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +233 -162
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +4 -4
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +5 -5
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +25 -21
- package/.docs/raw/reference/streaming/workflows/stream.mdx +36 -27
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +37 -28
- package/.docs/raw/reference/templates/overview.mdx +16 -39
- package/.docs/raw/reference/tools/client.mdx +1 -1
- package/.docs/raw/reference/tools/create-tool.mdx +45 -35
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -2
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +12 -12
- package/.docs/raw/reference/tools/mcp-client.mdx +78 -72
- package/.docs/raw/reference/tools/mcp-server.mdx +91 -78
- package/.docs/raw/reference/tools/vector-query-tool.mdx +48 -38
- package/.docs/raw/reference/vectors/astra.mdx +1 -1
- package/.docs/raw/reference/vectors/chroma.mdx +25 -19
- package/.docs/raw/reference/vectors/couchbase.mdx +4 -4
- package/.docs/raw/reference/vectors/lance.mdx +5 -6
- package/.docs/raw/reference/vectors/libsql.mdx +1 -1
- package/.docs/raw/reference/vectors/mongodb.mdx +1 -1
- package/.docs/raw/reference/vectors/opensearch.mdx +1 -1
- package/.docs/raw/reference/vectors/pg.mdx +8 -4
- package/.docs/raw/reference/vectors/pinecone.mdx +1 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +1 -1
- package/.docs/raw/reference/vectors/s3vectors.mdx +35 -27
- package/.docs/raw/reference/vectors/turbopuffer.mdx +1 -1
- package/.docs/raw/reference/vectors/upstash.mdx +33 -25
- package/.docs/raw/reference/vectors/vectorize.mdx +1 -1
- package/.docs/raw/reference/voice/azure.mdx +1 -1
- package/.docs/raw/reference/voice/cloudflare.mdx +1 -1
- package/.docs/raw/reference/voice/composite-voice.mdx +1 -1
- package/.docs/raw/reference/voice/deepgram.mdx +1 -1
- package/.docs/raw/reference/voice/elevenlabs.mdx +1 -1
- package/.docs/raw/reference/voice/google-gemini-live.mdx +7 -5
- package/.docs/raw/reference/voice/google.mdx +1 -1
- package/.docs/raw/reference/voice/mastra-voice.mdx +1 -1
- package/.docs/raw/reference/voice/murf.mdx +1 -1
- package/.docs/raw/reference/voice/openai-realtime.mdx +1 -1
- package/.docs/raw/reference/voice/openai.mdx +1 -1
- package/.docs/raw/reference/voice/playai.mdx +1 -1
- package/.docs/raw/reference/voice/sarvam.mdx +1 -1
- package/.docs/raw/reference/voice/speechify.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.events.mdx +1 -1
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +23 -30
- package/.docs/raw/reference/voice/voice.listen.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.speak.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +49 -34
- package/.docs/raw/reference/workflows/run-methods/start.mdx +43 -31
- package/.docs/raw/reference/workflows/run-methods/watch.mdx +7 -8
- package/.docs/raw/reference/workflows/run.mdx +7 -10
- package/.docs/raw/reference/workflows/step.mdx +16 -13
- 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 -7
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +74 -3
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +5 -5
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow.mdx +12 -23
- package/.docs/raw/scorers/custom-scorers.mdx +58 -48
- package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +6 -8
- package/.docs/raw/scorers/evals-old-api/overview.mdx +8 -8
- package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +9 -9
- package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +5 -5
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +3 -1
- package/.docs/raw/scorers/overview.mdx +23 -22
- package/.docs/raw/server-db/custom-api-routes.mdx +8 -8
- package/.docs/raw/server-db/mastra-client.mdx +56 -54
- package/.docs/raw/server-db/middleware.mdx +15 -11
- package/.docs/raw/server-db/production-server.mdx +5 -7
- package/.docs/raw/server-db/runtime-context.mdx +41 -38
- package/.docs/raw/server-db/storage.mdx +82 -87
- package/.docs/raw/streaming/events.mdx +24 -16
- package/.docs/raw/streaming/overview.mdx +17 -18
- package/.docs/raw/streaming/tool-streaming.mdx +9 -10
- package/.docs/raw/streaming/workflow-streaming.mdx +14 -12
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +92 -102
- package/.docs/raw/tools-mcp/overview.mdx +10 -15
- package/.docs/raw/voice/overview.mdx +273 -250
- package/.docs/raw/voice/speech-to-speech.mdx +14 -12
- package/.docs/raw/voice/speech-to-text.mdx +2 -2
- package/.docs/raw/voice/text-to-speech.mdx +2 -2
- package/.docs/raw/workflows/agents-and-tools.mdx +27 -30
- package/.docs/raw/workflows/control-flow.mdx +213 -170
- package/.docs/raw/workflows/error-handling.mdx +15 -17
- package/.docs/raw/workflows/human-in-the-loop.mdx +39 -39
- package/.docs/raw/workflows/inngest-workflow.mdx +35 -31
- package/.docs/raw/workflows/overview.mdx +108 -56
- package/.docs/raw/workflows/snapshots.mdx +54 -36
- package/.docs/raw/workflows/suspend-and-resume.mdx +52 -65
- package/.docs/raw/workflows-legacy/control-flow.mdx +15 -17
- package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +3 -1
- package/.docs/raw/workflows-legacy/error-handling.mdx +8 -6
- package/.docs/raw/workflows-legacy/nested-workflows.mdx +6 -0
- package/.docs/raw/workflows-legacy/overview.mdx +28 -26
- package/.docs/raw/workflows-legacy/runtime-variables.mdx +4 -2
- package/.docs/raw/workflows-legacy/steps.mdx +5 -3
- package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +10 -8
- package/.docs/raw/workflows-legacy/variables.mdx +10 -8
- package/CHANGELOG.md +24 -0
- package/package.json +5 -5
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -148
- package/.docs/raw/workflows/input-data-mapping.mdx +0 -107
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Suspend & Resume
|
|
2
|
+
title: "Suspend & Resume | Workflows | Mastra Docs"
|
|
3
3
|
description: "Suspend and resume in Mastra workflows allows you to pause execution while waiting for external input or resources."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Suspend & Resume
|
|
7
7
|
|
|
8
|
-
Workflows can be paused at any step,
|
|
9
|
-
|
|
10
|
-
Common scenarios for suspending workflows include:
|
|
11
|
-
|
|
12
|
-
- Waiting for human approval or input
|
|
13
|
-
- Pausing until external API resources become available
|
|
14
|
-
- Collecting additional data needed for later steps
|
|
15
|
-
- Rate limiting or throttling expensive operations
|
|
16
|
-
- Handling event-driven processes with external triggers
|
|
8
|
+
Workflows can be paused at any step to collect additional data, wait for API callbacks, throttle expensive operations, or wait for [Human in the Loop](./human-in-the-loop) input. When a workflow is suspended, its current state can be persisted as a [snapshot](./snapshots) and later resumed from the same point. Snapshots are stored in the configured storage system and persist across deployments and application restarts.
|
|
17
9
|
|
|
18
10
|
> **New to suspend and resume?** Watch these official video tutorials:
|
|
19
11
|
>
|
|
@@ -33,19 +25,19 @@ When running a workflow, its `status` can be one of the following:
|
|
|
33
25
|
|
|
34
26
|
To pause execution at a specific step until user input is received, use the `suspend` function to temporarily halt the workflow, allowing it to resume only when the necessary data is provided.
|
|
35
27
|
|
|
36
|
-
](/img/workflows/workflows-suspend-resume-suspend.jpg)
|
|
37
29
|
|
|
38
|
-
```typescript {16}
|
|
30
|
+
```typescript {16} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
39
31
|
const step1 = createStep({
|
|
40
32
|
id: "step-1",
|
|
41
33
|
inputSchema: z.object({
|
|
42
|
-
input: z.string()
|
|
34
|
+
input: z.string(),
|
|
43
35
|
}),
|
|
44
36
|
outputSchema: z.object({
|
|
45
|
-
output: z.string()
|
|
37
|
+
output: z.string(),
|
|
46
38
|
}),
|
|
47
39
|
resumeSchema: z.object({
|
|
48
|
-
city: z.string()
|
|
40
|
+
city: z.string(),
|
|
49
41
|
}),
|
|
50
42
|
execute: async ({ resumeData, suspend }) => {
|
|
51
43
|
const { city } = resumeData ?? {};
|
|
@@ -55,7 +47,7 @@ const step1 = createStep({
|
|
|
55
47
|
}
|
|
56
48
|
|
|
57
49
|
return { output: "" };
|
|
58
|
-
}
|
|
50
|
+
},
|
|
59
51
|
});
|
|
60
52
|
|
|
61
53
|
export const testWorkflow = createWorkflow({
|
|
@@ -65,21 +57,21 @@ export const testWorkflow = createWorkflow({
|
|
|
65
57
|
.commit();
|
|
66
58
|
```
|
|
67
59
|
|
|
68
|
-
> For more details, check out the [Suspend workflow example](
|
|
60
|
+
> For more details, check out the [Suspend workflow example](/examples/workflows_legacy/suspend-and-resume).
|
|
69
61
|
|
|
70
62
|
### Identifying suspended steps
|
|
71
63
|
|
|
72
64
|
To resume a suspended workflow, inspect the `suspended` array in the result to determine which step needs input:
|
|
73
65
|
|
|
74
|
-
```typescript {15}
|
|
66
|
+
```typescript {15} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
75
67
|
import { mastra } from "./mastra";
|
|
76
68
|
|
|
77
69
|
const run = await mastra.getWorkflow("testWorkflow").createRunAsync();
|
|
78
70
|
|
|
79
71
|
const result = await run.start({
|
|
80
72
|
inputData: {
|
|
81
|
-
city: "London"
|
|
82
|
-
}
|
|
73
|
+
city: "London",
|
|
74
|
+
},
|
|
83
75
|
});
|
|
84
76
|
|
|
85
77
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -88,8 +80,8 @@ if (result.status === "suspended") {
|
|
|
88
80
|
const resumedResult = await run.resume({
|
|
89
81
|
step: result.suspended[0],
|
|
90
82
|
resumeData: {
|
|
91
|
-
city: "Berlin"
|
|
92
|
-
}
|
|
83
|
+
city: "Berlin",
|
|
84
|
+
},
|
|
93
85
|
});
|
|
94
86
|
}
|
|
95
87
|
```
|
|
@@ -103,52 +95,48 @@ In this case, the logic resumes the first step listed in the `suspended` array.
|
|
|
103
95
|
// ...
|
|
104
96
|
"step-1": {
|
|
105
97
|
// ...
|
|
106
|
-
"status": "suspended"
|
|
98
|
+
"status": "suspended"
|
|
107
99
|
}
|
|
108
100
|
},
|
|
109
|
-
"suspended": [
|
|
110
|
-
[
|
|
111
|
-
"step-1"
|
|
112
|
-
]
|
|
113
|
-
]
|
|
101
|
+
"suspended": [["step-1"]]
|
|
114
102
|
}
|
|
115
103
|
```
|
|
116
104
|
|
|
117
|
-
> See [
|
|
105
|
+
> See [Workflow Output](./overview#workflow-output) for more details.
|
|
118
106
|
|
|
119
107
|
## Providing user feedback with suspend
|
|
120
108
|
|
|
121
109
|
When a workflow is suspended, feedback can be surfaced to the user through the `suspendSchema`. Include a reason in the `suspend` payload to explain why the workflow paused.
|
|
122
110
|
|
|
123
|
-
```typescript {13,23}
|
|
111
|
+
```typescript {13,23} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
124
112
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
125
113
|
import { z } from "zod";
|
|
126
114
|
|
|
127
115
|
const step1 = createStep({
|
|
128
116
|
id: "step-1",
|
|
129
117
|
inputSchema: z.object({
|
|
130
|
-
value: z.string()
|
|
118
|
+
value: z.string(),
|
|
131
119
|
}),
|
|
132
120
|
resumeSchema: z.object({
|
|
133
|
-
confirm: z.boolean()
|
|
121
|
+
confirm: z.boolean(),
|
|
134
122
|
}),
|
|
135
123
|
suspendSchema: z.object({
|
|
136
|
-
reason: z.string()
|
|
124
|
+
reason: z.string(),
|
|
137
125
|
}),
|
|
138
126
|
outputSchema: z.object({
|
|
139
|
-
value: z.string()
|
|
127
|
+
value: z.string(),
|
|
140
128
|
}),
|
|
141
129
|
execute: async ({ resumeData, suspend }) => {
|
|
142
130
|
const { confirm } = resumeData ?? {};
|
|
143
131
|
|
|
144
132
|
if (!confirm) {
|
|
145
133
|
return await suspend({
|
|
146
|
-
reason: "Confirm to continue"
|
|
134
|
+
reason: "Confirm to continue",
|
|
147
135
|
});
|
|
148
136
|
}
|
|
149
137
|
|
|
150
138
|
return { value: "" };
|
|
151
|
-
}
|
|
139
|
+
},
|
|
152
140
|
});
|
|
153
141
|
|
|
154
142
|
export const testWorkflow = createWorkflow({
|
|
@@ -156,7 +144,6 @@ export const testWorkflow = createWorkflow({
|
|
|
156
144
|
})
|
|
157
145
|
.then(step1)
|
|
158
146
|
.commit();
|
|
159
|
-
|
|
160
147
|
```
|
|
161
148
|
|
|
162
149
|
In this case, the reason provided explains that the user must confirm to continue.
|
|
@@ -168,36 +155,36 @@ In this case, the reason provided explains that the user must confirm to continu
|
|
|
168
155
|
"status": "suspended",
|
|
169
156
|
"suspendPayload": {
|
|
170
157
|
"reason": "Confirm to continue"
|
|
171
|
-
}
|
|
158
|
+
}
|
|
172
159
|
}
|
|
173
160
|
}
|
|
174
161
|
```
|
|
175
162
|
|
|
176
|
-
> See [
|
|
163
|
+
> See [Workflow Output](./overview#workflow-output) for more details.
|
|
177
164
|
|
|
178
165
|
## Resuming a workflow with `resume()`
|
|
179
166
|
|
|
180
167
|
A workflow can be resumed by calling `resume` and providing the required `resumeData`. You can either explicitly specify which step to resume from, or when exactly one step is suspended, omit the `step` parameter and the workflow will automatically resume that step.
|
|
181
168
|
|
|
182
|
-
```typescript {16-18}
|
|
169
|
+
```typescript {16-18} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
183
170
|
import { mastra } from "./mastra";
|
|
184
171
|
|
|
185
172
|
const run = await mastra.getWorkflow("testWorkflow").createRunAsync();
|
|
186
173
|
|
|
187
174
|
const result = await run.start({
|
|
188
|
-
|
|
189
|
-
city: "London"
|
|
190
|
-
}
|
|
175
|
+
inputData: {
|
|
176
|
+
city: "London",
|
|
177
|
+
},
|
|
191
178
|
});
|
|
192
179
|
|
|
193
180
|
console.log(JSON.stringify(result, null, 2));
|
|
194
181
|
|
|
195
182
|
if (result.status === "suspended") {
|
|
196
183
|
const resumedResult = await run.resume({
|
|
197
|
-
step:
|
|
184
|
+
step: "step-1",
|
|
198
185
|
resumeData: {
|
|
199
|
-
city: "Berlin"
|
|
200
|
-
}
|
|
186
|
+
city: "Berlin",
|
|
187
|
+
},
|
|
201
188
|
});
|
|
202
189
|
|
|
203
190
|
console.log(JSON.stringify(resumedResult, null, 2));
|
|
@@ -206,10 +193,10 @@ if (result.status === "suspended") {
|
|
|
206
193
|
|
|
207
194
|
You can also omit the `step` parameter when exactly one step is suspended:
|
|
208
195
|
|
|
209
|
-
```typescript {5}
|
|
196
|
+
```typescript {5} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
210
197
|
const resumedResult = await run.resume({
|
|
211
198
|
resumeData: {
|
|
212
|
-
city: "Berlin"
|
|
199
|
+
city: "Berlin",
|
|
213
200
|
},
|
|
214
201
|
// step parameter omitted - automatically resumes the single suspended step
|
|
215
202
|
});
|
|
@@ -217,43 +204,43 @@ const resumedResult = await run.resume({
|
|
|
217
204
|
|
|
218
205
|
You can pass `runtimeContext` as an argument to both the `start` and `resume` commands.
|
|
219
206
|
|
|
220
|
-
```typescript
|
|
207
|
+
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
221
208
|
import { RuntimeContext } from "@mastra/core/runtime-context";
|
|
222
209
|
|
|
223
210
|
const runtimeContext = new RuntimeContext();
|
|
224
211
|
|
|
225
212
|
const result = await run.start({
|
|
226
|
-
step:
|
|
213
|
+
step: "step-1",
|
|
227
214
|
inputData: {
|
|
228
|
-
city: "London"
|
|
215
|
+
city: "London",
|
|
229
216
|
},
|
|
230
|
-
runtimeContext
|
|
217
|
+
runtimeContext,
|
|
231
218
|
});
|
|
232
219
|
|
|
233
220
|
const resumedResult = await run.resume({
|
|
234
|
-
step:
|
|
221
|
+
step: "step-1",
|
|
235
222
|
resumeData: {
|
|
236
|
-
city: "New York"
|
|
223
|
+
city: "New York",
|
|
237
224
|
},
|
|
238
|
-
runtimeContext
|
|
225
|
+
runtimeContext,
|
|
239
226
|
});
|
|
240
227
|
```
|
|
241
228
|
|
|
242
|
-
> See [Runtime Context](
|
|
229
|
+
> See [Runtime Context](/docs/server-db/runtime-context) for more information.
|
|
243
230
|
|
|
244
231
|
### Resuming nested workflows
|
|
245
232
|
|
|
246
233
|
To resume a suspended nested workflow pass the workflow instance to the `step` parameter of the `resume` function.
|
|
247
234
|
|
|
248
|
-
```typescript {33-34}
|
|
235
|
+
```typescript {33-34} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
249
236
|
const dowhileWorkflow = createWorkflow({
|
|
250
|
-
id:
|
|
237
|
+
id: "dowhile-workflow",
|
|
251
238
|
inputSchema: z.object({ value: z.number() }),
|
|
252
239
|
outputSchema: z.object({ value: z.number() }),
|
|
253
240
|
})
|
|
254
241
|
.dountil(
|
|
255
242
|
createWorkflow({
|
|
256
|
-
id:
|
|
243
|
+
id: "simple-resume-workflow",
|
|
257
244
|
inputSchema: z.object({ value: z.number() }),
|
|
258
245
|
outputSchema: z.object({ value: z.number() }),
|
|
259
246
|
steps: [incrementStep, resumeStep],
|
|
@@ -265,7 +252,7 @@ const dowhileWorkflow = createWorkflow({
|
|
|
265
252
|
)
|
|
266
253
|
.then(
|
|
267
254
|
createStep({
|
|
268
|
-
id:
|
|
255
|
+
id: "final",
|
|
269
256
|
inputSchema: z.object({ value: z.number() }),
|
|
270
257
|
outputSchema: z.object({ value: z.number() }),
|
|
271
258
|
execute: async ({ inputData }) => ({ value: inputData.value }),
|
|
@@ -279,7 +266,7 @@ const result = await run.start({ inputData: { value: 0 } });
|
|
|
279
266
|
if (result.status === "suspended") {
|
|
280
267
|
const resumedResult = await run.resume({
|
|
281
268
|
resumeData: { value: 2 },
|
|
282
|
-
step: [
|
|
269
|
+
step: ["simple-resume-workflow", "resume"],
|
|
283
270
|
});
|
|
284
271
|
|
|
285
272
|
console.log(JSON.stringify(resumedResult, null, 2));
|
|
@@ -292,7 +279,7 @@ Workflows can also pause execution for timed delays or external events. These me
|
|
|
292
279
|
|
|
293
280
|
**Available methods:**
|
|
294
281
|
|
|
295
|
-
- [`.sleep()`](
|
|
296
|
-
- [`.sleepUntil()`](
|
|
297
|
-
- [`.waitForEvent()`](
|
|
298
|
-
- [`.sendEvent()`](
|
|
282
|
+
- [`.sleep()`](/reference/workflows/workflow-methods/sleep): Pause for a specified number of milliseconds
|
|
283
|
+
- [`.sleepUntil()`](/reference/workflows/workflow-methods/sleepUntil) : Pause until a specific date
|
|
284
|
+
- [`.waitForEvent()`](/reference/workflows/workflow-methods/waitForEvent): Pause until an external event is received
|
|
285
|
+
- [`.sendEvent()`](/reference/workflows/workflow-methods/sendEvent) : Send an event to resume a waiting workflow
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Branching, Merging, Conditions | Workflows (Legacy) | Mastra Docs"
|
|
2
|
+
title: "Control Flow in Legacy Workflows: Branching, Merging, and Conditions | Workflows (Legacy) | Mastra Docs"
|
|
3
|
+
sidebar_position: 7
|
|
4
|
+
sidebar_label: "Control Flow"
|
|
3
5
|
description: "Control flow in Mastra legacy workflows allows you to manage branching, merging, and conditions to construct legacy workflows that meet your logic requirements."
|
|
4
6
|
---
|
|
5
7
|
|
|
@@ -15,7 +17,7 @@ You can run multiple steps at the same time if they don't depend on each other.
|
|
|
15
17
|
myWorkflow.step(fetchUserData).step(fetchOrderData);
|
|
16
18
|
```
|
|
17
19
|
|
|
18
|
-
See the [Parallel Steps](
|
|
20
|
+
See the [Parallel Steps](/examples/workflows_legacy/parallel-steps) example for more details.
|
|
19
21
|
|
|
20
22
|
## Sequential Execution
|
|
21
23
|
|
|
@@ -25,7 +27,7 @@ Sometimes you need to run steps in strict order to ensure outputs from one step
|
|
|
25
27
|
myWorkflow.step(fetchOrderData).then(validateData).then(processOrder);
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
See the [Sequential Steps](
|
|
30
|
+
See the [Sequential Steps](/examples/workflows_legacy/sequential-steps) example for more details.
|
|
29
31
|
|
|
30
32
|
## Branching and Merging Paths
|
|
31
33
|
|
|
@@ -49,7 +51,7 @@ In this example:
|
|
|
49
51
|
- Separately, stepA also triggers stepC, which in turn leads to stepE.
|
|
50
52
|
- Separately, stepF is triggered when both stepD and stepE are completed.
|
|
51
53
|
|
|
52
|
-
See the [Branching Paths](
|
|
54
|
+
See the [Branching Paths](/examples/workflows_legacy/branching-paths) example for more details.
|
|
53
55
|
|
|
54
56
|
## Merging Multiple Branches
|
|
55
57
|
|
|
@@ -356,7 +358,7 @@ The `getStepResult` method provides a type-safe way to access step results. This
|
|
|
356
358
|
|
|
357
359
|
For better type safety, you can provide a type parameter to `getStepResult`:
|
|
358
360
|
|
|
359
|
-
```typescript showLineNumbers
|
|
361
|
+
```typescript showLineNumbers title="src/mastra/workflows/get-step-result.ts" copy
|
|
360
362
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
361
363
|
import { z } from "zod";
|
|
362
364
|
|
|
@@ -395,7 +397,7 @@ const analyzeDataStep = new LegacyStep({
|
|
|
395
397
|
|
|
396
398
|
The most type-safe approach is to reference the step directly in the `getStepResult` call:
|
|
397
399
|
|
|
398
|
-
```typescript showLineNumbers
|
|
400
|
+
```typescript showLineNumbers title="src/mastra/workflows/step-reference.ts" copy
|
|
399
401
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
400
402
|
import { z } from "zod";
|
|
401
403
|
|
|
@@ -442,7 +444,7 @@ Variable mapping is an explicit way to define data flow between steps.
|
|
|
442
444
|
This approach makes dependencies clear and provides good type safety.
|
|
443
445
|
The data injected into the step is available in the `context.inputData` object, and typed based on the `inputSchema` of the step.
|
|
444
446
|
|
|
445
|
-
```typescript showLineNumbers
|
|
447
|
+
```typescript showLineNumbers title="src/mastra/workflows/variable-mapping.ts" copy
|
|
446
448
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
447
449
|
import { z } from "zod";
|
|
448
450
|
|
|
@@ -495,14 +497,14 @@ workflow
|
|
|
495
497
|
.commit();
|
|
496
498
|
```
|
|
497
499
|
|
|
498
|
-
For more details on variable mapping, see the [Data Mapping with Workflow Variables](./variables
|
|
500
|
+
For more details on variable mapping, see the [Data Mapping with Workflow Variables](./variables) documentation.
|
|
499
501
|
|
|
500
502
|
### Using the Context Object
|
|
501
503
|
|
|
502
504
|
The context object provides direct access to all step results and their outputs. This approach is more flexible but requires careful handling to maintain type safety.
|
|
503
505
|
You can access step results directly through the `context.steps` object:
|
|
504
506
|
|
|
505
|
-
```typescript showLineNumbers
|
|
507
|
+
```typescript showLineNumbers title="src/mastra/workflows/context-access.ts" copy
|
|
506
508
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
507
509
|
import { z } from "zod";
|
|
508
510
|
|
|
@@ -537,7 +539,7 @@ workflow.step(fetchUserStep).then(processOrderStep).commit();
|
|
|
537
539
|
For comprehensive type safety across your entire workflow, you can define types for all steps and pass them to the Workflow
|
|
538
540
|
This allows you to get type safety for the context object on conditions, and on step results in the final workflow output.
|
|
539
541
|
|
|
540
|
-
```typescript showLineNumbers
|
|
542
|
+
```typescript showLineNumbers title="src/mastra/workflows/workflow-typing.ts" copy
|
|
541
543
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
542
544
|
import { z } from "zod";
|
|
543
545
|
|
|
@@ -592,7 +594,7 @@ workflow
|
|
|
592
594
|
|
|
593
595
|
In addition to step results, you can access the original trigger data that started the workflow:
|
|
594
596
|
|
|
595
|
-
```typescript showLineNumbers
|
|
597
|
+
```typescript showLineNumbers title="src/mastra/workflows/trigger-data.ts" copy
|
|
596
598
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
597
599
|
import { z } from "zod";
|
|
598
600
|
|
|
@@ -630,7 +632,7 @@ workflow.step(processOrderStep).commit();
|
|
|
630
632
|
|
|
631
633
|
The data injected into the step is available in the `context.inputData` object, and typed based on the `inputSchema` of the step.
|
|
632
634
|
|
|
633
|
-
```typescript showLineNumbers
|
|
635
|
+
```typescript showLineNumbers title="src/mastra/workflows/resume-data.ts" copy
|
|
634
636
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
635
637
|
import { z } from "zod";
|
|
636
638
|
|
|
@@ -678,7 +680,7 @@ console.log({ resumedResult });
|
|
|
678
680
|
|
|
679
681
|
You can get typed access to the results of a workflow by injecting the step types into the `Workflow` type params:
|
|
680
682
|
|
|
681
|
-
```typescript showLineNumbers
|
|
683
|
+
```typescript showLineNumbers title="src/mastra/workflows/get-results.ts" copy
|
|
682
684
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
683
685
|
import { z } from "zod";
|
|
684
686
|
|
|
@@ -741,23 +743,19 @@ if (result.results.fetchUser.status === "success") {
|
|
|
741
743
|
### Best Practices for Data Flow
|
|
742
744
|
|
|
743
745
|
1. **Use getStepResult with Step References for Type Safety**
|
|
744
|
-
|
|
745
746
|
- Ensures TypeScript can infer the correct types
|
|
746
747
|
- Catches type errors at compile time
|
|
747
748
|
|
|
748
749
|
2. \*_Use Variable Mapping for Explicit Dependencies_
|
|
749
|
-
|
|
750
750
|
- Makes data flow clear and maintainable
|
|
751
751
|
- Provides good documentation of step dependencies
|
|
752
752
|
|
|
753
753
|
3. **Define Output Schemas for Steps**
|
|
754
|
-
|
|
755
754
|
- Validates data at runtime
|
|
756
755
|
- Validates return type of the `execute` function
|
|
757
756
|
- Improves type inference in TypeScript
|
|
758
757
|
|
|
759
758
|
4. **Handle Missing Data Gracefully**
|
|
760
|
-
|
|
761
759
|
- Always check if step results exist before accessing properties
|
|
762
760
|
- Provide fallback values for optional data
|
|
763
761
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Dynamic Workflows (Legacy) | Mastra Docs"
|
|
2
|
+
title: "Dynamic Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
|
|
3
|
+
sidebar_position: 3
|
|
4
|
+
sidebar_label: "Dynamic Workflows"
|
|
3
5
|
description: "Learn how to create dynamic workflows within legacy workflow steps, allowing for flexible workflow creation based on runtime conditions."
|
|
4
6
|
---
|
|
5
7
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Error Handling in Workflows (Legacy) | Mastra Docs"
|
|
2
|
+
title: "Error Handling in Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
|
|
3
|
+
sidebar_position: 8
|
|
4
|
+
sidebar_label: "Error Handling"
|
|
3
5
|
description: "Learn how to handle errors in Mastra legacy workflows using step retries, conditional branching, and monitoring."
|
|
4
6
|
---
|
|
5
7
|
|
|
@@ -49,7 +51,7 @@ const apiStep = new LegacyStep({
|
|
|
49
51
|
});
|
|
50
52
|
```
|
|
51
53
|
|
|
52
|
-
For more details about step retries, see the [Step Retries](
|
|
54
|
+
For more details about step retries, see the [Step Retries](/reference/legacyWorkflows/step-retries) reference.
|
|
53
55
|
|
|
54
56
|
## Conditional Branching
|
|
55
57
|
|
|
@@ -179,7 +181,7 @@ For more complex error handling scenarios, consider:
|
|
|
179
181
|
|
|
180
182
|
## Related
|
|
181
183
|
|
|
182
|
-
- [Step Retries Reference](
|
|
183
|
-
- [Watch Method Reference](
|
|
184
|
-
- [Step Conditions](
|
|
185
|
-
- [Control Flow](./control-flow
|
|
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)
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Nested Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
|
|
3
|
+
sidebar_position: 4
|
|
4
|
+
sidebar_label: "Nested Workflows"
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Nested Workflows (Legacy)
|
|
2
8
|
|
|
3
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.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Handling Complex LLM Operations | Workflows (Legacy) | Mastra"
|
|
2
|
+
title: "Handling Complex LLM Operations with Workflows (Legacy) | Workflows (Legacy) | Mastra Docs"
|
|
3
|
+
sidebar_position: 1
|
|
4
|
+
sidebar_label: "Overview"
|
|
3
5
|
description: "Workflows in Mastra help you orchestrate complex sequences of operations with features like branching, parallel execution, resource suspension, and more."
|
|
4
6
|
---
|
|
5
7
|
|
|
@@ -7,14 +9,14 @@ description: "Workflows in Mastra help you orchestrate complex sequences of oper
|
|
|
7
9
|
|
|
8
10
|
All the legacy workflow documentation is available on the links below.
|
|
9
11
|
|
|
10
|
-
- [Steps](/docs/workflows-legacy/steps
|
|
11
|
-
- [Control Flow](/docs/workflows-legacy/control-flow
|
|
12
|
-
- [Variables](/docs/workflows-legacy/variables
|
|
13
|
-
- [Suspend & Resume](/docs/workflows-legacy/suspend-and-resume
|
|
14
|
-
- [Dynamic Workflows](/docs/workflows-legacy/dynamic-workflows
|
|
15
|
-
- [Error Handling](/docs/workflows-legacy/error-handling
|
|
16
|
-
- [Nested Workflows](/docs/workflows-legacy/nested-workflows
|
|
17
|
-
- [Runtime/Dynamic Variables](/docs/workflows-legacy/runtime-variables
|
|
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)
|
|
18
20
|
|
|
19
21
|
Workflows in Mastra help you orchestrate complex sequences of operations with features like branching, parallel execution, resource suspension, and more.
|
|
20
22
|
|
|
@@ -40,7 +42,7 @@ Let's examine each part of the workflow creation process:
|
|
|
40
42
|
|
|
41
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:
|
|
42
44
|
|
|
43
|
-
```ts
|
|
45
|
+
```ts title="src/mastra/workflow/index.ts"
|
|
44
46
|
import { LegacyStep, LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
45
47
|
|
|
46
48
|
const myWorkflow = new LegacyWorkflow({
|
|
@@ -55,7 +57,7 @@ const myWorkflow = new LegacyWorkflow({
|
|
|
55
57
|
|
|
56
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):
|
|
57
59
|
|
|
58
|
-
```ts
|
|
60
|
+
```ts title="src/mastra/workflow/index.ts"
|
|
59
61
|
const stepOne = new LegacyStep({
|
|
60
62
|
id: "stepOne",
|
|
61
63
|
outputSchema: z.object({
|
|
@@ -85,7 +87,7 @@ const stepTwo = new LegacyStep({
|
|
|
85
87
|
|
|
86
88
|
Now, let's create the control flow, and "commit" (finalize the workflow). In this case, `stepOne` runs first and is followed by `stepTwo`.
|
|
87
89
|
|
|
88
|
-
```ts
|
|
90
|
+
```ts title="src/mastra/workflow/index.ts"
|
|
89
91
|
myWorkflow.step(stepOne).then(stepTwo).commit();
|
|
90
92
|
```
|
|
91
93
|
|
|
@@ -93,7 +95,7 @@ myWorkflow.step(stepOne).then(stepTwo).commit();
|
|
|
93
95
|
|
|
94
96
|
Register your workflow with Mastra to enable logging and telemetry:
|
|
95
97
|
|
|
96
|
-
```ts showLineNumbers
|
|
98
|
+
```ts showLineNumbers title="src/mastra/index.ts"
|
|
97
99
|
import { Mastra } from "@mastra/core";
|
|
98
100
|
|
|
99
101
|
export const mastra = new Mastra({
|
|
@@ -103,7 +105,7 @@ export const mastra = new Mastra({
|
|
|
103
105
|
|
|
104
106
|
The workflow can also have the mastra instance injected into the context in the case where you need to create dynamic workflows:
|
|
105
107
|
|
|
106
|
-
```ts
|
|
108
|
+
```ts title="src/mastra/workflow/index.ts"
|
|
107
109
|
import { Mastra } from "@mastra/core";
|
|
108
110
|
import { LegacyWorkflow } from "@mastra/core/workflows/legacy";
|
|
109
111
|
|
|
@@ -119,7 +121,7 @@ const myWorkflow = new LegacyWorkflow({
|
|
|
119
121
|
|
|
120
122
|
Execute your workflow programmatically or via API:
|
|
121
123
|
|
|
122
|
-
```ts showLineNumbers
|
|
124
|
+
```ts showLineNumbers title="src/mastra/run-workflow.ts" copy
|
|
123
125
|
import { mastra } from "./index";
|
|
124
126
|
|
|
125
127
|
// Get the workflow
|
|
@@ -146,23 +148,23 @@ This example shows the essentials: define your workflow, add steps, commit the w
|
|
|
146
148
|
|
|
147
149
|
## Defining Steps
|
|
148
150
|
|
|
149
|
-
The basic building block of a workflow [is a step](./steps
|
|
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.
|
|
150
152
|
|
|
151
153
|
## Control Flow
|
|
152
154
|
|
|
153
|
-
Workflows let you define a [control flow](./control-flow
|
|
155
|
+
Workflows let you define a [control flow](./control-flow) to chain steps together in with parallel steps, branching paths, and more.
|
|
154
156
|
|
|
155
157
|
## Workflow Variables
|
|
156
158
|
|
|
157
|
-
When you need to map data between steps or create dynamic data flows, [workflow variables](./variables
|
|
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.
|
|
158
160
|
|
|
159
161
|
## Suspend and Resume
|
|
160
162
|
|
|
161
|
-
When you need to pause execution for external data, user input, or asynchronous events, Mastra [supports suspension at any step](./suspend-and-resume
|
|
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.
|
|
162
164
|
|
|
163
165
|
## Observability and Debugging
|
|
164
166
|
|
|
165
|
-
Mastra workflows automatically [log the input and output of each step within a workflow run](
|
|
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.
|
|
166
168
|
|
|
167
169
|
You can:
|
|
168
170
|
|
|
@@ -172,9 +174,9 @@ You can:
|
|
|
172
174
|
|
|
173
175
|
## More Resources
|
|
174
176
|
|
|
175
|
-
- [Sequential Steps workflow example](
|
|
176
|
-
- [Parallel Steps workflow example](
|
|
177
|
-
- [Branching Paths workflow example](
|
|
178
|
-
- [Workflow Variables example](
|
|
179
|
-
- [Cyclical Dependencies workflow example](
|
|
180
|
-
- [Suspend and Resume workflow example](
|
|
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,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Runtime
|
|
2
|
+
title: "Workflow Runtime Variables (Legacy) | Workflows (Legacy) | Mastra Docs"
|
|
3
|
+
sidebar_position: 6
|
|
4
|
+
sidebar_label: "Runtime/Dynamic Variables"
|
|
3
5
|
description: Learn how to use Mastra's dependency injection system to provide runtime configuration to workflows and steps.
|
|
4
6
|
---
|
|
5
7
|
|
|
@@ -41,7 +43,7 @@ await start({
|
|
|
41
43
|
|
|
42
44
|
Here's how to dynamically set a multiplier value from an HTTP header:
|
|
43
45
|
|
|
44
|
-
```typescript
|
|
46
|
+
```typescript title="src/index.ts"
|
|
45
47
|
import { Mastra } from "@mastra/core";
|
|
46
48
|
import { RuntimeContext } from "@mastra/core/di";
|
|
47
49
|
import { workflow as myWorkflow } from "./workflows";
|