@mastra/mcp-docs-server 1.0.0-beta.9 → 1.0.1
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 +3 -1
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +3 -1
- package/.docs/organized/changelogs/%40internal%2Fplayground.md +60 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +15 -15
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +3 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +302 -302
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +38 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +66 -66
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +522 -212
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +239 -239
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +439 -234
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +450 -211
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +202 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +448 -22
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +348 -348
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +60 -60
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +106 -106
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +90 -90
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +86 -86
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +221 -221
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +70 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +403 -225
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +72 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +145 -145
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +54 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +456 -226
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +625 -229
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +245 -245
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +281 -281
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +354 -156
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +545 -212
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +481 -202
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +194 -194
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +781 -235
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +198 -198
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +282 -282
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +163 -163
- package/.docs/organized/changelogs/%40mastra%2Frag.md +310 -310
- package/.docs/organized/changelogs/%40mastra%2Freact.md +328 -237
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +64 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +160 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +230 -230
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +479 -232
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +15 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +98 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +93 -93
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +45 -45
- package/.docs/organized/changelogs/create-mastra.md +219 -219
- package/.docs/organized/changelogs/mastra.md +276 -276
- package/.docs/organized/code-examples/a2a.md +2 -2
- package/.docs/organized/code-examples/agent-v6.md +221 -0
- package/.docs/organized/code-examples/agui.md +4 -4
- package/.docs/organized/code-examples/ai-elements.md +3 -3
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +3 -3
- package/.docs/organized/code-examples/assistant-ui.md +5 -5
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
- package/.docs/organized/code-examples/client-side-tools.md +4 -4
- package/.docs/organized/code-examples/crypto-chatbot.md +5 -5
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +7 -7
- package/.docs/organized/code-examples/inngest.md +1075 -0
- package/.docs/organized/code-examples/mcp-configuration.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +2 -2
- package/.docs/organized/code-examples/memory-per-resource-example.md +3 -3
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -1
- package/.docs/organized/code-examples/memory-with-context.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
- package/.docs/organized/code-examples/quick-start.md +1 -5
- package/.docs/organized/code-examples/server-app-access.md +2 -2
- package/.docs/organized/code-examples/server-express-adapter.md +1 -1
- package/.docs/organized/code-examples/server-fastify-adapter.md +83 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +2 -2
- package/.docs/organized/code-examples/server-koa-adapter.md +94 -0
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +24 -6
- package/.docs/raw/agents/agent-approval.mdx +209 -12
- package/.docs/raw/agents/agent-memory.mdx +36 -32
- package/.docs/raw/agents/guardrails.mdx +105 -56
- package/.docs/raw/agents/network-approval.mdx +281 -0
- package/.docs/raw/agents/networks.mdx +69 -13
- package/.docs/raw/agents/overview.mdx +43 -25
- package/.docs/raw/agents/processors.mdx +234 -17
- package/.docs/raw/agents/structured-output.mdx +78 -8
- package/.docs/raw/agents/using-tools.mdx +67 -6
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
- package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +3 -3
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/07-understanding-memory-threads.md +35 -0
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +1 -1
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +4 -5
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +3 -4
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +3 -4
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +3 -4
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +3 -4
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +22 -0
- package/.docs/raw/deployment/mastra-server.mdx +140 -0
- package/.docs/raw/deployment/monorepo.mdx +106 -42
- package/.docs/raw/deployment/overview.mdx +35 -48
- package/.docs/raw/deployment/web-framework.mdx +17 -19
- package/.docs/raw/deployment/workflow-runners.mdx +16 -0
- package/.docs/raw/evals/built-in-scorers.mdx +2 -0
- package/.docs/raw/evals/custom-scorers.mdx +60 -12
- package/.docs/raw/evals/overview.mdx +6 -6
- package/.docs/raw/evals/running-in-ci.mdx +4 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +59 -2
- package/.docs/raw/getting-started/project-structure.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +17 -1
- package/.docs/raw/getting-started/studio.mdx +6 -35
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +23 -33
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1034 -80
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +32 -11
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +9 -9
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +13 -16
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +5 -7
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +8 -5
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +18 -23
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/guides/deployment/inngest.mdx +673 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +7 -3
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +8 -5
- package/.docs/raw/guides/getting-started/astro.mdx +292 -451
- package/.docs/raw/guides/getting-started/express.mdx +72 -153
- package/.docs/raw/guides/getting-started/hono.mdx +227 -0
- package/.docs/raw/guides/getting-started/next-js.mdx +173 -61
- package/.docs/raw/guides/getting-started/nuxt.mdx +505 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +5 -5
- package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
- package/.docs/raw/guides/getting-started/vite-react.mdx +317 -147
- package/.docs/raw/guides/guide/ai-recruiter.mdx +10 -10
- package/.docs/raw/guides/guide/chef-michel.mdx +9 -11
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +15 -15
- package/.docs/raw/guides/guide/research-assistant.mdx +20 -20
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +38 -38
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/index.mdx +0 -1
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +105 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +15 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +170 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/deployment.mdx +42 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +0 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +40 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +17 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/rag.mdx +47 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +271 -25
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +72 -17
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +46 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +50 -7
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mastra-cloud/deployment.mdx +86 -0
- package/.docs/raw/mastra-cloud/observability.mdx +43 -0
- package/.docs/raw/mastra-cloud/overview.mdx +31 -0
- package/.docs/raw/mastra-cloud/setup.mdx +64 -0
- package/.docs/raw/mastra-cloud/studio.mdx +35 -0
- package/.docs/raw/mcp/overview.mdx +60 -25
- package/.docs/raw/mcp/publishing-mcp-server.mdx +7 -4
- package/.docs/raw/memory/memory-processors.mdx +17 -12
- package/.docs/raw/memory/message-history.mdx +72 -0
- package/.docs/raw/memory/overview.mdx +38 -76
- package/.docs/raw/memory/semantic-recall.mdx +65 -52
- package/.docs/raw/memory/storage.mdx +248 -0
- package/.docs/raw/memory/working-memory.mdx +24 -13
- package/.docs/raw/observability/logging.mdx +16 -15
- package/.docs/raw/observability/overview.mdx +27 -7
- package/.docs/raw/observability/tracing/bridges/otel.mdx +7 -4
- package/.docs/raw/observability/tracing/exporters/arize.mdx +61 -24
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +24 -5
- package/.docs/raw/observability/tracing/exporters/datadog.mdx +175 -0
- package/.docs/raw/observability/tracing/exporters/default.mdx +28 -7
- package/.docs/raw/observability/tracing/exporters/laminar.mdx +89 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +31 -22
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +33 -3
- package/.docs/raw/observability/tracing/exporters/otel.mdx +194 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/sentry.mdx +198 -0
- package/.docs/raw/observability/tracing/overview.mdx +388 -108
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +27 -7
- package/.docs/raw/rag/chunking-and-embedding.mdx +22 -33
- package/.docs/raw/rag/graph-rag.mdx +223 -0
- package/.docs/raw/rag/overview.mdx +6 -3
- package/.docs/raw/rag/retrieval.mdx +53 -57
- package/.docs/raw/rag/vector-databases.mdx +55 -31
- package/.docs/raw/reference/agents/agent.mdx +17 -14
- package/.docs/raw/reference/agents/generate.mdx +172 -44
- package/.docs/raw/reference/agents/generateLegacy.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDescription.mdx +3 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +5 -3
- package/.docs/raw/reference/agents/getLLM.mdx +5 -3
- package/.docs/raw/reference/agents/getMemory.mdx +5 -3
- package/.docs/raw/reference/agents/getModel.mdx +5 -3
- package/.docs/raw/reference/agents/getTools.mdx +4 -2
- package/.docs/raw/reference/agents/getVoice.mdx +4 -2
- package/.docs/raw/reference/agents/listAgents.mdx +4 -2
- package/.docs/raw/reference/agents/listScorers.mdx +5 -3
- package/.docs/raw/reference/agents/listTools.mdx +4 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +4 -2
- package/.docs/raw/reference/agents/network.mdx +113 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +5 -3
- package/.docs/raw/reference/ai-sdk/network-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +10 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +130 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +110 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +122 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +7 -4
- package/.docs/raw/reference/auth/auth0.mdx +5 -3
- package/.docs/raw/reference/auth/clerk.mdx +5 -3
- package/.docs/raw/reference/auth/firebase.mdx +6 -5
- package/.docs/raw/reference/auth/jwt.mdx +5 -3
- package/.docs/raw/reference/auth/supabase.mdx +5 -3
- package/.docs/raw/reference/auth/workos.mdx +5 -3
- package/.docs/raw/reference/cli/create-mastra.mdx +12 -10
- package/.docs/raw/reference/cli/mastra.mdx +63 -15
- package/.docs/raw/reference/client-js/agents.mdx +77 -35
- package/.docs/raw/reference/client-js/error-handling.mdx +3 -3
- package/.docs/raw/reference/client-js/logs.mdx +2 -0
- package/.docs/raw/reference/client-js/mastra-client.mdx +4 -2
- package/.docs/raw/reference/client-js/memory.mdx +43 -1
- package/.docs/raw/reference/client-js/observability.mdx +2 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +2 -0
- package/.docs/raw/reference/client-js/tools.mdx +2 -0
- package/.docs/raw/reference/client-js/vectors.mdx +2 -0
- package/.docs/raw/reference/client-js/workflows.mdx +47 -3
- package/.docs/raw/reference/configuration.mdx +761 -0
- package/.docs/raw/reference/core/addGateway.mdx +2 -0
- package/.docs/raw/reference/core/getAgent.mdx +3 -1
- package/.docs/raw/reference/core/getAgentById.mdx +3 -1
- package/.docs/raw/reference/core/getDeployer.mdx +3 -1
- package/.docs/raw/reference/core/getGateway.mdx +2 -0
- package/.docs/raw/reference/core/getGatewayById.mdx +2 -0
- package/.docs/raw/reference/core/getLogger.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +3 -1
- package/.docs/raw/reference/core/getMemory.mdx +7 -3
- package/.docs/raw/reference/core/getScorer.mdx +2 -0
- package/.docs/raw/reference/core/getScorerById.mdx +2 -0
- package/.docs/raw/reference/core/getServer.mdx +6 -4
- package/.docs/raw/reference/core/getStorage.mdx +5 -3
- package/.docs/raw/reference/core/getStoredAgentById.mdx +6 -4
- package/.docs/raw/reference/core/getTelemetry.mdx +3 -1
- package/.docs/raw/reference/core/getVector.mdx +3 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +3 -1
- package/.docs/raw/reference/core/listAgents.mdx +3 -1
- package/.docs/raw/reference/core/listGateways.mdx +2 -0
- package/.docs/raw/reference/core/listLogs.mdx +3 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +3 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +3 -1
- package/.docs/raw/reference/core/listMemory.mdx +8 -4
- package/.docs/raw/reference/core/listScorers.mdx +2 -0
- package/.docs/raw/reference/core/listStoredAgents.mdx +7 -5
- package/.docs/raw/reference/core/listVectors.mdx +3 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +3 -1
- package/.docs/raw/reference/core/mastra-class.mdx +27 -20
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +2 -0
- package/.docs/raw/reference/core/setLogger.mdx +3 -1
- package/.docs/raw/reference/core/setStorage.mdx +6 -4
- package/.docs/raw/reference/deployer/cloudflare.mdx +22 -53
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -1
- package/.docs/raw/reference/deployer/vercel.mdx +5 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/bias.mdx +4 -1
- package/.docs/raw/reference/evals/completeness.mdx +4 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/context-precision.mdx +4 -1
- package/.docs/raw/reference/evals/context-relevance.mdx +2 -0
- package/.docs/raw/reference/evals/create-scorer.mdx +11 -3
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -1
- package/.docs/raw/reference/evals/hallucination.mdx +4 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -1
- package/.docs/raw/reference/evals/mastra-scorer.mdx +2 -0
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +2 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +9 -7
- package/.docs/raw/reference/evals/run-evals.mdx +3 -1
- package/.docs/raw/reference/evals/scorer-utils.mdx +3 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +25 -23
- package/.docs/raw/reference/evals/toxicity.mdx +4 -1
- package/.docs/raw/reference/index.mdx +2 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +10 -8
- package/.docs/raw/reference/memory/clone-utilities.mdx +345 -0
- package/.docs/raw/reference/memory/cloneThread.mdx +237 -0
- package/.docs/raw/reference/memory/createThread.mdx +6 -4
- package/.docs/raw/reference/memory/deleteMessages.mdx +4 -2
- package/.docs/raw/reference/memory/getThreadById.mdx +3 -1
- package/.docs/raw/reference/memory/listThreads.mdx +187 -0
- package/.docs/raw/reference/memory/memory-class.mdx +27 -20
- package/.docs/raw/reference/memory/recall.mdx +6 -4
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +6 -2
- package/.docs/raw/reference/observability/tracing/configuration.mdx +51 -0
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +25 -6
- package/.docs/raw/reference/observability/tracing/exporters/braintrust.mdx +23 -2
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +3 -0
- package/.docs/raw/reference/observability/tracing/exporters/datadog.mdx +172 -0
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/laminar.mdx +139 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +26 -4
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +51 -34
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +25 -4
- package/.docs/raw/reference/observability/tracing/exporters/sentry.mdx +224 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +20 -0
- package/.docs/raw/reference/observability/tracing/processors/sensitive-data-filter.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/spans.mdx +2 -0
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +4 -2
- package/.docs/raw/reference/processors/language-detector.mdx +6 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +5 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +6 -4
- package/.docs/raw/reference/processors/pii-detector.mdx +6 -4
- package/.docs/raw/reference/processors/processor-interface.mdx +326 -23
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +5 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +7 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +5 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +62 -19
- package/.docs/raw/reference/processors/tool-call-filter.mdx +5 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +6 -3
- package/.docs/raw/reference/processors/working-memory-processor.mdx +6 -3
- package/.docs/raw/reference/rag/chunk.mdx +7 -6
- package/.docs/raw/reference/rag/database-config.mdx +8 -6
- package/.docs/raw/reference/rag/document.mdx +2 -0
- package/.docs/raw/reference/rag/embeddings.mdx +2 -0
- package/.docs/raw/reference/rag/extract-params.mdx +57 -3
- package/.docs/raw/reference/rag/graph-rag.mdx +2 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +27 -7
- package/.docs/raw/reference/rag/rerank.mdx +2 -0
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -0
- package/.docs/raw/reference/server/create-route.mdx +34 -18
- package/.docs/raw/reference/server/express-adapter.mdx +27 -51
- package/.docs/raw/reference/server/fastify-adapter.mdx +130 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +27 -51
- package/.docs/raw/reference/server/koa-adapter.mdx +129 -0
- package/.docs/raw/reference/server/mastra-server.mdx +52 -34
- package/.docs/raw/reference/server/routes.mdx +73 -10
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +10 -5
- package/.docs/raw/reference/storage/cloudflare.mdx +12 -2
- package/.docs/raw/reference/storage/composite.mdx +245 -0
- package/.docs/raw/reference/storage/convex.mdx +8 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +134 -8
- package/.docs/raw/reference/storage/lance.mdx +9 -5
- package/.docs/raw/reference/storage/libsql.mdx +76 -54
- package/.docs/raw/reference/storage/mongodb.mdx +115 -16
- package/.docs/raw/reference/storage/mssql.mdx +11 -6
- package/.docs/raw/{server-db/storage.mdx → reference/storage/overview.mdx} +15 -111
- package/.docs/raw/reference/storage/postgresql.mdx +228 -83
- package/.docs/raw/reference/storage/upstash.mdx +78 -2
- package/.docs/raw/reference/streaming/ChunkType.mdx +31 -3
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +67 -6
- package/.docs/raw/reference/streaming/agents/stream.mdx +48 -51
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +5 -3
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +37 -22
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +6 -4
- package/.docs/raw/reference/templates/overview.mdx +3 -2
- package/.docs/raw/reference/tools/client.mdx +3 -0
- package/.docs/raw/reference/tools/create-tool.mdx +127 -5
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +40 -3
- package/.docs/raw/reference/tools/mcp-client.mdx +110 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +278 -24
- package/.docs/raw/reference/tools/vector-query-tool.mdx +68 -4
- package/.docs/raw/reference/vectors/astra.mdx +5 -3
- package/.docs/raw/reference/vectors/chroma.mdx +5 -3
- package/.docs/raw/reference/vectors/convex.mdx +14 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +7 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +12 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +12 -4
- package/.docs/raw/reference/vectors/lance.mdx +6 -4
- package/.docs/raw/reference/vectors/libsql.mdx +66 -13
- package/.docs/raw/reference/vectors/mongodb.mdx +90 -10
- package/.docs/raw/reference/vectors/opensearch.mdx +30 -3
- package/.docs/raw/reference/vectors/pg.mdx +58 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +23 -8
- package/.docs/raw/reference/vectors/qdrant.mdx +148 -4
- package/.docs/raw/reference/vectors/s3vectors.mdx +8 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +6 -4
- package/.docs/raw/reference/vectors/upstash.mdx +60 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +5 -3
- package/.docs/raw/reference/voice/azure.mdx +2 -0
- package/.docs/raw/reference/voice/cloudflare.mdx +2 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +4 -0
- package/.docs/raw/reference/voice/deepgram.mdx +2 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +2 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +3 -0
- package/.docs/raw/reference/voice/google.mdx +2 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +2 -0
- package/.docs/raw/reference/voice/murf.mdx +2 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +3 -0
- package/.docs/raw/reference/voice/openai.mdx +2 -0
- package/.docs/raw/reference/voice/playai.mdx +2 -0
- package/.docs/raw/reference/voice/sarvam.mdx +2 -0
- package/.docs/raw/reference/voice/speechify.mdx +2 -0
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +3 -0
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +4 -0
- package/.docs/raw/reference/voice/voice.close.mdx +3 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +5 -1
- package/.docs/raw/reference/voice/voice.events.mdx +2 -0
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +3 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +6 -0
- package/.docs/raw/reference/voice/voice.off.mdx +2 -0
- package/.docs/raw/reference/voice/voice.on.mdx +5 -1
- package/.docs/raw/reference/voice/voice.send.mdx +4 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +6 -0
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +2 -0
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +55 -5
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +6 -4
- package/.docs/raw/reference/workflows/run-methods/start.mdx +7 -5
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +145 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +10 -8
- package/.docs/raw/reference/workflows/run.mdx +11 -3
- package/.docs/raw/reference/workflows/step.mdx +56 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +39 -2
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +71 -4
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +9 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow.mdx +193 -2
- package/.docs/raw/{auth → server/auth}/auth0.mdx +40 -21
- package/.docs/raw/{auth → server/auth}/clerk.mdx +37 -16
- package/.docs/raw/{auth → server/auth}/firebase.mdx +47 -25
- package/.docs/raw/{auth → server/auth}/index.mdx +8 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +22 -10
- package/.docs/raw/{auth → server/auth}/supabase.mdx +45 -25
- package/.docs/raw/{auth → server/auth}/workos.mdx +39 -20
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +40 -24
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +6 -6
- package/.docs/raw/{server-db → server}/mastra-client.mdx +35 -38
- package/.docs/raw/server/mastra-server.mdx +86 -0
- package/.docs/raw/{server-db → server}/middleware.mdx +11 -9
- package/.docs/raw/{server-db → server}/request-context.mdx +85 -43
- package/.docs/raw/{server-db → server}/server-adapters.mdx +154 -33
- package/.docs/raw/streaming/events.mdx +16 -7
- package/.docs/raw/streaming/overview.mdx +30 -17
- package/.docs/raw/streaming/tool-streaming.mdx +8 -6
- package/.docs/raw/streaming/workflow-streaming.mdx +8 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +4 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +46 -12
- package/.docs/raw/tools-mcp/overview.mdx +14 -13
- package/.docs/raw/voice/overview.mdx +17 -2
- package/.docs/raw/voice/speech-to-speech.mdx +5 -0
- package/.docs/raw/voice/speech-to-text.mdx +4 -0
- package/.docs/raw/voice/text-to-speech.mdx +3 -0
- package/.docs/raw/workflows/agents-and-tools.mdx +70 -21
- package/.docs/raw/workflows/control-flow.mdx +369 -34
- package/.docs/raw/workflows/error-handling.mdx +192 -18
- package/.docs/raw/workflows/human-in-the-loop.mdx +8 -7
- package/.docs/raw/workflows/input-data-mapping.mdx +9 -7
- package/.docs/raw/workflows/overview.mdx +80 -34
- package/.docs/raw/workflows/snapshots.mdx +19 -45
- package/.docs/raw/workflows/suspend-and-resume.mdx +14 -14
- package/.docs/raw/workflows/time-travel.mdx +25 -21
- package/.docs/raw/workflows/workflow-state.mdx +7 -8
- package/CHANGELOG.md +260 -0
- package/README.md +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +746 -49
- package/dist/tools/course.d.ts.map +1 -1
- package/dist/tools/embedded-docs.d.ts +276 -0
- package/dist/tools/embedded-docs.d.ts.map +1 -0
- package/package.json +9 -8
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/building-mastra.mdx +0 -73
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- package/.docs/raw/deployment/mastra-cloud/dashboard.mdx +0 -100
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +0 -53
- package/.docs/raw/deployment/mastra-cloud/overview.mdx +0 -65
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +0 -105
- package/.docs/raw/memory/conversation-history.mdx +0 -24
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +0 -140
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -150
- package/.docs/raw/memory/storage/memory-with-pg.mdx +0 -138
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +0 -146
- package/.docs/raw/memory/threads-and-resources.mdx +0 -95
- package/.docs/raw/reference/core/setTelemetry.mdx +0 -36
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +0 -110
- package/.docs/raw/reference/memory/query.mdx +0 -189
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +0 -70
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +0 -66
- package/.docs/raw/server-db/mastra-server.mdx +0 -97
- package/.docs/raw/workflows/inngest-workflow.mdx +0 -363
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Workflows overview | Workflows"
|
|
3
3
|
description: "Workflows in Mastra help you orchestrate complex sequences of tasks with features like branching, parallel execution, resource suspension, and more."
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/core"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
import Tabs from "@theme/Tabs";
|
|
@@ -8,7 +10,7 @@ import TabItem from "@theme/TabItem";
|
|
|
8
10
|
|
|
9
11
|
# Workflows overview
|
|
10
12
|
|
|
11
|
-
Workflows let you define complex sequences of tasks using clear, structured steps rather than relying on the reasoning of a single agent. They give you full control over how tasks are broken down, how data moves between them, and what gets executed when.
|
|
13
|
+
Workflows let you define complex sequences of tasks using clear, structured steps rather than relying on the reasoning of a single agent. They give you full control over how tasks are broken down, how data moves between them, and what gets executed when. Workflows run using the built-in execution engine by default, or can be deployed to [workflow runners](/docs/v1/deployment/workflow-runners) like Inngest for managed infrastructure.
|
|
12
14
|
|
|
13
15
|

|
|
14
16
|
|
|
@@ -32,7 +34,7 @@ Steps are the building blocks of workflows. Create a step using `createStep()` w
|
|
|
32
34
|
|
|
33
35
|
The `execute` function defines what the step does. Use it to call functions in your codebase, external APIs, agents, or tools.
|
|
34
36
|
|
|
35
|
-
```typescript {6,9,15} title="src/mastra/workflows/test-workflow.ts"
|
|
37
|
+
```typescript {6,9,15} title="src/mastra/workflows/test-workflow.ts"
|
|
36
38
|
import { createStep } from "@mastra/core/workflows";
|
|
37
39
|
|
|
38
40
|
const step1 = createStep({
|
|
@@ -53,7 +55,11 @@ const step1 = createStep({
|
|
|
53
55
|
});
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
:::info
|
|
59
|
+
|
|
60
|
+
Visit [Step Class](/reference/v1/workflows/step) for a full list of configuration options.
|
|
61
|
+
|
|
62
|
+
:::
|
|
57
63
|
|
|
58
64
|
### Using agents and tools
|
|
59
65
|
|
|
@@ -63,7 +69,7 @@ Workflow steps can also call registered agents or import and execute tools direc
|
|
|
63
69
|
|
|
64
70
|
Create a workflow using `createWorkflow()` with `inputSchema` and `outputSchema` to define the data it accepts and returns. Add steps using `.then()` and complete the workflow with `.commit()`.
|
|
65
71
|
|
|
66
|
-
```typescript {9,12,15,16} title="src/mastra/workflows/test-workflow.ts"
|
|
72
|
+
```typescript {9,12,15,16} title="src/mastra/workflows/test-workflow.ts"
|
|
67
73
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
68
74
|
import { z } from "zod";
|
|
69
75
|
|
|
@@ -82,7 +88,11 @@ export const testWorkflow = createWorkflow({
|
|
|
82
88
|
.commit();
|
|
83
89
|
```
|
|
84
90
|
|
|
85
|
-
|
|
91
|
+
:::info
|
|
92
|
+
|
|
93
|
+
Visit [Workflow Class](/reference/v1/workflows/workflow) for a full list of configuration options.
|
|
94
|
+
|
|
95
|
+
:::
|
|
86
96
|
|
|
87
97
|
### Understanding control flow
|
|
88
98
|
|
|
@@ -92,7 +102,7 @@ Workflows can be composed using a number of different methods. The method you ch
|
|
|
92
102
|
|
|
93
103
|
Workflow state lets you share values across steps without passing them through every step's inputSchema and outputSchema. Use state for tracking progress, accumulating results, or sharing configuration across the entire workflow.
|
|
94
104
|
|
|
95
|
-
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
105
|
+
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
96
106
|
const step1 = createStep({
|
|
97
107
|
id: "step-1",
|
|
98
108
|
inputSchema: z.object({ message: z.string() }),
|
|
@@ -110,13 +120,17 @@ const step1 = createStep({
|
|
|
110
120
|
});
|
|
111
121
|
```
|
|
112
122
|
|
|
113
|
-
|
|
123
|
+
:::info
|
|
124
|
+
|
|
125
|
+
Visit [Workflow State](/docs/v1/workflows/workflow-state) for complete documentation on state schemas, initial state, persistence across suspend/resume, and nested workflows.
|
|
126
|
+
|
|
127
|
+
:::
|
|
114
128
|
|
|
115
129
|
## Workflows as steps
|
|
116
130
|
|
|
117
131
|
Use a workflow as a step to reuse its logic within a larger composition. Input and output follow the same schema rules described in [Core principles](/docs/v1/workflows/control-flow).
|
|
118
132
|
|
|
119
|
-
```typescript {26} title="src/mastra/workflows/test-workflow.ts"
|
|
133
|
+
```typescript {26} title="src/mastra/workflows/test-workflow.ts"
|
|
120
134
|
const step1 = createStep({...});
|
|
121
135
|
const step2 = createStep({...});
|
|
122
136
|
|
|
@@ -150,7 +164,7 @@ export const testWorkflow = createWorkflow({
|
|
|
150
164
|
|
|
151
165
|
Clone a workflow using `cloneWorkflow()` when you want to reuse its logic but track it separately under a new ID. Each clone runs independently and appears as a distinct workflow in logs and observability tools.
|
|
152
166
|
|
|
153
|
-
```typescript {6} title="src/mastra/workflows/test-workflow.ts"
|
|
167
|
+
```typescript {6} title="src/mastra/workflows/test-workflow.ts"
|
|
154
168
|
import { cloneWorkflow } from "@mastra/core/workflows";
|
|
155
169
|
|
|
156
170
|
const step1 = createStep({...});
|
|
@@ -168,12 +182,11 @@ export const testWorkflow = createWorkflow({...})
|
|
|
168
182
|
|
|
169
183
|
Register your workflow in the Mastra instance to make it available throughout your application. Once registered, it can be called from agents or tools and has access to shared resources such as logging and observability features:
|
|
170
184
|
|
|
171
|
-
```typescript {
|
|
185
|
+
```typescript {5} title="src/mastra/index.ts"
|
|
172
186
|
import { Mastra } from "@mastra/core/mastra";
|
|
173
187
|
import { testWorkflow } from "./workflows/test-workflow";
|
|
174
188
|
|
|
175
189
|
export const mastra = new Mastra({
|
|
176
|
-
// ...
|
|
177
190
|
workflows: { testWorkflow },
|
|
178
191
|
});
|
|
179
192
|
```
|
|
@@ -182,7 +195,7 @@ export const mastra = new Mastra({
|
|
|
182
195
|
|
|
183
196
|
You can run workflows from agents, tools, the Mastra Client, or the command line. Get a reference by calling `.getWorkflow()` on your `mastra` or `mastraClient` instance, depending on your setup:
|
|
184
197
|
|
|
185
|
-
```typescript
|
|
198
|
+
```typescript
|
|
186
199
|
const testWorkflow = mastra.getWorkflow("testWorkflow");
|
|
187
200
|
```
|
|
188
201
|
:::info
|
|
@@ -197,7 +210,7 @@ Workflows can be run in two modes: start waits for all steps to complete before
|
|
|
197
210
|
<TabItem value="start" label="Start">
|
|
198
211
|
Create a workflow run instance using `createRun()`, then call `.start()` with `inputData` matching the workflow's `inputSchema`. The workflow executes all steps and returns the final result.
|
|
199
212
|
|
|
200
|
-
```typescript
|
|
213
|
+
```typescript
|
|
201
214
|
const run = await testWorkflow.createRun();
|
|
202
215
|
|
|
203
216
|
const result = await run.start({
|
|
@@ -206,42 +219,74 @@ const result = await run.start({
|
|
|
206
219
|
}
|
|
207
220
|
});
|
|
208
221
|
|
|
209
|
-
|
|
222
|
+
if (result.status === "success") {
|
|
223
|
+
console.log(result.result);
|
|
224
|
+
}
|
|
210
225
|
```
|
|
211
226
|
</TabItem>
|
|
212
227
|
<TabItem value="stream" label="Stream">
|
|
213
|
-
Create a workflow run instance using `.createRun()`, then call `.stream()` with `inputData` matching the workflow's `inputSchema`.
|
|
228
|
+
Create a workflow run instance using `.createRun()`, then call `.stream()` with `inputData` matching the workflow's `inputSchema`. Iterate over `fullStream` to track progress, then await `result` to get the final workflow result.
|
|
214
229
|
|
|
215
|
-
```typescript
|
|
230
|
+
```typescript
|
|
216
231
|
const run = await testWorkflow.createRun();
|
|
217
232
|
|
|
218
|
-
const
|
|
233
|
+
const stream = run.stream({
|
|
219
234
|
inputData: {
|
|
220
235
|
message: "Hello world"
|
|
221
236
|
}
|
|
222
237
|
});
|
|
223
238
|
|
|
224
|
-
for await (const chunk of
|
|
239
|
+
for await (const chunk of stream.fullStream) {
|
|
225
240
|
console.log(chunk);
|
|
226
241
|
}
|
|
242
|
+
|
|
243
|
+
// Get the final result (same type as run.start())
|
|
244
|
+
const result = await stream.result;
|
|
245
|
+
|
|
246
|
+
if (result.status === "success") {
|
|
247
|
+
console.log(result.result);
|
|
248
|
+
}
|
|
227
249
|
```
|
|
228
250
|
</TabItem>
|
|
229
251
|
</Tabs>
|
|
230
252
|
|
|
231
253
|
|
|
232
|
-
### Workflow
|
|
254
|
+
### Workflow result type
|
|
255
|
+
|
|
256
|
+
Both `run.start()` and `stream.result` return a discriminated union based on the `status` property, which can be `success`, `failed`, `suspended`, `tripwire`, or `paused`. You can always safely access `result.status`, `result.input`, `result.steps`, and optionally `result.state` regardless of the status.
|
|
257
|
+
|
|
258
|
+
Additionally, depending on the status, different properties are available:
|
|
259
|
+
|
|
260
|
+
| Status | Unique properties | Description |
|
|
261
|
+
| ----------- | ------------------------------- | -------------------------------------------------------- |
|
|
262
|
+
| `success` | `result` | The workflow's output data |
|
|
263
|
+
| `failed` | `error` | The error that caused the failure |
|
|
264
|
+
| `tripwire` | `tripwire` | Contains `reason`, `retry?`, `metadata?`, `processorId?` |
|
|
265
|
+
| `suspended` | `suspendPayload`, `suspended` | Suspension data and array of suspended step paths |
|
|
266
|
+
| `paused` | _(none)_ | Only common properties available |
|
|
233
267
|
|
|
234
|
-
|
|
268
|
+
To access status-specific properties, check the `status` first:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
const result = await run.start({ inputData: { message: "Hello world" } });
|
|
272
|
+
|
|
273
|
+
if (result.status === "success") {
|
|
274
|
+
console.log(result.result); // Only available when status is "success"
|
|
275
|
+
} else if (result.status === "failed") {
|
|
276
|
+
console.log(result.error.message);
|
|
277
|
+
} else if (result.status === "suspended") {
|
|
278
|
+
console.log(result.suspendPayload);
|
|
279
|
+
}
|
|
280
|
+
```
|
|
235
281
|
|
|
236
282
|
### Workflow output
|
|
237
283
|
|
|
238
|
-
|
|
284
|
+
Here's an example of a successful workflow result, showing the `input`, `steps`, and `result` properties:
|
|
239
285
|
|
|
240
286
|
```json
|
|
241
287
|
{
|
|
242
288
|
"status": "success",
|
|
243
289
|
"steps": {
|
|
244
|
-
// ...
|
|
245
290
|
"step-1": {
|
|
246
291
|
"status": "success",
|
|
247
292
|
"payload": {
|
|
@@ -249,7 +294,7 @@ The workflow output includes the full execution lifecycle, showing the input and
|
|
|
249
294
|
},
|
|
250
295
|
"output": {
|
|
251
296
|
"formatted": "HELLO WORLD"
|
|
252
|
-
}
|
|
297
|
+
}
|
|
253
298
|
},
|
|
254
299
|
"step-2": {
|
|
255
300
|
"status": "success",
|
|
@@ -258,7 +303,7 @@ The workflow output includes the full execution lifecycle, showing the input and
|
|
|
258
303
|
},
|
|
259
304
|
"output": {
|
|
260
305
|
"emphasized": "HELLO WORLD!!!"
|
|
261
|
-
}
|
|
306
|
+
}
|
|
262
307
|
}
|
|
263
308
|
},
|
|
264
309
|
"input": {
|
|
@@ -278,7 +323,7 @@ When a workflow run loses connection to the server, it can be restarted from the
|
|
|
278
323
|
|
|
279
324
|
Use `restartAllActiveWorkflowRuns()` to restart all active workflow runs of a workflow. This helps restart all active workflow runs of a workflow, without having to manually loop through each run and restart.
|
|
280
325
|
|
|
281
|
-
```typescript
|
|
326
|
+
```typescript
|
|
282
327
|
workflow.restartAllActiveWorkflowRuns();
|
|
283
328
|
```
|
|
284
329
|
|
|
@@ -286,13 +331,11 @@ workflow.restartAllActiveWorkflowRuns();
|
|
|
286
331
|
|
|
287
332
|
Use `restart()` to restart an active workflow run from the last active step. This will resume execution from the last active step, and the workflow will continue from there.
|
|
288
333
|
|
|
289
|
-
```typescript
|
|
334
|
+
```typescript
|
|
290
335
|
const run = await workflow.createRun();
|
|
291
336
|
|
|
292
337
|
const result = await run.start({ inputData: { value: "initial data" } });
|
|
293
338
|
|
|
294
|
-
//.. server connection lost,
|
|
295
|
-
|
|
296
339
|
const restartedResult = await run.restart();
|
|
297
340
|
```
|
|
298
341
|
|
|
@@ -300,14 +343,14 @@ const restartedResult = await run.restart();
|
|
|
300
343
|
|
|
301
344
|
When a workflow run is active, it will have a `status` of `running` or `waiting`. You can check the workflow's `status` to confirm it's active, and use `active` to identify the active workflow run.
|
|
302
345
|
|
|
303
|
-
```typescript
|
|
346
|
+
```typescript
|
|
304
347
|
const activeRuns = await workflow.listActiveWorkflowRuns();
|
|
305
348
|
if (activeRuns.runs.length > 0) {
|
|
306
349
|
console.log(activeRuns.runs);
|
|
307
350
|
}
|
|
308
351
|
```
|
|
309
352
|
|
|
310
|
-
:::
|
|
353
|
+
:::note
|
|
311
354
|
|
|
312
355
|
When running the local mastra server, all active workflow runs will be restarted automatically when the server starts.
|
|
313
356
|
|
|
@@ -315,15 +358,14 @@ When running the local mastra server, all active workflow runs will be restarted
|
|
|
315
358
|
|
|
316
359
|
## Using `RequestContext`
|
|
317
360
|
|
|
318
|
-
Use [RequestContext](/docs/v1/server
|
|
361
|
+
Use [RequestContext](/docs/v1/server/request-context) to access request-specific values. This lets you conditionally adjust behavior based on the context of the request.
|
|
319
362
|
|
|
320
|
-
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
363
|
+
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
321
364
|
export type UserTier = {
|
|
322
365
|
"user-tier": "enterprise" | "pro";
|
|
323
366
|
};
|
|
324
367
|
|
|
325
368
|
const step1 = createStep({
|
|
326
|
-
// ...
|
|
327
369
|
execute: async ({ requestContext }) => {
|
|
328
370
|
const userTier = requestContext.get("user-tier") as UserTier["user-tier"];
|
|
329
371
|
|
|
@@ -336,7 +378,11 @@ const step1 = createStep({
|
|
|
336
378
|
});
|
|
337
379
|
```
|
|
338
380
|
|
|
339
|
-
|
|
381
|
+
:::info
|
|
382
|
+
|
|
383
|
+
Visit [Request Context](/docs/v1/server/request-context) for more information.
|
|
384
|
+
|
|
385
|
+
:::
|
|
340
386
|
|
|
341
387
|
## Testing with Studio
|
|
342
388
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Snapshots | Workflows"
|
|
3
3
|
description: "Learn how to save and resume workflow execution state with snapshots in Mastra"
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/core"
|
|
6
|
+
- "@mastra/libsql"
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
# Snapshots
|
|
@@ -84,11 +87,11 @@ Each snapshot includes the `runId`, input, step status (`success`, `suspended`,
|
|
|
84
87
|
|
|
85
88
|
## How snapshots are saved and retrieved
|
|
86
89
|
|
|
87
|
-
Snapshots are saved to the configured storage system. By default, they use
|
|
90
|
+
Snapshots are saved to the configured storage system. By default, they use libSQL, but you can configure Upstash or PostgreSQL instead. Each snapshot is saved in the `workflow_snapshots` table and identified by the workflow's `runId`.
|
|
88
91
|
|
|
89
92
|
Read more about:
|
|
90
93
|
|
|
91
|
-
- [
|
|
94
|
+
- [libSQL Storage](/reference/v1/storage/libsql)
|
|
92
95
|
- [Upstash Storage](/reference/v1/storage/upstash)
|
|
93
96
|
- [PostgreSQL Storage](/reference/v1/storage/postgresql)
|
|
94
97
|
|
|
@@ -114,8 +117,9 @@ When a workflow is resumed, Mastra retrieves the persisted snapshot with these s
|
|
|
114
117
|
|
|
115
118
|
```typescript
|
|
116
119
|
const storage = mastra.getStorage();
|
|
120
|
+
const workflowStore = await storage?.getStore('workflows');
|
|
117
121
|
|
|
118
|
-
const snapshot = await
|
|
122
|
+
const snapshot = await workflowStore?.loadWorkflowSnapshot({
|
|
119
123
|
runId: "<run-id>",
|
|
120
124
|
workflowName: "<workflow-id>",
|
|
121
125
|
});
|
|
@@ -127,57 +131,27 @@ console.log(snapshot);
|
|
|
127
131
|
|
|
128
132
|
Snapshots are persisted using a `storage` instance configured on the `Mastra` class. This storage layer is shared across all workflows registered to that instance. Mastra supports multiple storage options for flexibility in different environments.
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
This example demonstrates how to use snapshots with LibSQL.
|
|
133
|
-
|
|
134
|
-
```typescript title="src/mastra/index.ts" showLineNumbers copy
|
|
134
|
+
```typescript title="src/mastra/index.ts"
|
|
135
135
|
import { Mastra } from "@mastra/core";
|
|
136
136
|
import { LibSQLStore } from "@mastra/libsql";
|
|
137
|
+
import { approvalWorkflow } from "./workflows";
|
|
137
138
|
|
|
138
139
|
export const mastra = new Mastra({
|
|
139
|
-
// ...
|
|
140
140
|
storage: new LibSQLStore({
|
|
141
141
|
id: 'mastra-storage',
|
|
142
142
|
url: ":memory:",
|
|
143
143
|
}),
|
|
144
|
+
workflows: { approvalWorkflow },
|
|
144
145
|
});
|
|
145
146
|
```
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
export const mastra = new Mastra({
|
|
156
|
-
// ...
|
|
157
|
-
storage: new UpstashStore({
|
|
158
|
-
id: 'upstash-storage',
|
|
159
|
-
url: "<upstash-redis-rest-url>",
|
|
160
|
-
token: "<upstash-redis-rest-token>",
|
|
161
|
-
}),
|
|
162
|
-
});
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### Postgres `@mastra/pg`
|
|
166
|
-
|
|
167
|
-
This example demonstrates how to use snapshots with PostgreSQL.
|
|
168
|
-
|
|
169
|
-
```typescript title="src/mastra/index.ts" showLineNumbers copy
|
|
170
|
-
import { Mastra } from "@mastra/core";
|
|
171
|
-
import { PostgresStore } from "@mastra/pg";
|
|
172
|
-
|
|
173
|
-
export const mastra = new Mastra({
|
|
174
|
-
// ...
|
|
175
|
-
storage: new PostgresStore({
|
|
176
|
-
id: 'mastra-storage',
|
|
177
|
-
connectionString: "<database-url>",
|
|
178
|
-
}),
|
|
179
|
-
});
|
|
180
|
-
```
|
|
148
|
+
- [libSQL Storage](/reference/v1/storage/libsql)
|
|
149
|
+
- [PostgreSQL Storage](/reference/v1/storage/postgresql)
|
|
150
|
+
- [MongoDB Storage](/reference/v1/storage/mongodb)
|
|
151
|
+
- [Upstash Storage](/reference/v1/storage/upstash)
|
|
152
|
+
- [Cloudflare D1](/reference/v1/storage/cloudflare-d1)
|
|
153
|
+
- [DynamoDB](/reference/v1/storage/dynamodb)
|
|
154
|
+
- [More storage providers](/docs/v1/memory/storage)
|
|
181
155
|
|
|
182
156
|
## Best practices
|
|
183
157
|
|
|
@@ -191,7 +165,7 @@ export const mastra = new Mastra({
|
|
|
191
165
|
|
|
192
166
|
You can attach custom metadata when suspending a workflow by defining a `suspendSchema`. This metadata is stored in the snapshot and made available when the workflow is resumed.
|
|
193
167
|
|
|
194
|
-
```typescript {30-34} title="src/mastra/workflows/test-workflow.ts"
|
|
168
|
+
```typescript {30-34} title="src/mastra/workflows/test-workflow.ts"
|
|
195
169
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
196
170
|
import { z } from "zod";
|
|
197
171
|
|
|
@@ -240,7 +214,7 @@ const approvalStep = createStep({
|
|
|
240
214
|
|
|
241
215
|
Use `resumeData` to pass structured input when resuming a suspended step. It must match the step’s `resumeSchema`.
|
|
242
216
|
|
|
243
|
-
```typescript {14-20}
|
|
217
|
+
```typescript {14-20}
|
|
244
218
|
const workflow = mastra.getWorkflow("approvalWorkflow");
|
|
245
219
|
|
|
246
220
|
const run = await workflow.createRun();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Suspend & Resume | Workflows"
|
|
3
3
|
description: "Suspend and resume in Mastra workflows allows you to pause execution while waiting for external input or resources."
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/core"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# Suspend & Resume
|
|
@@ -15,7 +17,7 @@ Use `suspend()` to pause workflow execution at a specific step. You can define a
|
|
|
15
17
|
|
|
16
18
|

|
|
17
19
|
|
|
18
|
-
```typescript {9-11,16-18} title="src/mastra/workflows/test-workflow.ts"
|
|
20
|
+
```typescript {9-11,16-18} title="src/mastra/workflows/test-workflow.ts"
|
|
19
21
|
const step1 = createStep({
|
|
20
22
|
id: "step-1",
|
|
21
23
|
inputSchema: z.object({
|
|
@@ -60,7 +62,7 @@ Use `resume()` to restart a suspended workflow from the step where it paused. Pa
|
|
|
60
62
|
|
|
61
63
|

|
|
62
64
|
|
|
63
|
-
```typescript
|
|
65
|
+
```typescript
|
|
64
66
|
import { step1 } from "./workflows/test-workflow";
|
|
65
67
|
|
|
66
68
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
@@ -82,7 +84,7 @@ const handleResume = async () => {
|
|
|
82
84
|
|
|
83
85
|
Passing the `step` object provides full type-safety for `resumeData`. Alternatively, you can pass a step ID for more flexibility when the ID comes from user input or a database.
|
|
84
86
|
|
|
85
|
-
```typescript
|
|
87
|
+
```typescript
|
|
86
88
|
const result = await run.resume({
|
|
87
89
|
step: "step-1",
|
|
88
90
|
resumeData: { approved: true }
|
|
@@ -91,11 +93,11 @@ const result = await run.resume({
|
|
|
91
93
|
|
|
92
94
|
If only one step is suspended, you can omit the step argument entirely and Mastra will resume the last suspended step in the workflow.
|
|
93
95
|
|
|
94
|
-
When resuming with only a `runId`, create a run instance first using `
|
|
96
|
+
When resuming with only a `runId`, create a run instance first using `createRun()`.
|
|
95
97
|
|
|
96
|
-
```typescript
|
|
98
|
+
```typescript
|
|
97
99
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
98
|
-
const run = await workflow.
|
|
100
|
+
const run = await workflow.createRun({ runId: "123" });
|
|
99
101
|
|
|
100
102
|
const stream = run.resume({
|
|
101
103
|
resumeData: { approved: true }
|
|
@@ -104,7 +106,7 @@ const stream = run.resume({
|
|
|
104
106
|
|
|
105
107
|
You can call `resume()` from anywhere in your application, including HTTP endpoints, event handlers, in response to [human input](/docs/v1/workflows/human-in-the-loop), or timers.
|
|
106
108
|
|
|
107
|
-
```typescript
|
|
109
|
+
```typescript
|
|
108
110
|
const midnight = new Date();
|
|
109
111
|
midnight.setUTCHours(24, 0, 0, 0);
|
|
110
112
|
|
|
@@ -119,7 +121,7 @@ setTimeout(async () => {
|
|
|
119
121
|
## Accessing suspend data with `suspendData`
|
|
120
122
|
When a step is suspended, you may want to access the data that was provided to `suspend()` when the step is later resumed. Use the `suspendData` parameter in your step's execute function to access this data.
|
|
121
123
|
|
|
122
|
-
```typescript {22-25,29-30} title="src/mastra/workflows/user-approval.ts"
|
|
124
|
+
```typescript {22-25,29-30} title="src/mastra/workflows/user-approval.ts"
|
|
123
125
|
const approvalStep = createStep({
|
|
124
126
|
id: "user-approval",
|
|
125
127
|
inputSchema: z.object({
|
|
@@ -164,7 +166,7 @@ The `suspendData` parameter is automatically populated when a step is resumed an
|
|
|
164
166
|
|
|
165
167
|
When a workflow is suspended, it restarts from the step where it paused. You can check the workflow's `status` to confirm it's suspended, and use `suspended` to identify the paused step or [nested workflow](/docs/v1/workflows/overview#workflows-as-steps).
|
|
166
168
|
|
|
167
|
-
```typescript {11}
|
|
169
|
+
```typescript {11}
|
|
168
170
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
169
171
|
const run = await workflow.createRun();
|
|
170
172
|
|
|
@@ -191,16 +193,14 @@ The `suspended` array contains the IDs of any suspended workflows and steps from
|
|
|
191
193
|
[ 'nested-workflow', 'step-1' ]
|
|
192
194
|
```
|
|
193
195
|
|
|
194
|
-
## Sleep
|
|
196
|
+
## Sleep
|
|
195
197
|
|
|
196
|
-
Sleep
|
|
198
|
+
Sleep methods can be used to pause execution at the workflow level, which sets the status to `waiting`. By comparison, `suspend()` pauses execution within a specific step and sets the status to `suspended`.
|
|
197
199
|
|
|
198
200
|
**Available methods:**
|
|
199
201
|
|
|
200
202
|
- [`.sleep()`](/reference/v1/workflows/workflow-methods/sleep): Pause for a specified number of milliseconds
|
|
201
|
-
- [`.sleepUntil()`](/reference/v1/workflows/workflow-methods/sleepUntil)
|
|
202
|
-
- [`.waitForEvent()`](/reference/v1/workflows/workflow-methods/waitForEvent): Pause until an external event is received
|
|
203
|
-
- [`.sendEvent()`](/reference/v1/workflows/workflow-methods/sendEvent) : Send an event to resume a waiting workflow
|
|
203
|
+
- [`.sleepUntil()`](/reference/v1/workflows/workflow-methods/sleepUntil): Pause until a specific date
|
|
204
204
|
|
|
205
205
|
## Related
|
|
206
206
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Time Travel | Workflows"
|
|
3
3
|
description: "Re-execute workflow steps from a specific point using time travel debugging in Mastra"
|
|
4
|
+
packages:
|
|
5
|
+
- "@mastra/core"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# Time Travel
|
|
@@ -23,7 +25,7 @@ Time travel requires storage to be configured since it relies on persisted workf
|
|
|
23
25
|
|
|
24
26
|
Use `run.timeTravel()` to re-execute a workflow from a specific step:
|
|
25
27
|
|
|
26
|
-
```typescript
|
|
28
|
+
```typescript
|
|
27
29
|
import { mastra } from "./mastra";
|
|
28
30
|
|
|
29
31
|
const workflow = mastra.getWorkflow("myWorkflow");
|
|
@@ -41,7 +43,7 @@ You can specify the target step using either a step reference or a step ID:
|
|
|
41
43
|
|
|
42
44
|
### Using step reference
|
|
43
45
|
|
|
44
|
-
```typescript
|
|
46
|
+
```typescript
|
|
45
47
|
const result = await run.timeTravel({
|
|
46
48
|
step: step2,
|
|
47
49
|
inputData: { value: 10 },
|
|
@@ -50,7 +52,7 @@ const result = await run.timeTravel({
|
|
|
50
52
|
|
|
51
53
|
### Using step ID
|
|
52
54
|
|
|
53
|
-
```typescript
|
|
55
|
+
```typescript
|
|
54
56
|
const result = await run.timeTravel({
|
|
55
57
|
step: "step2",
|
|
56
58
|
inputData: { value: 10 },
|
|
@@ -61,7 +63,7 @@ const result = await run.timeTravel({
|
|
|
61
63
|
|
|
62
64
|
For steps inside nested workflows, use dot notation, an array of step IDS or an array of step references:
|
|
63
65
|
|
|
64
|
-
```typescript
|
|
66
|
+
```typescript
|
|
65
67
|
// Using dot notation
|
|
66
68
|
const result = await run.timeTravel({
|
|
67
69
|
step: "nestedWorkflow.step3",
|
|
@@ -85,7 +87,7 @@ const result = await run.timeTravel({
|
|
|
85
87
|
|
|
86
88
|
You can provide context to specify the state of previous steps when time traveling:
|
|
87
89
|
|
|
88
|
-
```typescript {3-13}
|
|
90
|
+
```typescript {3-13}
|
|
89
91
|
const result = await run.timeTravel({
|
|
90
92
|
step: "step2",
|
|
91
93
|
context: {
|
|
@@ -114,7 +116,7 @@ The context object contains step results keyed by step ID. Each step result incl
|
|
|
114
116
|
|
|
115
117
|
Time travel is particularly useful for debugging and recovering from failed workflow executions:
|
|
116
118
|
|
|
117
|
-
```typescript
|
|
119
|
+
```typescript
|
|
118
120
|
const workflow = mastra.getWorkflow("myWorkflow");
|
|
119
121
|
const run = await workflow.createRun();
|
|
120
122
|
|
|
@@ -136,7 +138,7 @@ if (failedResult.status === "failed") {
|
|
|
136
138
|
|
|
137
139
|
You can time travel to resume a suspended workflow from an earlier step:
|
|
138
140
|
|
|
139
|
-
```typescript
|
|
141
|
+
```typescript
|
|
140
142
|
const run = await workflow.createRun();
|
|
141
143
|
|
|
142
144
|
// Start workflow - suspends at promptAgent step
|
|
@@ -159,28 +161,30 @@ if (initialResult.status === "suspended") {
|
|
|
159
161
|
|
|
160
162
|
Use `timeTravelStream()` to receive streaming events during time travel execution:
|
|
161
163
|
|
|
162
|
-
```typescript
|
|
164
|
+
```typescript
|
|
163
165
|
const run = await workflow.createRun();
|
|
164
166
|
|
|
165
|
-
const
|
|
167
|
+
const stream = run.timeTravelStream({
|
|
166
168
|
step: "step2",
|
|
167
169
|
inputData: { value: 10 },
|
|
168
170
|
});
|
|
169
171
|
|
|
170
|
-
|
|
171
|
-
for await (const event of output.fullStream) {
|
|
172
|
+
for await (const event of stream.fullStream) {
|
|
172
173
|
console.log(event.type, event.payload);
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
const result = await stream.result;
|
|
177
|
+
|
|
178
|
+
if (result.status === "success") {
|
|
179
|
+
console.log(result.result);
|
|
180
|
+
}
|
|
177
181
|
```
|
|
178
182
|
|
|
179
183
|
## Time travel with initial state
|
|
180
184
|
|
|
181
185
|
You can provide initial state when time traveling to set workflow-level state:
|
|
182
186
|
|
|
183
|
-
```typescript
|
|
187
|
+
```typescript
|
|
184
188
|
const result = await run.timeTravel({
|
|
185
189
|
step: "step2",
|
|
186
190
|
inputData: { value: 10 },
|
|
@@ -199,7 +203,7 @@ Time travel throws errors in specific situations:
|
|
|
199
203
|
|
|
200
204
|
You cannot time travel to a workflow that is currently running:
|
|
201
205
|
|
|
202
|
-
```typescript
|
|
206
|
+
```typescript
|
|
203
207
|
try {
|
|
204
208
|
await run.timeTravel({ step: "step2" });
|
|
205
209
|
} catch (error) {
|
|
@@ -211,7 +215,7 @@ try {
|
|
|
211
215
|
|
|
212
216
|
Time travel throws if the target step doesn't exist in the workflow:
|
|
213
217
|
|
|
214
|
-
```typescript
|
|
218
|
+
```typescript
|
|
215
219
|
try {
|
|
216
220
|
await run.timeTravel({ step: "nonExistentStep" });
|
|
217
221
|
} catch (error) {
|
|
@@ -223,7 +227,7 @@ try {
|
|
|
223
227
|
|
|
224
228
|
When `validateInputs` is enabled, time travel validates the input data against the step's schema:
|
|
225
229
|
|
|
226
|
-
```typescript
|
|
230
|
+
```typescript
|
|
227
231
|
try {
|
|
228
232
|
await run.timeTravel({
|
|
229
233
|
step: "step2",
|
|
@@ -238,7 +242,7 @@ try {
|
|
|
238
242
|
|
|
239
243
|
When time traveling into a nested workflow, you can provide context for both the parent and nested workflow steps:
|
|
240
244
|
|
|
241
|
-
```typescript
|
|
245
|
+
```typescript
|
|
242
246
|
const result = await run.timeTravel({
|
|
243
247
|
step: "nestedWorkflow.step3",
|
|
244
248
|
context: {
|
|
@@ -275,7 +279,7 @@ const result = await run.timeTravel({
|
|
|
275
279
|
|
|
276
280
|
Re-run a failed step with the same or modified input to diagnose issues:
|
|
277
281
|
|
|
278
|
-
```typescript
|
|
282
|
+
```typescript
|
|
279
283
|
const result = await run.timeTravel({
|
|
280
284
|
step: failedStepId,
|
|
281
285
|
context: originalContext, // Use context from the failed run
|
|
@@ -286,7 +290,7 @@ const result = await run.timeTravel({
|
|
|
286
290
|
|
|
287
291
|
Test individual steps with specific inputs on a new workflow run, useful for testing a step logic without starting workflow execution from the beginning.
|
|
288
292
|
|
|
289
|
-
```typescript
|
|
293
|
+
```typescript
|
|
290
294
|
const result = await run.timeTravel({
|
|
291
295
|
step: "processData",
|
|
292
296
|
inputData: { testData: "specific test case" },
|
|
@@ -297,7 +301,7 @@ const result = await run.timeTravel({
|
|
|
297
301
|
|
|
298
302
|
Re-run steps that failed due to temporary issues (network errors, rate limits):
|
|
299
303
|
|
|
300
|
-
```typescript
|
|
304
|
+
```typescript
|
|
301
305
|
// After fixing the external service issue
|
|
302
306
|
const result = await run.timeTravel({
|
|
303
307
|
step: "callExternalApi",
|