@mastra/mcp-docs-server 1.2.3-alpha.1 → 1.2.3-alpha.12
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/agent-builder/memory.md +4 -2
- package/.docs/docs/agent-controller/overview.md +1 -1
- package/.docs/docs/agents/agent-approval.md +38 -0
- package/.docs/docs/agents/heartbeats.md +211 -0
- package/.docs/docs/agents/signals.md +25 -1
- package/.docs/docs/observability/integrations/exporters/otel.md +23 -2
- package/.docs/docs/observability/metrics/overview.md +2 -2
- package/.docs/models/gateways/openrouter.md +1 -2
- package/.docs/models/gateways/vercel.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/anthropic.md +4 -5
- package/.docs/models/providers/chutes.md +17 -43
- package/.docs/models/providers/deepinfra.md +3 -2
- package/.docs/models/providers/friendli.md +1 -3
- package/.docs/models/providers/gmicloud.md +18 -15
- package/.docs/models/providers/huggingface.md +2 -1
- package/.docs/models/providers/inceptron.md +10 -8
- package/.docs/models/providers/llmgateway.md +3 -6
- package/.docs/models/providers/neuralwatt.md +9 -5
- package/.docs/models/providers/novita-ai.md +1 -1
- package/.docs/models/providers/nvidia.md +2 -1
- package/.docs/models/providers/siliconflow-cn.md +50 -78
- package/.docs/models/providers/siliconflow.md +52 -73
- package/.docs/models/providers/stepfun.md +1 -1
- package/.docs/models/providers/subconscious.md +71 -0
- package/.docs/models/providers/synthetic.md +8 -6
- package/.docs/models/providers/xiaomi.md +2 -2
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/agent-controller/agent-controller-class.md +9 -9
- package/.docs/reference/agents/listSuspendedRuns.md +91 -0
- package/.docs/reference/client-js/agents.md +21 -0
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/observability/metrics/automatic-metrics.md +2 -2
- package/.docs/reference/pubsub/lease-provider.md +131 -0
- package/.docs/reference/pubsub/redis-streams.md +10 -2
- package/CHANGELOG.md +43 -0
- package/package.json +5 -5
|
@@ -25,9 +25,11 @@ Observational memory lets the agent learn long-lived facts from past conversatio
|
|
|
25
25
|
|
|
26
26
|
## Observational memory model
|
|
27
27
|
|
|
28
|
-
Observational memory runs an Observer and Reflector model on top of every conversation.
|
|
28
|
+
Observational memory runs an Observer and Reflector model on top of every conversation. For Agent Builder agents, the default model is `openai/gpt-5-mini`, which requires an `OPENAI_API_KEY` environment variable in any environment where the Builder agent will run.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
> **Note:** This default applies only to agents created through the Agent Builder. Core (non-builder) agents configured with `observationalMemory: true` keep the framework default `google/gemini-2.5-flash` (which uses `GOOGLE_API_KEY`, falling back to `GOOGLE_GENERATIVE_AI_API_KEY`).
|
|
31
|
+
|
|
32
|
+
To use a different model, set `observationalMemory.model` to any model ID supported by the Mastra model router (and provide the matching provider credentials). An explicit model always wins over the Builder default:
|
|
31
33
|
|
|
32
34
|
```typescript
|
|
33
35
|
new MastraEditor({
|
|
@@ -18,7 +18,7 @@ The AgentController gives you the runtime pieces to ship interactive agent appli
|
|
|
18
18
|
- **Let users pick the right model for each step.** Per-mode [model management](https://mastra.ai/reference/agent-controller/agent-controller-class) switches models at runtime and tracks usage, which powers copilot UIs where users trade speed for capability.
|
|
19
19
|
- **Delegate focused work to child agents.** [Subagents](https://mastra.ai/docs/agent-controller/subagents) run subtasks with constrained tools and can fork the parent conversation, so a research mode can spin off web search or code review without polluting the main thread.
|
|
20
20
|
- **Drive a live UI from agent activity.** The [event system](https://mastra.ai/docs/agent-controller/session) emits typed events and coalesced display snapshots, so your TUI or web app reflects message updates, mode changes, and pending approvals in real time.
|
|
21
|
-
- **Run long-lived autonomous agents.** Structured task lists,
|
|
21
|
+
- **Run long-lived autonomous agents.** Structured task lists, interval handlers, and observational memory keep background task runners on track and let them learn across threads.
|
|
22
22
|
|
|
23
23
|
## When to use the AgentController
|
|
24
24
|
|
|
@@ -357,6 +357,44 @@ For automatic tool resumption to work:
|
|
|
357
357
|
|
|
358
358
|
Both approaches work with the same tool definitions. Automatic resumption triggers only when suspended tools exist in the message history and the user sends a new message on the same thread.
|
|
359
359
|
|
|
360
|
+
## Resuming after a restart
|
|
361
|
+
|
|
362
|
+
The examples above hold on to `stream.runId` between suspension and approval. That works while the process stays alive, but in production the approval often arrives later — after a page refresh, a server restart, or on a different server instance behind a load balancer.
|
|
363
|
+
|
|
364
|
+
Use [`listSuspendedRuns()`](https://mastra.ai/reference/agents/listSuspendedRuns) to rediscover the pending run for a conversation from storage:
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
// In the request handler that receives the user's decision
|
|
368
|
+
const { runs } = await agent.listSuspendedRuns({
|
|
369
|
+
threadId: 'thread-123',
|
|
370
|
+
resourceId: 'user-456',
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
const run = runs[0]
|
|
374
|
+
const toolCall = run?.toolCalls[0]
|
|
375
|
+
|
|
376
|
+
if (run && toolCall) {
|
|
377
|
+
let stream
|
|
378
|
+
if (toolCall.requiresApproval) {
|
|
379
|
+
// Suspended by requireApproval — approve or decline the tool call
|
|
380
|
+
stream = await agent.approveToolCall({ runId: run.runId, toolCallId: toolCall.toolCallId })
|
|
381
|
+
} else {
|
|
382
|
+
// Suspended by suspend() — resume with the data the tool asked for
|
|
383
|
+
console.log('Tool asked:', toolCall.suspendPayload)
|
|
384
|
+
stream = await agent.resumeStream({ name: 'San Francisco' }, { runId: run.runId })
|
|
385
|
+
}
|
|
386
|
+
for await (const chunk of stream.textStream) process.stdout.write(chunk)
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Each returned run includes the suspended tool calls (`toolCallId`, `toolName`, `args`, and `requiresApproval`). Approval suspensions (`requiresApproval: true`) are answered with `approveToolCall()` / `declineToolCall()`, while `suspend()`-based suspensions carry their `suspendPayload` and expect `resumeStream()` with resume data — so you can rebuild the right UI for either flow without keeping any state in memory.
|
|
391
|
+
|
|
392
|
+
`sendToolApproval()` uses the same storage-backed discovery automatically: when no active run is found in memory for the thread, it looks up the suspended run in storage before failing. If several suspended runs match the thread, pass a `toolCallId` to disambiguate.
|
|
393
|
+
|
|
394
|
+
The same discovery is available over HTTP as `GET /agents/:agentId/suspended-runs` and in the client SDK as [`agent.listSuspendedRuns()`](https://mastra.ai/reference/client-js/agents), so browser-based approval UIs can rediscover pending runs directly.
|
|
395
|
+
|
|
396
|
+
> **Note:** Suspended runs only survive restarts when your Mastra instance is configured with a persistent [storage provider](https://mastra.ai/docs/memory/storage). The default in-memory store loses snapshots when the process exits.
|
|
397
|
+
|
|
360
398
|
## Tool approval: Supervisor agents
|
|
361
399
|
|
|
362
400
|
A [supervisor agent](https://mastra.ai/docs/agents/supervisor-agents) coordinates multiple subagents using `.stream()` or `.generate()`. When a subagent calls a tool that requires approval, the request propagates up through the delegation chain and surfaces at the supervisor level:
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Heartbeats
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.46.0`
|
|
4
|
+
|
|
5
|
+
> **Beta:** This feature is in alpha. Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
7
|
+
A heartbeat runs an agent on a cron schedule. On each fire, Mastra sends a prompt to the agent, either as a [signal](https://mastra.ai/docs/agents/signals) into a thread or as a threadless `agent.generate()` run. Use heartbeats for recurring agent work such as daily summaries, periodic checks, or scheduled nudges into a conversation.
|
|
8
|
+
|
|
9
|
+
Heartbeats are persisted, so they survive restarts and redeploys. Manage them at runtime through `mastra.heartbeats`, the canonical create, read, update, and delete (CRUD) surface.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
Heartbeats require a [storage](https://mastra.ai/docs/memory/storage) adapter that implements the schedules domain, for example `@mastra/libsql`. Without one, `mastra.heartbeats.create()` throws.
|
|
14
|
+
|
|
15
|
+
## Quickstart
|
|
16
|
+
|
|
17
|
+
The following heartbeat runs the `pinger` agent every hour. It has no thread, so each fire is an isolated `agent.generate()` run.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Mastra } from '@mastra/core'
|
|
21
|
+
import { Agent } from '@mastra/core/agent'
|
|
22
|
+
import { LibSQLStore } from '@mastra/libsql'
|
|
23
|
+
|
|
24
|
+
const pinger = new Agent({
|
|
25
|
+
id: 'pinger',
|
|
26
|
+
name: 'Pinger',
|
|
27
|
+
instructions: 'Report the current system status in one sentence.',
|
|
28
|
+
model: 'openai/gpt-5.5',
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const mastra = new Mastra({
|
|
32
|
+
agents: { pinger },
|
|
33
|
+
storage: new LibSQLStore({ url: 'file:./mastra.db' }),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
await mastra.heartbeats.create({
|
|
37
|
+
agentId: 'pinger',
|
|
38
|
+
cron: '0 * * * *',
|
|
39
|
+
prompt: 'Give me a status update.',
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Mastra starts the scheduler the first time a heartbeat is created, then fires the agent on the cron you specify.
|
|
44
|
+
|
|
45
|
+
## Cadence
|
|
46
|
+
|
|
47
|
+
Heartbeats fire on a cron expression. The `cron` field accepts a standard 5-, 6-, or 7-part cron expression, and it's validated when you create or update the heartbeat.
|
|
48
|
+
|
|
49
|
+
Croner nicknames also work, for example `@hourly`, `@daily`, `@weekly`, `@monthly`, and `@midnight`. For day-and-time combinations, write the cron field directly:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Every weekday at 9am
|
|
53
|
+
await mastra.heartbeats.create({
|
|
54
|
+
agentId: 'pinger',
|
|
55
|
+
cron: '0 9 * * 1-5',
|
|
56
|
+
prompt: 'Start-of-day check.',
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Set `timezone` to an IANA timezone, for example `America/New_York`, so fire times don't depend on the host's locale. When omitted, the cron resolves against the host's local timezone.
|
|
61
|
+
|
|
62
|
+
For more readable cron construction, you can use a userland builder such as [`cron-time-generator`](https://www.npmjs.com/package/cron-time-generator) and pass its output to `cron`.
|
|
63
|
+
|
|
64
|
+
## Threadless and threaded heartbeats
|
|
65
|
+
|
|
66
|
+
A heartbeat fires in one of two modes, decided by whether you pass a `threadId`.
|
|
67
|
+
|
|
68
|
+
### Threadless
|
|
69
|
+
|
|
70
|
+
Without a `threadId`, each fire is an isolated `agent.generate()` run. Nothing is written to a conversation thread. This is the simplest mode and suits status checks, reports, and other work that doesn't need conversation context.
|
|
71
|
+
|
|
72
|
+
### Threaded
|
|
73
|
+
|
|
74
|
+
With a `threadId`, the heartbeat sends a [signal](https://mastra.ai/docs/agents/signals) into that thread, so the prompt joins the agent's conversation. Threaded heartbeats require a `resourceId` alongside the `threadId`.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
await mastra.heartbeats.create({
|
|
78
|
+
agentId: 'pinger',
|
|
79
|
+
cron: '0 9 * * *',
|
|
80
|
+
prompt: 'Summarize anything new since yesterday.',
|
|
81
|
+
threadId: 'thread-123',
|
|
82
|
+
resourceId: 'user-456',
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Threaded heartbeats accept extra fields that control how the signal behaves. They mirror the options [`agent.sendSignal`](https://mastra.ai/docs/agents/signals) accepts and stay JSON-serializable so they persist with the schedule.
|
|
87
|
+
|
|
88
|
+
- `signalType`: the [signal type](https://mastra.ai/docs/agents/signals) to send, for example `notification` or `system-reminder`. Defaults to `notification`.
|
|
89
|
+
- `tagName`: the XML tag the signal renders as. Defaults to `heartbeat`, so a fire surfaces to the agent as `<heartbeat>…</heartbeat>`.
|
|
90
|
+
- `attributes`: values rendered onto the signal's XML tag.
|
|
91
|
+
- `ifActive`: behavior when the thread is already streaming, as `{ behavior, attributes }`. `behavior` is one of `deliver`, `persist`, or `discard`.
|
|
92
|
+
- `ifIdle`: behavior when the thread is idle, as `{ behavior, attributes, streamOptions }`. `behavior` is one of `wake`, `persist`, or `discard`. `streamOptions.requestContext` is applied to the woken run.
|
|
93
|
+
|
|
94
|
+
These fields require a `threadId`. Passing them on a threadless heartbeat throws.
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
await mastra.heartbeats.create({
|
|
98
|
+
agentId: 'pinger',
|
|
99
|
+
cron: '0 9 * * *',
|
|
100
|
+
prompt: 'Summarize anything new since yesterday.',
|
|
101
|
+
threadId: 'thread-123',
|
|
102
|
+
resourceId: 'user-456',
|
|
103
|
+
tagName: 'check-in', // renders as <check-in>…</check-in>
|
|
104
|
+
attributes: { source: 'cron' },
|
|
105
|
+
ifActive: { behavior: 'discard' }, // skip if the thread is mid-stream
|
|
106
|
+
ifIdle: {
|
|
107
|
+
behavior: 'wake', // wake the agent if the thread is idle
|
|
108
|
+
streamOptions: { requestContext: { locale: 'en-US' } },
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`providerOptions` are merged into the signal payload on every fire and apply to both threaded and threadless heartbeats.
|
|
114
|
+
|
|
115
|
+
## Managing heartbeats
|
|
116
|
+
|
|
117
|
+
Use `mastra.heartbeats` for all heartbeat operations. To scope to a single agent, pass `agentId` to `create` or `list`.
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// Create
|
|
121
|
+
const hb = await mastra.heartbeats.create({
|
|
122
|
+
agentId: 'pinger',
|
|
123
|
+
cron: '0 * * * *',
|
|
124
|
+
prompt: 'Status check.',
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
// Read
|
|
128
|
+
await mastra.heartbeats.get(hb.id)
|
|
129
|
+
await mastra.heartbeats.list({ agentId: 'pinger' })
|
|
130
|
+
|
|
131
|
+
// Update — changing cron or timezone recomputes the next fire time
|
|
132
|
+
await mastra.heartbeats.update(hb.id, { cron: '*/30 * * * *' })
|
|
133
|
+
|
|
134
|
+
// Pause and resume
|
|
135
|
+
await mastra.heartbeats.pause(hb.id)
|
|
136
|
+
await mastra.heartbeats.resume(hb.id)
|
|
137
|
+
|
|
138
|
+
// Fire once now, off-schedule
|
|
139
|
+
await mastra.heartbeats.run(hb.id)
|
|
140
|
+
|
|
141
|
+
// Delete
|
|
142
|
+
await mastra.heartbeats.delete(hb.id)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
A few rules worth knowing:
|
|
146
|
+
|
|
147
|
+
- `pause` and `resume` are durable and idempotent. A paused heartbeat survives restarts, and `resume` recomputes the next fire time from now rather than firing backlogged runs.
|
|
148
|
+
- `run` fires the heartbeat once immediately without affecting its schedule.
|
|
149
|
+
- `list` filters by `agentId`, `threadId`, `resourceId`, and `name`.
|
|
150
|
+
|
|
151
|
+
### Custom IDs
|
|
152
|
+
|
|
153
|
+
By default `create` generates a random `hb_<uuid>` id. Pass `id` to choose a stable one, for example when you want a predictable handle to look up, update, or delete later:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
await mastra.heartbeats.create({
|
|
157
|
+
id: 'nightly-summary',
|
|
158
|
+
agentId: 'pinger',
|
|
159
|
+
cron: '0 9 * * *',
|
|
160
|
+
prompt: 'Summarize anything new since yesterday.',
|
|
161
|
+
})
|
|
162
|
+
// stored as `hb_nightly-summary`
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The id is normalized to `hb_<slug>`: the `hb_` prefix is added if missing and the rest is slugified. Creating a heartbeat with an id that already exists throws, so use `update` to change an existing one.
|
|
166
|
+
|
|
167
|
+
### From the client
|
|
168
|
+
|
|
169
|
+
The same operations are available from `@mastra/client-js` over the server routes, so you can manage heartbeats from a separate process or a UI.
|
|
170
|
+
|
|
171
|
+
## Lifecycle hooks
|
|
172
|
+
|
|
173
|
+
Hooks let you run code at key points in a heartbeat's lifecycle, for example to compute fire-time parameters or react to the outcome. Configure them on the `Mastra` constructor under `heartbeat`. The hooks are a single flat bundle that runs for every agent's heartbeats; each hook context carries the firing `agentId`, so branch on it when you need per-agent behavior. Hooks live at the `Mastra` level so they apply to both code-defined and stored agents.
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
const mastra = new Mastra({
|
|
177
|
+
agents: { pinger },
|
|
178
|
+
storage: new LibSQLStore({ url: 'file:./mastra.db' }),
|
|
179
|
+
heartbeat: {
|
|
180
|
+
prepare: async ({ agentId, heartbeat, trigger }) => {
|
|
181
|
+
// Return overrides, null to skip this fire, or undefined for defaults
|
|
182
|
+
return { prompt: `Status as of ${trigger.firedAt.toISOString()}` }
|
|
183
|
+
},
|
|
184
|
+
onFinish: async ({ agentId, outcome, runId }) => {
|
|
185
|
+
// Runs on any non-error, non-abort outcome
|
|
186
|
+
},
|
|
187
|
+
onError: async ({ agentId, phase, error }) => {
|
|
188
|
+
// Runs when prepare, the signal, or the agent run threw
|
|
189
|
+
},
|
|
190
|
+
onAbort: async ({ agentId, runId }) => {
|
|
191
|
+
// Runs when the run was aborted mid-stream
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
})
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The hooks are:
|
|
198
|
+
|
|
199
|
+
- `prepare`: runs before the fire. Return an object to override fire-time parameters such as `prompt` or `threadId`, `null` to skip the fire, or `undefined` to use the stored defaults.
|
|
200
|
+
- `onFinish`: runs once per trigger that reached a non-error, non-abort terminal state.
|
|
201
|
+
- `onError`: runs when `prepare`, the signal, or the agent run threw.
|
|
202
|
+
- `onAbort`: runs when the run was aborted mid-stream.
|
|
203
|
+
|
|
204
|
+
Every hook context includes `agentId` (the agent the heartbeat fired for) alongside `heartbeat` and `trigger`.
|
|
205
|
+
|
|
206
|
+
Hook exceptions are caught and logged. They never re-route the worker or trigger another hook.
|
|
207
|
+
|
|
208
|
+
## Related
|
|
209
|
+
|
|
210
|
+
- [Signals](https://mastra.ai/docs/agents/signals): the delivery mechanism behind threaded heartbeats.
|
|
211
|
+
- [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows): run a workflow, rather than an agent, on a cron schedule.
|
|
@@ -322,6 +322,29 @@ Use `createNotificationInboxTool()` to give agents one tool for inbox actions in
|
|
|
322
322
|
|
|
323
323
|
`sendNotificationSignal()` requires a storage domain with `notifications` support. Use `sendSignal({ type: 'notification' })` only for lower-level notification-shaped context that should bypass inbox storage.
|
|
324
324
|
|
|
325
|
+
## Distributed and serverless deployments
|
|
326
|
+
|
|
327
|
+
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.
|
|
328
|
+
|
|
329
|
+
The default in-memory pub/sub can't cross instance boundaries. On serverless platforms like Vercel, or any multi-instance deployment, a follow-up signal can land on a different instance than the one running the agent. Without a shared pub/sub, that instance can't reach the active run and starts its own, leaving the original run untouched and the thread processed twice.
|
|
330
|
+
|
|
331
|
+
Configure a shared pub/sub backed by Redis Streams on the `Mastra` instance so leases and signals coordinate across instances:
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
import { Mastra } from '@mastra/core'
|
|
335
|
+
import { RedisStreamsPubSub } from '@mastra/redis-streams'
|
|
336
|
+
|
|
337
|
+
export const mastra = new Mastra({
|
|
338
|
+
agents: { agent },
|
|
339
|
+
pubsub: new RedisStreamsPubSub({
|
|
340
|
+
url: process.env.REDIS_URL,
|
|
341
|
+
keyPrefix: 'mastra:my-app',
|
|
342
|
+
}),
|
|
343
|
+
})
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
`RedisStreamsPubSub` implements both the event delivery contract and distributed leasing, so a single backend handles cross-instance signal delivery and lease ownership. Vercel's one-click Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
|
|
347
|
+
|
|
325
348
|
## Compatibility and APIs
|
|
326
349
|
|
|
327
350
|
### Compatibility
|
|
@@ -404,4 +427,5 @@ Use heartbeats together with client-side reconnect logic. Heartbeats reduce idle
|
|
|
404
427
|
- [`client.getAgent().sendSignal()`](https://mastra.ai/reference/client-js/agents)
|
|
405
428
|
- [Server agent routes](https://mastra.ai/reference/server/routes)
|
|
406
429
|
- [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
|
|
407
|
-
- [`client.getAgent().sendToolApproval()`](https://mastra.ai/reference/client-js/agents)
|
|
430
|
+
- [`client.getAgent().sendToolApproval()`](https://mastra.ai/reference/client-js/agents)
|
|
431
|
+
- [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenTelemetry exporter
|
|
2
2
|
|
|
3
|
-
The OpenTelemetry (OTEL) exporter sends your traces and logs to any OTEL-compatible observability platform using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like Datadog, New Relic, SigNoz, MLflow, Dash0, Traceloop, Laminar, and more.
|
|
3
|
+
The OpenTelemetry (OTEL) exporter sends your traces and logs to any OTEL-compatible observability platform using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like Datadog, New Relic, SigNoz, MLflow, Latitude, Dash0, Traceloop, Laminar, and more.
|
|
4
4
|
|
|
5
5
|
> **Looking for bidirectional OTEL integration?:** If you have existing OpenTelemetry instrumentation and want Mastra traces to inherit context from active OTEL spans, see the [OpenTelemetry Bridge](https://mastra.ai/docs/observability/integrations/bridges/otel) instead.
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ The OpenTelemetry (OTEL) exporter sends your traces and logs to any OTEL-compati
|
|
|
8
8
|
|
|
9
9
|
Each provider requires specific protocol packages. Install the base exporter plus the protocol package for your provider:
|
|
10
10
|
|
|
11
|
-
### For HTTP/Protobuf Providers (SigNoz, New Relic, Laminar, MLflow)
|
|
11
|
+
### For HTTP/Protobuf Providers (SigNoz, New Relic, Laminar, MLflow, Latitude)
|
|
12
12
|
|
|
13
13
|
**npm**:
|
|
14
14
|
|
|
@@ -118,6 +118,27 @@ new OtelExporter({
|
|
|
118
118
|
})
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
### Latitude
|
|
122
|
+
|
|
123
|
+
[Latitude](https://latitude.so) is an open-source LLM observability and evaluation platform that ingests OTLP traces. Use the `custom` provider with HTTP/Protobuf, pointing at Latitude's ingestion endpoint and authenticating with your API key and project slug:
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
new OtelExporter({
|
|
127
|
+
provider: {
|
|
128
|
+
custom: {
|
|
129
|
+
endpoint: 'https://ingest.latitude.so/v1/traces',
|
|
130
|
+
protocol: 'http/protobuf',
|
|
131
|
+
headers: {
|
|
132
|
+
Authorization: `Bearer ${process.env.LATITUDE_API_KEY}`,
|
|
133
|
+
'X-Latitude-Project': process.env.LATITUDE_PROJECT,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Sign up at [console.latitude.so](https://console.latitude.so/login), or self-host and point the endpoint at your own ingestion host.
|
|
141
|
+
|
|
121
142
|
### Dash0
|
|
122
143
|
|
|
123
144
|
[Dash0](https://www.dash0.com/) provides real-time observability with automatic insights.
|
|
@@ -8,9 +8,9 @@ Three categories of metrics are emitted automatically:
|
|
|
8
8
|
- **Token usage metrics**: Input and output token counts broken down by type (text, cache, audio, image, reasoning).
|
|
9
9
|
- **Cost estimation**: Estimated cost per model call based on an embedded pricing registry.
|
|
10
10
|
|
|
11
|
-
> **Note:** Metrics require an
|
|
11
|
+
> **Note:** Metrics require an analytics-capable store for observability. Most relational databases (LibSQL, MSSQL) aren't supported for metrics. In-memory storage resets on restart.
|
|
12
12
|
>
|
|
13
|
-
> For local development, use [DuckDB](https://duckdb.org/) through `@mastra/duckdb`. For production, use [ClickHouse](https://clickhouse.com/) through `@mastra/clickhouse`.
|
|
13
|
+
> For local development, use [DuckDB](https://duckdb.org/) through `@mastra/duckdb`. For production, use [ClickHouse](https://clickhouse.com/) through `@mastra/clickhouse`. `PostgresStoreVNext` with the observability domain enabled also supports metrics, but always provide a time range to avoid full partition scans.
|
|
14
14
|
>
|
|
15
15
|
> Google Cloud Spanner supports metrics, but it's not recommended for heavy metrics workloads. The Spanner adapter disables metrics by default because metrics are write-heavy and scan-heavy. Set `disableMetrics: false` only for light workloads, or route metrics to an OLAP store.
|
|
16
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 336 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -61,7 +61,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
61
61
|
| `anthropic/claude-opus-4.1` |
|
|
62
62
|
| `anthropic/claude-opus-4.5` |
|
|
63
63
|
| `anthropic/claude-opus-4.6` |
|
|
64
|
-
| `anthropic/claude-opus-4.6-fast` |
|
|
65
64
|
| `anthropic/claude-opus-4.7` |
|
|
66
65
|
| `anthropic/claude-opus-4.7-fast` |
|
|
67
66
|
| `anthropic/claude-opus-4.8` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vercel
|
|
2
2
|
|
|
3
|
-
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
Vercel aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 294 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Vercel documentation](https://ai-sdk.dev/providers/ai-sdk-providers).
|
|
6
6
|
|
|
@@ -72,6 +72,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
72
72
|
| `amazon/nova-micro` |
|
|
73
73
|
| `amazon/nova-pro` |
|
|
74
74
|
| `amazon/titan-embed-text-v2` |
|
|
75
|
+
| `anthropic/claude-3.5-haiku` |
|
|
75
76
|
| `anthropic/claude-haiku-4.5` |
|
|
76
77
|
| `anthropic/claude-opus-4` |
|
|
77
78
|
| `anthropic/claude-opus-4.1` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 4482 models from 135 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Anthropic
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 17 Anthropic models through Mastra's model router. Authentication is handled automatically using the `ANTHROPIC_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Anthropic documentation](https://docs.anthropic.com/en/docs/about-claude/models).
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ const agent = new Agent({
|
|
|
15
15
|
id: "my-agent",
|
|
16
16
|
name: "My Agent",
|
|
17
17
|
instructions: "You are a helpful assistant",
|
|
18
|
-
model: "anthropic/claude-
|
|
18
|
+
model: "anthropic/claude-fable-5"
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
// Generate a response
|
|
@@ -32,7 +32,6 @@ for await (const chunk of stream) {
|
|
|
32
32
|
|
|
33
33
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
34
34
|
| -------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
35
|
-
| `anthropic/claude-3-5-haiku-latest` | 200K | | | | | | $0.80 | $4 |
|
|
36
35
|
| `anthropic/claude-fable-5` | 1.0M | | | | | | $10 | $50 |
|
|
37
36
|
| `anthropic/claude-haiku-4-5` | 200K | | | | | | $1 | $5 |
|
|
38
37
|
| `anthropic/claude-haiku-4-5-20251001` | 200K | | | | | | $1 | $5 |
|
|
@@ -60,7 +59,7 @@ const agent = new Agent({
|
|
|
60
59
|
id: "custom-agent",
|
|
61
60
|
name: "custom-agent",
|
|
62
61
|
model: {
|
|
63
|
-
id: "anthropic/claude-
|
|
62
|
+
id: "anthropic/claude-fable-5",
|
|
64
63
|
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
65
64
|
headers: {
|
|
66
65
|
"X-Custom-Header": "value"
|
|
@@ -79,7 +78,7 @@ const agent = new Agent({
|
|
|
79
78
|
const useAdvanced = requestContext.task === "complex";
|
|
80
79
|
return useAdvanced
|
|
81
80
|
? "anthropic/claude-sonnet-4-6"
|
|
82
|
-
: "anthropic/claude-
|
|
81
|
+
: "anthropic/claude-fable-5";
|
|
83
82
|
}
|
|
84
83
|
});
|
|
85
84
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Chutes
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 13 Chutes models through Mastra's model router. Authentication is handled automatically using the `CHUTES_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Chutes documentation](https://llm.chutes.ai).
|
|
6
6
|
|
|
@@ -32,47 +32,21 @@ for await (const chunk of stream) {
|
|
|
32
32
|
|
|
33
33
|
## Models
|
|
34
34
|
|
|
35
|
-
| Model
|
|
36
|
-
|
|
|
37
|
-
| `chutes/deepseek-ai/DeepSeek-
|
|
38
|
-
| `chutes/
|
|
39
|
-
| `chutes/
|
|
40
|
-
| `chutes/
|
|
41
|
-
| `chutes/
|
|
42
|
-
| `chutes/
|
|
43
|
-
| `chutes/
|
|
44
|
-
| `chutes/
|
|
45
|
-
| `chutes/
|
|
46
|
-
| `chutes/
|
|
47
|
-
| `chutes/
|
|
48
|
-
| `chutes/
|
|
49
|
-
| `chutes/
|
|
50
|
-
| `chutes/Qwen/Qwen2.5-Coder-32B-Instruct` | 33K | | | | | | $0.03 | $0.11 |
|
|
51
|
-
| `chutes/Qwen/Qwen2.5-VL-32B-Instruct` | 16K | | | | | | $0.05 | $0.22 |
|
|
52
|
-
| `chutes/Qwen/Qwen3-235B-A22B-Instruct-2507-TEE` | 262K | | | | | | $0.10 | $0.60 |
|
|
53
|
-
| `chutes/Qwen/Qwen3-235B-A22B-Thinking-2507` | 262K | | | | | | $0.11 | $0.60 |
|
|
54
|
-
| `chutes/Qwen/Qwen3-30B-A3B` | 41K | | | | | | $0.06 | $0.22 |
|
|
55
|
-
| `chutes/Qwen/Qwen3-32B-TEE` | 41K | | | | | | $0.08 | $0.24 |
|
|
56
|
-
| `chutes/Qwen/Qwen3-Coder-Next-TEE` | 262K | | | | | | $0.12 | $0.75 |
|
|
57
|
-
| `chutes/Qwen/Qwen3-Next-80B-A3B-Instruct` | 262K | | | | | | $0.10 | $0.80 |
|
|
58
|
-
| `chutes/Qwen/Qwen3.5-397B-A17B-TEE` | 262K | | | | | | $0.39 | $2 |
|
|
59
|
-
| `chutes/Qwen/Qwen3.6-27B-TEE` | 262K | | | | | | $0.20 | $2 |
|
|
60
|
-
| `chutes/Qwen/Qwen3Guard-Gen-0.6B` | 33K | | | | | | $0.01 | $0.01 |
|
|
61
|
-
| `chutes/rednote-hilab/dots.ocr` | 131K | | | | | | $0.01 | $0.01 |
|
|
62
|
-
| `chutes/tngtech/DeepSeek-TNG-R1T2-Chimera-TEE` | 164K | | | | | | $0.30 | $1 |
|
|
63
|
-
| `chutes/unsloth/gemma-3-12b-it` | 131K | | | | | | $0.03 | $0.10 |
|
|
64
|
-
| `chutes/unsloth/gemma-3-27b-it` | 128K | | | | | | $0.03 | $0.11 |
|
|
65
|
-
| `chutes/unsloth/gemma-3-4b-it` | 96K | | | | | | $0.01 | $0.03 |
|
|
66
|
-
| `chutes/unsloth/Llama-3.2-1B-Instruct` | 16K | | | | | | $0.01 | $0.01 |
|
|
67
|
-
| `chutes/unsloth/Llama-3.2-3B-Instruct` | 16K | | | | | | $0.01 | $0.01 |
|
|
68
|
-
| `chutes/unsloth/Mistral-Nemo-Instruct-2407` | 131K | | | | | | $0.02 | $0.04 |
|
|
69
|
-
| `chutes/XiaomiMiMo/MiMo-V2-Flash-TEE` | 262K | | | | | | $0.09 | $0.29 |
|
|
70
|
-
| `chutes/zai-org/GLM-4.6V` | 131K | | | | | | $0.30 | $0.90 |
|
|
71
|
-
| `chutes/zai-org/GLM-4.7-FP8` | 203K | | | | | | $0.30 | $1 |
|
|
72
|
-
| `chutes/zai-org/GLM-4.7-TEE` | 203K | | | | | | $0.39 | $2 |
|
|
73
|
-
| `chutes/zai-org/GLM-5-TEE` | 203K | | | | | | $0.95 | $3 |
|
|
74
|
-
| `chutes/zai-org/GLM-5-Turbo` | 203K | | | | | | $0.49 | $2 |
|
|
75
|
-
| `chutes/zai-org/GLM-5.1-TEE` | 203K | | | | | | $1 | $4 |
|
|
35
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
|
+
| ----------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
|
+
| `chutes/deepseek-ai/DeepSeek-V3.2-TEE` | 131K | | | | | | $1 | $1 |
|
|
38
|
+
| `chutes/google/gemma-4-31B-turbo-TEE` | 131K | | | | | | $0.12 | $0.37 |
|
|
39
|
+
| `chutes/MiniMaxAI/MiniMax-M2.5-TEE` | 197K | | | | | | $0.15 | $1 |
|
|
40
|
+
| `chutes/moonshotai/Kimi-K2.5-TEE` | 262K | | | | | | $0.44 | $2 |
|
|
41
|
+
| `chutes/moonshotai/Kimi-K2.6-TEE` | 262K | | | | | | $0.66 | $4 |
|
|
42
|
+
| `chutes/Qwen/Qwen3-235B-A22B-Thinking-2507-TEE` | 262K | | | | | | $0.30 | $1 |
|
|
43
|
+
| `chutes/Qwen/Qwen3-32B-TEE` | 41K | | | | | | $0.10 | $0.42 |
|
|
44
|
+
| `chutes/Qwen/Qwen3.5-397B-A17B-TEE` | 262K | | | | | | $0.45 | $3 |
|
|
45
|
+
| `chutes/Qwen/Qwen3.6-27B-TEE` | 262K | | | | | | $0.30 | $2 |
|
|
46
|
+
| `chutes/unsloth/Mistral-Nemo-Instruct-2407-TEE` | 131K | | | | | | $0.02 | $0.10 |
|
|
47
|
+
| `chutes/zai-org/GLM-5-TEE` | 203K | | | | | | $0.95 | $3 |
|
|
48
|
+
| `chutes/zai-org/GLM-5.1-TEE` | 203K | | | | | | $0.98 | $3 |
|
|
49
|
+
| `chutes/zai-org/GLM-5.2-TEE` | 1.0M | | | | | | $1 | $4 |
|
|
76
50
|
|
|
77
51
|
## Advanced configuration
|
|
78
52
|
|
|
@@ -102,7 +76,7 @@ const agent = new Agent({
|
|
|
102
76
|
model: ({ requestContext }) => {
|
|
103
77
|
const useAdvanced = requestContext.task === "complex";
|
|
104
78
|
return useAdvanced
|
|
105
|
-
? "chutes/zai-org/GLM-5.
|
|
79
|
+
? "chutes/zai-org/GLM-5.2-TEE"
|
|
106
80
|
: "chutes/MiniMaxAI/MiniMax-M2.5-TEE";
|
|
107
81
|
}
|
|
108
82
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deep Infra
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 26 Deep Infra models through Mastra's model router. Authentication is handled automatically using the `DEEPINFRA_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Deep Infra documentation](https://deepinfra.com/models).
|
|
6
6
|
|
|
@@ -57,6 +57,7 @@ for await (const chunk of stream) {
|
|
|
57
57
|
| `deepinfra/zai-org/GLM-4.7-Flash` | 203K | | | | | | $0.06 | $0.40 |
|
|
58
58
|
| `deepinfra/zai-org/GLM-5` | 203K | | | | | | $0.60 | $2 |
|
|
59
59
|
| `deepinfra/zai-org/GLM-5.1` | 203K | | | | | | $1 | $4 |
|
|
60
|
+
| `deepinfra/zai-org/GLM-5.2` | 1.0M | | | | | | $0.95 | $3 |
|
|
60
61
|
|
|
61
62
|
## Advanced configuration
|
|
62
63
|
|
|
@@ -85,7 +86,7 @@ const agent = new Agent({
|
|
|
85
86
|
model: ({ requestContext }) => {
|
|
86
87
|
const useAdvanced = requestContext.task === "complex";
|
|
87
88
|
return useAdvanced
|
|
88
|
-
? "deepinfra/zai-org/GLM-5.
|
|
89
|
+
? "deepinfra/zai-org/GLM-5.2"
|
|
89
90
|
: "deepinfra/MiniMaxAI/MiniMax-M2.5";
|
|
90
91
|
}
|
|
91
92
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Friendli
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 7 Friendli models through Mastra's model router. Authentication is handled automatically using the `FRIENDLI_TOKEN` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Friendli documentation](https://friendli.ai/docs/guides/serverless_endpoints/introduction).
|
|
6
6
|
|
|
@@ -36,8 +36,6 @@ for await (const chunk of stream) {
|
|
|
36
36
|
| --------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
37
|
| `friendli/deepseek-ai/DeepSeek-V3.2` | 164K | | | | | | $0.50 | $2 |
|
|
38
38
|
| `friendli/google/gemma-4-31B-it` | 262K | | | | | | $0.14 | $0.40 |
|
|
39
|
-
| `friendli/meta-llama/Llama-3.1-8B-Instruct` | 131K | | | | | | $0.10 | $0.10 |
|
|
40
|
-
| `friendli/meta-llama/Llama-3.3-70B-Instruct` | 131K | | | | | | $0.60 | $0.60 |
|
|
41
39
|
| `friendli/MiniMaxAI/MiniMax-M2.5` | 197K | | | | | | $0.30 | $1 |
|
|
42
40
|
| `friendli/Qwen/Qwen3-235B-A22B-Instruct-2507` | 262K | | | | | | $0.20 | $0.80 |
|
|
43
41
|
| `friendli/zai-org/GLM-5` | 203K | | | | | | $1 | $3 |
|