@mastra/mcp-docs-server 1.2.14-alpha.3 → 1.2.14-alpha.4
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/netlify.md +6 -6
- package/.docs/models/gateways/openrouter.md +6 -6
- package/.docs/models/gateways/vercel.md +6 -6
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +95 -96
- package/.docs/models/providers/alibaba-cn.md +23 -25
- package/.docs/models/providers/alibaba-token-plan-cn.md +24 -24
- package/.docs/models/providers/alibaba-token-plan.md +23 -25
- package/.docs/models/providers/alibaba.md +23 -25
- package/.docs/models/providers/ambient.md +23 -25
- package/.docs/models/providers/baseten.md +23 -25
- package/.docs/models/providers/chutes.md +23 -25
- package/.docs/models/providers/cortecs.md +23 -25
- package/.docs/models/providers/crof.md +23 -25
- package/.docs/models/providers/crossmodel.md +23 -25
- package/.docs/models/providers/deepinfra.md +22 -24
- package/.docs/models/providers/digitalocean.md +23 -25
- package/.docs/models/providers/empiriolabs.md +23 -25
- package/.docs/models/providers/fireworks-ai.md +24 -24
- package/.docs/models/providers/greenpt.md +23 -25
- package/.docs/models/providers/groq.md +23 -25
- package/.docs/models/providers/huggingface.md +23 -25
- package/.docs/models/providers/hyper.md +23 -25
- package/.docs/models/providers/impossibl.md +23 -25
- package/.docs/models/providers/infomaniak.md +24 -24
- package/.docs/models/providers/kilo.md +23 -25
- package/.docs/models/providers/llmgateway.md +23 -25
- package/.docs/models/providers/mistral.md +23 -25
- package/.docs/models/providers/modal.md +23 -25
- package/.docs/models/providers/modelis.md +23 -25
- package/.docs/models/providers/nano-gpt.md +23 -25
- package/.docs/models/providers/neuralwatt.md +23 -25
- package/.docs/models/providers/ofox.md +23 -25
- package/.docs/models/providers/ollama-cloud.md +23 -25
- package/.docs/models/providers/opencode-go.md +23 -25
- package/.docs/models/providers/opencode.md +23 -25
- package/.docs/models/providers/pioneer.md +23 -25
- package/.docs/models/providers/requesty.md +23 -25
- package/.docs/models/providers/routing-run.md +23 -25
- package/.docs/models/providers/scx.md +23 -25
- package/.docs/models/providers/tensorx.md +23 -25
- package/.docs/models/providers/togetherai.md +22 -24
- package/.docs/models/providers/umans-ai-coding-plan.md +24 -24
- package/.docs/models/providers/umans-ai.md +23 -25
- package/.docs/models/providers/wandb.md +23 -25
- package/.docs/models/providers/xai.md +26 -28
- package/.docs/models/providers/zai-coding-plan.md +23 -25
- package/.docs/models/providers/zhipuai-coding-plan.md +23 -25
- 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 +7 -0
- package/package.json +5 -5
- package/.docs/models/providers/neon.md +0 -109
|
@@ -11,22 +11,22 @@ TOGETHER_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: 'togetherai/LiquidAI/LFM2-24B-A2B',
|
|
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
|
|
|
@@ -64,31 +64,29 @@ for await (const chunk of stream) {
|
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
const agent = new Agent({
|
|
67
|
-
id:
|
|
68
|
-
name:
|
|
67
|
+
id: 'custom-agent',
|
|
68
|
+
name: 'custom-agent',
|
|
69
69
|
model: {
|
|
70
|
-
id:
|
|
70
|
+
id: 'togetherai/LiquidAI/LFM2-24B-A2B',
|
|
71
71
|
apiKey: process.env.TOGETHER_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 ===
|
|
87
|
-
return useAdvanced
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
});
|
|
86
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
87
|
+
return useAdvanced ? 'togetherai/zai-org/GLM-5.2' : 'togetherai/LiquidAI/LFM2-24B-A2B'
|
|
88
|
+
},
|
|
89
|
+
})
|
|
92
90
|
```
|
|
93
91
|
|
|
94
92
|
## Direct provider installation
|
|
@@ -11,22 +11,22 @@ UMANS_AI_CODING_PLAN_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: 'umans-ai-coding-plan/umans-coder',
|
|
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
|
|
|
@@ -51,30 +51,30 @@ for await (const chunk of stream) {
|
|
|
51
51
|
|
|
52
52
|
```typescript
|
|
53
53
|
const agent = new Agent({
|
|
54
|
-
id:
|
|
55
|
-
name:
|
|
54
|
+
id: 'custom-agent',
|
|
55
|
+
name: 'custom-agent',
|
|
56
56
|
model: {
|
|
57
|
-
url:
|
|
58
|
-
id:
|
|
57
|
+
url: 'https://api.code.umans.ai/v1',
|
|
58
|
+
id: 'umans-ai-coding-plan/umans-coder',
|
|
59
59
|
apiKey: process.env.UMANS_AI_CODING_PLAN_API_KEY,
|
|
60
60
|
headers: {
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
61
|
+
'X-Custom-Header': 'value',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
### Dynamic model selection
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
70
|
const agent = new Agent({
|
|
71
|
-
id:
|
|
72
|
-
name:
|
|
71
|
+
id: 'dynamic-agent',
|
|
72
|
+
name: 'Dynamic Agent',
|
|
73
73
|
model: ({ requestContext }) => {
|
|
74
|
-
const useAdvanced = requestContext.task ===
|
|
74
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
75
75
|
return useAdvanced
|
|
76
|
-
?
|
|
77
|
-
:
|
|
78
|
-
}
|
|
79
|
-
})
|
|
76
|
+
? 'umans-ai-coding-plan/umans-qwen3.6-35b-a3b'
|
|
77
|
+
: 'umans-ai-coding-plan/umans-coder'
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
80
|
```
|
|
@@ -11,22 +11,22 @@ UMANS_AI_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: 'umans-ai/umans-coder',
|
|
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,30 +50,28 @@ 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.code.umans.ai/v1',
|
|
57
|
+
id: 'umans-ai/umans-coder',
|
|
58
58
|
apiKey: process.env.UMANS_AI_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 ? 'umans-ai/umans-kimi-k3' : 'umans-ai/umans-coder'
|
|
75
|
+
},
|
|
76
|
+
})
|
|
79
77
|
```
|
|
@@ -11,22 +11,22 @@ WANDB_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: 'wandb/JetBrains/Mellum2-12B-A2.5B-Instruct',
|
|
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
|
|
|
@@ -70,30 +70,28 @@ for await (const chunk of stream) {
|
|
|
70
70
|
|
|
71
71
|
```typescript
|
|
72
72
|
const agent = new Agent({
|
|
73
|
-
id:
|
|
74
|
-
name:
|
|
73
|
+
id: 'custom-agent',
|
|
74
|
+
name: 'custom-agent',
|
|
75
75
|
model: {
|
|
76
|
-
url:
|
|
77
|
-
id:
|
|
76
|
+
url: 'https://api.inference.wandb.ai/v1',
|
|
77
|
+
id: 'wandb/JetBrains/Mellum2-12B-A2.5B-Instruct',
|
|
78
78
|
apiKey: process.env.WANDB_API_KEY,
|
|
79
79
|
headers: {
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
})
|
|
80
|
+
'X-Custom-Header': 'value',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
})
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
### Dynamic model selection
|
|
87
87
|
|
|
88
88
|
```typescript
|
|
89
89
|
const agent = new Agent({
|
|
90
|
-
id:
|
|
91
|
-
name:
|
|
90
|
+
id: 'dynamic-agent',
|
|
91
|
+
name: 'Dynamic Agent',
|
|
92
92
|
model: ({ requestContext }) => {
|
|
93
|
-
const useAdvanced = requestContext.task ===
|
|
94
|
-
return useAdvanced
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
});
|
|
93
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
94
|
+
return useAdvanced ? 'wandb/zai-org/GLM-5.2' : 'wandb/JetBrains/Mellum2-12B-A2.5B-Instruct'
|
|
95
|
+
},
|
|
96
|
+
})
|
|
99
97
|
```
|
|
@@ -11,22 +11,22 @@ XAI_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: 'xai/grok-4.20-0309-non-reasoning',
|
|
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
|
|
|
@@ -51,31 +51,29 @@ for await (const chunk of stream) {
|
|
|
51
51
|
|
|
52
52
|
```typescript
|
|
53
53
|
const agent = new Agent({
|
|
54
|
-
id:
|
|
55
|
-
name:
|
|
54
|
+
id: 'custom-agent',
|
|
55
|
+
name: 'custom-agent',
|
|
56
56
|
model: {
|
|
57
|
-
id:
|
|
57
|
+
id: 'xai/grok-4.20-0309-non-reasoning',
|
|
58
58
|
apiKey: process.env.XAI_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 ? 'xai/grok-imagine-video-1.5' : 'xai/grok-4.20-0309-non-reasoning'
|
|
75
|
+
},
|
|
76
|
+
})
|
|
79
77
|
```
|
|
80
78
|
|
|
81
79
|
## Provider Options
|
|
@@ -83,13 +81,13 @@ const agent = new Agent({
|
|
|
83
81
|
xAI supports the following provider-specific options via the `providerOptions` parameter:
|
|
84
82
|
|
|
85
83
|
```typescript
|
|
86
|
-
const response = await agent.generate(
|
|
84
|
+
const response = await agent.generate('Hello!', {
|
|
87
85
|
providerOptions: {
|
|
88
86
|
xai: {
|
|
89
87
|
// See available options in the table below
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
})
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
})
|
|
93
91
|
```
|
|
94
92
|
|
|
95
93
|
### Available Options
|
|
@@ -11,22 +11,22 @@ ZHIPU_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: 'zai-coding-plan/glm-4.7',
|
|
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
|
|
|
@@ -47,30 +47,28 @@ for await (const chunk of stream) {
|
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
49
|
const agent = new Agent({
|
|
50
|
-
id:
|
|
51
|
-
name:
|
|
50
|
+
id: 'custom-agent',
|
|
51
|
+
name: 'custom-agent',
|
|
52
52
|
model: {
|
|
53
|
-
url:
|
|
54
|
-
id:
|
|
53
|
+
url: 'https://api.z.ai/api/coding/paas/v4',
|
|
54
|
+
id: 'zai-coding-plan/glm-4.7',
|
|
55
55
|
apiKey: process.env.ZHIPU_API_KEY,
|
|
56
56
|
headers: {
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
})
|
|
57
|
+
'X-Custom-Header': 'value',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
### Dynamic model selection
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
const agent = new Agent({
|
|
67
|
-
id:
|
|
68
|
-
name:
|
|
67
|
+
id: 'dynamic-agent',
|
|
68
|
+
name: 'Dynamic Agent',
|
|
69
69
|
model: ({ requestContext }) => {
|
|
70
|
-
const useAdvanced = requestContext.task ===
|
|
71
|
-
return useAdvanced
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
});
|
|
70
|
+
const useAdvanced = requestContext.task === 'complex'
|
|
71
|
+
return useAdvanced ? 'zai-coding-plan/glm-5.2-highspeed' : 'zai-coding-plan/glm-4.7'
|
|
72
|
+
},
|
|
73
|
+
})
|
|
76
74
|
```
|
|
@@ -11,22 +11,22 @@ ZHIPU_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: 'zhipuai-coding-plan/glm-4.6v',
|
|
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,30 +50,28 @@ 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://open.bigmodel.cn/api/coding/paas/v4',
|
|
57
|
+
id: 'zhipuai-coding-plan/glm-4.6v',
|
|
58
58
|
apiKey: process.env.ZHIPU_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 ? 'zhipuai-coding-plan/glm-5v-turbo' : 'zhipuai-coding-plan/glm-4.6v'
|
|
75
|
+
},
|
|
76
|
+
})
|
|
79
77
|
```
|
|
@@ -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).
|