@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718
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%2Fastra.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
- package/.docs/organized/changelogs/create-mastra.md +302 -0
- package/.docs/organized/changelogs/mastra.md +302 -0
- package/.docs/organized/code-examples/agent-network.md +282 -0
- package/.docs/organized/code-examples/agent.md +388 -0
- package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
- package/.docs/organized/code-examples/assistant-ui.md +37 -0
- package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
- package/.docs/organized/code-examples/client-side-tools.md +69 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
- package/.docs/organized/code-examples/fireworks-r1.md +159 -0
- package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
- package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
- package/.docs/organized/code-examples/memory-with-context.md +167 -0
- package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
- package/.docs/organized/code-examples/memory-with-pg.md +224 -0
- package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
- package/.docs/organized/code-examples/quick-start.md +129 -0
- package/.docs/organized/code-examples/stock-price-tool.md +124 -0
- package/.docs/organized/code-examples/weather-agent.md +353 -0
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
- package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
- package/.docs/raw/agents/adding-tools.mdx +317 -0
- package/.docs/raw/agents/adding-voice.mdx +175 -0
- package/.docs/raw/agents/agent-memory.mdx +62 -0
- package/.docs/raw/agents/mcp-guide.mdx +215 -0
- package/.docs/raw/agents/overview.mdx +303 -0
- package/.docs/raw/community/discord.mdx +12 -0
- package/.docs/raw/community/licensing.mdx +63 -0
- package/.docs/raw/deployment/client.mdx +120 -0
- package/.docs/raw/deployment/deployment.mdx +127 -0
- package/.docs/raw/deployment/server.mdx +282 -0
- package/.docs/raw/evals/custom-eval.mdx +22 -0
- package/.docs/raw/evals/overview.mdx +95 -0
- package/.docs/raw/evals/running-in-ci.mdx +81 -0
- package/.docs/raw/evals/textual-evals.mdx +54 -0
- package/.docs/raw/faq/index.mdx +63 -0
- package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
- package/.docs/raw/frameworks/next-js.mdx +238 -0
- package/.docs/raw/getting-started/installation.mdx +442 -0
- package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
- package/.docs/raw/getting-started/project-structure.mdx +80 -0
- package/.docs/raw/index.mdx +22 -0
- package/.docs/raw/integrations/index.mdx +213 -0
- package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
- package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
- package/.docs/raw/memory/memory-processors.mdx +131 -0
- package/.docs/raw/memory/overview.mdx +119 -0
- package/.docs/raw/memory/semantic-recall.mdx +122 -0
- package/.docs/raw/memory/working-memory.mdx +87 -0
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
- package/.docs/raw/observability/tracing.mdx +115 -0
- package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
- package/.docs/raw/rag/overview.mdx +85 -0
- package/.docs/raw/rag/retrieval.mdx +365 -0
- package/.docs/raw/rag/vector-databases.mdx +340 -0
- package/.docs/raw/reference/agents/createTool.mdx +229 -0
- package/.docs/raw/reference/agents/generate.mdx +334 -0
- package/.docs/raw/reference/agents/getAgent.mdx +54 -0
- package/.docs/raw/reference/agents/stream.mdx +369 -0
- package/.docs/raw/reference/cli/build.mdx +55 -0
- package/.docs/raw/reference/cli/dev.mdx +134 -0
- package/.docs/raw/reference/cli/init.mdx +43 -0
- package/.docs/raw/reference/client-js/agents.mdx +107 -0
- package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
- package/.docs/raw/reference/client-js/logs.mdx +24 -0
- package/.docs/raw/reference/client-js/memory.mdx +97 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
- package/.docs/raw/reference/client-js/tools.mdx +44 -0
- package/.docs/raw/reference/client-js/vectors.mdx +79 -0
- package/.docs/raw/reference/client-js/workflows.mdx +136 -0
- package/.docs/raw/reference/core/mastra-class.mdx +232 -0
- package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +109 -0
- package/.docs/raw/reference/deployer/vercel.mdx +117 -0
- package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
- package/.docs/raw/reference/evals/bias.mdx +186 -0
- package/.docs/raw/reference/evals/completeness.mdx +174 -0
- package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
- package/.docs/raw/reference/evals/context-position.mdx +190 -0
- package/.docs/raw/reference/evals/context-precision.mdx +189 -0
- package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
- package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
- package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
- package/.docs/raw/reference/evals/hallucination.mdx +219 -0
- package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
- package/.docs/raw/reference/evals/summarization.mdx +205 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
- package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
- package/.docs/raw/reference/evals/toxicity.mdx +165 -0
- package/.docs/raw/reference/index.mdx +12 -0
- package/.docs/raw/reference/memory/Memory.mdx +212 -0
- package/.docs/raw/reference/memory/createThread.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
- package/.docs/raw/reference/memory/query.mdx +167 -0
- package/.docs/raw/reference/networks/agent-network.mdx +159 -0
- package/.docs/raw/reference/observability/create-logger.mdx +106 -0
- package/.docs/raw/reference/observability/logger.mdx +55 -0
- package/.docs/raw/reference/observability/otel-config.mdx +120 -0
- package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
- package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
- package/.docs/raw/reference/observability/providers/index.mdx +16 -0
- package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
- package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
- package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
- package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
- package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
- package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
- package/.docs/raw/reference/rag/astra.mdx +258 -0
- package/.docs/raw/reference/rag/chroma.mdx +281 -0
- package/.docs/raw/reference/rag/chunk.mdx +235 -0
- package/.docs/raw/reference/rag/document.mdx +127 -0
- package/.docs/raw/reference/rag/embeddings.mdx +160 -0
- package/.docs/raw/reference/rag/extract-params.mdx +226 -0
- package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
- package/.docs/raw/reference/rag/libsql.mdx +357 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
- package/.docs/raw/reference/rag/pg.mdx +477 -0
- package/.docs/raw/reference/rag/pinecone.mdx +281 -0
- package/.docs/raw/reference/rag/qdrant.mdx +236 -0
- package/.docs/raw/reference/rag/rerank.mdx +212 -0
- package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
- package/.docs/raw/reference/rag/upstash.mdx +247 -0
- package/.docs/raw/reference/rag/vectorize.mdx +298 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +48 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +207 -0
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
- package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
- package/.docs/raw/reference/voice/deepgram.mdx +164 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
- package/.docs/raw/reference/voice/google.mdx +198 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
- package/.docs/raw/reference/voice/murf.mdx +251 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
- package/.docs/raw/reference/voice/openai.mdx +168 -0
- package/.docs/raw/reference/voice/playai.mdx +159 -0
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/voice/speechify.mdx +145 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
- package/.docs/raw/reference/voice/voice.on.mdx +189 -0
- package/.docs/raw/reference/voice/voice.send.mdx +118 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/workflows/after.mdx +88 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/commit.mdx +37 -0
- package/.docs/raw/reference/workflows/createRun.mdx +77 -0
- package/.docs/raw/reference/workflows/else.mdx +72 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/execute.mdx +110 -0
- package/.docs/raw/reference/workflows/if.mdx +107 -0
- package/.docs/raw/reference/workflows/resume.mdx +155 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
- package/.docs/raw/reference/workflows/start.mdx +84 -0
- package/.docs/raw/reference/workflows/step-class.mdx +100 -0
- package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
- package/.docs/raw/reference/workflows/step-function.mdx +92 -0
- package/.docs/raw/reference/workflows/step-options.mdx +69 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
- package/.docs/raw/reference/workflows/suspend.mdx +70 -0
- package/.docs/raw/reference/workflows/then.mdx +74 -0
- package/.docs/raw/reference/workflows/until.mdx +165 -0
- package/.docs/raw/reference/workflows/watch.mdx +118 -0
- package/.docs/raw/reference/workflows/while.mdx +168 -0
- package/.docs/raw/reference/workflows/workflow.mdx +233 -0
- package/.docs/raw/storage/overview.mdx +378 -0
- package/.docs/raw/voice/overview.mdx +135 -0
- package/.docs/raw/voice/speech-to-text.mdx +45 -0
- package/.docs/raw/voice/text-to-speech.mdx +52 -0
- package/.docs/raw/voice/voice-to-voice.mdx +310 -0
- package/.docs/raw/workflows/control-flow.mdx +778 -0
- package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/nested-workflows.mdx +352 -0
- package/.docs/raw/workflows/overview.mdx +203 -0
- package/.docs/raw/workflows/steps.mdx +108 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
- package/.docs/raw/workflows/variables.mdx +313 -0
- package/LICENSE.md +46 -0
- package/README.md +129 -0
- package/dist/_tsup-dts-rollup.d.ts +149 -0
- package/dist/chunk-QWYMT5LP.js +194 -0
- package/dist/prepare-docs/prepare.d.ts +1 -0
- package/dist/prepare-docs/prepare.js +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +518 -0
- package/package.json +60 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.step() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.step()` method in workflows, which adds a new step to the workflow.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.step()
|
|
7
|
+
|
|
8
|
+
The `.step()` method adds a new step to the workflow, optionally configuring its variables and execution conditions.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow.step({
|
|
14
|
+
id: "stepTwo",
|
|
15
|
+
outputSchema: z.object({
|
|
16
|
+
result: z.number()
|
|
17
|
+
}),
|
|
18
|
+
execute: async ({ context }) => {
|
|
19
|
+
return { result: 42 };
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
<PropertiesTable
|
|
27
|
+
content={[
|
|
28
|
+
{
|
|
29
|
+
name: "stepConfig",
|
|
30
|
+
type: "Step | StepDefinition | string",
|
|
31
|
+
description: "Step instance, configuration object, or step ID to add to workflow",
|
|
32
|
+
isOptional: false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "options",
|
|
36
|
+
type: "StepOptions",
|
|
37
|
+
description: "Optional configuration for step execution",
|
|
38
|
+
isOptional: true
|
|
39
|
+
}
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
### StepDefinition
|
|
44
|
+
|
|
45
|
+
<PropertiesTable
|
|
46
|
+
content={[
|
|
47
|
+
{
|
|
48
|
+
name: "id",
|
|
49
|
+
type: "string",
|
|
50
|
+
description: "Unique identifier for the step",
|
|
51
|
+
isOptional: false
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "outputSchema",
|
|
55
|
+
type: "z.ZodSchema",
|
|
56
|
+
description: "Schema for validating step output",
|
|
57
|
+
isOptional: true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "execute",
|
|
61
|
+
type: "(params: ExecuteParams) => Promise<any>",
|
|
62
|
+
description: "Function containing step logic",
|
|
63
|
+
isOptional: false
|
|
64
|
+
}
|
|
65
|
+
]}
|
|
66
|
+
/>
|
|
67
|
+
|
|
68
|
+
### StepOptions
|
|
69
|
+
|
|
70
|
+
<PropertiesTable
|
|
71
|
+
content={[
|
|
72
|
+
{
|
|
73
|
+
name: "variables",
|
|
74
|
+
type: "Record<string, VariableRef>",
|
|
75
|
+
description: "Map of variable names to their source references",
|
|
76
|
+
isOptional: true
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "when",
|
|
80
|
+
type: "StepCondition",
|
|
81
|
+
description: "Condition that must be met for step to execute",
|
|
82
|
+
isOptional: true
|
|
83
|
+
}
|
|
84
|
+
]}
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
## Related
|
|
88
|
+
- [Basic Usage with Step Instance](../../workflows/steps.mdx)
|
|
89
|
+
- [Step Class Reference](./step-class.mdx)
|
|
90
|
+
- [Workflow Class Reference](./workflow.mdx)
|
|
91
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx)
|
|
92
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: StepOptions | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the step options in workflows, which control variable mapping, execution conditions, and other runtime behavior.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# StepOptions
|
|
7
|
+
|
|
8
|
+
Configuration options for workflow steps that control variable mapping, execution conditions, and other runtime behavior.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow.step(processOrder, {
|
|
14
|
+
variables: {
|
|
15
|
+
orderId: { step: 'trigger', path: 'id' },
|
|
16
|
+
userId: { step: 'auth', path: 'user.id' }
|
|
17
|
+
},
|
|
18
|
+
when: {
|
|
19
|
+
ref: { step: 'auth', path: 'status' },
|
|
20
|
+
query: { $eq: 'authenticated' }
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Properties
|
|
26
|
+
|
|
27
|
+
<PropertiesTable
|
|
28
|
+
content={[
|
|
29
|
+
{
|
|
30
|
+
name: "variables",
|
|
31
|
+
type: "Record<string, VariableRef>",
|
|
32
|
+
description: "Maps step input variables to values from other steps",
|
|
33
|
+
isOptional: true
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "when",
|
|
37
|
+
type: "StepCondition",
|
|
38
|
+
description: "Condition that must be met for step execution",
|
|
39
|
+
isOptional: true
|
|
40
|
+
}
|
|
41
|
+
]}
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
### VariableRef
|
|
45
|
+
|
|
46
|
+
<PropertiesTable
|
|
47
|
+
content={[
|
|
48
|
+
{
|
|
49
|
+
name: "step",
|
|
50
|
+
type: "string | Step | { id: string }",
|
|
51
|
+
description: "Source step for the variable value",
|
|
52
|
+
isOptional: false
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "path",
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "Path to the value in the step's output",
|
|
58
|
+
isOptional: false
|
|
59
|
+
}
|
|
60
|
+
]}
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
## Related
|
|
64
|
+
- [Path Comparison](../../workflows/control-flow.mdx#path-comparison)
|
|
65
|
+
- [Step Function Reference](./step-function.mdx)
|
|
66
|
+
- [Step Class Reference](./step-class.mdx)
|
|
67
|
+
- [Workflow Class Reference](./workflow.mdx)
|
|
68
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx)
|
|
69
|
+
```
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Step Retries | Error Handling | Mastra Docs"
|
|
3
|
+
description: "Automatically retry failed steps in Mastra workflows with configurable retry policies."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Step Retries
|
|
7
|
+
|
|
8
|
+
Mastra provides built-in retry mechanisms to handle transient failures in workflow steps. This allows workflows to recover gracefully from temporary issues without requiring manual intervention.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
When a step in a workflow fails (throws an exception), Mastra can automatically retry the step execution based on a configurable retry policy. This is useful for handling:
|
|
13
|
+
|
|
14
|
+
- Network connectivity issues
|
|
15
|
+
- Service unavailability
|
|
16
|
+
- Rate limiting
|
|
17
|
+
- Temporary resource constraints
|
|
18
|
+
- Other transient failures
|
|
19
|
+
|
|
20
|
+
## Default Behavior
|
|
21
|
+
|
|
22
|
+
By default, steps do not retry when they fail. This means:
|
|
23
|
+
|
|
24
|
+
- A step will execute once
|
|
25
|
+
- If it fails, it will immediately mark the step as failed
|
|
26
|
+
- The workflow will continue to execute any subsequent steps that don't depend on the failed step
|
|
27
|
+
|
|
28
|
+
## Configuration Options
|
|
29
|
+
|
|
30
|
+
Retries can be configured at two levels:
|
|
31
|
+
|
|
32
|
+
### 1. Workflow-level Configuration
|
|
33
|
+
|
|
34
|
+
You can set a default retry configuration for all steps in a workflow:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const workflow = new Workflow({
|
|
38
|
+
name: 'my-workflow',
|
|
39
|
+
retryConfig: {
|
|
40
|
+
attempts: 3, // Number of retries (in addition to the initial attempt)
|
|
41
|
+
delay: 1000, // Delay between retries in milliseconds
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Step-level Configuration
|
|
47
|
+
|
|
48
|
+
You can also configure retries on individual steps, which will override the workflow-level configuration for that specific step:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const fetchDataStep = new Step({
|
|
52
|
+
id: 'fetchData',
|
|
53
|
+
execute: async () => {
|
|
54
|
+
// Fetch data from external API
|
|
55
|
+
},
|
|
56
|
+
retryConfig: {
|
|
57
|
+
attempts: 5, // This step will retry up to 5 times
|
|
58
|
+
delay: 2000, // With a 2-second delay between retries
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Retry Parameters
|
|
64
|
+
|
|
65
|
+
The `retryConfig` object supports the following parameters:
|
|
66
|
+
|
|
67
|
+
| Parameter | Type | Default | Description |
|
|
68
|
+
|-----------|------|---------|-------------|
|
|
69
|
+
| `attempts` | number | 0 | The number of retry attempts (in addition to the initial attempt) |
|
|
70
|
+
| `delay` | number | 1000 | Time in milliseconds to wait between retries |
|
|
71
|
+
|
|
72
|
+
## How Retries Work
|
|
73
|
+
|
|
74
|
+
When a step fails, Mastra's retry mechanism:
|
|
75
|
+
|
|
76
|
+
1. Checks if the step has retry attempts remaining
|
|
77
|
+
2. If attempts remain:
|
|
78
|
+
- Decrements the attempt counter
|
|
79
|
+
- Transitions the step to a "waiting" state
|
|
80
|
+
- Waits for the configured delay period
|
|
81
|
+
- Retries the step execution
|
|
82
|
+
3. If no attempts remain or all attempts have been exhausted:
|
|
83
|
+
- Marks the step as "failed"
|
|
84
|
+
- Continues workflow execution (for steps that don't depend on the failed step)
|
|
85
|
+
|
|
86
|
+
During retry attempts, the workflow execution remains active but paused for the specific step that is being retried.
|
|
87
|
+
|
|
88
|
+
## Examples
|
|
89
|
+
|
|
90
|
+
### Basic Retry Example
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Workflow, Step } from '@mastra/core/workflows';
|
|
94
|
+
|
|
95
|
+
// Define a step that might fail
|
|
96
|
+
const unreliableApiStep = new Step({
|
|
97
|
+
id: 'callUnreliableApi',
|
|
98
|
+
execute: async () => {
|
|
99
|
+
// Simulate an API call that might fail
|
|
100
|
+
const random = Math.random();
|
|
101
|
+
if (random < 0.7) {
|
|
102
|
+
throw new Error('API call failed');
|
|
103
|
+
}
|
|
104
|
+
return { data: 'API response data' };
|
|
105
|
+
},
|
|
106
|
+
retryConfig: {
|
|
107
|
+
attempts: 3, // Retry up to 3 times
|
|
108
|
+
delay: 2000, // Wait 2 seconds between attempts
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Create a workflow with the unreliable step
|
|
113
|
+
const workflow = new Workflow({
|
|
114
|
+
name: 'retry-demo-workflow',
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
workflow
|
|
118
|
+
.step(unreliableApiStep)
|
|
119
|
+
.then(processResultStep)
|
|
120
|
+
.commit();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Workflow-level Retries with Step Override
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import { Workflow, Step } from '@mastra/core/workflows';
|
|
127
|
+
|
|
128
|
+
// Create a workflow with default retry configuration
|
|
129
|
+
const workflow = new Workflow({
|
|
130
|
+
name: 'multi-retry-workflow',
|
|
131
|
+
retryConfig: {
|
|
132
|
+
attempts: 2, // All steps will retry twice by default
|
|
133
|
+
delay: 1000, // With a 1-second delay
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// This step uses the workflow's default retry configuration
|
|
138
|
+
const standardStep = new Step({
|
|
139
|
+
id: 'standardStep',
|
|
140
|
+
execute: async () => {
|
|
141
|
+
// Some operation that might fail
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// This step overrides the workflow's retry configuration
|
|
146
|
+
const criticalStep = new Step({
|
|
147
|
+
id: 'criticalStep',
|
|
148
|
+
execute: async () => {
|
|
149
|
+
// Critical operation that needs more retry attempts
|
|
150
|
+
},
|
|
151
|
+
retryConfig: {
|
|
152
|
+
attempts: 5, // Override with 5 retry attempts
|
|
153
|
+
delay: 5000, // And a longer 5-second delay
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// This step disables retries
|
|
158
|
+
const noRetryStep = new Step({
|
|
159
|
+
id: 'noRetryStep',
|
|
160
|
+
execute: async () => {
|
|
161
|
+
// Operation that should not retry
|
|
162
|
+
},
|
|
163
|
+
retryConfig: {
|
|
164
|
+
attempts: 0, // Explicitly disable retries
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
workflow
|
|
169
|
+
.step(standardStep)
|
|
170
|
+
.then(criticalStep)
|
|
171
|
+
.then(noRetryStep)
|
|
172
|
+
.commit();
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Monitoring Retries
|
|
176
|
+
|
|
177
|
+
You can monitor retry attempts in your logs. Mastra logs retry-related events at the `debug` level:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
[DEBUG] Step fetchData failed (runId: abc-123)
|
|
181
|
+
[DEBUG] Attempt count for step fetchData: 2 remaining attempts (runId: abc-123)
|
|
182
|
+
[DEBUG] Step fetchData waiting (runId: abc-123)
|
|
183
|
+
[DEBUG] Step fetchData finished waiting (runId: abc-123)
|
|
184
|
+
[DEBUG] Step fetchData pending (runId: abc-123)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Best Practices
|
|
188
|
+
|
|
189
|
+
1. **Use Retries for Transient Failures**: Only configure retries for operations that might experience transient failures. For deterministic errors (like validation failures), retries won't help.
|
|
190
|
+
|
|
191
|
+
2. **Set Appropriate Delays**: Consider using longer delays for external API calls to allow time for services to recover.
|
|
192
|
+
|
|
193
|
+
3. **Limit Retry Attempts**: Don't set extremely high retry counts as this could cause workflows to run for excessive periods during outages.
|
|
194
|
+
|
|
195
|
+
4. **Implement Idempotent Operations**: Ensure your step's `execute` function is idempotent (can be called multiple times without side effects) since it may be retried.
|
|
196
|
+
|
|
197
|
+
5. **Consider Backoff Strategies**: For more advanced scenarios, consider implementing exponential backoff in your step's logic for operations that might be rate-limited.
|
|
198
|
+
|
|
199
|
+
## Related
|
|
200
|
+
|
|
201
|
+
- [Step Class Reference](./step-class.mdx)
|
|
202
|
+
- [Workflow Configuration](./workflow.mdx)
|
|
203
|
+
- [Error Handling in Workflows](../../workflows/error-handling.mdx)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: suspend() | Control Flow | Mastra Docs"
|
|
3
|
+
description: "Documentation for the suspend function in Mastra workflows, which pauses execution until resumed."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# suspend()
|
|
7
|
+
|
|
8
|
+
Pauses workflow execution at the current step until explicitly resumed. The workflow state is persisted and can be continued later.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
const approvalStep = new Step({
|
|
14
|
+
id: "needsApproval",
|
|
15
|
+
execute: async ({ context, suspend }) => {
|
|
16
|
+
if (context.steps.amount > 1000) {
|
|
17
|
+
await suspend();
|
|
18
|
+
}
|
|
19
|
+
return { approved: true };
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
<PropertiesTable
|
|
27
|
+
content={[
|
|
28
|
+
{
|
|
29
|
+
name: "metadata",
|
|
30
|
+
type: "Record<string, any>",
|
|
31
|
+
description: "Optional data to store with the suspended state",
|
|
32
|
+
isOptional: true
|
|
33
|
+
}
|
|
34
|
+
]}
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
## Returns
|
|
38
|
+
|
|
39
|
+
<PropertiesTable
|
|
40
|
+
content={[
|
|
41
|
+
{
|
|
42
|
+
name: "Promise<void>",
|
|
43
|
+
type: "Promise",
|
|
44
|
+
description: "Resolves when the workflow is successfully suspended"
|
|
45
|
+
}
|
|
46
|
+
]}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
## Additional Examples
|
|
50
|
+
|
|
51
|
+
Suspend with metadata:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const reviewStep = new Step({
|
|
55
|
+
id: "review",
|
|
56
|
+
execute: async ({ context, suspend }) => {
|
|
57
|
+
await suspend({
|
|
58
|
+
reason: "Needs manager approval",
|
|
59
|
+
requestedBy: context.user
|
|
60
|
+
});
|
|
61
|
+
return { reviewed: true };
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Related
|
|
67
|
+
|
|
68
|
+
- [Suspend & Resume Workflows](../../workflows/suspend-and-resume.mdx)
|
|
69
|
+
- [.resume()](./resume.mdx)
|
|
70
|
+
- [.watch()](./watch.mdx)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.then() | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.then()` method in workflows, which creates sequential dependencies between steps.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.then()
|
|
7
|
+
|
|
8
|
+
The `.then()` method creates a sequential dependency between workflow steps, ensuring steps execute in a specific order.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow
|
|
14
|
+
.step(stepOne)
|
|
15
|
+
.then(stepTwo)
|
|
16
|
+
.then(stepThree);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
<PropertiesTable
|
|
22
|
+
content={[
|
|
23
|
+
{
|
|
24
|
+
name: "step",
|
|
25
|
+
type: "Step | string",
|
|
26
|
+
description: "The step instance or step ID that should execute after the previous step completes",
|
|
27
|
+
isOptional: false
|
|
28
|
+
}
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
## Returns
|
|
33
|
+
|
|
34
|
+
<PropertiesTable
|
|
35
|
+
content={[
|
|
36
|
+
{
|
|
37
|
+
name: "workflow",
|
|
38
|
+
type: "Workflow",
|
|
39
|
+
description: "The workflow instance for method chaining"
|
|
40
|
+
}
|
|
41
|
+
]}
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
## Validation
|
|
45
|
+
|
|
46
|
+
When using `then`:
|
|
47
|
+
- The previous step must exist in the workflow
|
|
48
|
+
- Steps cannot form circular dependencies
|
|
49
|
+
- Each step can only appear once in a sequential chain
|
|
50
|
+
|
|
51
|
+
## Error Handling
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
try {
|
|
55
|
+
workflow
|
|
56
|
+
.step(stepA)
|
|
57
|
+
.then(stepB)
|
|
58
|
+
.then(stepA) // Will throw error - circular dependency
|
|
59
|
+
.commit();
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof ValidationError) {
|
|
62
|
+
console.log(error.type); // 'circular_dependency'
|
|
63
|
+
console.log(error.details);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Related
|
|
69
|
+
|
|
70
|
+
- [step Reference](./step-class.mdx)
|
|
71
|
+
- [after Reference](./after.mdx)
|
|
72
|
+
- [Sequential Steps Example](../../../examples/workflows/sequential-steps.mdx)
|
|
73
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx)
|
|
74
|
+
```
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.until() | Looping in Workflows | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `.until()` method in Mastra workflows, which repeats a step until a specified condition becomes true."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.until()
|
|
7
|
+
|
|
8
|
+
The `.until()` method repeats a step until a specified condition becomes true. This creates a loop that continues executing the specified step until the condition is satisfied.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow
|
|
14
|
+
.step(incrementStep)
|
|
15
|
+
.until(condition, incrementStep)
|
|
16
|
+
.then(finalStep);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
<PropertiesTable
|
|
22
|
+
content={[
|
|
23
|
+
{
|
|
24
|
+
name: "condition",
|
|
25
|
+
type: "Function | ReferenceCondition",
|
|
26
|
+
description: "A function or reference condition that determines when to stop looping",
|
|
27
|
+
isOptional: false
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "step",
|
|
31
|
+
type: "Step",
|
|
32
|
+
description: "The step to repeat until the condition is met",
|
|
33
|
+
isOptional: false
|
|
34
|
+
}
|
|
35
|
+
]}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
## Condition Types
|
|
39
|
+
|
|
40
|
+
### Function Condition
|
|
41
|
+
|
|
42
|
+
You can use a function that returns a boolean:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
workflow
|
|
46
|
+
.step(incrementStep)
|
|
47
|
+
.until(async ({ context }) => {
|
|
48
|
+
const result = context.getStepResult<{ value: number }>('increment');
|
|
49
|
+
return (result?.value ?? 0) >= 10; // Stop when value reaches or exceeds 10
|
|
50
|
+
}, incrementStep)
|
|
51
|
+
.then(finalStep);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Reference Condition
|
|
55
|
+
|
|
56
|
+
You can use a reference-based condition with comparison operators:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
workflow
|
|
60
|
+
.step(incrementStep)
|
|
61
|
+
.until(
|
|
62
|
+
{
|
|
63
|
+
ref: { step: incrementStep, path: 'value' },
|
|
64
|
+
query: { $gte: 10 }, // Stop when value is greater than or equal to 10
|
|
65
|
+
},
|
|
66
|
+
incrementStep
|
|
67
|
+
)
|
|
68
|
+
.then(finalStep);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Comparison Operators
|
|
72
|
+
|
|
73
|
+
When using reference-based conditions, you can use these comparison operators:
|
|
74
|
+
|
|
75
|
+
| Operator | Description | Example |
|
|
76
|
+
|----------|-------------|---------|
|
|
77
|
+
| `$eq` | Equal to | `{ $eq: 10 }` |
|
|
78
|
+
| `$ne` | Not equal to | `{ $ne: 0 }` |
|
|
79
|
+
| `$gt` | Greater than | `{ $gt: 5 }` |
|
|
80
|
+
| `$gte` | Greater than or equal to | `{ $gte: 10 }` |
|
|
81
|
+
| `$lt` | Less than | `{ $lt: 20 }` |
|
|
82
|
+
| `$lte` | Less than or equal to | `{ $lte: 15 }` |
|
|
83
|
+
|
|
84
|
+
## Returns
|
|
85
|
+
|
|
86
|
+
<PropertiesTable
|
|
87
|
+
content={[
|
|
88
|
+
{
|
|
89
|
+
name: "workflow",
|
|
90
|
+
type: "Workflow",
|
|
91
|
+
description: "The workflow instance for chaining"
|
|
92
|
+
}
|
|
93
|
+
]}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
## Example
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { Workflow, Step } from '@mastra/core';
|
|
100
|
+
import { z } from 'zod';
|
|
101
|
+
|
|
102
|
+
// Create a step that increments a counter
|
|
103
|
+
const incrementStep = new Step({
|
|
104
|
+
id: 'increment',
|
|
105
|
+
description: 'Increments the counter by 1',
|
|
106
|
+
outputSchema: z.object({
|
|
107
|
+
value: z.number(),
|
|
108
|
+
}),
|
|
109
|
+
execute: async ({ context }) => {
|
|
110
|
+
// Get current value from previous execution or start at 0
|
|
111
|
+
const currentValue =
|
|
112
|
+
context.getStepResult<{ value: number }>('increment')?.value ||
|
|
113
|
+
context.getStepResult<{ startValue: number }>('trigger')?.startValue ||
|
|
114
|
+
0;
|
|
115
|
+
|
|
116
|
+
// Increment the value
|
|
117
|
+
const value = currentValue + 1;
|
|
118
|
+
console.log(`Incrementing to ${value}`);
|
|
119
|
+
|
|
120
|
+
return { value };
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Create a final step
|
|
125
|
+
const finalStep = new Step({
|
|
126
|
+
id: 'final',
|
|
127
|
+
description: 'Final step after loop completes',
|
|
128
|
+
execute: async ({ context }) => {
|
|
129
|
+
const finalValue = context.getStepResult<{ value: number }>('increment')?.value;
|
|
130
|
+
console.log(`Loop completed with final value: ${finalValue}`);
|
|
131
|
+
return { finalValue };
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Create the workflow
|
|
136
|
+
const counterWorkflow = new Workflow({
|
|
137
|
+
name: 'counter-workflow',
|
|
138
|
+
triggerSchema: z.object({
|
|
139
|
+
startValue: z.number(),
|
|
140
|
+
targetValue: z.number(),
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Configure the workflow with an until loop
|
|
145
|
+
counterWorkflow
|
|
146
|
+
.step(incrementStep)
|
|
147
|
+
.until(async ({ context }) => {
|
|
148
|
+
const targetValue = context.triggerData.targetValue;
|
|
149
|
+
const currentValue = context.getStepResult<{ value: number }>('increment')?.value ?? 0;
|
|
150
|
+
return currentValue >= targetValue;
|
|
151
|
+
}, incrementStep)
|
|
152
|
+
.then(finalStep)
|
|
153
|
+
.commit();
|
|
154
|
+
|
|
155
|
+
// Execute the workflow
|
|
156
|
+
const run = counterWorkflow.createRun();
|
|
157
|
+
const result = await run.start({ triggerData: { startValue: 0, targetValue: 5 } });
|
|
158
|
+
// Will increment from 0 to 5, then stop and execute finalStep
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Related
|
|
162
|
+
|
|
163
|
+
- [.while()](./while.mdx) - Loop while a condition is true
|
|
164
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx#loop-control-with-until-and-while)
|
|
165
|
+
- [Workflow Class Reference](./workflow.mdx)
|