@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404184540 → 0.0.0-studio-cli-20260504022012

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.
Files changed (281) hide show
  1. package/.docs/docs/agents/adding-voice.md +18 -17
  2. package/.docs/docs/agents/background-tasks.md +242 -0
  3. package/.docs/docs/agents/channels.md +2 -1
  4. package/.docs/docs/agents/overview.md +4 -0
  5. package/.docs/docs/agents/processors.md +177 -5
  6. package/.docs/docs/agents/structured-output.md +66 -1
  7. package/.docs/docs/agents/supervisor-agents.md +65 -0
  8. package/.docs/docs/agents/using-tools.md +73 -0
  9. package/.docs/docs/browser/agent-browser.md +78 -0
  10. package/.docs/docs/browser/browser-viewer.md +144 -0
  11. package/.docs/docs/browser/overview.md +168 -0
  12. package/.docs/docs/browser/stagehand.md +129 -0
  13. package/.docs/docs/deployment/cloud-providers.md +5 -1
  14. package/.docs/docs/deployment/mastra-server.md +4 -4
  15. package/.docs/docs/deployment/monorepo.md +3 -3
  16. package/.docs/docs/deployment/overview.md +11 -8
  17. package/.docs/docs/editor/overview.md +290 -0
  18. package/.docs/docs/editor/prompts.md +134 -0
  19. package/.docs/docs/editor/tools.md +152 -0
  20. package/.docs/docs/evals/custom-scorers.md +63 -3
  21. package/.docs/docs/evals/datasets/overview.md +1 -1
  22. package/.docs/docs/index.md +2 -2
  23. package/.docs/docs/mastra-platform/configuration.md +36 -0
  24. package/.docs/docs/mastra-platform/overview.md +78 -0
  25. package/.docs/docs/mcp/overview.md +17 -0
  26. package/.docs/docs/memory/memory-processors.md +3 -3
  27. package/.docs/docs/memory/message-history.md +8 -2
  28. package/.docs/docs/memory/observational-memory.md +65 -8
  29. package/.docs/docs/memory/storage.md +1 -2
  30. package/.docs/docs/memory/working-memory.md +2 -2
  31. package/.docs/docs/observability/logging.md +1 -1
  32. package/.docs/docs/observability/metrics/overview.md +2 -2
  33. package/.docs/docs/observability/overview.md +1 -1
  34. package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
  35. package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
  36. package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
  37. package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
  38. package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
  39. package/.docs/docs/observability/tracing/exporters/default.md +5 -5
  40. package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
  41. package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
  42. package/.docs/docs/observability/tracing/overview.md +87 -20
  43. package/.docs/docs/server/custom-adapters.md +5 -5
  44. package/.docs/docs/server/custom-api-routes.md +3 -3
  45. package/.docs/docs/server/middleware.md +46 -42
  46. package/.docs/docs/server/request-context.md +13 -2
  47. package/.docs/docs/server/server-adapters.md +91 -8
  48. package/.docs/docs/streaming/background-task-streaming.md +80 -0
  49. package/.docs/docs/streaming/overview.md +3 -0
  50. package/.docs/docs/studio/deployment.md +24 -6
  51. package/.docs/docs/studio/observability.md +1 -1
  52. package/.docs/docs/studio/overview.md +4 -4
  53. package/.docs/docs/voice/overview.md +74 -5
  54. package/.docs/docs/voice/speech-to-speech.md +45 -1
  55. package/.docs/docs/voice/speech-to-text.md +7 -7
  56. package/.docs/docs/voice/text-to-speech.md +10 -10
  57. package/.docs/docs/workflows/agents-and-tools.md +1 -1
  58. package/.docs/docs/workflows/overview.md +105 -4
  59. package/.docs/docs/workflows/scheduled-workflows.md +181 -0
  60. package/.docs/docs/workspace/filesystem.md +64 -6
  61. package/.docs/docs/workspace/lsp.md +76 -4
  62. package/.docs/docs/workspace/overview.md +27 -8
  63. package/.docs/docs/workspace/sandbox.md +3 -1
  64. package/.docs/docs/workspace/search.md +41 -2
  65. package/.docs/docs/workspace/skills.md +19 -19
  66. package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
  67. package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
  68. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  69. package/.docs/guides/deployment/mastra-platform.md +191 -0
  70. package/.docs/guides/deployment/netlify.md +16 -1
  71. package/.docs/guides/getting-started/nestjs.md +238 -0
  72. package/.docs/guides/getting-started/next-js.md +0 -4
  73. package/.docs/guides/guide/code-review-bot.md +2 -2
  74. package/.docs/guides/guide/dev-assistant.md +4 -4
  75. package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
  76. package/.docs/guides/guide/slack-assistant.md +191 -0
  77. package/.docs/guides/migrations/mastra-cloud.md +368 -0
  78. package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
  79. package/.docs/models/embeddings.md +3 -3
  80. package/.docs/models/gateways/azure-openai.md +74 -35
  81. package/.docs/models/gateways/mastra.md +64 -0
  82. package/.docs/models/gateways/netlify.md +7 -3
  83. package/.docs/models/gateways/openrouter.md +28 -12
  84. package/.docs/models/gateways/vercel.md +16 -1
  85. package/.docs/models/gateways.md +1 -0
  86. package/.docs/models/index.md +43 -8
  87. package/.docs/models/providers/302ai.md +37 -4
  88. package/.docs/models/providers/abliteration-ai.md +71 -0
  89. package/.docs/models/providers/alibaba-cn.md +7 -2
  90. package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
  91. package/.docs/models/providers/alibaba-coding-plan.md +3 -2
  92. package/.docs/models/providers/alibaba.md +8 -1
  93. package/.docs/models/providers/anthropic.md +18 -5
  94. package/.docs/models/providers/baseten.md +3 -1
  95. package/.docs/models/providers/berget.md +10 -12
  96. package/.docs/models/providers/chutes.md +4 -2
  97. package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
  98. package/.docs/models/providers/cortecs.md +22 -2
  99. package/.docs/models/providers/deepinfra.md +8 -2
  100. package/.docs/models/providers/deepseek.md +6 -4
  101. package/.docs/models/providers/digitalocean.md +133 -0
  102. package/.docs/models/providers/fireworks-ai.md +6 -1
  103. package/.docs/models/providers/firmware.md +12 -10
  104. package/.docs/models/providers/friendli.md +6 -7
  105. package/.docs/models/providers/google.md +8 -4
  106. package/.docs/models/providers/helicone.md +1 -2
  107. package/.docs/models/providers/hpc-ai.md +73 -0
  108. package/.docs/models/providers/huggingface.md +6 -2
  109. package/.docs/models/providers/inception.md +9 -11
  110. package/.docs/models/providers/kilo.md +359 -339
  111. package/.docs/models/providers/kimi-for-coding.md +2 -1
  112. package/.docs/models/providers/llmgateway.md +67 -77
  113. package/.docs/models/providers/mistral.md +3 -2
  114. package/.docs/models/providers/mixlayer.md +75 -0
  115. package/.docs/models/providers/moonshotai-cn.md +3 -2
  116. package/.docs/models/providers/moonshotai.md +3 -2
  117. package/.docs/models/providers/nano-gpt.md +8 -2
  118. package/.docs/models/providers/neuralwatt.md +84 -0
  119. package/.docs/models/providers/novita-ai.md +19 -4
  120. package/.docs/models/providers/nvidia.md +8 -1
  121. package/.docs/models/providers/ollama-cloud.md +7 -2
  122. package/.docs/models/providers/openai.md +7 -2
  123. package/.docs/models/providers/opencode-go.md +21 -13
  124. package/.docs/models/providers/opencode.md +11 -4
  125. package/.docs/models/providers/ovhcloud.md +6 -8
  126. package/.docs/models/providers/poe.md +10 -15
  127. package/.docs/models/providers/regolo-ai.md +83 -0
  128. package/.docs/models/providers/siliconflow-cn.md +5 -2
  129. package/.docs/models/providers/siliconflow.md +6 -3
  130. package/.docs/models/providers/stepfun.md +8 -7
  131. package/.docs/models/providers/synthetic.md +5 -2
  132. package/.docs/models/providers/tencent-token-plan.md +71 -0
  133. package/.docs/models/providers/tencent-tokenhub.md +71 -0
  134. package/.docs/models/providers/togetherai.md +8 -7
  135. package/.docs/models/providers/vivgrid.md +7 -3
  136. package/.docs/models/providers/vultr.md +7 -6
  137. package/.docs/models/providers/wafer.ai.md +73 -0
  138. package/.docs/models/providers/wandb.md +3 -2
  139. package/.docs/models/providers/xai.md +6 -1
  140. package/.docs/models/providers/xiaomi-token-plan-ams.md +9 -7
  141. package/.docs/models/providers/xiaomi-token-plan-cn.md +9 -7
  142. package/.docs/models/providers/xiaomi-token-plan-sgp.md +9 -7
  143. package/.docs/models/providers/xiaomi.md +4 -2
  144. package/.docs/models/providers/zai-coding-plan.md +11 -19
  145. package/.docs/models/providers/zai.md +2 -1
  146. package/.docs/models/providers/zenmux.md +13 -5
  147. package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
  148. package/.docs/models/providers/zhipuai.md +2 -1
  149. package/.docs/models/providers.md +8 -0
  150. package/.docs/reference/agents/agent.md +1 -1
  151. package/.docs/reference/agents/channels.md +3 -3
  152. package/.docs/reference/agents/generate.md +88 -6
  153. package/.docs/reference/agents/generateLegacy.md +1 -1
  154. package/.docs/reference/ai-sdk/chat-route.md +2 -0
  155. package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
  156. package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
  157. package/.docs/reference/ai-sdk/network-route.md +2 -0
  158. package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
  159. package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
  160. package/.docs/reference/browser/agent-browser.md +375 -0
  161. package/.docs/reference/browser/browser-viewer.md +228 -0
  162. package/.docs/reference/browser/mastra-browser.md +286 -0
  163. package/.docs/reference/browser/stagehand-browser.md +286 -0
  164. package/.docs/reference/cli/mastra.md +703 -0
  165. package/.docs/reference/client-js/agents.md +166 -0
  166. package/.docs/reference/client-js/mastra-client.md +23 -0
  167. package/.docs/reference/client-js/observability.md +2 -2
  168. package/.docs/reference/client-js/workflows.md +62 -1
  169. package/.docs/reference/configuration.md +67 -1
  170. package/.docs/reference/core/addGateway.md +5 -5
  171. package/.docs/reference/core/getEditor.md +35 -0
  172. package/.docs/reference/core/getGateway.md +5 -5
  173. package/.docs/reference/core/getGatewayById.md +5 -5
  174. package/.docs/reference/core/getMCPServer.md +2 -2
  175. package/.docs/reference/core/getMCPServerById.md +2 -2
  176. package/.docs/reference/core/getScorer.md +3 -3
  177. package/.docs/reference/core/getScorerById.md +3 -3
  178. package/.docs/reference/core/listGateways.md +5 -5
  179. package/.docs/reference/core/listMCPServers.md +2 -2
  180. package/.docs/reference/core/listScorers.md +3 -3
  181. package/.docs/reference/core/mastra-class.md +11 -1
  182. package/.docs/reference/core/mastra-model-gateway.md +5 -5
  183. package/.docs/reference/datasets/create.md +4 -4
  184. package/.docs/reference/datasets/startExperiment.md +28 -2
  185. package/.docs/reference/datasets/update.md +4 -4
  186. package/.docs/reference/deployer/cloudflare.md +14 -1
  187. package/.docs/reference/deployer/netlify.md +50 -2
  188. package/.docs/reference/editor/mastra-editor.md +168 -0
  189. package/.docs/reference/editor/tool-provider.md +85 -0
  190. package/.docs/reference/evals/context-precision.md +3 -3
  191. package/.docs/reference/evals/context-relevance.md +3 -3
  192. package/.docs/reference/evals/create-scorer.md +5 -3
  193. package/.docs/reference/evals/filter-run.md +117 -0
  194. package/.docs/reference/evals/mastra-scorer.md +4 -4
  195. package/.docs/reference/evals/noise-sensitivity.md +6 -6
  196. package/.docs/reference/evals/prompt-alignment.md +12 -12
  197. package/.docs/reference/evals/run-evals.md +6 -6
  198. package/.docs/reference/evals/scorer-utils.md +3 -3
  199. package/.docs/reference/evals/trajectory-accuracy.md +3 -3
  200. package/.docs/reference/harness/harness-class.md +152 -53
  201. package/.docs/reference/index.md +25 -0
  202. package/.docs/reference/logging/pino-logger.md +0 -2
  203. package/.docs/reference/mastra-platform/api.md +108 -0
  204. package/.docs/reference/memory/clone-utilities.md +4 -2
  205. package/.docs/reference/memory/cloneThread.md +4 -2
  206. package/.docs/reference/memory/observational-memory.md +4 -0
  207. package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
  208. package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
  209. package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
  210. package/.docs/reference/observability/tracing/configuration.md +18 -11
  211. package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
  212. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
  213. package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
  214. package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
  215. package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
  216. package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
  217. package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
  218. package/.docs/reference/observability/tracing/instances.md +7 -7
  219. package/.docs/reference/observability/tracing/interfaces.md +23 -6
  220. package/.docs/reference/observability/tracing/span-filtering.md +95 -0
  221. package/.docs/reference/observability/tracing/spans.md +6 -6
  222. package/.docs/reference/processors/prefill-error-handler.md +70 -0
  223. package/.docs/reference/processors/processor-interface.md +400 -40
  224. package/.docs/reference/processors/skill-search-processor.md +20 -1
  225. package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
  226. package/.docs/reference/processors/tool-call-filter.md +23 -0
  227. package/.docs/reference/server/create-route.md +3 -3
  228. package/.docs/reference/server/express-adapter.md +4 -4
  229. package/.docs/reference/server/fastify-adapter.md +4 -4
  230. package/.docs/reference/server/hono-adapter.md +4 -4
  231. package/.docs/reference/server/koa-adapter.md +4 -4
  232. package/.docs/reference/server/mastra-server.md +3 -3
  233. package/.docs/reference/server/nestjs-adapter.md +169 -0
  234. package/.docs/reference/server/register-api-route.md +4 -4
  235. package/.docs/reference/server/routes.md +11 -10
  236. package/.docs/reference/storage/clickhouse.md +300 -0
  237. package/.docs/reference/storage/cloudflare-d1.md +42 -42
  238. package/.docs/reference/storage/composite.md +5 -3
  239. package/.docs/reference/storage/duckdb.md +150 -0
  240. package/.docs/reference/storage/overview.md +1 -1
  241. package/.docs/reference/storage/redis.md +266 -0
  242. package/.docs/reference/streaming/ChunkType.md +143 -3
  243. package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
  244. package/.docs/reference/streaming/agents/stream.md +10 -2
  245. package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
  246. package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
  247. package/.docs/reference/templates/overview.md +88 -14
  248. package/.docs/reference/tools/create-tool.md +107 -5
  249. package/.docs/reference/tools/mcp-client.md +45 -0
  250. package/.docs/reference/tools/mcp-server.md +1 -3
  251. package/.docs/reference/tools/perplexity.md +155 -0
  252. package/.docs/reference/tools/tavily.md +307 -0
  253. package/.docs/reference/vectors/mongodb.md +0 -2
  254. package/.docs/reference/voice/aws-nova-sonic.md +247 -0
  255. package/.docs/reference/voice/cloudflare.md +3 -3
  256. package/.docs/reference/voice/sarvam.md +29 -23
  257. package/.docs/reference/voice/voice.connect.md +4 -4
  258. package/.docs/reference/voice/voice.listen.md +3 -3
  259. package/.docs/reference/workflows/run-methods/resume.md +24 -0
  260. package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
  261. package/.docs/reference/workflows/step.md +88 -7
  262. package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
  263. package/.docs/reference/workflows/workflow.md +88 -4
  264. package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
  265. package/.docs/reference/workspace/docker-sandbox.md +196 -0
  266. package/.docs/reference/workspace/gcs-filesystem.md +1 -0
  267. package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
  268. package/.docs/reference/workspace/modal-sandbox.md +168 -0
  269. package/.docs/reference/workspace/process-manager.md +1 -1
  270. package/.docs/reference/workspace/s3-filesystem.md +80 -5
  271. package/.docs/reference/workspace/vercel.md +1 -1
  272. package/.docs/reference/workspace/workspace-class.md +37 -6
  273. package/CHANGELOG.md +486 -4
  274. package/dist/stdio.js.map +1 -1
  275. package/dist/utils.d.ts +1 -4
  276. package/dist/utils.d.ts.map +1 -1
  277. package/package.json +11 -11
  278. package/.docs/docs/mastra-cloud/deployment.md +0 -77
  279. package/.docs/docs/mastra-cloud/observability.md +0 -38
  280. package/.docs/docs/mastra-cloud/overview.md +0 -23
  281. package/.docs/docs/mastra-cloud/setup.md +0 -42
@@ -0,0 +1,266 @@
1
+ # Redis Storage
2
+
3
+ The Redis storage implementation provides a high-performance storage solution using direct Redis connections via [node-redis](https://github.com/redis/node-redis) (the official Redis client for Node.js). It supports standalone Redis, and through custom client configuration, Redis Sentinel and Cluster deployments.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/redis
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Using Connection String
14
+
15
+ ```typescript
16
+ import { RedisStore } from '@mastra/redis'
17
+
18
+ const storage = new RedisStore({
19
+ id: 'redis-storage',
20
+ connectionString: 'redis://localhost:6379',
21
+ })
22
+
23
+ await storage.init()
24
+ ```
25
+
26
+ ### Using Host/Port Configuration
27
+
28
+ ```typescript
29
+ import { RedisStore } from '@mastra/redis'
30
+
31
+ const storage = new RedisStore({
32
+ id: 'redis-storage',
33
+ host: 'localhost',
34
+ port: 6379,
35
+ password: 'your-password',
36
+ db: 0,
37
+ })
38
+
39
+ await storage.init()
40
+ ```
41
+
42
+ ### Using Pre-configured Client
43
+
44
+ For advanced configurations like Sentinel or Cluster, you can pass a pre-configured redis client:
45
+
46
+ ```typescript
47
+ import { RedisStore } from '@mastra/redis'
48
+ import { createClient } from 'redis'
49
+
50
+ const client = createClient({
51
+ url: 'redis://localhost:6379',
52
+ socket: {
53
+ reconnectStrategy: retries => Math.min(retries * 50, 2000),
54
+ },
55
+ })
56
+
57
+ // Connect the client before passing to RedisStore
58
+ await client.connect()
59
+
60
+ const storage = new RedisStore({
61
+ id: 'redis-storage',
62
+ client,
63
+ })
64
+ ```
65
+
66
+ ## Parameters
67
+
68
+ **id** (`string`): Unique identifier for the storage instance
69
+
70
+ **connectionString** (`string`): Redis connection URL (e.g., \`redis\://localhost:6379\` or \`redis\://:password\@localhost:6379\`)
71
+
72
+ **host** (`string`): Redis host address
73
+
74
+ **port** (`number`): Redis port number (Default: `6379`)
75
+
76
+ **password** (`string`): Redis password for authentication
77
+
78
+ **db** (`number`): Redis database number (Default: `0`)
79
+
80
+ **client** (`RedisClient`): Pre-configured redis client (from the \`redis\` package) for advanced setups
81
+
82
+ > **Note:** You must provide either `connectionString`, `host`, or `client`. These options are mutually exclusive.
83
+
84
+ ## Additional Notes
85
+
86
+ ### Key Structure
87
+
88
+ The Redis storage implementation uses the following key patterns:
89
+
90
+ - Threads: `mastra_threads:id:{threadId}`
91
+ - Messages: `mastra_messages:threadId:{threadId}:id:{messageId}`
92
+ - Message index: `msg-idx:{messageId}` (for fast lookups)
93
+ - Thread messages sorted set: `thread:{threadId}:messages`
94
+ - Workflow snapshots: `mastra_workflow_snapshot:namespace:{ns}:workflow_name:{name}:run_id:{id}`
95
+ - Scores: `mastra_scorers:id:{scoreId}`
96
+ - Resources: `mastra_resources:{resourceId}`
97
+
98
+ ### Redis Sentinel
99
+
100
+ For high-availability deployments using Redis Sentinel, create a custom client:
101
+
102
+ ```typescript
103
+ import { RedisStore } from '@mastra/redis'
104
+ import { createClient } from 'redis'
105
+
106
+ const client = createClient({
107
+ url: 'redis://sentinel-host:26379',
108
+ // Configure sentinel options as needed for your setup
109
+ })
110
+
111
+ await client.connect()
112
+
113
+ const storage = new RedisStore({
114
+ id: 'redis-sentinel-storage',
115
+ client,
116
+ })
117
+ ```
118
+
119
+ ### Redis Cluster
120
+
121
+ For Redis Cluster deployments, use the cluster client:
122
+
123
+ ```typescript
124
+ import { RedisStore } from '@mastra/redis'
125
+ import { createCluster } from 'redis'
126
+
127
+ const cluster = createCluster({
128
+ rootNodes: [
129
+ { url: 'redis://node-1:6379' },
130
+ { url: 'redis://node-2:6379' },
131
+ { url: 'redis://node-3:6379' },
132
+ ],
133
+ })
134
+
135
+ await cluster.connect()
136
+
137
+ const storage = new RedisStore({
138
+ id: 'redis-cluster-storage',
139
+ client: cluster,
140
+ })
141
+ ```
142
+
143
+ ### Accessing the Underlying Client
144
+
145
+ You can access the underlying redis client for custom operations:
146
+
147
+ ```typescript
148
+ const storage = new RedisStore({
149
+ id: 'redis-storage',
150
+ connectionString: 'redis://localhost:6379',
151
+ })
152
+
153
+ await storage.init()
154
+
155
+ const client = storage.getClient()
156
+
157
+ // Custom Redis operations
158
+ await client.set('custom-key', 'value')
159
+ const value = await client.get('custom-key')
160
+ ```
161
+
162
+ ### Closing Connections
163
+
164
+ When shutting down your application, close the Redis connection:
165
+
166
+ ```typescript
167
+ await storage.close()
168
+ ```
169
+
170
+ ## Usage Example
171
+
172
+ ### Adding memory to an agent
173
+
174
+ ```typescript
175
+ import { Memory } from '@mastra/memory'
176
+ import { Agent } from '@mastra/core/agent'
177
+ import { RedisStore } from '@mastra/redis'
178
+
179
+ export const redisAgent = new Agent({
180
+ id: 'redis-agent',
181
+ name: 'Redis Agent',
182
+ instructions:
183
+ 'You are an AI agent with the ability to automatically recall memories from previous interactions.',
184
+ model: 'openai/gpt-4o',
185
+ memory: new Memory({
186
+ storage: new RedisStore({
187
+ id: 'redis-agent-storage',
188
+ connectionString: process.env.REDIS_URL!,
189
+ }),
190
+ options: {
191
+ lastMessages: 10,
192
+ },
193
+ }),
194
+ })
195
+ ```
196
+
197
+ ### Using the agent
198
+
199
+ ```typescript
200
+ import 'dotenv/config'
201
+
202
+ import { mastra } from './mastra'
203
+
204
+ const threadId = '123'
205
+ const resourceId = 'user-456'
206
+
207
+ const agent = mastra.getAgent('redisAgent')
208
+
209
+ const message = await agent.stream('My name is Mastra', {
210
+ memory: {
211
+ thread: threadId,
212
+ resource: resourceId,
213
+ },
214
+ })
215
+
216
+ await message.textStream.pipeTo(new WritableStream())
217
+
218
+ const stream = await agent.stream("What's my name?", {
219
+ memory: {
220
+ thread: threadId,
221
+ resource: resourceId,
222
+ },
223
+ memoryOptions: {
224
+ lastMessages: 5,
225
+ },
226
+ })
227
+
228
+ for await (const chunk of stream.textStream) {
229
+ process.stdout.write(chunk)
230
+ }
231
+ ```
232
+
233
+ ### Using with Mastra instance
234
+
235
+ ```typescript
236
+ import { Mastra } from '@mastra/core'
237
+ import { RedisStore } from '@mastra/redis'
238
+
239
+ const storage = new RedisStore({
240
+ id: 'mastra-storage',
241
+ host: 'localhost',
242
+ port: 6379,
243
+ })
244
+
245
+ const mastra = new Mastra({
246
+ storage, // init() called automatically
247
+ })
248
+ ```
249
+
250
+ If using storage directly without Mastra, call `init()` explicitly:
251
+
252
+ ```typescript
253
+ import { RedisStore } from '@mastra/redis'
254
+
255
+ const storage = new RedisStore({
256
+ id: 'redis-storage',
257
+ host: 'localhost',
258
+ port: 6379,
259
+ })
260
+
261
+ await storage.init()
262
+
263
+ // Access domain-specific stores via getStore()
264
+ const memoryStore = await storage.getStore('memory')
265
+ const thread = await memoryStore?.getThreadById({ threadId: '...' })
266
+ ```
@@ -398,6 +398,146 @@ Contains output from workflow step execution, used primarily for usage tracking
398
398
 
399
399
  **payload.output** (`ChunkType`): Nested chunk data from step execution, typically containing finish events or other step results
400
400
 
401
+ ## Background task chunks
402
+
403
+ Emitted when a tool call is dispatched as a [background task](https://mastra.ai/docs/agents/background-tasks) and `streamUntilIdle()` is used.
404
+
405
+ ### background-task-started
406
+
407
+ Emitted when a tool call is enqueued as a background task and assigned a `taskId`.
408
+
409
+ **type** (`"background-task-started"`): Chunk type identifier
410
+
411
+ **payload** (`BackgroundTaskStartedPayload`): Identifies the newly enqueued task
412
+
413
+ **payload.taskId** (`string`): Unique identifier for the background task
414
+
415
+ **payload.toolName** (`string`): Name of the tool being executed
416
+
417
+ **payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
418
+
419
+ ### background-task-running
420
+
421
+ Emitted when a worker picks up the task and execution begins.
422
+
423
+ **type** (`"background-task-running"`): Chunk type identifier
424
+
425
+ **payload** (`BackgroundTaskRunningPayload`): Details about the running task
426
+
427
+ **payload.taskId** (`string`): Unique identifier for the background task
428
+
429
+ **payload.toolName** (`string`): Name of the tool being executed
430
+
431
+ **payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
432
+
433
+ **payload.runId** (`string`): Run ID of the agent that dispatched the task
434
+
435
+ **payload.agentId** (`string`): ID of the agent that dispatched the task
436
+
437
+ **payload.startedAt** (`Date`): Timestamp at which execution started
438
+
439
+ **payload.args** (`Record<string, unknown>`): Arguments passed to the tool's execute function
440
+
441
+ ### background-task-progress
442
+
443
+ Periodic snapshot of how many background tasks are currently running across the agent.
444
+
445
+ **type** (`"background-task-progress"`): Chunk type identifier
446
+
447
+ **payload** (`BackgroundTaskProgressPayload`): Aggregate progress for all running tasks
448
+
449
+ **payload.taskIds** (`string[]`): IDs of all currently running background tasks
450
+
451
+ **payload.runningCount** (`number`): Number of background tasks currently running
452
+
453
+ **payload.elapsedMs** (`number`): Milliseconds elapsed since the agent run started
454
+
455
+ ### background-task-output
456
+
457
+ A streamed output chunk emitted by the task's `execute` function. Wraps an inner [`tool-output`](#tool-output) chunk.
458
+
459
+ **type** (`"background-task-output"`): Chunk type identifier
460
+
461
+ **payload** (`BackgroundTaskOutputPayload`): Streamed output from the running task
462
+
463
+ **payload.taskId** (`string`): Unique identifier for the background task
464
+
465
+ **payload.toolName** (`string`): Name of the tool being executed
466
+
467
+ **payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
468
+
469
+ **payload.runId** (`string`): Run ID of the agent that dispatched the task
470
+
471
+ **payload.agentId** (`string`): ID of the agent that dispatched the task
472
+
473
+ **payload.payload** (`ToolOutputChunk`): Inner tool-output chunk produced by the task
474
+
475
+ ### background-task-completed
476
+
477
+ Emitted when the task finishes successfully. Triggers a continuation turn when consumed by [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle).
478
+
479
+ **type** (`"background-task-completed"`): Chunk type identifier
480
+
481
+ **payload** (`BackgroundTaskResultPayload`): The completed task's result
482
+
483
+ **payload.taskId** (`string`): Unique identifier for the background task
484
+
485
+ **payload.toolName** (`string`): Name of the tool that was executed
486
+
487
+ **payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
488
+
489
+ **payload.agentId** (`string`): ID of the agent that dispatched the task
490
+
491
+ **payload.runId** (`string`): Run ID of the agent that dispatched the task
492
+
493
+ **payload.result** (`unknown`): The tool's resolved return value
494
+
495
+ **payload.completedAt** (`Date`): Timestamp at which the task completed
496
+
497
+ **payload.isError** (`boolean`): True when the tool returned an error result rather than throwing
498
+
499
+ ### background-task-failed
500
+
501
+ Emitted when the task throws or times out. Triggers a continuation turn when consumed by [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle).
502
+
503
+ **type** (`"background-task-failed"`): Chunk type identifier
504
+
505
+ **payload** (`BackgroundTaskFailedPayload`): Failure details for the task
506
+
507
+ **payload.taskId** (`string`): Unique identifier for the background task
508
+
509
+ **payload.toolName** (`string`): Name of the tool that was executed
510
+
511
+ **payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
512
+
513
+ **payload.runId** (`string`): Run ID of the agent that dispatched the task
514
+
515
+ **payload.agentId** (`string`): ID of the agent that dispatched the task
516
+
517
+ **payload.error** (`{ message: string }`): Error details thrown by the task
518
+
519
+ **payload.completedAt** (`Date`): Timestamp at which the task failed
520
+
521
+ ### background-task-cancelled
522
+
523
+ Emitted when the task is cancelled before completing. Triggers a continuation turn when consumed by [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle).
524
+
525
+ **type** (`"background-task-cancelled"`): Chunk type identifier
526
+
527
+ **payload** (`BackgroundTaskCancelledPayload`): Cancellation details for the task
528
+
529
+ **payload.taskId** (`string`): Unique identifier for the background task
530
+
531
+ **payload.toolName** (`string`): Name of the tool that was executed
532
+
533
+ **payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
534
+
535
+ **payload.runId** (`string`): Run ID of the agent that dispatched the task
536
+
537
+ **payload.agentId** (`string`): ID of the agent that dispatched the task
538
+
539
+ **payload.completedAt** (`Date`): Timestamp at which the task was cancelled
540
+
401
541
  ## Metadata and special chunks
402
542
 
403
543
  ### response-metadata
@@ -479,6 +619,6 @@ for await (const chunk of stream.fullStream) {
479
619
 
480
620
  ## Related types
481
621
 
482
- - [.stream()](https://mastra.ai/reference/streaming/agents/stream) - Method that returns streams emitting these chunks
483
- - [MastraModelOutput](https://mastra.ai/reference/streaming/agents/MastraModelOutput) - The stream object that emits these chunks
484
- - [workflow.stream()](https://mastra.ai/reference/streaming/workflows/stream) - Method that returns streams emitting these chunks for workflows
622
+ - [.stream()](https://mastra.ai/reference/streaming/agents/stream): Method that returns streams emitting these chunks
623
+ - [MastraModelOutput](https://mastra.ai/reference/streaming/agents/MastraModelOutput): The stream object that emits these chunks
624
+ - [workflow.stream()](https://mastra.ai/reference/streaming/workflows/stream): Method that returns streams emitting these chunks for workflows
@@ -248,5 +248,5 @@ if (stream.error) {
248
248
 
249
249
  ## Related types
250
250
 
251
- - [.stream()](https://mastra.ai/reference/streaming/agents/stream) - Method that returns MastraModelOutput
252
- - [ChunkType](https://mastra.ai/reference/streaming/ChunkType) - All possible chunk types in the full stream
251
+ - [.stream()](https://mastra.ai/reference/streaming/agents/stream): Method that returns MastraModelOutput
252
+ - [ChunkType](https://mastra.ai/reference/streaming/ChunkType): All possible chunk types in the full stream
@@ -88,7 +88,7 @@ const stream = await agent.stream('message for agent')
88
88
 
89
89
  **options.structuredOutput** (`StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>`): Options to fine tune your structured output generation.
90
90
 
91
- **options.structuredOutput.schema** (`z.ZodSchema<S>`): Zod schema defining the expected output structure.
91
+ **options.structuredOutput.schema** (`StandardJSONSchemaV1`): Standard JSON Schema defining the expected output structure.
92
92
 
93
93
  **options.structuredOutput.model** (`MastraLanguageModel`): Language model to use for structured output generation. If provided, enables the agent to respond in multi step with tool calls, text, and structured output
94
94
 
@@ -120,7 +120,7 @@ const stream = await agent.stream('message for agent')
120
120
 
121
121
  **options.memory.resource** (`string`): Identifier for the user or resource associated with the thread.
122
122
 
123
- **options.memory.options** (`MemoryConfig`): Configuration for memory behavior including lastMessages, readOnly, semanticRecall, and workingMemory.
123
+ **options.memory.options** (`MemoryConfig`): Configuration for memory behavior including lastMessages, readOnly, semanticRecall, workingMemory, and filterIncompleteToolCalls.
124
124
 
125
125
  **options.onFinish** (`StreamTextOnFinishCallback<any> | StreamObjectOnFinishCallback<OUTPUT>`): Callback function called when streaming completes. Receives the final result.
126
126
 
@@ -206,6 +206,14 @@ const stream = await agent.stream('message for agent')
206
206
 
207
207
  **options.tracingOptions.tags** (`string[]`): Tags to apply to this trace. String labels for categorizing and filtering traces.
208
208
 
209
+ **options.versions** (`VersionOverrides`): Per-invocation version overrides for sub-agent delegation. Merged on top of Mastra instance-level versions and propagated automatically through sub-agent calls via requestContext. Requires the editor package. See \[Sub-agent versioning]\(/docs/editor/overview#sub-agent-versioning).
210
+
211
+ **options.versions.agents** (`Record<string, VersionSelector>`): A map of agent IDs to their version selectors.
212
+
213
+ **options.versions.agents.versionId** (`string`): Target a specific version by ID.
214
+
215
+ **options.versions.agents.status** (`'draft' | 'published'`): Target the latest version with this publication status.
216
+
209
217
  ## Returns
210
218
 
211
219
  **stream** (`MastraModelOutput<Output>`): Returns a MastraModelOutput instance that provides access to the streaming output.
@@ -0,0 +1,94 @@
1
+ # Agent.streamUntilIdle()
2
+
3
+ **Added in:** `@mastra/core@1.29.0`
4
+
5
+ `streamUntilIdle()` streams an agent's response and keeps the stream open until every background task dispatched during the run completes. When a task finishes, its result is written to memory and the agentic loop re-enters automatically so the LLM can react to it. The stream closes once no tasks are running and no completions are queued.
6
+
7
+ Use it when the agent dispatches background tasks (typically long-running tools or subagents) and you want a single stream that spans the initial response **plus** every continuation triggered by a task completion. For foreground-only runs or if you prefer to manage the continuation manually (manually prompt agent to process the result), use [`Agent.stream()`](https://mastra.ai/reference/streaming/agents/stream).
8
+
9
+ ## Usage example
10
+
11
+ ```ts
12
+ const stream = await agent.streamUntilIdle('Research solana for me', {
13
+ memory: { thread: 't1', resource: 'u1' },
14
+ })
15
+
16
+ for await (const chunk of stream.fullStream) {
17
+ // chunks from the initial turn AND any continuation turns triggered by
18
+ // background task completions flow through here
19
+ }
20
+ ```
21
+
22
+ > **Info:** `streamUntilIdle()` requires both a [`BackgroundTaskManager`](https://mastra.ai/reference/configuration) and a [memory](https://mastra.ai/docs/memory/overview) backend. Without either, it falls through to a plain `agent.stream()` call.
23
+
24
+ ## Parameters
25
+
26
+ **messages** (`string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]`): The messages to send to the agent. Can be a single string, array of strings, or structured message objects.
27
+
28
+ **options** (`AgentExecutionOptions<Output> & { maxIdleMs?: number }`): Accepts every option that Agent.stream() accepts, plus maxIdleMs. See the Agent.stream() reference for the full list.
29
+
30
+ **options.maxIdleMs** (`number`): Closes the outer stream after this many ms of idleness between turns. The timer only runs while the wrapper is between turns, so a slow first token does not close the stream. Default: 5 minutes.
31
+
32
+ **options.memory** (`{ thread?: string | { id: string }; resource?: string }`): Memory thread and resource for the run. Required for continuations to write background task results back into the conversation.
33
+
34
+ **options.structuredOutput** (`PublicStructuredOutputOptions<Output>`): Schema-based structured output. Same shape as Agent.stream(). Note that aggregate properties resolve against the first turn only.
35
+
36
+ For every other option (`maxSteps`, `modelSettings`, `toolChoice`, `outputProcessors`, `onFinish`, `onChunk`, etc.), see the [`Agent.stream()` parameters](https://mastra.ai/reference/streaming/agents/stream). `streamUntilIdle()` forwards them to the initial turn.
37
+
38
+ ## Returns
39
+
40
+ **stream** (`MastraModelOutput<Output>`): A MastraModelOutput where fullStream spans the initial turn plus every auto-continuation. Aggregate properties (text, toolCalls, toolResults, finishReason, messageList, getFullOutput()) resolve against the first turn only.
41
+
42
+ ### Aggregate properties caveat
43
+
44
+ `streamUntilIdle()` returns a proxy over the first turn's `MastraModelOutput`. Only `fullStream` is replaced with a combined stream that spans every continuation. Every other property — `text`, `toolCalls`, `toolResults`, `finishReason`, `messageList`, `getFullOutput()` — resolves against the **first turn's** internal buffer.
45
+
46
+ If you need an aggregate view across all continuations, consume `fullStream` yourself and accumulate.
47
+
48
+ ## Continuation behavior
49
+
50
+ Internally, `streamUntilIdle()`:
51
+
52
+ 1. Runs the initial turn via `agent.stream(...)` and pipes its `fullStream` into the outer stream.
53
+ 2. Subscribes to background-task completion events for the resolved memory scope.
54
+ 3. Queues each terminal event (`background-task-completed`, `background-task-failed`, `background-task-cancelled`) and, when the outer wrapper is idle between turns, re-invokes `agent.stream([], ...)` with a directive listing the just-completed `toolCallId`s. The continuation turn flows into the same outer stream.
55
+ 4. Closes the outer stream once no tasks are running and no completions are queued.
56
+
57
+ ## Extended usage example
58
+
59
+ ### Cap idle time between turns
60
+
61
+ ```ts
62
+ const stream = await agent.streamUntilIdle('Kick off the long jobs', {
63
+ memory: { thread: 't1', resource: 'u1' },
64
+ maxIdleMs: 60_000, // close the stream after 1 minute of idleness between turns
65
+ })
66
+
67
+ for await (const chunk of stream.fullStream) {
68
+ if (chunk.type === 'background-task-completed') {
69
+ console.log('Task complete:', chunk.payload.taskId)
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Aggregate text across continuations
75
+
76
+ ```ts
77
+ const stream = await agent.streamUntilIdle('Research and summarize', {
78
+ memory: { thread: 't1', resource: 'u1' },
79
+ })
80
+
81
+ let fullText = ''
82
+ for await (const chunk of stream.fullStream) {
83
+ if (chunk.type === 'text-delta') {
84
+ fullText += chunk.payload.text
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## Related
90
+
91
+ - [Background tasks](https://mastra.ai/docs/agents/background-tasks)
92
+ - [`Agent.stream()` reference](https://mastra.ai/reference/streaming/agents/stream)
93
+ - [backgroundTasks configuration reference](https://mastra.ai/reference/configuration)
94
+ - [Stream chunk types](https://mastra.ai/reference/streaming/ChunkType)
@@ -32,6 +32,8 @@ if (result!.status === 'suspended') {
32
32
 
33
33
  **step** (`Step<string, any, any, any, any, TEngineType>`): The step to resume execution from
34
34
 
35
+ **forEachIndex** (`number`): Target a specific iteration of a suspended \`.foreach()\` step. Pass the zero-based index of the iteration to resume; other iterations remain suspended. Omit to resume all suspended iterations of the step with the same \`resumeData\`.
36
+
35
37
  **tracingOptions** (`TracingOptions`): Options for Tracing configuration.
36
38
 
37
39
  **tracingOptions.metadata** (`Record<string, any>`): Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.