@mastra/core 1.87.0-alpha.7 → 1.87.0-alpha.9

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 (388) hide show
  1. package/dist/agent/agent.d.ts +3 -1
  2. package/dist/agent/durable/index.cjs +1 -1
  3. package/dist/agent/durable/index.js +1 -1
  4. package/dist/agent/index.cjs +3 -2
  5. package/dist/agent/index.d.ts +2 -0
  6. package/dist/agent/index.js +3 -3
  7. package/dist/agent/merge-persona.d.ts +15 -0
  8. package/dist/agent-builder/ee/index.cjs +1 -1
  9. package/dist/agent-builder/ee/index.js +1 -1
  10. package/dist/agent-controller/index.cjs +2 -2
  11. package/dist/agent-controller/index.js +2 -2
  12. package/dist/{agent-controller-QGBVBDRi.cjs → agent-controller-ZCQy7cOG.cjs} +7 -7
  13. package/dist/{agent-controller-GM-2_7C2.js → agent-controller-fazk0U_b.js} +7 -7
  14. package/dist/background-tasks/index.cjs +1 -1
  15. package/dist/background-tasks/index.js +1 -1
  16. package/dist/{background-tasks-C-3AqSKL.cjs → background-tasks-B63welNM.cjs} +1 -1
  17. package/dist/{background-tasks-lHCVpHbm.js → background-tasks-DlLB_pJR.js} +1 -1
  18. package/dist/browser/index.cjs +2 -2
  19. package/dist/browser/index.js +2 -2
  20. package/dist/{builder-C9UYOrxv.js → builder-D82iR2oQ.js} +2 -2
  21. package/dist/{builder-mGGr3IhH.cjs → builder-DCaL4xmU.cjs} +2 -2
  22. package/dist/capabilities/302ai.json +196 -196
  23. package/dist/capabilities/abliteratedllm.json +43 -34
  24. package/dist/capabilities/abliteration-ai.json +9 -9
  25. package/dist/capabilities/above.json +18 -18
  26. package/dist/capabilities/adaption.json +12 -12
  27. package/dist/capabilities/adzuki.json +28 -28
  28. package/dist/capabilities/agentrouter.json +10 -10
  29. package/dist/capabilities/agnes.json +2 -2
  30. package/dist/capabilities/ai-router.json +6 -6
  31. package/dist/capabilities/aiand.json +20 -20
  32. package/dist/capabilities/aigrow.json +10 -10
  33. package/dist/capabilities/aimlapi.json +143 -143
  34. package/dist/capabilities/aipg.json +2 -2
  35. package/dist/capabilities/aixy.json +23 -23
  36. package/dist/capabilities/aki-io.json +14 -14
  37. package/dist/capabilities/alibaba-cn.json +100 -94
  38. package/dist/capabilities/alibaba-coding-plan-cn.json +4 -4
  39. package/dist/capabilities/alibaba-coding-plan.json +4 -4
  40. package/dist/capabilities/alibaba-token-plan-cn.json +47 -47
  41. package/dist/capabilities/alibaba-token-plan.json +47 -47
  42. package/dist/capabilities/alibaba.json +63 -63
  43. package/dist/capabilities/ambient.json +14 -14
  44. package/dist/capabilities/amd.json +10 -10
  45. package/dist/capabilities/anthropic.json +42 -42
  46. package/dist/capabilities/anyapi.json +47 -47
  47. package/dist/capabilities/arcee.json +10 -10
  48. package/dist/capabilities/augure.json +5 -5
  49. package/dist/capabilities/auriko.json +21 -21
  50. package/dist/capabilities/bailing.json +4 -4
  51. package/dist/capabilities/baseten.json +34 -34
  52. package/dist/capabilities/bee.json +3 -3
  53. package/dist/capabilities/berget.json +18 -5
  54. package/dist/capabilities/bothub.json +15 -15
  55. package/dist/capabilities/boundless.json +35 -35
  56. package/dist/capabilities/bumo.json +43 -43
  57. package/dist/capabilities/byteplus.json +29 -29
  58. package/dist/capabilities/cheapaimodel.json +6 -6
  59. package/dist/capabilities/cheapest-token.json +28 -28
  60. package/dist/capabilities/chutes.json +9 -9
  61. package/dist/capabilities/clarifai.json +2 -2
  62. package/dist/capabilities/claudinio.json +10 -1
  63. package/dist/capabilities/cline-pass.json +40 -40
  64. package/dist/capabilities/cloudcode.json +10 -17
  65. package/dist/capabilities/cloudferro-sherlock.json +4 -4
  66. package/dist/capabilities/cloudflare-workers-ai.json +20 -20
  67. package/dist/capabilities/commandcode.json +148 -148
  68. package/dist/capabilities/concentrate.json +268 -268
  69. package/dist/capabilities/cortecs.json +104 -104
  70. package/dist/capabilities/crossmodel.json +172 -172
  71. package/dist/capabilities/crusoe.json +35 -6
  72. package/dist/capabilities/daoxe.json +8 -8
  73. package/dist/capabilities/databricks.json +126 -126
  74. package/dist/capabilities/deepinfra.json +105 -105
  75. package/dist/capabilities/deepseek.json +4 -4
  76. package/dist/capabilities/digitalocean.json +115 -115
  77. package/dist/capabilities/dothoosh.json +32 -32
  78. package/dist/capabilities/doubleword.json +26 -26
  79. package/dist/capabilities/edenai.json +281 -277
  80. package/dist/capabilities/empiriolabs.json +164 -164
  81. package/dist/capabilities/engy.json +10 -10
  82. package/dist/capabilities/entrim.json +5 -5
  83. package/dist/capabilities/evroc.json +13 -13
  84. package/dist/capabilities/ezkielyna.json +8 -8
  85. package/dist/capabilities/fastrouter.json +88 -88
  86. package/dist/capabilities/fireworks-ai.json +92 -92
  87. package/dist/capabilities/fortytwo.json +9 -3
  88. package/dist/capabilities/freemodel.json +18 -18
  89. package/dist/capabilities/friendli.json +8 -8
  90. package/dist/capabilities/frogbot.json +100 -100
  91. package/dist/capabilities/gisoo.json +20 -20
  92. package/dist/capabilities/gmicloud.json +16 -16
  93. package/dist/capabilities/google.json +48 -48
  94. package/dist/capabilities/graphn.json +13 -13
  95. package/dist/capabilities/greenpt.json +37 -37
  96. package/dist/capabilities/groq.json +2 -2
  97. package/dist/capabilities/helicone.json +78 -78
  98. package/dist/capabilities/hetzner.json +35 -3
  99. package/dist/capabilities/hostinger-router.json +14 -14
  100. package/dist/capabilities/hpc-ai.json +11 -11
  101. package/dist/capabilities/huawei-maas.json +14 -14
  102. package/dist/capabilities/hubris.json +31 -31
  103. package/dist/capabilities/huggingface.json +84 -174
  104. package/dist/capabilities/humain.json +2 -2
  105. package/dist/capabilities/hyper.json +19 -19
  106. package/dist/capabilities/impossibl.json +171 -171
  107. package/dist/capabilities/inception.json +3 -3
  108. package/dist/capabilities/inceptron.json +4 -4
  109. package/dist/capabilities/inco.json +4 -4
  110. package/dist/capabilities/infer.json +19 -19
  111. package/dist/capabilities/inferall.json +11 -11
  112. package/dist/capabilities/inference-coop.json +15 -15
  113. package/dist/capabilities/inferenceapis.json +24 -24
  114. package/dist/capabilities/inferris.json +4 -4
  115. package/dist/capabilities/infersia.json +13 -13
  116. package/dist/capabilities/inferx.json +2 -2
  117. package/dist/capabilities/infomaniak.json +2 -2
  118. package/dist/capabilities/io-net.json +4 -4
  119. package/dist/capabilities/isoquant.json +4 -4
  120. package/dist/capabilities/iteracompute.json +56 -56
  121. package/dist/capabilities/jad-ai.json +3 -3
  122. package/dist/capabilities/jalapeno.json +10 -10
  123. package/dist/capabilities/jiekou.json +64 -64
  124. package/dist/capabilities/jzstoken.json +50 -51
  125. package/dist/capabilities/keln.json +22 -22
  126. package/dist/capabilities/kenari.json +123 -123
  127. package/dist/capabilities/kilo.json +601 -601
  128. package/dist/capabilities/kimi-code-plan-cn.json +6 -6
  129. package/dist/capabilities/kimi-code-plan-global.json +6 -6
  130. package/dist/capabilities/kitani.json +6 -6
  131. package/dist/capabilities/klavo.json +22 -22
  132. package/dist/capabilities/korouter.json +34 -34
  133. package/dist/capabilities/kunavo.json +7 -7
  134. package/dist/capabilities/liquid.json +12 -12
  135. package/dist/capabilities/llmgateway-providers.json +934 -934
  136. package/dist/capabilities/llmgateway.json +334 -334
  137. package/dist/capabilities/llmtr.json +34 -34
  138. package/dist/capabilities/lowrouter.json +58 -58
  139. package/dist/capabilities/lyceum.json +18 -10
  140. package/dist/capabilities/melious.json +17 -17
  141. package/dist/capabilities/merge-gateway.json +255 -254
  142. package/dist/capabilities/meta.json +10 -10
  143. package/dist/capabilities/minimax-cn-coding-plan.json +5 -5
  144. package/dist/capabilities/minimax-cn.json +5 -5
  145. package/dist/capabilities/minimax-coding-plan.json +5 -5
  146. package/dist/capabilities/minimax.json +5 -5
  147. package/dist/capabilities/mistral.json +22 -22
  148. package/dist/capabilities/mixlayer.json +2 -2
  149. package/dist/capabilities/modal.json +12 -12
  150. package/dist/capabilities/model-oracle-ai.json +26 -26
  151. package/dist/capabilities/modelis.json +17 -17
  152. package/dist/capabilities/modelscope.json +2 -2
  153. package/dist/capabilities/modular.json +30 -8
  154. package/dist/capabilities/moneo.json +11 -11
  155. package/dist/capabilities/moonshotai-cn.json +6 -6
  156. package/dist/capabilities/moonshotai.json +6 -6
  157. package/dist/capabilities/morph.json +18 -18
  158. package/dist/capabilities/munito-eu.json +6 -6
  159. package/dist/capabilities/munito.json +8 -8
  160. package/dist/capabilities/nan.json +23 -23
  161. package/dist/capabilities/nano-gpt.json +565 -571
  162. package/dist/capabilities/nearai.json +93 -93
  163. package/dist/capabilities/nebius.json +32 -32
  164. package/dist/capabilities/neon.json +129 -129
  165. package/dist/capabilities/neuralwatt.json +42 -42
  166. package/dist/capabilities/nokeep.json +5 -5
  167. package/dist/capabilities/novita-ai.json +135 -135
  168. package/dist/capabilities/nvidia.json +49 -32
  169. package/dist/capabilities/oathbreaker.json +26 -3
  170. package/dist/capabilities/obscurify.json +27 -27
  171. package/dist/capabilities/oci.json +6 -6
  172. package/dist/capabilities/ofox.json +302 -302
  173. package/dist/capabilities/ollama-cloud.json +59 -59
  174. package/dist/capabilities/openai.json +58 -58
  175. package/dist/capabilities/opencode-go.json +78 -78
  176. package/dist/capabilities/openreason.json +5 -5
  177. package/dist/capabilities/openrouter.json +526 -526
  178. package/dist/capabilities/opper.json +27 -27
  179. package/dist/capabilities/orcarouter.json +243 -243
  180. package/dist/capabilities/outerlabs.json +32 -32
  181. package/dist/capabilities/ovhcloud.json +21 -21
  182. package/dist/capabilities/pareto.json +6 -6
  183. package/dist/capabilities/perplexity-agent.json +57 -57
  184. package/dist/capabilities/perplexity.json +2 -2
  185. package/dist/capabilities/phala.json +34 -34
  186. package/dist/capabilities/pioneer.json +34 -34
  187. package/dist/capabilities/poe.json +129 -129
  188. package/dist/capabilities/poolside.json +3 -3
  189. package/dist/capabilities/powerspring.json +12 -12
  190. package/dist/capabilities/primalabs.json +10 -10
  191. package/dist/capabilities/prime.json +113 -113
  192. package/dist/capabilities/privatemode-ai.json +14 -14
  193. package/dist/capabilities/proxystacks.json +7 -7
  194. package/dist/capabilities/qiniu-ai.json +14 -14
  195. package/dist/capabilities/refuseless.json +6 -6
  196. package/dist/capabilities/regolo-ai.json +10 -10
  197. package/dist/capabilities/requesty.json +371 -167
  198. package/dist/capabilities/ruapi.json +33 -17
  199. package/dist/capabilities/runcrate.json +10 -10
  200. package/dist/capabilities/runinfra.json +14 -14
  201. package/dist/capabilities/sakana.json +7 -7
  202. package/dist/capabilities/sambanova.json +9 -9
  203. package/dist/capabilities/sandbase.json +18 -18
  204. package/dist/capabilities/sarvam.json +11 -11
  205. package/dist/capabilities/scaleway.json +19 -19
  206. package/dist/capabilities/scnet-token-plan.json +11 -11
  207. package/dist/capabilities/scx-ai.json +27 -27
  208. package/dist/capabilities/sensenova.json +13 -13
  209. package/dist/capabilities/siliconflow-cn.json +55 -55
  210. package/dist/capabilities/siliconflow.json +63 -63
  211. package/dist/capabilities/snowflake-cortex.json +25 -25
  212. package/dist/capabilities/sokkan.json +2 -2
  213. package/dist/capabilities/sparrowcodes.json +22 -22
  214. package/dist/capabilities/standardcompute.json +97 -97
  215. package/dist/capabilities/steadyrouter.json +36 -36
  216. package/dist/capabilities/stepfun-ai-step-plan.json +4 -4
  217. package/dist/capabilities/stepfun-ai.json +4 -4
  218. package/dist/capabilities/stepfun-step-plan.json +4 -4
  219. package/dist/capabilities/stepfun.json +4 -4
  220. package/dist/capabilities/stepping-stone.json +19 -19
  221. package/dist/capabilities/superbot-gg.json +4 -4
  222. package/dist/capabilities/synthetic.json +9 -9
  223. package/dist/capabilities/synthorai.json +26 -26
  224. package/dist/capabilities/teamorouter.json +16 -16
  225. package/dist/capabilities/teapot-router.json +14 -14
  226. package/dist/capabilities/tencent-token-plan-intl.json +21 -21
  227. package/dist/capabilities/tencent-token-plan.json +42 -42
  228. package/dist/capabilities/tencent-tokenhub.json +49 -49
  229. package/dist/capabilities/tensorx.json +48 -48
  230. package/dist/capabilities/tenstorrent.json +8 -8
  231. package/dist/capabilities/the-grid-ai.json +34 -34
  232. package/dist/capabilities/thinkingmachines.json +78 -78
  233. package/dist/capabilities/tinfoil.json +13 -13
  234. package/dist/capabilities/togetherai.json +44 -44
  235. package/dist/capabilities/tokengo.json +25 -25
  236. package/dist/capabilities/tokenify.json +9 -9
  237. package/dist/capabilities/tokenwatt.json +10 -2
  238. package/dist/capabilities/trustedrouter.json +7 -7
  239. package/dist/capabilities/trustedtokens.json +19 -19
  240. package/dist/capabilities/umans-ai-coding-plan.json +14 -14
  241. package/dist/capabilities/umans-ai.json +10 -10
  242. package/dist/capabilities/unrestricted.json +6 -6
  243. package/dist/capabilities/uplinkswitch.json +20 -20
  244. package/dist/capabilities/upstage.json +6 -6
  245. package/dist/capabilities/vancine.json +25 -25
  246. package/dist/capabilities/vercel.json +552 -551
  247. package/dist/capabilities/vivgrid.json +74 -65
  248. package/dist/capabilities/volcengine-coding-plan.json +27 -27
  249. package/dist/capabilities/volcengine.json +29 -28
  250. package/dist/capabilities/vultr.json +25 -25
  251. package/dist/capabilities/wafer.ai.json +17 -17
  252. package/dist/capabilities/wallaby.json +4 -4
  253. package/dist/capabilities/wally.json +14 -14
  254. package/dist/capabilities/wandb.json +19 -19
  255. package/dist/capabilities/watt.json +25 -25
  256. package/dist/capabilities/xai.json +6 -6
  257. package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
  258. package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
  259. package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
  260. package/dist/capabilities/xiaomi.json +2 -2
  261. package/dist/capabilities/xpersona.json +12 -12
  262. package/dist/capabilities/xxapi.json +27 -27
  263. package/dist/capabilities/zai-coding-plan.json +12 -12
  264. package/dist/capabilities/zai.json +32 -32
  265. package/dist/capabilities/zenifra.json +27 -27
  266. package/dist/capabilities/zenmux.json +190 -190
  267. package/dist/capabilities/zerogpu.json +14 -14
  268. package/dist/capabilities/zhipuai-coding-plan.json +8 -8
  269. package/dist/capabilities/zhipuai.json +31 -31
  270. package/dist/capabilities/zro.json +6 -6
  271. package/dist/channels/index.cjs +2 -2
  272. package/dist/channels/index.js +2 -2
  273. package/dist/{channels-dBz-1Oy7.cjs → channels-BXZbY7TL.cjs} +1 -1
  274. package/dist/{channels-CyJ0PpSg.js → channels-Bs8wDPDl.js} +1 -1
  275. package/dist/coding-agent/index.cjs +2 -2
  276. package/dist/coding-agent/index.js +2 -2
  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 +722 -707
  281. package/dist/docs/references/docs-agents-code-mode.md +20 -0
  282. package/dist/docs/references/docs-browser.md +3 -1
  283. package/dist/docs/references/docs-knowledge-agents-and-tools.md +2 -0
  284. package/dist/docs/references/integrations.md +1 -0
  285. package/dist/docs/references/reference-processors-tool-search-processor.md +3 -3
  286. package/dist/docs/references/reference-tools-create-code-mode.md +22 -0
  287. package/dist/evals/index.cjs +1 -1
  288. package/dist/evals/index.js +1 -1
  289. package/dist/evals/scoreTraces/index.cjs +1 -1
  290. package/dist/evals/scoreTraces/index.js +1 -1
  291. package/dist/harness/index.cjs +2 -2
  292. package/dist/harness/index.js +2 -2
  293. package/dist/index.cjs +1 -1
  294. package/dist/index.js +1 -1
  295. package/dist/knowledge/agent-scopes.d.ts +17 -0
  296. package/dist/knowledge/declarations.d.ts +2 -0
  297. package/dist/knowledge/held-scopes-state-processor.d.ts +50 -0
  298. package/dist/knowledge/importers/types.d.ts +2 -0
  299. package/dist/knowledge/index.cjs +65 -15
  300. package/dist/knowledge/index.d.ts +6 -0
  301. package/dist/knowledge/index.js +64 -16
  302. package/dist/knowledge/page-tools.d.ts +14 -0
  303. package/dist/knowledge/run.d.ts +1 -0
  304. package/dist/llm/index.cjs +3 -3
  305. package/dist/llm/index.js +3 -3
  306. package/dist/llm/model/provider-types.generated.d.ts +8041 -8014
  307. package/dist/{llm-Du8yTHDN.js → llm-9xmy8HlF.js} +2 -2
  308. package/dist/{llm-BiSuGioB.cjs → llm-ypGNjEom.cjs} +2 -2
  309. package/dist/loop/index.cjs +2 -2
  310. package/dist/loop/index.js +2 -2
  311. package/dist/{manager-CiKAT1GP.js → manager-B-QrBhhd.js} +2 -2
  312. package/dist/{manager-Bd8By72w.cjs → manager-CYXV5_vY.cjs} +2 -2
  313. package/dist/mastra/index.cjs +1 -1
  314. package/dist/mastra/index.js +1 -1
  315. package/dist/{mastra-GjJdwKF7.js → mastra-DPSwJ5ae.js} +16 -16
  316. package/dist/{mastra-BD1Hqrb2.cjs → mastra-zszeli0N.cjs} +16 -16
  317. package/dist/memory/index.cjs +2 -2
  318. package/dist/memory/index.js +2 -2
  319. package/dist/{model-Bvfq1yB9.js → model-UYJb8Zel.js} +1 -1
  320. package/dist/{model-CI05YYPx.cjs → model-WLujr8OR.cjs} +1 -1
  321. package/dist/{netlify-DQ-v2Run.js → netlify-DTWAZGpA.js} +1 -1
  322. package/dist/{netlify-DkSS4nuo.cjs → netlify-wZafLKoe.cjs} +1 -1
  323. package/dist/notifications/index.cjs +1 -1
  324. package/dist/notifications/index.js +1 -1
  325. package/dist/processor-provider/index.cjs +1 -1
  326. package/dist/processor-provider/index.js +1 -1
  327. package/dist/processors/index.cjs +2 -2
  328. package/dist/processors/index.js +2 -2
  329. package/dist/processors/processors/tool-search.d.ts +2 -2
  330. package/dist/{provider-registry-K3a83H9-.cjs → provider-registry-BvpUdOiq.cjs} +21504 -21437
  331. package/dist/{provider-registry-D7D3C2RI.js → provider-registry-COT79RLh.js} +21504 -21437
  332. package/dist/provider-registry.json +22003 -21942
  333. package/dist/{registry-generator-BgHaZqDZ.js → registry-generator-BKjTPD6B.js} +1 -1
  334. package/dist/{registry-generator-RfPwMlUl.cjs → registry-generator-Dn1Tuacv.cjs} +1 -1
  335. package/dist/{rehydrate-C4-5kM6Z.js → rehydrate-BK1v65H7.js} +2 -2
  336. package/dist/{rehydrate-DwfzaTOg.cjs → rehydrate-C0xrJUBu.cjs} +2 -2
  337. package/dist/relevance/index.cjs +2 -2
  338. package/dist/relevance/index.js +2 -2
  339. package/dist/{run-registry-Bj_lW9M3.js → run-registry-DKiudqVU.js} +351 -36
  340. package/dist/{run-registry-BJa47sa2.cjs → run-registry-DX_EyboB.cjs} +374 -35
  341. package/dist/storage/index.cjs +2 -2
  342. package/dist/storage/index.js +2 -2
  343. package/dist/stream/index.cjs +2 -2
  344. package/dist/stream/index.js +2 -2
  345. package/dist/{stream-DaIpS6ky.js → stream-B4LzC6Sz.js} +1 -1
  346. package/dist/{stream-CWE0h7Yc.cjs → stream-BmtBm_-L.cjs} +1 -1
  347. package/dist/test-utils/llm-mock.cjs +1 -1
  348. package/dist/test-utils/llm-mock.js +1 -1
  349. package/dist/tool-loop-agent/index.cjs +1 -1
  350. package/dist/tool-loop-agent/index.js +1 -1
  351. package/dist/{tool-loop-agent-BGBhn5xS.cjs → tool-loop-agent-BIbw3quM.cjs} +3 -3
  352. package/dist/{tool-loop-agent-B12lpXBl.js → tool-loop-agent-CR2AgmkF.js} +3 -3
  353. package/dist/tools/code-mode/index.d.ts +2 -0
  354. package/dist/tools/code-mode/log-collector.d.ts +49 -0
  355. package/dist/tools/code-mode/types.d.ts +71 -0
  356. package/dist/tools/index.cjs +3 -1
  357. package/dist/tools/index.js +2 -2
  358. package/dist/{tools-n9lqzDNe.cjs → tools-BEYxowf0.cjs} +316 -30
  359. package/dist/{tools-DDfA_ES4.js → tools-tPy2FwMI.js} +305 -31
  360. package/dist/{utils-dueX8ECq.js → utils-BnG4bq6k.js} +1 -1
  361. package/dist/{utils-CPOlvXFL.cjs → utils-D2Bj0C2E.cjs} +1 -1
  362. package/dist/utils.cjs +1 -1
  363. package/dist/utils.js +1 -1
  364. package/dist/{validate-DdirQd9u.cjs → validate-BxgKlbt7.cjs} +1 -1
  365. package/dist/{validate-x3wcpuT8.js → validate-DHEGALaE.js} +1 -1
  366. package/dist/vector/index.cjs +1 -1
  367. package/dist/vector/index.js +1 -1
  368. package/dist/worker/index.cjs +1 -1
  369. package/dist/worker/index.js +1 -1
  370. package/dist/{worker-CfMtR2cV.js → worker-1lHN6hT1.js} +2 -2
  371. package/dist/{worker-CPZ3HqQn.cjs → worker-BRKHC9hv.cjs} +2 -2
  372. package/dist/{worker-NYiueScR.js → worker-C-xoXGOt.js} +2 -2
  373. package/dist/{worker-GrFJJ7Y0.cjs → worker-DYBrWSDX.cjs} +2 -2
  374. package/dist/{workflow-BgAes9PI.js → workflow-79JneaJP.js} +3 -3
  375. package/dist/{workflow-BNUED985.cjs → workflow-DGRDgyhs.cjs} +3 -3
  376. package/dist/workflows/builder/index.cjs +1 -1
  377. package/dist/workflows/builder/index.js +1 -1
  378. package/dist/workflows/evented/index.cjs +1 -1
  379. package/dist/workflows/evented/index.js +1 -1
  380. package/dist/workflows/index.cjs +4 -4
  381. package/dist/workflows/index.js +4 -4
  382. package/dist/workspace/index.cjs +1 -1
  383. package/dist/workspace/index.js +1 -1
  384. package/dist/workspace/sandbox/teardown-context.d.ts +74 -0
  385. package/dist/{workspace-Pv3J8K0c.cjs → workspace-C8Zo5_qK.cjs} +106 -5
  386. package/dist/{workspace-BK9ltbSa.js → workspace-DOAil8mG.js} +106 -5
  387. package/package.json +7 -7
  388. package/src/llm/model/provider-types.generated.d.ts +8041 -8014
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_workspace = require("../workspace-Pv3J8K0c.cjs");
2
+ const require_workspace = require("../workspace-C8Zo5_qK.cjs");
3
3
  const require_errors = require("../errors-D5kMB1FQ.cjs");
4
4
  const require_workspace_skills = require("../workspace-skills-BcquhPDn.cjs");
5
5
  exports.CompositeFilesystem = require_workspace.CompositeFilesystem;
@@ -1,4 +1,4 @@
1
- import { $ as SandboxAbortError, A as deleteFileTool, B as MastraSandbox, C as fileStatTool, E as truncateOutput, F as LocalSandbox, G as supportsComputer, H as UnsupportedStdinCloseError, I as detectIsolation, J as MountManager, K as supportsNetworking, L as getRecommendedIsolation, M as requireFilesystem, N as requireSandbox, P as requireWorkspace, Q as MountNotSupportedError, R as isIsolationAvailable, S as indexContentTool, T as DEFAULT_TAIL_LINES, U as MAX_SANDBOX_FILE_MODE, V as ProcessHandle, W as assertModesUnsupported, X as IsolationUnavailableError, Y as FilesystemNotMountableError, Z as MountError, _ as writeFileTool, a as describeFactorySandbox, b as mkdirTool, c as Workspace, ct as MastraFilesystem, d as collectSkillForPublish, dt as WORKSPACE_TOOLS, et as SandboxError, f as publishSkillFromSource, ft as WORKSPACE_TOOLS_PREFIX, g as resolveToolConfig, h as createWorkspaceTools, i as FactorySandbox, it as SandboxUnsupportedFeatureError, j as applyPatchTool, k as editFileTool, l as createSkillTools, lt as CompositeFilesystem, m as VersionedSkillSource, n as createRecreateSandboxTool, nt as SandboxNotReadyError, o as isFactorySandbox, p as CompositeVersionedSkillSource, q as validateSandboxFileMode, r as FACTORY_SANDBOX_BRAND, rt as SandboxTimeoutError, s as normalizeFactorySandboxSettings, st as LocalFilesystem, t as RECREATE_SANDBOX_TOOL_ID, tt as SandboxExecutionError, u as formatSkillActivation, ut as callLifecycle, v as searchTool, w as executeCommandTool, x as listFilesTool, y as readFileTool, z as SandboxProcessManager } from "../workspace-BK9ltbSa.js";
1
+ import { $ as SandboxAbortError, A as deleteFileTool, B as MastraSandbox, C as fileStatTool, E as truncateOutput, F as LocalSandbox, G as supportsComputer, H as UnsupportedStdinCloseError, I as detectIsolation, J as MountManager, K as supportsNetworking, L as getRecommendedIsolation, M as requireFilesystem, N as requireSandbox, P as requireWorkspace, Q as MountNotSupportedError, R as isIsolationAvailable, S as indexContentTool, T as DEFAULT_TAIL_LINES, U as MAX_SANDBOX_FILE_MODE, V as ProcessHandle, W as assertModesUnsupported, X as IsolationUnavailableError, Y as FilesystemNotMountableError, Z as MountError, _ as writeFileTool, a as describeFactorySandbox, b as mkdirTool, c as Workspace, ct as MastraFilesystem, d as collectSkillForPublish, dt as WORKSPACE_TOOLS, et as SandboxError, f as publishSkillFromSource, ft as WORKSPACE_TOOLS_PREFIX, g as resolveToolConfig, h as createWorkspaceTools, i as FactorySandbox, it as SandboxUnsupportedFeatureError, j as applyPatchTool, k as editFileTool, l as createSkillTools, lt as CompositeFilesystem, m as VersionedSkillSource, n as createRecreateSandboxTool, nt as SandboxNotReadyError, o as isFactorySandbox, p as CompositeVersionedSkillSource, q as validateSandboxFileMode, r as FACTORY_SANDBOX_BRAND, rt as SandboxTimeoutError, s as normalizeFactorySandboxSettings, st as LocalFilesystem, t as RECREATE_SANDBOX_TOOL_ID, tt as SandboxExecutionError, u as formatSkillActivation, ut as callLifecycle, v as searchTool, w as executeCommandTool, x as listFilesTool, y as readFileTool, z as SandboxProcessManager } from "../workspace-DOAil8mG.js";
2
2
  import { _ as WorkspaceError, a as FileReadRequiredError, b as WorkspaceReadOnlyError, c as FilesystemNotReadyError, d as PermissionError, f as SandboxFeatureNotSupportedError, g as UnsupportedGrepPatternError, h as StaleFileError, i as FileNotFoundError, l as IsDirectoryError, m as SearchNotAvailableError, n as DirectoryNotFoundError, o as FilesystemError, p as SandboxNotAvailableError, r as FileExistsError, s as FilesystemNotAvailableError, t as DirectoryNotEmptyError, u as NotDirectoryError, v as WorkspaceNotAvailableError, y as WorkspaceNotReadyError } from "../errors-CzFYpCHw.js";
3
3
  import { b as getMimeType, f as createGlobMatcher, h as matchGlob, l as LocalSkillSource, m as isGlobPattern, p as extractGlobBase } from "../workspace-skills-38OY32_b.js";
4
4
  export { CompositeFilesystem, CompositeVersionedSkillSource, DEFAULT_TAIL_LINES, DirectoryNotEmptyError, DirectoryNotFoundError, FACTORY_SANDBOX_BRAND, FactorySandbox, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, FilesystemNotMountableError, FilesystemNotReadyError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, LocalSkillSource, MAX_SANDBOX_FILE_MODE, MastraFilesystem, MastraSandbox, MountError, MountManager, MountNotSupportedError, NotDirectoryError, PermissionError, ProcessHandle, RECREATE_SANDBOX_TOOL_ID, SandboxAbortError, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxProcessManager, SandboxTimeoutError, SandboxUnsupportedFeatureError, SearchNotAvailableError, StaleFileError, UnsupportedGrepPatternError, UnsupportedStdinCloseError, VersionedSkillSource, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotAvailableError, WorkspaceNotReadyError, WorkspaceReadOnlyError, applyPatchTool, assertModesUnsupported, callLifecycle, collectSkillForPublish, createGlobMatcher, createRecreateSandboxTool, createSkillTools, createWorkspaceTools, deleteFileTool, describeFactorySandbox, detectIsolation, editFileTool, executeCommandTool, extractGlobBase, fileStatTool, formatSkillActivation, getMimeType, getRecommendedIsolation, indexContentTool, isFactorySandbox, isGlobPattern, isIsolationAvailable, listFilesTool, matchGlob, mkdirTool, normalizeFactorySandboxSettings, publishSkillFromSource, readFileTool, requireFilesystem, requireSandbox, requireWorkspace, resolveToolConfig, searchTool, supportsComputer, supportsNetworking, truncateOutput, validateSandboxFileMode, writeFileTool };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Sandbox teardown context (internal).
3
+ *
4
+ * `MastraSandbox.ensureRunning()` must let a provider's own teardown traffic
5
+ * through while blocking unrelated callers: `stop()`/`destroy()` legitimately
6
+ * list and kill processes, and those calls re-enter `ensureRunning()` on the
7
+ * same sandbox. Blocking them would deadlock teardown; letting every caller
8
+ * through lets a command interleave with a stop and run against a sandbox that
9
+ * is being torn down.
10
+ *
11
+ * The fix is caller identity, not a global flag: `stop()`/`destroy()` run their
12
+ * hook + provider work inside an {@link AsyncLocalStorage} scope holding the
13
+ * sandbox instance, so `ensureRunning()` can tell "this call is part of *this*
14
+ * sandbox's teardown" from "this call is external". Identity survives arbitrary
15
+ * awaits, so it reaches nested hooks and process-manager wrappers.
16
+ *
17
+ * Two properties keep that identity honest:
18
+ *
19
+ * - A scope expires when the teardown it opened settles. Work that outlives the
20
+ * teardown (a timer or an unawaited call scheduled inside a hook) still sees
21
+ * the scope as its store, but must not stay authorized to bypass the fence.
22
+ * - Scopes chain to the teardown that opened them, so one sandbox's hook tearing
23
+ * down another (`A.onStop` calling `B._stop()`) can still reach `A` from inside
24
+ * `B`'s teardown instead of deadlocking on `A`'s own in-flight stop. The chain
25
+ * only spans *live* teardowns: a settled scope ends it, so work an inner
26
+ * teardown left behind is an external caller of every sandbox, not a member of
27
+ * the enclosing teardown.
28
+ *
29
+ * Not exported from `workspace/sandbox/index.ts` or any package export.
30
+ */
31
+ /** The lifecycles that may re-enter the sandbox while it is torn down. */
32
+ type SandboxTeardownPhase = 'stopping' | 'destroying';
33
+ /**
34
+ * Whether this runtime can attribute a re-entrant call to its teardown scope.
35
+ *
36
+ * When it cannot, `ensureRunning()` keeps the legacy behavior of letting calls
37
+ * during `stopping` through (awaiting teardown without caller identity would
38
+ * deadlock providers doing process teardown). `destroying` still rejects.
39
+ */
40
+ export declare function isSandboxTeardownScopeSupported(): boolean;
41
+ /**
42
+ * Run `work` inside `sandbox`'s teardown scope for `phase`, so nested calls
43
+ * into the sandbox are recognized as part of this teardown.
44
+ *
45
+ * The scope deliberately covers only the teardown work itself — hook execution
46
+ * and the provider's `stop()`/`destroy()` — never unrelated external work, and
47
+ * it closes as soon as `work` settles: a callback the hook left behind (a timer,
48
+ * an unawaited command) sees the scope as its store once inherited, but is no
49
+ * longer authorized once the teardown it belongs to is over.
50
+ */
51
+ export declare function runInSandboxTeardown<T>(sandbox: unknown, phase: SandboxTeardownPhase, work: () => T | Promise<T>): Promise<T>;
52
+ /**
53
+ * Whether the current async scope is `sandbox`'s own in-flight teardown. Matched
54
+ * by instance identity, so one sandbox's teardown never authorizes another's.
55
+ *
56
+ * Walks the scope chain, which links each teardown to the one it ran inside: a
57
+ * sandbox torn down from inside another sandbox's teardown is still that outer
58
+ * teardown's work, and attributing it elsewhere would make it wait on the very
59
+ * stop it is part of.
60
+ *
61
+ * The walk requires every scope it crosses to be active. A settled scope ends
62
+ * it, because work that outlived a teardown (a timer or unawaited call the hook
63
+ * left behind) is an ordinary external caller: reaching through the expired
64
+ * scope to an enclosing teardown would hand that orphaned work permission its
65
+ * own teardown no longer has, and would make one sandbox's leftover callback
66
+ * count as another sandbox's teardown.
67
+ *
68
+ * The trade-off is deliberate: an outer teardown must not *await* work that an
69
+ * inner teardown left behind, since that work is now external and will wait on
70
+ * the outer stop. Only work still inside a live teardown is authorized.
71
+ */
72
+ export declare function isInSandboxTeardown(sandbox: unknown): boolean;
73
+ export {};
74
+ //# sourceMappingURL=teardown-context.d.ts.map
@@ -2746,6 +2746,97 @@ var ProcessHandle = class {
2746
2746
  return this._writer;
2747
2747
  }
2748
2748
  };
2749
+ // src/workspace/sandbox/teardown-context.ts
2750
+ let storage;
2751
+ let storageResolved = false;
2752
+ /**
2753
+ * Resolve `AsyncLocalStorage` lazily, without a static `node:async_hooks`
2754
+ * import.
2755
+ *
2756
+ * Studio's client bundle transitively imports the agent runtime, which pulls in
2757
+ * the sandbox modules, so a top-level `import 'node:async_hooks'` would hoist a
2758
+ * Node builtin into a browser graph. `process.getBuiltinModule` is available on
2759
+ * the supported Node baseline (>= 22.13) and returns the builtin without a
2760
+ * module-resolution step, so directly constructed sandboxes have no async
2761
+ * initialization gap. Elsewhere (import-only or browser-like runtimes) this
2762
+ * resolves to `undefined`.
2763
+ */
2764
+ function getStorage() {
2765
+ if (storageResolved) return storage;
2766
+ storageResolved = true;
2767
+ try {
2768
+ const getBuiltinModule = globalThis.process?.getBuiltinModule;
2769
+ const AsyncLocalStorage = (typeof getBuiltinModule === "function" ? getBuiltinModule("node:async_hooks") : void 0)?.AsyncLocalStorage;
2770
+ if (typeof AsyncLocalStorage === "function") storage = new AsyncLocalStorage();
2771
+ } catch {
2772
+ storage = void 0;
2773
+ }
2774
+ return storage;
2775
+ }
2776
+ /**
2777
+ * Whether this runtime can attribute a re-entrant call to its teardown scope.
2778
+ *
2779
+ * When it cannot, `ensureRunning()` keeps the legacy behavior of letting calls
2780
+ * during `stopping` through (awaiting teardown without caller identity would
2781
+ * deadlock providers doing process teardown). `destroying` still rejects.
2782
+ */
2783
+ function isSandboxTeardownScopeSupported() {
2784
+ return getStorage() !== void 0;
2785
+ }
2786
+ /**
2787
+ * Run `work` inside `sandbox`'s teardown scope for `phase`, so nested calls
2788
+ * into the sandbox are recognized as part of this teardown.
2789
+ *
2790
+ * The scope deliberately covers only the teardown work itself — hook execution
2791
+ * and the provider's `stop()`/`destroy()` — never unrelated external work, and
2792
+ * it closes as soon as `work` settles: a callback the hook left behind (a timer,
2793
+ * an unawaited command) sees the scope as its store once inherited, but is no
2794
+ * longer authorized once the teardown it belongs to is over.
2795
+ */
2796
+ async function runInSandboxTeardown(sandbox, phase, work) {
2797
+ const activeStorage = getStorage();
2798
+ if (!activeStorage) return work();
2799
+ const scope = {
2800
+ sandbox,
2801
+ phase,
2802
+ parent: activeStorage.getStore(),
2803
+ active: true
2804
+ };
2805
+ try {
2806
+ return await activeStorage.run(scope, work);
2807
+ } finally {
2808
+ scope.active = false;
2809
+ }
2810
+ }
2811
+ /**
2812
+ * Whether the current async scope is `sandbox`'s own in-flight teardown. Matched
2813
+ * by instance identity, so one sandbox's teardown never authorizes another's.
2814
+ *
2815
+ * Walks the scope chain, which links each teardown to the one it ran inside: a
2816
+ * sandbox torn down from inside another sandbox's teardown is still that outer
2817
+ * teardown's work, and attributing it elsewhere would make it wait on the very
2818
+ * stop it is part of.
2819
+ *
2820
+ * The walk requires every scope it crosses to be active. A settled scope ends
2821
+ * it, because work that outlived a teardown (a timer or unawaited call the hook
2822
+ * left behind) is an ordinary external caller: reaching through the expired
2823
+ * scope to an enclosing teardown would hand that orphaned work permission its
2824
+ * own teardown no longer has, and would make one sandbox's leftover callback
2825
+ * count as another sandbox's teardown.
2826
+ *
2827
+ * The trade-off is deliberate: an outer teardown must not *await* work that an
2828
+ * inner teardown left behind, since that work is now external and will wait on
2829
+ * the outer stop. Only work still inside a live teardown is authorized.
2830
+ */
2831
+ function isInSandboxTeardown(sandbox) {
2832
+ const activeStorage = getStorage();
2833
+ if (!activeStorage) return false;
2834
+ for (let scope = activeStorage.getStore(); scope; scope = scope.parent) {
2835
+ if (!scope.active) return false;
2836
+ if (scope.sandbox === sandbox) return true;
2837
+ }
2838
+ return false;
2839
+ }
2749
2840
  // src/workspace/sandbox/mastra-sandbox.ts
2750
2841
  /**
2751
2842
  * MastraSandbox Base Class
@@ -3109,8 +3200,14 @@ var MastraSandbox = class MastraSandbox extends require_base.MastraBase {
3109
3200
  * ```
3110
3201
  */
3111
3202
  async ensureRunning() {
3203
+ if (isInSandboxTeardown(this)) return;
3112
3204
  if (this.status === "destroyed") throw new SandboxNotReadyError(this.id);
3113
- if (this.status === "destroying" || this.status === "stopping") return;
3205
+ if (this.status === "destroying") throw new SandboxNotReadyError(this.id);
3206
+ if (this.status === "stopping") {
3207
+ if (!isSandboxTeardownScopeSupported()) return;
3208
+ const stopPromise = this._stopPromise;
3209
+ if (stopPromise) await stopPromise;
3210
+ }
3114
3211
  if (this.status !== "running") await this._start();
3115
3212
  if (this.status !== "running") throw new SandboxNotReadyError(this.id);
3116
3213
  }
@@ -3139,8 +3236,10 @@ var MastraSandbox = class MastraSandbox extends require_base.MastraBase {
3139
3236
  async _executeStop() {
3140
3237
  this.status = "stopping";
3141
3238
  try {
3142
- await this._onStop?.({ sandbox: this });
3143
- await this.stop();
3239
+ await runInSandboxTeardown(this, "stopping", async () => {
3240
+ await this._onStop?.({ sandbox: this });
3241
+ await this.stop();
3242
+ });
3144
3243
  this.status = "stopped";
3145
3244
  } catch (error) {
3146
3245
  this.status = "error";
@@ -3184,8 +3283,10 @@ var MastraSandbox = class MastraSandbox extends require_base.MastraBase {
3184
3283
  async _executeDestroy() {
3185
3284
  this.status = "destroying";
3186
3285
  try {
3187
- await this._onDestroy?.({ sandbox: this });
3188
- await this.destroy();
3286
+ await runInSandboxTeardown(this, "destroying", async () => {
3287
+ await this._onDestroy?.({ sandbox: this });
3288
+ await this.destroy();
3289
+ });
3189
3290
  this.status = "destroyed";
3190
3291
  } catch (error) {
3191
3292
  this.status = "error";
@@ -2741,6 +2741,97 @@ var ProcessHandle = class {
2741
2741
  return this._writer;
2742
2742
  }
2743
2743
  };
2744
+ // src/workspace/sandbox/teardown-context.ts
2745
+ let storage;
2746
+ let storageResolved = false;
2747
+ /**
2748
+ * Resolve `AsyncLocalStorage` lazily, without a static `node:async_hooks`
2749
+ * import.
2750
+ *
2751
+ * Studio's client bundle transitively imports the agent runtime, which pulls in
2752
+ * the sandbox modules, so a top-level `import 'node:async_hooks'` would hoist a
2753
+ * Node builtin into a browser graph. `process.getBuiltinModule` is available on
2754
+ * the supported Node baseline (>= 22.13) and returns the builtin without a
2755
+ * module-resolution step, so directly constructed sandboxes have no async
2756
+ * initialization gap. Elsewhere (import-only or browser-like runtimes) this
2757
+ * resolves to `undefined`.
2758
+ */
2759
+ function getStorage() {
2760
+ if (storageResolved) return storage;
2761
+ storageResolved = true;
2762
+ try {
2763
+ const getBuiltinModule = globalThis.process?.getBuiltinModule;
2764
+ const AsyncLocalStorage = (typeof getBuiltinModule === "function" ? getBuiltinModule("node:async_hooks") : void 0)?.AsyncLocalStorage;
2765
+ if (typeof AsyncLocalStorage === "function") storage = new AsyncLocalStorage();
2766
+ } catch {
2767
+ storage = void 0;
2768
+ }
2769
+ return storage;
2770
+ }
2771
+ /**
2772
+ * Whether this runtime can attribute a re-entrant call to its teardown scope.
2773
+ *
2774
+ * When it cannot, `ensureRunning()` keeps the legacy behavior of letting calls
2775
+ * during `stopping` through (awaiting teardown without caller identity would
2776
+ * deadlock providers doing process teardown). `destroying` still rejects.
2777
+ */
2778
+ function isSandboxTeardownScopeSupported() {
2779
+ return getStorage() !== void 0;
2780
+ }
2781
+ /**
2782
+ * Run `work` inside `sandbox`'s teardown scope for `phase`, so nested calls
2783
+ * into the sandbox are recognized as part of this teardown.
2784
+ *
2785
+ * The scope deliberately covers only the teardown work itself — hook execution
2786
+ * and the provider's `stop()`/`destroy()` — never unrelated external work, and
2787
+ * it closes as soon as `work` settles: a callback the hook left behind (a timer,
2788
+ * an unawaited command) sees the scope as its store once inherited, but is no
2789
+ * longer authorized once the teardown it belongs to is over.
2790
+ */
2791
+ async function runInSandboxTeardown(sandbox, phase, work) {
2792
+ const activeStorage = getStorage();
2793
+ if (!activeStorage) return work();
2794
+ const scope = {
2795
+ sandbox,
2796
+ phase,
2797
+ parent: activeStorage.getStore(),
2798
+ active: true
2799
+ };
2800
+ try {
2801
+ return await activeStorage.run(scope, work);
2802
+ } finally {
2803
+ scope.active = false;
2804
+ }
2805
+ }
2806
+ /**
2807
+ * Whether the current async scope is `sandbox`'s own in-flight teardown. Matched
2808
+ * by instance identity, so one sandbox's teardown never authorizes another's.
2809
+ *
2810
+ * Walks the scope chain, which links each teardown to the one it ran inside: a
2811
+ * sandbox torn down from inside another sandbox's teardown is still that outer
2812
+ * teardown's work, and attributing it elsewhere would make it wait on the very
2813
+ * stop it is part of.
2814
+ *
2815
+ * The walk requires every scope it crosses to be active. A settled scope ends
2816
+ * it, because work that outlived a teardown (a timer or unawaited call the hook
2817
+ * left behind) is an ordinary external caller: reaching through the expired
2818
+ * scope to an enclosing teardown would hand that orphaned work permission its
2819
+ * own teardown no longer has, and would make one sandbox's leftover callback
2820
+ * count as another sandbox's teardown.
2821
+ *
2822
+ * The trade-off is deliberate: an outer teardown must not *await* work that an
2823
+ * inner teardown left behind, since that work is now external and will wait on
2824
+ * the outer stop. Only work still inside a live teardown is authorized.
2825
+ */
2826
+ function isInSandboxTeardown(sandbox) {
2827
+ const activeStorage = getStorage();
2828
+ if (!activeStorage) return false;
2829
+ for (let scope = activeStorage.getStore(); scope; scope = scope.parent) {
2830
+ if (!scope.active) return false;
2831
+ if (scope.sandbox === sandbox) return true;
2832
+ }
2833
+ return false;
2834
+ }
2744
2835
  // src/workspace/sandbox/mastra-sandbox.ts
2745
2836
  /**
2746
2837
  * MastraSandbox Base Class
@@ -3104,8 +3195,14 @@ var MastraSandbox = class MastraSandbox extends MastraBase {
3104
3195
  * ```
3105
3196
  */
3106
3197
  async ensureRunning() {
3198
+ if (isInSandboxTeardown(this)) return;
3107
3199
  if (this.status === "destroyed") throw new SandboxNotReadyError(this.id);
3108
- if (this.status === "destroying" || this.status === "stopping") return;
3200
+ if (this.status === "destroying") throw new SandboxNotReadyError(this.id);
3201
+ if (this.status === "stopping") {
3202
+ if (!isSandboxTeardownScopeSupported()) return;
3203
+ const stopPromise = this._stopPromise;
3204
+ if (stopPromise) await stopPromise;
3205
+ }
3109
3206
  if (this.status !== "running") await this._start();
3110
3207
  if (this.status !== "running") throw new SandboxNotReadyError(this.id);
3111
3208
  }
@@ -3134,8 +3231,10 @@ var MastraSandbox = class MastraSandbox extends MastraBase {
3134
3231
  async _executeStop() {
3135
3232
  this.status = "stopping";
3136
3233
  try {
3137
- await this._onStop?.({ sandbox: this });
3138
- await this.stop();
3234
+ await runInSandboxTeardown(this, "stopping", async () => {
3235
+ await this._onStop?.({ sandbox: this });
3236
+ await this.stop();
3237
+ });
3139
3238
  this.status = "stopped";
3140
3239
  } catch (error) {
3141
3240
  this.status = "error";
@@ -3179,8 +3278,10 @@ var MastraSandbox = class MastraSandbox extends MastraBase {
3179
3278
  async _executeDestroy() {
3180
3279
  this.status = "destroying";
3181
3280
  try {
3182
- await this._onDestroy?.({ sandbox: this });
3183
- await this.destroy();
3281
+ await runInSandboxTeardown(this, "destroying", async () => {
3282
+ await this._onDestroy?.({ sandbox: this });
3283
+ await this.destroy();
3284
+ });
3184
3285
  this.status = "destroyed";
3185
3286
  } catch (error) {
3186
3287
  this.status = "error";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/core",
3
- "version": "1.87.0-alpha.7",
3
+ "version": "1.87.0-alpha.9",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -966,19 +966,19 @@
966
966
  "vscode-languageserver-protocol": "^3.18.5",
967
967
  "zod": "^4.6.7",
968
968
  "zod-v3": "npm:zod@3.25.76",
969
- "@internal/ai-v6": "0.0.99",
970
- "@internal/ai-v7": "0.0.99",
971
969
  "@internal/ai-sdk-v4": "0.0.99",
972
970
  "@internal/ai-sdk-v5": "0.0.99",
971
+ "@internal/ai-v7": "0.0.99",
972
+ "@internal/ai-v6": "0.0.99",
973
973
  "@internal/auth": "0.0.40",
974
974
  "@internal/core": "0.1.4",
975
975
  "@internal/deployer": "0.0.5",
976
- "@internal/lint": "0.0.152",
977
- "@internal/llm-recorder": "0.0.88",
978
976
  "@internal/external-types": "0.0.102",
977
+ "@internal/lint": "0.0.152",
979
978
  "@internal/types-builder": "0.0.127",
980
- "@internal/voice": "0.0.48",
981
- "@internal/test-utils": "0.0.88"
979
+ "@internal/llm-recorder": "0.0.88",
980
+ "@internal/test-utils": "0.0.88",
981
+ "@internal/voice": "0.0.48"
982
982
  },
983
983
  "engines": {
984
984
  "node": ">=22.13.0"