@mastra/mcp-docs-server 0.13.31 → 0.13.32-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +1 -0
  2. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +11 -11
  3. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +25 -25
  4. package/.docs/organized/changelogs/%40mastra%2Fastra.md +11 -11
  5. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
  6. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
  7. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +15 -15
  8. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +11 -11
  9. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
  10. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +23 -23
  11. package/.docs/organized/changelogs/%40mastra%2Fcore.md +122 -122
  12. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +10 -10
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +20 -20
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +19 -19
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +19 -19
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +19 -19
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +31 -31
  18. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +10 -10
  19. package/.docs/organized/changelogs/%40mastra%2Fevals.md +19 -19
  20. package/.docs/organized/changelogs/%40mastra%2Flance.md +10 -10
  21. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +23 -23
  22. package/.docs/organized/changelogs/%40mastra%2Floggers.md +10 -10
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +16 -16
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +14 -14
  26. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +10 -10
  27. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +10 -10
  28. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +11 -11
  29. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
  30. package/.docs/organized/changelogs/%40mastra%2Fpg.md +21 -21
  31. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +11 -11
  32. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +35 -35
  33. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +11 -11
  34. package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
  35. package/.docs/organized/changelogs/%40mastra%2Freact.md +20 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fserver.md +37 -37
  38. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +11 -11
  39. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +10 -10
  40. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +13 -13
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +10 -10
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +10 -10
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +10 -10
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +10 -10
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +9 -0
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +19 -19
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +10 -10
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +11 -11
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +10 -10
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +10 -10
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +10 -10
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
  54. package/.docs/organized/changelogs/create-mastra.md +11 -11
  55. package/.docs/organized/changelogs/mastra.md +26 -26
  56. package/.docs/organized/code-examples/agent.md +55 -1
  57. package/.docs/organized/code-examples/agui.md +2 -2
  58. package/.docs/organized/code-examples/ai-elements.md +2 -2
  59. package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
  60. package/.docs/organized/code-examples/ai-sdk-v5.md +2 -2
  61. package/.docs/organized/code-examples/assistant-ui.md +2 -2
  62. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
  63. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +2 -2
  64. package/.docs/organized/code-examples/client-side-tools.md +2 -2
  65. package/.docs/organized/code-examples/crypto-chatbot.md +2 -2
  66. package/.docs/organized/code-examples/heads-up-game.md +2 -2
  67. package/.docs/organized/code-examples/openapi-spec-writer.md +2 -2
  68. package/.docs/raw/agents/agent-memory.mdx +48 -31
  69. package/.docs/raw/agents/guardrails.mdx +8 -1
  70. package/.docs/raw/agents/networks.mdx +197 -128
  71. package/.docs/raw/agents/overview.mdx +10 -9
  72. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +92 -1
  73. package/.docs/raw/getting-started/installation.mdx +61 -68
  74. package/.docs/raw/memory/conversation-history.mdx +2 -2
  75. package/.docs/raw/memory/semantic-recall.mdx +36 -10
  76. package/.docs/raw/observability/ai-tracing/overview.mdx +220 -0
  77. package/.docs/raw/rag/chunking-and-embedding.mdx +19 -7
  78. package/.docs/raw/reference/cli/create-mastra.mdx +1 -1
  79. package/.docs/raw/reference/cli/mastra.mdx +1 -1
  80. package/.docs/raw/reference/client-js/agents.mdx +44 -25
  81. package/.docs/raw/reference/scorers/answer-relevancy.mdx +3 -6
  82. package/.docs/raw/reference/scorers/answer-similarity.mdx +7 -13
  83. package/.docs/raw/reference/scorers/bias.mdx +3 -6
  84. package/.docs/raw/reference/scorers/completeness.mdx +3 -6
  85. package/.docs/raw/reference/scorers/context-precision.mdx +6 -9
  86. package/.docs/raw/reference/scorers/context-relevance.mdx +12 -18
  87. package/.docs/raw/reference/scorers/faithfulness.mdx +3 -6
  88. package/.docs/raw/reference/scorers/hallucination.mdx +3 -6
  89. package/.docs/raw/reference/scorers/noise-sensitivity.mdx +13 -23
  90. package/.docs/raw/reference/scorers/prompt-alignment.mdx +16 -20
  91. package/.docs/raw/reference/scorers/tool-call-accuracy.mdx +4 -5
  92. package/.docs/raw/reference/scorers/toxicity.mdx +3 -6
  93. package/.docs/raw/reference/workflows/step.mdx +1 -1
  94. package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +23 -2
  95. package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +22 -4
  96. package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +14 -4
  97. package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +18 -1
  98. package/.docs/raw/server-db/runtime-context.mdx +13 -3
  99. package/.docs/raw/streaming/tool-streaming.mdx +30 -0
  100. package/.docs/raw/tools-mcp/overview.mdx +1 -1
  101. package/.docs/raw/workflows/overview.mdx +1 -1
  102. package/.docs/raw/workflows/suspend-and-resume.mdx +34 -23
  103. package/CHANGELOG.md +15 -0
  104. package/package.json +5 -5
  105. package/.docs/raw/workflows/pausing-execution.mdx +0 -142
@@ -5,7 +5,7 @@ description: "Suspend and resume in Mastra workflows allows you to pause executi
5
5
 
6
6
  # Suspend & Resume
7
7
 
8
- Workflows can be paused at any step, with their current state persisted as a snapshot in storage. Execution can then be resumed from this saved snapshot when ready. Persisting the snapshot ensures the workflow state is maintained across sessions, deployments, and server restarts, essential for workflows that may remain suspended while awaiting external input or resources.
8
+ Workflows can be paused at any step, with their current state persisted as a [snapshot](./snapshots.mdx) in storage. Execution can then be resumed from this saved snapshot when ready. Persisting the snapshot ensures the workflow state is maintained across sessions, deployments, and server restarts, essential for workflows that may remain suspended while awaiting external input or resources.
9
9
 
10
10
  Common scenarios for suspending workflows include:
11
11
 
@@ -215,6 +215,32 @@ const resumedResult = await run.resume({
215
215
  });
216
216
  ```
217
217
 
218
+ You can pass `runtimeContext` as an argument to both the `start` and `resume` commands.
219
+
220
+ ```typescript filename="src/mastra/workflows/test-workflow.ts"
221
+ import { RuntimeContext } from "@mastra/core/runtime-context";
222
+
223
+ const runtimeContext = new RuntimeContext();
224
+
225
+ const result = await run.start({
226
+ step: 'step-1',
227
+ inputData: {
228
+ city: "London"
229
+ },
230
+ runtimeContext
231
+ });
232
+
233
+ const resumedResult = await run.resume({
234
+ step: 'step-1',
235
+ resumeData: {
236
+ city: "New York"
237
+ },
238
+ runtimeContext
239
+ });
240
+ ```
241
+
242
+ > See [Runtime Context](../server-db/runtime-context.mdx) for more information.
243
+
218
244
  ### Resuming nested workflows
219
245
 
220
246
  To resume a suspended nested workflow pass the workflow instance to the `step` parameter of the `resume` function.
@@ -260,28 +286,13 @@ if (result.status === "suspended") {
260
286
  }
261
287
  ```
262
288
 
263
- ## Using `RuntimeContext` with suspend/resume
264
-
265
- When using suspend/resume with `RuntimeContext`, you can create the instance yourself, and pass it to the `start` and `resume` functions.
266
- `RuntimeContext` is not automatically shared on a workflow run.
267
-
268
- ```typescript {1,4,9,16} filename="src/mastra/workflows/test-workflow.tss" showLineNumbers copy
269
- import { RuntimeContext } from "@mastra/core/di";
270
- import { mastra } from "./mastra";
289
+ ## Sleep & Events
271
290
 
272
- const runtimeContext = new RuntimeContext();
273
- const run = await mastra.getWorkflow("testWorkflow").createRunAsync();
291
+ Workflows can also pause execution for timed delays or external events. These methods set the workflow status to `waiting` rather than `suspended`, and are useful for polling, delayed retries, or event-driven processes.
274
292
 
275
- const result = await run.start({
276
- inputData: { suggestions: ["London", "Paris", "New York"] },
277
- runtimeContext
278
- });
293
+ **Available methods:**
279
294
 
280
- if (result.status === "suspended") {
281
- const resumedResult = await run.resume({
282
- step: 'step-1',
283
- resumeData: { city: "New York" },
284
- runtimeContext
285
- });
286
- }
287
- ```
295
+ - [`.sleep()`](../../reference/workflows/workflow-methods/sleep.mdx): Pause for a specified number of milliseconds
296
+ - [`.sleepUntil()`](../../reference/workflows/workflow-methods/sleepUntil.mdx) : Pause until a specific date
297
+ - [`.waitForEvent()`](../../reference/workflows/workflow-methods/waitForEvent.mdx): Pause until an external event is received
298
+ - [`.sendEvent()`](../../reference/workflows/workflow-methods/sendEvent.mdx) : Send an event to resume a waiting workflow
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 0.13.32-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`efb5ed9`](https://github.com/mastra-ai/mastra/commit/efb5ed946ae7f410bc68c9430beb4b010afd25ec), [`8ea07b4`](https://github.com/mastra-ai/mastra/commit/8ea07b4bdc73e4218437dbb6dcb0f4b23e745a44), [`ba201b8`](https://github.com/mastra-ai/mastra/commit/ba201b8f8feac4c72350f2dbd52c13c7297ba7b0), [`4fc4136`](https://github.com/mastra-ai/mastra/commit/4fc413652866a8d2240694fddb2562e9edbb70df), [`b78e04d`](https://github.com/mastra-ai/mastra/commit/b78e04d935a16ecb1e59c5c96e564903527edddd), [`d10baf5`](https://github.com/mastra-ai/mastra/commit/d10baf5a3c924f2a6654e23a3e318ed03f189b76), [`038c55a`](https://github.com/mastra-ai/mastra/commit/038c55a7090fc1b1513a966386d3072617f836ac), [`182f045`](https://github.com/mastra-ai/mastra/commit/182f0458f25bd70aa774e64fd923c8a483eddbf1), [`7620d2b`](https://github.com/mastra-ai/mastra/commit/7620d2bddeb4fae4c3c0a0b4e672969795fca11a), [`b2365f0`](https://github.com/mastra-ai/mastra/commit/b2365f038dd4c5f06400428b224af963f399ad50), [`9029ba3`](https://github.com/mastra-ai/mastra/commit/9029ba34459c8859fed4c6b73efd8e2d0021e7ba), [`426cc56`](https://github.com/mastra-ai/mastra/commit/426cc561c85ae76a112ded2385532a91f9f9f074), [`00931fb`](https://github.com/mastra-ai/mastra/commit/00931fb1a21aa42c4fbc20c2c40dd62466b8fc8f), [`e473bfe`](https://github.com/mastra-ai/mastra/commit/e473bfe416c0b8e876973c2b6a6f13c394b7a93f), [`b78e04d`](https://github.com/mastra-ai/mastra/commit/b78e04d935a16ecb1e59c5c96e564903527edddd), [`648e2ca`](https://github.com/mastra-ai/mastra/commit/648e2ca42da54838c6ccbdaadc6fadd808fa6b86), [`b65c5e0`](https://github.com/mastra-ai/mastra/commit/b65c5e0fe6f3c390a9a8bbcf69304d972c3a4afb), [`7d35388`](https://github.com/mastra-ai/mastra/commit/7d35388b9bbb0adfd80658fefbe0b2ac3f7af6eb), [`10188d6`](https://github.com/mastra-ai/mastra/commit/10188d632a729010441f9c7e2a41eab60afccb23)]:
8
+ - @mastra/core@0.22.0-alpha.1
9
+ - @mastra/mcp@0.14.0-alpha.0
10
+
11
+ ## 0.13.32-alpha.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`c67ca32`](https://github.com/mastra-ai/mastra/commit/c67ca32e3c2cf69bfc146580770c720220ca44ac), [`dbc9e12`](https://github.com/mastra-ai/mastra/commit/dbc9e1216ba575ba59ead4afb727a01215f7de4f), [`99e41b9`](https://github.com/mastra-ai/mastra/commit/99e41b94957cdd25137d3ac12e94e8b21aa01b68), [`c28833c`](https://github.com/mastra-ai/mastra/commit/c28833c5b6d8e10eeffd7f7d39129d53b8bca240), [`f053e89`](https://github.com/mastra-ai/mastra/commit/f053e89160dbd0bd3333fc3492f68231b5c7c349), [`9a1a485`](https://github.com/mastra-ai/mastra/commit/9a1a4859b855e37239f652bf14b1ecd1029b8c4e), [`9257233`](https://github.com/mastra-ai/mastra/commit/9257233c4ffce09b2bedc2a9adbd70d7a83fa8e2), [`0f1a4c9`](https://github.com/mastra-ai/mastra/commit/0f1a4c984fb4b104b2f0b63ba18c9fa77f567700), [`2db6160`](https://github.com/mastra-ai/mastra/commit/2db6160e2022ff8827c15d30157e684683b934b5), [`8aeea37`](https://github.com/mastra-ai/mastra/commit/8aeea37efdde347c635a67fed56794943b7f74ec), [`02fe153`](https://github.com/mastra-ai/mastra/commit/02fe15351d6021d214da48ec982a0e9e4150bcee), [`74567b3`](https://github.com/mastra-ai/mastra/commit/74567b3d237ae3915cd0bca3cf55fa0a64e4e4a4), [`15a1733`](https://github.com/mastra-ai/mastra/commit/15a1733074cee8bd37370e1af34cd818e89fa7ac), [`fc2a774`](https://github.com/mastra-ai/mastra/commit/fc2a77468981aaddc3e77f83f0c4ad4a4af140da), [`4e08933`](https://github.com/mastra-ai/mastra/commit/4e08933625464dfde178347af5b6278fcf34188e)]:
16
+ - @mastra/core@0.21.2-alpha.0
17
+
3
18
  ## 0.13.31
4
19
 
5
20
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "0.13.31",
3
+ "version": "0.13.32-alpha.1",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,8 +33,8 @@
33
33
  "uuid": "^11.1.0",
34
34
  "zod": "^3.25.76",
35
35
  "zod-to-json-schema": "^3.24.6",
36
- "@mastra/core": "0.21.1",
37
- "@mastra/mcp": "^0.13.5"
36
+ "@mastra/core": "0.22.0-alpha.1",
37
+ "@mastra/mcp": "^0.14.0-alpha.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@hono/node-server": "^1.19.5",
@@ -43,14 +43,14 @@
43
43
  "@types/turndown": "^5.0.5",
44
44
  "@wong2/mcp-cli": "^1.10.0",
45
45
  "cross-env": "^10.1.0",
46
- "eslint": "^9.36.0",
46
+ "eslint": "^9.37.0",
47
47
  "hono": "^4.9.7",
48
48
  "tsup": "^8.5.0",
49
49
  "tsx": "^4.19.4",
50
50
  "typescript": "^5.8.3",
51
51
  "vitest": "^3.2.4",
52
52
  "@internal/lint": "0.0.50",
53
- "@mastra/core": "0.21.1"
53
+ "@mastra/core": "0.22.0-alpha.1"
54
54
  },
55
55
  "homepage": "https://mastra.ai",
56
56
  "repository": {
@@ -1,142 +0,0 @@
1
- ---
2
- title: "Pausing Execution | Mastra Docs"
3
- description: "Pausing execution in Mastra workflows allows you to pause execution while waiting for external input or resources via .sleep(), .sleepUntil() and .waitForEvent()."
4
- ---
5
-
6
- # Sleep & Events
7
-
8
- Mastra lets you pause workflow execution when waiting for external input or timing conditions. This can be useful for things like polling, delayed retries, or waiting on user actions.
9
-
10
- You can pause execution using:
11
-
12
- - `sleep()`: Pause for a set number of milliseconds
13
- - `sleepUntil()`: Pause until a specific timestamp
14
- - `waitForEvent()`: Pause until an external event is received
15
- - `sendEvent()`: Send an event to resume a waiting workflow
16
-
17
- When using any of these methods, the workflow status is set to `waiting` until execution resumes.
18
-
19
- ## Pausing with `.sleep()`
20
-
21
- The `sleep()` method pauses execution between steps for a specified number of milliseconds.
22
-
23
- ```typescript {9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
24
- import { createWorkflow, createStep } from "@mastra/core/workflows";
25
- import { z } from "zod";
26
-
27
- const step1 = createStep({...});
28
- const step2 = createStep({...});
29
-
30
- export const testWorkflow = createWorkflow({...})
31
- .then(step1)
32
- .sleep(1000)
33
- .then(step2)
34
- .commit();
35
- ```
36
-
37
- ### Pausing with `.sleep(callback)`
38
-
39
- The `sleep()` method also accepts a callback that returns the number of milliseconds to pause. The callback receives `inputData`, allowing the delay to be computed dynamically.
40
-
41
- ```typescript {9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
42
- import { createWorkflow, createStep } from "@mastra/core/workflows";
43
- import { z } from "zod";
44
-
45
- const step1 = createStep({...});
46
- const step2 = createStep({...});
47
-
48
- export const testWorkflow = createWorkflow({...})
49
- .then(step1)
50
- .sleep(async ({ inputData }) => {
51
- const { delayInMs } = inputData
52
- return delayInMs;
53
- })
54
- .then(step2)
55
- .commit();
56
- ```
57
-
58
- ## Pausing with `.sleepUntil()`
59
-
60
- The `sleepUntil()` method pauses execution between steps until a specified date.
61
-
62
- ```typescript {9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
63
- import { createWorkflow, createStep } from "@mastra/core/workflows";
64
- import { z } from "zod";
65
-
66
- const step1 = createStep({...});
67
- const step2 = createStep({...});
68
-
69
- export const testWorkflow = createWorkflow({...})
70
- .then(step1)
71
- .sleepUntil(new Date(Date.now() + 5000))
72
- .then(step2)
73
- .commit();
74
- ```
75
-
76
- ### Pausing with `.sleepUntil(callback)`
77
-
78
- The `sleepUntil()` method also accepts a callback that returns a `Date` object. The callback receives `inputData`, allowing the target time to be computed dynamically.
79
-
80
- ```typescript {9} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
81
- import { createWorkflow, createStep } from "@mastra/core/workflows";
82
- import { z } from "zod";
83
-
84
- const step1 = createStep({...});
85
- const step2 = createStep({...});
86
-
87
- export const testWorkflow = createWorkflow({...})
88
- .then(step1)
89
- .sleepUntil(async ({ inputData }) => {
90
- const { delayInMs } = inputData
91
- return new Date(Date.now() + delayInMs);
92
- })
93
- .then(step2)
94
- .commit();
95
- ```
96
-
97
-
98
- > `Date.now()` is evaluated when the workflow starts, not at the moment the `sleepUntil()` method is called.
99
-
100
- ## Pausing with `.waitForEvent()`
101
-
102
- The `waitForEvent()` method pauses execution until a specific event is received. Use `run.sendEvent()` to send the event. You must provide both the event name and the step to resume.
103
-
104
- ![Pausing with .waitForEvent()](/image/workflows/workflows-sleep-events-waitforevent.jpg)
105
-
106
- ```typescript {10} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
107
- import { createWorkflow, createStep } from "@mastra/core/workflows";
108
- import { z } from "zod";
109
-
110
- const step1 = createStep({...});
111
- const step2 = createStep({...});
112
- const step3 = createStep({...});
113
-
114
- export const testWorkflow = createWorkflow({...})
115
- .then(step1)
116
- .waitForEvent("my-event-name", step2)
117
- .then(step3)
118
- .commit();
119
- ```
120
- ## Sending an event with `.sendEvent()`
121
-
122
- The `.sendEvent()` method sends an event to the workflow. It accepts the event name and optional event data, which can be any JSON-serializable value.
123
-
124
- ```typescript {5,12,15} filename="src/test-workflow.ts" showLineNumbers copy
125
- import { mastra } from "./mastra";
126
-
127
- const run = await mastra.getWorkflow("testWorkflow").createRunAsync();
128
-
129
- const result = run.start({
130
- inputData: {
131
- value: "hello"
132
- }
133
- });
134
-
135
- setTimeout(() => {
136
- run.sendEvent("my-event-name", { value: "from event" });
137
- }, 3000);
138
-
139
- console.log(JSON.stringify(await result, null, 2));
140
- ```
141
-
142
- > In this example, avoid using `await run.start()` directly, it would block sending the event before the workflow reaches its waiting state.