@mastra/core 1.87.0 → 1.88.0-alpha.0

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 (404) hide show
  1. package/dist/_types/@internal_ai-v6@0.0.100/dist/index.d.ts +97 -2049
  2. package/dist/agent/agent.d.ts +10 -2
  3. package/dist/agent/durable/create-evented-agent.d.ts +2 -1
  4. package/dist/agent/durable/execution-engine.d.ts +4 -2
  5. package/dist/agent/durable/index.cjs +3 -2
  6. package/dist/agent/durable/index.js +3 -2
  7. package/dist/agent/durable/segment-spans.d.ts +7 -0
  8. package/dist/agent/durable/stored-signal-drain.d.ts +1 -1
  9. package/dist/agent/durable/types.d.ts +6 -0
  10. package/dist/agent/index.cjs +2 -2
  11. package/dist/agent/index.js +2 -2
  12. package/dist/agent/request-context-snapshot.d.ts +5 -0
  13. package/dist/agent/thread-stream-runtime.d.ts +26 -4
  14. package/dist/agent-builder/ee/index.cjs +1 -1
  15. package/dist/agent-builder/ee/index.js +1 -1
  16. package/dist/agent-controller/index.cjs +1 -1
  17. package/dist/agent-controller/index.js +1 -1
  18. package/dist/{agent-controller-vUU_atR-.js → agent-controller-CQDCmsFD.js} +15 -9
  19. package/dist/{agent-controller-DckvJ7bq.cjs → agent-controller-NQKYmY0W.cjs} +15 -9
  20. package/dist/background-tasks/index.cjs +1 -1
  21. package/dist/background-tasks/index.js +1 -1
  22. package/dist/{background-tasks-HAzB0JtC.js → background-tasks-B7UygDdO.js} +1 -1
  23. package/dist/{background-tasks-By_1e9Gf.cjs → background-tasks-CeARf1DK.cjs} +1 -1
  24. package/dist/browser/index.cjs +1 -1
  25. package/dist/browser/index.js +1 -1
  26. package/dist/{builder-CmtDqFLe.js → builder-CpAEmMdR.js} +2 -2
  27. package/dist/{builder-Dx8GMhFn.cjs → builder-Dmf04g9P.cjs} +2 -2
  28. package/dist/capabilities/302ai.json +196 -196
  29. package/dist/capabilities/abliteratedllm.json +33 -33
  30. package/dist/capabilities/abliteration-ai.json +9 -9
  31. package/dist/capabilities/above.json +13 -13
  32. package/dist/capabilities/adaption.json +7 -7
  33. package/dist/capabilities/adzuki.json +20 -20
  34. package/dist/capabilities/agentrouter.json +10 -10
  35. package/dist/capabilities/agnes.json +2 -2
  36. package/dist/capabilities/ai-router.json +6 -6
  37. package/dist/capabilities/aiand.json +27 -18
  38. package/dist/capabilities/aigrow.json +14 -14
  39. package/dist/capabilities/aimlapi.json +146 -146
  40. package/dist/capabilities/aipg.json +2 -2
  41. package/dist/capabilities/aixy.json +17 -17
  42. package/dist/capabilities/aki-io.json +14 -14
  43. package/dist/capabilities/alibaba-cn.json +94 -94
  44. package/dist/capabilities/alibaba-coding-plan-cn.json +5 -5
  45. package/dist/capabilities/alibaba-coding-plan.json +5 -5
  46. package/dist/capabilities/alibaba-token-plan-cn.json +50 -50
  47. package/dist/capabilities/alibaba-token-plan.json +53 -53
  48. package/dist/capabilities/alibaba.json +71 -71
  49. package/dist/capabilities/ambient.json +8 -8
  50. package/dist/capabilities/amd-tokenlab.json +4 -4
  51. package/dist/capabilities/amd.json +11 -11
  52. package/dist/capabilities/anthropic.json +36 -36
  53. package/dist/capabilities/anyapi.json +18 -18
  54. package/dist/capabilities/apiko.json +2 -2
  55. package/dist/capabilities/arcee.json +9 -9
  56. package/dist/capabilities/augure.json +5 -5
  57. package/dist/capabilities/auriko.json +23 -23
  58. package/dist/capabilities/bailing.json +5 -5
  59. package/dist/capabilities/baseten.json +47 -38
  60. package/dist/capabilities/bee.json +5 -5
  61. package/dist/capabilities/bothub.json +14 -14
  62. package/dist/capabilities/boundless.json +37 -37
  63. package/dist/capabilities/bumo.json +40 -40
  64. package/dist/capabilities/byteplus.json +22 -22
  65. package/dist/capabilities/cerebras.json +4 -4
  66. package/dist/capabilities/cheapaimodel.json +10 -10
  67. package/dist/capabilities/cheapest-token.json +25 -25
  68. package/dist/capabilities/chutes.json +34 -32
  69. package/dist/capabilities/cline-pass.json +29 -29
  70. package/dist/capabilities/cloudcode.json +7 -7
  71. package/dist/capabilities/cloudflare-workers-ai.json +15 -15
  72. package/dist/capabilities/commandcode.json +146 -146
  73. package/dist/capabilities/concentrate.json +286 -277
  74. package/dist/capabilities/cortecs.json +109 -109
  75. package/dist/capabilities/crossmodel.json +194 -194
  76. package/dist/capabilities/crusoe.json +13 -13
  77. package/dist/capabilities/daoxe.json +7 -7
  78. package/dist/capabilities/databricks.json +128 -120
  79. package/dist/capabilities/deepinfra.json +102 -102
  80. package/dist/capabilities/deepseek.json +4 -4
  81. package/dist/capabilities/digitalocean.json +113 -114
  82. package/dist/capabilities/dothoosh.json +29 -29
  83. package/dist/capabilities/doubleword.json +26 -26
  84. package/dist/capabilities/edenai.json +287 -278
  85. package/dist/capabilities/empiriolabs.json +169 -169
  86. package/dist/capabilities/engy.json +24 -18
  87. package/dist/capabilities/entrim.json +6 -6
  88. package/dist/capabilities/evroc.json +13 -13
  89. package/dist/capabilities/ezkielyna.json +9 -9
  90. package/dist/capabilities/fastrouter.json +79 -79
  91. package/dist/capabilities/fireworks-ai.json +92 -92
  92. package/dist/capabilities/freemodel.json +10 -10
  93. package/dist/capabilities/friendli.json +26 -5
  94. package/dist/capabilities/frogbot.json +97 -97
  95. package/dist/capabilities/gisoo.json +19 -19
  96. package/dist/capabilities/gmicloud.json +7 -7
  97. package/dist/capabilities/google.json +53 -53
  98. package/dist/capabilities/graphn.json +14 -14
  99. package/dist/capabilities/greenpt.json +34 -34
  100. package/dist/capabilities/groq.json +4 -4
  101. package/dist/capabilities/helicone.json +88 -88
  102. package/dist/capabilities/hetzner.json +4 -4
  103. package/dist/capabilities/hostinger-router.json +10 -10
  104. package/dist/capabilities/hpc-ai.json +2 -2
  105. package/dist/capabilities/huawei-maas.json +15 -15
  106. package/dist/capabilities/hubris.json +28 -28
  107. package/dist/capabilities/huggingface.json +87 -85
  108. package/dist/capabilities/hyper.json +24 -24
  109. package/dist/capabilities/impossibl.json +114 -114
  110. package/dist/capabilities/inception.json +3 -3
  111. package/dist/capabilities/inceptron.json +8 -8
  112. package/dist/capabilities/inco.json +2 -2
  113. package/dist/capabilities/infer.json +17 -17
  114. package/dist/capabilities/inferall.json +5 -5
  115. package/dist/capabilities/inference-coop.json +2 -2
  116. package/dist/capabilities/inferenceapis.json +27 -27
  117. package/dist/capabilities/inferris.json +3 -3
  118. package/dist/capabilities/infersia.json +11 -11
  119. package/dist/capabilities/infomaniak.json +2 -2
  120. package/dist/capabilities/io-net.json +2 -2
  121. package/dist/capabilities/iteracompute.json +38 -38
  122. package/dist/capabilities/jalapeno.json +10 -10
  123. package/dist/capabilities/jiekou.json +34 -34
  124. package/dist/capabilities/joingonka.json +4 -4
  125. package/dist/capabilities/jzstoken.json +49 -49
  126. package/dist/capabilities/keln.json +24 -24
  127. package/dist/capabilities/kenari.json +122 -137
  128. package/dist/capabilities/kilo.json +615 -614
  129. package/dist/capabilities/kimchi.json +14 -14
  130. package/dist/capabilities/kimi-code-plan-cn.json +9 -9
  131. package/dist/capabilities/kimi-code-plan-global.json +9 -9
  132. package/dist/capabilities/kitani.json +6 -6
  133. package/dist/capabilities/klavo.json +20 -20
  134. package/dist/capabilities/korouter.json +35 -35
  135. package/dist/capabilities/kunavo.json +10 -10
  136. package/dist/capabilities/liquid.json +9 -9
  137. package/dist/capabilities/lithosai.json +2 -2
  138. package/dist/capabilities/llmgateway-providers.json +959 -923
  139. package/dist/capabilities/llmgateway.json +349 -340
  140. package/dist/capabilities/llmtr.json +29 -29
  141. package/dist/capabilities/logits.json +2 -2
  142. package/dist/capabilities/lowrouter.json +53 -53
  143. package/dist/capabilities/lyceum.json +12 -12
  144. package/dist/capabilities/melious.json +9 -9
  145. package/dist/capabilities/merge-gateway.json +271 -263
  146. package/dist/capabilities/meta.json +11 -11
  147. package/dist/capabilities/minimax-cn-coding-plan.json +5 -5
  148. package/dist/capabilities/minimax-cn.json +5 -5
  149. package/dist/capabilities/minimax-coding-plan.json +5 -5
  150. package/dist/capabilities/minimax.json +5 -5
  151. package/dist/capabilities/mistral.json +16 -16
  152. package/dist/capabilities/mixlayer.json +4 -4
  153. package/dist/capabilities/modal.json +11 -11
  154. package/dist/capabilities/model-oracle-ai.json +19 -19
  155. package/dist/capabilities/modelis.json +16 -16
  156. package/dist/capabilities/modular.json +5 -5
  157. package/dist/capabilities/moneo.json +10 -10
  158. package/dist/capabilities/moonshotai-cn.json +6 -6
  159. package/dist/capabilities/moonshotai.json +6 -6
  160. package/dist/capabilities/morph.json +18 -18
  161. package/dist/capabilities/munito-eu.json +8 -8
  162. package/dist/capabilities/munito.json +10 -10
  163. package/dist/capabilities/nan.json +33 -33
  164. package/dist/capabilities/nano-gpt.json +557 -567
  165. package/dist/capabilities/nearai.json +77 -77
  166. package/dist/capabilities/nebius.json +42 -34
  167. package/dist/capabilities/neon.json +127 -127
  168. package/dist/capabilities/neuralwatt.json +37 -37
  169. package/dist/capabilities/nokeep.json +4 -4
  170. package/dist/capabilities/novita-ai.json +115 -115
  171. package/dist/capabilities/nvidia.json +17 -17
  172. package/dist/capabilities/oathbreaker.json +5 -5
  173. package/dist/capabilities/obscurify.json +29 -29
  174. package/dist/capabilities/oci.json +6 -6
  175. package/dist/capabilities/ofox.json +265 -265
  176. package/dist/capabilities/ollama-cloud.json +52 -52
  177. package/dist/capabilities/openai.json +58 -61
  178. package/dist/capabilities/opencode-go.json +90 -90
  179. package/dist/capabilities/openreason.json +6 -6
  180. package/dist/capabilities/openrouter.json +550 -548
  181. package/dist/capabilities/opper.json +26 -26
  182. package/dist/capabilities/orcarouter.json +310 -294
  183. package/dist/capabilities/outerlabs.json +29 -29
  184. package/dist/capabilities/ovhcloud.json +22 -22
  185. package/dist/capabilities/pareto.json +4 -4
  186. package/dist/capabilities/perplexity-agent.json +69 -69
  187. package/dist/capabilities/perplexity.json +2 -2
  188. package/dist/capabilities/phala.json +30 -30
  189. package/dist/capabilities/poe.json +111 -111
  190. package/dist/capabilities/poolside.json +2 -2
  191. package/dist/capabilities/powerspring.json +9 -9
  192. package/dist/capabilities/primalabs.json +11 -11
  193. package/dist/capabilities/prime.json +127 -119
  194. package/dist/capabilities/privatemode-ai.json +6 -6
  195. package/dist/capabilities/proxystacks.json +3 -3
  196. package/dist/capabilities/qiniu-ai.json +13 -13
  197. package/dist/capabilities/refuseless.json +5 -5
  198. package/dist/capabilities/regolo-ai.json +10 -10
  199. package/dist/capabilities/requesty.json +200 -200
  200. package/dist/capabilities/ruapi.json +20 -20
  201. package/dist/capabilities/runcrate.json +13 -13
  202. package/dist/capabilities/runinfra.json +19 -19
  203. package/dist/capabilities/sakana.json +5 -5
  204. package/dist/capabilities/sambanova.json +9 -9
  205. package/dist/capabilities/sandbase.json +22 -22
  206. package/dist/capabilities/sarvam.json +14 -14
  207. package/dist/capabilities/scaleway.json +17 -17
  208. package/dist/capabilities/scnet-token-plan.json +8 -8
  209. package/dist/capabilities/scx-ai.json +22 -22
  210. package/dist/capabilities/sensenova.json +11 -11
  211. package/dist/capabilities/siliconflow-cn.json +59 -59
  212. package/dist/capabilities/siliconflow.json +57 -57
  213. package/dist/capabilities/snowflake-cortex.json +19 -19
  214. package/dist/capabilities/sokkan.json +10 -10
  215. package/dist/capabilities/sparrowcodes.json +20 -20
  216. package/dist/capabilities/standardcompute.json +85 -85
  217. package/dist/capabilities/steadyrouter.json +40 -40
  218. package/dist/capabilities/stepfun-ai-step-plan.json +5 -5
  219. package/dist/capabilities/stepfun-ai.json +5 -5
  220. package/dist/capabilities/stepfun-step-plan.json +5 -5
  221. package/dist/capabilities/stepfun.json +5 -5
  222. package/dist/capabilities/stepping-stone.json +18 -18
  223. package/dist/capabilities/superbot-gg.json +4 -4
  224. package/dist/capabilities/synthetic.json +12 -12
  225. package/dist/capabilities/synthorai.json +21 -21
  226. package/dist/capabilities/teamorouter.json +17 -17
  227. package/dist/capabilities/teapot-router.json +13 -13
  228. package/dist/capabilities/tencent-token-plan-intl.json +22 -22
  229. package/dist/capabilities/tencent-token-plan.json +42 -42
  230. package/dist/capabilities/tencent-tokenhub.json +44 -44
  231. package/dist/capabilities/tensorx.json +43 -43
  232. package/dist/capabilities/tenstorrent.json +2 -2
  233. package/dist/capabilities/the-grid-ai.json +30 -30
  234. package/dist/capabilities/thinkingmachines.json +78 -78
  235. package/dist/capabilities/tinfoil.json +13 -13
  236. package/dist/capabilities/toapis.json +2 -2
  237. package/dist/capabilities/togetherai.json +54 -54
  238. package/dist/capabilities/tokengo.json +23 -23
  239. package/dist/capabilities/tokenharbor.json +217 -217
  240. package/dist/capabilities/tokenify.json +9 -9
  241. package/dist/capabilities/trustedrouter.json +6 -6
  242. package/dist/capabilities/trustedtokens.json +12 -12
  243. package/dist/capabilities/umans-ai-coding-plan.json +17 -17
  244. package/dist/capabilities/umans-ai.json +11 -11
  245. package/dist/capabilities/uncensuredai.json +5 -5
  246. package/dist/capabilities/unrestricted.json +4 -4
  247. package/dist/capabilities/uplinkswitch.json +20 -20
  248. package/dist/capabilities/upstage.json +2 -2
  249. package/dist/capabilities/vancine.json +20 -20
  250. package/dist/capabilities/vercel.json +580 -571
  251. package/dist/capabilities/vivgrid.json +61 -61
  252. package/dist/capabilities/volcengine-coding-plan.json +26 -26
  253. package/dist/capabilities/volcengine.json +24 -24
  254. package/dist/capabilities/vultr.json +15 -15
  255. package/dist/capabilities/wafer.ai.json +19 -19
  256. package/dist/capabilities/wallaby.json +5 -5
  257. package/dist/capabilities/wally.json +11 -11
  258. package/dist/capabilities/wandb.json +21 -21
  259. package/dist/capabilities/watt.json +19 -19
  260. package/dist/capabilities/xai.json +2 -2
  261. package/dist/capabilities/xpersona.json +13 -13
  262. package/dist/capabilities/xxapi.json +27 -27
  263. package/dist/capabilities/zai-coding-plan.json +11 -11
  264. package/dist/capabilities/zai.json +32 -32
  265. package/dist/capabilities/zenifra.json +27 -27
  266. package/dist/capabilities/zenmux.json +178 -178
  267. package/dist/capabilities/zerogpu.json +12 -12
  268. package/dist/capabilities/zhipuai-coding-plan.json +3 -3
  269. package/dist/capabilities/zhipuai.json +28 -28
  270. package/dist/capabilities/zro.json +7 -7
  271. package/dist/channels/index.cjs +2 -2
  272. package/dist/channels/index.js +2 -2
  273. package/dist/{channels-DChC1kXm.js → channels-BQ--aLCA.js} +1 -1
  274. package/dist/{channels-BamLzaJG.cjs → channels-CTCBsS5M.cjs} +1 -1
  275. package/dist/coding-agent/index.cjs +1 -1
  276. package/dist/coding-agent/index.js +1 -1
  277. package/dist/datasets/index.cjs +2 -2
  278. package/dist/datasets/index.js +2 -2
  279. package/dist/docs/SKILL.md +1 -1
  280. package/dist/docs/assets/SOURCE_MAP.json +804 -804
  281. package/dist/docs/references/docs-agents-human-in-the-loop.md +1 -1
  282. package/dist/docs/references/docs-agents-resumable-streams.md +3 -3
  283. package/dist/docs/references/docs-channels.md +8 -2
  284. package/dist/docs/references/docs-deployment-workers.md +10 -4
  285. package/dist/docs/references/docs-harness-durable-agents.md +17 -15
  286. package/dist/docs/references/docs-server-mcp.md +68 -0
  287. package/dist/docs/references/docs-server-pubsub.md +25 -16
  288. package/dist/docs/references/docs-signals-running-across-processes.md +9 -3
  289. package/dist/docs/references/docs-signals-sending-signals.md +1 -1
  290. package/dist/docs/references/docs-workflows-overview.md +3 -3
  291. package/dist/docs/references/reference-agents-agent.md +3 -1
  292. package/dist/docs/references/reference-agents-durable-agent.md +3 -3
  293. package/dist/docs/references/reference-configuration.md +60 -0
  294. package/dist/docs/references/reference-pubsub-base.md +1 -1
  295. package/dist/docs/references/reference-pubsub-caching-pubsub.md +1 -1
  296. package/dist/docs/references/reference-pubsub-google-cloud-pubsub.md +13 -7
  297. package/dist/docs/references/reference-pubsub-lease-provider.md +4 -0
  298. package/dist/docs/references/reference-pubsub-redis-streams.md +18 -9
  299. package/dist/docs/references/reference-pubsub-valkey-streams.md +25 -7
  300. package/dist/evals/index.cjs +1 -1
  301. package/dist/evals/index.js +1 -1
  302. package/dist/evals/scoreTraces/index.cjs +1 -1
  303. package/dist/evals/scoreTraces/index.js +1 -1
  304. package/dist/events/caching-pubsub.d.ts +3 -11
  305. package/dist/events/index.cjs +1 -1
  306. package/dist/events/index.js +1 -1
  307. package/dist/events/pubsub.d.ts +2 -1
  308. package/dist/{execution-fence-BBKnrhWR.cjs → execution-fence-C8Q0wWkG.cjs} +841 -219
  309. package/dist/{execution-fence--VdnD7p4.js → execution-fence-DGFyUV5h.js} +841 -219
  310. package/dist/harness/index.cjs +1 -1
  311. package/dist/harness/index.js +1 -1
  312. package/dist/index.cjs +1 -1
  313. package/dist/index.js +1 -1
  314. package/dist/knowledge/index.cjs +1 -1
  315. package/dist/knowledge/index.js +1 -1
  316. package/dist/llm/index.cjs +3 -3
  317. package/dist/llm/index.js +3 -3
  318. package/dist/llm/model/provider-types.generated.d.ts +7689 -7673
  319. package/dist/llm/reasoning/account-switch.d.ts +50 -0
  320. package/dist/llm/reasoning/index.cjs +65 -0
  321. package/dist/llm/reasoning/index.d.ts +1 -0
  322. package/dist/llm/reasoning/index.js +61 -1
  323. package/dist/{llm-DknPJDW6.cjs → llm-RIAYOAtD.cjs} +2 -2
  324. package/dist/{llm-ccA_1Q-H.js → llm-YNjDFSui.js} +2 -2
  325. package/dist/loop/index.cjs +2 -2
  326. package/dist/loop/index.js +2 -2
  327. package/dist/loop/suspended-run-auto-resume.d.ts +15 -0
  328. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +1 -1
  329. package/dist/{manager-DWX6-Cx4.js → manager-DZhtdV6Q.js} +2 -2
  330. package/dist/{manager-D9F0i7O2.cjs → manager-Y-jYcS7T.cjs} +2 -2
  331. package/dist/mastra/index.cjs +1 -1
  332. package/dist/mastra/index.d.ts +35 -11
  333. package/dist/mastra/index.js +1 -1
  334. package/dist/{mastra-BzWL4xI8.cjs → mastra-B2-HBq1-.cjs} +108 -20
  335. package/dist/{mastra-oUDN81l8.js → mastra-BJ54VxOO.js} +108 -20
  336. package/dist/memory/index.cjs +2 -2
  337. package/dist/memory/index.js +2 -2
  338. package/dist/{model-BwxfS6T_.js → model-cS3d5rmF.js} +1 -1
  339. package/dist/{model-BnD7SPlA.cjs → model-lzZPXaEV.cjs} +1 -1
  340. package/dist/{netlify-CS0VDbb9.cjs → netlify-1lti1j4Z.cjs} +1 -1
  341. package/dist/{netlify-DcY9gHCJ.js → netlify-ClBjc0Xg.js} +1 -1
  342. package/dist/notifications/index.cjs +1 -1
  343. package/dist/notifications/index.js +1 -1
  344. package/dist/{output-helpers-k2-48ssH.js → output-helpers-D-qplq22.js} +13 -15
  345. package/dist/{output-helpers-By5FbLpp.cjs → output-helpers-D4O_oFne.cjs} +12 -14
  346. package/dist/processor-provider/index.cjs +1 -1
  347. package/dist/processor-provider/index.js +1 -1
  348. package/dist/processors/index.cjs +2 -2
  349. package/dist/processors/index.js +2 -2
  350. package/dist/{provider-registry-OggbU6OE.cjs → provider-registry-C6jd3Uxi.cjs} +21565 -21544
  351. package/dist/{provider-registry-BvbEoScB.js → provider-registry-C_XQJvu2.js} +21565 -21544
  352. package/dist/provider-registry.json +22006 -21980
  353. package/dist/{registry-generator-CDaf48a6.cjs → registry-generator-BYdAlox6.cjs} +1 -1
  354. package/dist/{registry-generator-BFOQQHyt.js → registry-generator-DBrTbThj.js} +1 -1
  355. package/dist/{rehydrate-CFoKaNlm.js → rehydrate-4xHubfOY.js} +2 -2
  356. package/dist/{rehydrate-QeS0NjGw.cjs → rehydrate-BtwY0ima.cjs} +2 -2
  357. package/dist/relevance/index.cjs +2 -2
  358. package/dist/relevance/index.js +2 -2
  359. package/dist/{scheduler-0ShtMM1I.js → scheduler-D1qdie5k.js} +4 -2
  360. package/dist/{scheduler-CMjK0LoQ.cjs → scheduler-DE5lcHJA.cjs} +4 -2
  361. package/dist/server/index.d.ts +1 -1
  362. package/dist/server/types.d.ts +57 -0
  363. package/dist/storage/domains/memory/base.d.ts +6 -1
  364. package/dist/storage/index.cjs +2 -2
  365. package/dist/storage/index.js +2 -2
  366. package/dist/stream/index.cjs +2 -2
  367. package/dist/stream/index.js +2 -2
  368. package/dist/{stream-CNqAlDJF.cjs → stream-DqKDB3nL.cjs} +1 -1
  369. package/dist/{stream-D2rv1Ut1.js → stream-H_wVxqdK.js} +1 -1
  370. package/dist/test-utils/llm-mock.cjs +1 -1
  371. package/dist/test-utils/llm-mock.js +1 -1
  372. package/dist/tool-loop-agent/index.cjs +1 -1
  373. package/dist/tool-loop-agent/index.js +1 -1
  374. package/dist/{tool-loop-agent-Dusqj7-j.cjs → tool-loop-agent-D4gSdYuN.cjs} +3 -3
  375. package/dist/{tool-loop-agent-CFsOjueT.js → tool-loop-agent-DvZcOxWe.js} +3 -3
  376. package/dist/{utils-CIuOHPoS.cjs → utils-Dd4m7z13.cjs} +1 -1
  377. package/dist/{utils-DLnCt6E9.js → utils-h5k_ChdS.js} +1 -1
  378. package/dist/utils.cjs +1 -1
  379. package/dist/utils.js +1 -1
  380. package/dist/{validate-ShLcQTA5.js → validate-DQB9spZ1.js} +1 -1
  381. package/dist/{validate-1zReLtWc.cjs → validate-u6_TUYSo.cjs} +1 -1
  382. package/dist/vector/index.cjs +1 -1
  383. package/dist/vector/index.js +1 -1
  384. package/dist/worker/index.cjs +1 -1
  385. package/dist/worker/index.d.ts +1 -1
  386. package/dist/worker/index.js +1 -1
  387. package/dist/worker/workers/orchestration-worker.d.ts +13 -0
  388. package/dist/{worker-CQ8rTJwQ.cjs → worker-0F7Nukyf.cjs} +2 -2
  389. package/dist/{worker-BPNrwCFs.cjs → worker-D-cq8McN.cjs} +117 -32
  390. package/dist/{worker-ngt-F1Iv.js → worker-DWOK2M_5.js} +117 -32
  391. package/dist/{worker-CKcQcPl8.js → worker-DmUkyJY_.js} +2 -2
  392. package/dist/{workflow-B_e5wMmz.cjs → workflow-DXE15e-w.cjs} +4 -4
  393. package/dist/{workflow-XDIVRsu4.js → workflow-DamOke3z.js} +4 -4
  394. package/dist/workflows/builder/index.cjs +1 -1
  395. package/dist/workflows/builder/index.js +1 -1
  396. package/dist/workflows/evented/index.cjs +1 -1
  397. package/dist/workflows/evented/index.js +1 -1
  398. package/dist/workflows/evented/setup-warning.d.ts +20 -0
  399. package/dist/workflows/index.cjs +5 -5
  400. package/dist/workflows/index.js +5 -5
  401. package/dist/workflows/scheduler/types.d.ts +3 -0
  402. package/dist/workspace/tools/media.d.ts +2 -2
  403. package/package.json +7 -7
  404. package/src/llm/model/provider-types.generated.d.ts +7689 -7673
@@ -537,7 +537,7 @@ For automatic tool resumption to work:
537
537
  | Manual (`resumeStream()`) | Programmatic control, webhooks, button clicks, external triggers |
538
538
  | Automatic (`autoResumeSuspendedTools`) | Conversational flows where users provide resume data in natural language |
539
539
 
540
- Both approaches work with the same tool definitions. Automatic resumption triggers only when suspended tools exist in the message history and the user sends a new message on the same thread.
540
+ Both approaches work with the same tool definitions. Automatic resumption triggers only when suspended tools exist in the message history and the user sends a new message on the same thread. A message sent with `sendMessage()` or queued with `queueMessage()` while the tool is suspended starts that turn. A tool waiting for approval keeps both waiting until it's approved or declined.
541
541
 
542
542
  ## Resuming after a restart
543
543
 
@@ -23,7 +23,7 @@ Mastra resolves the stream transport and replay cache separately:
23
23
  - **Transport:** For the plain loop and the default durable engine, Mastra uses the first configured option: the agent's `durable.pubsub`, the agent's top-level `pubsub`, or `mastra.pubsub`. Evented steps publish on `mastra.pubsub` so workers can publish to the same stream.
24
24
  - **Replay cache:** Mastra uses the agent's `durable.cache`, then `mastra.serverCache`, then an in-memory cache. Evented runs use the shared Mastra cache when replay caching is enabled. If the transport is already a `CachingPubSub`, Mastra reuses its cache. Set `durable.cache: false` to skip adding a replay cache without changing the transport or its retained history.
25
25
 
26
- For deployments with more than one process, see [PubSub setup for resumable streams](https://mastra.ai/docs/server/pubsub).
26
+ The replay cache numbers each run's events and holds the run's ownership record. With more than one process, set up a PubSub backend and a server cache that every process shares in the same step, as in [distributed deployments](https://mastra.ai/docs/server/pubsub). With the default in-memory cache, only the process that started a run can serve it to the observe and abort routes, and evented steps that run on another process publish events that an offset can't skip.
27
27
 
28
28
  ## Configure streams
29
29
 
@@ -46,7 +46,7 @@ export const supportAgent = new Agent({
46
46
 
47
47
  | Option | Default | Description |
48
48
  | ------------------ | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
49
- | `pubsub` | `mastra.pubsub` | Bus the run is published on. Use a shared bus to follow runs across processes. |
49
+ | `pubsub` | `mastra.pubsub` | Bus the run is published on. Use a shared bus and a shared cache to follow runs across processes. |
50
50
  | `cache` | `mastra.serverCache`, else an in-memory cache | Replay cache. Pass `false` to disable this cache. Transports such as Redis Streams can still replay retained history. |
51
51
  | `shouldCache` | Every topic | Return `false` for a topic to skip caching it. |
52
52
  | `cleanupTimeoutMs` | `30000` | How long after it finishes a run is cleared. `0` turns off this timer only. The cache's own expiry and eviction still apply. |
@@ -141,7 +141,7 @@ When several servers share a PubSub and cache, such as Redis, a run started on o
141
141
  - Each run writes an ownership record (agent, run, resource and thread) to the cache before its first event. The server's observe and abort routes check the caller against that record, so tenant and thread checks hold on every server.
142
142
  - An unknown, expired or evicted record returns 404. If the cache can't be read, the routes return 503 rather than skipping the check.
143
143
  - With `durable: { cache: false }` the record is kept in `mastra.serverCache`, so ownership still works across servers. Replay then depends on the PubSub: one that keeps history, like Redis Streams, replays it, and an in-process bus delivers only live events.
144
- - With the default in-memory cache and PubSub, nothing is shared, so only the server running the agent can observe or stop its runs.
144
+ - With the default in-memory cache, each server keeps its own records, so only the server that started a run can observe or stop it through these routes, even when the PubSub is shared.
145
145
 
146
146
  ## Related
147
147
 
@@ -474,11 +474,13 @@ The default in-memory pub/sub can't cross instance boundaries, so on serverless
474
474
 
475
475
  Without a shared pub/sub, that instance can't reach the active run and starts its own, leaving the original run untouched and the thread processed twice.
476
476
 
477
- Configure a shared pub/sub backed by Redis Streams on the `Mastra` instance so leases and signals coordinate across instances:
477
+ Configure a shared pub/sub backed by Redis Streams on the `Mastra` instance so leases and signals coordinate across instances, and a server cache on the same Redis so every instance reads the same agent run streams:
478
478
 
479
479
  ```typescript
480
480
  import { Mastra } from '@mastra/core'
481
+ import { RedisServerCache } from '@mastra/redis'
481
482
  import { RedisStreamsPubSub } from '@mastra/redis-streams'
483
+ import { Redis } from 'ioredis'
482
484
  import { yourAgent } from './agents/your-agent'
483
485
 
484
486
  export const mastra = new Mastra({
@@ -487,10 +489,14 @@ export const mastra = new Mastra({
487
489
  url: process.env.REDIS_URL,
488
490
  keyPrefix: 'mastra:my-app',
489
491
  }),
492
+ cache: new RedisServerCache(
493
+ { client: new Redis(process.env.REDIS_URL!) },
494
+ { keyPrefix: 'mastra:my-app:cache:' },
495
+ ),
490
496
  })
491
497
  ```
492
498
 
493
- Vercel's managed Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
499
+ Replicas of one deployment use the same `keyPrefix` values, and another deployment on the same Redis needs its own on both the pubsub and the cache. Vercel's managed Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
494
500
 
495
501
  ## Other adapters
496
502
 
@@ -85,18 +85,20 @@ The server generated by `mastra build` starts these workers automatically. If yo
85
85
 
86
86
  This setup needs no external infrastructure beyond your storage adapter. It doesn't survive process crashes, and you can't scale individual components.
87
87
 
88
- > **Warning:** The in-memory PubSub delivers events only inside the process that published them. Running several Mastra instances on one storage with it isn't supported for evented workflows or agents. Each instance restarts the others' active evented workflow runs when it boots. A multi-instance deployment needs a PubSub backend that redelivers unacknowledged events and a storage adapter with workflow step guards. See [evented workflows and agents](https://mastra.ai/docs/server/pubsub).
88
+ > **Warning:** The in-memory PubSub delivers events only inside the process that published them. Running several Mastra instances on one storage with it isn't supported for evented workflows or agents. Each instance restarts the others' active evented workflow runs when it boots. A multi-instance deployment needs a PubSub backend that redelivers unacknowledged events, a storage adapter with workflow step guards, and, for evented agents, a server cache that every instance shares. See [evented workflows and agents](https://mastra.ai/docs/server/pubsub).
89
89
 
90
90
  ### Split processes
91
91
 
92
- To run workers in their own processes, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
92
+ To run workers in their own processes, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend with a server cache that every process shares, and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
93
93
 
94
94
  **Redis Streams + PostgreSQL**:
95
95
 
96
96
  ```typescript
97
97
  import { Mastra } from '@mastra/core/mastra'
98
98
  import { RedisStreamsPubSub } from '@mastra/redis-streams'
99
+ import { RedisServerCache } from '@mastra/redis'
99
100
  import { PostgresStore } from '@mastra/pg'
101
+ import { Redis } from 'ioredis'
100
102
 
101
103
  export const mastra = new Mastra({
102
104
  storage: new PostgresStore({
@@ -105,6 +107,7 @@ export const mastra = new Mastra({
105
107
  pubsub: new RedisStreamsPubSub({
106
108
  url: process.env.REDIS_URL!,
107
109
  }),
110
+ cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
108
111
  })
109
112
  ```
110
113
 
@@ -114,6 +117,8 @@ export const mastra = new Mastra({
114
117
  import { Mastra } from '@mastra/core/mastra'
115
118
  import { GoogleCloudPubSub } from '@mastra/google-cloud-pubsub'
116
119
  import { LibSQLStore } from '@mastra/libsql'
120
+ import { RedisServerCache } from '@mastra/redis'
121
+ import { Redis } from 'ioredis'
117
122
 
118
123
  export const mastra = new Mastra({
119
124
  storage: new LibSQLStore({
@@ -122,14 +127,15 @@ export const mastra = new Mastra({
122
127
  pubsub: new GoogleCloudPubSub({
123
128
  projectId: process.env.GCP_PROJECT_ID!,
124
129
  }),
130
+ cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
125
131
  })
126
132
  ```
127
133
 
128
- Any [supported storage backend](https://mastra.ai/reference/workers/overview) works. Swap the storage adapter for your preferred database.
134
+ Any [supported storage backend](https://mastra.ai/reference/workers/overview) works. Swap the storage adapter for your preferred database. Google Cloud Pub/Sub has no matching server cache, so the second example can use any cache that every process shares: `RedisServerCache` from `@mastra/redis` as shown, `ValkeyServerCache` from `@mastra/valkey`, or `ConvexServerCache` from `@mastra/convex`.
129
135
 
130
136
  Run the same build artifact in multiple containers, each with a different [`MASTRA_WORKERS`](https://mastra.ai/reference/workers/overview) value to control which worker starts in each process.
131
137
 
132
- Split deployments require a distributed PubSub backend ([`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), [`ValkeyStreamsPubSub`](https://mastra.ai/reference/pubsub/valkey-streams), or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)), a shared [storage backend](https://mastra.ai/reference/workers/overview), and network connectivity between the orchestration worker and the API. Messages sent to a running evented agent reach a run on a worker only when the agent's memory uses [storage that shares pending signals across processes](https://mastra.ai/docs/server/pubsub).
138
+ Split deployments require a distributed PubSub backend ([`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), [`ValkeyStreamsPubSub`](https://mastra.ai/reference/pubsub/valkey-streams), or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)), a shared [storage backend](https://mastra.ai/reference/workers/overview), a shared server cache, and network connectivity between the orchestration worker and the API. The cache holds each agent run's numbered stream events and ownership record, so a client can observe and reconnect to a run through any process. Messages sent to a running evented agent reach a run on a worker only when the agent's memory uses [storage that shares pending signals across processes](https://mastra.ai/docs/server/pubsub).
133
139
 
134
140
  ### Select workers
135
141
 
@@ -68,17 +68,17 @@ A durable agent adds three layers on top of a regular agent:
68
68
 
69
69
  2. **PubSub streaming**: The loop publishes chunks to a PubSub topic keyed by the run ID. The caller subscribes to that topic and pipes the chunks into a `ReadableStream`, while the cache replays any chunks missed during a disconnect.
70
70
 
71
- 3. **Cache layer**: An optional cache (in-memory by default, Redis or another backend in production) stores published events so that a late subscriber can catch up.
71
+ 3. **Cache layer**: The server cache stores and numbers published events so that a late subscriber can catch up. It's in-memory by default. A deployment with several processes uses one they all share, such as Redis.
72
72
 
73
73
  ## Execution variants
74
74
 
75
75
  Choose the engine based on where the agent should run:
76
76
 
77
- | Native agent setting | Wrapper equivalent | Best for |
78
- | ------------------------------------ | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
79
- | `durable.executionEngine: 'default'` | `createDurableAgent()` from `@mastra/core/agent/durable` | Local development and single-process servers. You get a stream you can await directly. |
80
- | `durable.executionEngine: 'evented'` | `createEventedAgent()` from `@mastra/core/agent/durable` | Runs in the background, and you can follow the run through PubSub. It can run in one process or across multiple processes with a [supported PubSub backend and storage adapter](https://mastra.ai/docs/server/pubsub). |
81
- | No native setting | `createInngestAgent()` from `@mastra/inngest` | On Inngest, with step memoization, retries, and a monitoring dashboard. |
77
+ | Native agent setting | Wrapper equivalent | Best for |
78
+ | ------------------------------------ | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
79
+ | `durable.executionEngine: 'default'` | `createDurableAgent()` from `@mastra/core/agent/durable` | Local development and single-process servers. You get a stream you can await directly. |
80
+ | `durable.executionEngine: 'evented'` | `createEventedAgent()` from `@mastra/core/agent/durable` | Runs in the background, and you can follow the run through PubSub. It can run in one process or across multiple processes with a [supported PubSub backend, storage adapter, and server cache](https://mastra.ai/docs/server/pubsub). |
81
+ | No native setting | `createInngestAgent()` from `@mastra/inngest` | On Inngest, with step memoization, retries, and a monitoring dashboard. |
82
82
 
83
83
  To set a default for registered native agents, use `durable.executionEngine` on [Mastra](https://mastra.ai/reference/core/mastra-class). An explicit agent setting overrides it. The choice is fixed at registration or first execution. Wrapper factories select their own engine without changing the wrapped agent's selection.
84
84
 
@@ -107,7 +107,7 @@ const agent = new Agent({
107
107
  export const eventedWriter = createEventedAgent({ agent })
108
108
  ```
109
109
 
110
- In one process, an evented agent runs on the default PubSub backend with no extra setup, which is how you try it locally. To run its steps on several processes, such as dedicated [workers](https://mastra.ai/docs/deployment/workers), configure a PubSub backend that redelivers unacknowledged events and a storage adapter with workflow step guards. `EventEmitterPubSub` and `UnixSocketPubSub` don't qualify. Messages sent to a running evented agent reach a run on another process only when the agent's memory uses [storage that shares pending signals across processes](https://mastra.ai/docs/server/pubsub). See [evented workflows and agents](https://mastra.ai/docs/server/pubsub) for the supported backends and adapters.
110
+ In one process, an evented agent runs on the default PubSub backend with no extra setup, which is how you try it locally. To run its steps on several processes, such as dedicated [workers](https://mastra.ai/docs/deployment/workers), configure a PubSub backend that redelivers unacknowledged events, a storage adapter with workflow step guards, and a server cache that every process shares. `EventEmitterPubSub` and `UnixSocketPubSub` don't qualify. Messages sent to a running evented agent reach a run on another process only when the agent's memory uses [storage that shares pending signals across processes](https://mastra.ai/docs/server/pubsub). See [evented workflows and agents](https://mastra.ai/docs/server/pubsub) for the supported backends and adapters.
111
111
 
112
112
  ### Resumable streams for stored agents
113
113
 
@@ -183,21 +183,24 @@ for await (const chunk of output.fullStream) {
183
183
 
184
184
  If you pass `idleTimeoutMs` and no chunks arrive for that long, Mastra checks `isAlive` when you provide it. If `isAlive` returns `true` or throws, the timer restarts and the stream stays open. Otherwise the stream ends with an error chunk and detaches the observer. The run itself is only cleaned up when `isAlive` returns `false`.
185
185
 
186
- `createDurableAgent()` and `createEventedAgent()` use an in-memory cache by default, which means resumable streams work within a single process. For reconnects across processes or replicas, share the replay cache, PubSub transport, and run storage between the producer and observer. A shared transport delivers live events but can't recover events held only in another process's cache. Configure a persistent cache backend (for example, Redis) so retained events survive process restarts:
186
+ A registered durable agent uses the server cache of its `Mastra` instance, `InMemoryServerCache` by default, so resumable streams work within a single process. For reconnects across processes or replicas, set the PubSub backend and a server cache on `Mastra` in the same step, and share run storage between every process. The cache holds the events a reconnect replays and each run's ownership record. A shared transport delivers live events but can't recover events held only in another process's cache. A Redis cache also keeps retained events across process restarts:
187
187
 
188
188
  ```typescript
189
- import { createDurableAgent } from '@mastra/core/agent/durable'
189
+ import { Mastra } from '@mastra/core'
190
190
  import { RedisServerCache } from '@mastra/redis'
191
+ import { RedisStreamsPubSub } from '@mastra/redis-streams'
191
192
  import Redis from 'ioredis'
193
+ import { durableAgent } from './agents/durable-agent'
192
194
 
193
- const cache = new RedisServerCache({ client: new Redis('redis://localhost:6379') })
194
-
195
- export const durableAgent = createDurableAgent({
196
- agent,
197
- cache,
195
+ export const mastra = new Mastra({
196
+ agents: { durableAgent },
197
+ pubsub: new RedisStreamsPubSub({ url: process.env.REDIS_URL! }),
198
+ cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
198
199
  })
199
200
  ```
200
201
 
202
+ `createDurableAgent()` also accepts its own `cache`. Evented agents use the `Mastra` cache for run events even when given one, because their steps publish from whichever process runs them.
203
+
201
204
  `createInngestAgent()` doesn't enable caching by default. Pass a `cache` option or register the agent with a `Mastra` instance that has a `serverCache` configured to enable resumable streams.
202
205
 
203
206
  For cached topics, each published event is recorded in the cache before it's delivered live, so publish latency is bounded by the round-trip to the cache. If the cache write fails, the event is still delivered live but can't be replayed. `@mastra/redis` and `@mastra/valkey` record each event in a single round-trip using a Lua script. `@mastra/redis` falls back to separate commands when the client has no `evalScript` or when Redis Cluster rejects the multi-key script. Per-run workflow watch events (`workflow.events.v2.*`) are never cached. If the cache is remote (for example, in another region) and you don't need to resume a topic, use `shouldCache` to publish that topic straight through:
@@ -205,7 +208,6 @@ For cached topics, each published event is recorded in the cache before it's del
205
208
  ```typescript
206
209
  export const durableAgent = createDurableAgent({
207
210
  agent,
208
- cache,
209
211
  // Skip the replay cache for the per-chunk stream topic; other topics stay resumable.
210
212
  shouldCache: topic => !topic.startsWith('agent.stream.'),
211
213
  })
@@ -408,6 +408,74 @@ claude mcp add --transport http mastra https://my-app.example.com/api/mcp \
408
408
 
409
409
  The endpoint doesn't return `403` with `error="insufficient_scope"` yet. A caller without `mcp:read` gets a plain `403`, because Mastra permissions aren't OAuth scopes a client could request.
410
410
 
411
+ ## Server card
412
+
413
+ The endpoint publishes an experimental [MCP Server Card](https://github.com/modelcontextprotocol/experimental-ext-server-card) at `/api/mcp/server-card`. MCP clients and registries read it before connecting to learn the server's name, version, endpoint URL, and supported protocol versions. It never lists tools, resources, or anything about a user.
414
+
415
+ The card is public, even when `server.auth` is configured, and any origin can read it. It's served whenever the endpoint is, and it follows `server.mcp.path`:
416
+
417
+ ```bash
418
+ curl https://my-app.example.com/api/mcp/server-card
419
+ ```
420
+
421
+ ```json
422
+ {
423
+ "$schema": "https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json",
424
+ "name": "com.example.my-app/mastra",
425
+ "version": "1.0.0",
426
+ "description": "Mastra server exposing agents, workflows, and tools over MCP",
427
+ "title": "Mastra",
428
+ "remotes": [
429
+ {
430
+ "type": "streamable-http",
431
+ "url": "https://my-app.example.com/api/mcp",
432
+ "supportedProtocolVersions": [
433
+ "2026-07-28",
434
+ "2025-11-25",
435
+ "2025-06-18",
436
+ "2025-03-26",
437
+ "2024-11-05",
438
+ "2024-10-07"
439
+ ]
440
+ }
441
+ ]
442
+ }
443
+ ```
444
+
445
+ The name, title, and version come from `server.mcp.serverInfo`, and the URL from the request. Behind a proxy, set `server.mcp.card.url`, or `server.mcp.oauth.resource`, to the public URL. A card with a set URL can also be stored by shared caches. Set `server.mcp.card` to change other fields, or to `false` to stop serving it:
446
+
447
+ ```typescript
448
+ import { Mastra } from '@mastra/core'
449
+
450
+ export const mastra = new Mastra({
451
+ server: {
452
+ mcp: {
453
+ card: {
454
+ name: 'com.example/assistant',
455
+ url: 'https://my-app.example.com/api/mcp',
456
+ },
457
+ },
458
+ },
459
+ })
460
+ ```
461
+
462
+ To publish a card for your own [`MCPServer`](https://mastra.ai/reference/tools/mcp-server), set its `serverCard` option.
463
+
464
+ An invalid `name`, `title`, `description`, `url`, or `websiteUrl` in `server.mcp.card`, such as a `name` without a slash, stops the server at startup with an error naming the field.
465
+
466
+ ### CORS with a server adapter
467
+
468
+ `mastra dev` and `mastra build` send the card's CORS headers whatever `server.cors` is set to. When you mount Mastra in your own app with a [server adapter](https://mastra.ai/docs/server/server-adapters), your app's CORS middleware runs first. A plain cross-origin `GET` still gets `Access-Control-Allow-Origin: *`, but a browser that sends `If-None-Match` from a script first sends a preflight request, and your middleware answers it with its own origin rules. Skip your CORS middleware for the card path so the card answers the preflight itself:
469
+
470
+ ```typescript
471
+ import cors from 'cors'
472
+
473
+ const appCors = cors({ origin: 'https://app.example.com' })
474
+ app.use((req, res, next) =>
475
+ req.path === '/api/mcp/server-card' ? next() : appCors(req, res, next),
476
+ )
477
+ ```
478
+
411
479
  ## Limitations
412
480
 
413
481
  - Workflows run synchronously within the MCP request. Long-running workflows are bounded by your server's request timeout.
@@ -16,7 +16,7 @@ Several built-in systems publish and subscribe to events through the same pub/su
16
16
  - **Scheduled workflows**: The scheduler dispatches due runs by publishing to the workflow topic. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows).
17
17
  - **Background tasks**: A task manager dispatches work to a worker group and fans task lifecycle updates out to subscribers, which is how background task streams stay live. See [Background task streaming](https://mastra.ai/docs/harness/background-tasks).
18
18
  - **Agent signals**: Sending a signal to an active agent run publishes an event on a thread topic. The event reaches the process that holds the run. A step of an evented run that executes in a different process gets the signal only through [storage that shares pending signals across processes](#signals-sent-to-a-running-evented-agent).
19
- - **Resumable streams**: Stream chunks are published per run, so a client that reconnects can replay what it missed.
19
+ - **Resumable streams**: Stream chunks are published per run and recorded in the server cache, so a client that reconnects can replay what it missed.
20
20
 
21
21
  Because these systems run on one bus, the backend you choose applies to all of them at once.
22
22
 
@@ -75,44 +75,49 @@ Use a distributed backend when you run more than one instance or host, and every
75
75
 
76
76
  For example, sending a signal to an agent run requires the signal event to cross the process boundary to the instance that owns the run. With the in-process default, that instance never receives the event.
77
77
 
78
+ Configure a server cache (`cache`) that every instance shares in the same step. Each agent run keeps its ownership record and its numbered event log in that cache. With the default `InMemoryServerCache`, each instance has its own: the observe and abort routes only find a run on the instance that started it, and an [evented agent](#evented-workflows-and-agents) step that runs on another instance publishes events that a reconnecting client can't skip by offset.
79
+
78
80
  [Durable agent](https://mastra.ai/docs/harness/durable-agents) crash recovery also depends on the backend when the storage adapter doesn't support run fencing. Recovery then uses the backend's leases to tell whether another instance still drives a run. `RedisStreamsPubSub` provides leases across hosts. `GoogleCloudPubSub` doesn't.
79
81
 
80
82
  Both backends below deliver across processes and hosts and persist events for redelivery.
81
83
 
82
- The following example uses [Redis Streams](https://redis.io/docs/latest/develop/data-types/streams/):
84
+ The following example uses [Redis Streams](https://redis.io/docs/latest/develop/data-types/streams/), with `RedisServerCache` from `@mastra/redis` on the same Redis:
83
85
 
84
86
  ```typescript
85
87
  import { Mastra } from '@mastra/core'
88
+ import { RedisServerCache } from '@mastra/redis'
86
89
  import { RedisStreamsPubSub } from '@mastra/redis-streams'
90
+ import { Redis } from 'ioredis'
87
91
 
88
92
  export const mastra = new Mastra({
89
- pubsub: new RedisStreamsPubSub({
90
- url: 'redis://localhost:6379',
91
- }),
93
+ pubsub: new RedisStreamsPubSub({ url: process.env.REDIS_URL! }),
94
+ cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
92
95
  })
93
96
  ```
94
97
 
95
- The following example uses [Google Cloud Pub/Sub](https://cloud.google.com/pubsub/docs):
98
+ The following example uses [Google Cloud Pub/Sub](https://cloud.google.com/pubsub/docs). Google Cloud Pub/Sub has no matching server cache, so use any cache that every process shares: `RedisServerCache` from `@mastra/redis` as below, `ValkeyServerCache` from `@mastra/valkey`, or `ConvexServerCache` from `@mastra/convex`.
96
99
 
97
100
  ```typescript
98
101
  import { Mastra } from '@mastra/core'
99
102
  import { GoogleCloudPubSub } from '@mastra/google-cloud-pubsub'
103
+ import { RedisServerCache } from '@mastra/redis'
104
+ import { Redis } from 'ioredis'
100
105
 
101
106
  export const mastra = new Mastra({
102
- pubsub: new GoogleCloudPubSub({
103
- projectId: 'my-project',
104
- }),
107
+ pubsub: new GoogleCloudPubSub({ projectId: 'my-project' }),
108
+ cache: new RedisServerCache({ client: new Redis(process.env.REDIS_URL!) }),
105
109
  })
106
110
  ```
107
111
 
108
112
  ## Evented workflows and agents
109
113
 
110
- Workflows on the [evented execution engine](https://mastra.ai/docs/workflows/scheduled-workflows) and agents using [evented durable execution](https://mastra.ai/docs/harness/durable-agents) advance a run one event at a time. Any worker can take the next event, which lets several processes share one run. That only holds when the deployment has both of the following:
114
+ Workflows on the [evented execution engine](https://mastra.ai/docs/workflows/scheduled-workflows) and agents using [evented durable execution](https://mastra.ai/docs/harness/durable-agents) advance a run one event at a time. Any worker can take the next event, which lets several processes share one run. That only holds when the deployment has the following:
111
115
 
112
116
  - **A PubSub backend that redelivers unacknowledged events**: When a worker stops in the middle of a step, the backend gives the step's event to another worker.
113
117
  - **A storage adapter with workflow step guards**: The backend can deliver the same event more than once, and the step guard keeps a later delivery from saving the step's result a second time. A step can still run more than once, so [make steps with side effects idempotent](https://mastra.ai/docs/workflows/overview).
118
+ - **For evented agents, a server cache that every process shares**: Each step appends its stream events to the run's log in the cache, which numbers them. With the default `InMemoryServerCache`, a step on another process publishes its events without a number, so a client that reconnects with an offset receives most of the run again.
114
119
 
115
- The backends that redeliver are marked **Yes** in the [Choosing a backend](#choosing-a-backend) table. A backend's reference page says whether redelivery can be turned off. The storage adapters with workflow step guards are `@mastra/pg` and `@mastra/libsql`. With `@mastra/libsql`, see [evented agent worker takeover](https://mastra.ai/reference/pubsub/redis-streams) for the database setups that work across machines.
120
+ The backends that redeliver are marked **Yes** in the [Choosing a backend](#choosing-a-backend) table. A backend's reference page says whether redelivery can be turned off. The storage adapters with workflow step guards are `@mastra/pg` and `@mastra/libsql`. With `@mastra/libsql`, see [evented agent worker takeover](https://mastra.ai/reference/pubsub/redis-streams) for the database setups that work across machines. Set the cache as in the [distributed deployment examples](#distributed-deployments).
116
121
 
117
122
  [`EventEmitterPubSub`](https://mastra.ai/reference/pubsub/event-emitter) and [`UnixSocketPubSub`](https://mastra.ai/reference/pubsub/unix-socket-pubsub) don't redeliver an event that a stopped process received and never acknowledged. On the default `EventEmitterPubSub`, evented workflows and agents run in one process, which is how you try the evented engine locally and run it in tests. Don't use either backend to run evented workflows or agents on several processes:
118
123
 
@@ -132,19 +137,23 @@ Messages and other signals sent to an evented agent's active run wait until a mo
132
137
  | `@mastra/libsql` | Yes | [Depends on the connection](https://mastra.ai/integrations/databases/libsql) |
133
138
  | `InMemoryStore` | Yes | No |
134
139
 
135
- A run keeps its signals in storage when the agent's memory uses storage that keeps pending signals and the run is the thread's active run, with a thread and a `resourceId`. A run started with `prepare()` and a run with `readOnly` memory aren't the thread's active run. Any other evented run keeps its signals in the memory of the process that started it, and they reach the run only when that process executes the run's next step. Otherwise the agent answers them in a new turn after the run ends. Input from `queueMessage()` and `queueSignal()` always stays in process memory.
140
+ A run keeps its signals in storage when the agent's memory uses storage that keeps pending signals and the run is the thread's active run, with a thread and a `resourceId`. A run started with `prepare()` and a run with `readOnly` memory aren't the thread's active run. Any other evented run keeps its signals in the memory of the process that started it, and they reach the run only when that process executes the run's next step. Otherwise the agent answers them in a new turn after the run ends. Input from `queueMessage()` and `queueSignal()` waits in the memory of the process that queued it, and is lost if that process stops. When that process finds the thread held by another process's run instead of starting the turn itself, it passes the input to that process. If that run keeps its signals in storage, the passed input is stored as a row that waits for the run to end, and all rows the run releases start the thread's next turn together.
136
141
 
137
142
  A stored signal that the run never takes waits for the thread's next run. The process that started the run starts that next run with the signal when the run ends, if that process is still up. When another run already holds the thread and reads the same storage, that run takes the signal at its next model request, or, if it already made its last one, the signal starts the thread's next turn when that run ends. Otherwise the signal waits for the thread's next run that reads the same storage. A run that fails deletes the signals its failed turn took, whether it fails in the process that started it or on a worker, and the thread's next run receives only the ones it never took. A failure that carries no saved progress is the exception, such as a step that runs out of deliveries with `storageVersion: 2`: the run then puts back the signals it took and never saved, and the thread's next run receives them again. When a run's `modelSettings.timeout.totalMs` deadline fires in the process that started it while another process executes its steps, the starting process saves only the turn's input, and the signals the interrupted step took and never saved go back to pending, so the thread's next run receives them again, also when the run saved earlier progress. A suspended run stops receiving signals once another run uses its thread, and signals sent to it afterwards wait for the thread's next run or are answered `blocked`, as [`sendSignal()`](https://mastra.ai/reference/agents/agent) describes. A signal taken by a step that crashes before the run saves its progress is taken again by the thread's next run if the crashed run never recovers or ends.
138
143
 
139
144
  ### Warning for unsupported setups
140
145
 
141
- Mastra logs a warning the first time an evented run is created in a setup that can't support several processes:
146
+ Mastra logs a warning when a setup can't support several processes:
142
147
 
143
148
  - The PubSub backend delivers to other processes and doesn't redeliver unacknowledged events.
144
149
  - The PubSub backend redelivers unacknowledged events and the storage adapter has no workflow step guards.
150
+ - The PubSub backend delivers to other processes, an evented agent is registered, and the server cache is `InMemoryServerCache`.
145
151
  - The PubSub backend delivers to other processes and an evented agent's active run keeps its signals in one process.
146
152
 
147
- Mastra logs the last case as a separate warning, the first time such a run starts, beginning with `Signals sent to running evented agents aren't supported on several processes with this setup`. It names the cause: the run has no memory, thread, or `resourceId`, the agent's memory storage doesn't keep pending signals, or that storage keeps them in one process.
153
+ The first two cases share one warning, logged the first time an evented run is created. The others are separate warnings:
154
+
155
+ - The server cache warning begins with `Evented agents aren't supported on several processes with this setup` and names the in-memory cache: `cache` on `Mastra`, or the cache of a `CachingPubSub` you configured as `pubsub`. Each process that can run an evented agent's steps logs it at startup, including dedicated workers. Mastra treats any other cache class as shared.
156
+ - The signals warning begins with `Signals sent to running evented agents aren't supported on several processes with this setup`, logged the first time such a run starts. It names the cause: the run has no memory, thread, or `resourceId`, the agent's memory storage doesn't keep pending signals, or that storage keeps them in one process.
148
157
 
149
158
  The default `EventEmitterPubSub` doesn't trigger the warning, because its events never leave the process. `UnixSocketPubSub` triggers it even when one process uses the socket, because Mastra can't tell how many processes share it.
150
159
 
@@ -169,9 +178,9 @@ To disable the warning for a setup that one process uses, set the `MASTRA_DISABL
169
178
 
170
179
  ## Resumable streams
171
180
 
172
- Resumable streams let a client reconnect and replay events it missed, which requires the backend to keep recent history. Distributed backends such as [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) persist events, so they support replay on their own.
181
+ [Resumable streams](https://mastra.ai/docs/agents/resumable-streams) let a client reconnect and replay events it missed. Mastra records each agent run's events in the server cache before publishing them and numbers them, so a client can replay a run from the start or from an offset. Replay reaches across processes only when they share the cache, as in the [distributed deployment examples](#distributed-deployments). [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) also retains events and replays a topic to a new subscriber, but only from the start.
173
182
 
174
- In-process delivery doesn't keep history. To add replay on top of [`EventEmitterPubSub`](https://mastra.ai/reference/pubsub/event-emitter), wrap it in [`CachingPubSub`](https://mastra.ai/reference/pubsub/caching-pubsub), which records published events per topic so a late or reconnecting subscriber can catch up before continuing with live events.
183
+ To record other topics too, wrap the backend in [`CachingPubSub`](https://mastra.ai/reference/pubsub/caching-pubsub). It records events per topic, except those Mastra publishes for the local process only, such as per-run workflow watch events, so a late or reconnecting subscriber can catch up before continuing with live events.
175
184
 
176
185
  ```typescript
177
186
  import { Mastra } from '@mastra/core'
@@ -105,12 +105,14 @@ Signal providers have their own lifecycle. Call [`provider.stop()`](https://mast
105
105
 
106
106
  ## Configuration
107
107
 
108
- A shared Redis Streams backend handles both signal delivery and thread leases:
108
+ A shared Redis Streams backend handles both signal delivery and thread leases, and a Redis server cache goes with it:
109
109
 
110
110
  ```typescript
111
111
  import { Mastra } from '@mastra/core'
112
112
  import { PostgresStore } from '@mastra/pg'
113
+ import { RedisServerCache } from '@mastra/redis'
113
114
  import { RedisStreamsPubSub } from '@mastra/redis-streams'
115
+ import { Redis } from 'ioredis'
114
116
 
115
117
  export const mastra = new Mastra({
116
118
  agents: { agent },
@@ -122,12 +124,16 @@ export const mastra = new Mastra({
122
124
  url: process.env.REDIS_URL,
123
125
  keyPrefix: 'mastra:my-app',
124
126
  }),
127
+ cache: new RedisServerCache(
128
+ { client: new Redis(process.env.REDIS_URL!) },
129
+ { keyPrefix: 'mastra:my-app:cache:' },
130
+ ),
125
131
  })
126
132
  ```
127
133
 
128
- Every instance points `storage` at the same database, so persisted signals, state signals, and notification records survive a restart and are visible to whichever process owns the thread.
134
+ Every instance points `storage` at the same database, so persisted signals, state signals, and notification records survive a restart and are visible to whichever process owns the thread. The shared `cache` holds each run's stream events and ownership record, so a client can observe a run and reconnect to it through any instance.
129
135
 
130
- Use the same `keyPrefix` on every coordinating instance, and a different prefix for environments sharing one Redis server. Vercel's managed Redis and Upstash Redis both work with `RedisStreamsPubSub`.
136
+ Use the same `keyPrefix` values on every coordinating instance, and give environments sharing one Redis server their own prefix on both the pubsub and the cache. Vercel's managed Redis and Upstash Redis both work with `RedisStreamsPubSub`.
131
137
 
132
138
  The lease settings are environment variables:
133
139
 
@@ -67,7 +67,7 @@ const result = agent.queueMessage('Also check whether the tests need updates.',
67
67
  await result.accepted
68
68
  ```
69
69
 
70
- Queued input waits for the active run to finish, then starts a new run. On an idle thread it starts immediately. [`cancelQueuedMessages()`](https://mastra.ai/reference/agents/agent) removes input that no run has taken yet, without stopping the active run. Its awaited result lists the IDs this process cancelled, including ones it deleted from memory storage when it knows the thread's store: this process started the thread's current run and that run hasn't ended, or the agent's memory is a fixed instance and this process knows the thread's run keeps its signals in storage. Other processes cancel matching input when they get the request, and those IDs aren't in the result. Input a run already took stays delivered.
70
+ Queued input waits for the active run to finish, then starts a new run. On an idle thread it starts immediately. A run paused on a tool's `suspend()` with `autoResumeSuspendedTools` enabled counts as finished. Queued input starts the next run, which [resumes the tool](https://mastra.ai/docs/agents/human-in-the-loop). Input passed to another process because that process holds the thread's run is the exception when that run [keeps its signals in storage](https://mastra.ai/docs/server/pubsub): it's stored, and all input passed to that run starts one new run together. [`cancelQueuedMessages()`](https://mastra.ai/reference/agents/agent) removes input that no run has taken yet, without stopping the active run. Its awaited result lists the IDs this process cancelled, including ones it deleted from memory storage when it knows the thread's store: this process started the thread's current run and that run hasn't ended, or the agent's memory is a fixed instance and this process knows the thread's run keeps its signals in storage. Other processes cancel matching input when they get the request, and those IDs aren't in the result. Input a run already took stays delivered.
71
71
 
72
72
  [`queueSignal()`](https://mastra.ai/reference/agents/agent) queues typed context with the same behavior but keeps the signal's `type`, `tagName`, and attributes.
73
73
 
@@ -127,7 +127,7 @@ export const testWorkflow = createWorkflow({
127
127
  message: z.string()
128
128
  }),
129
129
  outputSchema: z.object({
130
- output: z.string()
130
+ formatted: z.string()
131
131
  })
132
132
  })
133
133
  .then(step1)
@@ -149,7 +149,7 @@ export const testWorkflow = createWorkflow({
149
149
  message: v.string()
150
150
  })),
151
151
  outputSchema: toStandardJsonSchema(v.object({
152
- output: v.string()
152
+ formatted: v.string()
153
153
  }))
154
154
  })
155
155
  .then(step1)
@@ -170,7 +170,7 @@ export const testWorkflow = createWorkflow({
170
170
  message: "string"
171
171
  }),
172
172
  outputSchema: type({
173
- output: "string"
173
+ formatted: "string"
174
174
  })
175
175
  })
176
176
  .then(step1)
@@ -237,7 +237,9 @@ For an evented agent on [storage that keeps pending signals](https://mastra.ai/d
237
237
 
238
238
  ### `queueMessage(message, options)`
239
239
 
240
- Queues a user message for the next turn on a thread. If the thread is active, Mastra waits for the active run to finish, then starts a new run with the queued message. If the thread is idle, Mastra starts a run immediately.
240
+ Queues a user message for the next turn on a thread. If the thread is active, Mastra waits for the active run to finish, then starts a new run with the queued message. If the thread is idle, Mastra starts a run immediately. Messages passed to another process because it holds the thread's run are stored when that run [keeps its signals in storage](https://mastra.ai/docs/server/pubsub), and start one new run together when that run ends.
241
+
242
+ A run paused on a tool's `suspend()` with `autoResumeSuspendedTools` enabled counts as finished, because it's waiting for the user's next message. The queued message starts the next run, which [resumes the tool](https://mastra.ai/docs/agents/human-in-the-loop). A run paused for a tool approval or without `autoResumeSuspendedTools` keeps the message queued until it finishes.
241
243
 
242
244
  ```typescript
243
245
  agent.queueMessage('Also check whether the tests need updates.', {
@@ -111,7 +111,7 @@ Returns: `DurableAgent`
111
111
 
112
112
  Wraps an `Agent` with fire-and-forget durable execution on the built-in evented workflow engine. Like `createDurableAgent`, it returns a result you stream from, but the run is started without being awaited: events on the Mastra instance's PubSub drive execution independently of the caller. Register the agent on a `Mastra` instance with storage to get evented execution; without one, the agent falls back to the default in-process engine and logs a warning. It doesn't accept `id` or `name` overrides.
113
113
 
114
- An evented agent runs in one process on any PubSub backend. Running its steps on several processes needs a backend that redelivers unacknowledged events and a storage adapter with workflow step guards. See [evented workflows and agents](https://mastra.ai/docs/server/pubsub).
114
+ An evented agent runs in one process on any PubSub backend. Running its steps on several processes needs a backend that redelivers unacknowledged events, a storage adapter with workflow step guards, and a server cache on `Mastra` that every process shares. See [evented workflows and agents](https://mastra.ai/docs/server/pubsub).
115
115
 
116
116
  ```typescript
117
117
  import { createEventedAgent } from '@mastra/core/agent/durable'
@@ -125,7 +125,7 @@ Returns: `EventedAgent` (a subclass of `DurableAgent`)
125
125
 
126
126
  **agent** (`Agent`): The Agent to wrap with evented durable execution capabilities.
127
127
 
128
- **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.
128
+ **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. Once the agent is registered, evented run frames use the Mastra cache instead, because evented steps append there. Set to false to disable caching.
129
129
 
130
130
  **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`)
131
131
 
@@ -250,7 +250,7 @@ Indexed replay is limited to events still available in the configured cache. The
250
250
 
251
251
  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`.
252
252
 
253
- 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.
253
+ With a PubSub that reaches other processes, such as Redis Streams, set a server cache that every process shares, such as `RedisServerCache`, on the `Mastra` instance. With the default in-memory cache, a step of an evented agent (`createEventedAgent()`) that runs outside the process that started the run, such as on a dedicated worker, publishes its events without an index, so an offset can't skip them. An observer that reconnects through another process, such as a different server replica, can't replay from the starting process's cache either. Mastra logs a warning at startup when an evented agent runs on this setup. See [evented workflows and agents](https://mastra.ai/docs/server/pubsub).
254
254
 
255
255
  By default `observe()` waits indefinitely for events. If the process running the run dies, 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.
256
256