@mastra/core 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +236 -0
- package/dist/agent/agent.d.ts +6 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-VJWRJWSC.cjs → chunk-2X66GWF5.cjs} +94 -16
- package/dist/chunk-2X66GWF5.cjs.map +1 -0
- package/dist/{chunk-YM6245EM.js → chunk-6OXW5E2O.js} +3 -3
- package/dist/{chunk-YM6245EM.js.map → chunk-6OXW5E2O.js.map} +1 -1
- package/dist/{chunk-XWZAKKFT.cjs → chunk-6QBN6MZY.cjs} +14 -14
- package/dist/{chunk-XWZAKKFT.cjs.map → chunk-6QBN6MZY.cjs.map} +1 -1
- package/dist/{chunk-AYHSPIT6.cjs → chunk-7UAJ6LMR.cjs} +820 -259
- package/dist/chunk-7UAJ6LMR.cjs.map +1 -0
- package/dist/{chunk-RZNHRIM7.cjs → chunk-A72NTLFT.cjs} +5 -5
- package/dist/{chunk-RZNHRIM7.cjs.map → chunk-A72NTLFT.cjs.map} +1 -1
- package/dist/{chunk-EEU5NHHU.js → chunk-DFCRXDVK.js} +3 -3
- package/dist/{chunk-EEU5NHHU.js.map → chunk-DFCRXDVK.js.map} +1 -1
- package/dist/{chunk-5K45E5VE.js → chunk-GPJGPARM.js} +3 -2
- package/dist/chunk-GPJGPARM.js.map +1 -0
- package/dist/{chunk-LNKS4TJ6.cjs → chunk-HB6T4554.cjs} +8 -7
- package/dist/chunk-HB6T4554.cjs.map +1 -0
- package/dist/{chunk-DGS2KGDI.js → chunk-KUXNBWN7.js} +6 -5
- package/dist/chunk-KUXNBWN7.js.map +1 -0
- package/dist/{chunk-IHDE4CJV.js → chunk-QSHV7GPT.js} +89 -12
- package/dist/chunk-QSHV7GPT.js.map +1 -0
- package/dist/{chunk-3U3XFMGJ.cjs → chunk-QTAS3HND.cjs} +13 -8
- package/dist/chunk-QTAS3HND.cjs.map +1 -0
- package/dist/{chunk-RHKNKJNM.js → chunk-QWTB53GS.js} +4 -4
- package/dist/{chunk-RHKNKJNM.js.map → chunk-QWTB53GS.js.map} +1 -1
- package/dist/{chunk-4WG5K4CK.js → chunk-R4N65TLG.js} +7 -7
- package/dist/{chunk-4WG5K4CK.js.map → chunk-R4N65TLG.js.map} +1 -1
- package/dist/{chunk-5VQPSWPG.cjs → chunk-RABITNTG.cjs} +48 -48
- package/dist/{chunk-5VQPSWPG.cjs.map → chunk-RABITNTG.cjs.map} +1 -1
- package/dist/{chunk-TVPANHLE.cjs → chunk-SBOHDNIZ.cjs} +3 -2
- package/dist/chunk-SBOHDNIZ.cjs.map +1 -0
- package/dist/{chunk-MWGGSA5Q.js → chunk-T6GAM3SQ.js} +10 -5
- package/dist/chunk-T6GAM3SQ.js.map +1 -0
- package/dist/{chunk-TL2TTA4X.cjs → chunk-YQG7NBPR.cjs} +9 -9
- package/dist/{chunk-TL2TTA4X.cjs.map → chunk-YQG7NBPR.cjs.map} +1 -1
- package/dist/{chunk-XB3DA67Q.js → chunk-ZSBM2SVU.js} +818 -259
- package/dist/chunk-ZSBM2SVU.js.map +1 -0
- package/dist/datasets/experiment/scorer.d.ts.map +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +7 -6
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +4 -3
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/harness/harness.d.ts +21 -1
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/index.cjs +422 -5
- package/dist/harness/index.cjs.map +1 -1
- package/dist/harness/index.d.ts +2 -1
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +418 -3
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/types.d.ts +151 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +45 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/index.d.ts +1 -0
- package/dist/processors/processors/index.d.ts.map +1 -1
- package/dist/processors/processors/workspace-instructions.d.ts +50 -0
- package/dist/processors/processors/workspace-instructions.d.ts.map +1 -0
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +56 -56
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/index.cjs +160 -160
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workspace/constants/index.d.ts +2 -0
- package/dist/workspace/constants/index.d.ts.map +1 -1
- package/dist/workspace/errors.d.ts +1 -1
- package/dist/workspace/errors.d.ts.map +1 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts +4 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/file-write-lock.d.ts +35 -0
- package/dist/workspace/filesystem/file-write-lock.d.ts.map +1 -0
- package/dist/workspace/filesystem/filesystem.d.ts +5 -1
- package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/index.d.ts +1 -0
- package/dist/workspace/filesystem/index.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +17 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/index.cjs +72 -64
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/lifecycle.d.ts +1 -9
- package/dist/workspace/lifecycle.d.ts.map +1 -1
- package/dist/workspace/sandbox/index.d.ts +2 -0
- package/dist/workspace/sandbox/index.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-process-manager.d.ts +18 -0
- package/dist/workspace/sandbox/local-process-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/local-sandbox.d.ts +49 -35
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +45 -11
- package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/bubblewrap.d.ts +2 -3
- package/dist/workspace/sandbox/native-sandbox/bubblewrap.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/seatbelt.d.ts +2 -3
- package/dist/workspace/sandbox/native-sandbox/seatbelt.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/wrapper.d.ts +4 -5
- package/dist/workspace/sandbox/native-sandbox/wrapper.d.ts.map +1 -1
- package/dist/workspace/sandbox/process-manager/index.d.ts +4 -0
- package/dist/workspace/sandbox/process-manager/index.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/process-handle.d.ts +107 -0
- package/dist/workspace/sandbox/process-manager/process-handle.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/process-manager.d.ts +59 -0
- package/dist/workspace/sandbox/process-manager/process-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/types.d.ts +24 -0
- package/dist/workspace/sandbox/process-manager/types.d.ts.map +1 -0
- package/dist/workspace/sandbox/sandbox.d.ts +38 -2
- package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/types.d.ts +9 -2
- package/dist/workspace/sandbox/types.d.ts.map +1 -1
- package/dist/workspace/sandbox/utils.d.ts +7 -0
- package/dist/workspace/sandbox/utils.d.ts.map +1 -0
- package/dist/workspace/tools/execute-command.d.ts +53 -2
- package/dist/workspace/tools/execute-command.d.ts.map +1 -1
- package/dist/workspace/tools/get-process-output.d.ts +6 -0
- package/dist/workspace/tools/get-process-output.d.ts.map +1 -0
- package/dist/workspace/tools/index.d.ts +4 -1
- package/dist/workspace/tools/index.d.ts.map +1 -1
- package/dist/workspace/tools/kill-process.d.ts +4 -0
- package/dist/workspace/tools/kill-process.d.ts.map +1 -0
- package/dist/workspace/tools/output-helpers.d.ts +21 -0
- package/dist/workspace/tools/output-helpers.d.ts.map +1 -0
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/dist/workspace/types.d.ts +31 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/utils.d.ts +11 -0
- package/dist/workspace/utils.d.ts.map +1 -0
- package/dist/workspace/workspace.d.ts +36 -0
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-3U3XFMGJ.cjs.map +0 -1
- package/dist/chunk-5K45E5VE.js.map +0 -1
- package/dist/chunk-AYHSPIT6.cjs.map +0 -1
- package/dist/chunk-DGS2KGDI.js.map +0 -1
- package/dist/chunk-IHDE4CJV.js.map +0 -1
- package/dist/chunk-LNKS4TJ6.cjs.map +0 -1
- package/dist/chunk-MWGGSA5Q.js.map +0 -1
- package/dist/chunk-TVPANHLE.cjs.map +0 -1
- package/dist/chunk-VJWRJWSC.cjs.map +0 -1
- package/dist/chunk-XB3DA67Q.js.map +0 -1
- package/dist/docs/SKILL.md +0 -301
- package/dist/docs/assets/SOURCE_MAP.json +0 -1413
- package/dist/docs/references/docs-agents-adding-voice.md +0 -353
- package/dist/docs/references/docs-agents-agent-approval.md +0 -377
- package/dist/docs/references/docs-agents-agent-memory.md +0 -212
- package/dist/docs/references/docs-agents-guardrails.md +0 -382
- package/dist/docs/references/docs-agents-network-approval.md +0 -275
- package/dist/docs/references/docs-agents-networks.md +0 -290
- package/dist/docs/references/docs-agents-overview.md +0 -309
- package/dist/docs/references/docs-agents-processors.md +0 -632
- package/dist/docs/references/docs-agents-structured-output.md +0 -271
- package/dist/docs/references/docs-agents-using-tools.md +0 -214
- package/dist/docs/references/docs-evals-custom-scorers.md +0 -519
- package/dist/docs/references/docs-evals-overview.md +0 -146
- package/dist/docs/references/docs-evals-running-in-ci.md +0 -106
- package/dist/docs/references/docs-mcp-overview.md +0 -370
- package/dist/docs/references/docs-mcp-publishing-mcp-server.md +0 -95
- package/dist/docs/references/docs-memory-memory-processors.md +0 -316
- package/dist/docs/references/docs-memory-observational-memory.md +0 -246
- package/dist/docs/references/docs-memory-overview.md +0 -45
- package/dist/docs/references/docs-memory-semantic-recall.md +0 -272
- package/dist/docs/references/docs-memory-storage.md +0 -261
- package/dist/docs/references/docs-memory-working-memory.md +0 -400
- package/dist/docs/references/docs-observability-datasets-overview.md +0 -188
- package/dist/docs/references/docs-observability-datasets-running-experiments.md +0 -266
- package/dist/docs/references/docs-observability-logging.md +0 -99
- package/dist/docs/references/docs-observability-overview.md +0 -70
- package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
- package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -274
- package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -111
- package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -129
- package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -187
- package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -211
- package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
- package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -217
- package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -202
- package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -479
- package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
- package/dist/docs/references/docs-observability-tracing-overview.md +0 -1114
- package/dist/docs/references/docs-rag-chunking-and-embedding.md +0 -183
- package/dist/docs/references/docs-rag-graph-rag.md +0 -215
- package/dist/docs/references/docs-rag-overview.md +0 -72
- package/dist/docs/references/docs-rag-retrieval.md +0 -521
- package/dist/docs/references/docs-rag-vector-databases.md +0 -648
- package/dist/docs/references/docs-server-auth-auth0.md +0 -222
- package/dist/docs/references/docs-server-auth-clerk.md +0 -132
- package/dist/docs/references/docs-server-auth-composite-auth.md +0 -234
- package/dist/docs/references/docs-server-auth-custom-auth-provider.md +0 -513
- package/dist/docs/references/docs-server-auth-firebase.md +0 -272
- package/dist/docs/references/docs-server-auth-jwt.md +0 -110
- package/dist/docs/references/docs-server-auth-simple-auth.md +0 -178
- package/dist/docs/references/docs-server-auth-supabase.md +0 -117
- package/dist/docs/references/docs-server-auth-workos.md +0 -190
- package/dist/docs/references/docs-server-custom-adapters.md +0 -374
- package/dist/docs/references/docs-server-custom-api-routes.md +0 -267
- package/dist/docs/references/docs-server-mastra-client.md +0 -243
- package/dist/docs/references/docs-server-mastra-server.md +0 -71
- package/dist/docs/references/docs-server-middleware.md +0 -228
- package/dist/docs/references/docs-server-request-context.md +0 -478
- package/dist/docs/references/docs-streaming-events.md +0 -247
- package/dist/docs/references/docs-streaming-tool-streaming.md +0 -178
- package/dist/docs/references/docs-streaming-workflow-streaming.md +0 -109
- package/dist/docs/references/docs-voice-overview.md +0 -979
- package/dist/docs/references/docs-voice-speech-to-speech.md +0 -103
- package/dist/docs/references/docs-voice-speech-to-text.md +0 -80
- package/dist/docs/references/docs-voice-text-to-speech.md +0 -84
- package/dist/docs/references/docs-workflows-agents-and-tools.md +0 -170
- package/dist/docs/references/docs-workflows-control-flow.md +0 -823
- package/dist/docs/references/docs-workflows-error-handling.md +0 -360
- package/dist/docs/references/docs-workflows-human-in-the-loop.md +0 -213
- package/dist/docs/references/docs-workflows-overview.md +0 -372
- package/dist/docs/references/docs-workflows-snapshots.md +0 -238
- package/dist/docs/references/docs-workflows-suspend-and-resume.md +0 -205
- package/dist/docs/references/docs-workflows-time-travel.md +0 -309
- package/dist/docs/references/docs-workflows-workflow-state.md +0 -181
- package/dist/docs/references/docs-workspace-filesystem.md +0 -162
- package/dist/docs/references/docs-workspace-overview.md +0 -239
- package/dist/docs/references/docs-workspace-sandbox.md +0 -63
- package/dist/docs/references/docs-workspace-search.md +0 -219
- package/dist/docs/references/docs-workspace-skills.md +0 -126
- package/dist/docs/references/guides-agent-frameworks-ai-sdk.md +0 -140
- package/dist/docs/references/reference-agents-agent.md +0 -142
- package/dist/docs/references/reference-agents-generate.md +0 -174
- package/dist/docs/references/reference-agents-generateLegacy.md +0 -176
- package/dist/docs/references/reference-agents-getDefaultGenerateOptions.md +0 -36
- package/dist/docs/references/reference-agents-getDefaultOptions.md +0 -34
- package/dist/docs/references/reference-agents-getDefaultStreamOptions.md +0 -36
- package/dist/docs/references/reference-agents-getDescription.md +0 -21
- package/dist/docs/references/reference-agents-getInstructions.md +0 -34
- package/dist/docs/references/reference-agents-getLLM.md +0 -37
- package/dist/docs/references/reference-agents-getMemory.md +0 -34
- package/dist/docs/references/reference-agents-getModel.md +0 -34
- package/dist/docs/references/reference-agents-getTools.md +0 -29
- package/dist/docs/references/reference-agents-getVoice.md +0 -34
- package/dist/docs/references/reference-agents-listAgents.md +0 -35
- package/dist/docs/references/reference-agents-listScorers.md +0 -34
- package/dist/docs/references/reference-agents-listTools.md +0 -34
- package/dist/docs/references/reference-agents-listWorkflows.md +0 -34
- package/dist/docs/references/reference-agents-network.md +0 -134
- package/dist/docs/references/reference-ai-sdk-chat-route.md +0 -82
- package/dist/docs/references/reference-ai-sdk-network-route.md +0 -74
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +0 -232
- package/dist/docs/references/reference-ai-sdk-with-mastra.md +0 -59
- package/dist/docs/references/reference-ai-sdk-workflow-route.md +0 -79
- package/dist/docs/references/reference-auth-auth0.md +0 -73
- package/dist/docs/references/reference-auth-clerk.md +0 -36
- package/dist/docs/references/reference-auth-firebase.md +0 -80
- package/dist/docs/references/reference-auth-jwt.md +0 -26
- package/dist/docs/references/reference-auth-supabase.md +0 -33
- package/dist/docs/references/reference-auth-workos.md +0 -84
- package/dist/docs/references/reference-client-js-agents.md +0 -438
- package/dist/docs/references/reference-configuration.md +0 -749
- package/dist/docs/references/reference-core-addGateway.md +0 -42
- package/dist/docs/references/reference-core-getAgent.md +0 -21
- package/dist/docs/references/reference-core-getAgentById.md +0 -21
- package/dist/docs/references/reference-core-getDeployer.md +0 -22
- package/dist/docs/references/reference-core-getGateway.md +0 -38
- package/dist/docs/references/reference-core-getGatewayById.md +0 -41
- package/dist/docs/references/reference-core-getLogger.md +0 -22
- package/dist/docs/references/reference-core-getMCPServer.md +0 -45
- package/dist/docs/references/reference-core-getMCPServerById.md +0 -53
- package/dist/docs/references/reference-core-getMemory.md +0 -50
- package/dist/docs/references/reference-core-getScorer.md +0 -54
- package/dist/docs/references/reference-core-getScorerById.md +0 -54
- package/dist/docs/references/reference-core-getServer.md +0 -22
- package/dist/docs/references/reference-core-getStorage.md +0 -22
- package/dist/docs/references/reference-core-getStoredAgentById.md +0 -89
- package/dist/docs/references/reference-core-getTelemetry.md +0 -22
- package/dist/docs/references/reference-core-getVector.md +0 -22
- package/dist/docs/references/reference-core-getWorkflow.md +0 -40
- package/dist/docs/references/reference-core-listAgents.md +0 -21
- package/dist/docs/references/reference-core-listGateways.md +0 -40
- package/dist/docs/references/reference-core-listLogs.md +0 -38
- package/dist/docs/references/reference-core-listLogsByRunId.md +0 -36
- package/dist/docs/references/reference-core-listMCPServers.md +0 -51
- package/dist/docs/references/reference-core-listMemory.md +0 -56
- package/dist/docs/references/reference-core-listScorers.md +0 -29
- package/dist/docs/references/reference-core-listStoredAgents.md +0 -93
- package/dist/docs/references/reference-core-listVectors.md +0 -22
- package/dist/docs/references/reference-core-listWorkflows.md +0 -21
- package/dist/docs/references/reference-core-mastra-class.md +0 -66
- package/dist/docs/references/reference-core-mastra-model-gateway.md +0 -153
- package/dist/docs/references/reference-core-setLogger.md +0 -26
- package/dist/docs/references/reference-core-setStorage.md +0 -27
- package/dist/docs/references/reference-datasets-addItem.md +0 -35
- package/dist/docs/references/reference-datasets-addItems.md +0 -33
- package/dist/docs/references/reference-datasets-compareExperiments.md +0 -48
- package/dist/docs/references/reference-datasets-create.md +0 -49
- package/dist/docs/references/reference-datasets-dataset.md +0 -78
- package/dist/docs/references/reference-datasets-datasets-manager.md +0 -84
- package/dist/docs/references/reference-datasets-delete.md +0 -23
- package/dist/docs/references/reference-datasets-deleteExperiment.md +0 -25
- package/dist/docs/references/reference-datasets-deleteItem.md +0 -25
- package/dist/docs/references/reference-datasets-deleteItems.md +0 -27
- package/dist/docs/references/reference-datasets-get.md +0 -29
- package/dist/docs/references/reference-datasets-getDetails.md +0 -45
- package/dist/docs/references/reference-datasets-getExperiment.md +0 -28
- package/dist/docs/references/reference-datasets-getItem.md +0 -31
- package/dist/docs/references/reference-datasets-getItemHistory.md +0 -29
- package/dist/docs/references/reference-datasets-list.md +0 -29
- package/dist/docs/references/reference-datasets-listExperimentResults.md +0 -37
- package/dist/docs/references/reference-datasets-listExperiments.md +0 -31
- package/dist/docs/references/reference-datasets-listItems.md +0 -44
- package/dist/docs/references/reference-datasets-listVersions.md +0 -31
- package/dist/docs/references/reference-datasets-startExperiment.md +0 -60
- package/dist/docs/references/reference-datasets-startExperimentAsync.md +0 -41
- package/dist/docs/references/reference-datasets-update.md +0 -46
- package/dist/docs/references/reference-datasets-updateItem.md +0 -36
- package/dist/docs/references/reference-evals-answer-relevancy.md +0 -105
- package/dist/docs/references/reference-evals-answer-similarity.md +0 -99
- package/dist/docs/references/reference-evals-bias.md +0 -120
- package/dist/docs/references/reference-evals-completeness.md +0 -137
- package/dist/docs/references/reference-evals-content-similarity.md +0 -101
- package/dist/docs/references/reference-evals-context-precision.md +0 -196
- package/dist/docs/references/reference-evals-create-scorer.md +0 -270
- package/dist/docs/references/reference-evals-faithfulness.md +0 -114
- package/dist/docs/references/reference-evals-hallucination.md +0 -220
- package/dist/docs/references/reference-evals-keyword-coverage.md +0 -128
- package/dist/docs/references/reference-evals-mastra-scorer.md +0 -123
- package/dist/docs/references/reference-evals-run-evals.md +0 -138
- package/dist/docs/references/reference-evals-scorer-utils.md +0 -330
- package/dist/docs/references/reference-evals-textual-difference.md +0 -113
- package/dist/docs/references/reference-evals-tone-consistency.md +0 -119
- package/dist/docs/references/reference-evals-toxicity.md +0 -123
- package/dist/docs/references/reference-harness-harness-class.md +0 -645
- package/dist/docs/references/reference-logging-pino-logger.md +0 -117
- package/dist/docs/references/reference-memory-deleteMessages.md +0 -40
- package/dist/docs/references/reference-memory-memory-class.md +0 -147
- package/dist/docs/references/reference-memory-observational-memory.md +0 -565
- package/dist/docs/references/reference-observability-tracing-bridges-otel.md +0 -131
- package/dist/docs/references/reference-observability-tracing-configuration.md +0 -178
- package/dist/docs/references/reference-observability-tracing-exporters-console-exporter.md +0 -138
- package/dist/docs/references/reference-observability-tracing-exporters-datadog.md +0 -116
- package/dist/docs/references/reference-observability-tracing-instances.md +0 -109
- package/dist/docs/references/reference-observability-tracing-interfaces.md +0 -749
- package/dist/docs/references/reference-observability-tracing-processors-sensitive-data-filter.md +0 -144
- package/dist/docs/references/reference-observability-tracing-spans.md +0 -224
- package/dist/docs/references/reference-processors-batch-parts-processor.md +0 -61
- package/dist/docs/references/reference-processors-language-detector.md +0 -81
- package/dist/docs/references/reference-processors-message-history-processor.md +0 -85
- package/dist/docs/references/reference-processors-moderation-processor.md +0 -104
- package/dist/docs/references/reference-processors-pii-detector.md +0 -107
- package/dist/docs/references/reference-processors-processor-interface.md +0 -525
- package/dist/docs/references/reference-processors-prompt-injection-detector.md +0 -71
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +0 -123
- package/dist/docs/references/reference-processors-system-prompt-scrubber.md +0 -80
- package/dist/docs/references/reference-processors-token-limiter-processor.md +0 -113
- package/dist/docs/references/reference-processors-tool-call-filter.md +0 -85
- package/dist/docs/references/reference-processors-tool-search-processor.md +0 -113
- package/dist/docs/references/reference-processors-unicode-normalizer.md +0 -62
- package/dist/docs/references/reference-processors-working-memory-processor.md +0 -154
- package/dist/docs/references/reference-rag-database-config.md +0 -264
- package/dist/docs/references/reference-rag-embeddings.md +0 -92
- package/dist/docs/references/reference-server-mastra-server.md +0 -298
- package/dist/docs/references/reference-server-register-api-route.md +0 -249
- package/dist/docs/references/reference-storage-cloudflare-d1.md +0 -218
- package/dist/docs/references/reference-storage-composite.md +0 -235
- package/dist/docs/references/reference-storage-lance.md +0 -131
- package/dist/docs/references/reference-storage-libsql.md +0 -135
- package/dist/docs/references/reference-storage-mongodb.md +0 -262
- package/dist/docs/references/reference-storage-mssql.md +0 -155
- package/dist/docs/references/reference-storage-overview.md +0 -121
- package/dist/docs/references/reference-storage-postgresql.md +0 -529
- package/dist/docs/references/reference-storage-upstash.md +0 -160
- package/dist/docs/references/reference-streaming-ChunkType.md +0 -292
- package/dist/docs/references/reference-streaming-agents-MastraModelOutput.md +0 -182
- package/dist/docs/references/reference-streaming-agents-streamLegacy.md +0 -142
- package/dist/docs/references/reference-streaming-workflows-observeStream.md +0 -42
- package/dist/docs/references/reference-streaming-workflows-resumeStream.md +0 -61
- package/dist/docs/references/reference-streaming-workflows-stream.md +0 -88
- package/dist/docs/references/reference-streaming-workflows-timeTravelStream.md +0 -142
- package/dist/docs/references/reference-templates-overview.md +0 -194
- package/dist/docs/references/reference-tools-create-tool.md +0 -237
- package/dist/docs/references/reference-tools-graph-rag-tool.md +0 -185
- package/dist/docs/references/reference-tools-mcp-client.md +0 -962
- package/dist/docs/references/reference-tools-mcp-server.md +0 -1275
- package/dist/docs/references/reference-tools-vector-query-tool.md +0 -459
- package/dist/docs/references/reference-vectors-libsql.md +0 -305
- package/dist/docs/references/reference-vectors-mongodb.md +0 -295
- package/dist/docs/references/reference-vectors-pg.md +0 -408
- package/dist/docs/references/reference-vectors-upstash.md +0 -294
- package/dist/docs/references/reference-voice-composite-voice.md +0 -121
- package/dist/docs/references/reference-voice-mastra-voice.md +0 -313
- package/dist/docs/references/reference-voice-voice.addInstructions.md +0 -56
- package/dist/docs/references/reference-voice-voice.addTools.md +0 -67
- package/dist/docs/references/reference-voice-voice.connect.md +0 -94
- package/dist/docs/references/reference-voice-voice.events.md +0 -37
- package/dist/docs/references/reference-voice-voice.listen.md +0 -164
- package/dist/docs/references/reference-voice-voice.on.md +0 -111
- package/dist/docs/references/reference-voice-voice.speak.md +0 -157
- package/dist/docs/references/reference-workflows-run-methods-cancel.md +0 -86
- package/dist/docs/references/reference-workflows-run-methods-restart.md +0 -33
- package/dist/docs/references/reference-workflows-run-methods-resume.md +0 -59
- package/dist/docs/references/reference-workflows-run-methods-start.md +0 -58
- package/dist/docs/references/reference-workflows-run-methods-startAsync.md +0 -67
- package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +0 -142
- package/dist/docs/references/reference-workflows-run.md +0 -59
- package/dist/docs/references/reference-workflows-step.md +0 -119
- package/dist/docs/references/reference-workflows-workflow-methods-branch.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-commit.md +0 -17
- package/dist/docs/references/reference-workflows-workflow-methods-create-run.md +0 -63
- package/dist/docs/references/reference-workflows-workflow-methods-dountil.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-dowhile.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-foreach.md +0 -118
- package/dist/docs/references/reference-workflows-workflow-methods-map.md +0 -93
- package/dist/docs/references/reference-workflows-workflow-methods-parallel.md +0 -21
- package/dist/docs/references/reference-workflows-workflow-methods-sleep.md +0 -35
- package/dist/docs/references/reference-workflows-workflow-methods-sleepUntil.md +0 -35
- package/dist/docs/references/reference-workflows-workflow-methods-then.md +0 -21
- package/dist/docs/references/reference-workflows-workflow.md +0 -157
- package/dist/docs/references/reference-workspace-filesystem.md +0 -202
- package/dist/docs/references/reference-workspace-local-filesystem.md +0 -327
- package/dist/docs/references/reference-workspace-local-sandbox.md +0 -285
- package/dist/docs/references/reference-workspace-sandbox.md +0 -81
- package/dist/docs/references/reference-workspace-workspace-class.md +0 -226
- package/dist/docs/references/reference.md +0 -276
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Run.startAsync()
|
|
2
|
-
|
|
3
|
-
The `.startAsync()` method starts a workflow run without waiting for completion. It returns immediately with the `runId`, allowing the workflow to execute in the background. This is useful for long-running workflows, scheduled tasks, or when you want to avoid blocking on workflow completion.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
const run = await workflow.createRun();
|
|
9
|
-
|
|
10
|
-
// Fire-and-forget - returns immediately
|
|
11
|
-
const { runId } = await run.startAsync({
|
|
12
|
-
inputData: {
|
|
13
|
-
value: "initial data",
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Optionally poll for completion later
|
|
18
|
-
const result = await workflow.getWorkflowRunExecutionResult(runId);
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Parameters
|
|
22
|
-
|
|
23
|
-
**inputData?:** (`z.infer<TInput>`): Input data that matches the workflow's input schema
|
|
24
|
-
|
|
25
|
-
**requestContext?:** (`RequestContext`): Request Context data to use during workflow execution
|
|
26
|
-
|
|
27
|
-
**initialState?:** (`z.infer<TState>`): Initial state to use for the workflow execution
|
|
28
|
-
|
|
29
|
-
**tracingOptions?:** (`TracingOptions`): metadata?:Record\<string, any>Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.traceId?:stringTrace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.
|
|
30
|
-
|
|
31
|
-
**outputOptions?:** (`OutputOptions`): includeState?:booleanWhether to include the workflow run state in the result.
|
|
32
|
-
|
|
33
|
-
## Returns
|
|
34
|
-
|
|
35
|
-
**runId:** (`string`): The unique identifier for this workflow run. Use this to check status or retrieve results later.
|
|
36
|
-
|
|
37
|
-
## When to use startAsync()
|
|
38
|
-
|
|
39
|
-
Use `startAsync()` instead of `start()` when:
|
|
40
|
-
|
|
41
|
-
- **Long-running workflows**: The workflow may take minutes or hours to complete
|
|
42
|
-
- **Scheduled/cron triggers**: You want to trigger a workflow without blocking the scheduler
|
|
43
|
-
- **Avoiding polling failures**: With Inngest workflows, `start()` polls for completion which can fail and cause retries. `startAsync()` avoids this issue
|
|
44
|
-
- **Background processing**: You want to queue work and handle results asynchronously
|
|
45
|
-
|
|
46
|
-
## Checking workflow status
|
|
47
|
-
|
|
48
|
-
After calling `startAsync()`, you can check the workflow status using:
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
// Get the execution result (including step outputs)
|
|
52
|
-
const result = await workflow.getWorkflowRunExecutionResult(runId);
|
|
53
|
-
|
|
54
|
-
if (result?.status === 'success') {
|
|
55
|
-
console.log('Workflow completed:', result.steps);
|
|
56
|
-
} else if (result?.status === 'failed') {
|
|
57
|
-
console.log('Workflow failed:', result.error);
|
|
58
|
-
} else if (result?.status === 'running') {
|
|
59
|
-
console.log('Workflow still running...');
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Related
|
|
64
|
-
|
|
65
|
-
- [Run.start()](https://mastra.ai/reference/workflows/run-methods/start) - Start a workflow and wait for completion
|
|
66
|
-
- [Workflows overview](https://mastra.ai/docs/workflows/overview)
|
|
67
|
-
- [Workflow.createRun()](https://mastra.ai/reference/workflows/workflow-methods/create-run)
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# Run.timeTravel()
|
|
2
|
-
|
|
3
|
-
The `.timeTravel()` method re-executes a workflow starting from any specific step, using either stored snapshot data or custom context you provide. This is useful for debugging failed workflows, testing individual steps with different inputs, or recovering from errors without re-running the entire workflow.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
const run = await workflow.createRun();
|
|
9
|
-
|
|
10
|
-
const result = await run.timeTravel({
|
|
11
|
-
step: "step2",
|
|
12
|
-
inputData: { value: 10 },
|
|
13
|
-
});
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Parameters
|
|
17
|
-
|
|
18
|
-
**step:** (`Step<string, any, TInputSchema, any, any, any, TEngineType> | [...Step<string, any, any, any, any, any, TEngineType>[], Step<string, any, TInputSchema, any, any, any, TEngineType>] | string | string[]`): The target step to start execution from. It can be a Step instance, array of Steps (for nested workflows), step ID string, or array of step ID strings. Use dot notation or arrays for nested workflow steps (e.g., 'nestedWorkflow\.step3' or \['nestedWorkflow', 'step3'])
|
|
19
|
-
|
|
20
|
-
**inputData?:** (`z.infer<TInputSchema>`): Input data for the target step. Must match the step's input schema. If not provided, uses data from the workflow snapshot
|
|
21
|
-
|
|
22
|
-
**resumeData?:** (`any`): Resume data to provide if the workflow was previously suspended
|
|
23
|
-
|
|
24
|
-
**initialState?:** (`z.infer<TState>`): Initial state to set for the workflow run. Used to set workflow-level state before execution
|
|
25
|
-
|
|
26
|
-
**context?:** (`TimeTravelContext<any, any, any, any>`): Execution context containing step results for steps before the target step. Each key is a step ID with a StepResult object containing status, payload, output, startedAt, endedAt, suspendPayload, and resumePayload
|
|
27
|
-
|
|
28
|
-
**nestedStepsContext?:** (`Record<string, TimeTravelContext<any, any, any, any>>`): Context for nested workflow steps. Keyed by nested workflow ID, each containing step results for that nested workflow
|
|
29
|
-
|
|
30
|
-
**requestContext?:** (`RequestContext`): Request Context data to use during time travel execution
|
|
31
|
-
|
|
32
|
-
**outputWriter?:** (`(chunk: TOutput) => Promise<void>`): Optional asynchronous function to handle output chunks as they are produced
|
|
33
|
-
|
|
34
|
-
**tracingContext?:** (`TracingContext`): currentSpan?:SpanCurrent span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.
|
|
35
|
-
|
|
36
|
-
**tracingOptions?:** (`TracingOptions`): metadata?:Record\<string, any>Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.requestContextKeys?:string\[]Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').traceId?:stringTrace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.parentSpanId?:stringParent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.tags?:string\[]Tags to apply to this trace. String labels for categorizing and filtering traces.
|
|
37
|
-
|
|
38
|
-
**outputOptions?:** (`OutputOptions`): includeState?:booleanWhether to include the workflow run state in the result.includeResumeLabels?:booleanWhether to include resume labels in the result.
|
|
39
|
-
|
|
40
|
-
## Returns
|
|
41
|
-
|
|
42
|
-
**result:** (`Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>`): A promise that resolves to the workflow execution result containing step outputs and status
|
|
43
|
-
|
|
44
|
-
**traceId?:** (`string`): The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.
|
|
45
|
-
|
|
46
|
-
## Extended usage examples
|
|
47
|
-
|
|
48
|
-
### Time travel with custom context
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
const result = await run.timeTravel({
|
|
52
|
-
step: "step2",
|
|
53
|
-
context: {
|
|
54
|
-
step1: {
|
|
55
|
-
status: "success",
|
|
56
|
-
payload: { value: 0 },
|
|
57
|
-
output: { step1Result: 2 },
|
|
58
|
-
startedAt: Date.now(),
|
|
59
|
-
endedAt: Date.now(),
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Time travel to nested workflow step
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
// Using dot notation
|
|
69
|
-
const result = await run.timeTravel({
|
|
70
|
-
step: "nestedWorkflow.step3",
|
|
71
|
-
inputData: { value: 10 },
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Using array of step IDs
|
|
75
|
-
const result = await run.timeTravel({
|
|
76
|
-
step: ["nestedWorkflow", "step3"],
|
|
77
|
-
inputData: { value: 10 },
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Time travel with initial state
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
const result = await run.timeTravel({
|
|
85
|
-
step: "step2",
|
|
86
|
-
inputData: { value: 10 },
|
|
87
|
-
initialState: {
|
|
88
|
-
counter: 5,
|
|
89
|
-
metadata: { source: "time-travel" },
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Time travel with nested workflows context
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
const result = await run.timeTravel({
|
|
98
|
-
step: "nestedWorkflow.step3",
|
|
99
|
-
context: {
|
|
100
|
-
step1: {
|
|
101
|
-
status: "success",
|
|
102
|
-
payload: { value: 0 },
|
|
103
|
-
output: { step1Result: 2 },
|
|
104
|
-
startedAt: Date.now(),
|
|
105
|
-
endedAt: Date.now(),
|
|
106
|
-
},
|
|
107
|
-
nestedWorkflow: {
|
|
108
|
-
status: "running",
|
|
109
|
-
payload: { step1Result: 2 },
|
|
110
|
-
startedAt: Date.now(),
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
nestedStepsContext: {
|
|
114
|
-
nestedWorkflow: {
|
|
115
|
-
step2: {
|
|
116
|
-
status: "success",
|
|
117
|
-
payload: { step1Result: 2 },
|
|
118
|
-
output: { step2Result: 3 },
|
|
119
|
-
startedAt: Date.now(),
|
|
120
|
-
endedAt: Date.now(),
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Notes
|
|
128
|
-
|
|
129
|
-
- Time travel requires storage to be configured since it relies on persisted workflow snapshots
|
|
130
|
-
- When re-executing a workflow, the workflow loads the existing snapshot from storage (if available)
|
|
131
|
-
- Step results before the target step are reconstructed from the snapshot or provided context
|
|
132
|
-
- Execution begins from the specified step with the provided or reconstructed input data
|
|
133
|
-
- The workflow continues to completion from that point forward
|
|
134
|
-
- Time travel can be used on workflows that have not been run yet by providing custom context or input data for the step to start from.
|
|
135
|
-
|
|
136
|
-
## Related
|
|
137
|
-
|
|
138
|
-
- [Time Travel](https://mastra.ai/docs/workflows/time-travel)
|
|
139
|
-
- [Workflows overview](https://mastra.ai/docs/workflows/overview)
|
|
140
|
-
- [Workflow.createRun()](https://mastra.ai/reference/workflows/workflow-methods/create-run)
|
|
141
|
-
- [Snapshots](https://mastra.ai/docs/workflows/snapshots)
|
|
142
|
-
- [Suspend & Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Run Class
|
|
2
|
-
|
|
3
|
-
The `Run` class represents a workflow execution instance, providing methods to start, resume, stream, and monitor workflow execution.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
const run = await workflow.createRun();
|
|
9
|
-
|
|
10
|
-
const result = await run.start({
|
|
11
|
-
inputData: { value: "initial data" },
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
if (result.status === "suspended") {
|
|
15
|
-
const resumedResult = await run.resume({
|
|
16
|
-
resumeData: { value: "resume data" },
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Run Methods
|
|
22
|
-
|
|
23
|
-
**start:** (`(options?: StartOptions) => Promise<WorkflowResult>`): Starts workflow execution with input data
|
|
24
|
-
|
|
25
|
-
**resume:** (`(options?: ResumeOptions) => Promise<WorkflowResult>`): Resumes a suspended workflow from a specific step
|
|
26
|
-
|
|
27
|
-
**stream:** (`(options?: StreamOptions) => MastraWorkflowStream`): Monitors workflow execution as a stream of events with enhanced streaming features
|
|
28
|
-
|
|
29
|
-
**resumeStream:** (`(options?: ResumeStreamOptions) => MastraWorkflowStream`): Resumes a suspended workflow with streaming support
|
|
30
|
-
|
|
31
|
-
**cancel:** (`() => Promise<{ message: string }>`): Cancels the workflow execution, stopping any running steps and preventing subsequent steps from executing
|
|
32
|
-
|
|
33
|
-
**restart:** (`(options?: RestartOptions) => Promise<WorkflowResult>`): Restarts the workflow execution from last active step
|
|
34
|
-
|
|
35
|
-
**timeTravel:** (`(options?: TimeTravelOptions) => Promise<WorkflowResult>`): Re-executes a workflow starting from any specific step, using either stored snapshot data or custom context you provide.
|
|
36
|
-
|
|
37
|
-
**timeTravelStream:** (`(options?: TimeTravelOptions) => MastraWorkflowStream`): Time travels a workflow execution with streaming support
|
|
38
|
-
|
|
39
|
-
## Run Status
|
|
40
|
-
|
|
41
|
-
A workflow run's `status` indicates its current execution state. The possible values are:
|
|
42
|
-
|
|
43
|
-
**success:** (`string`): All steps finished executing successfully, with a valid result output
|
|
44
|
-
|
|
45
|
-
**failed:** (`string`): Workflow execution encountered an error during execution, with error details available
|
|
46
|
-
|
|
47
|
-
**suspended:** (`string`): Workflow execution is paused waiting for resume, with suspended step information
|
|
48
|
-
|
|
49
|
-
**canceled:** (`string`): Workflow execution was canceled via the cancel() method, stopping any running steps and preventing subsequent steps from executing
|
|
50
|
-
|
|
51
|
-
## Related
|
|
52
|
-
|
|
53
|
-
- [Run.start()](https://mastra.ai/reference/workflows/run-methods/start)
|
|
54
|
-
- [Run.resume()](https://mastra.ai/reference/workflows/run-methods/resume)
|
|
55
|
-
- [Run.cancel()](https://mastra.ai/reference/workflows/run-methods/cancel)
|
|
56
|
-
- [Run.restart()](https://mastra.ai/reference/workflows/run-methods/restart)
|
|
57
|
-
- [Run.timeTravel()](https://mastra.ai/reference/workflows/run-methods/timeTravel)
|
|
58
|
-
- [Run.stream()](https://mastra.ai/docs/streaming/workflow-streaming)
|
|
59
|
-
- [Run.timeTravelStream()](https://mastra.ai/reference/streaming/workflows/timeTravelStream)
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# Step Class
|
|
2
|
-
|
|
3
|
-
The Step class defines individual units of work within a workflow, encapsulating execution logic, data validation, and input/output handling. It can take either a tool or an agent as a parameter to automatically create a step from them.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
|
|
11
|
-
const step1 = createStep({
|
|
12
|
-
id: "step-1",
|
|
13
|
-
description: "passes value from input to output",
|
|
14
|
-
inputSchema: z.object({
|
|
15
|
-
value: z.number(),
|
|
16
|
-
}),
|
|
17
|
-
outputSchema: z.object({
|
|
18
|
-
value: z.number(),
|
|
19
|
-
}),
|
|
20
|
-
execute: async ({ inputData }) => {
|
|
21
|
-
const { value } = inputData;
|
|
22
|
-
return {
|
|
23
|
-
value,
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Creating steps from agents
|
|
30
|
-
|
|
31
|
-
You can create a step directly from an agent. The step will use the agent's name as its ID.
|
|
32
|
-
|
|
33
|
-
### Basic agent step
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { testAgent } from "../agents/test-agent";
|
|
37
|
-
|
|
38
|
-
const agentStep = createStep(testAgent);
|
|
39
|
-
// inputSchema: { prompt: string }
|
|
40
|
-
// outputSchema: { text: string }
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Agent step with structured output
|
|
44
|
-
|
|
45
|
-
Pass `structuredOutput` to have the agent return typed structured data:
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
const articleSchema = z.object({
|
|
49
|
-
title: z.string(),
|
|
50
|
-
summary: z.string(),
|
|
51
|
-
tags: z.array(z.string()),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const agentStep = createStep(testAgent, {
|
|
55
|
-
structuredOutput: { schema: articleSchema },
|
|
56
|
-
});
|
|
57
|
-
// inputSchema: { prompt: string }
|
|
58
|
-
// outputSchema: { title: string, summary: string, tags: string[] }
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Agent step options
|
|
62
|
-
|
|
63
|
-
**structuredOutput:** (`{ schema: z.ZodType<any> }`): When provided, the agent returns structured data matching this schema instead of plain text. The step's outputSchema is set to the provided schema.
|
|
64
|
-
|
|
65
|
-
**onFinish:** (`(result: AgentResult) => void`): Callback invoked when the agent completes generation.
|
|
66
|
-
|
|
67
|
-
## Constructor Parameters
|
|
68
|
-
|
|
69
|
-
**id:** (`string`): Unique identifier for the step
|
|
70
|
-
|
|
71
|
-
**description:** (`string`): Optional description of what the step does
|
|
72
|
-
|
|
73
|
-
**inputSchema:** (`z.ZodType<any>`): Zod schema defining the input structure
|
|
74
|
-
|
|
75
|
-
**outputSchema:** (`z.ZodType<any>`): Zod schema defining the output structure
|
|
76
|
-
|
|
77
|
-
**resumeSchema:** (`z.ZodType<any>`): Optional Zod schema for resuming the step
|
|
78
|
-
|
|
79
|
-
**suspendSchema:** (`z.ZodType<any>`): Optional Zod schema for suspending the step
|
|
80
|
-
|
|
81
|
-
**stateSchema:** (`z.ZodObject<any>`): Optional Zod schema for the step state. Automatically injected when using Mastra's state system. The stateSchema must be a subset of the workflow's stateSchema. If not specified, type is 'any'.
|
|
82
|
-
|
|
83
|
-
**requestContextSchema:** (`z.ZodType<any>`): Zod schema for validating request context values. When provided, the context is validated before the step's execute() runs, failing the step if validation fails.
|
|
84
|
-
|
|
85
|
-
**execute:** (`(params: ExecuteParams) => Promise<any>`): Async function containing step logic
|
|
86
|
-
|
|
87
|
-
**metadata:** (`Record<string, any>`): Optional key-value pairs for storing additional step information. Values must be serializable (no functions, circular references, etc.).
|
|
88
|
-
|
|
89
|
-
### ExecuteParams
|
|
90
|
-
|
|
91
|
-
**inputData:** (`z.infer<TStepInput>`): The input data matching the inputSchema
|
|
92
|
-
|
|
93
|
-
**resumeData:** (`z.infer<TResumeSchema>`): The resume data matching the resumeSchema, when resuming the step from a suspended state. Only exists if the step is being resumed.
|
|
94
|
-
|
|
95
|
-
**suspendData:** (`z.infer<TSuspendSchema>`): The suspend data that was originally passed to suspend() when the step was suspended. Only exists if the step is being resumed and was previously suspended with data.
|
|
96
|
-
|
|
97
|
-
**mastra:** (`Mastra`): Access to Mastra services (agents, tools, etc.)
|
|
98
|
-
|
|
99
|
-
**getStepResult:** (`(step: Step | string) => any`): Function to access results from other steps
|
|
100
|
-
|
|
101
|
-
**getInitData:** (`() => any`): Function to access the initial input data of the workflow in any step
|
|
102
|
-
|
|
103
|
-
**suspend:** (`(suspendPayload: any, suspendOptions?: { resumeLabel?: string }) => Promise<void>`): Function to pause workflow execution
|
|
104
|
-
|
|
105
|
-
**state:** (`z.infer<TState>`): The current workflow state. Contains shared values that persist across all steps and suspend/resume cycles. The structure is defined by the step's stateSchema.
|
|
106
|
-
|
|
107
|
-
**setState:** (`(state: z.infer<TState>) => void`): Function to set the state of the workflow. Inject via reducer-like pattern, such as 'setState({ ...state, ...newState })'
|
|
108
|
-
|
|
109
|
-
**runId:** (`string`): Current run id
|
|
110
|
-
|
|
111
|
-
**requestContext?:** (`RequestContext`): Request Context for dependency injection and contextual information.
|
|
112
|
-
|
|
113
|
-
**retryCount?:** (`number`): The retry count for this specific step, it automatically increases each time the step is retried
|
|
114
|
-
|
|
115
|
-
## Related
|
|
116
|
-
|
|
117
|
-
- [Workflow state](https://mastra.ai/docs/workflows/workflow-state)
|
|
118
|
-
- [Control flow](https://mastra.ai/docs/workflows/control-flow)
|
|
119
|
-
- [Using agents and tools](https://mastra.ai/docs/workflows/agents-and-tools)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Workflow\.branch()
|
|
2
|
-
|
|
3
|
-
The `.branch()` method creates conditional branches between workflow steps, allowing for different paths to be taken based on the result of a previous step.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
workflow.branch([
|
|
9
|
-
[async ({ context }) => true, step1],
|
|
10
|
-
[async ({ context }) => false, step2],
|
|
11
|
-
]);
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Parameters
|
|
15
|
-
|
|
16
|
-
**steps:** (`[() => boolean, Step]`): An array of tuples, each containing a condition function and a step to execute if the condition is true
|
|
17
|
-
|
|
18
|
-
## Returns
|
|
19
|
-
|
|
20
|
-
**workflow:** (`NewWorkflow`): The workflow instance for method chaining
|
|
21
|
-
|
|
22
|
-
## Related
|
|
23
|
-
|
|
24
|
-
- [Conditional Branching Logic](https://mastra.ai/docs/workflows/control-flow)
|
|
25
|
-
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Workflow\.commit()
|
|
2
|
-
|
|
3
|
-
The `.commit()` method finalizes the workflow and returns the final result.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
workflow.then(step1).commit();
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Returns
|
|
12
|
-
|
|
13
|
-
**workflow:** (`Workflow`): The workflow instance for method chaining
|
|
14
|
-
|
|
15
|
-
## Related
|
|
16
|
-
|
|
17
|
-
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Workflow\.createRun()
|
|
2
|
-
|
|
3
|
-
The `.createRun()` method creates a new workflow run instance, allowing you to execute the workflow with specific input data. This is the current API that returns a `Run` instance.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
await workflow.createRun();
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
**runId?:** (`string`): Optional custom identifier for the workflow run
|
|
14
|
-
|
|
15
|
-
**resourceId?:** (`string`): Optional identifier to associate the workflow run with a specific resource (e.g., user ID, tenant ID). This value is persisted with the workflow run and can be used for filtering and querying runs.
|
|
16
|
-
|
|
17
|
-
**disableScorers?:** (`boolean`): Optional flag to disable scorers for this workflow run
|
|
18
|
-
|
|
19
|
-
## Returns
|
|
20
|
-
|
|
21
|
-
**run:** (`Run`): A new workflow run instance that can be used to execute the workflow
|
|
22
|
-
|
|
23
|
-
## Extended usage example
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
const workflow = mastra.getWorkflow("workflow");
|
|
27
|
-
|
|
28
|
-
const run = await workflow.createRun();
|
|
29
|
-
|
|
30
|
-
const result = await run.start({
|
|
31
|
-
inputData: {
|
|
32
|
-
value: 10,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Using resourceId
|
|
38
|
-
|
|
39
|
-
The `resourceId` parameter associates a workflow run with a specific resource, such as a user or tenant. This is useful for multi-tenant applications or when you need to track which user initiated a workflow.
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
const workflow = mastra.getWorkflow("workflow");
|
|
43
|
-
|
|
44
|
-
// Create a run associated with a specific user
|
|
45
|
-
const run = await workflow.createRun({
|
|
46
|
-
resourceId: "user-123",
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const result = await run.start({
|
|
50
|
-
inputData: {
|
|
51
|
-
value: 10,
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Later, retrieve the run and access the resourceId
|
|
56
|
-
const storedRun = await workflow.getWorkflowRunById(run.runId);
|
|
57
|
-
console.log(storedRun.resourceId); // "user-123"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Related
|
|
61
|
-
|
|
62
|
-
- [Run Class](https://mastra.ai/reference/workflows/run)
|
|
63
|
-
- [Workflows overview](https://mastra.ai/docs/workflows/overview)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Workflow\.dountil()
|
|
2
|
-
|
|
3
|
-
The `.dountil()` method executes a step until a condition is met. It always runs the step at least once before evaluating the condition. The first time the condition is evaluated, `iterationCount` is `1`.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
workflow.dountil(step1, async ({ inputData }) => true);
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
**step:** (`Step`): The step instance to execute in the loop
|
|
14
|
-
|
|
15
|
-
**condition:** (`(params : ExecuteParams & { iterationCount: number }) => Promise<boolean>`): A function that returns a boolean indicating whether to continue the loop. The function receives the execution parameters and the iteration count.
|
|
16
|
-
|
|
17
|
-
## Returns
|
|
18
|
-
|
|
19
|
-
**workflow:** (`Workflow`): The workflow instance for method chaining
|
|
20
|
-
|
|
21
|
-
## Related
|
|
22
|
-
|
|
23
|
-
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
24
|
-
|
|
25
|
-
- [ExecuteParams](https://mastra.ai/reference/workflows/step)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Workflow\.dowhile()
|
|
2
|
-
|
|
3
|
-
The `.dowhile()` method executes a step while a condition is met. It always runs the step at least once before evaluating the condition. The first time the condition is evaluated, `iterationCount` is `1`.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
workflow.dowhile(step1, async ({ inputData }) => true);
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
**step:** (`Step`): The step instance to execute in the loop
|
|
14
|
-
|
|
15
|
-
**condition:** (`(params : ExecuteParams & { iterationCount: number }) => Promise<boolean>`): A function that returns a boolean indicating whether to continue the loop. The function receives the execution parameters and the iteration count.
|
|
16
|
-
|
|
17
|
-
## Returns
|
|
18
|
-
|
|
19
|
-
**workflow:** (`Workflow`): The workflow instance for method chaining
|
|
20
|
-
|
|
21
|
-
## Related
|
|
22
|
-
|
|
23
|
-
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
24
|
-
|
|
25
|
-
- [ExecuteParams](https://mastra.ai/reference/workflows/step)
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# Workflow\.foreach()
|
|
2
|
-
|
|
3
|
-
The `.foreach()` method creates a loop that executes a step for each item in an array. It always returns an array containing the output from each iteration, preserving the original order.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
workflow.foreach(step1, { concurrency: 2 });
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
**step:** (`Step`): The step instance to execute in the loop. The previous step must return an array type.
|
|
14
|
-
|
|
15
|
-
**opts?:** (`object`): number
|
|
16
|
-
|
|
17
|
-
## Returns
|
|
18
|
-
|
|
19
|
-
**workflow:** (`Workflow`): The workflow instance for method chaining. The output type is an array of the step's output type.
|
|
20
|
-
|
|
21
|
-
## Behavior
|
|
22
|
-
|
|
23
|
-
### Execution and waiting
|
|
24
|
-
|
|
25
|
-
The `.foreach()` method processes all items before the next step executes. The step following `.foreach()` only runs after every iteration has completed, regardless of concurrency settings. With `concurrency: 1` (default), items process sequentially. With higher concurrency, items process in parallel batches, but the next step still waits for all batches to finish.
|
|
26
|
-
|
|
27
|
-
If you need to run multiple operations per item, use a nested workflow as the step. This keeps all operations for each item together and is cleaner than chaining multiple `.foreach()` calls. See [Nested workflows inside foreach](https://mastra.ai/docs/workflows/control-flow) for examples.
|
|
28
|
-
|
|
29
|
-
### Output structure
|
|
30
|
-
|
|
31
|
-
`.foreach()` always outputs an array. Each element in the output array corresponds to the result of processing the element at the same index in the input array.
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
// Input: [{ value: 1 }, { value: 2 }, { value: 3 }]
|
|
35
|
-
// Step adds 10 to each value
|
|
36
|
-
// Output: [{ value: 11 }, { value: 12 }, { value: 13 }]
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Using `.then()` after `.foreach()`
|
|
40
|
-
|
|
41
|
-
When you chain `.then()` after `.foreach()`, the next step receives the entire output array as its input. This allows you to aggregate or process all results together.
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
workflow
|
|
45
|
-
.foreach(processItemStep) // Output: array of processed items
|
|
46
|
-
.then(aggregateStep) // Input: the entire array
|
|
47
|
-
.commit();
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Using `.map()` after `.foreach()`
|
|
51
|
-
|
|
52
|
-
Use `.map()` to transform the array output before passing it to the next step:
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
workflow
|
|
56
|
-
.foreach(processItemStep)
|
|
57
|
-
.map(async ({ inputData }) => ({
|
|
58
|
-
total: inputData.reduce((sum, item) => sum + item.value, 0),
|
|
59
|
-
count: inputData.length
|
|
60
|
-
}))
|
|
61
|
-
.then(nextStep)
|
|
62
|
-
.commit();
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Chaining multiple `.foreach()` calls
|
|
66
|
-
|
|
67
|
-
When you chain `.foreach()` calls, each operates on the array from the previous step:
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
workflow
|
|
71
|
-
.foreach(stepA) // If input is [a, b, c], output is [A, B, C]
|
|
72
|
-
.foreach(stepB) // Operates on [A, B, C], output is [A', B', C']
|
|
73
|
-
.commit();
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
If a step inside `.foreach()` returns an array, the output becomes an array of arrays. Use `.map()` with `.flat()` to flatten:
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
workflow
|
|
80
|
-
.foreach(chunkStep) // Output: [[chunk1, chunk2], [chunk3, chunk4]]
|
|
81
|
-
.map(async ({ inputData }) => inputData.flat()) // Output: [chunk1, chunk2, chunk3, chunk4]
|
|
82
|
-
.foreach(embedStep)
|
|
83
|
-
.commit();
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Progress events during streaming
|
|
87
|
-
|
|
88
|
-
When using `run.stream()`, foreach steps emit a `workflow-step-progress` event after each iteration completes. This lets you track real-time progress without waiting for the entire foreach to finish.
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
const run = await workflow.createRun();
|
|
92
|
-
const stream = run.stream({ inputData });
|
|
93
|
-
|
|
94
|
-
for await (const chunk of stream) {
|
|
95
|
-
if (chunk.type === 'workflow-step-progress') {
|
|
96
|
-
console.log(`${chunk.payload.completedCount}/${chunk.payload.totalCount}`);
|
|
97
|
-
// e.g. "1/3", "2/3", "3/3"
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Each progress event payload contains:
|
|
103
|
-
|
|
104
|
-
**id:** (`string`): The step ID of the foreach step
|
|
105
|
-
|
|
106
|
-
**completedCount:** (`number`): Number of iterations completed so far
|
|
107
|
-
|
|
108
|
-
**totalCount:** (`number`): Total number of iterations
|
|
109
|
-
|
|
110
|
-
**currentIndex:** (`number`): Index of the iteration that just completed
|
|
111
|
-
|
|
112
|
-
**iterationStatus:** (`'success' | 'failed' | 'suspended'`): Status of the iteration that just completed
|
|
113
|
-
|
|
114
|
-
**iterationOutput?:** (`Record<string, any>`): Output of the iteration (present when iterationStatus is 'success')
|
|
115
|
-
|
|
116
|
-
## Related
|
|
117
|
-
|
|
118
|
-
- [Looping with foreach](https://mastra.ai/docs/workflows/control-flow)
|