@mastra/core 1.3.0 → 1.4.0

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 (274) hide show
  1. package/CHANGELOG.md +462 -0
  2. package/datasets.d.ts +1 -0
  3. package/dist/agent/agent.d.ts +1 -1
  4. package/dist/agent/index.cjs +13 -13
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/adapters/AIV4Adapter.d.ts.map +1 -1
  7. package/dist/agent/message-list/adapters/AIV5Adapter.d.ts.map +1 -1
  8. package/dist/agent/message-list/conversion/output-converter.d.ts +2 -1
  9. package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
  10. package/dist/agent/message-list/index.cjs +18 -18
  11. package/dist/agent/message-list/index.js +1 -1
  12. package/dist/agent/workflows/prepare-stream/index.d.ts +1 -1
  13. package/dist/chunk-3JVFFAJX.cjs +1207 -0
  14. package/dist/chunk-3JVFFAJX.cjs.map +1 -0
  15. package/dist/{chunk-WL3AW3YA.js → chunk-3X3CZUXI.js} +4070 -3983
  16. package/dist/chunk-3X3CZUXI.js.map +1 -0
  17. package/dist/{chunk-2GWTJFVM.js → chunk-4EHGOATH.js} +46 -14
  18. package/dist/chunk-4EHGOATH.js.map +1 -0
  19. package/dist/{chunk-YNXIGRQE.cjs → chunk-4IJ4UDZX.cjs} +319 -83
  20. package/dist/chunk-4IJ4UDZX.cjs.map +1 -0
  21. package/dist/{chunk-CGPH7CMG.cjs → chunk-4KFEMXTV.cjs} +46 -14
  22. package/dist/chunk-4KFEMXTV.cjs.map +1 -0
  23. package/dist/{chunk-PHYJYZ32.js → chunk-4TQ4EBYX.js} +16 -8
  24. package/dist/chunk-4TQ4EBYX.js.map +1 -0
  25. package/dist/{chunk-SIZEIYNH.js → chunk-4XSAZPPS.js} +254 -18
  26. package/dist/chunk-4XSAZPPS.js.map +1 -0
  27. package/dist/{chunk-KUTU2YZF.js → chunk-5Q5Y34SS.js} +5 -5
  28. package/dist/{chunk-KUTU2YZF.js.map → chunk-5Q5Y34SS.js.map} +1 -1
  29. package/dist/{chunk-EH6SAGEO.cjs → chunk-64WGYTQK.cjs} +72 -53
  30. package/dist/{chunk-EH6SAGEO.cjs.map → chunk-64WGYTQK.cjs.map} +1 -1
  31. package/dist/{chunk-OOCEAC6U.cjs → chunk-65PHUUMF.cjs} +3 -3
  32. package/dist/{chunk-OOCEAC6U.cjs.map → chunk-65PHUUMF.cjs.map} +1 -1
  33. package/dist/{chunk-JNE2ABVB.js → chunk-7NKUSQEV.js} +1094 -10
  34. package/dist/chunk-7NKUSQEV.js.map +1 -0
  35. package/dist/{chunk-ZHFM7HCQ.js → chunk-AXHBJ4GX.js} +3 -3
  36. package/dist/{chunk-ZHFM7HCQ.js.map → chunk-AXHBJ4GX.js.map} +1 -1
  37. package/dist/{chunk-ILQXPZCD.js → chunk-AY6DBRS3.js} +37 -21
  38. package/dist/chunk-AY6DBRS3.js.map +1 -0
  39. package/dist/{chunk-TERSHTY5.cjs → chunk-BP7VYTOP.cjs} +1116 -21
  40. package/dist/chunk-BP7VYTOP.cjs.map +1 -0
  41. package/dist/{chunk-UE2G2LRP.cjs → chunk-CZ4NQANZ.cjs} +37 -21
  42. package/dist/chunk-CZ4NQANZ.cjs.map +1 -0
  43. package/dist/{chunk-NCC45KOB.cjs → chunk-DBSVT6AR.cjs} +7 -7
  44. package/dist/{chunk-NCC45KOB.cjs.map → chunk-DBSVT6AR.cjs.map} +1 -1
  45. package/dist/{chunk-BXLLXTT4.js → chunk-FLPEGTEK.js} +4 -4
  46. package/dist/{chunk-BXLLXTT4.js.map → chunk-FLPEGTEK.js.map} +1 -1
  47. package/dist/{chunk-ON2KVIUJ.cjs → chunk-HYRYTTMT.cjs} +7 -7
  48. package/dist/{chunk-ON2KVIUJ.cjs.map → chunk-HYRYTTMT.cjs.map} +1 -1
  49. package/dist/chunk-NJ7TL3LQ.js +1196 -0
  50. package/dist/chunk-NJ7TL3LQ.js.map +1 -0
  51. package/dist/{chunk-EUG4AON3.cjs → chunk-NKYWDNCI.cjs} +8 -7
  52. package/dist/{chunk-EUG4AON3.cjs.map → chunk-NKYWDNCI.cjs.map} +1 -1
  53. package/dist/{chunk-UHVG25VW.cjs → chunk-NZG2JAKS.cjs} +23 -15
  54. package/dist/chunk-NZG2JAKS.cjs.map +1 -0
  55. package/dist/{chunk-44SUGDBR.js → chunk-PS5ONCXY.js} +109 -5
  56. package/dist/chunk-PS5ONCXY.js.map +1 -0
  57. package/dist/{chunk-57QAF2ZQ.js → chunk-QTTWRCB5.js} +4 -4
  58. package/dist/{chunk-57QAF2ZQ.js.map → chunk-QTTWRCB5.js.map} +1 -1
  59. package/dist/{chunk-VM25PDSW.js → chunk-RZ4CIIZR.js} +4 -4
  60. package/dist/{chunk-VM25PDSW.js.map → chunk-RZ4CIIZR.js.map} +1 -1
  61. package/dist/{chunk-C3XU7ZDC.cjs → chunk-SU5APAM6.cjs} +123 -4
  62. package/dist/chunk-SU5APAM6.cjs.map +1 -0
  63. package/dist/{chunk-3MJCJLZS.js → chunk-U2HKJZCI.js} +24 -5
  64. package/dist/{chunk-3MJCJLZS.js.map → chunk-U2HKJZCI.js.map} +1 -1
  65. package/dist/{chunk-GCTAD6B7.cjs → chunk-VD5YA6RH.cjs} +12 -12
  66. package/dist/{chunk-GCTAD6B7.cjs.map → chunk-VD5YA6RH.cjs.map} +1 -1
  67. package/dist/{chunk-KAJNBNWP.cjs → chunk-YNNJLLFN.cjs} +4071 -3984
  68. package/dist/chunk-YNNJLLFN.cjs.map +1 -0
  69. package/dist/datasets/dataset.d.ts +153 -0
  70. package/dist/datasets/dataset.d.ts.map +1 -0
  71. package/dist/datasets/experiment/analytics/aggregate.d.ts +46 -0
  72. package/dist/datasets/experiment/analytics/aggregate.d.ts.map +1 -0
  73. package/dist/datasets/experiment/analytics/compare.d.ts +33 -0
  74. package/dist/datasets/experiment/analytics/compare.d.ts.map +1 -0
  75. package/dist/datasets/experiment/analytics/index.d.ts +9 -0
  76. package/dist/datasets/experiment/analytics/index.d.ts.map +1 -0
  77. package/dist/datasets/experiment/analytics/types.d.ts +103 -0
  78. package/dist/datasets/experiment/analytics/types.d.ts.map +1 -0
  79. package/dist/datasets/experiment/executor.d.ts +40 -0
  80. package/dist/datasets/experiment/executor.d.ts.map +1 -0
  81. package/dist/datasets/experiment/index.d.ts +31 -0
  82. package/dist/datasets/experiment/index.d.ts.map +1 -0
  83. package/dist/datasets/experiment/scorer.d.ts +21 -0
  84. package/dist/datasets/experiment/scorer.d.ts.map +1 -0
  85. package/dist/datasets/experiment/types.d.ts +140 -0
  86. package/dist/datasets/experiment/types.d.ts.map +1 -0
  87. package/dist/datasets/index.cjs +69 -0
  88. package/dist/datasets/index.cjs.map +1 -0
  89. package/dist/datasets/index.d.ts +6 -0
  90. package/dist/datasets/index.d.ts.map +1 -0
  91. package/dist/datasets/index.js +4 -0
  92. package/dist/datasets/index.js.map +1 -0
  93. package/dist/datasets/manager.d.ts +73 -0
  94. package/dist/datasets/manager.d.ts.map +1 -0
  95. package/dist/datasets/validation/errors.d.ts +44 -0
  96. package/dist/datasets/validation/errors.d.ts.map +1 -0
  97. package/dist/datasets/validation/index.d.ts +3 -0
  98. package/dist/datasets/validation/index.d.ts.map +1 -0
  99. package/dist/datasets/validation/validator.d.ts +24 -0
  100. package/dist/datasets/validation/validator.d.ts.map +1 -0
  101. package/dist/docs/SKILL.md +1 -3
  102. package/dist/docs/assets/SOURCE_MAP.json +436 -346
  103. package/dist/docs/references/docs-memory-observational-memory.md +86 -11
  104. package/dist/docs/references/docs-streaming-events.md +23 -0
  105. package/dist/docs/references/docs-workspace-filesystem.md +72 -1
  106. package/dist/docs/references/docs-workspace-overview.md +95 -12
  107. package/dist/docs/references/docs-workspace-sandbox.md +2 -0
  108. package/dist/docs/references/guides-agent-frameworks-ai-sdk.md +6 -2
  109. package/dist/docs/references/reference-ai-sdk-with-mastra.md +1 -1
  110. package/dist/docs/references/reference-memory-observational-memory.md +318 -9
  111. package/dist/docs/references/reference-streaming-workflows-stream.md +1 -0
  112. package/dist/docs/references/reference-workflows-workflow-methods-foreach.md +30 -0
  113. package/dist/docs/references/reference.md +3 -0
  114. package/dist/editor/index.d.ts +1 -1
  115. package/dist/editor/index.d.ts.map +1 -1
  116. package/dist/editor/types.d.ts +21 -3
  117. package/dist/editor/types.d.ts.map +1 -1
  118. package/dist/evals/index.cjs +20 -20
  119. package/dist/evals/index.js +3 -3
  120. package/dist/evals/scoreTraces/index.cjs +5 -5
  121. package/dist/evals/scoreTraces/index.js +2 -2
  122. package/dist/features/index.cjs +1 -1
  123. package/dist/features/index.cjs.map +1 -1
  124. package/dist/features/index.d.ts.map +1 -1
  125. package/dist/features/index.js +1 -1
  126. package/dist/features/index.js.map +1 -1
  127. package/dist/index.cjs +2 -7
  128. package/dist/index.d.ts +0 -9
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +1 -2
  131. package/dist/llm/index.cjs +10 -10
  132. package/dist/llm/index.js +2 -2
  133. package/dist/llm/model/provider-types.generated.d.ts +1694 -1659
  134. package/dist/loop/index.cjs +12 -12
  135. package/dist/loop/index.js +1 -1
  136. package/dist/loop/network/index.d.ts +1 -1
  137. package/dist/loop/workflows/agentic-execution/index.d.ts +1 -1
  138. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  139. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  140. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  141. package/dist/loop/workflows/agentic-loop/index.d.ts +1 -1
  142. package/dist/loop/workflows/errors.d.ts +4 -0
  143. package/dist/loop/workflows/errors.d.ts.map +1 -0
  144. package/dist/mastra/index.cjs +2 -2
  145. package/dist/mastra/index.d.ts +2 -0
  146. package/dist/mastra/index.d.ts.map +1 -1
  147. package/dist/mastra/index.js +1 -1
  148. package/dist/memory/index.cjs +14 -14
  149. package/dist/memory/index.js +1 -1
  150. package/dist/memory/memory.d.ts +5 -0
  151. package/dist/memory/memory.d.ts.map +1 -1
  152. package/dist/memory/types.d.ts +56 -0
  153. package/dist/memory/types.d.ts.map +1 -1
  154. package/dist/processors/index.cjs +41 -41
  155. package/dist/processors/index.js +1 -1
  156. package/dist/processors/processors/skills.d.ts +1 -1
  157. package/dist/processors/processors/skills.d.ts.map +1 -1
  158. package/dist/processors/runner.d.ts.map +1 -1
  159. package/dist/processors/trailing-assistant-guard.d.ts +34 -0
  160. package/dist/processors/trailing-assistant-guard.d.ts.map +1 -0
  161. package/dist/provider-registry-6LZAGQET.cjs +40 -0
  162. package/dist/{provider-registry-C6XCYX44.cjs.map → provider-registry-6LZAGQET.cjs.map} +1 -1
  163. package/dist/provider-registry-QUNT7S55.js +3 -0
  164. package/dist/{provider-registry-NWU4YFQW.js.map → provider-registry-QUNT7S55.js.map} +1 -1
  165. package/dist/provider-registry.json +4068 -3981
  166. package/dist/relevance/index.cjs +3 -3
  167. package/dist/relevance/index.js +1 -1
  168. package/dist/storage/base.d.ts +4 -1
  169. package/dist/storage/base.d.ts.map +1 -1
  170. package/dist/storage/constants.cjs +87 -27
  171. package/dist/storage/constants.d.ts +21 -2
  172. package/dist/storage/constants.d.ts.map +1 -1
  173. package/dist/storage/constants.js +1 -1
  174. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  175. package/dist/storage/domains/datasets/base.d.ts +83 -0
  176. package/dist/storage/domains/datasets/base.d.ts.map +1 -0
  177. package/dist/storage/domains/datasets/index.d.ts +3 -0
  178. package/dist/storage/domains/datasets/index.d.ts.map +1 -0
  179. package/dist/storage/domains/datasets/inmemory.d.ts +40 -0
  180. package/dist/storage/domains/datasets/inmemory.d.ts.map +1 -0
  181. package/dist/storage/domains/experiments/base.d.ts +28 -0
  182. package/dist/storage/domains/experiments/base.d.ts.map +1 -0
  183. package/dist/storage/domains/experiments/index.d.ts +3 -0
  184. package/dist/storage/domains/experiments/index.d.ts.map +1 -0
  185. package/dist/storage/domains/experiments/inmemory.d.ts +28 -0
  186. package/dist/storage/domains/experiments/inmemory.d.ts.map +1 -0
  187. package/dist/storage/domains/index.d.ts +3 -0
  188. package/dist/storage/domains/index.d.ts.map +1 -1
  189. package/dist/storage/domains/inmemory-db.d.ts +9 -1
  190. package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
  191. package/dist/storage/domains/mcp-clients/base.d.ts +47 -0
  192. package/dist/storage/domains/mcp-clients/base.d.ts.map +1 -0
  193. package/dist/storage/domains/mcp-clients/index.d.ts +3 -0
  194. package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -0
  195. package/dist/storage/domains/mcp-clients/inmemory.d.ts +31 -0
  196. package/dist/storage/domains/mcp-clients/inmemory.d.ts.map +1 -0
  197. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  198. package/dist/storage/index.cjs +201 -117
  199. package/dist/storage/index.js +2 -2
  200. package/dist/storage/mock.d.ts.map +1 -1
  201. package/dist/storage/types.d.ts +338 -3
  202. package/dist/storage/types.d.ts.map +1 -1
  203. package/dist/stream/base/output.d.ts.map +1 -1
  204. package/dist/stream/index.cjs +11 -11
  205. package/dist/stream/index.js +2 -2
  206. package/dist/stream/types.d.ts +15 -0
  207. package/dist/stream/types.d.ts.map +1 -1
  208. package/dist/test-utils/llm-mock.cjs +4 -4
  209. package/dist/test-utils/llm-mock.js +1 -1
  210. package/dist/tool-loop-agent/index.cjs +4 -4
  211. package/dist/tool-loop-agent/index.js +1 -1
  212. package/dist/tool-provider/index.cjs +4 -0
  213. package/dist/tool-provider/index.cjs.map +1 -0
  214. package/dist/tool-provider/index.d.ts +2 -0
  215. package/dist/tool-provider/index.d.ts.map +1 -0
  216. package/dist/tool-provider/index.js +3 -0
  217. package/dist/tool-provider/index.js.map +1 -0
  218. package/dist/tool-provider/types.d.ts +113 -0
  219. package/dist/tool-provider/types.d.ts.map +1 -0
  220. package/dist/utils.cjs +23 -23
  221. package/dist/utils.d.ts +1 -1
  222. package/dist/utils.d.ts.map +1 -1
  223. package/dist/utils.js +1 -1
  224. package/dist/vector/index.cjs +7 -7
  225. package/dist/vector/index.js +1 -1
  226. package/dist/workflows/evented/index.cjs +10 -10
  227. package/dist/workflows/evented/index.js +1 -1
  228. package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
  229. package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
  230. package/dist/workflows/index.cjs +25 -25
  231. package/dist/workflows/index.js +1 -1
  232. package/dist/workflows/workflow.d.ts +2 -2
  233. package/dist/workflows/workflow.d.ts.map +1 -1
  234. package/dist/workspace/filesystem/filesystem.d.ts +5 -15
  235. package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
  236. package/dist/workspace/filesystem/local-filesystem.d.ts +18 -2
  237. package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
  238. package/dist/workspace/filesystem/mastra-filesystem.d.ts +21 -1
  239. package/dist/workspace/filesystem/mastra-filesystem.d.ts.map +1 -1
  240. package/dist/workspace/index.cjs +41 -41
  241. package/dist/workspace/index.d.ts +1 -1
  242. package/dist/workspace/index.d.ts.map +1 -1
  243. package/dist/workspace/index.js +1 -1
  244. package/dist/workspace/lifecycle.d.ts +49 -53
  245. package/dist/workspace/lifecycle.d.ts.map +1 -1
  246. package/dist/workspace/sandbox/local-sandbox.d.ts +1 -1
  247. package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
  248. package/dist/workspace/sandbox/mastra-sandbox.d.ts +3 -2
  249. package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
  250. package/dist/workspace/sandbox/sandbox.d.ts +3 -4
  251. package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
  252. package/dist/workspace/workspace.d.ts +2 -15
  253. package/dist/workspace/workspace.d.ts.map +1 -1
  254. package/package.json +7 -7
  255. package/src/llm/model/provider-types.generated.d.ts +1694 -1659
  256. package/tool-provider.d.ts +1 -0
  257. package/dist/chunk-2GWTJFVM.js.map +0 -1
  258. package/dist/chunk-44SUGDBR.js.map +0 -1
  259. package/dist/chunk-C3XU7ZDC.cjs.map +0 -1
  260. package/dist/chunk-CGPH7CMG.cjs.map +0 -1
  261. package/dist/chunk-ILQXPZCD.js.map +0 -1
  262. package/dist/chunk-JNE2ABVB.js.map +0 -1
  263. package/dist/chunk-KAJNBNWP.cjs.map +0 -1
  264. package/dist/chunk-PHYJYZ32.js.map +0 -1
  265. package/dist/chunk-SIZEIYNH.js.map +0 -1
  266. package/dist/chunk-TERSHTY5.cjs.map +0 -1
  267. package/dist/chunk-UE2G2LRP.cjs.map +0 -1
  268. package/dist/chunk-UHVG25VW.cjs.map +0 -1
  269. package/dist/chunk-WL3AW3YA.js.map +0 -1
  270. package/dist/chunk-YNXIGRQE.cjs.map +0 -1
  271. package/dist/docs/references/reference-cli-mastra.md +0 -336
  272. package/dist/docs/references/reference-deployer-cloudflare.md +0 -56
  273. package/dist/provider-registry-C6XCYX44.cjs +0 -40
  274. package/dist/provider-registry-NWU4YFQW.js +0 -3
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunkCGPH7CMG_cjs = require('./chunk-CGPH7CMG.cjs');
3
+ var chunk4KFEMXTV_cjs = require('./chunk-4KFEMXTV.cjs');
4
4
  var chunkRQ56ZSIR_cjs = require('./chunk-RQ56ZSIR.cjs');
5
5
  var chunkZCBG4ZQT_cjs = require('./chunk-ZCBG4ZQT.cjs');
6
- var chunkTERSHTY5_cjs = require('./chunk-TERSHTY5.cjs');
7
- var chunkUE2G2LRP_cjs = require('./chunk-UE2G2LRP.cjs');
6
+ var chunkBP7VYTOP_cjs = require('./chunk-BP7VYTOP.cjs');
7
+ var chunkCZ4NQANZ_cjs = require('./chunk-CZ4NQANZ.cjs');
8
8
  var chunkZIEQA3YP_cjs = require('./chunk-ZIEQA3YP.cjs');
9
9
  var chunkPM3UIIBK_cjs = require('./chunk-PM3UIIBK.cjs');
10
- var chunkGCTAD6B7_cjs = require('./chunk-GCTAD6B7.cjs');
11
- var chunkON2KVIUJ_cjs = require('./chunk-ON2KVIUJ.cjs');
10
+ var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
11
+ var chunkVD5YA6RH_cjs = require('./chunk-VD5YA6RH.cjs');
12
+ var chunkHYRYTTMT_cjs = require('./chunk-HYRYTTMT.cjs');
12
13
  var chunk6BJ7XHRH_cjs = require('./chunk-6BJ7XHRH.cjs');
13
14
  var chunk4D4KB75Y_cjs = require('./chunk-4D4KB75Y.cjs');
14
- var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
15
- var chunkOOCEAC6U_cjs = require('./chunk-OOCEAC6U.cjs');
15
+ var chunk65PHUUMF_cjs = require('./chunk-65PHUUMF.cjs');
16
+ var chunkCYUP7QWT_cjs = require('./chunk-CYUP7QWT.cjs');
16
17
  var chunkKJBMTK5B_cjs = require('./chunk-KJBMTK5B.cjs');
17
18
  var chunk7UWHFWST_cjs = require('./chunk-7UWHFWST.cjs');
18
- var chunkCYUP7QWT_cjs = require('./chunk-CYUP7QWT.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');
@@ -1018,6 +1018,45 @@ function resolveThreadIdFromArgs(args) {
1018
1018
  if (args?.threadId) return { id: args.threadId };
1019
1019
  return void 0;
1020
1020
  }
1021
+ var CLAUDE_46_PATTERN = /[^0-9]4[.-]6/;
1022
+ function isMaybeClaude46(model) {
1023
+ if (typeof model === "function") return true;
1024
+ if (Array.isArray(model)) {
1025
+ return model.some((m) => isMaybeClaude46(m.model ?? m));
1026
+ }
1027
+ if (typeof model === "string") {
1028
+ return model.startsWith("anthropic") && CLAUDE_46_PATTERN.test(model);
1029
+ }
1030
+ if (model && typeof model === "object" && "provider" in model && "modelId" in model) {
1031
+ const { provider, modelId } = model;
1032
+ return provider.startsWith("anthropic") && CLAUDE_46_PATTERN.test(modelId);
1033
+ }
1034
+ return true;
1035
+ }
1036
+ var TrailingAssistantGuard = class {
1037
+ id = "trailing-assistant-guard";
1038
+ name = "Trailing Assistant Guard";
1039
+ processInputStep({ messages, structuredOutput }) {
1040
+ const willUseResponseFormat = structuredOutput?.schema && !structuredOutput?.model && !structuredOutput?.jsonPromptInjection;
1041
+ if (!willUseResponseFormat) return;
1042
+ const lastMessage = messages[messages.length - 1];
1043
+ if (!lastMessage || lastMessage.role !== "assistant") return;
1044
+ return {
1045
+ messages: [
1046
+ ...messages,
1047
+ {
1048
+ id: crypto2.randomUUID(),
1049
+ role: "user",
1050
+ content: {
1051
+ format: 2,
1052
+ parts: [{ type: "text", text: "Generate the structured response." }]
1053
+ },
1054
+ createdAt: /* @__PURE__ */ new Date()
1055
+ }
1056
+ ]
1057
+ };
1058
+ }
1059
+ };
1021
1060
 
1022
1061
  // src/processors/runner.ts
1023
1062
  var ProcessorState = class {
@@ -1145,11 +1184,23 @@ var ProcessorRunner = class _ProcessorRunner {
1145
1184
  );
1146
1185
  }
1147
1186
  if (result.status !== "success") {
1187
+ const details = [];
1188
+ if (result.status === "failed") {
1189
+ if (result.error) {
1190
+ details.push(result.error.message || JSON.stringify(result.error));
1191
+ }
1192
+ for (const [stepId, step] of Object.entries(result.steps)) {
1193
+ if (step.status === "failed" && step.error?.message) {
1194
+ details.push(`step ${stepId}: ${step.error.message}`);
1195
+ }
1196
+ }
1197
+ }
1198
+ const detailStr = details.length > 0 ? ` \u2014 ${details.join("; ")}` : "";
1148
1199
  throw new chunk4U7ZLI36_cjs.MastraError({
1149
1200
  category: "USER",
1150
1201
  domain: "AGENT",
1151
1202
  id: "PROCESSOR_WORKFLOW_FAILED",
1152
- text: `Processor workflow ${workflow.id} failed with status: ${result.status}`
1203
+ text: `Processor workflow ${workflow.id} failed with status: ${result.status}${detailStr}`
1153
1204
  });
1154
1205
  }
1155
1206
  const output = result.result;
@@ -1222,7 +1273,7 @@ var ProcessorRunner = class _ProcessorRunner {
1222
1273
  writer
1223
1274
  });
1224
1275
  const mutations = messageList.stopRecording();
1225
- if (result instanceof chunkUE2G2LRP_cjs.MessageList) {
1276
+ if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1226
1277
  if (result !== messageList) {
1227
1278
  throw new chunk4U7ZLI36_cjs.MastraError({
1228
1279
  category: "USER",
@@ -1474,7 +1525,7 @@ var ProcessorRunner = class _ProcessorRunner {
1474
1525
  retryCount
1475
1526
  });
1476
1527
  let mutations;
1477
- if (result instanceof chunkUE2G2LRP_cjs.MessageList) {
1528
+ if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1478
1529
  if (result !== messageList) {
1479
1530
  throw new chunk4U7ZLI36_cjs.MastraError({
1480
1531
  category: "USER",
@@ -1569,7 +1620,8 @@ var ProcessorRunner = class _ProcessorRunner {
1569
1620
  structuredOutput: args.structuredOutput,
1570
1621
  retryCount: args.retryCount ?? 0
1571
1622
  };
1572
- for (const [index, processorOrWorkflow] of this.inputProcessors.entries()) {
1623
+ const processors = stepInput.model && isMaybeClaude46(stepInput.model) ? [...this.inputProcessors, new TrailingAssistantGuard()] : this.inputProcessors;
1624
+ for (const [index, processorOrWorkflow] of processors.entries()) {
1573
1625
  const processableMessages = messageList.get.all.db();
1574
1626
  const idsBeforeProcessing = processableMessages.map((m) => m.id);
1575
1627
  const check = messageList.makeMessageSourceChecker();
@@ -1801,7 +1853,7 @@ var ProcessorRunner = class _ProcessorRunner {
1801
1853
  writer
1802
1854
  });
1803
1855
  const mutations = messageList.stopRecording();
1804
- if (result instanceof chunkUE2G2LRP_cjs.MessageList) {
1856
+ if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1805
1857
  if (result !== messageList) {
1806
1858
  throw new chunk4U7ZLI36_cjs.MastraError({
1807
1859
  category: "USER",
@@ -1871,7 +1923,7 @@ var ProcessorRunner = class _ProcessorRunner {
1871
1923
  processor,
1872
1924
  stepNumber
1873
1925
  }) {
1874
- if (result instanceof chunkUE2G2LRP_cjs.MessageList) {
1926
+ if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
1875
1927
  if (result !== messageList) {
1876
1928
  throw new chunk4U7ZLI36_cjs.MastraError({
1877
1929
  category: "USER",
@@ -1906,7 +1958,7 @@ var ProcessorRunner = class _ProcessorRunner {
1906
1958
  }
1907
1959
  const { model: _model, ...rest } = result;
1908
1960
  if (result.model) {
1909
- const resolvedModel = await chunkGCTAD6B7_cjs.resolveModelConfig(result.model);
1961
+ const resolvedModel = await chunkVD5YA6RH_cjs.resolveModelConfig(result.model);
1910
1962
  const isSupported = isSupportedLanguageModel(resolvedModel);
1911
1963
  if (!isSupported) {
1912
1964
  throw new chunk4U7ZLI36_cjs.MastraError({
@@ -2975,7 +3027,7 @@ var MastraModelOutput = class extends chunkRO47SMI7_cjs.MastraBase {
2975
3027
  );
2976
3028
  const responseMessages = self.messageList.get.response.aiV4.core();
2977
3029
  const lastResponseMessage = responseMessages[responseMessages.length - 1];
2978
- const outputText = lastResponseMessage ? chunkUE2G2LRP_cjs.coreContentToString(lastResponseMessage.content) : "";
3030
+ const outputText = lastResponseMessage ? chunkCZ4NQANZ_cjs.coreContentToString(lastResponseMessage.content) : "";
2979
3031
  if (lastStep && outputText && outputText !== originalText) {
2980
3032
  lastStep.text = outputText;
2981
3033
  }
@@ -4287,7 +4339,7 @@ function convertMastraChunkToAISDKv5({
4287
4339
  if (mode === "generate") {
4288
4340
  return {
4289
4341
  type: "file",
4290
- file: new chunkUE2G2LRP_cjs.DefaultGeneratedFile({
4342
+ file: new chunkCZ4NQANZ_cjs.DefaultGeneratedFile({
4291
4343
  data: chunk.payload.data,
4292
4344
  mediaType: chunk.payload.mimeType
4293
4345
  })
@@ -4295,7 +4347,7 @@ function convertMastraChunkToAISDKv5({
4295
4347
  }
4296
4348
  return {
4297
4349
  type: "file",
4298
- file: new chunkUE2G2LRP_cjs.DefaultGeneratedFileWithType({
4350
+ file: new chunkCZ4NQANZ_cjs.DefaultGeneratedFileWithType({
4299
4351
  data: chunk.payload.data,
4300
4352
  mediaType: chunk.payload.mimeType
4301
4353
  })
@@ -4909,7 +4961,7 @@ async function validateStepInput({
4909
4961
  }) {
4910
4962
  let inputData = prevOutput;
4911
4963
  let validationError;
4912
- if (validateInputs && chunkOOCEAC6U_cjs.isZodType(step.inputSchema)) {
4964
+ if (validateInputs && chunk65PHUUMF_cjs.isZodType(step.inputSchema)) {
4913
4965
  const inputSchema = step.inputSchema;
4914
4966
  const validatedInput = await inputSchema.safeParseAsync(prevOutput);
4915
4967
  if (!validatedInput.success) {
@@ -4938,7 +4990,7 @@ async function validateStepResumeData({ resumeData, step }) {
4938
4990
  }
4939
4991
  let validationError;
4940
4992
  const resumeSchema = step.resumeSchema;
4941
- if (resumeSchema && chunkOOCEAC6U_cjs.isZodType(resumeSchema)) {
4993
+ if (resumeSchema && chunk65PHUUMF_cjs.isZodType(resumeSchema)) {
4942
4994
  const validatedResumeData = await resumeSchema.safeParseAsync(resumeData);
4943
4995
  if (!validatedResumeData.success) {
4944
4996
  const errors = getZodErrors(validatedResumeData.error);
@@ -4969,7 +5021,7 @@ async function validateStepSuspendData({
4969
5021
  }
4970
5022
  let validationError;
4971
5023
  const suspendSchema = step.suspendSchema;
4972
- if (suspendSchema && validateInputs && chunkOOCEAC6U_cjs.isZodType(suspendSchema)) {
5024
+ if (suspendSchema && validateInputs && chunk65PHUUMF_cjs.isZodType(suspendSchema)) {
4973
5025
  const validatedSuspendData = await suspendSchema.safeParseAsync(suspendData);
4974
5026
  if (!validatedSuspendData.success) {
4975
5027
  const errors = getZodErrors(validatedSuspendData.error);
@@ -5000,7 +5052,7 @@ async function validateStepStateData({
5000
5052
  }
5001
5053
  let validationError;
5002
5054
  const stateSchema = step.stateSchema;
5003
- if (stateSchema && validateInputs && chunkOOCEAC6U_cjs.isZodType(stateSchema)) {
5055
+ if (stateSchema && validateInputs && chunk65PHUUMF_cjs.isZodType(stateSchema)) {
5004
5056
  const validatedStateData = await stateSchema.safeParseAsync(stateData);
5005
5057
  if (!validatedStateData.success) {
5006
5058
  const errors = getZodErrors(validatedStateData.error);
@@ -5019,7 +5071,7 @@ async function validateStepRequestContext({
5019
5071
  }) {
5020
5072
  let validationError;
5021
5073
  const requestContextSchema = step.requestContextSchema;
5022
- if (requestContextSchema && validateInputs && chunkOOCEAC6U_cjs.isZodType(requestContextSchema)) {
5074
+ if (requestContextSchema && validateInputs && chunk65PHUUMF_cjs.isZodType(requestContextSchema)) {
5023
5075
  const contextValues = requestContext?.all ?? {};
5024
5076
  const validatedRequestContext = await requestContextSchema.safeParseAsync(contextValues);
5025
5077
  if (!validatedRequestContext.success) {
@@ -5155,7 +5207,7 @@ var createTimeTravelExecutionParams = (params) => {
5155
5207
  result = void 0;
5156
5208
  }
5157
5209
  if (result) {
5158
- const formattedResult = chunkOOCEAC6U_cjs.removeUndefinedValues(result);
5210
+ const formattedResult = chunk65PHUUMF_cjs.removeUndefinedValues(result);
5159
5211
  stepResults[stepId] = formattedResult;
5160
5212
  }
5161
5213
  });
@@ -5715,7 +5767,7 @@ async function executeLoop(engine, params) {
5715
5767
  options: {
5716
5768
  type: "workflow_conditional_eval" /* WORKFLOW_CONDITIONAL_EVAL */,
5717
5769
  name: `condition: '${entry.loopType}'`,
5718
- input: chunkOOCEAC6U_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
5770
+ input: chunk65PHUUMF_cjs.selectFields(result.output, ["stepResult", "output.text", "output.object", "messages"]),
5719
5771
  attributes: {
5720
5772
  conditionIndex: iteration
5721
5773
  },
@@ -5851,6 +5903,8 @@ async function executeForeach(engine, params) {
5851
5903
  const prevForeachOutput = prevPayload?.suspendPayload?.__workflow_meta?.foreachOutput || [];
5852
5904
  const prevResumeLabels = prevPayload?.suspendPayload?.__workflow_meta?.resumeLabels || {};
5853
5905
  const resumeLabels = getResumeLabelsByStepId(prevResumeLabels, step.id);
5906
+ const totalCount = prevOutput.length;
5907
+ let completedCount = 0;
5854
5908
  for (let i = 0; i < prevOutput.length; i += concurrency) {
5855
5909
  const items = prevOutput.slice(i, i + concurrency);
5856
5910
  const itemsResults = await Promise.all(
@@ -5901,7 +5955,36 @@ async function executeForeach(engine, params) {
5901
5955
  const execResults = { status, error, suspendPayload, suspendedAt, endedAt, output };
5902
5956
  if (execResults.status === "suspended") {
5903
5957
  foreachIndexObj[i + resultIndex] = execResults;
5958
+ await pubsub.publish(`workflow.events.v2.${runId}`, {
5959
+ type: "watch",
5960
+ runId,
5961
+ data: {
5962
+ type: "workflow-step-progress",
5963
+ payload: {
5964
+ id: step.id,
5965
+ completedCount,
5966
+ totalCount,
5967
+ currentIndex: i + resultIndex,
5968
+ iterationStatus: "suspended"
5969
+ }
5970
+ }
5971
+ });
5904
5972
  } else {
5973
+ completedCount++;
5974
+ await pubsub.publish(`workflow.events.v2.${runId}`, {
5975
+ type: "watch",
5976
+ runId,
5977
+ data: {
5978
+ type: "workflow-step-progress",
5979
+ payload: {
5980
+ id: step.id,
5981
+ completedCount,
5982
+ totalCount,
5983
+ currentIndex: i + resultIndex,
5984
+ iterationStatus: "failed"
5985
+ }
5986
+ }
5987
+ });
5905
5988
  await pubsub.publish(`workflow.events.v2.${runId}`, {
5906
5989
  type: "watch",
5907
5990
  runId,
@@ -5927,6 +6010,22 @@ async function executeForeach(engine, params) {
5927
6010
  return result;
5928
6011
  }
5929
6012
  } else {
6013
+ completedCount++;
6014
+ await pubsub.publish(`workflow.events.v2.${runId}`, {
6015
+ type: "watch",
6016
+ runId,
6017
+ data: {
6018
+ type: "workflow-step-progress",
6019
+ payload: {
6020
+ id: step.id,
6021
+ completedCount,
6022
+ totalCount,
6023
+ currentIndex: i + resultIndex,
6024
+ iterationStatus: "success",
6025
+ iterationOutput: result?.output
6026
+ }
6027
+ }
6028
+ });
5930
6029
  const indexResumeLabel = Object.keys(resumeLabels).find(
5931
6030
  (key) => resumeLabels[key]?.foreachIndex === i + resultIndex
5932
6031
  );
@@ -8122,7 +8221,7 @@ function createStepFromProcessor(processor) {
8122
8221
  phase,
8123
8222
  // Auto-create MessageList from messages if not provided
8124
8223
  // This enables running processor workflows from the UI where messageList can't be serialized
8125
- messageList: messageList ?? (Array.isArray(messages) ? new chunkUE2G2LRP_cjs.MessageList().add(messages, "input").addSystem(systemMessages ?? []) : void 0),
8224
+ messageList: messageList ?? (Array.isArray(messages) ? new chunkCZ4NQANZ_cjs.MessageList().add(messages, "input").addSystem(systemMessages ?? []) : void 0),
8126
8225
  stepNumber,
8127
8226
  systemMessages,
8128
8227
  streamParts,
@@ -8176,7 +8275,7 @@ function createStepFromProcessor(processor) {
8176
8275
  messageList: checkedMessageList,
8177
8276
  systemMessages: systemMessages ?? []
8178
8277
  });
8179
- if (result instanceof chunkUE2G2LRP_cjs.MessageList) {
8278
+ if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
8180
8279
  if (result !== checkedMessageList) {
8181
8280
  throw new chunk4U7ZLI36_cjs.MastraError({
8182
8281
  category: "USER" /* USER */,
@@ -8340,7 +8439,7 @@ function createStepFromProcessor(processor) {
8340
8439
  messages,
8341
8440
  messageList: passThrough.messageList
8342
8441
  });
8343
- if (result instanceof chunkUE2G2LRP_cjs.MessageList) {
8442
+ if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
8344
8443
  if (result !== passThrough.messageList) {
8345
8444
  throw new chunk4U7ZLI36_cjs.MastraError({
8346
8445
  category: "USER" /* USER */,
@@ -8407,7 +8506,7 @@ function createStepFromProcessor(processor) {
8407
8506
  systemMessages: systemMessages ?? [],
8408
8507
  steps: steps ?? []
8409
8508
  });
8410
- if (result instanceof chunkUE2G2LRP_cjs.MessageList) {
8509
+ if (result instanceof chunkCZ4NQANZ_cjs.MessageList) {
8411
8510
  if (result !== checkedMessageList) {
8412
8511
  throw new chunk4U7ZLI36_cjs.MastraError({
8413
8512
  category: "USER" /* USER */,
@@ -9449,7 +9548,7 @@ var Run = class {
9449
9548
  }
9450
9549
  async _validateInput(inputData) {
9451
9550
  let inputDataToUse = inputData;
9452
- if (this.validateInputs && this.inputSchema && chunkOOCEAC6U_cjs.isZodType(this.inputSchema)) {
9551
+ if (this.validateInputs && this.inputSchema && chunk65PHUUMF_cjs.isZodType(this.inputSchema)) {
9453
9552
  const validatedInputData = await this.inputSchema.safeParseAsync(inputData);
9454
9553
  if (!validatedInputData.success) {
9455
9554
  const errors = getZodErrors(validatedInputData.error);
@@ -9463,7 +9562,7 @@ var Run = class {
9463
9562
  let initialStateToUse = initialState;
9464
9563
  if (this.validateInputs) {
9465
9564
  let stateSchema = this.stateSchema;
9466
- if (stateSchema && chunkOOCEAC6U_cjs.isZodType(stateSchema)) {
9565
+ if (stateSchema && chunk65PHUUMF_cjs.isZodType(stateSchema)) {
9467
9566
  const validatedInitialState = await stateSchema.safeParseAsync(initialState);
9468
9567
  if (!validatedInitialState.success) {
9469
9568
  const errors = getZodErrors(validatedInitialState.error);
@@ -9477,7 +9576,7 @@ var Run = class {
9477
9576
  return initialStateToUse;
9478
9577
  }
9479
9578
  async _validateRequestContext(requestContext) {
9480
- if (this.validateInputs && this.requestContextSchema && chunkOOCEAC6U_cjs.isZodType(this.requestContextSchema)) {
9579
+ if (this.validateInputs && this.requestContextSchema && chunk65PHUUMF_cjs.isZodType(this.requestContextSchema)) {
9481
9580
  const contextValues = requestContext?.all ?? {};
9482
9581
  const validatedRequestContext = await this.requestContextSchema.safeParseAsync(contextValues);
9483
9582
  if (!validatedRequestContext.success) {
@@ -9491,7 +9590,7 @@ var Run = class {
9491
9590
  }
9492
9591
  async _validateResumeData(resumeData, suspendedStep) {
9493
9592
  let resumeDataToUse = resumeData;
9494
- if (suspendedStep && suspendedStep.resumeSchema && this.validateInputs && chunkOOCEAC6U_cjs.isZodType(suspendedStep.resumeSchema)) {
9593
+ if (suspendedStep && suspendedStep.resumeSchema && this.validateInputs && chunk65PHUUMF_cjs.isZodType(suspendedStep.resumeSchema)) {
9495
9594
  const resumeSchema = suspendedStep.resumeSchema;
9496
9595
  const validatedResumeData = await resumeSchema.safeParseAsync(resumeData);
9497
9596
  if (!validatedResumeData.success) {
@@ -9504,7 +9603,7 @@ var Run = class {
9504
9603
  }
9505
9604
  async _validateTimetravelInputData(inputData, step) {
9506
9605
  let inputDataToUse = inputData;
9507
- if (step && step.inputSchema && this.validateInputs && chunkOOCEAC6U_cjs.isZodType(step.inputSchema)) {
9606
+ if (step && step.inputSchema && this.validateInputs && chunk65PHUUMF_cjs.isZodType(step.inputSchema)) {
9508
9607
  const inputSchema = step.inputSchema;
9509
9608
  const validatedInputData = await inputSchema.safeParseAsync(inputData);
9510
9609
  if (!validatedInputData.success) {
@@ -11080,6 +11179,7 @@ function executeStreamWithFallbackModels(models, logger) {
11080
11179
  let index = 0;
11081
11180
  let finalResult;
11082
11181
  let done = false;
11182
+ let lastError;
11083
11183
  for (const modelConfig of models) {
11084
11184
  index++;
11085
11185
  const maxRetries = modelConfig.maxRetries || 0;
@@ -11098,6 +11198,7 @@ function executeStreamWithFallbackModels(models, logger) {
11098
11198
  if (err instanceof TripWire) {
11099
11199
  throw err;
11100
11200
  }
11201
+ lastError = err;
11101
11202
  attempt++;
11102
11203
  logger?.error(`Error executing model ${modelConfig.model.modelId}, attempt ${attempt}====`, err);
11103
11204
  if (attempt > maxRetries) {
@@ -11109,8 +11210,10 @@ function executeStreamWithFallbackModels(models, logger) {
11109
11210
  }
11110
11211
  }
11111
11212
  if (typeof finalResult === "undefined") {
11112
- logger?.error("Exhausted all fallback models and reached the maximum number of retries.");
11113
- throw new Error("Exhausted all fallback models and reached the maximum number of retries.");
11213
+ const lastErrMsg = lastError instanceof Error ? lastError.message : String(lastError);
11214
+ const errorMessage = `Exhausted all fallback models and reached the maximum number of retries. Last error: ${lastErrMsg}`;
11215
+ logger?.error(errorMessage);
11216
+ throw new Error(errorMessage, { cause: lastError });
11114
11217
  }
11115
11218
  return finalResult;
11116
11219
  };
@@ -11675,6 +11778,16 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
11675
11778
  }
11676
11779
  });
11677
11780
  }
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
11678
11791
  function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep) {
11679
11792
  const processorRunner = rest.outputProcessors?.length && rest.logger ? new ProcessorRunner({
11680
11793
  inputProcessors: [],
@@ -11766,6 +11879,60 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
11766
11879
  };
11767
11880
  rest.messageList.add(msg, "response");
11768
11881
  }
11882
+ const allErrorsAreToolNotFound = errorResults?.length > 0 && errorResults.every((tc) => tc.error instanceof ToolNotFoundError);
11883
+ const hasPendingHITL = inputData.some((tc) => tc.result === void 0 && !tc.error);
11884
+ if (allErrorsAreToolNotFound && !hasPendingHITL) {
11885
+ const successfulResults = inputData.filter((tc) => tc.result !== void 0);
11886
+ if (successfulResults.length) {
11887
+ for (const toolCall of successfulResults) {
11888
+ const chunk = {
11889
+ type: "tool-result",
11890
+ runId: rest.runId,
11891
+ from: "AGENT" /* AGENT */,
11892
+ payload: {
11893
+ args: toolCall.args,
11894
+ toolCallId: toolCall.toolCallId,
11895
+ toolName: toolCall.toolName,
11896
+ result: toolCall.result,
11897
+ providerMetadata: toolCall.providerMetadata,
11898
+ providerExecuted: toolCall.providerExecuted
11899
+ }
11900
+ };
11901
+ await processAndEnqueueChunk(chunk);
11902
+ }
11903
+ const successMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
11904
+ const successMessage = {
11905
+ id: successMessageId || "",
11906
+ role: "assistant",
11907
+ content: {
11908
+ 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
+ }))
11920
+ },
11921
+ createdAt: /* @__PURE__ */ new Date()
11922
+ };
11923
+ rest.messageList.add(successMessage, "response");
11924
+ }
11925
+ initialResult.stepResult.isContinued = true;
11926
+ initialResult.stepResult.reason = "tool-calls";
11927
+ return {
11928
+ ...initialResult,
11929
+ messages: {
11930
+ all: rest.messageList.get.all.aiV5.model(),
11931
+ user: rest.messageList.get.input.aiV5.model(),
11932
+ nonUser: rest.messageList.get.response.aiV5.model()
11933
+ }
11934
+ };
11935
+ }
11769
11936
  if (initialResult.stepResult.reason !== "retry") {
11770
11937
  initialResult.stepResult.isContinued = false;
11771
11938
  }
@@ -11991,7 +12158,14 @@ function createToolCallStep({
11991
12158
  };
11992
12159
  }
11993
12160
  if (!tool2) {
11994
- throw new Error(`Tool ${inputData.toolName} not found`);
12161
+ const availableToolNames = Object.keys(stepTools || {});
12162
+ const availableToolsStr = availableToolNames.length > 0 ? ` Available tools: ${availableToolNames.join(", ")}` : "";
12163
+ return {
12164
+ error: new ToolNotFoundError(
12165
+ `Tool "${inputData.toolName}" not found.${availableToolsStr}. Call tools by their exact name only \u2014 never add prefixes, namespaces, or colons.`
12166
+ ),
12167
+ ...inputData
12168
+ };
11995
12169
  }
11996
12170
  if (tool2 && "onInputAvailable" in tool2) {
11997
12171
  try {
@@ -12995,7 +13169,7 @@ var MastraScorer = class _MastraScorer {
12995
13169
  }
12996
13170
  });
12997
13171
  }
12998
- const resolvedModel = await chunkGCTAD6B7_cjs.resolveModelConfig(modelConfig, void 0, this.#mastra);
13172
+ const resolvedModel = await chunkVD5YA6RH_cjs.resolveModelConfig(modelConfig, void 0, this.#mastra);
12999
13173
  const judge = new Agent({
13000
13174
  id: "judge",
13001
13175
  name: "judge",
@@ -13647,7 +13821,7 @@ var MastraLLMVNext = class extends chunkRO47SMI7_cjs.MastraBase {
13647
13821
  const remainingTokens = parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"] ?? "", 10);
13648
13822
  if (!isNaN(remainingTokens) && remainingTokens > 0 && remainingTokens < 2e3) {
13649
13823
  this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
13650
- await chunkOOCEAC6U_cjs.delay(10 * 1e3);
13824
+ await chunk65PHUUMF_cjs.delay(10 * 1e3);
13651
13825
  }
13652
13826
  },
13653
13827
  onFinish: async (props) => {
@@ -13910,7 +14084,7 @@ async function prepareMemoryStep({
13910
14084
  );
13911
14085
  }
13912
14086
  } else {
13913
- const messageList = new chunkUE2G2LRP_cjs.MessageList({
14087
+ const messageList = new chunkCZ4NQANZ_cjs.MessageList({
13914
14088
  threadId: thread?.id,
13915
14089
  resourceId: thread?.resourceId
13916
14090
  });
@@ -13973,7 +14147,7 @@ async function saveMessagesWithProcessors(memory, messages, processorRunner, con
13973
14147
  await memory.saveMessages({ messages });
13974
14148
  return;
13975
14149
  }
13976
- const messageList = new chunkUE2G2LRP_cjs.MessageList();
14150
+ const messageList = new chunkCZ4NQANZ_cjs.MessageList();
13977
14151
  for (const msg of messages) {
13978
14152
  messageList.add(msg, "response");
13979
14153
  }
@@ -15431,7 +15605,7 @@ async function networkLoop({
15431
15605
  "resumeData": "string"
15432
15606
  }
15433
15607
  `;
15434
- const messageList = new chunkUE2G2LRP_cjs.MessageList();
15608
+ const messageList = new chunkCZ4NQANZ_cjs.MessageList();
15435
15609
  messageList.addSystem(systemInstructions);
15436
15610
  messageList.add(task, "user");
15437
15611
  const result = llm.stream({
@@ -16069,7 +16243,7 @@ ${skillInstructions}`;
16069
16243
  message: `Reference file "${referencePath}" not found in skill "${skillName}". Available references: ${availableRefs.join(", ") || "none"}`
16070
16244
  };
16071
16245
  }
16072
- const result = chunkCGPH7CMG_cjs.extractLines(fullContent, startLine, endLine);
16246
+ const result = chunk4KFEMXTV_cjs.extractLines(fullContent, startLine, endLine);
16073
16247
  return {
16074
16248
  success: true,
16075
16249
  content: result.content,
@@ -16115,7 +16289,7 @@ ${skillInstructions}`;
16115
16289
  message: `Script file "${scriptPath}" not found in skill "${skillName}". Available scripts: ${availableScripts.join(", ") || "none"}`
16116
16290
  };
16117
16291
  }
16118
- const result = chunkCGPH7CMG_cjs.extractLines(fullContent, startLine, endLine);
16292
+ const result = chunk4KFEMXTV_cjs.extractLines(fullContent, startLine, endLine);
16119
16293
  return {
16120
16294
  success: true,
16121
16295
  content: result.content,
@@ -16225,9 +16399,9 @@ ${skillInstructions}`;
16225
16399
  /**
16226
16400
  * Process input step - inject available skills and provide skill tools
16227
16401
  */
16228
- async processInputStep({ messageList, tools, stepNumber }) {
16402
+ async processInputStep({ messageList, tools, stepNumber, requestContext }) {
16229
16403
  if (stepNumber === 0) {
16230
- await this.skills?.maybeRefresh();
16404
+ await this.skills?.maybeRefresh({ requestContext });
16231
16405
  }
16232
16406
  const skillsList = await this.skills?.list();
16233
16407
  const hasSkills = skillsList && skillsList.length > 0;
@@ -16360,7 +16534,7 @@ var AgentLegacyHandler = class {
16360
16534
  methodType: methodType === "generate" ? "generateLegacy" : "streamLegacy",
16361
16535
  memoryConfig
16362
16536
  });
16363
- let messageList = new chunkUE2G2LRP_cjs.MessageList({
16537
+ let messageList = new chunkCZ4NQANZ_cjs.MessageList({
16364
16538
  threadId,
16365
16539
  resourceId,
16366
16540
  generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
@@ -16491,7 +16665,7 @@ var AgentLegacyHandler = class {
16491
16665
  result: resToLog,
16492
16666
  threadId
16493
16667
  });
16494
- const messageListResponses = new chunkUE2G2LRP_cjs.MessageList({
16668
+ const messageListResponses = new chunkCZ4NQANZ_cjs.MessageList({
16495
16669
  threadId,
16496
16670
  resourceId,
16497
16671
  generateMessageId: this.capabilities.mastra?.generateId?.bind(this.capabilities.mastra),
@@ -17529,7 +17703,7 @@ var prepareToolsStepOutputSchema = z10.z.object({
17529
17703
  var prepareMemoryStepOutputSchema = z10.z.object({
17530
17704
  threadExists: z10.z.boolean(),
17531
17705
  thread: storageThreadSchema.optional(),
17532
- messageList: z10.z.instanceof(chunkUE2G2LRP_cjs.MessageList),
17706
+ messageList: z10.z.instanceof(chunkCZ4NQANZ_cjs.MessageList),
17533
17707
  /** Shared processor states map that persists across loop iterations for both input and output processors */
17534
17708
  processorStates: z10.z.instanceof(Map),
17535
17709
  /** Tripwire data when input processor triggered abort */
@@ -17569,7 +17743,7 @@ function createPrepareMemoryStep({
17569
17743
  outputSchema: prepareMemoryStepOutputSchema,
17570
17744
  execute: async ({ tracingContext }) => {
17571
17745
  const thread = threadFromArgs;
17572
- const messageList = new chunkUE2G2LRP_cjs.MessageList({
17746
+ const messageList = new chunkCZ4NQANZ_cjs.MessageList({
17573
17747
  threadId: thread?.id,
17574
17748
  resourceId,
17575
17749
  generateMessageId: capabilities.generateMessageId,
@@ -18043,7 +18217,7 @@ var Agent = class extends chunkRO47SMI7_cjs.MastraBase {
18043
18217
  * Throws an error if validation fails.
18044
18218
  */
18045
18219
  async #validateRequestContext(requestContext) {
18046
- if (this.#requestContextSchema && chunkOOCEAC6U_cjs.isZodType(this.#requestContextSchema)) {
18220
+ if (this.#requestContextSchema && chunk65PHUUMF_cjs.isZodType(this.#requestContextSchema)) {
18047
18221
  const contextValues = requestContext?.all ?? {};
18048
18222
  const validatedRequestContext = await this.#requestContextSchema.safeParseAsync(contextValues);
18049
18223
  if (!validatedRequestContext.success) {
@@ -18769,7 +18943,7 @@ ${errorMessages}`,
18769
18943
  */
18770
18944
  listTools({ requestContext = new chunkVDKWYUGC_cjs.RequestContext() } = {}) {
18771
18945
  if (typeof this.#tools !== "function") {
18772
- return chunkOOCEAC6U_cjs.ensureToolProperties(this.#tools);
18946
+ return chunk65PHUUMF_cjs.ensureToolProperties(this.#tools);
18773
18947
  }
18774
18948
  const result = this.#tools({
18775
18949
  requestContext,
@@ -18790,7 +18964,7 @@ ${errorMessages}`,
18790
18964
  this.logger.error(mastraError.toString());
18791
18965
  throw mastraError;
18792
18966
  }
18793
- return chunkOOCEAC6U_cjs.ensureToolProperties(tools);
18967
+ return chunk65PHUUMF_cjs.ensureToolProperties(tools);
18794
18968
  });
18795
18969
  }
18796
18970
  /**
@@ -18822,7 +18996,7 @@ ${errorMessages}`,
18822
18996
  });
18823
18997
  });
18824
18998
  } else {
18825
- llm = new chunkON2KVIUJ_cjs.MastraLLMV1({
18999
+ llm = new chunkHYRYTTMT_cjs.MastraLLMV1({
18826
19000
  model: resolvedModel,
18827
19001
  mastra: this.#mastra,
18828
19002
  options: { tracingPolicy: this.#options?.tracingPolicy }
@@ -18847,7 +19021,7 @@ ${errorMessages}`,
18847
19021
  */
18848
19022
  async resolveModelConfig(modelConfig, requestContext) {
18849
19023
  try {
18850
- return await chunkGCTAD6B7_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
19024
+ return await chunkVD5YA6RH_cjs.resolveModelConfig(modelConfig, requestContext, this.#mastra);
18851
19025
  } catch (error) {
18852
19026
  const mastraError = new chunk4U7ZLI36_cjs.MastraError({
18853
19027
  id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
@@ -19058,7 +19232,7 @@ ${errorMessages}`,
19058
19232
  instructions
19059
19233
  }) {
19060
19234
  const llm = await this.getLLM({ requestContext, model });
19061
- const normMessage = new chunkUE2G2LRP_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
19235
+ const normMessage = new chunkCZ4NQANZ_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
19062
19236
  if (!normMessage) {
19063
19237
  throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
19064
19238
  }
@@ -19081,7 +19255,7 @@ ${errorMessages}`,
19081
19255
  const systemInstructions = await this.resolveTitleInstructions(requestContext, instructions);
19082
19256
  let text = "";
19083
19257
  if (isSupportedLanguageModel(llm.getModel())) {
19084
- const messageList = new chunkUE2G2LRP_cjs.MessageList().add(
19258
+ const messageList = new chunkCZ4NQANZ_cjs.MessageList().add(
19085
19259
  [
19086
19260
  {
19087
19261
  role: "system",
@@ -19134,7 +19308,7 @@ ${errorMessages}`,
19134
19308
  async genTitle(userMessage, requestContext, tracingContext, model, instructions) {
19135
19309
  try {
19136
19310
  if (userMessage) {
19137
- const normMessage = new chunkUE2G2LRP_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
19311
+ const normMessage = new chunkCZ4NQANZ_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
19138
19312
  if (normMessage) {
19139
19313
  return await this.generateTitleFromUserMessage({
19140
19314
  message: normMessage,
@@ -19203,7 +19377,7 @@ ${errorMessages}`,
19203
19377
  tracingPolicy: this.#options?.tracingPolicy,
19204
19378
  requireApproval: toolObj.requireApproval
19205
19379
  };
19206
- const convertedToCoreTool = chunkOOCEAC6U_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19380
+ const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19207
19381
  convertedMemoryTools[toolName] = convertedToCoreTool;
19208
19382
  }
19209
19383
  }
@@ -19231,7 +19405,7 @@ ${errorMessages}`,
19231
19405
  if (!workspace) {
19232
19406
  return convertedWorkspaceTools;
19233
19407
  }
19234
- const workspaceTools = chunkCGPH7CMG_cjs.createWorkspaceTools(workspace);
19408
+ const workspaceTools = chunk4KFEMXTV_cjs.createWorkspaceTools(workspace);
19235
19409
  if (Object.keys(workspaceTools).length > 0) {
19236
19410
  this.logger.debug(`[Agent:${this.name}] - Adding workspace tools: ${Object.keys(workspaceTools).join(", ")}`, {
19237
19411
  runId
@@ -19252,7 +19426,7 @@ ${errorMessages}`,
19252
19426
  tracingPolicy: this.#options?.tracingPolicy,
19253
19427
  requireApproval: toolObj.requireApproval
19254
19428
  };
19255
- const convertedToCoreTool = chunkOOCEAC6U_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19429
+ const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(toolObj, options, void 0, autoResumeSuspendedTools);
19256
19430
  convertedWorkspaceTools[toolName] = convertedToCoreTool;
19257
19431
  }
19258
19432
  }
@@ -19409,7 +19583,7 @@ ${errorMessages}`,
19409
19583
  tracingPolicy: this.#options?.tracingPolicy,
19410
19584
  requireApproval: tool2.requireApproval
19411
19585
  };
19412
- return [k, chunkOOCEAC6U_cjs.makeCoreTool(tool2, options, void 0, autoResumeSuspendedTools)];
19586
+ return [k, chunk65PHUUMF_cjs.makeCoreTool(tool2, options, void 0, autoResumeSuspendedTools)];
19413
19587
  })
19414
19588
  );
19415
19589
  const assignedToolEntriesConverted = Object.fromEntries(
@@ -19459,7 +19633,7 @@ ${errorMessages}`,
19459
19633
  tracingPolicy: this.#options?.tracingPolicy,
19460
19634
  requireApproval: toolObj.requireApproval
19461
19635
  };
19462
- const convertedToCoreTool = chunkOOCEAC6U_cjs.makeCoreTool(toolObj, options, "toolset", autoResumeSuspendedTools);
19636
+ const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(toolObj, options, "toolset", autoResumeSuspendedTools);
19463
19637
  toolsForRequest[toolName] = convertedToCoreTool;
19464
19638
  }
19465
19639
  }
@@ -19504,7 +19678,7 @@ ${errorMessages}`,
19504
19678
  tracingPolicy: this.#options?.tracingPolicy,
19505
19679
  requireApproval: tool2.requireApproval
19506
19680
  };
19507
- const convertedToCoreTool = chunkOOCEAC6U_cjs.makeCoreTool(rest, options, "client-tool", autoResumeSuspendedTools);
19681
+ const convertedToCoreTool = chunk65PHUUMF_cjs.makeCoreTool(rest, options, "client-tool", autoResumeSuspendedTools);
19508
19682
  toolsForRequest[toolName] = convertedToCoreTool;
19509
19683
  }
19510
19684
  }
@@ -19738,7 +19912,7 @@ ${errorMessages}`,
19738
19912
  tracingContext,
19739
19913
  tracingPolicy: this.#options?.tracingPolicy
19740
19914
  };
19741
- convertedAgentTools[`agent-${agentName}`] = chunkOOCEAC6U_cjs.makeCoreTool(
19915
+ convertedAgentTools[`agent-${agentName}`] = chunk65PHUUMF_cjs.makeCoreTool(
19742
19916
  toolObj,
19743
19917
  options,
19744
19918
  void 0,
@@ -19923,7 +20097,7 @@ ${errorMessages}`,
19923
20097
  tracingContext,
19924
20098
  tracingPolicy: this.#options?.tracingPolicy
19925
20099
  };
19926
- convertedWorkflowTools[`workflow-${workflowName}`] = chunkOOCEAC6U_cjs.makeCoreTool(
20100
+ convertedWorkflowTools[`workflow-${workflowName}`] = chunk65PHUUMF_cjs.makeCoreTool(
19927
20101
  toolObj,
19928
20102
  options,
19929
20103
  void 0,
@@ -19953,7 +20127,7 @@ ${errorMessages}`,
19953
20127
  let mastraProxy = void 0;
19954
20128
  const logger = this.logger;
19955
20129
  if (this.#mastra) {
19956
- mastraProxy = chunkOOCEAC6U_cjs.createMastraProxy({ mastra: this.#mastra, logger });
20130
+ mastraProxy = chunk65PHUUMF_cjs.createMastraProxy({ mastra: this.#mastra, logger });
19957
20131
  }
19958
20132
  const assignedTools = await this.listAssignedTools({
19959
20133
  runId,
@@ -20203,7 +20377,7 @@ ${errorMessages}`,
20203
20377
  throw mastraError;
20204
20378
  }
20205
20379
  let headers;
20206
- if (resolvedModel instanceof chunkGCTAD6B7_cjs.ModelRouterLanguageModel) {
20380
+ if (resolvedModel instanceof chunkVD5YA6RH_cjs.ModelRouterLanguageModel) {
20207
20381
  headers = resolvedModel.config?.headers;
20208
20382
  }
20209
20383
  return [
@@ -20249,7 +20423,7 @@ ${errorMessages}`,
20249
20423
  throw mastraError;
20250
20424
  }
20251
20425
  let headers;
20252
- if (model2 instanceof chunkGCTAD6B7_cjs.ModelRouterLanguageModel) {
20426
+ if (model2 instanceof chunkVD5YA6RH_cjs.ModelRouterLanguageModel) {
20253
20427
  headers = model2.config?.headers;
20254
20428
  }
20255
20429
  return {
@@ -20307,7 +20481,7 @@ ${errorMessages}`,
20307
20481
  const targetProvider = structuredOutputModel.provider;
20308
20482
  const targetModelId = structuredOutputModel.modelId;
20309
20483
  if (targetProvider.includes("openai") || targetModelId.includes("openai")) {
20310
- if (chunkOOCEAC6U_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
20484
+ if (chunk65PHUUMF_cjs.isZodType(options.structuredOutput.schema) && targetModelId) {
20311
20485
  const modelInfo = {
20312
20486
  provider: targetProvider,
20313
20487
  modelId: targetModelId,
@@ -20714,7 +20888,7 @@ ${errorMessages}`,
20714
20888
  const defaultOptions = await this.getDefaultOptions({
20715
20889
  requestContext: options?.requestContext
20716
20890
  });
20717
- const mergedOptions = chunkOOCEAC6U_cjs.deepMerge(
20891
+ const mergedOptions = chunk65PHUUMF_cjs.deepMerge(
20718
20892
  defaultOptions,
20719
20893
  options ?? {}
20720
20894
  );
@@ -20778,7 +20952,7 @@ ${errorMessages}`,
20778
20952
  const defaultOptions = await this.getDefaultOptions({
20779
20953
  requestContext: streamOptions?.requestContext
20780
20954
  });
20781
- const mergedOptions = chunkOOCEAC6U_cjs.deepMerge(
20955
+ const mergedOptions = chunk65PHUUMF_cjs.deepMerge(
20782
20956
  defaultOptions,
20783
20957
  streamOptions ?? {}
20784
20958
  );
@@ -20836,7 +21010,7 @@ ${errorMessages}`,
20836
21010
  const defaultOptions = await this.getDefaultOptions({
20837
21011
  requestContext: streamOptions?.requestContext
20838
21012
  });
20839
- let mergedStreamOptions = chunkOOCEAC6U_cjs.deepMerge(
21013
+ let mergedStreamOptions = chunk65PHUUMF_cjs.deepMerge(
20840
21014
  defaultOptions,
20841
21015
  streamOptions ?? {}
20842
21016
  );
@@ -20910,7 +21084,7 @@ ${errorMessages}`,
20910
21084
  const defaultOptions = await this.getDefaultOptions({
20911
21085
  requestContext: options?.requestContext
20912
21086
  });
20913
- const mergedOptions = chunkOOCEAC6U_cjs.deepMerge(
21087
+ const mergedOptions = chunk65PHUUMF_cjs.deepMerge(
20914
21088
  defaultOptions,
20915
21089
  options ?? {}
20916
21090
  );
@@ -23115,7 +23289,7 @@ var ToolSearchProcessor = class {
23115
23289
  minScore: options.search?.minScore ?? 0
23116
23290
  };
23117
23291
  this.ttl = options.ttl ?? 36e5;
23118
- this.bm25Index = new chunkCGPH7CMG_cjs.BM25Index({}, TOOL_SEARCH_TOKENIZE_OPTIONS);
23292
+ this.bm25Index = new chunk4KFEMXTV_cjs.BM25Index({}, TOOL_SEARCH_TOKENIZE_OPTIONS);
23119
23293
  this.indexTools();
23120
23294
  if (this.ttl > 0) {
23121
23295
  this.scheduleCleanup();
@@ -23862,7 +24036,7 @@ var SemanticRecall = class {
23862
24036
  */
23863
24037
  formatCrossThreadMessages(messages, currentThreadId) {
23864
24038
  let result = ``;
23865
- const v1Messages = new chunkUE2G2LRP_cjs.MessageList().add(messages, "memory").get.all.v1();
24039
+ const v1Messages = new chunkCZ4NQANZ_cjs.MessageList().add(messages, "memory").get.all.v1();
23866
24040
  let lastYmd = null;
23867
24041
  for (const msg of v1Messages) {
23868
24042
  const date = msg.createdAt;
@@ -24200,6 +24374,14 @@ function augmentWithInit(storage) {
24200
24374
  }
24201
24375
 
24202
24376
  // src/memory/memory.ts
24377
+ function extractModelIdString(model) {
24378
+ if (typeof model === "string") return model;
24379
+ if (typeof model === "function") return void 0;
24380
+ if (model && typeof model === "object" && "id" in model && typeof model.id === "string") {
24381
+ return model.id;
24382
+ }
24383
+ return void 0;
24384
+ }
24203
24385
  var MemoryProcessor = class extends chunkRO47SMI7_cjs.MastraBase {
24204
24386
  /**
24205
24387
  * Process a list of messages and return a filtered or transformed list.
@@ -24296,7 +24478,7 @@ https://mastra.ai/en/docs/memory/semantic-recall`
24296
24478
  );
24297
24479
  }
24298
24480
  if (typeof config.embedder === "string") {
24299
- this.embedder = new chunkGCTAD6B7_cjs.ModelRouterEmbeddingModel(config.embedder);
24481
+ this.embedder = new chunkVD5YA6RH_cjs.ModelRouterEmbeddingModel(config.embedder);
24300
24482
  } else {
24301
24483
  this.embedder = config.embedder;
24302
24484
  }
@@ -24335,7 +24517,7 @@ https://mastra.ai/en/docs/memory/overview`
24335
24517
  }
24336
24518
  setEmbedder(embedder, embedderOptions) {
24337
24519
  if (typeof embedder === "string") {
24338
- this.embedder = new chunkGCTAD6B7_cjs.ModelRouterEmbeddingModel(embedder);
24520
+ this.embedder = new chunkVD5YA6RH_cjs.ModelRouterEmbeddingModel(embedder);
24339
24521
  } else {
24340
24522
  this.embedder = embedder;
24341
24523
  }
@@ -24402,7 +24584,7 @@ https://mastra.ai/en/docs/memory/overview`
24402
24584
  "The threads.generateTitle option has been moved. Use the top-level generateTitle option instead."
24403
24585
  );
24404
24586
  }
24405
- const mergedConfig = chunkOOCEAC6U_cjs.deepMerge(this.threadConfig, config || {});
24587
+ const mergedConfig = chunk65PHUUMF_cjs.deepMerge(this.threadConfig, config || {});
24406
24588
  if (typeof config?.workingMemory === "object" && config.workingMemory?.schema && typeof mergedConfig.workingMemory === "object") {
24407
24589
  mergedConfig.workingMemory.schema = config.workingMemory.schema;
24408
24590
  }
@@ -24646,7 +24828,7 @@ https://mastra.ai/en/docs/memory/overview`
24646
24828
  * @returns Serializable memory configuration
24647
24829
  */
24648
24830
  getConfig() {
24649
- const { generateTitle, workingMemory, threads, ...restConfig } = this.threadConfig;
24831
+ const { generateTitle, workingMemory, threads, observationalMemory, ...restConfig } = this.threadConfig;
24650
24832
  const config = {
24651
24833
  vector: this.vector?.id,
24652
24834
  options: {
@@ -24683,8 +24865,62 @@ https://mastra.ai/en/docs/memory/overview`
24683
24865
  const { telemetry, ...rest } = this.embedderOptions;
24684
24866
  config.embedderOptions = rest;
24685
24867
  }
24868
+ if (observationalMemory !== void 0) {
24869
+ config.observationalMemory = this.serializeObservationalMemory(observationalMemory);
24870
+ }
24686
24871
  return config;
24687
24872
  }
24873
+ /**
24874
+ * Serialize observational memory config to a JSON-safe representation.
24875
+ * Model references that aren't string IDs are dropped (non-serializable).
24876
+ */
24877
+ serializeObservationalMemory(om) {
24878
+ if (typeof om === "boolean") {
24879
+ return om;
24880
+ }
24881
+ if (om.enabled === false) {
24882
+ return false;
24883
+ }
24884
+ const result = {
24885
+ scope: om.scope,
24886
+ shareTokenBudget: om.shareTokenBudget
24887
+ };
24888
+ const topModelId = extractModelIdString(om.model);
24889
+ if (topModelId) {
24890
+ result.model = topModelId;
24891
+ }
24892
+ if (om.observation) {
24893
+ const obs = om.observation;
24894
+ result.observation = {
24895
+ messageTokens: obs.messageTokens,
24896
+ modelSettings: obs.modelSettings,
24897
+ providerOptions: obs.providerOptions,
24898
+ maxTokensPerBatch: obs.maxTokensPerBatch,
24899
+ bufferTokens: obs.bufferTokens,
24900
+ bufferActivation: obs.bufferActivation,
24901
+ blockAfter: obs.blockAfter
24902
+ };
24903
+ const obsModelId = extractModelIdString(obs.model);
24904
+ if (obsModelId) {
24905
+ result.observation.model = obsModelId;
24906
+ }
24907
+ }
24908
+ if (om.reflection) {
24909
+ const ref = om.reflection;
24910
+ result.reflection = {
24911
+ observationTokens: ref.observationTokens,
24912
+ modelSettings: ref.modelSettings,
24913
+ providerOptions: ref.providerOptions,
24914
+ blockAfter: ref.blockAfter,
24915
+ bufferActivation: ref.bufferActivation
24916
+ };
24917
+ const refModelId = extractModelIdString(ref.model);
24918
+ if (refModelId) {
24919
+ result.reflection.model = refModelId;
24920
+ }
24921
+ }
24922
+ return result;
24923
+ }
24688
24924
  };
24689
24925
  var isZodObject = (v) => v instanceof z10.ZodObject;
24690
24926
  var MockMemory = class extends MastraMemory {
@@ -24696,7 +24932,7 @@ var MockMemory = class extends MastraMemory {
24696
24932
  } = {}) {
24697
24933
  super({
24698
24934
  name: "mock",
24699
- storage: storage || new chunkTERSHTY5_cjs.InMemoryStore(),
24935
+ storage: storage || new chunkBP7VYTOP_cjs.InMemoryStore(),
24700
24936
  options: {
24701
24937
  workingMemory: enableWorkingMemory ? { enabled: true, template: workingMemoryTemplate } : void 0,
24702
24938
  lastMessages: enableMessageHistory ? 10 : void 0
@@ -25004,5 +25240,5 @@ exports.validateStepRequestContext = validateStepRequestContext;
25004
25240
  exports.validateStepResumeData = validateStepResumeData;
25005
25241
  exports.validateStepStateData = validateStepStateData;
25006
25242
  exports.validateStepSuspendData = validateStepSuspendData;
25007
- //# sourceMappingURL=chunk-YNXIGRQE.cjs.map
25008
- //# sourceMappingURL=chunk-YNXIGRQE.cjs.map
25243
+ //# sourceMappingURL=chunk-4IJ4UDZX.cjs.map
25244
+ //# sourceMappingURL=chunk-4IJ4UDZX.cjs.map