@mastra/core 1.86.0-alpha.7 → 1.86.0-alpha.8

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 (419) hide show
  1. package/dist/agent/agent.d.ts +60 -1
  2. package/dist/agent/agent.types.d.ts +30 -2
  3. package/dist/agent/durable/create-evented-agent.d.ts +6 -0
  4. package/dist/agent/durable/durable-agent.d.ts +1 -15
  5. package/dist/agent/durable/index.cjs +7 -14
  6. package/dist/agent/durable/index.js +7 -14
  7. package/dist/agent/index.cjs +2 -2
  8. package/dist/agent/index.js +2 -2
  9. package/dist/agent/types.d.ts +25 -0
  10. package/dist/agent-builder/ee/index.cjs +1 -1
  11. package/dist/agent-builder/ee/index.js +1 -1
  12. package/dist/agent-controller/index.cjs +1 -1
  13. package/dist/agent-controller/index.js +1 -1
  14. package/dist/{agent-controller-Cf3_IuY8.js → agent-controller-B7POPub5.js} +7 -7
  15. package/dist/{agent-controller-K5vHtqfO.cjs → agent-controller-DEPayioq.cjs} +7 -7
  16. package/dist/background-tasks/index.cjs +1 -1
  17. package/dist/background-tasks/index.js +1 -1
  18. package/dist/{background-tasks-DqnQMfuf.cjs → background-tasks-7iftnRK_.cjs} +1 -1
  19. package/dist/{background-tasks-BgpX1P_s.js → background-tasks-Cv1ecD6S.js} +1 -1
  20. package/dist/browser/index.cjs +2 -2
  21. package/dist/browser/index.js +2 -2
  22. package/dist/{builder-D8Osghdo.cjs → builder-DuJBbQDH.cjs} +2 -2
  23. package/dist/{builder-x295GDL6.js → builder-Gg-xnX_E.js} +2 -2
  24. package/dist/capabilities/302ai.json +194 -194
  25. package/dist/capabilities/abliteratedllm.json +32 -32
  26. package/dist/capabilities/abliteration-ai.json +11 -11
  27. package/dist/capabilities/above.json +12 -12
  28. package/dist/capabilities/adaption.json +13 -13
  29. package/dist/capabilities/adzuki.json +32 -32
  30. package/dist/capabilities/agentrouter.json +6 -6
  31. package/dist/capabilities/agnes.json +2 -2
  32. package/dist/capabilities/ai-router.json +5 -5
  33. package/dist/capabilities/aiand.json +23 -23
  34. package/dist/capabilities/aigrow.json +11 -11
  35. package/dist/capabilities/aimlapi.json +144 -144
  36. package/dist/capabilities/aixy.json +21 -21
  37. package/dist/capabilities/aki-io.json +15 -15
  38. package/dist/capabilities/alibaba-cn.json +79 -79
  39. package/dist/capabilities/alibaba-coding-plan-cn.json +2 -2
  40. package/dist/capabilities/alibaba-coding-plan.json +2 -2
  41. package/dist/capabilities/alibaba-token-plan-cn.json +52 -52
  42. package/dist/capabilities/alibaba-token-plan.json +53 -53
  43. package/dist/capabilities/alibaba.json +70 -70
  44. package/dist/capabilities/ambient.json +15 -15
  45. package/dist/capabilities/amd.json +9 -9
  46. package/dist/capabilities/anthropic.json +48 -48
  47. package/dist/capabilities/anyapi.json +12 -12
  48. package/dist/capabilities/apiko.json +4 -4
  49. package/dist/capabilities/arcee.json +10 -10
  50. package/dist/capabilities/augure.json +6 -6
  51. package/dist/capabilities/auriko.json +18 -18
  52. package/dist/capabilities/bailing.json +5 -5
  53. package/dist/capabilities/baseten.json +26 -26
  54. package/dist/capabilities/bee.json +4 -4
  55. package/dist/capabilities/berget.json +6 -6
  56. package/dist/capabilities/bothub.json +14 -14
  57. package/dist/capabilities/boundless.json +41 -41
  58. package/dist/capabilities/bumo.json +39 -39
  59. package/dist/capabilities/byteplus.json +34 -34
  60. package/dist/capabilities/cheapaimodel.json +7 -7
  61. package/dist/capabilities/cheapest-token.json +33 -33
  62. package/dist/capabilities/chutes.json +10 -10
  63. package/dist/capabilities/cline-pass.json +35 -35
  64. package/dist/capabilities/cloudcode.json +8 -8
  65. package/dist/capabilities/cloudferro-sherlock.json +4 -4
  66. package/dist/capabilities/cloudflare-workers-ai.json +31 -31
  67. package/dist/capabilities/commandcode.json +148 -148
  68. package/dist/capabilities/concentrate.json +277 -253
  69. package/dist/capabilities/cortecs.json +113 -113
  70. package/dist/capabilities/crossmodel.json +172 -172
  71. package/dist/capabilities/crusoe.json +9 -9
  72. package/dist/capabilities/daoxe.json +8 -8
  73. package/dist/capabilities/databricks.json +54 -54
  74. package/dist/capabilities/deepinfra.json +95 -86
  75. package/dist/capabilities/deepseek.json +3 -3
  76. package/dist/capabilities/digitalocean.json +117 -117
  77. package/dist/capabilities/dothoosh.json +35 -35
  78. package/dist/capabilities/doubleword.json +29 -29
  79. package/dist/capabilities/edenai.json +456 -456
  80. package/dist/capabilities/empiriolabs.json +174 -174
  81. package/dist/capabilities/engy.json +20 -20
  82. package/dist/capabilities/entrim.json +6 -6
  83. package/dist/capabilities/evroc.json +10 -10
  84. package/dist/capabilities/ezkielyna.json +10 -10
  85. package/dist/capabilities/fastrouter.json +77 -77
  86. package/dist/capabilities/fireworks-ai.json +60 -60
  87. package/dist/capabilities/freemodel.json +17 -17
  88. package/dist/capabilities/frogbot.json +93 -93
  89. package/dist/capabilities/gisoo.json +19 -19
  90. package/dist/capabilities/gmicloud.json +19 -19
  91. package/dist/capabilities/google.json +59 -59
  92. package/dist/capabilities/graphn.json +9 -9
  93. package/dist/capabilities/greenpt.json +34 -34
  94. package/dist/capabilities/groq.json +8 -8
  95. package/dist/capabilities/helicone.json +83 -83
  96. package/dist/capabilities/hopper.json +2 -2
  97. package/dist/capabilities/hostinger-router.json +9 -9
  98. package/dist/capabilities/hpc-ai.json +11 -11
  99. package/dist/capabilities/huawei-maas.json +13 -13
  100. package/dist/capabilities/hubris.json +33 -33
  101. package/dist/capabilities/huggingface.json +60 -51
  102. package/dist/capabilities/humain.json +2 -2
  103. package/dist/capabilities/hyper.json +27 -27
  104. package/dist/capabilities/impossibl.json +118 -118
  105. package/dist/capabilities/inception.json +3 -3
  106. package/dist/capabilities/inceptron.json +8 -8
  107. package/dist/capabilities/inco.json +4 -4
  108. package/dist/capabilities/infer.json +15 -15
  109. package/dist/capabilities/inferall.json +10 -10
  110. package/dist/capabilities/inference-coop.json +12 -12
  111. package/dist/capabilities/inferenceapis.json +20 -20
  112. package/dist/capabilities/inferris.json +4 -4
  113. package/dist/capabilities/infersia.json +8 -8
  114. package/dist/capabilities/inferx.json +3 -3
  115. package/dist/capabilities/infomaniak.json +4 -4
  116. package/dist/capabilities/io-net.json +4 -4
  117. package/dist/capabilities/iteracompute.json +63 -63
  118. package/dist/capabilities/jad-ai.json +3 -3
  119. package/dist/capabilities/jalapeno.json +11 -11
  120. package/dist/capabilities/jiekou.json +63 -63
  121. package/dist/capabilities/joingonka.json +4 -4
  122. package/dist/capabilities/jzstoken.json +52 -52
  123. package/dist/capabilities/keln.json +26 -26
  124. package/dist/capabilities/kenari.json +127 -127
  125. package/dist/capabilities/kilo.json +604 -628
  126. package/dist/capabilities/kimi-code-plan-cn.json +4 -4
  127. package/dist/capabilities/kimi-code-plan-global.json +4 -4
  128. package/dist/capabilities/kitani.json +6 -6
  129. package/dist/capabilities/klavo.json +26 -26
  130. package/dist/capabilities/korouter.json +34 -34
  131. package/dist/capabilities/kunavo.json +4 -4
  132. package/dist/capabilities/liquid.json +10 -10
  133. package/dist/capabilities/lithosai.json +2 -2
  134. package/dist/capabilities/llmgateway-providers.json +934 -907
  135. package/dist/capabilities/llmgateway.json +339 -339
  136. package/dist/capabilities/llmtr.json +27 -27
  137. package/dist/capabilities/longcat.json +2 -2
  138. package/dist/capabilities/lowrouter.json +53 -53
  139. package/dist/capabilities/lyceum.json +8 -8
  140. package/dist/capabilities/melious.json +13 -13
  141. package/dist/capabilities/merge-gateway.json +284 -284
  142. package/dist/capabilities/meta.json +11 -11
  143. package/dist/capabilities/minimax-cn-coding-plan.json +6 -6
  144. package/dist/capabilities/minimax-coding-plan.json +6 -6
  145. package/dist/capabilities/mistral.json +22 -22
  146. package/dist/capabilities/mixlayer.json +3 -3
  147. package/dist/capabilities/modal.json +13 -13
  148. package/dist/capabilities/model-oracle-ai.json +23 -23
  149. package/dist/capabilities/modelis.json +21 -21
  150. package/dist/capabilities/modelscope.json +2 -2
  151. package/dist/capabilities/modular.json +10 -10
  152. package/dist/capabilities/moneo.json +14 -14
  153. package/dist/capabilities/moonshotai-cn.json +7 -7
  154. package/dist/capabilities/moonshotai.json +7 -7
  155. package/dist/capabilities/morph.json +15 -15
  156. package/dist/capabilities/munito-eu.json +8 -8
  157. package/dist/capabilities/munito.json +10 -10
  158. package/dist/capabilities/nan.json +25 -25
  159. package/dist/capabilities/nano-gpt.json +570 -570
  160. package/dist/capabilities/nearai.json +87 -87
  161. package/dist/capabilities/nebius.json +41 -32
  162. package/dist/capabilities/neon.json +132 -132
  163. package/dist/capabilities/neuralwatt.json +38 -38
  164. package/dist/capabilities/novita-ai.json +153 -153
  165. package/dist/capabilities/nvidia.json +28 -28
  166. package/dist/capabilities/obscurify.json +33 -33
  167. package/dist/capabilities/oci.json +6 -6
  168. package/dist/capabilities/ofox.json +322 -322
  169. package/dist/capabilities/ollama-cloud.json +52 -52
  170. package/dist/capabilities/openai.json +47 -47
  171. package/dist/capabilities/opencode-go.json +79 -78
  172. package/dist/capabilities/openreason.json +5 -5
  173. package/dist/capabilities/openrouter.json +520 -530
  174. package/dist/capabilities/opper.json +30 -24
  175. package/dist/capabilities/orcarouter.json +227 -227
  176. package/dist/capabilities/outerlabs.json +28 -28
  177. package/dist/capabilities/ovhcloud.json +8 -8
  178. package/dist/capabilities/pareto.json +5 -5
  179. package/dist/capabilities/perplexity-agent.json +64 -64
  180. package/dist/capabilities/perplexity.json +2 -2
  181. package/dist/capabilities/phala.json +36 -36
  182. package/dist/capabilities/pioneer.json +30 -30
  183. package/dist/capabilities/poe.json +109 -109
  184. package/dist/capabilities/powerspring.json +10 -10
  185. package/dist/capabilities/primalabs.json +10 -10
  186. package/dist/capabilities/prime.json +116 -99
  187. package/dist/capabilities/privatemode-ai.json +10 -10
  188. package/dist/capabilities/proxystacks.json +7 -7
  189. package/dist/capabilities/qiniu-ai.json +12 -12
  190. package/dist/capabilities/refuseless.json +8 -8
  191. package/dist/capabilities/regolo-ai.json +8 -8
  192. package/dist/capabilities/requesty.json +172 -172
  193. package/dist/capabilities/ruapi.json +21 -21
  194. package/dist/capabilities/runcrate.json +15 -15
  195. package/dist/capabilities/runinfra.json +20 -20
  196. package/dist/capabilities/sakana.json +7 -7
  197. package/dist/capabilities/sambanova.json +4 -4
  198. package/dist/capabilities/sandbase.json +30 -30
  199. package/dist/capabilities/sarvam.json +5 -5
  200. package/dist/capabilities/scaleway.json +17 -17
  201. package/dist/capabilities/scnet-token-plan.json +8 -8
  202. package/dist/capabilities/scx-ai.json +26 -26
  203. package/dist/capabilities/sensenova.json +7 -7
  204. package/dist/capabilities/siliconflow-cn.json +45 -45
  205. package/dist/capabilities/siliconflow.json +59 -59
  206. package/dist/capabilities/snowflake-cortex.json +25 -25
  207. package/dist/capabilities/sokkan.json +9 -9
  208. package/dist/capabilities/sparrowcodes.json +23 -23
  209. package/dist/capabilities/standardcompute.json +103 -103
  210. package/dist/capabilities/steadyrouter.json +39 -39
  211. package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
  212. package/dist/capabilities/stepfun-ai.json +6 -6
  213. package/dist/capabilities/stepfun-step-plan.json +6 -6
  214. package/dist/capabilities/stepfun.json +6 -6
  215. package/dist/capabilities/stepping-stone.json +13 -13
  216. package/dist/capabilities/subconscious.json +2 -2
  217. package/dist/capabilities/synthetic.json +11 -11
  218. package/dist/capabilities/synthorai.json +27 -27
  219. package/dist/capabilities/teamorouter.json +30 -30
  220. package/dist/capabilities/teapot-router.json +13 -13
  221. package/dist/capabilities/tencent-token-plan.json +24 -24
  222. package/dist/capabilities/tencent-tokenhub.json +9 -9
  223. package/dist/capabilities/tensorx.json +45 -45
  224. package/dist/capabilities/tenstorrent.json +6 -6
  225. package/dist/capabilities/the-grid-ai.json +24 -24
  226. package/dist/capabilities/thinkingmachines.json +59 -59
  227. package/dist/capabilities/tinfoil.json +14 -14
  228. package/dist/capabilities/toapis.json +2 -2
  229. package/dist/capabilities/togetherai.json +53 -53
  230. package/dist/capabilities/tokengo.json +25 -25
  231. package/dist/capabilities/tokenify.json +10 -10
  232. package/dist/capabilities/trustedrouter.json +7 -7
  233. package/dist/capabilities/trustedtokens.json +16 -16
  234. package/dist/capabilities/umans-ai-coding-plan.json +15 -15
  235. package/dist/capabilities/umans-ai.json +8 -8
  236. package/dist/capabilities/uncensuredai.json +4 -4
  237. package/dist/capabilities/unrestricted.json +4 -4
  238. package/dist/capabilities/uplinkswitch.json +20 -20
  239. package/dist/capabilities/upstage.json +6 -6
  240. package/dist/capabilities/vancine.json +22 -22
  241. package/dist/capabilities/vercel.json +569 -577
  242. package/dist/capabilities/vivgrid.json +80 -80
  243. package/dist/capabilities/volcengine-coding-plan.json +26 -26
  244. package/dist/capabilities/volcengine.json +30 -30
  245. package/dist/capabilities/vultr.json +25 -25
  246. package/dist/capabilities/wafer.ai.json +18 -18
  247. package/dist/capabilities/wallaby.json +5 -5
  248. package/dist/capabilities/wally.json +8 -8
  249. package/dist/capabilities/wandb.json +20 -20
  250. package/dist/capabilities/watt.json +20 -20
  251. package/dist/capabilities/xai.json +6 -6
  252. package/dist/capabilities/xiaomi.json +5 -5
  253. package/dist/capabilities/xpersona.json +12 -12
  254. package/dist/capabilities/xxapi.json +33 -33
  255. package/dist/capabilities/zai-coding-plan.json +9 -9
  256. package/dist/capabilities/zai.json +27 -27
  257. package/dist/capabilities/zenifra.json +23 -23
  258. package/dist/capabilities/zenmux.json +192 -192
  259. package/dist/capabilities/zerogpu.json +10 -10
  260. package/dist/capabilities/zhipuai-coding-plan.json +7 -7
  261. package/dist/capabilities/zhipuai.json +26 -26
  262. package/dist/capabilities/zro.json +6 -6
  263. package/dist/channels/index.cjs +2 -2
  264. package/dist/channels/index.js +2 -2
  265. package/dist/{channels-Dx4jiXeK.js → channels-BRVCOutx.js} +1 -1
  266. package/dist/{channels-q6qnuRNV.cjs → channels-MjTA9bFp.cjs} +1 -1
  267. package/dist/coding-agent/index.cjs +2 -2
  268. package/dist/coding-agent/index.js +2 -2
  269. package/dist/datasets/dataset.d.ts +13 -6
  270. package/dist/datasets/experiment/durable.d.ts +16 -0
  271. package/dist/datasets/experiment/index.d.ts +2 -1
  272. package/dist/datasets/experiment/item.d.ts +26 -4
  273. package/dist/datasets/experiment/retries.d.ts +18 -0
  274. package/dist/datasets/experiment/types.d.ts +18 -0
  275. package/dist/datasets/experiment/workflow-id.d.ts +7 -0
  276. package/dist/datasets/experiment/workflow.d.ts +74 -0
  277. package/dist/datasets/index.cjs +3 -2
  278. package/dist/datasets/index.d.ts +2 -1
  279. package/dist/datasets/index.js +3 -3
  280. package/dist/docs/SKILL.md +2 -2
  281. package/dist/docs/assets/SOURCE_MAP.json +790 -790
  282. package/dist/docs/references/docs-deployment-workers.md +1 -1
  283. package/dist/docs/references/docs-evals-experiments.md +29 -1
  284. package/dist/docs/references/docs-harness-durable-agents.md +9 -5
  285. package/dist/docs/references/docs-knowledge-agents-and-tools.md +1 -0
  286. package/dist/docs/references/docs-knowledge-load-your-content.md +1 -1
  287. package/dist/docs/references/docs-mastra-platform-observability-overview.md +1 -1
  288. package/dist/docs/references/docs-server-pubsub.md +51 -8
  289. package/dist/docs/references/docs-signals-running-across-processes.md +2 -0
  290. package/dist/docs/references/docs-workflows-overview.md +1 -1
  291. package/dist/docs/references/docs-workflows-scheduled-workflows.md +1 -1
  292. package/dist/docs/references/integrations-channels-slack.md +4 -2
  293. package/dist/docs/references/integrations.md +6 -0
  294. package/dist/docs/references/reference-agents-agent.md +2 -0
  295. package/dist/docs/references/reference-agents-channels.md +116 -27
  296. package/dist/docs/references/reference-agents-durable-agent.md +2 -0
  297. package/dist/docs/references/reference-datasets-runExperimentItem.md +13 -1
  298. package/dist/docs/references/reference-datasets-startExperimentAsync.md +3 -1
  299. package/dist/docs/references/reference-editor-mastra-editor.md +3 -1
  300. package/dist/docs/references/reference-knowledge-knowledge-class.md +2 -2
  301. package/dist/docs/references/reference-knowledge-knowledge-tools.md +43 -20
  302. package/dist/docs/references/reference-processors-moderation-processor.md +2 -2
  303. package/dist/docs/references/reference-pubsub-base.md +5 -1
  304. package/dist/docs/references/reference-pubsub-event-emitter.md +2 -0
  305. package/dist/docs/references/reference-pubsub-redis-streams.md +1 -1
  306. package/dist/docs/references/reference-pubsub-unix-socket-pubsub.md +2 -0
  307. package/dist/docs/references/reference-streaming-ChunkType.md +1 -1
  308. package/dist/docs/references/reference-workers-overview.md +1 -1
  309. package/dist/docs/references/reference-workflows-run-methods-start.md +23 -0
  310. package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +4 -0
  311. package/dist/docs/references/reference-workflows-run.md +1 -1
  312. package/dist/evals/index.cjs +1 -1
  313. package/dist/evals/index.js +1 -1
  314. package/dist/evals/scoreTraces/index.cjs +1 -1
  315. package/dist/evals/scoreTraces/index.js +1 -1
  316. package/dist/events/caching-pubsub.d.ts +1 -0
  317. package/dist/events/event-emitter/index.d.ts +12 -5
  318. package/dist/events/index.cjs +15 -1
  319. package/dist/events/index.js +15 -1
  320. package/dist/events/pubsub.d.ts +29 -0
  321. package/dist/events/reach.d.ts +11 -0
  322. package/dist/events/unix-socket-pubsub.d.ts +14 -0
  323. package/dist/harness/index.cjs +1 -1
  324. package/dist/harness/index.js +1 -1
  325. package/dist/index.cjs +1 -1
  326. package/dist/index.js +1 -1
  327. package/dist/knowledge/index.cjs +1 -1
  328. package/dist/knowledge/index.js +1 -1
  329. package/dist/llm/index.cjs +3 -3
  330. package/dist/llm/index.js +3 -3
  331. package/dist/llm/model/provider-types.generated.d.ts +8092 -8089
  332. package/dist/llm/model/shared.types.d.ts +31 -0
  333. package/dist/{llm-DnXK3Pmw.js → llm-Djd8Qzi0.js} +2 -2
  334. package/dist/{llm-CsQuqKPc.cjs → llm-DmUucguC.cjs} +2 -2
  335. package/dist/loop/index.cjs +2 -2
  336. package/dist/loop/index.js +2 -2
  337. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +2 -2
  338. package/dist/{manager-BsghM-UL.js → manager-CO_Xz2zR.js} +460 -94
  339. package/dist/{manager-DwFnIrI6.cjs → manager-D27PkIPo.cjs} +476 -92
  340. package/dist/mastra/index.cjs +1 -1
  341. package/dist/mastra/index.d.ts +13 -0
  342. package/dist/mastra/index.js +1 -1
  343. package/dist/{mastra-B8i1UDZs.js → mastra-Ch00nEAJ.js} +31 -16
  344. package/dist/{mastra-Cn5NC6Es.cjs → mastra-qsVWpOTi.cjs} +31 -16
  345. package/dist/memory/index.cjs +2 -2
  346. package/dist/memory/index.js +2 -2
  347. package/dist/{model-CsOcWMUt.js → model-CW-mfGYA.js} +1 -1
  348. package/dist/{model-CNPfry_X.cjs → model-Do6DTJoj.cjs} +1 -1
  349. package/dist/{netlify-C-83Fxus.cjs → netlify-DU32SDT6.cjs} +1 -1
  350. package/dist/{netlify-C-OpNSGp.js → netlify-DZSAbdve.js} +1 -1
  351. package/dist/notifications/index.cjs +1 -1
  352. package/dist/notifications/index.js +1 -1
  353. package/dist/{output-helpers-JL-HeCbT.cjs → output-helpers-1Zu4Vt9C.cjs} +68 -25
  354. package/dist/{output-helpers-D4II19No.js → output-helpers-CedRCE17.js} +69 -26
  355. package/dist/processor-provider/index.cjs +1 -1
  356. package/dist/processor-provider/index.js +1 -1
  357. package/dist/processors/index.cjs +2 -2
  358. package/dist/processors/index.js +2 -2
  359. package/dist/{provider-registry-RZ8EgSe8.js → provider-registry-deA0x-Gd.js} +22467 -22456
  360. package/dist/{provider-registry-9O-H9osy.cjs → provider-registry-zGezZVsL.cjs} +22467 -22456
  361. package/dist/provider-registry.json +22423 -22408
  362. package/dist/{registry-generator-DxCX-FiO.cjs → registry-generator-BkQ1AxZn.cjs} +1 -1
  363. package/dist/{registry-generator-e8sltJls.js → registry-generator-VvBfOKAD.js} +1 -1
  364. package/dist/{rehydrate-D3fPgJwp.js → rehydrate-BjLV643n.js} +2 -2
  365. package/dist/{rehydrate-B-wrAN7C.cjs → rehydrate-DDYFpQsV.cjs} +2 -2
  366. package/dist/relevance/index.cjs +2 -2
  367. package/dist/relevance/index.js +2 -2
  368. package/dist/{run-registry-5_LQBGn_.cjs → run-registry-5Suldxz3.cjs} +519 -71
  369. package/dist/{run-registry-DC03XLeZ.js → run-registry-CGRPldLH.js} +519 -71
  370. package/dist/storage/domains/knowledge/base.d.ts +5 -0
  371. package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
  372. package/dist/storage/domains/knowledge/pages.d.ts +24 -7
  373. package/dist/storage/index.cjs +2 -2
  374. package/dist/storage/index.js +2 -2
  375. package/dist/stream/base/output.d.ts +42 -15
  376. package/dist/stream/index.cjs +2 -2
  377. package/dist/stream/index.js +2 -2
  378. package/dist/stream/types.d.ts +19 -0
  379. package/dist/{stream-CJUm6EAH.js → stream-Dpwx0whf.js} +1 -1
  380. package/dist/{stream-4aNIw_TQ.cjs → stream-Dvy_0o14.cjs} +1 -1
  381. package/dist/test-utils/llm-mock.cjs +1 -1
  382. package/dist/test-utils/llm-mock.js +1 -1
  383. package/dist/tool-loop-agent/index.cjs +1 -1
  384. package/dist/tool-loop-agent/index.js +1 -1
  385. package/dist/{tool-loop-agent-FEEwHfmg.js → tool-loop-agent-PbWrEj1k.js} +3 -3
  386. package/dist/{tool-loop-agent-Dn0QCB9n.cjs → tool-loop-agent-UxOv3FoK.cjs} +3 -3
  387. package/dist/tools/types.d.ts +27 -1
  388. package/dist/{utils-DY01hxVd.cjs → utils-BbMTlyBO.cjs} +1 -1
  389. package/dist/{utils-Bd_y1_a-.js → utils-BnNi1BYM.js} +1 -1
  390. package/dist/utils.cjs +1 -1
  391. package/dist/utils.js +1 -1
  392. package/dist/{validate-CX0yQo_q.js → validate-HSBcm96b.js} +1 -1
  393. package/dist/{validate-CuB_1Zd3.cjs → validate-Skps-cM3.cjs} +1 -1
  394. package/dist/vector/index.cjs +1 -1
  395. package/dist/vector/index.js +1 -1
  396. package/dist/worker/index.cjs +1 -1
  397. package/dist/worker/index.js +1 -1
  398. package/dist/{worker-GsGIxPMa.cjs → worker-BE-0DyKL.cjs} +2 -2
  399. package/dist/{worker-DSEfMPmq.js → worker-BKrKHZzU.js} +2 -2
  400. package/dist/{worker-CbaSmip-.cjs → worker-BNS5A3qP.cjs} +2 -2
  401. package/dist/{worker-B80xkcKG.js → worker-DehaD4qD.js} +2 -2
  402. package/dist/{workflow-CnBPXTpv.cjs → workflow-BjUTwaK9.cjs} +4 -4
  403. package/dist/{workflow-CZHY_C85.js → workflow-Bvw6yDjc.js} +4 -4
  404. package/dist/workflows/builder/index.cjs +1 -1
  405. package/dist/workflows/builder/index.js +1 -1
  406. package/dist/workflows/evented/index.cjs +1 -1
  407. package/dist/workflows/evented/index.js +1 -1
  408. package/dist/workflows/evented/setup-warning.d.ts +18 -0
  409. package/dist/workflows/evented/workflow-event-processor/run-status.d.ts +37 -0
  410. package/dist/workflows/evented/workflow.d.ts +10 -0
  411. package/dist/workflows/index.cjs +4 -4
  412. package/dist/workflows/index.js +4 -4
  413. package/dist/workflows/workflow.d.ts +6 -1
  414. package/dist/workspace/index.cjs +1 -1
  415. package/dist/workspace/index.js +1 -1
  416. package/dist/{workspace-D7TIleIt.js → workspace-C05xDH60.js} +160 -7
  417. package/dist/{workspace-D2drutNg.cjs → workspace-D1OzzlLw.cjs} +160 -7
  418. package/package.json +6 -6
  419. package/src/llm/model/provider-types.generated.d.ts +8092 -8089
@@ -1,17 +1,17 @@
1
1
  import { i as __toESM, t as __commonJSMin } from "./rolldown-runtime-tIEjjQTE.js";
2
2
  import { a as RegisteredLogger, t as ConsoleLogger, u as noopLogger } from "./logger-BwbmRqfc.js";
3
3
  import { t as MastraBase } from "./base-CKLWBhDo.js";
4
- import { _ as NoopLeaseProvider, c as RUN_LOG_TTL_MS, f as slimNestedAgentChunks, g as EventEmitterPubSub, h as withAck, m as stripModelSnapshots, n as PublisherQueueLimitError, o as serializeError$1, r as CachingPubSub, t as DefaultStepResult, u as isRunLocalTopic, y as isLeaseProvider } from "./output-helpers-D4II19No.js";
5
4
  import { A as compactStopReasonContext, D as agentLoopTermination, O as executionFailureTermination, S as resolveObservabilityContext, b as wrapMastra, i as subtractReportedUsage, k as tripwireTermination, n as extractUsageMetrics, r as isUsageIncomplete, t as calculateObservedUsage, x as createObservabilityContext, y as unwrapMastraTracingProxy } from "./observability-D7RNOAPx.js";
6
5
  import { a as MastraNonRetryableError, i as MastraError, n as ErrorDomain, o as getErrorFromUnknown, t as ErrorCategory } from "./error-oh2DLsP2.js";
7
6
  import { c as describeProviderError, i as classifyProviderError, l as readProviderErrorDetails, t as recordTerminalErrorMessage } from "./error-C9d_24w-.js";
8
- import { $ as RunJournal, $t as withAgentWorkflowToolMarker, A as findOwnModelStepSpan, At as materializeWorkflowRun, B as REPROCESS_PART_KEY, C as getResponseFormat, Cn as safeEnqueue, Ct as getSnapshotMemoryInfo, D as ProcessorState, Dt as isStateCheckpointDue, E as ProcessorRunner, En as createRunScopeKey, Et as applyStateColumnsWrite, F as ProviderHistoryCompat, Ft as unusedStateEntries, G as summarizeProcessorResultForSpan, H as withoutHeldContent, Ht as isObservationalMemoryEnabled$1, It as applyStatePatch, J as resolveProcessorSpanAttributes, Jt as hasToolResultProcessor, K as summarizeProcessorToolsForSpan, Kt as commitToolResult, M as isTrailingAssistantGuardContinuation, Mt as stateBaseOf, N as needsTrailingAssistantGuard, Nt as stateColumnsWrite, O as endOutputStreamSpanAtStepEnd, Ot as latestStepResults, P as removeTrailingAssistantGuardContinuations, Pt as summarizeStepResult, Q as createProcessorSendSignal, Qt as snapshotToolResult, Rt as diffStateAsJson, S as asJsonSchema, Sn as safeClose, St as getStepResultAsync, T as OUTPUT_STREAM_HOOK_DURATION_KEY_PREFIX, Tn as createRunScope, U as summarizeActiveToolsForSpan, V as takeHeldParts, W as summarizeProcessorModelForSpan, Wt as parseMemoryRequestContext, X as toProcessorSpanPhase, Xt as readModelOutput, Y as resolveProcessorSpanName, Yt as latestProcessedModelOutput, Z as PROCESSOR_LATE_SIGNAL_SINK, Zt as resolveModelOutputAfterToolResultProcessors, _ as stampChunkProducedAt, _n as isMastraTimeoutError, _t as resolveTemplate, a as convertFullStreamChunkToMastra, an as resolveThreadIdFromArgs, at as loadStepResults, b as escapeUnescapedControlCharsInJsonStrings, bt as validateTemplate, c as WorkflowRunOutput, cn as tryStreamWithJsonFallback, ct as residentStepResultsLoader, d as MastraModelOutput, dn as DEADLINE_SAVE_WAIT_MS, dt as collectMappingStepRefs, en as normalizeModelOutput, et as buildStepResultAccessors, f as createDestructurableOutput, fn as MastraTimeoutError, ft as collectPredicateStepRefs, g as getChunkProducedAt, gn as guardStreamWithAbort, h as resolveProcessorWriterMessageId, hn as guardStreamUntilMatch, ht as stepRefId, in as resolveSuspendedToolRunId, it as lazyStepResults, jt as pickStateKeys, k as endOutputStreamSpanOutsideStep, kt as materializeState, l as TripWire, ln as applyStateSignal, lt as storageV2StepResultAccessors, m as resolveOutputMessageSkippingCompletionChecks, mn as getAbortReason, mt as resolveStepOutputs, nn as isProcessorWorkflow, nt as hydrateStepResults, on as supportedLanguageModelSpecifications, ot as loadedStepResults, p as persistProcessorDataChunk, pn as createTimeoutAbortSignal, pt as predicateReadsState, q as summarizeToolChoiceForSpan, qt as computeModelOutputProviderMetadata, rn as isSupportedLanguageModel, rt as isStepResultStub, s as MastraAgentNetworkStream, sn as tryGenerateWithJsonFallback, st as residentStepResults, tn as validationErrorModelOutput, tt as getHydratedStepResult, u as getModelOutputForTripwire, un as DEADLINE_SAVE_CLAIM_HOLD_MS, ut as stubStepResult, v as markChunkOutputProcessed, vn as raceAgainstAbort, vt as templateReadsState, w as isSignalChunkExcluded, wn as safeError, x as isStructuredOutputError, xn as MastraModelInput, xt as getStepResult, y as createOutputHandler, yn as settledOrElapsed, yt as traverseMappingPath, z as FLUSH_HELD_PARTS_KEY, zt as patchState } from "./stream-CJUm6EAH.js";
7
+ import { $ as RunJournal, $t as withAgentWorkflowToolMarker, A as findOwnModelStepSpan, At as materializeWorkflowRun, B as REPROCESS_PART_KEY, C as getResponseFormat, Cn as safeEnqueue, Ct as getSnapshotMemoryInfo, D as ProcessorState, Dt as isStateCheckpointDue, E as ProcessorRunner, En as createRunScopeKey, Et as applyStateColumnsWrite, F as ProviderHistoryCompat, Ft as unusedStateEntries, G as summarizeProcessorResultForSpan, H as withoutHeldContent, Ht as isObservationalMemoryEnabled$1, It as applyStatePatch, J as resolveProcessorSpanAttributes, Jt as hasToolResultProcessor, K as summarizeProcessorToolsForSpan, Kt as commitToolResult, M as isTrailingAssistantGuardContinuation, Mt as stateBaseOf, N as needsTrailingAssistantGuard, Nt as stateColumnsWrite, O as endOutputStreamSpanAtStepEnd, Ot as latestStepResults, P as removeTrailingAssistantGuardContinuations, Pt as summarizeStepResult, Q as createProcessorSendSignal, Qt as snapshotToolResult, Rt as diffStateAsJson, S as asJsonSchema, Sn as safeClose, St as getStepResultAsync, T as OUTPUT_STREAM_HOOK_DURATION_KEY_PREFIX, Tn as createRunScope, U as summarizeActiveToolsForSpan, V as takeHeldParts, W as summarizeProcessorModelForSpan, Wt as parseMemoryRequestContext, X as toProcessorSpanPhase, Xt as readModelOutput, Y as resolveProcessorSpanName, Yt as latestProcessedModelOutput, Z as PROCESSOR_LATE_SIGNAL_SINK, Zt as resolveModelOutputAfterToolResultProcessors, _ as stampChunkProducedAt, _n as isMastraTimeoutError, _t as resolveTemplate, a as convertFullStreamChunkToMastra, an as resolveThreadIdFromArgs, at as loadStepResults, b as escapeUnescapedControlCharsInJsonStrings, bt as validateTemplate, c as WorkflowRunOutput, cn as tryStreamWithJsonFallback, ct as residentStepResultsLoader, d as MastraModelOutput, dn as DEADLINE_SAVE_WAIT_MS, dt as collectMappingStepRefs, en as normalizeModelOutput, et as buildStepResultAccessors, f as createDestructurableOutput, fn as MastraTimeoutError, ft as collectPredicateStepRefs, g as getChunkProducedAt, gn as guardStreamWithAbort, h as resolveProcessorWriterMessageId, hn as guardStreamUntilMatch, ht as stepRefId, in as resolveSuspendedToolRunId, it as lazyStepResults, jt as pickStateKeys, k as endOutputStreamSpanOutsideStep, kt as materializeState, l as TripWire, ln as applyStateSignal, lt as storageV2StepResultAccessors, m as resolveOutputMessageSkippingCompletionChecks, mn as getAbortReason, mt as resolveStepOutputs, nn as isProcessorWorkflow, nt as hydrateStepResults, on as supportedLanguageModelSpecifications, ot as loadedStepResults, p as persistProcessorDataChunk, pn as createTimeoutAbortSignal, pt as predicateReadsState, q as summarizeToolChoiceForSpan, qt as computeModelOutputProviderMetadata, rn as isSupportedLanguageModel, rt as isStepResultStub, s as MastraAgentNetworkStream, sn as tryGenerateWithJsonFallback, st as residentStepResults, tn as validationErrorModelOutput, tt as getHydratedStepResult, u as getModelOutputForTripwire, un as DEADLINE_SAVE_CLAIM_HOLD_MS, ut as stubStepResult, v as markChunkOutputProcessed, vn as raceAgainstAbort, vt as templateReadsState, w as isSignalChunkExcluded, wn as safeError, x as isStructuredOutputError, xn as MastraModelInput, xt as getStepResult, y as createOutputHandler, yn as settledOrElapsed, yt as traverseMappingPath, z as FLUSH_HELD_PARTS_KEY, zt as patchState } from "./stream-Dpwx0whf.js";
9
8
  import { c as MASTRA_THREAD_ID_KEY, d as isReservedRequestContextKey, f as mergeVersionOverrides$1, l as MASTRA_VERSIONS_KEY, n as MASTRA_AUTH_TOKEN_KEY, o as MASTRA_RESOURCE_ID_KEY, p as withoutLiveRequestKeys, r as MASTRA_INHERITED_MEMORY_KEY, s as MASTRA_SCOPES_KEY, t as MASTRA_CONTINUATION_TOOL_CALL_IDS_KEY, u as RequestContext } from "./request-context-COnZHt2-.js";
9
+ import { c as RUN_LOG_TTL_MS, f as slimNestedAgentChunks, g as NoopLeaseProvider, h as EventEmitterPubSub, m as stripModelSnapshots, n as PublisherQueueLimitError, o as serializeError$1, r as CachingPubSub, t as DefaultStepResult, u as isRunLocalTopic, v as isLeaseProvider, y as withAck } from "./output-helpers-CedRCE17.js";
10
10
  import { A as stableStringify$1, E as removeWorkingMemoryTags, P as embed$3, Z as preserveResponseItemIdsOnMerge, a as isTerminalToolInvocationState, c as withUnavailableAttachmentUrls, d as aiV5UIMessagesToAIV5ModelMessages, f as coreContentToString, i as isClientToolInvocationUpdate, l as isDownloadAssetsError, m as filterMessagesForPersistence, n as MessageList, ot as normalizeToolOutput, p as messagesAreEqual, r as advancesToolInvocationState, s as unavailableAttachmentPlaceholder, t as convertMessages, u as MessageMerger } from "./message-list-DEuRl82K.js";
11
11
  import { Bt as listScoresArgsSchema, Ft as listLogsArgsSchema, Lt as listMetricsArgsSchema, Nt as listFeedbackArgsSchema, t as EntityType } from "./storage-Cc50aQAp.js";
12
12
  import { a as getOrCreateSpan, f as resolveCurrentSpan, l as getTimeToFirstChunkMs, n as executeWithContextSync, o as getResumeTracingContext, p as resolveExportedSpanId, s as getRootExportSpan, t as executeWithContext, u as getWorkflowResumeTracingContext } from "./utils-DU_pU5SK.js";
13
13
  import { i as setSpanErrorOrigin, n as getSpanErrorOrigin } from "./error-count-BH-rJW7q.js";
14
- import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-DnXK3Pmw.js";
14
+ import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-Djd8Qzi0.js";
15
15
  import { a as withToolPayloadTransformMetadata, i as transformToolPayloadForTargets, n as hasTransformedToolPayload, o as withToolPayloadTransformProviderMetadata, r as normalizeToolPayloadTransformPolicy, t as getTransformedToolPayload } from "./payload-transform-Dj3HUeD4.js";
16
16
  import { boundedStringify, ensureSerializable, safeStringify } from "./utils/safe-stringify.js";
17
17
  import { d as signalSpanAttributes, h as signalToXmlMarkup, l as mastraDBMessageToSignal, n as createSignal, o as isMastraSignalMessage, s as isTransientSignalMessage, u as resolveDeliveryAttributes } from "./signals-CqR_iWkg.js";
@@ -24,13 +24,13 @@ import { _ as getRequestContextInputValues, a as getModelFacingValidationError,
24
24
  import { a as isApprovalExempt, c as isProviderDefinedTool, d as markAgentWorkflowTool, f as markApprovalExempt, l as isProviderTool, n as getNeedsApprovalFn, o as isBuiltBeforeApproval, r as getProviderToolName, s as isMastraTool, t as getBeforeApprovalFn } from "./toolchecks-DrsZdc3S.js";
25
25
  import { a as waitDelay, i as getRetryAfterMs, n as DEFAULT_MAX_RETRY_AFTER_MS, r as clampDelayMs } from "./fetchWithRetry-DFSvpYDT.js";
26
26
  import { i as hasFreeFormObject } from "./model-DS-b2R-R.js";
27
- import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-RZ8EgSe8.js";
27
+ import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-deA0x-Gd.js";
28
28
  import { t as InMemoryServerCache } from "./inmemory-BDD0w8gx.js";
29
29
  import { n as resolveDynamicArgument, t as getRequestUser } from "./dynamic-argument-BzPK3qPN.js";
30
- import { t as MastraLLMV1 } from "./model-CsOcWMUt.js";
31
- import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-Bd_y1_a-.js";
30
+ import { t as MastraLLMV1 } from "./model-CW-mfGYA.js";
31
+ import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-BnNi1BYM.js";
32
32
  import { h as getWorkflowFGAResourceId, i as MastraFGAPermissions, y as requireFGA } from "./ee-iTj2bRDt-By_B9ngH.js";
33
- import { a as resolveBackgroundConfig, o as createBackgroundTask, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-BgpX1P_s.js";
33
+ import { a as resolveBackgroundConfig, o as createBackgroundTask, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-Cv1ecD6S.js";
34
34
  import { t as ToolStream } from "./stream-D9JOykz7.js";
35
35
  import { MISSING, collectInvalidPredicatePaths, createPredicateEvaluator, derivePredicateLabel, normalizePredicatePath, walk } from "./predicate/index.js";
36
36
  import { Classifier } from "./classifier/index.js";
@@ -42,7 +42,7 @@ import { A as writeObjective, D as readObjective, O as resolveEffectiveGoalSetti
42
42
  import { An as computeTraceStatus, Cr as extractTrajectory, Dr as saveScorePayloadSchema, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Nn as extractBranchSpans, Pn as getBranchArgsSchema, Qn as listTracesArgsSchema, Sr as withBufferedReflectionVerified, Tr as extractWorkflowTrajectory, Yn as listBranchesArgsSchema, _r as isAppendOnlySince, ar as spanRecordSchema, br as maxObservationCursor, cr as toTraceSpans, gn as BRANCH_SPAN_TYPE_SET, gr as compareObservationalMemoryHeadOrder, hr as assertActiveObservationsApplied, or as toLightSpanRecord, pn as matchesExpectedWorkflowStatus, qn as isPreviewTruncated, sr as toTraceSpan, vn as TraceStatus, vr as isBufferedChunkCoveredByCursor, wr as extractTrajectoryFromTrace, xr as planReflectionGenerationText, yr as isBufferedReflectionUnchangedSince } from "./constants-BmdTvEYN.js";
43
43
  import { t as GoalSignalProvider } from "./signal-provider-BslnAjWG.js";
44
44
  import { t as slugify } from "./slugify-BUNmb-Ga.js";
45
- import { N as LocalSandbox, at as LocalFilesystem, dt as sliceByTokensSafe, ft as estimateTokenCount, it as normalizeReadTrackerPath, lt as WORKSPACE_TOOLS, m as resolveToolConfig, mt as shellQuote, o as Workspace, p as createWorkspaceTools, pt as sliceByTokens, rt as evaluateReadRecord, s as createSkillTools, st as CompositeFilesystem } from "./workspace-D7TIleIt.js";
45
+ import { N as LocalSandbox, at as LocalFilesystem, dt as sliceByTokensSafe, ft as estimateTokenCount, it as normalizeReadTrackerPath, lt as WORKSPACE_TOOLS, m as resolveToolConfig, mt as shellQuote, o as Workspace, p as createWorkspaceTools, pt as sliceByTokens, rt as evaluateReadRecord, s as createSkillTools, st as CompositeFilesystem } from "./workspace-C05xDH60.js";
46
46
  import { i as normalizeWebSearchProvider, n as createWebSearchProviderTool, r as isWebSearchTool } from "./tools-CDfyMpzN.js";
47
47
  import { D as BM25Index, O as tokenize } from "./workspace-skills-38OY32_b.js";
48
48
  import { f as calculatePagination, g as InMemoryThreadStateStorage, h as resolveListOrderBy, m as normalizePerPage, p as compareByField, s as StorageDomain, u as MastraCompositeStore } from "./filesystem-versioned-Bijb_p9l.js";
@@ -59,8 +59,8 @@ import { n as InMemoryWorkspacesStorage, t as FilesystemWorkspacesStorage } from
59
59
  import { n as resolveAgentSkills, t as mergeWorkspaceSkills } from "./agent-skills-resolver-CUEIMDbx.js";
60
60
  import { n as DefaultVoice } from "./voice-OS-kmlEA.js";
61
61
  import { TTLCache } from "@isaacs/ttlcache";
62
- import EventEmitter$1 from "events";
63
62
  import { any, array, boolean, custom, discriminatedUnion, enum as enum$1, instanceof as instanceof$1, json, lazy, literal, looseObject, never, null as null$1, number, object, record, safeParseAsync, string, union, unknown, z } from "zod/v4";
63
+ import EventEmitter$1 from "events";
64
64
  import { ReadableStream as ReadableStream$1, TransformStream as TransformStream$1 } from "stream/web";
65
65
  import { injectJsonInstructionIntoMessages, isAbortError } from "@ai-sdk/provider-utils-v6";
66
66
  import { z as z$1 } from "zod";
@@ -77,6 +77,18 @@ import { readFile, realpath, stat } from "fs/promises";
77
77
  import xxhash from "xxhash-wasm";
78
78
  import { RE2JS } from "re2js";
79
79
  import { LRUCache } from "lru-cache";
80
+ // src/events/reach.ts
81
+ /**
82
+ * Whether events published on `pubsub` can reach a subscriber in another
83
+ * process, read from the transport under any decorator.
84
+ *
85
+ * Only an explicit `false` counts as no. A pubsub built against a copy of
86
+ * `@mastra/core` that predates `deliversAcrossProcesses` has no such getter, and
87
+ * must keep being treated as a shared transport.
88
+ */
89
+ function reachesOtherProcesses(pubsub) {
90
+ return pubsub.__rawBus().deliversAcrossProcesses !== false;
91
+ }
80
92
  // src/storage/run-fencing.ts
81
93
  const RUN_FENCE_CONFLICT_ERROR_ID = "STORAGE_RUN_FENCE_CONFLICT";
82
94
  const RUN_FENCING_NOT_SUPPORTED_ERROR_ID = "STORAGE_RUN_FENCING_NOT_SUPPORTED";
@@ -1661,6 +1673,37 @@ const assertTimeTravelGraphMatchesSnapshot = (params) => {
1661
1673
  }
1662
1674
  if (missingStepIds.length > 0) throw new Error(`Cannot time travel to step '${targetStepId}': step(s) ${missingStepIds.map((id) => `'${id}'`).join(", ")} precede the target in the current execution graph but were not recorded in the snapshot. Either the workflow definition changed since the run was recorded (renamed steps, or unnamed .map() steps whose generated ids changed across processes), or the recorded run never reached these steps (it failed, was canceled, or was suspended before them). Steps recorded in the snapshot: ${reportedIdsSuffix}. The stored snapshot has not been modified.`);
1663
1675
  };
1676
+ const nestedRunIdentity = (stored, isForeach) => {
1677
+ const metadata = stored?.metadata;
1678
+ const foreachNestedRunIds = metadata?.foreachNestedRunIds && typeof metadata.foreachNestedRunIds === "object" ? metadata.foreachNestedRunIds : void 0;
1679
+ const keepNestedRunId = !isForeach || !foreachNestedRunIds && Array.isArray(stored?.payload) && stored.payload.length === 1;
1680
+ const identity = removeUndefinedValues({
1681
+ nestedRunId: keepNestedRunId && typeof metadata?.nestedRunId === "string" ? metadata.nestedRunId : void 0,
1682
+ foreachNestedRunIds
1683
+ });
1684
+ return Object.keys(identity).length > 0 ? identity : void 0;
1685
+ };
1686
+ const withSettledForeachRecords = (suspendPayload, output) => {
1687
+ const records = suspendPayload?.__workflow_meta?.foreachOutput;
1688
+ if (!Array.isArray(records) || !Array.isArray(output)) return suspendPayload;
1689
+ let changed = false;
1690
+ const foreachOutput = output.map((slot, index) => {
1691
+ const record = records[index];
1692
+ if (record || slot === null || slot === void 0 || slot?.status === "suspended") return record ?? null;
1693
+ changed = true;
1694
+ return {
1695
+ status: "success",
1696
+ output: slot
1697
+ };
1698
+ });
1699
+ return changed ? {
1700
+ ...suspendPayload,
1701
+ __workflow_meta: {
1702
+ ...suspendPayload.__workflow_meta,
1703
+ foreachOutput
1704
+ }
1705
+ } : suspendPayload;
1706
+ };
1664
1707
  const createTimeTravelExecutionParams = (params) => {
1665
1708
  const { steps, inputData, resumeData, context, nestedStepsContext, snapshot, initialState, graph, perStep } = params;
1666
1709
  const firstStepId = steps[0];
@@ -1722,12 +1765,13 @@ const createTimeTravelExecutionParams = (params) => {
1722
1765
  payload: isFirstEntryTarget ? firstEntryInput : context?.[stepId]?.payload ?? stepPayload ?? snapshotContext[stepId]?.payload ?? {},
1723
1766
  output: isCompleteStatus ? context?.[stepId]?.output ?? stepOutput ?? snapshotContext[stepId]?.output ?? {} : void 0,
1724
1767
  resumePayload: stepContext?.resumePayload,
1725
- suspendPayload: stepContext?.suspendPayload,
1768
+ suspendPayload: withSettledForeachRecords(stepContext?.suspendPayload, stepContext?.output),
1726
1769
  suspendOutput: stepContext?.suspendOutput,
1727
1770
  startedAt: stepContext?.startedAt ?? Date.now(),
1728
1771
  endedAt: isCompleteStatus ? stepContext?.endedAt ?? Date.now() : void 0,
1729
1772
  suspendedAt: stepContext?.suspendedAt,
1730
- resumedAt: stepContext?.resumedAt
1773
+ resumedAt: stepContext?.resumedAt,
1774
+ metadata: nestedRunIdentity(snapshotContext[stepId], entry.type === "foreach")
1731
1775
  };
1732
1776
  if ((perStep ? executionPath.length : currentExecPathLength) > 0 && !steps?.includes(stepId) && !context?.[stepId] && (!snapshotContext[stepId] || snapshotContext[stepId] && snapshotContext[stepId].status !== "suspended")) result = void 0;
1733
1777
  if (result) {
@@ -8861,6 +8905,7 @@ var Workflow = class Workflow extends MastraBase {
8861
8905
  snapshot: initialSnapshot,
8862
8906
  workflowStatus: "pending"
8863
8907
  }) : initialSnapshot, options?.resourceId, { stateBase: nestedRunStart?.inheritedState?.ref });
8908
+ if (nestedRun) nestedRun.inserted = true;
8864
8909
  }
8865
8910
  run.inheritedState = nestedRunStart?.inheritedState;
8866
8911
  return run;
@@ -8920,19 +8965,20 @@ var Workflow = class Workflow extends MastraBase {
8920
8965
  const nestedPubsub = useSharedPubsub ? pubsub : void 0;
8921
8966
  let startState = state;
8922
8967
  let startedFrom;
8923
- if (!restart && !isResume) {
8968
+ if (!isResume) {
8924
8969
  startedFrom = toJsonState(state);
8925
8970
  if (startedFrom) startState = copyState(state);
8926
8971
  }
8927
8972
  const inheritedState = !restart && !isResume ? await parentState?.(startState) : void 0;
8928
8973
  this.#nestedRun = {
8929
8974
  storageVersion: parentState ? 2 : 1,
8930
- start: !restart && !isResume ? {
8975
+ start: !isResume ? {
8931
8976
  input: inputData,
8932
8977
  state: startState,
8933
8978
  inheritedState
8934
8979
  } : void 0
8935
8980
  };
8981
+ const nestedRunHandoff = this.#nestedRun;
8936
8982
  const run = isResume ? await this.createRun({
8937
8983
  runId: resume.runId,
8938
8984
  resourceId,
@@ -8973,6 +9019,7 @@ var Workflow = class Workflow extends MastraBase {
8973
9019
  try {
8974
9020
  let restartNested = !!restart;
8975
9021
  let resumeNested = isResume;
9022
+ let storedPending = false;
8976
9023
  if ((restart || isResume) && !isTimeTravel) {
8977
9024
  const nestedSnapshot = await run.runStorage.loadHeader();
8978
9025
  let nestedStatus = nestedSnapshot?.status;
@@ -8990,7 +9037,8 @@ var Workflow = class Workflow extends MastraBase {
8990
9037
  else if (restart && nestedStatus === "suspended") {
8991
9038
  restartNested = false;
8992
9039
  resumeNested = true;
8993
- }
9040
+ } else if (restart && !isResume && (!nestedSnapshot || nestedRunHandoff.inserted)) restartNested = false;
9041
+ storedPending = nestedStatus === "pending" && !nestedRunHandoff.inserted;
8994
9042
  }
8995
9043
  if (isTimeTravel) {
8996
9044
  res = await run.timeTravel({
@@ -9013,6 +9061,7 @@ var Workflow = class Workflow extends MastraBase {
9013
9061
  handBackBase = startedFrom;
9014
9062
  } else if (restartNested) {
9015
9063
  handBackBase = await run.runStorage.loadDriveStartState();
9064
+ if (!handBackBase && storedPending) handBackBase = toJsonState((await run.runStorage.loadFull())?.value);
9016
9065
  res = await run.restart({
9017
9066
  requestContext,
9018
9067
  actor,
@@ -11327,6 +11376,34 @@ var EventedExecutionEngine = class extends ExecutionEngine {
11327
11376
  return result;
11328
11377
  }
11329
11378
  };
11379
+ // src/workflows/evented/setup-warning.ts
11380
+ const DOCS_URL = "https://mastra.ai/docs/server/pubsub#evented-workflows-and-agents";
11381
+ const warnedHosts = /* @__PURE__ */ new WeakSet();
11382
+ /**
11383
+ * Evented runs spread over several processes need a pubsub that hands a stopped
11384
+ * worker's event to another worker, and a store whose step guards let one
11385
+ * delivery of a step commit. Logs once per Mastra instance when the pubsub
11386
+ * reaches other processes and one of the two is missing.
11387
+ *
11388
+ * It judges the setup, not how many processes use it: Mastra can't count them.
11389
+ * A pubsub that stays inside the process is left alone, since no other process
11390
+ * can take part in its runs. `MASTRA_DISABLE_EVENTED_SETUP_WARNING=true`
11391
+ * disables it for a shared transport used by one process.
11392
+ *
11393
+ * The message names no supported pubsub or store. The docs page it links to is
11394
+ * the one place that lists them.
11395
+ */
11396
+ function warnUnsupportedEventedSetup(mastra, workflowsStore) {
11397
+ if (warnedHosts.has(mastra) || process.env.MASTRA_DISABLE_EVENTED_SETUP_WARNING === "true") return;
11398
+ if (!reachesOtherProcesses(mastra.pubsub)) return;
11399
+ const pubsub = mastra.pubsub.__rawBus();
11400
+ let missing;
11401
+ if (!pubsub.redeliversUnacked) missing = `${pubsub.constructor.name} doesn't redeliver unacknowledged events`;
11402
+ else if (workflowsStore && !workflowsStore.supportsWorkflowStepGuards()) missing = `the workflows store has no step guards`;
11403
+ if (!missing) return;
11404
+ warnedHosts.add(mastra);
11405
+ mastra.getLogger()?.warn(`Evented workflows and agents aren't supported on several processes with this setup: ${missing}. See ${DOCS_URL}`);
11406
+ }
11330
11407
  // src/agent/scopes.ts
11331
11408
  /**
11332
11409
  * Scope types Memory reads as the run's identity. Every other scope type is
@@ -14916,7 +14993,7 @@ var StepExecutor = class extends MastraBase {
14916
14993
  const cache = this.mastra?.serverCache;
14917
14994
  if (inner instanceof CachingPubSub) this.#stepPubsub = inner;
14918
14995
  else if (cache) {
14919
- const processLocalLogs = cache instanceof InMemoryServerCache && !(inner.__rawBus() instanceof EventEmitterPubSub);
14996
+ const processLocalLogs = cache instanceof InMemoryServerCache && reachesOtherProcesses(inner);
14920
14997
  this.#stepPubsub = new CachingPubSub(inner, cache, {
14921
14998
  shouldCache: (topic) => !isRunLocalTopic(topic),
14922
14999
  extendExistingLogsOnly: processLocalLogs,
@@ -15194,7 +15271,7 @@ var StepExecutor = class extends MastraBase {
15194
15271
  }),
15195
15272
  error: errorInstance
15196
15273
  } });
15197
- if (isExecutionFenceError(error) && this.mastra && !(this.mastra.pubsub.__rawBus() instanceof EventEmitterPubSub)) {
15274
+ if (isExecutionFenceError(error) && this.mastra && reachesOtherProcesses(this.mastra.pubsub)) {
15198
15275
  if (isStorageFencedExecution(requestContext, runId, params.parentWorkflow)) throw error;
15199
15276
  }
15200
15277
  const mastraError = new MastraError({
@@ -15425,6 +15502,58 @@ var StepExecutor = class extends MastraBase {
15425
15502
  }
15426
15503
  }
15427
15504
  };
15505
+ // src/workflows/evented/workflow-event-processor/run-status.ts
15506
+ const ENDED_RUN_STATUSES = /* @__PURE__ */ new Set([
15507
+ "success",
15508
+ "failed",
15509
+ "canceled",
15510
+ "tripwire"
15511
+ ]);
15512
+ /** The statuses of a run that has not ended yet. */
15513
+ const UNENDED_RUN_STATUSES = [
15514
+ "running",
15515
+ "waiting",
15516
+ "suspended",
15517
+ "pending",
15518
+ "paused",
15519
+ "bailed",
15520
+ "skipped"
15521
+ ];
15522
+ /** Whether a run stored with `status` has ended. */
15523
+ function isEndedRunStatus(status) {
15524
+ return ENDED_RUN_STATUSES.has(status);
15525
+ }
15526
+ /** Whether the stored run `run` has ended. */
15527
+ function hasRunEnded(run) {
15528
+ return !!run && isEndedRunStatus(run.status);
15529
+ }
15530
+ /** Whether `executionPath` points past the last entry of `stepGraph`: a step run there ends the run. */
15531
+ function isPastLastEntry(stepGraph, executionPath) {
15532
+ return (executionPath?.[0] ?? -1) >= stepGraph.length;
15533
+ }
15534
+ /**
15535
+ * Whether a step event is the one that ended the stored run `run`, which a worker still handles
15536
+ * when the run has ended. Only a successful run has one: its worker stores the end before
15537
+ * publishing it and may stop in between, and handling the event again publishes the end. The
15538
+ * stored active path names it: the step end the run ended at, or the step run past the last entry.
15539
+ * A failed run's end is stored by its own `workflow.fail`, which a redelivery of that event
15540
+ * finishes.
15541
+ *
15542
+ * This can't tell an end that was stored and not published from one that was already handled, so
15543
+ * a late copy of the event publishes the end again (and, for a nested run, hands it to the parent
15544
+ * again).
15545
+ */
15546
+ function isRunEndingEvent(type, executionPath, run, stepGraph) {
15547
+ return run.status === "success" && samePath(run.activePaths, executionPath) && (type === "workflow.step.end" || !!stepGraph && isPastLastEntry(stepGraph, executionPath));
15548
+ }
15549
+ /**
15550
+ * Whether two execution paths name the same position in the step graph. A missing path matches
15551
+ * only another missing path: a run stored without active paths was ended by an event without one.
15552
+ */
15553
+ function samePath(a, b) {
15554
+ if (!a || !b) return a === b;
15555
+ return a.length === b.length && a.every((index, depth) => index === b[depth]);
15556
+ }
15428
15557
  // src/workflows/evented/workflow-event-processor/finished-occurrence.ts
15429
15558
  const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
15430
15559
  "success",
@@ -15443,10 +15572,6 @@ const BRANCH_SETTLED_STATUSES = /* @__PURE__ */ new Set([
15443
15572
  "skipped",
15444
15573
  "suspended"
15445
15574
  ]);
15446
- /** Whether two execution paths name the same position in the step graph. */
15447
- function samePath(a, b) {
15448
- return !!a && a.length === b.length && a.every((index, depth) => index === b[depth]);
15449
- }
15450
15575
  /** The record of one foreach item, kept in the foreach step's resume metadata. */
15451
15576
  function foreachItem(result, index) {
15452
15577
  if (index === void 0) return;
@@ -16408,6 +16533,18 @@ function routeStepRun(stepGraph, { executionPath, restart }) {
16408
16533
  }
16409
16534
  }
16410
16535
  // src/workflows/evented/workflow-event-processor/sleep.ts
16536
+ /**
16537
+ * Records the sleep as the run's active step. Returns false when the run ended after the sleep
16538
+ * was dispatched: the write is refused, so the ended run is not reopened, and the sleep stops.
16539
+ */
16540
+ async function markSleepRunning(runStorage, executionPath, activeStepsPath) {
16541
+ return !!await runStorage.updateHeader({
16542
+ status: "running",
16543
+ activePaths: executionPath,
16544
+ activeStepsPath,
16545
+ expectedStatus: UNENDED_RUN_STATUSES
16546
+ }) || !hasRunEnded(await runStorage.loadHeader());
16547
+ }
16411
16548
  async function processWorkflowWaitForEvent(workflowData, { pubsub, eventName, currentState }) {
16412
16549
  const executionPath = currentState?.waitingPaths[eventName];
16413
16550
  if (!executionPath) return;
@@ -16460,14 +16597,10 @@ async function processWorkflowSleep({ workflow, workflowId, runId, executionPath
16460
16597
  },
16461
16598
  requestContext: withoutAuthToken(requestContext ?? {})
16462
16599
  });
16463
- await runStorage.updateHeader({
16464
- status: "running",
16465
- activePaths: executionPath,
16466
- activeStepsPath: {
16467
- ...activeStepsPath,
16468
- [step.id]: executionPath
16469
- }
16470
- });
16600
+ if (!await markSleepRunning(runStorage, executionPath, {
16601
+ ...activeStepsPath,
16602
+ [step.id]: executionPath
16603
+ })) return;
16471
16604
  const reqContext = new RequestContext(Object.entries(requestContext ?? {}));
16472
16605
  setLongTimeout(async () => {
16473
16606
  if (emitStepEvents) {
@@ -16541,14 +16674,10 @@ async function processWorkflowSleepUntil({ workflow, workflowId, runId, executio
16541
16674
  },
16542
16675
  requestContext: withoutAuthToken(requestContext ?? {})
16543
16676
  });
16544
- await runStorage.updateHeader({
16545
- status: "running",
16546
- activePaths: executionPath,
16547
- activeStepsPath: {
16548
- ...activeStepsPath,
16549
- [step.id]: executionPath
16550
- }
16551
- });
16677
+ if (!await markSleepRunning(runStorage, executionPath, {
16678
+ ...activeStepsPath,
16679
+ [step.id]: executionPath
16680
+ })) return;
16552
16681
  const reqContext = new RequestContext(Object.entries(requestContext ?? {}));
16553
16682
  const duration = await stepExecutor.resolveSleepUntil({
16554
16683
  workflowId,
@@ -17476,12 +17605,12 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
17476
17605
  stepResults: stepResults ?? {},
17477
17606
  workflowStatus: finalStatus
17478
17607
  }) ?? true;
17479
- if (shouldPersist) await runStorage.updateHeader({
17608
+ if (shouldPersist && !await this.#writeRunEnd("endWorkflow", args, runStorage, {
17480
17609
  status: finalStatus,
17481
17610
  result: normalizedPrevResult,
17482
17611
  activePaths: executionPath,
17483
17612
  activeStepsPath
17484
- });
17613
+ })) return;
17485
17614
  this.endRunSpans(args, finalStatus);
17486
17615
  if (finalStatus === "paused") await this.#pubsub.publish(`workflow.events.v2.${runId}`, {
17487
17616
  type: "watch",
@@ -17515,6 +17644,35 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
17515
17644
  }
17516
17645
  });
17517
17646
  }
17647
+ /**
17648
+ * Stores a run's end only while the run has not ended, so a late or second end can't replace
17649
+ * the first one. Returns true when the end is to be published: it was stored, the run is not
17650
+ * stored (as before), or the run already ended the same way at the same path, which is this end
17651
+ * handled again after its worker stopped before publishing it. Returns false, after logging, for
17652
+ * any other refusal: the run ended another way, or it was reopened (time travel writes `running`
17653
+ * on an ended run) between the write and the read, and an old end must not replace it.
17654
+ */
17655
+ async #writeRunEnd(handler, { workflowId, runId, executionPath, eventId }, runStorage, end) {
17656
+ const expectedStatus = end.status === "canceled" ? [...UNENDED_RUN_STATUSES, "canceled"] : UNENDED_RUN_STATUSES;
17657
+ if (await runStorage.updateHeader({
17658
+ ...end,
17659
+ expectedStatus
17660
+ })) return true;
17661
+ const stored = await runStorage.loadHeader();
17662
+ if (!stored) return true;
17663
+ if (hasRunEnded(stored) && stored.status === end.status && samePath(stored.activePaths, executionPath)) return true;
17664
+ this.mastra.getLogger()?.warn("Dropping a workflow end: the run already ended or was reopened", {
17665
+ handler,
17666
+ workflowId,
17667
+ runId,
17668
+ eventId,
17669
+ executionPath,
17670
+ status: end.status,
17671
+ storedStatus: stored.status,
17672
+ storedActivePaths: stored.activePaths
17673
+ });
17674
+ return false;
17675
+ }
17518
17676
  async publishFinishEvent(event) {
17519
17677
  for (;;) try {
17520
17678
  await this.#pubsub.publish("workflows-finish", event);
@@ -17651,6 +17809,17 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
17651
17809
  const step = liveParentWorkflow?.stepGraph?.[parentWorkflow.executionPath[0]];
17652
17810
  if (liveParentWorkflow && step?.type === "loop") {
17653
17811
  const parentStorage = this.#runStorage(parentWorkflow.workflowId, parentWorkflow.runId);
17812
+ const parentHeader = await parentStorage.loadHeader();
17813
+ if (hasRunEnded(parentHeader)) {
17814
+ this.mastra.getLogger()?.warn("Dropping a nested loop iteration end: the parent run already ended", {
17815
+ workflowId: parentWorkflow.workflowId,
17816
+ runId: parentWorkflow.runId,
17817
+ nestedRunId,
17818
+ executionPath: parentWorkflow.executionPath,
17819
+ storedStatus: parentHeader.status
17820
+ });
17821
+ return;
17822
+ }
17654
17823
  const loopStepResults = {
17655
17824
  ...parentWorkflow.stepResults ?? (await parentStorage.loadFull())?.context,
17656
17825
  __state: state
@@ -17786,21 +17955,19 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
17786
17955
  workflowStatus: "failed"
17787
17956
  }) ?? true;
17788
17957
  const ownershipLost = workflow?.options?.isOwnershipLostError?.(prevResult?.error);
17789
- if (ownershipLost) {} else if (shouldPersist) {
17790
- await runStorage.updateHeader({
17791
- status: "failed",
17792
- error: prevResult.error,
17793
- activePaths: executionPath,
17794
- activeStepsPath
17795
- });
17796
- if (currentStorageVersion() === 2) await this.pruneAndRepersistSnapshot({
17797
- workflow,
17798
- workflowId,
17799
- runId,
17800
- finished: true,
17801
- fence: await this.currentRunFence(runId)
17802
- });
17803
- }
17958
+ if (ownershipLost) {} else if (shouldPersist && !await this.#writeRunEnd("processWorkflowFail", args, runStorage, {
17959
+ status: "failed",
17960
+ error: prevResult.error,
17961
+ activePaths: executionPath,
17962
+ activeStepsPath
17963
+ })) return;
17964
+ else if (shouldPersist && currentStorageVersion() === 2) await this.pruneAndRepersistSnapshot({
17965
+ workflow,
17966
+ workflowId,
17967
+ runId,
17968
+ finished: true,
17969
+ fence: await this.currentRunFence(runId)
17970
+ });
17804
17971
  if (parentWorkflow) await this.#pubsub.publish("workflows", {
17805
17972
  type: "workflow.step.end",
17806
17973
  runId: parentWorkflow.runId,
@@ -17904,7 +18071,7 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
17904
18071
  restart
17905
18072
  });
17906
18073
  if (!rawStep || route.kind === "missing") {
17907
- if (executionPath[0] >= stepGraph.length) return this.endWorkflow({
18074
+ if (isPastLastEntry(stepGraph, executionPath)) return this.endWorkflow({
17908
18075
  workflow,
17909
18076
  parentWorkflow,
17910
18077
  workflowId,
@@ -18489,12 +18656,7 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
18489
18656
  workflowName: workflowId,
18490
18657
  runId
18491
18658
  });
18492
- if (snapshot && [
18493
- "success",
18494
- "failed",
18495
- "canceled",
18496
- "tripwire"
18497
- ].includes(snapshot.status)) return true;
18659
+ if (hasRunEnded(snapshot)) return true;
18498
18660
  if (snapshot?.status === "suspended" && snapshot.context[leafId]?.status === "suspended") return true;
18499
18661
  if (guardStart) try {
18500
18662
  assertWorkflowStepGuard({
@@ -18532,7 +18694,8 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
18532
18694
  nestedRunId = stepResults[leafId]?.suspendPayload?.__workflow_meta?.runId;
18533
18695
  } else if (timeTravel && timeTravel.steps?.length > 1 && timeTravel.steps[0] === leafId) {
18534
18696
  nestedDispatch = "time-travel";
18535
- nestedRunId = stepResults[leafId]?.metadata?.nestedRunId ?? globalThis.crypto.randomUUID();
18697
+ const recordedMetadata = stepResults[leafId]?.metadata;
18698
+ nestedRunId = (step.type === "foreach" ? recordedMetadata?.foreachNestedRunIds?.[executionPath[1]] ?? (recordedMetadata?.foreachNestedRunIds || executionPath[1] !== 0 ? void 0 : recordedMetadata?.nestedRunId) : recordedMetadata?.nestedRunId) ?? globalThis.crypto.randomUUID();
18536
18699
  } else if (restart && !!restart.activeStepsPath?.[leafId]) {
18537
18700
  nestedDispatch = "restart";
18538
18701
  nestedRunId = (step.type === "foreach" ? stepResults[leafId]?.metadata?.foreachNestedRunIds?.[executionPath[1]] : void 0) ?? stepResults[leafId]?.metadata?.nestedRunId ?? globalThis.crypto.randomUUID();
@@ -18661,12 +18824,23 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
18661
18824
  };
18662
18825
  return step.type === "loop" ? this.#processLoop(continuation, step, completedResult, args.eventId) : this.processWorkflowStepEnd(continuation);
18663
18826
  }
18664
- await runStorage.updateHeader({
18827
+ const stored = await runStorage.updateHeader({
18665
18828
  status: "running",
18666
18829
  activePaths: executionPath,
18667
18830
  activeStepsPath,
18668
18831
  expectedStatus: "running"
18669
- });
18832
+ }) ? void 0 : await runStorage.loadHeader();
18833
+ if (hasRunEnded(stored) && stored.status !== "canceled") {
18834
+ this.mastra.getLogger()?.warn("Not running a step: the run already ended", {
18835
+ type: "workflow.step.run",
18836
+ workflowId,
18837
+ runId,
18838
+ eventId: args.eventId,
18839
+ executionPath,
18840
+ storedStatus: stored.status
18841
+ });
18842
+ return;
18843
+ }
18670
18844
  }
18671
18845
  if (step.type === "foreach" && workflowsStore && authorizedEventId) {
18672
18846
  const storedResult = (await runStorage.loadSteps([leafId]))[leafId] ?? stepResults[leafId];
@@ -20270,7 +20444,7 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
20270
20444
  * should drop the event (or return 4xx for HTTP push).
20271
20445
  */
20272
20446
  async handle(event) {
20273
- if (this.mastra.pubsub.__rawBus() instanceof EventEmitterPubSub) return this.#handleDelivery(event);
20447
+ if (!reachesOtherProcesses(this.mastra.pubsub)) return this.#handleDelivery(event);
20274
20448
  if (!isStorageFencedExecution(new RequestContext(Object.entries(event.data?.requestContext ?? {})), event.runId, event.data?.parentWorkflow)) return this.#handleDelivery(event);
20275
20449
  try {
20276
20450
  if (await retrySettledDurableExecution(this.mastra, event)) return { ok: true };
@@ -20604,6 +20778,19 @@ var WorkflowEventProcessor = class WorkflowEventProcessor extends EventProcessor
20604
20778
  return;
20605
20779
  }
20606
20780
  const workflow = this.#resolveLiveWorkflow(workflowData);
20781
+ if ((type === "workflow.step.end" || type === "workflow.step.run") && hasRunEnded(currentState) && !isRunEndingEvent(type, workflowData.executionPath, currentState, workflow?.stepGraph)) {
20782
+ this.mastra.getLogger()?.warn("Dropping a step event: the run already ended", {
20783
+ type,
20784
+ workflowId: workflowData.workflowId,
20785
+ runId: workflowData.runId,
20786
+ eventId: event.id,
20787
+ executionPath: workflowData.executionPath,
20788
+ storedStatus: currentState.status,
20789
+ storedActivePaths: currentState.activePaths,
20790
+ deliveryAttempt: event.deliveryAttempt
20791
+ });
20792
+ return;
20793
+ }
20607
20794
  if (!workflow) {
20608
20795
  if (type === "workflow.fail" || type === "workflow.end" || type === "workflow.cancel") {} else return this.errorWorkflow(workflowData, new MastraError({
20609
20796
  id: "MASTRA_WORKFLOW",
@@ -21595,6 +21782,16 @@ function createStepFromProcessor(processor) {
21595
21782
  component: "PROCESSOR"
21596
21783
  };
21597
21784
  }
21785
+ /**
21786
+ * Builds a workflow on the evented execution engine: each step is an event on
21787
+ * the Mastra host's pubsub, so any worker can run the next one.
21788
+ *
21789
+ * In one process it runs on any pubsub, including the default one. Running it
21790
+ * on several processes needs a pubsub that redelivers unacknowledged events and
21791
+ * a workflows store with step guards.
21792
+ *
21793
+ * @see https://mastra.ai/docs/server/pubsub#evented-workflows-and-agents
21794
+ */
21598
21795
  function createWorkflow$1(params) {
21599
21796
  const eventProcessor = new WorkflowEventProcessor({ mastra: params.mastra });
21600
21797
  const executionEngine = new EventedExecutionEngine({
@@ -21651,6 +21848,7 @@ var EventedWorkflow = class extends Workflow {
21651
21848
  }
21652
21849
  });
21653
21850
  }
21851
+ if (!this.isInternal) warnUnsupportedEventedSetup(this.mastra, workflowsStore);
21654
21852
  const cachedRun = this.runs.get(runIdToUse);
21655
21853
  const shouldPersistSnapshot = this.options?.shouldPersistSnapshot?.({
21656
21854
  workflowStatus: cachedRun?.workflowRunStatus ?? "pending",
@@ -37829,10 +38027,19 @@ var DatasetsInMemory = class extends DatasetsStorage {
37829
38027
  field: "createdAt",
37830
38028
  direction: "DESC"
37831
38029
  });
37832
- items.sort(compareByField(orderBy.field, orderBy.direction));
37833
38030
  const { page, perPage: perPageInput } = args.pagination;
37834
38031
  const perPage = normalizePerPage(perPageInput, 100);
37835
38032
  const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
38033
+ if (perPage === 0) return {
38034
+ items: [],
38035
+ pagination: {
38036
+ total: items.length,
38037
+ page,
38038
+ perPage: perPageForResponse,
38039
+ hasMore: items.length > 0
38040
+ }
38041
+ };
38042
+ items.sort(compareByField(orderBy.field, orderBy.direction));
37836
38043
  const end = perPageInput === false ? items.length : start + perPage;
37837
38044
  return {
37838
38045
  items: items.slice(start, end),
@@ -39619,6 +39826,7 @@ var InMemoryKnowledgePageStore = class {
39619
39826
  }))].slice(0, limit);
39620
39827
  }
39621
39828
  async listPageActivity(input) {
39829
+ if (input.before !== void 0 && input.cursor !== void 0) throw new RangeError("Knowledge activity takes either a cursor or a before position, not both");
39622
39830
  const { items, nextCursor } = paginate(this.#activity.filter((event) => {
39623
39831
  const page = this.#pages.get(event.pageId);
39624
39832
  if (!page || !this.#pageReadable(page, input.read)) return false;
@@ -39628,6 +39836,9 @@ var InMemoryKnowledgePageStore = class {
39628
39836
  const note = this.#notes.get(event.noteId);
39629
39837
  if (!note || !this.#noteVisible(note, input.read)) return false;
39630
39838
  }
39839
+ if (input.since !== void 0 && event.createdAt.getTime() < input.since.getTime()) return false;
39840
+ if (input.until !== void 0 && event.createdAt.getTime() >= input.until.getTime()) return false;
39841
+ if (input.before !== void 0 && newestFirst(event, input.before) <= 0) return false;
39631
39842
  return true;
39632
39843
  }).sort(newestFirst), input.cursor, input.limit);
39633
39844
  return {
@@ -39821,7 +40032,8 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
39821
40032
  schemaVersion: 4,
39822
40033
  supportsSchemaInspection: true,
39823
40034
  supportsExplicitReset: true,
39824
- supportsPinKinds: true
40035
+ supportsPinKinds: true,
40036
+ supportsActivityDateRange: true
39825
40037
  };
39826
40038
  }
39827
40039
  async inspectSchema() {
@@ -62534,6 +62746,237 @@ function pinTool(host, onChange) {
62534
62746
  }
62535
62747
  });
62536
62748
  }
62749
+ const ACTIVITY_DEFAULT_LIMIT = 25;
62750
+ const ACTIVITY_MAX_LIMIT = 100;
62751
+ const ACTIVITY_MAX_BATCHES = 8;
62752
+ const ACTIVITY_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
62753
+ const ACTIVITY_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(\.\d{1,3})?)?(Z|([+-])(\d{2}):(\d{2}))$/;
62754
+ /**
62755
+ * `2026-07-01` (UTC midnight) or a date-time with an explicit zone (`Z` or `±hh:mm`). A date-time
62756
+ * without a zone would be read in the host's zone, and an impossible date (`2026-02-30`) would be
62757
+ * rolled over by `Date`, so both are refused.
62758
+ */
62759
+ function activityDate(name, value) {
62760
+ const trimmed = value.trim();
62761
+ const refuse = () => {
62762
+ throw new Error(`${name} must be a date like "2026-07-01" or a date-time with a zone like "2026-07-01T09:30:00Z" or "2026-07-01T09:30:00+02:00"; got "${value}".`);
62763
+ };
62764
+ const dateOnly = ACTIVITY_DATE.exec(trimmed);
62765
+ const dateTime = dateOnly ? void 0 : ACTIVITY_DATE_TIME.exec(trimmed);
62766
+ const match = dateOnly ?? dateTime ?? refuse();
62767
+ const [year, month, day, hour = 0, minute = 0, second = 0] = [
62768
+ 1,
62769
+ 2,
62770
+ 3,
62771
+ 4,
62772
+ 5,
62773
+ 6
62774
+ ].map((index) => match[index] === void 0 ? void 0 : Number(match[index]));
62775
+ const wall = /* @__PURE__ */ new Date(0);
62776
+ wall.setUTCFullYear(year, month - 1, day);
62777
+ wall.setUTCHours(hour, minute, second, 0);
62778
+ if (wall.getUTCFullYear() !== year || wall.getUTCMonth() !== month - 1 || wall.getUTCDate() !== day || wall.getUTCHours() !== hour || wall.getUTCMinutes() !== minute || wall.getUTCSeconds() !== second) refuse();
62779
+ if (dateTime?.[9] !== void 0) {
62780
+ const offsetHours = Number(dateTime[10]);
62781
+ const offsetMinutes = Number(dateTime[11]);
62782
+ if (offsetMinutes > 59 || offsetHours > 14 || offsetHours === 14 && offsetMinutes > 0) refuse();
62783
+ }
62784
+ const date = new Date(dateOnly ? `${trimmed}T00:00:00.000Z` : trimmed);
62785
+ if (Number.isNaN(date.getTime())) refuse();
62786
+ const utcYear = date.getUTCFullYear();
62787
+ if (utcYear < 1 || utcYear > 9999) refuse();
62788
+ return date;
62789
+ }
62790
+ async function activityBinding(parts) {
62791
+ const bytes = new TextEncoder().encode(JSON.stringify(parts.map((part) => part ?? null)));
62792
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
62793
+ return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
62794
+ }
62795
+ function encodeActivityCursor(cursor) {
62796
+ return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
62797
+ }
62798
+ function decodeActivityCursor(value) {
62799
+ try {
62800
+ const cursor = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
62801
+ if (cursor?.v === 1 && Array.isArray(cursor.before) && typeof cursor.before[0] === "string" && typeof cursor.before[1] === "string" && !Number.isNaN(new Date(cursor.before[0]).getTime()) && typeof cursor.bind === "string") return cursor;
62802
+ } catch {}
62803
+ throw new Error("knowledge_activity: that cursor did not come from knowledge_activity.");
62804
+ }
62805
+ function activityTool(host) {
62806
+ const maxTokens = maxTokensOf(host);
62807
+ return createTool({
62808
+ id: "knowledge_activity",
62809
+ description: `What changed in Knowledge over a period: page creates, edits, moves, merges and deletes, and notes added, restamped, removed or restored, newest first, with who made each change. Give \`since\` and/or \`until\` (a date like 2026-07-01, or a date-time with a zone like 2026-07-01T09:30:00Z; at least one); \`from\` narrows it to one page or scope. A note entry shows the note's current text (marked \`current\`), not its text when the change happened; a removed note shows no text. One result holds at most \`limit\` changes and about ${maxTokens.toLocaleString("en-US")} tokens of them; when it stops early, \`more\` is true and \`cursor\` continues (pass the same since, until and from).`,
62810
+ inputSchema: {
62811
+ type: "object",
62812
+ properties: {
62813
+ since: {
62814
+ type: "string",
62815
+ minLength: 1,
62816
+ description: "Changes at or after this time, e.g. \"2026-07-01\" (UTC midnight), \"2026-07-01T09:30:00Z\" or \"2026-07-01T09:30:00+02:00\". A date-time needs a zone."
62817
+ },
62818
+ until: {
62819
+ type: "string",
62820
+ minLength: 1,
62821
+ description: "Changes before this time, same formats as since."
62822
+ },
62823
+ from: {
62824
+ type: "string",
62825
+ minLength: 1,
62826
+ description: `Only changes to this page or scope. ${pageRefDescription}`
62827
+ },
62828
+ limit: {
62829
+ type: "integer",
62830
+ minimum: 1,
62831
+ maximum: ACTIVITY_MAX_LIMIT,
62832
+ description: `Maximum changes. Defaults to ${ACTIVITY_DEFAULT_LIMIT}.`
62833
+ },
62834
+ cursor: {
62835
+ type: "string",
62836
+ minLength: 1,
62837
+ description: "The previous result's cursor, for the changes after it (pass the same since, until and from)."
62838
+ }
62839
+ },
62840
+ additionalProperties: false
62841
+ },
62842
+ execute: async (input, context) => {
62843
+ const args = input;
62844
+ if (args.since === void 0 && args.until === void 0) throw new Error("knowledge_activity needs since or until, e.g. since: \"2026-07-01\".");
62845
+ const since = args.since === void 0 ? void 0 : activityDate("since", args.since);
62846
+ const until = args.until === void 0 ? void 0 : activityDate("until", args.until);
62847
+ if (since && until && since.getTime() >= until.getTime()) throw new Error("knowledge_activity: since must be earlier than until.");
62848
+ const limit = Math.min(Math.max(args.limit ?? ACTIVITY_DEFAULT_LIMIT, 1), ACTIVITY_MAX_LIMIT);
62849
+ if (!(await host.getStorage()).getCapabilities().supportsActivityDateRange) throw new KnowledgeUnsupportedCapabilityError("listPageActivity date range");
62850
+ const cursor = args.cursor === void 0 ? void 0 : decodeActivityCursor(args.cursor);
62851
+ const run = await start(host, context);
62852
+ const origin = args.from ? await run.pageOrCloseMatches(args.from) : void 0;
62853
+ const filter = origin ? origin.isScope ? { scopeId: origin.id } : { pageId: origin.id } : {};
62854
+ const bind = await activityBinding([
62855
+ since?.toISOString(),
62856
+ until?.toISOString(),
62857
+ "scopeId" in filter ? filter.scopeId : void 0,
62858
+ "pageId" in filter ? filter.pageId : void 0
62859
+ ]);
62860
+ if (cursor && cursor.bind !== bind) throw new Error("knowledge_activity: this cursor came from a call with different since, until or from. Pass the same ones as the call that returned it.");
62861
+ const entries = [];
62862
+ let used = 0;
62863
+ let position = cursor ? {
62864
+ createdAt: new Date(cursor.before[0]),
62865
+ id: cursor.before[1]
62866
+ } : void 0;
62867
+ let more = false;
62868
+ let stopped = false;
62869
+ let batches = 0;
62870
+ while (!stopped && entries.length < limit && batches < ACTIVITY_MAX_BATCHES) {
62871
+ batches++;
62872
+ const startedAt = position;
62873
+ const batch = await run.storage.listPageActivity({
62874
+ read: run.read,
62875
+ ...filter,
62876
+ ...since ? { since } : {},
62877
+ ...until ? { until } : {},
62878
+ ...position ? { before: position } : {},
62879
+ limit: limit - entries.length
62880
+ });
62881
+ more = batch.nextCursor !== void 0;
62882
+ const pages = /* @__PURE__ */ new Map();
62883
+ const notes = /* @__PURE__ */ new Map();
62884
+ for (const event of batch.events) {
62885
+ if (!pages.has(event.pageId)) {
62886
+ const page = await run.storage.getPage({
62887
+ id: event.pageId,
62888
+ read: run.read
62889
+ });
62890
+ if (page) pages.set(page.id, page);
62891
+ }
62892
+ if (event.noteId && !notes.has(event.noteId)) {
62893
+ const note = await run.storage.getNote({
62894
+ id: event.noteId,
62895
+ read: run.read,
62896
+ includeDeleted: true
62897
+ });
62898
+ if (note) notes.set(note.id, note);
62899
+ }
62900
+ }
62901
+ const { refs } = await pageRefs(run, [...pages.values()]);
62902
+ for (const event of batch.events) {
62903
+ const page = pages.get(event.pageId);
62904
+ const note = event.noteId ? notes.get(event.noteId) : void 0;
62905
+ if (!page || event.noteId && !note) {
62906
+ position = {
62907
+ createdAt: event.createdAt,
62908
+ id: event.id
62909
+ };
62910
+ continue;
62911
+ }
62912
+ const entry = {
62913
+ at: event.createdAt.toISOString(),
62914
+ action: event.action,
62915
+ page: {
62916
+ ref: refs.get(page.id) ?? page.id,
62917
+ name: page.name,
62918
+ ...page.deletedAt ? { deleted: true } : {}
62919
+ },
62920
+ author: event.provenance.author,
62921
+ ...note ? { note: note.deletedAt ? {
62922
+ ref: note.id,
62923
+ removed: true
62924
+ } : {
62925
+ ref: note.id,
62926
+ text: note.text,
62927
+ current: true
62928
+ } } : {}
62929
+ };
62930
+ let size = estimateTokenCount(JSON.stringify(entry));
62931
+ if (entries.length > 0 && used + size > maxTokens) {
62932
+ stopped = true;
62933
+ break;
62934
+ }
62935
+ if (entries.length === 0 && size > maxTokens && entry.note && "text" in entry.note) {
62936
+ const full = entry.note.text;
62937
+ let keep = full.length;
62938
+ while (keep > 0 && size > maxTokens) {
62939
+ keep = Math.floor(keep * .8);
62940
+ entry.note = {
62941
+ ref: entry.note.ref,
62942
+ text: full.slice(0, keep),
62943
+ current: true,
62944
+ truncated: true
62945
+ };
62946
+ size = estimateTokenCount(JSON.stringify(entry));
62947
+ }
62948
+ }
62949
+ entries.push(entry);
62950
+ used += size;
62951
+ position = {
62952
+ createdAt: event.createdAt,
62953
+ id: event.id
62954
+ };
62955
+ if (entries.length >= limit) break;
62956
+ }
62957
+ if (!more) break;
62958
+ if (position === startedAt) throw new Error("knowledge_activity: the store returned a continuation without any changes; stopping.");
62959
+ if (!stopped && entries.length >= limit) break;
62960
+ }
62961
+ const hasMore = stopped || more;
62962
+ return {
62963
+ ...origin ? { from: {
62964
+ ref: (await pageRefs(run, [origin])).refs.get(origin.id) ?? origin.id,
62965
+ name: origin.name
62966
+ } } : {},
62967
+ changes: entries,
62968
+ ...hasMore && position ? {
62969
+ more: true,
62970
+ cursor: encodeActivityCursor({
62971
+ v: 1,
62972
+ before: [position.createdAt.toISOString(), position.id],
62973
+ bind
62974
+ })
62975
+ } : {}
62976
+ };
62977
+ }
62978
+ });
62979
+ }
62537
62980
  /** The schema-4 Knowledge tools. @internal */
62538
62981
  function buildKnowledgePageTools(host, groups, onPinChange) {
62539
62982
  const tools = {};
@@ -62541,6 +62984,7 @@ function buildKnowledgePageTools(host, groups, onPinChange) {
62541
62984
  tools.knowledge_list = listTool(host);
62542
62985
  tools.knowledge_search = searchTool(host);
62543
62986
  tools.knowledge_read = readTool(host);
62987
+ tools.knowledge_activity = activityTool(host);
62544
62988
  }
62545
62989
  if (groups.write) {
62546
62990
  tools.knowledge_page = pageTool(host);
@@ -80908,7 +81352,11 @@ var EventedAgentExecutionEngine = class extends DefaultAgentExecutionEngine {
80908
81352
  }
80909
81353
  prepareExecution(pubsub, fence, workflowEngine, logger, guardrailLogger) {
80910
81354
  const engine = this.resolveWorkflowEngine(workflowEngine, logger);
80911
- const sharedTransport = engine === "evented" && pubsub !== void 0 && !(pubsub.__rawBus() instanceof EventEmitterPubSub);
81355
+ const sharedTransport = engine === "evented" && pubsub !== void 0 && reachesOtherProcesses(pubsub);
81356
+ if (sharedTransport && this.mastra) {
81357
+ const mastra = this.mastra;
81358
+ Promise.resolve(mastra.getStorage()?.getStore("workflows")).catch(() => void 0).then((store) => warnUnsupportedEventedSetup(mastra, store)).catch(() => {});
81359
+ }
80912
81360
  const sharedExecution = sharedTransport && fence?.generation !== void 0;
80913
81361
  if (sharedTransport && !sharedExecution && !this.#warnedUnfencedSharedExecution) {
80914
81362
  this.#warnedUnfencedSharedExecution = true;
@@ -81354,7 +81802,7 @@ async function prepareForDurableExecution(options) {
81354
81802
  });
81355
81803
  let tripwireData;
81356
81804
  if (inputProcessors.length > 0) try {
81357
- const { ProcessorRunner } = await import("./stream-CJUm6EAH.js").then((n) => n.j);
81805
+ const { ProcessorRunner } = await import("./stream-Dpwx0whf.js").then((n) => n.j);
81358
81806
  await new ProcessorRunner({
81359
81807
  inputProcessors,
81360
81808
  outputProcessors,
@@ -93226,7 +93674,7 @@ var Agent = class Agent extends MastraBase {
93226
93674
  *
93227
93675
  * @internal
93228
93676
  */
93229
- async subscribeToDurableRunStream(runId, options, onEvent) {
93677
+ async __subscribeToRunStream(runId, options, onEvent) {
93230
93678
  const pubsub = this.#executionStreamBus.forRun(this.__usesSharedRunLog()).pubsub;
93231
93679
  const replayFloor = await this.#readReplayFloor(runId, options.offset);
93232
93680
  const keepGeneration = createRunGenerationFilter(replayFloor);
@@ -102123,7 +102571,7 @@ var AgentThreadStreamRuntime = class {
102123
102571
  * `generation` only to name the owner a new acquisition takes.
102124
102572
  */
102125
102573
  #threadLeaseOwner(pubsub, runId, generation) {
102126
- if (this.#getPubSub(pubsub).__rawBus() instanceof EventEmitterPubSub) return threadLeaseOwner(runId);
102574
+ if (!reachesOtherProcesses(this.#getPubSub(pubsub))) return threadLeaseOwner(runId);
102127
102575
  if (generation !== void 0) return threadLeaseOwner(runId, generation);
102128
102576
  const state = this.#getState(pubsub);
102129
102577
  return state.leaseOwners.get(runId) ?? threadLeaseOwner(runId, state.threadRunsById.get(runId)?.generation);
@@ -107630,7 +108078,7 @@ function getActiveDurableAgentWorkflowExecutions(mastra) {
107630
108078
  * execution behind a broker, which another process may be executing.
107631
108079
  */
107632
108080
  function detachesOnShutdown(mastra, entry) {
107633
- return !!entry.eventedExecution && !(mastra.pubsub.__rawBus() instanceof EventEmitterPubSub);
108081
+ return !!entry.eventedExecution && reachesOtherProcesses(mastra.pubsub);
107634
108082
  }
107635
108083
  function isDurableAgentExecutionDetached(mastra, runId) {
107636
108084
  const entry = globalRunRegistry.has(runId) ? globalRunRegistry.get(runId) : void 0;