@mastra/mcp-docs-server 1.3.13-alpha.0 → 1.3.13-alpha.11
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/resumable-streams.md +140 -0
- package/.docs/docs/agents/tools.md +3 -2
- package/.docs/docs/auth/overview.md +1 -0
- package/.docs/docs/channels.md +34 -1
- package/.docs/docs/connections/mcp.md +34 -67
- package/.docs/docs/deployment/mastra-server.md +10 -2
- package/.docs/docs/deployment/workers.md +3 -1
- package/.docs/docs/harness/background-tasks.md +2 -1
- package/.docs/docs/harness/durable-agents.md +106 -8
- package/.docs/docs/harness/schedules.md +2 -0
- package/.docs/docs/mastra-platform/connect.md +231 -0
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +26 -1
- package/.docs/docs/observability/feedback.md +5 -7
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +41 -0
- package/.docs/docs/observability/tracing/overview.md +0 -2
- package/.docs/docs/sandbox/skills.md +32 -3
- package/.docs/docs/server/custom-adapters.md +40 -11
- package/.docs/docs/server/middleware.md +1 -1
- package/.docs/docs/signals/sending-signals.md +3 -1
- package/.docs/docs/workflows/overview.md +12 -0
- package/.docs/docs/workflows/suspend-and-resume.md +1 -1
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +46 -0
- package/.docs/integrations/auth/clerk.md +46 -7
- package/.docs/integrations/auth/neon.md +217 -0
- package/.docs/integrations/auth/supabase.md +46 -7
- package/.docs/integrations/auth/workos.md +54 -15
- package/.docs/integrations/channels/discord.md +84 -6
- package/.docs/integrations/channels/github.md +63 -24
- package/.docs/integrations/channels/slack.md +89 -8
- package/.docs/integrations/channels/teams.md +79 -5
- package/.docs/integrations/channels/telegram.md +47 -6
- package/.docs/integrations/crm/attio.md +42 -0
- package/.docs/integrations/crm/clay.md +42 -0
- package/.docs/integrations/crm/hubspot.md +41 -0
- package/.docs/integrations/databases/neon.md +37 -1
- package/.docs/integrations/databases/postgresql.md +46 -0
- package/.docs/integrations/deploy/render.md +59 -18
- package/.docs/integrations/deploy/temporal.md +74 -0
- package/.docs/integrations/documents/google-docs.md +41 -0
- package/.docs/integrations/documents/google-sheet.md +41 -0
- package/.docs/integrations/documents/microsoft-excel.md +43 -0
- package/.docs/integrations/documents/microsoft-powerpoint.md +41 -0
- package/.docs/integrations/documents/microsoft-word.md +41 -0
- package/.docs/integrations/documents/notion.md +41 -0
- package/.docs/integrations/documents/one-drive.md +41 -0
- package/.docs/integrations/documents/sharepoint-online.md +41 -0
- package/.docs/integrations/email-calendar/google-calendar.md +41 -0
- package/.docs/integrations/email-calendar/google-mail.md +41 -0
- package/.docs/integrations/email-calendar/outlook.md +41 -0
- package/.docs/integrations/file-storage/amazon-s3.md +1 -1
- package/.docs/integrations/file-storage/google-drive.md +54 -15
- package/.docs/integrations/observability/arize.md +1 -1
- package/.docs/integrations/observability/posthog.md +50 -11
- package/.docs/integrations/other/canva.md +42 -0
- package/.docs/integrations/other/fireflies.md +41 -0
- package/.docs/integrations/other/incident-io.md +41 -0
- package/.docs/integrations/other/resend.md +43 -0
- package/.docs/integrations/other/robinhood.md +44 -0
- package/.docs/integrations/other/sanity.md +42 -0
- package/.docs/integrations/other/snowflake.md +41 -0
- package/.docs/integrations/project-management/jira.md +41 -0
- package/.docs/integrations/project-management/linear.md +41 -0
- package/.docs/integrations/sandboxes/docker.md +39 -0
- package/.docs/integrations/sandboxes/e2b.md +1 -1
- package/.docs/integrations/voice/openai.md +40 -0
- package/.docs/integrations.md +40 -1
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/azure-openai.md +61 -2
- package/.docs/models/gateways/custom-gateways.md +2 -0
- package/.docs/models/gateways/merge-gateway.md +3 -1
- package/.docs/models/gateways/netlify.md +11 -7
- package/.docs/models/gateways/openrouter.md +13 -12
- package/.docs/models/gateways/requesty.md +221 -0
- package/.docs/models/gateways/vercel.md +423 -420
- package/.docs/models/gateways.md +7 -1
- package/.docs/models/index.md +46 -3
- package/.docs/models/providers/aiand.md +1 -1
- package/.docs/models/providers/aihubmix.md +2 -0
- package/.docs/models/providers/amazon-bedrock.md +4 -0
- package/.docs/models/providers/anthropic.md +2 -1
- package/.docs/models/providers/azure.md +4 -0
- package/.docs/models/providers/chutes.md +6 -4
- package/.docs/models/providers/cloudflare-ai-gateway.md +2 -0
- package/.docs/models/providers/cloudflare-workers-ai.md +0 -13
- package/.docs/models/providers/cohere.md +2 -0
- package/.docs/models/providers/crossmodel.md +5 -1
- package/.docs/models/providers/deepinfra.md +2 -1
- package/.docs/models/providers/edenai.md +12 -13
- package/.docs/models/providers/empiriolabs.md +3 -3
- package/.docs/models/providers/fireworks-ai.md +30 -28
- package/.docs/models/providers/google-vertex.md +2 -0
- package/.docs/models/providers/google.md +4 -3
- package/.docs/models/providers/hyper.md +8 -14
- package/.docs/models/providers/inceptron.md +2 -2
- package/.docs/models/providers/kilo.md +34 -33
- package/.docs/models/providers/llmgateway-providers.md +448 -427
- package/.docs/models/providers/llmgateway.md +9 -5
- package/.docs/models/providers/meta.md +5 -4
- package/.docs/models/providers/morph.md +2 -1
- package/.docs/models/providers/nano-gpt.md +51 -57
- package/.docs/models/providers/novita-ai.md +4 -2
- package/.docs/models/providers/ollama-cloud.md +2 -1
- package/.docs/models/providers/ollama.md +2 -0
- package/.docs/models/providers/opencode-go.md +3 -1
- package/.docs/models/providers/opencode.md +11 -6
- package/.docs/models/providers/prime.md +4 -4
- package/.docs/models/providers/qvac.md +2 -0
- package/.docs/models/providers/tencent-token-plan.md +2 -1
- package/.docs/models/providers/tencent-tokenhub.md +2 -1
- package/.docs/models/providers/tinfoil.md +2 -1
- package/.docs/models/providers/wandb.md +4 -4
- package/.docs/models/providers.md +0 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +4 -2
- package/.docs/reference/agent-controller/session.md +1 -1
- package/.docs/reference/agents/agent.md +2 -0
- package/.docs/reference/agents/channels.md +117 -1
- package/.docs/reference/agents/durable-agent.md +42 -29
- package/.docs/reference/ai-sdk/chat-route.md +33 -2
- package/.docs/reference/auth/neon.md +24 -15
- package/.docs/reference/build-with-ai.md +12 -2
- package/.docs/reference/cli/mastra.md +10 -1
- package/.docs/reference/client-js/agents.md +4 -4
- package/.docs/reference/client-js/observability.md +36 -6
- package/.docs/reference/code-sdk/mount-agent-controller.md +5 -1
- package/.docs/reference/connect/channels.md +55 -1
- package/.docs/reference/connect/credential.md +2 -1
- package/.docs/reference/connect/providers.md +5 -3
- package/.docs/reference/connect/tools.md +29 -2
- package/.docs/reference/core/getGatewayById.md +14 -1
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/evals/create-scorer.md +3 -1
- package/.docs/reference/file-based-agents/tools.md +3 -3
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/observability/feedback.md +43 -14
- package/.docs/reference/observability/tracing/advanced-queries.md +47 -58
- package/.docs/reference/observability/tracing/configuration.md +3 -0
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +51 -15
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +30 -0
- package/.docs/reference/observability/tracing/interfaces.md +2 -0
- package/.docs/reference/processors/processor-interface.md +24 -1
- package/.docs/reference/processors/semantic-recall-processor.md +7 -3
- package/.docs/reference/processors/skill-search-processor.md +3 -0
- package/.docs/reference/processors/skills-processor.md +84 -0
- package/.docs/reference/pubsub/lease-provider.md +4 -2
- package/.docs/reference/pubsub/redis-streams.md +3 -1
- package/.docs/reference/rag/graph-rag.md +2 -2
- package/.docs/reference/rag/rerank.md +1 -1
- package/.docs/reference/rag/rerankWithScorer.md +1 -1
- package/.docs/reference/streaming/agents/MastraModelOutput.md +13 -12
- package/.docs/reference/tools/mcp-client.md +26 -7
- package/.docs/reference/tools/mcp-server.md +6 -2
- package/.docs/reference/workers/overview.md +2 -2
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run.md +1 -1
- package/.docs/reference/workflows/workflow.md +1 -1
- package/.docs/reference/workspace/factory-sandbox.md +24 -8
- package/.docs/reference/workspace/platform-sandbox.md +22 -7
- package/.docs/reference/workspace/workspace-class.md +5 -5
- package/package.json +4 -5
- package/.docs/docs/mastra-platform/connect/channels.md +0 -165
- package/.docs/docs/mastra-platform/connect/overview.md +0 -102
- package/.docs/docs/mastra-platform/connect/providers.md +0 -66
- package/.docs/docs/mastra-platform/connect/tools.md +0 -151
- package/.docs/models/providers/requesty.md +0 -261
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# OpenCode
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 138 OpenCode models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [OpenCode documentation](https://opencode.ai/v2/docs/console/models/).
|
|
10
10
|
|
|
@@ -42,6 +42,7 @@ for await (const chunk of stream) {
|
|
|
42
42
|
| `opencode/big-pickle` | 200K | | | | | | — | — |
|
|
43
43
|
| `opencode/claude-fable-5` | 1.0M | | | | | | $10 | $50 |
|
|
44
44
|
| `opencode/claude-fable-5-1` | 1.0M | | | | | | $10 | $50 |
|
|
45
|
+
| `opencode/claude-fable-5-2` | 1.0M | | | | | | $8 | $40 |
|
|
45
46
|
| `opencode/claude-haiku-4-5` | 200K | | | | | | $1 | $5 |
|
|
46
47
|
| `opencode/claude-haiku-5-5` | 1.0M | | | | | | $0.10 | $0.50 |
|
|
47
48
|
| `opencode/claude-opus-4-5` | 200K | | | | | | $5 | $25 |
|
|
@@ -54,7 +55,6 @@ for await (const chunk of stream) {
|
|
|
54
55
|
| `opencode/claude-sonnet-4-6` | 1.0M | | | | | | $3 | $15 |
|
|
55
56
|
| `opencode/claude-sonnet-5` | 1.0M | | | | | | $2 | $10 |
|
|
56
57
|
| `opencode/claude-sonnet-5-5` | 1.0M | | | | | | $2 | $10 |
|
|
57
|
-
| `opencode/crouton-alpha-free` | 1.0M | | | | | | — | — |
|
|
58
58
|
| `opencode/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
59
59
|
| `opencode/deepseek-v4.1-flash` | 1.0M | | | | | | $0.30 | $1 |
|
|
60
60
|
| `opencode/deepseek-v4.1-flash-free` | 200K | | | | | | — | — |
|
|
@@ -63,10 +63,11 @@ for await (const chunk of stream) {
|
|
|
63
63
|
| `opencode/gemini-3.1-pro` | 1.0M | | | | | | $2 | $12 |
|
|
64
64
|
| `opencode/gemini-3.5-flash` | 1.0M | | | | | | $2 | $9 |
|
|
65
65
|
| `opencode/gemini-3.5-flash-lite` | 1.0M | | | | | | $0.30 | $3 |
|
|
66
|
-
| `opencode/gemini-3.6-flash` | 1.0M | | | | | | $
|
|
67
|
-
| `opencode/gemini-3.7-flash` | 1.0M | | | | | | $
|
|
68
|
-
| `opencode/gemini-3.8-flash` | 1.0M | | | | | | $
|
|
66
|
+
| `opencode/gemini-3.6-flash` | 1.0M | | | | | | $0.75 | $4 |
|
|
67
|
+
| `opencode/gemini-3.7-flash` | 1.0M | | | | | | $0.75 | $4 |
|
|
68
|
+
| `opencode/gemini-3.8-flash` | 1.0M | | | | | | $0.75 | $4 |
|
|
69
69
|
| `opencode/gemini-4-argon` | 1.0M | | | | | | $2 | $10 |
|
|
70
|
+
| `opencode/gemini-4-carbon` | 1.0M | | | | | | $2 | $10 |
|
|
70
71
|
| `opencode/glm-5` | 205K | | | | | | $1 | $3 |
|
|
71
72
|
| `opencode/glm-5.1` | 205K | | | | | | $1 | $4 |
|
|
72
73
|
| `opencode/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
@@ -101,21 +102,25 @@ for await (const chunk of stream) {
|
|
|
101
102
|
| `opencode/grok-4.6` | 500K | | | | | | $2 | $6 |
|
|
102
103
|
| `opencode/grok-4.7` | 500K | | | | | | $2 | $6 |
|
|
103
104
|
| `opencode/grok-build-0.1` | 256K | | | | | | $1 | $2 |
|
|
105
|
+
| `opencode/iceman-free` | 262K | | | | | | — | — |
|
|
106
|
+
| `opencode/inkling-2-small-free` | 1.0M | | | | | | — | — |
|
|
104
107
|
| `opencode/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
105
108
|
| `opencode/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
106
109
|
| `opencode/kimi-k2.7-code` | 262K | | | | | | $0.95 | $4 |
|
|
107
110
|
| `opencode/kimi-k3` | 1.0M | | | | | | $3 | $15 |
|
|
111
|
+
| `opencode/longcat-2.5-free` | 1.0M | | | | | | — | — |
|
|
108
112
|
| `opencode/mimo-v2.6-flash-free` | 200K | | | | | | — | — |
|
|
109
113
|
| `opencode/minimax-m2.5` | 205K | | | | | | $0.30 | $1 |
|
|
110
114
|
| `opencode/minimax-m2.7` | 205K | | | | | | $0.30 | $1 |
|
|
111
115
|
| `opencode/minimax-m3` | 512K | | | | | | $0.30 | $1 |
|
|
116
|
+
| `opencode/minimax-m3.1-flash-free` | 1.0M | | | | | | — | — |
|
|
112
117
|
| `opencode/mistral-large-4` | 524K | | | | | | $0.68 | $2 |
|
|
118
|
+
| `opencode/muse-ember-1.0` | 1.0M | | | | | | $0.10 | $0.50 |
|
|
113
119
|
| `opencode/muse-spark-1.2` | 1.0M | | | | | | $1 | $4 |
|
|
114
120
|
| `opencode/muse-spark-1.3` | 1.0M | | | | | | $1 | $4 |
|
|
115
121
|
| `opencode/muse-wonder-1.0` | 1.0M | | | | | | $4 | $20 |
|
|
116
122
|
| `opencode/nemotron-3.5-lightning-free` | 262K | | | | | | — | — |
|
|
117
123
|
| `opencode/nemotron-3.5-super-vl-free` | 1.0M | | | | | | — | — |
|
|
118
|
-
| `opencode/pulse-alpha-free` | 1.0M | | | | | | — | — |
|
|
119
124
|
| `opencode/qwen3.5-plus` | 262K | | | | | | $0.20 | $1 |
|
|
120
125
|
| `opencode/qwen3.6-plus` | 262K | | | | | | $0.50 | $3 |
|
|
121
126
|
| `opencode/qwen3.8-flash` | 1.0M | | | | | | $0.15 | $0.47 |
|
|
@@ -51,8 +51,8 @@ for await (const chunk of stream) {
|
|
|
51
51
|
| `prime/deepseek/deepseek-v4-flash` | 1.0M | | | | | | $0.44 | $1 |
|
|
52
52
|
| `prime/deepseek/deepseek-v4-flash-0731` | 1.0M | | | | | | $0.44 | $1 |
|
|
53
53
|
| `prime/deepseek/deepseek-v4-pro` | 1.0M | | | | | | $2 | $4 |
|
|
54
|
-
| `prime/deepseek/deepseek-v4.1-flash` | 1.0M | | | | | | $0.
|
|
55
|
-
| `prime/deepseek/deepseek-v4.1-flash-1017` | 1.0M | | | | | | $0.
|
|
54
|
+
| `prime/deepseek/deepseek-v4.1-flash` | 1.0M | | | | | | $0.04 | $1 |
|
|
55
|
+
| `prime/deepseek/deepseek-v4.1-flash-1017` | 1.0M | | | | | | $0.04 | $0.70 |
|
|
56
56
|
| `prime/google/gemini-3-flash-preview` | 1.0M | | | | | | $0.50 | $3 |
|
|
57
57
|
| `prime/google/gemini-3.1-pro-preview` | 1.0M | | | | | | $2 | $12 |
|
|
58
58
|
| `prime/google/gemini-3.5-flash` | 1.0M | | | | | | $2 | $9 |
|
|
@@ -106,8 +106,8 @@ for await (const chunk of stream) {
|
|
|
106
106
|
| `prime/x-ai/grok-4.6` | 500K | | | | | | $2 | $6 |
|
|
107
107
|
| `prime/x-ai/grok-4.7` | 500K | | | | | | $2 | $5 |
|
|
108
108
|
| `prime/z-ai/glm-5.2` | 1.0M | | | | | | $2 | $5 |
|
|
109
|
-
| `prime/z-ai/glm-5.3` | 1.0M | | | | | | $0.
|
|
110
|
-
| `prime/z-ai/glm-5.3-flash` | 1.0M | | | | | | $0.
|
|
109
|
+
| `prime/z-ai/glm-5.3` | 1.0M | | | | | | $0.40 | $2 |
|
|
110
|
+
| `prime/z-ai/glm-5.3-flash` | 1.0M | | | | | | $0.05 | $0.25 |
|
|
111
111
|
|
|
112
112
|
Model availability, capabilities, context windows, and pricing are sourced from [models.dev](https://models.dev) and may change.
|
|
113
113
|
|
|
@@ -8,6 +8,8 @@ QVAC is available through the AI SDK. Install the provider package to use their
|
|
|
8
8
|
|
|
9
9
|
For detailed provider-specific documentation, see the [AI SDK QVAC provider docs](https://ai-sdk.dev/providers/community-providers/qvac).
|
|
10
10
|
|
|
11
|
+
QVAC isn't a model router provider, so model strings like `qvac/<model>` don't resolve. Pass a model instance from `@qvac/ai-sdk-provider` to the agent's `model` option instead.
|
|
12
|
+
|
|
11
13
|
To use this provider with Mastra agents, see the [Agent Overview documentation](https://mastra.ai/docs/agents/overview).
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Tencent Token Plan
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 3 Tencent Token Plan models through Mastra's model router. Authentication is handled automatically using the `TENCENT_TOKEN_PLAN_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Tencent Token Plan documentation](https://cloud.tencent.com/document/product/1823/130060).
|
|
10
10
|
|
|
@@ -39,6 +39,7 @@ for await (const chunk of stream) {
|
|
|
39
39
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
40
|
| -------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
41
|
| `tencent-token-plan/hy3` | 256K | | | | | | — | — |
|
|
42
|
+
| `tencent-token-plan/hy4` | 1.0M | | | | | | $0.83 | $3 |
|
|
42
43
|
| `tencent-token-plan/hy4-preview` | 1.0M | | | | | | $0.83 | $3 |
|
|
43
44
|
|
|
44
45
|
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
|
# Tencent TokenHub
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 4 Tencent TokenHub models through Mastra's model router. Authentication is handled automatically using the `TENCENT_TOKENHUB_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Tencent TokenHub documentation](https://cloud.tencent.com/document/product/1823/130050).
|
|
10
10
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| ------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
41
|
| `tencent-tokenhub/hy3` | 256K | | | | | | — | — |
|
|
42
42
|
| `tencent-tokenhub/hy3-preview` | 256K | | | | | | — | — |
|
|
43
|
+
| `tencent-tokenhub/hy4` | 1.0M | | | | | | $0.83 | $3 |
|
|
43
44
|
| `tencent-tokenhub/hy4-preview` | 1.0M | | | | | | $0.83 | $3 |
|
|
44
45
|
|
|
45
46
|
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
|
# Tinfoil
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 9 Tinfoil models through Mastra's model router. Authentication is handled automatically using the `TINFOIL_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Tinfoil documentation](https://docs.tinfoil.sh).
|
|
10
10
|
|
|
@@ -44,6 +44,7 @@ for await (const chunk of stream) {
|
|
|
44
44
|
| `tinfoil/gpt-oss-120b` | 131K | | | | | | $0.15 | $0.60 |
|
|
45
45
|
| `tinfoil/gpt-oss-safeguard-120b` | 131K | | | | | | $0.15 | $0.60 |
|
|
46
46
|
| `tinfoil/kimi-k3` | 262K | | | | | | $4 | $20 |
|
|
47
|
+
| `tinfoil/kimi-k3-1-pro` | 262K | | | | | | $4 | $20 |
|
|
47
48
|
| `tinfoil/llama3-3-70b` | 131K | | | | | | $2 | $3 |
|
|
48
49
|
| `tinfoil/nomic-embed-text` | 8K | | | | | | $0.02 | — |
|
|
49
50
|
|
|
@@ -38,8 +38,8 @@ for await (const chunk of stream) {
|
|
|
38
38
|
|
|
39
39
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
40
|
| ----------------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
|
-
| `wandb/deepseek-ai/DeepSeek-V3.1` | 161K | | | | | | $0.
|
|
42
|
-
| `wandb/deepseek-ai/DeepSeek-V4-Flash-0731` | 262K | | | | | | $0.13 | $0.
|
|
41
|
+
| `wandb/deepseek-ai/DeepSeek-V3.1` | 161K | | | | | | $0.50 | $2 |
|
|
42
|
+
| `wandb/deepseek-ai/DeepSeek-V4-Flash-0731` | 262K | | | | | | $0.13 | $0.27 |
|
|
43
43
|
| `wandb/deepseek-ai/DeepSeek-V4-Pro-0813` | 1.0M | | | | | | $1 | $4 |
|
|
44
44
|
| `wandb/deepseek-ai/DeepSeek-V4.1-Flash` | 1.0M | | | | | | $0.13 | $0.65 |
|
|
45
45
|
| `wandb/deepseek-ai/DeepSeek-V4.1-Flash-1017` | 1.0M | | | | | | $0.30 | $1 |
|
|
@@ -53,10 +53,10 @@ for await (const chunk of stream) {
|
|
|
53
53
|
| `wandb/moonshotai/Kimi-K2.7-Code` | 262K | | | | | | $0.60 | $3 |
|
|
54
54
|
| `wandb/nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B` | 262K | | | | | | $0.50 | $2 |
|
|
55
55
|
| `wandb/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B` | 262K | | | | | | $0.07 | $0.20 |
|
|
56
|
-
| `wandb/nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B` | 1.0M | | | | | | $0.15 | $0.
|
|
56
|
+
| `wandb/nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B` | 1.0M | | | | | | $0.15 | $0.47 |
|
|
57
57
|
| `wandb/openai/gpt-oss-120b` | 131K | | | | | | $0.03 | $0.17 |
|
|
58
58
|
| `wandb/openai/gpt-oss-20b` | 131K | | | | | | $0.03 | $0.13 |
|
|
59
|
-
| `wandb/Qwen/Qwen3.6-35B-A3B` | 262K | | | | | | $0.10 | $0.
|
|
59
|
+
| `wandb/Qwen/Qwen3.6-35B-A3B` | 262K | | | | | | $0.10 | $0.89 |
|
|
60
60
|
| `wandb/Qwen/Qwen3.8-27B` | 262K | | | | | | $0.40 | $3 |
|
|
61
61
|
| `wandb/reflection/Beam-1.0-501B-A23B` | 1.0M | | | | | | $0.30 | $1 |
|
|
62
62
|
| `wandb/zai-org/GLM-5.2` | 1.0M | | | | | | $0.62 | $2 |
|
|
@@ -163,7 +163,6 @@ Direct access to individual AI model providers. Each provider offers unique mode
|
|
|
163
163
|
- [Qiniu](https://mastra.ai/models/providers/qiniu-ai)
|
|
164
164
|
- [Reflection](https://mastra.ai/models/providers/reflection)
|
|
165
165
|
- [Regolo AI](https://mastra.ai/models/providers/regolo-ai)
|
|
166
|
-
- [Requesty](https://mastra.ai/models/providers/requesty)
|
|
167
166
|
- [routing.run](https://mastra.ai/models/providers/routing-run)
|
|
168
167
|
- [RunInfra](https://mastra.ai/models/providers/runinfra)
|
|
169
168
|
- [Sakana AI](https://mastra.ai/models/providers/sakana)
|
|
@@ -507,7 +507,9 @@ Returns: `Promise<ModelAuthStatus>`
|
|
|
507
507
|
|
|
508
508
|
#### `listAvailableModels()`
|
|
509
509
|
|
|
510
|
-
List models from the configured and built-in gateways.
|
|
510
|
+
List models from the configured and built-in gateways. Each model's `useCount` comes from `modelUseCountProvider` when you configure one.
|
|
511
|
+
|
|
512
|
+
The built-in gateways download public catalogs (models.dev and Netlify). A call waits for a catalog only while none has downloaded yet. After that, calls return the last downloaded catalog, including when a download fails. Once it's 5 minutes old, the next call downloads a new one in the background without waiting for it. Configured gateways and API key availability are checked again after 10 seconds.
|
|
511
513
|
|
|
512
514
|
```typescript
|
|
513
515
|
const models = await controller.listAvailableModels()
|
|
@@ -517,7 +519,7 @@ Returns: `Promise<AvailableModel[]>`
|
|
|
517
519
|
|
|
518
520
|
#### `invalidateAvailableModelsCache()`
|
|
519
521
|
|
|
520
|
-
|
|
522
|
+
Make the next `listAvailableModels()` call check configured gateways and API key availability again, and download the models.dev and Netlify catalogs again in the background. Call it after your app stores or removes a credential or changes a custom provider.
|
|
521
523
|
|
|
522
524
|
```typescript
|
|
523
525
|
controller.invalidateAvailableModelsCache()
|
|
@@ -38,7 +38,7 @@ The session is organized into sub-objects, each owning one domain of per-convers
|
|
|
38
38
|
|
|
39
39
|
**mode** (`SessionMode`): Active mode selection. See mode methods below.
|
|
40
40
|
|
|
41
|
-
**model** (`SessionModel`): Active model selection
|
|
41
|
+
**model** (`SessionModel`): Active model selection. One model is persisted per thread and stays active when the session changes modes. See model methods below.
|
|
42
42
|
|
|
43
43
|
**om** (`SessionOM`): Observer and reflector model settings for observational memory.
|
|
44
44
|
|
|
@@ -601,6 +601,8 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
601
601
|
|
|
602
602
|
**requestContextSchema** (`StandardJSONSchemaV1`): Standard JSON Schema for validating request context values. When provided, the context is validated at the start of generate() or stream(), throwing a MastraError if validation fails.
|
|
603
603
|
|
|
604
|
+
**durable** (`boolean | { pubsub?: PubSub; cache?: MastraServerCache | false; shouldCache?: (topic: string) => boolean; cleanupTimeoutMs?: number }`): Publishes each run on its stream topic so another reader can follow it with observe() or reconnect after a disconnect. Omit to turn streams on when the agent is registered on Mastra and off for standalone agents. On a plain agent, pass false to stop publishing. This controls resumable streams only, not checkpoint execution. For durable execution, wrap the agent explicitly with createDurableAgent(). See Resumable streams.
|
|
605
|
+
|
|
604
606
|
**editor** (`false | { instructions?: boolean; tools?: boolean | { description?: boolean }; model?: boolean }`): Controls which fields the editor can override for this code-defined agent. Omit to allow editing instructions and tools. See Editor overrides below.
|
|
605
607
|
|
|
606
608
|
## `generate()` memory options
|
|
@@ -51,7 +51,7 @@ The `channels` property accepts a `ChannelConfig` object with the following fiel
|
|
|
51
51
|
|
|
52
52
|
**threadContext** (`{ maxMessages?: number; addSystemMessage?: boolean }`): How the agent picks up context about the current thread. maxMessages sets how many platform messages are saved to memory on first mention: the thread's first message plus up to maxMessages - 1 recent messages, with an omitted-count marker between them when needed (set to 0 to disable; only applies to non-DM threads). addSystemMessage: false skips the built-in system message that tells the agent which channel/platform a request came from. (Default: `{ maxMessages: 10, addSystemMessage: true }`)
|
|
53
53
|
|
|
54
|
-
**chatOptions** (`Omit<ChatConfig, 'adapters' | 'state' | 'userName'>`): Additional options passed directly to the Chat SDK. Use for advanced configuration such as dedupeTtlMs, fallbackStreamingPlaceholderText, lockScope, and messageHistory.
|
|
54
|
+
**chatOptions** (`Omit<ChatConfig, 'adapters' | 'state' | 'userName'>`): Additional options passed directly to the Chat SDK. Use for advanced configuration such as dedupeTtlMs, fallbackStreamingPlaceholderText, lockScope, and messageHistory. logger defaults to the Mastra logger. Set it to use a different logger or a Chat SDK log level.
|
|
55
55
|
|
|
56
56
|
**resolveResourceId** (`(ctx: ResolveResourceIdContext) => string | Promise<string>`): Decide which resourceId owns resource-level memory for a channel thread, separately from who sent the message. Runs only when a new thread is created; reused threads keep their stored owner and never call the hook. Return ctx.defaultResourceId (${platform}:${message.author.userId}) to keep the built-in behavior.
|
|
57
57
|
|
|
@@ -106,6 +106,8 @@ const agent = new Agent({
|
|
|
106
106
|
|
|
107
107
|
**streaming** (`boolean | { updateIntervalMs?: number }`): Stream agent text deltas to the channel as the agent generates them instead of buffering and posting once per step. Requires the underlying adapter to support post-and-edit streaming. Slack defaults to true; other adapters default to false. (Default: `false (true for Slack)`)
|
|
108
108
|
|
|
109
|
+
**generativeUI** (`boolean`): \*\*Experimental. Slack only; ignored on other adapters.\*\* Gives runs on the Slack adapter a render_card tool. The agent calls it with a json-render spec and the card is posted to the thread as Block Kit. Invalid specs return a list of issues to the agent instead of posting. Requires the optional @json-render/chat package. See Generative UI cards. (Default: `false`)
|
|
110
|
+
|
|
109
111
|
**textFormat** (`'markdown' | 'plain'`): Dialect for the agent's final reply text. 'markdown' (the default) posts replies as markdown: adapters with native markdown rendering (Slack) render it directly, others convert it to their platform format. 'plain' posts replies as literal plain text, restoring the pre-markdown behavior for agents prompted to emit a platform dialect such as Slack mrkdwn. Applies to final reply text only; tool cards, error messages, and tripwire notices are unaffected. Native streaming is always markdown regardless of this setting. (Default: `'markdown'`)
|
|
110
112
|
|
|
111
113
|
**textDisplay** (`'show' | 'hidden'`): Whether the agent's reply text is posted to the channel. 'hidden' never posts reply text, so the agent's own messages reach the channel only through tools you give it, such as a reply tool. Tool display, approval prompts, error messages, and typing status are unaffected, and the text still reaches the agent's stream and memory. (Default: `'show'`)
|
|
@@ -230,6 +232,83 @@ const agent = new Agent({
|
|
|
230
232
|
})
|
|
231
233
|
```
|
|
232
234
|
|
|
235
|
+
## Generative UI cards
|
|
236
|
+
|
|
237
|
+
> **Experimental:** `generativeUI` is experimental and may change in a minor release.
|
|
238
|
+
|
|
239
|
+
Set `generativeUI: true` on the Slack adapter to let the agent post structured cards (status summaries, key/value fields, tables, charts, images, and link buttons) instead of long markdown replies. Install the optional peer first:
|
|
240
|
+
|
|
241
|
+
**npm**:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npm install @json-render/chat
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**pnpm**:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
pnpm add @json-render/chat
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Yarn**:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
yarn add @json-render/chat
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Bun**:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
bun add @json-render/chat
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
`@json-render/chat` requires zod 4, so projects still on zod 3 can't enable `generativeUI` yet.
|
|
266
|
+
|
|
267
|
+
`@mastra/core` loads `@json-render/chat` at runtime, so `mastra build` and `mastra deploy` don't pick it up on their own. Add it to [`bundler.dynamicPackages`](https://mastra.ai/reference/core/mastra-class) so it's included in the build output:
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
import { Mastra } from '@mastra/core'
|
|
271
|
+
import { supportAgent } from './agents/support-agent'
|
|
272
|
+
|
|
273
|
+
export const mastra = new Mastra({
|
|
274
|
+
agents: { supportAgent },
|
|
275
|
+
bundler: { dynamicPackages: ['@json-render/chat'] },
|
|
276
|
+
})
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
import { Agent } from '@mastra/core/agent'
|
|
281
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
282
|
+
|
|
283
|
+
export const supportAgent = new Agent({
|
|
284
|
+
id: 'support-agent',
|
|
285
|
+
name: 'Support Agent',
|
|
286
|
+
instructions: 'You are a helpful support assistant.',
|
|
287
|
+
model: 'openai/gpt-6.1-sol',
|
|
288
|
+
channels: {
|
|
289
|
+
adapters: {
|
|
290
|
+
slack: { adapter: createSlackAdapter(), generativeUI: true },
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
})
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Runs on that adapter get a `render_card` tool whose description lists the available components. The agent passes a flat spec of `{ root, elements }`, where the root element is a `Card`:
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"root": "card",
|
|
301
|
+
"elements": {
|
|
302
|
+
"card": { "type": "Card", "props": { "title": "Deploy status" }, "children": ["fields"] },
|
|
303
|
+
"fields": { "type": "Fields", "children": ["env", "version"] },
|
|
304
|
+
"env": { "type": "Field", "props": { "label": "Environment", "value": "beta" } },
|
|
305
|
+
"version": { "type": "Field", "props": { "label": "Version", "value": "1.8.1" } }
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
The tool returns `{ ok: true, messageId }` once the card is posted. When the spec is invalid or exceeds the platform's limits (on Slack, one table and 100 rows per card), it returns `{ ok: false, issues }` without posting, so the agent can fix the spec and call it again. The tool call itself isn't rendered as a tool card. Interactive buttons aren't available yet. Cards can link out with `LinkButton`.
|
|
311
|
+
|
|
233
312
|
## Custom typing status
|
|
234
313
|
|
|
235
314
|
Pass a function to `typingStatus` to customize the status copy. The function is called once per stream chunk; return a string to set the status, or `false` / `null` / `undefined` to leave the current status unchanged. Return values are de-duplicated so the platform only sees a call when the status changes. When the run ends, any status it set is cleared automatically so runs that finish without posting a message don't leave a stale status on the thread.
|
|
@@ -480,6 +559,43 @@ type InlineLinkEntry =
|
|
|
480
559
|
| { match: string; mimeType: string } // Domain + forced mime type (skips HEAD)
|
|
481
560
|
```
|
|
482
561
|
|
|
562
|
+
## `toChatLogger()`
|
|
563
|
+
|
|
564
|
+
Adapts a Mastra logger to the Chat SDK `Logger` interface. Pass the result to an adapter's `logger` option so its logs go to the same logger as the rest of your app. See [Logging](https://mastra.ai/docs/channels) for when to use it.
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
import { toChatLogger } from '@mastra/core/channels'
|
|
568
|
+
import { createDiscordAdapter } from '@chat-adapter/discord'
|
|
569
|
+
import { PinoLogger } from '@mastra/loggers'
|
|
570
|
+
|
|
571
|
+
const logger = new PinoLogger({ name: 'app', level: 'info' })
|
|
572
|
+
|
|
573
|
+
const discord = createDiscordAdapter({
|
|
574
|
+
logger: toChatLogger(logger, { component: 'discord', minLevel: 'warn' }),
|
|
575
|
+
})
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
**logger** (`IMastraLogger`): The Mastra logger that receives the records.
|
|
579
|
+
|
|
580
|
+
**options** (`ToChatLoggerOptions`): Options for the bridge.
|
|
581
|
+
|
|
582
|
+
**options.minLevel** (`'debug' | 'info' | 'warn' | 'error' | 'silent'`): Lowest level to forward. 'silent' forwards nothing. With the default, the Mastra logger's own level decides what gets written.
|
|
583
|
+
|
|
584
|
+
**options.component** (`string`): Written as the component field on each record. child(prefix) extends it, so chat-sdk becomes chat-sdk:discord.
|
|
585
|
+
|
|
586
|
+
Returns: a Chat SDK `Logger`.
|
|
587
|
+
|
|
588
|
+
Extra log arguments become fields on the record:
|
|
589
|
+
|
|
590
|
+
| Arguments | Fields |
|
|
591
|
+
| -------------------- | -------------------------------- |
|
|
592
|
+
| None | `component` |
|
|
593
|
+
| One `Error` | `error`, `component` |
|
|
594
|
+
| One non-array object | The object's fields, `component` |
|
|
595
|
+
| Anything else | `args`, `component` |
|
|
596
|
+
|
|
597
|
+
An `Error` passed directly or under an object's `error` key is normalized so it keeps its message and stack when serialized.
|
|
598
|
+
|
|
483
599
|
## Related
|
|
484
600
|
|
|
485
601
|
- [Channels overview](https://mastra.ai/docs/channels): Concepts, quickstart, and platform setup
|
|
@@ -41,28 +41,9 @@ const text = await output.text
|
|
|
41
41
|
cleanup()
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
###
|
|
44
|
+
### Plain Agent stream configuration
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
import { Mastra } from '@mastra/core'
|
|
50
|
-
import { Agent } from '@mastra/core/agent'
|
|
51
|
-
|
|
52
|
-
const myAgent = new Agent({
|
|
53
|
-
id: 'my-agent',
|
|
54
|
-
name: 'My Agent',
|
|
55
|
-
instructions: 'You are a helpful assistant',
|
|
56
|
-
model: 'openai/gpt-6.1-sol',
|
|
57
|
-
durable: true, // or: { maxSteps: 10, cleanupTimeoutMs: 60_000 }
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
export const mastra = new Mastra({
|
|
61
|
-
agents: { myAgent },
|
|
62
|
-
})
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
`mastra.getAgent('myAgent')` returns the wrapped `DurableAgent`. Standalone agents (constructed but never registered on a `Mastra` instance) don't become durable. The wrapping is applied at registration.
|
|
46
|
+
The `durable` option on a plain `Agent` controls resumable streams only. It never wraps the agent or enables checkpoints. Use `createDurableAgent({ agent })` explicitly for durable execution, and pass execution options such as `maxSteps` and `shouldPersistSnapshot` to that factory.
|
|
66
47
|
|
|
67
48
|
## `createDurableAgent(options)`
|
|
68
49
|
|
|
@@ -86,7 +67,7 @@ Returns: `DurableAgent`
|
|
|
86
67
|
|
|
87
68
|
**cache** (`MastraServerCache | false`): Cache for stored stream events, which enables resumable streams. If omitted, the agent inherits the cache from the Mastra instance, or uses an InMemoryServerCache. Set to false to disable caching, which makes streams non-resumable.
|
|
88
69
|
|
|
89
|
-
**pubsub** (`PubSub`): PubSub instance for streaming events. (Default: `EventEmitterPubSub`)
|
|
70
|
+
**pubsub** (`PubSub`): PubSub instance for streaming events. Takes precedence over mastra.pubsub. When omitted, a registered agent publishes on mastra.pubsub and an unregistered agent uses an in-process EventEmitterPubSub. (Default: `mastra.pubsub, or EventEmitterPubSub when unregistered`)
|
|
90
71
|
|
|
91
72
|
**maxSteps** (`number`): Maximum number of steps for the agentic loop.
|
|
92
73
|
|
|
@@ -112,7 +93,7 @@ Returns: `EventedAgent` (a subclass of `DurableAgent`)
|
|
|
112
93
|
|
|
113
94
|
**cache** (`MastraServerCache | false`): Cache for stored stream events, which enables resumable streams. If omitted, the agent inherits the cache from the Mastra instance, or uses an InMemoryServerCache. Set to false to disable caching.
|
|
114
95
|
|
|
115
|
-
**pubsub** (`PubSub`): PubSub instance for streaming events. (Default: `EventEmitterPubSub`)
|
|
96
|
+
**pubsub** (`PubSub`): PubSub instance for streaming events. Once the agent is registered, evented run frames use mastra.pubsub instead, because evented steps publish there. (Default: `mastra.pubsub, or EventEmitterPubSub when unregistered`)
|
|
116
97
|
|
|
117
98
|
**maxSteps** (`number`): Maximum number of steps for the agentic loop.
|
|
118
99
|
|
|
@@ -132,7 +113,7 @@ The `DurableAgent` class accepts the same options as `createDurableAgent`, plus
|
|
|
132
113
|
|
|
133
114
|
**cache** (`MastraServerCache | false`): Cache for stored stream events. If omitted, inherits from the Mastra instance or uses an InMemoryServerCache. Set to false to disable caching.
|
|
134
115
|
|
|
135
|
-
**pubsub** (`PubSub`): PubSub instance for streaming events. (Default: `EventEmitterPubSub`)
|
|
116
|
+
**pubsub** (`PubSub`): PubSub instance for streaming events. Takes precedence over mastra.pubsub. When omitted, a registered agent publishes on mastra.pubsub and an unregistered agent uses an in-process EventEmitterPubSub. (Default: `mastra.pubsub, or EventEmitterPubSub when unregistered`)
|
|
136
117
|
|
|
137
118
|
**maxSteps** (`number`): Maximum number of steps for the agentic loop.
|
|
138
119
|
|
|
@@ -195,13 +176,43 @@ const { output } = await durableAgent.observe(runId, {
|
|
|
195
176
|
await output.text
|
|
196
177
|
```
|
|
197
178
|
|
|
198
|
-
The `offset` option is an inclusive, zero-based PubSub event index. It counts every cached event published to the run topic, including lifecycle events, rather than counting chunks.
|
|
179
|
+
The `offset` option is an inclusive, zero-based PubSub event index. It counts every cached event published to the run topic, including lifecycle events, rather than counting chunks. A chunk read from the run log carries the index of its event as `chunk.index`, on `stream()`, `observe()`, and the HTTP `/stream` and `/observe` endpoints. To resume after a dropped connection, pass `index + 1` of the last chunk that has an index, or omit `offset` if nothing arrived. Lifecycle events take an index but produce no chunk, so indexes have gaps and a chunk count isn't a valid offset.
|
|
180
|
+
|
|
181
|
+
Some chunks carry no `index`. The client builds `object` chunks itself rather than reading them from the log. An `abort` chunk is sent beside the `finish` of the same run-log entry, and only the `finish` carries the index, so a client that reconnects between the two gets the `abort` again.
|
|
182
|
+
|
|
183
|
+
A run that used a structuring model publishes its `object-result` to the run log, so that chunk carries an `index` and replays like any other. A core `observe()` caller holding the schema can also rebuild structured output from replayed text, but gets `object-result` only when it replays the text that produced it. HTTP `/observe` replays the log and doesn't rebuild it. To rebuild it after a reconnect, observe without an `offset` and skip chunks whose `index` you already processed. That replay also rebuilds `object` chunks you already received, and they have no `index` to skip by. Each `object` chunk is a snapshot of the object so far, so keep the latest one. Indexes come from the replay cache, so a chunk whose cache write failed, or any chunk when caching is off, has no `index`, so no offset can resume at it. Omitting `offset` replays whatever the transport itself retains, such as a Redis stream, and can repeat chunks you already received. The paragraphs below cover offsets past the end and transports without numeric offsets.
|
|
184
|
+
|
|
185
|
+
`index` is additive and `offset` keeps its meaning, so code that already passes a log position, or replays from `0`, needs no change. Code that passed a count of chunks received should switch to the last `index + 1`.
|
|
186
|
+
|
|
187
|
+
The following example records the resume offset while streaming and passes it to `observe()` after a reconnect:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
let offset: number | undefined
|
|
191
|
+
const { output } = await durableAgent.stream(messages, { runId })
|
|
192
|
+
for await (const chunk of output.fullStream) {
|
|
193
|
+
if (chunk.index === undefined) continue
|
|
194
|
+
offset = chunk.index + 1
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// After a dropped connection:
|
|
198
|
+
const { output: resumed } = await durableAgent.observe(runId, { offset })
|
|
199
|
+
```
|
|
199
200
|
|
|
200
201
|
A non-zero offset can skip earlier events. Aggregated values are built only from chunks delivered to that observer. If the offset skips earlier text deltas, `output.text` is partial and structured output may be incomplete or fail validation or parsing.
|
|
201
202
|
|
|
202
|
-
When the PubSub transport supports numeric offsets,
|
|
203
|
+
When the PubSub transport supports numeric offsets, the observer receives numbered events only when the published index reaches the requested offset. An offset beyond the highest retained index replays nothing and also skips live events with lower indexes.
|
|
204
|
+
|
|
205
|
+
An event without an `index`, such as one whose cache write failed, is delivered as it arrives whatever the offset.
|
|
206
|
+
|
|
207
|
+
If the retained log expires or is cleared and numbering restarts at `0` while an observer is attached, that observer resyncs to the new log and receives its events, including ones below the requested offset. Detection is best effort. If the cache can't be read at that moment, or the new log has numbered past the observer's position before its first event arrives, the observer can miss the restart and skip those events instead. An observer that reconnects after the restart with an offset from the old log can't tell the logs apart and skips the new log's events below that offset, so omit `offset` to replay the new log.
|
|
208
|
+
|
|
209
|
+
On a transport without numeric offset support, such as `RedisStreamsPubSub` with caching off, `observe()` with any offset, including `0`, starts with new live events and doesn't replay retained events. This is the same in core and over HTTP `/observe`. Omit `offset` to replay them. (HTTP `/observe` on a plain `Agent` replays the retained events instead, which can repeat events already received.)
|
|
203
210
|
|
|
204
|
-
|
|
211
|
+
Indexed replay is limited to events still available in the configured cache. The cache has nothing to replay when caching is disabled, `shouldCache` excludes the run topic, or retained events have been cleared. Omitting `offset` then replays only what the transport itself retains, if anything.
|
|
212
|
+
|
|
213
|
+
A failed cache write loses only that event from the cache. It has no `index`, and the events written before and after it still replay when the cache numbers and appends an event in one step. The in-memory and Valkey caches always do. `RedisServerCache` does while Redis scripting works, and switches to two steps when the client has no `eval` or Redis Cluster rejects the script with `CROSSSLOT`. A custom cache that keeps the default `listPushIndexed()` also takes two steps. A two-step cache can leave a gap that makes offset replay skip later events, so replay such a log without an `offset` and skip indexes already processed. Cache replay can't recover an event the cache never stored. A transport that retains it, such as `RedisStreamsPubSub`, can still deliver it without an `index`.
|
|
214
|
+
|
|
215
|
+
An evented agent (`createEventedAgent()`) on a cross-process PubSub, such as Redis Streams, can use the default in-memory server cache when its steps run in the process that started the run. That process numbers the events. Use a shared cache such as `RedisServerCache` on the `Mastra` instance when steps run in another process, such as a dedicated worker started with `workers: true`. That process can't share the in-memory counter, so its events aren't numbered and an offset can't skip them. Mastra logs a warning in the worker when this happens. Also use a shared cache when an observer reconnects through another process, such as a different server replica, because it can't replay from the starting process's in-memory cache.
|
|
205
216
|
|
|
206
217
|
By default `observe()` waits indefinitely for events. If the process running the run stops unexpectedly, the run stops producing events but never emits a completion event, so the observed stream would wait forever. Pass `idleTimeoutMs` to end the stream after a bounded period of silence. Before timing out, `observe()` can consult an optional `isAlive` check. Return `true` while work continues, such as during a long-running tool call or a pause for human input. A `false` result ends the stream with an error, as does omitting `isAlive`. A transient throw from `isAlive` is treated as "still alive", so a momentary check failure never ends a live stream.
|
|
207
218
|
|
|
@@ -257,7 +268,9 @@ const { runId } = await durableAgent.stream('Summarize the document')
|
|
|
257
268
|
durableAgent.abortRunStream(runId)
|
|
258
269
|
```
|
|
259
270
|
|
|
260
|
-
Publishing the abort request over PubSub requires a shared backend in a multi-process deployment, such as [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams). The default `EventEmitterPubSub` only reaches runs in the same process.
|
|
271
|
+
Publishing the abort request over PubSub requires a shared backend in a multi-process deployment, such as [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams). The default `EventEmitterPubSub` only reaches runs in the same process. A run parked on a tool approval is cancelled only in this process: another process sharing the storage can still approve it. To cancel a parked run on every server, call the server's `POST /agents/:agentId/runs/:runId/abort` route, which records the cancellation in storage so a later approval or resume is refused with `409 Conflict` (`AGENT_RESUME_ABORTED_RUN`).
|
|
272
|
+
|
|
273
|
+
`InngestAgent` doesn't implement this method. Cancel an Inngest run with the `abort()` returned by its `stream()`.
|
|
261
274
|
|
|
262
275
|
Stopping a durable run through `abortRunStream()` or `abortThreadStream()` requires `@mastra/core@1.62.0` or later. Earlier versions record the abort without stopping the run.
|
|
263
276
|
|
|
@@ -416,7 +429,7 @@ Model and tool calls after the checkpoint may run again. Make tool side effects
|
|
|
416
429
|
|
|
417
430
|
The server's `POST /agents/:agentId/recover` route returns ownership, already-in-progress, suspended-run, and inactive-run conflicts as `409 Conflict`. An unavailable checkpoint returns `500 Internal Server Error`.
|
|
418
431
|
|
|
419
|
-
**options.force** (`boolean`): Take the run over even while another execution holds it. That execution loses the run and stops, and streams for the run drop the events it still publishes. Its writes are rejected when the storage adapter supports run fencing. (Default: `false`)
|
|
432
|
+
**options.force** (`boolean`): Take the run over even while another execution holds it. That execution loses the run and stops, and streams for the run drop the events it still publishes. Its writes are rejected when the storage adapter supports run fencing. Tools still running in that execution can finish, so the same tool call can run twice. See make tools safe to repeat. (Default: `false`)
|
|
420
433
|
|
|
421
434
|
Returns: [`Promise<DurableAgentStreamResult>`](#durableagentstreamresult)
|
|
422
435
|
|
|
@@ -10,9 +10,9 @@ Use [`handleChatStream()`](https://mastra.ai/reference/ai-sdk/handle-chat-stream
|
|
|
10
10
|
|
|
11
11
|
`chatRoute()` keeps the existing AI SDK v5/default behavior. If your app is typed against AI SDK v6, pass `version: 'v6'`.
|
|
12
12
|
|
|
13
|
-
> **Disconnect behavior:** `chatRoute()` forwards the incoming request's `AbortSignal` to `agent.stream()`. If the client disconnects, Mastra aborts the in-flight generation.
|
|
13
|
+
> **Disconnect behavior:** By default, `chatRoute()` forwards the incoming request's `AbortSignal` to `agent.stream()`. If the client disconnects, Mastra aborts the in-flight generation.
|
|
14
14
|
>
|
|
15
|
-
>
|
|
15
|
+
> Set `resumable: true` to let the generation continue after a disconnect and allow AI SDK UI to reconnect to the active stream. Resumable chats don't support abort-based cancellation because `useChat().stop()` is indistinguishable from a refresh or network interruption at the server.
|
|
16
16
|
|
|
17
17
|
## Usage example
|
|
18
18
|
|
|
@@ -61,6 +61,8 @@ export const mastra = new Mastra({
|
|
|
61
61
|
|
|
62
62
|
**agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass { versionId: '\<id>' } to target an exact version, or { status: 'draft' } / { status: 'published' } to resolve by status. When the route is called, query parameters ?versionId=\<id> or ?status=draft|published take precedence over this static value. Requires the Editor to be configured.
|
|
63
63
|
|
|
64
|
+
**resumable** (`boolean`): Enables AI SDK UI stream resumption. Returns the POST route and a GET \<path>/:chatId/stream route, uses the AI SDK chat ID as the Mastra thread ID, and lets generation continue after the POST connection closes. (Default: `false`)
|
|
65
|
+
|
|
64
66
|
**defaultOptions** (`AgentExecutionOptions`): Default options passed to agent execution. These can include instructions, memory configuration, maxSteps, and other execution settings.
|
|
65
67
|
|
|
66
68
|
**sendStart** (`boolean`): Whether to send start events in the stream. (Default: `true`)
|
|
@@ -77,6 +79,35 @@ export const mastra = new Mastra({
|
|
|
77
79
|
|
|
78
80
|
**heartbeatMs** (`number`): Interval in milliseconds for SSE heartbeats that keep connections active through infrastructure with idle timeouts.
|
|
79
81
|
|
|
82
|
+
## Resumable streams
|
|
83
|
+
|
|
84
|
+
Set `resumable: true` on `chatRoute()` and `resume: true` on AI SDK UI's `useChat()` to reconnect after a refresh or network interruption. The route factory returns a two-item array containing:
|
|
85
|
+
|
|
86
|
+
- `POST <path>`: Starts the agent run. The request's AI SDK chat ID becomes the Mastra memory thread ID.
|
|
87
|
+
- `GET <path>/:chatId/stream`: Replays cached events and follows the active run. The route returns `204` when the run is finished, unavailable, expired, or outside the caller's scope.
|
|
88
|
+
|
|
89
|
+
Pass the returned array as one entry in `server.apiRoutes`. Mastra flattens nested route arrays during server configuration.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { Mastra } from '@mastra/core'
|
|
93
|
+
import { chatRoute } from '@mastra/ai-sdk'
|
|
94
|
+
|
|
95
|
+
export const mastra = new Mastra({
|
|
96
|
+
server: {
|
|
97
|
+
apiRoutes: [
|
|
98
|
+
chatRoute({
|
|
99
|
+
path: '/chat/:agentId',
|
|
100
|
+
resumable: true,
|
|
101
|
+
}),
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Active-run discovery is process-local. A reconnect request must reach the same running server process that started the generation. Resumable mode doesn't forward the request `AbortSignal`, so `useChat().stop()` closes the client connection without cancelling the agent run.
|
|
108
|
+
|
|
109
|
+
If the chat uses a resource ID, set `MASTRA_RESOURCE_ID_KEY` in the request context through authentication middleware. Don't send the resource ID only as `memory.resource` in the POST body: the reconnecting GET request has no body, so `chatRoute()` rejects that configuration with `400`.
|
|
110
|
+
|
|
80
111
|
## Additional configuration
|
|
81
112
|
|
|
82
113
|
You can use [`prepareSendMessagesRequest`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#transport.default-chat-transport.prepare-send-messages-request) to customize the request sent to the chat route, for example to pass additional configuration to the agent:
|