@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,305 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Event-Driven Workflows | Mastra Docs"
|
|
3
|
+
description: "Learn how to create event-driven workflows using afterEvent and resumeWithEvent methods in Mastra."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Event-Driven Workflows
|
|
7
|
+
|
|
8
|
+
Mastra provides built-in support for event-driven workflows through the `afterEvent` and `resumeWithEvent` methods. These methods allow you to create workflows that pause execution while waiting for specific events to occur, then resume with the event data when it's available.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Event-driven workflows are useful for scenarios where:
|
|
13
|
+
|
|
14
|
+
- You need to wait for external systems to complete processing
|
|
15
|
+
- User approval or input is required at specific points
|
|
16
|
+
- Asynchronous operations need to be coordinated
|
|
17
|
+
- Long-running processes need to break up execution across different services
|
|
18
|
+
|
|
19
|
+
## Defining Events
|
|
20
|
+
|
|
21
|
+
Before using event-driven methods, you must define the events your workflow will listen for in the workflow configuration:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Workflow } from '@mastra/core/workflows';
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
|
|
27
|
+
const workflow = new Workflow({
|
|
28
|
+
name: 'approval-workflow',
|
|
29
|
+
triggerSchema: z.object({ requestId: z.string() }),
|
|
30
|
+
events: {
|
|
31
|
+
// Define events with their validation schemas
|
|
32
|
+
approvalReceived: {
|
|
33
|
+
schema: z.object({
|
|
34
|
+
approved: z.boolean(),
|
|
35
|
+
approverName: z.string(),
|
|
36
|
+
comment: z.string().optional(),
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
documentUploaded: {
|
|
40
|
+
schema: z.object({
|
|
41
|
+
documentId: z.string(),
|
|
42
|
+
documentType: z.enum(['invoice', 'receipt', 'contract']),
|
|
43
|
+
metadata: z.record(z.string()).optional(),
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Each event must have a name and a schema that defines the structure of data expected when the event occurs.
|
|
51
|
+
|
|
52
|
+
## afterEvent()
|
|
53
|
+
|
|
54
|
+
The `afterEvent` method creates a suspension point in your workflow that automatically waits for a specific event.
|
|
55
|
+
|
|
56
|
+
### Syntax
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
workflow.afterEvent(eventName: string): Workflow
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Parameters
|
|
63
|
+
|
|
64
|
+
- `eventName`: The name of the event to wait for (must be defined in the workflow's `events` configuration)
|
|
65
|
+
|
|
66
|
+
### Return Value
|
|
67
|
+
|
|
68
|
+
Returns the workflow instance for method chaining.
|
|
69
|
+
|
|
70
|
+
### How It Works
|
|
71
|
+
|
|
72
|
+
When `afterEvent` is called, Mastra:
|
|
73
|
+
|
|
74
|
+
1. Creates a special step with ID `__eventName_event`
|
|
75
|
+
2. Configures this step to automatically suspend workflow execution
|
|
76
|
+
3. Sets up the continuation point after the event is received
|
|
77
|
+
|
|
78
|
+
### Usage Example
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
workflow
|
|
82
|
+
.step(initialProcessStep)
|
|
83
|
+
.afterEvent('approvalReceived') // Workflow suspends here
|
|
84
|
+
.step(postApprovalStep) // This runs after event is received
|
|
85
|
+
.then(finalStep)
|
|
86
|
+
.commit();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## resumeWithEvent()
|
|
90
|
+
|
|
91
|
+
The `resumeWithEvent` method resumes a suspended workflow by providing data for a specific event.
|
|
92
|
+
|
|
93
|
+
### Syntax
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
run.resumeWithEvent(eventName: string, data: any): Promise<WorkflowRunResult>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Parameters
|
|
100
|
+
|
|
101
|
+
- `eventName`: The name of the event being triggered
|
|
102
|
+
- `data`: The event data (must conform to the schema defined for this event)
|
|
103
|
+
|
|
104
|
+
### Return Value
|
|
105
|
+
|
|
106
|
+
Returns a Promise that resolves to the workflow execution results after resumption.
|
|
107
|
+
|
|
108
|
+
### How It Works
|
|
109
|
+
|
|
110
|
+
When `resumeWithEvent` is called, Mastra:
|
|
111
|
+
|
|
112
|
+
1. Validates the event data against the schema defined for that event
|
|
113
|
+
2. Loads the workflow snapshot
|
|
114
|
+
3. Updates the context with the event data
|
|
115
|
+
4. Resumes execution from the event step
|
|
116
|
+
5. Continues workflow execution with the subsequent steps
|
|
117
|
+
|
|
118
|
+
### Usage Example
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Create a workflow run
|
|
122
|
+
const run = workflow.createRun();
|
|
123
|
+
|
|
124
|
+
// Start the workflow
|
|
125
|
+
await run.start({ triggerData: { requestId: 'req-123' } });
|
|
126
|
+
|
|
127
|
+
// Later, when the event occurs:
|
|
128
|
+
const result = await run.resumeWithEvent('approvalReceived', {
|
|
129
|
+
approved: true,
|
|
130
|
+
approverName: 'John Doe',
|
|
131
|
+
comment: 'Looks good to me!'
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
console.log(result.results);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Accessing Event Data
|
|
138
|
+
|
|
139
|
+
When a workflow is resumed with event data, that data is available in the step context as `context.inputData.resumedEvent`:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const processApprovalStep = new Step({
|
|
143
|
+
id: 'processApproval',
|
|
144
|
+
execute: async ({ context }) => {
|
|
145
|
+
// Access the event data
|
|
146
|
+
const eventData = context.inputData.resumedEvent;
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
processingResult: `Processed approval from ${eventData.approverName}`,
|
|
150
|
+
wasApproved: eventData.approved,
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Multiple Events
|
|
157
|
+
|
|
158
|
+
You can create workflows that wait for multiple different events at various points:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
workflow
|
|
162
|
+
.step(createRequest)
|
|
163
|
+
.afterEvent('approvalReceived')
|
|
164
|
+
.step(processApproval)
|
|
165
|
+
.afterEvent('documentUploaded')
|
|
166
|
+
.step(processDocument)
|
|
167
|
+
.commit();
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
When resuming a workflow with multiple event suspension points, you need to provide the correct event name and data for the current suspension point.
|
|
171
|
+
|
|
172
|
+
## Practical Example
|
|
173
|
+
|
|
174
|
+
This example shows a complete workflow that requires both approval and document upload:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { Workflow, Step } from '@mastra/core/workflows';
|
|
178
|
+
import { z } from 'zod';
|
|
179
|
+
|
|
180
|
+
// Define steps
|
|
181
|
+
const createRequest = new Step({
|
|
182
|
+
id: 'createRequest',
|
|
183
|
+
execute: async () => ({ requestId: `req-${Date.now()}` }),
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const processApproval = new Step({
|
|
187
|
+
id: 'processApproval',
|
|
188
|
+
execute: async ({ context }) => {
|
|
189
|
+
const approvalData = context.inputData.resumedEvent;
|
|
190
|
+
return {
|
|
191
|
+
approved: approvalData.approved,
|
|
192
|
+
approver: approvalData.approverName,
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const processDocument = new Step({
|
|
198
|
+
id: 'processDocument',
|
|
199
|
+
execute: async ({ context }) => {
|
|
200
|
+
const documentData = context.inputData.resumedEvent;
|
|
201
|
+
return {
|
|
202
|
+
documentId: documentData.documentId,
|
|
203
|
+
processed: true,
|
|
204
|
+
type: documentData.documentType,
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const finalizeRequest = new Step({
|
|
210
|
+
id: 'finalizeRequest',
|
|
211
|
+
execute: async ({ context }) => {
|
|
212
|
+
const requestId = context.steps.createRequest.output.requestId;
|
|
213
|
+
const approved = context.steps.processApproval.output.approved;
|
|
214
|
+
const documentId = context.steps.processDocument.output.documentId;
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
finalized: true,
|
|
218
|
+
summary: `Request ${requestId} was ${approved ? 'approved' : 'rejected'} with document ${documentId}`
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Create workflow
|
|
224
|
+
const requestWorkflow = new Workflow({
|
|
225
|
+
name: 'document-request-workflow',
|
|
226
|
+
events: {
|
|
227
|
+
approvalReceived: {
|
|
228
|
+
schema: z.object({
|
|
229
|
+
approved: z.boolean(),
|
|
230
|
+
approverName: z.string(),
|
|
231
|
+
}),
|
|
232
|
+
},
|
|
233
|
+
documentUploaded: {
|
|
234
|
+
schema: z.object({
|
|
235
|
+
documentId: z.string(),
|
|
236
|
+
documentType: z.enum(['invoice', 'receipt', 'contract']),
|
|
237
|
+
}),
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Build workflow
|
|
243
|
+
requestWorkflow
|
|
244
|
+
.step(createRequest)
|
|
245
|
+
.afterEvent('approvalReceived')
|
|
246
|
+
.step(processApproval)
|
|
247
|
+
.afterEvent('documentUploaded')
|
|
248
|
+
.step(processDocument)
|
|
249
|
+
.then(finalizeRequest)
|
|
250
|
+
.commit();
|
|
251
|
+
|
|
252
|
+
// Export workflow
|
|
253
|
+
export { requestWorkflow };
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Running the Example Workflow
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import { requestWorkflow } from './workflows';
|
|
260
|
+
import { mastra } from './mastra';
|
|
261
|
+
|
|
262
|
+
async function runWorkflow() {
|
|
263
|
+
// Get the workflow
|
|
264
|
+
const workflow = mastra.getWorkflow('document-request-workflow');
|
|
265
|
+
const run = workflow.createRun();
|
|
266
|
+
|
|
267
|
+
// Start the workflow
|
|
268
|
+
const initialResult = await run.start();
|
|
269
|
+
console.log('Workflow started:', initialResult.results);
|
|
270
|
+
|
|
271
|
+
// Simulate receiving approval
|
|
272
|
+
const afterApprovalResult = await run.resumeWithEvent('approvalReceived', {
|
|
273
|
+
approved: true,
|
|
274
|
+
approverName: 'Jane Smith',
|
|
275
|
+
});
|
|
276
|
+
console.log('After approval:', afterApprovalResult.results);
|
|
277
|
+
|
|
278
|
+
// Simulate document upload
|
|
279
|
+
const finalResult = await run.resumeWithEvent('documentUploaded', {
|
|
280
|
+
documentId: 'doc-456',
|
|
281
|
+
documentType: 'invoice',
|
|
282
|
+
});
|
|
283
|
+
console.log('Final result:', finalResult.results);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
runWorkflow().catch(console.error);
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Best Practices
|
|
290
|
+
|
|
291
|
+
1. **Define Clear Event Schemas**: Use Zod to create precise schemas for event data validation
|
|
292
|
+
2. **Use Descriptive Event Names**: Choose event names that clearly communicate their purpose
|
|
293
|
+
3. **Handle Missing Events**: Ensure your workflow can handle cases where events don't occur or time out
|
|
294
|
+
4. **Include Monitoring**: Use the `watch` method to monitor suspended workflows waiting for events
|
|
295
|
+
5. **Consider Timeouts**: Implement timeout mechanisms for events that may never occur
|
|
296
|
+
6. **Document Events**: Clearly document the events your workflow depends on for other developers
|
|
297
|
+
|
|
298
|
+
## Related
|
|
299
|
+
|
|
300
|
+
- [Suspend and Resume in Workflows](../../workflows/suspend-and-resume.mdx)
|
|
301
|
+
- [Workflow Class Reference](./workflow.mdx)
|
|
302
|
+
- [Resume Method Reference](./resume.mdx)
|
|
303
|
+
- [Watch Method Reference](./watch.mdx)
|
|
304
|
+
- [After Event Reference](./afterEvent.mdx)
|
|
305
|
+
- [Resume With Event Reference](./resumeWithEvent.mdx)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.execute() | Workflows | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `.execute()` method in Mastra workflows, which runs workflow steps and returns results."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.execute()
|
|
7
|
+
|
|
8
|
+
Executes a workflow with the provided trigger data and returns the results. The workflow must be committed before execution.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
const workflow = new Workflow({
|
|
14
|
+
name: "my-workflow",
|
|
15
|
+
triggerSchema: z.object({
|
|
16
|
+
inputValue: z.number()
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
workflow.step(stepOne).then(stepTwo).commit();
|
|
21
|
+
|
|
22
|
+
const result = await workflow.execute({
|
|
23
|
+
triggerData: { inputValue: 42 }
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
<PropertiesTable
|
|
30
|
+
content={[
|
|
31
|
+
{
|
|
32
|
+
name: "options",
|
|
33
|
+
type: "ExecuteOptions",
|
|
34
|
+
description: "Options for workflow execution",
|
|
35
|
+
isOptional: true,
|
|
36
|
+
properties: [
|
|
37
|
+
{
|
|
38
|
+
name: "triggerData",
|
|
39
|
+
type: "TriggerSchema",
|
|
40
|
+
description: "Input data matching the workflow's trigger schema",
|
|
41
|
+
isOptional: false
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "runId",
|
|
45
|
+
type: "string",
|
|
46
|
+
description: "Optional ID to track this execution run",
|
|
47
|
+
isOptional: true
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
## Returns
|
|
55
|
+
|
|
56
|
+
<PropertiesTable
|
|
57
|
+
content={[
|
|
58
|
+
{
|
|
59
|
+
name: "WorkflowResult",
|
|
60
|
+
type: "object",
|
|
61
|
+
description: "Results from workflow execution",
|
|
62
|
+
properties: [
|
|
63
|
+
{
|
|
64
|
+
name: "runId",
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "Unique identifier for this execution run"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "results",
|
|
70
|
+
type: "Record<string, StepResult>",
|
|
71
|
+
description: "Results from each completed step"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "status",
|
|
75
|
+
type: "WorkflowStatus",
|
|
76
|
+
description: "Final status of the workflow run"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]}
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
## Additional Examples
|
|
84
|
+
|
|
85
|
+
Execute with run ID:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const result = await workflow.execute({
|
|
89
|
+
runId: "custom-run-id",
|
|
90
|
+
triggerData: { inputValue: 42 }
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Handle execution results:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const { runId, results, status } = await workflow.execute({
|
|
98
|
+
triggerData: { inputValue: 42 }
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (status === "COMPLETED") {
|
|
102
|
+
console.log("Step results:", results);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Related
|
|
107
|
+
|
|
108
|
+
- [Workflow.createRun()](./createRun.mdx)
|
|
109
|
+
- [Workflow.commit()](./commit.mdx)
|
|
110
|
+
- [Workflow.start()](./start.mdx)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.if() | Conditional Branching | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `.if()` method in Mastra workflows, which creates conditional branches based on specified conditions."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.if()
|
|
7
|
+
|
|
8
|
+
> Experimental
|
|
9
|
+
|
|
10
|
+
The `.if()` method creates a conditional branch in the workflow, allowing steps to execute only when a specified condition is true. This enables dynamic workflow paths based on the results of previous steps.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript copy showLineNumbers
|
|
15
|
+
workflow
|
|
16
|
+
.step(startStep)
|
|
17
|
+
.if(async ({ context }) => {
|
|
18
|
+
const value = context.getStepResult<{ value: number }>('start')?.value;
|
|
19
|
+
return value < 10; // If true, execute the "if" branch
|
|
20
|
+
})
|
|
21
|
+
.then(ifBranchStep)
|
|
22
|
+
.else()
|
|
23
|
+
.then(elseBranchStep)
|
|
24
|
+
.commit();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
<PropertiesTable
|
|
30
|
+
content={[
|
|
31
|
+
{
|
|
32
|
+
name: "condition",
|
|
33
|
+
type: "Function | ReferenceCondition",
|
|
34
|
+
description: "A function or reference condition that determines whether to execute the 'if' branch",
|
|
35
|
+
isOptional: false
|
|
36
|
+
}
|
|
37
|
+
]}
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
## Condition Types
|
|
41
|
+
|
|
42
|
+
### Function Condition
|
|
43
|
+
|
|
44
|
+
You can use a function that returns a boolean:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
workflow
|
|
48
|
+
.step(startStep)
|
|
49
|
+
.if(async ({ context }) => {
|
|
50
|
+
const result = context.getStepResult<{ status: string }>('start');
|
|
51
|
+
return result?.status === 'success'; // Execute "if" branch when status is "success"
|
|
52
|
+
})
|
|
53
|
+
.then(successStep)
|
|
54
|
+
.else()
|
|
55
|
+
.then(failureStep);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Reference Condition
|
|
59
|
+
|
|
60
|
+
You can use a reference-based condition with comparison operators:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
workflow
|
|
64
|
+
.step(startStep)
|
|
65
|
+
.if({
|
|
66
|
+
ref: { step: startStep, path: 'value' },
|
|
67
|
+
query: { $lt: 10 }, // Execute "if" branch when value is less than 10
|
|
68
|
+
})
|
|
69
|
+
.then(ifBranchStep)
|
|
70
|
+
.else()
|
|
71
|
+
.then(elseBranchStep);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Returns
|
|
75
|
+
|
|
76
|
+
<PropertiesTable
|
|
77
|
+
content={[
|
|
78
|
+
{
|
|
79
|
+
name: "workflow",
|
|
80
|
+
type: "Workflow",
|
|
81
|
+
description: "The workflow instance for method chaining"
|
|
82
|
+
}
|
|
83
|
+
]}
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
## Error Handling
|
|
87
|
+
|
|
88
|
+
The `if` method requires a previous step to be defined. If you try to use it without a preceding step, an error will be thrown:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
try {
|
|
92
|
+
// This will throw an error
|
|
93
|
+
workflow
|
|
94
|
+
.if(async ({ context }) => true)
|
|
95
|
+
.then(someStep)
|
|
96
|
+
.commit();
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error(error); // "Condition requires a step to be executed after"
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Related
|
|
103
|
+
|
|
104
|
+
- [else Reference](./else.mdx)
|
|
105
|
+
- [then Reference](./then.mdx)
|
|
106
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx)
|
|
107
|
+
- [Step Condition Reference](./step-condition.mdx)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: run.resume() | Running Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.resume()` method in workflows, which continues execution of a suspended workflow step.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# run.resume()
|
|
7
|
+
|
|
8
|
+
The `.resume()` method continues execution of a suspended workflow step, optionally providing new context data that can be accessed by the step on the inputData property.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript copy showLineNumbers
|
|
13
|
+
await run.resume({
|
|
14
|
+
runId: "abc-123",
|
|
15
|
+
stepId: "stepTwo",
|
|
16
|
+
context: {
|
|
17
|
+
secondValue: 100
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Parameters
|
|
23
|
+
|
|
24
|
+
<PropertiesTable
|
|
25
|
+
content={[
|
|
26
|
+
{
|
|
27
|
+
name: "config",
|
|
28
|
+
type: "object",
|
|
29
|
+
description: "Configuration for resuming the workflow",
|
|
30
|
+
isOptional: false
|
|
31
|
+
}
|
|
32
|
+
]}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
### config
|
|
36
|
+
|
|
37
|
+
<PropertiesTable
|
|
38
|
+
content={[
|
|
39
|
+
{
|
|
40
|
+
name: "runId",
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Unique identifier of the workflow run to resume",
|
|
43
|
+
isOptional: false
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "stepId",
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "ID of the suspended step to resume",
|
|
49
|
+
isOptional: false
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "context",
|
|
53
|
+
type: "Record<string, any>",
|
|
54
|
+
description: "New context data to inject into the step's inputData property",
|
|
55
|
+
isOptional: true
|
|
56
|
+
}
|
|
57
|
+
]}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
## Returns
|
|
61
|
+
|
|
62
|
+
<PropertiesTable
|
|
63
|
+
content={[
|
|
64
|
+
{
|
|
65
|
+
name: "Promise<WorkflowResult>",
|
|
66
|
+
type: "object",
|
|
67
|
+
description: "Result of the resumed workflow execution"
|
|
68
|
+
}
|
|
69
|
+
]}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
## Async/Await Flow
|
|
73
|
+
|
|
74
|
+
When a workflow is resumed, execution continues from the point immediately after the `suspend()` call in the step's execution function. This creates a natural flow in your code:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Step definition with suspend point
|
|
78
|
+
const reviewStep = new Step({
|
|
79
|
+
id: "review",
|
|
80
|
+
execute: async ({ context, suspend }) => {
|
|
81
|
+
// First part of execution
|
|
82
|
+
const initialAnalysis = analyzeData(context.inputData.data);
|
|
83
|
+
|
|
84
|
+
if (initialAnalysis.needsReview) {
|
|
85
|
+
// Suspend execution here
|
|
86
|
+
await suspend({ analysis: initialAnalysis });
|
|
87
|
+
|
|
88
|
+
// This code runs after resume() is called
|
|
89
|
+
// context.inputData now contains any data provided during resume
|
|
90
|
+
return {
|
|
91
|
+
reviewedData: enhanceWithFeedback(initialAnalysis, context.inputData.feedback)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { reviewedData: initialAnalysis };
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const { runId, resume, start } = workflow.createRun();
|
|
100
|
+
|
|
101
|
+
await start({
|
|
102
|
+
inputData: {
|
|
103
|
+
data: "some data"
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Later, resume the workflow
|
|
108
|
+
const result = await resume({
|
|
109
|
+
runId: "workflow-123",
|
|
110
|
+
stepId: "review",
|
|
111
|
+
context: {
|
|
112
|
+
// This data will be available in `context.inputData`
|
|
113
|
+
feedback: "Looks good, but improve section 3"
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Execution Flow
|
|
119
|
+
|
|
120
|
+
1. The workflow runs until it hits `await suspend()` in the `review` step
|
|
121
|
+
2. The workflow state is persisted and execution pauses
|
|
122
|
+
3. Later, `run.resume()` is called with new context data
|
|
123
|
+
4. Execution continues from the point after `suspend()` in the `review` step
|
|
124
|
+
5. The new context data (`feedback`) is available to the step on the `inputData` property
|
|
125
|
+
6. The step completes and returns its result
|
|
126
|
+
7. The workflow continues with subsequent steps
|
|
127
|
+
|
|
128
|
+
## Error Handling
|
|
129
|
+
|
|
130
|
+
The resume function may throw several types of errors:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
try {
|
|
134
|
+
await run.resume({
|
|
135
|
+
runId,
|
|
136
|
+
stepId: "stepTwo",
|
|
137
|
+
context: newData
|
|
138
|
+
});
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (error.message === "No snapshot found for workflow run") {
|
|
141
|
+
// Handle missing workflow state
|
|
142
|
+
}
|
|
143
|
+
if (error.message === "Failed to parse workflow snapshot") {
|
|
144
|
+
// Handle corrupted workflow state
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Related
|
|
150
|
+
|
|
151
|
+
- [Suspend and Resume](../../workflows/suspend-and-resume.mdx)
|
|
152
|
+
- [`suspend` Reference](./suspend.mdx)
|
|
153
|
+
- [`watch` Reference](./watch.mdx)
|
|
154
|
+
- [Workflow Class Reference](./workflow.mdx)
|
|
155
|
+
```
|