@mastra/mcp-docs-server 1.0.0-beta.11 → 1.0.0-beta.14
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/%40mastra%2Fagent-builder.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +51 -51
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +180 -180
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +68 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +331 -331
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +96 -96
- package/.docs/organized/changelogs/%40mastra%2Frag.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Freact.md +49 -2
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +122 -122
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +39 -39
- package/.docs/organized/changelogs/create-mastra.md +31 -31
- package/.docs/organized/changelogs/mastra.md +51 -51
- package/.docs/organized/code-examples/agent-v6.md +151 -0
- package/.docs/organized/code-examples/ai-elements.md +1 -1
- package/.docs/organized/code-examples/quick-start.md +0 -4
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/raw/agents/adding-voice.mdx +2 -3
- package/.docs/raw/agents/agent-approval.mdx +139 -6
- package/.docs/raw/agents/agent-memory.mdx +24 -32
- package/.docs/raw/agents/guardrails.mdx +61 -51
- package/.docs/raw/agents/networks.mdx +9 -13
- package/.docs/raw/agents/overview.mdx +40 -24
- package/.docs/raw/agents/processors.mdx +20 -19
- package/.docs/raw/agents/structured-output.mdx +11 -7
- package/.docs/raw/agents/using-tools.mdx +5 -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 +2 -2
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +3 -4
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -3
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +2 -3
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -2
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +2 -3
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +20 -0
- package/.docs/raw/deployment/{building-mastra.mdx → mastra-server.mdx} +5 -5
- package/.docs/raw/deployment/monorepo.mdx +23 -44
- package/.docs/raw/deployment/overview.mdx +32 -50
- package/.docs/raw/deployment/web-framework.mdx +15 -19
- package/.docs/raw/evals/custom-scorers.mdx +9 -6
- package/.docs/raw/evals/overview.mdx +3 -6
- package/.docs/raw/evals/running-in-ci.mdx +2 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +10 -1
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +4 -4
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1033 -79
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +11 -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 +12 -15
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/guides/deployment/inngest.mdx +386 -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 +170 -61
- package/.docs/raw/guides/getting-started/quickstart.mdx +4 -4
- 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 +17 -17
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +8 -8
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +17 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +6 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +0 -2
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/dashboard.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/observability.mdx +1 -5
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/overview.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/setting-up.mdx +8 -7
- package/.docs/raw/mcp/overview.mdx +31 -13
- package/.docs/raw/mcp/publishing-mcp-server.mdx +2 -2
- package/.docs/raw/memory/memory-processors.mdx +9 -9
- package/.docs/raw/memory/message-history.mdx +69 -0
- package/.docs/raw/memory/overview.mdx +34 -76
- package/.docs/raw/memory/semantic-recall.mdx +58 -49
- package/.docs/raw/memory/storage.mdx +188 -0
- package/.docs/raw/memory/working-memory.mdx +7 -7
- package/.docs/raw/observability/logging.mdx +10 -11
- package/.docs/raw/observability/overview.mdx +0 -1
- package/.docs/raw/observability/tracing/bridges/otel.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/default.mdx +3 -3
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +1 -2
- package/.docs/raw/observability/tracing/overview.mdx +23 -25
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/rag/chunking-and-embedding.mdx +18 -31
- package/.docs/raw/rag/graph-rag.mdx +220 -0
- package/.docs/raw/rag/overview.mdx +2 -3
- package/.docs/raw/rag/retrieval.mdx +34 -51
- package/.docs/raw/rag/vector-databases.mdx +29 -25
- package/.docs/raw/reference/agents/agent.mdx +3 -3
- package/.docs/raw/reference/agents/generate.mdx +1 -1
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +3 -3
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +3 -3
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +3 -3
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +3 -3
- package/.docs/raw/reference/agents/getLLM.mdx +3 -3
- package/.docs/raw/reference/agents/getMemory.mdx +3 -3
- package/.docs/raw/reference/agents/getModel.mdx +3 -3
- package/.docs/raw/reference/agents/getTools.mdx +2 -2
- package/.docs/raw/reference/agents/getVoice.mdx +2 -2
- package/.docs/raw/reference/agents/listAgents.mdx +2 -2
- package/.docs/raw/reference/agents/listScorers.mdx +3 -3
- package/.docs/raw/reference/agents/listTools.mdx +2 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +2 -2
- package/.docs/raw/reference/agents/network.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/network-route.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +6 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +127 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +107 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +3 -3
- package/.docs/raw/reference/auth/auth0.mdx +2 -3
- package/.docs/raw/reference/auth/clerk.mdx +2 -3
- package/.docs/raw/reference/auth/firebase.mdx +3 -5
- package/.docs/raw/reference/auth/jwt.mdx +2 -3
- package/.docs/raw/reference/auth/supabase.mdx +2 -3
- package/.docs/raw/reference/auth/workos.mdx +2 -3
- package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
- package/.docs/raw/reference/cli/mastra.mdx +10 -10
- package/.docs/raw/reference/client-js/agents.mdx +1 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +2 -2
- package/.docs/raw/reference/client-js/workflows.mdx +20 -0
- package/.docs/raw/reference/core/getAgent.mdx +1 -1
- package/.docs/raw/reference/core/getAgentById.mdx +1 -1
- package/.docs/raw/reference/core/getDeployer.mdx +1 -1
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +1 -1
- package/.docs/raw/reference/core/getMemory.mdx +2 -2
- package/.docs/raw/reference/core/getServer.mdx +3 -3
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getStoredAgentById.mdx +3 -3
- package/.docs/raw/reference/core/getTelemetry.mdx +1 -1
- package/.docs/raw/reference/core/getVector.mdx +1 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
- package/.docs/raw/reference/core/listAgents.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +1 -1
- package/.docs/raw/reference/core/listMemory.mdx +2 -2
- package/.docs/raw/reference/core/listStoredAgents.mdx +4 -4
- package/.docs/raw/reference/core/listVectors.mdx +1 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setStorage.mdx +2 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/cloudflare.mdx +1 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -1
- package/.docs/raw/reference/deployer/vercel.mdx +2 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +1 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/bias.mdx +1 -1
- package/.docs/raw/reference/evals/completeness.mdx +1 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/context-precision.mdx +1 -1
- package/.docs/raw/reference/evals/faithfulness.mdx +1 -1
- package/.docs/raw/reference/evals/hallucination.mdx +1 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +1 -1
- package/.docs/raw/reference/evals/prompt-alignment.mdx +7 -7
- package/.docs/raw/reference/evals/textual-difference.mdx +1 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +1 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +10 -10
- package/.docs/raw/reference/evals/toxicity.mdx +1 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +7 -8
- package/.docs/raw/reference/memory/createThread.mdx +2 -2
- package/.docs/raw/reference/memory/deleteMessages.mdx +2 -2
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +2 -2
- package/.docs/raw/reference/memory/memory-class.mdx +3 -3
- package/.docs/raw/reference/memory/query.mdx +2 -2
- package/.docs/raw/reference/memory/recall.mdx +2 -2
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +2 -2
- package/.docs/raw/reference/processors/language-detector.mdx +2 -2
- package/.docs/raw/reference/processors/message-history-processor.mdx +2 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +3 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +3 -3
- package/.docs/raw/reference/processors/processor-interface.mdx +13 -13
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +2 -2
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +2 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +3 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +2 -2
- package/.docs/raw/reference/processors/working-memory-processor.mdx +3 -3
- package/.docs/raw/reference/rag/chunk.mdx +1 -1
- package/.docs/raw/reference/rag/database-config.mdx +1 -1
- package/.docs/raw/reference/rag/extract-params.mdx +2 -2
- package/.docs/raw/reference/rag/metadata-filters.mdx +7 -7
- package/.docs/raw/reference/server/create-route.mdx +14 -14
- package/.docs/raw/reference/server/express-adapter.mdx +10 -11
- package/.docs/raw/reference/server/hono-adapter.mdx +10 -11
- package/.docs/raw/reference/server/mastra-server.mdx +22 -22
- package/.docs/raw/reference/server/routes.mdx +28 -1
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +3 -3
- package/.docs/raw/reference/storage/cloudflare.mdx +2 -2
- package/.docs/raw/reference/storage/convex.mdx +6 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +4 -4
- package/.docs/raw/reference/storage/lance.mdx +3 -3
- package/.docs/raw/reference/storage/libsql.mdx +69 -54
- package/.docs/raw/reference/storage/mongodb.mdx +80 -7
- package/.docs/raw/reference/storage/mssql.mdx +4 -4
- package/.docs/raw/{server-db/storage.mdx → reference/storage/overview.mdx} +13 -111
- package/.docs/raw/reference/storage/postgresql.mdx +78 -7
- package/.docs/raw/reference/storage/upstash.mdx +74 -2
- package/.docs/raw/reference/streaming/agents/stream.mdx +27 -5
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +2 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +35 -22
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +4 -4
- package/.docs/raw/reference/templates/overview.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +24 -5
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +3 -3
- package/.docs/raw/reference/tools/vector-query-tool.mdx +4 -4
- package/.docs/raw/reference/vectors/astra.mdx +3 -3
- package/.docs/raw/reference/vectors/chroma.mdx +3 -3
- package/.docs/raw/reference/vectors/convex.mdx +12 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +5 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +10 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +4 -4
- package/.docs/raw/reference/vectors/lance.mdx +4 -4
- package/.docs/raw/reference/vectors/libsql.mdx +61 -11
- package/.docs/raw/reference/vectors/mongodb.mdx +58 -5
- package/.docs/raw/reference/vectors/pg.mdx +53 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +3 -3
- package/.docs/raw/reference/vectors/qdrant.mdx +3 -3
- package/.docs/raw/reference/vectors/s3vectors.mdx +6 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +4 -4
- package/.docs/raw/reference/vectors/upstash.mdx +55 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +1 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/start.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +143 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +5 -5
- package/.docs/raw/reference/workflows/run.mdx +1 -1
- package/.docs/raw/reference/workflows/step.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +37 -2
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +6 -6
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +7 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow.mdx +17 -3
- package/.docs/raw/{auth → server/auth}/auth0.mdx +20 -14
- package/.docs/raw/{auth → server/auth}/clerk.mdx +16 -9
- package/.docs/raw/{auth → server/auth}/firebase.mdx +21 -15
- package/.docs/raw/{auth → server/auth}/index.mdx +6 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +14 -7
- package/.docs/raw/{auth → server/auth}/supabase.mdx +16 -9
- package/.docs/raw/{auth → server/auth}/workos.mdx +19 -13
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +13 -13
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +3 -5
- package/.docs/raw/{server-db → server}/mastra-client.mdx +26 -15
- package/.docs/raw/{server-db → server}/mastra-server.mdx +8 -8
- package/.docs/raw/{server-db → server}/middleware.mdx +9 -9
- package/.docs/raw/{server-db → server}/request-context.mdx +33 -32
- package/.docs/raw/{server-db → server}/server-adapters.mdx +12 -12
- package/.docs/raw/streaming/events.mdx +14 -7
- package/.docs/raw/streaming/overview.mdx +21 -10
- package/.docs/raw/streaming/tool-streaming.mdx +6 -6
- package/.docs/raw/streaming/workflow-streaming.mdx +6 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +31 -12
- package/.docs/raw/tools-mcp/overview.mdx +10 -11
- package/.docs/raw/voice/overview.mdx +1 -1
- package/.docs/raw/workflows/agents-and-tools.mdx +28 -19
- package/.docs/raw/workflows/control-flow.mdx +27 -40
- package/.docs/raw/workflows/error-handling.mdx +172 -18
- package/.docs/raw/workflows/human-in-the-loop.mdx +6 -7
- package/.docs/raw/workflows/inngest-workflow.mdx +8 -9
- package/.docs/raw/workflows/input-data-mapping.mdx +7 -7
- package/.docs/raw/workflows/overview.mdx +34 -23
- package/.docs/raw/workflows/snapshots.mdx +14 -44
- package/.docs/raw/workflows/suspend-and-resume.mdx +7 -7
- package/.docs/raw/workflows/time-travel.mdx +16 -16
- package/.docs/raw/workflows/workflow-state.mdx +5 -8
- package/CHANGELOG.md +23 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +53 -0
- package/package.json +4 -4
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- 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
|
@@ -13,7 +13,7 @@ Human-in-the-loop input works much like [pausing a workflow](/docs/v1/workflows/
|
|
|
13
13
|
|
|
14
14
|

|
|
15
15
|
|
|
16
|
-
```typescript {12-17,22-26} title="src/mastra/workflows/test-workflow.ts"
|
|
16
|
+
```typescript {12-17,22-26} title="src/mastra/workflows/test-workflow.ts"
|
|
17
17
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
18
18
|
import { z } from "zod";
|
|
19
19
|
|
|
@@ -64,7 +64,7 @@ export const testWorkflow = createWorkflow({
|
|
|
64
64
|
|
|
65
65
|
When a workflow is suspended, you can access the payload returned by `suspend()` by identifying the suspended step and reading its `suspendPayload`.
|
|
66
66
|
|
|
67
|
-
```typescript {12} title="src/test-workflow.ts"
|
|
67
|
+
```typescript {12} title="src/test-workflow.ts"
|
|
68
68
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
69
69
|
const run = await workflow.createRun();
|
|
70
70
|
|
|
@@ -95,7 +95,7 @@ As with [restarting a workflow](/docs/v1/workflows/suspend-and-resume#restarting
|
|
|
95
95
|
|
|
96
96
|

|
|
97
97
|
|
|
98
|
-
```typescript {13}
|
|
98
|
+
```typescript {13}
|
|
99
99
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
100
100
|
const run = await workflow.createRun();
|
|
101
101
|
|
|
@@ -117,9 +117,8 @@ const handleResume = async () => {
|
|
|
117
117
|
|
|
118
118
|
Use `bail()` to stop workflow execution at a step without triggering an error. This can be useful when a human explicitly rejects an action. The workflow completes with a `success` status, and any logic after the call to `bail()` is skipped.
|
|
119
119
|
|
|
120
|
-
```typescript {
|
|
120
|
+
```typescript {6-10}
|
|
121
121
|
const step1 = createStep({
|
|
122
|
-
// ...
|
|
123
122
|
execute: async ({ inputData, resumeData, suspend, bail }) => {
|
|
124
123
|
const { userEmail } = inputData;
|
|
125
124
|
const { approved } = resumeData ?? {};
|
|
@@ -147,7 +146,7 @@ const step1 = createStep({
|
|
|
147
146
|
|
|
148
147
|
For workflows that require input at multiple stages, the suspend pattern remains the same. Each step defines a `resumeSchema`, and `suspendSchema` typically with a reason that can be used to provide user feedback.
|
|
149
148
|
|
|
150
|
-
```typescript {11-16,21-25} title="src/mastra/workflows/test-workflow.ts"
|
|
149
|
+
```typescript {11-16,21-25} title="src/mastra/workflows/test-workflow.ts"
|
|
151
150
|
const step1 = createStep({...});
|
|
152
151
|
|
|
153
152
|
const step2 = createStep({
|
|
@@ -196,7 +195,7 @@ export const testWorkflow = createWorkflow({
|
|
|
196
195
|
|
|
197
196
|
Each step must be resumed in sequence, with a separate call to `resume()` for each suspended step. This approach helps manage multi-step approvals with consistent UI feedback and clear input handling at each stage.
|
|
198
197
|
|
|
199
|
-
```typescript {4,11}
|
|
198
|
+
```typescript {4,11}
|
|
200
199
|
const handleResume = async () => {
|
|
201
200
|
const result = await run.resume({
|
|
202
201
|
step: "step-1",
|
|
@@ -33,7 +33,7 @@ Initialize the Inngest integration to obtain Mastra-compatible workflow helpers.
|
|
|
33
33
|
|
|
34
34
|
In development
|
|
35
35
|
|
|
36
|
-
```ts
|
|
36
|
+
```ts title="src/mastra/inngest/index.ts"
|
|
37
37
|
import { Inngest } from "inngest";
|
|
38
38
|
import { realtimeMiddleware } from "@inngest/realtime/middleware";
|
|
39
39
|
|
|
@@ -47,7 +47,7 @@ export const inngest = new Inngest({
|
|
|
47
47
|
|
|
48
48
|
In production
|
|
49
49
|
|
|
50
|
-
```ts
|
|
50
|
+
```ts title="src/mastra/inngest/index.ts"
|
|
51
51
|
import { Inngest } from "inngest";
|
|
52
52
|
import { realtimeMiddleware } from "@inngest/realtime/middleware";
|
|
53
53
|
|
|
@@ -61,7 +61,7 @@ export const inngest = new Inngest({
|
|
|
61
61
|
|
|
62
62
|
Define the individual steps that will compose your workflow:
|
|
63
63
|
|
|
64
|
-
```ts
|
|
64
|
+
```ts title="src/mastra/workflows/index.ts"
|
|
65
65
|
import { z } from "zod";
|
|
66
66
|
import { inngest } from "../inngest";
|
|
67
67
|
import { init } from "@mastra/inngest";
|
|
@@ -88,7 +88,7 @@ const incrementStep = createStep({
|
|
|
88
88
|
|
|
89
89
|
Compose the steps into a workflow using the `dountil` loop pattern. The createWorkflow function creates a function on inngest server that is invocable.
|
|
90
90
|
|
|
91
|
-
```ts
|
|
91
|
+
```ts title="src/mastra/workflows/index.ts"
|
|
92
92
|
// workflow that is registered as a function on inngest server
|
|
93
93
|
const workflow = createWorkflow({
|
|
94
94
|
id: "increment-workflow",
|
|
@@ -109,7 +109,7 @@ export { workflow as incrementWorkflow };
|
|
|
109
109
|
|
|
110
110
|
Register the workflow with Mastra and configure the Inngest API endpoint:
|
|
111
111
|
|
|
112
|
-
```ts
|
|
112
|
+
```ts title="src/mastra/index.ts"
|
|
113
113
|
import { Mastra } from "@mastra/core";
|
|
114
114
|
import { serve as inngestServe } from "@mastra/inngest";
|
|
115
115
|
import { incrementWorkflow } from "./workflows";
|
|
@@ -216,11 +216,10 @@ docker run --rm -p 8288:8288 \
|
|
|
216
216
|
|
|
217
217
|
1. Add Vercel Deployer to Mastra instance
|
|
218
218
|
|
|
219
|
-
```ts
|
|
219
|
+
```ts title="src/mastra/index.ts"
|
|
220
220
|
import { VercelDeployer } from "@mastra/deployer-vercel";
|
|
221
221
|
|
|
222
222
|
export const mastra = new Mastra({
|
|
223
|
-
// ...other config
|
|
224
223
|
deployer: new VercelDeployer({
|
|
225
224
|
teamSlug: "your_team_slug",
|
|
226
225
|
projectName: "your_project_name",
|
|
@@ -291,7 +290,7 @@ You can serve additional Inngest functions alongside your Mastra workflows by us
|
|
|
291
290
|
|
|
292
291
|
First, create your custom Inngest functions:
|
|
293
292
|
|
|
294
|
-
```ts
|
|
293
|
+
```ts title="src/inngest/custom-functions.ts"
|
|
295
294
|
import { inngest } from "./inngest";
|
|
296
295
|
|
|
297
296
|
// Define custom Inngest functions
|
|
@@ -320,7 +319,7 @@ export const customWebhookFunction = inngest.createFunction(
|
|
|
320
319
|
|
|
321
320
|
Update your Mastra configuration to include the custom functions:
|
|
322
321
|
|
|
323
|
-
```ts
|
|
322
|
+
```ts title="src/mastra/index.ts"
|
|
324
323
|
import { Mastra } from "@mastra/core";
|
|
325
324
|
import { serve as inngestServe } from "@mastra/inngest";
|
|
326
325
|
import { incrementWorkflow } from "./workflows";
|
|
@@ -18,7 +18,7 @@ In this example the `output` from `step1` is transformed to match the `inputSche
|
|
|
18
18
|
|
|
19
19
|

|
|
20
20
|
|
|
21
|
-
```typescript {9} title="src/mastra/workflows/test-workflow.ts"
|
|
21
|
+
```typescript {9} title="src/mastra/workflows/test-workflow.ts"
|
|
22
22
|
const step1 = createStep({...});
|
|
23
23
|
const step2 = createStep({...});
|
|
24
24
|
|
|
@@ -38,7 +38,7 @@ export const testWorkflow = createWorkflow({...})
|
|
|
38
38
|
|
|
39
39
|
Use `inputData` to access the full output of the previous step:
|
|
40
40
|
|
|
41
|
-
```typescript {3} title="src/mastra/workflows/test-workflow.ts"
|
|
41
|
+
```typescript {3} title="src/mastra/workflows/test-workflow.ts"
|
|
42
42
|
.then(step1)
|
|
43
43
|
.map(({ inputData }) => {
|
|
44
44
|
console.log(inputData);
|
|
@@ -49,7 +49,7 @@ Use `inputData` to access the full output of the previous step:
|
|
|
49
49
|
|
|
50
50
|
Use `getStepResult` to access the full output of a specific step by referencing the step's instance:
|
|
51
51
|
|
|
52
|
-
```typescript {3} title="src/mastra/workflows/test-workflow.ts"
|
|
52
|
+
```typescript {3} title="src/mastra/workflows/test-workflow.ts"
|
|
53
53
|
.then(step1)
|
|
54
54
|
.map(async ({ getStepResult }) => {
|
|
55
55
|
console.log(getStepResult(step1));
|
|
@@ -60,7 +60,7 @@ Use `getStepResult` to access the full output of a specific step by referencing
|
|
|
60
60
|
|
|
61
61
|
Use `getInitData` to access the initial input data provided to the workflow:
|
|
62
62
|
|
|
63
|
-
```typescript {3} title="src/mastra/workflows/test-workflow.ts"
|
|
63
|
+
```typescript {3} title="src/mastra/workflows/test-workflow.ts"
|
|
64
64
|
.then(step1)
|
|
65
65
|
.map(async ({ getInitData }) => {
|
|
66
66
|
console.log(getInitData());
|
|
@@ -71,7 +71,7 @@ Use `getInitData` to access the initial input data provided to the workflow:
|
|
|
71
71
|
|
|
72
72
|
To use `mapVariable` import the necessary function from the workflows module:
|
|
73
73
|
|
|
74
|
-
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
74
|
+
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
75
75
|
import { mapVariable } from "@mastra/core/workflows";
|
|
76
76
|
```
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ import { mapVariable } from "@mastra/core/workflows";
|
|
|
79
79
|
|
|
80
80
|
You can rename step outputs using the object syntax in `.map()`. In the example below, the `value` output from `step1` is renamed to `details`:
|
|
81
81
|
|
|
82
|
-
```typescript {3-6} title="src/mastra/workflows/test-workflow.ts"
|
|
82
|
+
```typescript {3-6} title="src/mastra/workflows/test-workflow.ts"
|
|
83
83
|
.then(step1)
|
|
84
84
|
.map({
|
|
85
85
|
details: mapVariable({
|
|
@@ -93,7 +93,7 @@ You can rename step outputs using the object syntax in `.map()`. In the example
|
|
|
93
93
|
|
|
94
94
|
You can rename workflow outputs by using **referential composition**. This involves passing the workflow instance as the `initData`.
|
|
95
95
|
|
|
96
|
-
```typescript {6-9} title="src/mastra/workflows/test-workflow.ts"
|
|
96
|
+
```typescript {6-9} title="src/mastra/workflows/test-workflow.ts"
|
|
97
97
|
export const testWorkflow = createWorkflow({...});
|
|
98
98
|
|
|
99
99
|
testWorkflow
|
|
@@ -32,7 +32,7 @@ Steps are the building blocks of workflows. Create a step using `createStep()` w
|
|
|
32
32
|
|
|
33
33
|
The `execute` function defines what the step does. Use it to call functions in your codebase, external APIs, agents, or tools.
|
|
34
34
|
|
|
35
|
-
```typescript {6,9,15} title="src/mastra/workflows/test-workflow.ts"
|
|
35
|
+
```typescript {6,9,15} title="src/mastra/workflows/test-workflow.ts"
|
|
36
36
|
import { createStep } from "@mastra/core/workflows";
|
|
37
37
|
|
|
38
38
|
const step1 = createStep({
|
|
@@ -53,7 +53,11 @@ const step1 = createStep({
|
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
:::info
|
|
57
|
+
|
|
58
|
+
Visit [Step Class](/reference/v1/workflows/step) for a full list of configuration options.
|
|
59
|
+
|
|
60
|
+
:::
|
|
57
61
|
|
|
58
62
|
### Using agents and tools
|
|
59
63
|
|
|
@@ -63,7 +67,7 @@ Workflow steps can also call registered agents or import and execute tools direc
|
|
|
63
67
|
|
|
64
68
|
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
69
|
|
|
66
|
-
```typescript {9,12,15,16} title="src/mastra/workflows/test-workflow.ts"
|
|
70
|
+
```typescript {9,12,15,16} title="src/mastra/workflows/test-workflow.ts"
|
|
67
71
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
68
72
|
import { z } from "zod";
|
|
69
73
|
|
|
@@ -82,7 +86,11 @@ export const testWorkflow = createWorkflow({
|
|
|
82
86
|
.commit();
|
|
83
87
|
```
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
:::info
|
|
90
|
+
|
|
91
|
+
Visit [Workflow Class](/reference/v1/workflows/workflow) for a full list of configuration options.
|
|
92
|
+
|
|
93
|
+
:::
|
|
86
94
|
|
|
87
95
|
### Understanding control flow
|
|
88
96
|
|
|
@@ -92,7 +100,7 @@ Workflows can be composed using a number of different methods. The method you ch
|
|
|
92
100
|
|
|
93
101
|
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
102
|
|
|
95
|
-
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
103
|
+
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
96
104
|
const step1 = createStep({
|
|
97
105
|
id: "step-1",
|
|
98
106
|
inputSchema: z.object({ message: z.string() }),
|
|
@@ -110,13 +118,17 @@ const step1 = createStep({
|
|
|
110
118
|
});
|
|
111
119
|
```
|
|
112
120
|
|
|
113
|
-
|
|
121
|
+
:::info
|
|
122
|
+
|
|
123
|
+
Visit [Workflow State](/docs/v1/workflows/workflow-state) for complete documentation on state schemas, initial state, persistence across suspend/resume, and nested workflows.
|
|
124
|
+
|
|
125
|
+
:::
|
|
114
126
|
|
|
115
127
|
## Workflows as steps
|
|
116
128
|
|
|
117
129
|
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
130
|
|
|
119
|
-
```typescript {26} title="src/mastra/workflows/test-workflow.ts"
|
|
131
|
+
```typescript {26} title="src/mastra/workflows/test-workflow.ts"
|
|
120
132
|
const step1 = createStep({...});
|
|
121
133
|
const step2 = createStep({...});
|
|
122
134
|
|
|
@@ -150,7 +162,7 @@ export const testWorkflow = createWorkflow({
|
|
|
150
162
|
|
|
151
163
|
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
164
|
|
|
153
|
-
```typescript {6} title="src/mastra/workflows/test-workflow.ts"
|
|
165
|
+
```typescript {6} title="src/mastra/workflows/test-workflow.ts"
|
|
154
166
|
import { cloneWorkflow } from "@mastra/core/workflows";
|
|
155
167
|
|
|
156
168
|
const step1 = createStep({...});
|
|
@@ -168,12 +180,11 @@ export const testWorkflow = createWorkflow({...})
|
|
|
168
180
|
|
|
169
181
|
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
182
|
|
|
171
|
-
```typescript {
|
|
183
|
+
```typescript {5} title="src/mastra/index.ts"
|
|
172
184
|
import { Mastra } from "@mastra/core/mastra";
|
|
173
185
|
import { testWorkflow } from "./workflows/test-workflow";
|
|
174
186
|
|
|
175
187
|
export const mastra = new Mastra({
|
|
176
|
-
// ...
|
|
177
188
|
workflows: { testWorkflow },
|
|
178
189
|
});
|
|
179
190
|
```
|
|
@@ -182,7 +193,7 @@ export const mastra = new Mastra({
|
|
|
182
193
|
|
|
183
194
|
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
195
|
|
|
185
|
-
```typescript
|
|
196
|
+
```typescript
|
|
186
197
|
const testWorkflow = mastra.getWorkflow("testWorkflow");
|
|
187
198
|
```
|
|
188
199
|
:::info
|
|
@@ -197,7 +208,7 @@ Workflows can be run in two modes: start waits for all steps to complete before
|
|
|
197
208
|
<TabItem value="start" label="Start">
|
|
198
209
|
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
210
|
|
|
200
|
-
```typescript
|
|
211
|
+
```typescript
|
|
201
212
|
const run = await testWorkflow.createRun();
|
|
202
213
|
|
|
203
214
|
const result = await run.start({
|
|
@@ -212,7 +223,7 @@ console.log(result);
|
|
|
212
223
|
<TabItem value="stream" label="Stream">
|
|
213
224
|
Create a workflow run instance using `.createRun()`, then call `.stream()` with `inputData` matching the workflow's `inputSchema`. The workflow emits events as each step executes, which you can iterate over to track progress.
|
|
214
225
|
|
|
215
|
-
```typescript
|
|
226
|
+
```typescript
|
|
216
227
|
const run = await testWorkflow.createRun();
|
|
217
228
|
|
|
218
229
|
const result = await run.stream({
|
|
@@ -241,7 +252,6 @@ The workflow output includes the full execution lifecycle, showing the input and
|
|
|
241
252
|
{
|
|
242
253
|
"status": "success",
|
|
243
254
|
"steps": {
|
|
244
|
-
// ...
|
|
245
255
|
"step-1": {
|
|
246
256
|
"status": "success",
|
|
247
257
|
"payload": {
|
|
@@ -278,7 +288,7 @@ When a workflow run loses connection to the server, it can be restarted from the
|
|
|
278
288
|
|
|
279
289
|
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
290
|
|
|
281
|
-
```typescript
|
|
291
|
+
```typescript
|
|
282
292
|
workflow.restartAllActiveWorkflowRuns();
|
|
283
293
|
```
|
|
284
294
|
|
|
@@ -286,13 +296,11 @@ workflow.restartAllActiveWorkflowRuns();
|
|
|
286
296
|
|
|
287
297
|
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
298
|
|
|
289
|
-
```typescript
|
|
299
|
+
```typescript
|
|
290
300
|
const run = await workflow.createRun();
|
|
291
301
|
|
|
292
302
|
const result = await run.start({ inputData: { value: "initial data" } });
|
|
293
303
|
|
|
294
|
-
//.. server connection lost,
|
|
295
|
-
|
|
296
304
|
const restartedResult = await run.restart();
|
|
297
305
|
```
|
|
298
306
|
|
|
@@ -300,7 +308,7 @@ const restartedResult = await run.restart();
|
|
|
300
308
|
|
|
301
309
|
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
310
|
|
|
303
|
-
```typescript
|
|
311
|
+
```typescript
|
|
304
312
|
const activeRuns = await workflow.listActiveWorkflowRuns();
|
|
305
313
|
if (activeRuns.runs.length > 0) {
|
|
306
314
|
console.log(activeRuns.runs);
|
|
@@ -315,15 +323,14 @@ When running the local mastra server, all active workflow runs will be restarted
|
|
|
315
323
|
|
|
316
324
|
## Using `RequestContext`
|
|
317
325
|
|
|
318
|
-
Use [RequestContext](/docs/v1/server
|
|
326
|
+
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
327
|
|
|
320
|
-
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
328
|
+
```typescript title="src/mastra/workflows/test-workflow.ts"
|
|
321
329
|
export type UserTier = {
|
|
322
330
|
"user-tier": "enterprise" | "pro";
|
|
323
331
|
};
|
|
324
332
|
|
|
325
333
|
const step1 = createStep({
|
|
326
|
-
// ...
|
|
327
334
|
execute: async ({ requestContext }) => {
|
|
328
335
|
const userTier = requestContext.get("user-tier") as UserTier["user-tier"];
|
|
329
336
|
|
|
@@ -336,7 +343,11 @@ const step1 = createStep({
|
|
|
336
343
|
});
|
|
337
344
|
```
|
|
338
345
|
|
|
339
|
-
|
|
346
|
+
:::info
|
|
347
|
+
|
|
348
|
+
Visit [Request Context](/docs/v1/server/request-context) for more information.
|
|
349
|
+
|
|
350
|
+
:::
|
|
340
351
|
|
|
341
352
|
## Testing with Studio
|
|
342
353
|
|
|
@@ -84,11 +84,11 @@ Each snapshot includes the `runId`, input, step status (`success`, `suspended`,
|
|
|
84
84
|
|
|
85
85
|
## How snapshots are saved and retrieved
|
|
86
86
|
|
|
87
|
-
Snapshots are saved to the configured storage system. By default, they use
|
|
87
|
+
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
88
|
|
|
89
89
|
Read more about:
|
|
90
90
|
|
|
91
|
-
- [
|
|
91
|
+
- [libSQL Storage](/reference/v1/storage/libsql)
|
|
92
92
|
- [Upstash Storage](/reference/v1/storage/upstash)
|
|
93
93
|
- [PostgreSQL Storage](/reference/v1/storage/postgresql)
|
|
94
94
|
|
|
@@ -127,57 +127,27 @@ console.log(snapshot);
|
|
|
127
127
|
|
|
128
128
|
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
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
This example demonstrates how to use snapshots with LibSQL.
|
|
133
|
-
|
|
134
|
-
```typescript title="src/mastra/index.ts" showLineNumbers copy
|
|
130
|
+
```typescript title="src/mastra/index.ts"
|
|
135
131
|
import { Mastra } from "@mastra/core";
|
|
136
132
|
import { LibSQLStore } from "@mastra/libsql";
|
|
133
|
+
import { approvalWorkflow } from "./workflows";
|
|
137
134
|
|
|
138
135
|
export const mastra = new Mastra({
|
|
139
|
-
// ...
|
|
140
136
|
storage: new LibSQLStore({
|
|
141
137
|
id: 'mastra-storage',
|
|
142
138
|
url: ":memory:",
|
|
143
139
|
}),
|
|
140
|
+
workflows: { approvalWorkflow },
|
|
144
141
|
});
|
|
145
142
|
```
|
|
146
143
|
|
|
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
|
-
```
|
|
144
|
+
- [libSQL Storage](/reference/v1/storage/libsql)
|
|
145
|
+
- [PostgreSQL Storage](/reference/v1/storage/postgresql)
|
|
146
|
+
- [MongoDB Storage](/reference/v1/storage/mongodb)
|
|
147
|
+
- [Upstash Storage](/reference/v1/storage/upstash)
|
|
148
|
+
- [Cloudflare D1](/reference/v1/storage/cloudflare-d1)
|
|
149
|
+
- [DynamoDB](/reference/v1/storage/dynamodb)
|
|
150
|
+
- [More storage providers](/docs/v1/memory/storage)
|
|
181
151
|
|
|
182
152
|
## Best practices
|
|
183
153
|
|
|
@@ -191,7 +161,7 @@ export const mastra = new Mastra({
|
|
|
191
161
|
|
|
192
162
|
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
163
|
|
|
194
|
-
```typescript {30-34} title="src/mastra/workflows/test-workflow.ts"
|
|
164
|
+
```typescript {30-34} title="src/mastra/workflows/test-workflow.ts"
|
|
195
165
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
196
166
|
import { z } from "zod";
|
|
197
167
|
|
|
@@ -240,7 +210,7 @@ const approvalStep = createStep({
|
|
|
240
210
|
|
|
241
211
|
Use `resumeData` to pass structured input when resuming a suspended step. It must match the step’s `resumeSchema`.
|
|
242
212
|
|
|
243
|
-
```typescript {14-20}
|
|
213
|
+
```typescript {14-20}
|
|
244
214
|
const workflow = mastra.getWorkflow("approvalWorkflow");
|
|
245
215
|
|
|
246
216
|
const run = await workflow.createRun();
|
|
@@ -15,7 +15,7 @@ Use `suspend()` to pause workflow execution at a specific step. You can define a
|
|
|
15
15
|
|
|
16
16
|

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

|
|
62
62
|
|
|
63
|
-
```typescript
|
|
63
|
+
```typescript
|
|
64
64
|
import { step1 } from "./workflows/test-workflow";
|
|
65
65
|
|
|
66
66
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
@@ -82,7 +82,7 @@ const handleResume = async () => {
|
|
|
82
82
|
|
|
83
83
|
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
84
|
|
|
85
|
-
```typescript
|
|
85
|
+
```typescript
|
|
86
86
|
const result = await run.resume({
|
|
87
87
|
step: "step-1",
|
|
88
88
|
resumeData: { approved: true }
|
|
@@ -93,7 +93,7 @@ If only one step is suspended, you can omit the step argument entirely and Mastr
|
|
|
93
93
|
|
|
94
94
|
When resuming with only a `runId`, create a run instance first using `createRunAsync()`.
|
|
95
95
|
|
|
96
|
-
```typescript
|
|
96
|
+
```typescript
|
|
97
97
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
98
98
|
const run = await workflow.createRunAsync({ runId: "123" });
|
|
99
99
|
|
|
@@ -104,7 +104,7 @@ const stream = run.resume({
|
|
|
104
104
|
|
|
105
105
|
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
106
|
|
|
107
|
-
```typescript
|
|
107
|
+
```typescript
|
|
108
108
|
const midnight = new Date();
|
|
109
109
|
midnight.setUTCHours(24, 0, 0, 0);
|
|
110
110
|
|
|
@@ -119,7 +119,7 @@ setTimeout(async () => {
|
|
|
119
119
|
## Accessing suspend data with `suspendData`
|
|
120
120
|
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
121
|
|
|
122
|
-
```typescript {22-25,29-30} title="src/mastra/workflows/user-approval.ts"
|
|
122
|
+
```typescript {22-25,29-30} title="src/mastra/workflows/user-approval.ts"
|
|
123
123
|
const approvalStep = createStep({
|
|
124
124
|
id: "user-approval",
|
|
125
125
|
inputSchema: z.object({
|
|
@@ -164,7 +164,7 @@ The `suspendData` parameter is automatically populated when a step is resumed an
|
|
|
164
164
|
|
|
165
165
|
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
166
|
|
|
167
|
-
```typescript {11}
|
|
167
|
+
```typescript {11}
|
|
168
168
|
const workflow = mastra.getWorkflow("testWorkflow");
|
|
169
169
|
const run = await workflow.createRun();
|
|
170
170
|
|