@mastra/core 0.24.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (812) hide show
  1. package/CHANGELOG.md +484 -139
  2. package/README.md +2 -3
  3. package/agent/message-list.d.ts +1 -0
  4. package/dist/action/index.d.ts +0 -2
  5. package/dist/action/index.d.ts.map +1 -1
  6. package/dist/agent/__tests__/mock-model.d.ts +3 -1
  7. package/dist/agent/__tests__/mock-model.d.ts.map +1 -1
  8. package/dist/agent/agent-legacy.d.ts +176 -0
  9. package/dist/agent/agent-legacy.d.ts.map +1 -0
  10. package/dist/agent/agent.d.ts +83 -229
  11. package/dist/agent/agent.d.ts.map +1 -1
  12. package/dist/agent/agent.types.d.ts +10 -25
  13. package/dist/agent/agent.types.d.ts.map +1 -1
  14. package/dist/agent/index.cjs +10 -26
  15. package/dist/agent/index.d.ts +1 -2
  16. package/dist/agent/index.d.ts.map +1 -1
  17. package/dist/agent/index.js +2 -2
  18. package/dist/agent/message-list/index.cjs +16 -0
  19. package/dist/agent/message-list/index.d.ts +77 -87
  20. package/dist/agent/message-list/index.d.ts.map +1 -1
  21. package/dist/agent/message-list/index.js +3 -0
  22. package/dist/agent/message-list/prompt/attachments-to-parts.d.ts +2 -2
  23. package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
  24. package/dist/agent/message-list/prompt/convert-to-mastra-v1.d.ts +2 -2
  25. package/dist/agent/message-list/prompt/download-assets.d.ts.map +1 -1
  26. package/dist/agent/message-list/prompt/invalid-content-error.d.ts +1 -1
  27. package/dist/agent/message-list/prompt/invalid-content-error.d.ts.map +1 -1
  28. package/dist/agent/message-list/types.d.ts +2 -1
  29. package/dist/agent/message-list/types.d.ts.map +1 -1
  30. package/dist/agent/message-list/utils/ai-v4-v5/core-model-message.d.ts +3 -2
  31. package/dist/agent/message-list/utils/ai-v4-v5/core-model-message.d.ts.map +1 -1
  32. package/dist/agent/message-list/utils/ai-v4-v5/ui-message.d.ts +3 -2
  33. package/dist/agent/message-list/utils/ai-v4-v5/ui-message.d.ts.map +1 -1
  34. package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts +1 -1
  35. package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts.map +1 -1
  36. package/dist/agent/message-list/utils/convert-messages.d.ts +4 -4
  37. package/dist/agent/message-list/utils/convert-messages.d.ts.map +1 -1
  38. package/dist/agent/test-utils.d.ts +2 -79
  39. package/dist/agent/test-utils.d.ts.map +1 -1
  40. package/dist/agent/trip-wire.d.ts +1 -1
  41. package/dist/agent/trip-wire.d.ts.map +1 -1
  42. package/dist/agent/types.d.ts +23 -37
  43. package/dist/agent/types.d.ts.map +1 -1
  44. package/dist/agent/utils.d.ts +15 -64
  45. package/dist/agent/utils.d.ts.map +1 -1
  46. package/dist/agent/workflows/prepare-stream/index.d.ts +16 -20
  47. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  48. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +5 -7
  49. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  50. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +14 -18
  51. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
  52. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +6 -6
  53. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
  54. package/dist/agent/workflows/prepare-stream/schema.d.ts +10 -12
  55. package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
  56. package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -7
  57. package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
  58. package/dist/ai-sdk.types.d.ts +4705 -0
  59. package/dist/base.cjs +2 -2
  60. package/dist/base.d.ts +0 -16
  61. package/dist/base.d.ts.map +1 -1
  62. package/dist/base.js +1 -1
  63. package/dist/bundler/index.cjs +2 -2
  64. package/dist/bundler/index.d.ts +2 -1
  65. package/dist/bundler/index.d.ts.map +1 -1
  66. package/dist/bundler/index.js +1 -1
  67. package/dist/cache/index.cjs +3 -3
  68. package/dist/cache/index.js +1 -1
  69. package/dist/{chunk-7J3XX4AO.cjs → chunk-2ZVKF4HP.cjs} +199 -66
  70. package/dist/chunk-2ZVKF4HP.cjs.map +1 -0
  71. package/dist/chunk-4CDL2QJT.js +649 -0
  72. package/dist/chunk-4CDL2QJT.js.map +1 -0
  73. package/dist/chunk-5WRI5ZAA.js +29 -0
  74. package/dist/{chunk-3HXBPDKN.js.map → chunk-5WRI5ZAA.js.map} +1 -1
  75. package/dist/{chunk-KAEQISOW.js → chunk-76K3IYWM.js} +5 -5
  76. package/dist/chunk-76K3IYWM.js.map +1 -0
  77. package/dist/chunk-7AHYOMHJ.js +149 -0
  78. package/dist/chunk-7AHYOMHJ.js.map +1 -0
  79. package/dist/{chunk-UZKIGB7M.cjs → chunk-BMAFVZ2D.cjs} +5 -5
  80. package/dist/chunk-BMAFVZ2D.cjs.map +1 -0
  81. package/dist/chunk-CB575O6L.cjs +12432 -0
  82. package/dist/chunk-CB575O6L.cjs.map +1 -0
  83. package/dist/{chunk-6TEQIYXV.cjs → chunk-CBAB7GOD.cjs} +15 -15
  84. package/dist/chunk-CBAB7GOD.cjs.map +1 -0
  85. package/dist/{chunk-ROS5CMJS.cjs → chunk-CD56CXVE.cjs} +63 -50
  86. package/dist/chunk-CD56CXVE.cjs.map +1 -0
  87. package/dist/{chunk-Z4RIRDU3.js → chunk-CINNK34N.js} +45 -32
  88. package/dist/chunk-CINNK34N.js.map +1 -0
  89. package/dist/{chunk-77JHIM4E.cjs → chunk-DNEURYF3.cjs} +348 -424
  90. package/dist/chunk-DNEURYF3.cjs.map +1 -0
  91. package/dist/{chunk-A5KDVZDL.cjs → chunk-DSNPWVIG.cjs} +9 -9
  92. package/dist/chunk-DSNPWVIG.cjs.map +1 -0
  93. package/dist/chunk-DZUJEN5N.cjs +32 -0
  94. package/dist/{chunk-EBVYYC2Q.cjs.map → chunk-DZUJEN5N.cjs.map} +1 -1
  95. package/dist/chunk-E7K4FTLN.cjs +273 -0
  96. package/dist/chunk-E7K4FTLN.cjs.map +1 -0
  97. package/dist/{chunk-MJMID7LX.cjs → chunk-ECFXGXWO.cjs} +609 -644
  98. package/dist/chunk-ECFXGXWO.cjs.map +1 -0
  99. package/dist/chunk-ET6UOTTU.cjs +154 -0
  100. package/dist/chunk-ET6UOTTU.cjs.map +1 -0
  101. package/dist/chunk-GGYKYORQ.cjs +2060 -0
  102. package/dist/chunk-GGYKYORQ.cjs.map +1 -0
  103. package/dist/{chunk-HLRWYUFN.js → chunk-GRBGQ2GE.js} +5 -5
  104. package/dist/{chunk-HLRWYUFN.js.map → chunk-GRBGQ2GE.js.map} +1 -1
  105. package/dist/{chunk-3VXXCPKX.js → chunk-H6CZGPZD.js} +334 -410
  106. package/dist/chunk-H6CZGPZD.js.map +1 -0
  107. package/dist/chunk-HDJFSJCK.js +2237 -0
  108. package/dist/chunk-HDJFSJCK.js.map +1 -0
  109. package/dist/{chunk-34ZCWSUA.js → chunk-I4CXL4SR.js} +6 -9
  110. package/dist/chunk-I4CXL4SR.js.map +1 -0
  111. package/dist/{chunk-3JX2Y3WH.cjs → chunk-IQO7ANVS.cjs} +18 -21
  112. package/dist/chunk-IQO7ANVS.cjs.map +1 -0
  113. package/dist/{chunk-GPWMM745.cjs → chunk-J7O6WENZ.cjs} +5 -5
  114. package/dist/{chunk-GPWMM745.cjs.map → chunk-J7O6WENZ.cjs.map} +1 -1
  115. package/dist/{chunk-PZUZNPFM.js → chunk-JJ5O45LH.js} +3 -4
  116. package/dist/chunk-JJ5O45LH.js.map +1 -0
  117. package/dist/chunk-JPGVRWWL.js +12385 -0
  118. package/dist/chunk-JPGVRWWL.js.map +1 -0
  119. package/dist/chunk-JUBFO5J3.js +15761 -0
  120. package/dist/chunk-JUBFO5J3.js.map +1 -0
  121. package/dist/{chunk-E3PG7G6E.js → chunk-JV2KH24V.js} +599 -633
  122. package/dist/chunk-JV2KH24V.js.map +1 -0
  123. package/dist/chunk-KEXGB7FK.cjs +29 -0
  124. package/dist/chunk-KEXGB7FK.cjs.map +1 -0
  125. package/dist/chunk-KIZIOFZC.js +265 -0
  126. package/dist/chunk-KIZIOFZC.js.map +1 -0
  127. package/dist/{chunk-UXG7PYML.js → chunk-KJ2SW6VA.js} +9 -9
  128. package/dist/chunk-KJ2SW6VA.js.map +1 -0
  129. package/dist/{chunk-TTELJD4F.js → chunk-L54GIUCB.js} +2 -2
  130. package/dist/chunk-L54GIUCB.js.map +1 -0
  131. package/dist/chunk-LWBQ4P4N.cjs +2240 -0
  132. package/dist/chunk-LWBQ4P4N.cjs.map +1 -0
  133. package/dist/{chunk-ABZOBBLL.cjs → chunk-MA7TEM62.cjs} +735 -562
  134. package/dist/chunk-MA7TEM62.cjs.map +1 -0
  135. package/dist/{chunk-TSNDVBUU.cjs → chunk-MR7ZWBL6.cjs} +2 -2
  136. package/dist/chunk-MR7ZWBL6.cjs.map +1 -0
  137. package/dist/chunk-MSWTA73A.cjs +15825 -0
  138. package/dist/chunk-MSWTA73A.cjs.map +1 -0
  139. package/dist/chunk-MV7KHWUT.js +2031 -0
  140. package/dist/chunk-MV7KHWUT.js.map +1 -0
  141. package/dist/{chunk-3NTOFNIU.js → chunk-OJNJA5ZI.js} +3 -3
  142. package/dist/{chunk-3NTOFNIU.js.map → chunk-OJNJA5ZI.js.map} +1 -1
  143. package/dist/chunk-QM5SRDJX.js +9022 -0
  144. package/dist/chunk-QM5SRDJX.js.map +1 -0
  145. package/dist/{chunk-WBAXXG34.cjs → chunk-QUKUN6NR.cjs} +32 -66
  146. package/dist/chunk-QUKUN6NR.cjs.map +1 -0
  147. package/dist/chunk-S6URFGCZ.js +27 -0
  148. package/dist/chunk-S6URFGCZ.js.map +1 -0
  149. package/dist/chunk-SVLMF4UZ.cjs +9033 -0
  150. package/dist/chunk-SVLMF4UZ.cjs.map +1 -0
  151. package/dist/{chunk-ZMELUU72.js → chunk-TQTAMPSC.js} +3 -3
  152. package/dist/chunk-TQTAMPSC.js.map +1 -0
  153. package/dist/{chunk-5NTO7S5I.cjs → chunk-TWH4PTDG.cjs} +2 -4
  154. package/dist/chunk-TWH4PTDG.cjs.map +1 -0
  155. package/dist/{chunk-WCHE6FJ7.js → chunk-UIZSWUKP.js} +15 -50
  156. package/dist/chunk-UIZSWUKP.js.map +1 -0
  157. package/dist/{chunk-BWGXM3D4.js → chunk-VOQ3ULMT.js} +712 -541
  158. package/dist/chunk-VOQ3ULMT.js.map +1 -0
  159. package/dist/{chunk-MCASUJWY.cjs → chunk-VOY2RXOC.cjs} +36 -59
  160. package/dist/chunk-VOY2RXOC.cjs.map +1 -0
  161. package/dist/{chunk-FHVFGVIO.js → chunk-W7UH2PWL.js} +189 -56
  162. package/dist/chunk-W7UH2PWL.js.map +1 -0
  163. package/dist/chunk-WM6CK2F3.cjs +674 -0
  164. package/dist/chunk-WM6CK2F3.cjs.map +1 -0
  165. package/dist/{chunk-PFXXH2RP.js → chunk-X7JMA3IY.js} +15 -15
  166. package/dist/chunk-X7JMA3IY.js.map +1 -0
  167. package/dist/{chunk-NR77P3TK.js → chunk-XEVG546F.js} +14 -37
  168. package/dist/chunk-XEVG546F.js.map +1 -0
  169. package/dist/{chunk-QFF5JUKT.cjs → chunk-Y63IFHEZ.cjs} +4 -4
  170. package/dist/chunk-Y63IFHEZ.cjs.map +1 -0
  171. package/dist/{chunk-B7V6NYWH.cjs → chunk-Y6ROD72V.cjs} +4 -4
  172. package/dist/{chunk-B7V6NYWH.cjs.map → chunk-Y6ROD72V.cjs.map} +1 -1
  173. package/dist/deployer/index.cjs +8 -6
  174. package/dist/deployer/index.cjs.map +1 -1
  175. package/dist/deployer/index.js +10 -1
  176. package/dist/deployer/index.js.map +1 -1
  177. package/dist/di/index.cjs +3 -3
  178. package/dist/di/index.d.ts +1 -1
  179. package/dist/di/index.js +1 -1
  180. package/dist/error/index.cjs +6 -6
  181. package/dist/error/index.d.ts +0 -1
  182. package/dist/error/index.d.ts.map +1 -1
  183. package/dist/error/index.js +1 -1
  184. package/dist/{scores → evals}/base.d.ts +20 -18
  185. package/dist/evals/base.d.ts.map +1 -0
  186. package/dist/{scores → evals}/base.test-utils.d.ts +25 -25
  187. package/dist/evals/base.test-utils.d.ts.map +1 -0
  188. package/dist/{scores → evals}/hooks.d.ts +3 -3
  189. package/dist/evals/hooks.d.ts.map +1 -0
  190. package/dist/evals/index.cjs +37 -0
  191. package/dist/evals/index.d.ts +4 -0
  192. package/dist/evals/index.d.ts.map +1 -0
  193. package/dist/evals/index.js +4 -0
  194. package/dist/{scores/run-experiment → evals/run}/index.d.ts +18 -18
  195. package/dist/evals/run/index.d.ts.map +1 -0
  196. package/dist/evals/run/scorerAccumulator.d.ts.map +1 -0
  197. package/dist/{scores → evals}/scoreTraces/index.cjs +79 -99
  198. package/dist/evals/scoreTraces/index.cjs.map +1 -0
  199. package/dist/evals/scoreTraces/index.d.ts.map +1 -0
  200. package/dist/{scores → evals}/scoreTraces/index.js +72 -92
  201. package/dist/evals/scoreTraces/index.js.map +1 -0
  202. package/dist/{scores → evals}/scoreTraces/scoreTraces.d.ts +2 -2
  203. package/dist/evals/scoreTraces/scoreTraces.d.ts.map +1 -0
  204. package/dist/{scores → evals}/scoreTraces/scoreTracesWorkflow.d.ts +11 -11
  205. package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -0
  206. package/dist/{scores → evals}/scoreTraces/utils.d.ts +7 -7
  207. package/dist/evals/scoreTraces/utils.d.ts.map +1 -0
  208. package/dist/{scores → evals}/types.d.ts +22 -22
  209. package/dist/evals/types.d.ts.map +1 -0
  210. package/dist/features/index.cjs +8 -0
  211. package/dist/features/index.cjs.map +1 -0
  212. package/dist/features/index.d.ts +17 -0
  213. package/dist/features/index.d.ts.map +1 -0
  214. package/dist/features/index.js +6 -0
  215. package/dist/features/index.js.map +1 -0
  216. package/dist/hooks/index.cjs +4 -4
  217. package/dist/hooks/index.d.ts +1 -27
  218. package/dist/hooks/index.d.ts.map +1 -1
  219. package/dist/hooks/index.js +1 -1
  220. package/dist/index.cjs +2 -340
  221. package/dist/index.cjs.map +1 -1
  222. package/dist/index.d.ts +1 -18
  223. package/dist/index.d.ts.map +1 -1
  224. package/dist/index.js +1 -113
  225. package/dist/index.js.map +1 -1
  226. package/dist/integration/index.cjs +87 -10
  227. package/dist/integration/index.cjs.map +1 -1
  228. package/dist/integration/index.js +88 -1
  229. package/dist/integration/index.js.map +1 -1
  230. package/dist/integration/integration.d.ts +3 -3
  231. package/dist/integration/integration.d.ts.map +1 -1
  232. package/dist/llm/index.cjs +7 -7
  233. package/dist/llm/index.d.ts +5 -6
  234. package/dist/llm/index.d.ts.map +1 -1
  235. package/dist/llm/index.js +1 -1
  236. package/dist/llm/model/base.types.d.ts +6 -7
  237. package/dist/llm/model/base.types.d.ts.map +1 -1
  238. package/dist/llm/model/gateways/constants.d.ts.map +1 -1
  239. package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
  240. package/dist/llm/model/model.d.ts +7 -7
  241. package/dist/llm/model/model.d.ts.map +1 -1
  242. package/dist/llm/model/model.loop.d.ts +1 -1
  243. package/dist/llm/model/model.loop.d.ts.map +1 -1
  244. package/dist/llm/model/model.loop.types.d.ts +3 -3
  245. package/dist/llm/model/model.loop.types.d.ts.map +1 -1
  246. package/dist/llm/model/provider-types.generated.d.ts +80 -17
  247. package/dist/llm/model/resolve-model.d.ts +8 -8
  248. package/dist/llm/model/shared.types.d.ts +2 -2
  249. package/dist/llm/model/shared.types.d.ts.map +1 -1
  250. package/dist/logger/constants.d.ts +1 -1
  251. package/dist/logger/default-logger.d.ts +2 -2
  252. package/dist/logger/default-logger.d.ts.map +1 -1
  253. package/dist/logger/index.cjs +11 -11
  254. package/dist/logger/index.js +2 -2
  255. package/dist/logger/logger.d.ts +4 -4
  256. package/dist/logger/logger.d.ts.map +1 -1
  257. package/dist/logger/multi-logger.d.ts +2 -2
  258. package/dist/logger/multi-logger.d.ts.map +1 -1
  259. package/dist/logger/transport.d.ts +3 -3
  260. package/dist/logger/transport.d.ts.map +1 -1
  261. package/dist/loop/index.cjs +2 -2
  262. package/dist/loop/index.js +1 -1
  263. package/dist/loop/loop.d.ts +1 -1
  264. package/dist/loop/loop.d.ts.map +1 -1
  265. package/dist/loop/network/index.d.ts +15 -15
  266. package/dist/loop/network/index.d.ts.map +1 -1
  267. package/dist/loop/test-utils/generateText.d.ts.map +1 -1
  268. package/dist/loop/test-utils/options.d.ts.map +1 -1
  269. package/dist/loop/test-utils/resultObject.d.ts.map +1 -1
  270. package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
  271. package/dist/loop/types.d.ts +4 -7
  272. package/dist/loop/types.d.ts.map +1 -1
  273. package/dist/loop/workflows/agentic-execution/index.d.ts +55 -55
  274. package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
  275. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +38 -38
  276. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  277. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +20 -20
  278. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  279. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +2 -2
  280. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  281. package/dist/loop/workflows/agentic-loop/index.d.ts +55 -55
  282. package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
  283. package/dist/loop/workflows/schema.d.ts +19 -20
  284. package/dist/loop/workflows/schema.d.ts.map +1 -1
  285. package/dist/loop/workflows/stream.d.ts +1 -1
  286. package/dist/loop/workflows/stream.d.ts.map +1 -1
  287. package/dist/mastra/hooks.d.ts +2 -2
  288. package/dist/mastra/hooks.d.ts.map +1 -1
  289. package/dist/mastra/index.cjs +2 -2
  290. package/dist/mastra/index.d.ts +389 -180
  291. package/dist/mastra/index.d.ts.map +1 -1
  292. package/dist/mastra/index.js +1 -1
  293. package/dist/mcp/index.cjs +41 -4
  294. package/dist/mcp/index.cjs.map +1 -1
  295. package/dist/mcp/index.d.ts +6 -4
  296. package/dist/mcp/index.d.ts.map +1 -1
  297. package/dist/mcp/index.js +39 -2
  298. package/dist/mcp/index.js.map +1 -1
  299. package/dist/mcp/types.d.ts +0 -15
  300. package/dist/mcp/types.d.ts.map +1 -1
  301. package/dist/memory/index.cjs +327 -13
  302. package/dist/memory/index.cjs.map +1 -1
  303. package/dist/memory/index.d.ts +1 -0
  304. package/dist/memory/index.d.ts.map +1 -1
  305. package/dist/memory/index.js +327 -1
  306. package/dist/memory/index.js.map +1 -1
  307. package/dist/memory/memory.d.ts +33 -57
  308. package/dist/memory/memory.d.ts.map +1 -1
  309. package/dist/memory/mock.d.ts +61 -0
  310. package/dist/memory/mock.d.ts.map +1 -0
  311. package/dist/memory/types.d.ts +48 -45
  312. package/dist/memory/types.d.ts.map +1 -1
  313. package/dist/models-dev-DNBKXHT4.js +3 -0
  314. package/dist/{models-dev-4VGIWYS3.js.map → models-dev-DNBKXHT4.js.map} +1 -1
  315. package/dist/models-dev-YBEEQIX6.cjs +12 -0
  316. package/dist/{models-dev-AXZASLL2.cjs.map → models-dev-YBEEQIX6.cjs.map} +1 -1
  317. package/dist/netlify-7G2L5VSH.js +3 -0
  318. package/dist/{netlify-VJXBII33.js.map → netlify-7G2L5VSH.js.map} +1 -1
  319. package/dist/netlify-GWNGSIRZ.cjs +12 -0
  320. package/dist/{netlify-TX6V7SJJ.cjs.map → netlify-GWNGSIRZ.cjs.map} +1 -1
  321. package/dist/{ai-tracing → observability}/context.d.ts +5 -5
  322. package/dist/observability/context.d.ts.map +1 -0
  323. package/dist/observability/index.cjs +36 -0
  324. package/dist/observability/index.d.ts +11 -0
  325. package/dist/observability/index.d.ts.map +1 -0
  326. package/dist/observability/index.js +3 -0
  327. package/dist/observability/no-op.d.ts +22 -0
  328. package/dist/observability/no-op.d.ts.map +1 -0
  329. package/dist/observability/types/index.d.ts +2 -0
  330. package/dist/observability/types/index.d.ts.map +1 -0
  331. package/dist/{ai-tracing/types.d.ts → observability/types/tracing.d.ts} +161 -107
  332. package/dist/observability/types/tracing.d.ts.map +1 -0
  333. package/dist/observability/utils.d.ts +12 -0
  334. package/dist/observability/utils.d.ts.map +1 -0
  335. package/dist/processors/index.cjs +11 -11
  336. package/dist/processors/index.d.ts +10 -9
  337. package/dist/processors/index.d.ts.map +1 -1
  338. package/dist/processors/index.js +1 -1
  339. package/dist/processors/processors/batch-parts.d.ts +2 -1
  340. package/dist/processors/processors/batch-parts.d.ts.map +1 -1
  341. package/dist/processors/processors/language-detector.d.ts +6 -5
  342. package/dist/processors/processors/language-detector.d.ts.map +1 -1
  343. package/dist/processors/processors/moderation.d.ts +8 -7
  344. package/dist/processors/processors/moderation.d.ts.map +1 -1
  345. package/dist/processors/processors/pii-detector.d.ts +8 -7
  346. package/dist/processors/processors/pii-detector.d.ts.map +1 -1
  347. package/dist/processors/processors/prompt-injection-detector.d.ts +6 -5
  348. package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
  349. package/dist/processors/processors/structured-output.d.ts +3 -2
  350. package/dist/processors/processors/structured-output.d.ts.map +1 -1
  351. package/dist/processors/processors/system-prompt-scrubber.d.ts +6 -5
  352. package/dist/processors/processors/system-prompt-scrubber.d.ts.map +1 -1
  353. package/dist/processors/processors/token-limiter.d.ts +5 -4
  354. package/dist/processors/processors/token-limiter.d.ts.map +1 -1
  355. package/dist/processors/processors/unicode-normalizer.d.ts +5 -4
  356. package/dist/processors/processors/unicode-normalizer.d.ts.map +1 -1
  357. package/dist/processors/runner.d.ts +5 -5
  358. package/dist/processors/runner.d.ts.map +1 -1
  359. package/dist/provider-registry.json +175 -42
  360. package/dist/{registry-generator-DXRSYYYT.js → registry-generator-H4YNODDH.js} +2 -2
  361. package/dist/{registry-generator-DXRSYYYT.js.map → registry-generator-H4YNODDH.js.map} +1 -1
  362. package/dist/{registry-generator-6WVOHM2L.cjs → registry-generator-MK63POJO.cjs} +2 -2
  363. package/dist/{registry-generator-6WVOHM2L.cjs.map → registry-generator-MK63POJO.cjs.map} +1 -1
  364. package/dist/relevance/index.cjs +47 -13
  365. package/dist/relevance/index.cjs.map +1 -1
  366. package/dist/relevance/index.d.ts +0 -1
  367. package/dist/relevance/index.d.ts.map +1 -1
  368. package/dist/relevance/index.js +49 -1
  369. package/dist/relevance/index.js.map +1 -1
  370. package/dist/relevance/mastra-agent/index.d.ts.map +1 -1
  371. package/dist/request-context/index.cjs +12 -0
  372. package/dist/{runtime-context → request-context}/index.d.ts +1 -1
  373. package/dist/{runtime-context → request-context}/index.d.ts.map +1 -1
  374. package/dist/request-context/index.js +3 -0
  375. package/dist/server/auth.d.ts.map +1 -1
  376. package/dist/server/index.cjs +9 -25
  377. package/dist/server/index.cjs.map +1 -1
  378. package/dist/server/index.js +4 -21
  379. package/dist/server/index.js.map +1 -1
  380. package/dist/server/types.d.ts +3 -3
  381. package/dist/server/types.d.ts.map +1 -1
  382. package/dist/storage/base.d.ts +75 -143
  383. package/dist/storage/base.d.ts.map +1 -1
  384. package/dist/storage/constants.d.ts +3 -4
  385. package/dist/storage/constants.d.ts.map +1 -1
  386. package/dist/storage/domains/index.d.ts +0 -2
  387. package/dist/storage/domains/index.d.ts.map +1 -1
  388. package/dist/storage/domains/memory/base.d.ts +19 -56
  389. package/dist/storage/domains/memory/base.d.ts.map +1 -1
  390. package/dist/storage/domains/memory/inmemory.d.ts +15 -35
  391. package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
  392. package/dist/storage/domains/observability/base.d.ts +24 -24
  393. package/dist/storage/domains/observability/base.d.ts.map +1 -1
  394. package/dist/storage/domains/observability/inmemory.d.ts +18 -18
  395. package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
  396. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  397. package/dist/storage/domains/scores/base.d.ts +5 -5
  398. package/dist/storage/domains/scores/base.d.ts.map +1 -1
  399. package/dist/storage/domains/scores/inmemory.d.ts +5 -5
  400. package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
  401. package/dist/storage/domains/workflows/base.d.ts +4 -11
  402. package/dist/storage/domains/workflows/base.d.ts.map +1 -1
  403. package/dist/storage/domains/workflows/inmemory.d.ts +4 -11
  404. package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
  405. package/dist/storage/index.cjs +74 -1775
  406. package/dist/storage/index.cjs.map +1 -1
  407. package/dist/storage/index.js +1 -1744
  408. package/dist/storage/index.js.map +1 -1
  409. package/dist/storage/mock.d.ts +35 -92
  410. package/dist/storage/mock.d.ts.map +1 -1
  411. package/dist/storage/types.d.ts +77 -75
  412. package/dist/storage/types.d.ts.map +1 -1
  413. package/dist/stream/MastraAgentNetworkStream.d.ts +4 -2
  414. package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
  415. package/dist/stream/MastraWorkflowStream.d.ts +1 -1
  416. package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
  417. package/dist/stream/RunOutput.d.ts +1 -0
  418. package/dist/stream/RunOutput.d.ts.map +1 -1
  419. package/dist/stream/aisdk/v4/input.d.ts +1 -1
  420. package/dist/stream/aisdk/v4/input.d.ts.map +1 -1
  421. package/dist/stream/aisdk/v5/execute.d.ts +4 -11
  422. package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
  423. package/dist/stream/aisdk/v5/output.d.ts +1 -1
  424. package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
  425. package/dist/stream/base/output.d.ts +1 -1
  426. package/dist/stream/base/output.d.ts.map +1 -1
  427. package/dist/stream/index.cjs +11 -11
  428. package/dist/stream/index.d.ts +1 -1
  429. package/dist/stream/index.d.ts.map +1 -1
  430. package/dist/stream/index.js +2 -2
  431. package/dist/stream/types.d.ts +2 -6
  432. package/dist/stream/types.d.ts.map +1 -1
  433. package/dist/test-utils/llm-mock.cjs +8 -8
  434. package/dist/test-utils/llm-mock.cjs.map +1 -1
  435. package/dist/test-utils/llm-mock.d.ts +1 -1
  436. package/dist/test-utils/llm-mock.d.ts.map +1 -1
  437. package/dist/test-utils/llm-mock.js +3 -3
  438. package/dist/test-utils/llm-mock.js.map +1 -1
  439. package/dist/tools/index.cjs +4 -4
  440. package/dist/tools/index.js +1 -1
  441. package/dist/tools/is-vercel-tool.cjs +2 -2
  442. package/dist/tools/is-vercel-tool.js +1 -1
  443. package/dist/tools/tool-builder/builder.d.ts +3 -71
  444. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  445. package/dist/tools/tool.d.ts +25 -25
  446. package/dist/tools/tool.d.ts.map +1 -1
  447. package/dist/tools/types.d.ts +102 -11
  448. package/dist/tools/types.d.ts.map +1 -1
  449. package/dist/tools/validation.d.ts +4 -3
  450. package/dist/tools/validation.d.ts.map +1 -1
  451. package/dist/tts/index.cjs +12 -6
  452. package/dist/tts/index.cjs.map +1 -1
  453. package/dist/tts/index.d.ts +0 -1
  454. package/dist/tts/index.d.ts.map +1 -1
  455. package/dist/tts/index.js +14 -1
  456. package/dist/tts/index.js.map +1 -1
  457. package/dist/types/dynamic-argument.d.ts +3 -3
  458. package/dist/utils/fetchWithRetry.d.ts +9 -0
  459. package/dist/utils/fetchWithRetry.d.ts.map +1 -0
  460. package/dist/utils.cjs +33 -17
  461. package/dist/utils.d.ts +39 -6
  462. package/dist/utils.d.ts.map +1 -1
  463. package/dist/utils.js +1 -1
  464. package/dist/vector/embed.d.ts +1 -1
  465. package/dist/vector/embed.d.ts.map +1 -1
  466. package/dist/vector/index.cjs +80 -8
  467. package/dist/vector/index.cjs.map +1 -1
  468. package/dist/vector/index.js +80 -1
  469. package/dist/vector/index.js.map +1 -1
  470. package/dist/vector/vector.d.ts +5 -2
  471. package/dist/vector/vector.d.ts.map +1 -1
  472. package/dist/voice/composite-voice.d.ts +1 -7
  473. package/dist/voice/composite-voice.d.ts.map +1 -1
  474. package/dist/voice/index.cjs +4 -4
  475. package/dist/voice/index.js +1 -1
  476. package/dist/voice/voice.d.ts +0 -1
  477. package/dist/voice/voice.d.ts.map +1 -1
  478. package/dist/workflows/default.d.ts +35 -43
  479. package/dist/workflows/default.d.ts.map +1 -1
  480. package/dist/workflows/evented/execution-engine.d.ts +5 -3
  481. package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
  482. package/dist/workflows/evented/index.cjs +10 -10
  483. package/dist/workflows/evented/index.js +1 -1
  484. package/dist/workflows/evented/step-executor.d.ts +15 -13
  485. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  486. package/dist/workflows/evented/workflow-event-processor/index.d.ts +5 -5
  487. package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
  488. package/dist/workflows/evented/workflow-event-processor/loop.d.ts +3 -3
  489. package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
  490. package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
  491. package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
  492. package/dist/workflows/evented/workflow-event-processor/utils.d.ts +2 -7
  493. package/dist/workflows/evented/workflow-event-processor/utils.d.ts.map +1 -1
  494. package/dist/workflows/evented/workflow.d.ts +11 -14
  495. package/dist/workflows/evented/workflow.d.ts.map +1 -1
  496. package/dist/workflows/execution-engine.d.ts +6 -6
  497. package/dist/workflows/execution-engine.d.ts.map +1 -1
  498. package/dist/workflows/index.cjs +22 -14
  499. package/dist/workflows/index.js +1 -1
  500. package/dist/workflows/step.d.ts +5 -5
  501. package/dist/workflows/step.d.ts.map +1 -1
  502. package/dist/workflows/types.d.ts +21 -44
  503. package/dist/workflows/types.d.ts.map +1 -1
  504. package/dist/workflows/utils.d.ts +14 -0
  505. package/dist/workflows/utils.d.ts.map +1 -1
  506. package/dist/workflows/workflow.d.ts +74 -64
  507. package/dist/workflows/workflow.d.ts.map +1 -1
  508. package/evals/scoreTraces.d.ts +1 -0
  509. package/evals.d.ts +1 -0
  510. package/features.d.ts +1 -0
  511. package/observability.d.ts +1 -0
  512. package/package.json +49 -64
  513. package/request-context.d.ts +1 -0
  514. package/src/_types/ai-sdk.types.d.ts +4705 -0
  515. package/src/llm/model/provider-types.generated.d.ts +80 -17
  516. package/agent/input-processor/processors.d.ts +0 -1
  517. package/ai-tracing.d.ts +0 -1
  518. package/dist/agent/index.warning.d.ts +0 -13
  519. package/dist/agent/index.warning.d.ts.map +0 -1
  520. package/dist/agent/input-processor/index.cjs +0 -28
  521. package/dist/agent/input-processor/index.d.ts +0 -10
  522. package/dist/agent/input-processor/index.d.ts.map +0 -1
  523. package/dist/agent/input-processor/index.js +0 -3
  524. package/dist/agent/input-processor/processors/index.d.ts +0 -6
  525. package/dist/agent/input-processor/processors/index.d.ts.map +0 -1
  526. package/dist/agent/input-processor/processors/language-detector.d.ts +0 -18
  527. package/dist/agent/input-processor/processors/language-detector.d.ts.map +0 -1
  528. package/dist/agent/input-processor/processors/moderation.d.ts +0 -18
  529. package/dist/agent/input-processor/processors/moderation.d.ts.map +0 -1
  530. package/dist/agent/input-processor/processors/pii-detector.d.ts +0 -18
  531. package/dist/agent/input-processor/processors/pii-detector.d.ts.map +0 -1
  532. package/dist/agent/input-processor/processors/prompt-injection-detector.d.ts +0 -18
  533. package/dist/agent/input-processor/processors/prompt-injection-detector.d.ts.map +0 -1
  534. package/dist/agent/input-processor/processors/unicode-normalizer.d.ts +0 -18
  535. package/dist/agent/input-processor/processors/unicode-normalizer.d.ts.map +0 -1
  536. package/dist/ai-tracing/context.d.ts.map +0 -1
  537. package/dist/ai-tracing/exporters/base.d.ts +0 -111
  538. package/dist/ai-tracing/exporters/base.d.ts.map +0 -1
  539. package/dist/ai-tracing/exporters/cloud.d.ts +0 -30
  540. package/dist/ai-tracing/exporters/cloud.d.ts.map +0 -1
  541. package/dist/ai-tracing/exporters/console.d.ts +0 -10
  542. package/dist/ai-tracing/exporters/console.d.ts.map +0 -1
  543. package/dist/ai-tracing/exporters/default.d.ts +0 -98
  544. package/dist/ai-tracing/exporters/default.d.ts.map +0 -1
  545. package/dist/ai-tracing/exporters/index.d.ts +0 -9
  546. package/dist/ai-tracing/exporters/index.d.ts.map +0 -1
  547. package/dist/ai-tracing/index.cjs +0 -148
  548. package/dist/ai-tracing/index.d.ts +0 -13
  549. package/dist/ai-tracing/index.d.ts.map +0 -1
  550. package/dist/ai-tracing/index.js +0 -3
  551. package/dist/ai-tracing/model-tracing.d.ts +0 -63
  552. package/dist/ai-tracing/model-tracing.d.ts.map +0 -1
  553. package/dist/ai-tracing/registry.d.ts +0 -51
  554. package/dist/ai-tracing/registry.d.ts.map +0 -1
  555. package/dist/ai-tracing/span_processors/index.d.ts +0 -5
  556. package/dist/ai-tracing/span_processors/index.d.ts.map +0 -1
  557. package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts +0 -85
  558. package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts.map +0 -1
  559. package/dist/ai-tracing/spans/base.d.ts +0 -65
  560. package/dist/ai-tracing/spans/base.d.ts.map +0 -1
  561. package/dist/ai-tracing/spans/default.d.ts +0 -13
  562. package/dist/ai-tracing/spans/default.d.ts.map +0 -1
  563. package/dist/ai-tracing/spans/index.d.ts +0 -7
  564. package/dist/ai-tracing/spans/index.d.ts.map +0 -1
  565. package/dist/ai-tracing/spans/no-op.d.ts +0 -15
  566. package/dist/ai-tracing/spans/no-op.d.ts.map +0 -1
  567. package/dist/ai-tracing/tracers/base.d.ts +0 -105
  568. package/dist/ai-tracing/tracers/base.d.ts.map +0 -1
  569. package/dist/ai-tracing/tracers/default.d.ts +0 -7
  570. package/dist/ai-tracing/tracers/default.d.ts.map +0 -1
  571. package/dist/ai-tracing/tracers/index.d.ts +0 -6
  572. package/dist/ai-tracing/tracers/index.d.ts.map +0 -1
  573. package/dist/ai-tracing/types.d.ts.map +0 -1
  574. package/dist/ai-tracing/utils.d.ts +0 -68
  575. package/dist/ai-tracing/utils.d.ts.map +0 -1
  576. package/dist/base.warning.d.ts +0 -9
  577. package/dist/base.warning.d.ts.map +0 -1
  578. package/dist/bundler/index.warning.d.ts +0 -9
  579. package/dist/bundler/index.warning.d.ts.map +0 -1
  580. package/dist/chunk-253FBVD4.cjs +0 -1303
  581. package/dist/chunk-253FBVD4.cjs.map +0 -1
  582. package/dist/chunk-2B3VLGTH.js +0 -87
  583. package/dist/chunk-2B3VLGTH.js.map +0 -1
  584. package/dist/chunk-34ZCWSUA.js.map +0 -1
  585. package/dist/chunk-3HXBPDKN.js +0 -105
  586. package/dist/chunk-3JX2Y3WH.cjs.map +0 -1
  587. package/dist/chunk-3VXXCPKX.js.map +0 -1
  588. package/dist/chunk-4R2TBRS7.cjs +0 -191
  589. package/dist/chunk-4R2TBRS7.cjs.map +0 -1
  590. package/dist/chunk-5NTO7S5I.cjs.map +0 -1
  591. package/dist/chunk-6C7VGVK4.js +0 -267
  592. package/dist/chunk-6C7VGVK4.js.map +0 -1
  593. package/dist/chunk-6KOL2B3A.cjs +0 -75
  594. package/dist/chunk-6KOL2B3A.cjs.map +0 -1
  595. package/dist/chunk-6TEQIYXV.cjs.map +0 -1
  596. package/dist/chunk-6VOPKVYH.cjs +0 -57
  597. package/dist/chunk-6VOPKVYH.cjs.map +0 -1
  598. package/dist/chunk-77JHIM4E.cjs.map +0 -1
  599. package/dist/chunk-7J3XX4AO.cjs.map +0 -1
  600. package/dist/chunk-A5KDVZDL.cjs.map +0 -1
  601. package/dist/chunk-ABZOBBLL.cjs.map +0 -1
  602. package/dist/chunk-AQGLVU53.cjs +0 -603
  603. package/dist/chunk-AQGLVU53.cjs.map +0 -1
  604. package/dist/chunk-BLUDYAPI.js +0 -596
  605. package/dist/chunk-BLUDYAPI.js.map +0 -1
  606. package/dist/chunk-BWGXM3D4.js.map +0 -1
  607. package/dist/chunk-C7OVZMPW.cjs +0 -91
  608. package/dist/chunk-C7OVZMPW.cjs.map +0 -1
  609. package/dist/chunk-DMBN72QF.cjs +0 -39
  610. package/dist/chunk-DMBN72QF.cjs.map +0 -1
  611. package/dist/chunk-DTTOVV72.js +0 -2880
  612. package/dist/chunk-DTTOVV72.js.map +0 -1
  613. package/dist/chunk-E3PG7G6E.js.map +0 -1
  614. package/dist/chunk-EBVYYC2Q.cjs +0 -111
  615. package/dist/chunk-FHVFGVIO.js.map +0 -1
  616. package/dist/chunk-GB5BIA4V.js +0 -167
  617. package/dist/chunk-GB5BIA4V.js.map +0 -1
  618. package/dist/chunk-HEQTUMUA.cjs +0 -271
  619. package/dist/chunk-HEQTUMUA.cjs.map +0 -1
  620. package/dist/chunk-HF3GZRFP.cjs +0 -9
  621. package/dist/chunk-HF3GZRFP.cjs.map +0 -1
  622. package/dist/chunk-JVV5LREI.js +0 -431
  623. package/dist/chunk-JVV5LREI.js.map +0 -1
  624. package/dist/chunk-KAEQISOW.js.map +0 -1
  625. package/dist/chunk-KDX3ZMQ2.js +0 -12
  626. package/dist/chunk-KDX3ZMQ2.js.map +0 -1
  627. package/dist/chunk-LG5B3KIW.js +0 -1215
  628. package/dist/chunk-LG5B3KIW.js.map +0 -1
  629. package/dist/chunk-LZUSZT7R.cjs +0 -170
  630. package/dist/chunk-LZUSZT7R.cjs.map +0 -1
  631. package/dist/chunk-MCASUJWY.cjs.map +0 -1
  632. package/dist/chunk-MJMID7LX.cjs.map +0 -1
  633. package/dist/chunk-MKCC5K77.js +0 -90
  634. package/dist/chunk-MKCC5K77.js.map +0 -1
  635. package/dist/chunk-NPNGPMT2.js +0 -39
  636. package/dist/chunk-NPNGPMT2.js.map +0 -1
  637. package/dist/chunk-NR77P3TK.js.map +0 -1
  638. package/dist/chunk-NUAURT4I.cjs +0 -82
  639. package/dist/chunk-NUAURT4I.cjs.map +0 -1
  640. package/dist/chunk-OIT3PCWA.js +0 -72
  641. package/dist/chunk-OIT3PCWA.js.map +0 -1
  642. package/dist/chunk-P35FNLTQ.cjs +0 -2936
  643. package/dist/chunk-P35FNLTQ.cjs.map +0 -1
  644. package/dist/chunk-PFXXH2RP.js.map +0 -1
  645. package/dist/chunk-PZUZNPFM.js.map +0 -1
  646. package/dist/chunk-QFF5JUKT.cjs.map +0 -1
  647. package/dist/chunk-RKXWLG33.js +0 -7
  648. package/dist/chunk-RKXWLG33.js.map +0 -1
  649. package/dist/chunk-ROS5CMJS.cjs.map +0 -1
  650. package/dist/chunk-SJMKDSRF.js +0 -179
  651. package/dist/chunk-SJMKDSRF.js.map +0 -1
  652. package/dist/chunk-SSULK22X.cjs +0 -14
  653. package/dist/chunk-SSULK22X.cjs.map +0 -1
  654. package/dist/chunk-TSNDVBUU.cjs.map +0 -1
  655. package/dist/chunk-TTELJD4F.js.map +0 -1
  656. package/dist/chunk-TX4TTPYJ.cjs +0 -436
  657. package/dist/chunk-TX4TTPYJ.cjs.map +0 -1
  658. package/dist/chunk-UXG7PYML.js.map +0 -1
  659. package/dist/chunk-UZKIGB7M.cjs.map +0 -1
  660. package/dist/chunk-VF676YCO.cjs +0 -150
  661. package/dist/chunk-VF676YCO.cjs.map +0 -1
  662. package/dist/chunk-VQASQG5D.js +0 -55
  663. package/dist/chunk-VQASQG5D.js.map +0 -1
  664. package/dist/chunk-WBAXXG34.cjs.map +0 -1
  665. package/dist/chunk-WCHE6FJ7.js.map +0 -1
  666. package/dist/chunk-WM4RO23J.js +0 -145
  667. package/dist/chunk-WM4RO23J.js.map +0 -1
  668. package/dist/chunk-Z4RIRDU3.js.map +0 -1
  669. package/dist/chunk-ZABG3SZ2.cjs +0 -93
  670. package/dist/chunk-ZABG3SZ2.cjs.map +0 -1
  671. package/dist/chunk-ZISECZZO.js +0 -72
  672. package/dist/chunk-ZISECZZO.js.map +0 -1
  673. package/dist/chunk-ZMELUU72.js.map +0 -1
  674. package/dist/deployer/index.warning.d.ts +0 -9
  675. package/dist/deployer/index.warning.d.ts.map +0 -1
  676. package/dist/eval/evaluation.d.ts +0 -14
  677. package/dist/eval/evaluation.d.ts.map +0 -1
  678. package/dist/eval/index.cjs +0 -16
  679. package/dist/eval/index.d.ts +0 -4
  680. package/dist/eval/index.d.ts.map +0 -1
  681. package/dist/eval/index.js +0 -3
  682. package/dist/eval/metric.d.ts +0 -8
  683. package/dist/eval/metric.d.ts.map +0 -1
  684. package/dist/eval/types.d.ts +0 -9
  685. package/dist/eval/types.d.ts.map +0 -1
  686. package/dist/integration/index.warning.d.ts +0 -3
  687. package/dist/integration/index.warning.d.ts.map +0 -1
  688. package/dist/integration/integration.warning.d.ts +0 -5
  689. package/dist/integration/integration.warning.d.ts.map +0 -1
  690. package/dist/integration/openapi-toolset.warning.d.ts +0 -5
  691. package/dist/integration/openapi-toolset.warning.d.ts.map +0 -1
  692. package/dist/loop/telemetry/index.d.ts +0 -36
  693. package/dist/loop/telemetry/index.d.ts.map +0 -1
  694. package/dist/loop/telemetry/noop.d.ts +0 -3
  695. package/dist/loop/telemetry/noop.d.ts.map +0 -1
  696. package/dist/loop/test-utils/mockTracer.d.ts +0 -47
  697. package/dist/loop/test-utils/mockTracer.d.ts.map +0 -1
  698. package/dist/loop/test-utils/telemetry.d.ts +0 -6
  699. package/dist/loop/test-utils/telemetry.d.ts.map +0 -1
  700. package/dist/memory/index.warning.d.ts +0 -6
  701. package/dist/memory/index.warning.d.ts.map +0 -1
  702. package/dist/models-dev-4VGIWYS3.js +0 -3
  703. package/dist/models-dev-AXZASLL2.cjs +0 -12
  704. package/dist/netlify-TX6V7SJJ.cjs +0 -12
  705. package/dist/netlify-VJXBII33.js +0 -3
  706. package/dist/relevance/cohere/index.d.ts +0 -9
  707. package/dist/relevance/cohere/index.d.ts.map +0 -1
  708. package/dist/runtime-context/index.cjs +0 -12
  709. package/dist/runtime-context/index.js +0 -3
  710. package/dist/scores/base.d.ts.map +0 -1
  711. package/dist/scores/base.test-utils.d.ts.map +0 -1
  712. package/dist/scores/hooks.d.ts.map +0 -1
  713. package/dist/scores/index.cjs +0 -37
  714. package/dist/scores/index.cjs.map +0 -1
  715. package/dist/scores/index.d.ts +0 -4
  716. package/dist/scores/index.d.ts.map +0 -1
  717. package/dist/scores/index.js +0 -4
  718. package/dist/scores/index.js.map +0 -1
  719. package/dist/scores/run-experiment/index.d.ts.map +0 -1
  720. package/dist/scores/run-experiment/scorerAccumulator.d.ts.map +0 -1
  721. package/dist/scores/scoreTraces/index.cjs.map +0 -1
  722. package/dist/scores/scoreTraces/index.d.ts.map +0 -1
  723. package/dist/scores/scoreTraces/index.js.map +0 -1
  724. package/dist/scores/scoreTraces/scoreTraces.d.ts.map +0 -1
  725. package/dist/scores/scoreTraces/scoreTracesWorkflow.d.ts.map +0 -1
  726. package/dist/scores/scoreTraces/utils.d.ts.map +0 -1
  727. package/dist/scores/types.d.ts.map +0 -1
  728. package/dist/storage/base.warning.d.ts +0 -8
  729. package/dist/storage/base.warning.d.ts.map +0 -1
  730. package/dist/storage/domains/legacy-evals/base.d.ts +0 -13
  731. package/dist/storage/domains/legacy-evals/base.d.ts.map +0 -1
  732. package/dist/storage/domains/legacy-evals/index.d.ts +0 -2
  733. package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
  734. package/dist/storage/domains/legacy-evals/inmemory.d.ts +0 -17
  735. package/dist/storage/domains/legacy-evals/inmemory.d.ts.map +0 -1
  736. package/dist/storage/domains/traces/base.d.ts +0 -14
  737. package/dist/storage/domains/traces/base.d.ts.map +0 -1
  738. package/dist/storage/domains/traces/index.d.ts +0 -3
  739. package/dist/storage/domains/traces/index.d.ts.map +0 -1
  740. package/dist/storage/domains/traces/inmemory.d.ts +0 -22
  741. package/dist/storage/domains/traces/inmemory.d.ts.map +0 -1
  742. package/dist/storage/index.warning.d.ts +0 -3
  743. package/dist/storage/index.warning.d.ts.map +0 -1
  744. package/dist/telemetry/composite-exporter.d.ts +0 -10
  745. package/dist/telemetry/composite-exporter.d.ts.map +0 -1
  746. package/dist/telemetry/index.cjs +0 -32
  747. package/dist/telemetry/index.cjs.map +0 -1
  748. package/dist/telemetry/index.d.ts +0 -6
  749. package/dist/telemetry/index.d.ts.map +0 -1
  750. package/dist/telemetry/index.js +0 -3
  751. package/dist/telemetry/index.js.map +0 -1
  752. package/dist/telemetry/otel-vendor.cjs +0 -105
  753. package/dist/telemetry/otel-vendor.cjs.map +0 -1
  754. package/dist/telemetry/otel-vendor.d.ts +0 -11
  755. package/dist/telemetry/otel-vendor.d.ts.map +0 -1
  756. package/dist/telemetry/otel-vendor.js +0 -59
  757. package/dist/telemetry/otel-vendor.js.map +0 -1
  758. package/dist/telemetry/storage-exporter.d.ts +0 -21
  759. package/dist/telemetry/storage-exporter.d.ts.map +0 -1
  760. package/dist/telemetry/telemetry.d.ts +0 -59
  761. package/dist/telemetry/telemetry.d.ts.map +0 -1
  762. package/dist/telemetry/telemetry.decorators.d.ts +0 -15
  763. package/dist/telemetry/telemetry.decorators.d.ts.map +0 -1
  764. package/dist/telemetry/types.d.ts +0 -74
  765. package/dist/telemetry/types.d.ts.map +0 -1
  766. package/dist/telemetry/utility.d.ts +0 -15
  767. package/dist/telemetry/utility.d.ts.map +0 -1
  768. package/dist/tools/index.warning.d.ts +0 -8
  769. package/dist/tools/index.warning.d.ts.map +0 -1
  770. package/dist/tts/index.warning.d.ts +0 -7
  771. package/dist/tts/index.warning.d.ts.map +0 -1
  772. package/dist/vector/index.warning.d.ts +0 -6
  773. package/dist/vector/index.warning.d.ts.map +0 -1
  774. package/dist/workflows/index.warning.d.ts +0 -6
  775. package/dist/workflows/index.warning.d.ts.map +0 -1
  776. package/dist/workflows/legacy/index.cjs +0 -92
  777. package/dist/workflows/legacy/index.cjs.map +0 -1
  778. package/dist/workflows/legacy/index.d.ts +0 -5
  779. package/dist/workflows/legacy/index.d.ts.map +0 -1
  780. package/dist/workflows/legacy/index.js +0 -3
  781. package/dist/workflows/legacy/index.js.map +0 -1
  782. package/dist/workflows/legacy/machine.d.ts +0 -386
  783. package/dist/workflows/legacy/machine.d.ts.map +0 -1
  784. package/dist/workflows/legacy/step.d.ts +0 -15
  785. package/dist/workflows/legacy/step.d.ts.map +0 -1
  786. package/dist/workflows/legacy/types.d.ts +0 -397
  787. package/dist/workflows/legacy/types.d.ts.map +0 -1
  788. package/dist/workflows/legacy/utils.d.ts +0 -68
  789. package/dist/workflows/legacy/utils.d.ts.map +0 -1
  790. package/dist/workflows/legacy/workflow-instance.d.ts +0 -97
  791. package/dist/workflows/legacy/workflow-instance.d.ts.map +0 -1
  792. package/dist/workflows/legacy/workflow.d.ts +0 -109
  793. package/dist/workflows/legacy/workflow.d.ts.map +0 -1
  794. package/dist/workflows/workflow.warning.d.ts +0 -9
  795. package/dist/workflows/workflow.warning.d.ts.map +0 -1
  796. package/eval.d.ts +0 -1
  797. package/runtime-context.d.ts +0 -1
  798. package/scores/scoreTraces.d.ts +0 -1
  799. package/scores.d.ts +0 -1
  800. package/telemetry/otel-vendor.d.ts +0 -1
  801. package/telemetry.d.ts +0 -1
  802. package/workflows/legacy.d.ts +0 -1
  803. /package/dist/agent/{input-processor → message-list}/index.cjs.map +0 -0
  804. /package/dist/agent/{input-processor → message-list}/index.js.map +0 -0
  805. /package/dist/{ai-tracing → evals}/index.cjs.map +0 -0
  806. /package/dist/{ai-tracing → evals}/index.js.map +0 -0
  807. /package/dist/{scores/run-experiment → evals/run}/scorerAccumulator.d.ts +0 -0
  808. /package/dist/{scores → evals}/scoreTraces/index.d.ts +0 -0
  809. /package/dist/{eval → observability}/index.cjs.map +0 -0
  810. /package/dist/{eval → observability}/index.js.map +0 -0
  811. /package/dist/{runtime-context → request-context}/index.cjs.map +0 -0
  812. /package/dist/{runtime-context → request-context}/index.js.map +0 -0
@@ -1,15 +1,13 @@
1
- import { WorkflowEventProcessor } from './chunk-3VXXCPKX.js';
2
- import { saveScorePayloadSchema } from './chunk-KAEQISOW.js';
1
+ import { WorkflowEventProcessor } from './chunk-H6CZGPZD.js';
3
2
  import { augmentWithInit } from './chunk-436FFEF6.js';
3
+ import { saveScorePayloadSchema } from './chunk-76K3IYWM.js';
4
4
  import { PubSub } from './chunk-BVUMKER5.js';
5
- import { InstrumentClass, Telemetry } from './chunk-BLUDYAPI.js';
6
- import { InMemoryServerCache } from './chunk-3NTOFNIU.js';
7
- import { registerHook } from './chunk-TTELJD4F.js';
8
- import { setupAITracing, getAllAITracing, shutdownAITracingRegistry } from './chunk-DTTOVV72.js';
9
- import { noopLogger } from './chunk-PFXXH2RP.js';
10
- import { MastraError } from './chunk-PZUZNPFM.js';
11
- import { ConsoleLogger, LogLevel } from './chunk-UXG7PYML.js';
12
- import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-3HXBPDKN.js';
5
+ import { noopLogger } from './chunk-X7JMA3IY.js';
6
+ import { registerHook } from './chunk-L54GIUCB.js';
7
+ import { NoOpObservability } from './chunk-KIZIOFZC.js';
8
+ import { MastraError } from './chunk-JJ5O45LH.js';
9
+ import { InMemoryServerCache } from './chunk-OJNJA5ZI.js';
10
+ import { ConsoleLogger, LogLevel } from './chunk-KJ2SW6VA.js';
13
11
  import { randomUUID } from 'crypto';
14
12
  import EventEmitter from 'events';
15
13
  import pMap from 'p-map';
@@ -22,7 +20,7 @@ var EventEmitterPubSub = class extends PubSub {
22
20
  }
23
21
  async publish(topic, event) {
24
22
  const id = crypto.randomUUID();
25
- const createdAt = /* @__PURE__ */new Date();
23
+ const createdAt = /* @__PURE__ */ new Date();
26
24
  this.emitter.emit(topic, {
27
25
  ...event,
28
26
  id,
@@ -35,10 +33,11 @@ var EventEmitterPubSub = class extends PubSub {
35
33
  async unsubscribe(topic, cb) {
36
34
  this.emitter.off(topic, cb);
37
35
  }
38
- async flush() {}
36
+ async flush() {
37
+ }
39
38
  };
40
39
  function createOnScorerHook(mastra) {
41
- return async hookData => {
40
+ return async (hookData) => {
42
41
  const storage = mastra.getStorage();
43
42
  if (!storage) {
44
43
  mastra.getLogger()?.warn("Storage not found, skipping score validation and saving");
@@ -47,22 +46,24 @@ function createOnScorerHook(mastra) {
47
46
  const entityId = hookData.entity.id;
48
47
  const entityType = hookData.entityType;
49
48
  const scorer = hookData.scorer;
49
+ const scorerId = scorer.id;
50
+ if (!scorerId) {
51
+ mastra.getLogger()?.warn("Scorer ID not found, skipping score validation and saving");
52
+ return;
53
+ }
50
54
  try {
51
- const scorerToUse = await findScorer(mastra, entityId, entityType, scorer.name);
55
+ const scorerToUse = await findScorer(mastra, entityId, entityType, scorerId);
52
56
  if (!scorerToUse) {
53
57
  throw new MastraError({
54
58
  id: "MASTRA_SCORER_NOT_FOUND",
55
59
  domain: "MASTRA" /* MASTRA */,
56
60
  category: "USER" /* USER */,
57
- text: `Scorer with ID ${hookData.scorer.id} not found`
61
+ text: `Scorer with ID ${scorerId} not found`
58
62
  });
59
63
  }
60
64
  let input = hookData.input;
61
65
  let output = hookData.output;
62
- const {
63
- structuredOutput,
64
- ...rest
65
- } = hookData;
66
+ const { structuredOutput, ...rest } = hookData;
66
67
  const runResult = await scorerToUse.scorer.run({
67
68
  ...rest,
68
69
  input,
@@ -79,7 +80,7 @@ function createOnScorerHook(mastra) {
79
80
  ...rest,
80
81
  ...runResult,
81
82
  entityId,
82
- scorerId: hookData.scorer.name,
83
+ scorerId,
83
84
  spanId,
84
85
  traceId,
85
86
  metadata: {
@@ -88,34 +89,43 @@ function createOnScorerHook(mastra) {
88
89
  };
89
90
  await validateAndSaveScore(storage, payload);
90
91
  if (currentSpan && spanId && traceId) {
91
- await pMap(currentSpan.aiTracing.getExporters(), async exporter => {
92
- if (exporter.addScoreToTrace) {
93
- await exporter.addScoreToTrace({
94
- traceId,
95
- spanId,
96
- score: runResult.score,
97
- reason: runResult.reason,
98
- scorerName: scorerToUse.scorer.name,
99
- metadata: {
100
- ...(currentSpan.metadata ?? {})
92
+ await pMap(
93
+ currentSpan.observabilityInstance.getExporters(),
94
+ async (exporter) => {
95
+ if (exporter.addScoreToTrace) {
96
+ try {
97
+ await exporter.addScoreToTrace({
98
+ traceId,
99
+ spanId,
100
+ score: runResult.score,
101
+ reason: runResult.reason,
102
+ scorerName: scorerToUse.scorer.id,
103
+ metadata: {
104
+ ...currentSpan.metadata ?? {}
105
+ }
106
+ });
107
+ } catch (error) {
108
+ mastra.getLogger()?.error(`Failed to add score to trace via exporter: ${error}`);
101
109
  }
102
- });
103
- }
104
- }, {
105
- concurrency: 3
106
- });
110
+ }
111
+ },
112
+ { concurrency: 3 }
113
+ );
107
114
  }
108
115
  } catch (error) {
109
- const mastraError = new MastraError({
110
- id: "MASTRA_SCORER_FAILED_TO_RUN_HOOK",
111
- domain: "SCORER" /* SCORER */,
112
- category: "USER" /* USER */,
113
- details: {
114
- scorerId: scorer.id,
115
- entityId,
116
- entityType
117
- }
118
- }, error);
116
+ const mastraError = new MastraError(
117
+ {
118
+ id: "MASTRA_SCORER_FAILED_TO_RUN_HOOK",
119
+ domain: "SCORER" /* SCORER */,
120
+ category: "USER" /* USER */,
121
+ details: {
122
+ scorerId: scorer.id,
123
+ entityId,
124
+ entityType
125
+ }
126
+ },
127
+ error
128
+ );
119
129
  mastra.getLogger()?.trackException(mastraError);
120
130
  mastra.getLogger()?.error(mastraError.toString());
121
131
  }
@@ -125,56 +135,46 @@ async function validateAndSaveScore(storage, payload) {
125
135
  const payloadToSave = saveScorePayloadSchema.parse(payload);
126
136
  await storage?.saveScore(payloadToSave);
127
137
  }
128
- async function findScorer(mastra, entityId, entityType, scorerName) {
138
+ async function findScorer(mastra, entityId, entityType, scorerId) {
129
139
  let scorerToUse;
130
140
  if (entityType === "AGENT") {
131
- const scorers = await mastra.getAgentById(entityId).getScorers();
141
+ const scorers = await mastra.getAgentById(entityId).listScorers();
132
142
  for (const [_, scorer] of Object.entries(scorers)) {
133
- if (scorer.scorer.name === scorerName) {
143
+ if (scorer.scorer.id === scorerId) {
134
144
  scorerToUse = scorer;
135
145
  break;
136
146
  }
137
147
  }
138
148
  } else if (entityType === "WORKFLOW") {
139
- const scorers = await mastra.getWorkflowById(entityId).getScorers();
149
+ const scorers = await mastra.getWorkflowById(entityId).listScorers();
140
150
  for (const [_, scorer] of Object.entries(scorers)) {
141
- if (scorer.scorer.name === scorerName) {
151
+ if (scorer.scorer.id === scorerId) {
142
152
  scorerToUse = scorer;
143
153
  break;
144
154
  }
145
155
  }
146
156
  }
147
157
  if (!scorerToUse) {
148
- const mastraRegisteredScorer = mastra.getScorerByName(scorerName);
149
- scorerToUse = mastraRegisteredScorer ? {
150
- scorer: mastraRegisteredScorer
151
- } : void 0;
158
+ const mastraRegisteredScorer = mastra.getScorerById(scorerId);
159
+ scorerToUse = mastraRegisteredScorer ? { scorer: mastraRegisteredScorer } : void 0;
152
160
  }
153
161
  return scorerToUse;
154
162
  }
155
163
 
156
164
  // src/mastra/index.ts
157
- var _Mastra_decorators, _init;
158
- _Mastra_decorators = [InstrumentClass({
159
- prefix: "mastra",
160
- excludeMethods: ["getLogger", "getTelemetry"]
161
- })];
162
165
  var Mastra = class {
163
166
  #vectors;
164
167
  #agents;
165
168
  #logger;
166
- #legacy_workflows;
167
169
  #workflows;
170
+ #observability;
168
171
  #tts;
169
172
  #deployer;
170
173
  #serverMiddleware = [];
171
- /**
172
- * @deprecated Use {@link getAITracing()} instead.
173
- */
174
- #telemetry;
175
174
  #storage;
176
- #memory;
177
175
  #scorers;
176
+ #tools;
177
+ #processors;
178
178
  #server;
179
179
  #mcpServers;
180
180
  #bundler;
@@ -184,24 +184,6 @@ var Mastra = class {
184
184
  #internalMastraWorkflows = {};
185
185
  // This is only used internally for server handlers that require temporary persistence
186
186
  #serverCache;
187
- /**
188
- * @deprecated use {@link getAITracing()} instead
189
- */
190
- get telemetry() {
191
- return this.#telemetry;
192
- }
193
- /**
194
- * @deprecated use getStorage() instead
195
- */
196
- get storage() {
197
- return this.#storage;
198
- }
199
- /**
200
- * @deprecated use getMemory() instead
201
- */
202
- get memory() {
203
- return this.#memory;
204
- }
205
187
  get pubsub() {
206
188
  return this.#pubsub;
207
189
  }
@@ -274,14 +256,15 @@ var Mastra = class {
274
256
  * Creates a new Mastra instance with the provided configuration.
275
257
  *
276
258
  * The constructor initializes all the components specified in the config, sets up
277
- * internal systems like logging and telemetry, and registers components with each other.
259
+ * internal systems like logging and observability, and registers components with each other.
278
260
  *
279
261
  * @example
280
262
  * ```typescript
281
263
  * const mastra = new Mastra({
282
264
  * agents: {
283
265
  * assistant: new Agent({
284
- * name: 'assistant',
266
+ * id: 'assistant',
267
+ * name: 'Assistant',
285
268
  * instructions: 'You are a helpful assistant',
286
269
  * model: 'openai/gpt-5'
287
270
  * })
@@ -289,17 +272,12 @@ var Mastra = class {
289
272
  * storage: new PostgresStore({
290
273
  * connectionString: process.env.DATABASE_URL
291
274
  * }),
292
- * logger: new PinoLogger({ name: 'MyApp' })
275
+ * logger: new PinoLogger({ name: 'MyApp' }),
276
+ * observability: { default: { enabled: true }},
293
277
  * });
294
278
  * ```
295
279
  */
296
280
  constructor(config) {
297
- if (config?.serverMiddleware) {
298
- this.#serverMiddleware = config.serverMiddleware.map(m => ({
299
- handler: m.handler,
300
- path: m.path || "/api/*"
301
- }));
302
- }
303
281
  this.#serverCache = new InMemoryServerCache();
304
282
  if (config?.pubsub) {
305
283
  this.#pubsub = config.pubsub;
@@ -314,9 +292,7 @@ var Mastra = class {
314
292
  this.#events[topic] = config?.events?.[topic] ?? [];
315
293
  }
316
294
  }
317
- const workflowEventProcessor = new WorkflowEventProcessor({
318
- mastra: this
319
- });
295
+ const workflowEventProcessor = new WorkflowEventProcessor({ mastra: this });
320
296
  const workflowEventCb = async (event, cb) => {
321
297
  try {
322
298
  await workflowEventProcessor.process(event, cb);
@@ -337,10 +313,7 @@ var Mastra = class {
337
313
  logger = config.logger;
338
314
  } else {
339
315
  const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? LogLevel.WARN : LogLevel.INFO;
340
- logger = new ConsoleLogger({
341
- name: "Mastra",
342
- level: levelOnEnv
343
- });
316
+ logger = new ConsoleLogger({ name: "Mastra", level: levelOnEnv });
344
317
  }
345
318
  }
346
319
  this.#logger = logger;
@@ -349,202 +322,74 @@ var Mastra = class {
349
322
  if (storage) {
350
323
  storage = augmentWithInit(storage);
351
324
  }
352
- this.#telemetry = Telemetry.init(config?.telemetry);
353
- if (config?.telemetry?.enabled !== false && typeof globalThis !== "undefined" && globalThis.___MASTRA_TELEMETRY___ !== true) {
354
- this.#logger?.warn(`Mastra telemetry is enabled, but the required instrumentation file was not loaded. If you are using Mastra outside of the mastra server environment, see: https://mastra.ai/en/docs/observability/tracing#tracing-outside-mastra-server-environment`, `If you are using a custom instrumentation file or want to disable this warning, set the globalThis.___MASTRA_TELEMETRY___ variable to true in your instrumentation file.`);
355
- }
356
- if (config?.telemetry?.enabled !== false) {
357
- this.#logger?.warn(`Mastra telemetry is deprecated and will be removed on the Nov 4th release. Instead use AI Tracing. More info can be found here: https://github.com/mastra-ai/mastra/issues/8577 and here: https://mastra.ai/en/docs/observability/ai-tracing/overview`);
358
- }
359
325
  if (config?.observability) {
360
- setupAITracing(config.observability);
326
+ if (typeof config.observability.getDefaultInstance === "function") {
327
+ this.#observability = config.observability;
328
+ this.#observability.setLogger({ logger: this.#logger });
329
+ } else {
330
+ this.#logger?.warn(
331
+ 'Observability configuration error: Expected an Observability instance, but received a config object. Import and instantiate: import { Observability } from "@mastra/observability"; then pass: observability: new Observability({ default: { enabled: true } }). Observability has been disabled.'
332
+ );
333
+ this.#observability = new NoOpObservability();
334
+ }
335
+ } else {
336
+ this.#observability = new NoOpObservability();
337
+ }
338
+ this.#storage = storage;
339
+ this.#vectors = {};
340
+ this.#mcpServers = {};
341
+ this.#tts = {};
342
+ this.#agents = {};
343
+ this.#scorers = {};
344
+ this.#tools = {};
345
+ this.#processors = {};
346
+ this.#workflows = {};
347
+ if (config?.tools) {
348
+ Object.entries(config.tools).forEach(([key, tool]) => {
349
+ this.addTool(tool, key);
350
+ });
361
351
  }
362
- if (this.#telemetry && storage) {
363
- this.#storage = this.#telemetry.traceClass(storage, {
364
- excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert", "getTraces", "getEvalsByAgentName"]
352
+ if (config?.processors) {
353
+ Object.entries(config.processors).forEach(([key, processor]) => {
354
+ this.addProcessor(processor, key);
365
355
  });
366
- this.#storage.__setTelemetry(this.#telemetry);
367
- } else {
368
- this.#storage = storage;
369
356
  }
370
357
  if (config?.vectors) {
371
- let vectors = {};
372
358
  Object.entries(config.vectors).forEach(([key, vector]) => {
373
- if (this.#telemetry) {
374
- vectors[key] = this.#telemetry.traceClass(vector, {
375
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
376
- });
377
- vectors[key].__setTelemetry(this.#telemetry);
378
- } else {
379
- vectors[key] = vector;
380
- }
359
+ this.addVector(vector, key);
381
360
  });
382
- this.#vectors = vectors;
383
361
  }
384
- if (config?.mcpServers) {
385
- this.#mcpServers = config.mcpServers;
386
- Object.entries(this.#mcpServers).forEach(([key, server]) => {
387
- server.setId(key);
388
- if (this.#telemetry) {
389
- server.__setTelemetry(this.#telemetry);
390
- }
391
- server.__registerMastra(this);
392
- server.__setLogger(this.getLogger());
362
+ if (config?.scorers) {
363
+ Object.entries(config.scorers).forEach(([key, scorer]) => {
364
+ this.addScorer(scorer, key);
393
365
  });
394
366
  }
395
- if (config && `memory` in config) {
396
- const error = new MastraError({
397
- id: "MASTRA_CONSTRUCTOR_INVALID_MEMORY_CONFIG",
398
- domain: "MASTRA" /* MASTRA */,
399
- category: "USER" /* USER */,
400
- text: `
401
- Memory should be added to Agents, not to Mastra.
402
-
403
- Instead of:
404
- new Mastra({ memory: new Memory() })
405
-
406
- do:
407
- new Agent({ memory: new Memory() })
408
- `
367
+ if (config?.workflows) {
368
+ Object.entries(config.workflows).forEach(([key, workflow]) => {
369
+ this.addWorkflow(workflow, key);
409
370
  });
410
- this.#logger?.trackException(error);
411
- throw error;
412
371
  }
413
- if (config?.tts) {
414
- this.#tts = config.tts;
415
- Object.entries(this.#tts).forEach(([key, ttsCl]) => {
416
- if (this.#tts?.[key]) {
417
- if (this.#telemetry) {
418
- this.#tts[key] = this.#telemetry.traceClass(ttsCl, {
419
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
420
- });
421
- this.#tts[key].__setTelemetry(this.#telemetry);
422
- }
423
- }
372
+ if (config?.mcpServers) {
373
+ Object.entries(config.mcpServers).forEach(([key, server]) => {
374
+ this.addMCPServer(server, key);
424
375
  });
425
376
  }
426
- const agents = {};
427
377
  if (config?.agents) {
428
378
  Object.entries(config.agents).forEach(([key, agent]) => {
429
- if (agents[key]) {
430
- const error = new MastraError({
431
- id: "MASTRA_AGENT_REGISTRATION_DUPLICATE_ID",
432
- domain: "MASTRA" /* MASTRA */,
433
- category: "USER" /* USER */,
434
- text: `Agent with name ID:${key} already exists`,
435
- details: {
436
- agentId: key
437
- }
438
- });
439
- this.#logger?.trackException(error);
440
- throw error;
441
- }
442
- agent.__registerMastra(this);
443
- agent.__registerPrimitives({
444
- logger: this.getLogger(),
445
- telemetry: this.#telemetry,
446
- storage: this.storage,
447
- memory: this.memory,
448
- agents,
449
- tts: this.#tts,
450
- vectors: this.#vectors
451
- });
452
- agents[key] = agent;
379
+ this.addAgent(agent, key);
453
380
  });
454
381
  }
455
- this.#agents = agents;
456
- const scorers = {};
457
- if (config?.scorers) {
458
- Object.entries(config.scorers).forEach(([key, scorer]) => {
459
- scorers[key] = scorer;
460
- });
461
- }
462
- this.#scorers = scorers;
463
- this.#legacy_workflows = {};
464
- if (config?.legacy_workflows) {
465
- Object.entries(config.legacy_workflows).forEach(([key, workflow]) => {
466
- workflow.__registerMastra(this);
467
- workflow.__registerPrimitives({
468
- logger: this.getLogger(),
469
- telemetry: this.#telemetry,
470
- storage: this.storage,
471
- memory: this.memory,
472
- agents,
473
- tts: this.#tts,
474
- vectors: this.#vectors
475
- });
476
- this.#legacy_workflows[key] = workflow;
477
- const workflowSteps = Object.values(workflow.steps).filter(step => !!step.workflowId && !!step.workflow);
478
- if (workflowSteps.length > 0) {
479
- workflowSteps.forEach(step => {
480
- this.#legacy_workflows[step.workflowId] = step.workflow;
481
- });
482
- }
483
- });
484
- }
485
- this.#workflows = {};
486
- if (config?.workflows) {
487
- Object.entries(config.workflows).forEach(([key, workflow]) => {
488
- workflow.__registerMastra(this);
489
- workflow.__registerPrimitives({
490
- logger: this.getLogger(),
491
- telemetry: this.#telemetry,
492
- storage: this.storage,
493
- memory: this.memory,
494
- agents,
495
- tts: this.#tts,
496
- vectors: this.#vectors
497
- });
498
- this.#workflows[key] = workflow;
382
+ if (config?.tts) {
383
+ Object.entries(config.tts).forEach(([key, tts]) => {
384
+ this.#tts[key] = tts;
499
385
  });
500
386
  }
501
387
  if (config?.server) {
502
388
  this.#server = config.server;
503
389
  }
504
390
  registerHook("onScorerRun" /* ON_SCORER_RUN */, createOnScorerHook(this));
505
- if (config?.observability) {
506
- this.registerAITracingExporters();
507
- this.initAITracingExporters();
508
- }
509
- this.setLogger({
510
- logger
511
- });
512
- }
513
- /**
514
- * Register this Mastra instance with AI tracing exporters that need it
515
- */
516
- registerAITracingExporters() {
517
- const allTracingInstances = getAllAITracing();
518
- allTracingInstances.forEach(tracing => {
519
- const exporters = tracing.getExporters();
520
- exporters.forEach(exporter => {
521
- if ("__registerMastra" in exporter && typeof exporter.__registerMastra === "function") {
522
- exporter.__registerMastra(this);
523
- }
524
- });
525
- });
526
- }
527
- /**
528
- * Initialize all AI tracing exporters after registration is complete
529
- */
530
- initAITracingExporters() {
531
- const allTracingInstances = getAllAITracing();
532
- allTracingInstances.forEach(tracing => {
533
- const config = tracing.getConfig();
534
- const exporters = tracing.getExporters();
535
- exporters.forEach(exporter => {
536
- if ("init" in exporter && typeof exporter.init === "function") {
537
- try {
538
- exporter.init(config);
539
- } catch (error) {
540
- this.#logger?.warn("Failed to initialize AI tracing exporter", {
541
- exporterName: exporter.name,
542
- error: error instanceof Error ? error.message : String(error)
543
- });
544
- }
545
- }
546
- });
547
- });
391
+ this.#observability.setMastraContext({ mastra: this });
392
+ this.setLogger({ logger });
548
393
  }
549
394
  /**
550
395
  * Retrieves a registered agent by its name.
@@ -557,6 +402,7 @@ do:
557
402
  * const mastra = new Mastra({
558
403
  * agents: {
559
404
  * weatherAgent: new Agent({
405
+ * id: 'weather-agent',
560
406
  * name: 'weather-agent',
561
407
  * instructions: 'You provide weather information',
562
408
  * model: 'openai/gpt-5'
@@ -591,7 +437,7 @@ do:
591
437
  *
592
438
  * This method searches for an agent using its internal ID property. If no agent
593
439
  * is found with the given ID, it also attempts to find an agent using the ID as
594
- * a name (for backward compatibility).
440
+ * a name.
595
441
  *
596
442
  * @throws {MastraError} When no agent is found with the specified ID
597
443
  *
@@ -600,6 +446,7 @@ do:
600
446
  * const mastra = new Mastra({
601
447
  * agents: {
602
448
  * assistant: new Agent({
449
+ * id: 'assistant',
603
450
  * name: 'assistant',
604
451
  * instructions: 'You are a helpful assistant',
605
452
  * model: 'openai/gpt-5'
@@ -612,11 +459,12 @@ do:
612
459
  * ```
613
460
  */
614
461
  getAgentById(id) {
615
- let agent = Object.values(this.#agents).find(a => a.id === id);
462
+ let agent = Object.values(this.#agents).find((a) => a.id === id);
616
463
  if (!agent) {
617
464
  try {
618
465
  agent = this.getAgent(id);
619
- } catch {}
466
+ } catch {
467
+ }
620
468
  }
621
469
  if (!agent) {
622
470
  const error = new MastraError({
@@ -645,18 +493,58 @@ do:
645
493
  * ```typescript
646
494
  * const mastra = new Mastra({
647
495
  * agents: {
648
- * weatherAgent: new Agent({ name: 'weather', model: openai('gpt-4o') }),
649
- * supportAgent: new Agent({ name: 'support', model: openai('gpt-4o') })
496
+ * weatherAgent: new Agent({ id: 'weather-agent', name: 'weather', model: 'openai/gpt-4o' }),
497
+ * supportAgent: new Agent({ id: 'support-agent', name: 'support', model: 'openai/gpt-4o' })
650
498
  * }
651
499
  * });
652
500
  *
653
- * const allAgents = mastra.getAgents();
501
+ * const allAgents = mastra.listAgents();
654
502
  * console.log(Object.keys(allAgents)); // ['weatherAgent', 'supportAgent']
655
503
  * ```
656
504
  */
657
- getAgents() {
505
+ listAgents() {
658
506
  return this.#agents;
659
507
  }
508
+ /**
509
+ * Adds a new agent to the Mastra instance.
510
+ *
511
+ * This method allows dynamic registration of agents after the Mastra instance
512
+ * has been created. The agent will be initialized with the current logger.
513
+ *
514
+ * @throws {MastraError} When an agent with the same key already exists
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * const mastra = new Mastra();
519
+ * const newAgent = new Agent({
520
+ * id: 'chat-agent',
521
+ * name: 'Chat Assistant',
522
+ * model: 'openai/gpt-4o'
523
+ * });
524
+ * mastra.addAgent(newAgent); // Uses agent.id as key
525
+ * // or
526
+ * mastra.addAgent(newAgent, 'customKey'); // Uses custom key
527
+ * ```
528
+ */
529
+ addAgent(agent, key) {
530
+ const agentKey = key || agent.id;
531
+ const agents = this.#agents;
532
+ if (agents[agentKey]) {
533
+ const logger = this.getLogger();
534
+ logger.debug(`Agent with key ${agentKey} already exists. Skipping addition.`);
535
+ return;
536
+ }
537
+ agent.__setLogger(this.#logger);
538
+ agent.__registerMastra(this);
539
+ agent.__registerPrimitives({
540
+ logger: this.getLogger(),
541
+ storage: this.getStorage(),
542
+ agents,
543
+ tts: this.#tts,
544
+ vectors: this.#vectors
545
+ });
546
+ agents[agentKey] = agent;
547
+ }
660
548
  /**
661
549
  * Retrieves a registered vector store by its name.
662
550
  *
@@ -714,6 +602,50 @@ do:
714
602
  }
715
603
  return vector;
716
604
  }
605
+ /**
606
+ * Retrieves a specific vector store instance by its ID.
607
+ *
608
+ * This method searches for a vector store by its internal ID property.
609
+ * If not found by ID, it falls back to searching by registration key.
610
+ *
611
+ * @throws {MastraError} When the specified vector store is not found
612
+ *
613
+ * @example
614
+ * ```typescript
615
+ * const mastra = new Mastra({
616
+ * vectors: {
617
+ * embeddings: chromaVector
618
+ * }
619
+ * });
620
+ *
621
+ * const vectorStore = mastra.getVectorById('chroma-123');
622
+ * ```
623
+ */
624
+ getVectorById(id) {
625
+ const allVectors = this.#vectors ?? {};
626
+ for (const vector of Object.values(allVectors)) {
627
+ if (vector.id === id) {
628
+ return vector;
629
+ }
630
+ }
631
+ const vectorByKey = allVectors[id];
632
+ if (vectorByKey) {
633
+ return vectorByKey;
634
+ }
635
+ const error = new MastraError({
636
+ id: "MASTRA_GET_VECTOR_BY_ID_NOT_FOUND",
637
+ domain: "MASTRA" /* MASTRA */,
638
+ category: "USER" /* USER */,
639
+ text: `Vector store with id ${id} not found`,
640
+ details: {
641
+ status: 404,
642
+ vectorId: String(id),
643
+ vectors: Object.keys(allVectors).join(", ")
644
+ }
645
+ });
646
+ this.#logger?.trackException(error);
647
+ throw error;
648
+ }
717
649
  /**
718
650
  * Returns all registered vector stores as a record keyed by their names.
719
651
  *
@@ -736,9 +668,44 @@ do:
736
668
  * }
737
669
  * ```
738
670
  */
739
- getVectors() {
671
+ listVectors() {
740
672
  return this.#vectors;
741
673
  }
674
+ /**
675
+ * Adds a new vector store to the Mastra instance.
676
+ *
677
+ * This method allows dynamic registration of vector stores after the Mastra instance
678
+ * has been created. The vector store will be initialized with the current logger.
679
+ *
680
+ * @throws {MastraError} When a vector store with the same key already exists
681
+ *
682
+ * @example
683
+ * ```typescript
684
+ * const mastra = new Mastra();
685
+ * const newVector = new ChromaVector({ id: 'chroma-embeddings' });
686
+ * mastra.addVector(newVector); // Uses vector.id as key
687
+ * // or
688
+ * mastra.addVector(newVector, 'customKey'); // Uses custom key
689
+ * ```
690
+ */
691
+ addVector(vector, key) {
692
+ const vectorKey = key || vector.id;
693
+ const vectors = this.#vectors;
694
+ if (vectors[vectorKey]) {
695
+ const logger = this.getLogger();
696
+ logger.debug(`Vector with key ${vectorKey} already exists. Skipping addition.`);
697
+ return;
698
+ }
699
+ vector.__setLogger(this.#logger || this.getLogger());
700
+ vectors[vectorKey] = vector;
701
+ }
702
+ /**
703
+ * @deprecated Use listVectors() instead
704
+ */
705
+ getVectors() {
706
+ console.warn("getVectors() is deprecated. Use listVectors() instead.");
707
+ return this.listVectors();
708
+ }
742
709
  /**
743
710
  * Gets the currently configured deployment provider.
744
711
  *
@@ -763,55 +730,6 @@ do:
763
730
  getDeployer() {
764
731
  return this.#deployer;
765
732
  }
766
- /**
767
- * Retrieves a registered legacy workflow by its ID.
768
- *
769
- * Legacy workflows are the previous generation of workflow system in Mastra,
770
- * maintained for backward compatibility. For new implementations, use the
771
- * modern workflow system accessed via `getWorkflow()`.
772
- *
773
- * @template TWorkflowId - The specific workflow ID type from the registered legacy workflows
774
- * @throws {MastraError} When the legacy workflow with the specified ID is not found
775
- * @deprecated Use `getWorkflow()` for new implementations
776
- *
777
- * @example Getting a legacy workflow
778
- * ```typescript
779
- * const mastra = new Mastra({
780
- * legacy_workflows: {
781
- * oldDataFlow: legacyWorkflowInstance
782
- * }
783
- * });
784
- *
785
- * const workflow = mastra.legacy_getWorkflow('oldDataFlow');
786
- * const result = await workflow.execute({ input: 'data' });
787
- * ```
788
- */
789
- legacy_getWorkflow(id, {
790
- serialized
791
- } = {}) {
792
- const workflow = this.#legacy_workflows?.[id];
793
- if (!workflow) {
794
- const error = new MastraError({
795
- id: "MASTRA_GET_LEGACY_WORKFLOW_BY_ID_NOT_FOUND",
796
- domain: "MASTRA" /* MASTRA */,
797
- category: "USER" /* USER */,
798
- text: `Workflow with ID ${String(id)} not found`,
799
- details: {
800
- status: 404,
801
- workflowId: String(id),
802
- workflows: Object.keys(this.#legacy_workflows ?? {}).join(", ")
803
- }
804
- });
805
- this.#logger?.trackException(error);
806
- throw error;
807
- }
808
- if (serialized) {
809
- return {
810
- name: workflow.name
811
- };
812
- }
813
- return workflow;
814
- }
815
733
  /**
816
734
  * Retrieves a registered workflow by its ID.
817
735
  *
@@ -839,9 +757,7 @@ do:
839
757
  * });
840
758
  * ```
841
759
  */
842
- getWorkflow(id, {
843
- serialized
844
- } = {}) {
760
+ getWorkflow(id, { serialized } = {}) {
845
761
  const workflow = this.#workflows?.[id];
846
762
  if (!workflow) {
847
763
  const error = new MastraError({
@@ -859,25 +775,22 @@ do:
859
775
  throw error;
860
776
  }
861
777
  if (serialized) {
862
- return {
863
- name: workflow.name
864
- };
778
+ return { name: workflow.name };
865
779
  }
866
780
  return workflow;
867
781
  }
868
782
  __registerInternalWorkflow(workflow) {
869
783
  workflow.__registerMastra(this);
870
784
  workflow.__registerPrimitives({
871
- logger: this.getLogger(),
872
- storage: this.storage
785
+ logger: this.getLogger()
873
786
  });
874
787
  this.#internalMastraWorkflows[workflow.id] = workflow;
875
788
  }
876
789
  __hasInternalWorkflow(id) {
877
- return Object.values(this.#internalMastraWorkflows).some(workflow => workflow.id === id);
790
+ return Object.values(this.#internalMastraWorkflows).some((workflow) => workflow.id === id);
878
791
  }
879
792
  __getInternalWorkflow(id) {
880
- const workflow = Object.values(this.#internalMastraWorkflows).find(a => a.id === id);
793
+ const workflow = Object.values(this.#internalMastraWorkflows).find((a) => a.id === id);
881
794
  if (!workflow) {
882
795
  throw new MastraError({
883
796
  id: "MASTRA_GET_INTERNAL_WORKFLOW_BY_ID_NOT_FOUND",
@@ -897,7 +810,7 @@ do:
897
810
  *
898
811
  * This method searches for a workflow using its internal ID property. If no workflow
899
812
  * is found with the given ID, it also attempts to find a workflow using the ID as
900
- * a name (for backward compatibility).
813
+ * a name.
901
814
  *
902
815
  * @throws {MastraError} When no workflow is found with the specified ID
903
816
  *
@@ -922,11 +835,12 @@ do:
922
835
  * ```
923
836
  */
924
837
  getWorkflowById(id) {
925
- let workflow = Object.values(this.#workflows).find(a => a.id === id);
838
+ let workflow = Object.values(this.#workflows).find((a) => a.id === id);
926
839
  if (!workflow) {
927
840
  try {
928
841
  workflow = this.getWorkflow(id);
929
- } catch {}
842
+ } catch {
843
+ }
930
844
  }
931
845
  if (!workflow) {
932
846
  const error = new MastraError({
@@ -945,45 +859,6 @@ do:
945
859
  }
946
860
  return workflow;
947
861
  }
948
- /**
949
- * Returns all registered legacy workflows as a record keyed by their IDs.
950
- *
951
- * Legacy workflows are the previous generation of workflow system in Mastra,
952
- * maintained for backward compatibility. For new implementations, use `getWorkflows()`.
953
- *
954
- * @deprecated Use `getWorkflows()` for new implementations
955
- *
956
- * @example Listing all legacy workflows
957
- * ```typescript
958
- * const mastra = new Mastra({
959
- * legacy_workflows: {
960
- * oldFlow1: legacyWorkflow1,
961
- * oldFlow2: legacyWorkflow2
962
- * }
963
- * });
964
- *
965
- * const allLegacyWorkflows = mastra.legacy_getWorkflows();
966
- * console.log(Object.keys(allLegacyWorkflows)); // ['oldFlow1', 'oldFlow2']
967
- *
968
- * // Execute all legacy workflows
969
- * for (const [id, workflow] of Object.entries(allLegacyWorkflows)) {
970
- * console.log(`Legacy workflow ${id}:`, workflow.name);
971
- * }
972
- * ```
973
- */
974
- legacy_getWorkflows(props = {}) {
975
- if (props.serialized) {
976
- return Object.entries(this.#legacy_workflows).reduce((acc, [k, v]) => {
977
- return {
978
- ...acc,
979
- [k]: {
980
- name: v.name
981
- }
982
- };
983
- }, {});
984
- }
985
- return this.#legacy_workflows;
986
- }
987
862
  /**
988
863
  * Returns all registered scorers as a record keyed by their IDs.
989
864
  *
@@ -999,18 +874,48 @@ do:
999
874
  * }
1000
875
  * });
1001
876
  *
1002
- * const allScorers = mastra.getScorers();
877
+ * const allScorers = mastra.listScorers();
1003
878
  * console.log(Object.keys(allScorers)); // ['helpfulness', 'accuracy', 'relevance']
1004
879
  *
1005
880
  * // Check scorer configurations
1006
881
  * for (const [id, scorer] of Object.entries(allScorers)) {
1007
- * console.log(`Scorer ${id}:`, scorer.name, scorer.description);
882
+ * console.log(`Scorer ${id}:`, scorer.id, scorer.name, scorer.description);
1008
883
  * }
1009
884
  * ```
1010
885
  */
1011
- getScorers() {
886
+ listScorers() {
1012
887
  return this.#scorers;
1013
888
  }
889
+ /**
890
+ * Adds a new scorer to the Mastra instance.
891
+ *
892
+ * This method allows dynamic registration of scorers after the Mastra instance
893
+ * has been created.
894
+ *
895
+ * @throws {MastraError} When a scorer with the same key already exists
896
+ *
897
+ * @example
898
+ * ```typescript
899
+ * const mastra = new Mastra();
900
+ * const newScorer = new MastraScorer({
901
+ * id: 'quality-scorer',
902
+ * name: 'Quality Scorer'
903
+ * });
904
+ * mastra.addScorer(newScorer); // Uses scorer.id as key
905
+ * // or
906
+ * mastra.addScorer(newScorer, 'customKey'); // Uses custom key
907
+ * ```
908
+ */
909
+ addScorer(scorer, key) {
910
+ const scorerKey = key || scorer.id;
911
+ const scorers = this.#scorers;
912
+ if (scorers[scorerKey]) {
913
+ const logger = this.getLogger();
914
+ logger.debug(`Scorer with key ${scorerKey} already exists. Skipping addition.`);
915
+ return;
916
+ }
917
+ scorers[scorerKey] = scorer;
918
+ }
1014
919
  /**
1015
920
  * Retrieves a registered scorer by its key.
1016
921
  *
@@ -1024,7 +929,7 @@ do:
1024
929
  * const mastra = new Mastra({
1025
930
  * scorers: {
1026
931
  * helpfulness: new HelpfulnessScorer({
1027
- * model: openai('gpt-4o'),
932
+ * model: 'openai/gpt-4o',
1028
933
  * criteria: 'Rate how helpful this response is'
1029
934
  * }),
1030
935
  * accuracy: new AccuracyScorer({
@@ -1081,28 +986,298 @@ do:
1081
986
  * });
1082
987
  *
1083
988
  * // Find scorer by its internal name, not the registration key
1084
- * const scorer = mastra.getScorerByName('helpfulness-evaluator');
989
+ * const scorer = mastra.getScorerById('helpfulness-evaluator');
1085
990
  * const score = await scorer.score({
1086
991
  * input: 'question',
1087
992
  * output: 'answer'
1088
993
  * });
1089
994
  * ```
1090
995
  */
1091
- getScorerByName(name) {
996
+ getScorerById(id) {
1092
997
  for (const [_key, value] of Object.entries(this.#scorers ?? {})) {
1093
- if (value.name === name) {
998
+ if (value.id === id || value?.name === id) {
1094
999
  return value;
1095
1000
  }
1096
1001
  }
1097
1002
  const error = new MastraError({
1098
- id: "MASTRA_GET_SCORER_BY_NAME_NOT_FOUND",
1003
+ id: "MASTRA_GET_SCORER_BY_ID_NOT_FOUND",
1099
1004
  domain: "MASTRA" /* MASTRA */,
1100
1005
  category: "USER" /* USER */,
1101
- text: `Scorer with name ${String(name)} not found`
1006
+ text: `Scorer with id ${String(id)} not found`
1102
1007
  });
1103
1008
  this.#logger?.trackException(error);
1104
1009
  throw error;
1105
1010
  }
1011
+ /**
1012
+ * Retrieves a specific tool by registration key.
1013
+ *
1014
+ * @throws {MastraError} When the specified tool is not found
1015
+ *
1016
+ * @example
1017
+ * ```typescript
1018
+ * const mastra = new Mastra({
1019
+ * tools: {
1020
+ * calculator: calculatorTool,
1021
+ * weather: weatherTool
1022
+ * }
1023
+ * });
1024
+ *
1025
+ * const tool = mastra.getTool('calculator');
1026
+ * ```
1027
+ */
1028
+ getTool(name) {
1029
+ if (!this.#tools || !this.#tools[name]) {
1030
+ const error = new MastraError({
1031
+ id: "MASTRA_GET_TOOL_BY_NAME_NOT_FOUND",
1032
+ domain: "MASTRA" /* MASTRA */,
1033
+ category: "USER" /* USER */,
1034
+ text: `Tool with name ${String(name)} not found`,
1035
+ details: {
1036
+ status: 404,
1037
+ toolName: String(name),
1038
+ tools: Object.keys(this.#tools ?? {}).join(", ")
1039
+ }
1040
+ });
1041
+ this.#logger?.trackException(error);
1042
+ throw error;
1043
+ }
1044
+ return this.#tools[name];
1045
+ }
1046
+ /**
1047
+ * Retrieves a specific tool by its ID.
1048
+ *
1049
+ * @throws {MastraError} When the specified tool is not found
1050
+ *
1051
+ * @example
1052
+ * ```typescript
1053
+ * const mastra = new Mastra({
1054
+ * tools: {
1055
+ * calculator: calculatorTool
1056
+ * }
1057
+ * });
1058
+ *
1059
+ * const tool = mastra.getToolById('calculator-tool-id');
1060
+ * ```
1061
+ */
1062
+ getToolById(id) {
1063
+ const allTools = this.#tools;
1064
+ if (!allTools) {
1065
+ throw new MastraError({
1066
+ id: "MASTRA_GET_TOOL_BY_ID_NOT_FOUND",
1067
+ domain: "MASTRA" /* MASTRA */,
1068
+ category: "USER" /* USER */,
1069
+ text: `Tool with id ${id} not found`
1070
+ });
1071
+ }
1072
+ for (const tool of Object.values(allTools)) {
1073
+ if (tool.id === id) {
1074
+ return tool;
1075
+ }
1076
+ }
1077
+ const toolByKey = allTools[id];
1078
+ if (toolByKey) {
1079
+ return toolByKey;
1080
+ }
1081
+ const error = new MastraError({
1082
+ id: "MASTRA_GET_TOOL_BY_ID_NOT_FOUND",
1083
+ domain: "MASTRA" /* MASTRA */,
1084
+ category: "USER" /* USER */,
1085
+ text: `Tool with id ${id} not found`,
1086
+ details: {
1087
+ status: 404,
1088
+ toolId: String(id),
1089
+ tools: Object.keys(allTools).join(", ")
1090
+ }
1091
+ });
1092
+ this.#logger?.trackException(error);
1093
+ throw error;
1094
+ }
1095
+ /**
1096
+ * Lists all configured tools.
1097
+ *
1098
+ * @example
1099
+ * ```typescript
1100
+ * const mastra = new Mastra({
1101
+ * tools: {
1102
+ * calculator: calculatorTool,
1103
+ * weather: weatherTool
1104
+ * }
1105
+ * });
1106
+ *
1107
+ * const tools = mastra.listTools();
1108
+ * Object.entries(tools || {}).forEach(([name, tool]) => {
1109
+ * console.log(`Tool "${name}":`, tool.id);
1110
+ * });
1111
+ * ```
1112
+ */
1113
+ listTools() {
1114
+ return this.#tools;
1115
+ }
1116
+ /**
1117
+ * Adds a new tool to the Mastra instance.
1118
+ *
1119
+ * This method allows dynamic registration of tools after the Mastra instance
1120
+ * has been created.
1121
+ *
1122
+ * @throws {MastraError} When a tool with the same key already exists
1123
+ *
1124
+ * @example
1125
+ * ```typescript
1126
+ * const mastra = new Mastra();
1127
+ * const newTool = createTool({
1128
+ * id: 'calculator-tool',
1129
+ * description: 'Performs calculations'
1130
+ * });
1131
+ * mastra.addTool(newTool); // Uses tool.id as key
1132
+ * // or
1133
+ * mastra.addTool(newTool, 'customKey'); // Uses custom key
1134
+ * ```
1135
+ */
1136
+ addTool(tool, key) {
1137
+ const toolKey = key || tool.id;
1138
+ const tools = this.#tools;
1139
+ if (tools[toolKey]) {
1140
+ const logger = this.getLogger();
1141
+ logger.debug(`Tool with key ${toolKey} already exists. Skipping addition.`);
1142
+ return;
1143
+ }
1144
+ tools[toolKey] = tool;
1145
+ }
1146
+ /**
1147
+ * Retrieves a specific processor by registration key.
1148
+ *
1149
+ * @throws {MastraError} When the specified processor is not found
1150
+ *
1151
+ * @example
1152
+ * ```typescript
1153
+ * const mastra = new Mastra({
1154
+ * processors: {
1155
+ * validator: validatorProcessor,
1156
+ * transformer: transformerProcessor
1157
+ * }
1158
+ * });
1159
+ *
1160
+ * const processor = mastra.getProcessor('validator');
1161
+ * ```
1162
+ */
1163
+ getProcessor(name) {
1164
+ if (!this.#processors || !this.#processors[name]) {
1165
+ const error = new MastraError({
1166
+ id: "MASTRA_GET_PROCESSOR_BY_NAME_NOT_FOUND",
1167
+ domain: "MASTRA" /* MASTRA */,
1168
+ category: "USER" /* USER */,
1169
+ text: `Processor with name ${String(name)} not found`,
1170
+ details: {
1171
+ status: 404,
1172
+ processorName: String(name),
1173
+ processors: Object.keys(this.#processors ?? {}).join(", ")
1174
+ }
1175
+ });
1176
+ this.#logger?.trackException(error);
1177
+ throw error;
1178
+ }
1179
+ return this.#processors[name];
1180
+ }
1181
+ /**
1182
+ * Retrieves a specific processor by its ID.
1183
+ *
1184
+ * @throws {MastraError} When the specified processor is not found
1185
+ *
1186
+ * @example
1187
+ * ```typescript
1188
+ * const mastra = new Mastra({
1189
+ * processors: {
1190
+ * validator: validatorProcessor
1191
+ * }
1192
+ * });
1193
+ *
1194
+ * const processor = mastra.getProcessorById('validator-processor-id');
1195
+ * ```
1196
+ */
1197
+ getProcessorById(id) {
1198
+ const allProcessors = this.#processors;
1199
+ if (!allProcessors) {
1200
+ throw new MastraError({
1201
+ id: "MASTRA_GET_PROCESSOR_BY_ID_NOT_FOUND",
1202
+ domain: "MASTRA" /* MASTRA */,
1203
+ category: "USER" /* USER */,
1204
+ text: `Processor with id ${id} not found`
1205
+ });
1206
+ }
1207
+ for (const processor of Object.values(allProcessors)) {
1208
+ if (processor.id === id) {
1209
+ return processor;
1210
+ }
1211
+ }
1212
+ const processorByKey = allProcessors[id];
1213
+ if (processorByKey) {
1214
+ return processorByKey;
1215
+ }
1216
+ const error = new MastraError({
1217
+ id: "MASTRA_GET_PROCESSOR_BY_ID_NOT_FOUND",
1218
+ domain: "MASTRA" /* MASTRA */,
1219
+ category: "USER" /* USER */,
1220
+ text: `Processor with id ${id} not found`,
1221
+ details: {
1222
+ status: 404,
1223
+ processorId: String(id),
1224
+ processors: Object.keys(allProcessors).join(", ")
1225
+ }
1226
+ });
1227
+ this.#logger?.trackException(error);
1228
+ throw error;
1229
+ }
1230
+ /**
1231
+ * Lists all configured processors.
1232
+ *
1233
+ * @example
1234
+ * ```typescript
1235
+ * const mastra = new Mastra({
1236
+ * processors: {
1237
+ * validator: validatorProcessor,
1238
+ * transformer: transformerProcessor
1239
+ * }
1240
+ * });
1241
+ *
1242
+ * const processors = mastra.listProcessors();
1243
+ * Object.entries(processors || {}).forEach(([name, processor]) => {
1244
+ * console.log(`Processor "${name}":`, processor.id);
1245
+ * });
1246
+ * ```
1247
+ */
1248
+ listProcessors() {
1249
+ return this.#processors;
1250
+ }
1251
+ /**
1252
+ * Adds a new processor to the Mastra instance.
1253
+ *
1254
+ * This method allows dynamic registration of processors after the Mastra instance
1255
+ * has been created.
1256
+ *
1257
+ * @throws {MastraError} When a processor with the same key already exists
1258
+ *
1259
+ * @example
1260
+ * ```typescript
1261
+ * const mastra = new Mastra();
1262
+ * const newProcessor = {
1263
+ * id: 'text-processor',
1264
+ * processInput: async (messages) => messages
1265
+ * };
1266
+ * mastra.addProcessor(newProcessor); // Uses processor.id as key
1267
+ * // or
1268
+ * mastra.addProcessor(newProcessor, 'customKey'); // Uses custom key
1269
+ * ```
1270
+ */
1271
+ addProcessor(processor, key) {
1272
+ const processorKey = key || processor.id;
1273
+ const processors = this.#processors;
1274
+ if (processors[processorKey]) {
1275
+ const logger = this.getLogger();
1276
+ logger.debug(`Processor with key ${processorKey} already exists. Skipping addition.`);
1277
+ return;
1278
+ }
1279
+ processors[processorKey] = processor;
1280
+ }
1106
1281
  /**
1107
1282
  * Returns all registered workflows as a record keyed by their IDs.
1108
1283
  *
@@ -1116,7 +1291,7 @@ do:
1116
1291
  * }
1117
1292
  * });
1118
1293
  *
1119
- * const allWorkflows = mastra.getWorkflows();
1294
+ * const allWorkflows = mastra.listWorkflows();
1120
1295
  * console.log(Object.keys(allWorkflows)); // ['dataProcessor', 'emailSender', 'reportGenerator']
1121
1296
  *
1122
1297
  * // Execute all workflows with sample data
@@ -1126,19 +1301,52 @@ do:
1126
1301
  * }
1127
1302
  * ```
1128
1303
  */
1129
- getWorkflows(props = {}) {
1304
+ listWorkflows(props = {}) {
1130
1305
  if (props.serialized) {
1131
1306
  return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
1132
1307
  return {
1133
1308
  ...acc,
1134
- [k]: {
1135
- name: v.name
1136
- }
1309
+ [k]: { name: v.name }
1137
1310
  };
1138
1311
  }, {});
1139
1312
  }
1140
1313
  return this.#workflows;
1141
1314
  }
1315
+ /**
1316
+ * Adds a new workflow to the Mastra instance.
1317
+ *
1318
+ * This method allows dynamic registration of workflows after the Mastra instance
1319
+ * has been created. The workflow will be initialized with Mastra and primitives.
1320
+ *
1321
+ * @throws {MastraError} When a workflow with the same key already exists
1322
+ *
1323
+ * @example
1324
+ * ```typescript
1325
+ * const mastra = new Mastra();
1326
+ * const newWorkflow = createWorkflow({
1327
+ * id: 'data-pipeline',
1328
+ * name: 'Data Pipeline'
1329
+ * }).commit();
1330
+ * mastra.addWorkflow(newWorkflow); // Uses workflow.id as key
1331
+ * // or
1332
+ * mastra.addWorkflow(newWorkflow, 'customKey'); // Uses custom key
1333
+ * ```
1334
+ */
1335
+ addWorkflow(workflow, key) {
1336
+ const workflowKey = key || workflow.id;
1337
+ const workflows = this.#workflows;
1338
+ if (workflows[workflowKey]) {
1339
+ const logger = this.getLogger();
1340
+ logger.debug(`Workflow with key ${workflowKey} already exists. Skipping addition.`);
1341
+ return;
1342
+ }
1343
+ workflow.__registerMastra(this);
1344
+ workflow.__registerPrimitives({
1345
+ logger: this.getLogger(),
1346
+ storage: this.getStorage()
1347
+ });
1348
+ workflows[workflowKey] = workflow;
1349
+ }
1142
1350
  /**
1143
1351
  * Sets the storage provider for the Mastra instance.
1144
1352
  *
@@ -1153,6 +1361,7 @@ do:
1153
1361
  *
1154
1362
  * // Now agents can use memory with the storage
1155
1363
  * const agent = new Agent({
1364
+ * id: 'assistant',
1156
1365
  * name: 'assistant',
1157
1366
  * memory: new Memory({ storage: mastra.getStorage() })
1158
1367
  * });
@@ -1161,23 +1370,18 @@ do:
1161
1370
  setStorage(storage) {
1162
1371
  this.#storage = augmentWithInit(storage);
1163
1372
  }
1164
- setLogger({
1165
- logger
1166
- }) {
1373
+ setLogger({ logger }) {
1167
1374
  this.#logger = logger;
1168
1375
  if (this.#agents) {
1169
- Object.keys(this.#agents).forEach(key => {
1376
+ Object.keys(this.#agents).forEach((key) => {
1170
1377
  this.#agents?.[key]?.__setLogger(this.#logger);
1171
1378
  });
1172
1379
  }
1173
- if (this.#memory) {
1174
- this.#memory.__setLogger(this.#logger);
1175
- }
1176
1380
  if (this.#deployer) {
1177
1381
  this.#deployer.__setLogger(this.#logger);
1178
1382
  }
1179
1383
  if (this.#tts) {
1180
- Object.keys(this.#tts).forEach(key => {
1384
+ Object.keys(this.#tts).forEach((key) => {
1181
1385
  this.#tts?.[key]?.__setLogger(this.#logger);
1182
1386
  });
1183
1387
  }
@@ -1185,71 +1389,16 @@ do:
1185
1389
  this.#storage.__setLogger(this.#logger);
1186
1390
  }
1187
1391
  if (this.#vectors) {
1188
- Object.keys(this.#vectors).forEach(key => {
1392
+ Object.keys(this.#vectors).forEach((key) => {
1189
1393
  this.#vectors?.[key]?.__setLogger(this.#logger);
1190
1394
  });
1191
1395
  }
1192
1396
  if (this.#mcpServers) {
1193
- Object.keys(this.#mcpServers).forEach(key => {
1397
+ Object.keys(this.#mcpServers).forEach((key) => {
1194
1398
  this.#mcpServers?.[key]?.__setLogger(this.#logger);
1195
1399
  });
1196
1400
  }
1197
- const allTracingInstances = getAllAITracing();
1198
- allTracingInstances.forEach(instance => {
1199
- instance.__setLogger(this.#logger);
1200
- });
1201
- }
1202
- setTelemetry(telemetry) {
1203
- this.#telemetry = Telemetry.init(telemetry);
1204
- if (this.#agents) {
1205
- Object.keys(this.#agents).forEach(key => {
1206
- if (this.#telemetry) {
1207
- this.#agents?.[key]?.__setTelemetry(this.#telemetry);
1208
- }
1209
- });
1210
- }
1211
- if (this.#memory) {
1212
- this.#memory = this.#telemetry.traceClass(this.#memory, {
1213
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
1214
- });
1215
- this.#memory.__setTelemetry(this.#telemetry);
1216
- }
1217
- if (this.#deployer) {
1218
- this.#deployer = this.#telemetry.traceClass(this.#deployer, {
1219
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
1220
- });
1221
- this.#deployer.__setTelemetry(this.#telemetry);
1222
- }
1223
- if (this.#tts) {
1224
- let tts = {};
1225
- Object.entries(this.#tts).forEach(([key, ttsCl]) => {
1226
- if (this.#telemetry) {
1227
- tts[key] = this.#telemetry.traceClass(ttsCl, {
1228
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
1229
- });
1230
- tts[key].__setTelemetry(this.#telemetry);
1231
- }
1232
- });
1233
- this.#tts = tts;
1234
- }
1235
- if (this.#storage) {
1236
- this.#storage = this.#telemetry.traceClass(this.#storage, {
1237
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
1238
- });
1239
- this.#storage.__setTelemetry(this.#telemetry);
1240
- }
1241
- if (this.#vectors) {
1242
- let vectors = {};
1243
- Object.entries(this.#vectors).forEach(([key, vector]) => {
1244
- if (this.#telemetry) {
1245
- vectors[key] = this.#telemetry.traceClass(vector, {
1246
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
1247
- });
1248
- vectors[key].__setTelemetry(this.#telemetry);
1249
- }
1250
- });
1251
- this.#vectors = vectors;
1252
- }
1401
+ this.#observability.setLogger({ logger: this.#logger });
1253
1402
  }
1254
1403
  /**
1255
1404
  * Gets all registered text-to-speech (TTS) providers.
@@ -1295,67 +1444,18 @@ do:
1295
1444
  getLogger() {
1296
1445
  return this.#logger;
1297
1446
  }
1298
- /**
1299
- * Gets the currently configured telemetry instance.
1300
- *
1301
- * @example
1302
- * ```typescript
1303
- * const mastra = new Mastra({
1304
- * telemetry: {
1305
- * enabled: true,
1306
- * serviceName: 'my-mastra-app'
1307
- * }
1308
- * });
1309
- *
1310
- * const telemetry = mastra.getTelemetry();
1311
- * if (telemetry) {
1312
- * const span = telemetry.startSpan('custom-operation');
1313
- * span.setAttributes({ operation: 'data-processing' });
1314
- * span.end();
1315
- * }
1316
- * ```
1317
- *
1318
- * @deprecated use {@link getAITracing()} instead
1319
- */
1320
- getTelemetry() {
1321
- return this.#telemetry;
1322
- }
1323
- /**
1324
- * Gets the currently configured memory instance.
1325
- *
1326
- * @deprecated Memory should be configured directly on agents instead of on the Mastra instance.
1327
- * Use `new Agent({ memory: new Memory() })` instead.
1328
- *
1329
- * @example Legacy memory usage (deprecated)
1330
- * ```typescript
1331
- * // This approach is deprecated
1332
- * const mastra = new Mastra({
1333
- * // memory: new Memory() // This is no longer supported
1334
- * });
1335
- *
1336
- * // Use this instead:
1337
- * const agent = new Agent({
1338
- * name: 'assistant',
1339
- * memory: new Memory({
1340
- * storage: new LibSQLStore({ url: ':memory:' })
1341
- * })
1342
- * });
1343
- * ```
1344
- */
1345
- getMemory() {
1346
- return this.#memory;
1347
- }
1348
1447
  /**
1349
1448
  * Gets the currently configured storage provider.
1350
1449
  *
1351
1450
  * @example
1352
1451
  * ```typescript
1353
1452
  * const mastra = new Mastra({
1354
- * storage: new LibSQLStore({ url: 'file:./data.db' })
1453
+ * storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./data.db' })
1355
1454
  * });
1356
1455
  *
1357
1456
  * // Use the storage in agent memory
1358
1457
  * const agent = new Agent({
1458
+ * id: 'assistant',
1359
1459
  * name: 'assistant',
1360
1460
  * memory: new Memory({
1361
1461
  * storage: mastra.getStorage()
@@ -1366,6 +1466,9 @@ do:
1366
1466
  getStorage() {
1367
1467
  return this.#storage;
1368
1468
  }
1469
+ get observability() {
1470
+ return this.#observability;
1471
+ }
1369
1472
  getServerMiddleware() {
1370
1473
  return this.#serverMiddleware;
1371
1474
  }
@@ -1374,10 +1477,12 @@ do:
1374
1477
  }
1375
1478
  setServerMiddleware(serverMiddleware) {
1376
1479
  if (typeof serverMiddleware === "function") {
1377
- this.#serverMiddleware = [{
1378
- handler: serverMiddleware,
1379
- path: "/api/*"
1380
- }];
1480
+ this.#serverMiddleware = [
1481
+ {
1482
+ handler: serverMiddleware,
1483
+ path: "/api/*"
1484
+ }
1485
+ ];
1381
1486
  return;
1382
1487
  }
1383
1488
  if (!Array.isArray(serverMiddleware)) {
@@ -1390,7 +1495,7 @@ do:
1390
1495
  this.#logger?.trackException(error);
1391
1496
  throw error;
1392
1497
  }
1393
- this.#serverMiddleware = serverMiddleware.map(m => {
1498
+ this.#serverMiddleware = serverMiddleware.map((m) => {
1394
1499
  if (typeof m === "function") {
1395
1500
  return {
1396
1501
  handler: m,
@@ -1409,7 +1514,7 @@ do:
1409
1514
  getBundlerConfig() {
1410
1515
  return this.#bundler;
1411
1516
  }
1412
- async getLogsByRunId({
1517
+ async listLogsByRunId({
1413
1518
  runId,
1414
1519
  transportId,
1415
1520
  fromDate,
@@ -1421,7 +1526,7 @@ do:
1421
1526
  }) {
1422
1527
  if (!transportId) {
1423
1528
  const error = new MastraError({
1424
- id: "MASTRA_GET_LOGS_BY_RUN_ID_MISSING_TRANSPORT",
1529
+ id: "MASTRA_LIST_LOGS_BY_RUN_ID_MISSING_TRANSPORT",
1425
1530
  domain: "MASTRA" /* MASTRA */,
1426
1531
  category: "USER" /* USER */,
1427
1532
  text: "Transport ID is required",
@@ -1433,12 +1538,12 @@ do:
1433
1538
  this.#logger?.trackException(error);
1434
1539
  throw error;
1435
1540
  }
1436
- if (!this.#logger?.getLogsByRunId) {
1541
+ if (!this.#logger?.listLogsByRunId) {
1437
1542
  const error = new MastraError({
1438
1543
  id: "MASTRA_GET_LOGS_BY_RUN_ID_LOGGER_NOT_CONFIGURED",
1439
1544
  domain: "MASTRA" /* MASTRA */,
1440
1545
  category: "SYSTEM" /* SYSTEM */,
1441
- text: "Logger is not configured or does not support getLogsByRunId operation",
1546
+ text: "Logger is not configured or does not support listLogsByRunId operation",
1442
1547
  details: {
1443
1548
  runId,
1444
1549
  transportId
@@ -1447,7 +1552,7 @@ do:
1447
1552
  this.#logger?.trackException(error);
1448
1553
  throw error;
1449
1554
  }
1450
- return await this.#logger.getLogsByRunId({
1555
+ return await this.#logger.listLogsByRunId({
1451
1556
  runId,
1452
1557
  transportId,
1453
1558
  fromDate,
@@ -1458,7 +1563,7 @@ do:
1458
1563
  perPage
1459
1564
  });
1460
1565
  }
1461
- async getLogs(transportId, params) {
1566
+ async listLogs(transportId, params) {
1462
1567
  if (!transportId) {
1463
1568
  const error = new MastraError({
1464
1569
  id: "MASTRA_GET_LOGS_MISSING_TRANSPORT",
@@ -1484,7 +1589,7 @@ do:
1484
1589
  });
1485
1590
  throw error;
1486
1591
  }
1487
- return await this.#logger.getLogs(transportId, params);
1592
+ return await this.#logger.listLogs(transportId, params);
1488
1593
  }
1489
1594
  /**
1490
1595
  * Gets all registered Model Context Protocol (MCP) server instances.
@@ -1502,13 +1607,83 @@ do:
1502
1607
  * const mcpServers = mastra.getMCPServers();
1503
1608
  * if (mcpServers) {
1504
1609
  * const fsServer = mcpServers.filesystem;
1505
- * const tools = await fsServer.getTools();
1610
+ * const tools = await fsServer.listTools();
1506
1611
  * }
1507
1612
  * ```
1508
1613
  */
1509
- getMCPServers() {
1614
+ listMCPServers() {
1510
1615
  return this.#mcpServers;
1511
1616
  }
1617
+ /**
1618
+ * Adds a new MCP server to the Mastra instance.
1619
+ *
1620
+ * This method allows dynamic registration of MCP servers after the Mastra instance
1621
+ * has been created. The server will be initialized with ID, Mastra instance, and logger.
1622
+ *
1623
+ * @throws {MastraError} When an MCP server with the same key already exists
1624
+ *
1625
+ * @example
1626
+ * ```typescript
1627
+ * const mastra = new Mastra();
1628
+ * const newServer = new FileSystemMCPServer({
1629
+ * rootPath: '/data'
1630
+ * });
1631
+ * mastra.addMCPServer(newServer); // Uses server.id as key
1632
+ * // or
1633
+ * mastra.addMCPServer(newServer, 'customKey'); // Uses custom key
1634
+ * ```
1635
+ */
1636
+ addMCPServer(server, key) {
1637
+ if (key) {
1638
+ server.setId(key);
1639
+ }
1640
+ const resolvedId = server.id;
1641
+ if (!resolvedId) {
1642
+ const error = new MastraError({
1643
+ id: "MASTRA_ADD_MCP_SERVER_MISSING_ID",
1644
+ domain: "MASTRA" /* MASTRA */,
1645
+ category: "USER" /* USER */,
1646
+ text: "MCP server must expose an id or be registered under one",
1647
+ details: { status: 400 }
1648
+ });
1649
+ this.#logger?.trackException(error);
1650
+ throw error;
1651
+ }
1652
+ const serverKey = key ?? resolvedId;
1653
+ const servers = this.#mcpServers;
1654
+ if (servers[serverKey]) {
1655
+ const logger = this.getLogger();
1656
+ logger.debug(`MCP server with key ${serverKey} already exists. Skipping addition.`);
1657
+ return;
1658
+ }
1659
+ server.__registerMastra(this);
1660
+ server.__setLogger(this.getLogger());
1661
+ servers[serverKey] = server;
1662
+ }
1663
+ /**
1664
+ * Retrieves a specific MCP server instance by registration key.
1665
+ *
1666
+ * @throws {MastraError} When the specified MCP server is not found
1667
+ *
1668
+ * @example
1669
+ * ```typescript
1670
+ * const mastra = new Mastra({
1671
+ * mcpServers: {
1672
+ * filesystem: new FileSystemMCPServer({...})
1673
+ * }
1674
+ * });
1675
+ *
1676
+ * const fsServer = mastra.getMCPServer('filesystem');
1677
+ * const tools = await fsServer.listTools();
1678
+ * ```
1679
+ */
1680
+ getMCPServer(name) {
1681
+ if (!this.#mcpServers || !this.#mcpServers[name]) {
1682
+ this.#logger?.debug(`MCP server with name ${String(name)} not found`);
1683
+ return void 0;
1684
+ }
1685
+ return this.#mcpServers[name];
1686
+ }
1512
1687
  /**
1513
1688
  * Retrieves a specific Model Context Protocol (MCP) server instance by its logical ID.
1514
1689
  *
@@ -1528,24 +1703,24 @@ do:
1528
1703
  * }
1529
1704
  * });
1530
1705
  *
1531
- * const fsServer = mastra.getMCPServer('fs-server');
1706
+ * const fsServer = mastra.getMCPServerById('fs-server');
1532
1707
  * if (fsServer) {
1533
- * const tools = await fsServer.getTools();
1708
+ * const tools = await fsServer.listTools();
1534
1709
  * }
1535
1710
  * ```
1536
1711
  */
1537
- getMCPServer(serverId, version) {
1712
+ getMCPServerById(serverId, version) {
1538
1713
  if (!this.#mcpServers) {
1539
1714
  return void 0;
1540
1715
  }
1541
1716
  const allRegisteredServers = Object.values(this.#mcpServers || {});
1542
- const matchingLogicalIdServers = allRegisteredServers.filter(server => server.id === serverId);
1717
+ const matchingLogicalIdServers = allRegisteredServers.filter((server) => server.id === serverId);
1543
1718
  if (matchingLogicalIdServers.length === 0) {
1544
1719
  this.#logger?.debug(`No MCP servers found with logical ID: ${serverId}`);
1545
1720
  return void 0;
1546
1721
  }
1547
1722
  if (version) {
1548
- const specificVersionServer = matchingLogicalIdServers.find(server => server.version === version);
1723
+ const specificVersionServer = matchingLogicalIdServers.find((server) => server.version === version);
1549
1724
  if (!specificVersionServer) {
1550
1725
  this.#logger?.debug(`MCP server with logical ID '${serverId}' found, but not version '${version}'.`);
1551
1726
  }
@@ -1568,7 +1743,9 @@ do:
1568
1743
  return latestServer;
1569
1744
  }
1570
1745
  }
1571
- this.#logger?.warn(`Could not determine the latest server for logical ID '${serverId}' due to invalid or missing release dates, or no servers left after filtering.`);
1746
+ this.#logger?.warn(
1747
+ `Could not determine the latest server for logical ID '${serverId}' due to invalid or missing release dates, or no servers left after filtering.`
1748
+ );
1572
1749
  return void 0;
1573
1750
  }
1574
1751
  }
@@ -1605,7 +1782,7 @@ do:
1605
1782
  * Gracefully shuts down the Mastra instance and cleans up all resources.
1606
1783
  *
1607
1784
  * This method performs a clean shutdown of all Mastra components, including:
1608
- * - AI tracing registry and all tracing instances
1785
+ * - tracing registry and all tracing instances
1609
1786
  * - Event engine and pub/sub system
1610
1787
  * - All registered components and their resources
1611
1788
  *
@@ -1627,8 +1804,8 @@ do:
1627
1804
  * ```
1628
1805
  */
1629
1806
  async shutdown() {
1630
- await shutdownAITracingRegistry();
1631
1807
  await this.stopEventEngine();
1808
+ await this.#observability.shutdown();
1632
1809
  this.#logger?.info("Mastra shutdown completed");
1633
1810
  }
1634
1811
  // This method is only used internally for server hnadlers that require temporary persistence
@@ -1636,13 +1813,7 @@ do:
1636
1813
  return this.#serverCache;
1637
1814
  }
1638
1815
  };
1639
- Mastra = /*@__PURE__*/(_ => {
1640
- _init = __decoratorStart(null);
1641
- Mastra = __decorateElement(_init, 0, "Mastra", _Mastra_decorators, Mastra);
1642
- __runInitializers(_init, 1, Mastra);
1643
- return Mastra;
1644
- })();
1645
1816
 
1646
1817
  export { Mastra };
1647
- //# sourceMappingURL=chunk-BWGXM3D4.js.map
1648
- //# sourceMappingURL=chunk-BWGXM3D4.js.map
1818
+ //# sourceMappingURL=chunk-VOQ3ULMT.js.map
1819
+ //# sourceMappingURL=chunk-VOQ3ULMT.js.map