@mastra/mcp-docs-server 0.13.11-alpha.1 → 0.13.11-alpha.3
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 +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +29 -29
- 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 +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +20 -20
- 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 +22 -22
- 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,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: getWorkflows() | Agents | Mastra Docs"
|
|
3
|
-
description: "Documentation for the
|
|
2
|
+
title: "Reference: Agent.getWorkflows() | Agents | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Agent.getWorkflows()` method in Mastra agents, which retrieves the workflows that the agent can execute."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# getWorkflows()
|
|
6
|
+
# Agent.getWorkflows()
|
|
7
7
|
|
|
8
8
|
The `.getWorkflows()` method retrieves the workflows configured for an agent, resolving them if they're a function. These workflows enable the agent to execute complex, multi-step processes with defined execution paths.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
|
|
12
|
+
```typescript copy
|
|
13
|
+
await agent.getWorkflows();
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -27,10 +27,22 @@ const workflows = await agent.getWorkflows();
|
|
|
27
27
|
]}
|
|
28
28
|
/>
|
|
29
29
|
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
<PropertiesTable
|
|
33
|
+
content={[
|
|
34
|
+
{
|
|
35
|
+
name: "workflows",
|
|
36
|
+
type: "Promise<Record<string, Workflow>>",
|
|
37
|
+
description: "A promise that resolves to a record of workflow names to their corresponding Workflow instances.",
|
|
38
|
+
},
|
|
39
|
+
]}
|
|
40
|
+
/>
|
|
41
|
+
|
|
30
42
|
## Extended usage example
|
|
31
43
|
|
|
32
|
-
```typescript
|
|
33
|
-
|
|
44
|
+
```typescript copy
|
|
45
|
+
await agent.getWorkflows({
|
|
34
46
|
runtimeContext: new RuntimeContext()
|
|
35
47
|
});
|
|
36
48
|
```
|
|
@@ -49,14 +61,7 @@ const workflows = await agent.getWorkflows({
|
|
|
49
61
|
]}
|
|
50
62
|
/>
|
|
51
63
|
|
|
52
|
-
##
|
|
64
|
+
## Related
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
name: "workflows",
|
|
58
|
-
type: "Promise<Record<string, Workflow>>",
|
|
59
|
-
description: "A promise that resolves to a record of workflow names to their corresponding Workflow instances.",
|
|
60
|
-
},
|
|
61
|
-
]}
|
|
62
|
-
/>
|
|
66
|
+
- [Agents overview](../../docs/agents/overview.mdx)
|
|
67
|
+
- [Workflows overview](../../docs/workflows/overview.mdx)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: stream() | Agents | Mastra Docs"
|
|
3
|
-
description: "Documentation for the
|
|
2
|
+
title: "Reference: Agent.stream() | Agents | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Agent.stream()` method in Mastra agents, which enables real-time streaming of responses."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# stream()
|
|
6
|
+
# Agent.stream()
|
|
7
7
|
|
|
8
8
|
The `.stream()` method enables real-time streaming of responses from an agent. This method accepts messages and optional streaming options.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
|
|
12
|
+
```typescript copy
|
|
13
|
+
await agent.stream("message for agent");
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -31,20 +31,6 @@ const response = await agent.stream("message for agent");
|
|
|
31
31
|
]}
|
|
32
32
|
/>
|
|
33
33
|
|
|
34
|
-
## Extended usage example
|
|
35
|
-
|
|
36
|
-
```typescript showLineNumbers copy
|
|
37
|
-
const response = await agent.stream("message for agent", {
|
|
38
|
-
temperature: 0.7,
|
|
39
|
-
maxSteps: 3,
|
|
40
|
-
memory: {
|
|
41
|
-
thread: "user-123",
|
|
42
|
-
resource: "test-app"
|
|
43
|
-
},
|
|
44
|
-
toolChoice: "auto"
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
34
|
### Options parameters
|
|
49
35
|
|
|
50
36
|
<PropertiesTable
|
|
@@ -472,3 +458,22 @@ const response = await agent.stream("message for agent", {
|
|
|
472
458
|
},
|
|
473
459
|
]}
|
|
474
460
|
/>
|
|
461
|
+
|
|
462
|
+
## Extended usage example
|
|
463
|
+
|
|
464
|
+
```typescript showLineNumbers copy
|
|
465
|
+
await agent.stream("message for agent", {
|
|
466
|
+
temperature: 0.7,
|
|
467
|
+
maxSteps: 3,
|
|
468
|
+
memory: {
|
|
469
|
+
thread: "user-123",
|
|
470
|
+
resource: "test-app"
|
|
471
|
+
},
|
|
472
|
+
toolChoice: "auto"
|
|
473
|
+
});
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
## Related
|
|
477
|
+
|
|
478
|
+
- [Agent streaming](../../docs/agents/streaming.mdx)
|
|
479
|
+
- [Agent generation](../../docs/agents/overview.mdx#generate)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: streamVNext() | Agents | Mastra Docs"
|
|
3
|
-
description: "Documentation for the
|
|
2
|
+
title: "Reference: Agent.streamVNext() | Agents | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Agent.streamVNext()` method in Mastra agents, which enables real-time streaming of responses with enhanced capabilities."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# streamVNext()
|
|
6
|
+
# Agent.streamVNext()
|
|
7
7
|
|
|
8
8
|
The `.streamVNext()` method enables real-time streaming of responses from an agent with enhanced capabilities. This method accepts messages and optional streaming options, providing a next-generation streaming experience.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
|
|
12
|
+
```typescript copy
|
|
13
|
+
await agent.streamVNext("message for agent");
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -31,20 +31,6 @@ const response = await agent.streamVNext("message for agent");
|
|
|
31
31
|
]}
|
|
32
32
|
/>
|
|
33
33
|
|
|
34
|
-
## Extended usage example
|
|
35
|
-
|
|
36
|
-
```typescript showLineNumbers copy
|
|
37
|
-
const response = await agent.streamVNext("message for agent", {
|
|
38
|
-
temperature: 0.7,
|
|
39
|
-
maxSteps: 3,
|
|
40
|
-
memory: {
|
|
41
|
-
thread: "user-123",
|
|
42
|
-
resource: "test-app"
|
|
43
|
-
},
|
|
44
|
-
toolChoice: "auto"
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
34
|
### Options parameters
|
|
49
35
|
|
|
50
36
|
<PropertiesTable
|
|
@@ -402,3 +388,16 @@ const response = await agent.streamVNext("message for agent", {
|
|
|
402
388
|
]}
|
|
403
389
|
/>
|
|
404
390
|
|
|
391
|
+
## Extended usage example
|
|
392
|
+
|
|
393
|
+
```typescript showLineNumbers copy
|
|
394
|
+
await agent.streamVNext("message for agent", {
|
|
395
|
+
temperature: 0.7,
|
|
396
|
+
maxSteps: 3,
|
|
397
|
+
memory: {
|
|
398
|
+
thread: "user-123",
|
|
399
|
+
resource: "test-app"
|
|
400
|
+
},
|
|
401
|
+
toolChoice: "auto"
|
|
402
|
+
});
|
|
403
|
+
```
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
title: "Upstash Storage | Storage System | Mastra Core"
|
|
3
3
|
description: Documentation for the Upstash storage implementation in Mastra.
|
|
4
4
|
---
|
|
5
|
+
import { Callout } from 'nextra/components'
|
|
5
6
|
|
|
6
7
|
# Upstash Storage
|
|
7
8
|
|
|
8
9
|
The Upstash storage implementation provides a serverless-friendly storage solution using Upstash's Redis-compatible key-value store.
|
|
9
10
|
|
|
11
|
+
<Callout type="warning">
|
|
12
|
+
**Important:** When using Mastra with Upstash, the pay-as-you-go model can result in unexpectedly high costs due to the high volume of Redis commands generated during agent conversations. We strongly recommend using a **fixed pricing plan** for predictable costs. See [Upstash pricing](https://upstash.com/pricing/redis) for details and [GitHub issue #5850](https://github.com/mastra-ai/mastra/issues/5850) for context.
|
|
13
|
+
</Callout>
|
|
14
|
+
|
|
10
15
|
## Installation
|
|
11
16
|
|
|
12
17
|
```bash copy
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Reference: createTool() | Tools | Mastra Docs"
|
|
3
|
-
description: Documentation for the createTool function in Mastra, used to define custom tools for agents.
|
|
3
|
+
description: Documentation for the `createTool()` function in Mastra, used to define custom tools for agents.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# createTool()
|
|
7
7
|
|
|
8
8
|
The `createTool()` function is used to define custom tools that your Mastra agents can execute. Tools extend an agent's capabilities by allowing it to interact with external systems, perform calculations, or access specific data.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
```typescript filename="src/mastra/tools/weatherInfo.ts" copy
|
|
12
|
+
```typescript filename="src/mastra/tools/reverse-tool.ts" showLineNumbers copy
|
|
15
13
|
import { createTool } from "@mastra/core/tools";
|
|
16
14
|
import { z } from "zod";
|
|
17
15
|
|
|
18
|
-
export const
|
|
19
|
-
id: "
|
|
16
|
+
export const reverseTool = createTool({
|
|
17
|
+
id: "reverse-tool",
|
|
18
|
+
description: "Reverse the input string",
|
|
20
19
|
inputSchema: z.object({
|
|
21
|
-
|
|
20
|
+
input: z.string()
|
|
21
|
+
}),
|
|
22
|
+
outputSchema: z.object({
|
|
23
|
+
output: z.string()
|
|
22
24
|
}),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
|
|
25
|
+
execute: async ({ context }) => {
|
|
26
|
+
const { input } = context;
|
|
27
|
+
const reversed = input.split("").reverse().join("");
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
output: reversed
|
|
31
|
+
};
|
|
32
|
+
}
|
|
29
33
|
});
|
|
30
34
|
```
|
|
31
35
|
|
|
32
36
|
## Parameters
|
|
33
37
|
|
|
34
|
-
The `createTool()` function accepts an object with the following parameters:
|
|
35
|
-
|
|
36
38
|
<PropertiesTable
|
|
37
39
|
content={[
|
|
38
40
|
{
|
|
@@ -87,18 +89,9 @@ The `createTool()` function returns a `Tool` object.
|
|
|
87
89
|
]}
|
|
88
90
|
/>
|
|
89
91
|
|
|
90
|
-
## Tool Details
|
|
91
|
-
|
|
92
|
-
The `Tool` object returned by `createTool()` has the following key properties:
|
|
93
|
-
|
|
94
|
-
- **ID**: The unique identifier provided in the `id` parameter.
|
|
95
|
-
- **Description**: The description provided in the `description` parameter.
|
|
96
|
-
- **Parameters**: Derived from the `inputSchema`, defining the structure of inputs the tool expects.
|
|
97
|
-
- **Execute Function**: The logic defined in the `execute` parameter, which is called when the agent decides to use the tool.
|
|
98
|
-
|
|
99
92
|
## Related
|
|
100
93
|
|
|
101
|
-
- [Tools Overview](/docs/tools-mcp/overview)
|
|
102
|
-
- [Using Tools with Agents](/docs/agents/using-tools-and-mcp)
|
|
103
|
-
- [Dynamic Tool Context](/docs/tools-mcp/dynamic-context)
|
|
104
|
-
- [Advanced Tool Usage](/docs/tools-mcp/advanced-usage)
|
|
94
|
+
- [Tools Overview](/docs/tools-mcp/overview.mdx)
|
|
95
|
+
- [Using Tools with Agents](/docs/agents/using-tools-and-mcp.mdx)
|
|
96
|
+
- [Dynamic Tool Context](/docs/tools-mcp/dynamic-context.mdx)
|
|
97
|
+
- [Advanced Tool Usage](/docs/tools-mcp/advanced-usage.mdx)
|
|
@@ -246,8 +246,8 @@ const response = await agent.generate(
|
|
|
246
246
|
|
|
247
247
|
For more information on runtime context, please see:
|
|
248
248
|
|
|
249
|
-
- [Runtime Variables](../../docs/agents/runtime-variables)
|
|
250
|
-
- [Dynamic Context](../../docs/tools-mcp/dynamic-context)
|
|
249
|
+
- [Runtime Variables](../../docs/agents/runtime-variables.mdx)
|
|
250
|
+
- [Dynamic Context](../../docs/tools-mcp/dynamic-context.mdx)
|
|
251
251
|
|
|
252
252
|
## Related
|
|
253
253
|
|
|
@@ -314,7 +314,7 @@ This agent-driven approach:
|
|
|
314
314
|
|
|
315
315
|
For detailed filter syntax and store-specific capabilities, see the [Metadata Filters](../rag/metadata-filters) documentation.
|
|
316
316
|
|
|
317
|
-
For an example of how agent-driven filtering works, see the [Agent-Driven Metadata Filtering](../../../examples/rag/usage/filter-rag) example.
|
|
317
|
+
For an example of how agent-driven filtering works, see the [Agent-Driven Metadata Filtering](../../../examples/rag/usage/filter-rag.mdx) example.
|
|
318
318
|
|
|
319
319
|
## Example with Reranking
|
|
320
320
|
|
|
@@ -551,8 +551,8 @@ const response = await agent.generate(
|
|
|
551
551
|
|
|
552
552
|
For more information on runtime context, please see:
|
|
553
553
|
|
|
554
|
-
- [Runtime Variables](../../docs/agents/runtime-variables)
|
|
555
|
-
- [Dynamic Context](../../docs/tools-mcp/dynamic-context)
|
|
554
|
+
- [Runtime Variables](../../docs/agents/runtime-variables.mdx)
|
|
555
|
+
- [Dynamic Context](../../docs/tools-mcp/dynamic-context.mdx)
|
|
556
556
|
|
|
557
557
|
## Usage Without a Mastra Server
|
|
558
558
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.branch() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.branch() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.branch()` method in workflows, which creates conditional branches between steps.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.branch()
|
|
7
7
|
|
|
8
8
|
The `.branch()` method creates conditional branches between workflow steps, allowing for different paths to be taken based on the result of a previous step.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
12
|
+
```typescript copy
|
|
13
13
|
workflow.branch([
|
|
14
|
-
[async ({ context }) => true,
|
|
15
|
-
[async ({ context }) => false,
|
|
14
|
+
[async ({ context }) => true, step1],
|
|
15
|
+
[async ({ context }) => false, step2],
|
|
16
16
|
]);
|
|
17
17
|
```
|
|
18
18
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.commit() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.commit() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.commit()` method in workflows, which finalizes the workflow and returns the final result.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.commit()
|
|
7
7
|
|
|
8
8
|
The `.commit()` method finalizes the workflow and returns the final result.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.then(
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.then(step1).commit();
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Returns
|
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.createRunAsync() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.createRunAsync() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.createRunAsync()` method in workflows, which creates a new workflow run instance.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { Callout } from "nextra/components";
|
|
7
|
+
|
|
6
8
|
# Workflow.createRunAsync()
|
|
7
9
|
|
|
8
|
-
The `.createRunAsync()` method creates a new workflow run instance, allowing you to execute the workflow with specific input data.
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
```typescript
|
|
13
|
-
const myWorkflow = createWorkflow({
|
|
14
|
-
id: "my-workflow",
|
|
15
|
-
inputSchema: z.object({
|
|
16
|
-
startValue: z.string(),
|
|
17
|
-
}),
|
|
18
|
-
outputSchema: z.object({
|
|
19
|
-
result: z.string(),
|
|
20
|
-
}),
|
|
21
|
-
steps: [step1, step2, step3], // Declare steps used in this workflow
|
|
22
|
-
})
|
|
23
|
-
.then(step1)
|
|
24
|
-
.then(step2)
|
|
25
|
-
.then(step3)
|
|
26
|
-
.commit();
|
|
27
|
-
|
|
28
|
-
const mastra = new Mastra({
|
|
29
|
-
workflows: {
|
|
30
|
-
myWorkflow,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
10
|
+
The `.createRunAsync()` method creates a new workflow run instance, allowing you to execute the workflow with specific input data. This is the current API that returns a `Run` instance.
|
|
33
11
|
|
|
34
|
-
|
|
12
|
+
<Callout>
|
|
13
|
+
For the legacy `createRun()` method that returns an object with methods, see the [Legacy Workflows](../legacyWorkflows/createRun.mdx) section.
|
|
14
|
+
</Callout>
|
|
15
|
+
|
|
16
|
+
## Usage example
|
|
17
|
+
|
|
18
|
+
```typescript copy
|
|
19
|
+
await workflow.createRunAsync();
|
|
35
20
|
```
|
|
36
21
|
|
|
37
22
|
## Parameters
|
|
@@ -61,6 +46,20 @@ const run = await mastra.getWorkflow("myWorkflow").createRunAsync();
|
|
|
61
46
|
]}
|
|
62
47
|
/>
|
|
63
48
|
|
|
49
|
+
## Extended usage example
|
|
50
|
+
|
|
51
|
+
```typescript showLineNumbers copy
|
|
52
|
+
const workflow = mastra.getWorkflow("workflow");
|
|
53
|
+
|
|
54
|
+
const run = await workflow.createRunAsync();
|
|
55
|
+
|
|
56
|
+
const result = await run.start({
|
|
57
|
+
inputData: {
|
|
58
|
+
value: 10,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
64
63
|
## Related
|
|
65
64
|
|
|
66
|
-
- [Running workflows](../../
|
|
65
|
+
- [Running workflows](../../examples/workflows/running-workflows.mdx)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.dountil() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.dountil() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.dountil()` method in workflows, which creates a loop that executes a step until a condition is met.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.dountil()
|
|
7
7
|
|
|
8
8
|
The `.dountil()` method creates a loop that executes a step until a condition is met.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.dountil(
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.dountil(step1, async ({ inputData }) => true);
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Workflow.dowhile() |
|
|
3
|
-
description: Documentation for the
|
|
2
|
+
title: "Reference: Workflow.dowhile() | Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `Workflow.dowhile()` method in workflows, which creates a loop that executes a step while a condition is met.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workflow.dowhile()
|
|
7
7
|
|
|
8
8
|
The `.dowhile()` method creates a loop that executes a step while a condition is met.
|
|
9
9
|
|
|
10
|
-
## Usage
|
|
10
|
+
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
13
|
-
workflow.dowhile(
|
|
12
|
+
```typescript copy
|
|
13
|
+
workflow.dowhile(step1, async ({ inputData }) => true);
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Parameters
|