@mastra/mcp-docs-server 1.3.10-alpha.0 → 1.3.10-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/models/gateways/vercel.md +1 -6
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/cortecs.md +2 -2
- package/.docs/models/providers/inceptron.md +2 -2
- package/.docs/models/providers/kilo.md +2 -2
- package/.docs/models/providers/nano-gpt.md +6 -4
- package/.docs/reference/agent-controller/agent-controller-class.md +1 -1
- package/.docs/reference/agent-controller/session.md +5 -5
- package/.docs/reference/agents/agent.md +2 -2
- package/.docs/reference/agents/channels.md +3 -3
- package/.docs/reference/agents/durable-agent.md +11 -11
- package/.docs/reference/client-js/agent-controller.md +1 -1
- package/.docs/reference/client-js/agents.md +17 -1
- package/.docs/reference/client-js/datasets.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/connect/channels.md +1 -1
- package/.docs/reference/connect/tools.md +7 -7
- package/.docs/reference/core/mastra-class.md +3 -3
- package/.docs/reference/datasets/startExperiment.md +15 -0
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +1 -1
- package/.docs/reference/observability/tracing/bridges/otel.md +1 -1
- package/.docs/reference/processors/file-upload-processor.md +4 -4
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/provider-history-compat.md +1 -1
- package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +1 -1
- package/.docs/reference/processors/tool-call-filter.md +1 -1
- package/.docs/reference/processors/tool-search-processor.md +1 -1
- package/.docs/reference/pubsub/redis-streams.md +10 -0
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/signals/notifications.md +2 -2
- package/.docs/reference/storage/retention.md +1 -1
- package/.docs/reference/streaming/ChunkType.md +2 -2
- package/.docs/reference/streaming/agents/stream.md +2 -2
- package/.docs/reference/tools/create-tool.md +2 -2
- package/.docs/reference/tools/mcp-client.md +1 -1
- package/.docs/reference/tools/mcp-server.md +2 -2
- package/.docs/reference/vectors/turbopuffer.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +12 -12
- package/package.json +7 -7
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Vercel
|
|
6
6
|
|
|
7
|
-
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
7
|
+
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 414 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Vercel documentation](https://ai-sdk.dev/providers/ai-sdk-providers).
|
|
10
10
|
|
|
@@ -280,14 +280,11 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
280
280
|
| `nvidia/nemotron-3.5-super-vl` |
|
|
281
281
|
| `nvidia/nemotron-nano-12b-v2-vl` |
|
|
282
282
|
| `nvidia/nemotron-nano-9b-v2` |
|
|
283
|
-
| `openai/gpt-3.5-turbo` |
|
|
284
|
-
| `openai/gpt-4-turbo` |
|
|
285
283
|
| `openai/gpt-4.1` |
|
|
286
284
|
| `openai/gpt-4.1-fast` |
|
|
287
285
|
| `openai/gpt-4.1-mini` |
|
|
288
286
|
| `openai/gpt-4.1-mini-fast` |
|
|
289
287
|
| `openai/gpt-4.1-nano` |
|
|
290
|
-
| `openai/gpt-4.1-nano-fast` |
|
|
291
288
|
| `openai/gpt-4o` |
|
|
292
289
|
| `openai/gpt-4o-fast` |
|
|
293
290
|
| `openai/gpt-4o-mini` |
|
|
@@ -335,7 +332,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
335
332
|
| `openai/gpt-6-sol-fast` |
|
|
336
333
|
| `openai/gpt-6.1-sol` |
|
|
337
334
|
| `openai/gpt-6.1-sol-fast` |
|
|
338
|
-
| `openai/gpt-image-1` |
|
|
339
335
|
| `openai/gpt-image-1-mini` |
|
|
340
336
|
| `openai/gpt-image-1.5` |
|
|
341
337
|
| `openai/gpt-image-2` |
|
|
@@ -357,7 +353,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
357
353
|
| `openai/o3-mini` |
|
|
358
354
|
| `openai/o3-pro` |
|
|
359
355
|
| `openai/o4-mini` |
|
|
360
|
-
| `openai/o4-mini-fast` |
|
|
361
356
|
| `openai/text-embedding-3-large` |
|
|
362
357
|
| `openai/text-embedding-3-small` |
|
|
363
358
|
| `openai/text-embedding-ada-002` |
|
package/.docs/models/index.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Model Providers
|
|
6
6
|
|
|
7
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
7
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 8171 models from 218 providers through a single API.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -57,7 +57,7 @@ for await (const chunk of stream) {
|
|
|
57
57
|
| `cortecs/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
58
58
|
| `cortecs/deepseek-v4-pro-0813` | 1.0M | | | | | | $2 | $4 |
|
|
59
59
|
| `cortecs/deepseek-v4.1-flash` | 1.0M | | | | | | $0.20 | $0.60 |
|
|
60
|
-
| `cortecs/deepseek-v4.1-flash-1017` | 1.0M | | | | | | $0.
|
|
60
|
+
| `cortecs/deepseek-v4.1-flash-1017` | 1.0M | | | | | | $0.28 | $1 |
|
|
61
61
|
| `cortecs/devstral-2512` | 256K | | | | | | $0.48 | $2 |
|
|
62
62
|
| `cortecs/gemini-2.5-flash` | 1.0M | | | | | | $0.30 | $2 |
|
|
63
63
|
| `cortecs/gemini-2.5-pro` | 1.0M | | | | | | $1 | $10 |
|
|
@@ -115,7 +115,7 @@ for await (const chunk of stream) {
|
|
|
115
115
|
| `cortecs/mistral-large-2512` | 256K | | | | | | $0.61 | $2 |
|
|
116
116
|
| `cortecs/mistral-large-4-0` | 1.0M | | | | | | $0.77 | $2 |
|
|
117
117
|
| `cortecs/mistral-medium-3.5` | 256K | | | | | | $2 | $8 |
|
|
118
|
-
| `cortecs/mistral-nemo-instruct-2407` |
|
|
118
|
+
| `cortecs/mistral-nemo-instruct-2407` | 118K | | | | | | $0.14 | $0.14 |
|
|
119
119
|
| `cortecs/mistral-small-2503` | 128K | | | | | | $0.11 | $0.33 |
|
|
120
120
|
| `cortecs/mistral-small-2603` | 262K | | | | | | $0.16 | $0.63 |
|
|
121
121
|
| `cortecs/mistral-small-3.2-24b-instruct-2506` | 131K | | | | | | $0.10 | $0.31 |
|
|
@@ -39,9 +39,9 @@ for await (const chunk of stream) {
|
|
|
39
39
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
40
|
| ---------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
41
|
| `inceptron/deepseek-ai/DeepSeek-V4-Flash-0731` | 1.0M | | | | | | $0.11 | $0.41 |
|
|
42
|
-
| `inceptron/moonshotai/Kimi-K2.6` | 262K | | | | | | $0.
|
|
42
|
+
| `inceptron/moonshotai/Kimi-K2.6` | 262K | | | | | | $0.60 | $3 |
|
|
43
43
|
| `inceptron/moonshotai/Kimi-K2.7-Code` | 262K | | | | | | $0.67 | $3 |
|
|
44
|
-
| `inceptron/zai-org/GLM-5.2` | 1.0M | | | | | | $0.
|
|
44
|
+
| `inceptron/zai-org/GLM-5.2` | 1.0M | | | | | | $0.65 | $3 |
|
|
45
45
|
| `inceptron/zai-org/GLM-5.3` | 1.0M | | | | | | $0.40 | $2 |
|
|
46
46
|
| `inceptron/zai-org/GLM-5.3-Flash` | 1.0M | | | | | | $0.18 | $0.69 |
|
|
47
47
|
|
|
@@ -43,7 +43,7 @@ for await (const chunk of stream) {
|
|
|
43
43
|
| `kilo/~anthropic/claude-opus-latest` | 1.0M | | | | | | $4 | $20 |
|
|
44
44
|
| `kilo/~anthropic/claude-sonnet-latest` | 1.0M | | | | | | $2 | $10 |
|
|
45
45
|
| `kilo/~deepseek/deepseek-flash-latest` | 1.0M | | | | | | $0.07 | $0.50 |
|
|
46
|
-
| `kilo/~deepseek/deepseek-pro-latest` | 1.0M | | | | | | $0.
|
|
46
|
+
| `kilo/~deepseek/deepseek-pro-latest` | 1.0M | | | | | | $0.26 | $8 |
|
|
47
47
|
| `kilo/~deepseek/deepseek-v4-flash-latest` | 1.0M | | | | | | $0.05 | $0.16 |
|
|
48
48
|
| `kilo/~google/gemini-flash-latest` | 1.0M | | | | | | $0.75 | $4 |
|
|
49
49
|
| `kilo/~google/gemini-pro-latest` | 1.0M | | | | | | $2 | $10 |
|
|
@@ -352,7 +352,7 @@ for await (const chunk of stream) {
|
|
|
352
352
|
| `kilo/qwen/qwen3.8-max-prime` | 1.0M | | | | | | $4 | $12 |
|
|
353
353
|
| `kilo/qwen/qwen3.8-omni-flash` | 1.0M | | | | | | $0.15 | $0.47 |
|
|
354
354
|
| `kilo/recursive/flint-v1.0:free` | 262K | | | | | | — | — |
|
|
355
|
-
| `kilo/reflection/beam-1.0-501b-a23b` | 1.0M | | | | | | $0.
|
|
355
|
+
| `kilo/reflection/beam-1.0-501b-a23b` | 1.0M | | | | | | $0.24 | $0.98 |
|
|
356
356
|
| `kilo/reflection/beam-free` | 1.0M | | | | | | — | — |
|
|
357
357
|
| `kilo/rekaai/reka-edge` | 16K | | | | | | $0.10 | $0.10 |
|
|
358
358
|
| `kilo/rekaai/reka-flash-3` | 66K | | | | | | $0.10 | $0.20 |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# NanoGPT
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 626 NanoGPT models through Mastra's model router. Authentication is handled automatically using the `NANO_GPT_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [NanoGPT documentation](https://docs.nano-gpt.com).
|
|
10
10
|
|
|
@@ -41,6 +41,7 @@ for await (const chunk of stream) {
|
|
|
41
41
|
| `nano-gpt/abacusai/Dracarys-72B-Instruct` | 33K | | | | | | $0.49 | $0.49 |
|
|
42
42
|
| `nano-gpt/abliteration-ai/abliterated-model` | 262K | | | | | | $1 | $3 |
|
|
43
43
|
| `nano-gpt/abliteration-ai/abliterated-model-large` | 1.0M | | | | | | $3 | $5 |
|
|
44
|
+
| `nano-gpt/abliteration-ai/abliterated-model-large-flash` | 1.0M | | | | | | $1 | $2 |
|
|
44
45
|
| `nano-gpt/abliteration-ai/abliterated-model-large-v2` | 1.0M | | | | | | $3 | $5 |
|
|
45
46
|
| `nano-gpt/agnes-3.0-flash` | 524K | | | | | | $0.05 | $0.15 |
|
|
46
47
|
| `nano-gpt/aion-labs/aion-2.0` | 131K | | | | | | $0.80 | $2 |
|
|
@@ -230,9 +231,9 @@ for await (const chunk of stream) {
|
|
|
230
231
|
| `nano-gpt/google/gemini-flash-latest` | 1.0M | | | | | | $0.75 | $4 |
|
|
231
232
|
| `nano-gpt/google/gemini-flash-lite-latest` | 1.0M | | | | | | $0.30 | $3 |
|
|
232
233
|
| `nano-gpt/google/gemini-pro-latest` | 1.0M | | | | | | $2 | $12 |
|
|
233
|
-
| `nano-gpt/google/gemma-4-26b-a4b-it` | 262K | | | | | | $0.
|
|
234
|
+
| `nano-gpt/google/gemma-4-26b-a4b-it` | 262K | | | | | | $0.09 | $0.30 |
|
|
234
235
|
| `nano-gpt/google/gemma-4-26b-a4b-it-cybersecurity` | 262K | | | | | | $0.11 | $0.33 |
|
|
235
|
-
| `nano-gpt/google/gemma-4-26b-a4b-it:thinking` | 262K | | | | | | $0.
|
|
236
|
+
| `nano-gpt/google/gemma-4-26b-a4b-it:thinking` | 262K | | | | | | $0.09 | $0.30 |
|
|
236
237
|
| `nano-gpt/google/gemma-4-31b-it` | 262K | | | | | | $0.14 | $0.40 |
|
|
237
238
|
| `nano-gpt/google/gemma-4-31b-it:thinking` | 262K | | | | | | $0.10 | $0.34 |
|
|
238
239
|
| `nano-gpt/google/gemma4-31b-splituntied` | 262K | | | | | | $0.10 | $0.30 |
|
|
@@ -431,6 +432,7 @@ for await (const chunk of stream) {
|
|
|
431
432
|
| `nano-gpt/poolside/laguna-s-2.1` | 1.0M | | | | | | $0.10 | $0.20 |
|
|
432
433
|
| `nano-gpt/poolside/laguna-s-2.1:thinking` | 1.0M | | | | | | $0.10 | $0.20 |
|
|
433
434
|
| `nano-gpt/prism-ml/ternary-bonsai-2-27b` | 262K | | | | | | $0.07 | $0.50 |
|
|
435
|
+
| `nano-gpt/prism-ml/ternary-bonsai-2-9b` | 262K | | | | | | $0.08 | $0.13 |
|
|
434
436
|
| `nano-gpt/qvq-max` | 128K | | | | | | $1 | $5 |
|
|
435
437
|
| `nano-gpt/qwen/qwen-2.5-72b-instruct` | 131K | | | | | | $0.36 | $0.40 |
|
|
436
438
|
| `nano-gpt/qwen/qwen-long` | 10.0M | | | | | | $0.10 | $0.41 |
|
|
@@ -562,7 +564,7 @@ for await (const chunk of stream) {
|
|
|
562
564
|
| `nano-gpt/TEE/qwen3.6-35b-a3b` | 262K | | | | | | $0.20 | $1 |
|
|
563
565
|
| `nano-gpt/TEE/qwen3.8-27b` | 262K | | | | | | $0.40 | $3 |
|
|
564
566
|
| `nano-gpt/tencent/hy3` | 262K | | | | | | $0.07 | $0.26 |
|
|
565
|
-
| `nano-gpt/tencent/hy4-preview` | 1.0M | | | | | | $0.
|
|
567
|
+
| `nano-gpt/tencent/hy4-preview` | 1.0M | | | | | | $0.83 | $3 |
|
|
566
568
|
| `nano-gpt/TheDrummer/Anubis-70B-v1` | 66K | | | | | | $0.31 | $0.31 |
|
|
567
569
|
| `nano-gpt/TheDrummer/Anubis-70B-v1.1` | 32K | | | | | | $0.31 | $0.31 |
|
|
568
570
|
| `nano-gpt/TheDrummer/Artemis-v1.1` | 262K | | | | | | $0.10 | $0.45 |
|
|
@@ -348,7 +348,7 @@ Returns: `Promise<StorageListMessagesOutput>` with controller-format messages.
|
|
|
348
348
|
|
|
349
349
|
#### `generateThreadTitle(options)`
|
|
350
350
|
|
|
351
|
-
Generate and store a title from a thread's conversation without creating a Session. `threadId` is required. `sessionId`, `model`, and `requestContext
|
|
351
|
+
Generate and store a title from a thread's conversation without creating a Session. `threadId` is required. Optional fields include `sessionId`, `model`, and `requestContext`. Passing `sessionId` borrows a live session's agent and request context. The method throws when the thread doesn't exist and returns `undefined` when the model produces no title.
|
|
352
352
|
|
|
353
353
|
```typescript
|
|
354
354
|
const title = await controller.generateThreadTitle({
|
|
@@ -112,7 +112,7 @@ Queue a message for the next run, or send it immediately while the session is id
|
|
|
112
112
|
|
|
113
113
|
#### `queueSignal(signal, { requestContext?, tracingContext?, tracingOptions? }?)`
|
|
114
114
|
|
|
115
|
-
Queue a typed signal for the next run, or send it immediately while the session is idle. The signal keeps its `type`, `tagName`, and `attributes`.
|
|
115
|
+
Queue a typed signal for the next run, or send it immediately while the session is idle. The signal keeps its `type`, `tagName`, and `attributes`. Set `signal.author` to record an author, because the session doesn't stamp one from `requestContext` as it does for `queueMessage()`.
|
|
116
116
|
|
|
117
117
|
```typescript
|
|
118
118
|
await session.queueSignal({
|
|
@@ -252,7 +252,7 @@ Resume a suspended tool with application-provided data. Supply `toolCallId` for
|
|
|
252
252
|
|
|
253
253
|
An addressed resume uses the source thread's mode, model, and thread-owned preferences, without selecting that thread or replacing the active thread's subscription. Tool state callbacks remain bound to the source even if you switch threads during execution. Host-owned custom state and permission rules remain shared.
|
|
254
254
|
|
|
255
|
-
After a process restart, a full address can recover a persisted suspension through the controller's configured agents. Recovery requires a uniquely identified originating agent and the existing resume authorization checks. A setup failure leaves the prompt retryable
|
|
255
|
+
After a process restart, a full address can recover a persisted suspension through the controller's configured agents. Recovery requires a uniquely identified originating agent and the existing resume authorization checks. A setup failure leaves the prompt retryable without finishing another thread's active run.
|
|
256
256
|
|
|
257
257
|
```typescript
|
|
258
258
|
await session.respondToToolSuspension({
|
|
@@ -326,7 +326,7 @@ Create a thread, bind the session to it, and open its event stream. Pass `reques
|
|
|
326
326
|
|
|
327
327
|
For a session created with `createInitialThread: false`, explicit mode, model, and thread-preference selections made before its first binding seed the first new thread. This also applies to `ensureId()` and the first message. Failed creation leaves those selections available for retry.
|
|
328
328
|
|
|
329
|
-
After the session has bound a conversation,
|
|
329
|
+
After the session has bound a conversation, each new thread uses controller defaults rather than the previous conversation's choices, even if you clear or delete the binding. Opening an existing thread restores that thread's settings instead of applying unbound startup selections.
|
|
330
330
|
|
|
331
331
|
```typescript
|
|
332
332
|
const thread = await session.thread.create({
|
|
@@ -532,7 +532,7 @@ const mode = session.mode.resolve()
|
|
|
532
532
|
|
|
533
533
|
### `session.mode.switch({ modeId })`
|
|
534
534
|
|
|
535
|
-
Switch to another mode
|
|
535
|
+
Switch to another mode, persist the mode on the active thread, and emit `mode_changed`. The active model stays the same unless you switch it separately, which is necessary when your host assigns different models to different modes.
|
|
536
536
|
|
|
537
537
|
```typescript
|
|
538
538
|
await session.mode.switch({ modeId: 'build' })
|
|
@@ -871,7 +871,7 @@ const added = await session.state.update(current => ({
|
|
|
871
871
|
|
|
872
872
|
A `Session` is a live runtime object. Its event bus, arbitrary custom state, permission rules, permission grants, follow-ups, and active stream don't automatically survive controller or process recreation. The host must restore the host-owned state it needs.
|
|
873
873
|
|
|
874
|
-
Configured storage persists threads and messages along with token usage, while thread settings restore mode, model, and supported preferences. Restored settings can include thinking level, observational memory, and subagent model selections with per-agent-type overrides. Persisted suspended runs can be recovered using their full suspension address and originating agent
|
|
874
|
+
Configured storage persists threads and messages along with token usage, while thread settings restore mode, model, and supported preferences. Restored settings can include thinking level, observational memory, and subagent model selections with per-agent-type overrides. Persisted suspended runs can be recovered using their full suspension address and originating agent, but arbitrary custom state still requires host-managed persistence.
|
|
875
875
|
|
|
876
876
|
While a run retains a source-thread view, successful in-memory preference writes remain available when returning to that thread even if best-effort metadata persistence fails. A cold restart can recover only persisted settings and controller defaults.
|
|
877
877
|
|
|
@@ -250,7 +250,7 @@ Use [`subscribeThreadEvents({ resourceId, threadId }, listener)`](https://mastra
|
|
|
250
250
|
|
|
251
251
|
### `queueSignal(signal, options)`
|
|
252
252
|
|
|
253
|
-
Queues a typed signal for the next turn on a thread. It behaves like `queueMessage()`, but accepts any signal input
|
|
253
|
+
Queues a typed signal for the next turn on a thread. It behaves like `queueMessage()`, but accepts any signal input and preserves its `type`, `tagName`, and `attributes` for the queued run.
|
|
254
254
|
|
|
255
255
|
```typescript
|
|
256
256
|
agent.queueSignal(
|
|
@@ -668,7 +668,7 @@ The hook context `metadata` includes `agentId` and `agentName`. Per-execution ho
|
|
|
668
668
|
|
|
669
669
|
## Editor overrides
|
|
670
670
|
|
|
671
|
-
When you register the [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor), the `editor` field controls which parts of an agent are defined in code and which are owned by Studio. Fields owned by code are read-only in Studio and are stripped from saved overrides. Fields owned by Studio must be omitted from code
|
|
671
|
+
When you register the [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor), the `editor` field controls which parts of an agent are defined in code and which are owned by Studio. Fields owned by code are read-only in Studio and are stripped from saved overrides. Fields owned by Studio must be omitted from code. The agent reads these fields from stored overrides and fails closed when they're missing.
|
|
672
672
|
|
|
673
673
|
**editor** (`false | { instructions?: boolean; tools?: boolean | { description?: boolean } }`): Omit to allow editing instructions and tools, using values in code as defaults. Set to false to lock the agent. Set instructions: true to make Studio own the instructions; omit instructions from code. Set tools: true to make Studio own tool membership and descriptions; omit tools from code. Set tools: { description: true } to keep tool membership in code and allow only description edits.
|
|
674
674
|
|
|
@@ -122,7 +122,7 @@ const agent = new Agent({
|
|
|
122
122
|
|
|
123
123
|
Pass a function to `toolDisplay` for fully custom rendering. The function receives a `ToolDisplayEvent` (`running` / `result` / `error` / `approval` / `approved` / `denied`) and a `ToolDisplayContext` (`{ mode, platform }`); return `{ kind: 'post', message }` for a discrete post/edit, `{ kind: 'stream', chunk }` to push into the active streaming widget, or `undefined` to skip rendering that event.
|
|
124
124
|
|
|
125
|
-
After a user
|
|
125
|
+
After a user selects Approve or Deny, Mastra sends an `approved` or `denied` event. Both include `byUser`, the name of the user who responded, which is undefined in DMs. A `post` result replaces the approval card in place. If the function returns nothing, a blank message, or throws, Mastra shows the default "Approved" or "Denied" card, which names the user outside DMs.
|
|
126
126
|
|
|
127
127
|
By default, a stream result opens a streaming session when none is active. Set `openIfEmpty: false` when the chunk only applies to an existing session. Mastra skips the chunk when no session is active. Static channels ignore this option and keep their existing plain-text fallback behavior.
|
|
128
128
|
|
|
@@ -143,7 +143,7 @@ toolDisplay: event => {
|
|
|
143
143
|
}
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
Approve/deny prompts (`requireApproval`) render as a separate built-in card in every string mode, because inline task entries can't carry interactive buttons. With a `toolDisplay` function, the `approval` event is passed to your function in both streaming and static modes; return a non-blank `{ kind: 'post', message }` to replace the built-in card with your own message (for example, a localized one). Returning `undefined`, a blank message, or `{ kind: 'stream' }` falls back to the built-in card so the
|
|
146
|
+
Approve/deny prompts (`requireApproval`) render as a separate built-in card in every string mode, because inline task entries can't carry interactive buttons. With a `toolDisplay` function, the `approval` event is passed to your function in both streaming and static modes; return a non-blank `{ kind: 'post', message }` to replace the built-in card with your own message (for example, a localized one). Returning `undefined`, a blank message, or `{ kind: 'stream' }` falls back to the built-in card so the user can still approve or deny the request.
|
|
147
147
|
|
|
148
148
|
```typescript
|
|
149
149
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -275,7 +275,7 @@ onDirectMessage: async (thread, message, defaultHandler, ctx) => {
|
|
|
275
275
|
|
|
276
276
|
Anything the run reads from its request context can be decided per message this way, such as which user a platform sender maps to.
|
|
277
277
|
|
|
278
|
-
`ctx.signalMetadata` is the metadata attached to this message's Agent Signal, built fresh for every message. Add JSON-serializable, non-sensitive values before calling `defaultHandler`. Mastra may persist signal metadata and publish it through PubSub. Unlike `ctx.requestContext`, it follows the message whether it starts a new run or is delivered to one that
|
|
278
|
+
`ctx.signalMetadata` is the metadata attached to this message's Agent Signal, built fresh for every message. Add JSON-serializable, non-sensitive values before calling `defaultHandler`. Mastra may persist signal metadata and publish it through PubSub. Unlike `ctx.requestContext`, it follows the message whether it starts a new run or is delivered to one that's already active.
|
|
279
279
|
|
|
280
280
|
`ctx.skipped` lists earlier messages from the same sender that the Chat SDK batched into this turn when a `chatOptions.concurrency` strategy such as `burst`, `debounce`, or `queue` is set, oldest first. It's empty when nothing was batched.
|
|
281
281
|
|
|
@@ -96,7 +96,7 @@ Returns: `DurableAgent`
|
|
|
96
96
|
|
|
97
97
|
## `createEventedAgent(options)`
|
|
98
98
|
|
|
99
|
-
Wraps an `Agent` with fire-and-forget durable execution on the built-in evented workflow engine. Like `createDurableAgent`, it returns a result you stream from, but the run is started without being awaited:
|
|
99
|
+
Wraps an `Agent` with fire-and-forget durable execution on the built-in evented workflow engine. Like `createDurableAgent`, it returns a result you stream from, but the run is started without being awaited: events on the Mastra instance's PubSub drive execution independently of the caller. Register the agent on a `Mastra` instance with storage to get evented execution; without one, the agent falls back to the default in-process engine and logs a warning. It doesn't accept `id` or `name` overrides.
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
102
|
import { createEventedAgent } from '@mastra/core/agent/durable'
|
|
@@ -195,7 +195,7 @@ const { output } = await durableAgent.observe(runId, {
|
|
|
195
195
|
await output.text
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
The `offset` option is an inclusive, zero-based PubSub event index. It counts every cached event published to the run topic, including lifecycle events,
|
|
198
|
+
The `offset` option is an inclusive, zero-based PubSub event index. It counts every cached event published to the run topic, including lifecycle events, rather than counting chunks. This transport index is unavailable through public stream chunks and callbacks. Only pass an offset when another integration already tracks the transport position.
|
|
199
199
|
|
|
200
200
|
A non-zero offset can skip earlier events. Aggregated values are built only from chunks delivered to that observer. If the offset skips earlier text deltas, `output.text` is partial and structured output may be incomplete or fail validation or parsing.
|
|
201
201
|
|
|
@@ -255,7 +255,7 @@ const { runId } = await durableAgent.stream('Summarize the document')
|
|
|
255
255
|
durableAgent.abortRunStream(runId)
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
Publishing the abort request over PubSub requires a shared backend in a multi-process deployment, such as [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams). The default `EventEmitterPubSub` only reaches runs in the same process. `InngestAgent` doesn't implement this method. Cancel an Inngest run with the `abort()` returned by its `stream()`.
|
|
259
259
|
|
|
260
260
|
Stopping a durable run through `abortRunStream()` or `abortThreadStream()` requires `@mastra/core@1.62.0` or later. Earlier versions record the abort without stopping the run.
|
|
261
261
|
|
|
@@ -330,7 +330,7 @@ interface DurableAgentListActiveRunsResult {
|
|
|
330
330
|
|
|
331
331
|
Discovers runs stuck in `running` status for this agent and re-drives them from the last persisted snapshot. Accepts the same filters and pagination as `listActiveRuns()`, plus `runId`. Returns the outcome for each run.
|
|
332
332
|
|
|
333
|
-
Up to five run waits proceed concurrently, with results returned in discovery order. Each attempt has a single 30-second wait budget covering both `recover()` setup and settlement of the whole recovered workflow. When the budget expires, another run can use the slot. The
|
|
333
|
+
Up to five run waits proceed concurrently, with results returned in discovery order. Each attempt has a single 30-second wait budget covering both `recover()` setup and settlement of the whole recovered workflow. When the budget expires, another run can use the slot. The timeout returns `status: 'skipped'` with `reason: 'recovery-timeout'` and `retryAt` set 30 seconds ahead, without canceling setup or execution, releasing a live claim, or counting as success or failure. The attempt continues in the background, and its eventual outcome doesn't change the returned results. The concurrency limit bounds waiting, not live executions.
|
|
334
334
|
|
|
335
335
|
[`mastra.recoverAllDurableAgents()`](https://mastra.ai/reference/core/mastra-class) schedules timeout re-checks automatically. Direct callers of `recoverActiveRuns()` must schedule their own calls after `retryAt`. While the original bulk attempt remains pending, re-checks defer with another `recovery-timeout` and a future `retryAt`, without invoking `recover()` again. Once it settles, recovery checks the persisted snapshot and ownership before retrying. Finished or suspended runs aren't restarted.
|
|
336
336
|
|
|
@@ -354,14 +354,14 @@ Pass a `runId` to recover a single known run:
|
|
|
354
354
|
await durableAgent.recoverActiveRuns({ runId: 'run-abc-123' })
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
|
|
357
|
+
For a run that another execution still drives, `recoverActiveRuns()` returns `status: 'skipped'` and a `reason`, leaving that execution in control. Checking the run again requires a separate call. For a run held by another process, `retryAt` is the time after which that claim lapses unless renewed. Call `recoverActiveRuns({ runId })` after it to recover the run if its process crashed. [`mastra.recoverAllDurableAgents()`](https://mastra.ai/reference/core/mastra-class) schedules these re-checks itself.
|
|
358
358
|
|
|
359
|
-
| `reason` | Meaning
|
|
360
|
-
| --------------------- |
|
|
361
|
-
| `run-active` | Another execution, possibly in another process, holds the run. Sets `retryAt`.
|
|
362
|
-
| `run-active-locally` | This process is executing the run.
|
|
363
|
-
| `already-in-progress` | This process is already recovering the run.
|
|
364
|
-
| `recovery-timeout` | The wait expired or an earlier bulk recovery attempt is still pending. Sets `retryAt
|
|
359
|
+
| `reason` | Meaning |
|
|
360
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
361
|
+
| `run-active` | Another execution, possibly in another process, holds the run. Sets `retryAt`. |
|
|
362
|
+
| `run-active-locally` | This process is executing the run. |
|
|
363
|
+
| `already-in-progress` | This process is already recovering the run. |
|
|
364
|
+
| `recovery-timeout` | The wait expired or an earlier bulk recovery attempt is still pending. Sets `retryAt` without duplicating the pending attempt on re-checks. |
|
|
365
365
|
|
|
366
366
|
Returns:
|
|
367
367
|
|
|
@@ -177,7 +177,7 @@ Switches the active mode.
|
|
|
177
177
|
|
|
178
178
|
### `switchModel(modelId, options?)`
|
|
179
179
|
|
|
180
|
-
Switches the session's active model and persists it as the current model for the active thread
|
|
180
|
+
Switches the session's active model and persists it as the current model for the active thread, independently of mode changes. Pass `{ thinkingLevel }` as the second argument to apply and persist a thinking level with the model.
|
|
181
181
|
|
|
182
182
|
```typescript
|
|
183
183
|
await session.switchModel('anthropic/claude-sonnet-5-5', {
|
|
@@ -351,6 +351,22 @@ const { messages, initialHistoryPagination } = useChat({
|
|
|
351
351
|
|
|
352
352
|
The subscription also exposes `abort(options?)` and `unsubscribe()`. `await subscription.abort({ clearPendingSignals: true })` requests an abort and clears pending signals without closing the subscription. Omit the flag to preserve pending input. `unsubscribe()` closes the subscription without aborting the run.
|
|
353
353
|
|
|
354
|
+
### `abortRun(runId)`
|
|
355
|
+
|
|
356
|
+
Requests cancellation of a durable run by its ID, including a run without a memory thread. Cancelling the response body or aborting the client-wide `abortSignal` only disconnects the observer from durable execution. A per-call `abortSignal` passed to a streaming method requests cancellation for you. Use `abortRun()` to stop a run without that signal.
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
const runId = crypto.randomUUID()
|
|
360
|
+
const response = await agent.stream('Research this topic', { runId })
|
|
361
|
+
|
|
362
|
+
// When the user chooses Stop:
|
|
363
|
+
const { aborted } = await agent.abortRun(runId)
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**runId** (`string`): ID of the durable run to cancel.
|
|
367
|
+
|
|
368
|
+
Returns `{ aborted: boolean }`. A remote abort request is asynchronous, so `true` doesn't confirm that the worker has stopped. Unknown or completed runs return `false`. This method requires a durable agent and Agent execution permission. Run ownership checks apply. Runs with memory threads also require `memory:write` permission when fine-grained authorization is enabled. Non-durable agents return HTTP 501.
|
|
369
|
+
|
|
354
370
|
### `abortThread()`
|
|
355
371
|
|
|
356
372
|
Requests cancellation of the thread's active run. Set `clearPendingSignals: true` to clear pending signals before aborting.
|
|
@@ -748,7 +764,7 @@ response.processDataStream({
|
|
|
748
764
|
|
|
749
765
|
### Shape client tool output for the model
|
|
750
766
|
|
|
751
|
-
Client tools support `toModelOutput` to control what the model receives, including multimodal content such as images. Because client tools execute locally, the mapping also runs on the client after `execute` completes. The transformed output
|
|
767
|
+
Client tools support `toModelOutput` to control what the model receives, including multimodal content such as images. Because client tools execute locally, the mapping also runs on the client after `execute` completes. The client sends both the transformed output and the raw result back to the server, keeping the raw result available for storage and application logic.
|
|
752
768
|
|
|
753
769
|
```typescript
|
|
754
770
|
const screenshotTool = createTool({
|
|
@@ -130,7 +130,7 @@ Submitting to an experiment that has a target returns a `400`. Submitting after
|
|
|
130
130
|
|
|
131
131
|
## finalizeExperiment()
|
|
132
132
|
|
|
133
|
-
Marks a caller-driven experiment completed. The server
|
|
133
|
+
Marks a caller-driven experiment completed. The server handles bookkeeping for the caller by computing per-item counts from the persisted result rows: `succeededCount` (at least one attempt without an error), `failedCount` (every attempt errored), and `skippedCount` (never submitted). Idempotent: finalizing an already-completed experiment returns the stored record.
|
|
134
134
|
|
|
135
135
|
**datasetId** (`string`): ID of the dataset the experiment runs against.
|
|
136
136
|
|
|
@@ -639,7 +639,7 @@ export const mastra = new Mastra({
|
|
|
639
639
|
})
|
|
640
640
|
```
|
|
641
641
|
|
|
642
|
-
Explicit values override copied source settings. Omitting this option preserves the existing workspace-copy behavior
|
|
642
|
+
Explicit values override copied source settings. Omitting this option preserves the existing workspace-copy behavior, which copies only a subset of the source workspace's settings.
|
|
643
643
|
|
|
644
644
|
Only these keys are supported: `allowBuilds`, `onlyBuiltDependencies`, `ignoredBuiltDependencies`, `minimumReleaseAge`, `minimumReleaseAgeExclude`, `trustPolicy`, `trustPolicyExclude`, `trustPolicyIgnoreAfter`, and `blockExoticSubdeps`. Any other key throws an error before pnpm runs, including keys Mastra generates for deployment output (`packages`, `overrides`, `patchedDependencies`, `allowUnusedPatches`, `supportedArchitectures`, `nodeLinker`) and settings that change TLS verification, registries, network access, store integrity, dependency extensions, catalogs, or build-script permissions. `neverBuiltDependencies` is rejected because pnpm 10 runs every build script it doesn't list. This option doesn't accept command-line flags and isn't a place for secrets.
|
|
645
645
|
|
|
@@ -53,7 +53,7 @@ Each value in the `providers` record form is `true`, `false`, or a `ChannelsProv
|
|
|
53
53
|
|
|
54
54
|
The resolved `ChannelsResolver` satisfies `@mastra/core`'s channels-resolver contract:
|
|
55
55
|
|
|
56
|
-
- **Callable**: returns the current `Record<string, ChannelProvider>` of providers with an active connection. Mastra invokes it at runtime
|
|
56
|
+
- **Callable**: returns the current `Record<string, ChannelProvider>` of providers with an active connection. Mastra invokes it at runtime, using the TTL cache to keep repeat calls cheap. Only the first resolution waits on the platform. After the TTL expires, resolution returns the stale snapshot immediately and refreshes in the background, skipping the refresh during a short cooldown after a failed fetch, so a new connection can appear one resolution later than the TTL suggests.
|
|
57
57
|
- `getRoutes()`: the union of API routes for every enabled channel, available synchronously so Mastra can mount them at construction. Routes exist before (and after) their provider has an active connection.
|
|
58
58
|
- `refresh()`: fetches connections from the platform now and updates the cache. Rejects if the platform fetch fails.
|
|
59
59
|
- `disconnect()`: clears the cached snapshot so the next resolution fetches fresh. It doesn't tear down providers, sessions, or credentials.
|
|
@@ -56,9 +56,9 @@ const connected = tools(ctx => ({
|
|
|
56
56
|
}))
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
The resolver memoizes snapshots per distinct options value, so requests producing the same options share one cached snapshot with the usual `ttlMs` and stale-while-revalidate semantics. Structurally equal options returned from different calls count as the same value
|
|
59
|
+
The resolver memoizes snapshots per distinct options value, so requests producing the same options share one cached snapshot with the usual `ttlMs` and stale-while-revalidate semantics. Structurally equal options returned from different calls count as the same value, except that non-serializable values such as a custom `client.fetch` compare by identity. The resolver keeps caches for at most 32 distinct options values and evicts the least recently used one past that, so derive options from a small, closed set of inputs such as roles, not from unbounded per-request data.
|
|
60
60
|
|
|
61
|
-
With the callback form, option validation runs at the first resolution that produces
|
|
61
|
+
With the callback form, option validation runs at the first resolution that produces an options value rather than at `tools()` time, and a validation error fails that resolution. `refresh()` fetches for the options the callback returns without a context (the same variant a direct `await connected()` call uses), and `disconnect()` closes every memoized variant.
|
|
62
62
|
|
|
63
63
|
### Per-provider options
|
|
64
64
|
|
|
@@ -86,7 +86,7 @@ Every field falls back to an environment variable, so a fully env-configured app
|
|
|
86
86
|
|
|
87
87
|
## The resolver
|
|
88
88
|
|
|
89
|
-
The returned `ToolsResolver` caches its tools. Within `ttlMs` of the last fetch, it returns the cache. The first call after expiry still returns the cache right away and starts a background fetch from the platform (stale-while-revalidate). Later calls use the updated snapshot once the fetch succeeds
|
|
89
|
+
The returned `ToolsResolver` caches its tools. Within `ttlMs` of the last fetch, it returns the cache. The first call after expiry still returns the cache right away and starts a background fetch from the platform (stale-while-revalidate). Later calls use the updated snapshot once the fetch succeeds, or keep using the cached snapshot if the refresh fails. Refreshes depend on calls to the resolver rather than idle polling. Use `await connected.refresh()` to wait for a fresh tool record.
|
|
90
90
|
|
|
91
91
|
Call the resolver directly when you need a plain tool record, for example for the `toolsets` option at generate time:
|
|
92
92
|
|
|
@@ -103,10 +103,10 @@ const response = await agent.generate('Summarize my open issues.', {
|
|
|
103
103
|
The resolver also exposes methods for manual control:
|
|
104
104
|
|
|
105
105
|
- `refresh()` fetches from the platform immediately, then updates the cache and returns the tool record. Rejects if the platform fetch fails.
|
|
106
|
-
- `disconnect()` clears the cached snapshots and closes the MCP transports of the state behind this resolver. Resolvers created with identical options share that state, so this disconnects them too.
|
|
107
|
-
- `with(extra)` returns a new resolver that merges extra tools into every resolution
|
|
106
|
+
- `disconnect()` clears the cached snapshots and closes the MCP transports of the state behind this resolver. Resolvers created with identical options share that state, so this disconnects them too. A later resolution rebuilds the state, and already-returned MCP tools reconnect on their next call.
|
|
107
|
+
- `with(extra)` returns a new resolver that merges extra tools into every resolution, giving extras priority on key collision. It accepts a static tool record or a function (sync or async) and calls chain. For the same merge using a spread of the resolver's result in a `tools` callback, see [Tools](https://mastra.ai/docs/mastra-platform/connect/tools).
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
Error handling depends on the cause:
|
|
110
110
|
|
|
111
111
|
- Configuration errors (missing project ID or token, a malformed provider ID, both `allowTools` and `disallowTools` at one level, invalid `ttlMs`) throw when you call `tools()`. With [the callback form](#per-request-options), they fail the first resolution that produces the invalid options instead.
|
|
112
112
|
- An enabled provider ID that the platform catalog confirms is unknown fails the resolution with `invalid_options`. An unknown tool key or zero-match glob in a per-provider filter does the same. If the catalog can't be reached, an unknown ID downgrades to a warning and is skipped.
|
|
@@ -144,7 +144,7 @@ Connections in `needs_reauth` status are skipped with a warning until someone [r
|
|
|
144
144
|
|
|
145
145
|
Beyond the generated toolsets, the resolver discovers any connected provider that advertises MCP capability in the platform catalog. Discovered tools use the same flat contract, namespaced as `<provider-id>_<tool-name>`. If a provider has both a generated toolset and an MCP capability, the MCP catalog is preferred.
|
|
146
146
|
|
|
147
|
-
The application sends only its platform token
|
|
147
|
+
The application sends only its platform token. Before proxying each protocol request to the provider's MCP server, the platform removes caller authentication and injects the provider credential. MCP sessions are reused across refreshes and closed when the connection changes, the provider is detached, or `disconnect()` is called.
|
|
148
148
|
|
|
149
149
|
Discovered MCP tools follow the same approval policy as generated tools: none require approval unless `requireApproval` asks for it, for example `'neon-mcp': { requireApproval: ['neon-mcp_run_sql'] }`. Passing the removed `autoApproveTools` key throws an `invalid_options` error at call time.
|
|
150
150
|
|
|
@@ -149,11 +149,11 @@ Requires persistent storage. With an in-memory store, there's nothing to recover
|
|
|
149
149
|
|
|
150
150
|
Recovery processes up to five agents concurrently, with up to five run waits per agent, independently of `recovery.workflowConcurrency`. Each built-in `recoverActiveRuns()` attempt waits up to 30 seconds in total for `recover()` setup and settlement of the whole recovered workflow, then frees its slot for another run. These limits bound waiting, not live executions. This isn't an overall recovery deadline: discovery and overridden custom recovery methods aren't bounded by this budget.
|
|
151
151
|
|
|
152
|
-
A timed-out attempt continues in the background. Its outcome is `status: 'skipped'` with `reason: 'recovery-timeout'` and a future `retryAt`. It contributes only to `skipped`, not `recovered`, `succeeded`, or `failed`. Mastra schedules re-checks automatically
|
|
152
|
+
A timed-out attempt continues in the background. Its outcome is `status: 'skipped'` with `reason: 'recovery-timeout'` and a future `retryAt`. It contributes only to `skipped`, not `recovered`, `succeeded`, or `failed`. Mastra schedules re-checks automatically, deferring them until the original attempt settles to avoid starting another execution. Recovery then checks the persisted snapshot and ownership before retrying and skips finished or suspended runs. The returned counts remain unchanged by late settlement.
|
|
153
153
|
|
|
154
154
|
When shutdown begins, recovery stops dispatching new agents and runs. The recovery traversal and original attempts, including timed-out setup or execution, participate in the same shared shutdown drain as active executions. A recovery wait timeout doesn't cancel the attempt or give it a separate shutdown drain window.
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
Mastra leaves a run under its current execution's control and counts it in `skipped`. Automatic re-checks begin once that execution's claim could have lapsed, allowing recovery after a process crash without another call. `shutdown()` cancels pending re-checks. See [run ownership](https://mastra.ai/docs/harness/durable-agents).
|
|
157
157
|
|
|
158
158
|
```typescript
|
|
159
159
|
const result = await mastra.recoverAllDurableAgents()
|
|
@@ -170,4 +170,4 @@ Returns:
|
|
|
170
170
|
|
|
171
171
|
**failed** (`number`): Runs whose restart threw an error.
|
|
172
172
|
|
|
173
|
-
**skipped** (`number`): Runs skipped because they are already active, recovery is already in progress, or the recovery wait timed out.
|
|
173
|
+
**skipped** (`number`): Runs skipped because they are already active, recovery is already in progress, or the recovery wait timed out. Skips with a future retryAt, including recovery timeouts, are automatically re-checked. Timeout re-checks wait for the original attempt to settle before deciding whether to retry.
|
|
@@ -55,12 +55,27 @@ console.log(`${summary2.succeededCount}/${summary2.totalItems} succeeded`)
|
|
|
55
55
|
console.log(`Status: ${summary2.status}`)
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
### Compare models without changing the agent
|
|
59
|
+
|
|
60
|
+
Use `agentModel` to run the same agent against a different model. The registered agent keeps its own model, and the experiment's `metadata.agentModel` records the model the run used.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const summary = await dataset.startExperiment({
|
|
64
|
+
targetType: 'agent',
|
|
65
|
+
targetId: 'my-agent',
|
|
66
|
+
agentModel: 'anthropic/claude-haiku-5-5',
|
|
67
|
+
scorers: ['accuracy'],
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
58
71
|
## Parameters
|
|
59
72
|
|
|
60
73
|
**targetType** (`'agent' | 'workflow' | 'scorer'`): Type of registered target to run items against. Use with targetId.
|
|
61
74
|
|
|
62
75
|
**targetId** (`string`): ID of the registered target. Use with targetType.
|
|
63
76
|
|
|
77
|
+
**agentModel** (`MastraModelConfig`): Model to run the agent target with, instead of the agent's own model. Accepts a provider/modelId string, a model config object (for example { id, url, apiKey }), a model instance, or a { model, id } object. Model functions and fallback arrays aren't supported. Applies only when targetType is 'agent'. The model is passed with each call the experiment makes, so the registered agent and other experiments are unaffected. The agent version is picked the same way as without agentModel, and sub-agents keep their own models. The experiment's metadata and each run's trace metadata record it as agentModel (for example anthropic/claude-haiku-5-5).
|
|
78
|
+
|
|
64
79
|
**scorers** (`(MastraScorer | string)[] | AgentScorerConfig | WorkflowScorerConfig`): Scorers to evaluate each result. Accepts a flat array of MastraScorer instances or registered scorer IDs, or the same categorised config shape used by runEvals (AgentScorerConfig / WorkflowScorerConfig). When this option is provided, including as \[] or an empty categorized config, it overrides item-level and dataset-level scorer IDs for every item. When omitted, each item uses its own scorerIds when present, then falls back to the dataset scorer IDs. Sources aren't merged. Trajectory scorers (type: "trajectory") automatically receive a pre-extracted Trajectory as their output regardless of which form is used. Workflow step scorers are supported only through this run-level categorized configuration. Their results carry the originating stepId and keep targetScope: "span" (matching runEvals).
|
|
65
80
|
|
|
66
81
|
**name** (`string`): Display name for the experiment.
|
|
@@ -108,7 +108,7 @@ The scorer runs in two phases:
|
|
|
108
108
|
1. **Grade**: The judge model evaluates each criterion independently and returns a per-criterion verdict (`satisfied` / not) with reasoning.
|
|
109
109
|
2. **Score**: The scorer returns `1` only when every required criterion is `satisfied` and treats every criterion as required when none are marked. All other results receive `0`.
|
|
110
110
|
|
|
111
|
-
The `reason` summarizes the result and lists each criterion with its verdict,
|
|
111
|
+
The `reason` summarizes the result and lists each criterion with its verdict, giving the agent specific feedback on a failing grade rather than a generic "try again".
|
|
112
112
|
|
|
113
113
|
## Related
|
|
114
114
|
|
|
@@ -381,7 +381,7 @@ const result = await runEvals({
|
|
|
381
381
|
// result.verdict: 'passed' | 'scored' | 'failed'
|
|
382
382
|
```
|
|
383
383
|
|
|
384
|
-
Each turn runs `agent.generate()` with the same `threadId
|
|
384
|
+
Each turn runs `agent.generate()` with the same `threadId` to give the agent access to the full conversation history. `runEvals` also injects a `resourceId` (Mastra memory scopes messages by resource + thread), defaulting it to the generated thread. Pass `targetOptions.memory.resource` to pin a specific one. Cross-turn recall requires the agent to have a memory store configured. Otherwise turns run in isolation. Mix single-turn (`input`) and multi-turn (`inputs`) items in the same `data` array. When using `inputs`, `input` can be omitted.
|
|
385
385
|
|
|
386
386
|
Scoring uses the accumulated output from all turns as `run.output`, but only the first turn as `run.input`. Prefer output-based scorers (`checks.includes`, `checks.calledTool`, `checks.similarity`) for multi-turn. Input-relative scorers (e.g. faithfulness) only see the first turn's input. Trajectory scorers that read from the trace (`AgentScorerConfig.trajectory`) resolve against the last turn's span. Tool-call checks that read `run.output` (like `checks.calledTool`) still see every turn.
|
|
387
387
|
|
|
@@ -56,7 +56,7 @@ If no `LoggerProvider` is registered globally, emission is a silent no-op.
|
|
|
56
56
|
async flush(): Promise<void>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Force flushes the tracer provider and logger provider if they support `forceFlush`. The global providers are resolved at flush time, so a `LoggerProvider` registered after the bridge was constructed is flushed too. Useful in serverless environments where you need to drain telemetry before the runtime terminates.
|
|
59
|
+
Force flushes the tracer provider and logger provider if they support `forceFlush`. The global providers are resolved at flush time, so a `LoggerProvider` registered after the bridge was constructed is flushed too. Useful in serverless environments where you need to drain telemetry before the runtime terminates. Call `sdk.shutdown()` as well before the process exits to wait for any batch your OTEL SDK has already started exporting. Neither this method nor the provider's own `forceFlush()` waits for that batch.
|
|
60
60
|
|
|
61
61
|
### `shutdown`
|
|
62
62
|
|
|
@@ -121,7 +121,7 @@ The processor looks at the files of every user message the model receives, the t
|
|
|
121
121
|
Files sent inline, as binary, base64, or a data URL, are uploaded. The processor never downloads anything itself, so a request made by the server can't be pointed at an internal address:
|
|
122
122
|
|
|
123
123
|
- A link the model fetches itself, or a provider file ID, stays in the prompt, and `filter` isn't called for it.
|
|
124
|
-
- A link the model can't fetch is downloaded by Mastra before the model call. The
|
|
124
|
+
- A link the model can't fetch is downloaded by Mastra before the model call. The processor handles the downloaded bytes like any other file the model would receive.
|
|
125
125
|
|
|
126
126
|
## Upload location
|
|
127
127
|
|
|
@@ -170,7 +170,7 @@ The constructor throws a `MastraError` with the ID `FILE_UPLOAD_PROCESSOR_NO_SAN
|
|
|
170
170
|
|
|
171
171
|
The files of the current turn are checked as they were sent, before anything is written. A file that can't be uploaded stops the turn, and nothing is uploaded.
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
For a file in thread history that's too large or can't be decoded, the processor substitutes a note explaining the problem and lets the turn continue. This prevents a stored file from blocking every subsequent turn:
|
|
174
174
|
|
|
175
175
|
```text
|
|
176
176
|
[File not uploaded]
|
|
@@ -178,7 +178,7 @@ name: report.pdf
|
|
|
178
178
|
reason: File "report.pdf" is 31457280 bytes, over the 10485760 byte limit.
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
When the sandbox can't take the files, because there is no sandbox, it can't write, or a write fails, a file of the current turn stops the turn. A file of the thread history gets a note with the reason instead, and the turn goes on. A `filter` or `maxFileSize` that fails stops the turn, whichever file it affects.
|
|
181
|
+
When the sandbox can't take the files, because there is no sandbox, it can't write, or a write fails, a file of the current turn stops the turn. A file of the thread history gets a note with the reason instead, and the turn goes on. A `filter` or `maxFileSize` that fails stops the turn, whichever file it affects. Storage remains unchanged, allowing the thread to work again once the setup is fixed. A turn without a file to upload checks nothing, so scorers, agent networks, and calls without a thread keep working.
|
|
182
182
|
|
|
183
183
|
The processor stops a turn by calling `abort()` with `retry: false`. The model isn't called. `agent.generate()` resolves with `result.tripwire` set instead of rejecting, and `agent.stream()` emits a `tripwire` chunk.
|
|
184
184
|
|
|
@@ -220,7 +220,7 @@ The processor handles files sent with `agent.sendMessage()` and `agent.sendSigna
|
|
|
220
220
|
|
|
221
221
|
- A signal that wakes an idle agent is processed like the input of `agent.stream()`.
|
|
222
222
|
- A signal delivered to an active run is checked and uploaded before the next model call of that run.
|
|
223
|
-
-
|
|
223
|
+
- Signals that arrive on a durable agent before a run's first model call join the prompt after the turn's checks. Their files are uploaded like files in thread history.
|
|
224
224
|
|
|
225
225
|
## Limitations
|
|
226
226
|
|
|
@@ -84,7 +84,7 @@ export const agent = new Agent({
|
|
|
84
84
|
|
|
85
85
|
### Output processing with batching
|
|
86
86
|
|
|
87
|
-
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `ModerationProcessor` makes one moderation call per sentence instead of one per chunk. Buffering also catches content that
|
|
87
|
+
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `ModerationProcessor` makes one moderation call per sentence instead of one per chunk. Buffering also catches content that's split across chunks. Text then reaches the client in sentence-sized pieces.
|
|
88
88
|
|
|
89
89
|
When using `ModerationProcessor` as an output processor, it's recommended to combine it with `BatchPartsProcessor` to optimize performance. The `BatchPartsProcessor` batches stream chunks together before passing them to the moderator, reducing the number of LLM calls required for moderation.
|
|
90
90
|
|
|
@@ -64,7 +64,7 @@ Registering in `errorProcessors` alone, as the example above does, covers both h
|
|
|
64
64
|
| `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-5-5`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched. |
|
|
65
65
|
| `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged. |
|
|
66
66
|
| `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part, and retries. The message then replays by value instead of as an unsatisfiable `item_reference`. The repair is applied to the in-memory list for the current turn. |
|
|
67
|
-
| `anthropic-orphaned-thinking-step` | Anthropic | Reactive API error recovery | Recovers history that Anthropic rejects because `thinking` or `redacted_thinking` blocks in the latest assistant message
|
|
67
|
+
| `anthropic-orphaned-thinking-step` | Anthropic | Reactive API error recovery | Recovers history that Anthropic rejects because `thinking` or `redacted_thinking` blocks in the latest assistant message can't be modified. Removes steps that contain only reasoning when more assistant content follows them, and retries. Covers history saved by older `@mastra/memory` releases ([#22798](https://github.com/mastra-ai/mastra/issues/22798)). |
|
|
68
68
|
| `ensure-user-first-turn` | Amazon Bedrock, Google/Vertex Gemini | Preemptive prompt rewrite | Inserts a minimal user turn (`.`) before a leading assistant turn, because these providers reject conversations whose first non-system turn is the assistant's. This happens when an agent greets first or `lastMessages` cuts into a thread. Runs last, so it sees the prompt after other rules have dropped emptied turns. |
|
|
69
69
|
|
|
70
70
|
Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call. Persisted history is never changed, so the IDs and content in memory and in the Studio stay exactly as written.
|
|
@@ -56,7 +56,7 @@ const processor = new SystemPromptScrubber({
|
|
|
56
56
|
|
|
57
57
|
## Extended usage example
|
|
58
58
|
|
|
59
|
-
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `SystemPromptScrubber` makes one detection call per sentence instead of one per chunk. Buffering also catches content that
|
|
59
|
+
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `SystemPromptScrubber` makes one detection call per sentence instead of one per chunk. Buffering also catches content that's split across chunks. Text then reaches the client in sentence-sized pieces.
|
|
60
60
|
|
|
61
61
|
When using `SystemPromptScrubber` as an output processor, it's recommended to combine it with `BatchPartsProcessor` to optimize performance. The `BatchPartsProcessor` batches stream chunks together before passing them to the scrubber, reducing the number of LLM calls required for detection.
|
|
62
62
|
|
|
@@ -117,7 +117,7 @@ export const agent = new Agent({
|
|
|
117
117
|
|
|
118
118
|
### As a per-step processor (limit multi-step token growth)
|
|
119
119
|
|
|
120
|
-
When an agent uses tools across multiple steps (e.g. `maxSteps > 1`), each step accumulates conversation history from all previous steps. `TokenLimiterProcessor` applies its limit at every step, measuring the prompt that's about to be sent after any earlier prompt processors have run.
|
|
120
|
+
When an agent uses tools across multiple steps (e.g. `maxSteps > 1`), each step accumulates conversation history from all previous steps. `TokenLimiterProcessor` applies its limit at every step, measuring the prompt that's about to be sent after any earlier prompt processors have run. To count the prompt the model actually receives, register the limiter after prompt-shrinking processors such as `ToolCallFilter`:
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
123
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -66,7 +66,7 @@ const filter = new ToolCallFilter({
|
|
|
66
66
|
|
|
67
67
|
## Preserve compact model output
|
|
68
68
|
|
|
69
|
-
Set `preserveModelOutput: true` to retain compact `toModelOutput` history for tool results that the filter removes.
|
|
69
|
+
Set `preserveModelOutput: true` to retain compact `toModelOutput` history for tool results that the filter removes. Replacing the removed tool call and result with a single text part in the prompt lets the model see the output without the raw tool arguments.
|
|
70
70
|
|
|
71
71
|
Tool results without model output that can be represented as text are removed entirely.
|
|
72
72
|
|
|
@@ -238,7 +238,7 @@ Use `clearState`, `clearAllState`, `getStateStats`, and `cleanupNow` to inspect
|
|
|
238
238
|
|
|
239
239
|
Loaded state is derived from the conversation messages: a tool is loaded while a `search_tools` or `load_tool` result naming it remains in the messages. This mode:
|
|
240
240
|
|
|
241
|
-
- Works without memory configuration. Without memory, loaded tools are kept for the current process only, and only for requests with a real thread ID
|
|
241
|
+
- Works without memory configuration. Without memory, loaded tools are kept for the current process only, and only for requests with a real thread ID. Anonymous requests require the caller to resend the relevant messages to retain loaded tools between calls.
|
|
242
242
|
- Survives a restart whenever the messages are available again: from memory with message history, or because the caller resends the conversation. Without memory, a restart restores only what's in the messages the caller sends.
|
|
243
243
|
- De-loads a tool automatically once that result is no longer present in the messages.
|
|
244
244
|
|
|
@@ -181,6 +181,16 @@ When a subscriber calls `nack`, the event is republished with an incremented `de
|
|
|
181
181
|
|
|
182
182
|
A subscription never reclaims an event its own handler is still processing, so a slow handler isn't invoked twice for the same event. If a handler hangs, a different consumer in the group reclaims the event once it has been idle for `reclaimIdleMs`. In a single-consumer group there's no sibling to do that, so set `inFlightTimeoutMs` to have the subscription nack the event itself after that long.
|
|
183
183
|
|
|
184
|
+
### Evented agent worker takeover
|
|
185
|
+
|
|
186
|
+
With Postgres storage, distributed evented agents publish worker orchestration events through Redis. If a worker exits before acknowledging an event, another worker can reclaim it and finish the run while the original API process stays alive. Configure the API process with `MASTRA_WORKERS=false` and worker processes with `MASTRA_WORKERS=orchestration`. All processes must share the same Postgres database, Redis connection settings, and `keyPrefix`.
|
|
187
|
+
|
|
188
|
+
Keep `reclaimIdleMs` above 30 seconds (the default is 60 seconds). A lower value can reclaim an event while the stopped worker's step lease is still held, causing the event to be acknowledged without running.
|
|
189
|
+
|
|
190
|
+
Runs started on older versions can finish after upgrading, but don't have guaranteed crash recovery. Saved steps without occurrence identifiers keep their existing unguarded behavior. Other storage adapters keep distributed internal orchestration on the worker process.
|
|
191
|
+
|
|
192
|
+
An interrupted step can execute again, so make external side effects idempotent. Completed step occurrences are protected against stale redeliveries, and a completed loop iteration reuses its saved result and loop decision. Guarded execution persists the records needed for recovery even when `shouldPersistSnapshot` returns `false`. Resume, time travel, restart races, and individual `foreach` items aren't covered by these occurrence guards.
|
|
193
|
+
|
|
184
194
|
## Distributed leasing
|
|
185
195
|
|
|
186
196
|
`RedisStreamsPubSub` implements the [`LeaseProvider`](https://mastra.ai/reference/pubsub/lease-provider) contract on top of the same Redis connection. The [signals runtime](https://mastra.ai/docs/signals/overview) uses it to elect a single owner (usually per thread key) so that across instances only one process wakes and runs the agent, and others route follow-up work to the holder. This is what makes signals work on serverless and multi-instance deployments; without a shared lease, each instance would start its own competing run.
|
|
@@ -53,7 +53,7 @@ await pubsub.close()
|
|
|
53
53
|
|
|
54
54
|
## Broker election
|
|
55
55
|
|
|
56
|
-
The broker is the first process to link its socket into place at the shared path. It routes events between all connected clients, and other processes connect to it as clients. Each candidate binds a socket at a private name and hard-links it to the shared path. The link fails if a socket is already there,
|
|
56
|
+
The broker is the first process to link its socket into place at the shared path. It routes events between all connected clients, and other processes connect to it as clients. Each candidate binds a socket at a private name and hard-links it to the shared path. The link fails if a socket is already there, preventing a candidate from accidentally replacing a live broker.
|
|
57
57
|
|
|
58
58
|
When the broker exits cleanly, it removes the shared path. Clients then reconnect, and the first to link its socket into place becomes the new broker. The remaining clients resubscribe to it.
|
|
59
59
|
|
|
@@ -83,7 +83,7 @@ Each key serves a different purpose:
|
|
|
83
83
|
- `dedupeKey` identifies the same event. Reuse it when a retry or duplicate webhook should update the existing record.
|
|
84
84
|
- `coalesceKey` groups related events. Use it when several events should become one record, such as multiple failures from the same pipeline.
|
|
85
85
|
|
|
86
|
-
Both keys use the same matching rules
|
|
86
|
+
Both keys use the same matching rules despite their different purposes.
|
|
87
87
|
|
|
88
88
|
When a notification merges:
|
|
89
89
|
|
|
@@ -188,7 +188,7 @@ The built-in policy is:
|
|
|
188
188
|
| `medium` | Deliver immediately | Batch into a summary |
|
|
189
189
|
| `low` | Batch into a summary | Batch into a summary |
|
|
190
190
|
|
|
191
|
-
A custom `decide` function runs at receipt time and again at delivery time for records whose receipt-time decision deferred them or scheduled a summary.
|
|
191
|
+
A custom `decide` function runs at receipt time and again at delivery time for records whose receipt-time decision deferred them or scheduled a summary. The record's persisted schedule fixes when and how it delivers. Only `streamOptions` and `hold` from the delivery-time decision are honored. Keep the decider side-effect free.
|
|
192
192
|
|
|
193
193
|
## Dispatch
|
|
194
194
|
|
|
@@ -294,7 +294,7 @@ const storage = new MongoDBStore({
|
|
|
294
294
|
|
|
295
295
|
## Reclaiming disk
|
|
296
296
|
|
|
297
|
-
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist
|
|
297
|
+
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist for reuse by future writes. Reusing these pages prevents unbounded file growth for most users.
|
|
298
298
|
|
|
299
299
|
Handing that free space back to the OS is a separate concern that Mastra doesn't manage. If you specifically need to shrink the file, run the underlying database's compaction (for example `VACUUM` on self-hosted libSQL) yourself in a maintenance window. A full `VACUUM` locks the file and needs roughly twice the file size in free disk. On PostgreSQL, autovacuum reclaims dead tuples for reuse automatically. A manual `VACUUM FULL` is only needed if you must return disk to the OS.
|
|
300
300
|
|
|
@@ -726,7 +726,7 @@ type UserMessagePendingChunk = {
|
|
|
726
726
|
|
|
727
727
|
A transient removal event emitted when accepted user input is cancelled before delivery. Subscribers can remove the pending projection whose `data.id` matches the cancelled signal.
|
|
728
728
|
|
|
729
|
-
The chunk
|
|
729
|
+
The chunk is emitted only after the input has been removed, confirming removal rather than a cancellation request. It remains transient and isn't saved to conversation history.
|
|
730
730
|
|
|
731
731
|
```typescript
|
|
732
732
|
type UserMessageCancelledChunk = {
|
|
@@ -746,7 +746,7 @@ type UserMessageCancelledChunk = {
|
|
|
746
746
|
|
|
747
747
|
The stored history of a thread, emitted at the start of a thread subscription.
|
|
748
748
|
|
|
749
|
-
`thread-history` arrives only when you call [`agent.subscribeToThread()`](https://mastra.ai/reference/agents/agent) with `withInitialHistory: true`. It
|
|
749
|
+
`thread-history` arrives only when you call [`agent.subscribeToThread()`](https://mastra.ai/reference/agents/agent) with `withInitialHistory: true`. It's the first chunk, followed by retained parts newer than the history and then live parts. Without agent memory, or when the thread has no stored messages yet, the chunk is still emitted first with an empty `messages` array and `hasMore: false`.
|
|
750
750
|
|
|
751
751
|
**type** (`"thread-history"`): Chunk type identifier
|
|
752
752
|
|
|
@@ -250,7 +250,7 @@ const stream = await agent.stream('message for agent')
|
|
|
250
250
|
|
|
251
251
|
## `stopWhen` errors
|
|
252
252
|
|
|
253
|
-
If a `stopWhen` predicate throws, `fullStream` rejects with that error
|
|
253
|
+
If a `stopWhen` predicate throws, `fullStream` rejects with that error without emitting a `step-finish`, `finish`, or `error` chunk for the failure. Catch the rejection around stream consumption:
|
|
254
254
|
|
|
255
255
|
```ts
|
|
256
256
|
async function consumeStream() {
|
|
@@ -264,7 +264,7 @@ async function consumeStream() {
|
|
|
264
264
|
}
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
-
Durable transports reconstruct cross-process errors from their serialized name and message. The original stack, cause, and subclass identity
|
|
267
|
+
Durable transports reconstruct cross-process errors from their serialized name and message. The original stack, cause, and subclass identity aren't available to the stream consumer.
|
|
268
268
|
|
|
269
269
|
## Signal visibility
|
|
270
270
|
|
|
@@ -232,7 +232,7 @@ export const weatherTool = createTool({
|
|
|
232
232
|
})
|
|
233
233
|
```
|
|
234
234
|
|
|
235
|
-
Mastra forwards `strict: true` to model adapters that support strict tool calling
|
|
235
|
+
Mastra forwards `strict: true` to model adapters that support strict tool calling and ignores the option for other adapters.
|
|
236
236
|
|
|
237
237
|
## Example with `toModelOutput`
|
|
238
238
|
|
|
@@ -490,7 +490,7 @@ Client-executed tools don't define an `execute` function. The browser runs the t
|
|
|
490
490
|
|
|
491
491
|
For client-executed results, the follow-up request must include both the assistant tool call and the tool result, which `@mastra/client-js` sends automatically. A request that carries only the tool result doesn't fire the hook. In this case the callback receives `{ toolCallId, toolName, output, abortSignal }` only.
|
|
492
492
|
|
|
493
|
-
|
|
493
|
+
At-least-once delivery means a retried request runs the hook again. Keep the hook idempotent and treat client output as untrusted data: the server doesn't validate the result against `outputSchema`, so the `output` type is a static type only.
|
|
494
494
|
|
|
495
495
|
### Hook execution order
|
|
496
496
|
|
|
@@ -968,7 +968,7 @@ The client doesn't receive notifications when the server's event list changes ye
|
|
|
968
968
|
|
|
969
969
|
#### `events.subscribe(serverName, eventName, args?, options?)`
|
|
970
970
|
|
|
971
|
-
Starts a subscription and resolves once the server confirms it. Errors such as an unknown event, invalid arguments, or a forbidden subscription reject the returned promise. A new subscription starts at the point the server accepts it, so occurrences from before that point
|
|
971
|
+
Starts a subscription and resolves once the server confirms it. Errors such as an unknown event, invalid arguments, or a forbidden subscription reject the returned promise. A new subscription starts at the point the server accepts it, so occurrences from before that point aren't delivered unless `options.cursor` resumes from an earlier position. Under webhook delivery the promise can resolve after that point: the client answers `503` for a delivery it can't route yet, and the server retries it.
|
|
972
972
|
|
|
973
973
|
```typescript
|
|
974
974
|
async subscribe(
|
|
@@ -1464,7 +1464,7 @@ const ticketCreated = defineEvent({
|
|
|
1464
1464
|
})
|
|
1465
1465
|
```
|
|
1466
1466
|
|
|
1467
|
-
`authorize` runs on every `events/poll`, every `events/stream` open, and every webhook `events/subscribe`, including refreshes. An open stream isn't checked again until it reconnects, and a webhook subscription until its next refresh. A caller who loses access keeps receiving occurrences until then.
|
|
1467
|
+
`authorize` runs on every `events/poll`, every `events/stream` open, and every webhook `events/subscribe`, including refreshes. An open stream isn't checked again until it reconnects, and a webhook subscription until its next refresh. A caller who loses access keeps receiving occurrences until then. Use `authorize` to restrict events because FGA doesn't apply to them.
|
|
1468
1468
|
|
|
1469
1469
|
### `defineEvent()` options
|
|
1470
1470
|
|
|
@@ -1584,7 +1584,7 @@ Records an occurrence, delivers it to matching push streams and webhook subscrip
|
|
|
1584
1584
|
- Emitted events stay in the process that emitted them. Push streams, webhook subscriptions, and buffered polls only see events emitted by the same `MCPServer` instance, so a serverless or multi-instance deployment needs a `poll` source backed by shared storage.
|
|
1585
1585
|
- The buffer is in memory. A restarted server treats earlier cursors as a gap and reports `truncated: true`.
|
|
1586
1586
|
- Webhook delivery state (pending retries, suspension, verification results) is in memory and rebuilt when clients refresh.
|
|
1587
|
-
-
|
|
1587
|
+
- Event-list change announcements require the `eventsListChanged` filter on `subscriptions/listen`, which the MCP TypeScript SDK version used by `@mastra/mcp` doesn't carry. Until that support is available, the server neither advertises `listChanged` nor sends `notifications/events/list_changed`. Clients should re-run `events/list` to see changed event types.
|
|
1588
1588
|
|
|
1589
1589
|
## Related information
|
|
1590
1590
|
|
|
@@ -28,7 +28,7 @@ The TurbopufferVector class provides vector search using [Turbopuffer](https://t
|
|
|
28
28
|
|
|
29
29
|
### `createIndex()`
|
|
30
30
|
|
|
31
|
-
Turbopuffer has no explicit create-index operation. `createIndex()` validates the arguments and records the dimension and metric locally
|
|
31
|
+
Turbopuffer has no explicit create-index operation. `createIndex()` validates the arguments and records the dimension and metric locally. The first `upsert()` creates the namespace in Turbopuffer.
|
|
32
32
|
|
|
33
33
|
**indexName** (`string`): Name of the index to create
|
|
34
34
|
|
|
@@ -174,7 +174,7 @@ Over HTTP, `POST /api/workflows/:workflowId/time-travel-async` returns `409 Conf
|
|
|
174
174
|
|
|
175
175
|
Calling `timeTravel()` again after the previous call finished is still allowed and re-runs the target step.
|
|
176
176
|
|
|
177
|
-
> **Note:**
|
|
177
|
+
> **Note:** Storage adapters that report `supportsConcurrentUpdates()` enforce the claim atomically. This requires atomic read-modify-write support, which is unavailable in adapters such as ClickHouse, Cloudflare D1, Cloudflare KV, Cloudflare Durable Objects, LanceDB, and Redis. Claims are also skipped when `shouldPersistSnapshot` excludes the `running` status or when using the Inngest workflow runner, which doesn't support them yet.
|
|
178
178
|
|
|
179
179
|
## Notes
|
|
180
180
|
|
|
@@ -230,7 +230,7 @@ const pkg = sandbox.filesystem
|
|
|
230
230
|
: (await sandbox.executeCommand?.('cat', ['/workspace/app/package.json']))?.stdout
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
`E2BSandbox`
|
|
233
|
+
`E2BSandbox` always exposes `filesystem`. With `PlatformSandbox`, the property is available only when the provider is `e2b` and returns `undefined` otherwise. To use it in a `Workspace`, pass it explicitly as the workspace `filesystem`, or call it directly.
|
|
234
234
|
|
|
235
235
|
## Computer capability
|
|
236
236
|
|
|
@@ -173,7 +173,7 @@ Read records are scoped to the filesystem they were read from, identified by the
|
|
|
173
173
|
|
|
174
174
|
### Tool hooks
|
|
175
175
|
|
|
176
|
-
Set `tools.hooks` to run logic before and after every enabled workspace tool call. Hooks run after name remapping
|
|
176
|
+
Set `tools.hooks` to run logic before and after every enabled workspace tool call. Hooks run after name remapping and receive both the exposed `toolName` and the original `workspaceToolName` in their context.
|
|
177
177
|
|
|
178
178
|
```typescript
|
|
179
179
|
import { Workspace } from '@mastra/core/workspace'
|
|
@@ -471,17 +471,17 @@ A workspace provides tools to agents based on what's configured.
|
|
|
471
471
|
|
|
472
472
|
Added when a filesystem is configured:
|
|
473
473
|
|
|
474
|
-
| Tool | Description
|
|
475
|
-
| ------------------------------ |
|
|
476
|
-
| `mastra_workspace_read_file` | Read file contents. Text files return as text (with optional line range). Images and PDFs return as native media parts the model can view directly. Other binaries return metadata only unless an explicit `encoding` is passed.
|
|
477
|
-
| `mastra_workspace_write_file` | Create or overwrite a file with new content. Creates parent directories automatically.
|
|
478
|
-
| `mastra_workspace_edit_file` | Edit an existing file by finding and replacing text. Useful for targeted changes without rewriting the entire file.
|
|
479
|
-
| `mastra_workspace_list_files` | List directory contents as a tree structure. Supports recursive listing with depth limits, glob patterns, and `.gitignore` filtering (enabled by default: every `.gitignore` applies relative to its own directory, and `node_modules` is skipped unless the listed path is inside it).
|
|
480
|
-
| `mastra_workspace_delete` | Delete a file or directory. Supports recursive deletion for directories.
|
|
481
|
-
| `mastra_workspace_file_stat` | Get metadata about a file or directory including size, type, and modification time.
|
|
482
|
-
| `mastra_workspace_mkdir` | Create a directory. Creates parent directories automatically if they don't exist.
|
|
483
|
-
| `mastra_workspace_grep` | Search file contents using regex patterns. Supports glob filtering, context lines, and case-insensitive search. Applies `.gitignore` files the same way as `list_files` and skips `node_modules` unless the search path is inside it.
|
|
484
|
-
| `mastra_workspace_apply_patch` | Create, update, move, and delete several files in one call using a patch. Opt-in: only added when `tools[WORKSPACE_TOOLS.FILESYSTEM.APPLY_PATCH].enabled` is set. The top-level `tools.enabled` doesn't enable it. The tool checks every hunk before
|
|
474
|
+
| Tool | Description |
|
|
475
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
476
|
+
| `mastra_workspace_read_file` | Read file contents. Text files return as text (with optional line range). Images and PDFs return as native media parts the model can view directly. Other binaries return metadata only unless an explicit `encoding` is passed. |
|
|
477
|
+
| `mastra_workspace_write_file` | Create or overwrite a file with new content. Creates parent directories automatically. |
|
|
478
|
+
| `mastra_workspace_edit_file` | Edit an existing file by finding and replacing text. Useful for targeted changes without rewriting the entire file. |
|
|
479
|
+
| `mastra_workspace_list_files` | List directory contents as a tree structure. Supports recursive listing with depth limits, glob patterns, and `.gitignore` filtering (enabled by default: every `.gitignore` applies relative to its own directory, and `node_modules` is skipped unless the listed path is inside it). |
|
|
480
|
+
| `mastra_workspace_delete` | Delete a file or directory. Supports recursive deletion for directories. |
|
|
481
|
+
| `mastra_workspace_file_stat` | Get metadata about a file or directory including size, type, and modification time. |
|
|
482
|
+
| `mastra_workspace_mkdir` | Create a directory. Creates parent directories automatically if they don't exist. |
|
|
483
|
+
| `mastra_workspace_grep` | Search file contents using regex patterns. Supports glob filtering, context lines, and case-insensitive search. Applies `.gitignore` files the same way as `list_files` and skips `node_modules` unless the search path is inside it. |
|
|
484
|
+
| `mastra_workspace_apply_patch` | Create, update, move, and delete several files in one call using a patch. Opt-in: only added when `tools[WORKSPACE_TOOLS.FILESYSTEM.APPLY_PATCH].enabled` is set. The top-level `tools.enabled` doesn't enable it. The tool checks every hunk before writing and leaves all files unchanged if any hunk fails to match. |
|
|
485
485
|
|
|
486
486
|
With a static filesystem, write tools (`write_file`, `edit_file`, `delete`, `mkdir`, `apply_patch`) are excluded when the filesystem is in read-only mode. With a [runtime-defined filesystem](https://mastra.ai/docs/sandbox/filesystem), write tools are always included and read-only is enforced at runtime.
|
|
487
487
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.10-alpha.
|
|
3
|
+
"version": "1.3.10-alpha.2",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"local-pkg": "^1.1.2",
|
|
28
28
|
"zod": "^4.6.7",
|
|
29
29
|
"@mastra/mcp": "^2.6.0-alpha.0",
|
|
30
|
-
"@mastra/core": "1.80.0-alpha.
|
|
30
|
+
"@mastra/core": "1.80.0-alpha.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@hono/node-server": "^2.0.0",
|
|
34
34
|
"@modelcontextprotocol/client": "2.3.1",
|
|
35
35
|
"@types/node": "22.20.5",
|
|
36
|
-
"@vitest/coverage-v8": "4.1.
|
|
37
|
-
"@vitest/ui": "4.1.
|
|
36
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
37
|
+
"@vitest/ui": "4.1.12",
|
|
38
38
|
"@wong2/mcp-cli": "^2.0.0",
|
|
39
39
|
"cross-env": "^10.1.0",
|
|
40
40
|
"hono": "^4.13.7",
|
|
41
41
|
"tsdown": "0.23.1",
|
|
42
42
|
"tsx": "^4.23.1",
|
|
43
43
|
"typescript": "^7.0.2",
|
|
44
|
-
"vitest": "4.1.
|
|
45
|
-
"@
|
|
44
|
+
"vitest": "4.1.12",
|
|
45
|
+
"@internal/lint": "0.0.145",
|
|
46
46
|
"@internal/types-builder": "0.0.120",
|
|
47
|
-
"@
|
|
47
|
+
"@mastra/core": "1.80.0-alpha.1"
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://mastra.ai",
|
|
50
50
|
"repository": {
|