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

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 (421) hide show
  1. package/CHANGELOG.md +448 -0
  2. package/dist/agent/agent-legacy.d.ts +17 -20
  3. package/dist/agent/agent-legacy.d.ts.map +1 -1
  4. package/dist/agent/agent-types.test-d.d.ts +2 -0
  5. package/dist/agent/agent-types.test-d.d.ts.map +1 -0
  6. package/dist/agent/agent.d.ts +4 -4
  7. package/dist/agent/agent.d.ts.map +1 -1
  8. package/dist/agent/agent.types.d.ts +1 -1
  9. package/dist/agent/agent.types.d.ts.map +1 -1
  10. package/dist/agent/index.cjs +9 -9
  11. package/dist/agent/index.js +2 -2
  12. package/dist/agent/message-list/index.cjs +3 -3
  13. package/dist/agent/message-list/index.d.ts +49 -0
  14. package/dist/agent/message-list/index.d.ts.map +1 -1
  15. package/dist/agent/message-list/index.js +1 -1
  16. package/dist/agent/save-queue/index.d.ts +3 -1
  17. package/dist/agent/save-queue/index.d.ts.map +1 -1
  18. package/dist/agent/test-utils.d.ts +37 -0
  19. package/dist/agent/test-utils.d.ts.map +1 -1
  20. package/dist/agent/trip-wire.d.ts.map +1 -1
  21. package/dist/agent/types.d.ts +18 -3
  22. package/dist/agent/types.d.ts.map +1 -1
  23. package/dist/agent/utils.d.ts.map +1 -1
  24. package/dist/agent/workflows/prepare-stream/index.d.ts +10 -10
  25. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  26. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +1 -3
  27. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  28. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +4 -4
  29. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
  30. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +4 -4
  31. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
  32. package/dist/agent/workflows/prepare-stream/schema.d.ts +14 -14
  33. package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
  34. package/dist/base.cjs +2 -2
  35. package/dist/base.js +1 -1
  36. package/dist/bundler/index.cjs +2 -2
  37. package/dist/bundler/index.js +1 -1
  38. package/dist/cache/index.cjs +3 -3
  39. package/dist/cache/index.js +1 -1
  40. package/dist/{chunk-556MJ7CL.cjs → chunk-26YAGTXK.cjs} +43 -37
  41. package/dist/chunk-26YAGTXK.cjs.map +1 -0
  42. package/dist/{chunk-OJNJA5ZI.js → chunk-3CKZSDTQ.js} +3 -3
  43. package/dist/{chunk-OJNJA5ZI.js.map → chunk-3CKZSDTQ.js.map} +1 -1
  44. package/dist/{chunk-E7K4FTLN.cjs → chunk-3EYBRHB2.cjs} +18 -2
  45. package/dist/chunk-3EYBRHB2.cjs.map +1 -0
  46. package/dist/{chunk-X7F4CSGR.cjs → chunk-3JA6VPNM.cjs} +2 -2
  47. package/dist/chunk-3JA6VPNM.cjs.map +1 -0
  48. package/dist/{chunk-TQTAMPSC.js → chunk-3N3QE4ZK.js} +3 -3
  49. package/dist/chunk-3N3QE4ZK.js.map +1 -0
  50. package/dist/{chunk-BMAFVZ2D.cjs → chunk-4AP234N6.cjs} +4 -4
  51. package/dist/{chunk-BMAFVZ2D.cjs.map → chunk-4AP234N6.cjs.map} +1 -1
  52. package/dist/{chunk-XIDKHXNR.js → chunk-4F6RAJFU.js} +33 -6
  53. package/dist/chunk-4F6RAJFU.js.map +1 -0
  54. package/dist/{chunk-B5J5HYDN.js → chunk-4GTU7MB2.js} +160 -8
  55. package/dist/chunk-4GTU7MB2.js.map +1 -0
  56. package/dist/{chunk-ISMGVGUM.cjs → chunk-4JKEUSCC.cjs} +4 -4
  57. package/dist/{chunk-ISMGVGUM.cjs.map → chunk-4JKEUSCC.cjs.map} +1 -1
  58. package/dist/{chunk-KJIQGPQR.js → chunk-5T53HHNP.js} +24 -10
  59. package/dist/chunk-5T53HHNP.js.map +1 -0
  60. package/dist/{chunk-CBAB7GOD.cjs → chunk-6BJ7XHRH.cjs} +2 -2
  61. package/dist/{chunk-CBAB7GOD.cjs.map → chunk-6BJ7XHRH.cjs.map} +1 -1
  62. package/dist/{chunk-RROQ46B6.cjs → chunk-6C2PU6J4.cjs} +31 -47
  63. package/dist/chunk-6C2PU6J4.cjs.map +1 -0
  64. package/dist/{chunk-J7O6WENZ.cjs → chunk-6TBWJV35.js} +5 -5
  65. package/dist/chunk-6TBWJV35.js.map +1 -0
  66. package/dist/{chunk-DSNPWVIG.cjs → chunk-AF74UXR5.cjs} +4 -3
  67. package/dist/chunk-AF74UXR5.cjs.map +1 -0
  68. package/dist/chunk-AZQMPE7G.cjs +4981 -0
  69. package/dist/chunk-AZQMPE7G.cjs.map +1 -0
  70. package/dist/{chunk-HNHZGFZY.cjs → chunk-CZEJQSWB.cjs} +10 -2
  71. package/dist/chunk-CZEJQSWB.cjs.map +1 -0
  72. package/dist/{chunk-KEXGB7FK.cjs → chunk-DGV2FWB4.cjs} +7 -7
  73. package/dist/{chunk-KEXGB7FK.cjs.map → chunk-DGV2FWB4.cjs.map} +1 -1
  74. package/dist/{chunk-YDFX3JR2.js → chunk-DMPHPHMU.js} +174 -12
  75. package/dist/chunk-DMPHPHMU.js.map +1 -0
  76. package/dist/{chunk-76K3IYWM.js → chunk-EE5NIGJ4.js} +3 -3
  77. package/dist/{chunk-76K3IYWM.js.map → chunk-EE5NIGJ4.js.map} +1 -1
  78. package/dist/{chunk-Y63IFHEZ.cjs → chunk-EOPEDKLG.cjs} +4 -4
  79. package/dist/chunk-EOPEDKLG.cjs.map +1 -0
  80. package/dist/{chunk-T2CJRA6E.js → chunk-EPMSC67U.js} +145 -19
  81. package/dist/chunk-EPMSC67U.js.map +1 -0
  82. package/dist/{chunk-NZAXAFI3.js → chunk-F2GAJSBI.js} +3 -3
  83. package/dist/{chunk-NZAXAFI3.js.map → chunk-F2GAJSBI.js.map} +1 -1
  84. package/dist/{chunk-5O52O25J.js → chunk-F54IK3GJ.js} +2 -2
  85. package/dist/chunk-F54IK3GJ.js.map +1 -0
  86. package/dist/{chunk-KIZIOFZC.js → chunk-FNSFXWDN.js} +17 -3
  87. package/dist/chunk-FNSFXWDN.js.map +1 -0
  88. package/dist/{chunk-ZTTMSCLU.js → chunk-G32WDDGV.js} +85 -9
  89. package/dist/chunk-G32WDDGV.js.map +1 -0
  90. package/dist/{chunk-5SA2EZ33.js → chunk-GZ6MCDK2.js} +147 -15
  91. package/dist/chunk-GZ6MCDK2.js.map +1 -0
  92. package/dist/{chunk-NHP6ZIDG.cjs → chunk-HJNEZRI4.cjs} +28 -174
  93. package/dist/chunk-HJNEZRI4.cjs.map +1 -0
  94. package/dist/{chunk-S6URFGCZ.js → chunk-LSHPJWM5.js} +3 -3
  95. package/dist/{chunk-S6URFGCZ.js.map → chunk-LSHPJWM5.js.map} +1 -1
  96. package/dist/{chunk-XJQX54QP.cjs → chunk-M7CQULF7.cjs} +97 -16
  97. package/dist/chunk-M7CQULF7.cjs.map +1 -0
  98. package/dist/{chunk-D7CJ4HIQ.js → chunk-NAKPEQEQ.js} +10 -156
  99. package/dist/chunk-NAKPEQEQ.js.map +1 -0
  100. package/dist/{chunk-KJ2SW6VA.js → chunk-NRUZYMHE.js} +4 -3
  101. package/dist/chunk-NRUZYMHE.js.map +1 -0
  102. package/dist/{chunk-KWWD3U7G.cjs → chunk-PJ7AYWAX.cjs} +155 -29
  103. package/dist/chunk-PJ7AYWAX.cjs.map +1 -0
  104. package/dist/{chunk-7ZADRRDW.js → chunk-PK2A5WBG.js} +3 -3
  105. package/dist/chunk-PK2A5WBG.js.map +1 -0
  106. package/dist/{chunk-XBO6W7LZ.js → chunk-POM7FCH5.js} +6166 -4133
  107. package/dist/chunk-POM7FCH5.js.map +1 -0
  108. package/dist/{chunk-X7JMA3IY.js → chunk-PSCMWPLC.js} +2 -2
  109. package/dist/{chunk-X7JMA3IY.js.map → chunk-PSCMWPLC.js.map} +1 -1
  110. package/dist/{chunk-KP42JLXE.cjs → chunk-RBBEMTMA.cjs} +6199 -4154
  111. package/dist/chunk-RBBEMTMA.cjs.map +1 -0
  112. package/dist/chunk-TLLXRG2Z.js +4959 -0
  113. package/dist/chunk-TLLXRG2Z.js.map +1 -0
  114. package/dist/{chunk-SVLMF4UZ.cjs → chunk-TQB2HMEC.cjs} +45 -44
  115. package/dist/chunk-TQB2HMEC.cjs.map +1 -0
  116. package/dist/{chunk-Y6ROD72V.cjs → chunk-UIGRFDO6.cjs} +4 -4
  117. package/dist/{chunk-Y6ROD72V.cjs.map → chunk-UIGRFDO6.cjs.map} +1 -1
  118. package/dist/{chunk-PC6EKOWK.js → chunk-URBPEE67.js} +19 -31
  119. package/dist/chunk-URBPEE67.js.map +1 -0
  120. package/dist/{chunk-VYJXTHII.cjs → chunk-URMN7TTH.cjs} +148 -16
  121. package/dist/chunk-URMN7TTH.cjs.map +1 -0
  122. package/dist/{chunk-GRBGQ2GE.js → chunk-UVHSM2GU.cjs} +9 -3
  123. package/dist/chunk-UVHSM2GU.cjs.map +1 -0
  124. package/dist/{chunk-U3VE2EVB.cjs → chunk-VBKMNIWK.cjs} +30 -16
  125. package/dist/chunk-VBKMNIWK.cjs.map +1 -0
  126. package/dist/{chunk-V537VSV4.cjs → chunk-Y24HI6ND.cjs} +37 -10
  127. package/dist/chunk-Y24HI6ND.cjs.map +1 -0
  128. package/dist/{chunk-DQIZ5FFX.cjs → chunk-YBEW5YWC.cjs} +177 -15
  129. package/dist/chunk-YBEW5YWC.cjs.map +1 -0
  130. package/dist/{chunk-OUUPUAGA.cjs → chunk-YUXTDKYN.cjs} +168 -15
  131. package/dist/chunk-YUXTDKYN.cjs.map +1 -0
  132. package/dist/{chunk-IITXXVYI.cjs → chunk-YWMMBIOM.cjs} +10 -10
  133. package/dist/{chunk-IITXXVYI.cjs.map → chunk-YWMMBIOM.cjs.map} +1 -1
  134. package/dist/{chunk-3B2OPLGG.js → chunk-Z4Y554NX.js} +13 -7
  135. package/dist/chunk-Z4Y554NX.js.map +1 -0
  136. package/dist/{chunk-3ZQ7LX73.js → chunk-Z57R5WS4.js} +4 -4
  137. package/dist/{chunk-3ZQ7LX73.js.map → chunk-Z57R5WS4.js.map} +1 -1
  138. package/dist/{chunk-QM5SRDJX.js → chunk-ZUWJCGLM.js} +5 -4
  139. package/dist/chunk-ZUWJCGLM.js.map +1 -0
  140. package/dist/deployer/index.cjs +2 -2
  141. package/dist/deployer/index.js +1 -1
  142. package/dist/di/index.cjs +10 -2
  143. package/dist/di/index.d.ts +1 -1
  144. package/dist/di/index.d.ts.map +1 -1
  145. package/dist/di/index.js +1 -1
  146. package/dist/evals/base.d.ts +9 -1
  147. package/dist/evals/base.d.ts.map +1 -1
  148. package/dist/evals/index.cjs +9 -9
  149. package/dist/evals/index.js +2 -2
  150. package/dist/evals/scoreTraces/index.cjs +5 -5
  151. package/dist/evals/scoreTraces/index.js +2 -2
  152. package/dist/evals/types.d.ts +8 -8
  153. package/dist/index.cjs +2 -2
  154. package/dist/index.js +1 -1
  155. package/dist/integration/index.cjs +2 -2
  156. package/dist/integration/index.js +1 -1
  157. package/dist/llm/index.cjs +15 -15
  158. package/dist/llm/index.js +5 -5
  159. package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
  160. package/dist/llm/model/gateways/constants.d.ts.map +1 -1
  161. package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
  162. package/dist/llm/model/model.d.ts.map +1 -1
  163. package/dist/llm/model/model.loop.d.ts +1 -1
  164. package/dist/llm/model/model.loop.d.ts.map +1 -1
  165. package/dist/llm/model/provider-options.d.ts +4 -1
  166. package/dist/llm/model/provider-options.d.ts.map +1 -1
  167. package/dist/llm/model/provider-registry.d.ts.map +1 -1
  168. package/dist/llm/model/provider-types.generated.d.ts +39 -1
  169. package/dist/logger/constants.d.ts +1 -0
  170. package/dist/logger/constants.d.ts.map +1 -1
  171. package/dist/logger/index.cjs +11 -11
  172. package/dist/logger/index.js +2 -2
  173. package/dist/logger/transport.d.ts +1 -1
  174. package/dist/logger/transport.d.ts.map +1 -1
  175. package/dist/loop/index.cjs +2 -2
  176. package/dist/loop/index.js +1 -1
  177. package/dist/loop/loop.d.ts.map +1 -1
  178. package/dist/loop/network/index.d.ts +2 -2
  179. package/dist/loop/network/index.d.ts.map +1 -1
  180. package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
  181. package/dist/loop/types.d.ts +5 -2
  182. package/dist/loop/types.d.ts.map +1 -1
  183. package/dist/loop/workflows/agentic-execution/index.d.ts +96 -96
  184. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +65 -65
  185. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  186. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +32 -32
  187. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  188. package/dist/loop/workflows/agentic-loop/index.d.ts +97 -97
  189. package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
  190. package/dist/loop/workflows/schema.d.ts +32 -32
  191. package/dist/loop/workflows/stream.d.ts +1 -1
  192. package/dist/loop/workflows/stream.d.ts.map +1 -1
  193. package/dist/mastra/index.cjs +2 -2
  194. package/dist/mastra/index.d.ts +55 -0
  195. package/dist/mastra/index.d.ts.map +1 -1
  196. package/dist/mastra/index.js +1 -1
  197. package/dist/mcp/index.cjs +4 -4
  198. package/dist/mcp/index.js +2 -2
  199. package/dist/memory/index.cjs +21 -382
  200. package/dist/memory/index.cjs.map +1 -1
  201. package/dist/memory/index.js +1 -382
  202. package/dist/memory/index.js.map +1 -1
  203. package/dist/memory/memory.d.ts +22 -18
  204. package/dist/memory/memory.d.ts.map +1 -1
  205. package/dist/memory/mock.d.ts +6 -1
  206. package/dist/memory/mock.d.ts.map +1 -1
  207. package/dist/memory/types.d.ts +69 -11
  208. package/dist/memory/types.d.ts.map +1 -1
  209. package/dist/models-dev-6GD3644V.js +3 -0
  210. package/dist/{models-dev-F6MTIYTO.js.map → models-dev-6GD3644V.js.map} +1 -1
  211. package/dist/models-dev-IUQBXJSS.cjs +12 -0
  212. package/dist/{models-dev-XIVR5EJV.cjs.map → models-dev-IUQBXJSS.cjs.map} +1 -1
  213. package/dist/netlify-GXJ5D5DD.js +3 -0
  214. package/dist/{netlify-RX3JXCFQ.js.map → netlify-GXJ5D5DD.js.map} +1 -1
  215. package/dist/netlify-KJLY3GFS.cjs +12 -0
  216. package/dist/{netlify-MXBOGAJR.cjs.map → netlify-KJLY3GFS.cjs.map} +1 -1
  217. package/dist/observability/index.cjs +16 -8
  218. package/dist/observability/index.js +1 -1
  219. package/dist/observability/types/tracing.d.ts +183 -3
  220. package/dist/observability/types/tracing.d.ts.map +1 -1
  221. package/dist/observability/utils.d.ts +47 -1
  222. package/dist/observability/utils.d.ts.map +1 -1
  223. package/dist/processors/index.cjs +35 -11
  224. package/dist/processors/index.d.ts +99 -21
  225. package/dist/processors/index.d.ts.map +1 -1
  226. package/dist/processors/index.js +1 -1
  227. package/dist/processors/memory/index.d.ts +7 -0
  228. package/dist/processors/memory/index.d.ts.map +1 -0
  229. package/dist/processors/memory/message-history.d.ts +43 -0
  230. package/dist/processors/memory/message-history.d.ts.map +1 -0
  231. package/dist/processors/memory/semantic-recall.d.ts +152 -0
  232. package/dist/processors/memory/semantic-recall.d.ts.map +1 -0
  233. package/dist/processors/memory/working-memory.d.ts +65 -0
  234. package/dist/processors/memory/working-memory.d.ts.map +1 -0
  235. package/dist/processors/processors/index.d.ts +2 -1
  236. package/dist/processors/processors/index.d.ts.map +1 -1
  237. package/dist/processors/processors/language-detector.d.ts +14 -0
  238. package/dist/processors/processors/language-detector.d.ts.map +1 -1
  239. package/dist/processors/processors/moderation.d.ts +14 -0
  240. package/dist/processors/processors/moderation.d.ts.map +1 -1
  241. package/dist/processors/processors/pii-detector.d.ts +14 -0
  242. package/dist/processors/processors/pii-detector.d.ts.map +1 -1
  243. package/dist/processors/processors/prompt-injection-detector.d.ts +14 -0
  244. package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
  245. package/dist/processors/processors/structured-output.d.ts +2 -1
  246. package/dist/processors/processors/structured-output.d.ts.map +1 -1
  247. package/dist/processors/processors/token-limiter.d.ts +21 -11
  248. package/dist/processors/processors/token-limiter.d.ts.map +1 -1
  249. package/dist/processors/processors/tool-call-filter.d.ts +28 -0
  250. package/dist/processors/processors/tool-call-filter.d.ts.map +1 -0
  251. package/dist/processors/runner.d.ts +35 -4
  252. package/dist/processors/runner.d.ts.map +1 -1
  253. package/dist/provider-registry-7IFOXWPR.cjs +40 -0
  254. package/dist/{provider-registry-NBRXBOQT.cjs.map → provider-registry-7IFOXWPR.cjs.map} +1 -1
  255. package/dist/provider-registry-ZTMZMTVV.js +3 -0
  256. package/dist/{provider-registry-3LUCE7FT.js.map → provider-registry-ZTMZMTVV.js.map} +1 -1
  257. package/dist/provider-registry.json +111 -6
  258. package/dist/{registry-generator-DEPPRYYJ.cjs → registry-generator-34SC4TAU.cjs} +2 -2
  259. package/dist/registry-generator-34SC4TAU.cjs.map +1 -0
  260. package/dist/{registry-generator-FLW6NV42.js → registry-generator-UMTNPBJX.js} +2 -2
  261. package/dist/registry-generator-UMTNPBJX.js.map +1 -0
  262. package/dist/relevance/index.cjs +2 -2
  263. package/dist/relevance/index.js +1 -1
  264. package/dist/request-context/index.cjs +10 -2
  265. package/dist/request-context/index.d.ts +26 -0
  266. package/dist/request-context/index.d.ts.map +1 -1
  267. package/dist/request-context/index.js +1 -1
  268. package/dist/server/base.d.ts +51 -0
  269. package/dist/server/base.d.ts.map +1 -0
  270. package/dist/server/index.cjs +81 -2
  271. package/dist/server/index.cjs.map +1 -1
  272. package/dist/server/index.d.ts +3 -0
  273. package/dist/server/index.d.ts.map +1 -1
  274. package/dist/server/index.js +79 -2
  275. package/dist/server/index.js.map +1 -1
  276. package/dist/server/simple-auth.d.ts +27 -0
  277. package/dist/server/simple-auth.d.ts.map +1 -0
  278. package/dist/storage/base.d.ts +22 -1
  279. package/dist/storage/base.d.ts.map +1 -1
  280. package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
  281. package/dist/storage/index.cjs +49 -29
  282. package/dist/storage/index.js +1 -1
  283. package/dist/storage/storageWithInit.d.ts.map +1 -1
  284. package/dist/storage/types.d.ts +1 -1
  285. package/dist/storage/types.d.ts.map +1 -1
  286. package/dist/storage/utils.d.ts +82 -0
  287. package/dist/storage/utils.d.ts.map +1 -1
  288. package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
  289. package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
  290. package/dist/stream/MastraWorkflowStream.d.ts +1 -1
  291. package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
  292. package/dist/stream/RunOutput.d.ts +2 -2
  293. package/dist/stream/RunOutput.d.ts.map +1 -1
  294. package/dist/stream/aisdk/v5/execute.d.ts +3 -2
  295. package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
  296. package/dist/stream/aisdk/v5/input.d.ts +4 -1
  297. package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
  298. package/dist/stream/aisdk/v5/output.d.ts +1 -1
  299. package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
  300. package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
  301. package/dist/stream/base/base.d.ts +1 -1
  302. package/dist/stream/base/base.d.ts.map +1 -1
  303. package/dist/stream/base/output-format-handlers.d.ts +1 -1
  304. package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
  305. package/dist/stream/base/output.d.ts +1 -1
  306. package/dist/stream/base/output.d.ts.map +1 -1
  307. package/dist/stream/index.cjs +11 -11
  308. package/dist/stream/index.js +2 -2
  309. package/dist/stream/types.d.ts +2 -0
  310. package/dist/stream/types.d.ts.map +1 -1
  311. package/dist/test-utils/llm-mock.cjs +44 -10
  312. package/dist/test-utils/llm-mock.cjs.map +1 -1
  313. package/dist/test-utils/llm-mock.d.ts +3 -0
  314. package/dist/test-utils/llm-mock.d.ts.map +1 -1
  315. package/dist/test-utils/llm-mock.js +36 -6
  316. package/dist/test-utils/llm-mock.js.map +1 -1
  317. package/dist/tools/index.cjs +6 -6
  318. package/dist/tools/index.js +2 -2
  319. package/dist/tools/is-vercel-tool.cjs +2 -2
  320. package/dist/tools/is-vercel-tool.js +1 -1
  321. package/dist/tools/stream.d.ts +18 -2
  322. package/dist/tools/stream.d.ts.map +1 -1
  323. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  324. package/dist/tools/tool.d.ts +13 -0
  325. package/dist/tools/tool.d.ts.map +1 -1
  326. package/dist/tools/types.d.ts +24 -3
  327. package/dist/tools/types.d.ts.map +1 -1
  328. package/dist/tools/validation.d.ts +1 -1
  329. package/dist/tools/validation.d.ts.map +1 -1
  330. package/dist/tts/index.cjs +2 -2
  331. package/dist/tts/index.js +1 -1
  332. package/dist/utils.cjs +22 -22
  333. package/dist/utils.d.ts +1 -1
  334. package/dist/utils.d.ts.map +1 -1
  335. package/dist/utils.js +1 -1
  336. package/dist/vector/index.cjs +4 -4
  337. package/dist/vector/index.js +2 -2
  338. package/dist/voice/index.cjs +6 -6
  339. package/dist/voice/index.js +1 -1
  340. package/dist/workflows/default.d.ts +176 -281
  341. package/dist/workflows/default.d.ts.map +1 -1
  342. package/dist/workflows/evented/index.cjs +10 -10
  343. package/dist/workflows/evented/index.js +1 -1
  344. package/dist/workflows/evented/step-executor.d.ts +1 -1
  345. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  346. package/dist/workflows/execution-engine.d.ts +4 -2
  347. package/dist/workflows/execution-engine.d.ts.map +1 -1
  348. package/dist/workflows/handlers/control-flow.d.ts +135 -0
  349. package/dist/workflows/handlers/control-flow.d.ts.map +1 -0
  350. package/dist/workflows/handlers/entry.d.ts +45 -0
  351. package/dist/workflows/handlers/entry.d.ts.map +1 -0
  352. package/dist/workflows/handlers/sleep.d.ts +62 -0
  353. package/dist/workflows/handlers/sleep.d.ts.map +1 -0
  354. package/dist/workflows/handlers/step.d.ts +60 -0
  355. package/dist/workflows/handlers/step.d.ts.map +1 -0
  356. package/dist/workflows/index.cjs +20 -20
  357. package/dist/workflows/index.js +1 -1
  358. package/dist/workflows/step.d.ts +2 -2
  359. package/dist/workflows/step.d.ts.map +1 -1
  360. package/dist/workflows/types.d.ts +158 -3
  361. package/dist/workflows/types.d.ts.map +1 -1
  362. package/dist/workflows/workflow.d.ts +8 -6
  363. package/dist/workflows/workflow.d.ts.map +1 -1
  364. package/package.json +8 -5
  365. package/src/llm/model/provider-types.generated.d.ts +39 -1
  366. package/dist/chunk-3B2OPLGG.js.map +0 -1
  367. package/dist/chunk-3PSWNGBF.js +0 -3
  368. package/dist/chunk-3PSWNGBF.js.map +0 -1
  369. package/dist/chunk-436FFEF6.js +0 -34
  370. package/dist/chunk-436FFEF6.js.map +0 -1
  371. package/dist/chunk-556MJ7CL.cjs.map +0 -1
  372. package/dist/chunk-5O52O25J.js.map +0 -1
  373. package/dist/chunk-5SA2EZ33.js.map +0 -1
  374. package/dist/chunk-7ZADRRDW.js.map +0 -1
  375. package/dist/chunk-B5J5HYDN.js.map +0 -1
  376. package/dist/chunk-D7CJ4HIQ.js.map +0 -1
  377. package/dist/chunk-DQIZ5FFX.cjs.map +0 -1
  378. package/dist/chunk-DSNPWVIG.cjs.map +0 -1
  379. package/dist/chunk-E7K4FTLN.cjs.map +0 -1
  380. package/dist/chunk-GRBGQ2GE.js.map +0 -1
  381. package/dist/chunk-HNHZGFZY.cjs.map +0 -1
  382. package/dist/chunk-J7O6WENZ.cjs.map +0 -1
  383. package/dist/chunk-KIZIOFZC.js.map +0 -1
  384. package/dist/chunk-KJ2SW6VA.js.map +0 -1
  385. package/dist/chunk-KJIQGPQR.js.map +0 -1
  386. package/dist/chunk-KP42JLXE.cjs.map +0 -1
  387. package/dist/chunk-KWWD3U7G.cjs.map +0 -1
  388. package/dist/chunk-NHP6ZIDG.cjs.map +0 -1
  389. package/dist/chunk-OUUPUAGA.cjs.map +0 -1
  390. package/dist/chunk-PC6EKOWK.js.map +0 -1
  391. package/dist/chunk-PE3V7GUL.cjs +0 -4
  392. package/dist/chunk-PE3V7GUL.cjs.map +0 -1
  393. package/dist/chunk-QGWNF2QJ.cjs +0 -1697
  394. package/dist/chunk-QGWNF2QJ.cjs.map +0 -1
  395. package/dist/chunk-QM5SRDJX.js.map +0 -1
  396. package/dist/chunk-RROQ46B6.cjs.map +0 -1
  397. package/dist/chunk-SVLMF4UZ.cjs.map +0 -1
  398. package/dist/chunk-T2CJRA6E.js.map +0 -1
  399. package/dist/chunk-T2UNO766.js +0 -1694
  400. package/dist/chunk-T2UNO766.js.map +0 -1
  401. package/dist/chunk-TQTAMPSC.js.map +0 -1
  402. package/dist/chunk-U3VE2EVB.cjs.map +0 -1
  403. package/dist/chunk-V3VLOOSW.cjs +0 -36
  404. package/dist/chunk-V3VLOOSW.cjs.map +0 -1
  405. package/dist/chunk-V537VSV4.cjs.map +0 -1
  406. package/dist/chunk-VYJXTHII.cjs.map +0 -1
  407. package/dist/chunk-X7F4CSGR.cjs.map +0 -1
  408. package/dist/chunk-XBO6W7LZ.js.map +0 -1
  409. package/dist/chunk-XIDKHXNR.js.map +0 -1
  410. package/dist/chunk-XJQX54QP.cjs.map +0 -1
  411. package/dist/chunk-Y63IFHEZ.cjs.map +0 -1
  412. package/dist/chunk-YDFX3JR2.js.map +0 -1
  413. package/dist/chunk-ZTTMSCLU.js.map +0 -1
  414. package/dist/models-dev-F6MTIYTO.js +0 -3
  415. package/dist/models-dev-XIVR5EJV.cjs +0 -12
  416. package/dist/netlify-MXBOGAJR.cjs +0 -12
  417. package/dist/netlify-RX3JXCFQ.js +0 -3
  418. package/dist/provider-registry-3LUCE7FT.js +0 -3
  419. package/dist/provider-registry-NBRXBOQT.cjs +0 -40
  420. package/dist/registry-generator-DEPPRYYJ.cjs.map +0 -1
  421. package/dist/registry-generator-FLW6NV42.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/observability/types/tracing.ts","../src/observability/no-op.ts","../src/observability/utils.ts","../src/observability/context.ts"],"names":["SpanType","InternalSpans","SamplingStrategyType","TracingEventType"],"mappings":";;;AAgBO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,WAAA,CAAA,GAAY,WAAA;AAEZ,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,UAAA,kBAAA,CAAA,GAAmB,kBAAA;AAEnB,EAAAA,UAAA,YAAA,CAAA,GAAa,YAAA;AAEb,EAAAA,UAAA,aAAA,CAAA,GAAc,aAAA;AAEd,EAAAA,UAAA,eAAA,CAAA,GAAgB,eAAA;AAEhB,EAAAA,UAAA,eAAA,CAAA,GAAgB,eAAA;AAEhB,EAAAA,UAAA,WAAA,CAAA,GAAY,WAAA;AAEZ,EAAAA,UAAA,cAAA,CAAA,GAAe,cAAA;AAEf,EAAAA,UAAA,eAAA,CAAA,GAAgB,eAAA;AAEhB,EAAAA,UAAA,sBAAA,CAAA,GAAuB,sBAAA;AAEvB,EAAAA,UAAA,2BAAA,CAAA,GAA4B,2BAAA;AAE5B,EAAAA,UAAA,mBAAA,CAAA,GAAoB,mBAAA;AAEpB,EAAAA,UAAA,eAAA,CAAA,GAAgB,eAAA;AAEhB,EAAAA,UAAA,gBAAA,CAAA,GAAiB,gBAAA;AAEjB,EAAAA,UAAA,qBAAA,CAAA,GAAsB,qBAAA;AAhCZ,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AA+sBL,IAAK,aAAA,qBAAAC,cAAAA,KAAL;AAEL,EAAAA,cAAAA,CAAAA,cAAAA,CAAA,UAAO,CAAA,CAAA,GAAP,MAAA;AAEA,EAAAA,cAAAA,CAAAA,cAAAA,CAAA,cAAW,CAAA,CAAA,GAAX,UAAA;AAEA,EAAAA,cAAAA,CAAAA,cAAAA,CAAA,WAAQ,CAAA,CAAA,GAAR,OAAA;AAEA,EAAAA,cAAAA,CAAAA,cAAAA,CAAA,UAAO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import type { IMastraLogger } from '../../logger';\nimport type { Mastra } from '../../mastra';\nimport type { RequestContext } from '../../request-context';\nimport type { WorkflowRunStatus, WorkflowStepStatus } from '../../workflows';\n\n// ============================================================================\n// Span Types\n// ============================================================================\n\n/**\n * AI-specific span types with their associated metadata\n */\nexport enum SpanType {\n /** Agent run - root span for agent processes */\n AGENT_RUN = 'agent_run',\n /** Generic span for custom operations */\n GENERIC = 'generic',\n /** Model generation with model calls, token usage, prompts, completions */\n MODEL_GENERATION = 'model_generation',\n /** Single model execution step within a generation (one API call) */\n MODEL_STEP = 'model_step',\n /** Individual model streaming chunk/event */\n MODEL_CHUNK = 'model_chunk',\n /** MCP (Model Context Protocol) tool execution */\n MCP_TOOL_CALL = 'mcp_tool_call',\n /** Input or Output Processor execution */\n PROCESSOR_RUN = 'processor_run',\n /** Function/tool execution with inputs, outputs, errors */\n TOOL_CALL = 'tool_call',\n /** Workflow run - root span for workflow processes */\n WORKFLOW_RUN = 'workflow_run',\n /** Workflow step execution with step status, data flow */\n WORKFLOW_STEP = 'workflow_step',\n /** Workflow conditional execution with condition evaluation */\n WORKFLOW_CONDITIONAL = 'workflow_conditional',\n /** Individual condition evaluation within conditional */\n WORKFLOW_CONDITIONAL_EVAL = 'workflow_conditional_eval',\n /** Workflow parallel execution */\n WORKFLOW_PARALLEL = 'workflow_parallel',\n /** Workflow loop execution */\n WORKFLOW_LOOP = 'workflow_loop',\n /** Workflow sleep operation */\n WORKFLOW_SLEEP = 'workflow_sleep',\n /** Workflow wait for event operation */\n WORKFLOW_WAIT_EVENT = 'workflow_wait_event',\n}\n\n// ============================================================================\n// Type-Specific Attributes Interfaces\n// ============================================================================\n\n/**\n * Base attributes that all spans can have\n */\nexport interface AIBaseAttributes {}\n\n/**\n * Agent Run attributes\n */\nexport interface AgentRunAttributes extends AIBaseAttributes {\n /** Agent identifier */\n agentId: string;\n /** Human-readable agent name */\n agentName?: string;\n /** Conversation/thread/session identifier for multi-turn interactions */\n conversationId?: string;\n /** Agent Instructions **/\n instructions?: string;\n /** Agent Prompt **/\n prompt?: string;\n /** Available tools for this execution */\n availableTools?: string[];\n /** Maximum steps allowed */\n maxSteps?: number;\n}\n\n/** Token usage statistics - supports both v5 and legacy formats */\nexport interface UsageStats {\n // VNext paths\n inputTokens?: number;\n outputTokens?: number;\n // Legacy format (for backward compatibility)\n promptTokens?: number;\n completionTokens?: number;\n // Common fields\n totalTokens?: number;\n reasoningTokens?: number;\n cachedInputTokens?: number;\n promptCacheHitTokens?: number;\n promptCacheMissTokens?: number;\n}\n\n/**\n * Model Generation attributes\n */\nexport interface ModelGenerationAttributes extends AIBaseAttributes {\n /** Model name (e.g., 'gpt-4', 'claude-3') */\n model?: string;\n /** Model provider (e.g., 'openai', 'anthropic') */\n provider?: string;\n /** Type of result/output this LLM call produced */\n resultType?: 'tool_selection' | 'response_generation' | 'reasoning' | 'planning';\n /** Token usage statistics - supports both v5 and legacy formats */\n usage?: UsageStats;\n /** Model parameters */\n parameters?: {\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n topK?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n stopSequences?: string[];\n seed?: number;\n maxRetries?: number;\n abortSignal?: any;\n headers?: Record<string, string | undefined>;\n };\n /** Whether this was a streaming response */\n streaming?: boolean;\n /** Reason the generation finished */\n finishReason?: string;\n /**\n * When the first token/chunk of the completion was received.\n * Used to calculate time-to-first-token (TTFT) metrics.\n * Only applicable for streaming responses.\n */\n completionStartTime?: Date;\n /** Actual model used in the response (may differ from request model) */\n responseModel?: string;\n /** Unique identifier for the response */\n responseId?: string;\n /** Server address for the model endpoint */\n serverAddress?: string;\n /** Server port for the model endpoint */\n serverPort?: number;\n}\n\n/**\n * Model Step attributes - for a single model execution within a generation\n */\nexport interface ModelStepAttributes extends AIBaseAttributes {\n /** Index of this step in the generation (0, 1, 2, ...) */\n stepIndex?: number;\n /** Token usage statistics */\n usage?: UsageStats;\n /** Reason this step finished (stop, tool-calls, length, etc.) */\n finishReason?: string;\n /** Should execution continue */\n isContinued?: boolean;\n /** Result warnings */\n warnings?: Record<string, any>;\n}\n\n/**\n * Model Chunk attributes - for individual streaming chunks/events\n */\nexport interface ModelChunkAttributes extends AIBaseAttributes {\n /** Type of chunk (text-delta, reasoning-delta, tool-call, etc.) */\n chunkType?: string;\n /** Sequence number of this chunk in the stream */\n sequenceNumber?: number;\n}\n\n/**\n * Tool Call attributes\n */\nexport interface ToolCallAttributes extends AIBaseAttributes {\n toolId?: string;\n toolType?: string;\n toolDescription?: string;\n success?: boolean;\n}\n\n/**\n * MCP Tool Call attributes\n */\nexport interface MCPToolCallAttributes extends AIBaseAttributes {\n /** Id of the MCP tool/function */\n toolId: string;\n /** MCP server identifier */\n mcpServer: string;\n /** MCP server version */\n serverVersion?: string;\n /** Whether tool execution was successful */\n success?: boolean;\n}\n\n/**\n * Processor attributes\n */\nexport interface ProcessorRunAttributes extends AIBaseAttributes {\n /** Name of the Processor */\n processorName: string;\n /** Processor type (input or output) */\n processorType: 'input' | 'output';\n /** Processor index in the agent */\n processorIndex?: number;\n /** MessageList mutations performed by this processor */\n messageListMutations?: Array<{\n type: 'add' | 'addSystem' | 'removeByIds' | 'clear';\n source?: string;\n count?: number;\n ids?: string[];\n text?: string;\n tag?: string;\n message?: any;\n }>;\n}\n\n/**\n * Workflow Run attributes\n */\nexport interface WorkflowRunAttributes extends AIBaseAttributes {\n /** Workflow identifier */\n workflowId: string;\n /** Workflow status */\n status?: WorkflowRunStatus;\n}\n\n/**\n * Workflow Step attributes\n */\nexport interface WorkflowStepAttributes extends AIBaseAttributes {\n /** Step identifier */\n stepId: string;\n /** Step status */\n status?: WorkflowStepStatus;\n}\n\n/**\n * Workflow Conditional attributes\n */\nexport interface WorkflowConditionalAttributes extends AIBaseAttributes {\n /** Number of conditions evaluated */\n conditionCount: number;\n /** Which condition indexes evaluated to true */\n truthyIndexes?: number[];\n /** Which steps will be executed */\n selectedSteps?: string[];\n}\n\n/**\n * Workflow Conditional Evaluation attributes\n */\nexport interface WorkflowConditionalEvalAttributes extends AIBaseAttributes {\n /** Index of this condition in the conditional */\n conditionIndex: number;\n /** Result of condition evaluation */\n result?: boolean;\n}\n\n/**\n * Workflow Parallel attributes\n */\nexport interface WorkflowParallelAttributes extends AIBaseAttributes {\n /** Number of parallel branches */\n branchCount: number;\n /** Step IDs being executed in parallel */\n parallelSteps?: string[];\n}\n\n/**\n * Workflow Loop attributes\n */\nexport interface WorkflowLoopAttributes extends AIBaseAttributes {\n /** Type of loop (foreach, dowhile, dountil) */\n loopType?: 'foreach' | 'dowhile' | 'dountil';\n /** Current iteration number (for individual iterations) */\n iteration?: number;\n /** Total iterations (if known) */\n totalIterations?: number;\n /** Number of steps to run concurrently in foreach loop */\n concurrency?: number;\n}\n\n/**\n * Workflow Sleep attributes\n */\nexport interface WorkflowSleepAttributes extends AIBaseAttributes {\n /** Sleep duration in milliseconds */\n durationMs?: number;\n /** Sleep until date */\n untilDate?: Date;\n /** Sleep type */\n sleepType?: 'fixed' | 'dynamic';\n}\n\n/**\n * Workflow Wait Event attributes\n */\nexport interface WorkflowWaitEventAttributes extends AIBaseAttributes {\n /** Event name being waited for */\n eventName?: string;\n /** Timeout in milliseconds */\n timeoutMs?: number;\n /** Whether event was received or timed out */\n eventReceived?: boolean;\n /** Wait duration in milliseconds */\n waitDurationMs?: number;\n}\n\n/**\n * AI-specific span types mapped to their attributes\n */\nexport interface SpanTypeMap {\n [SpanType.AGENT_RUN]: AgentRunAttributes;\n [SpanType.WORKFLOW_RUN]: WorkflowRunAttributes;\n [SpanType.MODEL_GENERATION]: ModelGenerationAttributes;\n [SpanType.MODEL_STEP]: ModelStepAttributes;\n [SpanType.MODEL_CHUNK]: ModelChunkAttributes;\n [SpanType.TOOL_CALL]: ToolCallAttributes;\n [SpanType.MCP_TOOL_CALL]: MCPToolCallAttributes;\n [SpanType.PROCESSOR_RUN]: ProcessorRunAttributes;\n [SpanType.WORKFLOW_STEP]: WorkflowStepAttributes;\n [SpanType.WORKFLOW_CONDITIONAL]: WorkflowConditionalAttributes;\n [SpanType.WORKFLOW_CONDITIONAL_EVAL]: WorkflowConditionalEvalAttributes;\n [SpanType.WORKFLOW_PARALLEL]: WorkflowParallelAttributes;\n [SpanType.WORKFLOW_LOOP]: WorkflowLoopAttributes;\n [SpanType.WORKFLOW_SLEEP]: WorkflowSleepAttributes;\n [SpanType.WORKFLOW_WAIT_EVENT]: WorkflowWaitEventAttributes;\n [SpanType.GENERIC]: AIBaseAttributes;\n}\n\n/**\n * Union type for cases that need to handle any span type\n */\nexport type AnySpanAttributes = SpanTypeMap[keyof SpanTypeMap];\n\n// ============================================================================\n// Span Interfaces\n// ============================================================================\n\n/**\n * Base Span interface\n */\ninterface BaseSpan<TType extends SpanType> {\n /** Unique span identifier */\n id: string;\n /** OpenTelemetry-compatible trace ID (32 hex chars) - present on all spans */\n traceId: string;\n /** Name of the span */\n name: string;\n /** Type of the span */\n type: TType;\n /** When span started */\n startTime: Date;\n /** When span ended */\n endTime?: Date;\n /** Span-type specific attributes */\n attributes?: SpanTypeMap[TType];\n /** User-defined metadata */\n metadata?: Record<string, any>;\n /** Labels used to categorize and filter traces. Only valid on root spans. */\n tags?: string[];\n /** Input passed at the start of the span */\n input?: any;\n /** Output generated at the end of the span */\n output?: any;\n /** Error information if span failed */\n errorInfo?: {\n message: string;\n id?: string;\n domain?: string;\n category?: string;\n details?: Record<string, any>;\n };\n /** Is an event span? (event occurs at startTime, has no endTime) */\n isEvent: boolean;\n}\n\n/**\n * Span interface, used internally for tracing\n */\nexport interface Span<TType extends SpanType> extends BaseSpan<TType> {\n /** Is an internal span? (spans internal to the operation of mastra) */\n isInternal: boolean;\n /** Parent span reference (undefined for root spans) */\n parent?: AnySpan;\n /** Pointer to the ObservabilityInstance instance */\n observabilityInstance: ObservabilityInstance;\n /** Trace-level state shared across all spans in this trace */\n traceState?: TraceState;\n\n // Methods for span lifecycle\n /** End the span */\n end(options?: EndSpanOptions<TType>): void;\n\n /** Record an error for the span, optionally end the span as well */\n error(options: ErrorSpanOptions<TType>): void;\n\n /** Update span attributes */\n update(options: UpdateSpanOptions<TType>): void;\n\n /** Create child span - can be any span type independent of parent */\n createChildSpan(options: ChildSpanOptions<SpanType.MODEL_GENERATION>): AIModelGenerationSpan;\n createChildSpan<TChildType extends SpanType>(options: ChildSpanOptions<TChildType>): Span<TChildType>;\n\n /** Create event span - can be any span type independent of parent */\n createEventSpan<TChildType extends SpanType>(options: ChildEventOptions<TChildType>): Span<TChildType>;\n\n /** Returns `TRUE` if the span is the root span of a trace */\n get isRootSpan(): boolean;\n\n /** Returns `TRUE` if the span is a valid span (not a NO-OP Span) */\n get isValid(): boolean;\n\n /** Get the closest parent spanId that isn't an internal span */\n getParentSpanId(includeInternalSpans?: boolean): string | undefined;\n\n /** Find the closest parent span of a specific type by walking up the parent chain */\n findParent<T extends SpanType>(spanType: T): Span<T> | undefined;\n\n /** Returns a lightweight span ready for export */\n exportSpan(includeInternalSpans?: boolean): ExportedSpan<TType> | undefined;\n\n /** Returns the traceId on span, unless NoOpSpan, then undefined */\n get externalTraceId(): string | undefined;\n\n /**\n * Execute an async function within this span's tracing context.\n *\n * When a bridge is configured, this enables auto-instrumented operations\n * (HTTP requests, database queries, etc.) to be properly nested under this\n * span in the external tracing system.\n *\n * @param fn - The async function to execute within the span context\n * @returns The result of the function execution\n *\n * @example\n * ```typescript\n * const result = await modelSpan.executeInContext(async () => {\n * return model.generateText(...);\n * });\n * ```\n */\n executeInContext<T>(fn: () => Promise<T>): Promise<T>;\n\n /**\n * Execute a synchronous function within this span's tracing context.\n *\n * When a bridge is configured, this enables auto-instrumented operations\n * (HTTP requests, database queries, etc.) to be properly nested under this\n * span in the external tracing system.\n *\n * @param fn - The synchronous function to execute within the span context\n * @returns The result of the function execution\n *\n * @example\n * ```typescript\n * const result = modelSpan.executeInContextSync(() => {\n * return model.streamText(...);\n * });\n * ```\n */\n executeInContextSync<T>(fn: () => T): T;\n}\n\nexport interface BridgeSpanContext {\n /**\n * Execute an async function within this span's tracing context.\n *\n * When a bridge is configured, this enables auto-instrumented operations\n * (HTTP requests, database queries, etc.) to be properly nested under this\n * span in the external tracing system.\n *\n * @param fn - The async function to execute within the span context\n * @returns The result of the function execution\n *\n * @example\n * ```typescript\n * const result = await modelSpan.executeInContext(async () => {\n * return model.generateText(...);\n * });\n * ```\n */\n executeInContext<T>(fn: () => Promise<T>): Promise<T>;\n\n /**\n * Execute a synchronous function within this span's tracing context.\n *\n * When a bridge is configured, this enables auto-instrumented operations\n * (HTTP requests, database queries, etc.) to be properly nested under this\n * span in the external tracing system.\n *\n * @param fn - The synchronous function to execute within the span context\n * @returns The result of the function execution\n *\n * @example\n * ```typescript\n * const result = modelSpan.executeInContextSync(() => {\n * return model.streamText(...);\n * });\n * ```\n */\n executeInContextSync<T>(fn: () => T): T;\n}\n\n/**\n * Specialized span interface for MODEL_GENERATION spans\n * Provides access to creating a ModelSpanTracker for tracking MODEL_STEP and MODEL_CHUNK spans\n */\nexport interface AIModelGenerationSpan extends Span<SpanType.MODEL_GENERATION> {\n /** Create a ModelSpanTracker for tracking model execution steps and chunks */\n createTracker(): IModelSpanTracker | undefined;\n}\n\n/**\n * Exported Span interface, used for tracing exporters\n */\nexport interface ExportedSpan<TType extends SpanType> extends BaseSpan<TType> {\n /** Parent span id reference (undefined for root spans) */\n parentSpanId?: string;\n /** `TRUE` if the span is the root span of a trace */\n isRootSpan: boolean;\n /**\n * Tags for this trace (only present on root spans).\n * Tags are string labels used to categorize and filter traces.\n */\n tags?: string[];\n}\n\nexport interface IModelSpanTracker {\n getTracingContext(): TracingContext;\n reportGenerationError(options: ErrorSpanOptions<SpanType.MODEL_GENERATION>): void;\n endGeneration(options?: EndSpanOptions<SpanType.MODEL_GENERATION>): void;\n wrapStream<T extends { pipeThrough: Function }>(stream: T): T;\n}\n\n/**\n * Union type for cases that need to handle any span\n */\nexport type AnySpan = Span<keyof SpanTypeMap>;\n\n/**\n * Union type for cases that need to handle any exported span\n */\nexport type AnyExportedSpan = ExportedSpan<keyof SpanTypeMap>;\n\n// ============================================================================\n// Tracing Interfaces\n// ============================================================================\n\n/**\n * Primary interface for Observability\n */\nexport interface ObservabilityInstance {\n /**\n * Get current configuration\n */\n getConfig(): Readonly<ObservabilityInstanceConfig>;\n\n /**\n * Get all exporters\n */\n getExporters(): readonly ObservabilityExporter[];\n\n /**\n * Get all span output processors\n */\n getSpanOutputProcessors(): readonly SpanOutputProcessor[];\n\n /**\n * Get the logger instance (for exporters and other components)\n */\n getLogger(): IMastraLogger;\n\n /**\n * Get the bridge instance if configured\n */\n getBridge(): ObservabilityBridge | undefined;\n\n /**\n * Start a new span of a specific SpanType\n */\n startSpan<TType extends SpanType>(options: StartSpanOptions<TType>): Span<TType>;\n\n /**\n * Shutdown tracing and clean up resources\n */\n shutdown(): Promise<void>;\n\n /**\n * Override setLogger to add tracing specific initialization log\n */\n __setLogger(logger: IMastraLogger): void;\n}\n\n// ============================================================================\n// Span Create/Update/Error Option Types\n// ============================================================================\n\ninterface CreateBaseOptions<TType extends SpanType> {\n /** Span attributes */\n attributes?: SpanTypeMap[TType];\n /** Span metadata */\n metadata?: Record<string, any>;\n /** Span name */\n name: string;\n /** Span type */\n type: TType;\n /** Policy-level tracing configuration */\n tracingPolicy?: TracingPolicy;\n /** Request Context for metadata extraction */\n requestContext?: RequestContext;\n}\n\n/**\n * Options for creating new spans\n */\nexport interface CreateSpanOptions<TType extends SpanType> extends CreateBaseOptions<TType> {\n /** Input data */\n input?: any;\n /** Output data (for event spans) */\n output?: any;\n /** Labels used to categorize and filter traces. Only valid on root spans. */\n tags?: string[];\n /** Parent span */\n parent?: AnySpan;\n /** Is an event span? */\n isEvent?: boolean;\n /**\n * Trace ID to use for this span (1-32 hexadecimal characters).\n * Only used for root spans without a parent.\n */\n traceId?: string;\n /**\n * Parent span ID to use for this span (1-16 hexadecimal characters).\n * Only used for root spans without a parent.\n */\n parentSpanId?: string;\n /** Trace-level state shared across all spans in this trace */\n traceState?: TraceState;\n}\n\n/**\n * Options for starting new spans\n */\nexport interface StartSpanOptions<TType extends SpanType> extends CreateSpanOptions<TType> {\n /**\n * Options passed when using a custom sampler strategy\n */\n customSamplerOptions?: CustomSamplerOptions;\n /** Tracing options for this execution */\n tracingOptions?: TracingOptions;\n}\n\n/**\n * Options for new child spans\n */\nexport interface ChildSpanOptions<TType extends SpanType> extends CreateBaseOptions<TType> {\n /** Input data */\n input?: any;\n}\n\n/**\n * Options for new child events\n * Event spans have no input, and no endTime\n */\nexport interface ChildEventOptions<TType extends SpanType> extends CreateBaseOptions<TType> {\n /** Output data */\n output?: any;\n}\n\ninterface UpdateBaseOptions<TType extends SpanType> {\n /** Span attributes */\n attributes?: Partial<SpanTypeMap[TType]>;\n /** Span metadata */\n metadata?: Record<string, any>;\n}\n\nexport interface EndSpanOptions<TType extends SpanType> extends UpdateBaseOptions<TType> {\n /** Output data */\n output?: any;\n}\n\nexport interface UpdateSpanOptions<TType extends SpanType> extends UpdateBaseOptions<TType> {\n /** Input data */\n input?: any;\n /** Output data */\n output?: any;\n}\n\nexport interface ErrorSpanOptions<TType extends SpanType> extends UpdateBaseOptions<TType> {\n /** The error associated with the issue */\n error: MastraError | Error;\n /** End the span when true */\n endSpan?: boolean;\n}\n\nexport interface GetOrCreateSpanOptions<TType extends SpanType> {\n type: TType;\n name: string;\n input?: any;\n attributes?: SpanTypeMap[TType];\n metadata?: Record<string, any>;\n tracingPolicy?: TracingPolicy;\n tracingOptions?: TracingOptions;\n tracingContext?: TracingContext;\n requestContext?: RequestContext;\n mastra?: Mastra;\n}\n\n// ============================================================================\n// Lifecycle Types\n// ============================================================================\n\nexport interface ObservabilityEntrypoint {\n shutdown(): Promise<void>;\n\n setMastraContext(options: { mastra: Mastra }): void;\n\n setLogger(options: { logger: IMastraLogger }): void;\n\n getSelectedInstance(options: ConfigSelectorOptions): ObservabilityInstance | undefined;\n\n // Registry management methods\n registerInstance(name: string, instance: ObservabilityInstance, isDefault?: boolean): void;\n getInstance(name: string): ObservabilityInstance | undefined;\n getDefaultInstance(): ObservabilityInstance | undefined;\n listInstances(): ReadonlyMap<string, ObservabilityInstance>;\n unregisterInstance(name: string): boolean;\n hasInstance(name: string): boolean;\n setConfigSelector(selector: ConfigSelector): void;\n clear(): void;\n}\n\n/**\n * Bitwise options to set different types of spans as internal in\n * a workflow or agent execution.\n */\nexport enum InternalSpans {\n /** No spans are marked internal */\n NONE = 0,\n /** Workflow spans are marked internal */\n WORKFLOW = 1 << 0, // 0001\n /** Agent spans are marked internal */\n AGENT = 1 << 1, // 0010\n /** Tool spans are marked internal */\n TOOL = 1 << 2, // 0100\n /** Model spans are marked internal */\n MODEL = 1 << 3, // 1000\n\n /** All spans are marked internal */\n ALL = (1 << 4) - 1, // 1111 (all bits set up to 3)\n}\n\n/**\n * Policy-level tracing configuration applied when creating\n * a workflow or agent. Unlike TracingOptions, which are\n * provided at execution time, policies define persistent rules\n * for how spans are treated across all executions of the\n * workflow/agent.\n */\nexport interface TracingPolicy {\n /**\n * Bitwise options to set different types of spans as Internal in\n * a workflow or agent execution. Internal spans are hidden by\n * default in exported traces.\n */\n internal?: InternalSpans;\n}\n\n/**\n * Trace-level state computed once at the start of a trace\n * and shared by all spans within that trace.\n */\nexport interface TraceState {\n /**\n * RequestContext keys to extract as metadata for all spans in this trace.\n * Computed by merging the tracing config's requestContextKeys\n * with the per-request requestContextKeys.\n */\n requestContextKeys: string[];\n}\n\n/**\n * Options passed when starting a new agent or workflow execution\n */\nexport interface TracingOptions {\n /** Metadata to add to the root trace span */\n metadata?: Record<string, any>;\n /**\n * Additional RequestContext keys to extract as metadata for this trace.\n * These keys are added to the requestContextKeys config.\n * Supports dot notation for nested values (e.g., 'user.id', 'session.data.experimentId').\n */\n requestContextKeys?: string[];\n /**\n * Trace ID to use for this execution (1-32 hexadecimal characters).\n * If provided, this trace will be part of the specified trace rather than starting a new one.\n */\n traceId?: string;\n /**\n * Parent span ID to use for this execution (1-16 hexadecimal characters).\n * If provided, the root span will be created as a child of this span.\n */\n parentSpanId?: string;\n /**\n * Tags to apply to this trace.\n * Tags are string labels that can be used to categorize and filter traces\n * Note: Tags are only applied to the root span of a trace.\n */\n tags?: string[];\n}\n\nexport interface SpanIds {\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n}\n\n/**\n * Context for tracing that flows through workflow and agent execution\n */\nexport interface TracingContext {\n /** Current Span for creating child spans and adding metadata */\n currentSpan?: AnySpan;\n}\n\n/**\n * Properties returned to the user for working with traces externally.\n */\nexport type TracingProperties = {\n /** Trace ID used on the execution (if the execution was traced). */\n traceId?: string;\n};\n\n// ============================================================================\n// Registry Config Interfaces\n// ============================================================================\n\n/**\n * Configuration for a single observability instance\n */\nexport interface ObservabilityInstanceConfig {\n /** Unique identifier for this config in the observability registry */\n name: string;\n /** Service name for observability */\n serviceName: string;\n /** Sampling strategy - controls whether tracing is collected (defaults to ALWAYS) */\n sampling?: SamplingStrategy;\n /** Custom exporters */\n exporters?: ObservabilityExporter[];\n /** Custom processors */\n spanOutputProcessors?: SpanOutputProcessor[];\n /** OpenTelemetry bridge for integration with existing OTEL infrastructure */\n bridge?: ObservabilityBridge;\n /** Set to `true` if you want to see spans internal to the operation of mastra */\n includeInternalSpans?: boolean;\n /**\n * RequestContext keys to automatically extract as metadata for all spans\n * created with this observablity configuration.\n * Supports dot notation for nested values.\n */\n requestContextKeys?: string[];\n}\n\n/**\n * Complete Observability registry configuration\n */\nexport interface ObservabilityRegistryConfig {\n /** Enables default exporters, with sampling: always, and sensitive data filtering */\n default?: {\n enabled?: boolean;\n };\n /** Map of tracing instance names to their configurations or pre-instantiated instances */\n configs?: Record<string, Omit<ObservabilityInstanceConfig, 'name'> | ObservabilityInstance>;\n /** Optional selector function to choose which tracing instance to use */\n configSelector?: ConfigSelector;\n}\n\n// ============================================================================\n// Sampling Strategy Interfaces\n// ============================================================================\n\n/**\n * Sampling strategy types\n */\nexport enum SamplingStrategyType {\n ALWAYS = 'always',\n NEVER = 'never',\n RATIO = 'ratio',\n CUSTOM = 'custom',\n}\n\n/**\n * Sampling strategy configuration\n */\nexport type SamplingStrategy =\n | { type: SamplingStrategyType.ALWAYS }\n | { type: SamplingStrategyType.NEVER }\n | { type: SamplingStrategyType.RATIO; probability: number }\n | { type: SamplingStrategyType.CUSTOM; sampler: (options?: CustomSamplerOptions) => boolean };\n\n/**\n * Options passed when using a custom sampler strategy\n */\nexport interface CustomSamplerOptions {\n requestContext?: RequestContext;\n metadata?: Record<string, any>;\n}\n\n// ============================================================================\n// Exporter and Processor Interfaces\n// ============================================================================\n\n/**\n * Tracing event types\n */\nexport enum TracingEventType {\n SPAN_STARTED = 'span_started',\n SPAN_UPDATED = 'span_updated',\n SPAN_ENDED = 'span_ended',\n}\n\n/**\n * Tracing events that can be exported\n */\nexport type TracingEvent =\n | { type: TracingEventType.SPAN_STARTED; exportedSpan: AnyExportedSpan }\n | { type: TracingEventType.SPAN_UPDATED; exportedSpan: AnyExportedSpan }\n | { type: TracingEventType.SPAN_ENDED; exportedSpan: AnyExportedSpan };\n\nexport interface InitExporterOptions {\n mastra?: Mastra;\n config?: ObservabilityInstanceConfig;\n}\n\nexport interface InitBridgeOptions {\n mastra?: Mastra;\n config?: ObservabilityInstanceConfig;\n}\n\n/**\n * Interface for tracing exporters\n */\nexport interface ObservabilityExporter {\n /** Exporter name */\n name: string;\n\n /** Initialize exporter with tracing configuration and/or access to Mastra */\n init?(options: InitExporterOptions): void;\n\n /** Sets logger instance on the exporter. */\n __setLogger?(logger: IMastraLogger): void;\n\n /** Export tracing events */\n exportTracingEvent(event: TracingEvent): Promise<void>;\n\n addScoreToTrace?({\n traceId,\n spanId,\n score,\n reason,\n scorerName,\n metadata,\n }: {\n traceId: string;\n spanId?: string;\n score: number;\n reason?: string;\n scorerName: string;\n metadata?: Record<string, any>;\n }): Promise<void>;\n\n /** Shutdown exporter */\n shutdown(): Promise<void>;\n}\n\n/**\n * Interface for observability bridges\n */\nexport interface ObservabilityBridge {\n /** Bridge name */\n name: string;\n\n /** Initialize bridge with observability configuration and/or access to Mastra */\n init?(options: InitBridgeOptions): void;\n\n /** Sets logger instance on the bridge */\n __setLogger?(logger: IMastraLogger): void;\n\n /**\n * Export Mastra tracing events to OTEL infrastructure\n * Called for SPAN_STARTED, SPAN_UPDATED, SPAN_ENDED events\n *\n * @param event - Tracing event with exported span\n */\n exportTracingEvent(event: TracingEvent): Promise<void>;\n\n /**\n * Execute an async function within the tracing context of a Mastra span.\n * This enables auto-instrumented operations (HTTP, DB) to have correct parent spans\n * in the external tracing system (e.g., OpenTelemetry, DataDog, etc.).\n *\n * @param spanId - The ID of the Mastra span to use as context\n * @param fn - The async function to execute within the span context\n * @returns The result of the function execution\n */\n executeInContext?<T>(spanId: string, fn: () => Promise<T>): Promise<T>;\n\n /**\n * Execute a synchronous function within the tracing context of a Mastra span.\n * This enables auto-instrumented operations (HTTP, DB) to have correct parent spans\n * in the external tracing system (e.g., OpenTelemetry, DataDog, etc.).\n *\n * @param spanId - The ID of the Mastra span to use as context\n * @param fn - The synchronous function to execute within the span context\n * @returns The result of the function execution\n */\n executeInContextSync?<T>(spanId: string, fn: () => T): T;\n\n /**\n * Create a span in the bridge's tracing system.\n * Called during Mastra span construction to get bridge-generated identifiers.\n *\n * @param options - Span creation options from Mastra\n * @returns Span identifiers (spanId, traceId, parentSpanId) from bridge, or undefined if creation fails\n */\n createSpan(options: CreateSpanOptions<SpanType>): SpanIds | undefined;\n\n /** Shutdown bridge and cleanup resources */\n shutdown(): Promise<void>;\n}\n\n/**\n * Interface for span processors\n */\nexport interface SpanOutputProcessor {\n /** Processor name */\n name: string;\n /** Process span before export */\n process(span?: AnySpan): AnySpan | undefined;\n /** Shutdown processor */\n shutdown(): Promise<void>;\n}\n\n// ============================================================================\n// Tracing Config Selector Interfaces\n// ============================================================================\n\n/**\n * Options passed when using a custom tracing config selector\n */\nexport interface ConfigSelectorOptions {\n /** Request Context */\n requestContext?: RequestContext;\n}\n\n/**\n * Function to select which tracing instance to use for a given span\n * Returns the name of the tracing instance, or undefined to use default\n */\nexport type ConfigSelector = (\n options: ConfigSelectorOptions,\n availableConfigs: ReadonlyMap<string, ObservabilityInstance>,\n) => string | undefined;\n\n// ============================================================================\n// Tracing Storage Interfaces\n// ============================================================================\n\nexport type TracingStorageStrategy = 'realtime' | 'batch-with-updates' | 'insert-only';\n","import type { Mastra } from '..';\nimport type { IMastraLogger } from '../logger';\nimport type { ObservabilityInstance, ConfigSelectorOptions, ObservabilityEntrypoint, ConfigSelector } from './types';\n\nexport class NoOpObservability implements ObservabilityEntrypoint {\n setMastraContext(_options: { mastra: Mastra }): void {\n return;\n }\n\n setLogger(_options: { logger: IMastraLogger }): void {\n return;\n }\n\n getSelectedInstance(_options: ConfigSelectorOptions): ObservabilityInstance | undefined {\n return;\n }\n\n registerInstance(_name: string, _instance: ObservabilityInstance, _isDefault = false): void {\n return;\n }\n\n getInstance(_name: string): ObservabilityInstance | undefined {\n return;\n }\n\n getDefaultInstance(): ObservabilityInstance | undefined {\n return;\n }\n\n listInstances(): ReadonlyMap<string, ObservabilityInstance> {\n return new Map();\n }\n\n unregisterInstance(_name: string): boolean {\n return false;\n }\n\n hasInstance(_name: string): boolean {\n return false;\n }\n\n setConfigSelector(_selector: ConfigSelector): void {\n return;\n }\n\n clear(): void {\n return;\n }\n\n async shutdown(): Promise<void> {\n return;\n }\n}\n","import type { Span, SpanType, GetOrCreateSpanOptions, AnySpan } from './types';\n\n/**\n * Creates or gets a child span from existing tracing context or starts a new trace.\n * This helper consolidates the common pattern of creating spans that can either be:\n * 1. Children of an existing span (when tracingContext.currentSpan exists)\n * 2. New root spans (when no current span exists)\n *\n * @param options - Configuration object for span creation\n * @returns The created Span or undefined if tracing is disabled\n */\nexport function getOrCreateSpan<T extends SpanType>(options: GetOrCreateSpanOptions<T>): Span<T> | undefined {\n const { type, attributes, tracingContext, requestContext, tracingOptions, ...rest } = options;\n\n const metadata = {\n ...(rest.metadata ?? {}),\n ...(tracingOptions?.metadata ?? {}),\n };\n\n // If we have a current span, create a child span\n if (tracingContext?.currentSpan) {\n return tracingContext.currentSpan.createChildSpan({\n type,\n attributes,\n ...rest,\n metadata,\n });\n }\n\n // Otherwise, try to create a new root span\n const instance = options.mastra?.observability?.getSelectedInstance({ requestContext });\n\n return instance?.startSpan<T>({\n type,\n attributes,\n ...rest,\n metadata,\n requestContext,\n tracingOptions,\n traceId: tracingOptions?.traceId,\n parentSpanId: tracingOptions?.parentSpanId,\n customSamplerOptions: {\n requestContext,\n metadata,\n },\n });\n}\n\n/**\n * Execute an async function within the span's tracing context if available.\n * Falls back to direct execution if no span exists.\n *\n * When a bridge is configured, this enables auto-instrumented operations\n * (HTTP requests, database queries, etc.) to be properly nested under the\n * current span in the external tracing system.\n *\n * @param span - The span to use as context (or undefined to execute without context)\n * @param fn - The async function to execute\n * @returns The result of the function execution\n *\n * @example\n * ```typescript\n * const result = await executeWithContext(llmSpan, async () =>\n * model.generateText(args)\n * );\n * ```\n */\nexport async function executeWithContext<T>(params: { span?: AnySpan; fn: () => Promise<T> }): Promise<T> {\n const { span, fn } = params;\n\n if (span?.executeInContext) {\n return span.executeInContext(fn);\n }\n\n return fn();\n}\n\n/**\n * Execute a synchronous function within the span's tracing context if available.\n * Falls back to direct execution if no span exists.\n *\n * When a bridge is configured, this enables auto-instrumented operations\n * (HTTP requests, database queries, etc.) to be properly nested under the\n * current span in the external tracing system.\n *\n * @param span - The span to use as context (or undefined to execute without context)\n * @param fn - The synchronous function to execute\n * @returns The result of the function execution\n *\n * @example\n * ```typescript\n * const result = executeWithContextSync(llmSpan, () =>\n * model.streamText(args)\n * );\n * ```\n */\nexport function executeWithContextSync<T>(params: { span?: AnySpan; fn: () => T }): T {\n const { span, fn } = params;\n\n if (span?.executeInContextSync) {\n return span.executeInContextSync(fn);\n }\n\n return fn();\n}\n","/**\n * Tracing Context Integration\n *\n * This module provides automatic tracing context propagation throughout Mastra's execution contexts.\n * It uses JavaScript Proxies to transparently wrap Mastra, Agent, and Workflow instances so that\n * tracing context is automatically injected without requiring manual passing by users.\n */\n\nimport type { MastraPrimitives } from '../action';\nimport type { Agent } from '../agent';\nimport type { Mastra } from '../mastra';\nimport type { Workflow } from '../workflows';\nimport type { TracingContext, AnySpan } from './types';\n\nconst AGENT_GETTERS = ['getAgent', 'getAgentById'];\nconst AGENT_METHODS_TO_WRAP = ['generate', 'stream', 'generateLegacy', 'streamLegacy'];\n\nconst WORKFLOW_GETTERS = ['getWorkflow', 'getWorkflowById'];\nconst WORKFLOW_METHODS_TO_WRAP = ['execute', 'createRun', 'createRun'];\n\n/**\n * Helper function to detect NoOp spans to avoid unnecessary wrapping\n */\nfunction isNoOpSpan(span: AnySpan): boolean {\n // Check if this is a NoOp span implementation\n return span.constructor.name === 'NoOpSpan' || (span as any).__isNoOp === true;\n}\n\n/**\n * Checks to see if a passed object is an actual instance of Mastra\n * (for the purposes of wrapping it for Tracing)\n */\nexport function isMastra<T extends Mastra | (Mastra & MastraPrimitives) | MastraPrimitives>(mastra: T): boolean {\n const hasAgentGetters = AGENT_GETTERS.every(method => typeof (mastra as any)?.[method] === 'function');\n const hasWorkflowGetters = WORKFLOW_GETTERS.every(method => typeof (mastra as any)?.[method] === 'function');\n\n return hasAgentGetters && hasWorkflowGetters;\n}\n\n/**\n * Creates a tracing-aware Mastra proxy that automatically injects\n * tracing context into agent and workflow method calls\n */\nexport function wrapMastra<T extends Mastra | (Mastra & MastraPrimitives) | MastraPrimitives>(\n mastra: T,\n tracingContext: TracingContext,\n): T {\n // Don't wrap if no current span or if using NoOp span\n if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) {\n return mastra;\n }\n\n // Check if this object has the methods we want to wrap - if not, return as is\n if (!isMastra(mastra)) {\n return mastra;\n }\n\n try {\n return new Proxy(mastra, {\n get(target, prop) {\n try {\n if (AGENT_GETTERS.includes(prop as string)) {\n return (...args: any[]) => {\n const agent = (target as any)[prop](...args);\n return wrapAgent(agent, tracingContext);\n };\n }\n\n // Wrap workflow getters\n if (WORKFLOW_GETTERS.includes(prop as string)) {\n return (...args: any[]) => {\n const workflow = (target as any)[prop](...args);\n return wrapWorkflow(workflow, tracingContext);\n };\n }\n\n // Pass through all other methods unchanged - bind functions to preserve 'this' context\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n } catch (error) {\n console.warn('Tracing: Failed to wrap method, falling back to original', error);\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n }\n },\n });\n } catch (error) {\n console.warn('Tracing: Failed to create proxy, using original Mastra instance', error);\n return mastra;\n }\n}\n\n/**\n * Creates a tracing-aware Agent proxy that automatically injects\n * tracing context into generation method calls\n */\nfunction wrapAgent<T extends Agent>(agent: T, tracingContext: TracingContext): T {\n // Don't wrap if no current span or if using NoOp span\n if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) {\n return agent;\n }\n\n try {\n return new Proxy(agent, {\n get(target, prop) {\n try {\n if (AGENT_METHODS_TO_WRAP.includes(prop as string)) {\n return (input: any, options: any = {}) => {\n return (target as any)[prop](input, {\n ...options,\n tracingContext,\n });\n };\n }\n\n // Bind functions to preserve 'this' context for private member access\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n } catch (error) {\n console.warn('Tracing: Failed to wrap agent method, falling back to original', error);\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n }\n },\n });\n } catch (error) {\n console.warn('Tracing: Failed to create agent proxy, using original instance', error);\n return agent;\n }\n}\n\n/**\n * Creates a tracing-aware Workflow proxy that automatically injects\n * tracing context into execution method calls\n */\nfunction wrapWorkflow<T extends Workflow>(workflow: T, tracingContext: TracingContext): T {\n // Don't wrap if no current span or if using NoOp span\n if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) {\n return workflow;\n }\n\n try {\n return new Proxy(workflow, {\n get(target, prop) {\n try {\n // Wrap workflow execution methods with tracing context\n if (WORKFLOW_METHODS_TO_WRAP.includes(prop as string)) {\n // Handle createRun and createRun methods differently\n if (prop === 'createRun' || prop === 'createRun') {\n return async (options: any = {}) => {\n const run = await (target as any)[prop](options);\n return run ? wrapRun(run, tracingContext) : run;\n };\n }\n\n // Handle other methods like execute\n return (input: any, options: any = {}) => {\n return (target as any)[prop](input, {\n ...options,\n tracingContext,\n });\n };\n }\n\n // Bind functions to preserve 'this' context for private member access\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n } catch (error) {\n console.warn('Tracing: Failed to wrap workflow method, falling back to original', error);\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n }\n },\n });\n } catch (error) {\n console.warn('Tracing: Failed to create workflow proxy, using original instance', error);\n return workflow;\n }\n}\n\n/**\n * Creates a tracing-aware Run proxy that automatically injects\n * tracing context into start method calls\n */\nfunction wrapRun<T extends object>(run: T, tracingContext: TracingContext): T {\n // Don't wrap if no current span or if using NoOp span\n if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) {\n return run;\n }\n\n try {\n return new Proxy(run, {\n get(target, prop) {\n try {\n if (prop === 'start') {\n return (startOptions: any = {}) => {\n return (target as any).start({\n ...startOptions,\n tracingContext: startOptions.tracingContext ?? tracingContext,\n });\n };\n }\n\n // Pass through all other properties and methods unchanged\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n } catch (error) {\n console.warn('Tracing: Failed to wrap run method, falling back to original', error);\n const value = (target as any)[prop];\n return typeof value === 'function' ? value.bind(target) : value;\n }\n },\n });\n } catch (error) {\n console.warn('Tracing: Failed to create run proxy, using original instance', error);\n return run;\n }\n}\n"]}
@@ -63,5 +63,5 @@ var ToolStream = class extends web.WritableStream {
63
63
  };
64
64
 
65
65
  exports.ToolStream = ToolStream;
66
- //# sourceMappingURL=chunk-X7F4CSGR.cjs.map
67
- //# sourceMappingURL=chunk-X7F4CSGR.cjs.map
66
+ //# sourceMappingURL=chunk-3JA6VPNM.cjs.map
67
+ //# sourceMappingURL=chunk-3JA6VPNM.c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AAA,IACrB;AAAA,EACF;AAAA,EAEA,MAAM,OAAmC,IAAA,EAAgE;AAEvG,IAAA,IAAA,CAAK,UAAA,GAAa,IAAA,CAAK,UAAA,CAAW,IAAA,CAAK,YAAY;AACjD,MAAA,IAAI,CAAC,KAAK,cAAA,EAAgB;AACxB,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,MAAA,GAAS,IAAA,CAAK,cAAA,CAAe,SAAA,EAAU;AAC7C,MAAA,IAAI;AACF,QAAA,MAAM,MAAA,CAAO,MAAM,IAAI,CAAA;AAAA,MACzB,CAAA,SAAE;AACA,QAAA,MAAA,CAAO,WAAA,EAAY;AAAA,MACrB;AAAA,IACF,CAAC,CAAA;AAED,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EACd;AACF","file":"chunk-3JA6VPNM.cjs","sourcesContent":["import { WritableStream } from 'node:stream/web';\nimport type { DataChunkType } from '../stream/types';\n\n/**\n * ToolStream is a WritableStream that wraps chunks with metadata before writing to an underlying stream.\n *\n * It extends `WritableStream<unknown>` to allow piping from any ReadableStream type.\n * This is necessary because WritableStream is contravariant in its type parameter -\n * a WritableStream<unknown> can accept writes of any type, making it compatible\n * with ReadableStream<T> for any T.\n *\n * @example\n * ```typescript\n * // In a tool's execute function:\n * const stream = await agent.stream(prompt);\n * await stream.fullStream.pipeTo(context.writer);\n * ```\n *\n */\nexport class ToolStream extends WritableStream<unknown> {\n originalStream?: WritableStream;\n private writeQueue: Promise<void> = Promise.resolve();\n\n constructor(\n {\n prefix,\n callId,\n name,\n runId,\n }: {\n prefix: string;\n callId: string;\n name: string;\n runId: string;\n },\n originalStream?: WritableStream,\n ) {\n super({\n async write(chunk: any) {\n const writer = originalStream?.getWriter();\n\n try {\n await writer?.write({\n type: `${prefix}-output`,\n runId,\n from: 'USER',\n payload: {\n output: chunk,\n ...(prefix === 'workflow-step'\n ? {\n runId,\n stepName: name,\n }\n : {\n [`${prefix}CallId`]: callId,\n [`${prefix}Name`]: name,\n }),\n },\n });\n } finally {\n writer?.releaseLock();\n }\n },\n });\n this.originalStream = originalStream;\n }\n\n async write(data: any) {\n const writer = this.getWriter();\n\n try {\n await writer.write(data);\n } finally {\n writer.releaseLock();\n }\n }\n\n async custom<T extends { type: string }>(data: T extends { type: `data-${string}` } ? DataChunkType : T) {\n // Queue the write operation to prevent concurrent access to the writer\n this.writeQueue = this.writeQueue.then(async () => {\n if (!this.originalStream) {\n return;\n }\n\n const writer = this.originalStream.getWriter();\n try {\n await writer.write(data);\n } finally {\n writer.releaseLock();\n }\n });\n\n return this.writeQueue;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { MastraBase } from './chunk-S6URFGCZ.js';
1
+ import { MastraBase } from './chunk-LSHPJWM5.js';
2
2
  import { readFile } from 'fs/promises';
3
3
  import { parse } from 'dotenv';
4
4
 
@@ -20,5 +20,5 @@ var MastraBundler = class extends MastraBase {
20
20
  };
21
21
 
22
22
  export { MastraBundler };
23
- //# sourceMappingURL=chunk-TQTAMPSC.js.map
24
- //# sourceMappingURL=chunk-TQTAMPSC.js.map
23
+ //# sourceMappingURL=chunk-3N3QE4ZK.js.map
24
+ //# sourceMappingURL=chunk-3N3QE4ZK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bundler/index.ts"],"names":[],"mappings":";;;;AAmBO,IAAe,aAAA,GAAf,cAAqC,UAAA,CAA+B;AAAA,EACzE,WAAA,CAAY,EAAE,IAAA,EAAM,SAAA,GAAY,WAAU,EAAyD;AACjG,IAAA,KAAA,CAAM,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAAA,EAC3B;AAAA,EAEA,MAAM,WAAA,GAA4C;AAChD,IAAA,MAAM,OAAA,uBAAc,GAAA,EAAI;AAExB,IAAA,KAAA,MAAW,IAAA,IAAQ,MAAM,IAAA,CAAK,WAAA,EAAY,EAAG;AAC3C,MAAA,MAAM,OAAA,GAAU,MAAM,QAAA,CAAS,IAAA,EAAM,OAAO,CAAA;AAC5C,MAAA,MAAM,MAAA,GAAS,MAAM,OAAO,CAAA;AAE5B,MAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AAC/C,QAAA,OAAA,CAAQ,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,MACxB,CAAC,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,OAAA;AAAA,EACT;AAYF","file":"chunk-3N3QE4ZK.js","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { parse } from 'dotenv';\n\nimport { MastraBase } from '../base';\n\nexport interface IBundler {\n loadEnvVars(): Promise<Map<string, string>>;\n getEnvFiles(): Promise<string[]>;\n getAllToolPaths(mastraDir: string, toolsPaths: (string | string[])[]): (string | string[])[];\n bundle(\n entryFile: string,\n outputDirectory: string,\n options: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void>;\n prepare(outputDirectory: string): Promise<void>;\n writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;\n lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;\n}\n\nexport abstract class MastraBundler extends MastraBase implements IBundler {\n constructor({ name, component = 'BUNDLER' }: { name: string; component?: 'BUNDLER' | 'DEPLOYER' }) {\n super({ component, name });\n }\n\n async loadEnvVars(): Promise<Map<string, string>> {\n const envVars = new Map();\n\n for (const file of await this.getEnvFiles()) {\n const content = await readFile(file, 'utf-8');\n const config = parse(content);\n\n Object.entries(config).forEach(([key, value]) => {\n envVars.set(key, value);\n });\n }\n\n return envVars;\n }\n\n abstract getAllToolPaths(mastraDir: string, toolsPaths: (string | string[])[]): (string | string[])[];\n abstract prepare(outputDirectory: string): Promise<void>;\n abstract writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;\n abstract getEnvFiles(): Promise<string[]>;\n abstract bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void>;\n abstract lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkE7K4FTLN_cjs = require('./chunk-E7K4FTLN.cjs');
3
+ var chunk3EYBRHB2_cjs = require('./chunk-3EYBRHB2.cjs');
4
4
  var zod = require('zod');
5
5
 
6
6
  var scoringExtractStepResultSchema = zod.z.record(zod.z.string(), zod.z.any()).optional();
@@ -18,7 +18,7 @@ var saveScorePayloadSchema = zod.z.object({
18
18
  input: zod.z.any().optional(),
19
19
  output: zod.z.any(),
20
20
  source: zod.z.enum(["LIVE", "TEST"]),
21
- entityType: zod.z.enum(["AGENT", "WORKFLOW", ...Object.values(chunkE7K4FTLN_cjs.SpanType)]).optional(),
21
+ entityType: zod.z.enum(["AGENT", "WORKFLOW", ...Object.values(chunk3EYBRHB2_cjs.SpanType)]).optional(),
22
22
  scorer: zod.z.record(zod.z.string(), zod.z.any()),
23
23
  traceId: zod.z.string().optional(),
24
24
  spanId: zod.z.string().optional(),
@@ -43,5 +43,5 @@ exports.saveScorePayloadSchema = saveScorePayloadSchema;
43
43
  exports.scoreResultSchema = scoreResultSchema;
44
44
  exports.scoringExtractStepResultSchema = scoringExtractStepResultSchema;
45
45
  exports.scoringValueSchema = scoringValueSchema;
46
- //# sourceMappingURL=chunk-BMAFVZ2D.cjs.map
47
- //# sourceMappingURL=chunk-BMAFVZ2D.cjs.map
46
+ //# sourceMappingURL=chunk-4AP234N6.cjs.map
47
+ //# sourceMappingURL=chunk-4AP234N6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/evals/types.ts"],"names":["z","SpanType"],"mappings":";;;;;AA6CO,IAAM,8BAAA,GAAiCA,KAAA,CAAE,MAAA,CAAOA,KAAA,CAAE,MAAA,IAAUA,KAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA;AAIrE,IAAM,kBAAA,GAAqBA,MAAE,MAAA;AAE7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AE,MAAA,EAAO,CAAE,QAAA;AACvB,CAAC","file":"chunk-BMAFVZ2D.cjs","sourcesContent":["import type { CoreMessage, CoreSystemMessage } from '@internal/ai-sdk-v4';\nimport { z } from 'zod';\nimport type { MastraDBMessage } from '../agent';\nimport { SpanType } from '../observability';\nimport type { TracingContext } from '../observability';\n\nexport type ScoringSamplingConfig = { type: 'none' } | { type: 'ratio'; rate: number };\n\nexport type ScoringSource = 'LIVE' | 'TEST';\n\nexport type ScoringEntityType = 'AGENT' | 'WORKFLOW' | SpanType;\n\nexport type ScoringPrompts = {\n description: string;\n prompt: string;\n};\n\nexport type ScoringInput = {\n runId?: string;\n input?: any;\n output: any;\n additionalContext?: Record<string, any>;\n requestContext?: Record<string, any>;\n tracingContext?: TracingContext;\n};\n\nexport type ScoringHookInput = {\n runId?: string;\n scorer: Record<string, any>;\n input: any;\n output: any;\n metadata?: Record<string, any>;\n additionalContext?: Record<string, any>;\n source: ScoringSource;\n entity: Record<string, any>;\n entityType: ScoringEntityType;\n requestContext?: Record<string, any>;\n tracingContext?: TracingContext;\n structuredOutput?: boolean;\n traceId?: string;\n spanId?: string;\n resourceId?: string;\n threadId?: string;\n};\n\nexport const scoringExtractStepResultSchema = z.record(z.string(), z.any()).optional();\n\nexport type ScoringExtractStepResult = z.infer<typeof scoringExtractStepResultSchema>;\n\nexport const scoringValueSchema = z.number();\n\nexport const scoreResultSchema = z.object({\n result: z.record(z.string(), z.any()).optional(),\n score: scoringValueSchema,\n prompt: z.string().optional(),\n});\n\nexport type ScoringAnalyzeStepResult = z.infer<typeof scoreResultSchema>;\n\nexport type ScoringInputWithExtractStepResult<TExtract = any> = ScoringInput & {\n runId: string;\n extractStepResult?: TExtract;\n extractPrompt?: string;\n};\n\nexport type ScoringInputWithExtractStepResultAndAnalyzeStepResult<\n TExtract = any,\n TScore = any,\n> = ScoringInputWithExtractStepResult<TExtract> & {\n score: number;\n analyzeStepResult?: TScore;\n analyzePrompt?: string;\n};\n\nexport type ScoringInputWithExtractStepResultAndScoreAndReason =\n ScoringInputWithExtractStepResultAndAnalyzeStepResult & {\n reason?: string;\n reasonPrompt?: string;\n };\n\nexport type ScoreRowData = ScoringInputWithExtractStepResultAndScoreAndReason &\n ScoringHookInput & {\n id: string;\n entityId: string;\n scorerId: string;\n createdAt: Date;\n updatedAt: Date;\n preprocessStepResult?: Record<string, any>;\n preprocessPrompt?: string;\n generateScorePrompt?: string;\n generateReasonPrompt?: string;\n };\n\nexport type ExtractionStepFn = (input: ScoringInput) => Promise<Record<string, any>>;\n\nexport type AnalyzeStepFn = (input: ScoringInputWithExtractStepResult) => Promise<ScoringAnalyzeStepResult>;\n\nexport type ReasonStepFn = (\n input: ScoringInputWithExtractStepResultAndAnalyzeStepResult,\n) => Promise<{ reason: string; reasonPrompt?: string } | null>;\n\nexport type ScorerOptions = {\n name: string;\n description: string;\n extract?: ExtractionStepFn;\n analyze: AnalyzeStepFn;\n reason?: ReasonStepFn;\n metadata?: Record<string, any>;\n isLLMScorer?: boolean;\n};\n\nexport type ScorerRunInputForAgent = {\n inputMessages: MastraDBMessage[];\n rememberedMessages: MastraDBMessage[];\n systemMessages: CoreMessage[];\n taggedSystemMessages: Record<string, CoreSystemMessage[]>;\n};\n\nexport type ScorerRunOutputForAgent = MastraDBMessage[];\n\nexport const saveScorePayloadSchema = z.object({\n runId: z.string(),\n scorerId: z.string(),\n entityId: z.string(),\n score: z.number(),\n input: z.any().optional(),\n output: z.any(),\n source: z.enum(['LIVE', 'TEST']),\n entityType: z.enum(['AGENT', 'WORKFLOW', ...Object.values(SpanType)]).optional(),\n scorer: z.record(z.string(), z.any()),\n\n traceId: z.string().optional(),\n spanId: z.string().optional(),\n preprocessStepResult: z.record(z.string(), z.any()).optional(),\n extractStepResult: z.record(z.string(), z.any()).optional(),\n analyzeStepResult: z.record(z.string(), z.any()).optional(),\n reason: z.string().optional(),\n metadata: z.record(z.string(), z.any()).optional(),\n preprocessPrompt: z.string().optional(),\n extractPrompt: z.string().optional(),\n generateScorePrompt: z.string().optional(),\n generateReasonPrompt: z.string().optional(),\n analyzePrompt: z.string().optional(),\n additionalContext: z.record(z.string(), z.any()).optional(),\n requestContext: z.record(z.string(), z.any()).optional(),\n entity: z.record(z.string(), z.any()).optional(),\n resourceId: z.string().optional(),\n threadId: z.string().optional(),\n});\n\nexport type ValidatedSaveScorePayload = z.infer<typeof saveScorePayloadSchema>;\n"]}
1
+ {"version":3,"sources":["../src/evals/types.ts"],"names":["z","SpanType"],"mappings":";;;;;AA6CO,IAAM,8BAAA,GAAiCA,KAAA,CAAE,MAAA,CAAOA,KAAA,CAAE,MAAA,IAAUA,KAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA;AAIrE,IAAM,kBAAA,GAAqBA,MAAE,MAAA;AAE7B,IAAM,iBAAA,GAAoBA,MAAE,MAAA,CAAO;AAAA,EACxC,MAAA,EAAQA,KAAA,CAAE,MAAA,CAAOA,KAAA,CAAE,MAAA,IAAUA,KAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA,EAAS;AAAA,EAC/C,KAAA,EAAO,kBAAA;AAAA,EACP,MAAA,EAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACrB,CAAC;AAiEM,IAAM,sBAAA,GAAyBA,MAAE,MAAA,CAAO;AAAA,EAC7C,KAAA,EAAOA,MAAE,MAAA,EAAO;AAAA,EAChB,QAAA,EAAUA,MAAE,MAAA,EAAO;AAAA,EACnB,QAAA,EAAUA,MAAE,MAAA,EAAO;AAAA,EACnB,KAAA,EAAOA,MAAE,MAAA,EAAO;AAAA,EAChB,KAAA,EAAOA,KAAA,CAAE,GAAA,EAAI,CAAE,QAAA,EAAS;AAAA,EACxB,MAAA,EAAQA,MAAE,GAAA,EAAI;AAAA,EACd,QAAQA,KAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,MAAM,CAAC,CAAA;AAAA,EAC/B,UAAA,EAAYA,KAAA,CAAE,IAAA,CAAK,CAAC,OAAA,EAAS,UAA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AAA,EACnC,iBAAA,EAAmBA,KAAA,CAAE,MAAA,CAAOA,KAAA,CAAE,MAAA,IAAUA,KAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,cAAA,EAAgBA,KAAA,CAAE,MAAA,CAAOA,KAAA,CAAE,MAAA,IAAUA,KAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA,EAAS;AAAA,EACvD,MAAA,EAAQA,KAAA,CAAE,MAAA,CAAOA,KAAA,CAAE,MAAA,IAAUA,KAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA,EAAS;AAAA,EAC/C,UAAA,EAAYA,KAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAChC,QAAA,EAAUA,KAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACvB,CAAC","file":"chunk-4AP234N6.cjs","sourcesContent":["import type { CoreMessage, CoreSystemMessage } from '@internal/ai-sdk-v4';\nimport { z } from 'zod';\nimport type { MastraDBMessage } from '../agent';\nimport { SpanType } from '../observability';\nimport type { TracingContext } from '../observability';\n\nexport type ScoringSamplingConfig = { type: 'none' } | { type: 'ratio'; rate: number };\n\nexport type ScoringSource = 'LIVE' | 'TEST';\n\nexport type ScoringEntityType = 'AGENT' | 'WORKFLOW' | SpanType;\n\nexport type ScoringPrompts = {\n description: string;\n prompt: string;\n};\n\nexport type ScoringInput = {\n runId?: string;\n input?: any;\n output: any;\n additionalContext?: Record<string, any>;\n requestContext?: Record<string, any>;\n tracingContext?: TracingContext;\n};\n\nexport type ScoringHookInput = {\n runId?: string;\n scorer: Record<string, any>;\n input: any;\n output: any;\n metadata?: Record<string, any>;\n additionalContext?: Record<string, any>;\n source: ScoringSource;\n entity: Record<string, any>;\n entityType: ScoringEntityType;\n requestContext?: Record<string, any>;\n tracingContext?: TracingContext;\n structuredOutput?: boolean;\n traceId?: string;\n spanId?: string;\n resourceId?: string;\n threadId?: string;\n};\n\nexport const scoringExtractStepResultSchema = z.record(z.string(), z.any()).optional();\n\nexport type ScoringExtractStepResult = z.infer<typeof scoringExtractStepResultSchema>;\n\nexport const scoringValueSchema = z.number();\n\nexport const scoreResultSchema = z.object({\n result: z.record(z.string(), z.any()).optional(),\n score: scoringValueSchema,\n prompt: z.string().optional(),\n});\n\nexport type ScoringAnalyzeStepResult = z.infer<typeof scoreResultSchema>;\n\nexport type ScoringInputWithExtractStepResult<TExtract = any> = ScoringInput & {\n runId: string;\n extractStepResult?: TExtract;\n extractPrompt?: string;\n};\n\nexport type ScoringInputWithExtractStepResultAndAnalyzeStepResult<\n TExtract = any,\n TScore = any,\n> = ScoringInputWithExtractStepResult<TExtract> & {\n score: number;\n analyzeStepResult?: TScore;\n analyzePrompt?: string;\n};\n\nexport type ScoringInputWithExtractStepResultAndScoreAndReason =\n ScoringInputWithExtractStepResultAndAnalyzeStepResult & {\n reason?: string;\n reasonPrompt?: string;\n };\n\nexport type ScoreRowData = ScoringInputWithExtractStepResultAndScoreAndReason &\n ScoringHookInput & {\n id: string;\n entityId: string;\n scorerId: string;\n createdAt: Date;\n updatedAt: Date;\n preprocessStepResult?: Record<string, any>;\n preprocessPrompt?: string;\n generateScorePrompt?: string;\n generateReasonPrompt?: string;\n };\n\nexport type ExtractionStepFn = (input: ScoringInput) => Promise<Record<string, any>>;\n\nexport type AnalyzeStepFn = (input: ScoringInputWithExtractStepResult) => Promise<ScoringAnalyzeStepResult>;\n\nexport type ReasonStepFn = (\n input: ScoringInputWithExtractStepResultAndAnalyzeStepResult,\n) => Promise<{ reason: string; reasonPrompt?: string } | null>;\n\nexport type ScorerOptions = {\n name: string;\n description: string;\n extract?: ExtractionStepFn;\n analyze: AnalyzeStepFn;\n reason?: ReasonStepFn;\n metadata?: Record<string, any>;\n isLLMScorer?: boolean;\n};\n\nexport type ScorerRunInputForAgent = {\n inputMessages: MastraDBMessage[];\n rememberedMessages: MastraDBMessage[];\n systemMessages: CoreMessage[];\n taggedSystemMessages: Record<string, CoreSystemMessage[]>;\n};\n\nexport type ScorerRunOutputForAgent = MastraDBMessage[];\n\nexport const saveScorePayloadSchema = z.object({\n runId: z.string(),\n scorerId: z.string(),\n entityId: z.string(),\n score: z.number(),\n input: z.any().optional(),\n output: z.any(),\n source: z.enum(['LIVE', 'TEST']),\n entityType: z.enum(['AGENT', 'WORKFLOW', ...Object.values(SpanType)]).optional(),\n scorer: z.record(z.string(), z.any()),\n\n traceId: z.string().optional(),\n spanId: z.string().optional(),\n preprocessStepResult: z.record(z.string(), z.any()).optional(),\n extractStepResult: z.record(z.string(), z.any()).optional(),\n analyzeStepResult: z.record(z.string(), z.any()).optional(),\n reason: z.string().optional(),\n metadata: z.record(z.string(), z.any()).optional(),\n preprocessPrompt: z.string().optional(),\n extractPrompt: z.string().optional(),\n generateScorePrompt: z.string().optional(),\n generateReasonPrompt: z.string().optional(),\n analyzePrompt: z.string().optional(),\n additionalContext: z.record(z.string(), z.any()).optional(),\n requestContext: z.record(z.string(), z.any()).optional(),\n entity: z.record(z.string(), z.any()).optional(),\n resourceId: z.string().optional(),\n threadId: z.string().optional(),\n});\n\nexport type ValidatedSaveScorePayload = z.infer<typeof saveScorePayloadSchema>;\n"]}
@@ -1,6 +1,6 @@
1
- import { RequestContext } from './chunk-GRBGQ2GE.js';
1
+ import { RequestContext } from './chunk-6TBWJV35.js';
2
+ import { z } from 'zod';
2
3
 
3
- // src/tools/validation.ts
4
4
  function truncateForLogging(data, maxLength = 200) {
5
5
  try {
6
6
  const stringified = JSON.stringify(data, null, 2);
@@ -31,18 +31,31 @@ Provided arguments: ${truncateForLogging(suspendData)}`,
31
31
  };
32
32
  return { data: suspendData, error };
33
33
  }
34
+ function normalizeNullishInput(schema, input) {
35
+ if (input !== void 0 && input !== null) {
36
+ return input;
37
+ }
38
+ if (schema instanceof z.ZodArray) {
39
+ return [];
40
+ }
41
+ if (schema instanceof z.ZodObject) {
42
+ return {};
43
+ }
44
+ return input;
45
+ }
34
46
  function validateToolInput(schema, input, toolId) {
35
47
  if (!schema || !("safeParse" in schema)) {
36
48
  return { data: input };
37
49
  }
38
- const validation = schema.safeParse(input);
50
+ const normalizedInput = normalizeNullishInput(schema, input);
51
+ const validation = schema.safeParse(normalizedInput);
39
52
  if (validation.success) {
40
53
  return { data: validation.data };
41
54
  }
42
55
  const errorMessages = validation.error.issues.map((e) => `- ${e.path?.join(".") || "root"}: ${e.message}`).join("\n");
43
56
  const error = {
44
57
  error: true,
45
- message: `Tool validation failed${toolId ? ` for ${toolId}` : ""}. Please fix the following errors and try again:
58
+ message: `Tool input validation failed${toolId ? ` for ${toolId}` : ""}. Please fix the following errors and try again:
46
59
  ${errorMessages}
47
60
 
48
61
  Provided arguments: ${truncateForLogging(input)}`,
@@ -102,6 +115,19 @@ var Tool = class {
102
115
  * ```
103
116
  */
104
117
  requireApproval;
118
+ /**
119
+ * Provider-specific options passed to the model when this tool is used.
120
+ * Keys are provider names (e.g., 'anthropic', 'openai'), values are provider-specific configs.
121
+ * @example
122
+ * ```typescript
123
+ * providerOptions: {
124
+ * anthropic: {
125
+ * cacheControl: { type: 'ephemeral' }
126
+ * }
127
+ * }
128
+ * ```
129
+ */
130
+ providerOptions;
105
131
  /**
106
132
  * Creates a new Tool instance with input validation wrapper.
107
133
  *
@@ -125,6 +151,7 @@ var Tool = class {
125
151
  this.resumeSchema = opts.resumeSchema;
126
152
  this.mastra = opts.mastra;
127
153
  this.requireApproval = opts.requireApproval || false;
154
+ this.providerOptions = opts.providerOptions;
128
155
  if (opts.execute) {
129
156
  const originalExecute = opts.execute;
130
157
  this.execute = async (inputData, context) => {
@@ -237,5 +264,5 @@ function isVercelTool(tool) {
237
264
  }
238
265
 
239
266
  export { Tool, createTool, isVercelTool, validateToolInput, validateToolOutput, validateToolSuspendData };
240
- //# sourceMappingURL=chunk-XIDKHXNR.js.map
241
- //# sourceMappingURL=chunk-XIDKHXNR.js.map
267
+ //# sourceMappingURL=chunk-4F6RAJFU.js.map
268
+ //# sourceMappingURL=chunk-4F6RAJFU.js.map
@@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,OAAO,CAAC,EAAE,IAAA,IAAQ,EAAE,IAAA,YAAgB,SAAS,YAAA,IAAgB,IAAA,CAAA;AAC/D","file":"chunk-4F6RAJFU.js","sourcesContent":["import { z } from 'zod';\nimport type { ZodLikeSchema } from '../types/zod-compat';\n\nexport interface ValidationError<T = any> {\n error: true;\n message: string;\n validationErrors: z.ZodFormattedError<T>;\n}\n\n/**\n * Safely truncates data for error messages to avoid exposing sensitive information.\n * @param data The data to truncate\n * @param maxLength Maximum length of the truncated string (default: 200)\n * @returns Truncated string representation\n */\nfunction truncateForLogging(data: unknown, maxLength: number = 200): string {\n try {\n const stringified = JSON.stringify(data, null, 2);\n if (stringified.length <= maxLength) {\n return stringified;\n }\n return stringified.slice(0, maxLength) + '... (truncated)';\n } catch {\n return '[Unable to serialize data]';\n }\n}\n\n/**\n * Validates raw suspend data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param suspendData The raw suspend data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolSuspendData<T = any>(\n schema: ZodLikeSchema | undefined,\n suspendData: unknown,\n toolId?: string,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return suspend data as-is\n if (!schema || !('safeParse' in schema)) {\n return { data: suspendData };\n }\n\n // Validate the input directly - no unwrapping needed in v1.0\n const validation = schema.safeParse(suspendData);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool suspension data validation failed${toolId ? ` for ${toolId}` : ''}. Please fix the following errors and try again:\\n${errorMessages}\\n\\nProvided arguments: ${truncateForLogging(suspendData)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: suspendData, error };\n}\n\n/**\n * Normalizes undefined/null input to an appropriate default value based on schema type.\n * This handles LLMs (Claude Sonnet 4.5, Gemini 2.4, etc.) that send undefined/null\n * instead of {} or [] when all parameters are optional.\n *\n * @param schema The Zod schema to check\n * @param input The input to normalize\n * @returns The normalized input (original value, {}, or [])\n */\nfunction normalizeNullishInput(schema: ZodLikeSchema, input: unknown): unknown {\n if (input !== undefined && input !== null) {\n return input;\n }\n\n // Check if schema is an array type\n if (schema instanceof z.ZodArray) {\n return [];\n }\n\n // Check if schema is an object type\n if (schema instanceof z.ZodObject) {\n return {};\n }\n\n // For other schema types, return the original input and let Zod validate\n return input;\n}\n\n/**\n * Validates raw input data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param input The raw input data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolInput<T = any>(\n schema: ZodLikeSchema | undefined,\n input: unknown,\n toolId?: string,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return input as-is\n if (!schema || !('safeParse' in schema)) {\n return { data: input };\n }\n\n // Normalize undefined/null input to appropriate default for the schema type\n // This handles LLMs that send undefined instead of {} or [] for optional parameters\n const normalizedInput = normalizeNullishInput(schema, input);\n\n // Validate the normalized input\n const validation = schema.safeParse(normalizedInput);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool input validation failed${toolId ? ` for ${toolId}` : ''}. Please fix the following errors and try again:\\n${errorMessages}\\n\\nProvided arguments: ${truncateForLogging(input)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: input, error };\n}\n\n/**\n * Validates tool output data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param output The output data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolOutput<T = any>(\n schema: ZodLikeSchema | undefined,\n output: unknown,\n toolId?: string,\n suspendCalled?: boolean,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return output as-is\n if (!schema || !('safeParse' in schema) || suspendCalled) {\n return { data: output };\n }\n\n // Validate the output\n const validation = schema.safeParse(output);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool output validation failed${toolId ? ` for ${toolId}` : ''}. The tool returned invalid output:\\n${errorMessages}\\n\\nReturned output: ${truncateForLogging(output)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: output, error };\n}\n","import type { Mastra } from '../mastra';\nimport { RequestContext } from '../request-context';\nimport type { ZodLikeSchema, InferZodLikeSchema } from '../types/zod-compat';\nimport type { ToolAction, ToolExecutionContext } from './types';\nimport { validateToolInput, validateToolOutput, validateToolSuspendData } from './validation';\n\n/**\n * A type-safe tool that agents and workflows can call to perform specific actions.\n *\n * @template TSchemaIn - Input schema type\n * @template TSchemaOut - Output schema type\n * @template TSuspendSchema - Suspend operation schema type\n * @template TResumeSchema - Resume operation schema type\n * @template TContext - Execution context type\n *\n * @example Basic tool with validation\n * ```typescript\n * const weatherTool = createTool({\n * id: 'get-weather',\n * description: 'Get weather for a location',\n * inputSchema: z.object({\n * location: z.string(),\n * units: z.enum(['celsius', 'fahrenheit']).optional()\n * }),\n * execute: async (inputData) => {\n * return await fetchWeather(inputData.location, inputData.units);\n * }\n * });\n * ```\n *\n * @example Tool requiring approval\n * ```typescript\n * const deleteFileTool = createTool({\n * id: 'delete-file',\n * description: 'Delete a file',\n * requireApproval: true,\n * inputSchema: z.object({ filepath: z.string() }),\n * execute: async (inputData) => {\n * await fs.unlink(inputData.filepath);\n * return { deleted: true };\n * }\n * });\n * ```\n *\n * @example Tool with Mastra integration\n * ```typescript\n * const saveTool = createTool({\n * id: 'save-data',\n * description: 'Save data to storage',\n * inputSchema: z.object({ key: z.string(), value: z.any() }),\n * execute: async (inputData, context) => {\n * const storage = context?.mastra?.getStorage();\n * await storage?.set(inputData.key, inputData.value);\n * return { saved: true };\n * }\n * });\n * ```\n */\nexport class Tool<\n TSchemaIn extends ZodLikeSchema | undefined = undefined,\n TSchemaOut extends ZodLikeSchema | undefined = undefined,\n TSuspendSchema extends ZodLikeSchema = any,\n TResumeSchema extends ZodLikeSchema = any,\n TContext extends ToolExecutionContext<TSuspendSchema, TResumeSchema> = ToolExecutionContext<\n TSuspendSchema,\n TResumeSchema\n >,\n TId extends string = string,\n> implements ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>\n{\n /** Unique identifier for the tool */\n id: TId;\n\n /** Description of what the tool does */\n description: string;\n\n /** Schema for validating input parameters */\n inputSchema?: TSchemaIn;\n\n /** Schema for validating output structure */\n outputSchema?: TSchemaOut;\n\n /** Schema for suspend operation data */\n suspendSchema?: TSuspendSchema;\n\n /** Schema for resume operation data */\n resumeSchema?: TResumeSchema;\n\n /**\n * Tool execution function\n * @param inputData - The raw, validated input data\n * @param context - Optional execution context with metadata\n * @returns Promise resolving to tool output or a ValidationError if input validation fails\n */\n execute?: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext>['execute'];\n\n /** Parent Mastra instance for accessing shared resources */\n mastra?: Mastra;\n\n /**\n * Whether the tool requires explicit user approval before execution\n * @example\n * ```typescript\n * // For destructive operations\n * requireApproval: true\n * ```\n */\n requireApproval?: boolean;\n\n /**\n * Provider-specific options passed to the model when this tool is used.\n * Keys are provider names (e.g., 'anthropic', 'openai'), values are provider-specific configs.\n * @example\n * ```typescript\n * providerOptions: {\n * anthropic: {\n * cacheControl: { type: 'ephemeral' }\n * }\n * }\n * ```\n */\n providerOptions?: Record<string, Record<string, unknown>>;\n\n /**\n * Creates a new Tool instance with input validation wrapper.\n *\n * @param opts - Tool configuration and execute function\n * @example\n * ```typescript\n * const tool = new Tool({\n * id: 'my-tool',\n * description: 'Does something useful',\n * inputSchema: z.object({ name: z.string() }),\n * execute: async (inputData) => ({ greeting: `Hello ${inputData.name}` })\n * });\n * ```\n */\n constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>) {\n this.id = opts.id;\n this.description = opts.description;\n this.inputSchema = opts.inputSchema;\n this.outputSchema = opts.outputSchema;\n this.suspendSchema = opts.suspendSchema;\n this.resumeSchema = opts.resumeSchema;\n this.mastra = opts.mastra;\n this.requireApproval = opts.requireApproval || false;\n this.providerOptions = opts.providerOptions;\n\n // Tools receive two parameters:\n // 1. input - The raw, validated input data\n // 2. context - Execution metadata (mastra, suspend, etc.)\n if (opts.execute) {\n const originalExecute = opts.execute;\n this.execute = async (inputData: unknown, context?: any) => {\n // Validate input if schema exists\n const { data, error } = validateToolInput(this.inputSchema, inputData, this.id);\n if (error) {\n return error as any;\n }\n\n let suspendData = null;\n\n const baseContext = context\n ? {\n ...context,\n ...(context.suspend\n ? {\n suspend: (args: any) => {\n suspendData = args;\n return context.suspend?.(args);\n },\n }\n : {}),\n }\n : {};\n\n // Organize context based on execution source\n let organizedContext = baseContext;\n if (!context) {\n // No context provided - create a minimal context with requestContext\n organizedContext = {\n requestContext: new RequestContext(),\n mastra: undefined,\n };\n } else {\n // Check if this is agent execution (has toolCallId and messages)\n const isAgentExecution = baseContext.toolCallId && baseContext.messages;\n\n // Check if this is workflow execution (has workflow properties)\n // Agent execution takes precedence - don't treat as workflow if it's an agent call\n const isWorkflowExecution = !isAgentExecution && (baseContext.workflow || baseContext.workflowId);\n\n if (isAgentExecution && !baseContext.agent) {\n // Reorganize agent context - nest agent-specific properties under 'agent' key\n const { toolCallId, messages, suspend, resumeData, threadId, resourceId, writableStream, ...rest } =\n baseContext;\n organizedContext = {\n ...rest,\n agent: {\n toolCallId,\n messages,\n suspend,\n resumeData,\n threadId,\n resourceId,\n writableStream,\n },\n // Ensure requestContext is always present\n requestContext: rest.requestContext || new RequestContext(),\n };\n } else if (isWorkflowExecution && !baseContext.workflow) {\n // Reorganize workflow context - nest workflow-specific properties under 'workflow' key\n const { workflowId, runId, state, setState, suspend, resumeData, ...rest } = baseContext;\n organizedContext = {\n ...rest,\n workflow: {\n workflowId,\n runId,\n state,\n setState,\n suspend,\n resumeData,\n },\n // Ensure requestContext is always present\n requestContext: rest.requestContext || new RequestContext(),\n };\n } else {\n // Ensure requestContext is always present even for direct execution\n organizedContext = {\n ...baseContext,\n agent: baseContext.agent\n ? {\n ...baseContext.agent,\n suspend: (args: any) => {\n suspendData = args;\n return baseContext.agent?.suspend?.(args);\n },\n }\n : baseContext.agent,\n workflow: baseContext.workflow\n ? {\n ...baseContext.workflow,\n suspend: (args: any) => {\n suspendData = args;\n return baseContext.workflow?.suspend?.(args);\n },\n }\n : baseContext.workflow,\n requestContext: baseContext.requestContext || new RequestContext(),\n };\n }\n }\n\n const resumeData =\n organizedContext.agent?.resumeData ?? organizedContext.workflow?.resumeData ?? organizedContext?.resumeData;\n\n if (resumeData) {\n const resumeValidation = validateToolInput(this.resumeSchema, resumeData, this.id);\n if (resumeValidation.error) {\n return resumeValidation.error as any;\n }\n }\n\n // Call the original execute with validated input and organized context\n const output = await originalExecute(data as any, organizedContext);\n\n if (suspendData) {\n const suspendValidation = validateToolSuspendData(this.suspendSchema, suspendData, this.id);\n if (suspendValidation.error) {\n return suspendValidation.error as any;\n }\n }\n\n const skiptOutputValidation = !!(typeof output === 'undefined' && suspendData);\n\n // Validate output if schema exists\n const outputValidation = validateToolOutput(this.outputSchema, output, this.id, skiptOutputValidation);\n if (outputValidation.error) {\n return outputValidation.error as any;\n }\n\n return outputValidation.data;\n };\n }\n }\n}\n\n/**\n * Creates a type-safe tool with automatic input validation.\n *\n * @template TSchemaIn - Input schema type\n * @template TSchemaOut - Output schema type\n * @template TSuspendSchema - Suspend operation schema type\n * @template TResumeSchema - Resume operation schema type\n * @template TContext - Execution context type\n * @template TExecute - Execute function type\n *\n * @param opts - Tool configuration including schemas and execute function\n * @returns Type-safe Tool instance with conditional typing based on schemas\n *\n * @example Simple tool\n * ```typescript\n * const greetTool = createTool({\n * id: 'greet',\n * description: 'Say hello',\n * execute: async () => ({ message: 'Hello!' })\n * });\n * ```\n *\n * @example Tool with input validation\n * ```typescript\n * const calculateTool = createTool({\n * id: 'calculate',\n * description: 'Perform calculations',\n * inputSchema: z.object({\n * operation: z.enum(['add', 'subtract']),\n * a: z.number(),\n * b: z.number()\n * }),\n * execute: async (inputData) => {\n * const result = inputData.operation === 'add'\n * ? inputData.a + inputData.b\n * : inputData.a - inputData.b;\n * return { result };\n * }\n * });\n * ```\n *\n * @example Tool with output schema\n * ```typescript\n * const userTool = createTool({\n * id: 'get-user',\n * description: 'Get user data',\n * inputSchema: z.object({ userId: z.string() }),\n * outputSchema: z.object({\n * id: z.string(),\n * name: z.string(),\n * email: z.string()\n * }),\n * execute: async (inputData) => {\n * return await fetchUser(inputData.userId);\n * }\n * });\n * ```\n *\n * @example Tool with external API\n * ```typescript\n * const weatherTool = createTool({\n * id: 'weather',\n * description: 'Get weather data',\n * inputSchema: z.object({\n * city: z.string(),\n * units: z.enum(['metric', 'imperial']).default('metric')\n * }),\n * execute: async (inputData) => {\n * const response = await fetch(\n * `https://api.weather.com/v1/weather?q=${inputData.city}&units=${inputData.units}`\n * );\n * return response.json();\n * }\n * });\n * ```\n */\nexport function createTool<\n TId extends string = string,\n TSchemaIn extends ZodLikeSchema | undefined = undefined,\n TSchemaOut extends ZodLikeSchema | undefined = undefined,\n TSuspendSchema extends ZodLikeSchema = any,\n TResumeSchema extends ZodLikeSchema = any,\n TContext extends ToolExecutionContext<TSuspendSchema, TResumeSchema> = ToolExecutionContext<\n TSuspendSchema,\n TResumeSchema\n >,\n TExecute extends ToolAction<\n TSchemaIn,\n TSchemaOut,\n TSuspendSchema,\n TResumeSchema,\n TContext,\n TId\n >['execute'] = ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>['execute'],\n>(\n opts: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId> & {\n execute?: TExecute;\n },\n): [TSchemaIn, TSchemaOut, TExecute] extends [ZodLikeSchema, ZodLikeSchema, Function]\n ? Tool<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId> & {\n inputSchema: TSchemaIn;\n outputSchema: TSchemaOut;\n execute: (\n inputData: TSchemaIn extends ZodLikeSchema ? InferZodLikeSchema<TSchemaIn> : unknown,\n context?: TContext,\n ) => Promise<TSchemaOut extends ZodLikeSchema ? InferZodLikeSchema<TSchemaOut> : unknown>;\n }\n : Tool<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId> {\n return new Tool(opts) as any;\n}\n","import { Tool } from './tool';\nimport type { ToolToConvert } from './tool-builder/builder';\nimport type { VercelTool } from './types';\n\n/**\n * Checks if a tool is a Vercel Tool\n * @param tool - The tool to check\n * @returns True if the tool is a Vercel Tool, false otherwise\n */\nexport function isVercelTool(tool?: ToolToConvert): tool is VercelTool {\n // Checks if this tool is not an instance of Tool\n return !!(tool && !(tool instanceof Tool) && 'parameters' in tool);\n}\n"]}
@@ -1,10 +1,12 @@
1
- import { output_exports, generateText, generateObject, streamText, streamObject } from './chunk-QM5SRDJX.js';
2
- import { isZodType, delay } from './chunk-PC6EKOWK.js';
1
+ import { output_exports, generateText, generateObject, streamText, streamObject } from './chunk-ZUWJCGLM.js';
2
+ import { isZodType, delay } from './chunk-URBPEE67.js';
3
+ import { executeWithContext, executeWithContextSync } from './chunk-FNSFXWDN.js';
3
4
  import { MastraError } from './chunk-JJ5O45LH.js';
4
- import { MastraBase } from './chunk-S6URFGCZ.js';
5
+ import { MastraBase } from './chunk-LSHPJWM5.js';
5
6
  import { OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, GoogleSchemaCompatLayer, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, MetaSchemaCompatLayer, applyCompatLayer, jsonSchema } from '@mastra/schema-compat';
6
7
  import { zodToJsonSchema } from '@mastra/schema-compat/zod-to-json';
7
8
  import { z } from 'zod';
9
+ import { randomUUID } from 'crypto';
8
10
 
9
11
  var MastraLLMV1 = class extends MastraBase {
10
12
  #model;
@@ -183,7 +185,10 @@ var MastraLLMV1 = class extends MastraBase {
183
185
  }) : void 0
184
186
  };
185
187
  try {
186
- const result = await generateText(argsForExecute);
188
+ const result = await executeWithContext({
189
+ span: llmSpan,
190
+ fn: () => generateText(argsForExecute)
191
+ });
187
192
  if (schema && result.finishReason === "stop") {
188
193
  result.object = result.experimental_output;
189
194
  }
@@ -508,7 +513,7 @@ var MastraLLMV1 = class extends MastraBase {
508
513
  }) : void 0
509
514
  };
510
515
  try {
511
- return streamText(argsForExecute);
516
+ return executeWithContextSync({ span: llmSpan, fn: () => streamText(argsForExecute) });
512
517
  } catch (e) {
513
518
  const mastraError = new MastraError(
514
519
  {
@@ -747,7 +752,154 @@ var MastraLLMV1 = class extends MastraBase {
747
752
  });
748
753
  }
749
754
  };
755
+ var AISDKV5LanguageModel = class {
756
+ /**
757
+ * The language model must specify which language model interface version it implements.
758
+ */
759
+ specificationVersion = "v2";
760
+ /**
761
+ * Name of the provider for logging purposes.
762
+ */
763
+ provider;
764
+ /**
765
+ * Provider-specific model ID for logging purposes.
766
+ */
767
+ modelId;
768
+ /**
769
+ * Supported URL patterns by media type for the provider.
770
+ *
771
+ * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
772
+ * and the values are arrays of regular expressions that match the URL paths.
773
+ * The matching should be against lower-case URLs.
774
+ * Matched URLs are supported natively by the model and are not downloaded.
775
+ * @returns A map of supported URL patterns by media type (as a promise or a plain object).
776
+ */
777
+ supportedUrls;
778
+ #model;
779
+ constructor(config) {
780
+ this.#model = config;
781
+ this.provider = this.#model.provider;
782
+ this.modelId = this.#model.modelId;
783
+ this.supportedUrls = this.#model.supportedUrls;
784
+ }
785
+ async doGenerate(options) {
786
+ const result = await this.#model.doGenerate(options);
787
+ return {
788
+ request: result.request,
789
+ response: result.response,
790
+ stream: new ReadableStream({
791
+ start(controller) {
792
+ controller.enqueue({ type: "stream-start", warnings: result.warnings });
793
+ controller.enqueue({
794
+ type: "response-metadata",
795
+ id: result.response?.id,
796
+ modelId: result.response?.modelId,
797
+ timestamp: result.response?.timestamp
798
+ });
799
+ for (const message of result.content) {
800
+ if (message.type === "tool-call") {
801
+ const toolCall = message;
802
+ controller.enqueue({
803
+ type: "tool-input-start",
804
+ id: toolCall.toolCallId,
805
+ toolName: toolCall.toolName
806
+ });
807
+ controller.enqueue({
808
+ type: "tool-input-delta",
809
+ id: toolCall.toolCallId,
810
+ delta: toolCall.input
811
+ });
812
+ controller.enqueue({
813
+ type: "tool-input-end",
814
+ id: toolCall.toolCallId
815
+ });
816
+ controller.enqueue(toolCall);
817
+ } else if (message.type === "tool-result") {
818
+ const toolResult = message;
819
+ controller.enqueue(toolResult);
820
+ } else if (message.type === "text") {
821
+ const text = message;
822
+ const id = `msg_${randomUUID()}`;
823
+ controller.enqueue({
824
+ type: "text-start",
825
+ id,
826
+ providerMetadata: text.providerMetadata
827
+ });
828
+ controller.enqueue({
829
+ type: "text-delta",
830
+ id,
831
+ delta: text.text
832
+ });
833
+ controller.enqueue({
834
+ type: "text-end",
835
+ id
836
+ });
837
+ } else if (message.type === "reasoning") {
838
+ const id = `reasoning_${randomUUID()}`;
839
+ const reasoning = message;
840
+ controller.enqueue({
841
+ type: "reasoning-start",
842
+ id,
843
+ providerMetadata: reasoning.providerMetadata
844
+ });
845
+ controller.enqueue({
846
+ type: "reasoning-delta",
847
+ id,
848
+ delta: reasoning.text,
849
+ providerMetadata: reasoning.providerMetadata
850
+ });
851
+ controller.enqueue({
852
+ type: "reasoning-end",
853
+ id,
854
+ providerMetadata: reasoning.providerMetadata
855
+ });
856
+ } else if (message.type === "file") {
857
+ const file = message;
858
+ controller.enqueue({
859
+ type: "file",
860
+ mediaType: file.mediaType,
861
+ data: file.data
862
+ });
863
+ } else if (message.type === "source") {
864
+ const source = message;
865
+ if (source.sourceType === "url") {
866
+ controller.enqueue({
867
+ type: "source",
868
+ id: source.id,
869
+ sourceType: "url",
870
+ url: source.url,
871
+ title: source.title,
872
+ providerMetadata: source.providerMetadata
873
+ });
874
+ } else {
875
+ controller.enqueue({
876
+ type: "source",
877
+ id: source.id,
878
+ sourceType: "document",
879
+ mediaType: source.mediaType,
880
+ filename: source.filename,
881
+ title: source.title,
882
+ providerMetadata: source.providerMetadata
883
+ });
884
+ }
885
+ }
886
+ }
887
+ controller.enqueue({
888
+ type: "finish",
889
+ finishReason: result.finishReason,
890
+ usage: result.usage,
891
+ providerMetadata: result.providerMetadata
892
+ });
893
+ controller.close();
894
+ }
895
+ })
896
+ };
897
+ }
898
+ async doStream(options) {
899
+ return await this.#model.doStream(options);
900
+ }
901
+ };
750
902
 
751
- export { MastraLLMV1 };
752
- //# sourceMappingURL=chunk-B5J5HYDN.js.map
753
- //# sourceMappingURL=chunk-B5J5HYDN.js.map
903
+ export { AISDKV5LanguageModel, MastraLLMV1 };
904
+ //# sourceMappingURL=chunk-4GTU7MB2.js.map
905
+ //# sourceMappingURL=chunk-4GTU7MB2.js.map