@mastra/mcp-docs-server 1.2.14-alpha.3 → 1.2.14
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/docs/agents/processors.md +25 -1
- package/.docs/docs/workflows/agents-and-tools.md +29 -0
- package/.docs/docs/workflows/stored-workflows.md +146 -0
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/neon.md +71 -0
- package/.docs/models/gateways/vercel.md +1 -1
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/ambient.md +1 -1
- package/.docs/models/providers/cortecs.md +112 -66
- package/.docs/models/providers/hyper.md +6 -6
- package/.docs/models/providers/kilo.md +1 -1
- package/.docs/models/providers/llmgateway.md +1 -1
- package/.docs/models/providers/minimax.md +23 -25
- package/.docs/models/providers/nano-gpt.md +1 -1
- package/.docs/models/providers/openai.md +26 -28
- package/.docs/models/providers/perplexity-agent.md +24 -24
- package/.docs/models/providers.md +0 -1
- package/.docs/reference/client-js/workflows.md +92 -0
- package/.docs/reference/core/addStoredWorkflow.md +62 -0
- package/.docs/reference/core/addStoredWorkflows.md +40 -0
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/processors/processor-interface.md +121 -10
- package/.docs/reference/server/routes.md +13 -0
- package/.docs/reference/storage/overview.md +9 -8
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/streaming/workflows/stream.md +1 -1
- package/.docs/reference/workflows/stored-workflow-definition.md +292 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +62 -0
- package/.docs/reference/workflows/workflow-methods/tool.md +43 -0
- package/CHANGELOG.md +14 -0
- package/package.json +5 -5
- package/.docs/models/providers/neon.md +0 -109
|
@@ -39,18 +39,18 @@ for await (const chunk of stream) {
|
|
|
39
39
|
| `hyper/deepseek-v4-flash` | 1.0M | | | | | | $0.20 | $0.40 |
|
|
40
40
|
| `hyper/deepseek-v4-flash-0731` | 1.0M | | | | | | $0.15 | $0.30 |
|
|
41
41
|
| `hyper/deepseek-v4-pro` | 1.0M | | | | | | $2 | $5 |
|
|
42
|
-
| `hyper/gemma-4-26b-a4b-it` | 256K | | | | | | $0.
|
|
43
|
-
| `hyper/glm-5` | 203K | | | | | | $0.
|
|
42
|
+
| `hyper/gemma-4-26b-a4b-it` | 256K | | | | | | $0.12 | $0.40 |
|
|
43
|
+
| `hyper/glm-5` | 203K | | | | | | $0.82 | $3 |
|
|
44
44
|
| `hyper/glm-5.1` | 203K | | | | | | $2 | $5 |
|
|
45
45
|
| `hyper/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
46
|
-
| `hyper/gpt-oss-120b` | 131K | | | | | | $0.
|
|
47
|
-
| `hyper/kimi-k2.5` | 262K | | | | | | $0.
|
|
46
|
+
| `hyper/gpt-oss-120b` | 131K | | | | | | $0.17 | $0.63 |
|
|
47
|
+
| `hyper/kimi-k2.5` | 262K | | | | | | $0.56 | $3 |
|
|
48
48
|
| `hyper/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
49
49
|
| `hyper/kimi-k2.7-code` | 256K | | | | | | $0.95 | $4 |
|
|
50
50
|
| `hyper/kimi-k3` | 1.0M | | | | | | $3 | $16 |
|
|
51
|
-
| `hyper/llama-3.3-70b-instruct` | 128K | | | | | | $0.
|
|
51
|
+
| `hyper/llama-3.3-70b-instruct` | 128K | | | | | | $0.61 | $1 |
|
|
52
52
|
| `hyper/llama-4-maverick-17b-128e-instruct-fp8` | 430K | | | | | | $0.28 | $0.93 |
|
|
53
|
-
| `hyper/minimax-m2.7` | 262K | | | | | | $0.
|
|
53
|
+
| `hyper/minimax-m2.7` | 262K | | | | | | $0.44 | $2 |
|
|
54
54
|
| `hyper/minimax-m3` | 512K | | | | | | $0.33 | $1 |
|
|
55
55
|
| `hyper/qwen3-coder-480b-a35b-instruct-int4-mixed-ar` | 106K | | | | | | $0.57 | $2 |
|
|
56
56
|
| `hyper/qwen3-next-80b-a3b-instruct` | 262K | | | | | | $0.12 | $1 |
|
|
@@ -360,7 +360,7 @@ for await (const chunk of stream) {
|
|
|
360
360
|
| `kilo/thinkingmachines/inkling` | 524K | | | | | | $0.95 | $4 |
|
|
361
361
|
| `kilo/thinkingmachines/inkling-small` | 524K | | | | | | $0.45 | $1 |
|
|
362
362
|
| `kilo/undi95/remm-slerp-l2-13b` | 6K | | | | | | $0.45 | $0.65 |
|
|
363
|
-
| `kilo/upstage/solar-pro-3` |
|
|
363
|
+
| `kilo/upstage/solar-pro-3` | 131K | | | | | | $0.15 | $0.60 |
|
|
364
364
|
| `kilo/writer/palmyra-x5` | 1.0M | | | | | | $0.60 | $6 |
|
|
365
365
|
| `kilo/x-ai/grok-4.20` | 2.0M | | | | | | $1 | $3 |
|
|
366
366
|
| `kilo/x-ai/grok-4.20-multi-agent` | 2.0M | | | | | | $1 | $3 |
|
|
@@ -56,7 +56,7 @@ for await (const chunk of stream) {
|
|
|
56
56
|
| `llmgateway/cosmos3-super-reasoner` | 262K | | | | | | $0.10 | $0.30 |
|
|
57
57
|
| `llmgateway/custom` | 128K | | | | | | — | — |
|
|
58
58
|
| `llmgateway/deepseek-v3.2` | 164K | | | | | | $0.26 | $0.38 |
|
|
59
|
-
| `llmgateway/deepseek-v4-flash` | 1.1M | | | | | | $0.
|
|
59
|
+
| `llmgateway/deepseek-v4-flash` | 1.1M | | | | | | $0.08 | $0.15 |
|
|
60
60
|
| `llmgateway/deepseek-v4-pro` | 1.1M | | | | | | $0.43 | $0.87 |
|
|
61
61
|
| `llmgateway/fugu-ultra` | 1.0M | | | | | | $5 | $30 |
|
|
62
62
|
| `llmgateway/gemini-2.5-flash` | 1.0M | | | | | | $0.30 | $3 |
|
|
@@ -11,22 +11,22 @@ MINIMAX_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'minimax/MiniMax-M2',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
27
|
+
const stream = await agent.stream('Tell me a story')
|
|
28
28
|
for await (const chunk of stream) {
|
|
29
|
-
console.log(chunk)
|
|
29
|
+
console.log(chunk)
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -50,32 +50,30 @@ for await (const chunk of stream) {
|
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
52
|
const agent = new Agent({
|
|
53
|
-
id:
|
|
54
|
-
name:
|
|
53
|
+
id: 'custom-agent',
|
|
54
|
+
name: 'custom-agent',
|
|
55
55
|
model: {
|
|
56
|
-
url:
|
|
57
|
-
id:
|
|
56
|
+
url: 'https://api.minimax.io/anthropic/v1',
|
|
57
|
+
id: 'minimax/MiniMax-M2',
|
|
58
58
|
apiKey: process.env.MINIMAX_API_KEY,
|
|
59
59
|
headers: {
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
})
|
|
60
|
+
'X-Custom-Header': 'value',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
### Dynamic model selection
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
69
|
const agent = new Agent({
|
|
70
|
-
id:
|
|
71
|
-
name:
|
|
70
|
+
id: 'dynamic-agent',
|
|
71
|
+
name: 'Dynamic Agent',
|
|
72
72
|
model: ({ requestContext }) => {
|
|
73
|
-
const useAdvanced = requestContext.task ===
|
|
74
|
-
return useAdvanced
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
});
|
|
73
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
74
|
+
return useAdvanced ? 'minimax/MiniMax-M3' : 'minimax/MiniMax-M2'
|
|
75
|
+
},
|
|
76
|
+
})
|
|
79
77
|
```
|
|
80
78
|
|
|
81
79
|
## Direct provider installation
|
|
@@ -84,7 +84,6 @@ for await (const chunk of stream) {
|
|
|
84
84
|
| `nano-gpt/Baichuan-M2` | 33K | | | | | | $16 | $16 |
|
|
85
85
|
| `nano-gpt/Baichuan4-Air` | 33K | | | | | | $0.16 | $0.16 |
|
|
86
86
|
| `nano-gpt/Baichuan4-Turbo` | 128K | | | | | | $2 | $2 |
|
|
87
|
-
| `nano-gpt/baidu/ernie-4.5-vl-28b-a3b` | 33K | | | | | | $0.14 | $0.56 |
|
|
88
87
|
| `nano-gpt/baseten/Kimi-K2-Instruct-FP4` | 128K | | | | | | $0.40 | $2 |
|
|
89
88
|
| `nano-gpt/brave` | 8K | | | | | | $5 | $5 |
|
|
90
89
|
| `nano-gpt/brave-pro` | 8K | | | | | | $5 | $5 |
|
|
@@ -426,6 +425,7 @@ for await (const chunk of stream) {
|
|
|
426
425
|
| `nano-gpt/perplexity-academic-researcher` | 127K | | | | | | $2 | $8 |
|
|
427
426
|
| `nano-gpt/phi-4-mini-instruct` | 128K | | | | | | $0.17 | $0.68 |
|
|
428
427
|
| `nano-gpt/phi-4-multimodal-instruct` | 128K | | | | | | $0.07 | $0.11 |
|
|
428
|
+
| `nano-gpt/pokee-isaac` | 10.0M | | | | | | $0.15 | $1 |
|
|
429
429
|
| `nano-gpt/poolside/laguna-m.1` | 262K | | | | | | $0.20 | $0.40 |
|
|
430
430
|
| `nano-gpt/poolside/laguna-s-2.1` | 1.0M | | | | | | $0.10 | $0.20 |
|
|
431
431
|
| `nano-gpt/poolside/laguna-s-2.1:thinking` | 1.0M | | | | | | $0.10 | $0.20 |
|
|
@@ -11,22 +11,22 @@ OPENAI_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'openai/chatgpt-image-latest',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
27
|
+
const stream = await agent.stream('Tell me a story')
|
|
28
28
|
for await (const chunk of stream) {
|
|
29
|
-
console.log(chunk)
|
|
29
|
+
console.log(chunk)
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -78,31 +78,29 @@ for await (const chunk of stream) {
|
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
80
|
const agent = new Agent({
|
|
81
|
-
id:
|
|
82
|
-
name:
|
|
81
|
+
id: 'custom-agent',
|
|
82
|
+
name: 'custom-agent',
|
|
83
83
|
model: {
|
|
84
|
-
id:
|
|
84
|
+
id: 'openai/chatgpt-image-latest',
|
|
85
85
|
apiKey: process.env.OPENAI_API_KEY,
|
|
86
86
|
headers: {
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
})
|
|
87
|
+
'X-Custom-Header': 'value',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
### Dynamic model selection
|
|
94
94
|
|
|
95
95
|
```typescript
|
|
96
96
|
const agent = new Agent({
|
|
97
|
-
id:
|
|
98
|
-
name:
|
|
97
|
+
id: 'dynamic-agent',
|
|
98
|
+
name: 'Dynamic Agent',
|
|
99
99
|
model: ({ requestContext }) => {
|
|
100
|
-
const useAdvanced = requestContext.task ===
|
|
101
|
-
return useAdvanced
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
});
|
|
100
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
101
|
+
return useAdvanced ? 'openai/text-embedding-ada-002' : 'openai/chatgpt-image-latest'
|
|
102
|
+
},
|
|
103
|
+
})
|
|
106
104
|
```
|
|
107
105
|
|
|
108
106
|
## Provider Options
|
|
@@ -110,13 +108,13 @@ const agent = new Agent({
|
|
|
110
108
|
OpenAI supports the following provider-specific options via the `providerOptions` parameter:
|
|
111
109
|
|
|
112
110
|
```typescript
|
|
113
|
-
const response = await agent.generate(
|
|
111
|
+
const response = await agent.generate('Hello!', {
|
|
114
112
|
providerOptions: {
|
|
115
113
|
openai: {
|
|
116
114
|
// See available options in the table below
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
})
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
})
|
|
120
118
|
```
|
|
121
119
|
|
|
122
120
|
### Available Options
|
|
@@ -11,22 +11,22 @@ PERPLEXITY_API_KEY=your-api-key
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Agent } from
|
|
14
|
+
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
|
|
16
16
|
const agent = new Agent({
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
instructions:
|
|
20
|
-
model:
|
|
21
|
-
})
|
|
17
|
+
id: 'my-agent',
|
|
18
|
+
name: 'My Agent',
|
|
19
|
+
instructions: 'You are a helpful assistant',
|
|
20
|
+
model: 'perplexity-agent/anthropic/claude-haiku-4-5',
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
24
|
-
const response = await agent.generate(
|
|
24
|
+
const response = await agent.generate('Hello!')
|
|
25
25
|
|
|
26
26
|
// Stream a response
|
|
27
|
-
const stream = await agent.stream(
|
|
27
|
+
const stream = await agent.stream('Tell me a story')
|
|
28
28
|
for await (const chunk of stream) {
|
|
29
|
-
console.log(chunk)
|
|
29
|
+
console.log(chunk)
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -63,32 +63,32 @@ for await (const chunk of stream) {
|
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
65
|
const agent = new Agent({
|
|
66
|
-
id:
|
|
67
|
-
name:
|
|
66
|
+
id: 'custom-agent',
|
|
67
|
+
name: 'custom-agent',
|
|
68
68
|
model: {
|
|
69
|
-
url:
|
|
70
|
-
id:
|
|
69
|
+
url: 'https://api.perplexity.ai/v1',
|
|
70
|
+
id: 'perplexity-agent/anthropic/claude-haiku-4-5',
|
|
71
71
|
apiKey: process.env.PERPLEXITY_API_KEY,
|
|
72
72
|
headers: {
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
})
|
|
73
|
+
'X-Custom-Header': 'value',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
### Dynamic model selection
|
|
80
80
|
|
|
81
81
|
```typescript
|
|
82
82
|
const agent = new Agent({
|
|
83
|
-
id:
|
|
84
|
-
name:
|
|
83
|
+
id: 'dynamic-agent',
|
|
84
|
+
name: 'Dynamic Agent',
|
|
85
85
|
model: ({ requestContext }) => {
|
|
86
|
-
const useAdvanced = requestContext.task ===
|
|
86
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
87
87
|
return useAdvanced
|
|
88
|
-
?
|
|
89
|
-
:
|
|
90
|
-
}
|
|
91
|
-
})
|
|
88
|
+
? 'perplexity-agent/xai/grok-4-1-fast-non-reasoning'
|
|
89
|
+
: 'perplexity-agent/anthropic/claude-haiku-4-5'
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
## Direct provider installation
|
|
@@ -101,7 +101,6 @@ Direct access to individual AI model providers. Each provider offers unique mode
|
|
|
101
101
|
- [NanoGPT](https://mastra.ai/models/providers/nano-gpt)
|
|
102
102
|
- [NEAR AI Cloud](https://mastra.ai/models/providers/nearai)
|
|
103
103
|
- [Nebius Token Factory](https://mastra.ai/models/providers/nebius)
|
|
104
|
-
- [Neon](https://mastra.ai/models/providers/neon)
|
|
105
104
|
- [Neuralwatt](https://mastra.ai/models/providers/neuralwatt)
|
|
106
105
|
- [Nova](https://mastra.ai/models/providers/nova)
|
|
107
106
|
- [NovitaAI](https://mastra.ai/models/providers/novita-ai)
|
|
@@ -212,6 +212,98 @@ A workflow run result yields the following:
|
|
|
212
212
|
|
|
213
213
|
**payload** (`object`): Contains currentStep (id, status, output, payload) and workflowState (status, steps record)
|
|
214
214
|
|
|
215
|
+
## Stored workflows
|
|
216
|
+
|
|
217
|
+
> **Beta:** Stored workflows are in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
218
|
+
|
|
219
|
+
Stored workflows are workflow definitions expressed as JSON. The server persists each definition and registers it as a runnable workflow. See [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows) for the definition format.
|
|
220
|
+
|
|
221
|
+
### `listStoredWorkflows()`
|
|
222
|
+
|
|
223
|
+
List stored workflow definitions, optionally filtered by `status` (`'active' | 'archived'`) and `authorId`:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
const { definitions, total } = await mastraClient.listStoredWorkflows({
|
|
227
|
+
status: 'active',
|
|
228
|
+
})
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### `upsertStoredWorkflow()`
|
|
232
|
+
|
|
233
|
+
Create or replace a stored workflow definition. The server validates the definition, persists it, and live-registers it for execution:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
const stored = await mastraClient.upsertStoredWorkflow({
|
|
237
|
+
id: 'greeting-workflow',
|
|
238
|
+
description: 'Returns a greeting for the supplied name',
|
|
239
|
+
inputSchema: {
|
|
240
|
+
type: 'object',
|
|
241
|
+
properties: { name: { type: 'string' } },
|
|
242
|
+
required: ['name'],
|
|
243
|
+
},
|
|
244
|
+
outputSchema: {
|
|
245
|
+
type: 'object',
|
|
246
|
+
properties: { message: { type: 'string' } },
|
|
247
|
+
required: ['message'],
|
|
248
|
+
},
|
|
249
|
+
graph: [
|
|
250
|
+
{
|
|
251
|
+
type: 'mapping',
|
|
252
|
+
id: 'create-greeting',
|
|
253
|
+
mapConfig: JSON.stringify({
|
|
254
|
+
message: { template: 'Hello, ${initData.name}!' },
|
|
255
|
+
}),
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
})
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
When the root definition nests helper workflows that don't exist yet, pass them in the same request through `dependencies`. The server validates and registers the bundle as a unit and echoes the helper ids back as `dependencyIds`:
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
const stored = await mastraClient.upsertStoredWorkflow({
|
|
265
|
+
id: 'root-workflow',
|
|
266
|
+
// ...schemas and graph referencing 'helper-workflow'...
|
|
267
|
+
dependencies: [helperDefinition],
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
console.log(stored.dependencyIds) // ['helper-workflow']
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### `getStoredWorkflow()`
|
|
274
|
+
|
|
275
|
+
Get a stored workflow instance for definition management. To execute a stored workflow, use `getWorkflow(id).createRun()` like any other workflow:
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
const storedWorkflow = mastraClient.getStoredWorkflow('greeting-workflow')
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### `storedWorkflow.details()`
|
|
282
|
+
|
|
283
|
+
Retrieve the persisted definition, including schemas, graph, status, and timestamps:
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
const definition = await storedWorkflow.details()
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### `storedWorkflow.delete()`
|
|
290
|
+
|
|
291
|
+
Delete the stored definition and unregister the live workflow:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
await storedWorkflow.delete()
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Executing a stored workflow
|
|
298
|
+
|
|
299
|
+
Once registered, a stored workflow runs through the ordinary workflow API:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
const workflow = mastraClient.getWorkflow('greeting-workflow')
|
|
303
|
+
const run = await workflow.createRun()
|
|
304
|
+
const result = await run.startAsync({ inputData: { name: 'Ada' } })
|
|
305
|
+
```
|
|
306
|
+
|
|
215
307
|
## Schedules
|
|
216
308
|
|
|
217
309
|
Schedules are declared in code via the `schedule` field on `createWorkflow`. The client SDK exposes read and operational methods for managing workflow schedules at runtime. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Mastra.addStoredWorkflow()
|
|
4
|
+
|
|
5
|
+
> **Beta:** Stored workflows are in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
7
|
+
The `.addStoredWorkflow()` method validates a stored workflow definition and registers it as a live workflow on the instance, persisting it through the `workflowDefinitions` storage domain. Once registered, the workflow runs like any other workflow via [`getWorkflow()`](https://mastra.ai/reference/core/getWorkflow).
|
|
8
|
+
|
|
9
|
+
See [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows) for a complete setup example and the [stored workflow definition reference](https://mastra.ai/reference/workflows/stored-workflow-definition) for the accepted fields and graph entries.
|
|
10
|
+
|
|
11
|
+
## Usage example
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
await mastra.addStoredWorkflow({
|
|
15
|
+
id: 'greeting-workflow',
|
|
16
|
+
description: 'Returns a greeting for the supplied name',
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: { name: { type: 'string' } },
|
|
20
|
+
required: ['name'],
|
|
21
|
+
},
|
|
22
|
+
outputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: { message: { type: 'string' } },
|
|
25
|
+
required: ['message'],
|
|
26
|
+
},
|
|
27
|
+
graph: [
|
|
28
|
+
{
|
|
29
|
+
type: 'mapping',
|
|
30
|
+
id: 'create-greeting',
|
|
31
|
+
mapConfig: JSON.stringify({
|
|
32
|
+
message: { template: 'Hello, ${initData.name}!' },
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const run = await mastra.getWorkflow('greeting-workflow').createRun()
|
|
39
|
+
const result = await run.start({ inputData: { name: 'Ada' } })
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Parameters
|
|
43
|
+
|
|
44
|
+
**def** (`StoredWorkflowGraph`): The workflow definition: id, optional description and metadata, JSON Schema input/output schemas, optional state and request-context schemas, and the step graph.
|
|
45
|
+
|
|
46
|
+
## Returns
|
|
47
|
+
|
|
48
|
+
A promise that resolves once the definition is validated, registered, and persisted.
|
|
49
|
+
|
|
50
|
+
## Behavior
|
|
51
|
+
|
|
52
|
+
- The definition is fully validated (structure, references, schema flow) before anything is mutated. Agents, tools, and workflows referenced by the graph must already be registered on the instance.
|
|
53
|
+
- Adding a definition with an existing ID replaces both the stored definition and the live registration. In-flight runs keep the graph they started with.
|
|
54
|
+
- Without a storage adapter that supports the `workflowDefinitions` domain, the workflow is still validated and registered in memory, but the definition is lost on restart.
|
|
55
|
+
- To add a root workflow together with helper workflows it nests, use [`addStoredWorkflows()`](https://mastra.ai/reference/core/addStoredWorkflows).
|
|
56
|
+
|
|
57
|
+
## Related
|
|
58
|
+
|
|
59
|
+
- [Mastra.addStoredWorkflows()](https://mastra.ai/reference/core/addStoredWorkflows): Add a dependency-ordered bundle of definitions
|
|
60
|
+
- [Mastra.getWorkflow()](https://mastra.ai/reference/core/getWorkflow): Retrieve a registered workflow
|
|
61
|
+
- [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows): Set up and use stored workflows
|
|
62
|
+
- [Stored workflow definition](https://mastra.ai/reference/workflows/stored-workflow-definition): Definition fields and graph entries
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Mastra.addStoredWorkflows()
|
|
4
|
+
|
|
5
|
+
> **Beta:** Stored workflows are in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
7
|
+
The `.addStoredWorkflows()` method adds a bundle of stored workflow definitions that may reference each other. The typical case is a root workflow plus helper workflows it nests, where none of the definitions exist yet.
|
|
8
|
+
|
|
9
|
+
The whole bundle is validated up front. Members are then registered in dependency order, so a helper is always in place before the workflow that nests it.
|
|
10
|
+
|
|
11
|
+
[`addStoredWorkflow()`](https://mastra.ai/reference/core/addStoredWorkflow) is the single-member case.
|
|
12
|
+
|
|
13
|
+
## Usage example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
await mastra.addStoredWorkflows([
|
|
17
|
+
helperDefinition, // nested by the root — order in the array doesn't matter
|
|
18
|
+
rootDefinition, // graph contains { type: 'workflow', workflowId: helperDefinition.id }
|
|
19
|
+
])
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Parameters
|
|
23
|
+
|
|
24
|
+
**defs** (`readonly StoredWorkflowGraph[]`): The workflow definitions to add. Nested-workflow references may resolve against the live registries or against other members of the same bundle.
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
A promise that resolves once every member is validated, registered, and persisted.
|
|
29
|
+
|
|
30
|
+
## Behavior
|
|
31
|
+
|
|
32
|
+
- References resolve against the instance's registries union the bundle's own IDs, so a root may nest a helper introduced in the same call. Registration order is derived from the dependency graph, not the array order.
|
|
33
|
+
- A rejected bundle registers nothing. Duplicate IDs, invalid members, and dependency cycles are detected before anything is mutated, and if registration or persistence fails partway, the in-memory registry is restored to its prior state.
|
|
34
|
+
- Storage writes happen last. A storage-level failure mid-bundle can leave some rows written, but the registry is still rolled back and the orphaned rows are inert until the next boot.
|
|
35
|
+
|
|
36
|
+
## Related
|
|
37
|
+
|
|
38
|
+
- [Mastra.addStoredWorkflow()](https://mastra.ai/reference/core/addStoredWorkflow): Add a single definition
|
|
39
|
+
- [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows): Set up and use stored workflows
|
|
40
|
+
- [Stored workflow definition](https://mastra.ai/reference/workflows/stored-workflow-definition): Definition fields and graph entries
|
package/.docs/reference/index.md
CHANGED
|
@@ -83,6 +83,8 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
83
83
|
- [Mastra Class](https://mastra.ai/reference/core/mastra-class)
|
|
84
84
|
- [MastraModelGateway](https://mastra.ai/reference/core/mastra-model-gateway)
|
|
85
85
|
- [.addGateway()](https://mastra.ai/reference/core/addGateway)
|
|
86
|
+
- [.addStoredWorkflow()](https://mastra.ai/reference/core/addStoredWorkflow)
|
|
87
|
+
- [.addStoredWorkflows()](https://mastra.ai/reference/core/addStoredWorkflows)
|
|
86
88
|
- [.getAgent()](https://mastra.ai/reference/core/getAgent)
|
|
87
89
|
- [.getAgentById()](https://mastra.ai/reference/core/getAgentById)
|
|
88
90
|
- [.getDeployer()](https://mastra.ai/reference/core/getDeployer)
|
|
@@ -364,8 +366,10 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
364
366
|
- [Overview](https://mastra.ai/reference/workers/overview)
|
|
365
367
|
- [Run Class](https://mastra.ai/reference/workflows/run)
|
|
366
368
|
- [Step Class](https://mastra.ai/reference/workflows/step)
|
|
369
|
+
- [Stored Workflow Definition](https://mastra.ai/reference/workflows/stored-workflow-definition)
|
|
367
370
|
- [Workflow Class](https://mastra.ai/reference/workflows/workflow)
|
|
368
371
|
- [Workflow State Reader](https://mastra.ai/reference/workflows/workflow-state-reader)
|
|
372
|
+
- [.agent()](https://mastra.ai/reference/workflows/workflow-methods/agent)
|
|
369
373
|
- [.branch()](https://mastra.ai/reference/workflows/workflow-methods/branch)
|
|
370
374
|
- [.commit()](https://mastra.ai/reference/workflows/workflow-methods/commit)
|
|
371
375
|
- [.createRun()](https://mastra.ai/reference/workflows/workflow-methods/create-run)
|
|
@@ -377,6 +381,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
377
381
|
- [.sleep()](https://mastra.ai/reference/workflows/workflow-methods/sleep)
|
|
378
382
|
- [.sleepUntil()](https://mastra.ai/reference/workflows/workflow-methods/sleepUntil)
|
|
379
383
|
- [.then()](https://mastra.ai/reference/workflows/workflow-methods/then)
|
|
384
|
+
- [.tool()](https://mastra.ai/reference/workflows/workflow-methods/tool)
|
|
380
385
|
- [.cancel()](https://mastra.ai/reference/workflows/run-methods/cancel)
|
|
381
386
|
- [.restart()](https://mastra.ai/reference/workflows/run-methods/restart)
|
|
382
387
|
- [.resume()](https://mastra.ai/reference/workflows/run-methods/resume)
|