@mastra/mcp-docs-server 1.1.35-alpha.11 → 1.1.35-alpha.15
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/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +48 -4
- package/.docs/docs/agents/using-tools.md +8 -0
- package/.docs/docs/editor/tools.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +68 -6
- package/.docs/docs/observability/tracing/exporters/default.md +36 -1
- package/.docs/docs/workflows/suspend-and-resume.md +28 -1
- package/.docs/models/gateways/openrouter.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/digitalocean.md +9 -2
- package/.docs/models/providers/google.md +2 -1
- package/.docs/models/providers/poe.md +4 -1
- package/.docs/reference/agents/agent.md +2 -0
- package/.docs/reference/client-js/responses.md +4 -0
- package/.docs/reference/configuration.md +4 -4
- package/.docs/reference/editor/tool-provider.md +3 -3
- package/.docs/reference/harness/harness-class.md +21 -8
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/observability/tracing/configuration.md +3 -0
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +2 -0
- package/.docs/reference/observability/tracing/interfaces.md +36 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +22 -0
- package/.docs/reference/tools/create-tool.md +46 -0
- package/.docs/reference/workflows/workflow-state-reader.md +113 -0
- package/CHANGELOG.md +14 -0
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Advanced
|
|
1
|
+
# Advanced configuration of semantic recall
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Configure semantic recall with the `semanticRecall` option:
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
const memory = new Memory({
|
|
@@ -19,11 +19,55 @@ const memory = new Memory({
|
|
|
19
19
|
before: 2,
|
|
20
20
|
after: 1,
|
|
21
21
|
},
|
|
22
|
+
scope: 'resource', // Search all threads for this resource
|
|
23
|
+
filter: { projectId: { $eq: 'project-a' } },
|
|
22
24
|
},
|
|
23
25
|
},
|
|
24
26
|
})
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
The `topK` parameter controls how many
|
|
29
|
+
The `topK` parameter controls how many similar messages Mastra retrieves. A higher value retrieves more messages, which can help with complex topics but may include less relevant information. The default value is `4`.
|
|
28
30
|
|
|
29
|
-
The `messageRange` parameter controls how much context
|
|
31
|
+
The `messageRange` parameter controls how much context Mastra includes with each match. Messages before and after the match help the agent understand the matched message.
|
|
32
|
+
|
|
33
|
+
The `scope` parameter controls whether Mastra searches the current thread (`'thread'`) or all threads owned by a resource (`'resource'`). Use `scope: 'resource'` to let the agent recall information from past conversations for the same resource.
|
|
34
|
+
|
|
35
|
+
The `filter` parameter restricts semantic recall results to messages with matching thread metadata, such as a project ID or category.
|
|
36
|
+
|
|
37
|
+
Filters match metadata stored on message embeddings when messages are saved. If thread metadata changes later, existing embeddings keep their previous metadata until those messages are saved or indexed again.
|
|
38
|
+
|
|
39
|
+
Supported filter operators:
|
|
40
|
+
|
|
41
|
+
- `$and`: Logical AND
|
|
42
|
+
- `$eq`: Equal to
|
|
43
|
+
- `$gt`: Greater than
|
|
44
|
+
- `$gte`: Greater than or equal
|
|
45
|
+
- `$in`: In array
|
|
46
|
+
- `$lt`: Less than
|
|
47
|
+
- `$lte`: Less than or equal
|
|
48
|
+
- `$ne`: Not equal to
|
|
49
|
+
- `$nin`: Not in array
|
|
50
|
+
- `$or`: Logical OR
|
|
51
|
+
|
|
52
|
+
The following example demonstrates metadata filters for common use cases:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Filter by project
|
|
56
|
+
const options = {
|
|
57
|
+
semanticRecall: { filter: { projectId: { $eq: 'my-project' } } },
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Filter by multiple categories
|
|
61
|
+
const options = {
|
|
62
|
+
semanticRecall: { filter: { category: { $in: ['work', 'research'] } } },
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Filter by project and priority
|
|
66
|
+
const options = {
|
|
67
|
+
semanticRecall: {
|
|
68
|
+
filter: {
|
|
69
|
+
$and: [{ projectId: { $eq: 'project-a' } }, { priority: { $gte: 3 } }],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
```
|
|
@@ -224,6 +224,14 @@ export const weatherTool = createTool({
|
|
|
224
224
|
})
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
+
## Transform tool payloads for UI and transcripts
|
|
228
|
+
|
|
229
|
+
Use `transform` when a tool returns raw data your application needs, but browser-facing streams or user-visible transcript messages should receive a smaller or safer shape. `transform` is separate from `toModelOutput`: `toModelOutput` shapes the payload sent back to the model, while `transform` shapes tool input, output, errors, approval payloads, and suspension payloads for `display` and `transcript` targets.
|
|
230
|
+
|
|
231
|
+
If a transform is configured and it fails, Mastra does not fall back to the raw payload for display or transcript targets. Input deltas are suppressed when no safe `inputDelta` transform is available.
|
|
232
|
+
|
|
233
|
+
See the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool) for a `transform` example. For shared rules across several tools, configure the agent-level `transform` policy in the [`Agent` constructor](https://mastra.ai/reference/agents/agent).
|
|
234
|
+
|
|
227
235
|
## Control tool selection
|
|
228
236
|
|
|
229
237
|
Pass `toolChoice` or `activeTools` to `.generate()` or `.stream()` to control which tools the agent uses at runtime.
|
|
@@ -73,7 +73,7 @@ Integration providers connect external tool platforms to the editor. Once regist
|
|
|
73
73
|
})
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
Composio tool slugs use a format like `GITHUB_CREATE_ISSUE`. Tool calls are scoped to
|
|
76
|
+
Composio tool slugs use a format like `GITHUB_CREATE_ISSUE`. Tool calls are scoped to the `resourceId` passed through request context for per-user authentication.
|
|
77
77
|
|
|
78
78
|
### Arcade
|
|
79
79
|
|
|
@@ -121,26 +121,88 @@ Each vector store page below includes installation instructions, configuration p
|
|
|
121
121
|
|
|
122
122
|
## Recall configuration
|
|
123
123
|
|
|
124
|
-
The
|
|
124
|
+
The following options control semantic recall behavior:
|
|
125
125
|
|
|
126
|
-
1. **topK**:
|
|
127
|
-
2. **messageRange**:
|
|
128
|
-
3. **scope**: Whether to search
|
|
126
|
+
1. **topK**: The number of similar messages to retrieve
|
|
127
|
+
2. **messageRange**: The surrounding messages to include with each match
|
|
128
|
+
3. **scope**: Whether to search the current thread or all threads for a resource
|
|
129
|
+
4. **filter**: Metadata criteria that restrict search results
|
|
129
130
|
|
|
130
131
|
```typescript
|
|
131
132
|
const agent = new Agent({
|
|
132
133
|
memory: new Memory({
|
|
133
134
|
options: {
|
|
134
135
|
semanticRecall: {
|
|
135
|
-
topK: 3, // Retrieve 3
|
|
136
|
+
topK: 3, // Retrieve 3 similar messages
|
|
136
137
|
messageRange: 2, // Include 2 messages before and after each match
|
|
137
|
-
scope: 'resource', // Search
|
|
138
|
+
scope: 'resource', // Search all threads for this resource
|
|
139
|
+
filter: { projectId: { $eq: 'project-a' } },
|
|
138
140
|
},
|
|
139
141
|
},
|
|
140
142
|
}),
|
|
141
143
|
})
|
|
142
144
|
```
|
|
143
145
|
|
|
146
|
+
> **Note:** `scope: 'resource'` is supported by the LibSQL, PostgreSQL, and Upstash storage adapters.
|
|
147
|
+
|
|
148
|
+
### Metadata filtering
|
|
149
|
+
|
|
150
|
+
The `filter` option restricts semantic recall results to messages with matching thread metadata.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const agent = new Agent({
|
|
154
|
+
memory: new Memory({
|
|
155
|
+
options: {
|
|
156
|
+
semanticRecall: {
|
|
157
|
+
scope: 'resource',
|
|
158
|
+
filter: {
|
|
159
|
+
projectId: { $eq: 'project-a' },
|
|
160
|
+
category: { $in: ['work', 'personal'] },
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Filters match metadata stored on message embeddings when messages are saved. If thread metadata changes later, existing embeddings keep their previous metadata until those messages are saved or indexed again.
|
|
169
|
+
|
|
170
|
+
Supported filter operators:
|
|
171
|
+
|
|
172
|
+
- `$and`: Logical AND
|
|
173
|
+
- `$eq`: Equal to
|
|
174
|
+
- `$gt`: Greater than
|
|
175
|
+
- `$gte`: Greater than or equal
|
|
176
|
+
- `$in`: In array
|
|
177
|
+
- `$lt`: Less than
|
|
178
|
+
- `$lte`: Less than or equal
|
|
179
|
+
- `$ne`: Not equal to
|
|
180
|
+
- `$nin`: Not in array
|
|
181
|
+
- `$or`: Logical OR
|
|
182
|
+
|
|
183
|
+
The following example demonstrates metadata filters for common use cases:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// Filter by project
|
|
187
|
+
const options = {
|
|
188
|
+
semanticRecall: { filter: { projectId: { $eq: 'my-project' } } },
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Filter by multiple categories
|
|
192
|
+
const options = {
|
|
193
|
+
semanticRecall: { filter: { category: { $in: ['work', 'research'] } } },
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Filter by project and priority
|
|
197
|
+
const options = {
|
|
198
|
+
semanticRecall: {
|
|
199
|
+
filter: {
|
|
200
|
+
$and: [{ projectId: { $eq: 'project-a' } }, { priority: { $gte: 3 } }],
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
144
206
|
## Embedder configuration
|
|
145
207
|
|
|
146
208
|
Semantic recall relies on an [embedding model](https://mastra.ai/reference/memory/memory-class) to convert messages into embeddings. Mastra supports embedding models through the model router using `provider/model` strings, or you can use any [embedding model](https://sdk.vercel.ai/docs/ai-sdk-core/embeddings) compatible with the AI SDK.
|
|
@@ -174,7 +174,42 @@ The DefaultExporter includes robust error handling for production use:
|
|
|
174
174
|
- **Persistent Failures**: Drop batch after 4 failed attempts
|
|
175
175
|
- **Buffer Overflow**: Prevent memory issues during storage outages
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
## Dropped observability events
|
|
178
|
+
|
|
179
|
+
`DefaultExporter` emits structured drop events when it cannot persist observability data. Register an exporter or bridge with `onDroppedEvent` to forward these drops to alerting or monitoring.
|
|
180
|
+
|
|
181
|
+
There are two drop reasons:
|
|
182
|
+
|
|
183
|
+
- `unsupported-storage`: The storage provider does not implement the signal type.
|
|
184
|
+
- `retry-exhausted`: The exporter retried a batch up to `maxRetries` times and then dropped it.
|
|
185
|
+
|
|
186
|
+
The following example demonstrates forwarding drop details to a monitoring endpoint:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { BaseExporter } from '@mastra/observability'
|
|
190
|
+
import type { ObservabilityDropEvent, TracingEvent } from '@mastra/core/observability'
|
|
191
|
+
|
|
192
|
+
class DropAlertExporter extends BaseExporter {
|
|
193
|
+
name = 'drop-alerts'
|
|
194
|
+
|
|
195
|
+
async onDroppedEvent(event: ObservabilityDropEvent) {
|
|
196
|
+
await fetch('https://monitoring.example.com/observability-drops', {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: { 'content-type': 'application/json' },
|
|
199
|
+
body: JSON.stringify({
|
|
200
|
+
count: event.count,
|
|
201
|
+
signal: event.signal,
|
|
202
|
+
reason: event.reason,
|
|
203
|
+
exporterName: event.exporterName,
|
|
204
|
+
}),
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
protected async _exportTracingEvent(_event: TracingEvent) {}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Configuration examples
|
|
178
213
|
|
|
179
214
|
```typescript
|
|
180
215
|
// Zero config - recommended for most users
|
|
@@ -188,6 +188,32 @@ The `suspended` array contains the IDs of any suspended workflows and steps from
|
|
|
188
188
|
['nested-workflow', 'step-1']
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
+
## Recovering suspended runs
|
|
192
|
+
|
|
193
|
+
Use `workflow.getWorkflowRunById()` with `createWorkflowStateReader()` when your application needs to recover a suspended run from storage. The reader exposes suspended steps, resume labels, step payloads, and step outputs without reading the raw snapshot shape.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import { createWorkflowStateReader } from '@mastra/core/workflows'
|
|
197
|
+
|
|
198
|
+
const workflow = mastra.getWorkflow('testWorkflow')
|
|
199
|
+
const state = await workflow.getWorkflowRunById('run-123')
|
|
200
|
+
|
|
201
|
+
if (state?.status === 'suspended') {
|
|
202
|
+
const reader = createWorkflowStateReader(state)
|
|
203
|
+
const suspendedStep = reader.getSuspendedStep()
|
|
204
|
+
const approvalLabel = reader.getResumeLabel('approve')
|
|
205
|
+
const run = await workflow.createRun({ runId: state.runId })
|
|
206
|
+
|
|
207
|
+
await run.resume({
|
|
208
|
+
step: approvalLabel?.stepId ?? suspendedStep?.path,
|
|
209
|
+
resumeData: { approved: true },
|
|
210
|
+
forEachIndex: approvalLabel?.foreachIndex,
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
For nested workflows, `suspendedStep.path` contains the resume path. For `foreach` suspensions, matching resume labels include `foreachIndex` when the label points to a specific iteration.
|
|
216
|
+
|
|
191
217
|
## Sleep
|
|
192
218
|
|
|
193
219
|
Sleep methods can be used to pause execution at the workflow level, which sets the status to `waiting`. By comparison, `suspend()` pauses execution within a specific step and sets the status to `suspended`.
|
|
@@ -202,4 +228,5 @@ Sleep methods can be used to pause execution at the workflow level, which sets t
|
|
|
202
228
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
203
229
|
- [Human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop)
|
|
204
230
|
- [Snapshots](https://mastra.ai/docs/workflows/snapshots)
|
|
205
|
-
- [Time Travel](https://mastra.ai/docs/workflows/time-travel)
|
|
231
|
+
- [Time Travel](https://mastra.ai/docs/workflows/time-travel)
|
|
232
|
+
- [Workflow state reader](https://mastra.ai/reference/workflows/workflow-state-reader)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 189 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -195,6 +195,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
195
195
|
| `sourceful/riverflow-v2-max-preview` |
|
|
196
196
|
| `sourceful/riverflow-v2-standard-preview` |
|
|
197
197
|
| `stepfun/step-3.5-flash` |
|
|
198
|
+
| `tencent/hy3-preview` |
|
|
198
199
|
| `x-ai/grok-3` |
|
|
199
200
|
| `x-ai/grok-3-beta` |
|
|
200
201
|
| `x-ai/grok-3-mini` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3891 models from 108 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DigitalOcean
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 71 DigitalOcean models through Mastra's model router. Authentication is handled automatically using the `DIGITALOCEAN_ACCESS_TOKEN` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [DigitalOcean documentation](https://docs.digitalocean.com/products/gradient-ai-platform/details/models/).
|
|
6
6
|
|
|
@@ -37,6 +37,7 @@ for await (const chunk of stream) {
|
|
|
37
37
|
| `digitalocean/alibaba-qwen3-32b` | 131K | | | | | | $0.25 | $0.55 |
|
|
38
38
|
| `digitalocean/all-mini-lm-l6-v2` | 256 | | | | | | $0.01 | — |
|
|
39
39
|
| `digitalocean/anthropic-claude-4.1-opus` | 200K | | | | | | $15 | $75 |
|
|
40
|
+
| `digitalocean/anthropic-claude-4.5-haiku` | 200K | | | | | | $1 | $5 |
|
|
40
41
|
| `digitalocean/anthropic-claude-4.5-sonnet` | 1.0M | | | | | | $3 | $15 |
|
|
41
42
|
| `digitalocean/anthropic-claude-4.6-sonnet` | 1.0M | | | | | | $3 | $15 |
|
|
42
43
|
| `digitalocean/anthropic-claude-haiku-4.5` | 200K | | | | | | $1 | $5 |
|
|
@@ -50,6 +51,7 @@ for await (const chunk of stream) {
|
|
|
50
51
|
| `digitalocean/bge-reranker-v2-m3` | 8K | | | | | | $0.01 | — |
|
|
51
52
|
| `digitalocean/deepseek-3.2` | 128K | | | | | | $0.50 | $2 |
|
|
52
53
|
| `digitalocean/deepseek-r1-distill-llama-70b` | 131K | | | | | | $0.99 | $0.99 |
|
|
54
|
+
| `digitalocean/deepseek-v3` | 164K | | | | | | — | — |
|
|
53
55
|
| `digitalocean/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
54
56
|
| `digitalocean/e5-large-v2` | 512 | | | | | | $0.02 | — |
|
|
55
57
|
| `digitalocean/fal-ai/elevenlabs/tts/multilingual-v2` | — | | | | | | — | — |
|
|
@@ -62,11 +64,14 @@ for await (const chunk of stream) {
|
|
|
62
64
|
| `digitalocean/kimi-k2.5` | 262K | | | | | | $0.50 | $3 |
|
|
63
65
|
| `digitalocean/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
64
66
|
| `digitalocean/llama-4-maverick` | 1.0M | | | | | | $0.25 | $0.87 |
|
|
65
|
-
| `digitalocean/
|
|
67
|
+
| `digitalocean/llama3-8b-instruct` | 131K | | | | | | $0.20 | $0.20 |
|
|
66
68
|
| `digitalocean/llama3.3-70b-instruct` | 128K | | | | | | $0.65 | $0.65 |
|
|
67
69
|
| `digitalocean/minimax-m2.5` | 205K | | | | | | $0.30 | $1 |
|
|
70
|
+
| `digitalocean/ministral-3-8b-instruct-2512` | 262K | | | | | | — | — |
|
|
68
71
|
| `digitalocean/mistral-3-14B` | 262K | | | | | | $0.20 | $0.20 |
|
|
72
|
+
| `digitalocean/mistral-7b-instruct-v0.3` | 33K | | | | | | — | — |
|
|
69
73
|
| `digitalocean/multi-qa-mpnet-base-dot-v1` | 512 | | | | | | $0.01 | — |
|
|
74
|
+
| `digitalocean/nemotron-3-nano-30b` | 262K | | | | | | — | — |
|
|
70
75
|
| `digitalocean/nemotron-3-nano-omni` | 66K | | | | | | $0.50 | $0.90 |
|
|
71
76
|
| `digitalocean/nemotron-nano-12b-v2-vl` | 128K | | | | | | $0.20 | $0.60 |
|
|
72
77
|
| `digitalocean/nvidia-nemotron-3-super-120b` | 256K | | | | | | $0.30 | $0.65 |
|
|
@@ -87,11 +92,13 @@ for await (const chunk of stream) {
|
|
|
87
92
|
| `digitalocean/openai-gpt-5.5` | 1.0M | | | | | | $5 | $30 |
|
|
88
93
|
| `digitalocean/openai-gpt-image-1` | — | | | | | | $5 | $40 |
|
|
89
94
|
| `digitalocean/openai-gpt-image-1.5` | — | | | | | | $5 | $10 |
|
|
95
|
+
| `digitalocean/openai-gpt-image-2` | — | | | | | | — | — |
|
|
90
96
|
| `digitalocean/openai-gpt-oss-120b` | 131K | | | | | | $0.10 | $0.70 |
|
|
91
97
|
| `digitalocean/openai-gpt-oss-20b` | 131K | | | | | | $0.05 | $0.45 |
|
|
92
98
|
| `digitalocean/openai-o1` | 200K | | | | | | $15 | $60 |
|
|
93
99
|
| `digitalocean/openai-o3` | 200K | | | | | | $2 | $8 |
|
|
94
100
|
| `digitalocean/openai-o3-mini` | 200K | | | | | | $1 | $4 |
|
|
101
|
+
| `digitalocean/qwen-2.5-14b-instruct` | 131K | | | | | | — | — |
|
|
95
102
|
| `digitalocean/qwen3-coder-flash` | 262K | | | | | | $0.45 | $2 |
|
|
96
103
|
| `digitalocean/qwen3-embedding-0.6b` | 8K | | | | | | $0.04 | — |
|
|
97
104
|
| `digitalocean/qwen3-tts-voicedesign` | 33K | | | | | | — | — |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Google
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 38 Google models through Mastra's model router. Authentication is handled automatically using the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Google documentation](https://ai.google.dev/gemini-api/docs/pricing).
|
|
6
6
|
|
|
@@ -54,6 +54,7 @@ for await (const chunk of stream) {
|
|
|
54
54
|
| `google/gemini-3-flash-preview` | 1.0M | | | | | | $0.50 | $3 |
|
|
55
55
|
| `google/gemini-3-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
56
56
|
| `google/gemini-3.1-flash-image-preview` | 131K | | | | | | $0.25 | $60 |
|
|
57
|
+
| `google/gemini-3.1-flash-lite` | 1.0M | | | | | | $0.25 | $2 |
|
|
57
58
|
| `google/gemini-3.1-flash-lite-preview` | 1.0M | | | | | | $0.25 | $2 |
|
|
58
59
|
| `google/gemini-3.1-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
59
60
|
| `google/gemini-3.1-pro-preview-customtools` | 1.0M | | | | | | $2 | $12 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Poe
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 124 Poe models through Mastra's model router. Authentication is handled automatically using the `POE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Poe documentation](https://creator.poe.com/docs/external-applications/openai-compatible-api).
|
|
6
6
|
|
|
@@ -51,6 +51,8 @@ for await (const chunk of stream) {
|
|
|
51
51
|
| `poe/elevenlabs/elevenlabs-music` | 2K | | | | | | — | — |
|
|
52
52
|
| `poe/elevenlabs/elevenlabs-v2.5-turbo` | 128K | | | | | | — | — |
|
|
53
53
|
| `poe/elevenlabs/elevenlabs-v3` | 128K | | | | | | — | — |
|
|
54
|
+
| `poe/empiriolabs/deepseek-v4-flash-el` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
55
|
+
| `poe/empiriolabs/deepseek-v4-pro-el` | 1.0M | | | | | | $2 | $3 |
|
|
54
56
|
| `poe/fireworks-ai/kimi-k2.5-fw` | 262K | | | | | | — | — |
|
|
55
57
|
| `poe/google/gemini-2.0-flash` | 990K | | | | | | $0.10 | $0.42 |
|
|
56
58
|
| `poe/google/gemini-2.0-flash-lite` | 990K | | | | | | $0.05 | $0.21 |
|
|
@@ -87,6 +89,7 @@ for await (const chunk of stream) {
|
|
|
87
89
|
| `poe/novita/glm-5` | 205K | | | | | | $1 | $3 |
|
|
88
90
|
| `poe/novita/kimi-k2-thinking` | 256K | | | | | | — | — |
|
|
89
91
|
| `poe/novita/kimi-k2.5` | 128K | | | | | | $0.60 | $3 |
|
|
92
|
+
| `poe/novita/kimi-k2.6` | 262K | | | | | | $0.96 | $4 |
|
|
90
93
|
| `poe/novita/minimax-m2.1` | 205K | | | | | | — | — |
|
|
91
94
|
| `poe/openai/dall-e-3` | 800 | | | | | | — | — |
|
|
92
95
|
| `poe/openai/gpt-3.5-turbo` | 16K | | | | | | $0.45 | $1 |
|
|
@@ -110,6 +110,8 @@ export const agent = new Agent({
|
|
|
110
110
|
|
|
111
111
|
**tools** (`ToolsInput | ({ requestContext: RequestContext }) => ToolsInput | Promise<ToolsInput>`): Tools that the agent can access. Can be provided statically or resolved dynamically.
|
|
112
112
|
|
|
113
|
+
**transform** (`ToolPayloadTransformPolicy`): Shared policy for transforming tool payloads before display streams or user-visible transcript messages receive them. Use per-tool \`transform\` on \`createTool()\` for tool-local rules.
|
|
114
|
+
|
|
113
115
|
**workflows** (`Record<string, Workflow> | ({ requestContext: RequestContext }) => Record<string, Workflow> | Promise<Record<string, Workflow>>`): Workflows that the agent can execute. Can be static or dynamically resolved.
|
|
114
116
|
|
|
115
117
|
**defaultOptions** (`AgentExecutionOptions | ({ requestContext: RequestContext }) => AgentExecutionOptions | Promise<AgentExecutionOptions>`): Default options used when calling \`stream()\` and \`generate()\`.
|
|
@@ -59,6 +59,8 @@ for await (const event of stream) {
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
Streaming responses can also include tool events. Tool-call streams use `response.output_item.added`, `response.function_call_arguments.delta`, `response.function_call_arguments.done`, and `response.output_item.done` events. Tool results appear as `function_call_output` items with `<toolCallId>:output` IDs.
|
|
63
|
+
|
|
62
64
|
**Returns:** `Promise<ResponsesStream>`.
|
|
63
65
|
|
|
64
66
|
#### `retrieve(responseId, requestContext?)`
|
|
@@ -130,6 +132,8 @@ Use [`client.conversations`](https://mastra.ai/reference/client-js/conversations
|
|
|
130
132
|
|
|
131
133
|
If the model calls a function, that activity appears in `response.output` as `function_call` and `function_call_output` items alongside the final assistant `message`.
|
|
132
134
|
|
|
135
|
+
When `stream: true`, function calls are also emitted as Responses stream events. Read `response.function_call_arguments.delta` events for partial argument chunks and prefer `response.function_call_arguments.done` for the finalized arguments payload and tool name. Read `response.output_item.done` events for completed `function_call` and `function_call_output` items. Tool output items use `<toolCallId>:output` IDs.
|
|
136
|
+
|
|
133
137
|
## Structured output
|
|
134
138
|
|
|
135
139
|
Use `text.format` when you want JSON output.
|
|
@@ -175,20 +175,20 @@ Custom ID generator function for creating unique identifiers. Mastra passes opti
|
|
|
175
175
|
> **Warning:** This is used internally by Mastra for creating IDs for workflow runs, agent conversations, and other resources. Most users won't need to configure this option.
|
|
176
176
|
|
|
177
177
|
```typescript
|
|
178
|
+
import { v4 as uuid } from '@lukeed/uuid'
|
|
178
179
|
import { Mastra } from '@mastra/core'
|
|
179
|
-
import { nanoid } from 'nanoid'
|
|
180
180
|
|
|
181
181
|
export const mastra = new Mastra({
|
|
182
182
|
idGenerator: context => {
|
|
183
183
|
if (context?.idType === 'message' && context?.threadId) {
|
|
184
|
-
return `msg-${context.threadId}-${
|
|
184
|
+
return `msg-${context.threadId}-${uuid()}`
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
if (context?.idType === 'run' && context?.source && context?.entityId) {
|
|
188
|
-
return `${context.source}-run-${context.entityId}-${
|
|
188
|
+
return `${context.source}-run-${context.entityId}-${uuid()}`
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
return
|
|
191
|
+
return uuid()
|
|
192
192
|
},
|
|
193
193
|
})
|
|
194
194
|
```
|
|
@@ -14,7 +14,7 @@ Tool providers implement these methods:
|
|
|
14
14
|
|
|
15
15
|
**getToolSchema(slug)** (`(slug: string) => Promise<JSONSchema>`): Returns the JSON schema for a specific tool identified by its slug.
|
|
16
16
|
|
|
17
|
-
**resolveTools(slugs, options?)** (`(slugs: string[], options?) => Promise<Record<string, ToolAction>>`): Resolves tool slugs into executable Mastra tool actions.
|
|
17
|
+
**resolveTools(slugs, options?)** (`(slugs: string[], options?) => Promise<Record<string, ToolAction>>`): Resolves tool slugs into executable Mastra tool actions. Built-in providers use resourceId from request context for per-user authentication.
|
|
18
18
|
|
|
19
19
|
***
|
|
20
20
|
|
|
@@ -47,7 +47,7 @@ Composio tools use uppercase slug format: `GITHUB_CREATE_ISSUE`, `SLACK_SEND_MES
|
|
|
47
47
|
|
|
48
48
|
### Authentication
|
|
49
49
|
|
|
50
|
-
Tool execution is scoped to
|
|
50
|
+
Tool execution is scoped to the `resourceId` passed through request context. The provider maps that value to the user identity required by Composio's auth flow.
|
|
51
51
|
|
|
52
52
|
***
|
|
53
53
|
|
|
@@ -82,4 +82,4 @@ Arcade tools use `Toolkit.ToolName` format: `Github.GetRepository`, `Slack.SendM
|
|
|
82
82
|
|
|
83
83
|
### Authentication
|
|
84
84
|
|
|
85
|
-
Like Composio, tool execution
|
|
85
|
+
Like Composio, tool execution uses `resourceId` from request context for per-user authorization. The provider maps that value to the user identity required by Arcade's auth flow.
|
|
@@ -98,7 +98,7 @@ await harness.sendMessage({ content: 'Hello!' })
|
|
|
98
98
|
|
|
99
99
|
**omConfig** (`HarnessOMConfig`): Default configuration for observational memory (observer/reflector model IDs and thresholds).
|
|
100
100
|
|
|
101
|
-
**disableBuiltinTools** (`BuiltinToolId[]`): Built-in harness tool IDs to remove from the \`harnessBuiltIn\` toolset. Valid values are \`ask\_user\`, \`submit\_plan\`, \`task\_write\`, \`task\_check\`, and \`subagent\`.
|
|
101
|
+
**disableBuiltinTools** (`BuiltinToolId[]`): Built-in harness tool IDs to remove from the \`harnessBuiltIn\` toolset. Valid values are \`ask\_user\`, \`submit\_plan\`, \`task\_write\`, \`task\_update\`, \`task\_complete\`, \`task\_check\`, and \`subagent\`.
|
|
102
102
|
|
|
103
103
|
**heartbeatHandlers** (`HeartbeatHandler[]`): Periodic background tasks started during \`init()\`. Use for gateway sync, cache refresh, and similar tasks.
|
|
104
104
|
|
|
@@ -162,6 +162,17 @@ Return the current `HarnessDisplayState` snapshot for UI rendering.
|
|
|
162
162
|
const displayState = harness.getDisplayState()
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
+
#### `restoreDisplayTasks(tasks)`
|
|
166
|
+
|
|
167
|
+
Restore the task portion of `HarnessDisplayState` after a UI replays persisted task tool history. This emits `display_state_changed` without emitting a live `task_updated` event.
|
|
168
|
+
|
|
169
|
+
If later task tools should read the replayed tasks, persist the same task list with `setState({ tasks })` before calling `restoreDisplayTasks(tasks)`.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
await harness.setState({ tasks: replayedTasks })
|
|
173
|
+
harness.restoreDisplayTasks(replayedTasks)
|
|
174
|
+
```
|
|
175
|
+
|
|
165
176
|
#### `setState(updates)`
|
|
166
177
|
|
|
167
178
|
Update the harness state. Validates against `stateSchema` if provided, and emits a `state_changed` event with the new state and changed keys.
|
|
@@ -831,13 +842,15 @@ The harness emits events through registered listeners. The following table lists
|
|
|
831
842
|
|
|
832
843
|
The harness provides built-in tools to agents in every mode:
|
|
833
844
|
|
|
834
|
-
| Tool
|
|
835
|
-
|
|
|
836
|
-
| `ask_user`
|
|
837
|
-
| `submit_plan`
|
|
838
|
-
| `task_write`
|
|
839
|
-
| `
|
|
840
|
-
| `
|
|
845
|
+
| Tool | Description |
|
|
846
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
847
|
+
| `ask_user` | Ask the user a question and wait for their response. Supports free text, single-select choices, and multi-select choices. |
|
|
848
|
+
| `submit_plan` | Submit a plan for user review and approval. |
|
|
849
|
+
| `task_write` | Create or replace a structured task list for tracking progress. Assigns task IDs when omitted and returns the structured task list snapshot. |
|
|
850
|
+
| `task_update` | Update one tracked task by ID and return the structured task list snapshot. |
|
|
851
|
+
| `task_complete` | Mark one tracked task completed by ID and return the structured task list snapshot. |
|
|
852
|
+
| `task_check` | Check the completion status of the current task list and return `tasks`, `summary`, `incompleteTasks`, and `isError` fields. |
|
|
853
|
+
| `subagent` | Spawn a focused subagent with constrained tools (only available when `subagents` is configured). Pass `forked: true` to inherit the parent conversation — see [Forked subagents](#forked-subagents). |
|
|
841
854
|
|
|
842
855
|
### `ask_user` selections
|
|
843
856
|
|
package/.docs/reference/index.md
CHANGED
|
@@ -278,6 +278,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
278
278
|
- [Run Class](https://mastra.ai/reference/workflows/run)
|
|
279
279
|
- [Step Class](https://mastra.ai/reference/workflows/step)
|
|
280
280
|
- [Workflow Class](https://mastra.ai/reference/workflows/workflow)
|
|
281
|
+
- [Workflow State Reader](https://mastra.ai/reference/workflows/workflow-state-reader)
|
|
281
282
|
- [.branch()](https://mastra.ai/reference/workflows/workflow-methods/branch)
|
|
282
283
|
- [.commit()](https://mastra.ai/reference/workflows/workflow-methods/commit)
|
|
283
284
|
- [.createRun()](https://mastra.ai/reference/workflows/workflow-methods/create-run)
|
|
@@ -7,6 +7,7 @@ interface ObservabilityRegistryConfig {
|
|
|
7
7
|
default?: { enabled?: boolean }
|
|
8
8
|
configs?: Record<string, Omit<ObservabilityInstanceConfig, 'name'> | ObservabilityInstance>
|
|
9
9
|
configSelector?: ConfigSelector
|
|
10
|
+
sensitiveDataFilter?: boolean | SensitiveDataFilterOptions
|
|
10
11
|
}
|
|
11
12
|
```
|
|
12
13
|
|
|
@@ -16,6 +17,8 @@ interface ObservabilityRegistryConfig {
|
|
|
16
17
|
|
|
17
18
|
**configSelector** (`ConfigSelector`): Runtime configuration selector function
|
|
18
19
|
|
|
20
|
+
**sensitiveDataFilter** (`boolean | SensitiveDataFilterOptions`): Controls whether a \[SensitiveDataFilter]\(/reference/observability/tracing/processors/sensitive-data-filter) is auto-applied to every configured instance. Defaults to \`true\`. Pass \`false\` to opt out, or pass a \`SensitiveDataFilterOptions\` object to customize fields, redaction token, or redaction style. If a config already includes a \`SensitiveDataFilter\` in \`spanOutputProcessors\`, it is not duplicated. Pre-instantiated instances are not modified.
|
|
21
|
+
|
|
19
22
|
## `ObservabilityInstanceConfig`
|
|
20
23
|
|
|
21
24
|
```typescript
|
|
@@ -128,6 +128,8 @@ Failed flushes are retried with exponential backoff:
|
|
|
128
128
|
- Maximum attempts: `maxRetries`
|
|
129
129
|
- Batch is dropped after all retries fail
|
|
130
130
|
|
|
131
|
+
When storage does not support a signal or retries are exhausted, `DefaultExporter` emits an `ObservabilityDropEvent` through `onDroppedEvent` handlers registered on exporters and bridges. The drop event includes the signal, reason, count, exporter name, storage name when known, and sanitized error details.
|
|
132
|
+
|
|
131
133
|
### Out-of-Order Handling
|
|
132
134
|
|
|
133
135
|
For `batch-with-updates` strategy:
|
|
@@ -141,10 +141,18 @@ interface ObservabilityExporter {
|
|
|
141
141
|
/** Handle feedback events */
|
|
142
142
|
onFeedbackEvent?(event: FeedbackEvent): void | Promise<void>
|
|
143
143
|
|
|
144
|
+
/** Handle exporter pipeline droppedEvent */
|
|
145
|
+
onDroppedEvent?(event: ObservabilityDropEvent): void | Promise<void>
|
|
146
|
+
|
|
144
147
|
/** Export tracing events */
|
|
145
148
|
exportTracingEvent(event: TracingEvent): Promise<void>
|
|
146
149
|
|
|
147
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* @deprecated Implement `onScoreEvent` instead. Eval scores now flow through the
|
|
152
|
+
* unified observability bus as `ScoreEvent`s. This method is preserved on the
|
|
153
|
+
* interface for backwards compatibility with existing exporters; new exporters
|
|
154
|
+
* should not implement it.
|
|
155
|
+
*/
|
|
148
156
|
addScoreToTrace?({
|
|
149
157
|
traceId,
|
|
150
158
|
spanId,
|
|
@@ -171,6 +179,33 @@ interface ObservabilityExporter {
|
|
|
171
179
|
|
|
172
180
|
Event callback payloads use observability event bus envelopes: `TracingEvent` carries span lifecycle events with `exportedSpan`, `LogEvent` wraps `ExportedLog` in `log`, `MetricEvent` wraps `ExportedMetric` in `metric`, `ScoreEvent` wraps `ExportedScore` in `score`, and `FeedbackEvent` wraps `ExportedFeedback` in `feedback`. For Cloud exporter behavior for these callbacks, see [CloudExporter](https://mastra.ai/reference/observability/tracing/exporters/cloud-exporter).
|
|
173
181
|
|
|
182
|
+
### `ObservabilityDropEvent`
|
|
183
|
+
|
|
184
|
+
Structured event emitted when the exporter pipeline drops observability events.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
type ObservabilityDropSignal = 'tracing' | 'log' | 'metric' | 'score' | 'feedback'
|
|
188
|
+
|
|
189
|
+
type ObservabilityDropReason = 'unsupported-storage' | 'retry-exhausted'
|
|
190
|
+
|
|
191
|
+
interface ObservabilityDropEvent {
|
|
192
|
+
type: 'drop'
|
|
193
|
+
signal: ObservabilityDropSignal
|
|
194
|
+
reason: ObservabilityDropReason
|
|
195
|
+
count: number
|
|
196
|
+
timestamp: Date
|
|
197
|
+
exporterName: string
|
|
198
|
+
storageName?: string
|
|
199
|
+
error?: {
|
|
200
|
+
id?: string
|
|
201
|
+
domain?: string
|
|
202
|
+
message: string
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Use `onDroppedEvent` on a custom exporter or bridge to forward these events to external metrics or alerting systems.
|
|
208
|
+
|
|
174
209
|
### `SpanOutputProcessor`
|
|
175
210
|
|
|
176
211
|
Interface for span output processors.
|
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
A SpanOutputProcessor that redacts sensitive information from span fields.
|
|
4
4
|
|
|
5
|
+
## Auto-applied by default
|
|
6
|
+
|
|
7
|
+
`Observability` automatically appends a `SensitiveDataFilter` to every configured instance's `spanOutputProcessors` so secrets are redacted before they reach exporters such as the Mastra cloud exporter. The filter runs last (after any user-provided processors) so that sensitive data introduced or surfaced by upstream processors is still redacted. You do not need to add it manually unless you want to customize its options.
|
|
8
|
+
|
|
9
|
+
To opt out or customize the auto-applied filter, use the `sensitiveDataFilter` option on the [`Observability` registry config](https://mastra.ai/reference/observability/tracing/configuration):
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Observability } from '@mastra/observability'
|
|
13
|
+
|
|
14
|
+
new Observability({
|
|
15
|
+
configs: {
|
|
16
|
+
/* ... */
|
|
17
|
+
},
|
|
18
|
+
// disable the auto-applied filter
|
|
19
|
+
sensitiveDataFilter: false,
|
|
20
|
+
// or customize it
|
|
21
|
+
// sensitiveDataFilter: { sensitiveFields: ['mySecret'], redactionStyle: 'partial' },
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If a config already includes a `SensitiveDataFilter` in `spanOutputProcessors`, the auto-applied filter is skipped to avoid double redaction. Pre-instantiated `ObservabilityInstance` values are not modified — add a `SensitiveDataFilter` to their processors yourself if needed.
|
|
26
|
+
|
|
5
27
|
## Constructor
|
|
6
28
|
|
|
7
29
|
```typescript
|
|
@@ -173,6 +173,50 @@ The tool still returns the full `execute` result to your application, while the
|
|
|
173
173
|
- `type: 'json'`
|
|
174
174
|
- `type: 'content'` with parts like `text`, `image-url`, `image-data`, `file-url`, `file-data`, `file-id`, `image-file-id`, or `custom`
|
|
175
175
|
|
|
176
|
+
## Example with `transform`
|
|
177
|
+
|
|
178
|
+
Use `transform` when the tool should keep raw inputs or outputs for runtime behavior, but display streams or transcript messages should receive a smaller or safer shape.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { createTool } from '@mastra/core/tools'
|
|
182
|
+
import { z } from 'zod'
|
|
183
|
+
|
|
184
|
+
export const customerTool = createTool({
|
|
185
|
+
id: 'lookup-customer',
|
|
186
|
+
description: 'Looks up a customer',
|
|
187
|
+
inputSchema: z.object({
|
|
188
|
+
customerId: z.string(),
|
|
189
|
+
internalPath: z.string(),
|
|
190
|
+
}),
|
|
191
|
+
outputSchema: z.object({
|
|
192
|
+
displayName: z.string(),
|
|
193
|
+
apiKey: z.string(),
|
|
194
|
+
debugScore: z.number(),
|
|
195
|
+
}),
|
|
196
|
+
execute: async () => {
|
|
197
|
+
return {
|
|
198
|
+
displayName: 'Acme',
|
|
199
|
+
apiKey: 'secret-value',
|
|
200
|
+
debugScore: 0.97,
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
transform: {
|
|
204
|
+
display: {
|
|
205
|
+
input: ({ input }) => ({ customerId: input?.customerId }),
|
|
206
|
+
output: ({ output }) => ({ displayName: output?.displayName }),
|
|
207
|
+
error: () => ({ message: 'Customer lookup failed' }),
|
|
208
|
+
},
|
|
209
|
+
transcript: {
|
|
210
|
+
input: ({ input }) => ({ customerId: input?.customerId }),
|
|
211
|
+
output: ({ output }) => ({ displayName: output?.displayName }),
|
|
212
|
+
error: () => ({ message: 'Customer lookup failed' }),
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
})
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The tool still receives the raw `inputSchema` value and returns the raw `execute` result. Mastra applies `display` transforms to streamed UI payloads and `transcript` transforms to user-visible transcript messages.
|
|
219
|
+
|
|
176
220
|
## Example with MCP annotations
|
|
177
221
|
|
|
178
222
|
When exposing tools via MCP (Model Context Protocol), you can add annotations to describe tool behavior and customize how clients display the tool. These MCP-specific properties are grouped under the `mcp` property:
|
|
@@ -224,6 +268,8 @@ export const weatherTool = createTool({
|
|
|
224
268
|
|
|
225
269
|
**toModelOutput** (`(output: TSchemaOut) => unknown`): Optional function that transforms the tool's \`execute\` output before it is sent back to the model. Use this to return \`text\`, \`json\`, or \`content\`-shaped outputs (including multimodal parts like images/files) to the model while still keeping the full raw output in your application code.
|
|
226
270
|
|
|
271
|
+
**transform** (`ToolPayloadTransform`): Optional target-aware transform for tool payloads before they leave runtime for display streams or user-visible transcript messages. Configure \`display\` and \`transcript\` transforms for phases such as \`input\`, \`inputDelta\`, \`output\`, \`error\`, \`approval\`, \`suspend\`, and \`resume\`.
|
|
272
|
+
|
|
227
273
|
**suspendSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the structure of the payload passed to \`suspend()\`. This payload is returned to the client when the tool suspends execution.
|
|
228
274
|
|
|
229
275
|
**resumeSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected structure of \`resumeData\` when the tool is resumed. Used by the agent to extract data from user messages when \`autoResumeSuspendedTools\` is enabled.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Workflow state reader
|
|
2
|
+
|
|
3
|
+
Workflow state reader helpers inspect the public `WorkflowState` returned by `workflow.getWorkflowRunById()`. Use them to recover suspended runs, inspect resume labels, and read step payloads or outputs without parsing raw workflow snapshots.
|
|
4
|
+
|
|
5
|
+
## Usage example
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { createWorkflowStateReader } from '@mastra/core/workflows'
|
|
9
|
+
|
|
10
|
+
const state = await workflow.getWorkflowRunById('run-123')
|
|
11
|
+
|
|
12
|
+
if (state) {
|
|
13
|
+
const reader = createWorkflowStateReader(state)
|
|
14
|
+
const suspendedStep = reader.getSuspendedStep()
|
|
15
|
+
const labels = reader.getResumeLabels()
|
|
16
|
+
|
|
17
|
+
console.log(reader.getStatus())
|
|
18
|
+
console.log(reader.getStepOutput('extract-data'))
|
|
19
|
+
console.log(suspendedStep?.path)
|
|
20
|
+
console.log(labels.approve)
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Functions
|
|
25
|
+
|
|
26
|
+
### `createWorkflowStateReader(state)`
|
|
27
|
+
|
|
28
|
+
Creates a reader object with methods bound to one `WorkflowState`.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const reader = createWorkflowStateReader(state)
|
|
32
|
+
const suspendedStep = reader.getSuspendedStep()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `getWorkflowStepOutput(state, stepId)`
|
|
36
|
+
|
|
37
|
+
Returns the output for a step ID, including nested workflow dot paths such as `parent.child`. For `foreach` steps, returns one entry per iteration; suspended iterations can have `undefined` output entries.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const output = getWorkflowStepOutput(state, 'extract-data')
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### `getWorkflowStepPayload(state, stepId)`
|
|
44
|
+
|
|
45
|
+
Returns the payload that was passed to a step. For `foreach` steps, returns one entry per iteration.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
const payload = getWorkflowStepPayload(state, 'extract-data')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `getWorkflowSuspendedStep(state)`
|
|
52
|
+
|
|
53
|
+
Returns the first suspended step from the workflow state. When multiple steps are suspended, ordering follows the order stored in `suspendedPaths`.
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const suspendedStep = getWorkflowSuspendedStep(state)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `getWorkflowSuspendedSteps(state)`
|
|
60
|
+
|
|
61
|
+
Returns all suspended steps from the workflow state. Each result includes the top-level step ID, resume path, execution path, suspend payload, suspend output, and matching resume labels.
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const suspendedSteps = getWorkflowSuspendedSteps(state)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `getWorkflowResumeLabel(state, label)`
|
|
68
|
+
|
|
69
|
+
Returns a resume label by name.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const label = getWorkflowResumeLabel(state, 'approve')
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `getWorkflowResumeLabels(state)`
|
|
76
|
+
|
|
77
|
+
Returns all resume labels from the workflow state.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const labels = getWorkflowResumeLabels(state)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Reader methods
|
|
84
|
+
|
|
85
|
+
`createWorkflowStateReader(state)` returns the following methods:
|
|
86
|
+
|
|
87
|
+
**getStatus** (`() => WorkflowRunStatus`): Returns the workflow run status.
|
|
88
|
+
|
|
89
|
+
**getResult** (`() => WorkflowState["result"]`): Returns the terminal workflow result when it exists.
|
|
90
|
+
|
|
91
|
+
**getError** (`() => WorkflowState["error"]`): Returns the terminal workflow error when it exists.
|
|
92
|
+
|
|
93
|
+
**getStepOutput** (`(stepId: string) => any | Array<any | undefined> | undefined`): Returns the output for a step ID or nested workflow dot path.
|
|
94
|
+
|
|
95
|
+
**getStepPayload** (`(stepId: string) => any | Array<any | undefined> | undefined`): Returns the payload for a step ID or nested workflow dot path.
|
|
96
|
+
|
|
97
|
+
**getSuspendedStep** (`() => { stepId: string; path: string[]; executionPath?: number[]; step?: NonNullable<WorkflowState["steps"]>[string]; payload?: any; suspendPayload?: any; suspendOutput?: any; resumeLabels: Record<string, { stepId: string; foreachIndex?: number }> } | undefined`): Returns the first suspended step.
|
|
98
|
+
|
|
99
|
+
**getSuspendedSteps** (`() => Array<{ stepId: string; path: string[]; executionPath?: number[]; step?: NonNullable<WorkflowState["steps"]>[string]; payload?: any; suspendPayload?: any; suspendOutput?: any; resumeLabels: Record<string, { stepId: string; foreachIndex?: number }> }>`): Returns all suspended steps.
|
|
100
|
+
|
|
101
|
+
**getResumeLabel** (`(label: string) => { stepId: string; foreachIndex?: number } | undefined`): Returns a resume label by name.
|
|
102
|
+
|
|
103
|
+
**getResumeLabels** (`() => Record<string, { stepId: string; foreachIndex?: number }>`): Returns all resume labels.
|
|
104
|
+
|
|
105
|
+
## Notes
|
|
106
|
+
|
|
107
|
+
`requestContext` and `tracingContext` are only returned by `workflow.getWorkflowRunById()` when explicitly requested with `fields`.
|
|
108
|
+
|
|
109
|
+
## Related
|
|
110
|
+
|
|
111
|
+
- [Suspend & resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
112
|
+
- [Snapshots](https://mastra.ai/docs/workflows/snapshots)
|
|
113
|
+
- [Workflow class](https://mastra.ai/reference/workflows/workflow)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.35-alpha.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`6742347`](https://github.com/mastra-ai/mastra/commit/6742347d71955d7639adc9ddf6ff8282de7ee3ba), [`7b0ad1f`](https://github.com/mastra-ai/mastra/commit/7b0ad1f5c53dc118c6da12ae82ae2587037dc2b8), [`62666c3`](https://github.com/mastra-ai/mastra/commit/62666c367eaeac3941ead454b1d38810cc855721), [`4af2160`](https://github.com/mastra-ai/mastra/commit/4af2160322f4718cac421930cce85641e9512389), [`136c959`](https://github.com/mastra-ai/mastra/commit/136c9592fb0eeb0cd212f28629d8a29b7557a2fc), [`4df7cc7`](https://github.com/mastra-ai/mastra/commit/4df7cc79342fd065fe7fdeef93c094db14b12bcd), [`aca3121`](https://github.com/mastra-ai/mastra/commit/aca31211233dac25459f140ea4fcfb3a5af64c18), [`9cdf38e`](https://github.com/mastra-ai/mastra/commit/9cdf38e58506e1109c8b38f97cd7770978a4218e), [`990851e`](https://github.com/mastra-ai/mastra/commit/990851edcb0e30be5c2c18b6532f1a876cc2d335), [`6068a6c`](https://github.com/mastra-ai/mastra/commit/6068a6c42950fad3ebfc92346417896ba60803d2), [`00106be`](https://github.com/mastra-ai/mastra/commit/00106bede59b81e5b0e9cd6aad8d3b5dbc336387), [`e2a079c`](https://github.com/mastra-ai/mastra/commit/e2a079cc3755b1895f7bd5dc36e9be81b11c7c22), [`534a456`](https://github.com/mastra-ai/mastra/commit/534a456a25e4df1e5407e7e632f4cb3b1fa14f9d), [`36bae07`](https://github.com/mastra-ai/mastra/commit/36bae07c0e70b1b3006f2fd20830e8883dcbd066)]:
|
|
8
|
+
- @mastra/core@1.33.0-alpha.7
|
|
9
|
+
|
|
10
|
+
## 1.1.35-alpha.12
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`b560d6f`](https://github.com/mastra-ai/mastra/commit/b560d6f88b9b904b15c10f75c949eb145bc27684), [`36b3bbf`](https://github.com/mastra-ai/mastra/commit/36b3bbf5a8d59f7e23d47e29340e76c681b4929c), [`b275631`](https://github.com/mastra-ai/mastra/commit/b275631dc10541a482b2e2d4a3e3cfa843bd5fa1)]:
|
|
15
|
+
- @mastra/core@1.33.0-alpha.6
|
|
16
|
+
|
|
3
17
|
## 1.1.35-alpha.11
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.35-alpha.
|
|
3
|
+
"version": "1.1.35-alpha.15",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
32
|
"@mastra/mcp": "^1.7.0",
|
|
33
|
-
"@mastra/core": "1.33.0-alpha.
|
|
33
|
+
"@mastra/core": "1.33.0-alpha.7"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.19.11",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vitest": "4.1.5",
|
|
49
49
|
"@internal/lint": "0.0.92",
|
|
50
50
|
"@internal/types-builder": "0.0.67",
|
|
51
|
-
"@mastra/core": "1.33.0-alpha.
|
|
51
|
+
"@mastra/core": "1.33.0-alpha.7"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|