@mastra/mcp-docs-server 1.2.26-alpha.3 → 1.2.26-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +21 -0
- package/.docs/docs/deployment/mastra-server.md +8 -2
- package/.docs/docs/guides/context-engineering.md +1 -1
- package/.docs/docs/harness/background-tasks.md +30 -24
- package/.docs/docs/harness/signals.md +39 -0
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/memory/message-history.md +5 -1
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +7 -0
- package/.docs/integrations/file-storage/archil.md +3 -3
- package/.docs/integrations/frameworks/electron.md +1 -1
- package/.docs/integrations/sandboxes/cloudflare-sandbox.md +2 -0
- package/.docs/integrations/sandboxes/docker.md +13 -0
- package/.docs/models/gateways/merge-gateway.md +6 -1
- package/.docs/models/gateways/netlify.md +2 -1
- package/.docs/models/gateways/openrouter.md +8 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/above.md +1 -1
- package/.docs/models/providers/baseten.md +2 -1
- package/.docs/models/providers/bothub.md +2 -1
- package/.docs/models/providers/cline-pass.md +18 -17
- package/.docs/models/providers/cortecs.md +3 -3
- package/.docs/models/providers/deepinfra.md +6 -3
- package/.docs/models/providers/edenai.md +18 -4
- package/.docs/models/providers/empiriolabs.md +3 -1
- package/.docs/models/providers/greenpt.md +2 -1
- package/.docs/models/providers/huggingface.md +4 -1
- package/.docs/models/providers/hyper.md +3 -3
- package/.docs/models/providers/kilo.md +15 -10
- package/.docs/models/providers/llmgateway-providers.md +4 -2
- package/.docs/models/providers/llmgateway.md +3 -1
- package/.docs/models/providers/nan.md +1 -1
- package/.docs/models/providers/nano-gpt.md +12 -3
- package/.docs/models/providers/ofox.md +15 -9
- package/.docs/models/providers/ollama-cloud.md +2 -1
- package/.docs/models/providers/pioneer.md +11 -2
- package/.docs/models/providers/requesty.md +2 -2
- package/.docs/models/providers/volcengine-coding-plan.md +3 -1
- package/.docs/reference/configuration.md +2 -2
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/memory/cloneThread.md +2 -0
- package/.docs/reference/memory/copyThread.md +65 -0
- package/.docs/reference/memory/memory-class.md +2 -1
- package/.docs/reference/memory/updateThreadResourceId.md +46 -0
- package/.docs/reference/processors/processor-interface.md +2 -0
- package/.docs/reference/pubsub/redis-streams.md +6 -0
- package/.docs/reference/pubsub/valkey-streams.md +6 -0
- package/.docs/reference/workspace/filesystem.md +72 -0
- package/package.json +6 -6
|
@@ -76,7 +76,7 @@ Short list of known model IDs are:
|
|
|
76
76
|
|
|
77
77
|
Go to <https://mastra.ai/models> for a full list of supported models.
|
|
78
78
|
|
|
79
|
-
Add a tool an agent by importing the tool and passing it to the agent constructor as a tools object.
|
|
79
|
+
Add a tool to an agent by importing the tool and passing it to the agent constructor as a tools object.
|
|
80
80
|
|
|
81
81
|
Example:
|
|
82
82
|
|
|
@@ -976,6 +976,27 @@ export class ContextLengthHandler implements Processor {
|
|
|
976
976
|
|
|
977
977
|
Mastra includes a built-in [`PrefillErrorHandler`](https://mastra.ai/reference/processors/prefill-error-handler) that automatically handles the Anthropic "assistant message prefill" error. This processor is auto-injected and requires no configuration.
|
|
978
978
|
|
|
979
|
+
## Receive background work notifications
|
|
980
|
+
|
|
981
|
+
Use `createBackgroundWorkSignalProcessor()` to retain the active caller's signal capability for eligible background tool calls:
|
|
982
|
+
|
|
983
|
+
```typescript
|
|
984
|
+
import { Agent } from '@mastra/core/agent'
|
|
985
|
+
import { createBackgroundWorkSignalProcessor } from '@mastra/core/processors'
|
|
986
|
+
|
|
987
|
+
const agent = new Agent({
|
|
988
|
+
id: 'background-agent',
|
|
989
|
+
name: 'Background agent',
|
|
990
|
+
instructions: 'Complete tasks using the available tools.',
|
|
991
|
+
model: 'openai/gpt-5.6-sol',
|
|
992
|
+
inputProcessors: [createBackgroundWorkSignalProcessor()],
|
|
993
|
+
})
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
Mastra's background runtime remains responsible for execution, persistence, retries, result reconciliation, and continuation. The processor only retains caller-scoped notification access. When background work starts, it emits `work-deferred` or `work-awaited` with `status: 'running'`. After the authoritative tool result is reconciled, it emits `work-completed` or `work-failed`.
|
|
997
|
+
|
|
998
|
+
Notifications are process-local and best-effort. If the originating run has already ended or the signal can't be delivered (for example, because the task resumed on another process), Mastra preserves the authoritative result without recreating the run or retrying the notification. Foreground calls never emit background work notifications because there is no detached work to report.
|
|
999
|
+
|
|
979
1000
|
## Related documentation
|
|
980
1001
|
|
|
981
1002
|
- [Agent lifecycle](https://mastra.ai/docs/guides/agent-lifecycle): Full-run ordering and `RequestContext` visibility
|
|
@@ -143,9 +143,15 @@ To add your own endpoints, see [Custom API Routes](https://mastra.ai/docs/server
|
|
|
143
143
|
|
|
144
144
|
## Graceful shutdown and rolling deploys
|
|
145
145
|
|
|
146
|
-
By default, the generated server handles `SIGINT` and `SIGTERM`. It stops accepting connections, waits up to [`server.drainTimeout`](https://mastra.ai/reference/configuration) for active requests and streams, then runs `mastra.shutdown()`. The drain timeout defaults to 5 seconds. A second signal terminates the process immediately. See [`server.handleShutdownSignals`](https://mastra.ai/reference/configuration) if you need to manage signals yourself.
|
|
146
|
+
By default, the generated server handles `SIGINT` and `SIGTERM`. It stops accepting connections, waits up to [`server.drainTimeout`](https://mastra.ai/reference/configuration) for active requests and streams, then runs `mastra.shutdown()`. Shutdown gives in-flight workflow runs (including durable agent runs) the same drain window to finish before workers and pub/sub subscriptions are torn down. The drain timeout defaults to 5 seconds. A second signal terminates the process immediately. See [`server.handleShutdownSignals`](https://mastra.ai/reference/configuration) if you need to manage signals yourself.
|
|
147
147
|
|
|
148
|
-
Increase `drainTimeout` when your hosting platform's termination grace period can accommodate longer turns.
|
|
148
|
+
Increase `drainTimeout` when your hosting platform's termination grace period can accommodate longer turns. The HTTP drain and the workflow drain run one after the other, so keep enough time for both plus shutdown cleanup.
|
|
149
|
+
|
|
150
|
+
If you call `mastra.shutdown()` yourself, pass `drainTimeout` to control how long it waits for in-flight workflow runs:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
await mastra.shutdown({ drainTimeout: 30_000 })
|
|
154
|
+
```
|
|
149
155
|
|
|
150
156
|
```typescript
|
|
151
157
|
import { Mastra } from '@mastra/core/mastra'
|
|
@@ -178,7 +178,7 @@ await assistant.generate('Help me plan the next project milestone.', {
|
|
|
178
178
|
|
|
179
179
|
The example assumes storage is configured on the registered Mastra instance or directly on `Memory`. `lastMessages` controls how many recent messages Mastra loads from the thread. The default is 10.
|
|
180
180
|
|
|
181
|
-
Message history works well for shorter conversations where recent turns contain the context the agent needs. For long-running conversations, Mastra recommends [Observational Memory](https://mastra.ai/docs/memory/observational-memory), which keeps recent conversation available and turns older history into a dense observation log.
|
|
181
|
+
Message history works well for shorter conversations where recent turns contain the context the agent needs. Because the `lastMessages` window slides forward on every request, each turn past the limit removes the oldest message from the start of the prompt and invalidates the provider prompt cache. For long-running conversations, Mastra recommends [Observational Memory](https://mastra.ai/docs/memory/observational-memory), which keeps recent conversation available and turns older history into a dense observation log while keeping the prompt prefix stable for caching.
|
|
182
182
|
|
|
183
183
|
## Observational Memory
|
|
184
184
|
|
|
@@ -44,16 +44,16 @@ The full set of options is listed in the [backgroundTasks configuration referenc
|
|
|
44
44
|
|
|
45
45
|
## Run a tool in the background
|
|
46
46
|
|
|
47
|
-
Enabling the manager doesn't run anything in the background by itself
|
|
47
|
+
Enabling the manager doesn't run anything in the background by itself. Tools become eligible at one of two layers:
|
|
48
48
|
|
|
49
49
|
1. **Tool-level config**: the tool itself declares it as background-eligible.
|
|
50
50
|
2. **Agent-level config**: the agent declares which of its tools are background-eligible.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Eligible tools default to `deferred` execution. Set `defaultDisposition: 'foreground'` at either layer when eligibility should only give the LLM the option to run a call in the background. The LLM can include a `_background` field in the tool arguments to select `foreground`, `deferred`, or `awaited` execution for a specific call and override its timeout or retries.
|
|
53
53
|
|
|
54
54
|
### Tool-level
|
|
55
55
|
|
|
56
|
-
Set `background.enabled: true` on the tool definition. Tools opted in at this layer
|
|
56
|
+
Set `background.enabled: true` on the tool definition. Tools opted in at this layer are eligible for background execution when called by an agent that has the manager enabled. Their configured default disposition determines whether each call runs inline or in the background unless the call includes a `_background` override.
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
import { createTool } from '@mastra/core/tools'
|
|
@@ -65,6 +65,7 @@ export const researchTool = createTool({
|
|
|
65
65
|
inputSchema: z.object({ topic: z.string() }),
|
|
66
66
|
background: {
|
|
67
67
|
enabled: true,
|
|
68
|
+
defaultDisposition: 'deferred',
|
|
68
69
|
timeoutMs: 600_000,
|
|
69
70
|
maxRetries: 1,
|
|
70
71
|
},
|
|
@@ -104,20 +105,23 @@ When a tool is registered on an agent that has background tasks enabled, the mod
|
|
|
104
105
|
```json
|
|
105
106
|
{
|
|
106
107
|
"topic": "solana",
|
|
107
|
-
"_background": { "
|
|
108
|
+
"_background": { "disposition": "awaited", "timeoutMs": 900000 }
|
|
108
109
|
}
|
|
109
110
|
```
|
|
110
111
|
|
|
111
|
-
The
|
|
112
|
+
The available dispositions are:
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
- `foreground`: Run the tool synchronously without background-work lifecycle signals.
|
|
115
|
+
- `deferred`: Dispatch the tool and let the agent continue. The task remains attached to the run, and streams using `untilIdle` wait for it to reconcile.
|
|
116
|
+
- `awaited`: Dispatch the tool through the background task manager, but hold the current branch until its authoritative result has been reconciled.
|
|
117
|
+
|
|
118
|
+
For compatibility, `_background.enabled: true` selects `deferred`, and `_background.enabled: false` selects `foreground`. An explicit `disposition` takes precedence over `enabled`.
|
|
114
119
|
|
|
115
|
-
|
|
120
|
+
The `_background` override only _modifies_ tools the developer has already opted in at the tool or agent layer. If a tool hasn't been opted in, a model-selected background disposition is ignored and the tool runs in the foreground. This keeps deterministic, foreground-only tools (calculators, lookups, schema validators) from being silently dispatched as tasks.
|
|
116
121
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
4. Manager defaults (`defaultTimeoutMs`, `defaultRetries`).
|
|
122
|
+
### Resolution order
|
|
123
|
+
|
|
124
|
+
When a tool call is dispatched, agent-level and tool-level settings determine eligibility and fallback values. For an eligible tool, the LLM `_background` fields override the corresponding values for that call. Manager defaults fill timeout and retry values that remain unset. An `_background` field can't enable a tool that's not eligible.
|
|
121
125
|
|
|
122
126
|
If the agent has `backgroundTasks.disabled: true`, every tool call runs synchronously regardless of the layers above.
|
|
123
127
|
|
|
@@ -204,7 +208,7 @@ const stream = await supervisor.stream('Research AI in education and write an ar
|
|
|
204
208
|
|
|
205
209
|
### Inheriting from the subagent
|
|
206
210
|
|
|
207
|
-
If a subagent isn't listed under the supervisor's `backgroundTasks.tools` but has background-eligible tools of its own (either via tool-level `background.enabled: true` or its own `backgroundTasks.tools` entry) the framework still dispatches the entire subagent invocation as a background task. The supervisor inherits the subagent's intent: the subagent itself becomes the background task, and its
|
|
211
|
+
If a subagent isn't listed under the supervisor's `backgroundTasks.tools` but has background-eligible tools of its own (either via tool-level `background.enabled: true` or its own `backgroundTasks.tools` entry) the framework still dispatches the entire subagent invocation as a background task. The supervisor inherits the subagent's intent: the subagent itself becomes the background task, and it can dispatch its eligible ordinary tools in the background inside its loop. Further delegated-agent calls run in the foreground.
|
|
208
212
|
|
|
209
213
|
The background config used for the inherited dispatch (for example `waitTimeoutMs`) is derived from the subagent's own `backgroundTasks` config.
|
|
210
214
|
|
|
@@ -223,9 +227,11 @@ const researchAgent = new Agent({
|
|
|
223
227
|
})
|
|
224
228
|
```
|
|
225
229
|
|
|
226
|
-
When this `researchAgent` is delegated to from a supervisor that has no
|
|
230
|
+
When this `researchAgent` is delegated to from a supervisor that has no background task configuration for the `researchAgent`, the supervisor still dispatches the whole `researchAgent` invocation as a background task.
|
|
231
|
+
|
|
232
|
+
Mastra supports one nested background-tool level inside a delegated run: a root agent can delegate to a subagent, and that subagent can dispatch an eligible ordinary tool in the background. A second delegated-agent edge runs in the foreground and doesn't receive nested background guidance. This limit is execution-scoped and doesn't mutate the shared subagent configuration.
|
|
227
233
|
|
|
228
|
-
|
|
234
|
+
Which layer to use depends on where consistency matters: subagent-level configuration travels with the agent, so its background behavior stays the same under every supervisor, whereas the supervisor-side opt-in above centralizes that tuning in one place. This boundary stops at a single nested delegation level and has no workflow integration.
|
|
229
235
|
|
|
230
236
|
## Suspending and resuming
|
|
231
237
|
|
|
@@ -315,23 +321,23 @@ export const mastra = new Mastra({
|
|
|
315
321
|
Calling `stream()` with no filter returns a stream of every task event in the system. On connection, the stream emits a snapshot of all currently running tasks, then forwards live events as they happen.
|
|
316
322
|
|
|
317
323
|
```typescript
|
|
318
|
-
const bgManager = mastra.backgroundTaskManager
|
|
319
|
-
if (!bgManager) throw new Error('Background tasks are not enabled')
|
|
324
|
+
const bgManager = mastra.backgroundTaskManager;
|
|
325
|
+
if (!bgManager) throw new Error('Background tasks are not enabled');
|
|
320
326
|
|
|
321
|
-
const controller = new AbortController()
|
|
322
|
-
const stream = bgManager.stream({ abortSignal: controller.signal })
|
|
327
|
+
const controller = new AbortController();
|
|
328
|
+
const stream = bgManager.stream({ abortSignal: controller.signal });
|
|
323
329
|
|
|
324
330
|
for await (const chunk of stream) {
|
|
325
331
|
switch (chunk.type) {
|
|
326
332
|
case 'background-task-running':
|
|
327
|
-
console.log('started', chunk.payload.taskId, chunk.payload.toolName)
|
|
328
|
-
break
|
|
333
|
+
console.log('started', chunk.payload.taskId, chunk.payload.toolName);
|
|
334
|
+
break;
|
|
329
335
|
case 'background-task-completed':
|
|
330
|
-
console.log('done', chunk.payload.taskId, chunk.payload.result)
|
|
331
|
-
break
|
|
336
|
+
console.log('done', chunk.payload.taskId, chunk.payload.result);
|
|
337
|
+
break;
|
|
332
338
|
case 'background-task-failed':
|
|
333
|
-
console.error('failed', chunk.payload.taskId, chunk.payload.error)
|
|
334
|
-
break
|
|
339
|
+
console.error('failed', chunk.payload.taskId, chunk.payload.error);
|
|
340
|
+
break;
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
343
|
```
|
|
@@ -318,6 +318,45 @@ Use `createNotificationInboxTool()` to give agents one tool for inbox actions in
|
|
|
318
318
|
|
|
319
319
|
`sendNotificationSignal()` requires a storage domain with `notifications` support. Use `sendSignal({ type: 'notification' })` only for lower-level notification-shaped context that should bypass inbox storage.
|
|
320
320
|
|
|
321
|
+
## Cross-agent connections in Mastra Code
|
|
322
|
+
|
|
323
|
+
Cross-agent communication is experimental and off by default. Enable it in Mastra Code with the `/settings` toggle "Experimental cross-agent communication" and restart. Embedded clients can set `crossAgentSignals: true` when calling `createMastraCode()`. The setting enables thread ownership advertisements and peer discovery. It also makes the agent connection tools available. It doesn't affect the pub/sub transport itself.
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
import { createMastraCode } from 'mastracode'
|
|
327
|
+
|
|
328
|
+
const mastraCode = await createMastraCode({
|
|
329
|
+
crossAgentSignals: true,
|
|
330
|
+
})
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Mastra Code can use notification signals to communicate between agent threads. A peer is an exact `{ agentId, resourceId, threadId }` endpoint. Discovery is a point-in-time advertisement that the exact endpoint is available now. It isn't a durable connection or a guarantee that delivery will succeed.
|
|
334
|
+
|
|
335
|
+
`agent_connections_list` returns one `peers` collection. Each peer includes:
|
|
336
|
+
|
|
337
|
+
- `relationship`: `none` or `saved`. This is the authoritative durable state for the current sender thread.
|
|
338
|
+
- `presence`: `advertised` or `absent`. This reflects the current discovery pass.
|
|
339
|
+
- `displayStatus`: A derived, presentational value: `discovered`, `connected`, or `saved`.
|
|
340
|
+
- `canAttemptSend`: `true` only when the peer is both saved and currently advertised.
|
|
341
|
+
|
|
342
|
+
The displayed statuses mean:
|
|
343
|
+
|
|
344
|
+
| Status | Meaning | Can attempt a send? |
|
|
345
|
+
| -------------- | ----------------------------------------------------------- | ------------------- |
|
|
346
|
+
| `[discovered]` | Advertised now, but not saved by the current sender thread. | No |
|
|
347
|
+
| `[connected]` | Saved by the current sender thread and advertised now. | Yes |
|
|
348
|
+
| `[saved]` | Saved by the current sender thread, but not advertised now. | No |
|
|
349
|
+
|
|
350
|
+
Use the connection tools for distinct operations:
|
|
351
|
+
|
|
352
|
+
- `agent_connect` saves a freshly discovered exact peer in the current sender thread.
|
|
353
|
+
- `agent_disconnect` removes a saved peer from the current sender thread. The peer doesn't need to be currently advertised, and repeated disconnects are safe.
|
|
354
|
+
- `agent_signal_send` requires the exact peer to remain saved and freshly advertised at send time. A previously discovered or recently seen peer that's absent from the current discovery pass isn't sendable.
|
|
355
|
+
|
|
356
|
+
Saved connections remain in the sender thread until explicitly disconnected. Every send independently refreshes discovery and verifies the exact endpoint before routing begins. A saved connection therefore records collaboration intent. It doesn't indicate current presence.
|
|
357
|
+
|
|
358
|
+
After a send attempt reaches Core routing, the routing result is authoritative. The result can be `wake`, `deliver`, `persist`, `blocked`, or `discard`, depending on the target thread and notification policy. A send that isn't acknowledged by the advertised thread owner returns an error and doesn't consume its `messageId`, so the sender can retry it.
|
|
359
|
+
|
|
321
360
|
## Distributed and serverless deployments
|
|
322
361
|
|
|
323
362
|
Signals coordinate runs through a pub/sub backend. When a signal arrives on a backend that implements `LeaseProvider`, Mastra acquires a lease on the target thread so a single process owns the conversation at a time, then either wakes the agent or routes the input into the running loop. Backends without leasing fall back to a no-op that always grants ownership, which is fine in a single process but not across instances.
|
package/.docs/docs/index.md
CHANGED
|
@@ -74,7 +74,7 @@ Short list of known model IDs are:
|
|
|
74
74
|
|
|
75
75
|
Go to <https://mastra.ai/models> for a full list of supported models.
|
|
76
76
|
|
|
77
|
-
Add a tool an agent by importing the tool and passing it to the agent constructor as a tools object.
|
|
77
|
+
Add a tool to an agent by importing the tool and passing it to the agent constructor as a tools object.
|
|
78
78
|
|
|
79
79
|
Example:
|
|
80
80
|
|
|
@@ -122,6 +122,8 @@ You can use this history in two ways:
|
|
|
122
122
|
- **Automatic inclusion**: Mastra automatically includes recent messages in the context window. The default of 10 messages keeps agents grounded in the conversation. Adjust it with `lastMessages` when needed.
|
|
123
123
|
- [**Manual querying**](#querying): For more control, query threads and messages directly with `recall()`. Use the results to choose which memories enter the context window or to render conversation history in your UI.
|
|
124
124
|
|
|
125
|
+
> **Note:** `lastMessages` counts every stored message, including tool calls, tool results, and [signals](https://mastra.ai/docs/harness/signals) of any kind, so a single turn can add several messages to the count. The window also slides forward on every request: once a thread grows past the limit, the oldest message leaves context on each turn, which changes the start of the prompt and invalidates the provider prompt cache. For long-running conversations, use [Observational Memory](https://mastra.ai/docs/memory/observational-memory), which keeps the prompt prefix stable.
|
|
126
|
+
|
|
125
127
|
> **Tip:** When memory is enabled, [Studio](https://mastra.ai/docs/studio/overview) uses message history to display past conversations in the chat sidebar.
|
|
126
128
|
|
|
127
129
|
## Thread title generation
|
|
@@ -343,7 +345,9 @@ const { thread, clonedMessages } = await memory.cloneThread({
|
|
|
343
345
|
|
|
344
346
|
You can filter cloned messages by count or date range and specify custom thread IDs. Utility methods are also available to inspect clone relationships.
|
|
345
347
|
|
|
346
|
-
|
|
348
|
+
If you don't need the copied messages returned, for example when forking a long thread, use `copyThread()`. It never returns message payloads, and on LibSQL and PostgreSQL the rows are copied inside the database. When semantic recall is enabled, the copied messages are still read back in batches to generate embeddings.
|
|
349
|
+
|
|
350
|
+
See [`cloneThread()`](https://mastra.ai/reference/memory/cloneThread), [`copyThread()`](https://mastra.ai/reference/memory/copyThread), and [clone utilities](https://mastra.ai/reference/memory/clone-utilities) for the full API.
|
|
347
351
|
|
|
348
352
|
## Deleting messages
|
|
349
353
|
|
|
@@ -1362,6 +1362,11 @@ export function NestedAgentChat() {
|
|
|
1362
1362
|
<div key={index} className="nested-agent">
|
|
1363
1363
|
<strong>Nested Agent: {id}</strong>
|
|
1364
1364
|
{data.text && <p>{data.text}</p>}
|
|
1365
|
+
{data.toolErrors?.map(toolError => (
|
|
1366
|
+
<p key={toolError.toolCallId} className="nested-agent-error">
|
|
1367
|
+
{toolError.toolName} failed: {toolError.errorText}
|
|
1368
|
+
</p>
|
|
1369
|
+
))}
|
|
1365
1370
|
</div>
|
|
1366
1371
|
)
|
|
1367
1372
|
}
|
|
@@ -1388,6 +1393,8 @@ Key points:
|
|
|
1388
1393
|
- Piping `fullStream` to `context.writer` creates `data-tool-agent` parts
|
|
1389
1394
|
- Read `data-tool-agent-step` when you need the full payload for the nested step that finished
|
|
1390
1395
|
- The `AgentDataPart` has `id` (on the part) and `data.text` (the current nested-agent text snapshot)
|
|
1396
|
+
- A tool that throws inside the nested agent is reported in `data.toolErrors`, each entry `{ toolCallId, toolName, args?, errorText, providerExecuted? }`. `errorText` is a JSON-safe string, so the failure survives serialization to the client instead of arriving as `{}`
|
|
1397
|
+
- `toolErrors` resets at each nested step boundary, like `toolCalls` and `toolResults`. For a finished step, read it from `data-tool-agent-step` (`data.step.toolErrors`) or from `data.steps[]` on the final snapshot
|
|
1391
1398
|
- The tool still returns its own output after the stream completes
|
|
1392
1399
|
|
|
1393
1400
|
For a complete implementation, see the [tool-nested-streams example](https://github.com/mastra-ai/ui-dojo/blob/main/src/pages/ai-sdk/tool-nested-streams.tsx) in UI Dojo.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Archil
|
|
6
6
|
|
|
7
|
-
Stores files on [Archil](https://docs.archil.com) elastic, serverless disks. Combines an S3-compatible object API for fast reads/writes with `exec()` for POSIX shell operations and `
|
|
7
|
+
Stores files on [Archil](https://docs.archil.com) elastic, serverless disks. Combines an S3-compatible object API for fast reads/writes with `exec()` for POSIX shell operations and `diskGrep()` for parallel server-side search. For interface details, see [WorkspaceFilesystem Interface](https://mastra.ai/reference/workspace/filesystem).
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -173,12 +173,12 @@ const result = await filesystem.exec('ls -la /data')
|
|
|
173
173
|
// { exitCode: 0, stdout: '...', stderr: '' }
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
#### `
|
|
176
|
+
#### `diskGrep(options)`
|
|
177
177
|
|
|
178
178
|
Run a parallel server-side search across files on the disk.
|
|
179
179
|
|
|
180
180
|
```typescript
|
|
181
|
-
const results = await filesystem.
|
|
181
|
+
const results = await filesystem.diskGrep({
|
|
182
182
|
directory: '/logs',
|
|
183
183
|
pattern: 'ERROR',
|
|
184
184
|
recursive: true,
|
|
@@ -430,7 +430,7 @@ export default function App(): React.JSX.Element {
|
|
|
430
430
|
}
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
-
This connects [`useChat()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) to the `/chat/weather-agent` endpoint, sending
|
|
433
|
+
This connects [`useChat()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) to the `/chat/weather-agent` endpoint, sending prompts there and streaming the response back in chunks.
|
|
434
434
|
|
|
435
435
|
## Test your agent
|
|
436
436
|
|
|
@@ -82,6 +82,8 @@ const result = await workspace.sandbox?.executeCommand?.('npm', ['test'], {
|
|
|
82
82
|
|
|
83
83
|
Relative paths are resolved under `/workspace`. Absolute paths must also resolve within `/workspace`. Each file is sent as its own bridge request, and the bridge caps a single file at 32 MiB.
|
|
84
84
|
|
|
85
|
+
The Cloudflare sandbox cannot set per-file permissions, so a `writeFiles` call that includes a `mode` is rejected rather than silently ignored.
|
|
86
|
+
|
|
85
87
|
```typescript
|
|
86
88
|
await workspace.sandbox?.writeFiles?.([
|
|
87
89
|
{ path: 'src/index.ts', content: "console.log('hello')\n" },
|
|
@@ -162,6 +162,19 @@ const sandbox = new DockerSandbox({
|
|
|
162
162
|
})
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
+
## Write files
|
|
166
|
+
|
|
167
|
+
Upload multiple files in one call with `writeFiles`. Relative paths resolve under the working directory. Set an optional per-file `mode` to control POSIX permissions; it must be an integer between `0o001` and `0o777`. When `mode` is omitted, new files are created with `0644`.
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
await sandbox.writeFiles([
|
|
171
|
+
{ path: 'src/index.js', content: "console.log('hello')\n" },
|
|
172
|
+
{ path: 'run.sh', content: '#!/bin/sh\n', mode: 0o755 },
|
|
173
|
+
])
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Docker is the only built-in sandbox that applies an explicit `mode`. Providers that cannot honor per-file permissions (Vercel, E2B, Daytona, Cloudflare) reject a `writeFiles` call that includes a `mode` instead of silently dropping it.
|
|
177
|
+
|
|
165
178
|
## Bind mounts
|
|
166
179
|
|
|
167
180
|
Mount host directories into the container using the `volumes` option:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Merge Gateway
|
|
6
6
|
|
|
7
|
-
Merge Gateway aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
7
|
+
Merge Gateway aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 187 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Merge Gateway documentation](https://docs.merge.dev/merge-gateway).
|
|
10
10
|
|
|
@@ -67,6 +67,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
67
67
|
| `deepseek/deepseek-v3.1` |
|
|
68
68
|
| `deepseek/deepseek-v3.2` |
|
|
69
69
|
| `deepseek/deepseek-v4-flash` |
|
|
70
|
+
| `deepseek/deepseek-v4-flash-0423` |
|
|
70
71
|
| `deepseek/deepseek-v4-flash-0731` |
|
|
71
72
|
| `deepseek/deepseek-v4-flash-0731-fast` |
|
|
72
73
|
| `deepseek/deepseek-v4-pro` |
|
|
@@ -94,6 +95,9 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
94
95
|
| `google/gemini-embedding-001` |
|
|
95
96
|
| `google/gemini-flash-latest` |
|
|
96
97
|
| `google/gemini-flash-lite-latest` |
|
|
98
|
+
| `google/gemma-3-12b-it` |
|
|
99
|
+
| `google/gemma-3-27b-it` |
|
|
100
|
+
| `google/gemma-3-4b-it` |
|
|
97
101
|
| `google/gemma-4-26b-a4b-it` |
|
|
98
102
|
| `google/gemma-4-31b-it` |
|
|
99
103
|
| `meta/llama-3.1-70b-instruct` |
|
|
@@ -160,6 +164,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
160
164
|
| `openai/gpt-oss-120b` |
|
|
161
165
|
| `openai/gpt-oss-20b` |
|
|
162
166
|
| `openai/gpt-oss-safeguard-120b` |
|
|
167
|
+
| `openai/gpt-oss-safeguard-20b` |
|
|
163
168
|
| `openai/o1` |
|
|
164
169
|
| `openai/o3` |
|
|
165
170
|
| `openai/o3-mini` |
|
|
@@ -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 253 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
|
|
|
@@ -161,6 +161,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
161
161
|
| `openrouter/inclusionai/ling-3.0-flash-fin` |
|
|
162
162
|
| `openrouter/inclusionai/ling-3.0-flash-fin:free` |
|
|
163
163
|
| `openrouter/inclusionai/ling-3.0-flash-sante:free` |
|
|
164
|
+
| `openrouter/inclusionai/ling-3.0-flash-vl` |
|
|
164
165
|
| `openrouter/inclusionai/ling-3.0-flash-vl:free` |
|
|
165
166
|
| `openrouter/mancer/weaver` |
|
|
166
167
|
| `openrouter/meta-llama/llama-3.1-70b-instruct` |
|
|
@@ -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 365 models through Mastra's model router.
|
|
8
8
|
|
|
9
9
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
10
10
|
|
|
@@ -46,8 +46,11 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
46
46
|
| `~google/gemini-flash-latest` |
|
|
47
47
|
| `~google/gemini-pro-latest` |
|
|
48
48
|
| `~moonshotai/kimi-latest` |
|
|
49
|
-
| `~openai/gpt-latest`
|
|
49
|
+
| `~openai/gpt-astra-latest` |
|
|
50
|
+
| `~openai/gpt-luna-latest` |
|
|
50
51
|
| `~openai/gpt-mini-latest` |
|
|
52
|
+
| `~openai/gpt-sol-latest` |
|
|
53
|
+
| `~openai/gpt-terra-latest` |
|
|
51
54
|
| `~x-ai/grok-latest` |
|
|
52
55
|
| `~z-ai/glm-flash-latest` |
|
|
53
56
|
| `~z-ai/glm-latest` |
|
|
@@ -147,6 +150,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
147
150
|
| `inclusionai/ling-3.0-flash-fin` |
|
|
148
151
|
| `inclusionai/ling-3.0-flash-fin:free` |
|
|
149
152
|
| `inclusionai/ling-3.0-flash-sante:free` |
|
|
153
|
+
| `inclusionai/ling-3.0-flash-vl` |
|
|
150
154
|
| `inclusionai/ling-3.0-flash-vl:free` |
|
|
151
155
|
| `kwaipilot/kat-coder-pro-v2` |
|
|
152
156
|
| `kwaipilot/kat-coder-pro-v2.5` |
|
|
@@ -350,7 +354,9 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
350
354
|
| `rekaai/reka-flash-3` |
|
|
351
355
|
| `relace/relace-apply-3` |
|
|
352
356
|
| `relace/relace-search` |
|
|
357
|
+
| `sakana/fugu-max` |
|
|
353
358
|
| `sakana/fugu-ultra` |
|
|
359
|
+
| `sakana/fugu-ultra-v2` |
|
|
354
360
|
| `sakana/sakana-namazu` |
|
|
355
361
|
| `sao10k/l3-lunaris-8b` |
|
|
356
362
|
| `sao10k/l3.1-euryale-70b` |
|
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 7245 models from 200 providers through a single API.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -38,7 +38,7 @@ for await (const chunk of stream) {
|
|
|
38
38
|
|
|
39
39
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
40
|
| ------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
|
-
| `above/deepseek-v4-flash` | 1.0M | | | | | | $0.
|
|
41
|
+
| `above/deepseek-v4-flash` | 1.0M | | | | | | $0.17 | $0.66 |
|
|
42
42
|
| `above/deepseek-v4-flash-vision-exp` | 1.0M | | | | | | $0.24 | $0.73 |
|
|
43
43
|
| `above/deepseek-v4-pro` | 1.0M | | | | | | $0.73 | $2 |
|
|
44
44
|
| `above/glm-5.2` | 1.0M | | | | | | $2 | $5 |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Baseten
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 23 Baseten models through Mastra's model router. Authentication is handled automatically using the `BASETEN_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Baseten documentation](https://docs.baseten.co).
|
|
10
10
|
|
|
@@ -41,6 +41,7 @@ for await (const chunk of stream) {
|
|
|
41
41
|
| `baseten/deepseek-ai/DeepSeek-V4-Flash-0731` | 1.0M | | | | | | $0.13 | $0.26 |
|
|
42
42
|
| `baseten/deepseek-ai/DeepSeek-V4-Pro` | 1.0M | | | | | | $2 | $3 |
|
|
43
43
|
| `baseten/deepseek-ai/DeepSeek-V4-Pro-0813` | 1.0M | | | | | | $1 | $4 |
|
|
44
|
+
| `baseten/deepseek-ai/DeepSeek-V4.1-Flash` | 1.0M | | | | | | $0.30 | $1 |
|
|
44
45
|
| `baseten/moonshotai/Kimi-K2.5` | 262K | | | | | | $0.60 | $3 |
|
|
45
46
|
| `baseten/moonshotai/Kimi-K2.6` | 262K | | | | | | $0.95 | $4 |
|
|
46
47
|
| `baseten/moonshotai/Kimi-K2.7-Code` | 262K | | | | | | $0.95 | $4 |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Bothub
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 8 Bothub models through Mastra's model router. Authentication is handled automatically using the `BOTHUB_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Bothub documentation](https://bothub.ru/models).
|
|
10
10
|
|
|
@@ -44,6 +44,7 @@ for await (const chunk of stream) {
|
|
|
44
44
|
| `bothub/glm-5.3` | 1.0M | | | | | | $2 | $5 |
|
|
45
45
|
| `bothub/glm-5.3-flash` | 1.0M | | | | | | $0.12 | $0.44 |
|
|
46
46
|
| `bothub/gpt-5.6-luna` | 1.1M | | | | | | $0.06 | $0.37 |
|
|
47
|
+
| `bothub/muse-spark-1.3-contributor` | 1.0M | | | | | | $0.10 | $0.20 |
|
|
47
48
|
| `bothub/nemotron-3-ultra-550b-a55b:free` | 1.0M | | | | | | — | — |
|
|
48
49
|
|
|
49
50
|
Model availability, capabilities, context windows, and pricing are sourced from [models.dev](https://models.dev) and may change.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# ClinePass
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 15 ClinePass models through Mastra's model router. Authentication is handled automatically using the `CLINE_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [ClinePass documentation](https://docs.cline.bot/getting-started/clinepass).
|
|
10
10
|
|
|
@@ -36,22 +36,23 @@ for await (const chunk of stream) {
|
|
|
36
36
|
|
|
37
37
|
## Models
|
|
38
38
|
|
|
39
|
-
| Model
|
|
40
|
-
|
|
|
41
|
-
| `cline-pass/cline-pass/deepseek-v4-flash`
|
|
42
|
-
| `cline-pass/cline-pass/deepseek-v4-pro`
|
|
43
|
-
| `cline-pass/cline-pass/
|
|
44
|
-
| `cline-pass/cline-pass/glm-5.
|
|
45
|
-
| `cline-pass/cline-pass/glm-5.3
|
|
46
|
-
| `cline-pass/cline-pass/
|
|
47
|
-
| `cline-pass/cline-pass/kimi-k2.
|
|
48
|
-
| `cline-pass/cline-pass/kimi-
|
|
49
|
-
| `cline-pass/cline-pass/
|
|
50
|
-
| `cline-pass/cline-pass/mimo-v2.5
|
|
51
|
-
| `cline-pass/cline-pass/
|
|
52
|
-
| `cline-pass/cline-pass/
|
|
53
|
-
| `cline-pass/cline-pass/qwen3.7-
|
|
54
|
-
| `cline-pass/cline-pass/qwen3.
|
|
39
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
|
+
| ------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
|
+
| `cline-pass/cline-pass/deepseek-v4-flash` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
42
|
+
| `cline-pass/cline-pass/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
43
|
+
| `cline-pass/cline-pass/deepseek-v4.1-flash` | 1.0M | | | | | | $0.15 | $0.60 |
|
|
44
|
+
| `cline-pass/cline-pass/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
45
|
+
| `cline-pass/cline-pass/glm-5.3` | 1.0M | | | | | | $1 | $4 |
|
|
46
|
+
| `cline-pass/cline-pass/glm-5.3-flash` | 1.0M | | | | | | $0.15 | $0.50 |
|
|
47
|
+
| `cline-pass/cline-pass/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
48
|
+
| `cline-pass/cline-pass/kimi-k2.7-code` | 262K | | | | | | $0.95 | $4 |
|
|
49
|
+
| `cline-pass/cline-pass/kimi-k3` | 1.0M | | | | | | $3 | $15 |
|
|
50
|
+
| `cline-pass/cline-pass/mimo-v2.5` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
51
|
+
| `cline-pass/cline-pass/mimo-v2.5-pro` | 1.0M | | | | | | $2 | $3 |
|
|
52
|
+
| `cline-pass/cline-pass/minimax-m3` | 1.0M | | | | | | $0.30 | $1 |
|
|
53
|
+
| `cline-pass/cline-pass/qwen3.7-max` | 1.0M | | | | | | $3 | $8 |
|
|
54
|
+
| `cline-pass/cline-pass/qwen3.7-plus` | 1.0M | | | | | | $0.40 | $2 |
|
|
55
|
+
| `cline-pass/cline-pass/qwen3.8-max` | 1.0M | | | | | | $2 | $6 |
|
|
55
56
|
|
|
56
57
|
Model availability, capabilities, context windows, and pricing are sourced from [models.dev](https://models.dev) and may change.
|
|
57
58
|
|
|
@@ -52,7 +52,7 @@ for await (const chunk of stream) {
|
|
|
52
52
|
| `cortecs/codestral-2508` | 256K | | | | | | $0.33 | $1 |
|
|
53
53
|
| `cortecs/deepseek-r1-0528` | 164K | | | | | | $0.65 | $3 |
|
|
54
54
|
| `cortecs/deepseek-v3.2` | 164K | | | | | | $0.30 | $0.49 |
|
|
55
|
-
| `cortecs/deepseek-v4-flash-0731` | 1.0M | | | | | | $0.
|
|
55
|
+
| `cortecs/deepseek-v4-flash-0731` | 1.0M | | | | | | $0.09 | $0.17 |
|
|
56
56
|
| `cortecs/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
57
57
|
| `cortecs/deepseek-v4-pro-0813` | 1.0M | | | | | | $2 | $4 |
|
|
58
58
|
| `cortecs/devstral-2512` | 256K | | | | | | $0.48 | $2 |
|
|
@@ -73,7 +73,7 @@ for await (const chunk of stream) {
|
|
|
73
73
|
| `cortecs/glm-5.1` | 203K | | | | | | $1 | $4 |
|
|
74
74
|
| `cortecs/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
75
75
|
| `cortecs/glm-5.3` | 1.0M | | | | | | $1 | $4 |
|
|
76
|
-
| `cortecs/glm-5.3-flash` | 1.0M | | | | | | $0.
|
|
76
|
+
| `cortecs/glm-5.3-flash` | 1.0M | | | | | | $0.10 | $0.35 |
|
|
77
77
|
| `cortecs/glm-5v-turbo` | 203K | | | | | | $1 | $4 |
|
|
78
78
|
| `cortecs/gpt-4.1` | 1.0M | | | | | | $2 | $9 |
|
|
79
79
|
| `cortecs/gpt-4.1-mini` | 1.0M | | | | | | $0.43 | $2 |
|
|
@@ -139,7 +139,7 @@ for await (const chunk of stream) {
|
|
|
139
139
|
| `cortecs/qwen3.6-27b` | 262K | | | | | | $0.45 | $3 |
|
|
140
140
|
| `cortecs/qwen3.6-35b-a3b` | 262K | | | | | | $0.17 | $0.56 |
|
|
141
141
|
| `cortecs/qwen3.8-2.4t-a95b` | 262K | | | | | | $3 | $6 |
|
|
142
|
-
| `cortecs/qwen3.8-27b` | 262K | | | | | | $0.
|
|
142
|
+
| `cortecs/qwen3.8-27b` | 262K | | | | | | $0.10 | $0.40 |
|
|
143
143
|
| `cortecs/qwen3.8-flash-next` | 262K | | | | | | $0.20 | $0.50 |
|
|
144
144
|
| `cortecs/qwen3guard-gen-0.6b` | 32K | | | | | | — | — |
|
|
145
145
|
| `cortecs/qwen3guard-gen-8b` | 32K | | | | | | — | — |
|