@mastra/core 1.2.1-alpha.0 → 1.3.0-alpha.2

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 (403) hide show
  1. package/CHANGELOG.md +341 -0
  2. package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +2093 -262
  3. package/dist/agent/agent-legacy.d.ts.map +1 -1
  4. package/dist/agent/agent.d.ts +12 -3
  5. package/dist/agent/agent.d.ts.map +1 -1
  6. package/dist/agent/index.cjs +13 -13
  7. package/dist/agent/index.js +2 -2
  8. package/dist/agent/message-list/index.cjs +18 -18
  9. package/dist/agent/message-list/index.js +1 -1
  10. package/dist/agent/message-list/message-list.d.ts.map +1 -1
  11. package/dist/agent/types.d.ts +6 -1
  12. package/dist/agent/types.d.ts.map +1 -1
  13. package/dist/agent/workflows/prepare-stream/index.d.ts +3 -1
  14. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  15. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  16. package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -1
  17. package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
  18. package/dist/base.cjs +2 -2
  19. package/dist/base.d.ts +13 -1
  20. package/dist/base.d.ts.map +1 -1
  21. package/dist/base.js +1 -1
  22. package/dist/bundler/index.cjs +2 -2
  23. package/dist/bundler/index.js +1 -1
  24. package/dist/cache/index.cjs +3 -3
  25. package/dist/cache/index.js +1 -1
  26. package/dist/{chunk-ENCTSDWC.js → chunk-2GWTJFVM.js} +2410 -1402
  27. package/dist/chunk-2GWTJFVM.js.map +1 -0
  28. package/dist/{chunk-OB4V67IX.cjs → chunk-2K5PNW2U.cjs} +4 -4
  29. package/dist/{chunk-OB4V67IX.cjs.map → chunk-2K5PNW2U.cjs.map} +1 -1
  30. package/dist/{chunk-VZXYBFCX.cjs → chunk-2P6DD7M5.cjs} +10 -10
  31. package/dist/{chunk-VZXYBFCX.cjs.map → chunk-2P6DD7M5.cjs.map} +1 -1
  32. package/dist/{chunk-Q2D7LERO.cjs → chunk-2VD5OGOT.cjs} +4 -4
  33. package/dist/{chunk-Q2D7LERO.cjs.map → chunk-2VD5OGOT.cjs.map} +1 -1
  34. package/dist/{chunk-2DMSFLJY.cjs → chunk-6TZKQI4R.cjs} +8 -8
  35. package/dist/chunk-6TZKQI4R.cjs.map +1 -0
  36. package/dist/{chunk-4NG7CKEG.js → chunk-6VGCVSP4.js} +3 -3
  37. package/dist/{chunk-4NG7CKEG.js.map → chunk-6VGCVSP4.js.map} +1 -1
  38. package/dist/{chunk-IIZF4W7B.cjs → chunk-7UWHFWST.cjs} +52 -5
  39. package/dist/chunk-7UWHFWST.cjs.map +1 -0
  40. package/dist/{chunk-VW7YQWDW.cjs → chunk-BFIOQFGF.cjs} +28 -2
  41. package/dist/chunk-BFIOQFGF.cjs.map +1 -0
  42. package/dist/{chunk-E3VFKTIA.js → chunk-BXLLXTT4.js} +2245 -179
  43. package/dist/chunk-BXLLXTT4.js.map +1 -0
  44. package/dist/{chunk-HMCXNOF6.cjs → chunk-CGPH7CMG.cjs} +2431 -1417
  45. package/dist/chunk-CGPH7CMG.cjs.map +1 -0
  46. package/dist/{chunk-GVLPTDJA.cjs → chunk-D5JZT6EK.cjs} +236 -63
  47. package/dist/chunk-D5JZT6EK.cjs.map +1 -0
  48. package/dist/{chunk-5SOS47PH.cjs → chunk-FLHFB23E.cjs} +454 -222
  49. package/dist/chunk-FLHFB23E.cjs.map +1 -0
  50. package/dist/{chunk-XCPEEIHI.cjs → chunk-GCTAD6B7.cjs} +3012 -927
  51. package/dist/chunk-GCTAD6B7.cjs.map +1 -0
  52. package/dist/{chunk-W3AQUG66.js → chunk-GIY5BINT.js} +4 -4
  53. package/dist/{chunk-W3AQUG66.js.map → chunk-GIY5BINT.js.map} +1 -1
  54. package/dist/{chunk-M6VFJX5A.js → chunk-GMSAGYTB.js} +3 -3
  55. package/dist/{chunk-M6VFJX5A.js.map → chunk-GMSAGYTB.js.map} +1 -1
  56. package/dist/{chunk-JRJJ5VQE.cjs → chunk-GZD6443M.cjs} +99 -55
  57. package/dist/chunk-GZD6443M.cjs.map +1 -0
  58. package/dist/{chunk-Z6NRYYOH.js → chunk-ILQXPZCD.js} +9 -4
  59. package/dist/chunk-ILQXPZCD.js.map +1 -0
  60. package/dist/{chunk-5YVR7B4R.js → chunk-JQNREL64.js} +29 -9
  61. package/dist/chunk-JQNREL64.js.map +1 -0
  62. package/dist/{chunk-QOFI2WBM.cjs → chunk-JU6K7UDX.cjs} +991 -229
  63. package/dist/chunk-JU6K7UDX.cjs.map +1 -0
  64. package/dist/{chunk-HN2MSTR6.cjs → chunk-KAJNBNWP.cjs} +283 -38
  65. package/dist/chunk-KAJNBNWP.cjs.map +1 -0
  66. package/dist/{chunk-MSWXEOZC.js → chunk-KL2JPSRX.js} +5 -5
  67. package/dist/chunk-KL2JPSRX.js.map +1 -0
  68. package/dist/{chunk-MQB7XFXP.js → chunk-LHRHOPUC.js} +3 -3
  69. package/dist/{chunk-MQB7XFXP.js.map → chunk-LHRHOPUC.js.map} +1 -1
  70. package/dist/{chunk-VX7UA3SO.js → chunk-MOOJ3H3C.js} +974 -217
  71. package/dist/chunk-MOOJ3H3C.js.map +1 -0
  72. package/dist/{chunk-HU2ONA2W.cjs → chunk-ON2KVIUJ.cjs} +17 -17
  73. package/dist/{chunk-HU2ONA2W.cjs.map → chunk-ON2KVIUJ.cjs.map} +1 -1
  74. package/dist/{chunk-I66TMZJ3.cjs → chunk-OOCEAC6U.cjs} +21 -18
  75. package/dist/chunk-OOCEAC6U.cjs.map +1 -0
  76. package/dist/{chunk-MNWW2R3U.js → chunk-OV7OOUUR.js} +90 -54
  77. package/dist/chunk-OV7OOUUR.js.map +1 -0
  78. package/dist/{chunk-C4WWWQHT.cjs → chunk-RO47SMI7.cjs} +23 -3
  79. package/dist/chunk-RO47SMI7.cjs.map +1 -0
  80. package/dist/{chunk-6FG6FU5Y.cjs → chunk-RQ56ZSIR.cjs} +4 -4
  81. package/dist/{chunk-6FG6FU5Y.cjs.map → chunk-RQ56ZSIR.cjs.map} +1 -1
  82. package/dist/{chunk-IW3BNL7A.js → chunk-RS6CZXGA.js} +50 -3
  83. package/dist/chunk-RS6CZXGA.js.map +1 -0
  84. package/dist/{chunk-AIJLACR2.js → chunk-S53FKKVL.js} +27 -3
  85. package/dist/chunk-S53FKKVL.js.map +1 -0
  86. package/dist/{chunk-G6E3QNJC.js → chunk-SBPPGJL6.js} +4078 -4333
  87. package/dist/chunk-SBPPGJL6.js.map +1 -0
  88. package/dist/{chunk-UZL4H5P2.cjs → chunk-SH4PCZ3X.cjs} +5375 -5648
  89. package/dist/chunk-SH4PCZ3X.cjs.map +1 -0
  90. package/dist/{chunk-ZWM2CAIM.js → chunk-STKNQDVA.js} +4 -4
  91. package/dist/{chunk-ZWM2CAIM.js.map → chunk-STKNQDVA.js.map} +1 -1
  92. package/dist/{chunk-A5QFWX67.cjs → chunk-U2CABSMC.cjs} +79 -59
  93. package/dist/chunk-U2CABSMC.cjs.map +1 -0
  94. package/dist/{chunk-7MDVYPWX.cjs → chunk-UE2G2LRP.cjs} +9 -4
  95. package/dist/chunk-UE2G2LRP.cjs.map +1 -0
  96. package/dist/{chunk-AUF6U2BL.js → chunk-VM25PDSW.js} +5 -5
  97. package/dist/{chunk-AUF6U2BL.js.map → chunk-VM25PDSW.js.map} +1 -1
  98. package/dist/{chunk-RXD5EGQF.js → chunk-VVD56FI4.js} +228 -55
  99. package/dist/chunk-VVD56FI4.js.map +1 -0
  100. package/dist/{chunk-JIT2OY3X.js → chunk-WCAFTXGK.js} +23 -3
  101. package/dist/chunk-WCAFTXGK.js.map +1 -0
  102. package/dist/{chunk-P62OJXQ4.js → chunk-WL3AW3YA.js} +282 -37
  103. package/dist/chunk-WL3AW3YA.js.map +1 -0
  104. package/dist/{chunk-YLODOPYM.cjs → chunk-XDD5V446.cjs} +4163 -5352
  105. package/dist/chunk-XDD5V446.cjs.map +1 -0
  106. package/dist/{chunk-B4M33FCS.cjs → chunk-XQVYEOI7.cjs} +7 -7
  107. package/dist/{chunk-B4M33FCS.cjs.map → chunk-XQVYEOI7.cjs.map} +1 -1
  108. package/dist/{chunk-BP2TSCBW.js → chunk-ZATLLPIH.js} +4391 -5561
  109. package/dist/chunk-ZATLLPIH.js.map +1 -0
  110. package/dist/{chunk-T6PRRKMW.js → chunk-ZHFM7HCQ.js} +9 -6
  111. package/dist/chunk-ZHFM7HCQ.js.map +1 -0
  112. package/dist/{chunk-WFUNLRQX.js → chunk-ZRUTE56J.js} +366 -134
  113. package/dist/chunk-ZRUTE56J.js.map +1 -0
  114. package/dist/deployer/index.cjs +2 -2
  115. package/dist/deployer/index.js +1 -1
  116. package/dist/docs/SKILL.md +2 -9
  117. package/dist/docs/assets/SOURCE_MAP.json +399 -342
  118. package/dist/docs/references/docs-agents-agent-memory.md +45 -1
  119. package/dist/docs/references/docs-agents-network-approval.md +1 -1
  120. package/dist/docs/references/docs-agents-networks.md +3 -3
  121. package/dist/docs/references/docs-agents-overview.md +8 -0
  122. package/dist/docs/references/docs-agents-using-tools.md +82 -72
  123. package/dist/docs/references/docs-memory-observational-memory.md +11 -8
  124. package/dist/docs/references/docs-observability-overview.md +1 -1
  125. package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +70 -0
  126. package/dist/docs/references/docs-observability-tracing-overview.md +1 -1
  127. package/dist/docs/references/docs-server-middleware.md +0 -2
  128. package/dist/docs/references/docs-server-request-context.md +17 -0
  129. package/dist/docs/references/docs-workflows-agents-and-tools.md +2 -2
  130. package/dist/docs/references/docs-workflows-overview.md +1 -1
  131. package/dist/docs/references/docs-workspace-filesystem.md +2 -0
  132. package/dist/docs/references/docs-workspace-overview.md +3 -1
  133. package/dist/docs/references/docs-workspace-sandbox.md +2 -0
  134. package/dist/docs/references/docs-workspace-search.md +2 -0
  135. package/dist/docs/references/docs-workspace-skills.md +3 -1
  136. package/dist/docs/references/reference-agents-getTools.md +1 -6
  137. package/dist/docs/references/reference-agents-listAgents.md +1 -1
  138. package/dist/docs/references/reference-agents-network.md +0 -2
  139. package/dist/docs/references/reference-cli-mastra.md +29 -4
  140. package/dist/docs/references/reference-client-js-agents.md +1 -1
  141. package/dist/docs/references/reference-configuration.md +1 -1
  142. package/dist/docs/references/reference-core-getStoredAgentById.md +2 -2
  143. package/dist/docs/references/reference-core-listStoredAgents.md +1 -1
  144. package/dist/docs/references/reference-memory-observational-memory.md +2 -0
  145. package/dist/docs/references/reference-tools-mcp-client.md +0 -2
  146. package/dist/docs/references/reference-workflows-step.md +2 -0
  147. package/dist/docs/references/reference-workflows-workflow-methods-map.md +2 -2
  148. package/dist/docs/references/reference-workspace-filesystem.md +2 -0
  149. package/dist/docs/references/reference-workspace-local-filesystem.md +2 -0
  150. package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
  151. package/dist/docs/references/reference-workspace-sandbox.md +2 -0
  152. package/dist/docs/references/reference-workspace-workspace-class.md +2 -0
  153. package/dist/docs/references/reference.md +7 -2
  154. package/dist/editor/index.d.ts +1 -1
  155. package/dist/editor/index.d.ts.map +1 -1
  156. package/dist/editor/types.d.ts +53 -48
  157. package/dist/editor/types.d.ts.map +1 -1
  158. package/dist/evals/base.d.ts +15 -0
  159. package/dist/evals/base.d.ts.map +1 -1
  160. package/dist/evals/index.cjs +20 -20
  161. package/dist/evals/index.js +3 -3
  162. package/dist/evals/run/index.d.ts +3 -3
  163. package/dist/evals/run/index.d.ts.map +1 -1
  164. package/dist/evals/scoreTraces/index.cjs +5 -5
  165. package/dist/evals/scoreTraces/index.js +2 -2
  166. package/dist/features/index.cjs +1 -1
  167. package/dist/features/index.cjs.map +1 -1
  168. package/dist/features/index.d.ts.map +1 -1
  169. package/dist/features/index.js +1 -1
  170. package/dist/features/index.js.map +1 -1
  171. package/dist/index.cjs +4 -4
  172. package/dist/index.d.ts +3 -3
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +2 -2
  175. package/dist/integration/index.cjs +2 -2
  176. package/dist/integration/index.js +1 -1
  177. package/dist/llm/index.cjs +16 -16
  178. package/dist/llm/index.js +5 -5
  179. package/dist/llm/model/gateways/constants.d.ts.map +1 -1
  180. package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
  181. package/dist/llm/model/model.loop.d.ts +1 -1
  182. package/dist/llm/model/model.loop.d.ts.map +1 -1
  183. package/dist/llm/model/provider-types.generated.d.ts +128 -10
  184. package/dist/llm/model/resolve-model.d.ts.map +1 -1
  185. package/dist/loop/index.cjs +12 -12
  186. package/dist/loop/index.js +1 -1
  187. package/dist/loop/network/index.d.ts +3 -3
  188. package/dist/loop/network/index.d.ts.map +1 -1
  189. package/dist/loop/network/run-command-tool.d.ts +1 -1
  190. package/dist/loop/types.d.ts +13 -0
  191. package/dist/loop/types.d.ts.map +1 -1
  192. package/dist/loop/workflows/agentic-execution/index.d.ts +9 -9
  193. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +7 -7
  194. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  195. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +3 -3
  196. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  197. package/dist/loop/workflows/agentic-loop/index.d.ts +9 -9
  198. package/dist/loop/workflows/schema.d.ts +12 -12
  199. package/dist/mastra/index.cjs +2 -2
  200. package/dist/mastra/index.d.ts +91 -5
  201. package/dist/mastra/index.d.ts.map +1 -1
  202. package/dist/mastra/index.js +1 -1
  203. package/dist/mcp/index.cjs +2 -2
  204. package/dist/mcp/index.js +1 -1
  205. package/dist/memory/index.cjs +14 -14
  206. package/dist/memory/index.js +1 -1
  207. package/dist/memory/mock.d.ts.map +1 -1
  208. package/dist/memory/types.d.ts +128 -0
  209. package/dist/memory/types.d.ts.map +1 -1
  210. package/dist/models-dev-FQVUTQ7L.js +3 -0
  211. package/dist/{models-dev-Z45JSLWD.js.map → models-dev-FQVUTQ7L.js.map} +1 -1
  212. package/dist/models-dev-PPIXUUCU.cjs +12 -0
  213. package/dist/{models-dev-OQKVMEIT.cjs.map → models-dev-PPIXUUCU.cjs.map} +1 -1
  214. package/dist/netlify-4RIKF7Y3.js +3 -0
  215. package/dist/{netlify-SSWMYSAX.js.map → netlify-4RIKF7Y3.js.map} +1 -1
  216. package/dist/netlify-V5F7JEJH.cjs +12 -0
  217. package/dist/{netlify-TXZZCT6N.cjs.map → netlify-V5F7JEJH.cjs.map} +1 -1
  218. package/dist/processors/index.cjs +41 -41
  219. package/dist/processors/index.js +1 -1
  220. package/dist/processors/step-schema.d.ts +44 -44
  221. package/dist/provider-registry-C6XCYX44.cjs +40 -0
  222. package/dist/{provider-registry-NR7FXV2Q.cjs.map → provider-registry-C6XCYX44.cjs.map} +1 -1
  223. package/dist/provider-registry-NWU4YFQW.js +3 -0
  224. package/dist/{provider-registry-RPOTQNHI.js.map → provider-registry-NWU4YFQW.js.map} +1 -1
  225. package/dist/provider-registry.json +278 -33
  226. package/dist/relevance/index.cjs +3 -3
  227. package/dist/relevance/index.js +1 -1
  228. package/dist/server/index.cjs +3 -3
  229. package/dist/server/index.js +1 -1
  230. package/dist/storage/base.d.ts +3 -1
  231. package/dist/storage/base.d.ts.map +1 -1
  232. package/dist/storage/constants.cjs +51 -19
  233. package/dist/storage/constants.d.ts +10 -2
  234. package/dist/storage/constants.d.ts.map +1 -1
  235. package/dist/storage/constants.js +1 -1
  236. package/dist/storage/domains/agents/base.d.ts +13 -164
  237. package/dist/storage/domains/agents/base.d.ts.map +1 -1
  238. package/dist/storage/domains/agents/index.d.ts +0 -1
  239. package/dist/storage/domains/agents/index.d.ts.map +1 -1
  240. package/dist/storage/domains/agents/inmemory.d.ts +6 -10
  241. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  242. package/dist/storage/domains/index.d.ts +3 -0
  243. package/dist/storage/domains/index.d.ts.map +1 -1
  244. package/dist/storage/domains/inmemory-db.d.ts +7 -1
  245. package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
  246. package/dist/storage/domains/memory/base.d.ts +45 -5
  247. package/dist/storage/domains/memory/base.d.ts.map +1 -1
  248. package/dist/storage/domains/memory/inmemory.d.ts +7 -7
  249. package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
  250. package/dist/storage/domains/observability/types.d.ts +62 -62
  251. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  252. package/dist/storage/domains/prompt-blocks/base.d.ts +47 -0
  253. package/dist/storage/domains/prompt-blocks/base.d.ts.map +1 -0
  254. package/dist/storage/domains/prompt-blocks/index.d.ts +3 -0
  255. package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
  256. package/dist/storage/domains/prompt-blocks/inmemory.d.ts +31 -0
  257. package/dist/storage/domains/prompt-blocks/inmemory.d.ts.map +1 -0
  258. package/dist/storage/domains/scorer-definitions/base.d.ts +47 -0
  259. package/dist/storage/domains/scorer-definitions/base.d.ts.map +1 -0
  260. package/dist/storage/domains/scorer-definitions/index.d.ts +3 -0
  261. package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
  262. package/dist/storage/domains/scorer-definitions/inmemory.d.ts +31 -0
  263. package/dist/storage/domains/scorer-definitions/inmemory.d.ts.map +1 -0
  264. package/dist/storage/domains/versioned.d.ts +136 -0
  265. package/dist/storage/domains/versioned.d.ts.map +1 -0
  266. package/dist/storage/index.cjs +156 -104
  267. package/dist/storage/index.js +2 -2
  268. package/dist/storage/mock.d.ts.map +1 -1
  269. package/dist/storage/types.d.ts +481 -27
  270. package/dist/storage/types.d.ts.map +1 -1
  271. package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
  272. package/dist/stream/MastraWorkflowStream.d.ts +1 -1
  273. package/dist/stream/RunOutput.d.ts +1 -1
  274. package/dist/stream/RunOutput.d.ts.map +1 -1
  275. package/dist/stream/base/output.d.ts +4 -0
  276. package/dist/stream/base/output.d.ts.map +1 -1
  277. package/dist/stream/index.cjs +11 -11
  278. package/dist/stream/index.js +2 -2
  279. package/dist/test-utils/llm-mock.cjs +4 -4
  280. package/dist/test-utils/llm-mock.js +1 -1
  281. package/dist/tool-loop-agent/index.cjs +4 -4
  282. package/dist/tool-loop-agent/index.js +1 -1
  283. package/dist/tools/index.cjs +4 -4
  284. package/dist/tools/index.js +1 -1
  285. package/dist/tools/is-vercel-tool.cjs +2 -2
  286. package/dist/tools/is-vercel-tool.js +1 -1
  287. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  288. package/dist/tools/types.d.ts +15 -0
  289. package/dist/tools/types.d.ts.map +1 -1
  290. package/dist/tools/validation.d.ts.map +1 -1
  291. package/dist/tts/index.cjs +2 -2
  292. package/dist/tts/index.js +1 -1
  293. package/dist/types/zod-compat.d.ts +2 -2
  294. package/dist/types/zod-compat.d.ts.map +1 -1
  295. package/dist/utils/zod-utils.d.ts +19 -0
  296. package/dist/utils/zod-utils.d.ts.map +1 -1
  297. package/dist/utils.cjs +28 -28
  298. package/dist/utils.d.ts +7 -1
  299. package/dist/utils.d.ts.map +1 -1
  300. package/dist/utils.js +2 -2
  301. package/dist/vector/index.cjs +9 -9
  302. package/dist/vector/index.js +2 -2
  303. package/dist/voice/index.cjs +6 -6
  304. package/dist/voice/index.js +1 -1
  305. package/dist/workflows/evented/index.cjs +10 -10
  306. package/dist/workflows/evented/index.js +1 -1
  307. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  308. package/dist/workflows/evented/workflow.d.ts +3 -1
  309. package/dist/workflows/evented/workflow.d.ts.map +1 -1
  310. package/dist/workflows/execution-engine.d.ts.map +1 -1
  311. package/dist/workflows/index.cjs +25 -25
  312. package/dist/workflows/index.js +1 -1
  313. package/dist/workflows/step.d.ts +4 -3
  314. package/dist/workflows/step.d.ts.map +1 -1
  315. package/dist/workflows/types.d.ts +2 -1
  316. package/dist/workflows/types.d.ts.map +1 -1
  317. package/dist/workflows/workflow.d.ts +12 -4
  318. package/dist/workflows/workflow.d.ts.map +1 -1
  319. package/dist/workspace/errors.d.ts +6 -0
  320. package/dist/workspace/errors.d.ts.map +1 -1
  321. package/dist/workspace/filesystem/composite-filesystem.d.ts +93 -0
  322. package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -0
  323. package/dist/workspace/filesystem/filesystem.d.ts +35 -0
  324. package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
  325. package/dist/workspace/filesystem/index.d.ts +2 -0
  326. package/dist/workspace/filesystem/index.d.ts.map +1 -1
  327. package/dist/workspace/filesystem/local-filesystem.d.ts +9 -1
  328. package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
  329. package/dist/workspace/filesystem/mastra-filesystem.d.ts +92 -3
  330. package/dist/workspace/filesystem/mastra-filesystem.d.ts.map +1 -1
  331. package/dist/workspace/filesystem/mount.d.ts +34 -0
  332. package/dist/workspace/filesystem/mount.d.ts.map +1 -0
  333. package/dist/workspace/index.cjs +62 -34
  334. package/dist/workspace/index.d.ts +6 -2
  335. package/dist/workspace/index.d.ts.map +1 -1
  336. package/dist/workspace/index.js +1 -1
  337. package/dist/workspace/lifecycle.d.ts +29 -0
  338. package/dist/workspace/lifecycle.d.ts.map +1 -1
  339. package/dist/workspace/sandbox/errors.d.ts +50 -0
  340. package/dist/workspace/sandbox/errors.d.ts.map +1 -0
  341. package/dist/workspace/sandbox/index.d.ts +3 -0
  342. package/dist/workspace/sandbox/index.d.ts.map +1 -1
  343. package/dist/workspace/sandbox/local-sandbox.d.ts +17 -2
  344. package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
  345. package/dist/workspace/sandbox/mastra-sandbox.d.ts +153 -6
  346. package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
  347. package/dist/workspace/sandbox/mount-manager.d.ts +195 -0
  348. package/dist/workspace/sandbox/mount-manager.d.ts.map +1 -0
  349. package/dist/workspace/sandbox/sandbox.d.ts +37 -84
  350. package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
  351. package/dist/workspace/sandbox/types.d.ts +92 -0
  352. package/dist/workspace/sandbox/types.d.ts.map +1 -0
  353. package/dist/workspace/tools/tools.d.ts.map +1 -1
  354. package/dist/workspace/tools/tree-formatter.d.ts.map +1 -1
  355. package/dist/workspace/workspace.d.ts +73 -3
  356. package/dist/workspace/workspace.d.ts.map +1 -1
  357. package/package.json +16 -16
  358. package/src/llm/model/provider-types.generated.d.ts +128 -10
  359. package/dist/chunk-2DMSFLJY.cjs.map +0 -1
  360. package/dist/chunk-5SOS47PH.cjs.map +0 -1
  361. package/dist/chunk-5YVR7B4R.js.map +0 -1
  362. package/dist/chunk-7MDVYPWX.cjs.map +0 -1
  363. package/dist/chunk-A5QFWX67.cjs.map +0 -1
  364. package/dist/chunk-AIJLACR2.js.map +0 -1
  365. package/dist/chunk-BP2TSCBW.js.map +0 -1
  366. package/dist/chunk-C4WWWQHT.cjs.map +0 -1
  367. package/dist/chunk-E3VFKTIA.js.map +0 -1
  368. package/dist/chunk-ENCTSDWC.js.map +0 -1
  369. package/dist/chunk-G6E3QNJC.js.map +0 -1
  370. package/dist/chunk-GVLPTDJA.cjs.map +0 -1
  371. package/dist/chunk-HMCXNOF6.cjs.map +0 -1
  372. package/dist/chunk-HN2MSTR6.cjs.map +0 -1
  373. package/dist/chunk-I66TMZJ3.cjs.map +0 -1
  374. package/dist/chunk-IIZF4W7B.cjs.map +0 -1
  375. package/dist/chunk-IW3BNL7A.js.map +0 -1
  376. package/dist/chunk-JIT2OY3X.js.map +0 -1
  377. package/dist/chunk-JRJJ5VQE.cjs.map +0 -1
  378. package/dist/chunk-MNWW2R3U.js.map +0 -1
  379. package/dist/chunk-MSWXEOZC.js.map +0 -1
  380. package/dist/chunk-P62OJXQ4.js.map +0 -1
  381. package/dist/chunk-QOFI2WBM.cjs.map +0 -1
  382. package/dist/chunk-RXD5EGQF.js.map +0 -1
  383. package/dist/chunk-T6PRRKMW.js.map +0 -1
  384. package/dist/chunk-UZL4H5P2.cjs.map +0 -1
  385. package/dist/chunk-VW7YQWDW.cjs.map +0 -1
  386. package/dist/chunk-VX7UA3SO.js.map +0 -1
  387. package/dist/chunk-WFUNLRQX.js.map +0 -1
  388. package/dist/chunk-XCPEEIHI.cjs.map +0 -1
  389. package/dist/chunk-YLODOPYM.cjs.map +0 -1
  390. package/dist/chunk-Z6NRYYOH.js.map +0 -1
  391. package/dist/docs/references/docs-tools-mcp-advanced-usage.md +0 -143
  392. package/dist/docs/references/docs-tools-mcp-mcp-overview.md +0 -383
  393. package/dist/docs/references/docs-tools-mcp-overview.md +0 -78
  394. package/dist/docs/references/docs-workflows-input-data-mapping.md +0 -102
  395. package/dist/docs/references/reference-deployer-netlify.md +0 -14
  396. package/dist/docs/references/reference-deployer-vercel.md +0 -39
  397. package/dist/docs/references/reference-tools-client.md +0 -228
  398. package/dist/models-dev-OQKVMEIT.cjs +0 -12
  399. package/dist/models-dev-Z45JSLWD.js +0 -3
  400. package/dist/netlify-SSWMYSAX.js +0 -3
  401. package/dist/netlify-TXZZCT6N.cjs +0 -12
  402. package/dist/provider-registry-NR7FXV2Q.cjs +0 -40
  403. package/dist/provider-registry-RPOTQNHI.js +0 -3
@@ -1,23 +1,23 @@
1
- import { extractLines, createWorkspaceTools, BM25Index } from './chunk-ENCTSDWC.js';
2
- import { DefaultVoice } from './chunk-MQB7XFXP.js';
1
+ import { extractLines, createWorkspaceTools, BM25Index } from './chunk-2GWTJFVM.js';
2
+ import { DefaultVoice } from './chunk-LHRHOPUC.js';
3
3
  import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-2QXNHEDL.js';
4
- import { InMemoryStore } from './chunk-VX7UA3SO.js';
5
- import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-Z6NRYYOH.js';
4
+ import { InMemoryStore } from './chunk-MOOJ3H3C.js';
5
+ import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-ILQXPZCD.js';
6
6
  import { parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-UTLWS5LV.js';
7
7
  import { generateId, asSchema, jsonSchema, APICallError, tool } from './chunk-CPLRD2VP.js';
8
- import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-E3VFKTIA.js';
9
- import { MastraLLMV1 } from './chunk-AUF6U2BL.js';
8
+ import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-BXLLXTT4.js';
9
+ import { MastraLLMV1 } from './chunk-VM25PDSW.js';
10
10
  import { noopLogger } from './chunk-PSCMWPLC.js';
11
11
  import { PubSub } from './chunk-BVUMKER5.js';
12
12
  import { executeHook } from './chunk-L54GIUCB.js';
13
- import { isZodType, removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, selectFields, delay } from './chunk-T6PRRKMW.js';
13
+ import { isZodType, removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, selectFields, delay } from './chunk-ZHFM7HCQ.js';
14
14
  import { ToolStream } from './chunk-DD2VNRQM.js';
15
- import { Tool, createTool } from './chunk-IW3BNL7A.js';
15
+ import { Tool, createTool } from './chunk-RS6CZXGA.js';
16
16
  import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-Y3TQ52UE.js';
17
17
  import { RequestContext, MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY } from './chunk-CCLV5CAA.js';
18
18
  import { MastraError, getErrorFromUnknown } from './chunk-FJEVLHJT.js';
19
19
  import { zodToJsonSchema } from './chunk-PJKCPRYF.js';
20
- import { MastraBase } from './chunk-JIT2OY3X.js';
20
+ import { MastraBase } from './chunk-WCAFTXGK.js';
21
21
  import { RegisteredLogger, ConsoleLogger } from './chunk-X2WMFSPB.js';
22
22
  import { __commonJS, __toESM } from './chunk-7D4SUZUM.js';
23
23
  import z10, { z, ZodObject } from 'zod';
@@ -2515,6 +2515,7 @@ var MastraModelOutput = class extends MastraBase {
2515
2515
  #tripwire = void 0;
2516
2516
  #delayedPromises = {
2517
2517
  suspendPayload: new DelayedPromise(),
2518
+ resumeSchema: new DelayedPromise(),
2518
2519
  object: new DelayedPromise(),
2519
2520
  finishReason: new DelayedPromise(),
2520
2521
  usage: new DelayedPromise(),
@@ -2664,6 +2665,7 @@ var MastraModelOutput = class extends MastraBase {
2664
2665
  case "tool-call-approval":
2665
2666
  self.#status = "suspended";
2666
2667
  self.#delayedPromises.suspendPayload.resolve(chunk.payload);
2668
+ self.#delayedPromises.resumeSchema.resolve(chunk.payload.resumeSchema);
2667
2669
  break;
2668
2670
  case "raw":
2669
2671
  if (!self.#options.includeRawChunks) {
@@ -2878,8 +2880,9 @@ var MastraModelOutput = class extends MastraBase {
2878
2880
  steps: self.#bufferedSteps,
2879
2881
  totalUsage: self.#usageCount,
2880
2882
  content: [],
2881
- suspendPayload: void 0
2883
+ suspendPayload: void 0,
2882
2884
  // Tripwire doesn't suspend, so resolve to undefined
2885
+ resumeSchema: void 0
2883
2886
  });
2884
2887
  self.#emitChunk(chunk);
2885
2888
  controller.enqueue(chunk);
@@ -3008,7 +3011,8 @@ var MastraModelOutput = class extends MastraBase {
3008
3011
  steps: self.#bufferedSteps,
3009
3012
  totalUsage: self.#getTotalUsage(),
3010
3013
  content: messageList.get.response.aiV5.stepContent(),
3011
- suspendPayload: void 0
3014
+ suspendPayload: void 0,
3015
+ resumeSchema: void 0
3012
3016
  });
3013
3017
  const baseFinishStep = self.#bufferedSteps[self.#bufferedSteps.length - 1];
3014
3018
  if (baseFinishStep) {
@@ -3166,6 +3170,9 @@ var MastraModelOutput = class extends MastraBase {
3166
3170
  get suspendPayload() {
3167
3171
  return this.#getDelayedPromise(this.#delayedPromises.suspendPayload);
3168
3172
  }
3173
+ get resumeSchema() {
3174
+ return this.#getDelayedPromise(this.#delayedPromises.resumeSchema);
3175
+ }
3169
3176
  /**
3170
3177
  * Stream of all chunks. Provides complete control over stream processing.
3171
3178
  */
@@ -3328,6 +3335,7 @@ var MastraModelOutput = class extends MastraBase {
3328
3335
  traceId: this.traceId,
3329
3336
  runId: this.runId,
3330
3337
  suspendPayload: await this.suspendPayload,
3338
+ resumeSchema: await this.resumeSchema,
3331
3339
  // All messages from this execution (input + memory history + response)
3332
3340
  messages: this.messageList.get.all.db(),
3333
3341
  // Only messages loaded from memory (conversation history)
@@ -4790,6 +4798,10 @@ var ExecutionEngine = class extends MastraBase {
4790
4798
  }
4791
4799
  __registerMastra(mastra) {
4792
4800
  this.mastra = mastra;
4801
+ const logger = mastra?.getLogger();
4802
+ if (logger) {
4803
+ this.__setLogger(logger);
4804
+ }
4793
4805
  }
4794
4806
  getLogger() {
4795
4807
  return this.logger;
@@ -7774,13 +7786,14 @@ function createStepFromParams(params) {
7774
7786
  requestContextSchema: params.requestContextSchema,
7775
7787
  scorers: params.scorers,
7776
7788
  retries: params.retries,
7789
+ metadata: params.metadata,
7777
7790
  execute: params.execute.bind(params)
7778
7791
  };
7779
7792
  }
7780
7793
  function createStepFromAgent(params, agentOrToolOptions) {
7781
7794
  const options = agentOrToolOptions ?? {};
7782
7795
  const outputSchema = options?.structuredOutput?.schema ?? z.object({ text: z.string() });
7783
- const { retries, scorers, ...agentOptions } = options ?? {};
7796
+ const { retries, scorers, metadata, ...agentOptions } = options ?? {};
7784
7797
  return {
7785
7798
  id: params.id,
7786
7799
  description: params.getDescription(),
@@ -7790,6 +7803,7 @@ function createStepFromAgent(params, agentOrToolOptions) {
7790
7803
  outputSchema,
7791
7804
  retries,
7792
7805
  scorers,
7806
+ metadata,
7793
7807
  execute: async ({
7794
7808
  inputData,
7795
7809
  runId,
@@ -7915,6 +7929,7 @@ function createStepFromTool(params, toolOpts) {
7915
7929
  suspendSchema: params.suspendSchema,
7916
7930
  retries: toolOpts?.retries,
7917
7931
  scorers: toolOpts?.scorers,
7932
+ metadata: toolOpts?.metadata,
7918
7933
  execute: async ({
7919
7934
  inputData,
7920
7935
  mastra,
@@ -8427,7 +8442,8 @@ function cloneStep(step, opts) {
8427
8442
  execute: step.execute,
8428
8443
  retries: step.retries,
8429
8444
  scorers: step.scorers,
8430
- component: step.component
8445
+ component: step.component,
8446
+ metadata: step.metadata
8431
8447
  };
8432
8448
  }
8433
8449
  function isProcessor(obj) {
@@ -8554,6 +8570,7 @@ var Workflow = class extends MastraBase {
8554
8570
  step: {
8555
8571
  id: step.id,
8556
8572
  description: step.description,
8573
+ metadata: step.metadata,
8557
8574
  component: step.component,
8558
8575
  serializedStepFlow: step.serializedStepFlow,
8559
8576
  canSuspend: Boolean(step.suspendSchema || step.resumeSchema)
@@ -8723,6 +8740,7 @@ var Workflow = class extends MastraBase {
8723
8740
  step: {
8724
8741
  id: step.id,
8725
8742
  description: step.description,
8743
+ metadata: step.metadata,
8726
8744
  component: step.component,
8727
8745
  serializedStepFlow: step.serializedStepFlow,
8728
8746
  canSuspend: Boolean(step.suspendSchema || step.resumeSchema)
@@ -8750,6 +8768,7 @@ var Workflow = class extends MastraBase {
8750
8768
  step: {
8751
8769
  id: step.id,
8752
8770
  description: step.description,
8771
+ metadata: step.metadata,
8753
8772
  component: step.component,
8754
8773
  serializedStepFlow: step.serializedStepFlow,
8755
8774
  canSuspend: Boolean(step.suspendSchema || step.resumeSchema)
@@ -8775,6 +8794,7 @@ var Workflow = class extends MastraBase {
8775
8794
  step: {
8776
8795
  id: step.id,
8777
8796
  description: step.description,
8797
+ metadata: step.metadata,
8778
8798
  component: step.component,
8779
8799
  serializedStepFlow: step.serializedStepFlow,
8780
8800
  canSuspend: Boolean(step.suspendSchema || step.resumeSchema)
@@ -8798,6 +8818,7 @@ var Workflow = class extends MastraBase {
8798
8818
  step: {
8799
8819
  id: step.id,
8800
8820
  description: step.description,
8821
+ metadata: step.metadata,
8801
8822
  component: step.component,
8802
8823
  serializedStepFlow: step.serializedStepFlow,
8803
8824
  canSuspend: Boolean(step.suspendSchema || step.resumeSchema)
@@ -8816,6 +8837,7 @@ var Workflow = class extends MastraBase {
8816
8837
  step: {
8817
8838
  id: step.id,
8818
8839
  description: step.description,
8840
+ metadata: step.metadata,
8819
8841
  component: step.component,
8820
8842
  serializedStepFlow: step.serializedStepFlow,
8821
8843
  canSuspend: Boolean(actualStep.suspendSchema || actualStep.resumeSchema)
@@ -11093,6 +11115,7 @@ function createLLMExecutionStep({
11093
11115
  modelSpanTracker,
11094
11116
  autoResumeSuspendedTools,
11095
11117
  maxProcessorRetries,
11118
+ workspace,
11096
11119
  outputWriter
11097
11120
  }) {
11098
11121
  const initialSystemMessages = messageList.getAllSystemMessages();
@@ -11106,7 +11129,7 @@ function createLLMExecutionStep({
11106
11129
  let warnings;
11107
11130
  let request;
11108
11131
  let rawResponse;
11109
- const { outputStream, callBail, runState, stepTools } = await executeStreamWithFallbackModels(
11132
+ const { outputStream, callBail, runState, stepTools, stepWorkspace } = await executeStreamWithFallbackModels(
11110
11133
  models,
11111
11134
  logger
11112
11135
  )(async (modelConfig, isLastModel) => {
@@ -11125,7 +11148,8 @@ function createLLMExecutionStep({
11125
11148
  activeTools,
11126
11149
  providerOptions,
11127
11150
  modelSettings,
11128
- structuredOutput
11151
+ structuredOutput,
11152
+ workspace
11129
11153
  };
11130
11154
  const inputStepProcessors = [
11131
11155
  ...inputProcessors || [],
@@ -11411,10 +11435,17 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
11411
11435
  throw error;
11412
11436
  }
11413
11437
  }
11414
- return { outputStream: outputStream2, callBail: false, runState: runState2, stepTools: currentStep.tools };
11438
+ return {
11439
+ outputStream: outputStream2,
11440
+ callBail: false,
11441
+ runState: runState2,
11442
+ stepTools: currentStep.tools,
11443
+ stepWorkspace: currentStep.workspace
11444
+ };
11415
11445
  });
11416
11446
  if (_internal) {
11417
11447
  _internal.stepTools = stepTools;
11448
+ _internal.stepWorkspace = stepWorkspace ?? _internal.stepWorkspace;
11418
11449
  }
11419
11450
  if (callBail) {
11420
11451
  const usage2 = outputStream._getImmediateUsage();
@@ -11566,6 +11597,9 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
11566
11597
  tripwire: stepTripwireData
11567
11598
  })
11568
11599
  );
11600
+ if (shouldRetry) {
11601
+ messageList.removeByIds([messageId]);
11602
+ }
11569
11603
  const retryFeedbackText = shouldRetry && processOutputStepTripwire ? `[Processor Feedback] Your previous response was not accepted: ${processOutputStepTripwire.message}. Please try again with the feedback in mind.` : void 0;
11570
11604
  const messages = {
11571
11605
  all: messageList.get.all.aiV5.model(),
@@ -11801,7 +11835,8 @@ function createToolCallStep({
11801
11835
  args,
11802
11836
  suspendPayload,
11803
11837
  resumeSchema,
11804
- type
11838
+ type,
11839
+ suspendedToolRunId
11805
11840
  }) => {
11806
11841
  const metadataKey = type === "suspension" ? "suspendedTools" : "pendingToolApprovals";
11807
11842
  const responseMessages = messageList.get.response.db();
@@ -11816,7 +11851,7 @@ function createToolCallStep({
11816
11851
  toolName,
11817
11852
  args,
11818
11853
  type,
11819
- runId,
11854
+ runId: suspendedToolRunId ?? runId,
11820
11855
  // Store the runId so we can resume after page refresh
11821
11856
  ...type === "suspension" ? { suspendPayload } : {},
11822
11857
  resumeSchema
@@ -12036,42 +12071,122 @@ function createToolCallStep({
12036
12071
  outputWriter,
12037
12072
  // Pass current step span as parent for tool call spans
12038
12073
  tracingContext: modelSpanTracker?.getTracingContext(),
12074
+ // Pass workspace from _internal (set by llmExecutionStep via prepareStep/processInputStep)
12075
+ workspace: _internal?.stepWorkspace,
12039
12076
  suspend: async (suspendPayload, options2) => {
12040
- controller.enqueue({
12041
- type: "tool-call-suspended",
12042
- runId,
12043
- from: "AGENT" /* AGENT */,
12044
- payload: {
12077
+ if (options2?.requireToolApproval) {
12078
+ controller.enqueue({
12079
+ type: "tool-call-approval",
12080
+ runId,
12081
+ from: "AGENT" /* AGENT */,
12082
+ payload: {
12083
+ toolCallId: inputData.toolCallId,
12084
+ toolName: inputData.toolName,
12085
+ args: inputData.args,
12086
+ resumeSchema: JSON.stringify(
12087
+ zodToJsonSchema$1(
12088
+ z10.object({
12089
+ approved: z10.boolean().describe(
12090
+ "Controls if the tool call is approved or not, should be true when approved and false when declined"
12091
+ )
12092
+ })
12093
+ )
12094
+ )
12095
+ }
12096
+ });
12097
+ addToolMetadata({
12045
12098
  toolCallId: inputData.toolCallId,
12046
12099
  toolName: inputData.toolName,
12047
- suspendPayload,
12048
12100
  args: inputData.args,
12049
- resumeSchema: options2?.resumeSchema
12050
- }
12051
- });
12052
- addToolMetadata({
12053
- toolCallId: inputData.toolCallId,
12054
- toolName: inputData.toolName,
12055
- args,
12056
- suspendPayload,
12057
- type: "suspension",
12058
- resumeSchema: options2?.resumeSchema
12059
- });
12060
- await flushMessagesBeforeSuspension();
12061
- return await suspend(
12062
- {
12063
- toolCallSuspended: suspendPayload,
12064
- __streamState: streamState.serialize(),
12101
+ type: "approval",
12102
+ suspendedToolRunId: options2.runId,
12103
+ resumeSchema: JSON.stringify(
12104
+ zodToJsonSchema$1(
12105
+ z10.object({
12106
+ approved: z10.boolean().describe(
12107
+ "Controls if the tool call is approved or not, should be true when approved and false when declined"
12108
+ )
12109
+ })
12110
+ )
12111
+ )
12112
+ });
12113
+ await flushMessagesBeforeSuspension();
12114
+ return suspend(
12115
+ {
12116
+ requireToolApproval: {
12117
+ toolCallId: inputData.toolCallId,
12118
+ toolName: inputData.toolName,
12119
+ args: inputData.args
12120
+ },
12121
+ __streamState: streamState.serialize()
12122
+ },
12123
+ {
12124
+ resumeLabel: inputData.toolCallId
12125
+ }
12126
+ );
12127
+ } else {
12128
+ controller.enqueue({
12129
+ type: "tool-call-suspended",
12130
+ runId,
12131
+ from: "AGENT" /* AGENT */,
12132
+ payload: {
12133
+ toolCallId: inputData.toolCallId,
12134
+ toolName: inputData.toolName,
12135
+ suspendPayload,
12136
+ args: inputData.args,
12137
+ resumeSchema: options2?.resumeSchema
12138
+ }
12139
+ });
12140
+ addToolMetadata({
12141
+ toolCallId: inputData.toolCallId,
12065
12142
  toolName: inputData.toolName,
12066
- resumeLabel: options2?.resumeLabel
12067
- },
12068
- {
12069
- resumeLabel: inputData.toolCallId
12070
- }
12071
- );
12143
+ args,
12144
+ suspendPayload,
12145
+ suspendedToolRunId: options2?.isAgentSuspend ? options2.runId : void 0,
12146
+ type: "suspension",
12147
+ resumeSchema: options2?.resumeSchema
12148
+ });
12149
+ await flushMessagesBeforeSuspension();
12150
+ return await suspend(
12151
+ {
12152
+ toolCallSuspended: suspendPayload,
12153
+ __streamState: streamState.serialize(),
12154
+ toolName: inputData.toolName,
12155
+ resumeLabel: options2?.resumeLabel
12156
+ },
12157
+ {
12158
+ resumeLabel: inputData.toolCallId
12159
+ }
12160
+ );
12161
+ }
12072
12162
  },
12073
12163
  resumeData: resumeDataToPassToToolOptions
12074
12164
  };
12165
+ if (resumeDataToPassToToolOptions && inputData.toolName?.startsWith("agent-") && !isResumeToolCall) {
12166
+ let suspendedToolRunId = "";
12167
+ const messages = messageList.get.all.db();
12168
+ const assistantMessages = [...messages].reverse().filter((message) => message.role === "assistant");
12169
+ for (const message of assistantMessages) {
12170
+ const pendingOrSuspendedTools = message.content.metadata?.suspendedTools || message.content.metadata?.pendingToolApprovals;
12171
+ if (pendingOrSuspendedTools && pendingOrSuspendedTools[inputData.toolName]) {
12172
+ suspendedToolRunId = pendingOrSuspendedTools[inputData.toolName].runId;
12173
+ break;
12174
+ }
12175
+ const dataToolSuspendedParts = message.content.parts?.filter(
12176
+ (part) => (part.type === "data-tool-call-suspended" || part.type === "data-tool-call-approval") && !part.data.resumed
12177
+ );
12178
+ if (dataToolSuspendedParts && dataToolSuspendedParts.length > 0) {
12179
+ const foundTool = dataToolSuspendedParts.find((part) => part.data.toolName === inputData.toolName);
12180
+ if (foundTool) {
12181
+ suspendedToolRunId = foundTool.data.runId;
12182
+ break;
12183
+ }
12184
+ }
12185
+ }
12186
+ if (suspendedToolRunId) {
12187
+ args.suspendedToolRunId = suspendedToolRunId;
12188
+ }
12189
+ }
12075
12190
  const result = await tool2.execute(args, toolOptions);
12076
12191
  if (tool2 && "onOutput" in tool2 && typeof tool2.onOutput === "function") {
12077
12192
  try {
@@ -12574,6 +12689,12 @@ var MastraScorer = class _MastraScorer {
12574
12689
  }
12575
12690
  }
12576
12691
  #mastra;
12692
+ #rawConfig;
12693
+ /**
12694
+ * Tracks whether this scorer was defined in code or loaded from storage.
12695
+ * Set by `Mastra.addScorer()` when the `source` option is provided.
12696
+ */
12697
+ source;
12577
12698
  /**
12578
12699
  * Registers the Mastra instance with the scorer.
12579
12700
  * This enables access to custom gateways for model resolution.
@@ -12582,6 +12703,20 @@ var MastraScorer = class _MastraScorer {
12582
12703
  __registerMastra(mastra) {
12583
12704
  this.#mastra = mastra;
12584
12705
  }
12706
+ /**
12707
+ * Returns the raw storage configuration this scorer was created from,
12708
+ * or undefined if it was created from code.
12709
+ */
12710
+ toRawConfig() {
12711
+ return this.#rawConfig;
12712
+ }
12713
+ /**
12714
+ * Sets the raw storage configuration for this scorer.
12715
+ * @internal
12716
+ */
12717
+ __setRawConfig(rawConfig) {
12718
+ this.#rawConfig = rawConfig;
12719
+ }
12585
12720
  get type() {
12586
12721
  return this.config.type;
12587
12722
  }
@@ -13375,7 +13510,8 @@ var MastraLLMVNext = class extends MastraBase {
13375
13510
  autoResumeSuspendedTools,
13376
13511
  maxProcessorRetries,
13377
13512
  processorStates,
13378
- activeTools
13513
+ activeTools,
13514
+ workspace
13379
13515
  }) {
13380
13516
  let stopWhenToUse;
13381
13517
  if (maxSteps && typeof maxSteps === "number") {
@@ -13442,6 +13578,7 @@ var MastraLLMVNext = class extends MastraBase {
13442
13578
  maxProcessorRetries,
13443
13579
  processorStates,
13444
13580
  activeTools,
13581
+ workspace,
13445
13582
  options: {
13446
13583
  ...options,
13447
13584
  onStepFinish: async (props) => {
@@ -13614,6 +13751,7 @@ async function getRoutingAgent({
13614
13751
  const toolsToUse = await agent.listTools({ requestContext });
13615
13752
  const model = await agent.getModel({ requestContext });
13616
13753
  const memoryToUse = await agent.getMemory({ requestContext });
13754
+ const clientToolsToUse = (await agent.getDefaultOptions({ requestContext }))?.clientTools;
13617
13755
  const configuredInputProcessors = await agent.listConfiguredInputProcessors(requestContext);
13618
13756
  const configuredOutputProcessors = await agent.listConfiguredOutputProcessors(requestContext);
13619
13757
  const agentList = Object.entries(agentsToUse).map(([name, agent2]) => {
@@ -13625,7 +13763,7 @@ async function getRoutingAgent({
13625
13763
  )}`;
13626
13764
  }).join("\n");
13627
13765
  const memoryTools = await memoryToUse?.listTools?.();
13628
- const toolList = Object.entries({ ...toolsToUse, ...memoryTools }).map(([name, tool2]) => {
13766
+ const toolList = Object.entries({ ...toolsToUse, ...memoryTools, ...clientToolsToUse || {} }).map(([name, tool2]) => {
13629
13767
  const inputSchema = "inputSchema" in tool2 ? tool2.inputSchema ?? z10.object({}) : z10.object({});
13630
13768
  return ` - **${name}**: ${tool2.description}, input schema: ${JSON.stringify(zodToJsonSchema(inputSchema))}`;
13631
13769
  }).join("\n");
@@ -14012,20 +14150,6 @@ async function createNetworkLoop({
14012
14150
  });
14013
14151
  }
14014
14152
  const isComplete = object.primitiveId === "none" && object.primitiveType === "none";
14015
- if (isComplete && object.selectionReason) {
14016
- await writer.write({
14017
- type: "routing-agent-text-start",
14018
- payload: { runId: stepId },
14019
- from: "NETWORK" /* NETWORK */,
14020
- runId
14021
- });
14022
- await writer.write({
14023
- type: "routing-agent-text-delta",
14024
- payload: { runId: stepId, text: object.selectionReason },
14025
- from: "NETWORK" /* NETWORK */,
14026
- runId
14027
- });
14028
- }
14029
14153
  const conversationContext = filterMessagesForSubAgent(result.rememberedMessages ?? []);
14030
14154
  const endPayload = {
14031
14155
  task: inputData.task,
@@ -14678,7 +14802,8 @@ async function createNetworkLoop({
14678
14802
  const agentTools = await agent.listTools({ requestContext });
14679
14803
  const memory = await agent.getMemory({ requestContext });
14680
14804
  const memoryTools = await memory?.listTools?.();
14681
- const toolsMap = { ...agentTools, ...memoryTools };
14805
+ const clientTools = (await agent.getDefaultOptions({ requestContext }))?.clientTools;
14806
+ const toolsMap = { ...agentTools, ...memoryTools, ...clientTools || {} };
14682
14807
  let tool2 = toolsMap[inputData.primitiveId];
14683
14808
  if (!tool2) {
14684
14809
  const mastraError = new MastraError({
@@ -16274,7 +16399,7 @@ var AgentLegacyHandler = class {
16274
16399
  title: thread.title,
16275
16400
  memoryConfig,
16276
16401
  resourceId,
16277
- saveThread: false
16402
+ saveThread: true
16278
16403
  });
16279
16404
  }
16280
16405
  requestContext.set("MastraMemory", {
@@ -16385,9 +16510,7 @@ var AgentLegacyHandler = class {
16385
16510
  model: titleModel,
16386
16511
  instructions: titleInstructions
16387
16512
  } = this.capabilities.resolveTitleGenerationConfig(config?.generateTitle);
16388
- const rememberedUserMessages = messageList.get.remembered.db().filter((m) => m.role === "user");
16389
- const isFirstUserMessage = rememberedUserMessages.length === 0;
16390
- if (shouldGenerate && isFirstUserMessage && userMessage) {
16513
+ if (shouldGenerate && !threadExists && userMessage) {
16391
16514
  promises.push(
16392
16515
  this.capabilities.genTitle(userMessage, requestContext, { currentSpan: agentSpan }, titleModel, titleInstructions).then((title) => {
16393
16516
  if (title) {
@@ -16543,12 +16666,14 @@ var AgentLegacyHandler = class {
16543
16666
  let messageList;
16544
16667
  let thread;
16545
16668
  let threadExists;
16669
+ let threadCreatedByStep = false;
16546
16670
  return {
16547
16671
  llm,
16548
16672
  before: async () => {
16549
16673
  const beforeResult = await before();
16550
16674
  const { messageObjects, convertedTools, agentSpan } = beforeResult;
16551
16675
  threadExists = beforeResult.threadExists || false;
16676
+ threadCreatedByStep = false;
16552
16677
  messageList = beforeResult.messageList;
16553
16678
  thread = beforeResult.thread;
16554
16679
  const threadId = thread?.id;
@@ -16564,7 +16689,7 @@ var AgentLegacyHandler = class {
16564
16689
  requestContext,
16565
16690
  onStepFinish: async (props) => {
16566
16691
  if (savePerStep) {
16567
- if (!threadExists && memory && thread) {
16692
+ if (!threadExists && !threadCreatedByStep && memory && thread) {
16568
16693
  await memory.createThread({
16569
16694
  threadId,
16570
16695
  title: thread.title,
@@ -16572,7 +16697,7 @@ var AgentLegacyHandler = class {
16572
16697
  resourceId: thread.resourceId,
16573
16698
  memoryConfig
16574
16699
  });
16575
- threadExists = true;
16700
+ threadCreatedByStep = true;
16576
16701
  }
16577
16702
  await this.capabilities.saveStepMessages({
16578
16703
  result: props,
@@ -16637,17 +16762,23 @@ var AgentLegacyHandler = class {
16637
16762
  };
16638
16763
  const { llm, before, after } = await this.prepareLLMOptions(messages, mergedGenerateOptions, "generate");
16639
16764
  if (llm.getModel().specificationVersion !== "v1") {
16640
- this.capabilities.logger.error("V2 models are not supported for generateLegacy. Please use generate instead.", {
16641
- modelId: llm.getModel().modelId
16642
- });
16765
+ const specVersion = llm.getModel().specificationVersion;
16766
+ this.capabilities.logger.error(
16767
+ `Models with specificationVersion "${specVersion}" are not supported for generateLegacy. Please use generate() instead.`,
16768
+ {
16769
+ modelId: llm.getModel().modelId,
16770
+ specificationVersion: specVersion
16771
+ }
16772
+ );
16643
16773
  throw new MastraError({
16644
16774
  id: "AGENT_GENERATE_V2_MODEL_NOT_SUPPORTED",
16645
16775
  domain: "AGENT" /* AGENT */,
16646
16776
  category: "USER" /* USER */,
16647
16777
  details: {
16648
- modelId: llm.getModel().modelId
16778
+ modelId: llm.getModel().modelId,
16779
+ specificationVersion: specVersion
16649
16780
  },
16650
- text: "V2 models are not supported for generateLegacy. Please use generate instead."
16781
+ text: `Models with specificationVersion "${specVersion}" are not supported for generateLegacy(). Please use generate() instead.`
16651
16782
  });
16652
16783
  }
16653
16784
  const llmToUse = llm;
@@ -16857,17 +16988,23 @@ var AgentLegacyHandler = class {
16857
16988
  };
16858
16989
  const { llm, before, after } = await this.prepareLLMOptions(messages, mergedStreamOptions, "stream");
16859
16990
  if (llm.getModel().specificationVersion !== "v1") {
16860
- this.capabilities.logger.error("V2 models are not supported for streamLegacy. Please use stream instead.", {
16861
- modelId: llm.getModel().modelId
16862
- });
16991
+ const specVersion = llm.getModel().specificationVersion;
16992
+ this.capabilities.logger.error(
16993
+ `Models with specificationVersion "${specVersion}" are not supported for streamLegacy. Please use stream() instead.`,
16994
+ {
16995
+ modelId: llm.getModel().modelId,
16996
+ specificationVersion: specVersion
16997
+ }
16998
+ );
16863
16999
  throw new MastraError({
16864
17000
  id: "AGENT_STREAM_V2_MODEL_NOT_SUPPORTED",
16865
17001
  domain: "AGENT" /* AGENT */,
16866
17002
  category: "USER" /* USER */,
16867
17003
  details: {
16868
- modelId: llm.getModel().modelId
17004
+ modelId: llm.getModel().modelId,
17005
+ specificationVersion: specVersion
16869
17006
  },
16870
- text: "V2 models are not supported for streamLegacy. Please use stream instead."
17007
+ text: `Models with specificationVersion "${specVersion}" are not supported for streamLegacy(). Please use stream() instead.`
16871
17008
  });
16872
17009
  }
16873
17010
  const beforeResult = await before();
@@ -17168,6 +17305,7 @@ function createMapResultsStep({
17168
17305
  return async ({ inputData, bail, tracingContext }) => {
17169
17306
  const toolsData = inputData["prepare-tools-step"];
17170
17307
  const memoryData = inputData["prepare-memory-step"];
17308
+ let threadCreatedByStep = false;
17171
17309
  const result = {
17172
17310
  ...options,
17173
17311
  tools: toolsData.convertedTools,
@@ -17178,7 +17316,7 @@ function createMapResultsStep({
17178
17316
  requestContext,
17179
17317
  onStepFinish: async (props) => {
17180
17318
  if (options.savePerStep && !memoryConfig?.readOnly) {
17181
- if (!memoryData.threadExists && memory && memoryData.thread) {
17319
+ if (!memoryData.threadExists && !threadCreatedByStep && memory && memoryData.thread) {
17182
17320
  await memory.createThread({
17183
17321
  threadId: memoryData.thread?.id,
17184
17322
  title: memoryData.thread?.title,
@@ -17186,7 +17324,7 @@ function createMapResultsStep({
17186
17324
  resourceId: memoryData.thread?.resourceId,
17187
17325
  memoryConfig
17188
17326
  });
17189
- memoryData.threadExists = true;
17327
+ threadCreatedByStep = true;
17190
17328
  }
17191
17329
  await capabilities.saveStepMessages({
17192
17330
  result: props,
@@ -17561,7 +17699,8 @@ function createStreamStep({
17561
17699
  memoryConfig,
17562
17700
  memory,
17563
17701
  resourceId,
17564
- autoResumeSuspendedTools
17702
+ autoResumeSuspendedTools,
17703
+ workspace
17565
17704
  }) {
17566
17705
  return createStep({
17567
17706
  id: "stream-text-step",
@@ -17597,7 +17736,8 @@ function createStreamStep({
17597
17736
  agentName,
17598
17737
  toolCallId,
17599
17738
  methodType: modelMethodType,
17600
- autoResumeSuspendedTools
17739
+ autoResumeSuspendedTools,
17740
+ workspace
17601
17741
  });
17602
17742
  return streamResult;
17603
17743
  }
@@ -17624,7 +17764,8 @@ function createPrepareStreamWorkflow({
17624
17764
  resumeContext,
17625
17765
  agentId,
17626
17766
  agentName,
17627
- toolCallId
17767
+ toolCallId,
17768
+ workspace
17628
17769
  }) {
17629
17770
  const prepareToolsStep = createPrepareToolsStep({
17630
17771
  capabilities,
@@ -17663,7 +17804,8 @@ function createPrepareStreamWorkflow({
17663
17804
  memoryConfig,
17664
17805
  memory,
17665
17806
  resourceId,
17666
- autoResumeSuspendedTools: options.autoResumeSuspendedTools
17807
+ autoResumeSuspendedTools: options.autoResumeSuspendedTools,
17808
+ workspace
17667
17809
  });
17668
17810
  const mapResultsStep = createMapResultsStep({
17669
17811
  capabilities,
@@ -17748,7 +17890,7 @@ var Agent = class extends MastraBase {
17748
17890
  * ```
17749
17891
  */
17750
17892
  constructor(config) {
17751
- super({ component: RegisteredLogger.AGENT });
17893
+ super({ component: RegisteredLogger.AGENT, rawConfig: config.rawConfig });
17752
17894
  this.name = config.name;
17753
17895
  this.id = config.id ?? config.name;
17754
17896
  this.source = "code";
@@ -18093,6 +18235,25 @@ ${errorMessages}`,
18093
18235
  const configuredProcessors = typeof this.#outputProcessors === "function" ? await this.#outputProcessors({ requestContext: requestContext || new RequestContext() }) : this.#outputProcessors;
18094
18236
  return this.combineProcessorsIntoWorkflow(configuredProcessors, `${this.id}-configured-output-processor`);
18095
18237
  }
18238
+ /**
18239
+ * Returns the IDs of the raw configured input and output processors,
18240
+ * without combining them into workflows. Used by the editor to clone
18241
+ * agent processor configuration to storage.
18242
+ */
18243
+ async getConfiguredProcessorIds(requestContext) {
18244
+ const ctx = requestContext || new RequestContext();
18245
+ let inputProcessorIds = [];
18246
+ if (this.#inputProcessors) {
18247
+ const processors = typeof this.#inputProcessors === "function" ? await this.#inputProcessors({ requestContext: ctx }) : this.#inputProcessors;
18248
+ inputProcessorIds = processors.map((p) => p.id).filter(Boolean);
18249
+ }
18250
+ let outputProcessorIds = [];
18251
+ if (this.#outputProcessors) {
18252
+ const processors = typeof this.#outputProcessors === "function" ? await this.#outputProcessors({ requestContext: ctx }) : this.#outputProcessors;
18253
+ outputProcessorIds = processors.map((p) => p.id).filter(Boolean);
18254
+ }
18255
+ return { inputProcessorIds, outputProcessorIds };
18256
+ }
18096
18257
  /**
18097
18258
  * Returns configured processor workflows for registration with Mastra.
18098
18259
  * This excludes memory-derived processors to avoid triggering memory factory functions.
@@ -18211,26 +18372,17 @@ ${errorMessages}`,
18211
18372
  requestContext = new RequestContext()
18212
18373
  } = {}) {
18213
18374
  if (this.#workspace) {
18214
- let resolvedWorkspace;
18215
18375
  if (typeof this.#workspace !== "function") {
18216
- resolvedWorkspace = this.#workspace;
18217
- } else {
18218
- const result = this.#workspace({ requestContext, mastra: this.#mastra });
18219
- resolvedWorkspace = await Promise.resolve(result);
18220
- if (!resolvedWorkspace) {
18221
- const mastraError = new MastraError({
18222
- id: "AGENT_GET_WORKSPACE_FUNCTION_EMPTY_RETURN",
18223
- domain: "AGENT" /* AGENT */,
18224
- category: "USER" /* USER */,
18225
- details: {
18226
- agentName: this.name
18227
- },
18228
- text: `[Agent:${this.name}] - Function-based workspace returned empty value`
18229
- });
18230
- this.logger.trackException(mastraError);
18231
- this.logger.error(mastraError.toString());
18232
- throw mastraError;
18233
- }
18376
+ return this.#workspace;
18377
+ }
18378
+ const result = this.#workspace({ requestContext, mastra: this.#mastra });
18379
+ const resolvedWorkspace = await Promise.resolve(result);
18380
+ if (!resolvedWorkspace) {
18381
+ return void 0;
18382
+ }
18383
+ resolvedWorkspace.__setLogger(this.logger);
18384
+ if (this.#mastra) {
18385
+ this.#mastra.addWorkspace(resolvedWorkspace);
18234
18386
  }
18235
18387
  return resolvedWorkspace;
18236
18388
  }
@@ -18817,6 +18969,9 @@ ${errorMessages}`,
18817
18969
  */
18818
18970
  __registerMastra(mastra) {
18819
18971
  this.#mastra = mastra;
18972
+ if (this.#workspace && typeof this.#workspace !== "function") {
18973
+ this.#workspace.__setLogger(this.logger);
18974
+ }
18820
18975
  if (this.#tools && typeof this.#tools === "object") {
18821
18976
  Object.entries(this.#tools).forEach(([key, tool2]) => {
18822
18977
  try {
@@ -18989,6 +19144,10 @@ ${errorMessages}`,
18989
19144
  return convertedMemoryTools;
18990
19145
  }
18991
19146
  const memory = await this.getMemory({ requestContext });
19147
+ if (!threadId && !resourceId) {
19148
+ this.logger.debug(`[Agent:${this.name}] - Skipping memory tools (no thread or resource context)`, { runId });
19149
+ return convertedMemoryTools;
19150
+ }
18992
19151
  const memoryTools = memory?.listTools?.(memoryConfig);
18993
19152
  if (memoryTools) {
18994
19153
  this.logger.debug(
@@ -19384,11 +19543,20 @@ ${errorMessages}`,
19384
19543
  source: "agent",
19385
19544
  entityId: agentName
19386
19545
  }) || `${slugify.default(this.id)}-${agentName}`;
19546
+ const suspendedToolRunId = inputData.suspendedToolRunId;
19547
+ const { resumeData, suspend } = context?.agent ?? {};
19387
19548
  if ((methodType === "generate" || methodType === "generateLegacy") && supportedLanguageModelSpecifications.includes(modelVersion)) {
19388
19549
  if (!agent.hasOwnMemory() && this.#memory) {
19389
19550
  agent.__setMemory(this.#memory);
19390
19551
  }
19391
- const generateResult = await agent.generate(inputData.prompt, {
19552
+ const generateResult = resumeData ? await agent.resumeGenerate(resumeData, {
19553
+ runId: suspendedToolRunId,
19554
+ requestContext,
19555
+ tracingContext: context?.tracingContext,
19556
+ ...inputData.instructions && { instructions: inputData.instructions },
19557
+ ...inputData.maxSteps && { maxSteps: inputData.maxSteps },
19558
+ ...resourceId && threadId ? { memory: { resource: subAgentResourceId, thread: subAgentThreadId } } : {}
19559
+ }) : await agent.generate(inputData.prompt, {
19392
19560
  requestContext,
19393
19561
  tracingContext: context?.tracingContext,
19394
19562
  ...inputData.instructions && { instructions: inputData.instructions },
@@ -19400,6 +19568,13 @@ ${errorMessages}`,
19400
19568
  }
19401
19569
  } : {}
19402
19570
  });
19571
+ if (generateResult.finishReason === "suspended") {
19572
+ return suspend?.(generateResult.suspendPayload, {
19573
+ resumeSchema: generateResult.resumeSchema,
19574
+ runId: generateResult.runId,
19575
+ isAgentSuspend: true
19576
+ });
19577
+ }
19403
19578
  result = { text: generateResult.text, subAgentThreadId, subAgentResourceId };
19404
19579
  } else if (methodType === "generate" && modelVersion === "v1") {
19405
19580
  const generateResult = await agent.generateLegacy(inputData.prompt, {
@@ -19411,7 +19586,19 @@ ${errorMessages}`,
19411
19586
  if (!agent.hasOwnMemory() && this.#memory) {
19412
19587
  agent.__setMemory(this.#memory);
19413
19588
  }
19414
- const streamResult = await agent.stream(inputData.prompt, {
19589
+ const streamResult = resumeData ? await agent.resumeStream(resumeData, {
19590
+ runId: suspendedToolRunId,
19591
+ requestContext,
19592
+ tracingContext: context?.tracingContext,
19593
+ ...inputData.instructions && { instructions: inputData.instructions },
19594
+ ...inputData.maxSteps && { maxSteps: inputData.maxSteps },
19595
+ ...resourceId && threadId ? {
19596
+ memory: {
19597
+ resource: subAgentResourceId,
19598
+ thread: subAgentThreadId
19599
+ }
19600
+ } : {}
19601
+ }) : await agent.stream(inputData.prompt, {
19415
19602
  requestContext,
19416
19603
  tracingContext: context?.tracingContext,
19417
19604
  ...inputData.instructions && { instructions: inputData.instructions },
@@ -19428,8 +19615,34 @@ ${errorMessages}`,
19428
19615
  if (context?.writer) {
19429
19616
  if (chunk.type.startsWith("data-")) {
19430
19617
  await context.writer.custom(chunk);
19618
+ if (chunk.type === "data-tool-call-approval") {
19619
+ return suspend?.(
19620
+ {},
19621
+ { requireToolApproval: true, runId: streamResult.runId, isAgentSuspend: true }
19622
+ );
19623
+ }
19624
+ if (chunk.type === "data-tool-call-suspended") {
19625
+ return suspend?.(chunk.data.suspendPayload, {
19626
+ resumeSchema: chunk.data.resumeSchema,
19627
+ runId: streamResult.runId,
19628
+ isAgentSuspend: true
19629
+ });
19630
+ }
19431
19631
  } else {
19432
19632
  await context.writer.write(chunk);
19633
+ if (chunk.type === "tool-call-approval") {
19634
+ return suspend?.(
19635
+ {},
19636
+ { requireToolApproval: true, runId: streamResult.runId, isAgentSuspend: true }
19637
+ );
19638
+ }
19639
+ if (chunk.type === "tool-call-suspended") {
19640
+ return suspend?.(chunk.payload.suspendPayload, {
19641
+ resumeSchema: chunk.payload.resumeSchema,
19642
+ runId: streamResult.runId,
19643
+ isAgentSuspend: true
19644
+ });
19645
+ }
19433
19646
  }
19434
19647
  }
19435
19648
  if (chunk.type === "text-delta") {
@@ -19524,7 +19737,7 @@ ${errorMessages}`,
19524
19737
  for (const [workflowName, workflow] of Object.entries(workflows)) {
19525
19738
  const extendedInputSchema = z.object({
19526
19739
  // @ts-expect-error - zod types mismatch between v3 and v4
19527
- inputData: workflow.inputSchema,
19740
+ inputData: workflow.inputSchema ?? z.object({}).passthrough(),
19528
19741
  ...workflow.stateSchema ? { initialState: workflow.stateSchema } : {}
19529
19742
  });
19530
19743
  const toolObj = createTool({
@@ -20110,6 +20323,7 @@ ${errorMessages}`,
20110
20323
  mastra: this.#mastra
20111
20324
  });
20112
20325
  const memory = await this.getMemory({ requestContext });
20326
+ const workspace = await this.getWorkspace({ requestContext });
20113
20327
  const saveQueueManager = new SaveQueueManager({
20114
20328
  logger: this.logger,
20115
20329
  memory
@@ -20158,7 +20372,8 @@ ${errorMessages}`,
20158
20372
  resumeContext,
20159
20373
  agentId: this.id,
20160
20374
  agentName: this.name,
20161
- toolCallId: options.toolCallId
20375
+ toolCallId: options.toolCallId,
20376
+ workspace
20162
20377
  });
20163
20378
  const run = await executionWorkflow.createRun();
20164
20379
  const result = await run.start({ tracingContext: { currentSpan: agentSpan } });
@@ -20248,9 +20463,7 @@ ${errorMessages}`,
20248
20463
  model: titleModel,
20249
20464
  instructions: titleInstructions
20250
20465
  } = this.resolveTitleGenerationConfig(config.generateTitle);
20251
- const rememberedUserMessages = messageList.get.remembered.db().filter((m) => m.role === "user");
20252
- const isFirstUserMessage = rememberedUserMessages.length === 0;
20253
- if (shouldGenerate && isFirstUserMessage) {
20466
+ if (shouldGenerate && !threadExists) {
20254
20467
  const userMessage = this.getMostRecentUserMessage(messageList.get.all.ui());
20255
20468
  if (userMessage) {
20256
20469
  const title = await this.genTitle(
@@ -20482,16 +20695,17 @@ ${errorMessages}`,
20482
20695
  if (!isSupportedLanguageModel(modelInfo)) {
20483
20696
  const modelId = modelInfo.modelId || "unknown";
20484
20697
  const provider = modelInfo.provider || "unknown";
20698
+ const specVersion = modelInfo.specificationVersion;
20485
20699
  throw new MastraError({
20486
20700
  id: "AGENT_GENERATE_V1_MODEL_NOT_SUPPORTED",
20487
20701
  domain: "AGENT" /* AGENT */,
20488
20702
  category: "USER" /* USER */,
20489
- text: `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with generate(). Please use AI SDK v5+ models or call the generateLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`,
20703
+ text: specVersion === "v1" ? `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with generate(). Please use AI SDK v5+ models or call the generateLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.` : `Agent "${this.name}" has a model (${provider}:${modelId}) with unrecognized specificationVersion "${specVersion}". Supported versions: v1 (legacy), v2 (AI SDK v5), v3 (AI SDK v6). Please ensure your AI SDK provider is compatible with this version of Mastra.`,
20490
20704
  details: {
20491
20705
  agentName: this.name,
20492
20706
  modelId,
20493
20707
  provider,
20494
- specificationVersion: modelInfo.specificationVersion
20708
+ specificationVersion: specVersion
20495
20709
  }
20496
20710
  });
20497
20711
  }
@@ -20545,16 +20759,17 @@ ${errorMessages}`,
20545
20759
  if (!isSupportedLanguageModel(modelInfo)) {
20546
20760
  const modelId = modelInfo.modelId || "unknown";
20547
20761
  const provider = modelInfo.provider || "unknown";
20762
+ const specVersion = modelInfo.specificationVersion;
20548
20763
  throw new MastraError({
20549
20764
  id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
20550
20765
  domain: "AGENT" /* AGENT */,
20551
20766
  category: "USER" /* USER */,
20552
- text: `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with stream(). Please use AI SDK v5+ models or call the streamLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`,
20767
+ text: specVersion === "v1" ? `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with stream(). Please use AI SDK v5+ models or call the streamLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.` : `Agent "${this.name}" has a model (${provider}:${modelId}) with unrecognized specificationVersion "${specVersion}". Supported versions: v1 (legacy), v2 (AI SDK v5), v3 (AI SDK v6). Please ensure your AI SDK provider is compatible with this version of Mastra.`,
20553
20768
  details: {
20554
20769
  agentName: this.name,
20555
20770
  modelId,
20556
20771
  provider,
20557
- specificationVersion: modelInfo.specificationVersion
20772
+ specificationVersion: specVersion
20558
20773
  }
20559
20774
  });
20560
20775
  }
@@ -20599,11 +20814,18 @@ ${errorMessages}`,
20599
20814
  requestContext: mergedStreamOptions.requestContext
20600
20815
  });
20601
20816
  if (!isSupportedLanguageModel(llm.getModel())) {
20817
+ const modelInfo = llm.getModel();
20818
+ const specVersion = modelInfo.specificationVersion;
20602
20819
  throw new MastraError({
20603
20820
  id: "AGENT_STREAM_V1_MODEL_NOT_SUPPORTED",
20604
20821
  domain: "AGENT" /* AGENT */,
20605
20822
  category: "USER" /* USER */,
20606
- text: "V1 models are not supported for stream. Please use streamLegacy instead."
20823
+ text: specVersion === "v1" ? "V1 models are not supported for resumeStream. Please use streamLegacy instead." : `Model has unrecognized specificationVersion "${specVersion}". Supported versions: v1 (legacy), v2 (AI SDK v5), v3 (AI SDK v6). Please ensure your AI SDK provider is compatible with this version of Mastra.`,
20824
+ details: {
20825
+ modelId: modelInfo.modelId,
20826
+ provider: modelInfo.provider,
20827
+ specificationVersion: specVersion
20828
+ }
20607
20829
  });
20608
20830
  }
20609
20831
  const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
@@ -20669,16 +20891,17 @@ ${errorMessages}`,
20669
20891
  if (!isSupportedLanguageModel(modelInfo)) {
20670
20892
  const modelId = modelInfo.modelId || "unknown";
20671
20893
  const provider = modelInfo.provider || "unknown";
20894
+ const specVersion = modelInfo.specificationVersion;
20672
20895
  throw new MastraError({
20673
20896
  id: "AGENT_GENERATE_V1_MODEL_NOT_SUPPORTED",
20674
20897
  domain: "AGENT" /* AGENT */,
20675
20898
  category: "USER" /* USER */,
20676
- text: `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with generate(). Please use AI SDK v5+ models or call the generateLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.`,
20899
+ text: specVersion === "v1" ? `Agent "${this.name}" is using AI SDK v4 model (${provider}:${modelId}) which is not compatible with generate(). Please use AI SDK v5+ models or call the generateLegacy() method instead. See https://mastra.ai/en/docs/streaming/overview for more information.` : `Agent "${this.name}" has a model (${provider}:${modelId}) with unrecognized specificationVersion "${specVersion}". Supported versions: v1 (legacy), v2 (AI SDK v5), v3 (AI SDK v6). Please ensure your AI SDK provider is compatible with this version of Mastra.`,
20677
20900
  details: {
20678
20901
  agentName: this.name,
20679
20902
  modelId,
20680
20903
  provider,
20681
- specificationVersion: modelInfo.specificationVersion
20904
+ specificationVersion: specVersion
20682
20905
  }
20683
20906
  });
20684
20907
  }
@@ -24529,21 +24752,30 @@ var MockMemory = class extends MastraMemory {
24529
24752
  const threadId = context?.agent?.threadId;
24530
24753
  const resourceId = context?.agent?.resourceId;
24531
24754
  const memory = context?.memory;
24532
- if (!threadId || !memory || !resourceId) {
24533
- throw new Error("Thread ID, Memory instance, and resourceId are required for working memory updates");
24755
+ if (!memory) {
24756
+ throw new Error("Memory instance is required for working memory updates");
24534
24757
  }
24535
- let thread = await memory.getThreadById({ threadId });
24536
- if (!thread) {
24537
- thread = await memory.createThread({
24538
- threadId,
24539
- resourceId,
24540
- memoryConfig: _config
24541
- });
24758
+ const scope = mergedConfig.workingMemory?.scope || "resource";
24759
+ if (scope === "thread" && !threadId) {
24760
+ throw new Error("Thread ID is required for thread-scoped working memory updates");
24542
24761
  }
24543
- if (thread.resourceId && thread.resourceId !== resourceId) {
24544
- throw new Error(
24545
- `Thread with id ${threadId} resourceId does not match the current resourceId ${resourceId}`
24546
- );
24762
+ if (scope === "resource" && !resourceId) {
24763
+ throw new Error("Resource ID is required for resource-scoped working memory updates");
24764
+ }
24765
+ if (threadId) {
24766
+ let thread = await memory.getThreadById({ threadId });
24767
+ if (!thread) {
24768
+ thread = await memory.createThread({
24769
+ threadId,
24770
+ resourceId,
24771
+ memoryConfig: _config
24772
+ });
24773
+ }
24774
+ if (thread.resourceId && resourceId && thread.resourceId !== resourceId) {
24775
+ throw new Error(
24776
+ `Thread with id ${threadId} resourceId does not match the current resourceId ${resourceId}`
24777
+ );
24778
+ }
24547
24779
  }
24548
24780
  const workingMemory = typeof inputData.memory === "string" ? inputData.memory : JSON.stringify(inputData.memory);
24549
24781
  await memory.updateWorkingMemory({
@@ -24639,5 +24871,5 @@ var MockMemory = class extends MastraMemory {
24639
24871
  };
24640
24872
 
24641
24873
  export { Agent, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MastraScorer, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SkillsProcessor, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, ToolSearchProcessor, TripWire, UnicodeNormalizer, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cleanStepResult, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createScorer, createStep, createTimeTravelExecutionParams, createWorkflow, extractWorkingMemoryContent, extractWorkingMemoryTags, formatCheckFeedback, formatCompletionFeedback, formatValidationFeedback, generateFinalResult, generateStructuredFinalResult, getResumeLabelsByStepId, getStepIds, getStepResult, getThreadOMMetadata, getZodErrors, globalEmbeddingCache, hydrateSerializedStepErrors, isObservationalMemoryEnabled, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, removeWorkingMemoryTags, resolveThreadIdFromArgs, runChecks, runCompletionScorers, runCountDeprecationMessage, runDefaultCompletionCheck, runValidation, setThreadOMMetadata, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepRequestContext, validateStepResumeData, validateStepStateData, validateStepSuspendData };
24642
- //# sourceMappingURL=chunk-WFUNLRQX.js.map
24643
- //# sourceMappingURL=chunk-WFUNLRQX.js.map
24874
+ //# sourceMappingURL=chunk-ZRUTE56J.js.map
24875
+ //# sourceMappingURL=chunk-ZRUTE56J.js.map