@mastra/mcp-docs-server 0.13.11-alpha.0 → 0.13.11-alpha.2
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%2Fclient-js.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Flance.md +15 -12
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +23 -23
- package/.docs/organized/changelogs/create-mastra.md +13 -13
- package/.docs/organized/changelogs/mastra.md +34 -34
- package/.docs/organized/code-examples/a2a.md +52 -19
- package/.docs/organized/code-examples/weather-agent.md +14 -0
- package/.docs/raw/auth/jwt.mdx +3 -1
- package/.docs/raw/evals/overview.mdx +8 -0
- package/.docs/raw/getting-started/installation.mdx +45 -7
- package/.docs/raw/getting-started/mcp-docs-server.mdx +3 -3
- package/.docs/raw/memory/overview.mdx +11 -5
- package/.docs/raw/reference/agents/agent.mdx +6 -2
- package/.docs/raw/reference/agents/generate.mdx +48 -40
- package/.docs/raw/reference/agents/getAgent.mdx +10 -5
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +22 -17
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +22 -17
- package/.docs/raw/reference/agents/getDefaultVNextStreamOptions.mdx +22 -17
- package/.docs/raw/reference/agents/getDescription.mdx +9 -5
- package/.docs/raw/reference/agents/getInstructions.mdx +22 -17
- package/.docs/raw/reference/agents/getLLM.mdx +23 -18
- package/.docs/raw/reference/agents/getMemory.mdx +22 -17
- package/.docs/raw/reference/agents/getModel.mdx +22 -17
- package/.docs/raw/reference/agents/getScorers.mdx +22 -17
- package/.docs/raw/reference/agents/getTools.mdx +22 -17
- package/.docs/raw/reference/agents/getVoice.mdx +22 -17
- package/.docs/raw/reference/agents/getWorkflows.mdx +22 -17
- package/.docs/raw/reference/agents/stream.mdx +24 -19
- package/.docs/raw/reference/agents/streamVNext.mdx +18 -19
- package/.docs/raw/reference/cli/build.mdx +1 -0
- package/.docs/raw/reference/storage/upstash.mdx +5 -0
- package/.docs/raw/reference/tools/create-tool.mdx +22 -29
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +2 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +3 -3
- package/.docs/raw/reference/workflows/branch.mdx +6 -6
- package/.docs/raw/reference/workflows/commit.mdx +5 -5
- package/.docs/raw/reference/workflows/create-run.mdx +28 -29
- package/.docs/raw/reference/workflows/dountil.mdx +5 -5
- package/.docs/raw/reference/workflows/dowhile.mdx +5 -5
- package/.docs/raw/reference/workflows/execute.mdx +83 -91
- package/.docs/raw/reference/workflows/foreach.mdx +5 -5
- package/.docs/raw/reference/workflows/map.mdx +8 -93
- package/.docs/raw/reference/workflows/parallel.mdx +5 -5
- package/.docs/raw/reference/workflows/resume.mdx +45 -47
- package/.docs/raw/reference/workflows/sendEvent.mdx +5 -5
- package/.docs/raw/reference/workflows/sleep.mdx +5 -5
- package/.docs/raw/reference/workflows/sleepUntil.mdx +16 -8
- package/.docs/raw/reference/workflows/start.mdx +42 -27
- package/.docs/raw/reference/workflows/step.mdx +15 -29
- package/.docs/raw/reference/workflows/stream.mdx +55 -205
- package/.docs/raw/reference/workflows/streamVNext.mdx +55 -174
- package/.docs/raw/reference/workflows/then.mdx +5 -5
- package/.docs/raw/reference/workflows/waitForEvent.mdx +5 -5
- package/.docs/raw/reference/workflows/watch.mdx +31 -13
- package/.docs/raw/reference/workflows/workflow.mdx +27 -100
- package/.docs/raw/scorers/overview.mdx +8 -0
- package/.docs/raw/server-db/local-dev-playground.mdx +16 -1
- package/dist/tools/__tests__/test-setup.d.ts +1 -1
- package/dist/tools/__tests__/test-setup.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,45 +1,19 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.execute() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.execute() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.execute()` method in workflows, which executes a workflow directly and returns the output.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.execute()
|
|
7
7
|
|
|
8
|
-
The `.execute()` method executes a
|
|
8
|
+
The `.execute()` method executes a workflow directly and returns the output, allowing you to run a workflow without creating a separate run instance.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const myStep = createStep({
|
|
18
|
-
id: "my-step",
|
|
19
|
-
description: "Does something useful",
|
|
20
|
-
inputSchema,
|
|
21
|
-
outputSchema: z.object({
|
|
22
|
-
outputValue: z.string(),
|
|
23
|
-
}),
|
|
24
|
-
resumeSchema: z.object({
|
|
25
|
-
resumeValue: z.string(),
|
|
26
|
-
}),
|
|
27
|
-
suspendSchema: z.object({
|
|
28
|
-
suspendValue: z.string(),
|
|
29
|
-
}),
|
|
30
|
-
execute: async ({
|
|
31
|
-
inputData,
|
|
32
|
-
mastra,
|
|
33
|
-
getStepResult,
|
|
34
|
-
getInitData,
|
|
35
|
-
runtimeContext,
|
|
36
|
-
}) => {
|
|
37
|
-
const otherStepOutput = getStepResult(step2);
|
|
38
|
-
const initData = getInitData<typeof inputSchema>(); // typed as the input schema variable (zod schema)
|
|
39
|
-
return {
|
|
40
|
-
outputValue: `Processed: ${inputData.inputValue}, ${initData.startValue} (runtimeContextValue: ${runtimeContext.get("runtimeContextValue")})`,
|
|
41
|
-
};
|
|
42
|
-
},
|
|
12
|
+
```typescript showLineNumbers copy
|
|
13
|
+
await workflow.execute({
|
|
14
|
+
inputData: {
|
|
15
|
+
value: "hello world"
|
|
16
|
+
}
|
|
43
17
|
});
|
|
44
18
|
```
|
|
45
19
|
|
|
@@ -48,77 +22,93 @@ const myStep = createStep({
|
|
|
48
22
|
<PropertiesTable
|
|
49
23
|
content={[
|
|
50
24
|
{
|
|
51
|
-
name: "
|
|
52
|
-
type: "
|
|
53
|
-
description: "
|
|
25
|
+
name: "inputData",
|
|
26
|
+
type: "z.infer<TInput>",
|
|
27
|
+
description: "Input data that matches the workflow's input schema",
|
|
54
28
|
isOptional: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "resumeData",
|
|
32
|
+
type: "any",
|
|
33
|
+
description: "Data for resuming a suspended workflow",
|
|
34
|
+
isOptional: true,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "suspend",
|
|
38
|
+
type: "(suspendPayload: any) => Promise<any>",
|
|
39
|
+
description: "Function to suspend workflow execution",
|
|
40
|
+
isOptional: false,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "resume",
|
|
44
|
+
type: "object",
|
|
45
|
+
description: "Configuration for resuming workflow execution",
|
|
46
|
+
isOptional: true,
|
|
55
47
|
properties: [
|
|
56
48
|
{
|
|
57
|
-
name: "
|
|
58
|
-
type: "
|
|
59
|
-
description: "
|
|
49
|
+
name: "steps",
|
|
50
|
+
type: "string[]",
|
|
51
|
+
description: "Steps to resume",
|
|
60
52
|
isOptional: false,
|
|
61
53
|
},
|
|
62
54
|
{
|
|
63
|
-
name: "
|
|
64
|
-
type: "
|
|
65
|
-
description: "
|
|
66
|
-
isOptional: true,
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "suspend",
|
|
70
|
-
type: "(suspendPayload: any) => Promise<void>",
|
|
71
|
-
description: "Function to suspend step execution",
|
|
55
|
+
name: "resumePayload",
|
|
56
|
+
type: "any",
|
|
57
|
+
description: "Payload data for resuming",
|
|
72
58
|
isOptional: false,
|
|
73
59
|
},
|
|
74
60
|
{
|
|
75
|
-
name: "
|
|
76
|
-
type: "
|
|
77
|
-
description: "
|
|
61
|
+
name: "runId",
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "ID of the run to resume",
|
|
78
64
|
isOptional: true,
|
|
79
|
-
properties: [
|
|
80
|
-
{
|
|
81
|
-
name: "steps",
|
|
82
|
-
type: "string[]",
|
|
83
|
-
description: "Steps to resume",
|
|
84
|
-
isOptional: false,
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "resumePayload",
|
|
88
|
-
type: "any",
|
|
89
|
-
description: "Payload data for resuming",
|
|
90
|
-
isOptional: false,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "runId",
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "ID of the run to resume",
|
|
96
|
-
isOptional: true,
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: "emitter",
|
|
102
|
-
type: "object",
|
|
103
|
-
description: "Event emitter object",
|
|
104
|
-
isOptional: false,
|
|
105
|
-
properties: [
|
|
106
|
-
{
|
|
107
|
-
name: "emit",
|
|
108
|
-
type: "(event: string, data: any) => void",
|
|
109
|
-
description: "Function to emit events",
|
|
110
|
-
isOptional: false,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
65
|
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "emitter",
|
|
70
|
+
type: "object",
|
|
71
|
+
description: "Event emitter object for workflow events",
|
|
72
|
+
isOptional: false,
|
|
73
|
+
properties: [
|
|
114
74
|
{
|
|
115
|
-
name: "
|
|
116
|
-
type: "
|
|
117
|
-
description: "
|
|
75
|
+
name: "emit",
|
|
76
|
+
type: "(event: string, data: any) => void",
|
|
77
|
+
description: "Function to emit events",
|
|
118
78
|
isOptional: false,
|
|
119
79
|
},
|
|
120
80
|
],
|
|
121
81
|
},
|
|
82
|
+
{
|
|
83
|
+
name: "mastra",
|
|
84
|
+
type: "Mastra",
|
|
85
|
+
description: "Mastra instance",
|
|
86
|
+
isOptional: false,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "runtimeContext",
|
|
90
|
+
type: "RuntimeContext",
|
|
91
|
+
description: "Runtime context data to use during workflow execution",
|
|
92
|
+
isOptional: true,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "abort",
|
|
96
|
+
type: "() => any",
|
|
97
|
+
description: "Function to abort workflow execution",
|
|
98
|
+
isOptional: false,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "abortSignal",
|
|
102
|
+
type: "AbortSignal",
|
|
103
|
+
description: "Abort signal for workflow execution",
|
|
104
|
+
isOptional: false,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "runCount",
|
|
108
|
+
type: "number",
|
|
109
|
+
description: "Number of times the workflow has been run",
|
|
110
|
+
isOptional: true,
|
|
111
|
+
},
|
|
122
112
|
]}
|
|
123
113
|
/>
|
|
124
114
|
|
|
@@ -129,11 +119,13 @@ const myStep = createStep({
|
|
|
129
119
|
{
|
|
130
120
|
name: "result",
|
|
131
121
|
type: "Promise<z.infer<TOutput>>",
|
|
132
|
-
description: "A promise that resolves to the output of the executed
|
|
122
|
+
description: "A promise that resolves to the output of the executed workflow",
|
|
133
123
|
},
|
|
134
124
|
]}
|
|
135
125
|
/>
|
|
136
126
|
|
|
137
127
|
## Related
|
|
138
128
|
|
|
129
|
+
- [Workflow.createRunAsync()](./create-run.mdx) - Alternative method for creating workflow runs
|
|
130
|
+
- [WorkflowRun.start()](./start.mdx) - Starting workflow execution
|
|
139
131
|
- [Running workflows](../../docs/workflows/overview.mdx#running-workflows)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.foreach() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.foreach() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.foreach()` method in workflows, which creates a loop that executes a step for each item in an array.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.foreach()
|
|
7
7
|
|
|
8
8
|
The `.foreach()` method creates a loop that executes a step for each item in an array.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.foreach(
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.foreach(step1, { concurrency: 2 });
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -1,62 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.map() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.map() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.map()` method in workflows, which maps output data from a previous step to the input of a subsequent step.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.map()
|
|
7
7
|
|
|
8
8
|
The `.map()` method maps output data from a previous step to the input of a subsequent step, allowing you to transform data between steps.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
|
|
14
|
-
id: "step1",
|
|
15
|
-
inputSchema: z.object({
|
|
16
|
-
inputValue: z.string(),
|
|
17
|
-
}),
|
|
18
|
-
outputSchema: z.object({
|
|
19
|
-
outputValue: z.string(),
|
|
20
|
-
}),
|
|
21
|
-
execute: async ({ inputData }) => {
|
|
22
|
-
return { outputValue: inputData.inputValue };
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const step2 = createStep({
|
|
27
|
-
id: "step2",
|
|
28
|
-
inputSchema: z.object({
|
|
29
|
-
unexpectedName: z.string(),
|
|
30
|
-
}),
|
|
31
|
-
outputSchema: z.object({
|
|
32
|
-
result: z.string(),
|
|
33
|
-
}),
|
|
34
|
-
execute: async ({ inputData }) => {
|
|
35
|
-
return { result: inputData.unexpectedName };
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const workflow = createWorkflow({
|
|
40
|
-
id: "my-workflow",
|
|
41
|
-
steps: [step1, step2],
|
|
42
|
-
inputSchema: z.object({
|
|
43
|
-
inputValue: z.string(),
|
|
44
|
-
}),
|
|
45
|
-
outputSchema: z.object({
|
|
46
|
-
result: z.string(),
|
|
47
|
-
}),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
workflow
|
|
51
|
-
.then(step1)
|
|
52
|
-
.map({
|
|
53
|
-
unexpectedName: {
|
|
54
|
-
step: step1,
|
|
55
|
-
path: "outputValue",
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
.then(step2)
|
|
59
|
-
.commit();
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.map(async ({ inputData }) => `${inputData.value} - map`
|
|
60
14
|
```
|
|
61
15
|
|
|
62
16
|
## Parameters
|
|
@@ -64,49 +18,10 @@ workflow
|
|
|
64
18
|
<PropertiesTable
|
|
65
19
|
content={[
|
|
66
20
|
{
|
|
67
|
-
name: "
|
|
68
|
-
type: "
|
|
69
|
-
description:
|
|
70
|
-
"Configuration object that defines how data should be mapped between workflow steps, either as a mapping object or a mapping function",
|
|
21
|
+
name: "mappingFunction",
|
|
22
|
+
type: "(params: { inputData: any }) => any",
|
|
23
|
+
description: "Function that transforms input data and returns the mapped result",
|
|
71
24
|
isOptional: false,
|
|
72
|
-
properties: [
|
|
73
|
-
{
|
|
74
|
-
name: "step",
|
|
75
|
-
type: "Step | Step[]",
|
|
76
|
-
description: "The step(s) to map output from",
|
|
77
|
-
isOptional: true,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: "path",
|
|
81
|
-
type: "string",
|
|
82
|
-
description: "Path to the output value in the step result",
|
|
83
|
-
isOptional: true,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "value",
|
|
87
|
-
type: "any",
|
|
88
|
-
description: "Static value to map",
|
|
89
|
-
isOptional: true,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: "schema",
|
|
93
|
-
type: "ZodType",
|
|
94
|
-
description: "Schema for validating the mapped value",
|
|
95
|
-
isOptional: true,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: "initData",
|
|
99
|
-
type: "Step",
|
|
100
|
-
description: "Step containing initial workflow data to map from",
|
|
101
|
-
isOptional: true,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: "runtimeContextPath",
|
|
105
|
-
type: "string",
|
|
106
|
-
description: "Path to value in runtime context",
|
|
107
|
-
isOptional: true,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
25
|
},
|
|
111
26
|
]}
|
|
112
27
|
/>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.parallel() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.parallel() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.parallel()` method in workflows, which executes multiple steps in parallel.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.parallel()
|
|
7
7
|
|
|
8
8
|
The `.parallel()` method executes multiple steps in parallel.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.parallel([
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.parallel([step1, step2]);
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -1,65 +1,52 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference:
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: WorkflowRun.resume() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `WorkflowRun.resume()` method in workflows, which resumes a suspended workflow run with new data.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# WorkflowRun.resume()
|
|
7
7
|
|
|
8
8
|
The `.resume()` method resumes a suspended workflow run with new data, allowing you to continue execution from a specific step.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
const run = await
|
|
14
|
-
|
|
12
|
+
```typescript showLineNumbers copy
|
|
13
|
+
const run = await workflow.createRunAsync();
|
|
14
|
+
|
|
15
|
+
const result = await run.start({ inputData: { value: "initial data" } });
|
|
15
16
|
|
|
16
17
|
if (result.status === "suspended") {
|
|
17
18
|
const resumedResults = await run.resume({
|
|
18
|
-
resumeData: {
|
|
19
|
+
resumeData: { value: "resume data" }
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
```
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
For more advanced scenarios where you need to specify the exact step to resume:
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
await run.resume({
|
|
28
|
-
step: result.suspended[0], // Explicitly choose which step to resume
|
|
29
|
-
resumeData: { newValue: 0 },
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
> **Note**: When exactly one step is suspended, you can omit the `step` parameter and the workflow will automatically resume that step. For workflows with multiple suspended steps, you must explicitly specify which step to resume.
|
|
33
|
-
|
|
34
23
|
## Parameters
|
|
35
24
|
|
|
36
25
|
<PropertiesTable
|
|
37
26
|
content={[
|
|
38
27
|
{
|
|
39
|
-
name: "
|
|
40
|
-
type: "
|
|
41
|
-
description: "
|
|
42
|
-
isOptional:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
],
|
|
28
|
+
name: "resumeData",
|
|
29
|
+
type: "z.infer<TResumeSchema>",
|
|
30
|
+
description: "Data for resuming the suspended step",
|
|
31
|
+
isOptional: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "step",
|
|
35
|
+
type: "Step<string, any, any, TResumeSchema, any, TEngineType> | [...Step<string, any, any, any, any, TEngineType>[], Step<string, any, any, TResumeSchema, any, TEngineType>] | string | string[]",
|
|
36
|
+
description: "The step(s) to resume execution from. Can be a Step instance, array of Steps, step ID string, or array of step ID strings",
|
|
37
|
+
isOptional: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "runtimeContext",
|
|
41
|
+
type: "RuntimeContext",
|
|
42
|
+
description: "Runtime context data to use when resuming",
|
|
43
|
+
isOptional: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "runCount",
|
|
47
|
+
type: "number",
|
|
48
|
+
description: "Optional run count for nested workflow execution",
|
|
49
|
+
isOptional: true,
|
|
63
50
|
},
|
|
64
51
|
]}
|
|
65
52
|
/>
|
|
@@ -69,14 +56,25 @@ await run.resume({
|
|
|
69
56
|
<PropertiesTable
|
|
70
57
|
content={[
|
|
71
58
|
{
|
|
72
|
-
name: "
|
|
59
|
+
name: "result",
|
|
73
60
|
type: "Promise<WorkflowResult<TOutput, TSteps>>",
|
|
74
|
-
description:
|
|
75
|
-
"A promise that resolves to the result of the resumed workflow run",
|
|
61
|
+
description: "A promise that resolves to the workflow execution result containing step outputs and status",
|
|
76
62
|
},
|
|
77
63
|
]}
|
|
78
64
|
/>
|
|
79
65
|
|
|
66
|
+
## Extended usage example
|
|
67
|
+
|
|
68
|
+
```typescript showLineNumbers copy
|
|
69
|
+
if (result.status === "suspended") {
|
|
70
|
+
const resumedResults = await run.resume({
|
|
71
|
+
step: result.suspended[0],
|
|
72
|
+
resumeData: { value: "resume data" }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
> **Note**: When exactly one step is suspended, you can omit the `step` parameter and the workflow will automatically resume that step. For workflows with multiple suspended steps, you must explicitly specify which step to resume.
|
|
77
|
+
|
|
80
78
|
## Related
|
|
81
79
|
|
|
82
80
|
- [Suspend and resume](../../docs/workflows/suspend-and-resume.mdx)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.sendEvent() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.sendEvent() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.sendEvent()` method in workflows, which resumes execution when an event is sent.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.sendEvent()
|
|
7
7
|
|
|
8
8
|
The `.sendEvent()` resumes execution when an event is sent.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.sendEvent('
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.sendEvent('event-name', step1);
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.sleep() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.sleep() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.sleep()` method in workflows, which pauses execution for a specified number of milliseconds.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.sleep()
|
|
7
7
|
|
|
8
8
|
The `.sleep()` method pauses execution for a specified number of milliseconds.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.sleep(
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.sleep(5000);
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.sleepUntil() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.sleepUntil() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.sleepUntil()` method in workflows, which pauses execution until a specified date.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.sleepUntil()
|
|
7
7
|
|
|
8
8
|
The `.sleepUntil()` method pauses execution until a specified date.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.sleepUntil(new Date(Date.now() +
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.sleepUntil(new Date(Date.now() + 5000));
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -18,9 +18,9 @@ workflow.sleepUntil(new Date(Date.now() + 1000));
|
|
|
18
18
|
<PropertiesTable
|
|
19
19
|
content={[
|
|
20
20
|
{
|
|
21
|
-
name: "
|
|
22
|
-
type: "Date",
|
|
23
|
-
description: "The
|
|
21
|
+
name: "dateOrCallback",
|
|
22
|
+
type: "Date | ((params: ExecuteFunctionParams) => Promise<Date>)",
|
|
23
|
+
description: "Either a Date object or a callback function that returns a Date. The callback receives execution context and can compute the target time dynamically based on input data.",
|
|
24
24
|
isOptional: false,
|
|
25
25
|
},
|
|
26
26
|
]}
|
|
@@ -38,6 +38,14 @@ workflow.sleepUntil(new Date(Date.now() + 1000));
|
|
|
38
38
|
]}
|
|
39
39
|
/>
|
|
40
40
|
|
|
41
|
+
## Extended usage example
|
|
42
|
+
|
|
43
|
+
```typescript showLineNumbers copy
|
|
44
|
+
workflow.sleepUntil(async ({ inputData }) => {
|
|
45
|
+
return new Date(Date.now() + inputData.value);
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
41
49
|
## Related
|
|
42
50
|
|
|
43
51
|
- [Sleep & Events](../../docs/workflows/pausing-execution.mdx)
|