@mastra/mcp-docs-server 1.3.1 → 1.3.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/harness/durable-agents.md +21 -3
- package/.docs/docs/memory/observational-memory.md +25 -12
- package/.docs/docs/memory/overview.md +2 -2
- package/.docs/integrations/deploy/kubernetes.md +6 -4
- package/.docs/models/gateways/netlify.md +5 -1
- package/.docs/models/gateways/openrouter.md +3 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/kilo.md +6 -4
- package/.docs/models/providers/nano-gpt.md +3 -3
- package/.docs/reference/agents/agent.md +15 -0
- package/.docs/reference/agents/durable-agent.md +1 -1
- package/.docs/reference/client-js/agents.md +2 -0
- package/.docs/reference/memory/cloneThread.md +2 -2
- package/.docs/reference/memory/observational-memory.md +4 -6
- package/.docs/reference/pubsub/base.md +11 -0
- package/.docs/reference/pubsub/redis-streams.md +8 -0
- package/package.json +3 -3
|
@@ -163,15 +163,29 @@ Visit the [`createInngestAgent()` reference](https://mastra.ai/reference/agents/
|
|
|
163
163
|
Durable agents support resumable streams through PubSub and an event cache. When a client disconnects mid-stream, the cache continues storing events. The same client can reconnect by calling `observe()` with the `runId`:
|
|
164
164
|
|
|
165
165
|
```typescript
|
|
166
|
-
const { output
|
|
166
|
+
const { output } = await durableResearcher.observe(runId)
|
|
167
167
|
|
|
168
168
|
for await (const chunk of output.fullStream) {
|
|
169
169
|
// Chunks from the run, including any missed while disconnected
|
|
170
170
|
}
|
|
171
|
+
```
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
Observing doesn't own the run. When the loop ends, or you leave it early with `break`, `return`, or an error, the observer unsubscribes and the run keeps going for anyone else watching it. To stop observing from outside the loop, for example when the client disconnects, call `detach()`:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
const { output, detach } = await durableResearcher.observe(runId)
|
|
177
|
+
|
|
178
|
+
request.signal.addEventListener('abort', detach, { once: true })
|
|
179
|
+
|
|
180
|
+
if (request.signal.aborted) detach()
|
|
181
|
+
|
|
182
|
+
for await (const chunk of output.fullStream) {
|
|
183
|
+
// Stops when the run finishes or the client disconnects
|
|
184
|
+
}
|
|
173
185
|
```
|
|
174
186
|
|
|
187
|
+
If you pass `idleTimeoutMs` and no chunks arrive for that long, Mastra checks `isAlive` when you provide it. If `isAlive` returns `true` or throws, the timer restarts and the stream stays open. Otherwise the stream ends with an error chunk and detaches the observer. The run itself is only cleaned up when `isAlive` returns `false`.
|
|
188
|
+
|
|
175
189
|
`createDurableAgent()` and `createEventedAgent()` use an in-memory cache by default, which means resumable streams work within a single process. For production, provide a persistent cache backend (e.g., Redis) so cached events survive process restarts:
|
|
176
190
|
|
|
177
191
|
```typescript
|
|
@@ -231,7 +245,11 @@ Visit [Background tasks](https://mastra.ai/docs/harness/background-tasks) for th
|
|
|
231
245
|
|
|
232
246
|
## Cleanup
|
|
233
247
|
|
|
234
|
-
Every `stream()` and `observe()` call returns a `cleanup` function
|
|
248
|
+
Every `stream()` and `observe()` call returns a `cleanup` function that tears the run down: it unsubscribes from PubSub, removes the run from the internal registry, and deletes the run's cached events so nobody can replay it afterward.
|
|
249
|
+
|
|
250
|
+
When you don't call `cleanup()` yourself, Mastra calls it `cleanupTimeoutMs` after the run finishes, errors, or is aborted. Detaching an observer or reaching a plain `idleTimeoutMs` doesn't start this timer. Set `cleanupTimeoutMs: 0` to turn the timer off.
|
|
251
|
+
|
|
252
|
+
Call `cleanup()` from the process that started the run. To stop watching a run from `observe()`, use `detach()` or leave the loop instead.
|
|
235
253
|
|
|
236
254
|
## Tool approval
|
|
237
255
|
|
|
@@ -615,29 +615,42 @@ const memory = new Memory({
|
|
|
615
615
|
|
|
616
616
|
Thread scope requires a valid `threadId` to be provided when calling the agent. If `threadId` is missing, Observational Memory throws an error. This prevents multiple threads from silently sharing a single observation record, which can cause database deadlocks.
|
|
617
617
|
|
|
618
|
-
### Resource scope (
|
|
618
|
+
### Resource scope (deprecated)
|
|
619
619
|
|
|
620
|
-
|
|
620
|
+
> **Deprecated:** `scope: 'resource'` is deprecated and will be removed in a future release. Mastra logs a warning the first time Observational Memory is created with resource scope. Remove the `scope` option to use the default thread scope, and use the [alternatives below](#cross-thread-continuity-without-resource-scope) for cross-conversation continuity.
|
|
621
|
+
|
|
622
|
+
In resource scope, observations are shared across all threads for a resource (typically a user). Resource scope works much worse than thread scope for prompt caching and for the agent's understanding of the conversation:
|
|
623
|
+
|
|
624
|
+
- **Prompt caching:** Observations from every thread share one record. When any thread is observed, the observation context changes for all other threads, which invalidates their cached prompt prefix.
|
|
625
|
+
- **Agent understanding:** Each thread sees a mix of observations from every thread for the resource. Every new thread starts with context from earlier threads, and the agent may continue work that another thread started but didn't finish.
|
|
626
|
+
- **Performance:** Unobserved messages across _all_ threads are processed together, which is slow for users with many existing threads.
|
|
627
|
+
|
|
628
|
+
A new knowledge and subconscious memory primitive for cross-thread memory is coming soon and will replace resource scope. Until then, use the alternatives below.
|
|
629
|
+
|
|
630
|
+
#### Cross-thread continuity without resource scope
|
|
631
|
+
|
|
632
|
+
Switching from resource scope to thread scope doesn't migrate resource-scoped observations. Each thread uses its existing thread-scoped record if it has one, or starts a new, empty one, and messages already observed under resource scope aren't observed again. Keep facts that must carry over in resource-scoped working memory.
|
|
633
|
+
|
|
634
|
+
Use thread scope with one or both of these features instead:
|
|
635
|
+
|
|
636
|
+
- [Retrieval mode](#retrieval-mode): The agent gets a `recall` tool that can list and browse other threads for the same resource, and optionally search them semantically. The agent looks up earlier conversations only when it needs them.
|
|
637
|
+
- [Resource-scoped working memory](https://mastra.ai/docs/memory/working-memory): Stores small, durable facts about the user that every thread can read.
|
|
621
638
|
|
|
622
639
|
```typescript
|
|
623
640
|
const memory = new Memory({
|
|
624
641
|
options: {
|
|
625
642
|
observationalMemory: {
|
|
626
643
|
model: 'google/gemini-2.5-flash',
|
|
644
|
+
retrieval: true,
|
|
645
|
+
},
|
|
646
|
+
workingMemory: {
|
|
647
|
+
enabled: true,
|
|
627
648
|
scope: 'resource',
|
|
628
649
|
},
|
|
629
650
|
},
|
|
630
651
|
})
|
|
631
652
|
```
|
|
632
653
|
|
|
633
|
-
Resource scope works, however it's marked as experimental for now until we prove task adherence/continuity across multiple ongoing simultaneous threads. As of today, you may need to tweak your system prompt to prevent one thread from continuing the work that another had already started (but hadn't finished).
|
|
634
|
-
|
|
635
|
-
This is because in resource scope, each thread is a perspective on _all_ threads for the resource.
|
|
636
|
-
|
|
637
|
-
For your use-case this may not be a problem, so your mileage may vary.
|
|
638
|
-
|
|
639
|
-
> **Warning:** In resource scope, unobserved messages across _all_ threads are processed together. For users with many existing threads, this can be slow. Use thread scope for existing apps.
|
|
640
|
-
|
|
641
654
|
## Token budgets
|
|
642
655
|
|
|
643
656
|
OM uses token thresholds to decide when to observe and reflect. See [token budget configuration](https://mastra.ai/reference/memory/observational-memory) for details.
|
|
@@ -786,7 +799,7 @@ const memory = new Memory({
|
|
|
786
799
|
|
|
787
800
|
Setting `bufferTokens: false` disables both observation and reflection async buffering. See [async buffering configuration](https://mastra.ai/reference/memory/observational-memory) for the full API.
|
|
788
801
|
|
|
789
|
-
> **Note:** Resource scope automatically disables async buffering.
|
|
802
|
+
> **Note:** Resource scope (deprecated) automatically disables async buffering.
|
|
790
803
|
|
|
791
804
|
## Observer Context Optimization
|
|
792
805
|
|
|
@@ -889,7 +902,7 @@ hooks: {
|
|
|
889
902
|
No manual migration needed. OM reads existing messages and observes them lazily when thresholds are exceeded.
|
|
890
903
|
|
|
891
904
|
- **Thread scope**: The first time a thread exceeds `observation.messageTokens`, the Observer processes the backlog.
|
|
892
|
-
- **Resource scope**: All unobserved messages across all threads for a resource are processed together. For users with many existing threads, this could take substantial time.
|
|
905
|
+
- **Resource scope (deprecated)**: All unobserved messages across all threads for a resource are processed together. For users with many existing threads, this could take substantial time.
|
|
893
906
|
|
|
894
907
|
## Comparing OM with other memory features
|
|
895
908
|
|
|
@@ -212,7 +212,7 @@ To go beyond this default isolation, you can share memory between agents by pass
|
|
|
212
212
|
|
|
213
213
|
When you call agents directly (outside the delegation flow), memory sharing is controlled by two identifiers: `resourceId` and `threadId`. Agents that use the same values read and write to the same data. This is useful when agents collaborate on a shared context, for example, a researcher that saves notes and a writer that reads them.
|
|
214
214
|
|
|
215
|
-
**Resource-scoped sharing** is the most common pattern. [Working memory](https://mastra.ai/docs/memory/working-memory) and [semantic recall](https://mastra.ai/docs/memory/semantic-recall) default to `scope: 'resource'`. If two agents share a `resourceId`, they share
|
|
215
|
+
**Resource-scoped sharing** is the most common pattern. [Working memory](https://mastra.ai/docs/memory/working-memory) and [semantic recall](https://mastra.ai/docs/memory/semantic-recall) default to `scope: 'resource'`. If two agents share a `resourceId`, they share working memory and embeddings, even across different threads:
|
|
216
216
|
|
|
217
217
|
```typescript
|
|
218
218
|
// Both agents share the same resource-scoped memory
|
|
@@ -225,7 +225,7 @@ await writer.generate('Write a summary from the research notes.', {
|
|
|
225
225
|
})
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
Because both calls use `resource: 'project-42'`, the writer can access the researcher's
|
|
228
|
+
Because both calls use `resource: 'project-42'`, the writer can access the researcher's working memory. Semantic embeddings are also shared through the resource. Each agent still has its own thread, so message histories stay separate.
|
|
229
229
|
|
|
230
230
|
**Thread-scoped sharing** gives tighter coupling. [Observational Memory](https://mastra.ai/docs/memory/observational-memory) uses `scope: 'thread'` by default. If two agents use the same `resource` and `thread`, they share the full message history. Each agent sees every message the other has written. This is useful when agents need to build on each other's exact outputs.
|
|
231
231
|
|
|
@@ -251,18 +251,20 @@ Register the durable agent with the `Mastra` instance above. Its run state now l
|
|
|
251
251
|
A durable agent publishes stream chunks to a per-run topic through the shared pub/sub. A client that disconnects reconnects by calling `observe()` with the run's ID, and replays the chunks it missed from the shared cache:
|
|
252
252
|
|
|
253
253
|
```typescript
|
|
254
|
-
const { output,
|
|
254
|
+
const { output, detach } = await durableAssistant.observe(runId)
|
|
255
|
+
|
|
256
|
+
request.signal.addEventListener('abort', detach, { once: true })
|
|
257
|
+
|
|
258
|
+
if (request.signal.aborted) detach()
|
|
255
259
|
|
|
256
260
|
for await (const chunk of output.fullStream) {
|
|
257
261
|
// Chunks from the run, including any missed while disconnected
|
|
258
262
|
}
|
|
259
|
-
|
|
260
|
-
cleanup()
|
|
261
263
|
```
|
|
262
264
|
|
|
263
265
|
Because the run state is in Postgres and the events are in Redis, the reconnecting request can be served by any pod, not only the one that started the run. See [Resumable streams](https://mastra.ai/docs/harness/durable-agents).
|
|
264
266
|
|
|
265
|
-
Multiple clients can observe the same run at once. Each `observe()` call receives the full stream, so a user watching from two devices, or two people following the same run, stay in sync.
|
|
267
|
+
Multiple clients can observe the same run at once. Each `observe()` call receives the full stream, so a user watching from two devices, or two people following the same run, stay in sync. When one client leaves the loop or calls `detach()`, only that client stops watching. Don't call `cleanup()` from an observer, because it clears the cached events the other clients need to reconnect.
|
|
266
268
|
|
|
267
269
|
## Tool approval across pods
|
|
268
270
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Netlify
|
|
6
6
|
|
|
7
|
-
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access
|
|
7
|
+
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access 269 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Netlify documentation](https://docs.netlify.com/build/ai-gateway/overview/).
|
|
10
10
|
|
|
@@ -188,11 +188,15 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
188
188
|
| `openrouter/minimax/minimax-m2.5` |
|
|
189
189
|
| `openrouter/minimax/minimax-m2.7` |
|
|
190
190
|
| `openrouter/minimax/minimax-m3` |
|
|
191
|
+
| `openrouter/mistralai/devstral-2512` |
|
|
191
192
|
| `openrouter/mistralai/ministral-14b-2512` |
|
|
192
193
|
| `openrouter/mistralai/ministral-3b-2512` |
|
|
193
194
|
| `openrouter/mistralai/ministral-8b-2512` |
|
|
194
195
|
| `openrouter/mistralai/mistral-large-2407` |
|
|
196
|
+
| `openrouter/mistralai/mistral-large-2512` |
|
|
197
|
+
| `openrouter/mistralai/mistral-medium-3` |
|
|
195
198
|
| `openrouter/mistralai/mistral-medium-3-5` |
|
|
199
|
+
| `openrouter/mistralai/mistral-medium-3.1` |
|
|
196
200
|
| `openrouter/mistralai/mistral-nemo` |
|
|
197
201
|
| `openrouter/mistralai/mistral-saba` |
|
|
198
202
|
| `openrouter/mistralai/mistral-small-24b-instruct-2501` |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# OpenRouter
|
|
6
6
|
|
|
7
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
7
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 387 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
10
10
|
|
|
@@ -187,11 +187,13 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
187
187
|
| `minimax/minimax-m2.7` |
|
|
188
188
|
| `minimax/minimax-m3` |
|
|
189
189
|
| `mistralai/codestral-2508` |
|
|
190
|
+
| `mistralai/devstral-2512` |
|
|
190
191
|
| `mistralai/ministral-14b-2512` |
|
|
191
192
|
| `mistralai/ministral-3b-2512` |
|
|
192
193
|
| `mistralai/ministral-8b-2512` |
|
|
193
194
|
| `mistralai/mistral-large` |
|
|
194
195
|
| `mistralai/mistral-large-2407` |
|
|
196
|
+
| `mistralai/mistral-large-2512` |
|
|
195
197
|
| `mistralai/mistral-medium-3` |
|
|
196
198
|
| `mistralai/mistral-medium-3-5` |
|
|
197
199
|
| `mistralai/mistral-medium-3.1` |
|
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 7624 models from 210 providers through a single API.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Kilo Gateway
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 394 Kilo Gateway models through Mastra's model router. Authentication is handled automatically using the `KILO_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Kilo Gateway documentation](https://kilo.ai).
|
|
10
10
|
|
|
@@ -47,7 +47,7 @@ for await (const chunk of stream) {
|
|
|
47
47
|
| `kilo/~deepseek/deepseek-v4-flash-latest` | 1.0M | | | | | | $0.03 | $0.32 |
|
|
48
48
|
| `kilo/~google/gemini-flash-latest` | 1.0M | | | | | | $0.75 | $4 |
|
|
49
49
|
| `kilo/~google/gemini-pro-latest` | 1.0M | | | | | | $2 | $12 |
|
|
50
|
-
| `kilo/~moonshotai/kimi-latest` | 1.0M | | | | | | $1 | $
|
|
50
|
+
| `kilo/~moonshotai/kimi-latest` | 1.0M | | | | | | $1 | $11 |
|
|
51
51
|
| `kilo/~openai/gpt-astra-latest` | 1.1M | | | | | | $10 | $50 |
|
|
52
52
|
| `kilo/~openai/gpt-luna-latest` | 1.1M | | | | | | $0.10 | $0.50 |
|
|
53
53
|
| `kilo/~openai/gpt-mini-latest` | 400K | | | | | | $0.75 | $5 |
|
|
@@ -190,20 +190,22 @@ for await (const chunk of stream) {
|
|
|
190
190
|
| `kilo/minimax/minimax-m2.7` | 205K | | | | | | $0.30 | $1 |
|
|
191
191
|
| `kilo/minimax/minimax-m3` | 524K | | | | | | $0.30 | $1 |
|
|
192
192
|
| `kilo/mistralai/codestral-2508` | 256K | | | | | | $0.30 | $0.90 |
|
|
193
|
+
| `kilo/mistralai/devstral-2512` | 262K | | | | | | $0.40 | $2 |
|
|
193
194
|
| `kilo/mistralai/ministral-14b-2512` | 262K | | | | | | $0.20 | $0.20 |
|
|
194
195
|
| `kilo/mistralai/ministral-3b-2512` | 131K | | | | | | $0.10 | $0.10 |
|
|
195
196
|
| `kilo/mistralai/ministral-8b-2512` | 262K | | | | | | $0.15 | $0.15 |
|
|
196
197
|
| `kilo/mistralai/mistral-large` | 128K | | | | | | $2 | $6 |
|
|
197
198
|
| `kilo/mistralai/mistral-large-2407` | 131K | | | | | | $2 | $6 |
|
|
199
|
+
| `kilo/mistralai/mistral-large-2512` | 262K | | | | | | $0.50 | $2 |
|
|
198
200
|
| `kilo/mistralai/mistral-medium-3` | 131K | | | | | | $0.40 | $2 |
|
|
199
201
|
| `kilo/mistralai/mistral-medium-3-5` | 262K | | | | | | $2 | $8 |
|
|
200
202
|
| `kilo/mistralai/mistral-medium-3.1` | 131K | | | | | | $0.40 | $2 |
|
|
201
|
-
| `kilo/mistralai/mistral-nemo` | 131K | | | | | | $0.
|
|
203
|
+
| `kilo/mistralai/mistral-nemo` | 131K | | | | | | $0.15 | $0.15 |
|
|
202
204
|
| `kilo/mistralai/mistral-saba` | 33K | | | | | | $0.20 | $0.60 |
|
|
203
205
|
| `kilo/mistralai/mistral-small-24b-instruct-2501` | 33K | | | | | | $0.05 | $0.08 |
|
|
204
206
|
| `kilo/mistralai/mistral-small-2603` | 262K | | | | | | $0.15 | $0.60 |
|
|
205
207
|
| `kilo/mistralai/mistral-small-3.1-24b-instruct` | 128K | | | | | | $0.35 | $0.56 |
|
|
206
|
-
| `kilo/mistralai/mistral-small-3.2-24b-instruct` | 256K | | | | | | $0.
|
|
208
|
+
| `kilo/mistralai/mistral-small-3.2-24b-instruct` | 256K | | | | | | $0.10 | $0.30 |
|
|
207
209
|
| `kilo/mistralai/mixtral-8x22b-instruct` | 66K | | | | | | $2 | $6 |
|
|
208
210
|
| `kilo/mistralai/voxtral-small-24b-2507` | 33K | | | | | | $0.10 | $0.30 |
|
|
209
211
|
| `kilo/moonshotai/kimi-k2` | 131K | | | | | | $0.57 | $2 |
|
|
@@ -83,7 +83,7 @@ for await (const chunk of stream) {
|
|
|
83
83
|
| `nano-gpt/anthropic/claude-opus-4.8:thinking` | 1.0M | | | | | | $5 | $25 |
|
|
84
84
|
| `nano-gpt/anthropic/claude-opus-5` | 1.0M | | | | | | $5 | $25 |
|
|
85
85
|
| `nano-gpt/anthropic/claude-opus-5.5` | 1.0M | | | | | | $4 | $20 |
|
|
86
|
-
| `nano-gpt/anthropic/claude-opus-latest` | 1.0M | | | | | | $
|
|
86
|
+
| `nano-gpt/anthropic/claude-opus-latest` | 1.0M | | | | | | $4 | $20 |
|
|
87
87
|
| `nano-gpt/anthropic/claude-sonnet-4` | 200K | | | | | | $3 | $15 |
|
|
88
88
|
| `nano-gpt/anthropic/claude-sonnet-4:thinking` | 1.0M | | | | | | $3 | $15 |
|
|
89
89
|
| `nano-gpt/anthropic/claude-sonnet-4:thinking:1024` | 1.0M | | | | | | $3 | $15 |
|
|
@@ -400,7 +400,7 @@ for await (const chunk of stream) {
|
|
|
400
400
|
| `nano-gpt/openai/gpt-astra-latest` | 1.1M | | | | | | $10 | $50 |
|
|
401
401
|
| `nano-gpt/openai/gpt-chat-latest` | 1.1M | | | | | | $2 | $10 |
|
|
402
402
|
| `nano-gpt/openai/gpt-latest` | 1.1M | | | | | | $10 | $50 |
|
|
403
|
-
| `nano-gpt/openai/gpt-luna-latest` | 1.1M | | | | | | $0.
|
|
403
|
+
| `nano-gpt/openai/gpt-luna-latest` | 1.1M | | | | | | $0.10 | $0.50 |
|
|
404
404
|
| `nano-gpt/openai/gpt-oss-120b` | 128K | | | | | | $0.35 | $0.75 |
|
|
405
405
|
| `nano-gpt/openai/gpt-oss-20b` | 128K | | | | | | $0.20 | $0.30 |
|
|
406
406
|
| `nano-gpt/openai/gpt-oss-safeguard-20b` | 128K | | | | | | $0.07 | $0.30 |
|
|
@@ -586,7 +586,7 @@ for await (const chunk of stream) {
|
|
|
586
586
|
| `nano-gpt/x-ai/grok-4.6` | 500K | | | | | | $2 | $6 |
|
|
587
587
|
| `nano-gpt/x-ai/grok-4.7` | 500K | | | | | | $2 | $5 |
|
|
588
588
|
| `nano-gpt/x-ai/grok-build-0.1` | 256K | | | | | | $1 | $2 |
|
|
589
|
-
| `nano-gpt/x-ai/grok-latest` | 500K | | | | | | $2 | $
|
|
589
|
+
| `nano-gpt/x-ai/grok-latest` | 500K | | | | | | $2 | $5 |
|
|
590
590
|
| `nano-gpt/xiaomi/mimo-v2.5` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
591
591
|
| `nano-gpt/xiaomi/mimo-v2.5-pro` | 1.0M | | | | | | $0.43 | $0.87 |
|
|
592
592
|
| `nano-gpt/xiaomi/mimo-v2.5-pro:thinking` | 1.0M | | | | | | $0.43 | $0.87 |
|
|
@@ -510,6 +510,8 @@ Subscribes to raw stream chunks for a memory thread. Use this before calling `se
|
|
|
510
510
|
|
|
511
511
|
**options.hideSignals** (`boolean | AgentSignalType[]`): Use true to hide all recognized signals, false to show all, or an array to hide selected types from this subscription, including live, idle-persisted, and replayed signals. Other subscribers and the initiating stream keep their own policies.
|
|
512
512
|
|
|
513
|
+
**options.withInitialHistory** (`boolean | { perPage?: number }`): Emit the stored thread messages as one thread-history chunk first, then only retained parts newer than that history, then live parts. Completed runs already in storage aren't replayed; pending tool approvals are still emitted. perPage limits how many recent messages are loaded (default 40). Requires agent memory; without it the subscription is live-only.
|
|
514
|
+
|
|
513
515
|
By default, subscriptions include every signal type, including reactive reminders. To hide reminders for one subscriber without affecting another:
|
|
514
516
|
|
|
515
517
|
```ts
|
|
@@ -520,6 +522,19 @@ const filtered = await agent.subscribeToThread({
|
|
|
520
522
|
})
|
|
521
523
|
```
|
|
522
524
|
|
|
525
|
+
To render a thread without replaying finished runs, request initial history. The first chunk carries the stored messages:
|
|
526
|
+
|
|
527
|
+
```ts
|
|
528
|
+
const subscription = await agent.subscribeToThread({
|
|
529
|
+
threadId: 'thread-abc',
|
|
530
|
+
withInitialHistory: true,
|
|
531
|
+
})
|
|
532
|
+
for await (const chunk of subscription.stream) {
|
|
533
|
+
if (chunk.type === 'thread-history') render(chunk.payload.messages)
|
|
534
|
+
else handle(chunk)
|
|
535
|
+
}
|
|
536
|
+
```
|
|
537
|
+
|
|
523
538
|
`hideSignals: true` hides all recognized signal types. Set it to `false` to show all signals. An array accepts `user`, `state`, `reactive`, `notification`, `user-message`, and `system-reminder`. Matching normalizes `system-reminder` to `reactive` and `user-message` to `user`. An omitted option, `false`, or `[]` excludes nothing. Each subscriber filters its own live and replayed chunks, including remote pubsub events and idle-persisted signals. Filtering preserves non-signal chunks, unknown or malformed signal chunks, ordering, and completion/error events, even when every signal type is excluded.
|
|
524
539
|
|
|
525
540
|
Exclusions don't change model context, storage, shared broadcasts, or another caller's output. They aren't a security boundary and don't replace `ifActive`/`ifIdle` delivery policies or `transient` persistence behavior. This option is supported by the in-process core API, not HTTP or client-js subscription requests. See [stream signal visibility](https://mastra.ai/reference/streaming/agents/stream) for transform ordering and the distinction from recall's exact stored-type matching and reminder-hidden history default.
|
|
@@ -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 workflow engine. Like `createDurableAgent`, it returns a result you stream from, but the
|
|
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: execution is driven by events on the Mastra instance's PubSub, so the run progresses 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'
|
|
@@ -302,6 +302,8 @@ await subscription.processDataStream({
|
|
|
302
302
|
})
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
+
Pass `withInitialHistory: true` (or `{ perPage }`) to receive the stored messages as a first `thread-history` chunk instead of fetching history separately. Finished runs aren't replayed after it, so completed answers don't stream again on reconnect.
|
|
306
|
+
|
|
305
307
|
`subscribeToThread()` returns the underlying `Response` plus a `processDataStream()` helper. The helper reads the subscription stream until the connection closes or the request is aborted. Pass `reconnect: true` to resubscribe when the transport closes or a reconnect request fails, such as after a proxy idle timeout.
|
|
306
308
|
|
|
307
309
|
**resourceId** (`string`): Resource ID for the memory thread.
|
|
@@ -171,7 +171,7 @@ When working memory is enabled, `cloneThread()` copies or shares working memory
|
|
|
171
171
|
When [Observational Memory](https://mastra.ai/docs/memory/observational-memory) is enabled, `cloneThread()` automatically clones the OM records associated with the source thread. The behavior depends on the OM scope:
|
|
172
172
|
|
|
173
173
|
- **Thread-scoped OM**: The OM record is cloned to the new thread. All internal message ID references are remapped to point to the cloned messages.
|
|
174
|
-
- **Resource-scoped OM (same `resourceId`)**: The OM record is shared between the source and cloned threads since they belong to the same resource. No duplication occurs.
|
|
175
|
-
- **Resource-scoped OM (different `resourceId`)**: The OM record is cloned to the new resource. Message IDs are remapped and any thread-identifying tags within observations are updated to reference the cloned thread.
|
|
174
|
+
- **Resource-scoped OM (deprecated, same `resourceId`)**: The OM record is shared between the source and cloned threads since they belong to the same resource. No duplication occurs.
|
|
175
|
+
- **Resource-scoped OM (deprecated, different `resourceId`)**: The OM record is cloned to the new resource. Message IDs are remapped and any thread-identifying tags within observations are updated to reference the cloned thread.
|
|
176
176
|
|
|
177
177
|
Only the current (most recent) OM generation is cloned. Older history generations aren't copied. Transient processing state (observation/reflection in-progress flags) is reset on the cloned record.
|
|
@@ -39,7 +39,7 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
39
39
|
|
|
40
40
|
**model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with observation.model or reflection.model — an error will be thrown if both are set. When this and observation.model/reflection.model are all omitted, OM falls back to google/gemini-2.5-flash. Use "default" to explicitly use the default model (google/gemini-2.5-flash). (Default: `'google/gemini-2.5-flash'`)
|
|
41
41
|
|
|
42
|
-
**scope** (`'resource' | 'thread'`): Memory scope for observations. 'thread' keeps observations per-thread. 'resource'
|
|
42
|
+
**scope** (`'resource' | 'thread'`): Memory scope for observations. 'thread' keeps observations per-thread. 'resource' is deprecated and will be removed in a future release. It shares observations across all threads for a resource and works much worse than thread scope for prompt caching and agent understanding. For cross-thread continuity, use thread scope with retrieval or resource-scoped working memory. See resource scope (deprecated). (Default: `'thread'`)
|
|
43
43
|
|
|
44
44
|
**activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity, even before observation.messageTokens is reached. Accepts a numeric millisecond value such as 300\_000, duration strings like "5m" or "1hr", "auto" for a provider-aware prompt cache TTL, or false to disable inherited observation idle activation. Reflections do not inherit this setting. Use reflection.activateAfterIdle to opt reflections into idle activation.
|
|
45
45
|
|
|
@@ -71,7 +71,7 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
71
71
|
|
|
72
72
|
**observation.messageTokens** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. Text is estimated locally with tokenx. Image parts are included with model-aware heuristics when possible, with deterministic fallbacks when image metadata is incomplete. Image-like file parts are counted the same way when uploads are normalized as files.
|
|
73
73
|
|
|
74
|
-
**observation.maxTokensPerBatch** (`number`): Maximum tokens per batch when observing multiple threads in resource scope. Threads are chunked into batches of this size and processed in parallel. Lower values mean more parallelism but more API calls.
|
|
74
|
+
**observation.maxTokensPerBatch** (`number`): Maximum tokens per batch when observing multiple threads in resource scope (deprecated). Threads are chunked into batches of this size and processed in parallel. Lower values mean more parallelism but more API calls.
|
|
75
75
|
|
|
76
76
|
**observation.modelSettings** (`ObservationalMemoryModelSettings`): Model settings for the Observer agent. The temperature: 0.3 default is only applied when the resolved model is known to support temperature. The maxOutputTokens: 100\_000 default is only applied with default model selection (no model set, "default", or a ModelByInputTokens selector). Custom models get no maxOutputTokens default.
|
|
77
77
|
|
|
@@ -216,7 +216,7 @@ const memory = new Memory({
|
|
|
216
216
|
|
|
217
217
|
Set `workingMemory.agentManaged: true` if the main agent should still receive working memory tool and instruction injection.
|
|
218
218
|
|
|
219
|
-
###
|
|
219
|
+
### Custom thresholds
|
|
220
220
|
|
|
221
221
|
```typescript
|
|
222
222
|
import { Memory } from '@mastra/memory'
|
|
@@ -231,7 +231,6 @@ export const agent = new Agent({
|
|
|
231
231
|
options: {
|
|
232
232
|
observationalMemory: {
|
|
233
233
|
model: 'google/gemini-2.5-flash',
|
|
234
|
-
scope: 'resource',
|
|
235
234
|
observation: {
|
|
236
235
|
messageTokens: 20_000,
|
|
237
236
|
},
|
|
@@ -420,7 +419,7 @@ observationalMemory: {
|
|
|
420
419
|
|
|
421
420
|
Setting `bufferTokens: false` disables both observation and reflection async buffering. Observations and reflections will run synchronously when their thresholds are reached.
|
|
422
421
|
|
|
423
|
-
> **Note:** Async buffering isn't supported with `scope: 'resource'` and is automatically disabled in resource scope.
|
|
422
|
+
> **Note:** Async buffering isn't supported with the deprecated `scope: 'resource'` and is automatically disabled in resource scope.
|
|
424
423
|
|
|
425
424
|
## Streaming data parts
|
|
426
425
|
|
|
@@ -734,7 +733,6 @@ const om = new ObservationalMemory({
|
|
|
734
733
|
storage: storage.stores.memory!,
|
|
735
734
|
memory,
|
|
736
735
|
model: 'google/gemini-2.5-flash',
|
|
737
|
-
scope: 'resource',
|
|
738
736
|
observation: {
|
|
739
737
|
messageTokens: 20_000,
|
|
740
738
|
},
|
|
@@ -119,6 +119,17 @@ The default implementation is a no-op because transports that retain nothing per
|
|
|
119
119
|
await pubsub.clearTopic('workflow.events.v2.run-123')
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
+
#### `trimTopic(topic, { runId, producedBefore? })`
|
|
123
|
+
|
|
124
|
+
Deletes every retained entry on the topic that was published with `runId`. Other entries are untouched. Mastra calls this once a run completes successfully and its messages are saved to storage, so finished runs leave the topic while runs still in progress or waiting for approval stay. The default implementation is a no-op. [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) overrides it. Same best-effort contract as `clearTopic`.
|
|
125
|
+
|
|
126
|
+
With `producedBefore` (epoch ms), only entries whose `data.producedAt` is at or before it are deleted, and entries marked `data.pinned` (approval and suspension prompts) are kept. Mastra uses this while a run continues: each time the run's messages are saved mid-run, the parts up to the last finished step leave the topic.
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
await pubsub.trimTopic('agent.thread.thread-abc', { runId: 'run-123' })
|
|
130
|
+
await pubsub.trimTopic('agent.thread.thread-abc', { runId: 'run-123', producedBefore: Date.now() })
|
|
131
|
+
```
|
|
132
|
+
|
|
122
133
|
### Replay methods
|
|
123
134
|
|
|
124
135
|
These methods support resuming a stream after a disconnect. The default implementations fall back to a regular `subscribe`, so backends without history support behave as live-only. [`CachingPubSub`](https://mastra.ai/reference/pubsub/caching-pubsub) overrides them to replay cached events.
|
|
@@ -159,6 +159,14 @@ Not every topic reaches a `clearTopic` call. Topics without a defined end of lif
|
|
|
159
159
|
await pubsub.clearTopic('workflow.events.run-123')
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
+
### `trimTopic(topic, { runId, producedBefore? })`
|
|
163
|
+
|
|
164
|
+
Pages through the stream with `XRANGE` and runs `XDEL` for every entry published with `runId`. With `producedBefore`, only entries produced at or before that time are deleted, skipping approval and suspension prompts. Mastra uses this to trim a long run each time its messages are saved. Mastra calls this once a thread run's messages are persisted, so an idle thread's stream empties instead of growing to `maxLen`. Because entries are matched by `runId`, a run resumed after a restart also removes the entries it published before the restart. Entries from other runs, including those from other processes, are never touched. Best-effort. Failures are logged at warn level.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
await pubsub.trimTopic('agent.thread.thread-abc', { runId: 'run-123' })
|
|
168
|
+
```
|
|
169
|
+
|
|
162
170
|
### `close()`
|
|
163
171
|
|
|
164
172
|
Closes the Redis connections and stops all subscriptions. Call this during graceful shutdown.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.1",
|
|
3
|
+
"version": "1.3.2-alpha.1",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
|
|
27
27
|
"local-pkg": "^1.1.2",
|
|
28
28
|
"zod": "^4.6.4",
|
|
29
|
-
"@mastra/core": "1.
|
|
29
|
+
"@mastra/core": "1.72.0-alpha.0",
|
|
30
30
|
"@mastra/mcp": "^2.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typescript": "^7.0.2",
|
|
45
45
|
"vitest": "4.1.11",
|
|
46
46
|
"@internal/lint": "0.0.137",
|
|
47
|
-
"@mastra/core": "1.
|
|
47
|
+
"@mastra/core": "1.72.0-alpha.0",
|
|
48
48
|
"@internal/types-builder": "0.0.112"
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://mastra.ai",
|