@mastra/core 1.4.0 → 1.5.0-alpha.1

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 (369) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/dist/agent/agent.d.ts +3 -2
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/index.cjs +13 -13
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
  7. package/dist/agent/message-list/index.cjs +18 -18
  8. package/dist/agent/message-list/index.js +1 -1
  9. package/dist/agent/message-list/merge/MessageMerger.d.ts.map +1 -1
  10. package/dist/agent/message-list/message-list.d.ts.map +1 -1
  11. package/dist/agent/types.d.ts +2 -2
  12. package/dist/agent/types.d.ts.map +1 -1
  13. package/dist/agent/workflows/prepare-stream/index.d.ts +1 -0
  14. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  15. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +1 -0
  16. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
  17. package/dist/agent/workflows/prepare-stream/schema.d.ts +8 -0
  18. package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
  19. package/dist/{chunk-Y3TQ52UE.js → chunk-33TGTTTS.js} +4 -3
  20. package/dist/chunk-33TGTTTS.js.map +1 -0
  21. package/dist/{chunk-3X3CZUXI.js → chunk-3KJW4EMO.js} +660 -206
  22. package/dist/chunk-3KJW4EMO.js.map +1 -0
  23. package/dist/{chunk-YNNJLLFN.cjs → chunk-3YMDR4OL.cjs} +661 -207
  24. package/dist/chunk-3YMDR4OL.cjs.map +1 -0
  25. package/dist/{chunk-NJ7TL3LQ.js → chunk-5EOLBHHS.js} +26 -15
  26. package/dist/chunk-5EOLBHHS.js.map +1 -0
  27. package/dist/{chunk-RZ4CIIZR.js → chunk-6DUTLERJ.js} +4 -4
  28. package/dist/{chunk-RZ4CIIZR.js.map → chunk-6DUTLERJ.js.map} +1 -1
  29. package/dist/{chunk-VTE2OBKS.cjs → chunk-A6EWCOGA.cjs} +417 -77
  30. package/dist/chunk-A6EWCOGA.cjs.map +1 -0
  31. package/dist/{chunk-4XSAZPPS.js → chunk-A7V2NSY3.js} +313 -137
  32. package/dist/chunk-A7V2NSY3.js.map +1 -0
  33. package/dist/{chunk-FLPEGTEK.js → chunk-AIRMLZ43.js} +5 -5
  34. package/dist/{chunk-FLPEGTEK.js.map → chunk-AIRMLZ43.js.map} +1 -1
  35. package/dist/{chunk-DBSVT6AR.cjs → chunk-BKQAP27M.cjs} +9 -9
  36. package/dist/{chunk-DBSVT6AR.cjs.map → chunk-BKQAP27M.cjs.map} +1 -1
  37. package/dist/{chunk-RS6CZXGA.js → chunk-BQHWJLXU.js} +15 -4
  38. package/dist/chunk-BQHWJLXU.js.map +1 -0
  39. package/dist/{chunk-V2MLGA7T.js → chunk-CXVMDV2B.js} +417 -78
  40. package/dist/chunk-CXVMDV2B.js.map +1 -0
  41. package/dist/{chunk-NKYWDNCI.cjs → chunk-E2FHTXAI.cjs} +7 -7
  42. package/dist/{chunk-NKYWDNCI.cjs.map → chunk-E2FHTXAI.cjs.map} +1 -1
  43. package/dist/{chunk-7UWHFWST.cjs → chunk-EAZ6YDCQ.cjs} +15 -3
  44. package/dist/chunk-EAZ6YDCQ.cjs.map +1 -0
  45. package/dist/{chunk-64WGYTQK.cjs → chunk-FTBLAVTF.cjs} +55 -55
  46. package/dist/{chunk-64WGYTQK.cjs.map → chunk-FTBLAVTF.cjs.map} +1 -1
  47. package/dist/{chunk-4EHGOATH.js → chunk-FZ5DRHKE.js} +1337 -547
  48. package/dist/chunk-FZ5DRHKE.js.map +1 -0
  49. package/dist/{chunk-4TQ4EBYX.js → chunk-GEDGDKQ6.js} +9 -9
  50. package/dist/chunk-GEDGDKQ6.js.map +1 -0
  51. package/dist/{chunk-QTTWRCB5.js → chunk-I3AWF54W.js} +5 -5
  52. package/dist/{chunk-QTTWRCB5.js.map → chunk-I3AWF54W.js.map} +1 -1
  53. package/dist/{chunk-U2HKJZCI.js → chunk-IBNCZTNQ.js} +6 -6
  54. package/dist/{chunk-U2HKJZCI.js.map → chunk-IBNCZTNQ.js.map} +1 -1
  55. package/dist/{chunk-3JVFFAJX.cjs → chunk-IJIE3ZID.cjs} +27 -16
  56. package/dist/chunk-IJIE3ZID.cjs.map +1 -0
  57. package/dist/{chunk-NZG2JAKS.cjs → chunk-JWG272ZZ.cjs} +19 -19
  58. package/dist/chunk-JWG272ZZ.cjs.map +1 -0
  59. package/dist/{chunk-BP7VYTOP.cjs → chunk-JZ6TH4HQ.cjs} +954 -401
  60. package/dist/chunk-JZ6TH4HQ.cjs.map +1 -0
  61. package/dist/{chunk-SU5APAM6.cjs → chunk-KNXZ7KYL.cjs} +94 -6
  62. package/dist/chunk-KNXZ7KYL.cjs.map +1 -0
  63. package/dist/{chunk-CYUP7QWT.cjs → chunk-KRAGJ433.cjs} +4 -3
  64. package/dist/chunk-KRAGJ433.cjs.map +1 -0
  65. package/dist/{chunk-XDD5V446.cjs → chunk-MDC6VYA6.cjs} +6 -2
  66. package/dist/{chunk-XDD5V446.cjs.map → chunk-MDC6VYA6.cjs.map} +1 -1
  67. package/dist/{chunk-AXHBJ4GX.js → chunk-NN26FSKL.js} +10 -8
  68. package/dist/chunk-NN26FSKL.js.map +1 -0
  69. package/dist/{chunk-AY6DBRS3.js → chunk-OHLVZVIK.js} +36 -2
  70. package/dist/chunk-OHLVZVIK.js.map +1 -0
  71. package/dist/{chunk-5Q5Y34SS.js → chunk-PECKKR4C.js} +4 -4
  72. package/dist/{chunk-5Q5Y34SS.js.map → chunk-PECKKR4C.js.map} +1 -1
  73. package/dist/{chunk-HYRYTTMT.cjs → chunk-PHHJLGZU.cjs} +9 -9
  74. package/dist/{chunk-HYRYTTMT.cjs.map → chunk-PHHJLGZU.cjs.map} +1 -1
  75. package/dist/{chunk-65PHUUMF.cjs → chunk-QDH6MVJ7.cjs} +24 -22
  76. package/dist/chunk-QDH6MVJ7.cjs.map +1 -0
  77. package/dist/{chunk-VD5YA6RH.cjs → chunk-QSN5KQXZ.cjs} +18 -18
  78. package/dist/{chunk-VD5YA6RH.cjs.map → chunk-QSN5KQXZ.cjs.map} +1 -1
  79. package/dist/{chunk-4IJ4UDZX.cjs → chunk-RH2K66O2.cjs} +399 -223
  80. package/dist/chunk-RH2K66O2.cjs.map +1 -0
  81. package/dist/{chunk-4KFEMXTV.cjs → chunk-S4VVZI4E.cjs} +1361 -546
  82. package/dist/chunk-S4VVZI4E.cjs.map +1 -0
  83. package/dist/{chunk-ZATLLPIH.js → chunk-TPDMP7OD.js} +6 -2
  84. package/dist/chunk-TPDMP7OD.js.map +1 -0
  85. package/dist/{chunk-PS5ONCXY.js → chunk-UZFGMMKU.js} +82 -4
  86. package/dist/chunk-UZFGMMKU.js.map +1 -0
  87. package/dist/{chunk-7NKUSQEV.js → chunk-YIN5F7VO.js} +936 -389
  88. package/dist/chunk-YIN5F7VO.js.map +1 -0
  89. package/dist/{chunk-CZ4NQANZ.cjs → chunk-YW54RH77.cjs} +36 -2
  90. package/dist/chunk-YW54RH77.cjs.map +1 -0
  91. package/dist/datasets/experiment/executor.d.ts.map +1 -1
  92. package/dist/datasets/index.cjs +17 -17
  93. package/dist/datasets/index.js +2 -2
  94. package/dist/docs/SKILL.md +27 -1
  95. package/dist/docs/assets/SOURCE_MAP.json +463 -389
  96. package/dist/docs/references/docs-agents-processors.md +52 -0
  97. package/dist/docs/references/docs-observability-datasets-overview.md +188 -0
  98. package/dist/docs/references/docs-observability-datasets-running-experiments.md +266 -0
  99. package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +7 -4
  100. package/dist/docs/references/reference-agents-generate.md +1 -1
  101. package/dist/docs/references/reference-configuration.md +3 -4
  102. package/dist/docs/references/reference-datasets-addItem.md +35 -0
  103. package/dist/docs/references/reference-datasets-addItems.md +33 -0
  104. package/dist/docs/references/reference-datasets-compareExperiments.md +48 -0
  105. package/dist/docs/references/reference-datasets-create.md +49 -0
  106. package/dist/docs/references/reference-datasets-dataset.md +78 -0
  107. package/dist/docs/references/reference-datasets-datasets-manager.md +84 -0
  108. package/dist/docs/references/reference-datasets-delete.md +23 -0
  109. package/dist/docs/references/reference-datasets-deleteExperiment.md +25 -0
  110. package/dist/docs/references/reference-datasets-deleteItem.md +25 -0
  111. package/dist/docs/references/reference-datasets-deleteItems.md +27 -0
  112. package/dist/docs/references/reference-datasets-get.md +29 -0
  113. package/dist/docs/references/reference-datasets-getDetails.md +45 -0
  114. package/dist/docs/references/reference-datasets-getExperiment.md +28 -0
  115. package/dist/docs/references/reference-datasets-getItem.md +31 -0
  116. package/dist/docs/references/reference-datasets-getItemHistory.md +29 -0
  117. package/dist/docs/references/reference-datasets-list.md +29 -0
  118. package/dist/docs/references/reference-datasets-listExperimentResults.md +37 -0
  119. package/dist/docs/references/reference-datasets-listExperiments.md +31 -0
  120. package/dist/docs/references/reference-datasets-listItems.md +44 -0
  121. package/dist/docs/references/reference-datasets-listVersions.md +31 -0
  122. package/dist/docs/references/reference-datasets-startExperiment.md +60 -0
  123. package/dist/docs/references/reference-datasets-startExperimentAsync.md +41 -0
  124. package/dist/docs/references/reference-datasets-update.md +46 -0
  125. package/dist/docs/references/reference-datasets-updateItem.md +36 -0
  126. package/dist/docs/references/reference-memory-observational-memory.md +36 -0
  127. package/dist/docs/references/reference-processors-processor-interface.md +4 -0
  128. package/dist/docs/references/reference-tools-create-tool.md +1 -1
  129. package/dist/docs/references/reference.md +24 -0
  130. package/dist/editor/index.d.ts +1 -1
  131. package/dist/editor/index.d.ts.map +1 -1
  132. package/dist/editor/types.d.ts +108 -2
  133. package/dist/editor/types.d.ts.map +1 -1
  134. package/dist/evals/index.cjs +20 -20
  135. package/dist/evals/index.js +3 -3
  136. package/dist/evals/scoreTraces/index.cjs +5 -5
  137. package/dist/evals/scoreTraces/index.js +2 -2
  138. package/dist/harness/harness.d.ts +281 -0
  139. package/dist/harness/harness.d.ts.map +1 -0
  140. package/dist/harness/index.cjs +1728 -0
  141. package/dist/harness/index.cjs.map +1 -0
  142. package/dist/harness/index.d.ts +4 -0
  143. package/dist/harness/index.d.ts.map +1 -0
  144. package/dist/harness/index.js +1723 -0
  145. package/dist/harness/index.js.map +1 -0
  146. package/dist/harness/tools.d.ts +65 -0
  147. package/dist/harness/tools.d.ts.map +1 -0
  148. package/dist/harness/types.d.ts +561 -0
  149. package/dist/harness/types.d.ts.map +1 -0
  150. package/dist/index.cjs +2 -2
  151. package/dist/index.js +1 -1
  152. package/dist/integration/index.cjs +2 -2
  153. package/dist/integration/index.js +1 -1
  154. package/dist/llm/index.cjs +20 -20
  155. package/dist/llm/index.js +3 -3
  156. package/dist/llm/model/gateways/constants.d.ts.map +1 -1
  157. package/dist/llm/model/gateways/models-dev.d.ts +2 -3
  158. package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
  159. package/dist/llm/model/provider-types.generated.d.ts +312 -93
  160. package/dist/loop/index.cjs +12 -12
  161. package/dist/loop/index.js +1 -1
  162. package/dist/loop/network/index.d.ts.map +1 -1
  163. package/dist/loop/test-utils/options.d.ts.map +1 -1
  164. package/dist/loop/test-utils/tools.d.ts.map +1 -1
  165. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  166. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  167. package/dist/loop/workflows/stream.d.ts.map +1 -1
  168. package/dist/mastra/index.cjs +2 -2
  169. package/dist/mastra/index.d.ts +3 -3
  170. package/dist/mastra/index.d.ts.map +1 -1
  171. package/dist/mastra/index.js +1 -1
  172. package/dist/memory/index.cjs +14 -14
  173. package/dist/memory/index.js +1 -1
  174. package/dist/memory/memory.d.ts +10 -0
  175. package/dist/memory/memory.d.ts.map +1 -1
  176. package/dist/memory/types.d.ts +24 -0
  177. package/dist/memory/types.d.ts.map +1 -1
  178. package/dist/models-dev-BW2GAM3K.cjs +12 -0
  179. package/dist/{models-dev-PPIXUUCU.cjs.map → models-dev-BW2GAM3K.cjs.map} +1 -1
  180. package/dist/models-dev-MDI5E2YA.js +3 -0
  181. package/dist/{models-dev-FQVUTQ7L.js.map → models-dev-MDI5E2YA.js.map} +1 -1
  182. package/dist/observability/index.cjs +11 -11
  183. package/dist/observability/index.js +1 -1
  184. package/dist/observability/utils.d.ts.map +1 -1
  185. package/dist/processors/index.cjs +41 -41
  186. package/dist/processors/index.js +1 -1
  187. package/dist/processors/processors/skills.d.ts +5 -0
  188. package/dist/processors/processors/skills.d.ts.map +1 -1
  189. package/dist/processors/runner.d.ts +2 -2
  190. package/dist/processors/runner.d.ts.map +1 -1
  191. package/dist/processors/step-schema.d.ts +218 -49453
  192. package/dist/processors/step-schema.d.ts.map +1 -1
  193. package/dist/provider-registry-4PH2JPIA.cjs +40 -0
  194. package/dist/{provider-registry-6LZAGQET.cjs.map → provider-registry-4PH2JPIA.cjs.map} +1 -1
  195. package/dist/provider-registry-VEJ3PN4S.js +3 -0
  196. package/dist/{provider-registry-QUNT7S55.js.map → provider-registry-VEJ3PN4S.js.map} +1 -1
  197. package/dist/provider-registry.json +657 -203
  198. package/dist/relevance/index.cjs +3 -3
  199. package/dist/relevance/index.js +1 -1
  200. package/dist/server/composite-auth.d.ts.map +1 -1
  201. package/dist/server/index.cjs +6 -1
  202. package/dist/server/index.cjs.map +1 -1
  203. package/dist/server/index.js +6 -1
  204. package/dist/server/index.js.map +1 -1
  205. package/dist/storage/base.d.ts +4 -1
  206. package/dist/storage/base.d.ts.map +1 -1
  207. package/dist/storage/constants.cjs +82 -42
  208. package/dist/storage/constants.d.ts +11 -1
  209. package/dist/storage/constants.d.ts.map +1 -1
  210. package/dist/storage/constants.js +1 -1
  211. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  212. package/dist/storage/domains/blobs/base.d.ts +47 -0
  213. package/dist/storage/domains/blobs/base.d.ts.map +1 -0
  214. package/dist/storage/domains/blobs/index.d.ts +3 -0
  215. package/dist/storage/domains/blobs/index.d.ts.map +1 -0
  216. package/dist/storage/domains/blobs/inmemory.d.ts +17 -0
  217. package/dist/storage/domains/blobs/inmemory.d.ts.map +1 -0
  218. package/dist/storage/domains/datasets/inmemory.d.ts.map +1 -1
  219. package/dist/storage/domains/index.d.ts +3 -0
  220. package/dist/storage/domains/index.d.ts.map +1 -1
  221. package/dist/storage/domains/inmemory-db.d.ts +7 -1
  222. package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
  223. package/dist/storage/domains/mcp-clients/inmemory.d.ts.map +1 -1
  224. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  225. package/dist/storage/domains/prompt-blocks/inmemory.d.ts.map +1 -1
  226. package/dist/storage/domains/scorer-definitions/inmemory.d.ts.map +1 -1
  227. package/dist/storage/domains/skills/base.d.ts +47 -0
  228. package/dist/storage/domains/skills/base.d.ts.map +1 -0
  229. package/dist/storage/domains/skills/index.d.ts +3 -0
  230. package/dist/storage/domains/skills/index.d.ts.map +1 -0
  231. package/dist/storage/domains/skills/inmemory.d.ts +31 -0
  232. package/dist/storage/domains/skills/inmemory.d.ts.map +1 -0
  233. package/dist/storage/domains/versioned.d.ts +12 -3
  234. package/dist/storage/domains/versioned.d.ts.map +1 -1
  235. package/dist/storage/domains/workspaces/base.d.ts +47 -0
  236. package/dist/storage/domains/workspaces/base.d.ts.map +1 -0
  237. package/dist/storage/domains/workspaces/index.d.ts +3 -0
  238. package/dist/storage/domains/workspaces/index.d.ts.map +1 -0
  239. package/dist/storage/domains/workspaces/inmemory.d.ts +31 -0
  240. package/dist/storage/domains/workspaces/inmemory.d.ts.map +1 -0
  241. package/dist/storage/index.cjs +202 -138
  242. package/dist/storage/index.js +2 -2
  243. package/dist/storage/mock.d.ts.map +1 -1
  244. package/dist/storage/types.d.ts +422 -12
  245. package/dist/storage/types.d.ts.map +1 -1
  246. package/dist/stream/base/output.d.ts.map +1 -1
  247. package/dist/stream/index.cjs +11 -11
  248. package/dist/stream/index.js +2 -2
  249. package/dist/test-utils/llm-mock.cjs +4 -4
  250. package/dist/test-utils/llm-mock.js +1 -1
  251. package/dist/tool-loop-agent/index.cjs +4 -4
  252. package/dist/tool-loop-agent/index.js +1 -1
  253. package/dist/tools/index.cjs +8 -4
  254. package/dist/tools/index.js +1 -1
  255. package/dist/tools/is-vercel-tool.cjs +2 -2
  256. package/dist/tools/is-vercel-tool.js +1 -1
  257. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  258. package/dist/tools/tool.d.ts +13 -0
  259. package/dist/tools/tool.d.ts.map +1 -1
  260. package/dist/tools/toolchecks.d.ts.map +1 -1
  261. package/dist/tools/types.d.ts +24 -0
  262. package/dist/tools/types.d.ts.map +1 -1
  263. package/dist/types/zod-compat.d.ts +27 -6
  264. package/dist/types/zod-compat.d.ts.map +1 -1
  265. package/dist/utils.cjs +23 -23
  266. package/dist/utils.js +1 -1
  267. package/dist/vector/index.cjs +12 -12
  268. package/dist/vector/index.js +2 -2
  269. package/dist/workflows/evented/index.cjs +10 -10
  270. package/dist/workflows/evented/index.js +1 -1
  271. package/dist/workflows/handlers/entry.d.ts.map +1 -1
  272. package/dist/workflows/index.cjs +25 -25
  273. package/dist/workflows/index.js +1 -1
  274. package/dist/workflows/workflow.d.ts +2 -2
  275. package/dist/workflows/workflow.d.ts.map +1 -1
  276. package/dist/workspace/constants/index.d.ts +1 -0
  277. package/dist/workspace/constants/index.d.ts.map +1 -1
  278. package/dist/workspace/errors.d.ts +3 -0
  279. package/dist/workspace/errors.d.ts.map +1 -1
  280. package/dist/workspace/filesystem/composite-filesystem.d.ts +75 -6
  281. package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -1
  282. package/dist/workspace/filesystem/local-filesystem.d.ts +42 -0
  283. package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
  284. package/dist/workspace/glob.d.ts +61 -0
  285. package/dist/workspace/glob.d.ts.map +1 -0
  286. package/dist/workspace/index.cjs +133 -41
  287. package/dist/workspace/index.d.ts +8 -1
  288. package/dist/workspace/index.d.ts.map +1 -1
  289. package/dist/workspace/index.js +1 -1
  290. package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
  291. package/dist/workspace/skills/composite-versioned-skill-source.d.ts +44 -0
  292. package/dist/workspace/skills/composite-versioned-skill-source.d.ts.map +1 -0
  293. package/dist/workspace/skills/index.d.ts +3 -0
  294. package/dist/workspace/skills/index.d.ts.map +1 -1
  295. package/dist/workspace/skills/local-skill-source.d.ts.map +1 -1
  296. package/dist/workspace/skills/publish.d.ts +34 -0
  297. package/dist/workspace/skills/publish.d.ts.map +1 -0
  298. package/dist/workspace/skills/skill-source.d.ts +2 -0
  299. package/dist/workspace/skills/skill-source.d.ts.map +1 -1
  300. package/dist/workspace/skills/types.d.ts +16 -0
  301. package/dist/workspace/skills/types.d.ts.map +1 -1
  302. package/dist/workspace/skills/versioned-skill-source.d.ts +20 -0
  303. package/dist/workspace/skills/versioned-skill-source.d.ts.map +1 -0
  304. package/dist/workspace/skills/workspace-skills.d.ts +5 -0
  305. package/dist/workspace/skills/workspace-skills.d.ts.map +1 -1
  306. package/dist/workspace/tools/delete-file.d.ts +5 -0
  307. package/dist/workspace/tools/delete-file.d.ts.map +1 -0
  308. package/dist/workspace/tools/edit-file.d.ts +7 -0
  309. package/dist/workspace/tools/edit-file.d.ts.map +1 -0
  310. package/dist/workspace/tools/execute-command.d.ts +7 -0
  311. package/dist/workspace/tools/execute-command.d.ts.map +1 -0
  312. package/dist/workspace/tools/file-stat.d.ts +4 -0
  313. package/dist/workspace/tools/file-stat.d.ts.map +1 -0
  314. package/dist/workspace/tools/grep.d.ts +9 -0
  315. package/dist/workspace/tools/grep.d.ts.map +1 -0
  316. package/dist/workspace/tools/helpers.d.ts +36 -0
  317. package/dist/workspace/tools/helpers.d.ts.map +1 -0
  318. package/dist/workspace/tools/index-content.d.ts +6 -0
  319. package/dist/workspace/tools/index-content.d.ts.map +1 -0
  320. package/dist/workspace/tools/index.d.ts +13 -1
  321. package/dist/workspace/tools/index.d.ts.map +1 -1
  322. package/dist/workspace/tools/list-files.d.ts +10 -0
  323. package/dist/workspace/tools/list-files.d.ts.map +1 -0
  324. package/dist/workspace/tools/mkdir.d.ts +5 -0
  325. package/dist/workspace/tools/mkdir.d.ts.map +1 -0
  326. package/dist/workspace/tools/read-file.d.ts +8 -0
  327. package/dist/workspace/tools/read-file.d.ts.map +1 -0
  328. package/dist/workspace/tools/search.d.ts +7 -0
  329. package/dist/workspace/tools/search.d.ts.map +1 -0
  330. package/dist/workspace/tools/tools.d.ts +5 -7
  331. package/dist/workspace/tools/tools.d.ts.map +1 -1
  332. package/dist/workspace/tools/tree-formatter.d.ts +2 -0
  333. package/dist/workspace/tools/tree-formatter.d.ts.map +1 -1
  334. package/dist/workspace/tools/write-file.d.ts +6 -0
  335. package/dist/workspace/tools/write-file.d.ts.map +1 -0
  336. package/dist/workspace/workspace.d.ts +56 -10
  337. package/dist/workspace/workspace.d.ts.map +1 -1
  338. package/harness.d.ts +1 -0
  339. package/package.json +8 -6
  340. package/src/llm/model/provider-types.generated.d.ts +312 -93
  341. package/dist/chunk-3JVFFAJX.cjs.map +0 -1
  342. package/dist/chunk-3X3CZUXI.js.map +0 -1
  343. package/dist/chunk-4EHGOATH.js.map +0 -1
  344. package/dist/chunk-4IJ4UDZX.cjs.map +0 -1
  345. package/dist/chunk-4KFEMXTV.cjs.map +0 -1
  346. package/dist/chunk-4TQ4EBYX.js.map +0 -1
  347. package/dist/chunk-4XSAZPPS.js.map +0 -1
  348. package/dist/chunk-65PHUUMF.cjs.map +0 -1
  349. package/dist/chunk-7NKUSQEV.js.map +0 -1
  350. package/dist/chunk-7UWHFWST.cjs.map +0 -1
  351. package/dist/chunk-AXHBJ4GX.js.map +0 -1
  352. package/dist/chunk-AY6DBRS3.js.map +0 -1
  353. package/dist/chunk-BP7VYTOP.cjs.map +0 -1
  354. package/dist/chunk-CYUP7QWT.cjs.map +0 -1
  355. package/dist/chunk-CZ4NQANZ.cjs.map +0 -1
  356. package/dist/chunk-NJ7TL3LQ.js.map +0 -1
  357. package/dist/chunk-NZG2JAKS.cjs.map +0 -1
  358. package/dist/chunk-PS5ONCXY.js.map +0 -1
  359. package/dist/chunk-RS6CZXGA.js.map +0 -1
  360. package/dist/chunk-SU5APAM6.cjs.map +0 -1
  361. package/dist/chunk-V2MLGA7T.js.map +0 -1
  362. package/dist/chunk-VTE2OBKS.cjs.map +0 -1
  363. package/dist/chunk-Y3TQ52UE.js.map +0 -1
  364. package/dist/chunk-YNNJLLFN.cjs.map +0 -1
  365. package/dist/chunk-ZATLLPIH.js.map +0 -1
  366. package/dist/models-dev-FQVUTQ7L.js +0 -3
  367. package/dist/models-dev-PPIXUUCU.cjs +0 -12
  368. package/dist/provider-registry-6LZAGQET.cjs +0 -40
  369. package/dist/provider-registry-QUNT7S55.js +0 -3
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunk4KFEMXTV_cjs = require('./chunk-4KFEMXTV.cjs');
4
3
  var chunkRQ56ZSIR_cjs = require('./chunk-RQ56ZSIR.cjs');
5
4
  var chunkZCBG4ZQT_cjs = require('./chunk-ZCBG4ZQT.cjs');
6
- var chunkBP7VYTOP_cjs = require('./chunk-BP7VYTOP.cjs');
7
- var chunkCZ4NQANZ_cjs = require('./chunk-CZ4NQANZ.cjs');
5
+ var chunkS4VVZI4E_cjs = require('./chunk-S4VVZI4E.cjs');
6
+ var chunkJZ6TH4HQ_cjs = require('./chunk-JZ6TH4HQ.cjs');
7
+ var chunkYW54RH77_cjs = require('./chunk-YW54RH77.cjs');
8
8
  var chunkZIEQA3YP_cjs = require('./chunk-ZIEQA3YP.cjs');
9
9
  var chunkPM3UIIBK_cjs = require('./chunk-PM3UIIBK.cjs');
10
10
  var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
11
- var chunkVD5YA6RH_cjs = require('./chunk-VD5YA6RH.cjs');
12
- var chunkHYRYTTMT_cjs = require('./chunk-HYRYTTMT.cjs');
11
+ var chunkQSN5KQXZ_cjs = require('./chunk-QSN5KQXZ.cjs');
12
+ var chunkPHHJLGZU_cjs = require('./chunk-PHHJLGZU.cjs');
13
13
  var chunk6BJ7XHRH_cjs = require('./chunk-6BJ7XHRH.cjs');
14
14
  var chunk4D4KB75Y_cjs = require('./chunk-4D4KB75Y.cjs');
15
- var chunk65PHUUMF_cjs = require('./chunk-65PHUUMF.cjs');
16
- var chunkCYUP7QWT_cjs = require('./chunk-CYUP7QWT.cjs');
15
+ var chunkQDH6MVJ7_cjs = require('./chunk-QDH6MVJ7.cjs');
16
+ var chunkKRAGJ433_cjs = require('./chunk-KRAGJ433.cjs');
17
17
  var chunkKJBMTK5B_cjs = require('./chunk-KJBMTK5B.cjs');
18
- var chunk7UWHFWST_cjs = require('./chunk-7UWHFWST.cjs');
18
+ var chunkEAZ6YDCQ_cjs = require('./chunk-EAZ6YDCQ.cjs');
19
19
  var chunkVDKWYUGC_cjs = require('./chunk-VDKWYUGC.cjs');
20
20
  var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
21
21
  var chunk4WQYXT2I_cjs = require('./chunk-4WQYXT2I.cjs');
@@ -1273,7 +1273,7 @@ var ProcessorRunner = class _ProcessorRunner {
1273
1273
  writer
1274
1274
  });
1275
1275
  const mutations = messageList.stopRecording();
1276
- if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1276
+ if (result instanceof chunkYW54RH77_cjs.MessageList) {
1277
1277
  if (result !== messageList) {
1278
1278
  throw new chunk4U7ZLI36_cjs.MastraError({
1279
1279
  category: "USER",
@@ -1310,7 +1310,7 @@ var ProcessorRunner = class _ProcessorRunner {
1310
1310
  /**
1311
1311
  * Process a stream part through all output processors with state management
1312
1312
  */
1313
- async processPart(part, processorStates, tracingContext, requestContext, messageList, retryCount = 0) {
1313
+ async processPart(part, processorStates, tracingContext, requestContext, messageList, retryCount = 0, writer) {
1314
1314
  if (!this.outputProcessors.length) {
1315
1315
  return { part, blocked: false };
1316
1316
  }
@@ -1383,7 +1383,8 @@ var ProcessorRunner = class _ProcessorRunner {
1383
1383
  tracingContext: { currentSpan: state.span },
1384
1384
  requestContext,
1385
1385
  messageList,
1386
- retryCount
1386
+ retryCount,
1387
+ writer
1387
1388
  });
1388
1389
  processedPart = result;
1389
1390
  state.addOutputPart(processedPart);
@@ -1423,11 +1424,14 @@ var ProcessorRunner = class _ProcessorRunner {
1423
1424
  return { part, blocked: false };
1424
1425
  }
1425
1426
  }
1426
- async runOutputProcessorsForStream(streamResult, tracingContext) {
1427
+ async runOutputProcessorsForStream(streamResult, tracingContext, writer) {
1427
1428
  return new ReadableStream({
1428
1429
  start: async (controller) => {
1429
1430
  const reader = streamResult.fullStream.getReader();
1430
1431
  const processorStates = /* @__PURE__ */ new Map();
1432
+ const streamWriter = writer ?? {
1433
+ custom: async (data) => controller.enqueue(data)
1434
+ };
1431
1435
  try {
1432
1436
  while (true) {
1433
1437
  const { done, value } = await reader.read();
@@ -1441,7 +1445,7 @@ var ProcessorRunner = class _ProcessorRunner {
1441
1445
  reason,
1442
1446
  tripwireOptions,
1443
1447
  processorId
1444
- } = await this.processPart(value, processorStates, tracingContext);
1448
+ } = await this.processPart(value, processorStates, tracingContext, void 0, void 0, 0, streamWriter);
1445
1449
  if (blocked) {
1446
1450
  void this.logger.debug(`[Agent:${this.agentName}] - Stream part blocked by output processor`, {
1447
1451
  reason,
@@ -1525,7 +1529,7 @@ var ProcessorRunner = class _ProcessorRunner {
1525
1529
  retryCount
1526
1530
  });
1527
1531
  let mutations;
1528
- if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1532
+ if (result instanceof chunkYW54RH77_cjs.MessageList) {
1529
1533
  if (result !== messageList) {
1530
1534
  throw new chunk4U7ZLI36_cjs.MastraError({
1531
1535
  category: "USER",
@@ -1853,7 +1857,7 @@ var ProcessorRunner = class _ProcessorRunner {
1853
1857
  writer
1854
1858
  });
1855
1859
  const mutations = messageList.stopRecording();
1856
- if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1860
+ if (result instanceof chunkYW54RH77_cjs.MessageList) {
1857
1861
  if (result !== messageList) {
1858
1862
  throw new chunk4U7ZLI36_cjs.MastraError({
1859
1863
  category: "USER",
@@ -1923,7 +1927,7 @@ var ProcessorRunner = class _ProcessorRunner {
1923
1927
  processor,
1924
1928
  stepNumber
1925
1929
  }) {
1926
- if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1930
+ if (result instanceof chunkYW54RH77_cjs.MessageList) {
1927
1931
  if (result !== messageList) {
1928
1932
  throw new chunk4U7ZLI36_cjs.MastraError({
1929
1933
  category: "USER",
@@ -1958,7 +1962,7 @@ var ProcessorRunner = class _ProcessorRunner {
1958
1962
  }
1959
1963
  const { model: _model, ...rest } = result;
1960
1964
  if (result.model) {
1961
- const resolvedModel = await chunkVD5YA6RH_cjs.resolveModelConfig(result.model);
1965
+ const resolvedModel = await chunkQSN5KQXZ_cjs.resolveModelConfig(result.model);
1962
1966
  const isSupported = isSupportedLanguageModel(resolvedModel);
1963
1967
  if (!isSupported) {
1964
1968
  throw new chunk4U7ZLI36_cjs.MastraError({
@@ -2696,6 +2700,9 @@ var MastraModelOutput = class extends chunkRO47SMI7_cjs.MastraBase {
2696
2700
  structuredOutputProcessorState.customState.controller = controller;
2697
2701
  }
2698
2702
  }
2703
+ const streamWriter = {
2704
+ custom: async (data) => controller.enqueue(data)
2705
+ };
2699
2706
  const {
2700
2707
  part: processed,
2701
2708
  blocked,
@@ -2707,7 +2714,9 @@ var MastraModelOutput = class extends chunkRO47SMI7_cjs.MastraBase {
2707
2714
  processorStates,
2708
2715
  options.tracingContext,
2709
2716
  options.requestContext,
2710
- self.messageList
2717
+ self.messageList,
2718
+ 0,
2719
+ streamWriter
2711
2720
  );
2712
2721
  if (blocked) {
2713
2722
  controller.enqueue({
@@ -3027,7 +3036,7 @@ var MastraModelOutput = class extends chunkRO47SMI7_cjs.MastraBase {
3027
3036
  );
3028
3037
  const responseMessages = self.messageList.get.response.aiV4.core();
3029
3038
  const lastResponseMessage = responseMessages[responseMessages.length - 1];
3030
- const outputText = lastResponseMessage ? chunkCZ4NQANZ_cjs.coreContentToString(lastResponseMessage.content) : "";
3039
+ const outputText = lastResponseMessage ? chunkYW54RH77_cjs.coreContentToString(lastResponseMessage.content) : "";
3031
3040
  if (lastStep && outputText && outputText !== originalText) {
3032
3041
  lastStep.text = outputText;
3033
3042
  }
@@ -4339,7 +4348,7 @@ function convertMastraChunkToAISDKv5({
4339
4348
  if (mode === "generate") {
4340
4349
  return {
4341
4350
  type: "file",
4342
- file: new chunkCZ4NQANZ_cjs.DefaultGeneratedFile({
4351
+ file: new chunkYW54RH77_cjs.DefaultGeneratedFile({
4343
4352
  data: chunk.payload.data,
4344
4353
  mediaType: chunk.payload.mimeType
4345
4354
  })
@@ -4347,7 +4356,7 @@ function convertMastraChunkToAISDKv5({
4347
4356
  }
4348
4357
  return {
4349
4358
  type: "file",
4350
- file: new chunkCZ4NQANZ_cjs.DefaultGeneratedFileWithType({
4359
+ file: new chunkYW54RH77_cjs.DefaultGeneratedFileWithType({
4351
4360
  data: chunk.payload.data,
4352
4361
  mediaType: chunk.payload.mimeType
4353
4362
  })
@@ -4961,7 +4970,7 @@ async function validateStepInput({
4961
4970
  }) {
4962
4971
  let inputData = prevOutput;
4963
4972
  let validationError;
4964
- if (validateInputs && chunk65PHUUMF_cjs.isZodType(step.inputSchema)) {
4973
+ if (validateInputs && chunkQDH6MVJ7_cjs.isZodType(step.inputSchema)) {
4965
4974
  const inputSchema = step.inputSchema;
4966
4975
  const validatedInput = await inputSchema.safeParseAsync(prevOutput);
4967
4976
  if (!validatedInput.success) {
@@ -4990,7 +4999,7 @@ async function validateStepResumeData({ resumeData, step }) {
4990
4999
  }
4991
5000
  let validationError;
4992
5001
  const resumeSchema = step.resumeSchema;
4993
- if (resumeSchema && chunk65PHUUMF_cjs.isZodType(resumeSchema)) {
5002
+ if (resumeSchema && chunkQDH6MVJ7_cjs.isZodType(resumeSchema)) {
4994
5003
  const validatedResumeData = await resumeSchema.safeParseAsync(resumeData);
4995
5004
  if (!validatedResumeData.success) {
4996
5005
  const errors = getZodErrors(validatedResumeData.error);
@@ -5021,7 +5030,7 @@ async function validateStepSuspendData({
5021
5030
  }
5022
5031
  let validationError;
5023
5032
  const suspendSchema = step.suspendSchema;
5024
- if (suspendSchema && validateInputs && chunk65PHUUMF_cjs.isZodType(suspendSchema)) {
5033
+ if (suspendSchema && validateInputs && chunkQDH6MVJ7_cjs.isZodType(suspendSchema)) {
5025
5034
  const validatedSuspendData = await suspendSchema.safeParseAsync(suspendData);
5026
5035
  if (!validatedSuspendData.success) {
5027
5036
  const errors = getZodErrors(validatedSuspendData.error);
@@ -5052,7 +5061,7 @@ async function validateStepStateData({
5052
5061
  }
5053
5062
  let validationError;
5054
5063
  const stateSchema = step.stateSchema;
5055
- if (stateSchema && validateInputs && chunk65PHUUMF_cjs.isZodType(stateSchema)) {
5064
+ if (stateSchema && validateInputs && chunkQDH6MVJ7_cjs.isZodType(stateSchema)) {
5056
5065
  const validatedStateData = await stateSchema.safeParseAsync(stateData);
5057
5066
  if (!validatedStateData.success) {
5058
5067
  const errors = getZodErrors(validatedStateData.error);
@@ -5071,7 +5080,7 @@ async function validateStepRequestContext({
5071
5080
  }) {
5072
5081
  let validationError;
5073
5082
  const requestContextSchema = step.requestContextSchema;
5074
- if (requestContextSchema && validateInputs && chunk65PHUUMF_cjs.isZodType(requestContextSchema)) {
5083
+ if (requestContextSchema && validateInputs && chunkQDH6MVJ7_cjs.isZodType(requestContextSchema)) {
5075
5084
  const contextValues = requestContext?.all ?? {};
5076
5085
  const validatedRequestContext = await requestContextSchema.safeParseAsync(contextValues);
5077
5086
  if (!validatedRequestContext.success) {
@@ -5207,7 +5216,7 @@ var createTimeTravelExecutionParams = (params) => {
5207
5216
  result = void 0;
5208
5217
  }
5209
5218
  if (result) {
5210
- const formattedResult = chunk65PHUUMF_cjs.removeUndefinedValues(result);
5219
+ const formattedResult = chunkQDH6MVJ7_cjs.removeUndefinedValues(result);
5211
5220
  stepResults[stepId] = formattedResult;
5212
5221
  }
5213
5222
  });
@@ -5582,7 +5591,7 @@ async function executeConditional(engine, params) {
5582
5591
  }
5583
5592
  });
5584
5593
  const results = await Promise.all(
5585
- stepsToRun.map(async (step, index) => {
5594
+ stepsToRun.map(async (step) => {
5586
5595
  const currStepResult = stepResults[step.step.id];
5587
5596
  const isRestartStep = restart ? !!restart.activeStepsPath[step.step.id] : void 0;
5588
5597
  if (currStepResult && timeTravel && timeTravel.executionPath.length > 0) {
@@ -5607,7 +5616,7 @@ async function executeConditional(engine, params) {
5607
5616
  executionContext: {
5608
5617
  workflowId,
5609
5618
  runId,
5610
- executionPath: [...executionContext.executionPath, index],
5619
+ executionPath: [...executionContext.executionPath, entry.steps.indexOf(step)],
5611
5620
  activeStepsPath: executionContext.activeStepsPath,
5612
5621
  suspendedPaths: executionContext.suspendedPaths,
5613
5622
  resumeLabels: executionContext.resumeLabels,
@@ -5767,7 +5776,7 @@ async function executeLoop(engine, params) {
5767
5776
  options: {
5768
5777
  type: "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */,
5769
5778
  name: `condition: '${entry.loopType}'`,
5770
- input: chunk65PHUUMF_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
5779
+ input: chunkQDH6MVJ7_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
5771
5780
  attributes: {
5772
5781
  conditionIndex: iteration
5773
5782
  },
@@ -6109,6 +6118,48 @@ async function executeForeach(engine, params) {
6109
6118
  }
6110
6119
 
6111
6120
  // src/workflows/handlers/entry.ts
6121
+ function buildResumedBlockResult(entrySteps, stepResults, executionContext, opts) {
6122
+ const stepsToCheck = opts?.onlyExecutedSteps ? entrySteps.filter((s) => s.type === "step" && stepResults[s.step.id] !== void 0) : entrySteps;
6123
+ const allComplete = stepsToCheck.every((s) => {
6124
+ if (s.type === "step") {
6125
+ const r = stepResults[s.step.id];
6126
+ return r && r.status === "success";
6127
+ }
6128
+ return true;
6129
+ });
6130
+ let result;
6131
+ if (allComplete) {
6132
+ result = {
6133
+ status: "success",
6134
+ output: entrySteps.reduce((acc, s) => {
6135
+ if (s.type === "step") {
6136
+ const r = stepResults[s.step.id];
6137
+ if (r && r.status === "success") {
6138
+ acc[s.step.id] = r.output;
6139
+ }
6140
+ }
6141
+ return acc;
6142
+ }, {})
6143
+ };
6144
+ } else {
6145
+ const stillSuspended = entrySteps.find((s) => s.type === "step" && stepResults[s.step.id]?.status === "suspended");
6146
+ const suspendData = stillSuspended && stillSuspended.type === "step" ? stepResults[stillSuspended.step.id]?.suspendPayload : {};
6147
+ result = {
6148
+ status: "suspended",
6149
+ payload: suspendData,
6150
+ suspendPayload: suspendData,
6151
+ suspendedAt: Date.now()
6152
+ };
6153
+ }
6154
+ if (result.status === "suspended") {
6155
+ entrySteps.forEach((s, stepIndex) => {
6156
+ if (s.type === "step" && stepResults[s.step.id]?.status === "suspended") {
6157
+ executionContext.suspendedPaths[s.step.id] = [...executionContext.executionPath, stepIndex];
6158
+ }
6159
+ });
6160
+ }
6161
+ return result;
6162
+ }
6112
6163
  async function persistStepUpdate(engine, params) {
6113
6164
  const {
6114
6165
  workflowId,
@@ -6237,49 +6288,7 @@ async function executeEntry(engine, params) {
6237
6288
  });
6238
6289
  engine.applyMutableContext(executionContext, resumedStepResult.mutableContext);
6239
6290
  Object.assign(stepResults, resumedStepResult.stepResults);
6240
- const allParallelStepsComplete = entry.steps.every((parallelStep) => {
6241
- if (parallelStep.type === "step") {
6242
- const stepResult = stepResults[parallelStep.step.id];
6243
- return stepResult && stepResult.status === "success";
6244
- }
6245
- return true;
6246
- });
6247
- if (allParallelStepsComplete) {
6248
- execResults = {
6249
- status: "success",
6250
- output: entry.steps.reduce((acc, parallelStep) => {
6251
- if (parallelStep.type === "step") {
6252
- const stepResult = stepResults[parallelStep.step.id];
6253
- if (stepResult && stepResult.status === "success") {
6254
- acc[parallelStep.step.id] = stepResult.output;
6255
- }
6256
- }
6257
- return acc;
6258
- }, {})
6259
- };
6260
- } else {
6261
- const stillSuspended = entry.steps.find((parallelStep) => {
6262
- if (parallelStep.type === "step") {
6263
- const stepResult = stepResults[parallelStep.step.id];
6264
- return stepResult && stepResult.status === "suspended";
6265
- }
6266
- return false;
6267
- });
6268
- execResults = {
6269
- status: "suspended",
6270
- payload: stillSuspended && stillSuspended.type === "step" ? stepResults[stillSuspended.step.id]?.suspendPayload : {}
6271
- };
6272
- }
6273
- if (execResults.status === "suspended") {
6274
- entry.steps.forEach((parallelStep, stepIndex) => {
6275
- if (parallelStep.type === "step") {
6276
- const stepResult = stepResults[parallelStep.step.id];
6277
- if (stepResult && stepResult.status === "suspended") {
6278
- executionContext.suspendedPaths[parallelStep.step.id] = [...executionContext.executionPath, stepIndex];
6279
- }
6280
- }
6281
- });
6282
- }
6291
+ execResults = buildResumedBlockResult(entry.steps, stepResults, executionContext);
6283
6292
  return {
6284
6293
  result: execResults,
6285
6294
  stepResults,
@@ -6306,6 +6315,79 @@ async function executeEntry(engine, params) {
6306
6315
  disableScorers,
6307
6316
  perStep
6308
6317
  });
6318
+ } else if (resume?.resumePath?.length && entry.type === "conditional") {
6319
+ const idx = resume.resumePath.shift();
6320
+ const branchStep = entry.steps[idx];
6321
+ let branchResult;
6322
+ if (branchStep.type !== "step") {
6323
+ branchResult = await executeEntry(engine, {
6324
+ workflowId,
6325
+ runId,
6326
+ resourceId,
6327
+ entry: branchStep,
6328
+ prevStep,
6329
+ serializedStepGraph,
6330
+ stepResults,
6331
+ resume,
6332
+ executionContext: {
6333
+ workflowId,
6334
+ runId,
6335
+ executionPath: [...executionContext.executionPath, idx],
6336
+ suspendedPaths: executionContext.suspendedPaths,
6337
+ resumeLabels: executionContext.resumeLabels,
6338
+ retryConfig: executionContext.retryConfig,
6339
+ activeStepsPath: executionContext.activeStepsPath,
6340
+ state: executionContext.state
6341
+ },
6342
+ tracingContext,
6343
+ pubsub,
6344
+ abortController,
6345
+ requestContext,
6346
+ outputWriter,
6347
+ disableScorers,
6348
+ perStep
6349
+ });
6350
+ } else {
6351
+ const resumePrevOutput = stepResults[branchStep.step.id]?.payload ?? prevOutput;
6352
+ branchResult = await engine.executeStep({
6353
+ workflowId,
6354
+ runId,
6355
+ resourceId,
6356
+ step: branchStep.step,
6357
+ prevOutput: resumePrevOutput,
6358
+ stepResults,
6359
+ serializedStepGraph,
6360
+ resume,
6361
+ restart,
6362
+ timeTravel,
6363
+ executionContext: {
6364
+ workflowId,
6365
+ runId,
6366
+ executionPath: [...executionContext.executionPath, idx],
6367
+ suspendedPaths: executionContext.suspendedPaths,
6368
+ resumeLabels: executionContext.resumeLabels,
6369
+ retryConfig: executionContext.retryConfig,
6370
+ activeStepsPath: executionContext.activeStepsPath,
6371
+ state: executionContext.state
6372
+ },
6373
+ tracingContext,
6374
+ pubsub,
6375
+ abortController,
6376
+ requestContext,
6377
+ outputWriter,
6378
+ disableScorers,
6379
+ perStep
6380
+ });
6381
+ }
6382
+ engine.applyMutableContext(executionContext, branchResult.mutableContext);
6383
+ Object.assign(stepResults, branchResult.stepResults);
6384
+ execResults = buildResumedBlockResult(entry.steps, stepResults, executionContext, { onlyExecutedSteps: true });
6385
+ return {
6386
+ result: execResults,
6387
+ stepResults,
6388
+ mutableContext: engine.buildMutableContext(executionContext),
6389
+ requestContext: branchResult.requestContext
6390
+ };
6309
6391
  } else if (entry.type === "conditional") {
6310
6392
  execResults = await engine.executeConditional({
6311
6393
  workflowId,
@@ -6968,7 +7050,7 @@ async function executeStep(engine, params) {
6968
7050
  requestContextUpdate: null
6969
7051
  };
6970
7052
  const isNestedWorkflow = step.component === "WORKFLOW";
6971
- const mastraForStep = engine.mastra ? isNestedWorkflow ? engine.mastra : chunkCYUP7QWT_cjs.wrapMastra(engine.mastra, { currentSpan: stepSpan }) : void 0;
7053
+ const mastraForStep = engine.mastra ? isNestedWorkflow ? engine.mastra : chunkKRAGJ433_cjs.wrapMastra(engine.mastra, { currentSpan: stepSpan }) : void 0;
6972
7054
  const output = await runStep({
6973
7055
  runId,
6974
7056
  resourceId,
@@ -7881,10 +7963,10 @@ function isAgent(input) {
7881
7963
  return input instanceof Agent;
7882
7964
  }
7883
7965
  function isToolStep(input) {
7884
- return input instanceof chunk7UWHFWST_cjs.Tool;
7966
+ return input instanceof chunkEAZ6YDCQ_cjs.Tool;
7885
7967
  }
7886
7968
  function isStepParams(input) {
7887
- return input !== null && typeof input === "object" && "id" in input && "execute" in input && !(input instanceof Agent) && !(input instanceof chunk7UWHFWST_cjs.Tool);
7969
+ return input !== null && typeof input === "object" && "id" in input && "execute" in input && !(input instanceof Agent) && !(input instanceof chunkEAZ6YDCQ_cjs.Tool);
7888
7970
  }
7889
7971
  function createStep(params, agentOrToolOptions) {
7890
7972
  if (isAgent(params)) {
@@ -8221,7 +8303,7 @@ function createStepFromProcessor(processor) {
8221
8303
  phase,
8222
8304
  // Auto-create MessageList from messages if not provided
8223
8305
  // This enables running processor workflows from the UI where messageList can't be serialized
8224
- messageList: messageList ?? (Array.isArray(messages) ? new chunkCZ4NQANZ_cjs.MessageList().add(messages, "input").addSystem(systemMessages ?? []) : void 0),
8306
+ messageList: messageList ?? (Array.isArray(messages) ? new chunkYW54RH77_cjs.MessageList().add(messages, "input").addSystem(systemMessages ?? []) : void 0),
8225
8307
  stepNumber,
8226
8308
  systemMessages,
8227
8309
  streamParts,
@@ -8275,7 +8357,7 @@ function createStepFromProcessor(processor) {
8275
8357
  messageList: checkedMessageList,
8276
8358
  systemMessages: systemMessages ?? []
8277
8359
  });
8278
- if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
8360
+ if (result instanceof chunkYW54RH77_cjs.MessageList) {
8279
8361
  if (result !== checkedMessageList) {
8280
8362
  throw new chunk4U7ZLI36_cjs.MastraError({
8281
8363
  category: "USER" /* USER */,
@@ -8439,7 +8521,7 @@ function createStepFromProcessor(processor) {
8439
8521
  messages,
8440
8522
  messageList: passThrough.messageList
8441
8523
  });
8442
- if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
8524
+ if (result instanceof chunkYW54RH77_cjs.MessageList) {
8443
8525
  if (result !== passThrough.messageList) {
8444
8526
  throw new chunk4U7ZLI36_cjs.MastraError({
8445
8527
  category: "USER" /* USER */,
@@ -8506,7 +8588,7 @@ function createStepFromProcessor(processor) {
8506
8588
  systemMessages: systemMessages ?? [],
8507
8589
  steps: steps ?? []
8508
8590
  });
8509
- if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
8591
+ if (result instanceof chunkYW54RH77_cjs.MessageList) {
8510
8592
  if (result !== checkedMessageList) {
8511
8593
  throw new chunk4U7ZLI36_cjs.MastraError({
8512
8594
  category: "USER" /* USER */,
@@ -8574,7 +8656,7 @@ function cloneStep(step, opts) {
8574
8656
  };
8575
8657
  }
8576
8658
  function isProcessor(obj) {
8577
- return obj !== null && typeof obj === "object" && "id" in obj && typeof obj.id === "string" && !(obj instanceof Agent) && !(obj instanceof chunk7UWHFWST_cjs.Tool) && (typeof obj.processInput === "function" || typeof obj.processInputStep === "function" || typeof obj.processOutputStream === "function" || typeof obj.processOutputResult === "function" || typeof obj.processOutputStep === "function");
8659
+ return obj !== null && typeof obj === "object" && "id" in obj && typeof obj.id === "string" && !(obj instanceof Agent) && !(obj instanceof chunkEAZ6YDCQ_cjs.Tool) && (typeof obj.processInput === "function" || typeof obj.processInputStep === "function" || typeof obj.processOutputStream === "function" || typeof obj.processOutputResult === "function" || typeof obj.processOutputStep === "function");
8578
8660
  }
8579
8661
  function createWorkflow(params) {
8580
8662
  return new Workflow(params);
@@ -9548,7 +9630,7 @@ var Run = class {
9548
9630
  }
9549
9631
  async _validateInput(inputData) {
9550
9632
  let inputDataToUse = inputData;
9551
- if (this.validateInputs && this.inputSchema && chunk65PHUUMF_cjs.isZodType(this.inputSchema)) {
9633
+ if (this.validateInputs && this.inputSchema && chunkQDH6MVJ7_cjs.isZodType(this.inputSchema)) {
9552
9634
  const validatedInputData = await this.inputSchema.safeParseAsync(inputData);
9553
9635
  if (!validatedInputData.success) {
9554
9636
  const errors = getZodErrors(validatedInputData.error);
@@ -9562,7 +9644,7 @@ var Run = class {
9562
9644
  let initialStateToUse = initialState;
9563
9645
  if (this.validateInputs) {
9564
9646
  let stateSchema = this.stateSchema;
9565
- if (stateSchema && chunk65PHUUMF_cjs.isZodType(stateSchema)) {
9647
+ if (stateSchema && chunkQDH6MVJ7_cjs.isZodType(stateSchema)) {
9566
9648
  const validatedInitialState = await stateSchema.safeParseAsync(initialState);
9567
9649
  if (!validatedInitialState.success) {
9568
9650
  const errors = getZodErrors(validatedInitialState.error);
@@ -9576,7 +9658,7 @@ var Run = class {
9576
9658
  return initialStateToUse;
9577
9659
  }
9578
9660
  async _validateRequestContext(requestContext) {
9579
- if (this.validateInputs && this.requestContextSchema && chunk65PHUUMF_cjs.isZodType(this.requestContextSchema)) {
9661
+ if (this.validateInputs && this.requestContextSchema && chunkQDH6MVJ7_cjs.isZodType(this.requestContextSchema)) {
9580
9662
  const contextValues = requestContext?.all ?? {};
9581
9663
  const validatedRequestContext = await this.requestContextSchema.safeParseAsync(contextValues);
9582
9664
  if (!validatedRequestContext.success) {
@@ -9590,7 +9672,7 @@ var Run = class {
9590
9672
  }
9591
9673
  async _validateResumeData(resumeData, suspendedStep) {
9592
9674
  let resumeDataToUse = resumeData;
9593
- if (suspendedStep && suspendedStep.resumeSchema && this.validateInputs && chunk65PHUUMF_cjs.isZodType(suspendedStep.resumeSchema)) {
9675
+ if (suspendedStep && suspendedStep.resumeSchema && this.validateInputs && chunkQDH6MVJ7_cjs.isZodType(suspendedStep.resumeSchema)) {
9594
9676
  const resumeSchema = suspendedStep.resumeSchema;
9595
9677
  const validatedResumeData = await resumeSchema.safeParseAsync(resumeData);
9596
9678
  if (!validatedResumeData.success) {
@@ -9603,7 +9685,7 @@ var Run = class {
9603
9685
  }
9604
9686
  async _validateTimetravelInputData(inputData, step) {
9605
9687
  let inputDataToUse = inputData;
9606
- if (step && step.inputSchema && this.validateInputs && chunk65PHUUMF_cjs.isZodType(step.inputSchema)) {
9688
+ if (step && step.inputSchema && this.validateInputs && chunkQDH6MVJ7_cjs.isZodType(step.inputSchema)) {
9607
9689
  const inputSchema = step.inputSchema;
9608
9690
  const validatedInputData = await inputSchema.safeParseAsync(inputData);
9609
9691
  if (!validatedInputData.success) {
@@ -9626,7 +9708,7 @@ var Run = class {
9626
9708
  outputOptions,
9627
9709
  perStep
9628
9710
  }) {
9629
- const workflowSpan = chunkCYUP7QWT_cjs.getOrCreateSpan({
9711
+ const workflowSpan = chunkKRAGJ433_cjs.getOrCreateSpan({
9630
9712
  type: "workflow_run" /* WORKFLOW_RUN */,
9631
9713
  name: `workflow run: '${this.workflowId}'`,
9632
9714
  entityType: "workflow_run" /* WORKFLOW_RUN */,
@@ -10129,7 +10211,7 @@ var Run = class {
10129
10211
  requestContextToUse.set(key, value);
10130
10212
  }
10131
10213
  });
10132
- const workflowSpan = chunkCYUP7QWT_cjs.getOrCreateSpan({
10214
+ const workflowSpan = chunkKRAGJ433_cjs.getOrCreateSpan({
10133
10215
  type: "workflow_run" /* WORKFLOW_RUN */,
10134
10216
  name: `workflow run: '${this.workflowId}'`,
10135
10217
  entityType: "workflow_run" /* WORKFLOW_RUN */,
@@ -10241,7 +10323,7 @@ var Run = class {
10241
10323
  requestContextToUse.set(key, value);
10242
10324
  }
10243
10325
  }
10244
- const workflowSpan = chunkCYUP7QWT_cjs.getOrCreateSpan({
10326
+ const workflowSpan = chunkKRAGJ433_cjs.getOrCreateSpan({
10245
10327
  type: "workflow_run" /* WORKFLOW_RUN */,
10246
10328
  name: `workflow run: '${this.workflowId}'`,
10247
10329
  entityType: "workflow_run" /* WORKFLOW_RUN */,
@@ -10335,7 +10417,7 @@ var Run = class {
10335
10417
  requestContextToUse.set(key, value);
10336
10418
  }
10337
10419
  }
10338
- const workflowSpan = chunkCYUP7QWT_cjs.getOrCreateSpan({
10420
+ const workflowSpan = chunkKRAGJ433_cjs.getOrCreateSpan({
10339
10421
  type: "workflow_run" /* WORKFLOW_RUN */,
10340
10422
  name: `workflow run: '${this.workflowId}'`,
10341
10423
  input: inputData,
@@ -11429,7 +11511,7 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
11429
11511
  }
11430
11512
  }
11431
11513
  if (isSupportedLanguageModel(currentStep.model)) {
11432
- modelResult = chunkCYUP7QWT_cjs.executeWithContextSync({
11514
+ modelResult = chunkKRAGJ433_cjs.executeWithContextSync({
11433
11515
  span: modelSpanTracker?.getTracingContext()?.currentSpan,
11434
11516
  fn: () => execute({
11435
11517
  runId,
@@ -11778,16 +11860,6 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
11778
11860
  }
11779
11861
  });
11780
11862
  }
11781
-
11782
- // src/loop/workflows/errors.ts
11783
- var ToolNotFoundError = class extends Error {
11784
- constructor(message) {
11785
- super(message);
11786
- this.name = "ToolNotFoundError";
11787
- }
11788
- };
11789
-
11790
- // src/loop/workflows/agentic-execution/llm-mapping-step.ts
11791
11863
  function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep) {
11792
11864
  const processorRunner = rest.outputProcessors?.length && rest.logger ? new ProcessorRunner({
11793
11865
  inputProcessors: [],
@@ -11797,6 +11869,7 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11797
11869
  processorStates: rest.processorStates
11798
11870
  }) : void 0;
11799
11871
  const tracingContext = rest.modelSpanTracker?.getTracingContext();
11872
+ const streamWriter = rest.outputWriter ? { custom: async (data) => rest.outputWriter(data) } : void 0;
11800
11873
  async function processAndEnqueueChunk(chunk) {
11801
11874
  if (processorRunner && rest.processorStates) {
11802
11875
  const {
@@ -11810,7 +11883,9 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11810
11883
  rest.processorStates,
11811
11884
  tracingContext,
11812
11885
  rest.requestContext,
11813
- rest.messageList
11886
+ rest.messageList,
11887
+ 0,
11888
+ streamWriter
11814
11889
  );
11815
11890
  if (blocked) {
11816
11891
  rest.controller.enqueue({
@@ -11822,13 +11897,16 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11822
11897
  processorId
11823
11898
  }
11824
11899
  });
11825
- return;
11900
+ return null;
11826
11901
  }
11827
11902
  if (processed) {
11828
11903
  rest.controller.enqueue(processed);
11904
+ return processed;
11829
11905
  }
11906
+ return null;
11830
11907
  } else {
11831
11908
  rest.controller.enqueue(chunk);
11909
+ return chunk;
11832
11910
  }
11833
11911
  }
11834
11912
  return createStep({
@@ -11837,6 +11915,20 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11837
11915
  outputSchema: llmIterationOutputSchema,
11838
11916
  execute: async ({ inputData, getStepResult: getStepResult2, bail }) => {
11839
11917
  const initialResult = getStepResult2(llmExecutionStep);
11918
+ async function getProviderMetadataWithModelOutput(toolCall) {
11919
+ const tool2 = rest.tools?.[toolCall.toolName];
11920
+ let modelOutput;
11921
+ if (tool2?.toModelOutput && toolCall.result != null) {
11922
+ modelOutput = await tool2.toModelOutput(toolCall.result);
11923
+ }
11924
+ const existingMastra = toolCall.providerMetadata?.mastra;
11925
+ const providerMetadata = {
11926
+ ...toolCall.providerMetadata,
11927
+ ...modelOutput != null ? { mastra: { ...existingMastra, modelOutput } } : {}
11928
+ };
11929
+ const hasMetadata = Object.keys(providerMetadata).length > 0;
11930
+ return hasMetadata ? providerMetadata : void 0;
11931
+ }
11840
11932
  if (inputData?.some((toolCall) => toolCall?.result === void 0)) {
11841
11933
  const errorResults = inputData.filter((toolCall) => toolCall?.error);
11842
11934
  const toolResultMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
@@ -11854,7 +11946,8 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11854
11946
  providerMetadata: toolCall.providerMetadata
11855
11947
  }
11856
11948
  };
11857
- await processAndEnqueueChunk(chunk);
11949
+ const processed = await processAndEnqueueChunk(chunk);
11950
+ if (processed) await rest.options?.onChunk?.(processed);
11858
11951
  }
11859
11952
  const msg = {
11860
11953
  id: toolResultMessageId || "",
@@ -11879,9 +11972,8 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11879
11972
  };
11880
11973
  rest.messageList.add(msg, "response");
11881
11974
  }
11882
- const allErrorsAreToolNotFound = errorResults?.length > 0 && errorResults.every((tc) => tc.error instanceof ToolNotFoundError);
11883
11975
  const hasPendingHITL = inputData.some((tc) => tc.result === void 0 && !tc.error);
11884
- if (allErrorsAreToolNotFound && !hasPendingHITL) {
11976
+ if (errorResults?.length > 0 && !hasPendingHITL) {
11885
11977
  const successfulResults = inputData.filter((tc) => tc.result !== void 0);
11886
11978
  if (successfulResults.length) {
11887
11979
  for (const toolCall of successfulResults) {
@@ -11898,7 +11990,8 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11898
11990
  providerExecuted: toolCall.providerExecuted
11899
11991
  }
11900
11992
  };
11901
- await processAndEnqueueChunk(chunk);
11993
+ const processed = await processAndEnqueueChunk(chunk);
11994
+ if (processed) await rest.options?.onChunk?.(processed);
11902
11995
  }
11903
11996
  const successMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
11904
11997
  const successMessage = {
@@ -11906,17 +11999,22 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11906
11999
  role: "assistant",
11907
12000
  content: {
11908
12001
  format: 2,
11909
- parts: successfulResults.map((toolCall) => ({
11910
- type: "tool-invocation",
11911
- toolInvocation: {
11912
- state: "result",
11913
- toolCallId: toolCall.toolCallId,
11914
- toolName: toolCall.toolName,
11915
- args: toolCall.args,
11916
- result: toolCall.result
11917
- },
11918
- ...toolCall.providerMetadata ? { providerMetadata: toolCall.providerMetadata } : {}
11919
- }))
12002
+ parts: await Promise.all(
12003
+ successfulResults.map(async (toolCall) => {
12004
+ const providerMetadata = await getProviderMetadataWithModelOutput(toolCall);
12005
+ return {
12006
+ type: "tool-invocation",
12007
+ toolInvocation: {
12008
+ state: "result",
12009
+ toolCallId: toolCall.toolCallId,
12010
+ toolName: toolCall.toolName,
12011
+ args: toolCall.args,
12012
+ result: toolCall.result
12013
+ },
12014
+ ...providerMetadata ? { providerMetadata } : {}
12015
+ };
12016
+ })
12017
+ )
11920
12018
  },
11921
12019
  createdAt: /* @__PURE__ */ new Date()
11922
12020
  };
@@ -11960,14 +12058,8 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11960
12058
  providerExecuted: toolCall.providerExecuted
11961
12059
  }
11962
12060
  };
11963
- await processAndEnqueueChunk(chunk);
11964
- if (supportedLanguageModelSpecifications.includes(initialResult?.metadata?.modelVersion)) {
11965
- await rest.options?.onChunk?.({
11966
- chunk: convertMastraChunkToAISDKv5({
11967
- chunk
11968
- })
11969
- });
11970
- }
12061
+ const processed = await processAndEnqueueChunk(chunk);
12062
+ if (processed) await rest.options?.onChunk?.(processed);
11971
12063
  }
11972
12064
  const toolResultMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
11973
12065
  const toolResultMessage = {
@@ -11975,19 +12067,22 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11975
12067
  role: "assistant",
11976
12068
  content: {
11977
12069
  format: 2,
11978
- parts: inputData.map((toolCall) => {
11979
- return {
11980
- type: "tool-invocation",
11981
- toolInvocation: {
11982
- state: "result",
11983
- toolCallId: toolCall.toolCallId,
11984
- toolName: toolCall.toolName,
11985
- args: toolCall.args,
11986
- result: toolCall.result
11987
- },
11988
- ...toolCall.providerMetadata ? { providerMetadata: toolCall.providerMetadata } : {}
11989
- };
11990
- })
12070
+ parts: await Promise.all(
12071
+ inputData.map(async (toolCall) => {
12072
+ const providerMetadata = await getProviderMetadataWithModelOutput(toolCall);
12073
+ return {
12074
+ type: "tool-invocation",
12075
+ toolInvocation: {
12076
+ state: "result",
12077
+ toolCallId: toolCall.toolCallId,
12078
+ toolName: toolCall.toolName,
12079
+ args: toolCall.args,
12080
+ result: toolCall.result
12081
+ },
12082
+ ...providerMetadata ? { providerMetadata } : {}
12083
+ };
12084
+ })
12085
+ )
11991
12086
  },
11992
12087
  createdAt: /* @__PURE__ */ new Date()
11993
12088
  };
@@ -12005,6 +12100,16 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
12005
12100
  }
12006
12101
  });
12007
12102
  }
12103
+
12104
+ // src/loop/workflows/errors.ts
12105
+ var ToolNotFoundError = class extends Error {
12106
+ constructor(message) {
12107
+ super(message);
12108
+ this.name = "ToolNotFoundError";
12109
+ }
12110
+ };
12111
+
12112
+ // src/loop/workflows/agentic-execution/tool-call-step.ts
12008
12113
  function createToolCallStep({
12009
12114
  tools,
12010
12115
  messageList,
@@ -12265,7 +12370,8 @@ function createToolCallStep({
12265
12370
  } else if (isResumeToolCall) {
12266
12371
  await removeToolMetadata(inputData.toolName, "suspension");
12267
12372
  }
12268
- const resumeDataToPassToToolOptions = toolRequiresApproval && Object.keys(resumeData).length === 1 && "approved" in resumeData ? void 0 : resumeData;
12373
+ const isAgentTool = inputData.toolName?.startsWith("agent-");
12374
+ const resumeDataToPassToToolOptions = !isAgentTool && toolRequiresApproval && Object.keys(resumeData).length === 1 && "approved" in resumeData ? void 0 : resumeData;
12269
12375
  const toolOptions = {
12270
12376
  abortSignal: options?.abortSignal,
12271
12377
  toolCallId: inputData.toolCallId,
@@ -12275,6 +12381,8 @@ function createToolCallStep({
12275
12381
  tracingContext: modelSpanTracker?.getTracingContext(),
12276
12382
  // Pass workspace from _internal (set by llmExecutionStep via prepareStep/processInputStep)
12277
12383
  workspace: _internal?.stepWorkspace,
12384
+ // Forward requestContext so tools receive values set by the workflow step
12385
+ requestContext,
12278
12386
  suspend: async (suspendPayload, options2) => {
12279
12387
  if (options2?.requireToolApproval) {
12280
12388
  controller.enqueue({
@@ -12364,7 +12472,7 @@ function createToolCallStep({
12364
12472
  },
12365
12473
  resumeData: resumeDataToPassToToolOptions
12366
12474
  };
12367
- if (resumeDataToPassToToolOptions && inputData.toolName?.startsWith("agent-") && !isResumeToolCall) {
12475
+ if (resumeDataToPassToToolOptions && isAgentTool && !isResumeToolCall) {
12368
12476
  let suspendedToolRunId = "";
12369
12477
  const messages = messageList.get.all.db();
12370
12478
  const assistantMessages = [...messages].reverse().filter((message) => message.role === "assistant");
@@ -12696,13 +12804,14 @@ function workflowLoopStream({
12696
12804
  const run = await agenticLoopWorkflow.createRun({
12697
12805
  runId
12698
12806
  });
12699
- const requestContext = new chunkVDKWYUGC_cjs.RequestContext();
12807
+ const requestContext = rest.requestContext ?? new chunkVDKWYUGC_cjs.RequestContext();
12700
12808
  if (requireToolApproval) {
12701
12809
  requestContext.set("__mastra_requireToolApproval", true);
12702
12810
  }
12703
12811
  const executionResult = resumeContext ? await run.resume({
12704
12812
  resumeData: resumeContext.resumeData,
12705
12813
  tracingContext: rest.modelSpanTracker?.getTracingContext(),
12814
+ requestContext,
12706
12815
  label: toolCallId
12707
12816
  }) : await run.start({
12708
12817
  inputData: initialData,
@@ -13169,7 +13278,7 @@ var MastraScorer = class _MastraScorer {
13169
13278
  }
13170
13279
  });
13171
13280
  }
13172
- const resolvedModel = await chunkVD5YA6RH_cjs.resolveModelConfig(modelConfig, void 0, this.#mastra);
13281
+ const resolvedModel = await chunkQSN5KQXZ_cjs.resolveModelConfig(modelConfig, void 0, this.#mastra);
13173
13282
  const judge = new Agent({
13174
13283
  id: "judge",
13175
13284
  name: "judge",
@@ -13821,7 +13930,7 @@ var MastraLLMVNext = class extends chunkRO47SMI7_cjs.MastraBase {
13821
13930
  const remainingTokens = parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"] ?? "", 10);
13822
13931
  if (!isNaN(remainingTokens) && remainingTokens > 0 && remainingTokens < 2e3) {
13823
13932
  this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
13824
- await chunk65PHUUMF_cjs.delay(10 * 1e3);
13933
+ await chunkQDH6MVJ7_cjs.delay(10 * 1e3);
13825
13934
  }
13826
13935
  },
13827
13936
  onFinish: async (props) => {
@@ -14084,7 +14193,7 @@ async function prepareMemoryStep({
14084
14193
  );
14085
14194
  }
14086
14195
  } else {
14087
- const messageList = new chunkCZ4NQANZ_cjs.MessageList({
14196
+ const messageList = new chunkYW54RH77_cjs.MessageList({
14088
14197
  threadId: thread?.id,
14089
14198
  resourceId: thread?.resourceId
14090
14199
  });
@@ -14147,7 +14256,7 @@ async function saveMessagesWithProcessors(memory, messages, processorRunner, con
14147
14256
  await memory.saveMessages({ messages });
14148
14257
  return;
14149
14258
  }
14150
- const messageList = new chunkCZ4NQANZ_cjs.MessageList();
14259
+ const messageList = new chunkYW54RH77_cjs.MessageList();
14151
14260
  for (const msg of messages) {
14152
14261
  messageList.add(msg, "response");
14153
14262
  }
@@ -14576,12 +14685,11 @@ async function createNetworkLoop({
14576
14685
  }
14577
14686
  ],
14578
14687
  format: 2,
14579
- ...requireApprovalMetadata || suspendedTools ? {
14580
- metadata: {
14581
- ...requireApprovalMetadata ? { requireApprovalMetadata } : {},
14582
- ...suspendedTools ? { suspendedTools } : {}
14583
- }
14584
- } : {}
14688
+ metadata: {
14689
+ mode: "network",
14690
+ ...requireApprovalMetadata ? { requireApprovalMetadata } : {},
14691
+ ...suspendedTools ? { suspendedTools } : {}
14692
+ }
14585
14693
  },
14586
14694
  createdAt: /* @__PURE__ */ new Date(),
14587
14695
  threadId: initData?.threadId || runId,
@@ -14860,8 +14968,9 @@ async function createNetworkLoop({
14860
14968
  content: {
14861
14969
  parts: [{ type: "text", text: finalResult }],
14862
14970
  format: 2,
14863
- ...suspendPayload ? {
14864
- metadata: {
14971
+ metadata: {
14972
+ mode: "network",
14973
+ ...suspendPayload ? {
14865
14974
  suspendedTools: {
14866
14975
  [inputData.primitiveId]: {
14867
14976
  args: input,
@@ -14876,8 +14985,8 @@ async function createNetworkLoop({
14876
14985
  toolCallId: inputData.primitiveId
14877
14986
  }
14878
14987
  }
14879
- }
14880
- } : {}
14988
+ } : {}
14989
+ }
14881
14990
  },
14882
14991
  createdAt: /* @__PURE__ */ new Date(),
14883
14992
  threadId: initData?.threadId || runId,
@@ -15169,7 +15278,10 @@ async function createNetworkLoop({
15169
15278
  })
15170
15279
  }
15171
15280
  ],
15172
- format: 2
15281
+ format: 2,
15282
+ metadata: {
15283
+ mode: "network"
15284
+ }
15173
15285
  },
15174
15286
  createdAt: /* @__PURE__ */ new Date(),
15175
15287
  threadId: initData.threadId || runId,
@@ -15334,7 +15446,10 @@ async function createNetworkLoop({
15334
15446
  })
15335
15447
  }
15336
15448
  ],
15337
- format: 2
15449
+ format: 2,
15450
+ metadata: {
15451
+ mode: "network"
15452
+ }
15338
15453
  },
15339
15454
  createdAt: /* @__PURE__ */ new Date(),
15340
15455
  threadId: initData.threadId || runId,
@@ -15381,7 +15496,10 @@ async function createNetworkLoop({
15381
15496
  })
15382
15497
  }
15383
15498
  ],
15384
- format: 2
15499
+ format: 2,
15500
+ metadata: {
15501
+ mode: "network"
15502
+ }
15385
15503
  },
15386
15504
  createdAt: /* @__PURE__ */ new Date(),
15387
15505
  threadId: initData.threadId || runId,
@@ -15605,7 +15723,7 @@ async function networkLoop({
15605
15723
  "resumeData": "string"
15606
15724
  }
15607
15725
  `;
15608
- const messageList = new chunkCZ4NQANZ_cjs.MessageList();
15726
+ const messageList = new chunkYW54RH77_cjs.MessageList();
15609
15727
  messageList.addSystem(systemInstructions);
15610
15728
  messageList.add(task, "user");
15611
15729
  const result = llm.stream({
@@ -16172,7 +16290,7 @@ ${skillInstructions}`;
16172
16290
  createSkillActivateTool() {
16173
16291
  const skills = this.skills;
16174
16292
  const activatedSkills = this._activatedSkills;
16175
- return chunk7UWHFWST_cjs.createTool({
16293
+ return chunkEAZ6YDCQ_cjs.createTool({
16176
16294
  id: "skill-activate",
16177
16295
  description: "Activate a skill to load its full instructions. You should activate skills proactively when they are relevant to the user's request without asking for permission first.",
16178
16296
  inputSchema: z10__default.default.object({
@@ -16213,7 +16331,7 @@ ${skillInstructions}`;
16213
16331
  createSkillReadReferenceTool() {
16214
16332
  const skills = this.skills;
16215
16333
  const activatedSkills = this._activatedSkills;
16216
- return chunk7UWHFWST_cjs.createTool({
16334
+ return chunkEAZ6YDCQ_cjs.createTool({
16217
16335
  id: "skill-read-reference",
16218
16336
  description: "Read a reference file from an activated skill. Optionally specify line range to read a portion of the file.",
16219
16337
  inputSchema: z10__default.default.object({
@@ -16243,7 +16361,7 @@ ${skillInstructions}`;
16243
16361
  message: `Reference file "${referencePath}" not found in skill "${skillName}". Available references: ${availableRefs.join(", ") || "none"}`
16244
16362
  };
16245
16363
  }
16246
- const result = chunk4KFEMXTV_cjs.extractLines(fullContent, startLine, endLine);
16364
+ const result = chunkS4VVZI4E_cjs.extractLines(fullContent, startLine, endLine);
16247
16365
  return {
16248
16366
  success: true,
16249
16367
  content: result.content,
@@ -16259,7 +16377,7 @@ ${skillInstructions}`;
16259
16377
  createSkillReadScriptTool() {
16260
16378
  const skills = this.skills;
16261
16379
  const activatedSkills = this._activatedSkills;
16262
- return chunk7UWHFWST_cjs.createTool({
16380
+ return chunkEAZ6YDCQ_cjs.createTool({
16263
16381
  id: "skill-read-script",
16264
16382
  description: "Read a script file from an activated skill. Scripts contain executable code. Optionally specify line range.",
16265
16383
  inputSchema: z10__default.default.object({
@@ -16289,7 +16407,7 @@ ${skillInstructions}`;
16289
16407
  message: `Script file "${scriptPath}" not found in skill "${skillName}". Available scripts: ${availableScripts.join(", ") || "none"}`
16290
16408
  };
16291
16409
  }
16292
- const result = chunk4KFEMXTV_cjs.extractLines(fullContent, startLine, endLine);
16410
+ const result = chunkS4VVZI4E_cjs.extractLines(fullContent, startLine, endLine);
16293
16411
  return {
16294
16412
  success: true,
16295
16413
  content: result.content,
@@ -16305,7 +16423,7 @@ ${skillInstructions}`;
16305
16423
  createSkillReadAssetTool() {
16306
16424
  const skills = this.skills;
16307
16425
  const activatedSkills = this._activatedSkills;
16308
- return chunk7UWHFWST_cjs.createTool({
16426
+ return chunkEAZ6YDCQ_cjs.createTool({
16309
16427
  id: "skill-read-asset",
16310
16428
  description: "Read an asset file from an activated skill. Assets include templates, data files, and other static resources. Binary files are returned as base64.",
16311
16429
  inputSchema: z10__default.default.object({
@@ -16357,7 +16475,7 @@ ${skillInstructions}`;
16357
16475
  */
16358
16476
  createSkillSearchTool() {
16359
16477
  const skills = this.skills;
16360
- return chunk7UWHFWST_cjs.createTool({
16478
+ return chunkEAZ6YDCQ_cjs.createTool({
16361
16479
  id: "skill-search",
16362
16480
  description: "Search across skill content to find relevant information. Useful when you need to find specific details within skills.",
16363
16481
  inputSchema: z10__default.default.object({
@@ -16394,6 +16512,17 @@ ${skillInstructions}`;
16394
16512
  });
16395
16513
  }
16396
16514
  // ===========================================================================
16515
+ // Helpers
16516
+ // ===========================================================================
16517
+ /**
16518
+ * Mark a tool as never requiring approval.
16519
+ * Skill tools are internal plumbing and should bypass requireToolApproval.
16520
+ */
16521
+ withNoApproval(tool2) {
16522
+ tool2.needsApprovalFn = () => false;
16523
+ return tool2;
16524
+ }
16525
+ // ===========================================================================
16397
16526
  // Processor Interface
16398
16527
  // ===========================================================================
16399
16528
  /**
@@ -16429,13 +16558,13 @@ ${skillInstructions}`;
16429
16558
  }
16430
16559
  const skillTools = {};
16431
16560
  if (hasSkills) {
16432
- skillTools["skill-activate"] = this.createSkillActivateTool();
16433
- skillTools["skill-search"] = this.createSkillSearchTool();
16561
+ skillTools["skill-activate"] = this.withNoApproval(this.createSkillActivateTool());
16562
+ skillTools["skill-search"] = this.withNoApproval(this.createSkillSearchTool());
16434
16563
  }
16435
16564
  if (this._activatedSkills.size > 0) {
16436
- skillTools["skill-read-reference"] = this.createSkillReadReferenceTool();
16437
- skillTools["skill-read-script"] = this.createSkillReadScriptTool();
16438
- skillTools["skill-read-asset"] = this.createSkillReadAssetTool();
16565
+ skillTools["skill-read-reference"] = this.withNoApproval(this.createSkillReadReferenceTool());
16566
+ skillTools["skill-read-script"] = this.withNoApproval(this.createSkillReadScriptTool());
16567
+ skillTools["skill-read-asset"] = this.withNoApproval(this.createSkillReadAssetTool());
16439
16568
  }
16440
16569
  return {
16441
16570
  messageList,
@@ -16479,7 +16608,7 @@ var AgentLegacyHandler = class {
16479
16608
  if (process.env.NODE_ENV !== "test") {
16480
16609
  this.capabilities.logger.debug(`[Agents:${this.capabilities.name}] - Starting generation`, { runId });
16481
16610
  }
16482
- const agentSpan = chunkCYUP7QWT_cjs.getOrCreateSpan({
16611
+ const agentSpan = chunkKRAGJ433_cjs.getOrCreateSpan({
16483
16612
  type: "agent_run" /* AGENT_RUN */,
16484
16613
  name: `agent run: '${this.capabilities.id}'`,
16485
16614
  entityType: "agent" /* AGENT */,
@@ -16534,7 +16663,7 @@ var AgentLegacyHandler = class {
16534
16663
  methodType: methodType === "generate" ? "generateLegacy" : "streamLegacy",
16535
16664
  memoryConfig
16536
16665
  });
16537
- let messageList = new chunkCZ4NQANZ_cjs.MessageList({
16666
+ let messageList = new chunkYW54RH77_cjs.MessageList({
16538
16667
  threadId,
16539
16668
  resourceId,
16540
16669
  generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
@@ -16665,7 +16794,7 @@ var AgentLegacyHandler = class {
16665
16794
  result: resToLog,
16666
16795
  threadId
16667
16796
  });
16668
- const messageListResponses = new chunkCZ4NQANZ_cjs.MessageList({
16797
+ const messageListResponses = new chunkYW54RH77_cjs.MessageList({
16669
16798
  threadId,
16670
16799
  resourceId,
16671
16800
  generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
@@ -16714,7 +16843,7 @@ var AgentLegacyHandler = class {
16714
16843
  model: titleModel,
16715
16844
  instructions: titleInstructions
16716
16845
  } = this.capabilities.resolveTitleGenerationConfig(config?.generateTitle);
16717
- if (shouldGenerate && !threadExists && userMessage) {
16846
+ if (shouldGenerate && !thread2.title && userMessage) {
16718
16847
  promises.push(
16719
16848
  this.capabilities.genTitle(userMessage, requestContext, { currentSpan: agentSpan }, titleModel, titleInstructions).then((title) => {
16720
16849
  if (title) {
@@ -17686,6 +17815,7 @@ var coreToolSchema = z10.z.object({
17686
17815
  ]),
17687
17816
  outputSchema: z10.z.union([z10.z.record(z10.z.string(), z10.z.any()), z10.z.any()]).optional(),
17688
17817
  execute: z10.z.optional(z10.z.function(z10.z.tuple([z10.z.any(), z10.z.any()]), z10.z.promise(z10.z.any()))),
17818
+ toModelOutput: z10.z.optional(z10.z.function(z10.z.tuple([z10.z.any()]), z10.z.any())),
17689
17819
  type: z10.z.union([z10.z.literal("function"), z10.z.literal("provider-defined"), z10.z.undefined()]).optional(),
17690
17820
  args: z10.z.record(z10.z.string(), z10.z.any()).optional()
17691
17821
  });
@@ -17703,7 +17833,7 @@ var prepareToolsStepOutputSchema = z10.z.object({
17703
17833
  var prepareMemoryStepOutputSchema = z10.z.object({
17704
17834
  threadExists: z10.z.boolean(),
17705
17835
  thread: storageThreadSchema.optional(),
17706
- messageList: z10.z.instanceof(chunkCZ4NQANZ_cjs.MessageList),
17836
+ messageList: z10.z.instanceof(chunkYW54RH77_cjs.MessageList),
17707
17837
  /** Shared processor states map that persists across loop iterations for both input and output processors */
17708
17838
  processorStates: z10.z.instanceof(Map),
17709
17839
  /** Tripwire data when input processor triggered abort */
@@ -17743,7 +17873,7 @@ function createPrepareMemoryStep({
17743
17873
  outputSchema: prepareMemoryStepOutputSchema,
17744
17874
  execute: async ({ tracingContext }) => {
17745
17875
  const thread = threadFromArgs;
17746
- const messageList = new chunkCZ4NQANZ_cjs.MessageList({
17876
+ const messageList = new chunkYW54RH77_cjs.MessageList({
17747
17877
  threadId: thread?.id,
17748
17878
  resourceId,
17749
17879
  generateMessageId: capabilities.generateMessageId,
@@ -18217,7 +18347,7 @@ var Agent = class extends chunkRO47SMI7_cjs.MastraBase {
18217
18347
  * Throws an error if validation fails.
18218
18348
  */
18219
18349
  async #validateRequestContext(requestContext) {
18220
- if (this.#requestContextSchema && chunk65PHUUMF_cjs.isZodType(this.#requestContextSchema)) {
18350
+ if (this.#requestContextSchema && chunkQDH6MVJ7_cjs.isZodType(this.#requestContextSchema)) {
18221
18351
  const contextValues = requestContext?.all ?? {};
18222
18352
  const validatedRequestContext = await this.#requestContextSchema.safeParseAsync(contextValues);
18223
18353
  if (!validatedRequestContext.success) {
@@ -18943,7 +19073,7 @@ ${errorMessages}`,
18943
19073
  */
18944
19074
  listTools({ requestContext = new chunkVDKWYUGC_cjs.RequestContext() } = {}) {
18945
19075
  if (typeof this.#tools !== "function") {
18946
- return chunk65PHUUMF_cjs.ensureToolProperties(this.#tools);
19076
+ return chunkQDH6MVJ7_cjs.ensureToolProperties(this.#tools);
18947
19077
  }
18948
19078
  const result = this.#tools({
18949
19079
  requestContext,
@@ -18964,7 +19094,7 @@ ${errorMessages}`,
18964
19094
  this.logger.error(mastraError.toString());
18965
19095
  throw mastraError;
18966
19096
  }
18967
- return chunk65PHUUMF_cjs.ensureToolProperties(tools);
19097
+ return chunkQDH6MVJ7_cjs.ensureToolProperties(tools);
18968
19098
  });
18969
19099
  }
18970
19100
  /**
@@ -18996,7 +19126,7 @@ ${errorMessages}`,
18996
19126
  });
18997
19127
  });
18998
19128
  } else {
18999
- llm = new chunkHYRYTTMT_cjs.MastraLLMV1({
19129
+ llm = new chunkPHHJLGZU_cjs.MastraLLMV1({
19000
19130
  model: resolvedModel,
19001
19131
  mastra: this.#mastra,
19002
19132
  options: { tracingPolicy: this.#options?.tracingPolicy }
@@ -19021,7 +19151,7 @@ ${errorMessages}`,
19021
19151
  */
19022
19152
  async resolveModelConfig(modelConfig, requestContext) {
19023
19153
  try {
19024
- return await chunkVD5YA6RH_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
19154
+ return await chunkQSN5KQXZ_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
19025
19155
  } catch (error) {
19026
19156
  const mastraError = new chunk4U7ZLI36_cjs.MastraError({
19027
19157
  id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
@@ -19232,7 +19362,7 @@ ${errorMessages}`,
19232
19362
  instructions
19233
19363
  }) {
19234
19364
  const llm = await this.getLLM({ requestContext, model });
19235
- const normMessage = new chunkCZ4NQANZ_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
19365
+ const normMessage = new chunkYW54RH77_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
19236
19366
  if (!normMessage) {
19237
19367
  throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
19238
19368
  }
@@ -19255,7 +19385,7 @@ ${errorMessages}`,
19255
19385
  const systemInstructions = await this.resolveTitleInstructions(requestContext, instructions);
19256
19386
  let text = "";
19257
19387
  if (isSupportedLanguageModel(llm.getModel())) {
19258
- const messageList = new chunkCZ4NQANZ_cjs.MessageList().add(
19388
+ const messageList = new chunkYW54RH77_cjs.MessageList().add(
19259
19389
  [
19260
19390
  {
19261
19391
  role: "system",
@@ -19308,7 +19438,7 @@ ${errorMessages}`,
19308
19438
  async genTitle(userMessage, requestContext, tracingContext, model, instructions) {
19309
19439
  try {
19310
19440
  if (userMessage) {
19311
- const normMessage = new chunkCZ4NQANZ_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
19441
+ const normMessage = new chunkYW54RH77_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
19312
19442
  if (normMessage) {
19313
19443
  return await this.generateTitleFromUserMessage({
19314
19444
  message: normMessage,
@@ -19319,7 +19449,7 @@ ${errorMessages}`,
19319
19449
  });
19320
19450
  }
19321
19451
  }
19322
- return `New Thread ${(/* @__PURE__ */ new Date()).toISOString()}`;
19452
+ return void 0;
19323
19453
  } catch (e) {
19324
19454
  this.logger.error("Error generating title:", e);
19325
19455
  return void 0;
@@ -19328,6 +19458,13 @@ ${errorMessages}`,
19328
19458
  __setMemory(memory) {
19329
19459
  this.#memory = memory;
19330
19460
  }
19461
+ __setWorkspace(workspace) {
19462
+ this.#workspace = workspace;
19463
+ if (this.#mastra && workspace && typeof workspace !== "function") {
19464
+ workspace.__setLogger(this.logger);
19465
+ this.#mastra.addWorkspace(workspace);
19466
+ }
19467
+ }
19331
19468
  /**
19332
19469
  * Retrieves and converts memory tools to CoreTool format.
19333
19470
  * @internal
@@ -19377,7 +19514,7 @@ ${errorMessages}`,
19377
19514
  tracingPolicy: this.#options?.tracingPolicy,
19378
19515
  requireApproval: toolObj.requireApproval
19379
19516
  };
19380
- const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19517
+ const convertedToCoreTool = chunkQDH6MVJ7_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19381
19518
  convertedMemoryTools[toolName] = convertedToCoreTool;
19382
19519
  }
19383
19520
  }
@@ -19405,7 +19542,7 @@ ${errorMessages}`,
19405
19542
  if (!workspace) {
19406
19543
  return convertedWorkspaceTools;
19407
19544
  }
19408
- const workspaceTools = chunk4KFEMXTV_cjs.createWorkspaceTools(workspace);
19545
+ const workspaceTools = chunkS4VVZI4E_cjs.createWorkspaceTools(workspace);
19409
19546
  if (Object.keys(workspaceTools).length > 0) {
19410
19547
  this.logger.debug(`[Agent:${this.name}] - Adding workspace tools: ${Object.keys(workspaceTools).join(", ")}`, {
19411
19548
  runId
@@ -19426,7 +19563,7 @@ ${errorMessages}`,
19426
19563
  tracingPolicy: this.#options?.tracingPolicy,
19427
19564
  requireApproval: toolObj.requireApproval
19428
19565
  };
19429
- const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19566
+ const convertedToCoreTool = chunkQDH6MVJ7_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19430
19567
  convertedWorkspaceTools[toolName] = convertedToCoreTool;
19431
19568
  }
19432
19569
  }
@@ -19583,7 +19720,7 @@ ${errorMessages}`,
19583
19720
  tracingPolicy: this.#options?.tracingPolicy,
19584
19721
  requireApproval: tool2.requireApproval
19585
19722
  };
19586
- return [k, chunk65PHUUMF_cjs.makeCoreTool(tool2, options, void 0, autoResumeSuspendedTools)];
19723
+ return [k, chunkQDH6MVJ7_cjs.makeCoreTool(tool2, options, void 0, autoResumeSuspendedTools)];
19587
19724
  })
19588
19725
  );
19589
19726
  const assignedToolEntriesConverted = Object.fromEntries(
@@ -19633,7 +19770,7 @@ ${errorMessages}`,
19633
19770
  tracingPolicy: this.#options?.tracingPolicy,
19634
19771
  requireApproval: toolObj.requireApproval
19635
19772
  };
19636
- const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(toolObj, options, "toolset", autoResumeSuspendedTools);
19773
+ const convertedToCoreTool = chunkQDH6MVJ7_cjs.makeCoreTool(toolObj, options, "toolset", autoResumeSuspendedTools);
19637
19774
  toolsForRequest[toolName] = convertedToCoreTool;
19638
19775
  }
19639
19776
  }
@@ -19678,7 +19815,7 @@ ${errorMessages}`,
19678
19815
  tracingPolicy: this.#options?.tracingPolicy,
19679
19816
  requireApproval: tool2.requireApproval
19680
19817
  };
19681
- const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(rest, options, "client-tool", autoResumeSuspendedTools);
19818
+ const convertedToCoreTool = chunkQDH6MVJ7_cjs.makeCoreTool(rest, options, "client-tool", autoResumeSuspendedTools);
19682
19819
  toolsForRequest[toolName] = convertedToCoreTool;
19683
19820
  }
19684
19821
  }
@@ -19717,7 +19854,7 @@ ${errorMessages}`,
19717
19854
  subAgentResourceId: z10.z.string().describe("The resource ID of the agent").optional()
19718
19855
  });
19719
19856
  const modelVersion = (await agent.getModel({ requestContext })).specificationVersion;
19720
- const toolObj = chunk7UWHFWST_cjs.createTool({
19857
+ const toolObj = chunkEAZ6YDCQ_cjs.createTool({
19721
19858
  id: `agent-${agentName}`,
19722
19859
  description: agent.getDescription() || `Agent: ${agentName}`,
19723
19860
  inputSchema: agentInputSchema,
@@ -19726,6 +19863,7 @@ ${errorMessages}`,
19726
19863
  // manually wrap agent tools with tracing, so that we can pass the
19727
19864
  // current tool span onto the agent to maintain continuity of the trace
19728
19865
  execute: async (inputData, context) => {
19866
+ const savedMastraMemory = requestContext.get("MastraMemory");
19729
19867
  try {
19730
19868
  this.logger.debug(`[Agent:${this.name}] - Executing agent as tool ${agentName}`, {
19731
19869
  name: agentName,
@@ -19874,8 +20012,14 @@ ${errorMessages}`,
19874
20012
  }
19875
20013
  result = { text: fullText };
19876
20014
  }
20015
+ if (savedMastraMemory !== void 0) {
20016
+ requestContext.set("MastraMemory", savedMastraMemory);
20017
+ }
19877
20018
  return result;
19878
20019
  } catch (err) {
20020
+ if (savedMastraMemory !== void 0) {
20021
+ requestContext.set("MastraMemory", savedMastraMemory);
20022
+ }
19879
20023
  const mastraError = new chunk4U7ZLI36_cjs.MastraError(
19880
20024
  {
19881
20025
  id: "AGENT_AGENT_TOOL_EXECUTION_FAILED",
@@ -19912,7 +20056,7 @@ ${errorMessages}`,
19912
20056
  tracingContext,
19913
20057
  tracingPolicy: this.#options?.tracingPolicy
19914
20058
  };
19915
- convertedAgentTools[`agent-${agentName}`] = chunk65PHUUMF_cjs.makeCoreTool(
20059
+ convertedAgentTools[`agent-${agentName}`] = chunkQDH6MVJ7_cjs.makeCoreTool(
19916
20060
  toolObj,
19917
20061
  options,
19918
20062
  void 0,
@@ -19944,7 +20088,7 @@ ${errorMessages}`,
19944
20088
  inputData: workflow.inputSchema ?? z10.z.object({}).passthrough(),
19945
20089
  ...workflow.stateSchema ? { initialState: workflow.stateSchema } : {}
19946
20090
  });
19947
- const toolObj = chunk7UWHFWST_cjs.createTool({
20091
+ const toolObj = chunkEAZ6YDCQ_cjs.createTool({
19948
20092
  id: `workflow-${workflowName}`,
19949
20093
  description: workflow.description || `Workflow: ${workflowName}`,
19950
20094
  inputSchema: extendedInputSchema,
@@ -20097,7 +20241,7 @@ ${errorMessages}`,
20097
20241
  tracingContext,
20098
20242
  tracingPolicy: this.#options?.tracingPolicy
20099
20243
  };
20100
- convertedWorkflowTools[`workflow-${workflowName}`] = chunk65PHUUMF_cjs.makeCoreTool(
20244
+ convertedWorkflowTools[`workflow-${workflowName}`] = chunkQDH6MVJ7_cjs.makeCoreTool(
20101
20245
  toolObj,
20102
20246
  options,
20103
20247
  void 0,
@@ -20127,7 +20271,7 @@ ${errorMessages}`,
20127
20271
  let mastraProxy = void 0;
20128
20272
  const logger = this.logger;
20129
20273
  if (this.#mastra) {
20130
- mastraProxy = chunk65PHUUMF_cjs.createMastraProxy({ mastra: this.#mastra, logger });
20274
+ mastraProxy = chunkQDH6MVJ7_cjs.createMastraProxy({ mastra: this.#mastra, logger });
20131
20275
  }
20132
20276
  const assignedTools = await this.listAssignedTools({
20133
20277
  runId,
@@ -20196,7 +20340,7 @@ ${errorMessages}`,
20196
20340
  mastraProxy,
20197
20341
  autoResumeSuspendedTools
20198
20342
  });
20199
- return this.formatTools({
20343
+ const allTools = {
20200
20344
  ...assignedTools,
20201
20345
  ...memoryTools,
20202
20346
  ...toolsetTools,
@@ -20204,7 +20348,8 @@ ${errorMessages}`,
20204
20348
  ...agentTools,
20205
20349
  ...workflowTools,
20206
20350
  ...workspaceTools
20207
- });
20351
+ };
20352
+ return this.formatTools(allTools);
20208
20353
  }
20209
20354
  /**
20210
20355
  * Formats and validates tool names to comply with naming restrictions.
@@ -20377,7 +20522,7 @@ ${errorMessages}`,
20377
20522
  throw mastraError;
20378
20523
  }
20379
20524
  let headers;
20380
- if (resolvedModel instanceof chunkVD5YA6RH_cjs.ModelRouterLanguageModel) {
20525
+ if (resolvedModel instanceof chunkQSN5KQXZ_cjs.ModelRouterLanguageModel) {
20381
20526
  headers = resolvedModel.config?.headers;
20382
20527
  }
20383
20528
  return [
@@ -20423,7 +20568,7 @@ ${errorMessages}`,
20423
20568
  throw mastraError;
20424
20569
  }
20425
20570
  let headers;
20426
- if (model2 instanceof chunkVD5YA6RH_cjs.ModelRouterLanguageModel) {
20571
+ if (model2 instanceof chunkQSN5KQXZ_cjs.ModelRouterLanguageModel) {
20427
20572
  headers = model2.config?.headers;
20428
20573
  }
20429
20574
  return {
@@ -20481,7 +20626,7 @@ ${errorMessages}`,
20481
20626
  const targetProvider = structuredOutputModel.provider;
20482
20627
  const targetModelId = structuredOutputModel.modelId;
20483
20628
  if (targetProvider.includes("openai") || targetModelId.includes("openai")) {
20484
- if (chunk65PHUUMF_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
20629
+ if (chunkQDH6MVJ7_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
20485
20630
  const modelInfo = {
20486
20631
  provider: targetProvider,
20487
20632
  modelId: targetModelId,
@@ -20504,7 +20649,7 @@ ${errorMessages}`,
20504
20649
  resourceId
20505
20650
  }) || crypto2.randomUUID();
20506
20651
  const instructions = options.instructions || await this.getInstructions({ requestContext });
20507
- const agentSpan = chunkCYUP7QWT_cjs.getOrCreateSpan({
20652
+ const agentSpan = chunkKRAGJ433_cjs.getOrCreateSpan({
20508
20653
  type: "agent_run" /* AGENT_RUN */,
20509
20654
  name: `agent run: '${this.id}'`,
20510
20655
  entityType: "agent" /* AGENT */,
@@ -20667,7 +20812,7 @@ ${errorMessages}`,
20667
20812
  model: titleModel,
20668
20813
  instructions: titleInstructions
20669
20814
  } = this.resolveTitleGenerationConfig(config.generateTitle);
20670
- if (shouldGenerate && !threadExists) {
20815
+ if (shouldGenerate && !thread.title) {
20671
20816
  const userMessage = this.getMostRecentUserMessage(messageList.get.all.ui());
20672
20817
  if (userMessage) {
20673
20818
  const title = await this.genTitle(
@@ -20888,7 +21033,7 @@ ${errorMessages}`,
20888
21033
  const defaultOptions = await this.getDefaultOptions({
20889
21034
  requestContext: options?.requestContext
20890
21035
  });
20891
- const mergedOptions = chunk65PHUUMF_cjs.deepMerge(
21036
+ const mergedOptions = chunkQDH6MVJ7_cjs.deepMerge(
20892
21037
  defaultOptions,
20893
21038
  options ?? {}
20894
21039
  );
@@ -20952,7 +21097,7 @@ ${errorMessages}`,
20952
21097
  const defaultOptions = await this.getDefaultOptions({
20953
21098
  requestContext: streamOptions?.requestContext
20954
21099
  });
20955
- const mergedOptions = chunk65PHUUMF_cjs.deepMerge(
21100
+ const mergedOptions = chunkQDH6MVJ7_cjs.deepMerge(
20956
21101
  defaultOptions,
20957
21102
  streamOptions ?? {}
20958
21103
  );
@@ -21010,7 +21155,7 @@ ${errorMessages}`,
21010
21155
  const defaultOptions = await this.getDefaultOptions({
21011
21156
  requestContext: streamOptions?.requestContext
21012
21157
  });
21013
- let mergedStreamOptions = chunk65PHUUMF_cjs.deepMerge(
21158
+ let mergedStreamOptions = chunkQDH6MVJ7_cjs.deepMerge(
21014
21159
  defaultOptions,
21015
21160
  streamOptions ?? {}
21016
21161
  );
@@ -21084,7 +21229,7 @@ ${errorMessages}`,
21084
21229
  const defaultOptions = await this.getDefaultOptions({
21085
21230
  requestContext: options?.requestContext
21086
21231
  });
21087
- const mergedOptions = chunk65PHUUMF_cjs.deepMerge(
21232
+ const mergedOptions = chunkQDH6MVJ7_cjs.deepMerge(
21088
21233
  defaultOptions,
21089
21234
  options ?? {}
21090
21235
  );
@@ -23289,7 +23434,7 @@ var ToolSearchProcessor = class {
23289
23434
  minScore: options.search?.minScore ?? 0
23290
23435
  };
23291
23436
  this.ttl = options.ttl ?? 36e5;
23292
- this.bm25Index = new chunk4KFEMXTV_cjs.BM25Index({}, TOOL_SEARCH_TOKENIZE_OPTIONS);
23437
+ this.bm25Index = new chunkS4VVZI4E_cjs.BM25Index({}, TOOL_SEARCH_TOKENIZE_OPTIONS);
23293
23438
  this.indexTools();
23294
23439
  if (this.ttl > 0) {
23295
23440
  this.scheduleCleanup();
@@ -23454,7 +23599,7 @@ var ToolSearchProcessor = class {
23454
23599
  messageList.addSystem(
23455
23600
  "To discover available tools, call search_tools with a keyword query. To add a tool to the conversation, call load_tool with the tool name. Tools must be loaded before they can be used."
23456
23601
  );
23457
- const searchTool = chunk7UWHFWST_cjs.createTool({
23602
+ const searchTool = chunkEAZ6YDCQ_cjs.createTool({
23458
23603
  id: "search_tools",
23459
23604
  description: "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools with their names and descriptions. After finding a useful tool, use load_tool to make it available.",
23460
23605
  inputSchema: z10.z.object({
@@ -23484,7 +23629,7 @@ var ToolSearchProcessor = class {
23484
23629
  };
23485
23630
  }
23486
23631
  });
23487
- const loadTool = chunk7UWHFWST_cjs.createTool({
23632
+ const loadTool = chunkEAZ6YDCQ_cjs.createTool({
23488
23633
  id: "load_tool",
23489
23634
  description: "Load a specific tool into your context. Call this after finding a tool with search_tools. Once loaded, the tool will be available for use. Args: toolName - The exact name of the tool to load (from search results).",
23490
23635
  inputSchema: z10.z.object({
@@ -24036,7 +24181,7 @@ var SemanticRecall = class {
24036
24181
  */
24037
24182
  formatCrossThreadMessages(messages, currentThreadId) {
24038
24183
  let result = ``;
24039
- const v1Messages = new chunkCZ4NQANZ_cjs.MessageList().add(messages, "memory").get.all.v1();
24184
+ const v1Messages = new chunkYW54RH77_cjs.MessageList().add(messages, "memory").get.all.v1();
24040
24185
  let lastYmd = null;
24041
24186
  for (const msg of v1Messages) {
24042
24187
  const date = msg.createdAt;
@@ -24478,7 +24623,7 @@ https://mastra.ai/en/docs/memory/semantic-recall`
24478
24623
  );
24479
24624
  }
24480
24625
  if (typeof config.embedder === "string") {
24481
- this.embedder = new chunkVD5YA6RH_cjs.ModelRouterEmbeddingModel(config.embedder);
24626
+ this.embedder = new chunkQSN5KQXZ_cjs.ModelRouterEmbeddingModel(config.embedder);
24482
24627
  } else {
24483
24628
  this.embedder = config.embedder;
24484
24629
  }
@@ -24517,7 +24662,7 @@ https://mastra.ai/en/docs/memory/overview`
24517
24662
  }
24518
24663
  setEmbedder(embedder, embedderOptions) {
24519
24664
  if (typeof embedder === "string") {
24520
- this.embedder = new chunkVD5YA6RH_cjs.ModelRouterEmbeddingModel(embedder);
24665
+ this.embedder = new chunkQSN5KQXZ_cjs.ModelRouterEmbeddingModel(embedder);
24521
24666
  } else {
24522
24667
  this.embedder = embedder;
24523
24668
  }
@@ -24541,6 +24686,35 @@ https://mastra.ai/en/docs/memory/overview`
24541
24686
  listTools(_config) {
24542
24687
  return {};
24543
24688
  }
24689
+ /**
24690
+ * Cached promise for the embedding dimension probe.
24691
+ * Stored as a promise to deduplicate concurrent calls.
24692
+ */
24693
+ _embeddingDimensionPromise;
24694
+ /**
24695
+ * Probe the embedder to determine its actual output dimension.
24696
+ * The result is cached so subsequent calls are free.
24697
+ */
24698
+ async getEmbeddingDimension() {
24699
+ if (!this.embedder) return void 0;
24700
+ if (!this._embeddingDimensionPromise) {
24701
+ this._embeddingDimensionPromise = (async () => {
24702
+ try {
24703
+ const result = await this.embedder.doEmbed({
24704
+ values: ["a"],
24705
+ ...this.embedderOptions || {}
24706
+ });
24707
+ return result.embeddings[0]?.length;
24708
+ } catch (e) {
24709
+ console.warn(
24710
+ `[Mastra Memory] Failed to probe embedder for dimension, falling back to default. This may cause index name mismatches if the embedder uses non-default dimensions. Error: ${e}`
24711
+ );
24712
+ return void 0;
24713
+ }
24714
+ })();
24715
+ }
24716
+ return this._embeddingDimensionPromise;
24717
+ }
24544
24718
  /**
24545
24719
  * Get the index name for semantic recall embeddings.
24546
24720
  * This is used to ensure consistency between the Memory class and SemanticRecall processor.
@@ -24584,7 +24758,7 @@ https://mastra.ai/en/docs/memory/overview`
24584
24758
  "The threads.generateTitle option has been moved. Use the top-level generateTitle option instead."
24585
24759
  );
24586
24760
  }
24587
- const mergedConfig = chunk65PHUUMF_cjs.deepMerge(this.threadConfig, config || {});
24761
+ const mergedConfig = chunkQDH6MVJ7_cjs.deepMerge(this.threadConfig, config || {});
24588
24762
  if (typeof config?.workingMemory === "object" && config.workingMemory?.schema && typeof mergedConfig.workingMemory === "object") {
24589
24763
  mergedConfig.workingMemory.schema = config.workingMemory.schema;
24590
24764
  }
@@ -24613,7 +24787,7 @@ https://mastra.ai/en/docs/memory/overview`
24613
24787
  source: "memory",
24614
24788
  resourceId
24615
24789
  }),
24616
- title: title || `New Thread ${(/* @__PURE__ */ new Date()).toISOString()}`,
24790
+ title: title || "",
24617
24791
  resourceId,
24618
24792
  createdAt: /* @__PURE__ */ new Date(),
24619
24793
  updatedAt: /* @__PURE__ */ new Date(),
@@ -24730,7 +24904,8 @@ https://mastra.ai/en/docs/memory/overview`
24730
24904
  const hasSemanticRecall = configuredProcessors.some((p) => !isProcessorWorkflow(p) && p.id === "semantic-recall");
24731
24905
  if (!hasSemanticRecall) {
24732
24906
  const semanticConfig = typeof effectiveConfig.semanticRecall === "object" ? effectiveConfig.semanticRecall : {};
24733
- const indexName = this.getEmbeddingIndexName();
24907
+ const embeddingDimension = await this.getEmbeddingDimension();
24908
+ const indexName = this.getEmbeddingIndexName(embeddingDimension);
24734
24909
  processors.push(
24735
24910
  new SemanticRecall({
24736
24911
  storage: memoryStore,
@@ -24788,7 +24963,8 @@ https://mastra.ai/en/docs/memory/overview`
24788
24963
  const hasSemanticRecall = configuredProcessors.some((p) => !isProcessorWorkflow(p) && p.id === "semantic-recall");
24789
24964
  if (!hasSemanticRecall) {
24790
24965
  const semanticRecallConfig = typeof effectiveConfig.semanticRecall === "object" ? effectiveConfig.semanticRecall : {};
24791
- const indexName = this.getEmbeddingIndexName();
24966
+ const embeddingDimension = await this.getEmbeddingDimension();
24967
+ const indexName = this.getEmbeddingIndexName(embeddingDimension);
24792
24968
  processors.push(
24793
24969
  new SemanticRecall({
24794
24970
  storage: memoryStore,
@@ -24932,7 +25108,7 @@ var MockMemory = class extends MastraMemory {
24932
25108
  } = {}) {
24933
25109
  super({
24934
25110
  name: "mock",
24935
- storage: storage || new chunkBP7VYTOP_cjs.InMemoryStore(),
25111
+ storage: storage || new chunkJZ6TH4HQ_cjs.InMemoryStore(),
24936
25112
  options: {
24937
25113
  workingMemory: enableWorkingMemory ? { enabled: true, template: workingMemoryTemplate } : void 0,
24938
25114
  lastMessages: enableMessageHistory ? 10 : void 0
@@ -25010,7 +25186,7 @@ var MockMemory = class extends MastraMemory {
25010
25186
  return {};
25011
25187
  }
25012
25188
  return {
25013
- updateWorkingMemory: chunk7UWHFWST_cjs.createTool({
25189
+ updateWorkingMemory: chunkEAZ6YDCQ_cjs.createTool({
25014
25190
  id: "update-working-memory",
25015
25191
  description: `Update the working memory with new information. Any data not included will be overwritten.`,
25016
25192
  inputSchema: z10__default.default.object({ memory: z10__default.default.string() }),
@@ -25240,5 +25416,5 @@ exports.validateStepRequestContext = validateStepRequestContext;
25240
25416
  exports.validateStepResumeData = validateStepResumeData;
25241
25417
  exports.validateStepStateData = validateStepStateData;
25242
25418
  exports.validateStepSuspendData = validateStepSuspendData;
25243
- //# sourceMappingURL=chunk-4IJ4UDZX.cjs.map
25244
- //# sourceMappingURL=chunk-4IJ4UDZX.cjs.map
25419
+ //# sourceMappingURL=chunk-RH2K66O2.cjs.map
25420
+ //# sourceMappingURL=chunk-RH2K66O2.cjs.map