@mastra/core 1.0.0-beta.14 → 1.0.0-beta.15

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 (349) hide show
  1. package/CHANGELOG.md +307 -0
  2. package/dist/agent/agent-legacy.d.ts.map +1 -1
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/index.cjs +11 -11
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/index.cjs +3 -3
  7. package/dist/agent/message-list/index.d.ts +1 -1
  8. package/dist/agent/message-list/index.d.ts.map +1 -1
  9. package/dist/agent/message-list/index.js +1 -1
  10. package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
  11. package/dist/agent/utils.d.ts.map +1 -1
  12. package/dist/{chunk-TDM43G4I.cjs → chunk-2OOMJRXZ.cjs} +9 -9
  13. package/dist/{chunk-TDM43G4I.cjs.map → chunk-2OOMJRXZ.cjs.map} +1 -1
  14. package/dist/chunk-37YWZMBX.js +27 -0
  15. package/dist/chunk-37YWZMBX.js.map +1 -0
  16. package/dist/{chunk-GBQXIVL6.js → chunk-3HDRO3GG.js} +790 -1206
  17. package/dist/chunk-3HDRO3GG.js.map +1 -0
  18. package/dist/{chunk-VZJOEGQA.js → chunk-4DFWV4IR.js} +2 -2
  19. package/dist/chunk-4DFWV4IR.js.map +1 -0
  20. package/dist/{chunk-373OC54J.js → chunk-4HP7CS6L.js} +7 -6
  21. package/dist/chunk-4HP7CS6L.js.map +1 -0
  22. package/dist/{chunk-4CMIJQF6.js → chunk-4J4M2Q5R.js} +14 -14
  23. package/dist/chunk-4J4M2Q5R.js.map +1 -0
  24. package/dist/{chunk-HWMMIRIF.cjs → chunk-4U7ZLI36.cjs} +3 -2
  25. package/dist/chunk-4U7ZLI36.cjs.map +1 -0
  26. package/dist/{chunk-Z55SJVEC.cjs → chunk-6HJFCSJ4.cjs} +7 -6
  27. package/dist/chunk-6HJFCSJ4.cjs.map +1 -0
  28. package/dist/{chunk-EGHGFLL3.cjs → chunk-AAX7ZOM7.cjs} +2 -2
  29. package/dist/chunk-AAX7ZOM7.cjs.map +1 -0
  30. package/dist/{chunk-SLBWA2F3.js → chunk-AR5CF3IN.js} +3 -3
  31. package/dist/{chunk-SLBWA2F3.js.map → chunk-AR5CF3IN.js.map} +1 -1
  32. package/dist/{chunk-QDVYP2T7.js → chunk-BAZHNX5P.js} +8 -8
  33. package/dist/{chunk-QDVYP2T7.js.map → chunk-BAZHNX5P.js.map} +1 -1
  34. package/dist/{chunk-O3ULBGV6.cjs → chunk-BC2VKOH4.cjs} +43 -21
  35. package/dist/chunk-BC2VKOH4.cjs.map +1 -0
  36. package/dist/{chunk-5UQ5TB6J.js → chunk-BCUKD2XG.js} +59 -19
  37. package/dist/chunk-BCUKD2XG.js.map +1 -0
  38. package/dist/{chunk-67LM2UCT.js → chunk-CBQ6WDUJ.js} +5 -5
  39. package/dist/{chunk-67LM2UCT.js.map → chunk-CBQ6WDUJ.js.map} +1 -1
  40. package/dist/chunk-CBVHOGXX.cjs +674 -0
  41. package/dist/chunk-CBVHOGXX.cjs.map +1 -0
  42. package/dist/{chunk-O5BQBZEF.cjs → chunk-CBY37FTP.cjs} +28 -28
  43. package/dist/{chunk-O5BQBZEF.cjs.map → chunk-CBY37FTP.cjs.map} +1 -1
  44. package/dist/{chunk-3IP3DZ7G.js → chunk-D2IFWD7A.js} +285 -124
  45. package/dist/chunk-D2IFWD7A.js.map +1 -0
  46. package/dist/{chunk-JAGQZZ43.cjs → chunk-DDK3URK2.cjs} +636 -313
  47. package/dist/chunk-DDK3URK2.cjs.map +1 -0
  48. package/dist/chunk-DRJTNGI4.cjs +263 -0
  49. package/dist/chunk-DRJTNGI4.cjs.map +1 -0
  50. package/dist/{chunk-72E3YF6A.cjs → chunk-EMLEZXTQ.cjs} +15 -12
  51. package/dist/chunk-EMLEZXTQ.cjs.map +1 -0
  52. package/dist/{chunk-YPLZDWG7.js → chunk-FJEVLHJT.js} +3 -2
  53. package/dist/chunk-FJEVLHJT.js.map +1 -0
  54. package/dist/{chunk-53SZJCBX.cjs → chunk-GXMJ5URG.cjs} +25 -25
  55. package/dist/{chunk-53SZJCBX.cjs.map → chunk-GXMJ5URG.cjs.map} +1 -1
  56. package/dist/chunk-H2NHG7QL.cjs +32 -0
  57. package/dist/chunk-H2NHG7QL.cjs.map +1 -0
  58. package/dist/chunk-HAYBGFPA.js +259 -0
  59. package/dist/chunk-HAYBGFPA.js.map +1 -0
  60. package/dist/{chunk-AYBJ5GAD.js → chunk-IHISDRFV.js} +124 -50
  61. package/dist/chunk-IHISDRFV.js.map +1 -0
  62. package/dist/{chunk-DBW6S25C.cjs → chunk-IRTICXRZ.cjs} +101 -61
  63. package/dist/chunk-IRTICXRZ.cjs.map +1 -0
  64. package/dist/{chunk-ETWAR2YE.cjs → chunk-LOV5NNGK.cjs} +811 -1235
  65. package/dist/chunk-LOV5NNGK.cjs.map +1 -0
  66. package/dist/{chunk-QF4MHFSU.js → chunk-NGWTSHNA.js} +470 -152
  67. package/dist/chunk-NGWTSHNA.js.map +1 -0
  68. package/dist/{chunk-72YCRTEX.cjs → chunk-O2CAMK4A.cjs} +13 -2
  69. package/dist/chunk-O2CAMK4A.cjs.map +1 -0
  70. package/dist/{chunk-GELVUDUY.js → chunk-O7M7DR4E.js} +3 -3
  71. package/dist/{chunk-GELVUDUY.js.map → chunk-O7M7DR4E.js.map} +1 -1
  72. package/dist/chunk-OTIGV7CL.js +10215 -0
  73. package/dist/chunk-OTIGV7CL.js.map +1 -0
  74. package/dist/{chunk-4AT6YQKZ.js → chunk-QXL3F3T2.js} +7 -4
  75. package/dist/chunk-QXL3F3T2.js.map +1 -0
  76. package/dist/{chunk-6CG7IY57.cjs → chunk-RA2CHJCY.cjs} +319 -158
  77. package/dist/chunk-RA2CHJCY.cjs.map +1 -0
  78. package/dist/chunk-RMV5HJM7.cjs +10237 -0
  79. package/dist/chunk-RMV5HJM7.cjs.map +1 -0
  80. package/dist/{chunk-FPDJ4XN6.cjs → chunk-S23TNDXG.cjs} +125 -51
  81. package/dist/chunk-S23TNDXG.cjs.map +1 -0
  82. package/dist/{chunk-OOUFPYSX.cjs → chunk-SSB4AVHU.cjs} +17 -17
  83. package/dist/{chunk-OOUFPYSX.cjs.map → chunk-SSB4AVHU.cjs.map} +1 -1
  84. package/dist/{chunk-TRUNX3AX.cjs → chunk-T2LVULCK.cjs} +31 -31
  85. package/dist/chunk-T2LVULCK.cjs.map +1 -0
  86. package/dist/{chunk-LDXKZYOV.js → chunk-XJB7J4UT.js} +30 -8
  87. package/dist/chunk-XJB7J4UT.js.map +1 -0
  88. package/dist/chunk-YV43YEZ6.js +598 -0
  89. package/dist/chunk-YV43YEZ6.js.map +1 -0
  90. package/dist/{chunk-Y36Y5MTD.js → chunk-ZGIVAQRI.js} +13 -3
  91. package/dist/chunk-ZGIVAQRI.js.map +1 -0
  92. package/dist/error/index.cjs +6 -6
  93. package/dist/error/index.d.ts +1 -0
  94. package/dist/error/index.d.ts.map +1 -1
  95. package/dist/error/index.js +1 -1
  96. package/dist/evals/index.cjs +49 -9
  97. package/dist/evals/index.js +2 -2
  98. package/dist/evals/scoreTraces/index.cjs +70 -22
  99. package/dist/evals/scoreTraces/index.cjs.map +1 -1
  100. package/dist/evals/scoreTraces/index.js +63 -15
  101. package/dist/evals/scoreTraces/index.js.map +1 -1
  102. package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
  103. package/dist/evals/scoreTraces/utils.d.ts.map +1 -1
  104. package/dist/evals/types.d.ts +568 -116
  105. package/dist/evals/types.d.ts.map +1 -1
  106. package/dist/index.cjs +2 -2
  107. package/dist/index.js +1 -1
  108. package/dist/integration/index.cjs +2 -2
  109. package/dist/integration/index.js +1 -1
  110. package/dist/llm/index.cjs +20 -20
  111. package/dist/llm/index.js +4 -4
  112. package/dist/llm/model/aisdk/v6/model.d.ts +1 -9
  113. package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
  114. package/dist/llm/model/embedding-router.d.ts +1 -1
  115. package/dist/llm/model/model.d.ts.map +1 -1
  116. package/dist/llm/model/model.loop.d.ts.map +1 -1
  117. package/dist/llm/model/provider-options.d.ts +2 -1
  118. package/dist/llm/model/provider-options.d.ts.map +1 -1
  119. package/dist/llm/model/provider-types.generated.d.ts +42 -17
  120. package/dist/loop/index.cjs +2 -2
  121. package/dist/loop/index.js +1 -1
  122. package/dist/loop/network/index.d.ts +6 -6
  123. package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts +1 -9
  124. package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts.map +1 -1
  125. package/dist/loop/types.d.ts +5 -2
  126. package/dist/loop/types.d.ts.map +1 -1
  127. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  128. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  129. package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
  130. package/dist/mastra/hooks.d.ts.map +1 -1
  131. package/dist/mastra/index.cjs +2 -2
  132. package/dist/mastra/index.d.ts +7 -2
  133. package/dist/mastra/index.d.ts.map +1 -1
  134. package/dist/mastra/index.js +1 -1
  135. package/dist/mcp/index.cjs +4 -4
  136. package/dist/mcp/index.js +1 -1
  137. package/dist/memory/index.cjs +26 -6
  138. package/dist/memory/index.d.ts +1 -0
  139. package/dist/memory/index.d.ts.map +1 -1
  140. package/dist/memory/index.js +1 -1
  141. package/dist/memory/memory.d.ts +9 -8
  142. package/dist/memory/memory.d.ts.map +1 -1
  143. package/dist/memory/mock.d.ts +2 -1
  144. package/dist/memory/mock.d.ts.map +1 -1
  145. package/dist/memory/types.d.ts +3 -4
  146. package/dist/memory/types.d.ts.map +1 -1
  147. package/dist/memory/working-memory-utils.d.ts +20 -0
  148. package/dist/memory/working-memory-utils.d.ts.map +1 -0
  149. package/dist/models-dev-26XLUKVK.cjs +12 -0
  150. package/dist/{models-dev-PPS7X4JM.cjs.map → models-dev-26XLUKVK.cjs.map} +1 -1
  151. package/dist/models-dev-HUFLQFPB.js +3 -0
  152. package/dist/{models-dev-E3WWI7VA.js.map → models-dev-HUFLQFPB.js.map} +1 -1
  153. package/dist/netlify-CUYK2MZ2.cjs +12 -0
  154. package/dist/{netlify-VZFM5UH3.cjs.map → netlify-CUYK2MZ2.cjs.map} +1 -1
  155. package/dist/netlify-J4QPOROO.js +3 -0
  156. package/dist/{netlify-TY656UYF.js.map → netlify-J4QPOROO.js.map} +1 -1
  157. package/dist/observability/index.cjs +14 -10
  158. package/dist/observability/index.js +1 -1
  159. package/dist/observability/types/tracing.d.ts +32 -19
  160. package/dist/observability/types/tracing.d.ts.map +1 -1
  161. package/dist/processors/index.cjs +37 -37
  162. package/dist/processors/index.d.ts +2 -0
  163. package/dist/processors/index.d.ts.map +1 -1
  164. package/dist/processors/index.js +1 -1
  165. package/dist/processors/memory/message-history.d.ts +7 -1
  166. package/dist/processors/memory/message-history.d.ts.map +1 -1
  167. package/dist/processors/processors/language-detector.d.ts.map +1 -1
  168. package/dist/processors/processors/moderation.d.ts.map +1 -1
  169. package/dist/processors/processors/pii-detector.d.ts.map +1 -1
  170. package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
  171. package/dist/processors/processors/token-limiter.d.ts +5 -2
  172. package/dist/processors/processors/token-limiter.d.ts.map +1 -1
  173. package/dist/processors/runner.d.ts +2 -0
  174. package/dist/processors/runner.d.ts.map +1 -1
  175. package/dist/provider-registry-6CIGRQVZ.js +3 -0
  176. package/dist/{provider-registry-NXVD764B.js.map → provider-registry-6CIGRQVZ.js.map} +1 -1
  177. package/dist/provider-registry-7O7FJ4BS.cjs +40 -0
  178. package/dist/{provider-registry-ZIWSEUQE.cjs.map → provider-registry-7O7FJ4BS.cjs.map} +1 -1
  179. package/dist/provider-registry.json +120 -46
  180. package/dist/relevance/index.cjs +3 -3
  181. package/dist/relevance/index.js +1 -1
  182. package/dist/server/index.cjs +5 -5
  183. package/dist/server/index.js +1 -1
  184. package/dist/storage/base.d.ts +40 -292
  185. package/dist/storage/base.d.ts.map +1 -1
  186. package/dist/storage/constants.cjs +60 -0
  187. package/dist/storage/constants.cjs.map +1 -0
  188. package/dist/storage/constants.d.ts +6 -1
  189. package/dist/storage/constants.d.ts.map +1 -1
  190. package/dist/storage/constants.js +3 -0
  191. package/dist/storage/constants.js.map +1 -0
  192. package/dist/storage/domains/agents/base.d.ts +2 -2
  193. package/dist/storage/domains/agents/base.d.ts.map +1 -1
  194. package/dist/storage/domains/agents/inmemory.d.ts +5 -4
  195. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  196. package/dist/storage/domains/base.d.ts +20 -0
  197. package/dist/storage/domains/base.d.ts.map +1 -0
  198. package/dist/storage/domains/index.d.ts +3 -0
  199. package/dist/storage/domains/index.d.ts.map +1 -1
  200. package/dist/storage/domains/inmemory-db.d.ts +57 -0
  201. package/dist/storage/domains/inmemory-db.d.ts.map +1 -0
  202. package/dist/storage/domains/memory/base.d.ts +2 -2
  203. package/dist/storage/domains/memory/base.d.ts.map +1 -1
  204. package/dist/storage/domains/memory/inmemory.d.ts +5 -13
  205. package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
  206. package/dist/storage/domains/observability/base.d.ts +24 -29
  207. package/dist/storage/domains/observability/base.d.ts.map +1 -1
  208. package/dist/storage/domains/observability/index.d.ts +1 -0
  209. package/dist/storage/domains/observability/index.d.ts.map +1 -1
  210. package/dist/storage/domains/observability/inmemory.d.ts +46 -35
  211. package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
  212. package/dist/storage/domains/observability/types.d.ts +2365 -0
  213. package/dist/storage/domains/observability/types.d.ts.map +1 -0
  214. package/dist/storage/domains/scores/base.d.ts +9 -20
  215. package/dist/storage/domains/scores/base.d.ts.map +1 -1
  216. package/dist/storage/domains/scores/inmemory.d.ts +11 -22
  217. package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
  218. package/dist/storage/domains/shared.d.ts +76 -0
  219. package/dist/storage/domains/shared.d.ts.map +1 -0
  220. package/dist/storage/domains/workflows/base.d.ts +4 -2
  221. package/dist/storage/domains/workflows/base.d.ts.map +1 -1
  222. package/dist/storage/domains/workflows/inmemory.d.ts +10 -9
  223. package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
  224. package/dist/storage/index.cjs +272 -59
  225. package/dist/storage/index.js +2 -1
  226. package/dist/storage/mock.d.ts +28 -174
  227. package/dist/storage/mock.d.ts.map +1 -1
  228. package/dist/storage/types.d.ts +39 -44
  229. package/dist/storage/types.d.ts.map +1 -1
  230. package/dist/storage/utils.d.ts +5 -0
  231. package/dist/storage/utils.d.ts.map +1 -1
  232. package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
  233. package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
  234. package/dist/stream/MastraWorkflowStream.d.ts +1 -1
  235. package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
  236. package/dist/stream/RunOutput.d.ts.map +1 -1
  237. package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
  238. package/dist/stream/base/output.d.ts.map +1 -1
  239. package/dist/stream/index.cjs +12 -12
  240. package/dist/stream/index.js +2 -2
  241. package/dist/stream/types.d.ts +3 -0
  242. package/dist/stream/types.d.ts.map +1 -1
  243. package/dist/test-utils/llm-mock.cjs +4 -4
  244. package/dist/test-utils/llm-mock.js +1 -1
  245. package/dist/tool-loop-agent/index.cjs +20 -0
  246. package/dist/tool-loop-agent/index.cjs.map +1 -0
  247. package/dist/tool-loop-agent/index.d.ts +36 -0
  248. package/dist/tool-loop-agent/index.d.ts.map +1 -0
  249. package/dist/tool-loop-agent/index.js +3 -0
  250. package/dist/tool-loop-agent/index.js.map +1 -0
  251. package/dist/tool-loop-agent/tool-loop-processor.d.ts +30 -0
  252. package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +1 -0
  253. package/dist/tool-loop-agent/utils.d.ts +17 -0
  254. package/dist/tool-loop-agent/utils.d.ts.map +1 -0
  255. package/dist/tools/index.cjs +4 -4
  256. package/dist/tools/index.js +1 -1
  257. package/dist/tools/is-vercel-tool.cjs +2 -2
  258. package/dist/tools/is-vercel-tool.js +1 -1
  259. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  260. package/dist/tools/toolchecks.d.ts +1 -1
  261. package/dist/tools/toolchecks.d.ts.map +1 -1
  262. package/dist/tools/validation.d.ts +1 -1
  263. package/dist/tools/validation.d.ts.map +1 -1
  264. package/dist/utils/zod-utils.d.ts +34 -0
  265. package/dist/utils/zod-utils.d.ts.map +1 -0
  266. package/dist/utils.cjs +39 -22
  267. package/dist/utils.d.ts +1 -1
  268. package/dist/utils.d.ts.map +1 -1
  269. package/dist/utils.js +2 -1
  270. package/dist/vector/index.cjs +12 -5299
  271. package/dist/vector/index.cjs.map +1 -1
  272. package/dist/vector/index.js +3 -5274
  273. package/dist/vector/index.js.map +1 -1
  274. package/dist/vector/vector.d.ts +13 -3
  275. package/dist/vector/vector.d.ts.map +1 -1
  276. package/dist/voice/index.cjs +6 -6
  277. package/dist/voice/index.js +1 -1
  278. package/dist/workflows/default.d.ts +2 -0
  279. package/dist/workflows/default.d.ts.map +1 -1
  280. package/dist/workflows/evented/execution-engine.d.ts +1 -0
  281. package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
  282. package/dist/workflows/evented/index.cjs +10 -10
  283. package/dist/workflows/evented/index.js +1 -1
  284. package/dist/workflows/evented/step-executor.d.ts +1 -0
  285. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  286. package/dist/workflows/evented/workflow-event-processor/index.d.ts +5 -4
  287. package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
  288. package/dist/workflows/evented/workflow-event-processor/loop.d.ts +2 -2
  289. package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
  290. package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
  291. package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
  292. package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
  293. package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
  294. package/dist/workflows/evented/workflow.d.ts +5 -2
  295. package/dist/workflows/evented/workflow.d.ts.map +1 -1
  296. package/dist/workflows/execution-engine.d.ts +1 -0
  297. package/dist/workflows/execution-engine.d.ts.map +1 -1
  298. package/dist/workflows/handlers/control-flow.d.ts +4 -0
  299. package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
  300. package/dist/workflows/handlers/entry.d.ts +3 -2
  301. package/dist/workflows/handlers/entry.d.ts.map +1 -1
  302. package/dist/workflows/handlers/step.d.ts +1 -0
  303. package/dist/workflows/handlers/step.d.ts.map +1 -1
  304. package/dist/workflows/index.cjs +23 -23
  305. package/dist/workflows/index.js +1 -1
  306. package/dist/workflows/types.d.ts +23 -3
  307. package/dist/workflows/types.d.ts.map +1 -1
  308. package/dist/workflows/utils.d.ts +1 -0
  309. package/dist/workflows/utils.d.ts.map +1 -1
  310. package/dist/workflows/workflow.d.ts +22 -8
  311. package/dist/workflows/workflow.d.ts.map +1 -1
  312. package/package.json +16 -6
  313. package/src/llm/model/provider-types.generated.d.ts +42 -17
  314. package/storage/constants.d.ts +1 -0
  315. package/tool-loop-agent.d.ts +1 -0
  316. package/dist/chunk-373OC54J.js.map +0 -1
  317. package/dist/chunk-3IP3DZ7G.js.map +0 -1
  318. package/dist/chunk-4AT6YQKZ.js.map +0 -1
  319. package/dist/chunk-4CMIJQF6.js.map +0 -1
  320. package/dist/chunk-5UQ5TB6J.js.map +0 -1
  321. package/dist/chunk-6CG7IY57.cjs.map +0 -1
  322. package/dist/chunk-72E3YF6A.cjs.map +0 -1
  323. package/dist/chunk-72YCRTEX.cjs.map +0 -1
  324. package/dist/chunk-ADADLFDR.js +0 -42
  325. package/dist/chunk-ADADLFDR.js.map +0 -1
  326. package/dist/chunk-AYBJ5GAD.js.map +0 -1
  327. package/dist/chunk-DBW6S25C.cjs.map +0 -1
  328. package/dist/chunk-EGHGFLL3.cjs.map +0 -1
  329. package/dist/chunk-ETWAR2YE.cjs.map +0 -1
  330. package/dist/chunk-FPDJ4XN6.cjs.map +0 -1
  331. package/dist/chunk-GBQXIVL6.js.map +0 -1
  332. package/dist/chunk-HWMMIRIF.cjs.map +0 -1
  333. package/dist/chunk-JAGQZZ43.cjs.map +0 -1
  334. package/dist/chunk-LDXKZYOV.js.map +0 -1
  335. package/dist/chunk-O3ULBGV6.cjs.map +0 -1
  336. package/dist/chunk-QF4MHFSU.js.map +0 -1
  337. package/dist/chunk-T2VLUFGG.cjs +0 -47
  338. package/dist/chunk-T2VLUFGG.cjs.map +0 -1
  339. package/dist/chunk-TRUNX3AX.cjs.map +0 -1
  340. package/dist/chunk-VZJOEGQA.js.map +0 -1
  341. package/dist/chunk-Y36Y5MTD.js.map +0 -1
  342. package/dist/chunk-YPLZDWG7.js.map +0 -1
  343. package/dist/chunk-Z55SJVEC.cjs.map +0 -1
  344. package/dist/models-dev-E3WWI7VA.js +0 -3
  345. package/dist/models-dev-PPS7X4JM.cjs +0 -12
  346. package/dist/netlify-TY656UYF.js +0 -3
  347. package/dist/netlify-VZFM5UH3.cjs +0 -12
  348. package/dist/provider-registry-NXVD764B.js +0 -3
  349. package/dist/provider-registry-ZIWSEUQE.cjs +0 -40
@@ -1,18 +1,18 @@
1
- import { DefaultVoice } from './chunk-GELVUDUY.js';
1
+ import { DefaultVoice } from './chunk-O7M7DR4E.js';
2
2
  import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-6PMMP3FR.js';
3
- import { InMemoryStore } from './chunk-GBQXIVL6.js';
4
- import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-4AT6YQKZ.js';
3
+ import { InMemoryStore } from './chunk-3HDRO3GG.js';
4
+ import { MessageList, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-QXL3F3T2.js';
5
5
  import { createTextStreamResponse, createUIMessageStreamResponse, createUIMessageStream, parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-2SQB3WBT.js';
6
6
  import { generateId, asSchema, jsonSchema, APICallError, tool } from './chunk-G6E6V2Z4.js';
7
- import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-QDVYP2T7.js';
8
- import { MastraLLMV1 } from './chunk-4CMIJQF6.js';
7
+ import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-BAZHNX5P.js';
8
+ import { MastraLLMV1 } from './chunk-4J4M2Q5R.js';
9
9
  import { PubSub } from './chunk-BVUMKER5.js';
10
10
  import { executeHook } from './chunk-L54GIUCB.js';
11
- import { removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, isZodType, deepMerge, selectFields, delay } from './chunk-LDXKZYOV.js';
12
- import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-Y36Y5MTD.js';
13
- import { MastraError, getErrorFromUnknown } from './chunk-YPLZDWG7.js';
11
+ import { removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, isZodType, deepMerge, selectFields, delay } from './chunk-XJB7J4UT.js';
12
+ import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-ZGIVAQRI.js';
13
+ import { MastraError, getErrorFromUnknown } from './chunk-FJEVLHJT.js';
14
14
  import { ToolStream } from './chunk-DD2VNRQM.js';
15
- import { Tool, createTool } from './chunk-373OC54J.js';
15
+ import { Tool, createTool } from './chunk-4HP7CS6L.js';
16
16
  import { RequestContext, MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY } from './chunk-6TBWJV35.js';
17
17
  import { zodToJsonSchema as zodToJsonSchema$1 } from './chunk-PJKCPRYF.js';
18
18
  import { MastraBase } from './chunk-LSHPJWM5.js';
@@ -805,8 +805,9 @@ var ProcessorState = class {
805
805
  this.span = parentSpan?.createChildSpan({
806
806
  type: "processor_run" /* PROCESSOR_RUN */,
807
807
  name: `output processor: ${processorName}`,
808
+ entityType: "output_processor" /* OUTPUT_PROCESSOR */,
809
+ entityName: processorName,
808
810
  attributes: {
809
- processorName,
810
811
  processorType: "output",
811
812
  processorIndex: processorIndex ?? 0
812
813
  },
@@ -905,8 +906,10 @@ var ProcessorRunner = class _ProcessorRunner {
905
906
  const processorSpan2 = parentSpan2?.createChildSpan({
906
907
  type: "processor_run" /* PROCESSOR_RUN */,
907
908
  name: `output processor workflow: ${processorOrWorkflow.id}`,
909
+ entityType: "output_processor" /* OUTPUT_PROCESSOR */,
910
+ entityId: processorOrWorkflow.id,
911
+ entityName: processorOrWorkflow.name,
908
912
  attributes: {
909
- processorName: processorOrWorkflow.id,
910
913
  processorType: "output",
911
914
  processorIndex: index
912
915
  },
@@ -947,8 +950,10 @@ var ProcessorRunner = class _ProcessorRunner {
947
950
  const processorSpan = parentSpan?.createChildSpan({
948
951
  type: "processor_run" /* PROCESSOR_RUN */,
949
952
  name: `output processor: ${processor.id}`,
953
+ entityType: "output_processor" /* OUTPUT_PROCESSOR */,
954
+ entityId: processor.id,
955
+ entityName: processor.name,
950
956
  attributes: {
951
- processorName: processor.name ?? processor.id,
952
957
  processorType: "output",
953
958
  processorIndex: index
954
959
  },
@@ -1183,8 +1188,10 @@ var ProcessorRunner = class _ProcessorRunner {
1183
1188
  const processorSpan2 = parentSpan2?.createChildSpan({
1184
1189
  type: "processor_run" /* PROCESSOR_RUN */,
1185
1190
  name: `input processor workflow: ${processorOrWorkflow.id}`,
1191
+ entityType: "input_processor" /* INPUT_PROCESSOR */,
1192
+ entityId: processorOrWorkflow.id,
1193
+ entityName: processorOrWorkflow.name,
1186
1194
  attributes: {
1187
- processorName: processorOrWorkflow.id,
1188
1195
  processorType: "input",
1189
1196
  processorIndex: index
1190
1197
  },
@@ -1227,8 +1234,10 @@ var ProcessorRunner = class _ProcessorRunner {
1227
1234
  const processorSpan = parentSpan?.createChildSpan({
1228
1235
  type: "processor_run" /* PROCESSOR_RUN */,
1229
1236
  name: `input processor: ${processor.id}`,
1237
+ entityType: "input_processor" /* INPUT_PROCESSOR */,
1238
+ entityId: processor.id,
1239
+ entityName: processor.name,
1230
1240
  attributes: {
1231
- processorName: processor.name ?? processor.id,
1232
1241
  processorType: "input",
1233
1242
  processorIndex: index
1234
1243
  },
@@ -1351,8 +1360,10 @@ var ProcessorRunner = class _ProcessorRunner {
1351
1360
  const processorSpan2 = parentSpan?.createChildSpan({
1352
1361
  type: "processor_run" /* PROCESSOR_RUN */,
1353
1362
  name: `input step processor workflow: ${processorOrWorkflow.id}`,
1363
+ entityType: "input_processor" /* INPUT_PROCESSOR */,
1364
+ entityId: processorOrWorkflow.id,
1365
+ entityName: processorOrWorkflow.name,
1354
1366
  attributes: {
1355
- processorName: processorOrWorkflow.id,
1356
1367
  processorType: "input",
1357
1368
  processorIndex: index
1358
1369
  },
@@ -1411,8 +1422,10 @@ var ProcessorRunner = class _ProcessorRunner {
1411
1422
  const processorSpan = currentSpan?.createChildSpan({
1412
1423
  type: "processor_run" /* PROCESSOR_RUN */,
1413
1424
  name: `input step processor: ${processor.id}`,
1425
+ entityType: "input_processor" /* INPUT_PROCESSOR */,
1426
+ entityId: processor.id,
1427
+ entityName: processor.name,
1414
1428
  attributes: {
1415
- processorName: processor.name ?? processor.id,
1416
1429
  processorType: "input",
1417
1430
  processorIndex: index
1418
1431
  },
@@ -1505,6 +1518,7 @@ var ProcessorRunner = class _ProcessorRunner {
1505
1518
  */
1506
1519
  async runProcessOutputStep(args) {
1507
1520
  const {
1521
+ steps,
1508
1522
  messageList,
1509
1523
  stepNumber,
1510
1524
  finishReason,
@@ -1524,8 +1538,10 @@ var ProcessorRunner = class _ProcessorRunner {
1524
1538
  const processorSpan2 = parentSpan2?.createChildSpan({
1525
1539
  type: "processor_run" /* PROCESSOR_RUN */,
1526
1540
  name: `output step processor workflow: ${processorOrWorkflow.id}`,
1541
+ entityType: "output_processor" /* OUTPUT_PROCESSOR */,
1542
+ entityId: processorOrWorkflow.id,
1543
+ entityName: processorOrWorkflow.name,
1527
1544
  attributes: {
1528
- processorName: processorOrWorkflow.id,
1529
1545
  processorType: "output",
1530
1546
  processorIndex: index
1531
1547
  },
@@ -1544,6 +1560,7 @@ var ProcessorRunner = class _ProcessorRunner {
1544
1560
  toolCalls,
1545
1561
  text,
1546
1562
  systemMessages: currentSystemMessages2,
1563
+ steps,
1547
1564
  retryCount
1548
1565
  },
1549
1566
  tracingContext,
@@ -1572,8 +1589,10 @@ var ProcessorRunner = class _ProcessorRunner {
1572
1589
  const processorSpan = parentSpan?.createChildSpan({
1573
1590
  type: "processor_run" /* PROCESSOR_RUN */,
1574
1591
  name: `output step processor: ${processor.id}`,
1592
+ entityType: "output_processor" /* OUTPUT_PROCESSOR */,
1593
+ entityId: processor.id,
1594
+ entityName: processor.name,
1575
1595
  attributes: {
1576
- processorName: processor.name ?? processor.id,
1577
1596
  processorType: "output",
1578
1597
  processorIndex: index
1579
1598
  },
@@ -1590,6 +1609,7 @@ var ProcessorRunner = class _ProcessorRunner {
1590
1609
  toolCalls,
1591
1610
  text,
1592
1611
  systemMessages: currentSystemMessages,
1612
+ steps,
1593
1613
  abort,
1594
1614
  tracingContext: { currentSpan: processorSpan },
1595
1615
  requestContext,
@@ -1904,7 +1924,7 @@ function convertFullStreamChunkToMastra(value, ctx) {
1904
1924
  from: "AGENT" /* AGENT */,
1905
1925
  payload: {
1906
1926
  stepResult: {
1907
- reason: value.finishReason
1927
+ reason: normalizeFinishReason(value.finishReason)
1908
1928
  },
1909
1929
  output: {
1910
1930
  // Normalize usage to handle both V2 (flat) and V3 (nested) formats
@@ -2172,6 +2192,21 @@ function normalizeUsage(usage) {
2172
2192
  raw: usage
2173
2193
  };
2174
2194
  }
2195
+ function isV3FinishReason(finishReason) {
2196
+ return typeof finishReason === "object" && finishReason !== null && "unified" in finishReason;
2197
+ }
2198
+ function normalizeFinishReason(finishReason) {
2199
+ if (!finishReason) {
2200
+ return "other";
2201
+ }
2202
+ if (finishReason === "tripwire" || finishReason === "retry") {
2203
+ return finishReason;
2204
+ }
2205
+ if (isV3FinishReason(finishReason)) {
2206
+ return finishReason.unified;
2207
+ }
2208
+ return finishReason === "unknown" ? "other" : finishReason;
2209
+ }
2175
2210
 
2176
2211
  // src/stream/aisdk/v5/output.ts
2177
2212
  var AISDKV5OutputStream = class {
@@ -4344,6 +4379,8 @@ var WorkflowRunOutput = class {
4344
4379
  } else {
4345
4380
  self.#status = "failed";
4346
4381
  }
4382
+ } else if (chunk.type === "workflow-paused") {
4383
+ self.#status = "paused";
4347
4384
  }
4348
4385
  },
4349
4386
  close() {
@@ -4479,6 +4516,8 @@ var WorkflowRunOutput = class {
4479
4516
  } else {
4480
4517
  self.#status = "failed";
4481
4518
  }
4519
+ } else if (chunk.type === "workflow-paused") {
4520
+ self.#status = "paused";
4482
4521
  }
4483
4522
  },
4484
4523
  close() {
@@ -5203,7 +5242,7 @@ var getStepIds = (entry) => {
5203
5242
  return [];
5204
5243
  };
5205
5244
  var createTimeTravelExecutionParams = (params) => {
5206
- const { steps, inputData, resumeData, context, nestedStepsContext, snapshot, initialState, graph } = params;
5245
+ const { steps, inputData, resumeData, context, nestedStepsContext, snapshot, initialState, graph, perStep } = params;
5207
5246
  const firstStepId = steps[0];
5208
5247
  let executionPath = [];
5209
5248
  const stepResults = {};
@@ -5270,7 +5309,8 @@ var createTimeTravelExecutionParams = (params) => {
5270
5309
  suspendedAt: stepContext?.suspendedAt,
5271
5310
  resumedAt: stepContext?.resumedAt
5272
5311
  };
5273
- if (currentExecPathLength > 0 && (!snapshotContext[stepId] || snapshotContext[stepId] && snapshotContext[stepId].status !== "suspended")) {
5312
+ const execPathLengthToUse = perStep ? executionPath.length : currentExecPathLength;
5313
+ if (execPathLengthToUse > 0 && !steps?.includes(stepId) && !context?.[stepId] && (!snapshotContext[stepId] || snapshotContext[stepId] && snapshotContext[stepId].status !== "suspended")) {
5274
5314
  result = void 0;
5275
5315
  }
5276
5316
  if (result) {
@@ -5325,7 +5365,8 @@ async function executeParallel(engine, params) {
5325
5365
  abortController,
5326
5366
  requestContext,
5327
5367
  outputWriter,
5328
- disableScorers
5368
+ disableScorers,
5369
+ perStep
5329
5370
  } = params;
5330
5371
  const parallelSpan = tracingContext.currentSpan?.createChildSpan({
5331
5372
  type: "workflow_parallel" /* WORKFLOW_PARALLEL */,
@@ -5347,7 +5388,7 @@ async function executeParallel(engine, params) {
5347
5388
  makeStepRunning = timeTravel.steps[0] === step.step.id;
5348
5389
  }
5349
5390
  if (!makeStepRunning) {
5350
- continue;
5391
+ break;
5351
5392
  }
5352
5393
  const startTime = resume?.steps[0] === step.step.id ? void 0 : Date.now();
5353
5394
  const resumeTime = resume?.steps[0] === step.step.id ? Date.now() : void 0;
@@ -5359,6 +5400,9 @@ async function executeParallel(engine, params) {
5359
5400
  ...resumeTime ? { resumedAt: resumeTime } : {}
5360
5401
  };
5361
5402
  executionContext.activeStepsPath[step.step.id] = [...executionContext.executionPath, stepIndex];
5403
+ if (perStep) {
5404
+ break;
5405
+ }
5362
5406
  }
5363
5407
  if (timeTravel && timeTravel.executionPath.length > 0) {
5364
5408
  timeTravel.executionPath.shift();
@@ -5370,6 +5414,9 @@ async function executeParallel(engine, params) {
5370
5414
  if (currStepResult && currStepResult.status !== "running") {
5371
5415
  return currStepResult;
5372
5416
  }
5417
+ if (!currStepResult && (perStep || timeTravel)) {
5418
+ return {};
5419
+ }
5373
5420
  const stepExecResult = await engine.executeStep({
5374
5421
  workflowId,
5375
5422
  runId,
@@ -5398,7 +5445,8 @@ async function executeParallel(engine, params) {
5398
5445
  abortController,
5399
5446
  requestContext,
5400
5447
  outputWriter,
5401
- disableScorers
5448
+ disableScorers,
5449
+ perStep
5402
5450
  });
5403
5451
  engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
5404
5452
  Object.assign(stepResults, stepExecResult.stepResults);
@@ -5459,7 +5507,8 @@ async function executeConditional(engine, params) {
5459
5507
  abortController,
5460
5508
  requestContext,
5461
5509
  outputWriter,
5462
- disableScorers
5510
+ disableScorers,
5511
+ perStep
5463
5512
  } = params;
5464
5513
  const conditionalSpan = tracingContext.currentSpan?.createChildSpan({
5465
5514
  type: "workflow_conditional" /* WORKFLOW_CONDITIONAL */,
@@ -5554,7 +5603,18 @@ async function executeConditional(engine, params) {
5554
5603
  }
5555
5604
  })
5556
5605
  )).filter((index) => index !== null);
5557
- const stepsToRun = entry.steps.filter((_, index) => truthyIndexes.includes(index));
5606
+ let stepsToRun = entry.steps.filter((_, index) => truthyIndexes.includes(index));
5607
+ if (perStep || timeTravel && timeTravel.executionPath.length > 0) {
5608
+ const possibleStepsToRun = stepsToRun.filter((s) => {
5609
+ const currStepResult = stepResults[s.step.id];
5610
+ if (timeTravel && timeTravel.executionPath.length > 0) {
5611
+ return timeTravel.steps[0] === s.step.id;
5612
+ }
5613
+ return !currStepResult;
5614
+ });
5615
+ const possibleStepToRun = possibleStepsToRun?.[0];
5616
+ stepsToRun = possibleStepToRun ? [possibleStepToRun] : stepsToRun;
5617
+ }
5558
5618
  conditionalSpan?.update({
5559
5619
  attributes: {
5560
5620
  truthyIndexes,
@@ -5601,7 +5661,8 @@ async function executeConditional(engine, params) {
5601
5661
  abortController,
5602
5662
  requestContext,
5603
5663
  outputWriter,
5604
- disableScorers
5664
+ disableScorers,
5665
+ perStep
5605
5666
  });
5606
5667
  engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
5607
5668
  Object.assign(stepResults, stepExecResult.stepResults);
@@ -5663,7 +5724,8 @@ async function executeLoop(engine, params) {
5663
5724
  requestContext,
5664
5725
  outputWriter,
5665
5726
  disableScorers,
5666
- serializedStepGraph
5727
+ serializedStepGraph,
5728
+ perStep
5667
5729
  } = params;
5668
5730
  const { step, condition } = entry;
5669
5731
  const loopSpan = tracingContext.currentSpan?.createChildSpan({
@@ -5704,7 +5766,8 @@ async function executeLoop(engine, params) {
5704
5766
  outputWriter,
5705
5767
  disableScorers,
5706
5768
  serializedStepGraph,
5707
- iterationCount: iteration + 1
5769
+ iterationCount: iteration + 1,
5770
+ perStep
5708
5771
  });
5709
5772
  engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
5710
5773
  Object.assign(stepResults, stepExecResult.stepResults);
@@ -5804,7 +5867,8 @@ async function executeForeach(engine, params) {
5804
5867
  requestContext,
5805
5868
  outputWriter,
5806
5869
  disableScorers,
5807
- serializedStepGraph
5870
+ serializedStepGraph,
5871
+ perStep
5808
5872
  } = params;
5809
5873
  const { step, opts } = entry;
5810
5874
  const results = [];
@@ -5881,7 +5945,8 @@ async function executeForeach(engine, params) {
5881
5945
  skipEmits: true,
5882
5946
  outputWriter,
5883
5947
  disableScorers,
5884
- serializedStepGraph
5948
+ serializedStepGraph,
5949
+ perStep
5885
5950
  });
5886
5951
  engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
5887
5952
  Object.assign(stepResults, stepExecResult.stepResults);
@@ -6023,7 +6088,8 @@ async function persistStepUpdate(engine, params) {
6023
6088
  requestContext.forEach((value, key) => {
6024
6089
  requestContextObj[key] = value;
6025
6090
  });
6026
- await engine.mastra?.getStorage()?.persistWorkflowSnapshot({
6091
+ const workflowsStore = await engine.mastra?.getStorage()?.getStore("workflows");
6092
+ await workflowsStore?.persistWorkflowSnapshot({
6027
6093
  workflowName: workflowId,
6028
6094
  runId,
6029
6095
  resourceId,
@@ -6065,7 +6131,8 @@ async function executeEntry(engine, params) {
6065
6131
  abortController,
6066
6132
  requestContext,
6067
6133
  outputWriter,
6068
- disableScorers
6134
+ disableScorers,
6135
+ perStep
6069
6136
  } = params;
6070
6137
  const prevOutput = engine.getStepOutput(stepResults, prevStep);
6071
6138
  let execResults;
@@ -6089,7 +6156,8 @@ async function executeEntry(engine, params) {
6089
6156
  requestContext,
6090
6157
  outputWriter,
6091
6158
  disableScorers,
6092
- serializedStepGraph
6159
+ serializedStepGraph,
6160
+ perStep
6093
6161
  });
6094
6162
  execResults = stepExecResult.result;
6095
6163
  engine.applyMutableContext(executionContext, stepExecResult.mutableContext);
@@ -6121,7 +6189,8 @@ async function executeEntry(engine, params) {
6121
6189
  abortController,
6122
6190
  requestContext,
6123
6191
  outputWriter,
6124
- disableScorers
6192
+ disableScorers,
6193
+ perStep
6125
6194
  });
6126
6195
  engine.applyMutableContext(executionContext, resumedStepResult.mutableContext);
6127
6196
  Object.assign(stepResults, resumedStepResult.stepResults);
@@ -6191,7 +6260,8 @@ async function executeEntry(engine, params) {
6191
6260
  abortController,
6192
6261
  requestContext,
6193
6262
  outputWriter,
6194
- disableScorers
6263
+ disableScorers,
6264
+ perStep
6195
6265
  });
6196
6266
  } else if (entry.type === "conditional") {
6197
6267
  execResults = await engine.executeConditional({
@@ -6210,7 +6280,8 @@ async function executeEntry(engine, params) {
6210
6280
  abortController,
6211
6281
  requestContext,
6212
6282
  outputWriter,
6213
- disableScorers
6283
+ disableScorers,
6284
+ perStep
6214
6285
  });
6215
6286
  } else if (entry.type === "loop") {
6216
6287
  execResults = await engine.executeLoop({
@@ -6230,7 +6301,8 @@ async function executeEntry(engine, params) {
6230
6301
  requestContext,
6231
6302
  outputWriter,
6232
6303
  disableScorers,
6233
- serializedStepGraph
6304
+ serializedStepGraph,
6305
+ perStep
6234
6306
  });
6235
6307
  } else if (entry.type === "foreach") {
6236
6308
  execResults = await engine.executeForeach({
@@ -6250,7 +6322,8 @@ async function executeEntry(engine, params) {
6250
6322
  requestContext,
6251
6323
  outputWriter,
6252
6324
  disableScorers,
6253
- serializedStepGraph
6325
+ serializedStepGraph,
6326
+ perStep
6254
6327
  });
6255
6328
  } else if (entry.type === "sleep") {
6256
6329
  const startedAt = Date.now();
@@ -6662,7 +6735,8 @@ async function executeStep(engine, params) {
6662
6735
  disableScorers,
6663
6736
  serializedStepGraph,
6664
6737
  tracingContext,
6665
- iterationCount
6738
+ iterationCount,
6739
+ perStep
6666
6740
  } = params;
6667
6741
  const stepCallId = randomUUID();
6668
6742
  const { inputData, validationError } = await validateStepInput({
@@ -6704,10 +6778,9 @@ async function executeStep(engine, params) {
6704
6778
  const stepSpan = tracingContext.currentSpan?.createChildSpan({
6705
6779
  name: `workflow step: '${step.id}'`,
6706
6780
  type: "workflow_step" /* WORKFLOW_STEP */,
6781
+ entityType: "workflow_step" /* WORKFLOW_STEP */,
6782
+ entityId: step.id,
6707
6783
  input: inputData,
6708
- attributes: {
6709
- stepId: step.id
6710
- },
6711
6784
  tracingPolicy: engine.options?.tracingPolicy
6712
6785
  });
6713
6786
  const operationId = `workflow.${workflowId}.run.${runId}.step.${step.id}.running_ev`;
@@ -6749,7 +6822,8 @@ async function executeStep(engine, params) {
6749
6822
  requestContext,
6750
6823
  tracingContext,
6751
6824
  outputWriter,
6752
- stepSpan
6825
+ stepSpan,
6826
+ perStep
6753
6827
  });
6754
6828
  if (workflowResult !== null) {
6755
6829
  const stepResult2 = { ...stepInfo, ...workflowResult };
@@ -6881,12 +6955,15 @@ async function executeStep(engine, params) {
6881
6955
  outputWriter,
6882
6956
  // Disable scorers must be explicitly set to false they are on by default
6883
6957
  scorers: disableScorers === false ? void 0 : step.scorers,
6884
- validateInputs: engine.options?.validateInputs
6958
+ validateInputs: engine.options?.validateInputs,
6959
+ perStep
6885
6960
  });
6886
6961
  if (engine.requiresDurableContextSerialization()) {
6887
6962
  contextMutations.requestContextUpdate = engine.serializeRequestContext(requestContext);
6888
6963
  }
6889
- return { output, suspended, bailed, contextMutations };
6964
+ const isNestedWorkflowStep = step.component === "WORKFLOW";
6965
+ const nestedWflowStepPaused = isNestedWorkflowStep && perStep;
6966
+ return { output, suspended, bailed, contextMutations, nestedWflowStepPaused };
6890
6967
  },
6891
6968
  { retries, delay: delay2, stepSpan, workflowId, runId }
6892
6969
  );
@@ -6925,6 +7002,8 @@ async function executeStep(engine, params) {
6925
7002
  };
6926
7003
  } else if (durableResult.bailed) {
6927
7004
  execResults = { status: "bailed", output: durableResult.bailed.payload, endedAt: Date.now() };
7005
+ } else if (durableResult.nestedWflowStepPaused) {
7006
+ execResults = { status: "paused" };
6928
7007
  } else {
6929
7008
  execResults = { status: "success", output: durableResult.output, endedAt: Date.now() };
6930
7009
  }
@@ -7348,7 +7427,8 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
7348
7427
  workflowSpan,
7349
7428
  disableScorers,
7350
7429
  restart,
7351
- timeTravel
7430
+ timeTravel,
7431
+ perStep
7352
7432
  } = params;
7353
7433
  const { attempts = 0, delay: delay2 = 0 } = retryConfig ?? {};
7354
7434
  const steps = graph.steps;
@@ -7412,7 +7492,8 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
7412
7492
  pubsub: params.pubsub,
7413
7493
  requestContext: currentRequestContext,
7414
7494
  outputWriter: params.outputWriter,
7415
- disableScorers
7495
+ disableScorers,
7496
+ perStep
7416
7497
  });
7417
7498
  this.applyMutableContext(executionContext, lastOutput.mutableContext);
7418
7499
  lastState = lastOutput.mutableContext.state;
@@ -7451,13 +7532,47 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
7451
7532
  }
7452
7533
  });
7453
7534
  }
7454
- await this.invokeLifecycleCallbacks(result2);
7535
+ if (lastOutput.result.status !== "paused") {
7536
+ await this.invokeLifecycleCallbacks(result2);
7537
+ }
7538
+ if (lastOutput.result.status === "paused") {
7539
+ await params.pubsub.publish(`workflow.events.v2.${runId}`, {
7540
+ type: "watch",
7541
+ runId,
7542
+ data: { type: "workflow-paused", payload: {} }
7543
+ });
7544
+ }
7455
7545
  return {
7456
7546
  ...result2,
7457
7547
  ...lastOutput.result.status === "suspended" && params.outputOptions?.includeResumeLabels ? { resumeLabels: lastOutput.mutableContext.resumeLabels } : {},
7458
7548
  ...params.outputOptions?.includeState ? { state: lastState } : {}
7459
7549
  };
7460
7550
  }
7551
+ if (perStep) {
7552
+ const result2 = await this.fmtReturnValue(params.pubsub, stepResults, lastOutput.result);
7553
+ await this.persistStepUpdate({
7554
+ workflowId,
7555
+ runId,
7556
+ resourceId,
7557
+ stepResults: lastOutput.stepResults,
7558
+ serializedStepGraph: params.serializedStepGraph,
7559
+ executionContext: lastExecutionContext,
7560
+ workflowStatus: "paused",
7561
+ requestContext: currentRequestContext
7562
+ });
7563
+ await params.pubsub.publish(`workflow.events.v2.${runId}`, {
7564
+ type: "watch",
7565
+ runId,
7566
+ data: { type: "workflow-paused", payload: {} }
7567
+ });
7568
+ workflowSpan?.end({
7569
+ attributes: {
7570
+ status: "paused"
7571
+ }
7572
+ });
7573
+ delete result2.result;
7574
+ return { ...result2, status: "paused", ...params.outputOptions?.includeState ? { state: lastState } : {} };
7575
+ }
7461
7576
  }
7462
7577
  const result = await this.fmtReturnValue(params.pubsub, stepResults, lastOutput.result);
7463
7578
  await this.persistStepUpdate({
@@ -7989,7 +8104,8 @@ function createStep(params, agentOptions) {
7989
8104
  finishReason,
7990
8105
  toolCalls,
7991
8106
  text,
7992
- systemMessages: systemMessages ?? []
8107
+ systemMessages: systemMessages ?? [],
8108
+ steps: steps ?? []
7993
8109
  });
7994
8110
  const applyMessages = (msgs) => {
7995
8111
  const deletedIds = idsBeforeProcessing.filter((i) => !msgs.some((m) => m.id === i));
@@ -8255,8 +8371,8 @@ var Workflow = class extends MastraBase {
8255
8371
  if (typeof mappingConfig === "function") {
8256
8372
  const mappingStep2 = createStep({
8257
8373
  id: stepOptions?.id || `mapping_${this.#mastra?.generateId() || randomUUID()}`,
8258
- inputSchema: z.object({}),
8259
- outputSchema: z.object({}),
8374
+ inputSchema: z.any(),
8375
+ outputSchema: z.any(),
8260
8376
  execute: mappingConfig
8261
8377
  });
8262
8378
  this.stepFlow.push({ type: "step", step: mappingStep2 });
@@ -8312,7 +8428,15 @@ var Workflow = class extends MastraBase {
8312
8428
  result[key] = requestContext.get(m.requestContextPath);
8313
8429
  continue;
8314
8430
  }
8315
- const stepResult = m.initData ? getInitData() : getStepResult2(Array.isArray(m.step) ? m.step.find((s) => getStepResult2(s)) : m.step);
8431
+ const stepResult = m.initData ? getInitData() : getStepResult2(
8432
+ Array.isArray(m.step) ? m.step.find((s) => {
8433
+ const result2 = getStepResult2(s);
8434
+ if (typeof result2 === "object" && result2 !== null) {
8435
+ return Object.keys(result2).length > 0;
8436
+ }
8437
+ return result2;
8438
+ }) : m.step
8439
+ );
8316
8440
  if (m.path === ".") {
8317
8441
  result[key] = stepResult;
8318
8442
  continue;
@@ -8530,7 +8654,8 @@ var Workflow = class extends MastraBase {
8530
8654
  run.workflowRunStatus = workflowSnapshotInStorage.status;
8531
8655
  }
8532
8656
  if (!workflowSnapshotInStorage && shouldPersistSnapshot) {
8533
- await this.mastra?.getStorage()?.persistWorkflowSnapshot({
8657
+ const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
8658
+ await workflowsStore?.persistWorkflowSnapshot({
8534
8659
  workflowName: this.id,
8535
8660
  runId: runIdToUse,
8536
8661
  resourceId: options?.resourceId,
@@ -8595,7 +8720,8 @@ var Workflow = class extends MastraBase {
8595
8720
  retryCount,
8596
8721
  tracingContext,
8597
8722
  outputWriter,
8598
- validateInputs
8723
+ validateInputs,
8724
+ perStep
8599
8725
  }) {
8600
8726
  this.__registerMastra(mastra);
8601
8727
  const effectiveValidateInputs = validateInputs ?? this.#options.validateInputs ?? true;
@@ -8643,7 +8769,8 @@ var Workflow = class extends MastraBase {
8643
8769
  requestContext,
8644
8770
  tracingContext,
8645
8771
  outputWriter,
8646
- outputOptions: { includeState: true, includeResumeLabels: true }
8772
+ outputOptions: { includeState: true, includeResumeLabels: true },
8773
+ perStep
8647
8774
  });
8648
8775
  } else if (restart) {
8649
8776
  res = await run.restart({ requestContext, tracingContext, outputWriter });
@@ -8655,7 +8782,8 @@ var Workflow = class extends MastraBase {
8655
8782
  tracingContext,
8656
8783
  outputWriter,
8657
8784
  outputOptions: { includeState: true, includeResumeLabels: true },
8658
- label: resume.label
8785
+ label: resume.label,
8786
+ perStep
8659
8787
  });
8660
8788
  } else {
8661
8789
  res = await run.start({
@@ -8664,7 +8792,8 @@ var Workflow = class extends MastraBase {
8664
8792
  tracingContext,
8665
8793
  outputWriter,
8666
8794
  initialState: state,
8667
- outputOptions: { includeState: true, includeResumeLabels: true }
8795
+ outputOptions: { includeState: true, includeResumeLabels: true },
8796
+ perStep
8668
8797
  });
8669
8798
  }
8670
8799
  unwatch();
@@ -8700,7 +8829,12 @@ var Workflow = class extends MastraBase {
8700
8829
  this.logger.debug("Cannot get workflow runs. Mastra storage is not initialized");
8701
8830
  return { runs: [], total: 0 };
8702
8831
  }
8703
- return storage.listWorkflowRuns({ workflowName: this.id, ...args ?? {} });
8832
+ const workflowsStore = await storage.getStore("workflows");
8833
+ if (!workflowsStore) {
8834
+ this.logger.debug("Cannot get workflow runs. Workflows storage domain is not available");
8835
+ return { runs: [], total: 0 };
8836
+ }
8837
+ return workflowsStore.listWorkflowRuns({ workflowName: this.id, ...args ?? {} });
8704
8838
  }
8705
8839
  async listActiveWorkflowRuns() {
8706
8840
  const runningRuns = await this.listWorkflowRuns({ status: "running" });
@@ -8737,7 +8871,12 @@ var Workflow = class extends MastraBase {
8737
8871
  this.logger.debug("Cannot get workflow runs from storage. Mastra storage is not initialized");
8738
8872
  return this.#runs.get(runId) ? { ...this.#runs.get(runId), workflowName: this.id } : null;
8739
8873
  }
8740
- const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
8874
+ const workflowsStore = await storage.getStore("workflows");
8875
+ if (!workflowsStore) {
8876
+ this.logger.debug("Cannot get workflow runs. Workflows storage domain is not available");
8877
+ return this.#runs.get(runId) ? { ...this.#runs.get(runId), workflowName: this.id } : null;
8878
+ }
8879
+ const run = await workflowsStore.getWorkflowRunById({ runId, workflowName: this.id });
8741
8880
  return run ?? (this.#runs.get(runId) ? { ...this.#runs.get(runId), workflowName: this.id } : null);
8742
8881
  }
8743
8882
  async deleteWorkflowRunById(runId) {
@@ -8746,7 +8885,12 @@ var Workflow = class extends MastraBase {
8746
8885
  this.logger.debug("Cannot delete workflow run by ID. Mastra storage is not initialized");
8747
8886
  return;
8748
8887
  }
8749
- await storage.deleteWorkflowRunById({ runId, workflowName: this.id });
8888
+ const workflowsStore = await storage.getStore("workflows");
8889
+ if (!workflowsStore) {
8890
+ this.logger.debug("Cannot delete workflow run. Workflows storage domain is not available");
8891
+ return;
8892
+ }
8893
+ await workflowsStore.deleteWorkflowRunById({ runId, workflowName: this.id });
8750
8894
  this.#runs.delete(runId);
8751
8895
  }
8752
8896
  async getWorkflowRunSteps({ runId, workflowId }) {
@@ -8755,7 +8899,12 @@ var Workflow = class extends MastraBase {
8755
8899
  this.logger.debug("Cannot get workflow run steps. Mastra storage is not initialized");
8756
8900
  return {};
8757
8901
  }
8758
- const run = await storage.getWorkflowRunById({ runId, workflowName: workflowId });
8902
+ const workflowsStore = await storage.getStore("workflows");
8903
+ if (!workflowsStore) {
8904
+ this.logger.debug("Cannot get workflow run steps. Workflows storage domain is not available");
8905
+ return {};
8906
+ }
8907
+ const run = await workflowsStore.getWorkflowRunById({ runId, workflowName: workflowId });
8759
8908
  let snapshot = run?.snapshot;
8760
8909
  if (!snapshot) {
8761
8910
  return {};
@@ -8797,7 +8946,12 @@ var Workflow = class extends MastraBase {
8797
8946
  this.logger.debug("Cannot get workflow run execution result. Mastra storage is not initialized");
8798
8947
  return null;
8799
8948
  }
8800
- const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
8949
+ const workflowsStore = await storage.getStore("workflows");
8950
+ if (!workflowsStore) {
8951
+ this.logger.debug("Cannot get workflow run execution result. Workflows storage domain is not available");
8952
+ return null;
8953
+ }
8954
+ const run = await workflowsStore.getWorkflowRunById({ runId, workflowName: this.id });
8801
8955
  let snapshot = run?.snapshot;
8802
8956
  if (!snapshot) {
8803
8957
  return null;
@@ -8956,7 +9110,8 @@ var Run = class {
8956
9110
  this.abortController.abort();
8957
9111
  this.workflowRunStatus = "canceled";
8958
9112
  try {
8959
- await this.mastra?.getStorage()?.updateWorkflowState({
9113
+ const workflowsStore = await this.mastra?.getStorage()?.getStore("workflows");
9114
+ await workflowsStore?.updateWorkflowState({
8960
9115
  workflowName: this.workflowId,
8961
9116
  runId: this.runId,
8962
9117
  opts: {
@@ -9034,15 +9189,15 @@ var Run = class {
9034
9189
  tracingContext,
9035
9190
  tracingOptions,
9036
9191
  format,
9037
- outputOptions
9192
+ outputOptions,
9193
+ perStep
9038
9194
  }) {
9039
9195
  const workflowSpan = getOrCreateSpan({
9040
9196
  type: "workflow_run" /* WORKFLOW_RUN */,
9041
9197
  name: `workflow run: '${this.workflowId}'`,
9198
+ entityType: "workflow_run" /* WORKFLOW_RUN */,
9199
+ entityId: this.workflowId,
9042
9200
  input: inputData,
9043
- attributes: {
9044
- workflowId: this.workflowId
9045
- },
9046
9201
  metadata: {
9047
9202
  resourceId: this.resourceId,
9048
9203
  runId: this.runId
@@ -9072,7 +9227,8 @@ var Run = class {
9072
9227
  outputWriter,
9073
9228
  workflowSpan,
9074
9229
  format,
9075
- outputOptions
9230
+ outputOptions,
9231
+ perStep
9076
9232
  });
9077
9233
  if (result.status !== "suspended") {
9078
9234
  this.cleanup?.();
@@ -9239,9 +9395,10 @@ var Run = class {
9239
9395
  }
9240
9396
  async streamAsync({
9241
9397
  inputData,
9242
- requestContext
9398
+ requestContext,
9399
+ perStep
9243
9400
  } = {}) {
9244
- return this.stream({ inputData, requestContext });
9401
+ return this.stream({ inputData, requestContext, perStep });
9245
9402
  }
9246
9403
  /**
9247
9404
  * Starts the workflow execution with the provided input as a stream
@@ -9255,7 +9412,8 @@ var Run = class {
9255
9412
  tracingOptions,
9256
9413
  closeOnSuspend = true,
9257
9414
  initialState,
9258
- outputOptions
9415
+ outputOptions,
9416
+ perStep
9259
9417
  } = {}) {
9260
9418
  if (this.closeStreamAction && this.streamOutput) {
9261
9419
  return this.streamOutput;
@@ -9310,7 +9468,8 @@ var Run = class {
9310
9468
  runId: self.runId,
9311
9469
  data: chunk
9312
9470
  });
9313
- }
9471
+ },
9472
+ perStep
9314
9473
  });
9315
9474
  let executionResults;
9316
9475
  try {
@@ -9352,7 +9511,8 @@ var Run = class {
9352
9511
  requestContext,
9353
9512
  tracingContext,
9354
9513
  tracingOptions,
9355
- outputOptions
9514
+ outputOptions,
9515
+ perStep
9356
9516
  } = {}) {
9357
9517
  return this.resumeStreamVNext({
9358
9518
  resumeData,
@@ -9360,7 +9520,8 @@ var Run = class {
9360
9520
  requestContext,
9361
9521
  tracingContext,
9362
9522
  tracingOptions,
9363
- outputOptions
9523
+ outputOptions,
9524
+ perStep
9364
9525
  });
9365
9526
  }
9366
9527
  /**
@@ -9375,7 +9536,8 @@ var Run = class {
9375
9536
  tracingContext,
9376
9537
  tracingOptions,
9377
9538
  forEachIndex,
9378
- outputOptions
9539
+ outputOptions,
9540
+ perStep
9379
9541
  } = {}) {
9380
9542
  this.closeStreamAction = async () => {
9381
9543
  };
@@ -9425,7 +9587,8 @@ var Run = class {
9425
9587
  },
9426
9588
  isVNext: true,
9427
9589
  forEachIndex,
9428
- outputOptions
9590
+ outputOptions,
9591
+ perStep
9429
9592
  });
9430
9593
  self.executionResults = executionResultsPromise;
9431
9594
  let executionResults;
@@ -9496,7 +9659,8 @@ var Run = class {
9496
9659
  return this._restart(args);
9497
9660
  }
9498
9661
  async _resume(params) {
9499
- const snapshot = await this.#mastra?.getStorage()?.loadWorkflowSnapshot({
9662
+ const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
9663
+ const snapshot = await workflowsStore?.loadWorkflowSnapshot({
9500
9664
  workflowName: this.workflowId,
9501
9665
  runId: this.runId
9502
9666
  });
@@ -9571,10 +9735,9 @@ var Run = class {
9571
9735
  const workflowSpan = getOrCreateSpan({
9572
9736
  type: "workflow_run" /* WORKFLOW_RUN */,
9573
9737
  name: `workflow run: '${this.workflowId}'`,
9738
+ entityType: "workflow_run" /* WORKFLOW_RUN */,
9739
+ entityId: this.workflowId,
9574
9740
  input: resumeDataToUse,
9575
- attributes: {
9576
- workflowId: this.workflowId
9577
- },
9578
9741
  metadata: {
9579
9742
  resourceId: this.resourceId,
9580
9743
  runId: this.runId
@@ -9609,7 +9772,8 @@ var Run = class {
9609
9772
  abortController: this.abortController,
9610
9773
  workflowSpan,
9611
9774
  outputOptions: params.outputOptions,
9612
- outputWriter: params.outputWriter
9775
+ outputWriter: params.outputWriter,
9776
+ perStep: params.perStep
9613
9777
  }).then((result) => {
9614
9778
  if (!params.isVNext && result.status !== "suspended") {
9615
9779
  this.closeStreamAction?.().catch(() => {
@@ -9633,7 +9797,8 @@ var Run = class {
9633
9797
  if (this.workflowEngineType !== "default") {
9634
9798
  throw new Error(`restart() is not supported on ${this.workflowEngineType} workflows`);
9635
9799
  }
9636
- const snapshot = await this.#mastra?.getStorage()?.loadWorkflowSnapshot({
9800
+ const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
9801
+ const snapshot = await workflowsStore?.loadWorkflowSnapshot({
9637
9802
  workflowName: this.workflowId,
9638
9803
  runId: this.runId
9639
9804
  });
@@ -9682,9 +9847,8 @@ var Run = class {
9682
9847
  const workflowSpan = getOrCreateSpan({
9683
9848
  type: "workflow_run" /* WORKFLOW_RUN */,
9684
9849
  name: `workflow run: '${this.workflowId}'`,
9685
- attributes: {
9686
- workflowId: this.workflowId
9687
- },
9850
+ entityType: "workflow_run" /* WORKFLOW_RUN */,
9851
+ entityId: this.workflowId,
9688
9852
  metadata: {
9689
9853
  resourceId: this.resourceId,
9690
9854
  runId: this.runId
@@ -9728,12 +9892,14 @@ var Run = class {
9728
9892
  outputWriter,
9729
9893
  tracingContext,
9730
9894
  tracingOptions,
9731
- outputOptions
9895
+ outputOptions,
9896
+ perStep
9732
9897
  }) {
9733
9898
  if (!stepParam || Array.isArray(stepParam) && stepParam.length === 0) {
9734
9899
  throw new Error("Step is required and must be a valid step or array of steps");
9735
9900
  }
9736
- const snapshot = await this.#mastra?.getStorage()?.loadWorkflowSnapshot({
9901
+ const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
9902
+ const snapshot = await workflowsStore?.loadWorkflowSnapshot({
9737
9903
  workflowName: this.workflowId,
9738
9904
  runId: this.runId
9739
9905
  });
@@ -9763,7 +9929,8 @@ var Run = class {
9763
9929
  nestedStepsContext,
9764
9930
  snapshot,
9765
9931
  initialState,
9766
- graph: this.executionGraph
9932
+ graph: this.executionGraph,
9933
+ perStep
9767
9934
  });
9768
9935
  const requestContextToUse = requestContext ?? new RequestContext();
9769
9936
  for (const [key, value] of Object.entries(snapshot.requestContext ?? {})) {
@@ -9775,9 +9942,8 @@ var Run = class {
9775
9942
  type: "workflow_run" /* WORKFLOW_RUN */,
9776
9943
  name: `workflow run: '${this.workflowId}'`,
9777
9944
  input: inputData,
9778
- attributes: {
9779
- workflowId: this.workflowId
9780
- },
9945
+ entityType: "workflow_run" /* WORKFLOW_RUN */,
9946
+ entityId: this.workflowId,
9781
9947
  metadata: {
9782
9948
  resourceId: this.resourceId,
9783
9949
  runId: this.runId
@@ -9803,7 +9969,8 @@ var Run = class {
9803
9969
  abortController: this.abortController,
9804
9970
  outputWriter,
9805
9971
  workflowSpan,
9806
- outputOptions
9972
+ outputOptions,
9973
+ perStep
9807
9974
  });
9808
9975
  if (result.status !== "suspended") {
9809
9976
  this.cleanup?.();
@@ -9824,7 +9991,8 @@ var Run = class {
9824
9991
  requestContext,
9825
9992
  tracingContext,
9826
9993
  tracingOptions,
9827
- outputOptions
9994
+ outputOptions,
9995
+ perStep
9828
9996
  }) {
9829
9997
  this.closeStreamAction = async () => {
9830
9998
  };
@@ -9865,7 +10033,8 @@ var Run = class {
9865
10033
  outputWriter: async (chunk) => {
9866
10034
  void controller.enqueue(chunk);
9867
10035
  },
9868
- outputOptions
10036
+ outputOptions,
10037
+ perStep
9869
10038
  });
9870
10039
  self.executionResults = executionResultsPromise;
9871
10040
  let executionResults;
@@ -10470,7 +10639,8 @@ async function processOutputStream({
10470
10639
  messageList.add(message, "response");
10471
10640
  runState.setState({
10472
10641
  isReasoning: false,
10473
- reasoningDeltas: []
10642
+ reasoningDeltas: [],
10643
+ providerOptions: void 0
10474
10644
  });
10475
10645
  if (isControllerOpen(controller)) {
10476
10646
  controller.enqueue(chunk);
@@ -10604,6 +10774,9 @@ function executeStreamWithFallbackModels(models) {
10604
10774
  done = true;
10605
10775
  break;
10606
10776
  } catch (err) {
10777
+ if (err instanceof TripWire) {
10778
+ throw err;
10779
+ }
10607
10780
  attempt++;
10608
10781
  console.error(`Error executing model ${modelConfig.model.modelId}, attempt ${attempt}====`, err);
10609
10782
  if (attempt > maxRetries) {
@@ -10707,6 +10880,45 @@ function createLLMExecutionStep({
10707
10880
  });
10708
10881
  Object.assign(currentStep, processInputStepResult);
10709
10882
  } catch (error) {
10883
+ if (error instanceof TripWire) {
10884
+ if (isControllerOpen(controller)) {
10885
+ controller.enqueue({
10886
+ type: "tripwire",
10887
+ runId,
10888
+ from: "AGENT" /* AGENT */,
10889
+ payload: {
10890
+ reason: error.message,
10891
+ retry: error.options?.retry,
10892
+ metadata: error.options?.metadata,
10893
+ processorId: error.processorId
10894
+ }
10895
+ });
10896
+ }
10897
+ const runState3 = new AgenticRunState({
10898
+ _internal,
10899
+ model
10900
+ });
10901
+ return {
10902
+ callBail: true,
10903
+ outputStream: new MastraModelOutput({
10904
+ model: {
10905
+ modelId: model.modelId,
10906
+ provider: model.provider,
10907
+ version: model.specificationVersion
10908
+ },
10909
+ stream: new ReadableStream$1({
10910
+ start(c) {
10911
+ c.close();
10912
+ }
10913
+ }),
10914
+ messageList,
10915
+ messageId,
10916
+ options: { runId }
10917
+ }),
10918
+ runState: runState3,
10919
+ stepTools: tools
10920
+ };
10921
+ }
10710
10922
  console.error("Error in processInputStep processors:", error);
10711
10923
  throw error;
10712
10924
  }
@@ -10740,7 +10952,8 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
10740
10952
  resumeData can not be an empty object nor null/undefined.
10741
10953
  When you find that and call that tool, add the resumeData to the tool call arguments/input.
10742
10954
  Also, add the runId of the suspended tool as suspendedToolRunId to the tool call arguments/input.
10743
- If the suspendedTool.type is 'approval', resumeData will be an object that contains 'approved' which can either be true or false depending on the user's message.`;
10955
+ If the suspendedTool.type is 'approval', resumeData will be an object that contains 'approved' which can either be true or false depending on the user's message. If you can't construct resumeData from the message for approval type, set approved to true and add resumeData: { approved: true } to the tool call arguments/input.
10956
+ `;
10744
10957
  }
10745
10958
  return message;
10746
10959
  });
@@ -10954,6 +11167,7 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
10954
11167
  }));
10955
11168
  const currentRetryCount = inputData.processorRetryCount || 0;
10956
11169
  await processorRunner.runProcessOutputStep({
11170
+ steps: inputData.output?.steps ?? [],
10957
11171
  messages: messageList.get.all.db(),
10958
11172
  messageList,
10959
11173
  stepNumber,
@@ -11363,7 +11577,17 @@ function createToolCallStep({
11363
11577
  }
11364
11578
  const resumeData = resumeDataFromArgs ?? workflowResumeData;
11365
11579
  const isResumeToolCall = !!resumeDataFromArgs;
11366
- if (requireToolApproval || tool2.requireApproval) {
11580
+ let toolRequiresApproval = requireToolApproval || tool2.requireApproval;
11581
+ if (tool2.needsApprovalFn) {
11582
+ try {
11583
+ const needsApprovalResult = await tool2.needsApprovalFn(args);
11584
+ toolRequiresApproval = needsApprovalResult;
11585
+ } catch (error) {
11586
+ console.error(`Error evaluating needsApprovalFn for tool ${inputData.toolName}:`, error);
11587
+ toolRequiresApproval = true;
11588
+ }
11589
+ }
11590
+ if (toolRequiresApproval) {
11367
11591
  if (!resumeData) {
11368
11592
  controller.enqueue({
11369
11593
  type: "tool-call-approval",
@@ -11626,11 +11850,10 @@ function createAgenticLoopWorkflow(params) {
11626
11850
  };
11627
11851
  accumulatedSteps.push(currentStep);
11628
11852
  if (rest.stopWhen && typedInputData.stepResult?.isContinued && accumulatedSteps.length > 0) {
11853
+ const steps = accumulatedSteps;
11629
11854
  const conditions = await Promise.all(
11630
11855
  (Array.isArray(rest.stopWhen) ? rest.stopWhen : [rest.stopWhen]).map((condition) => {
11631
- return condition({
11632
- steps: accumulatedSteps
11633
- });
11856
+ return condition({ steps });
11634
11857
  })
11635
11858
  );
11636
11859
  const hasStopped = conditions.some((condition) => condition);
@@ -12076,8 +12299,6 @@ var MastraLLMVNext = class extends MastraBase {
12076
12299
  messages: [...messageList.getSystemMessages(), ...messages]
12077
12300
  },
12078
12301
  attributes: {
12079
- agentId,
12080
- agentName,
12081
12302
  model: firstModel.modelId,
12082
12303
  provider: firstModel.provider,
12083
12304
  streaming: true,
@@ -13372,12 +13593,13 @@ var AgentLegacyHandler = class {
13372
13593
  const agentSpan = getOrCreateSpan({
13373
13594
  type: "agent_run" /* AGENT_RUN */,
13374
13595
  name: `agent run: '${this.capabilities.id}'`,
13596
+ entityType: "agent" /* AGENT */,
13597
+ entityId: this.capabilities.id,
13598
+ entityName: this.capabilities.name,
13375
13599
  input: {
13376
13600
  messages
13377
13601
  },
13378
13602
  attributes: {
13379
- agentId: this.capabilities.id,
13380
- agentName: this.capabilities.name,
13381
13603
  instructions: this.capabilities.convertInstructionsToString(instructions),
13382
13604
  availableTools: [
13383
13605
  ...toolsets ? Object.keys(toolsets) : [],
@@ -15123,7 +15345,7 @@ var Agent = class extends MastraBase {
15123
15345
  async listResolvedOutputProcessors(requestContext) {
15124
15346
  const configuredProcessors = this.#outputProcessors ? typeof this.#outputProcessors === "function" ? await this.#outputProcessors({ requestContext: requestContext || new RequestContext() }) : this.#outputProcessors : [];
15125
15347
  const memory = await this.getMemory({ requestContext: requestContext || new RequestContext() });
15126
- const memoryProcessors = memory ? memory.getOutputProcessors(configuredProcessors, requestContext) : [];
15348
+ const memoryProcessors = memory ? await memory.getOutputProcessors(configuredProcessors, requestContext) : [];
15127
15349
  const allProcessors = [...configuredProcessors, ...memoryProcessors];
15128
15350
  return this.combineProcessorsIntoWorkflow(allProcessors, `${this.id}-output-processor`);
15129
15351
  }
@@ -15135,7 +15357,7 @@ var Agent = class extends MastraBase {
15135
15357
  async listResolvedInputProcessors(requestContext) {
15136
15358
  const configuredProcessors = this.#inputProcessors ? typeof this.#inputProcessors === "function" ? await this.#inputProcessors({ requestContext: requestContext || new RequestContext() }) : this.#inputProcessors : [];
15137
15359
  const memory = await this.getMemory({ requestContext: requestContext || new RequestContext() });
15138
- const memoryProcessors = memory ? memory.getInputProcessors(configuredProcessors, requestContext) : [];
15360
+ const memoryProcessors = memory ? await memory.getInputProcessors(configuredProcessors, requestContext) : [];
15139
15361
  const allProcessors = [...memoryProcessors, ...configuredProcessors];
15140
15362
  return this.combineProcessorsIntoWorkflow(allProcessors, `${this.id}-input-processor`);
15141
15363
  }
@@ -16965,10 +17187,11 @@ var Agent = class extends MastraBase {
16965
17187
  const agentSpan = getOrCreateSpan({
16966
17188
  type: "agent_run" /* AGENT_RUN */,
16967
17189
  name: `agent run: '${this.id}'`,
17190
+ entityType: "agent" /* AGENT */,
17191
+ entityId: this.id,
17192
+ entityName: this.name,
16968
17193
  input: options.messages,
16969
17194
  attributes: {
16970
- agentId: this.id,
16971
- agentName: this.name,
16972
17195
  conversationId: threadFromArgs?.id,
16973
17196
  instructions: this.#convertInstructionsToString(instructions)
16974
17197
  },
@@ -17391,7 +17614,8 @@ var Agent = class extends MastraBase {
17391
17614
  text: "V1 models are not supported for stream. Please use streamLegacy instead."
17392
17615
  });
17393
17616
  }
17394
- const existingSnapshot = await this.#mastra?.getStorage()?.loadWorkflowSnapshot({
17617
+ const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
17618
+ const existingSnapshot = await workflowsStore?.loadWorkflowSnapshot({
17395
17619
  workflowName: "agentic-loop",
17396
17620
  runId: streamOptions?.runId ?? ""
17397
17621
  });
@@ -19459,6 +19683,50 @@ var ToolCallFilter = class {
19459
19683
  }
19460
19684
  };
19461
19685
 
19686
+ // src/memory/working-memory-utils.ts
19687
+ var WORKING_MEMORY_START_TAG = "<working_memory>";
19688
+ var WORKING_MEMORY_END_TAG = "</working_memory>";
19689
+ function extractWorkingMemoryTags(text) {
19690
+ const results = [];
19691
+ let pos = 0;
19692
+ while (pos < text.length) {
19693
+ const start = text.indexOf(WORKING_MEMORY_START_TAG, pos);
19694
+ if (start === -1) break;
19695
+ const end = text.indexOf(WORKING_MEMORY_END_TAG, start + WORKING_MEMORY_START_TAG.length);
19696
+ if (end === -1) break;
19697
+ results.push(text.substring(start, end + WORKING_MEMORY_END_TAG.length));
19698
+ pos = end + WORKING_MEMORY_END_TAG.length;
19699
+ }
19700
+ return results.length > 0 ? results : null;
19701
+ }
19702
+ function removeWorkingMemoryTags(text) {
19703
+ let result = "";
19704
+ let pos = 0;
19705
+ while (pos < text.length) {
19706
+ const start = text.indexOf(WORKING_MEMORY_START_TAG, pos);
19707
+ if (start === -1) {
19708
+ result += text.substring(pos);
19709
+ break;
19710
+ }
19711
+ result += text.substring(pos, start);
19712
+ const end = text.indexOf(WORKING_MEMORY_END_TAG, start + WORKING_MEMORY_START_TAG.length);
19713
+ if (end === -1) {
19714
+ result += text.substring(start);
19715
+ break;
19716
+ }
19717
+ pos = end + WORKING_MEMORY_END_TAG.length;
19718
+ }
19719
+ return result;
19720
+ }
19721
+ function extractWorkingMemoryContent(text) {
19722
+ const start = text.indexOf(WORKING_MEMORY_START_TAG);
19723
+ if (start === -1) return null;
19724
+ const contentStart = start + WORKING_MEMORY_START_TAG.length;
19725
+ const end = text.indexOf(WORKING_MEMORY_END_TAG, contentStart);
19726
+ if (end === -1) return null;
19727
+ return text.substring(contentStart, end);
19728
+ }
19729
+
19462
19730
  // src/processors/memory/message-history.ts
19463
19731
  var MessageHistory = class {
19464
19732
  id = "message-history";
@@ -19501,25 +19769,43 @@ var MessageHistory = class {
19501
19769
  }
19502
19770
  return messageList;
19503
19771
  }
19504
- filterIncompleteToolCalls(messages) {
19772
+ /**
19773
+ * Filters messages before persisting to storage:
19774
+ * 1. Removes incomplete tool calls (state === 'call' or 'partial-call')
19775
+ * 2. Removes updateWorkingMemory tool invocations (hide args from message history)
19776
+ * 3. Strips <working_memory> tags from text content
19777
+ */
19778
+ filterMessagesForPersistence(messages) {
19505
19779
  return messages.map((m) => {
19506
- if (m.role === `assistant`) {
19507
- const assistant = {
19508
- ...m,
19509
- content: {
19510
- ...m.content,
19511
- parts: m.content.parts.map((p) => {
19512
- if (p.type === `tool-invocation` && (p.toolInvocation.state === `call` || p.toolInvocation.state === `partial-call`)) {
19513
- return null;
19514
- }
19515
- return p;
19516
- }).filter((p) => Boolean(p))
19780
+ const newMessage = { ...m };
19781
+ if (m.content && typeof m.content === "object" && !Array.isArray(m.content)) {
19782
+ newMessage.content = { ...m.content };
19783
+ }
19784
+ if (typeof newMessage.content?.content === "string" && newMessage.content.content.length > 0) {
19785
+ newMessage.content.content = removeWorkingMemoryTags(newMessage.content.content).trim();
19786
+ }
19787
+ if (Array.isArray(newMessage.content?.parts)) {
19788
+ newMessage.content.parts = newMessage.content.parts.map((p) => {
19789
+ if (p.type === `tool-invocation` && (p.toolInvocation.state === `call` || p.toolInvocation.state === `partial-call`)) {
19790
+ return null;
19517
19791
  }
19518
- };
19519
- if (assistant.content.parts.length === 0) return null;
19520
- return assistant;
19792
+ if (p.type === `tool-invocation` && p.toolInvocation.toolName === `updateWorkingMemory`) {
19793
+ return null;
19794
+ }
19795
+ if (p.type === `text`) {
19796
+ const text = typeof p.text === "string" ? p.text : "";
19797
+ return {
19798
+ ...p,
19799
+ text: removeWorkingMemoryTags(text).trim()
19800
+ };
19801
+ }
19802
+ return p;
19803
+ }).filter((p) => Boolean(p));
19804
+ if (newMessage.content.parts.length === 0) {
19805
+ return null;
19806
+ }
19521
19807
  }
19522
- return m;
19808
+ return newMessage;
19523
19809
  }).filter((m) => Boolean(m));
19524
19810
  }
19525
19811
  async processOutputResult(args) {
@@ -19536,7 +19822,7 @@ var MessageHistory = class {
19536
19822
  if (messagesToSave.length === 0) {
19537
19823
  return messageList;
19538
19824
  }
19539
- const filtered = this.filterIncompleteToolCalls(messagesToSave);
19825
+ const filtered = this.filterMessagesForPersistence(messagesToSave);
19540
19826
  await this.storage.saveMessages({ messages: filtered });
19541
19827
  const thread = await this.storage.getThreadById({ threadId });
19542
19828
  if (thread) {
@@ -20150,6 +20436,7 @@ var MastraMemory = class extends MastraBase {
20150
20436
  _storage;
20151
20437
  vector;
20152
20438
  embedder;
20439
+ embedderOptions;
20153
20440
  threadConfig = { ...memoryDefaultOptions };
20154
20441
  #mastra;
20155
20442
  constructor(config) {
@@ -20240,7 +20527,11 @@ https://mastra.ai/en/docs/memory/overview`
20240
20527
  this.vector = vector;
20241
20528
  }
20242
20529
  setEmbedder(embedder) {
20243
- this.embedder = embedder;
20530
+ if (typeof embedder === "string") {
20531
+ this.embedder = new ModelRouterEmbeddingModel(embedder);
20532
+ } else {
20533
+ this.embedder = embedder;
20534
+ }
20244
20535
  }
20245
20536
  /**
20246
20537
  * Get a system message to inject into the conversation.
@@ -20362,14 +20653,15 @@ https://mastra.ai/en/docs/memory/overview`
20362
20653
  * @param configuredProcessors - Processors already configured by the user (for deduplication)
20363
20654
  * @returns Array of input processors configured for this memory instance
20364
20655
  */
20365
- getInputProcessors(configuredProcessors = [], context) {
20656
+ async getInputProcessors(configuredProcessors = [], context) {
20657
+ const memoryStore = await this.storage.getStore("memory");
20366
20658
  const processors = [];
20367
20659
  const memoryContext = context?.get("MastraMemory");
20368
20660
  const runtimeMemoryConfig = memoryContext?.memoryConfig;
20369
20661
  const effectiveConfig = runtimeMemoryConfig ? this.getMergedThreadConfig(runtimeMemoryConfig) : this.threadConfig;
20370
20662
  const isWorkingMemoryEnabled = typeof effectiveConfig.workingMemory === "object" && effectiveConfig.workingMemory.enabled !== false;
20371
20663
  if (isWorkingMemoryEnabled) {
20372
- if (!this.storage?.stores?.memory)
20664
+ if (!memoryStore)
20373
20665
  throw new MastraError({
20374
20666
  category: "USER",
20375
20667
  domain: "STORAGE" /* STORAGE */,
@@ -20387,7 +20679,7 @@ https://mastra.ai/en/docs/memory/overview`
20387
20679
  }
20388
20680
  processors.push(
20389
20681
  new WorkingMemory({
20390
- storage: this.storage.stores.memory,
20682
+ storage: memoryStore,
20391
20683
  template,
20392
20684
  scope: typeof effectiveConfig.workingMemory === "object" ? effectiveConfig.workingMemory.scope : void 0,
20393
20685
  useVNext: typeof effectiveConfig.workingMemory === "object" && "version" in effectiveConfig.workingMemory && effectiveConfig.workingMemory.version === "vnext",
@@ -20398,7 +20690,7 @@ https://mastra.ai/en/docs/memory/overview`
20398
20690
  }
20399
20691
  const lastMessages = effectiveConfig.lastMessages;
20400
20692
  if (lastMessages) {
20401
- if (!this.storage?.stores?.memory)
20693
+ if (!memoryStore)
20402
20694
  throw new MastraError({
20403
20695
  category: "USER",
20404
20696
  domain: "STORAGE" /* STORAGE */,
@@ -20409,14 +20701,14 @@ https://mastra.ai/en/docs/memory/overview`
20409
20701
  if (!hasMessageHistory) {
20410
20702
  processors.push(
20411
20703
  new MessageHistory({
20412
- storage: this.storage.stores.memory,
20704
+ storage: memoryStore,
20413
20705
  lastMessages: typeof lastMessages === "number" ? lastMessages : void 0
20414
20706
  })
20415
20707
  );
20416
20708
  }
20417
20709
  }
20418
20710
  if (effectiveConfig.semanticRecall) {
20419
- if (!this.storage?.stores?.memory)
20711
+ if (!memoryStore)
20420
20712
  throw new MastraError({
20421
20713
  category: "USER",
20422
20714
  domain: "STORAGE" /* STORAGE */,
@@ -20443,7 +20735,7 @@ https://mastra.ai/en/docs/memory/overview`
20443
20735
  const indexName = this.getEmbeddingIndexName();
20444
20736
  processors.push(
20445
20737
  new SemanticRecall({
20446
- storage: this.storage.stores.memory,
20738
+ storage: memoryStore,
20447
20739
  vector: this.vector,
20448
20740
  embedder: this.embedder,
20449
20741
  indexName,
@@ -20460,7 +20752,8 @@ https://mastra.ai/en/docs/memory/overview`
20460
20752
  * @param configuredProcessors - Processors already configured by the user (for deduplication)
20461
20753
  * @returns Array of output processors configured for this memory instance
20462
20754
  */
20463
- getOutputProcessors(configuredProcessors = [], context) {
20755
+ async getOutputProcessors(configuredProcessors = [], context) {
20756
+ const memoryStore = await this.storage.getStore("memory");
20464
20757
  const processors = [];
20465
20758
  const memoryContext = context?.get("MastraMemory");
20466
20759
  const runtimeMemoryConfig = memoryContext?.memoryConfig;
@@ -20469,7 +20762,7 @@ https://mastra.ai/en/docs/memory/overview`
20469
20762
  return [];
20470
20763
  }
20471
20764
  if (effectiveConfig.semanticRecall) {
20472
- if (!this.storage?.stores?.memory)
20765
+ if (!memoryStore)
20473
20766
  throw new MastraError({
20474
20767
  category: "USER",
20475
20768
  domain: "STORAGE" /* STORAGE */,
@@ -20496,7 +20789,7 @@ https://mastra.ai/en/docs/memory/overview`
20496
20789
  const indexName = this.getEmbeddingIndexName();
20497
20790
  processors.push(
20498
20791
  new SemanticRecall({
20499
- storage: this.storage.stores.memory,
20792
+ storage: memoryStore,
20500
20793
  vector: this.vector,
20501
20794
  embedder: this.embedder,
20502
20795
  indexName,
@@ -20507,7 +20800,7 @@ https://mastra.ai/en/docs/memory/overview`
20507
20800
  }
20508
20801
  const lastMessages = effectiveConfig.lastMessages;
20509
20802
  if (lastMessages) {
20510
- if (!this.storage?.stores?.memory)
20803
+ if (!memoryStore)
20511
20804
  throw new MastraError({
20512
20805
  category: "USER",
20513
20806
  domain: "STORAGE" /* STORAGE */,
@@ -20518,7 +20811,7 @@ https://mastra.ai/en/docs/memory/overview`
20518
20811
  if (!hasMessageHistory) {
20519
20812
  processors.push(
20520
20813
  new MessageHistory({
20521
- storage: this.storage.stores.memory,
20814
+ storage: memoryStore,
20522
20815
  lastMessages: typeof lastMessages === "number" ? lastMessages : void 0
20523
20816
  })
20524
20817
  );
@@ -20545,22 +20838,39 @@ var MockMemory = class extends MastraMemory {
20545
20838
  });
20546
20839
  this._hasOwnStorage = true;
20547
20840
  }
20841
+ async getMemoryStore() {
20842
+ const store = await this.storage.getStore("memory");
20843
+ if (!store) {
20844
+ throw new MastraError({
20845
+ id: "MASTRA_MEMORY_STORAGE_NOT_AVAILABLE",
20846
+ domain: "MASTRA_MEMORY" /* MASTRA_MEMORY */,
20847
+ category: "SYSTEM" /* SYSTEM */,
20848
+ text: "Memory storage is not supported by this storage adapter"
20849
+ });
20850
+ }
20851
+ return store;
20852
+ }
20548
20853
  async getThreadById({ threadId }) {
20549
- return this.storage.getThreadById({ threadId });
20854
+ const memoryStorage = await this.getMemoryStore();
20855
+ return memoryStorage.getThreadById({ threadId });
20550
20856
  }
20551
20857
  async saveThread({ thread }) {
20552
- return this.storage.saveThread({ thread });
20858
+ const memoryStorage = await this.getMemoryStore();
20859
+ return memoryStorage.saveThread({ thread });
20553
20860
  }
20554
20861
  async saveMessages({
20555
20862
  messages
20556
20863
  }) {
20557
- return this.storage.saveMessages({ messages });
20864
+ const memoryStorage = await this.getMemoryStore();
20865
+ return memoryStorage.saveMessages({ messages });
20558
20866
  }
20559
20867
  async listThreadsByResourceId(args) {
20560
- return this.storage.listThreadsByResourceId(args);
20868
+ const memoryStorage = await this.getMemoryStore();
20869
+ return memoryStorage.listThreadsByResourceId(args);
20561
20870
  }
20562
20871
  async recall(args) {
20563
- const result = await this.storage.listMessages({
20872
+ const memoryStorage = await this.getMemoryStore();
20873
+ const result = await memoryStorage.listMessages({
20564
20874
  threadId: args.threadId,
20565
20875
  resourceId: args.resourceId,
20566
20876
  perPage: args.perPage,
@@ -20572,11 +20882,13 @@ var MockMemory = class extends MastraMemory {
20572
20882
  return result;
20573
20883
  }
20574
20884
  async deleteThread(threadId) {
20575
- return this.storage.deleteThread({ threadId });
20885
+ const memoryStorage = await this.getMemoryStore();
20886
+ return memoryStorage.deleteThread({ threadId });
20576
20887
  }
20577
20888
  async deleteMessages(messageIds) {
20889
+ const memoryStorage = await this.getMemoryStore();
20578
20890
  const ids = Array.isArray(messageIds) ? messageIds?.map((item) => typeof item === "string" ? item : item.id) : [messageIds];
20579
- return this.storage.deleteMessages(ids);
20891
+ return memoryStorage.deleteMessages(ids);
20580
20892
  }
20581
20893
  async getWorkingMemory({
20582
20894
  threadId,
@@ -20593,10 +20905,15 @@ var MockMemory = class extends MastraMemory {
20593
20905
  if (!id) {
20594
20906
  return null;
20595
20907
  }
20596
- const resource = await this.storage.getResourceById({ resourceId: id });
20908
+ const memoryStorage = await this.getMemoryStore();
20909
+ const resource = await memoryStorage.getResourceById({ resourceId: id });
20597
20910
  return resource?.workingMemory || null;
20598
20911
  }
20599
20912
  listTools(_config) {
20913
+ const mergedConfig = this.getMergedThreadConfig(_config);
20914
+ if (!mergedConfig.workingMemory?.enabled) {
20915
+ return {};
20916
+ }
20600
20917
  return {
20601
20918
  updateWorkingMemory: createTool({
20602
20919
  id: "update-working-memory",
@@ -20681,7 +20998,8 @@ var MockMemory = class extends MastraMemory {
20681
20998
  if (!id) {
20682
20999
  throw new Error(`Cannot update working memory: ${scope} ID is required`);
20683
21000
  }
20684
- await this.storage.updateResource({
21001
+ const memoryStorage = await this.getMemoryStore();
21002
+ await memoryStorage.updateResource({
20685
21003
  resourceId: id,
20686
21004
  workingMemory
20687
21005
  });
@@ -20710,6 +21028,6 @@ var MockMemory = class extends MastraMemory {
20710
21028
  }
20711
21029
  };
20712
21030
 
20713
- export { AISDKV5OutputStream, Agent, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, TripWire, UnicodeNormalizer, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createStep, createTimeTravelExecutionParams, createWorkflow, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, hydrateSerializedStepErrors, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, resolveThreadIdFromArgs, runCountDeprecationMessage, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepResumeData, validateStepStateData, validateStepSuspendData };
20714
- //# sourceMappingURL=chunk-QF4MHFSU.js.map
20715
- //# sourceMappingURL=chunk-QF4MHFSU.js.map
21031
+ export { AISDKV5OutputStream, Agent, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, TripWire, UnicodeNormalizer, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createStep, createTimeTravelExecutionParams, createWorkflow, extractWorkingMemoryContent, extractWorkingMemoryTags, getResumeLabelsByStepId, getStepIds, getStepResult, getZodErrors, hydrateSerializedStepErrors, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, removeWorkingMemoryTags, resolveThreadIdFromArgs, runCountDeprecationMessage, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepResumeData, validateStepStateData, validateStepSuspendData };
21032
+ //# sourceMappingURL=chunk-NGWTSHNA.js.map
21033
+ //# sourceMappingURL=chunk-NGWTSHNA.js.map