@mastra/core 1.0.0-beta.3 → 1.0.0-beta.5

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 (314) hide show
  1. package/CHANGELOG.md +369 -0
  2. package/dist/agent/agent.d.ts +2 -2
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/agent.types.d.ts +2 -0
  5. package/dist/agent/agent.types.d.ts.map +1 -1
  6. package/dist/agent/index.cjs +9 -9
  7. package/dist/agent/index.js +2 -2
  8. package/dist/agent/message-list/index.cjs +3 -3
  9. package/dist/agent/message-list/index.d.ts +5 -0
  10. package/dist/agent/message-list/index.d.ts.map +1 -1
  11. package/dist/agent/message-list/index.js +1 -1
  12. package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
  13. package/dist/agent/types.d.ts +2 -3
  14. package/dist/agent/types.d.ts.map +1 -1
  15. package/dist/agent/utils.d.ts.map +1 -1
  16. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  17. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  18. package/dist/agent/workflows/prepare-stream/stream-step.d.ts +8 -1
  19. package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
  20. package/dist/{chunk-4DWZ4Z6H.js → chunk-3B2OPLGG.js} +13 -7
  21. package/dist/chunk-3B2OPLGG.js.map +1 -0
  22. package/dist/{chunk-GRGPQ32U.js → chunk-3ZQ7LX73.js} +13 -13
  23. package/dist/chunk-3ZQ7LX73.js.map +1 -0
  24. package/dist/{chunk-VZGBVYXA.cjs → chunk-556MJ7CL.cjs} +33 -27
  25. package/dist/chunk-556MJ7CL.cjs.map +1 -0
  26. package/dist/{chunk-HGNRQ3OG.js → chunk-5O52O25J.js} +15 -8
  27. package/dist/chunk-5O52O25J.js.map +1 -0
  28. package/dist/{chunk-VU6DVS7J.js → chunk-5SA2EZ33.js} +421 -29
  29. package/dist/chunk-5SA2EZ33.js.map +1 -0
  30. package/dist/chunk-6XCINXZ7.cjs +194 -0
  31. package/dist/chunk-6XCINXZ7.cjs.map +1 -0
  32. package/dist/{chunk-KOSW5PP5.js → chunk-7ZADRRDW.js} +466 -125
  33. package/dist/chunk-7ZADRRDW.js.map +1 -0
  34. package/dist/{chunk-JXESKY4A.js → chunk-B5J5HYDN.js} +7 -5
  35. package/dist/chunk-B5J5HYDN.js.map +1 -0
  36. package/dist/chunk-BWYU7D33.js +192 -0
  37. package/dist/chunk-BWYU7D33.js.map +1 -0
  38. package/dist/{chunk-MCUX2D5Q.js → chunk-D7CJ4HIQ.js} +263 -24
  39. package/dist/chunk-D7CJ4HIQ.js.map +1 -0
  40. package/dist/{chunk-G36A2JRR.cjs → chunk-DQIZ5FFX.cjs} +457 -326
  41. package/dist/chunk-DQIZ5FFX.cjs.map +1 -0
  42. package/dist/{chunk-ZPMFINU2.cjs → chunk-HNHZGFZY.cjs} +466 -131
  43. package/dist/chunk-HNHZGFZY.cjs.map +1 -0
  44. package/dist/{chunk-3VOUB4ZU.cjs → chunk-IITXXVYI.cjs} +17 -17
  45. package/dist/chunk-IITXXVYI.cjs.map +1 -0
  46. package/dist/{chunk-QUKUN6NR.cjs → chunk-ISMGVGUM.cjs} +105 -5
  47. package/dist/chunk-ISMGVGUM.cjs.map +1 -0
  48. package/dist/{chunk-OQF4H5Y2.js → chunk-KJIQGPQR.js} +4 -4
  49. package/dist/{chunk-OQF4H5Y2.js.map → chunk-KJIQGPQR.js.map} +1 -1
  50. package/dist/{chunk-OWX2PUFH.cjs → chunk-KP42JLXE.cjs} +506 -236
  51. package/dist/chunk-KP42JLXE.cjs.map +1 -0
  52. package/dist/{chunk-4RSHBKDJ.cjs → chunk-KWWD3U7G.cjs} +5 -5
  53. package/dist/chunk-KWWD3U7G.cjs.map +1 -0
  54. package/dist/{chunk-N4SJ4YX7.cjs → chunk-NHP6ZIDG.cjs} +271 -31
  55. package/dist/chunk-NHP6ZIDG.cjs.map +1 -0
  56. package/dist/{chunk-UIZSWUKP.js → chunk-NZAXAFI3.js} +104 -6
  57. package/dist/chunk-NZAXAFI3.js.map +1 -0
  58. package/dist/{chunk-O6NA3Z43.cjs → chunk-OUUPUAGA.cjs} +10 -8
  59. package/dist/chunk-OUUPUAGA.cjs.map +1 -0
  60. package/dist/{chunk-D6EDHNGV.js → chunk-PC6EKOWK.js} +64 -11
  61. package/dist/chunk-PC6EKOWK.js.map +1 -0
  62. package/dist/{chunk-YQ7NLZZ3.cjs → chunk-QGWNF2QJ.cjs} +74 -618
  63. package/dist/chunk-QGWNF2QJ.cjs.map +1 -0
  64. package/dist/{chunk-HBJPYQRN.cjs → chunk-RROQ46B6.cjs} +69 -16
  65. package/dist/chunk-RROQ46B6.cjs.map +1 -0
  66. package/dist/{chunk-G3OOCXAI.js → chunk-T2CJRA6E.js} +4 -4
  67. package/dist/chunk-T2CJRA6E.js.map +1 -0
  68. package/dist/{chunk-T3WZCEC4.js → chunk-T2UNO766.js} +47 -591
  69. package/dist/chunk-T2UNO766.js.map +1 -0
  70. package/dist/{chunk-EZVRSZMK.cjs → chunk-U3VE2EVB.cjs} +11 -11
  71. package/dist/{chunk-EZVRSZMK.cjs.map → chunk-U3VE2EVB.cjs.map} +1 -1
  72. package/dist/{chunk-4IKJAKCD.cjs → chunk-V537VSV4.cjs} +74 -16
  73. package/dist/chunk-V537VSV4.cjs.map +1 -0
  74. package/dist/{chunk-XRIVPHXV.cjs → chunk-VYJXTHII.cjs} +422 -30
  75. package/dist/chunk-VYJXTHII.cjs.map +1 -0
  76. package/dist/{chunk-LRSB62Z6.cjs → chunk-X7F4CSGR.cjs} +15 -8
  77. package/dist/chunk-X7F4CSGR.cjs.map +1 -0
  78. package/dist/{chunk-CKGIPST2.js → chunk-XBO6W7LZ.js} +462 -193
  79. package/dist/chunk-XBO6W7LZ.js.map +1 -0
  80. package/dist/{chunk-KEURQGCQ.js → chunk-XIDKHXNR.js} +74 -17
  81. package/dist/chunk-XIDKHXNR.js.map +1 -0
  82. package/dist/{chunk-JTXVR2RA.cjs → chunk-XJQX54QP.cjs} +5 -5
  83. package/dist/{chunk-JTXVR2RA.cjs.map → chunk-XJQX54QP.cjs.map} +1 -1
  84. package/dist/{chunk-BAMR7HKO.js → chunk-YDFX3JR2.js} +457 -326
  85. package/dist/chunk-YDFX3JR2.js.map +1 -0
  86. package/dist/{chunk-5CWWU22H.js → chunk-ZTTMSCLU.js} +3 -3
  87. package/dist/{chunk-5CWWU22H.js.map → chunk-ZTTMSCLU.js.map} +1 -1
  88. package/dist/evals/base.d.ts +1 -1
  89. package/dist/evals/base.d.ts.map +1 -1
  90. package/dist/evals/base.test-utils.d.ts +25 -25
  91. package/dist/evals/index.cjs +4 -4
  92. package/dist/evals/index.js +1 -1
  93. package/dist/evals/scoreTraces/index.cjs +3 -3
  94. package/dist/evals/scoreTraces/index.js +1 -1
  95. package/dist/index.cjs +2 -2
  96. package/dist/index.js +1 -1
  97. package/dist/integration/index.cjs +2 -2
  98. package/dist/integration/index.js +1 -1
  99. package/dist/llm/index.cjs +18 -14
  100. package/dist/llm/index.d.ts +2 -1
  101. package/dist/llm/index.d.ts.map +1 -1
  102. package/dist/llm/index.js +5 -5
  103. package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
  104. package/dist/llm/model/gateway-resolver.d.ts.map +1 -1
  105. package/dist/llm/model/gateways/azure.d.ts +36 -0
  106. package/dist/llm/model/gateways/azure.d.ts.map +1 -0
  107. package/dist/llm/model/gateways/base.d.ts +3 -6
  108. package/dist/llm/model/gateways/base.d.ts.map +1 -1
  109. package/dist/llm/model/gateways/index.d.ts +4 -1
  110. package/dist/llm/model/gateways/index.d.ts.map +1 -1
  111. package/dist/llm/model/gateways/models-dev.d.ts +2 -2
  112. package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
  113. package/dist/llm/model/gateways/netlify.d.ts +2 -2
  114. package/dist/llm/model/gateways/netlify.d.ts.map +1 -1
  115. package/dist/llm/model/model.d.ts.map +1 -1
  116. package/dist/llm/model/model.loop.d.ts +1 -1
  117. package/dist/llm/model/model.loop.d.ts.map +1 -1
  118. package/dist/llm/model/provider-registry.d.ts.map +1 -1
  119. package/dist/llm/model/provider-types.generated.d.ts +192 -11
  120. package/dist/llm/model/registry-generator.d.ts +12 -0
  121. package/dist/llm/model/registry-generator.d.ts.map +1 -1
  122. package/dist/llm/model/router.d.ts.map +1 -1
  123. package/dist/loop/index.cjs +2 -2
  124. package/dist/loop/index.js +1 -1
  125. package/dist/loop/loop.d.ts.map +1 -1
  126. package/dist/loop/network/index.d.ts.map +1 -1
  127. package/dist/loop/test-utils/generateText.d.ts.map +1 -1
  128. package/dist/loop/test-utils/resultObject.d.ts.map +1 -1
  129. package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
  130. package/dist/loop/test-utils/toUIMessageStream.d.ts.map +1 -1
  131. package/dist/loop/test-utils/utils.d.ts.map +1 -1
  132. package/dist/loop/types.d.ts +8 -0
  133. package/dist/loop/types.d.ts.map +1 -1
  134. package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
  135. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  136. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  137. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +1 -1
  138. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  139. package/dist/mastra/index.cjs +2 -2
  140. package/dist/mastra/index.d.ts +9 -9
  141. package/dist/mastra/index.d.ts.map +1 -1
  142. package/dist/mastra/index.js +1 -1
  143. package/dist/mcp/index.cjs.map +1 -1
  144. package/dist/mcp/index.d.ts +4 -4
  145. package/dist/mcp/index.d.ts.map +1 -1
  146. package/dist/mcp/index.js.map +1 -1
  147. package/dist/mcp/types.d.ts +2 -2
  148. package/dist/mcp/types.d.ts.map +1 -1
  149. package/dist/memory/index.cjs +89 -34
  150. package/dist/memory/index.cjs.map +1 -1
  151. package/dist/memory/index.js +85 -30
  152. package/dist/memory/index.js.map +1 -1
  153. package/dist/memory/mock.d.ts +9 -13
  154. package/dist/memory/mock.d.ts.map +1 -1
  155. package/dist/models-dev-F6MTIYTO.js +3 -0
  156. package/dist/{models-dev-GCVENVWA.js.map → models-dev-F6MTIYTO.js.map} +1 -1
  157. package/dist/models-dev-XIVR5EJV.cjs +12 -0
  158. package/dist/{models-dev-TIBJR6IG.cjs.map → models-dev-XIVR5EJV.cjs.map} +1 -1
  159. package/dist/netlify-MXBOGAJR.cjs +12 -0
  160. package/dist/{netlify-NTSNNT6F.cjs.map → netlify-MXBOGAJR.cjs.map} +1 -1
  161. package/dist/netlify-RX3JXCFQ.js +3 -0
  162. package/dist/{netlify-O5NJW7CF.js.map → netlify-RX3JXCFQ.js.map} +1 -1
  163. package/dist/processors/index.cjs +11 -11
  164. package/dist/processors/index.d.ts +2 -2
  165. package/dist/processors/index.d.ts.map +1 -1
  166. package/dist/processors/index.js +1 -1
  167. package/dist/processors/processors/batch-parts.d.ts +1 -1
  168. package/dist/processors/processors/batch-parts.d.ts.map +1 -1
  169. package/dist/processors/processors/language-detector.d.ts +1 -1
  170. package/dist/processors/processors/language-detector.d.ts.map +1 -1
  171. package/dist/processors/processors/moderation.d.ts +1 -1
  172. package/dist/processors/processors/moderation.d.ts.map +1 -1
  173. package/dist/processors/processors/pii-detector.d.ts +1 -1
  174. package/dist/processors/processors/pii-detector.d.ts.map +1 -1
  175. package/dist/processors/processors/prompt-injection-detector.d.ts +1 -1
  176. package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
  177. package/dist/processors/processors/structured-output.d.ts +1 -1
  178. package/dist/processors/processors/structured-output.d.ts.map +1 -1
  179. package/dist/processors/processors/system-prompt-scrubber.d.ts +1 -1
  180. package/dist/processors/processors/system-prompt-scrubber.d.ts.map +1 -1
  181. package/dist/processors/processors/token-limiter.d.ts +1 -1
  182. package/dist/processors/processors/token-limiter.d.ts.map +1 -1
  183. package/dist/processors/processors/unicode-normalizer.d.ts +1 -1
  184. package/dist/processors/processors/unicode-normalizer.d.ts.map +1 -1
  185. package/dist/provider-registry-3LUCE7FT.js +3 -0
  186. package/dist/{provider-registry-74GMFZKT.js.map → provider-registry-3LUCE7FT.js.map} +1 -1
  187. package/dist/provider-registry-NBRXBOQT.cjs +40 -0
  188. package/dist/{provider-registry-BZP3DIIV.cjs.map → provider-registry-NBRXBOQT.cjs.map} +1 -1
  189. package/dist/provider-registry.json +400 -22
  190. package/dist/{registry-generator-JPCV47SC.cjs → registry-generator-DEPPRYYJ.cjs} +21 -6
  191. package/dist/registry-generator-DEPPRYYJ.cjs.map +1 -0
  192. package/dist/{registry-generator-XD4FPZTU.js → registry-generator-FLW6NV42.js} +21 -7
  193. package/dist/registry-generator-FLW6NV42.js.map +1 -0
  194. package/dist/relevance/index.cjs +2 -2
  195. package/dist/relevance/index.js +1 -1
  196. package/dist/server/auth.d.ts +11 -0
  197. package/dist/server/auth.d.ts.map +1 -1
  198. package/dist/server/composite-auth.d.ts +9 -0
  199. package/dist/server/composite-auth.d.ts.map +1 -0
  200. package/dist/server/index.cjs +41 -0
  201. package/dist/server/index.cjs.map +1 -1
  202. package/dist/server/index.d.ts +1 -0
  203. package/dist/server/index.d.ts.map +1 -1
  204. package/dist/server/index.js +41 -1
  205. package/dist/server/index.js.map +1 -1
  206. package/dist/storage/index.cjs +29 -29
  207. package/dist/storage/index.js +1 -1
  208. package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
  209. package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
  210. package/dist/stream/base/output.d.ts.map +1 -1
  211. package/dist/stream/index.cjs +11 -11
  212. package/dist/stream/index.js +2 -2
  213. package/dist/stream/types.d.ts +7 -2
  214. package/dist/stream/types.d.ts.map +1 -1
  215. package/dist/test-utils/llm-mock.cjs +68 -31
  216. package/dist/test-utils/llm-mock.cjs.map +1 -1
  217. package/dist/test-utils/llm-mock.d.ts +4 -2
  218. package/dist/test-utils/llm-mock.d.ts.map +1 -1
  219. package/dist/test-utils/llm-mock.js +67 -30
  220. package/dist/test-utils/llm-mock.js.map +1 -1
  221. package/dist/tools/index.cjs +6 -6
  222. package/dist/tools/index.js +2 -2
  223. package/dist/tools/is-vercel-tool.cjs +2 -2
  224. package/dist/tools/is-vercel-tool.js +1 -1
  225. package/dist/tools/stream.d.ts +1 -0
  226. package/dist/tools/stream.d.ts.map +1 -1
  227. package/dist/tools/tool-builder/builder.d.ts +2 -0
  228. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  229. package/dist/tools/tool.d.ts +6 -6
  230. package/dist/tools/tool.d.ts.map +1 -1
  231. package/dist/tools/types.d.ts +6 -2
  232. package/dist/tools/types.d.ts.map +1 -1
  233. package/dist/tools/validation.d.ts +13 -1
  234. package/dist/tools/validation.d.ts.map +1 -1
  235. package/dist/utils.cjs +22 -22
  236. package/dist/utils.d.ts +1 -1
  237. package/dist/utils.d.ts.map +1 -1
  238. package/dist/utils.js +1 -1
  239. package/dist/vector/filter/index.cjs +7 -189
  240. package/dist/vector/filter/index.cjs.map +1 -1
  241. package/dist/vector/filter/index.js +1 -190
  242. package/dist/vector/filter/index.js.map +1 -1
  243. package/dist/vector/index.cjs +5 -0
  244. package/dist/vector/index.cjs.map +1 -1
  245. package/dist/vector/index.d.ts +1 -0
  246. package/dist/vector/index.d.ts.map +1 -1
  247. package/dist/vector/index.js +1 -0
  248. package/dist/vector/index.js.map +1 -1
  249. package/dist/vector/types.d.ts +86 -3
  250. package/dist/vector/types.d.ts.map +1 -1
  251. package/dist/vector/vector.d.ts +39 -2
  252. package/dist/vector/vector.d.ts.map +1 -1
  253. package/dist/voice/aisdk/index.d.ts +3 -0
  254. package/dist/voice/aisdk/index.d.ts.map +1 -0
  255. package/dist/voice/aisdk/speech.d.ts +23 -0
  256. package/dist/voice/aisdk/speech.d.ts.map +1 -0
  257. package/dist/voice/aisdk/transcription.d.ts +22 -0
  258. package/dist/voice/aisdk/transcription.d.ts.map +1 -0
  259. package/dist/voice/composite-voice.d.ts +4 -3
  260. package/dist/voice/composite-voice.d.ts.map +1 -1
  261. package/dist/voice/index.cjs +12 -4
  262. package/dist/voice/index.d.ts +1 -0
  263. package/dist/voice/index.d.ts.map +1 -1
  264. package/dist/voice/index.js +1 -1
  265. package/dist/workflows/default.d.ts.map +1 -1
  266. package/dist/workflows/evented/index.cjs +10 -10
  267. package/dist/workflows/evented/index.js +1 -1
  268. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  269. package/dist/workflows/index.cjs +23 -19
  270. package/dist/workflows/index.js +1 -1
  271. package/dist/workflows/types.d.ts +2 -2
  272. package/dist/workflows/types.d.ts.map +1 -1
  273. package/dist/workflows/utils.d.ts +7 -0
  274. package/dist/workflows/utils.d.ts.map +1 -1
  275. package/dist/workflows/workflow.d.ts +4 -2
  276. package/dist/workflows/workflow.d.ts.map +1 -1
  277. package/package.json +17 -16
  278. package/src/llm/model/provider-types.generated.d.ts +192 -11
  279. package/dist/chunk-3VOUB4ZU.cjs.map +0 -1
  280. package/dist/chunk-4DWZ4Z6H.js.map +0 -1
  281. package/dist/chunk-4IKJAKCD.cjs.map +0 -1
  282. package/dist/chunk-4RSHBKDJ.cjs.map +0 -1
  283. package/dist/chunk-BAMR7HKO.js.map +0 -1
  284. package/dist/chunk-CKGIPST2.js.map +0 -1
  285. package/dist/chunk-D6EDHNGV.js.map +0 -1
  286. package/dist/chunk-G36A2JRR.cjs.map +0 -1
  287. package/dist/chunk-G3OOCXAI.js.map +0 -1
  288. package/dist/chunk-GRGPQ32U.js.map +0 -1
  289. package/dist/chunk-HBJPYQRN.cjs.map +0 -1
  290. package/dist/chunk-HGNRQ3OG.js.map +0 -1
  291. package/dist/chunk-JXESKY4A.js.map +0 -1
  292. package/dist/chunk-KEURQGCQ.js.map +0 -1
  293. package/dist/chunk-KOSW5PP5.js.map +0 -1
  294. package/dist/chunk-LRSB62Z6.cjs.map +0 -1
  295. package/dist/chunk-MCUX2D5Q.js.map +0 -1
  296. package/dist/chunk-N4SJ4YX7.cjs.map +0 -1
  297. package/dist/chunk-O6NA3Z43.cjs.map +0 -1
  298. package/dist/chunk-OWX2PUFH.cjs.map +0 -1
  299. package/dist/chunk-QUKUN6NR.cjs.map +0 -1
  300. package/dist/chunk-T3WZCEC4.js.map +0 -1
  301. package/dist/chunk-UIZSWUKP.js.map +0 -1
  302. package/dist/chunk-VU6DVS7J.js.map +0 -1
  303. package/dist/chunk-VZGBVYXA.cjs.map +0 -1
  304. package/dist/chunk-XRIVPHXV.cjs.map +0 -1
  305. package/dist/chunk-YQ7NLZZ3.cjs.map +0 -1
  306. package/dist/chunk-ZPMFINU2.cjs.map +0 -1
  307. package/dist/models-dev-GCVENVWA.js +0 -3
  308. package/dist/models-dev-TIBJR6IG.cjs +0 -12
  309. package/dist/netlify-NTSNNT6F.cjs +0 -12
  310. package/dist/netlify-O5NJW7CF.js +0 -3
  311. package/dist/provider-registry-74GMFZKT.js +0 -3
  312. package/dist/provider-registry-BZP3DIIV.cjs +0 -40
  313. package/dist/registry-generator-JPCV47SC.cjs.map +0 -1
  314. package/dist/registry-generator-XD4FPZTU.js.map +0 -1
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkQUKUN6NR_cjs = require('./chunk-QUKUN6NR.cjs');
3
+ var chunkISMGVGUM_cjs = require('./chunk-ISMGVGUM.cjs');
4
4
  var chunkABJOUEVA_cjs = require('./chunk-ABJOUEVA.cjs');
5
- var chunkG36A2JRR_cjs = require('./chunk-G36A2JRR.cjs');
6
- var chunkN4SJ4YX7_cjs = require('./chunk-N4SJ4YX7.cjs');
7
- var chunkO6NA3Z43_cjs = require('./chunk-O6NA3Z43.cjs');
5
+ var chunkDQIZ5FFX_cjs = require('./chunk-DQIZ5FFX.cjs');
6
+ var chunkNHP6ZIDG_cjs = require('./chunk-NHP6ZIDG.cjs');
7
+ var chunkOUUPUAGA_cjs = require('./chunk-OUUPUAGA.cjs');
8
8
  var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
9
- var chunkHBJPYQRN_cjs = require('./chunk-HBJPYQRN.cjs');
9
+ var chunkRROQ46B6_cjs = require('./chunk-RROQ46B6.cjs');
10
10
  var chunkE7K4FTLN_cjs = require('./chunk-E7K4FTLN.cjs');
11
11
  var chunkTWH4PTDG_cjs = require('./chunk-TWH4PTDG.cjs');
12
- var chunkLRSB62Z6_cjs = require('./chunk-LRSB62Z6.cjs');
13
- var chunk4IKJAKCD_cjs = require('./chunk-4IKJAKCD.cjs');
12
+ var chunkX7F4CSGR_cjs = require('./chunk-X7F4CSGR.cjs');
13
+ var chunkV537VSV4_cjs = require('./chunk-V537VSV4.cjs');
14
14
  var chunkJ7O6WENZ_cjs = require('./chunk-J7O6WENZ.cjs');
15
15
  var chunk4WQYXT2I_cjs = require('./chunk-4WQYXT2I.cjs');
16
16
  var chunkKEXGB7FK_cjs = require('./chunk-KEXGB7FK.cjs');
@@ -21,8 +21,8 @@ var web = require('stream/web');
21
21
  var crypto2 = require('crypto');
22
22
  var providerV5 = require('@ai-sdk/provider-v5');
23
23
  var aiV5 = require('ai-v5');
24
- var z5 = require('zod');
25
24
  var schemaCompat = require('@mastra/schema-compat');
25
+ var z5 = require('zod');
26
26
  var radash = require('radash');
27
27
  var providerUtilsV5 = require('@ai-sdk/provider-utils-v5');
28
28
  var lite = require('js-tiktoken/lite');
@@ -449,14 +449,22 @@ function prepareToolsAndToolChoice({
449
449
  inputSchema: aiV5.asSchema(sdkTool.inputSchema).jsonSchema,
450
450
  providerOptions: sdkTool.providerOptions
451
451
  };
452
- case "provider-defined":
452
+ case "provider-defined": {
453
+ const providerId = sdkTool.id;
454
+ let providerToolName = name;
455
+ if (providerId && providerId.includes(".")) {
456
+ providerToolName = providerId.split(".").slice(1).join(".");
457
+ } else if (providerId) {
458
+ providerToolName = providerId;
459
+ }
453
460
  return {
454
461
  type: "provider-defined",
455
- name,
462
+ name: providerToolName,
456
463
  // TODO: as any seems wrong here. are there cases where we don't have an id?
457
- id: sdkTool.id,
464
+ id: providerId,
458
465
  args: sdkTool.args
459
466
  };
467
+ }
460
468
  default: {
461
469
  const exhaustiveCheck = toolType;
462
470
  throw new Error(`Unsupported tool type: ${exhaustiveCheck}`);
@@ -962,7 +970,8 @@ async function validateStepInput({
962
970
  const errorMessages = errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n");
963
971
  validationError = new Error("Step input validation failed: \n" + errorMessages);
964
972
  } else {
965
- inputData = radash.isEmpty(validatedInput.data) ? prevOutput : validatedInput.data;
973
+ const isEmptyData = radash.isEmpty(validatedInput.data);
974
+ inputData = isEmptyData ? prevOutput : validatedInput.data;
966
975
  }
967
976
  }
968
977
  return { inputData, validationError };
@@ -985,6 +994,27 @@ async function validateStepResumeData({ resumeData, step }) {
985
994
  }
986
995
  return { resumeData, validationError };
987
996
  }
997
+ async function validateStepSuspendData({
998
+ suspendData,
999
+ step
1000
+ }) {
1001
+ if (!suspendData) {
1002
+ return { suspendData: void 0, validationError: void 0 };
1003
+ }
1004
+ let validationError;
1005
+ const suspendSchema = step.suspendSchema;
1006
+ if (suspendSchema) {
1007
+ const validatedSuspendData = await suspendSchema.safeParseAsync(suspendData);
1008
+ if (!validatedSuspendData.success) {
1009
+ const errors = getZodErrors(validatedSuspendData.error);
1010
+ const errorMessages = errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n");
1011
+ validationError = new Error("Step suspend data validation failed: \n" + errorMessages);
1012
+ } else {
1013
+ suspendData = validatedSuspendData.data;
1014
+ }
1015
+ }
1016
+ return { suspendData, validationError };
1017
+ }
988
1018
  function getResumeLabelsByStepId(resumeLabels, stepId) {
989
1019
  return Object.entries(resumeLabels).filter(([_, value]) => value.stepId === stepId).reduce(
990
1020
  (acc, [key, value]) => {
@@ -1099,7 +1129,7 @@ var createTimeTravelExecutionParams = (params) => {
1099
1129
  result = void 0;
1100
1130
  }
1101
1131
  if (result) {
1102
- const formattedResult = chunkHBJPYQRN_cjs.removeUndefinedValues(result);
1132
+ const formattedResult = chunkRROQ46B6_cjs.removeUndefinedValues(result);
1103
1133
  stepResults[stepId] = formattedResult;
1104
1134
  }
1105
1135
  });
@@ -1443,7 +1473,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
1443
1473
  [chunkABJOUEVA_cjs.STREAM_FORMAT_SYMBOL]: executionContext.format,
1444
1474
  engine: {},
1445
1475
  abortSignal: abortController?.signal,
1446
- writer: new chunkLRSB62Z6_cjs.ToolStream(
1476
+ writer: new chunkX7F4CSGR_cjs.ToolStream(
1447
1477
  {
1448
1478
  prefix: "workflow-step",
1449
1479
  callId: stepCallId,
@@ -1520,7 +1550,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
1520
1550
  [chunkABJOUEVA_cjs.STREAM_FORMAT_SYMBOL]: executionContext.format,
1521
1551
  engine: {},
1522
1552
  abortSignal: abortController?.signal,
1523
- writer: new chunkLRSB62Z6_cjs.ToolStream(
1553
+ writer: new chunkX7F4CSGR_cjs.ToolStream(
1524
1554
  {
1525
1555
  prefix: "workflow-step",
1526
1556
  callId: stepCallId,
@@ -1673,6 +1703,13 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
1673
1703
  getInitData: () => stepResults?.input,
1674
1704
  getStepResult: getStepResult.bind(this, stepResults),
1675
1705
  suspend: async (suspendPayload, suspendOptions) => {
1706
+ const { suspendData, validationError: validationError2 } = await validateStepSuspendData({
1707
+ suspendData: suspendPayload,
1708
+ step
1709
+ });
1710
+ if (validationError2) {
1711
+ throw validationError2;
1712
+ }
1676
1713
  executionContext.suspendedPaths[step.id] = executionContext.executionPath;
1677
1714
  if (suspendOptions?.resumeLabel) {
1678
1715
  const resumeLabel = Array.isArray(suspendOptions.resumeLabel) ? suspendOptions.resumeLabel : [suspendOptions.resumeLabel];
@@ -1683,7 +1720,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
1683
1720
  };
1684
1721
  }
1685
1722
  }
1686
- suspended = { payload: suspendPayload };
1723
+ suspended = { payload: suspendData };
1687
1724
  },
1688
1725
  bail: (result2) => {
1689
1726
  bailed = { payload: result2 };
@@ -1714,7 +1751,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
1714
1751
  [chunkABJOUEVA_cjs.STREAM_FORMAT_SYMBOL]: executionContext.format,
1715
1752
  engine: {},
1716
1753
  abortSignal: abortController?.signal,
1717
- writer: new chunkLRSB62Z6_cjs.ToolStream(
1754
+ writer: new chunkX7F4CSGR_cjs.ToolStream(
1718
1755
  {
1719
1756
  prefix: "workflow-step",
1720
1757
  callId: stepCallId,
@@ -2077,7 +2114,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
2077
2114
  [chunkABJOUEVA_cjs.STREAM_FORMAT_SYMBOL]: executionContext.format,
2078
2115
  engine: {},
2079
2116
  abortSignal: abortController?.signal,
2080
- writer: new chunkLRSB62Z6_cjs.ToolStream(
2117
+ writer: new chunkX7F4CSGR_cjs.ToolStream(
2081
2118
  {
2082
2119
  prefix: "workflow-step",
2083
2120
  callId: crypto2.randomUUID(),
@@ -2286,7 +2323,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
2286
2323
  const evalSpan = loopSpan?.createChildSpan({
2287
2324
  type: "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */,
2288
2325
  name: `condition: '${entry.loopType}'`,
2289
- input: chunkHBJPYQRN_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
2326
+ input: chunkRROQ46B6_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
2290
2327
  attributes: {
2291
2328
  conditionIndex: iteration
2292
2329
  },
@@ -2322,7 +2359,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
2322
2359
  [chunkABJOUEVA_cjs.STREAM_FORMAT_SYMBOL]: executionContext.format,
2323
2360
  engine: {},
2324
2361
  abortSignal: abortController?.signal,
2325
- writer: new chunkLRSB62Z6_cjs.ToolStream(
2362
+ writer: new chunkX7F4CSGR_cjs.ToolStream(
2326
2363
  {
2327
2364
  prefix: "workflow-step",
2328
2365
  callId: crypto2.randomUUID(),
@@ -2979,7 +3016,7 @@ function mapVariable(config) {
2979
3016
  function createStep(params, agentOptions) {
2980
3017
  if (params instanceof Agent) {
2981
3018
  return {
2982
- id: params.name,
3019
+ id: params.id,
2983
3020
  description: params.getDescription(),
2984
3021
  // @ts-ignore
2985
3022
  inputSchema: z5.z.object({
@@ -3071,7 +3108,7 @@ function createStep(params, agentOptions) {
3071
3108
  component: params.component
3072
3109
  };
3073
3110
  }
3074
- if (params instanceof chunk4IKJAKCD_cjs.Tool) {
3111
+ if (params instanceof chunkV537VSV4_cjs.Tool) {
3075
3112
  if (!params.inputSchema || !params.outputSchema) {
3076
3113
  throw new Error("Tool must have input and output schemas defined");
3077
3114
  }
@@ -3082,6 +3119,8 @@ function createStep(params, agentOptions) {
3082
3119
  description: params.description,
3083
3120
  inputSchema: params.inputSchema,
3084
3121
  outputSchema: params.outputSchema,
3122
+ resumeSchema: params.resumeSchema,
3123
+ suspendSchema: params.suspendSchema,
3085
3124
  execute: async ({
3086
3125
  inputData,
3087
3126
  mastra,
@@ -3098,10 +3137,11 @@ function createStep(params, agentOptions) {
3098
3137
  mastra,
3099
3138
  requestContext,
3100
3139
  tracingContext,
3101
- suspend,
3102
3140
  resumeData,
3103
3141
  workflow: {
3104
3142
  runId,
3143
+ suspend,
3144
+ resumeData,
3105
3145
  workflowId,
3106
3146
  state,
3107
3147
  setState
@@ -3562,6 +3602,7 @@ var Workflow = class extends chunkKEXGB7FK_cjs.MastraBase {
3562
3602
  const run = this.#runs.get(runIdToUse) ?? new Run({
3563
3603
  workflowId: this.id,
3564
3604
  stateSchema: this.stateSchema,
3605
+ inputSchema: this.inputSchema,
3565
3606
  runId: runIdToUse,
3566
3607
  resourceId: options?.resourceId,
3567
3608
  executionEngine: this.executionEngine,
@@ -3921,6 +3962,7 @@ var Run = class {
3921
3962
  closeStreamAction;
3922
3963
  executionResults;
3923
3964
  stateSchema;
3965
+ inputSchema;
3924
3966
  cleanup;
3925
3967
  retryConfig;
3926
3968
  constructor(params) {
@@ -3939,6 +3981,7 @@ var Run = class {
3939
3981
  this.workflowSteps = params.workflowSteps;
3940
3982
  this.validateInputs = params.validateInputs;
3941
3983
  this.stateSchema = params.stateSchema;
3984
+ this.inputSchema = params.inputSchema;
3942
3985
  this.workflowRunStatus = "pending";
3943
3986
  this.workflowEngineType = params.workflowEngineType;
3944
3987
  }
@@ -3955,29 +3998,16 @@ var Run = class {
3955
3998
  this.abortController?.abort();
3956
3999
  }
3957
4000
  async _validateInput(inputData) {
3958
- const firstEntry = this.executionGraph.steps[0];
3959
4001
  let inputDataToUse = inputData;
3960
- if (firstEntry && this.validateInputs) {
3961
- let inputSchema;
3962
- if (firstEntry.type === "step" || firstEntry.type === "foreach" || firstEntry.type === "loop") {
3963
- const step = firstEntry.step;
3964
- inputSchema = step.inputSchema;
3965
- } else if (firstEntry.type === "conditional" || firstEntry.type === "parallel") {
3966
- const firstStep = firstEntry.steps[0];
3967
- if (firstStep && firstStep.type === "step") {
3968
- inputSchema = firstStep.step.inputSchema;
3969
- }
3970
- }
3971
- if (inputSchema) {
3972
- const validatedInputData = await inputSchema.safeParseAsync(inputData);
3973
- if (!validatedInputData.success) {
3974
- const errors = getZodErrors(validatedInputData.error);
3975
- throw new Error(
3976
- "Invalid input data: \n" + errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n")
3977
- );
3978
- }
3979
- inputDataToUse = validatedInputData.data;
4002
+ if (this.validateInputs && this.inputSchema) {
4003
+ const validatedInputData = await this.inputSchema.safeParseAsync(inputData);
4004
+ if (!validatedInputData.success) {
4005
+ const errors = getZodErrors(validatedInputData.error);
4006
+ throw new Error(
4007
+ "Invalid input data: \n" + errors.map((e) => `- ${e.path?.join(".")}: ${e.message}`).join("\n")
4008
+ );
3980
4009
  }
4010
+ inputDataToUse = validatedInputData.data;
3981
4011
  }
3982
4012
  return inputDataToUse;
3983
4013
  }
@@ -5356,7 +5386,7 @@ function convertMastraChunkToAISDKv5({
5356
5386
  if (mode === "generate") {
5357
5387
  return {
5358
5388
  type: "file",
5359
- file: new chunkG36A2JRR_cjs.DefaultGeneratedFile({
5389
+ file: new chunkDQIZ5FFX_cjs.DefaultGeneratedFile({
5360
5390
  data: chunk.payload.data,
5361
5391
  mediaType: chunk.payload.mimeType
5362
5392
  })
@@ -5364,7 +5394,7 @@ function convertMastraChunkToAISDKv5({
5364
5394
  }
5365
5395
  return {
5366
5396
  type: "file",
5367
- file: new chunkG36A2JRR_cjs.DefaultGeneratedFileWithType({
5397
+ file: new chunkDQIZ5FFX_cjs.DefaultGeneratedFileWithType({
5368
5398
  data: chunk.payload.data,
5369
5399
  mediaType: chunk.payload.mimeType
5370
5400
  })
@@ -5748,23 +5778,22 @@ async function processOutputStream({
5748
5778
  if (runState.state.textDeltas.length) {
5749
5779
  const textStartPayload = chunk.payload;
5750
5780
  const providerMetadata = textStartPayload.providerMetadata ?? runState.state.providerOptions;
5751
- messageList.add(
5752
- {
5753
- id: messageId,
5754
- role: "assistant",
5755
- content: [
5756
- providerMetadata ? {
5781
+ const message = {
5782
+ id: messageId,
5783
+ role: "assistant",
5784
+ content: {
5785
+ format: 2,
5786
+ parts: [
5787
+ {
5757
5788
  type: "text",
5758
5789
  text: runState.state.textDeltas.join(""),
5759
- providerOptions: providerMetadata
5760
- } : {
5761
- type: "text",
5762
- text: runState.state.textDeltas.join("")
5790
+ ...providerMetadata ? { providerMetadata } : {}
5763
5791
  }
5764
5792
  ]
5765
5793
  },
5766
- "response"
5767
- );
5794
+ createdAt: /* @__PURE__ */ new Date()
5795
+ };
5796
+ messageList.add(message, "response");
5768
5797
  }
5769
5798
  runState.setState({
5770
5799
  isStreaming: false,
@@ -5844,20 +5873,23 @@ async function processOutputStream({
5844
5873
  providerOptions: chunk.payload.providerMetadata ?? runState.state.providerOptions
5845
5874
  });
5846
5875
  if (Object.values(chunk.payload.providerMetadata || {}).find((v) => v?.redactedData)) {
5847
- messageList.add(
5848
- {
5849
- id: messageId,
5850
- role: "assistant",
5851
- content: [
5876
+ const message = {
5877
+ id: messageId,
5878
+ role: "assistant",
5879
+ content: {
5880
+ format: 2,
5881
+ parts: [
5852
5882
  {
5853
5883
  type: "reasoning",
5854
- text: "",
5855
- providerOptions: chunk.payload.providerMetadata ?? runState.state.providerOptions
5884
+ reasoning: "",
5885
+ details: [{ type: "redacted", data: "" }],
5886
+ providerMetadata: chunk.payload.providerMetadata ?? runState.state.providerOptions
5856
5887
  }
5857
5888
  ]
5858
5889
  },
5859
- "response"
5860
- );
5890
+ createdAt: /* @__PURE__ */ new Date()
5891
+ };
5892
+ messageList.add(message, "response");
5861
5893
  if (isControllerOpen(controller)) {
5862
5894
  controller.enqueue(chunk);
5863
5895
  }
@@ -5883,20 +5915,23 @@ async function processOutputStream({
5883
5915
  }
5884
5916
  case "reasoning-end": {
5885
5917
  if (runState.state.reasoningDeltas.length > 0) {
5886
- messageList.add(
5887
- {
5888
- id: messageId,
5889
- role: "assistant",
5890
- content: [
5918
+ const message = {
5919
+ id: messageId,
5920
+ role: "assistant",
5921
+ content: {
5922
+ format: 2,
5923
+ parts: [
5891
5924
  {
5892
5925
  type: "reasoning",
5893
- text: runState.state.reasoningDeltas.join(""),
5894
- providerOptions: chunk.payload.providerMetadata ?? runState.state.providerOptions
5926
+ reasoning: "",
5927
+ details: [{ type: "text", text: runState.state.reasoningDeltas.join("") }],
5928
+ providerMetadata: chunk.payload.providerMetadata ?? runState.state.providerOptions
5895
5929
  }
5896
5930
  ]
5897
5931
  },
5898
- "response"
5899
- );
5932
+ createdAt: /* @__PURE__ */ new Date()
5933
+ };
5934
+ messageList.add(message, "response");
5900
5935
  }
5901
5936
  runState.setState({
5902
5937
  isReasoning: false,
@@ -5908,25 +5943,31 @@ async function processOutputStream({
5908
5943
  break;
5909
5944
  }
5910
5945
  case "file":
5911
- messageList.add(
5912
- {
5946
+ {
5947
+ const message = {
5913
5948
  id: messageId,
5914
5949
  role: "assistant",
5915
- content: [
5916
- {
5917
- type: "file",
5918
- data: chunk.payload.data,
5919
- mimeType: chunk.payload.mimeType
5920
- }
5921
- ]
5922
- },
5923
- "response"
5924
- );
5925
- controller.enqueue(chunk);
5950
+ content: {
5951
+ format: 2,
5952
+ parts: [
5953
+ {
5954
+ type: "file",
5955
+ // @ts-expect-error
5956
+ data: chunk.payload.data,
5957
+ // TODO: incorrect string type
5958
+ mimeType: chunk.payload.mimeType
5959
+ }
5960
+ ]
5961
+ },
5962
+ createdAt: /* @__PURE__ */ new Date()
5963
+ };
5964
+ messageList.add(message, "response");
5965
+ controller.enqueue(chunk);
5966
+ }
5926
5967
  break;
5927
5968
  case "source":
5928
- messageList.add(
5929
- {
5969
+ {
5970
+ const message = {
5930
5971
  id: messageId,
5931
5972
  role: "assistant",
5932
5973
  content: {
@@ -5945,10 +5986,10 @@ async function processOutputStream({
5945
5986
  ]
5946
5987
  },
5947
5988
  createdAt: /* @__PURE__ */ new Date()
5948
- },
5949
- "response"
5950
- );
5951
- controller.enqueue(chunk);
5989
+ };
5990
+ messageList.add(message, "response");
5991
+ controller.enqueue(chunk);
5992
+ }
5952
5993
  break;
5953
5994
  case "finish":
5954
5995
  runState.setState({
@@ -6115,7 +6156,7 @@ function createLLMExecutionStep({
6115
6156
  }
6116
6157
  if (prepareStepResult.messages) {
6117
6158
  const newMessages = prepareStepResult.messages;
6118
- const newMessageList = new chunkG36A2JRR_cjs.MessageList();
6159
+ const newMessageList = new chunkDQIZ5FFX_cjs.MessageList();
6119
6160
  for (const message of newMessages) {
6120
6161
  if (message.role === "system") {
6121
6162
  newMessageList.addSystem(message);
@@ -6287,24 +6328,27 @@ function createLLMExecutionStep({
6287
6328
  return chunk.payload;
6288
6329
  });
6289
6330
  if (toolCalls.length > 0) {
6290
- const assistantContent = [
6291
- ...toolCalls.map((toolCall) => {
6292
- return {
6293
- type: "tool-call",
6294
- toolCallId: toolCall.toolCallId,
6295
- toolName: toolCall.toolName,
6296
- args: toolCall.args
6297
- };
6298
- })
6299
- ];
6300
- messageList.add(
6301
- {
6302
- id: messageId,
6303
- role: "assistant",
6304
- content: assistantContent
6331
+ const message = {
6332
+ id: messageId,
6333
+ role: "assistant",
6334
+ content: {
6335
+ format: 2,
6336
+ parts: toolCalls.map((toolCall) => {
6337
+ return {
6338
+ type: "tool-invocation",
6339
+ toolInvocation: {
6340
+ state: "call",
6341
+ toolCallId: toolCall.toolCallId,
6342
+ toolName: toolCall.toolName,
6343
+ args: toolCall.args
6344
+ },
6345
+ ...toolCall.providerMetadata ? { providerMetadata: toolCall.providerMetadata } : {}
6346
+ };
6347
+ })
6305
6348
  },
6306
- "response"
6307
- );
6349
+ createdAt: /* @__PURE__ */ new Date()
6350
+ };
6351
+ messageList.add(message, "response");
6308
6352
  }
6309
6353
  const finishReason = runState?.state?.stepResult?.reason ?? outputStream._getImmediateFinishReason();
6310
6354
  const hasErrored = runState.state.hasErrored;
@@ -6386,24 +6430,28 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
6386
6430
  };
6387
6431
  rest.controller.enqueue(chunk);
6388
6432
  });
6389
- rest.messageList.add(
6390
- {
6391
- id: toolResultMessageId,
6392
- role: "tool",
6393
- content: errorResults.map((toolCall) => {
6433
+ const msg = {
6434
+ id: toolResultMessageId || "",
6435
+ role: "assistant",
6436
+ content: {
6437
+ format: 2,
6438
+ parts: errorResults.map((toolCallErrorResult) => {
6394
6439
  return {
6395
- type: "tool-result",
6396
- args: toolCall.args,
6397
- toolCallId: toolCall.toolCallId,
6398
- toolName: toolCall.toolName,
6399
- result: {
6400
- tool_execution_error: toolCall.error?.message ?? toolCall.error
6401
- }
6440
+ type: "tool-invocation",
6441
+ toolInvocation: {
6442
+ state: "result",
6443
+ toolCallId: toolCallErrorResult.toolCallId,
6444
+ toolName: toolCallErrorResult.toolName,
6445
+ args: toolCallErrorResult.args,
6446
+ result: toolCallErrorResult.error?.message ?? toolCallErrorResult.error
6447
+ },
6448
+ ...toolCallErrorResult.providerMetadata ? { providerMetadata: toolCallErrorResult.providerMetadata } : {}
6402
6449
  };
6403
6450
  })
6404
6451
  },
6405
- "response"
6406
- );
6452
+ createdAt: /* @__PURE__ */ new Date()
6453
+ };
6454
+ rest.messageList.add(msg, "response");
6407
6455
  }
6408
6456
  initialResult.stepResult.isContinued = false;
6409
6457
  return bail(initialResult);
@@ -6431,24 +6479,30 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
6431
6479
  })
6432
6480
  });
6433
6481
  }
6434
- const toolResultMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
6435
- rest.messageList.add(
6436
- {
6437
- id: toolResultMessageId,
6438
- role: "tool",
6439
- content: inputData.map((toolCall2) => {
6440
- return {
6441
- type: "tool-result",
6442
- args: toolCall2.args,
6443
- toolCallId: toolCall2.toolCallId,
6444
- toolName: toolCall2.toolName,
6445
- result: toolCall2.result
6446
- };
6447
- })
6448
- },
6449
- "response"
6450
- );
6451
6482
  }
6483
+ const toolResultMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
6484
+ const toolResultMessage = {
6485
+ id: toolResultMessageId || "",
6486
+ role: "assistant",
6487
+ content: {
6488
+ format: 2,
6489
+ parts: inputData.map((toolCall) => {
6490
+ return {
6491
+ type: "tool-invocation",
6492
+ toolInvocation: {
6493
+ state: "result",
6494
+ toolCallId: toolCall.toolCallId,
6495
+ toolName: toolCall.toolName,
6496
+ args: toolCall.args,
6497
+ result: toolCall.result
6498
+ },
6499
+ ...toolCall.providerMetadata ? { providerMetadata: toolCall.providerMetadata } : {}
6500
+ };
6501
+ })
6502
+ },
6503
+ createdAt: /* @__PURE__ */ new Date()
6504
+ };
6505
+ rest.messageList.add(toolResultMessage, "response");
6452
6506
  return {
6453
6507
  ...initialResult,
6454
6508
  messages: {
@@ -6471,13 +6525,87 @@ function createToolCallStep({
6471
6525
  controller,
6472
6526
  runId,
6473
6527
  streamState,
6474
- modelSpanTracker
6528
+ modelSpanTracker,
6529
+ _internal
6475
6530
  }) {
6476
6531
  return createStep({
6477
6532
  id: "toolCallStep",
6478
6533
  inputSchema: toolCallInputSchema,
6479
6534
  outputSchema: toolCallOutputSchema,
6480
6535
  execute: async ({ inputData, suspend, resumeData, requestContext }) => {
6536
+ const addToolApprovalMetadata = (toolCallId, toolName, args) => {
6537
+ const responseMessages = messageList.get.response.db();
6538
+ const lastAssistantMessage = [...responseMessages].reverse().find((msg) => msg.role === "assistant");
6539
+ if (lastAssistantMessage) {
6540
+ const content = lastAssistantMessage.content;
6541
+ if (!content) return;
6542
+ const metadata = typeof lastAssistantMessage.content.metadata === "object" && lastAssistantMessage.content.metadata !== null ? lastAssistantMessage.content.metadata : {};
6543
+ metadata.pendingToolApprovals = metadata.pendingToolApprovals || {};
6544
+ metadata.pendingToolApprovals[toolCallId] = {
6545
+ toolName,
6546
+ args,
6547
+ type: "approval",
6548
+ runId
6549
+ // Store the runId so we can resume after page refresh
6550
+ };
6551
+ lastAssistantMessage.content.metadata = metadata;
6552
+ }
6553
+ };
6554
+ const removeToolApprovalMetadata = async (toolCallId) => {
6555
+ const { saveQueueManager, memoryConfig, threadId } = _internal || {};
6556
+ if (!saveQueueManager || !threadId) {
6557
+ return;
6558
+ }
6559
+ const getMetadata = (message) => {
6560
+ const content = message.content;
6561
+ if (!content) return void 0;
6562
+ const metadata = typeof content.metadata === "object" && content.metadata !== null ? content.metadata : void 0;
6563
+ return metadata;
6564
+ };
6565
+ const allMessages = messageList.get.all.db();
6566
+ const lastAssistantMessage = [...allMessages].reverse().find((msg) => {
6567
+ const metadata = getMetadata(msg);
6568
+ const pendingToolApprovals = metadata?.pendingToolApprovals;
6569
+ return !!pendingToolApprovals?.[toolCallId];
6570
+ });
6571
+ if (lastAssistantMessage) {
6572
+ const metadata = getMetadata(lastAssistantMessage);
6573
+ const pendingToolApprovals = metadata?.pendingToolApprovals;
6574
+ if (pendingToolApprovals && typeof pendingToolApprovals === "object") {
6575
+ delete pendingToolApprovals[toolCallId];
6576
+ if (metadata && Object.keys(pendingToolApprovals).length === 0) {
6577
+ delete metadata.pendingToolApprovals;
6578
+ }
6579
+ try {
6580
+ await saveQueueManager.flushMessages(messageList, threadId, memoryConfig);
6581
+ } catch (error) {
6582
+ console.error("Error removing tool approval metadata:", error);
6583
+ }
6584
+ }
6585
+ }
6586
+ };
6587
+ const flushMessagesBeforeSuspension = async () => {
6588
+ const { saveQueueManager, memoryConfig, threadId, resourceId, memory } = _internal || {};
6589
+ if (!saveQueueManager || !threadId) {
6590
+ return;
6591
+ }
6592
+ try {
6593
+ if (memory && !_internal.threadExists && resourceId) {
6594
+ const thread = await memory.getThreadById?.({ threadId });
6595
+ if (!thread) {
6596
+ await memory.createThread?.({
6597
+ threadId,
6598
+ resourceId,
6599
+ memoryConfig
6600
+ });
6601
+ }
6602
+ _internal.threadExists = true;
6603
+ }
6604
+ await saveQueueManager.flushMessages(messageList, threadId, memoryConfig);
6605
+ } catch (error) {
6606
+ console.error("Error flushing messages before suspension:", error);
6607
+ }
6608
+ };
6481
6609
  if (inputData.providerExecuted) {
6482
6610
  return {
6483
6611
  ...inputData,
@@ -6517,6 +6645,8 @@ function createToolCallStep({
6517
6645
  args: inputData.args
6518
6646
  }
6519
6647
  });
6648
+ addToolApprovalMetadata(inputData.toolCallId, inputData.toolName, inputData.args);
6649
+ await flushMessagesBeforeSuspension();
6520
6650
  return suspend(
6521
6651
  {
6522
6652
  requireToolApproval: {
@@ -6531,6 +6661,7 @@ function createToolCallStep({
6531
6661
  }
6532
6662
  );
6533
6663
  } else {
6664
+ await removeToolApprovalMetadata(inputData.toolCallId);
6534
6665
  if (!resumeData.approved) {
6535
6666
  return {
6536
6667
  result: "Tool call was not approved by the user",
@@ -6553,6 +6684,7 @@ function createToolCallStep({
6553
6684
  from: "AGENT" /* AGENT */,
6554
6685
  payload: { toolCallId: inputData.toolCallId, toolName: inputData.toolName, suspendPayload }
6555
6686
  });
6687
+ await flushMessagesBeforeSuspension();
6556
6688
  return await suspend(
6557
6689
  {
6558
6690
  toolCallSuspended: suspendPayload,
@@ -6566,6 +6698,18 @@ function createToolCallStep({
6566
6698
  resumeData
6567
6699
  };
6568
6700
  const result = await tool.execute(inputData.args, toolOptions);
6701
+ if (tool && "onOutput" in tool && typeof tool.onOutput === "function") {
6702
+ try {
6703
+ await tool.onOutput({
6704
+ toolCallId: inputData.toolCallId,
6705
+ toolName: inputData.toolName,
6706
+ output: result,
6707
+ abortSignal: options?.abortSignal
6708
+ });
6709
+ } catch (error) {
6710
+ console.error("Error calling onOutput", error);
6711
+ }
6712
+ }
6569
6713
  return { result, ...inputData };
6570
6714
  } catch (error) {
6571
6715
  return {
@@ -6585,6 +6729,7 @@ function createAgenticExecutionWorkflow({ models, _internal, ...rest }) {
6585
6729
  ...rest
6586
6730
  });
6587
6731
  const toolCallStep = createToolCallStep({
6732
+ _internal,
6588
6733
  ...rest
6589
6734
  });
6590
6735
  const llmMappingStep = createLLMMappingStep(
@@ -6609,6 +6754,16 @@ function createAgenticExecutionWorkflow({ models, _internal, ...rest }) {
6609
6754
  validateInputs: false
6610
6755
  }
6611
6756
  }).then(llmExecutionStep).map(
6757
+ async ({ inputData }) => {
6758
+ const typedInputData = inputData;
6759
+ const responseMessages = typedInputData.messages.nonUser;
6760
+ if (responseMessages && responseMessages.length > 0) {
6761
+ rest.messageList.add(responseMessages, "response");
6762
+ }
6763
+ return typedInputData;
6764
+ },
6765
+ { id: "add-response-to-messagelist" }
6766
+ ).map(
6612
6767
  async ({ inputData }) => {
6613
6768
  const typedInputData = inputData;
6614
6769
  return typedInputData.output.toolCalls || [];
@@ -6872,7 +7027,13 @@ function loop({
6872
7027
  const internalToUse = {
6873
7028
  now: _internal?.now || (() => Date.now()),
6874
7029
  generateId: _internal?.generateId || (() => aiV5.generateId()),
6875
- currentDate: _internal?.currentDate || (() => /* @__PURE__ */ new Date())
7030
+ currentDate: _internal?.currentDate || (() => /* @__PURE__ */ new Date()),
7031
+ saveQueueManager: _internal?.saveQueueManager,
7032
+ memoryConfig: _internal?.memoryConfig,
7033
+ threadId: _internal?.threadId,
7034
+ resourceId: _internal?.resourceId,
7035
+ memory: _internal?.memory,
7036
+ threadExists: _internal?.threadExists
6876
7037
  };
6877
7038
  let startTimestamp = internalToUse.now?.();
6878
7039
  const messageId = rest.experimental_generateMessageId?.() || internalToUse.generateId?.();
@@ -7058,7 +7219,8 @@ var MastraLLMVNext = class extends chunkKEXGB7FK_cjs.MastraBase {
7058
7219
  _internal,
7059
7220
  agentId,
7060
7221
  toolCallId,
7061
- methodType
7222
+ methodType,
7223
+ includeRawChunks
7062
7224
  }) {
7063
7225
  let stopWhenToUse;
7064
7226
  if (maxSteps && typeof maxSteps === "number") {
@@ -7116,6 +7278,7 @@ var MastraLLMVNext = class extends chunkKEXGB7FK_cjs.MastraBase {
7116
7278
  requireToolApproval,
7117
7279
  agentId,
7118
7280
  methodType,
7281
+ includeRawChunks,
7119
7282
  options: {
7120
7283
  ...options,
7121
7284
  onStepFinish: async (props) => {
@@ -7153,9 +7316,10 @@ var MastraLLMVNext = class extends chunkKEXGB7FK_cjs.MastraBase {
7153
7316
  usage: props?.usage,
7154
7317
  runId
7155
7318
  });
7156
- if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
7319
+ const remainingTokens = parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"] ?? "", 10);
7320
+ if (!isNaN(remainingTokens) && remainingTokens > 0 && remainingTokens < 2e3) {
7157
7321
  this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
7158
- await chunkHBJPYQRN_cjs.delay(10 * 1e3);
7322
+ await chunkRROQ46B6_cjs.delay(10 * 1e3);
7159
7323
  }
7160
7324
  },
7161
7325
  onFinish: async (props) => {
@@ -7459,7 +7623,7 @@ async function prepareMemoryStep({
7459
7623
  );
7460
7624
  }
7461
7625
  } else {
7462
- const messageList = new chunkG36A2JRR_cjs.MessageList({
7626
+ const messageList = new chunkDQIZ5FFX_cjs.MessageList({
7463
7627
  threadId: thread?.id,
7464
7628
  resourceId: thread?.resourceId
7465
7629
  });
@@ -7549,11 +7713,13 @@ async function createNetworkLoop({
7549
7713
  const routingAgent = await getRoutingAgent({ requestContext, agent });
7550
7714
  let completionResult;
7551
7715
  const iterationCount = (inputData.iteration ?? -1) + 1;
7716
+ const stepId = generateId3();
7552
7717
  await writer.write({
7553
7718
  type: "routing-agent-start",
7554
7719
  payload: {
7720
+ networkId: agent.id,
7555
7721
  agentId: routingAgent.id,
7556
- runId,
7722
+ runId: stepId,
7557
7723
  inputData: {
7558
7724
  ...inputData,
7559
7725
  iteration: iterationCount
@@ -7599,7 +7765,7 @@ async function createNetworkLoop({
7599
7765
  await writer.write({
7600
7766
  type: "routing-agent-text-start",
7601
7767
  payload: {
7602
- runId
7768
+ runId: stepId
7603
7769
  },
7604
7770
  from: "NETWORK" /* NETWORK */,
7605
7771
  runId
@@ -7613,6 +7779,7 @@ async function createNetworkLoop({
7613
7779
  await writer.write({
7614
7780
  type: "routing-agent-text-delta",
7615
7781
  payload: {
7782
+ runId: stepId,
7616
7783
  text: currentSlice
7617
7784
  },
7618
7785
  from: "NETWORK" /* NETWORK */,
@@ -7641,6 +7808,7 @@ async function createNetworkLoop({
7641
7808
  await writer.write({
7642
7809
  type: "routing-agent-text-delta",
7643
7810
  payload: {
7811
+ runId: stepId,
7644
7812
  text: currentSlice
7645
7813
  },
7646
7814
  from: "NETWORK" /* NETWORK */,
@@ -7661,7 +7829,7 @@ async function createNetworkLoop({
7661
7829
  isComplete: true,
7662
7830
  selectionReason: completionResult.object.completionReason || "",
7663
7831
  iteration: iterationCount,
7664
- runId
7832
+ runId: stepId
7665
7833
  };
7666
7834
  await writer.write({
7667
7835
  type: "routing-agent-end",
@@ -7763,7 +7931,7 @@ ${completionResult?.object?.finalResult}` : ""}
7763
7931
  isComplete: object.primitiveId === "none" && object.primitiveType === "none",
7764
7932
  selectionReason: object.selectionReason,
7765
7933
  iteration: iterationCount,
7766
- runId
7934
+ runId: stepId
7767
7935
  };
7768
7936
  await writer.write({
7769
7937
  type: "routing-agent-end",
@@ -7799,23 +7967,24 @@ ${completionResult?.object?.finalResult}` : ""}
7799
7967
  }),
7800
7968
  execute: async ({ inputData, writer, getInitData }) => {
7801
7969
  const agentsMap = await agent.listAgents({ requestContext });
7802
- const agentId = inputData.primitiveId;
7803
- const agentForStep = agentsMap[agentId];
7970
+ const agentForStep = agentsMap[inputData.primitiveId];
7804
7971
  if (!agentForStep) {
7805
7972
  const mastraError = new chunkTWH4PTDG_cjs.MastraError({
7806
7973
  id: "AGENT_NETWORK_AGENT_EXECUTION_STEP_INVALID_TASK_INPUT",
7807
7974
  domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
7808
7975
  category: "USER" /* USER */,
7809
- text: `Agent ${agentId} not found`
7976
+ text: `Agent ${inputData.primitiveId} not found`
7810
7977
  });
7811
7978
  throw mastraError;
7812
7979
  }
7980
+ const agentId = agentForStep.id;
7981
+ const stepId = generateId3();
7813
7982
  await writer.write({
7814
7983
  type: "agent-execution-start",
7815
7984
  payload: {
7816
- agentId: inputData.primitiveId,
7985
+ agentId,
7817
7986
  args: inputData,
7818
- runId
7987
+ runId: stepId
7819
7988
  },
7820
7989
  from: "NETWORK" /* NETWORK */,
7821
7990
  runId
@@ -7827,9 +7996,12 @@ ${completionResult?.object?.finalResult}` : ""}
7827
7996
  for await (const chunk of result.fullStream) {
7828
7997
  await writer.write({
7829
7998
  type: `agent-execution-event-${chunk.type}`,
7830
- payload: chunk,
7831
- runId: chunk.runId,
7832
- from: "NETWORK" /* NETWORK */
7999
+ payload: {
8000
+ ...chunk,
8001
+ runId: stepId
8002
+ },
8003
+ from: "NETWORK" /* NETWORK */,
8004
+ runId
7833
8005
  });
7834
8006
  }
7835
8007
  const memory = await agent.getMemory({ requestContext });
@@ -7865,10 +8037,11 @@ ${completionResult?.object?.finalResult}` : ""}
7865
8037
  });
7866
8038
  const endPayload = {
7867
8039
  task: inputData.task,
7868
- agentId: inputData.primitiveId,
8040
+ agentId,
7869
8041
  result: await result.text,
7870
8042
  isComplete: false,
7871
- iteration: inputData.iteration
8043
+ iteration: inputData.iteration,
8044
+ runId: stepId
7872
8045
  };
7873
8046
  await writer.write({
7874
8047
  type: "agent-execution-end",
@@ -7937,11 +8110,12 @@ ${completionResult?.object?.finalResult}` : ""}
7937
8110
  );
7938
8111
  throw mastraError;
7939
8112
  }
8113
+ const stepId = generateId3();
7940
8114
  const run = await wf.createRun({ runId });
7941
8115
  const toolData = {
7942
- name: wf.name,
8116
+ workflowId: wf.id,
7943
8117
  args: inputData,
7944
- runId
8118
+ runId: stepId
7945
8119
  };
7946
8120
  await writer?.write({
7947
8121
  type: "workflow-execution-start",
@@ -7954,13 +8128,16 @@ ${completionResult?.object?.finalResult}` : ""}
7954
8128
  requestContext
7955
8129
  });
7956
8130
  let chunks = [];
7957
- for await (const chunk of stream) {
8131
+ for await (const chunk of stream.fullStream) {
7958
8132
  chunks.push(chunk);
7959
8133
  await writer?.write({
7960
8134
  type: `workflow-execution-event-${chunk.type}`,
7961
- payload: chunk,
7962
- runId: chunk.runId,
7963
- from: "NETWORK" /* NETWORK */
8135
+ payload: {
8136
+ ...chunk,
8137
+ runId: stepId
8138
+ },
8139
+ from: "NETWORK" /* NETWORK */,
8140
+ runId
7964
8141
  });
7965
8142
  }
7966
8143
  let runSuccess = true;
@@ -8002,13 +8179,15 @@ ${completionResult?.object?.finalResult}` : ""}
8002
8179
  primitiveType: inputData.primitiveType,
8003
8180
  result: finalResult,
8004
8181
  isComplete: false,
8005
- iteration: inputData.iteration,
8006
- name: wf.name
8182
+ iteration: inputData.iteration
8007
8183
  };
8008
8184
  await writer?.write({
8009
8185
  type: "workflow-execution-end",
8010
8186
  payload: {
8011
8187
  ...endPayload,
8188
+ result: workflowState,
8189
+ name: wf.name,
8190
+ runId: stepId,
8012
8191
  usage: await stream.usage
8013
8192
  },
8014
8193
  from: "NETWORK" /* NETWORK */,
@@ -8043,14 +8222,13 @@ ${completionResult?.object?.finalResult}` : ""}
8043
8222
  const memory = await agent.getMemory({ requestContext });
8044
8223
  const memoryTools = await memory?.listTools?.();
8045
8224
  const toolsMap = { ...agentTools, ...memoryTools };
8046
- const toolId = inputData.primitiveId;
8047
- let tool = toolsMap[toolId];
8225
+ let tool = toolsMap[inputData.primitiveId];
8048
8226
  if (!tool) {
8049
8227
  const mastraError = new chunkTWH4PTDG_cjs.MastraError({
8050
8228
  id: "AGENT_NETWORK_TOOL_EXECUTION_STEP_INVALID_TASK_INPUT",
8051
8229
  domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
8052
8230
  category: "USER" /* USER */,
8053
- text: `Tool ${toolId} not found`
8231
+ text: `Tool ${inputData.primitiveId} not found`
8054
8232
  });
8055
8233
  throw mastraError;
8056
8234
  }
@@ -8059,10 +8237,11 @@ ${completionResult?.object?.finalResult}` : ""}
8059
8237
  id: "AGENT_NETWORK_TOOL_EXECUTION_STEP_INVALID_TASK_INPUT",
8060
8238
  domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
8061
8239
  category: "USER" /* USER */,
8062
- text: `Tool ${toolId} does not have an execute function`
8240
+ text: `Tool ${inputData.primitiveId} does not have an execute function`
8063
8241
  });
8064
8242
  throw mastraError;
8065
8243
  }
8244
+ const toolId = tool.id;
8066
8245
  let inputDataToUse;
8067
8246
  try {
8068
8247
  inputDataToUse = JSON.parse(inputData.prompt);
@@ -8911,7 +9090,7 @@ var AgentLegacyHandler = class {
8911
9090
  writableStream,
8912
9091
  methodType: methodType === "generate" ? "generateLegacy" : "streamLegacy"
8913
9092
  });
8914
- const messageList = new chunkG36A2JRR_cjs.MessageList({
9093
+ const messageList = new chunkDQIZ5FFX_cjs.MessageList({
8915
9094
  threadId,
8916
9095
  resourceId,
8917
9096
  generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
@@ -8992,7 +9171,7 @@ var AgentLegacyHandler = class {
8992
9171
  existingThread || hasResourceScopeSemanticRecall ? this.capabilities.getMemoryMessages({
8993
9172
  resourceId,
8994
9173
  threadId: threadObject.id,
8995
- vectorMessageSearch: new chunkG36A2JRR_cjs.MessageList().add(messages, `user`).getLatestUserContent() || "",
9174
+ vectorMessageSearch: new chunkDQIZ5FFX_cjs.MessageList().add(messages, `user`).getLatestUserContent() || "",
8996
9175
  memoryConfig,
8997
9176
  requestContext
8998
9177
  }) : { messages: [] },
@@ -9014,7 +9193,7 @@ The following messages were remembered from a different conversation:
9014
9193
  <remembered_from_other_conversation>
9015
9194
  ${(() => {
9016
9195
  let result = ``;
9017
- const messages2 = new chunkG36A2JRR_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
9196
+ const messages2 = new chunkDQIZ5FFX_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
9018
9197
  let lastYmd = null;
9019
9198
  for (const msg of messages2) {
9020
9199
  const date = msg.createdAt;
@@ -9065,7 +9244,7 @@ the following messages are from ${ymd}
9065
9244
  systemMessage,
9066
9245
  memorySystemMessage: memorySystemMessage || void 0
9067
9246
  });
9068
- const processedList = new chunkG36A2JRR_cjs.MessageList({
9247
+ const processedList = new chunkDQIZ5FFX_cjs.MessageList({
9069
9248
  threadId: threadObject.id,
9070
9249
  resourceId,
9071
9250
  generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
@@ -9121,7 +9300,7 @@ the following messages are from ${ymd}
9121
9300
  result: resToLog,
9122
9301
  threadId
9123
9302
  });
9124
- const messageListResponses = new chunkG36A2JRR_cjs.MessageList({
9303
+ const messageListResponses = new chunkDQIZ5FFX_cjs.MessageList({
9125
9304
  threadId,
9126
9305
  resourceId,
9127
9306
  generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
@@ -9481,7 +9660,7 @@ the following messages are from ${ymd}
9481
9660
  requestContext: mergedGenerateOptions.requestContext || new chunkJ7O6WENZ_cjs.RequestContext(),
9482
9661
  tracingContext,
9483
9662
  outputProcessorOverrides: finalOutputProcessors,
9484
- messageList: new chunkG36A2JRR_cjs.MessageList({
9663
+ messageList: new chunkDQIZ5FFX_cjs.MessageList({
9485
9664
  threadId: llmOptions.threadId || "",
9486
9665
  resourceId: llmOptions.resourceId || ""
9487
9666
  }).add(
@@ -9571,7 +9750,7 @@ the following messages are from ${ymd}
9571
9750
  const outputProcessorResult = await this.capabilities.__runOutputProcessors({
9572
9751
  requestContext: mergedGenerateOptions.requestContext || new chunkJ7O6WENZ_cjs.RequestContext(),
9573
9752
  tracingContext,
9574
- messageList: new chunkG36A2JRR_cjs.MessageList({
9753
+ messageList: new chunkDQIZ5FFX_cjs.MessageList({
9575
9754
  threadId: llmOptions.threadId || "",
9576
9755
  resourceId: llmOptions.resourceId || ""
9577
9756
  }).add(
@@ -11874,6 +12053,7 @@ function createMapResultsStep({
11874
12053
  stopWhen: result.stopWhen,
11875
12054
  maxSteps: result.maxSteps,
11876
12055
  providerOptions: result.providerOptions,
12056
+ includeRawChunks: options.includeRawChunks,
11877
12057
  options: {
11878
12058
  ...options.prepareStep && { prepareStep: options.prepareStep },
11879
12059
  onFinish: async (payload) => {
@@ -11966,7 +12146,7 @@ var prepareToolsStepOutputSchema = z5.z.object({
11966
12146
  var prepareMemoryStepOutputSchema = z5.z.object({
11967
12147
  threadExists: z5.z.boolean(),
11968
12148
  thread: storageThreadSchema.optional(),
11969
- messageList: z5.z.instanceof(chunkG36A2JRR_cjs.MessageList),
12149
+ messageList: z5.z.instanceof(chunkDQIZ5FFX_cjs.MessageList),
11970
12150
  tripwire: z5.z.boolean().optional(),
11971
12151
  tripwireReason: z5.z.string().optional()
11972
12152
  });
@@ -11999,7 +12179,7 @@ function createPrepareMemoryStep({
11999
12179
  outputSchema: prepareMemoryStepOutputSchema,
12000
12180
  execute: async ({ tracingContext }) => {
12001
12181
  const thread = threadFromArgs;
12002
- const messageList = new chunkG36A2JRR_cjs.MessageList({
12182
+ const messageList = new chunkDQIZ5FFX_cjs.MessageList({
12003
12183
  threadId: thread?.id,
12004
12184
  resourceId,
12005
12185
  generateMessageId: capabilities.generateMessageId,
@@ -12080,7 +12260,7 @@ function createPrepareMemoryStep({
12080
12260
  existingThread || hasResourceScopeSemanticRecall ? capabilities.getMemoryMessages({
12081
12261
  resourceId,
12082
12262
  threadId: threadObject.id,
12083
- vectorMessageSearch: new chunkG36A2JRR_cjs.MessageList().add(options.messages, `user`).getLatestUserContent() || "",
12263
+ vectorMessageSearch: new chunkDQIZ5FFX_cjs.MessageList().add(options.messages, `user`).getLatestUserContent() || "",
12084
12264
  memoryConfig,
12085
12265
  requestContext
12086
12266
  }) : { messages: [] },
@@ -12106,7 +12286,7 @@ The following messages were remembered from a different conversation:
12106
12286
  <remembered_from_other_conversation>
12107
12287
  ${(() => {
12108
12288
  let result = ``;
12109
- const messages = new chunkG36A2JRR_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
12289
+ const messages = new chunkDQIZ5FFX_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1();
12110
12290
  let lastYmd = null;
12111
12291
  for (const msg of messages) {
12112
12292
  const date = msg.createdAt;
@@ -12153,7 +12333,7 @@ the following messages are from ${ymd}
12153
12333
  systemMessage,
12154
12334
  memorySystemMessage: memorySystemMessage || void 0
12155
12335
  });
12156
- const processedList = new chunkG36A2JRR_cjs.MessageList({
12336
+ const processedList = new chunkDQIZ5FFX_cjs.MessageList({
12157
12337
  threadId: threadObject.id,
12158
12338
  resourceId,
12159
12339
  generateMessageId: capabilities.generateMessageId,
@@ -12229,7 +12409,11 @@ function createStreamStep({
12229
12409
  resumeContext,
12230
12410
  agentId,
12231
12411
  toolCallId,
12232
- methodType
12412
+ methodType,
12413
+ saveQueueManager,
12414
+ memoryConfig,
12415
+ memory,
12416
+ resourceId
12233
12417
  }) {
12234
12418
  return createStep({
12235
12419
  id: "stream-text-step",
@@ -12256,7 +12440,12 @@ function createStreamStep({
12256
12440
  requireToolApproval,
12257
12441
  resumeContext,
12258
12442
  _internal: {
12259
- generateId: capabilities.generateMessageId
12443
+ generateId: capabilities.generateMessageId,
12444
+ saveQueueManager,
12445
+ memoryConfig,
12446
+ threadId: validatedInputData.threadId,
12447
+ resourceId,
12448
+ memory
12260
12449
  },
12261
12450
  agentId,
12262
12451
  toolCallId,
@@ -12317,7 +12506,11 @@ function createPrepareStreamWorkflow({
12317
12506
  resumeContext,
12318
12507
  agentId,
12319
12508
  toolCallId,
12320
- methodType
12509
+ methodType,
12510
+ saveQueueManager,
12511
+ memoryConfig,
12512
+ memory,
12513
+ resourceId
12321
12514
  });
12322
12515
  const mapResultsStep = createMapResultsStep({
12323
12516
  capabilities,
@@ -12474,7 +12667,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
12474
12667
  this.#voice?.addInstructions(config.instructions);
12475
12668
  }
12476
12669
  } else {
12477
- this.#voice = new chunkQUKUN6NR_cjs.DefaultVoice();
12670
+ this.#voice = new chunkISMGVGUM_cjs.DefaultVoice();
12478
12671
  }
12479
12672
  if (config.inputProcessors) {
12480
12673
  this.#inputProcessors = config.inputProcessors;
@@ -12721,7 +12914,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
12721
12914
  voice?.addInstructions(this.#convertInstructionsToString(instructions));
12722
12915
  return voice;
12723
12916
  } else {
12724
- return new chunkQUKUN6NR_cjs.DefaultVoice();
12917
+ return new chunkISMGVGUM_cjs.DefaultVoice();
12725
12918
  }
12726
12919
  }
12727
12920
  /**
@@ -12942,7 +13135,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
12942
13135
  */
12943
13136
  listTools({ requestContext = new chunkJ7O6WENZ_cjs.RequestContext() } = {}) {
12944
13137
  if (typeof this.#tools !== "function") {
12945
- return chunkHBJPYQRN_cjs.ensureToolProperties(this.#tools);
13138
+ return chunkRROQ46B6_cjs.ensureToolProperties(this.#tools);
12946
13139
  }
12947
13140
  const result = this.#tools({ requestContext, mastra: this.#mastra });
12948
13141
  return resolveMaybePromise(result, (tools) => {
@@ -12960,7 +13153,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
12960
13153
  this.logger.error(mastraError.toString());
12961
13154
  throw mastraError;
12962
13155
  }
12963
- return chunkHBJPYQRN_cjs.ensureToolProperties(tools);
13156
+ return chunkRROQ46B6_cjs.ensureToolProperties(tools);
12964
13157
  });
12965
13158
  }
12966
13159
  /**
@@ -12992,7 +13185,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
12992
13185
  });
12993
13186
  });
12994
13187
  } else {
12995
- llm = new chunkO6NA3Z43_cjs.MastraLLMV1({
13188
+ llm = new chunkOUUPUAGA_cjs.MastraLLMV1({
12996
13189
  model: resolvedModel,
12997
13190
  mastra: this.#mastra,
12998
13191
  options: { tracingPolicy: this.#options?.tracingPolicy }
@@ -13017,7 +13210,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13017
13210
  */
13018
13211
  async resolveModelConfig(modelConfig, requestContext) {
13019
13212
  try {
13020
- return await chunkN4SJ4YX7_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
13213
+ return await chunkNHP6ZIDG_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
13021
13214
  } catch (error) {
13022
13215
  const mastraError = new chunkTWH4PTDG_cjs.MastraError({
13023
13216
  id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
@@ -13223,7 +13416,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13223
13416
  instructions
13224
13417
  }) {
13225
13418
  const llm = await this.getLLM({ requestContext, model });
13226
- const normMessage = new chunkG36A2JRR_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
13419
+ const normMessage = new chunkDQIZ5FFX_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
13227
13420
  if (!normMessage) {
13228
13421
  throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
13229
13422
  }
@@ -13246,7 +13439,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13246
13439
  const systemInstructions = await this.resolveTitleInstructions(requestContext, instructions);
13247
13440
  let text = "";
13248
13441
  if (llm.getModel().specificationVersion === "v2") {
13249
- const messageList = new chunkG36A2JRR_cjs.MessageList().add(
13442
+ const messageList = new chunkDQIZ5FFX_cjs.MessageList().add(
13250
13443
  [
13251
13444
  {
13252
13445
  role: "system",
@@ -13298,7 +13491,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13298
13491
  async genTitle(userMessage, requestContext, tracingContext, model, instructions) {
13299
13492
  try {
13300
13493
  if (userMessage) {
13301
- const normMessage = new chunkG36A2JRR_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
13494
+ const normMessage = new chunkDQIZ5FFX_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
13302
13495
  if (normMessage) {
13303
13496
  return await this.generateTitleFromUserMessage({
13304
13497
  message: normMessage,
@@ -13358,9 +13551,10 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13358
13551
  requestContext,
13359
13552
  tracingContext,
13360
13553
  model: await this.getModel({ requestContext }),
13361
- tracingPolicy: this.#options?.tracingPolicy
13554
+ tracingPolicy: this.#options?.tracingPolicy,
13555
+ requireApproval: toolObj.requireApproval
13362
13556
  };
13363
- const convertedToCoreTool = chunkHBJPYQRN_cjs.makeCoreTool(toolObj, options);
13557
+ const convertedToCoreTool = chunkRROQ46B6_cjs.makeCoreTool(toolObj, options);
13364
13558
  convertedMemoryTools[toolName] = convertedToCoreTool;
13365
13559
  }
13366
13560
  }
@@ -13510,7 +13704,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13510
13704
  tracingPolicy: this.#options?.tracingPolicy,
13511
13705
  requireApproval: tool.requireApproval
13512
13706
  };
13513
- return [k, chunkHBJPYQRN_cjs.makeCoreTool(tool, options)];
13707
+ return [k, chunkRROQ46B6_cjs.makeCoreTool(tool, options)];
13514
13708
  })
13515
13709
  );
13516
13710
  const assignedToolEntriesConverted = Object.fromEntries(
@@ -13556,9 +13750,10 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13556
13750
  requestContext,
13557
13751
  tracingContext,
13558
13752
  model: await this.getModel({ requestContext }),
13559
- tracingPolicy: this.#options?.tracingPolicy
13753
+ tracingPolicy: this.#options?.tracingPolicy,
13754
+ requireApproval: toolObj.requireApproval
13560
13755
  };
13561
- const convertedToCoreTool = chunkHBJPYQRN_cjs.makeCoreTool(toolObj, options, "toolset");
13756
+ const convertedToCoreTool = chunkRROQ46B6_cjs.makeCoreTool(toolObj, options, "toolset");
13562
13757
  toolsForRequest[toolName] = convertedToCoreTool;
13563
13758
  }
13564
13759
  }
@@ -13599,9 +13794,10 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13599
13794
  requestContext,
13600
13795
  tracingContext,
13601
13796
  model: await this.getModel({ requestContext }),
13602
- tracingPolicy: this.#options?.tracingPolicy
13797
+ tracingPolicy: this.#options?.tracingPolicy,
13798
+ requireApproval: tool.requireApproval
13603
13799
  };
13604
- const convertedToCoreTool = chunkHBJPYQRN_cjs.makeCoreTool(rest, options, "client-tool");
13800
+ const convertedToCoreTool = chunkRROQ46B6_cjs.makeCoreTool(rest, options, "client-tool");
13605
13801
  toolsForRequest[toolName] = convertedToCoreTool;
13606
13802
  }
13607
13803
  }
@@ -13624,7 +13820,11 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13624
13820
  if (Object.keys(agents).length > 0) {
13625
13821
  for (const [agentName, agent] of Object.entries(agents)) {
13626
13822
  const agentInputSchema = z5.z.object({
13627
- prompt: z5.z.string().describe("The prompt to send to the agent")
13823
+ prompt: z5.z.string().describe("The prompt to send to the agent"),
13824
+ threadId: z5.z.string().optional().describe("Thread ID for conversation continuity for memory messages"),
13825
+ resourceId: z5.z.string().optional().describe("Resource/user identifier for memory messages"),
13826
+ instructions: z5.z.string().optional().describe("Custom instructions to override agent defaults"),
13827
+ maxSteps: z5.z.number().optional().describe("Maximum number of execution steps for the sub-agent")
13628
13828
  });
13629
13829
  const agentOutputSchema = z5.z.object({
13630
13830
  text: z5.z.string().describe("The response from the agent"),
@@ -13632,13 +13832,12 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13632
13832
  subAgentResourceId: z5.z.string().describe("The resource ID of the agent").optional()
13633
13833
  });
13634
13834
  const modelVersion = (await agent.getModel()).specificationVersion;
13635
- const toolObj = chunk4IKJAKCD_cjs.createTool({
13835
+ const toolObj = chunkV537VSV4_cjs.createTool({
13636
13836
  id: `agent-${agentName}`,
13637
13837
  description: `Agent: ${agentName}`,
13638
13838
  inputSchema: agentInputSchema,
13639
13839
  outputSchema: agentOutputSchema,
13640
13840
  mastra: this.#mastra,
13641
- // BREAKING CHANGE v1.0: New tool signature - first param is inputData, second is context
13642
13841
  // manually wrap agent tools with tracing, so that we can pass the
13643
13842
  // current tool span onto the agent to maintain continuity of the trace
13644
13843
  execute: async (inputData, context) => {
@@ -13651,16 +13850,18 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13651
13850
  resourceId
13652
13851
  });
13653
13852
  let result;
13853
+ const slugify = await import('@sindresorhus/slugify');
13854
+ const subAgentThreadId = inputData.threadId || context?.mastra?.generateId() || crypto2.randomUUID();
13855
+ const subAgentResourceId = inputData.resourceId || context?.mastra?.generateId() || `${slugify.default(this.id)}-${agentName}`;
13654
13856
  if ((methodType === "generate" || methodType === "generateLegacy") && modelVersion === "v2") {
13655
13857
  if (!agent.hasOwnMemory() && this.#memory) {
13656
13858
  agent.__setMemory(this.#memory);
13657
13859
  }
13658
- const subAgentThreadId = crypto2.randomUUID();
13659
- const slugify = await import('@sindresorhus/slugify');
13660
- const subAgentResourceId = `${slugify.default(this.id)}-${agentName}`;
13661
13860
  const generateResult = await agent.generate(inputData.prompt, {
13662
13861
  requestContext,
13663
13862
  tracingContext: context?.tracingContext,
13863
+ ...inputData.instructions && { instructions: inputData.instructions },
13864
+ ...inputData.maxSteps && { maxSteps: inputData.maxSteps },
13664
13865
  ...resourceId && threadId ? {
13665
13866
  memory: {
13666
13867
  resource: subAgentResourceId,
@@ -13679,12 +13880,11 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13679
13880
  if (!agent.hasOwnMemory() && this.#memory) {
13680
13881
  agent.__setMemory(this.#memory);
13681
13882
  }
13682
- const subAgentThreadId = crypto2.randomUUID();
13683
- const slugify = await import('@sindresorhus/slugify');
13684
- const subAgentResourceId = `${slugify.default(this.id)}-${agentName}`;
13685
13883
  const streamResult = await agent.stream(inputData.prompt, {
13686
13884
  requestContext,
13687
13885
  tracingContext: context?.tracingContext,
13886
+ ...inputData.instructions && { instructions: inputData.instructions },
13887
+ ...inputData.maxSteps && { maxSteps: inputData.maxSteps },
13688
13888
  ...resourceId && threadId ? {
13689
13889
  memory: {
13690
13890
  resource: subAgentResourceId,
@@ -13695,7 +13895,11 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13695
13895
  let fullText = "";
13696
13896
  for await (const chunk of streamResult.fullStream) {
13697
13897
  if (context?.writer) {
13698
- await context.writer.write(chunk);
13898
+ if (chunk.type.startsWith("data-")) {
13899
+ await context.writer.custom(chunk);
13900
+ } else {
13901
+ await context.writer.write(chunk);
13902
+ }
13699
13903
  }
13700
13904
  if (chunk.type === "text-delta") {
13701
13905
  fullText += chunk.payload.text;
@@ -13710,7 +13914,11 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13710
13914
  let fullText = "";
13711
13915
  for await (const chunk of streamResult.fullStream) {
13712
13916
  if (context?.writer) {
13713
- await context.writer.write(chunk);
13917
+ if (chunk.type.startsWith("data-")) {
13918
+ await context.writer.custom(chunk);
13919
+ } else {
13920
+ await context.writer.write(chunk);
13921
+ }
13714
13922
  }
13715
13923
  if (chunk.type === "text-delta") {
13716
13924
  fullText += chunk.textDelta;
@@ -13756,7 +13964,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13756
13964
  tracingContext,
13757
13965
  tracingPolicy: this.#options?.tracingPolicy
13758
13966
  };
13759
- convertedAgentTools[`agent-${agentName}`] = chunkHBJPYQRN_cjs.makeCoreTool(toolObj, options);
13967
+ convertedAgentTools[`agent-${agentName}`] = chunkRROQ46B6_cjs.makeCoreTool(toolObj, options);
13760
13968
  }
13761
13969
  }
13762
13970
  return convertedAgentTools;
@@ -13777,13 +13985,25 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13777
13985
  const workflows = await this.listWorkflows({ requestContext });
13778
13986
  if (Object.keys(workflows).length > 0) {
13779
13987
  for (const [workflowName, workflow] of Object.entries(workflows)) {
13780
- const toolObj = chunk4IKJAKCD_cjs.createTool({
13988
+ const extendedInputSchema = z5.z.object({
13989
+ inputData: workflow.inputSchema,
13990
+ ...workflow.stateSchema ? { initialState: workflow.stateSchema } : {}
13991
+ });
13992
+ const toolObj = chunkV537VSV4_cjs.createTool({
13781
13993
  id: `workflow-${workflowName}`,
13782
13994
  description: workflow.description || `Workflow: ${workflowName}`,
13783
- inputSchema: workflow.inputSchema,
13784
- outputSchema: z5.z.object({ result: workflow.outputSchema, runId: z5.z.string() }),
13995
+ inputSchema: extendedInputSchema,
13996
+ outputSchema: z5.z.union([
13997
+ z5.z.object({
13998
+ result: workflow.outputSchema,
13999
+ runId: z5.z.string().describe("Unique identifier for the workflow run")
14000
+ }),
14001
+ z5.z.object({
14002
+ runId: z5.z.string().describe("Unique identifier for the workflow run"),
14003
+ error: z5.z.string().describe("Error message if workflow execution failed")
14004
+ })
14005
+ ]),
13785
14006
  mastra: this.#mastra,
13786
- // BREAKING CHANGE v1.0: New tool signature - first param is inputData, second is context
13787
14007
  // manually wrap workflow tools with tracing, so that we can pass the
13788
14008
  // current tool span onto the workflow to maintain continuity of the trace
13789
14009
  execute: async (inputData, context) => {
@@ -13797,16 +14017,18 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13797
14017
  resourceId
13798
14018
  });
13799
14019
  const run = await workflow.createRun();
13800
- let result;
14020
+ const { initialState, inputData: workflowInputData } = inputData;
14021
+ let result = void 0;
13801
14022
  if (methodType === "generate" || methodType === "generateLegacy") {
13802
14023
  result = await run.start({
13803
- inputData,
14024
+ inputData: workflowInputData,
13804
14025
  requestContext,
13805
- tracingContext: context?.tracingContext
14026
+ tracingContext: context?.tracingContext,
14027
+ ...initialState && { initialState }
13806
14028
  });
13807
14029
  } else if (methodType === "streamLegacy") {
13808
14030
  const streamResult = run.streamLegacy({
13809
- inputData,
14031
+ inputData: workflowInputData,
13810
14032
  requestContext,
13811
14033
  tracingContext: context?.tracingContext
13812
14034
  });
@@ -13819,17 +14041,36 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13819
14041
  result = await streamResult.getWorkflowState();
13820
14042
  } else if (methodType === "stream") {
13821
14043
  const streamResult = run.stream({
13822
- inputData,
14044
+ inputData: workflowInputData,
13823
14045
  requestContext,
13824
- tracingContext: context?.tracingContext
14046
+ tracingContext: context?.tracingContext,
14047
+ ...initialState && { initialState }
13825
14048
  });
13826
14049
  if (context?.writer) {
13827
14050
  await streamResult.fullStream.pipeTo(context.writer);
13828
14051
  }
13829
14052
  result = await streamResult.result;
13830
14053
  }
13831
- const workflowOutput = result?.result || result;
13832
- return { result: workflowOutput, runId: run.runId };
14054
+ if (result?.status === "success") {
14055
+ const workflowOutput = result?.result || result;
14056
+ return { result: workflowOutput, runId: run.runId };
14057
+ } else if (result?.status === "failed") {
14058
+ const workflowOutputError = result?.error;
14059
+ return {
14060
+ error: workflowOutputError?.message || String(workflowOutputError) || "Workflow execution failed",
14061
+ runId: run.runId
14062
+ };
14063
+ } else if (result?.status === "suspended") {
14064
+ return {
14065
+ error: `Workflow ended with status: "suspended". This is not currently handled in the basic agent workflow tool transformation. To achieve this you'll need to write your own tool that uses a workflow internally.`,
14066
+ runId: run.runId
14067
+ };
14068
+ } else {
14069
+ return {
14070
+ error: `Workflow should never reach this path, workflow returned no status`,
14071
+ runId: run.runId
14072
+ };
14073
+ }
13833
14074
  } catch (err) {
13834
14075
  const mastraError = new chunkTWH4PTDG_cjs.MastraError(
13835
14076
  {
@@ -13866,7 +14107,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13866
14107
  tracingContext,
13867
14108
  tracingPolicy: this.#options?.tracingPolicy
13868
14109
  };
13869
- convertedWorkflowTools[`workflow-${workflowName}`] = chunkHBJPYQRN_cjs.makeCoreTool(toolObj, options);
14110
+ convertedWorkflowTools[`workflow-${workflowName}`] = chunkRROQ46B6_cjs.makeCoreTool(toolObj, options);
13870
14111
  }
13871
14112
  }
13872
14113
  return convertedWorkflowTools;
@@ -13889,7 +14130,7 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
13889
14130
  let mastraProxy = void 0;
13890
14131
  const logger = this.logger;
13891
14132
  if (this.#mastra) {
13892
- mastraProxy = chunkHBJPYQRN_cjs.createMastraProxy({ mastra: this.#mastra, logger });
14133
+ mastraProxy = chunkRROQ46B6_cjs.createMastraProxy({ mastra: this.#mastra, logger });
13893
14134
  }
13894
14135
  const assignedTools = await this.listAssignedTools({
13895
14136
  runId,
@@ -14204,6 +14445,34 @@ var Agent = class extends chunkKEXGB7FK_cjs.MastraBase {
14204
14445
  );
14205
14446
  }
14206
14447
  const llm = await this.getLLM({ requestContext, model: options.model });
14448
+ if ("structuredOutput" in options && options.structuredOutput && options.structuredOutput.schema) {
14449
+ let structuredOutputModel = llm.getModel();
14450
+ if (options.structuredOutput?.model) {
14451
+ structuredOutputModel = await this.resolveModelConfig(
14452
+ options.structuredOutput?.model,
14453
+ requestContext
14454
+ );
14455
+ }
14456
+ const targetProvider = structuredOutputModel.provider;
14457
+ const targetModelId = structuredOutputModel.modelId;
14458
+ if (targetProvider.includes("openai") || targetModelId.includes("openai")) {
14459
+ if (chunkRROQ46B6_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
14460
+ const modelInfo = {
14461
+ provider: targetProvider,
14462
+ modelId: targetModelId,
14463
+ supportsStructuredOutputs: false
14464
+ // Set to false to enable transform
14465
+ };
14466
+ const isReasoningModel = /^o[1-5]/.test(targetModelId);
14467
+ const compatLayer = isReasoningModel ? new schemaCompat.OpenAIReasoningSchemaCompatLayer(modelInfo) : new schemaCompat.OpenAISchemaCompatLayer(modelInfo);
14468
+ if (compatLayer.shouldApply() && options.structuredOutput.schema) {
14469
+ options.structuredOutput.schema = compatLayer.processZodType(
14470
+ options.structuredOutput.schema
14471
+ );
14472
+ }
14473
+ }
14474
+ }
14475
+ }
14207
14476
  const runId = options.runId || this.#mastra?.generateId() || crypto2.randomUUID();
14208
14477
  const instructions = options.instructions || await this.getInstructions({ requestContext });
14209
14478
  const agentSpan = chunkE7K4FTLN_cjs.getOrCreateSpan({
@@ -15924,7 +16193,7 @@ var MastraModelOutput = class extends chunkKEXGB7FK_cjs.MastraBase {
15924
16193
  self.messageList,
15925
16194
  options.tracingContext
15926
16195
  );
15927
- const outputText = self.messageList.get.response.aiV4.core().map((m) => chunkG36A2JRR_cjs.MessageList.coreContentToString(m.content)).join("\n");
16196
+ const outputText = self.messageList.get.response.aiV4.core().map((m) => chunkDQIZ5FFX_cjs.MessageList.coreContentToString(m.content)).join("\n");
15928
16197
  self.#delayedPromises.text.resolve(outputText);
15929
16198
  self.#delayedPromises.finishReason.resolve(self.#finishReason);
15930
16199
  if (chunk.payload.metadata) {
@@ -16561,5 +16830,6 @@ exports.tryGenerateWithJsonFallback = tryGenerateWithJsonFallback;
16561
16830
  exports.tryStreamWithJsonFallback = tryStreamWithJsonFallback;
16562
16831
  exports.validateStepInput = validateStepInput;
16563
16832
  exports.validateStepResumeData = validateStepResumeData;
16564
- //# sourceMappingURL=chunk-OWX2PUFH.cjs.map
16565
- //# sourceMappingURL=chunk-OWX2PUFH.cjs.map
16833
+ exports.validateStepSuspendData = validateStepSuspendData;
16834
+ //# sourceMappingURL=chunk-KP42JLXE.cjs.map
16835
+ //# sourceMappingURL=chunk-KP42JLXE.cjs.map