@mastra/mcp-docs-server 0.13.11-alpha.1 → 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 +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +21 -21
- 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 +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +14 -14
- 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 +15 -15
- package/.docs/organized/changelogs/create-mastra.md +11 -11
- package/.docs/organized/changelogs/mastra.md +24 -24
- 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/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 +5 -5
|
@@ -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)
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference:
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: WorkflowRun.start() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `WorkflowRun.start()` method in workflows, which starts a workflow run with input data.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# WorkflowRun.start()
|
|
7
7
|
|
|
8
8
|
The `.start()` method starts a workflow run with input data, allowing you to execute the workflow from the beginning.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
const run = await
|
|
12
|
+
```typescript showLineNumbers copy
|
|
13
|
+
const run = await workflow.createRunAsync();
|
|
14
14
|
|
|
15
|
-
// Start the workflow with input data
|
|
16
15
|
const result = await run.start({
|
|
17
16
|
inputData: {
|
|
18
|
-
|
|
17
|
+
value: "initial data",
|
|
19
18
|
},
|
|
20
19
|
});
|
|
21
20
|
```
|
|
@@ -25,24 +24,22 @@ const result = await run.start({
|
|
|
25
24
|
<PropertiesTable
|
|
26
25
|
content={[
|
|
27
26
|
{
|
|
28
|
-
name: "
|
|
29
|
-
type: "
|
|
30
|
-
description: "
|
|
31
|
-
isOptional:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
],
|
|
27
|
+
name: "inputData",
|
|
28
|
+
type: "z.infer<TInput>",
|
|
29
|
+
description: "Input data that matches the workflow's input schema",
|
|
30
|
+
isOptional: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "runtimeContext",
|
|
34
|
+
type: "RuntimeContext",
|
|
35
|
+
description: "Runtime context data to use during workflow execution",
|
|
36
|
+
isOptional: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "writableStream",
|
|
40
|
+
type: "WritableStream<ChunkType>",
|
|
41
|
+
description: "Optional writable stream for streaming workflow output",
|
|
42
|
+
isOptional: true,
|
|
46
43
|
},
|
|
47
44
|
]}
|
|
48
45
|
/>
|
|
@@ -54,11 +51,29 @@ const result = await run.start({
|
|
|
54
51
|
{
|
|
55
52
|
name: "result",
|
|
56
53
|
type: "Promise<WorkflowResult<TOutput, TSteps>>",
|
|
57
|
-
description: "A promise that resolves to the result
|
|
54
|
+
description: "A promise that resolves to the workflow execution result containing step outputs and status",
|
|
58
55
|
},
|
|
59
56
|
]}
|
|
60
57
|
/>
|
|
61
58
|
|
|
59
|
+
## Extended usage example
|
|
60
|
+
|
|
61
|
+
```typescript showLineNumbers copy
|
|
62
|
+
import { RuntimeContext } from "@mastra/core/runtime-context";
|
|
63
|
+
|
|
64
|
+
const run = await workflow.createRunAsync();
|
|
65
|
+
|
|
66
|
+
const runtimeContext = new RuntimeContext();
|
|
67
|
+
runtimeContext.set("variable", false);
|
|
68
|
+
|
|
69
|
+
const result = await run.start({
|
|
70
|
+
inputData: {
|
|
71
|
+
value: "initial data"
|
|
72
|
+
},
|
|
73
|
+
runtimeContext
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
62
77
|
## Related
|
|
63
78
|
|
|
64
79
|
- [Running workflows](../../docs/workflows/overview.mdx#running-workflows)
|
|
@@ -1,48 +1,34 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Step |
|
|
3
|
-
description: Documentation for the Step class, which defines individual units of work within a workflow.
|
|
2
|
+
title: "Reference: Step Class | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the Step class in Mastra, which defines individual units of work within a workflow.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Step
|
|
6
|
+
# Step Class
|
|
7
7
|
|
|
8
8
|
The Step class defines individual units of work within a workflow, encapsulating execution logic, data validation, and input/output handling.
|
|
9
9
|
It can take either a tool or an agent as a parameter to automatically create a step from them.
|
|
10
10
|
|
|
11
|
-
## Usage
|
|
11
|
+
## Usage example
|
|
12
12
|
|
|
13
|
-
```typescript
|
|
14
|
-
import { createStep } from "@mastra/core/workflows";
|
|
13
|
+
```typescript filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
14
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
id: "
|
|
17
|
+
const step1 = createStep({
|
|
18
|
+
id: "step-1",
|
|
19
|
+
description: "passes value from input to output",
|
|
19
20
|
inputSchema: z.object({
|
|
20
|
-
|
|
21
|
-
userId: z.string(),
|
|
21
|
+
value: z.number()
|
|
22
22
|
}),
|
|
23
23
|
outputSchema: z.object({
|
|
24
|
-
|
|
25
|
-
orderId: z.string(),
|
|
24
|
+
value: z.number()
|
|
26
25
|
}),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}),
|
|
30
|
-
suspendSchema: z.object({}),
|
|
31
|
-
execute: async ({
|
|
32
|
-
inputData,
|
|
33
|
-
mastra,
|
|
34
|
-
getStepResult,
|
|
35
|
-
getInitData,
|
|
36
|
-
suspend,
|
|
37
|
-
runtimeContext,
|
|
38
|
-
runCount
|
|
39
|
-
runId,
|
|
40
|
-
}) => {
|
|
26
|
+
execute: async ({ inputData }) => {
|
|
27
|
+
const { value } = inputData;
|
|
41
28
|
return {
|
|
42
|
-
|
|
43
|
-
orderId: inputData.orderId,
|
|
29
|
+
value
|
|
44
30
|
};
|
|
45
|
-
}
|
|
31
|
+
}
|
|
46
32
|
});
|
|
47
33
|
```
|
|
48
34
|
|