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

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 (374) hide show
  1. package/CHANGELOG.md +472 -0
  2. package/dist/agent/agent-legacy.d.ts.map +1 -1
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/index.cjs +11 -11
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/index.cjs +3 -3
  7. package/dist/agent/message-list/index.d.ts +1 -1
  8. package/dist/agent/message-list/index.d.ts.map +1 -1
  9. package/dist/agent/message-list/index.js +1 -1
  10. package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
  11. package/dist/agent/utils.d.ts.map +1 -1
  12. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  13. package/dist/{chunk-DBW6S25C.cjs → chunk-33VDGXRH.cjs} +83 -65
  14. package/dist/chunk-33VDGXRH.cjs.map +1 -0
  15. package/dist/chunk-37YWZMBX.js +27 -0
  16. package/dist/chunk-37YWZMBX.js.map +1 -0
  17. package/dist/chunk-3ZRMVPQA.cjs +263 -0
  18. package/dist/chunk-3ZRMVPQA.cjs.map +1 -0
  19. package/dist/{chunk-VZJOEGQA.js → chunk-4DFWV4IR.js} +2 -2
  20. package/dist/chunk-4DFWV4IR.js.map +1 -0
  21. package/dist/{chunk-53SZJCBX.cjs → chunk-4KVIXN7K.cjs} +24 -24
  22. package/dist/{chunk-53SZJCBX.cjs.map → chunk-4KVIXN7K.cjs.map} +1 -1
  23. package/dist/{chunk-QDVYP2T7.js → chunk-4N6WB4EZ.js} +7 -7
  24. package/dist/{chunk-QDVYP2T7.js.map → chunk-4N6WB4EZ.js.map} +1 -1
  25. package/dist/{chunk-HWMMIRIF.cjs → chunk-4U7ZLI36.cjs} +3 -2
  26. package/dist/chunk-4U7ZLI36.cjs.map +1 -0
  27. package/dist/{chunk-O5BQBZEF.cjs → chunk-4UH5LAF5.cjs} +28 -28
  28. package/dist/{chunk-O5BQBZEF.cjs.map → chunk-4UH5LAF5.cjs.map} +1 -1
  29. package/dist/{chunk-JAGQZZ43.cjs → chunk-5DL6Y7PJ.cjs} +696 -352
  30. package/dist/chunk-5DL6Y7PJ.cjs.map +1 -0
  31. package/dist/{chunk-Z55SJVEC.cjs → chunk-6YUHA5UH.cjs} +7 -6
  32. package/dist/chunk-6YUHA5UH.cjs.map +1 -0
  33. package/dist/{chunk-TRUNX3AX.cjs → chunk-7KL2YFFK.cjs} +31 -31
  34. package/dist/chunk-7KL2YFFK.cjs.map +1 -0
  35. package/dist/{chunk-6CG7IY57.cjs → chunk-A6JNGJIU.cjs} +325 -164
  36. package/dist/chunk-A6JNGJIU.cjs.map +1 -0
  37. package/dist/{chunk-EGHGFLL3.cjs → chunk-AAX7ZOM7.cjs} +2 -2
  38. package/dist/chunk-AAX7ZOM7.cjs.map +1 -0
  39. package/dist/{chunk-O3ULBGV6.cjs → chunk-AQ22JIR7.cjs} +43 -21
  40. package/dist/chunk-AQ22JIR7.cjs.map +1 -0
  41. package/dist/chunk-CSCTVLD5.js +598 -0
  42. package/dist/chunk-CSCTVLD5.js.map +1 -0
  43. package/dist/chunk-DMX7MC4N.js +3 -0
  44. package/dist/{chunk-GXSERFAG.js.map → chunk-DMX7MC4N.js.map} +1 -1
  45. package/dist/{chunk-AYBJ5GAD.js → chunk-DT5RMENY.js} +302 -136
  46. package/dist/chunk-DT5RMENY.js.map +1 -0
  47. package/dist/{chunk-72E3YF6A.cjs → chunk-EMLEZXTQ.cjs} +15 -12
  48. package/dist/chunk-EMLEZXTQ.cjs.map +1 -0
  49. package/dist/{chunk-QF4MHFSU.js → chunk-F7PAZAGE.js} +530 -191
  50. package/dist/chunk-F7PAZAGE.js.map +1 -0
  51. package/dist/{chunk-LDXKZYOV.js → chunk-FB5QMTJJ.js} +30 -8
  52. package/dist/chunk-FB5QMTJJ.js.map +1 -0
  53. package/dist/{chunk-YPLZDWG7.js → chunk-FJEVLHJT.js} +3 -2
  54. package/dist/chunk-FJEVLHJT.js.map +1 -0
  55. package/dist/{chunk-GBQXIVL6.js → chunk-GNUITL2N.js} +801 -1240
  56. package/dist/chunk-GNUITL2N.js.map +1 -0
  57. package/dist/chunk-H2NHG7QL.cjs +32 -0
  58. package/dist/chunk-H2NHG7QL.cjs.map +1 -0
  59. package/dist/chunk-J4SXS7KN.js +259 -0
  60. package/dist/chunk-J4SXS7KN.js.map +1 -0
  61. package/dist/{chunk-Y36Y5MTD.js → chunk-JQM64OZF.js} +13 -3
  62. package/dist/chunk-JQM64OZF.js.map +1 -0
  63. package/dist/{chunk-67LM2UCT.js → chunk-K4XAKG7L.js} +5 -5
  64. package/dist/{chunk-67LM2UCT.js.map → chunk-K4XAKG7L.js.map} +1 -1
  65. package/dist/{chunk-4CMIJQF6.js → chunk-KKYAYRIO.js} +14 -14
  66. package/dist/chunk-KKYAYRIO.js.map +1 -0
  67. package/dist/{chunk-FPDJ4XN6.cjs → chunk-NCAMNQC3.cjs} +303 -137
  68. package/dist/chunk-NCAMNQC3.cjs.map +1 -0
  69. package/dist/chunk-NK4UN2LF.cjs +674 -0
  70. package/dist/chunk-NK4UN2LF.cjs.map +1 -0
  71. package/dist/{chunk-5UQ5TB6J.js → chunk-NNFF3URD.js} +41 -23
  72. package/dist/chunk-NNFF3URD.js.map +1 -0
  73. package/dist/{chunk-GELVUDUY.js → chunk-O7M7DR4E.js} +3 -3
  74. package/dist/{chunk-GELVUDUY.js.map → chunk-O7M7DR4E.js.map} +1 -1
  75. package/dist/chunk-OTIGV7CL.js +10215 -0
  76. package/dist/chunk-OTIGV7CL.js.map +1 -0
  77. package/dist/{chunk-ETWAR2YE.cjs → chunk-OXV6QFSV.cjs} +828 -1275
  78. package/dist/chunk-OXV6QFSV.cjs.map +1 -0
  79. package/dist/{chunk-373OC54J.js → chunk-QD776HMB.js} +7 -6
  80. package/dist/{chunk-373OC54J.js.map → chunk-QD776HMB.js.map} +1 -1
  81. package/dist/{chunk-4AT6YQKZ.js → chunk-QXL3F3T2.js} +7 -4
  82. package/dist/chunk-QXL3F3T2.js.map +1 -0
  83. package/dist/chunk-RMV5HJM7.cjs +10237 -0
  84. package/dist/chunk-RMV5HJM7.cjs.map +1 -0
  85. package/dist/chunk-ROOVGRNA.cjs +4 -0
  86. package/dist/{chunk-X4RMXTXF.cjs.map → chunk-ROOVGRNA.cjs.map} +1 -1
  87. package/dist/{chunk-OOUFPYSX.cjs → chunk-SSB4AVHU.cjs} +17 -17
  88. package/dist/{chunk-OOUFPYSX.cjs.map → chunk-SSB4AVHU.cjs.map} +1 -1
  89. package/dist/{chunk-TDM43G4I.cjs → chunk-UT6MASE5.cjs} +9 -9
  90. package/dist/{chunk-TDM43G4I.cjs.map → chunk-UT6MASE5.cjs.map} +1 -1
  91. package/dist/{chunk-3IP3DZ7G.js → chunk-UTMBASR5.js} +291 -130
  92. package/dist/chunk-UTMBASR5.js.map +1 -0
  93. package/dist/{chunk-SLBWA2F3.js → chunk-WDXYPI3P.js} +3 -3
  94. package/dist/{chunk-SLBWA2F3.js.map → chunk-WDXYPI3P.js.map} +1 -1
  95. package/dist/{chunk-72YCRTEX.cjs → chunk-ZSZOYPSJ.cjs} +13 -2
  96. package/dist/chunk-ZSZOYPSJ.cjs.map +1 -0
  97. package/dist/error/index.cjs +6 -6
  98. package/dist/error/index.d.ts +1 -0
  99. package/dist/error/index.d.ts.map +1 -1
  100. package/dist/error/index.js +1 -1
  101. package/dist/evals/index.cjs +49 -9
  102. package/dist/evals/index.js +2 -2
  103. package/dist/evals/scoreTraces/index.cjs +70 -22
  104. package/dist/evals/scoreTraces/index.cjs.map +1 -1
  105. package/dist/evals/scoreTraces/index.js +63 -15
  106. package/dist/evals/scoreTraces/index.js.map +1 -1
  107. package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
  108. package/dist/evals/scoreTraces/utils.d.ts.map +1 -1
  109. package/dist/evals/types.d.ts +566 -116
  110. package/dist/evals/types.d.ts.map +1 -1
  111. package/dist/index.cjs +2 -2
  112. package/dist/index.js +1 -1
  113. package/dist/integration/index.cjs +2 -2
  114. package/dist/integration/index.js +1 -1
  115. package/dist/llm/index.cjs +20 -20
  116. package/dist/llm/index.js +4 -4
  117. package/dist/llm/model/aisdk/v6/model.d.ts +1 -9
  118. package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
  119. package/dist/llm/model/embedding-router.d.ts +1 -1
  120. package/dist/llm/model/model.d.ts.map +1 -1
  121. package/dist/llm/model/model.loop.d.ts.map +1 -1
  122. package/dist/llm/model/provider-options.d.ts +2 -1
  123. package/dist/llm/model/provider-options.d.ts.map +1 -1
  124. package/dist/llm/model/provider-types.generated.d.ts +129 -58
  125. package/dist/loop/index.cjs +2 -2
  126. package/dist/loop/index.js +1 -1
  127. package/dist/loop/network/index.d.ts +6 -6
  128. package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts +1 -9
  129. package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts.map +1 -1
  130. package/dist/loop/types.d.ts +5 -2
  131. package/dist/loop/types.d.ts.map +1 -1
  132. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  133. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +1 -1
  134. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  135. package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
  136. package/dist/mastra/hooks.d.ts.map +1 -1
  137. package/dist/mastra/index.cjs +2 -2
  138. package/dist/mastra/index.d.ts +7 -2
  139. package/dist/mastra/index.d.ts.map +1 -1
  140. package/dist/mastra/index.js +1 -1
  141. package/dist/mcp/index.cjs +7 -4
  142. package/dist/mcp/index.cjs.map +1 -1
  143. package/dist/mcp/index.d.ts +2 -0
  144. package/dist/mcp/index.d.ts.map +1 -1
  145. package/dist/mcp/index.js +4 -1
  146. package/dist/mcp/index.js.map +1 -1
  147. package/dist/mcp/types.d.ts +2 -0
  148. package/dist/mcp/types.d.ts.map +1 -1
  149. package/dist/memory/index.cjs +26 -6
  150. package/dist/memory/index.d.ts +1 -0
  151. package/dist/memory/index.d.ts.map +1 -1
  152. package/dist/memory/index.js +1 -1
  153. package/dist/memory/memory.d.ts +9 -8
  154. package/dist/memory/memory.d.ts.map +1 -1
  155. package/dist/memory/mock.d.ts +2 -1
  156. package/dist/memory/mock.d.ts.map +1 -1
  157. package/dist/memory/types.d.ts +3 -4
  158. package/dist/memory/types.d.ts.map +1 -1
  159. package/dist/memory/working-memory-utils.d.ts +20 -0
  160. package/dist/memory/working-memory-utils.d.ts.map +1 -0
  161. package/dist/models-dev-26XLUKVK.cjs +12 -0
  162. package/dist/{models-dev-PPS7X4JM.cjs.map → models-dev-26XLUKVK.cjs.map} +1 -1
  163. package/dist/models-dev-HUFLQFPB.js +3 -0
  164. package/dist/{models-dev-E3WWI7VA.js.map → models-dev-HUFLQFPB.js.map} +1 -1
  165. package/dist/netlify-3MHHJG2E.js +3 -0
  166. package/dist/{netlify-TY656UYF.js.map → netlify-3MHHJG2E.js.map} +1 -1
  167. package/dist/netlify-5Y33S7WL.cjs +12 -0
  168. package/dist/{netlify-VZFM5UH3.cjs.map → netlify-5Y33S7WL.cjs.map} +1 -1
  169. package/dist/observability/index.cjs +14 -10
  170. package/dist/observability/index.js +1 -1
  171. package/dist/observability/types/tracing.d.ts +34 -20
  172. package/dist/observability/types/tracing.d.ts.map +1 -1
  173. package/dist/processors/index.cjs +37 -37
  174. package/dist/processors/index.d.ts +2 -0
  175. package/dist/processors/index.d.ts.map +1 -1
  176. package/dist/processors/index.js +1 -1
  177. package/dist/processors/memory/message-history.d.ts +7 -1
  178. package/dist/processors/memory/message-history.d.ts.map +1 -1
  179. package/dist/processors/processors/language-detector.d.ts.map +1 -1
  180. package/dist/processors/processors/moderation.d.ts.map +1 -1
  181. package/dist/processors/processors/pii-detector.d.ts.map +1 -1
  182. package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
  183. package/dist/processors/processors/structured-output.d.ts +1 -0
  184. package/dist/processors/processors/structured-output.d.ts.map +1 -1
  185. package/dist/processors/processors/token-limiter.d.ts +5 -2
  186. package/dist/processors/processors/token-limiter.d.ts.map +1 -1
  187. package/dist/processors/runner.d.ts +2 -0
  188. package/dist/processors/runner.d.ts.map +1 -1
  189. package/dist/provider-registry-LXSWMVEC.js +3 -0
  190. package/dist/{provider-registry-NXVD764B.js.map → provider-registry-LXSWMVEC.js.map} +1 -1
  191. package/dist/provider-registry-YJ2P5YY5.cjs +40 -0
  192. package/dist/{provider-registry-ZIWSEUQE.cjs.map → provider-registry-YJ2P5YY5.cjs.map} +1 -1
  193. package/dist/provider-registry.json +298 -132
  194. package/dist/relevance/index.cjs +3 -3
  195. package/dist/relevance/index.js +1 -1
  196. package/dist/server/index.cjs +5 -5
  197. package/dist/server/index.js +1 -1
  198. package/dist/server/types.d.ts +28 -0
  199. package/dist/server/types.d.ts.map +1 -1
  200. package/dist/storage/base.d.ts +95 -300
  201. package/dist/storage/base.d.ts.map +1 -1
  202. package/dist/storage/constants.cjs +60 -0
  203. package/dist/storage/constants.cjs.map +1 -0
  204. package/dist/storage/constants.d.ts +6 -1
  205. package/dist/storage/constants.d.ts.map +1 -1
  206. package/dist/storage/constants.js +3 -0
  207. package/dist/storage/constants.js.map +1 -0
  208. package/dist/storage/domains/agents/base.d.ts +2 -2
  209. package/dist/storage/domains/agents/base.d.ts.map +1 -1
  210. package/dist/storage/domains/agents/inmemory.d.ts +5 -4
  211. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  212. package/dist/storage/domains/base.d.ts +20 -0
  213. package/dist/storage/domains/base.d.ts.map +1 -0
  214. package/dist/storage/domains/index.d.ts +3 -0
  215. package/dist/storage/domains/index.d.ts.map +1 -1
  216. package/dist/storage/domains/inmemory-db.d.ts +57 -0
  217. package/dist/storage/domains/inmemory-db.d.ts.map +1 -0
  218. package/dist/storage/domains/memory/base.d.ts +2 -2
  219. package/dist/storage/domains/memory/base.d.ts.map +1 -1
  220. package/dist/storage/domains/memory/inmemory.d.ts +5 -13
  221. package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
  222. package/dist/storage/domains/observability/base.d.ts +24 -29
  223. package/dist/storage/domains/observability/base.d.ts.map +1 -1
  224. package/dist/storage/domains/observability/index.d.ts +1 -0
  225. package/dist/storage/domains/observability/index.d.ts.map +1 -1
  226. package/dist/storage/domains/observability/inmemory.d.ts +46 -35
  227. package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
  228. package/dist/storage/domains/observability/types.d.ts +2365 -0
  229. package/dist/storage/domains/observability/types.d.ts.map +1 -0
  230. package/dist/storage/domains/scores/base.d.ts +9 -20
  231. package/dist/storage/domains/scores/base.d.ts.map +1 -1
  232. package/dist/storage/domains/scores/inmemory.d.ts +11 -22
  233. package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
  234. package/dist/storage/domains/shared.d.ts +76 -0
  235. package/dist/storage/domains/shared.d.ts.map +1 -0
  236. package/dist/storage/domains/workflows/base.d.ts +4 -2
  237. package/dist/storage/domains/workflows/base.d.ts.map +1 -1
  238. package/dist/storage/domains/workflows/inmemory.d.ts +10 -9
  239. package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
  240. package/dist/storage/index.cjs +272 -59
  241. package/dist/storage/index.js +2 -1
  242. package/dist/storage/mock.d.ts +26 -174
  243. package/dist/storage/mock.d.ts.map +1 -1
  244. package/dist/storage/types.d.ts +15 -44
  245. package/dist/storage/types.d.ts.map +1 -1
  246. package/dist/storage/utils.d.ts +5 -0
  247. package/dist/storage/utils.d.ts.map +1 -1
  248. package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
  249. package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
  250. package/dist/stream/MastraWorkflowStream.d.ts +1 -1
  251. package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
  252. package/dist/stream/RunOutput.d.ts.map +1 -1
  253. package/dist/stream/aisdk/v5/compat/consume-stream.d.ts +4 -1
  254. package/dist/stream/aisdk/v5/compat/consume-stream.d.ts.map +1 -1
  255. package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
  256. package/dist/stream/base/output.d.ts.map +1 -1
  257. package/dist/stream/index.cjs +12 -12
  258. package/dist/stream/index.js +2 -2
  259. package/dist/stream/types.d.ts +3 -0
  260. package/dist/stream/types.d.ts.map +1 -1
  261. package/dist/test-utils/llm-mock.cjs +4 -4
  262. package/dist/test-utils/llm-mock.js +1 -1
  263. package/dist/tool-loop-agent/index.cjs +20 -0
  264. package/dist/tool-loop-agent/index.cjs.map +1 -0
  265. package/dist/tool-loop-agent/index.d.ts +36 -0
  266. package/dist/tool-loop-agent/index.d.ts.map +1 -0
  267. package/dist/tool-loop-agent/index.js +3 -0
  268. package/dist/tool-loop-agent/index.js.map +1 -0
  269. package/dist/tool-loop-agent/tool-loop-processor.d.ts +30 -0
  270. package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +1 -0
  271. package/dist/tool-loop-agent/utils.d.ts +17 -0
  272. package/dist/tool-loop-agent/utils.d.ts.map +1 -0
  273. package/dist/tools/index.cjs +4 -4
  274. package/dist/tools/index.d.ts +1 -0
  275. package/dist/tools/index.d.ts.map +1 -1
  276. package/dist/tools/index.js +1 -1
  277. package/dist/tools/is-vercel-tool.cjs +2 -2
  278. package/dist/tools/is-vercel-tool.js +1 -1
  279. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  280. package/dist/tools/tool.d.ts +4 -4
  281. package/dist/tools/tool.d.ts.map +1 -1
  282. package/dist/tools/toolchecks.d.ts +1 -1
  283. package/dist/tools/toolchecks.d.ts.map +1 -1
  284. package/dist/tools/types.d.ts +3 -1
  285. package/dist/tools/types.d.ts.map +1 -1
  286. package/dist/tools/validation.d.ts +1 -1
  287. package/dist/tools/validation.d.ts.map +1 -1
  288. package/dist/utils/zod-utils.d.ts +34 -0
  289. package/dist/utils/zod-utils.d.ts.map +1 -0
  290. package/dist/utils.cjs +39 -22
  291. package/dist/utils.d.ts +1 -1
  292. package/dist/utils.d.ts.map +1 -1
  293. package/dist/utils.js +2 -1
  294. package/dist/vector/index.cjs +12 -5299
  295. package/dist/vector/index.cjs.map +1 -1
  296. package/dist/vector/index.js +3 -5274
  297. package/dist/vector/index.js.map +1 -1
  298. package/dist/vector/vector.d.ts +13 -3
  299. package/dist/vector/vector.d.ts.map +1 -1
  300. package/dist/voice/index.cjs +6 -6
  301. package/dist/voice/index.js +1 -1
  302. package/dist/workflows/default.d.ts +2 -0
  303. package/dist/workflows/default.d.ts.map +1 -1
  304. package/dist/workflows/evented/execution-engine.d.ts +1 -0
  305. package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
  306. package/dist/workflows/evented/index.cjs +10 -10
  307. package/dist/workflows/evented/index.js +1 -1
  308. package/dist/workflows/evented/step-executor.d.ts +1 -0
  309. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  310. package/dist/workflows/evented/workflow-event-processor/index.d.ts +5 -4
  311. package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
  312. package/dist/workflows/evented/workflow-event-processor/loop.d.ts +2 -2
  313. package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
  314. package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
  315. package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
  316. package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
  317. package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
  318. package/dist/workflows/evented/workflow.d.ts +5 -2
  319. package/dist/workflows/evented/workflow.d.ts.map +1 -1
  320. package/dist/workflows/execution-engine.d.ts +1 -0
  321. package/dist/workflows/execution-engine.d.ts.map +1 -1
  322. package/dist/workflows/handlers/control-flow.d.ts +4 -0
  323. package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
  324. package/dist/workflows/handlers/entry.d.ts +3 -2
  325. package/dist/workflows/handlers/entry.d.ts.map +1 -1
  326. package/dist/workflows/handlers/step.d.ts +1 -0
  327. package/dist/workflows/handlers/step.d.ts.map +1 -1
  328. package/dist/workflows/index.cjs +23 -23
  329. package/dist/workflows/index.js +1 -1
  330. package/dist/workflows/types.d.ts +23 -3
  331. package/dist/workflows/types.d.ts.map +1 -1
  332. package/dist/workflows/utils.d.ts +1 -0
  333. package/dist/workflows/utils.d.ts.map +1 -1
  334. package/dist/workflows/workflow.d.ts +22 -8
  335. package/dist/workflows/workflow.d.ts.map +1 -1
  336. package/package.json +15 -5
  337. package/src/llm/model/provider-types.generated.d.ts +129 -58
  338. package/storage/constants.d.ts +1 -0
  339. package/tool-loop-agent.d.ts +1 -0
  340. package/dist/chunk-3IP3DZ7G.js.map +0 -1
  341. package/dist/chunk-4AT6YQKZ.js.map +0 -1
  342. package/dist/chunk-4CMIJQF6.js.map +0 -1
  343. package/dist/chunk-5UQ5TB6J.js.map +0 -1
  344. package/dist/chunk-6CG7IY57.cjs.map +0 -1
  345. package/dist/chunk-72E3YF6A.cjs.map +0 -1
  346. package/dist/chunk-72YCRTEX.cjs.map +0 -1
  347. package/dist/chunk-ADADLFDR.js +0 -42
  348. package/dist/chunk-ADADLFDR.js.map +0 -1
  349. package/dist/chunk-AYBJ5GAD.js.map +0 -1
  350. package/dist/chunk-DBW6S25C.cjs.map +0 -1
  351. package/dist/chunk-EGHGFLL3.cjs.map +0 -1
  352. package/dist/chunk-ETWAR2YE.cjs.map +0 -1
  353. package/dist/chunk-FPDJ4XN6.cjs.map +0 -1
  354. package/dist/chunk-GBQXIVL6.js.map +0 -1
  355. package/dist/chunk-GXSERFAG.js +0 -3
  356. package/dist/chunk-HWMMIRIF.cjs.map +0 -1
  357. package/dist/chunk-JAGQZZ43.cjs.map +0 -1
  358. package/dist/chunk-LDXKZYOV.js.map +0 -1
  359. package/dist/chunk-O3ULBGV6.cjs.map +0 -1
  360. package/dist/chunk-QF4MHFSU.js.map +0 -1
  361. package/dist/chunk-T2VLUFGG.cjs +0 -47
  362. package/dist/chunk-T2VLUFGG.cjs.map +0 -1
  363. package/dist/chunk-TRUNX3AX.cjs.map +0 -1
  364. package/dist/chunk-VZJOEGQA.js.map +0 -1
  365. package/dist/chunk-X4RMXTXF.cjs +0 -4
  366. package/dist/chunk-Y36Y5MTD.js.map +0 -1
  367. package/dist/chunk-YPLZDWG7.js.map +0 -1
  368. package/dist/chunk-Z55SJVEC.cjs.map +0 -1
  369. package/dist/models-dev-E3WWI7VA.js +0 -3
  370. package/dist/models-dev-PPS7X4JM.cjs +0 -12
  371. package/dist/netlify-TY656UYF.js +0 -3
  372. package/dist/netlify-VZFM5UH3.cjs +0 -12
  373. package/dist/provider-registry-NXVD764B.js +0 -3
  374. package/dist/provider-registry-ZIWSEUQE.cjs +0 -40
@@ -1,188 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunk72E3YF6A_cjs = require('./chunk-72E3YF6A.cjs');
4
- var chunkHWMMIRIF_cjs = require('./chunk-HWMMIRIF.cjs');
3
+ var chunkEMLEZXTQ_cjs = require('./chunk-EMLEZXTQ.cjs');
4
+ var chunkNK4UN2LF_cjs = require('./chunk-NK4UN2LF.cjs');
5
+ var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
5
6
  var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
6
7
 
7
- // src/storage/constants.ts
8
- var TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
9
- var TABLE_MESSAGES = "mastra_messages";
10
- var TABLE_THREADS = "mastra_threads";
11
- var TABLE_TRACES = "mastra_traces";
12
- var TABLE_RESOURCES = "mastra_resources";
13
- var TABLE_SCORERS = "mastra_scorers";
14
- var TABLE_SPANS = "mastra_ai_spans";
15
- var TABLE_AGENTS = "mastra_agents";
16
- var SCORERS_SCHEMA = {
17
- id: { type: "text", nullable: false, primaryKey: true },
18
- scorerId: { type: "text" },
19
- traceId: { type: "text", nullable: true },
20
- spanId: { type: "text", nullable: true },
21
- runId: { type: "text" },
22
- scorer: { type: "jsonb" },
23
- preprocessStepResult: { type: "jsonb", nullable: true },
24
- extractStepResult: { type: "jsonb", nullable: true },
25
- analyzeStepResult: { type: "jsonb", nullable: true },
26
- score: { type: "float" },
27
- reason: { type: "text", nullable: true },
28
- metadata: { type: "jsonb", nullable: true },
29
- preprocessPrompt: { type: "text", nullable: true },
30
- extractPrompt: { type: "text", nullable: true },
31
- generateScorePrompt: { type: "text", nullable: true },
32
- generateReasonPrompt: { type: "text", nullable: true },
33
- analyzePrompt: { type: "text", nullable: true },
34
- // Deprecated
35
- reasonPrompt: { type: "text", nullable: true },
36
- input: { type: "jsonb" },
37
- output: { type: "jsonb" },
38
- // MESSAGE OUTPUT
39
- additionalContext: { type: "jsonb", nullable: true },
40
- // DATA FROM THE CONTEXT PARAM ON AN AGENT
41
- requestContext: { type: "jsonb", nullable: true },
42
- // THE EVALUATE Request Context FOR THE RUN
43
- /**
44
- * Things you can evaluate
45
- */
46
- entityType: { type: "text", nullable: true },
47
- // WORKFLOW, AGENT, TOOL, STEP, NETWORK
48
- entity: { type: "jsonb", nullable: true },
49
- // MINIMAL JSON DATA ABOUT WORKFLOW, AGENT, TOOL, STEP, NETWORK
50
- entityId: { type: "text", nullable: true },
51
- source: { type: "text" },
52
- resourceId: { type: "text", nullable: true },
53
- threadId: { type: "text", nullable: true },
54
- createdAt: { type: "timestamp" },
55
- updatedAt: { type: "timestamp" }
56
- };
57
- var SPAN_SCHEMA = {
58
- // Composite primary key of traceId and spanId
59
- traceId: { type: "text", nullable: false },
60
- spanId: { type: "text", nullable: false },
61
- parentSpanId: { type: "text", nullable: true },
62
- name: { type: "text", nullable: false },
63
- scope: { type: "jsonb", nullable: true },
64
- // Mastra package info {"core-version": "0.1.0"}
65
- spanType: { type: "text", nullable: false },
66
- // WORKFLOW_RUN, WORKFLOW_STEP, AGENT_RUN, AGENT_STEP, TOOL_RUN, TOOL_STEP, etc.
67
- attributes: { type: "jsonb", nullable: true },
68
- metadata: { type: "jsonb", nullable: true },
69
- links: { type: "jsonb", nullable: true },
70
- input: { type: "jsonb", nullable: true },
71
- output: { type: "jsonb", nullable: true },
72
- error: { type: "jsonb", nullable: true },
73
- startedAt: { type: "timestamp", nullable: false },
74
- // When the span started
75
- endedAt: { type: "timestamp", nullable: true },
76
- // When the span ended
77
- createdAt: { type: "timestamp", nullable: false },
78
- // The time the database record was created
79
- updatedAt: { type: "timestamp", nullable: true },
80
- // The time the database record was last updated
81
- isEvent: { type: "boolean", nullable: false }
82
- };
83
- var AGENTS_SCHEMA = {
84
- id: { type: "text", nullable: false, primaryKey: true },
85
- name: { type: "text", nullable: false },
86
- description: { type: "text", nullable: true },
87
- instructions: { type: "text", nullable: false },
88
- // System instructions for the agent
89
- model: { type: "jsonb", nullable: false },
90
- // Model configuration (provider, name, etc.)
91
- tools: { type: "jsonb", nullable: true },
92
- // Serialized tool references/configurations
93
- defaultOptions: { type: "jsonb", nullable: true },
94
- // Default options for generate/stream calls
95
- workflows: { type: "jsonb", nullable: true },
96
- // Workflow references (IDs or configurations)
97
- agents: { type: "jsonb", nullable: true },
98
- // Sub-agent references (IDs or configurations)
99
- inputProcessors: { type: "jsonb", nullable: true },
100
- // Input processor configurations
101
- outputProcessors: { type: "jsonb", nullable: true },
102
- // Output processor configurations
103
- memory: { type: "jsonb", nullable: true },
104
- // Memory configuration
105
- scorers: { type: "jsonb", nullable: true },
106
- // Scorer configurations
107
- metadata: { type: "jsonb", nullable: true },
108
- // Additional metadata for the agent
109
- createdAt: { type: "timestamp", nullable: false },
110
- updatedAt: { type: "timestamp", nullable: false }
111
- };
112
- var TABLE_SCHEMAS = {
113
- [TABLE_WORKFLOW_SNAPSHOT]: {
114
- workflow_name: {
115
- type: "text"
116
- },
117
- run_id: {
118
- type: "text"
119
- },
120
- resourceId: { type: "text", nullable: true },
121
- snapshot: {
122
- type: "text"
123
- },
124
- createdAt: {
125
- type: "timestamp"
126
- },
127
- updatedAt: {
128
- type: "timestamp"
129
- }
130
- },
131
- [TABLE_SCORERS]: SCORERS_SCHEMA,
132
- [TABLE_THREADS]: {
133
- id: { type: "text", nullable: false, primaryKey: true },
134
- resourceId: { type: "text", nullable: false },
135
- title: { type: "text", nullable: false },
136
- metadata: { type: "text", nullable: true },
137
- createdAt: { type: "timestamp", nullable: false },
138
- updatedAt: { type: "timestamp", nullable: false }
139
- },
140
- [TABLE_MESSAGES]: {
141
- id: { type: "text", nullable: false, primaryKey: true },
142
- thread_id: { type: "text", nullable: false },
143
- content: { type: "text", nullable: false },
144
- role: { type: "text", nullable: false },
145
- type: { type: "text", nullable: false },
146
- createdAt: { type: "timestamp", nullable: false },
147
- resourceId: { type: "text", nullable: true }
148
- },
149
- [TABLE_SPANS]: SPAN_SCHEMA,
150
- [TABLE_TRACES]: {
151
- id: { type: "text", nullable: false, primaryKey: true },
152
- parentSpanId: { type: "text", nullable: true },
153
- name: { type: "text", nullable: false },
154
- traceId: { type: "text", nullable: false },
155
- scope: { type: "text", nullable: false },
156
- kind: { type: "integer", nullable: false },
157
- attributes: { type: "jsonb", nullable: true },
158
- status: { type: "jsonb", nullable: true },
159
- events: { type: "jsonb", nullable: true },
160
- links: { type: "jsonb", nullable: true },
161
- other: { type: "text", nullable: true },
162
- startTime: { type: "bigint", nullable: false },
163
- endTime: { type: "bigint", nullable: false },
164
- createdAt: { type: "timestamp", nullable: false }
165
- },
166
- [TABLE_RESOURCES]: {
167
- id: { type: "text", nullable: false, primaryKey: true },
168
- workingMemory: { type: "text", nullable: true },
169
- metadata: { type: "jsonb", nullable: true },
170
- createdAt: { type: "timestamp", nullable: false },
171
- updatedAt: { type: "timestamp", nullable: false }
172
- },
173
- [TABLE_AGENTS]: AGENTS_SCHEMA
174
- };
175
-
176
8
  // src/storage/base.ts
177
- function ensureDate(date) {
178
- if (!date) return void 0;
179
- return date instanceof Date ? date : new Date(date);
180
- }
181
- function serializeDate(date) {
182
- if (!date) return void 0;
183
- const dateObj = ensureDate(date);
184
- return dateObj?.toISOString();
185
- }
186
9
  function normalizePerPage(perPageInput, defaultValue) {
187
10
  if (perPageInput === false) {
188
11
  return Number.MAX_SAFE_INTEGER;
@@ -206,573 +29,164 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
206
29
  stores;
207
30
  /**
208
31
  * When true, automatic initialization (table creation/migrations) is disabled.
209
- * This is useful for CI/CD pipelines where you want to:
210
- * 1. Run migrations explicitly during deployment (not at runtime)
211
- * 2. Use different credentials for schema changes vs runtime operations
212
- *
213
- * When disableInit is true:
214
- * - The storage will not automatically create/alter tables on first use
215
- * - You must call `storage.init()` explicitly in your CI/CD scripts
216
- *
217
- * @example
218
- * // In CI/CD script:
219
- * const storage = new PostgresStore({ ...config, disableInit: false });
220
- * await storage.init(); // Explicitly run migrations
221
- *
222
- * // In runtime application:
223
- * const storage = new PostgresStore({ ...config, disableInit: true });
224
- * // No auto-init, tables must already exist
225
32
  */
226
33
  disableInit = false;
227
- constructor({ id, name, disableInit }) {
228
- if (!id || typeof id !== "string" || id.trim() === "") {
34
+ constructor(config) {
35
+ const name = config.name ?? "MastraStorage";
36
+ if (!config.id || typeof config.id !== "string" || config.id.trim() === "") {
229
37
  throw new Error(`${name}: id must be provided and cannot be empty.`);
230
38
  }
231
39
  super({
232
40
  component: "STORAGE",
233
41
  name
234
42
  });
235
- this.id = id;
236
- this.disableInit = disableInit ?? false;
237
- }
238
- get supports() {
239
- return {
240
- selectByIncludeResourceScope: false,
241
- resourceWorkingMemory: false,
242
- hasColumn: false,
243
- createTable: false,
244
- deleteMessages: false,
245
- observabilityInstance: false,
246
- indexManagement: false,
247
- listScoresBySpan: false,
248
- agents: false
249
- };
250
- }
251
- ensureDate(date) {
252
- return ensureDate(date);
253
- }
254
- serializeDate(date) {
255
- return serializeDate(date);
256
- }
257
- async getResourceById(_) {
258
- throw new Error(
259
- `Resource working memory is not supported by this storage adapter (${this.constructor.name}). Supported storage adapters: LibSQL (@mastra/libsql), PostgreSQL (@mastra/pg), Upstash (@mastra/upstash). To use per-resource working memory, switch to one of these supported storage adapters.`
260
- );
261
- }
262
- async saveResource(_) {
263
- throw new Error(
264
- `Resource working memory is not supported by this storage adapter (${this.constructor.name}). Supported storage adapters: LibSQL (@mastra/libsql), PostgreSQL (@mastra/pg), Upstash (@mastra/upstash). To use per-resource working memory, switch to one of these supported storage adapters.`
265
- );
266
- }
267
- async updateResource(_) {
268
- throw new Error(
269
- `Resource working memory is not supported by this storage adapter (${this.constructor.name}). Supported storage adapters: LibSQL (@mastra/libsql), PostgreSQL (@mastra/pg), Upstash (@mastra/upstash). To use per-resource working memory, switch to one of these supported storage adapters.`
270
- );
271
- }
272
- async listMessages(args) {
273
- if (this.stores?.memory) {
274
- return this.stores.memory.listMessages(args);
275
- }
276
- throw new chunkHWMMIRIF_cjs.MastraError({
277
- id: "MASTRA_STORAGE_LIST_MESSAGES_NOT_SUPPORTED",
278
- domain: "STORAGE" /* STORAGE */,
279
- category: "SYSTEM" /* SYSTEM */,
280
- text: `Listing messages is not implemented by this storage adapter (${this.constructor.name})`
281
- });
282
- }
283
- async listWorkflowRuns(args) {
284
- if (this.stores?.workflows) {
285
- return this.stores.workflows.listWorkflowRuns(args);
286
- }
287
- throw new chunkHWMMIRIF_cjs.MastraError({
288
- id: "MASTRA_STORAGE_LIST_WORKFLOW_RUNS_NOT_SUPPORTED",
289
- domain: "STORAGE" /* STORAGE */,
290
- category: "SYSTEM" /* SYSTEM */,
291
- text: `Listing workflow runs is not implemented by this storage adapter (${this.constructor.name})`
292
- });
293
- }
294
- async listThreadsByResourceId(args) {
295
- if (this.stores?.memory) {
296
- return this.stores.memory.listThreadsByResourceId(args);
297
- }
298
- throw new chunkHWMMIRIF_cjs.MastraError({
299
- id: "MASTRA_STORAGE_LIST_THREADS_BY_RESOURCE_ID_PAGINATED_NOT_SUPPORTED",
300
- domain: "STORAGE" /* STORAGE */,
301
- category: "SYSTEM" /* SYSTEM */,
302
- text: `Listing threads by resource ID paginated is not implemented by this storage adapter (${this.constructor.name})`
303
- });
304
- }
305
- async listMessagesById({ messageIds }) {
306
- if (this.stores?.memory) {
307
- const result = await this.stores.memory.listMessagesById({ messageIds });
308
- return result;
43
+ this.id = config.id;
44
+ this.disableInit = config.disableInit ?? false;
45
+ if (config.default || config.domains) {
46
+ const defaultStores = config.default?.stores;
47
+ const domainOverrides = config.domains ?? {};
48
+ const hasDefaultDomains = defaultStores && Object.values(defaultStores).some((v) => v !== void 0);
49
+ const hasOverrideDomains = Object.values(domainOverrides).some((v) => v !== void 0);
50
+ if (!hasDefaultDomains && !hasOverrideDomains) {
51
+ throw new Error(
52
+ "MastraStorage requires at least one storage source. Provide either a default storage with domains or domain overrides."
53
+ );
54
+ }
55
+ this.stores = {
56
+ memory: domainOverrides.memory ?? defaultStores?.memory,
57
+ workflows: domainOverrides.workflows ?? defaultStores?.workflows,
58
+ scores: domainOverrides.scores ?? defaultStores?.scores,
59
+ observability: domainOverrides.observability ?? defaultStores?.observability,
60
+ agents: domainOverrides.agents ?? defaultStores?.agents
61
+ };
309
62
  }
310
- throw new chunkHWMMIRIF_cjs.MastraError({
311
- id: "MASTRA_STORAGE_LIST_MESSAGES_BY_ID_NOT_SUPPORTED",
312
- domain: "STORAGE" /* STORAGE */,
313
- category: "SYSTEM" /* SYSTEM */,
314
- text: `Listing messages by ID is not implemented by this storage adapter (${this.constructor.name})`
315
- });
316
63
  }
317
- async deleteMessages(_messageIds) {
318
- throw new Error(
319
- `Message deletion is not supported by this storage adapter (${this.constructor.name}). The deleteMessages method needs to be implemented in the storage adapter.`
320
- );
64
+ /**
65
+ * Get a domain-specific storage interface.
66
+ *
67
+ * @param storeName - The name of the domain to access ('memory', 'workflows', 'scores', 'observability', 'agents')
68
+ * @returns The domain storage interface, or undefined if not available
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const memory = await storage.getStore('memory');
73
+ * if (memory) {
74
+ * await memory.saveThread({ thread });
75
+ * }
76
+ * ```
77
+ */
78
+ async getStore(storeName) {
79
+ return this.stores?.[storeName];
321
80
  }
81
+ /**
82
+ * Initialize all domain stores.
83
+ * This creates necessary tables, indexes, and performs any required migrations.
84
+ */
322
85
  async init() {
323
86
  if (this.shouldCacheInit && await this.hasInitialized) {
324
87
  return;
325
88
  }
326
- const tableCreationTasks = [
327
- this.createTable({
328
- tableName: TABLE_WORKFLOW_SNAPSHOT,
329
- schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]
330
- }),
331
- this.createTable({
332
- tableName: TABLE_THREADS,
333
- schema: TABLE_SCHEMAS[TABLE_THREADS]
334
- }),
335
- this.createTable({
336
- tableName: TABLE_MESSAGES,
337
- schema: TABLE_SCHEMAS[TABLE_MESSAGES]
338
- }),
339
- this.createTable({
340
- tableName: TABLE_TRACES,
341
- schema: TABLE_SCHEMAS[TABLE_TRACES]
342
- }),
343
- this.createTable({
344
- tableName: TABLE_SCORERS,
345
- schema: TABLE_SCHEMAS[TABLE_SCORERS]
346
- })
347
- ];
348
- if (this.supports.resourceWorkingMemory) {
349
- tableCreationTasks.push(
350
- this.createTable({
351
- tableName: TABLE_RESOURCES,
352
- schema: TABLE_SCHEMAS[TABLE_RESOURCES]
353
- })
354
- );
355
- }
356
- if (this.supports.observabilityInstance) {
357
- tableCreationTasks.push(
358
- this.createTable({
359
- tableName: TABLE_SPANS,
360
- schema: TABLE_SCHEMAS[TABLE_SPANS]
361
- })
362
- );
89
+ const initTasks = [];
90
+ if (this.stores?.memory) {
91
+ initTasks.push(this.stores.memory.init());
363
92
  }
364
- if (this.supports.agents) {
365
- tableCreationTasks.push(
366
- this.createTable({
367
- tableName: TABLE_AGENTS,
368
- schema: TABLE_SCHEMAS[TABLE_AGENTS]
369
- })
370
- );
93
+ if (this.stores?.workflows) {
94
+ initTasks.push(this.stores.workflows.init());
371
95
  }
372
- this.hasInitialized = Promise.all(tableCreationTasks).then(() => true);
373
- await this.hasInitialized;
374
- await this?.alterTable?.({
375
- tableName: TABLE_MESSAGES,
376
- schema: TABLE_SCHEMAS[TABLE_MESSAGES],
377
- ifNotExists: ["resourceId"]
378
- });
379
- await this?.alterTable?.({
380
- tableName: TABLE_WORKFLOW_SNAPSHOT,
381
- schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT],
382
- ifNotExists: ["resourceId"]
383
- });
384
- await this?.alterTable?.({
385
- tableName: TABLE_SCORERS,
386
- schema: TABLE_SCHEMAS[TABLE_SCORERS],
387
- ifNotExists: ["spanId", "requestContext"]
388
- });
389
- }
390
- async persistWorkflowSnapshot({
391
- workflowName,
392
- runId,
393
- resourceId,
394
- snapshot
395
- }) {
396
- await this.init();
397
- const data = {
398
- workflow_name: workflowName,
399
- run_id: runId,
400
- resourceId,
401
- snapshot,
402
- createdAt: /* @__PURE__ */ new Date(),
403
- updatedAt: /* @__PURE__ */ new Date()
404
- };
405
- this.logger.debug("Persisting workflow snapshot", { workflowName, runId, data });
406
- await this.insert({
407
- tableName: TABLE_WORKFLOW_SNAPSHOT,
408
- record: data
409
- });
410
- }
411
- async loadWorkflowSnapshot({
412
- workflowName,
413
- runId
414
- }) {
415
- if (!this.hasInitialized) {
416
- await this.init();
96
+ if (this.stores?.scores) {
97
+ initTasks.push(this.stores.scores.init());
417
98
  }
418
- this.logger.debug("Loading workflow snapshot", { workflowName, runId });
419
- const d = await this.load({
420
- tableName: TABLE_WORKFLOW_SNAPSHOT,
421
- keys: { workflow_name: workflowName, run_id: runId }
422
- });
423
- return d ? d.snapshot : null;
424
- }
425
- async listScoresBySpan({
426
- traceId,
427
- spanId,
428
- pagination: _pagination
429
- }) {
430
- throw new chunkHWMMIRIF_cjs.MastraError({
431
- id: "SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED",
432
- domain: "STORAGE" /* STORAGE */,
433
- category: "SYSTEM" /* SYSTEM */,
434
- details: { traceId, spanId }
435
- });
436
- }
437
- /**
438
- * OBSERVABILITY
439
- */
440
- /**
441
- * Provides hints for tracing strategy selection by the DefaultExporter.
442
- * Storage adapters can override this to specify their preferred and supported strategies.
443
- */
444
- get tracingStrategy() {
445
99
  if (this.stores?.observability) {
446
- return this.stores.observability.tracingStrategy;
100
+ initTasks.push(this.stores.observability.init());
447
101
  }
448
- throw new chunkHWMMIRIF_cjs.MastraError({
449
- id: "MASTRA_STORAGE_TRACING_STRATEGY_NOT_SUPPORTED",
450
- domain: "STORAGE" /* STORAGE */,
451
- category: "SYSTEM" /* SYSTEM */,
452
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
453
- });
454
- }
455
- /**
456
- * Creates a single Span record in the storage provider.
457
- */
458
- async createSpan(span) {
459
- if (this.stores?.observability) {
460
- return this.stores.observability.createSpan(span);
102
+ if (this.stores?.agents) {
103
+ initTasks.push(this.stores.agents.init());
461
104
  }
462
- throw new chunkHWMMIRIF_cjs.MastraError({
463
- id: "MASTRA_STORAGE_CREATE_AI_SPAN_NOT_SUPPORTED",
464
- domain: "STORAGE" /* STORAGE */,
465
- category: "SYSTEM" /* SYSTEM */,
466
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
467
- });
105
+ this.hasInitialized = Promise.all(initTasks).then(() => true);
106
+ await this.hasInitialized;
468
107
  }
108
+ };
109
+
110
+ // src/storage/domains/base.ts
111
+ var StorageDomain = class extends chunkDGV2FWB4_cjs.MastraBase {
469
112
  /**
470
- * Updates a single Span with partial data. Primarily used for realtime trace creation.
113
+ * Initialize the storage domain.
114
+ * This should create any necessary tables/collections.
115
+ * Default implementation is a no-op - override in adapters that need initialization.
471
116
  */
472
- async updateSpan(params) {
473
- if (this.stores?.observability) {
474
- return this.stores.observability.updateSpan(params);
475
- }
476
- throw new chunkHWMMIRIF_cjs.MastraError({
477
- id: "MASTRA_STORAGE_UPDATE_AI_SPAN_NOT_SUPPORTED",
478
- domain: "STORAGE" /* STORAGE */,
479
- category: "SYSTEM" /* SYSTEM */,
480
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
481
- });
117
+ async init() {
482
118
  }
483
- /**
484
- * Retrieves a single trace with all its associated spans.
485
- */
486
- async getTrace(traceId) {
487
- if (this.stores?.observability) {
488
- return this.stores.observability.getTrace(traceId);
489
- }
490
- throw new chunkHWMMIRIF_cjs.MastraError({
491
- id: "MASTRA_STORAGE_GET_TRACE_NOT_SUPPORTED",
492
- domain: "STORAGE" /* STORAGE */,
493
- category: "SYSTEM" /* SYSTEM */,
494
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
119
+ };
120
+
121
+ // src/storage/domains/agents/base.ts
122
+ var AgentsStorage = class extends StorageDomain {
123
+ constructor() {
124
+ super({
125
+ component: "STORAGE",
126
+ name: "AGENTS"
495
127
  });
496
128
  }
497
129
  /**
498
- * Retrieves a paginated list of traces with optional filtering.
130
+ * Parses orderBy input for consistent sorting behavior.
499
131
  */
500
- async getTracesPaginated(args) {
501
- if (this.stores?.observability) {
502
- return this.stores.observability.getTracesPaginated(args);
503
- }
504
- throw new chunkHWMMIRIF_cjs.MastraError({
505
- id: "MASTRA_STORAGE_GET_TRACES_PAGINATED_NOT_SUPPORTED",
506
- domain: "STORAGE" /* STORAGE */,
507
- category: "SYSTEM" /* SYSTEM */,
508
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
509
- });
132
+ parseOrderBy(orderBy, defaultDirection = "DESC") {
133
+ return {
134
+ field: orderBy?.field && orderBy.field in AGENT_ORDER_BY_SET ? orderBy.field : "createdAt",
135
+ direction: orderBy?.direction && orderBy.direction in AGENT_SORT_DIRECTION_SET ? orderBy.direction : defaultDirection
136
+ };
510
137
  }
511
- /**
512
- * Creates multiple Spans in a single batch.
513
- */
514
- async batchCreateSpans(args) {
515
- if (this.stores?.observability) {
516
- return this.stores.observability.batchCreateSpans(args);
517
- }
518
- throw new chunkHWMMIRIF_cjs.MastraError({
519
- id: "MASTRA_STORAGE_BATCH_CREATE_AI_SPANS_NOT_SUPPORTED",
520
- domain: "STORAGE" /* STORAGE */,
521
- category: "SYSTEM" /* SYSTEM */,
522
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
523
- });
138
+ };
139
+ var AGENT_ORDER_BY_SET = {
140
+ createdAt: true,
141
+ updatedAt: true
142
+ };
143
+ var AGENT_SORT_DIRECTION_SET = {
144
+ ASC: true,
145
+ DESC: true
146
+ };
147
+
148
+ // src/storage/domains/agents/inmemory.ts
149
+ var InMemoryAgentsStorage = class extends AgentsStorage {
150
+ db;
151
+ constructor({ db }) {
152
+ super();
153
+ this.db = db;
524
154
  }
525
- /**
526
- * Updates multiple Spans in a single batch.
527
- */
528
- async batchUpdateSpans(args) {
529
- if (this.stores?.observability) {
530
- return this.stores.observability.batchUpdateSpans(args);
531
- }
532
- throw new chunkHWMMIRIF_cjs.MastraError({
533
- id: "MASTRA_STORAGE_BATCH_UPDATE_AI_SPANS_NOT_SUPPORTED",
534
- domain: "STORAGE" /* STORAGE */,
535
- category: "SYSTEM" /* SYSTEM */,
536
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
537
- });
155
+ async dangerouslyClearAll() {
156
+ this.db.agents.clear();
538
157
  }
539
- /**
540
- * Deletes multiple traces and all their associated spans in a single batch operation.
541
- */
542
- async batchDeleteTraces(args) {
543
- if (this.stores?.observability) {
544
- return this.stores.observability.batchDeleteTraces(args);
545
- }
546
- throw new chunkHWMMIRIF_cjs.MastraError({
547
- id: "MASTRA_STORAGE_BATCH_DELETE_TRACES_NOT_SUPPORTED",
548
- domain: "STORAGE" /* STORAGE */,
549
- category: "SYSTEM" /* SYSTEM */,
550
- text: `tracing is not supported by this storage adapter (${this.constructor.name})`
551
- });
158
+ async getAgentById({ id }) {
159
+ this.logger.debug(`InMemoryAgentsStorage: getAgentById called for ${id}`);
160
+ const agent = this.db.agents.get(id);
161
+ return agent ? {
162
+ ...agent,
163
+ metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
164
+ model: { ...agent.model },
165
+ tools: agent.tools ? [...agent.tools] : agent.tools,
166
+ workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
167
+ agents: agent.agents ? [...agent.agents] : agent.agents,
168
+ scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
169
+ } : null;
552
170
  }
553
- /**
554
- * DATABASE INDEX MANAGEMENT
555
- * These methods delegate to the operations store for index management.
556
- * Storage adapters that support indexes should implement these in their operations class.
557
- */
558
- /**
559
- * Creates a database index on specified columns
560
- * @throws {MastraError} if not supported by the storage adapter
561
- */
562
- async createIndex(options) {
563
- if (this.stores?.operations) {
564
- return this.stores.operations.createIndex(options);
171
+ async createAgent({ agent }) {
172
+ this.logger.debug(`InMemoryAgentsStorage: createAgent called for ${agent.id}`);
173
+ if (this.db.agents.has(agent.id)) {
174
+ throw new Error(`Agent with id ${agent.id} already exists`);
565
175
  }
566
- throw new chunkHWMMIRIF_cjs.MastraError({
567
- id: "MASTRA_STORAGE_CREATE_INDEX_NOT_SUPPORTED",
568
- domain: "STORAGE" /* STORAGE */,
569
- category: "SYSTEM" /* SYSTEM */,
570
- text: `Index management is not supported by this storage adapter (${this.constructor.name})`
571
- });
176
+ const now = /* @__PURE__ */ new Date();
177
+ const newAgent = {
178
+ ...agent,
179
+ createdAt: now,
180
+ updatedAt: now
181
+ };
182
+ this.db.agents.set(agent.id, newAgent);
183
+ return { ...newAgent };
572
184
  }
573
- /**
574
- * Drops a database index by name
575
- * @throws {MastraError} if not supported by the storage adapter
576
- */
577
- async dropIndex(indexName) {
578
- if (this.stores?.operations) {
579
- return this.stores.operations.dropIndex(indexName);
580
- }
581
- throw new chunkHWMMIRIF_cjs.MastraError({
582
- id: "MASTRA_STORAGE_DROP_INDEX_NOT_SUPPORTED",
583
- domain: "STORAGE" /* STORAGE */,
584
- category: "SYSTEM" /* SYSTEM */,
585
- text: `Index management is not supported by this storage adapter (${this.constructor.name})`
586
- });
587
- }
588
- /**
589
- * Lists database indexes for a table or all tables
590
- * @throws {MastraError} if not supported by the storage adapter
591
- */
592
- async listIndexes(tableName) {
593
- if (this.stores?.operations) {
594
- return this.stores.operations.listIndexes(tableName);
595
- }
596
- throw new chunkHWMMIRIF_cjs.MastraError({
597
- id: "MASTRA_STORAGE_LIST_INDEXES_NOT_SUPPORTED",
598
- domain: "STORAGE" /* STORAGE */,
599
- category: "SYSTEM" /* SYSTEM */,
600
- text: `Index management is not supported by this storage adapter (${this.constructor.name})`
601
- });
602
- }
603
- /**
604
- * Gets detailed statistics for a specific index
605
- * @throws {MastraError} if not supported by the storage adapter
606
- */
607
- async describeIndex(indexName) {
608
- if (this.stores?.operations) {
609
- return this.stores.operations.describeIndex(indexName);
610
- }
611
- throw new chunkHWMMIRIF_cjs.MastraError({
612
- id: "MASTRA_STORAGE_DESCRIBE_INDEX_NOT_SUPPORTED",
613
- domain: "STORAGE" /* STORAGE */,
614
- category: "SYSTEM" /* SYSTEM */,
615
- text: `Index management is not supported by this storage adapter (${this.constructor.name})`
616
- });
617
- }
618
- /**
619
- * AGENTS STORAGE
620
- * These methods delegate to the agents store for agent CRUD operations.
621
- * This enables dynamic creation of agents via Mastra Studio.
622
- */
623
- /**
624
- * Retrieves an agent by its unique identifier.
625
- * @param id - The unique identifier of the agent
626
- * @returns The agent if found, null otherwise
627
- * @throws {MastraError} if not supported by the storage adapter
628
- */
629
- async getAgentById({ id }) {
630
- if (this.stores?.agents) {
631
- return this.stores.agents.getAgentById({ id });
632
- }
633
- throw new chunkHWMMIRIF_cjs.MastraError({
634
- id: "MASTRA_STORAGE_GET_AGENT_BY_ID_NOT_SUPPORTED",
635
- domain: "STORAGE" /* STORAGE */,
636
- category: "SYSTEM" /* SYSTEM */,
637
- text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
638
- });
639
- }
640
- /**
641
- * Creates a new agent in storage.
642
- * @param agent - The agent data to create
643
- * @returns The created agent with timestamps
644
- * @throws {MastraError} if not supported by the storage adapter
645
- */
646
- async createAgent({ agent }) {
647
- if (this.stores?.agents) {
648
- return this.stores.agents.createAgent({ agent });
649
- }
650
- throw new chunkHWMMIRIF_cjs.MastraError({
651
- id: "MASTRA_STORAGE_CREATE_AGENT_NOT_SUPPORTED",
652
- domain: "STORAGE" /* STORAGE */,
653
- category: "SYSTEM" /* SYSTEM */,
654
- text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
655
- });
656
- }
657
- /**
658
- * Updates an existing agent in storage.
659
- * @param id - The unique identifier of the agent to update
660
- * @param updates - The fields to update
661
- * @returns The updated agent
662
- * @throws {MastraError} if not supported by the storage adapter
663
- */
664
- async updateAgent(args) {
665
- if (this.stores?.agents) {
666
- return this.stores.agents.updateAgent(args);
667
- }
668
- throw new chunkHWMMIRIF_cjs.MastraError({
669
- id: "MASTRA_STORAGE_UPDATE_AGENT_NOT_SUPPORTED",
670
- domain: "STORAGE" /* STORAGE */,
671
- category: "SYSTEM" /* SYSTEM */,
672
- text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
673
- });
674
- }
675
- /**
676
- * Deletes an agent from storage.
677
- * @param id - The unique identifier of the agent to delete
678
- * @throws {MastraError} if not supported by the storage adapter
679
- */
680
- async deleteAgent({ id }) {
681
- if (this.stores?.agents) {
682
- return this.stores.agents.deleteAgent({ id });
683
- }
684
- throw new chunkHWMMIRIF_cjs.MastraError({
685
- id: "MASTRA_STORAGE_DELETE_AGENT_NOT_SUPPORTED",
686
- domain: "STORAGE" /* STORAGE */,
687
- category: "SYSTEM" /* SYSTEM */,
688
- text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
689
- });
690
- }
691
- /**
692
- * Lists all agents with optional pagination.
693
- * @param args - Pagination and ordering options
694
- * @returns Paginated list of agents
695
- * @throws {MastraError} if not supported by the storage adapter
696
- */
697
- async listAgents(args) {
698
- if (this.stores?.agents) {
699
- return this.stores.agents.listAgents(args);
700
- }
701
- throw new chunkHWMMIRIF_cjs.MastraError({
702
- id: "MASTRA_STORAGE_LIST_AGENTS_NOT_SUPPORTED",
703
- domain: "STORAGE" /* STORAGE */,
704
- category: "SYSTEM" /* SYSTEM */,
705
- text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
706
- });
707
- }
708
- };
709
-
710
- // src/storage/domains/agents/base.ts
711
- var AgentsStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
712
- constructor() {
713
- super({
714
- component: "STORAGE",
715
- name: "AGENTS"
716
- });
717
- }
718
- /**
719
- * Parses orderBy input for consistent sorting behavior.
720
- */
721
- parseOrderBy(orderBy, defaultDirection = "DESC") {
722
- return {
723
- field: orderBy?.field && orderBy.field in AGENT_ORDER_BY_SET ? orderBy.field : "createdAt",
724
- direction: orderBy?.direction && orderBy.direction in AGENT_SORT_DIRECTION_SET ? orderBy.direction : defaultDirection
725
- };
726
- }
727
- };
728
- var AGENT_ORDER_BY_SET = {
729
- createdAt: true,
730
- updatedAt: true
731
- };
732
- var AGENT_SORT_DIRECTION_SET = {
733
- ASC: true,
734
- DESC: true
735
- };
736
-
737
- // src/storage/domains/agents/inmemory.ts
738
- var InMemoryAgentsStorage = class extends AgentsStorage {
739
- collection;
740
- constructor({ collection }) {
741
- super();
742
- this.collection = collection;
743
- }
744
- async getAgentById({ id }) {
745
- this.logger.debug(`InMemoryAgentsStorage: getAgentById called for ${id}`);
746
- const agent = this.collection.get(id);
747
- return agent ? {
748
- ...agent,
749
- metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
750
- model: { ...agent.model },
751
- tools: agent.tools ? [...agent.tools] : agent.tools,
752
- workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
753
- agents: agent.agents ? [...agent.agents] : agent.agents,
754
- scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
755
- } : null;
756
- }
757
- async createAgent({ agent }) {
758
- this.logger.debug(`InMemoryAgentsStorage: createAgent called for ${agent.id}`);
759
- if (this.collection.has(agent.id)) {
760
- throw new Error(`Agent with id ${agent.id} already exists`);
761
- }
762
- const now = /* @__PURE__ */ new Date();
763
- const newAgent = {
764
- ...agent,
765
- createdAt: now,
766
- updatedAt: now
767
- };
768
- this.collection.set(agent.id, newAgent);
769
- return { ...newAgent };
770
- }
771
- async updateAgent({ id, ...updates }) {
772
- this.logger.debug(`InMemoryAgentsStorage: updateAgent called for ${id}`);
773
- const existingAgent = this.collection.get(id);
774
- if (!existingAgent) {
775
- throw new Error(`Agent with id ${id} not found`);
185
+ async updateAgent({ id, ...updates }) {
186
+ this.logger.debug(`InMemoryAgentsStorage: updateAgent called for ${id}`);
187
+ const existingAgent = this.db.agents.get(id);
188
+ if (!existingAgent) {
189
+ throw new Error(`Agent with id ${id} not found`);
776
190
  }
777
191
  const updatedAgent = {
778
192
  ...existingAgent,
@@ -795,12 +209,12 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
795
209
  },
796
210
  updatedAt: /* @__PURE__ */ new Date()
797
211
  };
798
- this.collection.set(id, updatedAgent);
212
+ this.db.agents.set(id, updatedAgent);
799
213
  return { ...updatedAgent };
800
214
  }
801
215
  async deleteAgent({ id }) {
802
216
  this.logger.debug(`InMemoryAgentsStorage: deleteAgent called for ${id}`);
803
- this.collection.delete(id);
217
+ this.db.agents.delete(id);
804
218
  }
805
219
  async listAgents(args) {
806
220
  const { page = 0, perPage: perPageInput, orderBy } = args || {};
@@ -814,7 +228,7 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
814
228
  if (page * perPage > maxOffset) {
815
229
  throw new Error("page value too large");
816
230
  }
817
- const agents = Array.from(this.collection.values());
231
+ const agents = Array.from(this.db.agents.values());
818
232
  const sortedAgents = this.sortAgents(agents, field, direction);
819
233
  const clonedAgents = sortedAgents.map((agent) => ({
820
234
  ...agent,
@@ -843,6 +257,30 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
843
257
  }
844
258
  };
845
259
 
260
+ // src/storage/domains/inmemory-db.ts
261
+ var InMemoryDB = class {
262
+ threads = /* @__PURE__ */ new Map();
263
+ messages = /* @__PURE__ */ new Map();
264
+ resources = /* @__PURE__ */ new Map();
265
+ workflows = /* @__PURE__ */ new Map();
266
+ scores = /* @__PURE__ */ new Map();
267
+ traces = /* @__PURE__ */ new Map();
268
+ agents = /* @__PURE__ */ new Map();
269
+ /**
270
+ * Clears all data from all collections.
271
+ * Useful for testing.
272
+ */
273
+ clear() {
274
+ this.threads.clear();
275
+ this.messages.clear();
276
+ this.resources.clear();
277
+ this.workflows.clear();
278
+ this.scores.clear();
279
+ this.traces.clear();
280
+ this.agents.clear();
281
+ }
282
+ };
283
+
846
284
  // src/storage/utils.ts
847
285
  function safelyParseJSON(input) {
848
286
  if (input && typeof input === "object") return input;
@@ -858,7 +296,7 @@ function safelyParseJSON(input) {
858
296
  }
859
297
  function transformRow(row, tableName, options = {}) {
860
298
  const { preferredTimestampFields = {}, convertTimestamps = false, nullValuePattern, fieldMappings = {} } = options;
861
- const tableSchema = TABLE_SCHEMAS[tableName];
299
+ const tableSchema = chunkNK4UN2LF_cjs.TABLE_SCHEMAS[tableName];
862
300
  const result = {};
863
301
  for (const [key, columnSchema] of Object.entries(tableSchema)) {
864
302
  const sourceKey = fieldMappings[key] ?? key;
@@ -889,7 +327,7 @@ function transformRow(row, tableName, options = {}) {
889
327
  return result;
890
328
  }
891
329
  function transformScoreRow(row, options = {}) {
892
- return transformRow(row, TABLE_SCORERS, options);
330
+ return transformRow(row, chunkNK4UN2LF_cjs.TABLE_SCORERS, options);
893
331
  }
894
332
  function toUpperSnakeCase(str) {
895
333
  return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
@@ -907,9 +345,57 @@ function createStorageErrorId(store, operation, status) {
907
345
  function createVectorErrorId(store, operation, status) {
908
346
  return createStoreErrorId("vector", store, operation, status);
909
347
  }
348
+ function getSqlType(type) {
349
+ switch (type) {
350
+ case "text":
351
+ return "TEXT";
352
+ case "timestamp":
353
+ return "TIMESTAMP";
354
+ case "float":
355
+ return "FLOAT";
356
+ case "integer":
357
+ return "INTEGER";
358
+ case "bigint":
359
+ return "BIGINT";
360
+ case "jsonb":
361
+ return "JSONB";
362
+ case "boolean":
363
+ return "BOOLEAN";
364
+ default:
365
+ return "TEXT";
366
+ }
367
+ }
368
+ function getDefaultValue(type) {
369
+ switch (type) {
370
+ case "text":
371
+ case "uuid":
372
+ return "DEFAULT ''";
373
+ case "timestamp":
374
+ return "DEFAULT '1970-01-01 00:00:00'";
375
+ case "integer":
376
+ case "bigint":
377
+ case "float":
378
+ return "DEFAULT 0";
379
+ case "jsonb":
380
+ return "DEFAULT '{}'";
381
+ case "boolean":
382
+ return "DEFAULT FALSE";
383
+ default:
384
+ return "DEFAULT ''";
385
+ }
386
+ }
387
+ function ensureDate(date) {
388
+ if (!date) return void 0;
389
+ return date instanceof Date ? date : new Date(date);
390
+ }
391
+ function serializeDate(date) {
392
+ if (!date) return void 0;
393
+ const dateObj = ensureDate(date);
394
+ return dateObj?.toISOString();
395
+ }
910
396
 
911
397
  // src/storage/domains/memory/base.ts
912
- var MemoryStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
398
+ var MemoryStorage = class extends StorageDomain {
913
399
  constructor() {
914
400
  super({
915
401
  component: "STORAGE",
@@ -954,25 +440,25 @@ var THREAD_THREAD_SORT_DIRECTION_SET = {
954
440
 
955
441
  // src/storage/domains/memory/inmemory.ts
956
442
  var InMemoryMemory = class extends MemoryStorage {
957
- collection;
958
- operations;
959
- constructor({
960
- collection,
961
- operations
962
- }) {
443
+ db;
444
+ constructor({ db }) {
963
445
  super();
964
- this.collection = collection;
965
- this.operations = operations;
446
+ this.db = db;
447
+ }
448
+ async dangerouslyClearAll() {
449
+ this.db.threads.clear();
450
+ this.db.messages.clear();
451
+ this.db.resources.clear();
966
452
  }
967
453
  async getThreadById({ threadId }) {
968
- this.logger.debug(`MockStore: getThreadById called for ${threadId}`);
969
- const thread = this.collection.threads.get(threadId);
454
+ this.logger.debug(`InMemoryMemory: getThreadById called for ${threadId}`);
455
+ const thread = this.db.threads.get(threadId);
970
456
  return thread ? { ...thread, metadata: thread.metadata ? { ...thread.metadata } : thread.metadata } : null;
971
457
  }
972
458
  async saveThread({ thread }) {
973
- this.logger.debug(`MockStore: saveThread called for ${thread.id}`);
459
+ this.logger.debug(`InMemoryMemory: saveThread called for ${thread.id}`);
974
460
  const key = thread.id;
975
- this.collection.threads.set(key, thread);
461
+ this.db.threads.set(key, thread);
976
462
  return thread;
977
463
  }
978
464
  async updateThread({
@@ -980,8 +466,8 @@ var InMemoryMemory = class extends MemoryStorage {
980
466
  title,
981
467
  metadata
982
468
  }) {
983
- this.logger.debug(`MockStore: updateThread called for ${id}`);
984
- const thread = this.collection.threads.get(id);
469
+ this.logger.debug(`InMemoryMemory: updateThread called for ${id}`);
470
+ const thread = this.db.threads.get(id);
985
471
  if (!thread) {
986
472
  throw new Error(`Thread with id ${id} not found`);
987
473
  }
@@ -993,11 +479,11 @@ var InMemoryMemory = class extends MemoryStorage {
993
479
  return thread;
994
480
  }
995
481
  async deleteThread({ threadId }) {
996
- this.logger.debug(`MockStore: deleteThread called for ${threadId}`);
997
- this.collection.threads.delete(threadId);
998
- this.collection.messages.forEach((msg, key) => {
482
+ this.logger.debug(`InMemoryMemory: deleteThread called for ${threadId}`);
483
+ this.db.threads.delete(threadId);
484
+ this.db.messages.forEach((msg, key) => {
999
485
  if (msg.thread_id === threadId) {
1000
- this.collection.messages.delete(key);
486
+ this.db.messages.delete(key);
1001
487
  }
1002
488
  });
1003
489
  }
@@ -1011,7 +497,7 @@ var InMemoryMemory = class extends MemoryStorage {
1011
497
  orderBy
1012
498
  }) {
1013
499
  const threadIds = Array.isArray(threadId) ? threadId : [threadId];
1014
- this.logger.debug(`MockStore: listMessages called for threads ${threadIds.join(", ")}`);
500
+ this.logger.debug(`InMemoryMemory: listMessages called for threads ${threadIds.join(", ")}`);
1015
501
  if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
1016
502
  throw new Error("threadId must be a non-empty string or array of non-empty strings");
1017
503
  }
@@ -1026,7 +512,7 @@ var InMemoryMemory = class extends MemoryStorage {
1026
512
  throw new Error("page value too large");
1027
513
  }
1028
514
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
1029
- let threadMessages = Array.from(this.collection.messages.values()).filter((msg) => {
515
+ let threadMessages = Array.from(this.db.messages.values()).filter((msg) => {
1030
516
  if (!threadIdSet.has(msg.thread_id)) return false;
1031
517
  if (resourceId && msg.resourceId !== resourceId) return false;
1032
518
  return true;
@@ -1064,7 +550,7 @@ var InMemoryMemory = class extends MemoryStorage {
1064
550
  }
1065
551
  if (include && include.length > 0) {
1066
552
  for (const includeItem of include) {
1067
- const targetMessage = this.collection.messages.get(includeItem.id);
553
+ const targetMessage = this.db.messages.get(includeItem.id);
1068
554
  if (targetMessage) {
1069
555
  const convertedMessage = {
1070
556
  id: targetMessage.id,
@@ -1080,7 +566,7 @@ var InMemoryMemory = class extends MemoryStorage {
1080
566
  messageIds.add(convertedMessage.id);
1081
567
  }
1082
568
  if (includeItem.withPreviousMessages) {
1083
- const allThreadMessages = Array.from(this.collection.messages.values()).filter((msg) => msg.thread_id === (includeItem.threadId || threadId)).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
569
+ const allThreadMessages = Array.from(this.db.messages.values()).filter((msg) => msg.thread_id === (includeItem.threadId || threadId)).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
1084
570
  const targetIndex = allThreadMessages.findIndex((msg) => msg.id === includeItem.id);
1085
571
  if (targetIndex !== -1) {
1086
572
  const startIndex = Math.max(0, targetIndex - (includeItem.withPreviousMessages || 0));
@@ -1103,7 +589,7 @@ var InMemoryMemory = class extends MemoryStorage {
1103
589
  }
1104
590
  }
1105
591
  if (includeItem.withNextMessages) {
1106
- const allThreadMessages = Array.from(this.collection.messages.values()).filter((msg) => msg.thread_id === (includeItem.threadId || threadId)).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
592
+ const allThreadMessages = Array.from(this.db.messages.values()).filter((msg) => msg.thread_id === (includeItem.threadId || threadId)).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
1107
593
  const targetIndex = allThreadMessages.findIndex((msg) => msg.id === includeItem.id);
1108
594
  if (targetIndex !== -1) {
1109
595
  const endIndex = Math.min(
@@ -1174,20 +660,23 @@ var InMemoryMemory = class extends MemoryStorage {
1174
660
  };
1175
661
  }
1176
662
  async listMessagesById({ messageIds }) {
1177
- this.logger.debug(`MockStore: listMessagesById called`);
1178
- const rawMessages = messageIds.map((id) => this.collection.messages.get(id)).filter((message) => !!message);
1179
- const list = new chunk72E3YF6A_cjs.MessageList().add(rawMessages.map(this.parseStoredMessage), "memory");
663
+ this.logger.debug(`InMemoryMemory: listMessagesById called`);
664
+ const rawMessages = messageIds.map((id) => this.db.messages.get(id)).filter((message) => !!message);
665
+ const list = new chunkEMLEZXTQ_cjs.MessageList().add(
666
+ rawMessages.map((m) => this.parseStoredMessage(m)),
667
+ "memory"
668
+ );
1180
669
  return { messages: list.get.all.db() };
1181
670
  }
1182
671
  async saveMessages(args) {
1183
672
  const { messages } = args;
1184
- this.logger.debug(`MockStore: saveMessages called with ${messages.length} messages`);
673
+ this.logger.debug(`InMemoryMemory: saveMessages called with ${messages.length} messages`);
1185
674
  if (messages.some((msg) => msg.id === "error-message" || msg.resourceId === null)) {
1186
675
  throw new Error("Simulated error for testing");
1187
676
  }
1188
677
  const threadIds = new Set(messages.map((msg) => msg.threadId).filter((id) => Boolean(id)));
1189
678
  for (const threadId of threadIds) {
1190
- const thread = this.collection.threads.get(threadId);
679
+ const thread = this.db.threads.get(threadId);
1191
680
  if (thread) {
1192
681
  thread.updatedAt = /* @__PURE__ */ new Date();
1193
682
  }
@@ -1203,15 +692,15 @@ var InMemoryMemory = class extends MemoryStorage {
1203
692
  createdAt: message.createdAt,
1204
693
  resourceId: message.resourceId || null
1205
694
  };
1206
- this.collection.messages.set(key, storageMessage);
695
+ this.db.messages.set(key, storageMessage);
1207
696
  }
1208
- const list = new chunk72E3YF6A_cjs.MessageList().add(messages, "memory");
697
+ const list = new chunkEMLEZXTQ_cjs.MessageList().add(messages, "memory");
1209
698
  return { messages: list.get.all.db() };
1210
699
  }
1211
700
  async updateMessages(args) {
1212
701
  const updatedMessages = [];
1213
702
  for (const update of args.messages) {
1214
- const storageMsg = this.collection.messages.get(update.id);
703
+ const storageMsg = this.db.messages.get(update.id);
1215
704
  if (!storageMsg) continue;
1216
705
  const oldThreadId = storageMsg.thread_id;
1217
706
  const newThreadId = update.threadId || oldThreadId;
@@ -1238,13 +727,13 @@ var InMemoryMemory = class extends MemoryStorage {
1238
727
  storageMsg.thread_id = newThreadId;
1239
728
  const base = Date.now();
1240
729
  let oldThreadNewTime;
1241
- const oldThread = this.collection.threads.get(oldThreadId);
730
+ const oldThread = this.db.threads.get(oldThreadId);
1242
731
  if (oldThread) {
1243
732
  const prev = new Date(oldThread.updatedAt).getTime();
1244
733
  oldThreadNewTime = Math.max(base, prev + 1);
1245
734
  oldThread.updatedAt = new Date(oldThreadNewTime);
1246
735
  }
1247
- const newThread = this.collection.threads.get(newThreadId);
736
+ const newThread = this.db.threads.get(newThreadId);
1248
737
  if (newThread) {
1249
738
  const prev = new Date(newThread.updatedAt).getTime();
1250
739
  let newThreadNewTime = Math.max(base + 1, prev + 1);
@@ -1254,7 +743,7 @@ var InMemoryMemory = class extends MemoryStorage {
1254
743
  newThread.updatedAt = new Date(newThreadNewTime);
1255
744
  }
1256
745
  } else {
1257
- const thread = this.collection.threads.get(oldThreadId);
746
+ const thread = this.db.threads.get(oldThreadId);
1258
747
  if (thread) {
1259
748
  const prev = new Date(thread.updatedAt).getTime();
1260
749
  let newTime = Date.now();
@@ -1262,7 +751,7 @@ var InMemoryMemory = class extends MemoryStorage {
1262
751
  thread.updatedAt = new Date(newTime);
1263
752
  }
1264
753
  }
1265
- this.collection.messages.set(update.id, storageMsg);
754
+ this.db.messages.set(update.id, storageMsg);
1266
755
  updatedMessages.push({
1267
756
  id: storageMsg.id,
1268
757
  threadId: storageMsg.thread_id,
@@ -1279,18 +768,18 @@ var InMemoryMemory = class extends MemoryStorage {
1279
768
  if (!messageIds || messageIds.length === 0) {
1280
769
  return;
1281
770
  }
1282
- this.logger.debug(`MockStore: deleteMessages called for ${messageIds.length} messages`);
771
+ this.logger.debug(`InMemoryMemory: deleteMessages called for ${messageIds.length} messages`);
1283
772
  const threadIds = /* @__PURE__ */ new Set();
1284
773
  for (const messageId of messageIds) {
1285
- const message = this.collection.messages.get(messageId);
774
+ const message = this.db.messages.get(messageId);
1286
775
  if (message && message.thread_id) {
1287
776
  threadIds.add(message.thread_id);
1288
777
  }
1289
- this.collection.messages.delete(messageId);
778
+ this.db.messages.delete(messageId);
1290
779
  }
1291
780
  const now = /* @__PURE__ */ new Date();
1292
781
  for (const threadId of threadIds) {
1293
- const thread = this.collection.threads.get(threadId);
782
+ const thread = this.db.threads.get(threadId);
1294
783
  if (thread) {
1295
784
  thread.updatedAt = now;
1296
785
  }
@@ -1307,8 +796,8 @@ var InMemoryMemory = class extends MemoryStorage {
1307
796
  if (page * perPage > maxOffset) {
1308
797
  throw new Error("page value too large");
1309
798
  }
1310
- this.logger.debug(`MockStore: listThreadsByResourceId called for ${resourceId}`);
1311
- const threads = Array.from(this.collection.threads.values()).filter((t) => t.resourceId === resourceId);
799
+ this.logger.debug(`InMemoryMemory: listThreadsByResourceId called for ${resourceId}`);
800
+ const threads = Array.from(this.db.threads.values()).filter((t) => t.resourceId === resourceId);
1312
801
  const sortedThreads = this.sortThreads(threads, field, direction);
1313
802
  const clonedThreads = sortedThreads.map((thread) => ({
1314
803
  ...thread,
@@ -1324,13 +813,13 @@ var InMemoryMemory = class extends MemoryStorage {
1324
813
  };
1325
814
  }
1326
815
  async getResourceById({ resourceId }) {
1327
- this.logger.debug(`MockStore: getResourceById called for ${resourceId}`);
1328
- const resource = this.collection.resources.get(resourceId);
816
+ this.logger.debug(`InMemoryMemory: getResourceById called for ${resourceId}`);
817
+ const resource = this.db.resources.get(resourceId);
1329
818
  return resource ? { ...resource, metadata: resource.metadata ? { ...resource.metadata } : resource.metadata } : null;
1330
819
  }
1331
820
  async saveResource({ resource }) {
1332
- this.logger.debug(`MockStore: saveResource called for ${resource.id}`);
1333
- this.collection.resources.set(resource.id, resource);
821
+ this.logger.debug(`InMemoryMemory: saveResource called for ${resource.id}`);
822
+ this.db.resources.set(resource.id, resource);
1334
823
  return resource;
1335
824
  }
1336
825
  async updateResource({
@@ -1338,8 +827,8 @@ var InMemoryMemory = class extends MemoryStorage {
1338
827
  workingMemory,
1339
828
  metadata
1340
829
  }) {
1341
- this.logger.debug(`MockStore: updateResource called for ${resourceId}`);
1342
- let resource = this.collection.resources.get(resourceId);
830
+ this.logger.debug(`InMemoryMemory: updateResource called for ${resourceId}`);
831
+ let resource = this.db.resources.get(resourceId);
1343
832
  if (!resource) {
1344
833
  resource = {
1345
834
  id: resourceId,
@@ -1359,7 +848,7 @@ var InMemoryMemory = class extends MemoryStorage {
1359
848
  updatedAt: /* @__PURE__ */ new Date()
1360
849
  };
1361
850
  }
1362
- this.collection.resources.set(resourceId, resource);
851
+ this.db.resources.set(resourceId, resource);
1363
852
  return resource;
1364
853
  }
1365
854
  sortThreads(threads, field, direction) {
@@ -1380,13 +869,15 @@ var InMemoryMemory = class extends MemoryStorage {
1380
869
  };
1381
870
 
1382
871
  // src/storage/domains/observability/base.ts
1383
- var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
872
+ var ObservabilityStorage = class extends StorageDomain {
1384
873
  constructor() {
1385
874
  super({
1386
875
  component: "STORAGE",
1387
876
  name: "OBSERVABILITY"
1388
877
  });
1389
878
  }
879
+ async dangerouslyClearAll() {
880
+ }
1390
881
  /**
1391
882
  * Provides hints for tracing strategy selection by the DefaultExporter.
1392
883
  * Storage adapters can override this to specify their preferred and supported strategies.
@@ -1401,8 +892,8 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1401
892
  /**
1402
893
  * Creates a single Span record in the storage provider.
1403
894
  */
1404
- createSpan(_span) {
1405
- throw new chunkHWMMIRIF_cjs.MastraError({
895
+ async createSpan(_args) {
896
+ throw new chunk4U7ZLI36_cjs.MastraError({
1406
897
  id: "OBSERVABILITY_CREATE_SPAN_NOT_IMPLEMENTED",
1407
898
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1408
899
  category: "SYSTEM" /* SYSTEM */,
@@ -1412,19 +903,41 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1412
903
  /**
1413
904
  * Updates a single Span with partial data. Primarily used for realtime trace creation.
1414
905
  */
1415
- updateSpan(_params) {
1416
- throw new chunkHWMMIRIF_cjs.MastraError({
906
+ async updateSpan(_args) {
907
+ throw new chunk4U7ZLI36_cjs.MastraError({
1417
908
  id: "OBSERVABILITY_STORAGE_UPDATE_SPAN_NOT_IMPLEMENTED",
1418
909
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1419
910
  category: "SYSTEM" /* SYSTEM */,
1420
911
  text: "This storage provider does not support updating spans"
1421
912
  });
1422
913
  }
914
+ /**
915
+ * Retrieves a single span.
916
+ */
917
+ async getSpan(_args) {
918
+ throw new chunk4U7ZLI36_cjs.MastraError({
919
+ id: "OBSERVABILITY_STORAGE_GET_SPAN_NOT_IMPLEMENTED",
920
+ domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
921
+ category: "SYSTEM" /* SYSTEM */,
922
+ text: "This storage provider does not support getting spans"
923
+ });
924
+ }
925
+ /**
926
+ * Retrieves a single root span.
927
+ */
928
+ async getRootSpan(_args) {
929
+ throw new chunk4U7ZLI36_cjs.MastraError({
930
+ id: "OBSERVABILITY_STORAGE_GET_ROOT_SPAN_NOT_IMPLEMENTED",
931
+ domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
932
+ category: "SYSTEM" /* SYSTEM */,
933
+ text: "This storage provider does not support getting root spans"
934
+ });
935
+ }
1423
936
  /**
1424
937
  * Retrieves a single trace with all its associated spans.
1425
938
  */
1426
- getTrace(_traceId) {
1427
- throw new chunkHWMMIRIF_cjs.MastraError({
939
+ async getTrace(_args) {
940
+ throw new chunk4U7ZLI36_cjs.MastraError({
1428
941
  id: "OBSERVABILITY_STORAGE_GET_TRACE_NOT_IMPLEMENTED",
1429
942
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1430
943
  category: "SYSTEM" /* SYSTEM */,
@@ -1432,21 +945,21 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1432
945
  });
1433
946
  }
1434
947
  /**
1435
- * Retrieves a paginated list of traces with optional filtering.
948
+ * Retrieves a list of traces with optional filtering.
1436
949
  */
1437
- getTracesPaginated(_args) {
1438
- throw new chunkHWMMIRIF_cjs.MastraError({
1439
- id: "OBSERVABILITY_STORAGE_GET_TRACES_PAGINATED_NOT_IMPLEMENTED",
950
+ async listTraces(_args) {
951
+ throw new chunk4U7ZLI36_cjs.MastraError({
952
+ id: "OBSERVABILITY_STORAGE_LIST_TRACES_NOT_IMPLEMENTED",
1440
953
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1441
954
  category: "SYSTEM" /* SYSTEM */,
1442
- text: "This storage provider does not support getting traces paginated"
955
+ text: "This storage provider does not support listing traces"
1443
956
  });
1444
957
  }
1445
958
  /**
1446
959
  * Creates multiple Spans in a single batch.
1447
960
  */
1448
- batchCreateSpans(_args) {
1449
- throw new chunkHWMMIRIF_cjs.MastraError({
961
+ async batchCreateSpans(_args) {
962
+ throw new chunk4U7ZLI36_cjs.MastraError({
1450
963
  id: "OBSERVABILITY_STORAGE_BATCH_CREATE_SPAN_NOT_IMPLEMENTED",
1451
964
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1452
965
  category: "SYSTEM" /* SYSTEM */,
@@ -1456,8 +969,8 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1456
969
  /**
1457
970
  * Updates multiple Spans in a single batch.
1458
971
  */
1459
- batchUpdateSpans(_args) {
1460
- throw new chunkHWMMIRIF_cjs.MastraError({
972
+ async batchUpdateSpans(_args) {
973
+ throw new chunk4U7ZLI36_cjs.MastraError({
1461
974
  id: "OBSERVABILITY_STORAGE_BATCH_UPDATE_SPANS_NOT_IMPLEMENTED",
1462
975
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1463
976
  category: "SYSTEM" /* SYSTEM */,
@@ -1467,8 +980,8 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1467
980
  /**
1468
981
  * Deletes multiple traces and all their associated spans in a single batch operation.
1469
982
  */
1470
- batchDeleteTraces(_args) {
1471
- throw new chunkHWMMIRIF_cjs.MastraError({
983
+ async batchDeleteTraces(_args) {
984
+ throw new chunk4U7ZLI36_cjs.MastraError({
1472
985
  id: "OBSERVABILITY_STORAGE_BATCH_DELETE_TRACES_NOT_IMPLEMENTED",
1473
986
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1474
987
  category: "SYSTEM" /* SYSTEM */,
@@ -1479,12 +992,13 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1479
992
 
1480
993
  // src/storage/domains/observability/inmemory.ts
1481
994
  var ObservabilityInMemory = class extends ObservabilityStorage {
1482
- operations;
1483
- collection;
1484
- constructor({ collection, operations }) {
995
+ db;
996
+ constructor({ db }) {
1485
997
  super();
1486
- this.collection = collection;
1487
- this.operations = operations;
998
+ this.db = db;
999
+ }
1000
+ async dangerouslyClearAll() {
1001
+ this.db.traces.clear();
1488
1002
  }
1489
1003
  get tracingStrategy() {
1490
1004
  return {
@@ -1492,22 +1006,32 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
1492
1006
  supported: ["realtime", "batch-with-updates", "insert-only"]
1493
1007
  };
1494
1008
  }
1495
- async createSpan(span) {
1009
+ async createSpan(args) {
1010
+ const { span } = args;
1496
1011
  this.validateCreateSpan(span);
1497
- const id = this.generateId(span);
1498
- const record = span;
1499
- record.createdAt = /* @__PURE__ */ new Date();
1500
- record.updatedAt = record.createdAt;
1501
- this.collection.set(id, record);
1012
+ const now = /* @__PURE__ */ new Date();
1013
+ const record = {
1014
+ ...span,
1015
+ createdAt: now,
1016
+ updatedAt: now
1017
+ };
1018
+ this.upsertSpanToTrace(record);
1502
1019
  }
1503
1020
  async batchCreateSpans(args) {
1504
- for (const record of args.records) {
1505
- await this.createSpan(record);
1021
+ const now = /* @__PURE__ */ new Date();
1022
+ for (const span of args.records) {
1023
+ this.validateCreateSpan(span);
1024
+ const record = {
1025
+ ...span,
1026
+ createdAt: now,
1027
+ updatedAt: now
1028
+ };
1029
+ this.upsertSpanToTrace(record);
1506
1030
  }
1507
1031
  }
1508
1032
  validateCreateSpan(record) {
1509
1033
  if (!record.spanId) {
1510
- throw new chunkHWMMIRIF_cjs.MastraError({
1034
+ throw new chunk4U7ZLI36_cjs.MastraError({
1511
1035
  id: "OBSERVABILITY_SPAN_ID_REQUIRED",
1512
1036
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1513
1037
  category: "SYSTEM" /* SYSTEM */,
@@ -1515,7 +1039,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
1515
1039
  });
1516
1040
  }
1517
1041
  if (!record.traceId) {
1518
- throw new chunkHWMMIRIF_cjs.MastraError({
1042
+ throw new chunk4U7ZLI36_cjs.MastraError({
1519
1043
  id: "OBSERVABILITY_TRACE_ID_REQUIRED",
1520
1044
  domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1521
1045
  category: "SYSTEM" /* SYSTEM */,
@@ -1523,11 +1047,74 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
1523
1047
  });
1524
1048
  }
1525
1049
  }
1526
- generateId({ traceId, spanId }) {
1527
- return `${traceId}-${spanId}`;
1050
+ /**
1051
+ * Inserts or updates a span in the trace and recomputes trace-level properties
1052
+ */
1053
+ upsertSpanToTrace(span) {
1054
+ const { traceId, spanId } = span;
1055
+ let traceEntry = this.db.traces.get(traceId);
1056
+ if (!traceEntry) {
1057
+ traceEntry = {
1058
+ spans: {},
1059
+ rootSpan: null,
1060
+ status: "running" /* RUNNING */,
1061
+ hasChildError: false
1062
+ };
1063
+ this.db.traces.set(traceId, traceEntry);
1064
+ }
1065
+ traceEntry.spans[spanId] = span;
1066
+ if (span.parentSpanId === null) {
1067
+ traceEntry.rootSpan = span;
1068
+ }
1069
+ this.recomputeTraceProperties(traceEntry);
1070
+ }
1071
+ /**
1072
+ * Recomputes derived trace properties from all spans
1073
+ */
1074
+ recomputeTraceProperties(traceEntry) {
1075
+ const spans = Object.values(traceEntry.spans);
1076
+ if (spans.length === 0) return;
1077
+ traceEntry.hasChildError = spans.some((s) => s.error != null);
1078
+ const rootSpan = traceEntry.rootSpan;
1079
+ if (rootSpan) {
1080
+ if (rootSpan.error != null) {
1081
+ traceEntry.status = "error" /* ERROR */;
1082
+ } else if (rootSpan.endedAt === null) {
1083
+ traceEntry.status = "running" /* RUNNING */;
1084
+ } else {
1085
+ traceEntry.status = "success" /* SUCCESS */;
1086
+ }
1087
+ } else {
1088
+ traceEntry.status = "running" /* RUNNING */;
1089
+ }
1090
+ }
1091
+ async getSpan(args) {
1092
+ const { traceId, spanId } = args;
1093
+ const traceEntry = this.db.traces.get(traceId);
1094
+ if (!traceEntry) {
1095
+ return null;
1096
+ }
1097
+ const span = traceEntry.spans[spanId];
1098
+ if (!span) {
1099
+ return null;
1100
+ }
1101
+ return { span };
1102
+ }
1103
+ async getRootSpan(args) {
1104
+ const { traceId } = args;
1105
+ const traceEntry = this.db.traces.get(traceId);
1106
+ if (!traceEntry || !traceEntry.rootSpan) {
1107
+ return null;
1108
+ }
1109
+ return { span: traceEntry.rootSpan };
1528
1110
  }
1529
- async getTrace(traceId) {
1530
- const spans = Array.from(this.collection.values()).filter((span) => span.traceId === traceId);
1111
+ async getTrace(args) {
1112
+ const { traceId } = args;
1113
+ const traceEntry = this.db.traces.get(traceId);
1114
+ if (!traceEntry) {
1115
+ return null;
1116
+ }
1117
+ const spans = Object.values(traceEntry.spans);
1531
1118
  if (spans.length === 0) {
1532
1119
  return null;
1533
1120
  }
@@ -1537,278 +1124,239 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
1537
1124
  spans
1538
1125
  };
1539
1126
  }
1540
- async getTracesPaginated({
1541
- filters,
1542
- pagination
1543
- }) {
1544
- const allRootSpans = this.filterForRootSpans(Array.from(this.collection.values()));
1545
- const filteredRootSpans = this.filterSpansByFilter(allRootSpans, filters);
1546
- const startDate = pagination?.dateRange?.start;
1547
- const endDate = pagination?.dateRange?.end;
1548
- const filteredRootSpansByDate = this.filterSpansByDate(filteredRootSpans, startDate, endDate);
1549
- const total = filteredRootSpansByDate.length;
1550
- const page = pagination?.page ?? 0;
1551
- const perPage = pagination?.perPage ?? 10;
1127
+ async listTraces(args) {
1128
+ const { filters, pagination, orderBy } = chunkNK4UN2LF_cjs.listTracesArgsSchema.parse(args);
1129
+ const matchingRootSpans = [];
1130
+ for (const [, traceEntry] of this.db.traces) {
1131
+ if (!traceEntry.rootSpan) continue;
1132
+ if (this.traceMatchesFilters(traceEntry, filters)) {
1133
+ matchingRootSpans.push(traceEntry.rootSpan);
1134
+ }
1135
+ }
1136
+ const { field: sortField, direction: sortDirection } = orderBy;
1137
+ matchingRootSpans.sort((a, b) => {
1138
+ if (sortField === "endedAt") {
1139
+ const aVal = a.endedAt;
1140
+ const bVal = b.endedAt;
1141
+ if (aVal == null && bVal == null) return 0;
1142
+ if (aVal == null) return sortDirection === "DESC" ? -1 : 1;
1143
+ if (bVal == null) return sortDirection === "DESC" ? 1 : -1;
1144
+ const diff = aVal.getTime() - bVal.getTime();
1145
+ return sortDirection === "DESC" ? -diff : diff;
1146
+ } else {
1147
+ const diff = a.startedAt.getTime() - b.startedAt.getTime();
1148
+ return sortDirection === "DESC" ? -diff : diff;
1149
+ }
1150
+ });
1151
+ const total = matchingRootSpans.length;
1152
+ const { page, perPage } = pagination;
1552
1153
  const start = page * perPage;
1553
1154
  const end = start + perPage;
1554
- const paged = this.filterSpansByPagination(filteredRootSpansByDate, pagination);
1155
+ const paged = matchingRootSpans.slice(start, end);
1555
1156
  return {
1556
1157
  spans: paged,
1557
1158
  pagination: { total, page, perPage, hasMore: end < total }
1558
1159
  };
1559
1160
  }
1560
- filterForRootSpans(spans) {
1561
- return spans.filter((span) => span.parentSpanId === null);
1562
- }
1563
- filterSpansByDate(spans, startDate, endDate) {
1564
- return spans.filter((span) => {
1565
- if (startDate && span.startedAt < startDate) return false;
1566
- if (endDate && span.startedAt > endDate) return false;
1567
- return true;
1568
- });
1569
- }
1570
- filterSpansByFilter(spans, filter) {
1571
- return spans.filter((span) => {
1572
- if (filter?.name && span.name !== filter.name) return false;
1573
- if (filter?.spanType && span.spanType !== filter.spanType) return false;
1574
- if (filter?.entityType === "agent" && filter.entityId !== span.attributes?.agentId) return false;
1575
- if (filter?.entityType === "workflow" && filter.entityId !== span.attributes?.workflowId) return false;
1576
- return true;
1577
- });
1578
- }
1579
- filterSpansByPagination(spans, pagination) {
1580
- const page = pagination?.page ?? 0;
1581
- const perPage = pagination?.perPage ?? 10;
1582
- const start = page * perPage;
1583
- const end = start + perPage;
1584
- return spans.slice(start, end);
1585
- }
1586
- async updateSpan(params) {
1587
- const id = this.generateId(params);
1588
- const span = this.collection.get(id);
1589
- if (!span) {
1590
- throw new chunkHWMMIRIF_cjs.MastraError({
1591
- id: "OBSERVABILITY_UPDATE_SPAN_NOT_FOUND",
1592
- domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1593
- category: "SYSTEM" /* SYSTEM */,
1594
- text: "Span not found for update"
1595
- });
1161
+ /**
1162
+ * Check if a trace matches all provided filters
1163
+ */
1164
+ traceMatchesFilters(traceEntry, filters) {
1165
+ if (!filters) return true;
1166
+ const rootSpan = traceEntry.rootSpan;
1167
+ if (!rootSpan) return false;
1168
+ if (filters.startedAt) {
1169
+ if (filters.startedAt.start && rootSpan.startedAt < filters.startedAt.start) {
1170
+ return false;
1171
+ }
1172
+ if (filters.startedAt.end && rootSpan.startedAt > filters.startedAt.end) {
1173
+ return false;
1174
+ }
1596
1175
  }
1597
- this.collection.set(id, { ...span, ...params.updates, updatedAt: /* @__PURE__ */ new Date() });
1598
- }
1599
- async batchUpdateSpans(args) {
1600
- for (const record of args.records) {
1601
- await this.updateSpan(record);
1176
+ if (filters.endedAt) {
1177
+ if (rootSpan.endedAt == null) {
1178
+ return false;
1179
+ }
1180
+ if (filters.endedAt.start && rootSpan.endedAt < filters.endedAt.start) {
1181
+ return false;
1182
+ }
1183
+ if (filters.endedAt.end && rootSpan.endedAt > filters.endedAt.end) {
1184
+ return false;
1185
+ }
1602
1186
  }
1603
- }
1604
- async batchDeleteTraces(args) {
1605
- for (const traceId of args.traceIds) {
1606
- const spans = Array.from(this.collection.values()).filter((span) => span.traceId === traceId);
1607
- for (const span of spans) {
1608
- this.collection.delete(this.generateId(span));
1187
+ if (filters.spanType !== void 0 && rootSpan.spanType !== filters.spanType) {
1188
+ return false;
1189
+ }
1190
+ if (filters.entityType !== void 0 && rootSpan.entityType !== filters.entityType) {
1191
+ return false;
1192
+ }
1193
+ if (filters.entityId !== void 0 && rootSpan.entityId !== filters.entityId) {
1194
+ return false;
1195
+ }
1196
+ if (filters.entityName !== void 0 && rootSpan.entityName !== filters.entityName) {
1197
+ return false;
1198
+ }
1199
+ if (filters.userId !== void 0 && rootSpan.userId !== filters.userId) {
1200
+ return false;
1201
+ }
1202
+ if (filters.organizationId !== void 0 && rootSpan.organizationId !== filters.organizationId) {
1203
+ return false;
1204
+ }
1205
+ if (filters.resourceId !== void 0 && rootSpan.resourceId !== filters.resourceId) {
1206
+ return false;
1207
+ }
1208
+ if (filters.runId !== void 0 && rootSpan.runId !== filters.runId) {
1209
+ return false;
1210
+ }
1211
+ if (filters.sessionId !== void 0 && rootSpan.sessionId !== filters.sessionId) {
1212
+ return false;
1213
+ }
1214
+ if (filters.threadId !== void 0 && rootSpan.threadId !== filters.threadId) {
1215
+ return false;
1216
+ }
1217
+ if (filters.requestId !== void 0 && rootSpan.requestId !== filters.requestId) {
1218
+ return false;
1219
+ }
1220
+ if (filters.environment !== void 0 && rootSpan.environment !== filters.environment) {
1221
+ return false;
1222
+ }
1223
+ if (filters.source !== void 0 && rootSpan.source !== filters.source) {
1224
+ return false;
1225
+ }
1226
+ if (filters.serviceName !== void 0 && rootSpan.serviceName !== filters.serviceName) {
1227
+ return false;
1228
+ }
1229
+ if (filters.scope != null && rootSpan.scope != null) {
1230
+ for (const [key, value] of Object.entries(filters.scope)) {
1231
+ if (!this.jsonValueEquals(rootSpan.scope[key], value)) {
1232
+ return false;
1233
+ }
1609
1234
  }
1235
+ } else if (filters.scope != null && rootSpan.scope == null) {
1236
+ return false;
1610
1237
  }
1611
- }
1612
- };
1613
-
1614
- // src/storage/domains/operations/base.ts
1615
- var StoreOperations = class extends chunkDGV2FWB4_cjs.MastraBase {
1616
- constructor() {
1617
- super({
1618
- component: "STORAGE",
1619
- name: "OPERATIONS"
1620
- });
1621
- }
1622
- getSqlType(type) {
1623
- switch (type) {
1624
- case "text":
1625
- return "TEXT";
1626
- case "timestamp":
1627
- return "TIMESTAMP";
1628
- case "float":
1629
- return "FLOAT";
1630
- case "integer":
1631
- return "INTEGER";
1632
- case "bigint":
1633
- return "BIGINT";
1634
- case "jsonb":
1635
- return "JSONB";
1636
- default:
1637
- return "TEXT";
1238
+ if (filters.metadata != null && rootSpan.metadata != null) {
1239
+ for (const [key, value] of Object.entries(filters.metadata)) {
1240
+ if (!this.jsonValueEquals(rootSpan.metadata[key], value)) {
1241
+ return false;
1242
+ }
1243
+ }
1244
+ } else if (filters.metadata != null && rootSpan.metadata == null) {
1245
+ return false;
1638
1246
  }
1639
- }
1640
- getDefaultValue(type) {
1641
- switch (type) {
1642
- case "text":
1643
- case "uuid":
1644
- return "DEFAULT ''";
1645
- case "timestamp":
1646
- return "DEFAULT '1970-01-01 00:00:00'";
1647
- case "integer":
1648
- case "bigint":
1649
- case "float":
1650
- return "DEFAULT 0";
1651
- case "jsonb":
1652
- return "DEFAULT '{}'";
1653
- default:
1654
- return "DEFAULT ''";
1247
+ if (filters.tags != null && filters.tags.length > 0) {
1248
+ if (rootSpan.tags == null) {
1249
+ return false;
1250
+ }
1251
+ for (const tag of filters.tags) {
1252
+ if (!rootSpan.tags.includes(tag)) {
1253
+ return false;
1254
+ }
1255
+ }
1655
1256
  }
1257
+ if (filters.status !== void 0 && traceEntry.status !== filters.status) {
1258
+ return false;
1259
+ }
1260
+ if (filters.hasChildError !== void 0 && traceEntry.hasChildError !== filters.hasChildError) {
1261
+ return false;
1262
+ }
1263
+ return true;
1656
1264
  }
1657
1265
  /**
1658
- * DATABASE INDEX MANAGEMENT
1659
- * Optional methods for database index management.
1660
- * Storage adapters can override these to provide index management capabilities.
1661
- */
1662
- /**
1663
- * Creates a database index on specified columns
1664
- * @throws {MastraError} if not supported by the storage adapter
1665
- */
1666
- async createIndex(_options) {
1667
- throw new chunkHWMMIRIF_cjs.MastraError({
1668
- id: "MASTRA_STORAGE_CREATE_INDEX_NOT_SUPPORTED",
1669
- domain: "STORAGE" /* STORAGE */,
1670
- category: "SYSTEM" /* SYSTEM */,
1671
- text: `Index management is not supported by this storage adapter`
1672
- });
1673
- }
1674
- /**
1675
- * Drops a database index by name
1676
- * @throws {MastraError} if not supported by the storage adapter
1677
- */
1678
- async dropIndex(_indexName) {
1679
- throw new chunkHWMMIRIF_cjs.MastraError({
1680
- id: "MASTRA_STORAGE_DROP_INDEX_NOT_SUPPORTED",
1681
- domain: "STORAGE" /* STORAGE */,
1682
- category: "SYSTEM" /* SYSTEM */,
1683
- text: `Index management is not supported by this storage adapter`
1684
- });
1685
- }
1686
- /**
1687
- * Lists database indexes for a table or all tables
1688
- * @throws {MastraError} if not supported by the storage adapter
1689
- */
1690
- async listIndexes(_tableName) {
1691
- throw new chunkHWMMIRIF_cjs.MastraError({
1692
- id: "MASTRA_STORAGE_LIST_INDEXES_NOT_SUPPORTED",
1693
- domain: "STORAGE" /* STORAGE */,
1694
- category: "SYSTEM" /* SYSTEM */,
1695
- text: `Index management is not supported by this storage adapter`
1696
- });
1697
- }
1698
- /**
1699
- * Gets detailed statistics for a specific index
1700
- * @throws {MastraError} if not supported by the storage adapter
1701
- */
1702
- async describeIndex(_indexName) {
1703
- throw new chunkHWMMIRIF_cjs.MastraError({
1704
- id: "MASTRA_STORAGE_DESCRIBE_INDEX_NOT_SUPPORTED",
1705
- domain: "STORAGE" /* STORAGE */,
1706
- category: "SYSTEM" /* SYSTEM */,
1707
- text: `Index management is not supported by this storage adapter`
1708
- });
1709
- }
1710
- /**
1711
- * Returns definitions for automatic performance indexes
1712
- * Storage adapters can override this to define indexes that should be created during initialization
1713
- * @returns Array of index definitions to create automatically
1266
+ * Deep equality check for JSON values
1714
1267
  */
1715
- getAutomaticIndexDefinitions() {
1716
- return [];
1717
- }
1718
- };
1719
-
1720
- // src/storage/domains/operations/inmemory.ts
1721
- var StoreOperationsInMemory = class extends StoreOperations {
1722
- data;
1723
- constructor() {
1724
- super();
1725
- this.data = {
1726
- mastra_workflow_snapshot: /* @__PURE__ */ new Map(),
1727
- mastra_messages: /* @__PURE__ */ new Map(),
1728
- mastra_threads: /* @__PURE__ */ new Map(),
1729
- mastra_traces: /* @__PURE__ */ new Map(),
1730
- mastra_resources: /* @__PURE__ */ new Map(),
1731
- mastra_scorers: /* @__PURE__ */ new Map(),
1732
- mastra_ai_spans: /* @__PURE__ */ new Map(),
1733
- mastra_agents: /* @__PURE__ */ new Map()
1734
- };
1735
- }
1736
- getDatabase() {
1737
- return this.data;
1738
- }
1739
- async insert({ tableName, record }) {
1740
- const table = this.data[tableName];
1741
- let key = record.id;
1742
- if ([TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
1743
- key = record.workflow_name ? `${record.workflow_name}-${record.run_id}` : record.run_id;
1744
- record.id = key;
1745
- } else if (!record.id) {
1746
- key = `auto-${Date.now()}-${Math.random()}`;
1747
- record.id = key;
1268
+ jsonValueEquals(a, b) {
1269
+ if (a === void 0 || b === void 0) {
1270
+ return a === b;
1748
1271
  }
1749
- table.set(key, record);
1750
- }
1751
- async batchInsert({ tableName, records }) {
1752
- const table = this.data[tableName];
1753
- for (const record of records) {
1754
- let key = record.id;
1755
- if ([TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
1756
- key = record.run_id;
1757
- record.id = key;
1758
- } else if (!record.id) {
1759
- key = `auto-${Date.now()}-${Math.random()}`;
1760
- record.id = key;
1272
+ if (a === null || b === null) {
1273
+ return a === b;
1274
+ }
1275
+ if (typeof a !== typeof b) {
1276
+ return false;
1277
+ }
1278
+ if (a instanceof Date && b instanceof Date) {
1279
+ return a.getTime() === b.getTime();
1280
+ }
1281
+ if (a instanceof Date || b instanceof Date) {
1282
+ return false;
1283
+ }
1284
+ if (typeof a === "object") {
1285
+ if (Array.isArray(a) && Array.isArray(b)) {
1286
+ if (a.length !== b.length) return false;
1287
+ return a.every((val, i) => this.jsonValueEquals(val, b[i]));
1761
1288
  }
1762
- table.set(key, record);
1289
+ if (Array.isArray(a) || Array.isArray(b)) {
1290
+ return false;
1291
+ }
1292
+ const aKeys = Object.keys(a);
1293
+ const bKeys = Object.keys(b);
1294
+ if (aKeys.length !== bKeys.length) return false;
1295
+ return aKeys.every(
1296
+ (key) => this.jsonValueEquals(a[key], b[key])
1297
+ );
1763
1298
  }
1299
+ return a === b;
1764
1300
  }
1765
- async load({ tableName, keys }) {
1766
- this.logger.debug(`MockStore: load called for ${tableName} with keys`, keys);
1767
- const table = this.data[tableName];
1768
- const records = Array.from(table.values());
1769
- return records.filter((record) => Object.keys(keys).every((key) => record[key] === keys[key]))?.[0];
1770
- }
1771
- async createTable({
1772
- tableName,
1773
- schema
1774
- }) {
1775
- this.logger.debug(`MockStore: createTable called for ${tableName} with schema`, schema);
1776
- this.data[tableName] = /* @__PURE__ */ new Map();
1777
- }
1778
- async clearTable({ tableName }) {
1779
- this.logger.debug(`MockStore: clearTable called for ${tableName}`);
1780
- this.data[tableName].clear();
1781
- }
1782
- async dropTable({ tableName }) {
1783
- this.logger.debug(`MockStore: dropTable called for ${tableName}`);
1784
- this.data[tableName].clear();
1301
+ async updateSpan(args) {
1302
+ const { traceId, spanId, updates } = args;
1303
+ const traceEntry = this.db.traces.get(traceId);
1304
+ if (!traceEntry) {
1305
+ throw new chunk4U7ZLI36_cjs.MastraError({
1306
+ id: "OBSERVABILITY_UPDATE_SPAN_NOT_FOUND",
1307
+ domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1308
+ category: "SYSTEM" /* SYSTEM */,
1309
+ text: "Trace not found for span update"
1310
+ });
1311
+ }
1312
+ const span = traceEntry.spans[spanId];
1313
+ if (!span) {
1314
+ throw new chunk4U7ZLI36_cjs.MastraError({
1315
+ id: "OBSERVABILITY_UPDATE_SPAN_NOT_FOUND",
1316
+ domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
1317
+ category: "SYSTEM" /* SYSTEM */,
1318
+ text: "Span not found for update"
1319
+ });
1320
+ }
1321
+ const updatedSpan = {
1322
+ ...span,
1323
+ ...updates,
1324
+ updatedAt: /* @__PURE__ */ new Date()
1325
+ };
1326
+ traceEntry.spans[spanId] = updatedSpan;
1327
+ if (updatedSpan.parentSpanId === null) {
1328
+ traceEntry.rootSpan = updatedSpan;
1329
+ }
1330
+ this.recomputeTraceProperties(traceEntry);
1785
1331
  }
1786
- async alterTable({
1787
- tableName,
1788
- schema
1789
- }) {
1790
- this.logger.debug(`MockStore: alterTable called for ${tableName} with schema`, schema);
1332
+ async batchUpdateSpans(args) {
1333
+ for (const record of args.records) {
1334
+ await this.updateSpan(record);
1335
+ }
1791
1336
  }
1792
- async hasColumn(table, column) {
1793
- this.logger.debug(`MockStore: hasColumn called for ${table} with column ${column}`);
1794
- return true;
1337
+ async batchDeleteTraces(args) {
1338
+ for (const traceId of args.traceIds) {
1339
+ this.db.traces.delete(traceId);
1340
+ }
1795
1341
  }
1796
1342
  };
1797
1343
 
1798
1344
  // src/storage/domains/scores/base.ts
1799
- var ScoresStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1345
+ var ScoresStorage = class extends StorageDomain {
1800
1346
  constructor() {
1801
1347
  super({
1802
1348
  component: "STORAGE",
1803
1349
  name: "SCORES"
1804
1350
  });
1805
1351
  }
1352
+ async dangerouslyClearAll() {
1353
+ }
1806
1354
  async listScoresBySpan({
1807
1355
  traceId,
1808
1356
  spanId,
1809
1357
  pagination: _pagination
1810
1358
  }) {
1811
- throw new chunkHWMMIRIF_cjs.MastraError({
1359
+ throw new chunk4U7ZLI36_cjs.MastraError({
1812
1360
  id: "SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED",
1813
1361
  domain: "STORAGE" /* STORAGE */,
1814
1362
  category: "SYSTEM" /* SYSTEM */,
@@ -1819,17 +1367,20 @@ var ScoresStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1819
1367
 
1820
1368
  // src/storage/domains/scores/inmemory.ts
1821
1369
  var ScoresInMemory = class extends ScoresStorage {
1822
- scores;
1823
- constructor({ collection }) {
1370
+ db;
1371
+ constructor({ db }) {
1824
1372
  super();
1825
- this.scores = collection;
1373
+ this.db = db;
1374
+ }
1375
+ async dangerouslyClearAll() {
1376
+ this.db.scores.clear();
1826
1377
  }
1827
1378
  async getScoreById({ id }) {
1828
- return this.scores.get(id) ?? null;
1379
+ return this.db.scores.get(id) ?? null;
1829
1380
  }
1830
1381
  async saveScore(score) {
1831
1382
  const newScore = { id: crypto.randomUUID(), createdAt: /* @__PURE__ */ new Date(), updatedAt: /* @__PURE__ */ new Date(), ...score };
1832
- this.scores.set(newScore.id, newScore);
1383
+ this.db.scores.set(newScore.id, newScore);
1833
1384
  return { score: newScore };
1834
1385
  }
1835
1386
  async listScoresByScorerId({
@@ -1839,7 +1390,7 @@ var ScoresInMemory = class extends ScoresStorage {
1839
1390
  entityType,
1840
1391
  source
1841
1392
  }) {
1842
- const scores = Array.from(this.scores.values()).filter((score) => {
1393
+ const scores = Array.from(this.db.scores.values()).filter((score) => {
1843
1394
  let baseFilter = score.scorerId === scorerId;
1844
1395
  if (entityId) {
1845
1396
  baseFilter = baseFilter && score.entityId === entityId;
@@ -1870,7 +1421,7 @@ var ScoresInMemory = class extends ScoresStorage {
1870
1421
  runId,
1871
1422
  pagination
1872
1423
  }) {
1873
- const scores = Array.from(this.scores.values()).filter((score) => score.runId === runId);
1424
+ const scores = Array.from(this.db.scores.values()).filter((score) => score.runId === runId);
1874
1425
  const { page, perPage: perPageInput } = pagination;
1875
1426
  const perPage = normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
1876
1427
  const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
@@ -1890,7 +1441,7 @@ var ScoresInMemory = class extends ScoresStorage {
1890
1441
  entityType,
1891
1442
  pagination
1892
1443
  }) {
1893
- const scores = Array.from(this.scores.values()).filter((score) => {
1444
+ const scores = Array.from(this.db.scores.values()).filter((score) => {
1894
1445
  const baseFilter = score.entityId === entityId && score.entityType === entityType;
1895
1446
  return baseFilter;
1896
1447
  });
@@ -1913,7 +1464,7 @@ var ScoresInMemory = class extends ScoresStorage {
1913
1464
  spanId,
1914
1465
  pagination
1915
1466
  }) {
1916
- const scores = Array.from(this.scores.values()).filter(
1467
+ const scores = Array.from(this.db.scores.values()).filter(
1917
1468
  (score) => score.traceId === traceId && score.spanId === spanId
1918
1469
  );
1919
1470
  scores.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
@@ -1934,7 +1485,7 @@ var ScoresInMemory = class extends ScoresStorage {
1934
1485
  };
1935
1486
 
1936
1487
  // src/storage/domains/workflows/base.ts
1937
- var WorkflowsStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1488
+ var WorkflowsStorage = class extends StorageDomain {
1938
1489
  constructor() {
1939
1490
  super({
1940
1491
  component: "STORAGE",
@@ -1945,12 +1496,16 @@ var WorkflowsStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
1945
1496
 
1946
1497
  // src/storage/domains/workflows/inmemory.ts
1947
1498
  var WorkflowsInMemory = class extends WorkflowsStorage {
1948
- operations;
1949
- collection;
1950
- constructor({ collection, operations }) {
1499
+ db;
1500
+ constructor({ db }) {
1951
1501
  super();
1952
- this.collection = collection;
1953
- this.operations = operations;
1502
+ this.db = db;
1503
+ }
1504
+ async dangerouslyClearAll() {
1505
+ this.db.workflows.clear();
1506
+ }
1507
+ getWorkflowKey(workflowName, runId) {
1508
+ return `${workflowName}-${runId}`;
1954
1509
  }
1955
1510
  async updateWorkflowResults({
1956
1511
  workflowName,
@@ -1959,8 +1514,9 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
1959
1514
  result,
1960
1515
  requestContext
1961
1516
  }) {
1962
- this.logger.debug(`MockStore: updateWorkflowResults called for ${workflowName} ${runId} ${stepId}`, result);
1963
- const run = this.collection.get(`${workflowName}-${runId}`);
1517
+ this.logger.debug(`WorkflowsInMemory: updateWorkflowResults called for ${workflowName} ${runId} ${stepId}`, result);
1518
+ const key = this.getWorkflowKey(workflowName, runId);
1519
+ const run = this.db.workflows.get(key);
1964
1520
  if (!run) {
1965
1521
  return {};
1966
1522
  }
@@ -1979,18 +1535,19 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
1979
1535
  status: "pending",
1980
1536
  runId: run.run_id
1981
1537
  };
1982
- this.collection.set(`${workflowName}-${runId}`, {
1538
+ this.db.workflows.set(key, {
1983
1539
  ...run,
1984
1540
  snapshot
1985
1541
  });
1542
+ } else {
1543
+ snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
1986
1544
  }
1987
- snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
1988
1545
  if (!snapshot || !snapshot?.context) {
1989
1546
  throw new Error(`Snapshot not found for runId ${runId}`);
1990
1547
  }
1991
1548
  snapshot.context[stepId] = result;
1992
1549
  snapshot.requestContext = { ...snapshot.requestContext, ...requestContext };
1993
- this.collection.set(`${workflowName}-${runId}`, {
1550
+ this.db.workflows.set(key, {
1994
1551
  ...run,
1995
1552
  snapshot
1996
1553
  });
@@ -2001,7 +1558,8 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
2001
1558
  runId,
2002
1559
  opts
2003
1560
  }) {
2004
- const run = this.collection.get(`${workflowName}-${runId}`);
1561
+ const key = this.getWorkflowKey(workflowName, runId);
1562
+ const run = this.db.workflows.get(key);
2005
1563
  if (!run) {
2006
1564
  return;
2007
1565
  }
@@ -2020,7 +1578,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
2020
1578
  status: "pending",
2021
1579
  runId: run.run_id
2022
1580
  };
2023
- this.collection.set(`${workflowName}-${runId}`, {
1581
+ this.db.workflows.set(key, {
2024
1582
  ...run,
2025
1583
  snapshot
2026
1584
  });
@@ -2031,7 +1589,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
2031
1589
  throw new Error(`Snapshot not found for runId ${runId}`);
2032
1590
  }
2033
1591
  snapshot = { ...snapshot, ...opts };
2034
- this.collection.set(`${workflowName}-${runId}`, {
1592
+ this.db.workflows.set(key, {
2035
1593
  ...run,
2036
1594
  snapshot
2037
1595
  });
@@ -2041,31 +1599,34 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
2041
1599
  workflowName,
2042
1600
  runId,
2043
1601
  resourceId,
2044
- snapshot
1602
+ snapshot,
1603
+ createdAt,
1604
+ updatedAt
2045
1605
  }) {
1606
+ const key = this.getWorkflowKey(workflowName, runId);
1607
+ const now = /* @__PURE__ */ new Date();
2046
1608
  const data = {
2047
1609
  workflow_name: workflowName,
2048
1610
  run_id: runId,
2049
1611
  resourceId,
2050
1612
  snapshot,
2051
- createdAt: /* @__PURE__ */ new Date(),
2052
- updatedAt: /* @__PURE__ */ new Date()
1613
+ createdAt: createdAt ?? now,
1614
+ updatedAt: updatedAt ?? now
2053
1615
  };
2054
- await this.operations.insert({
2055
- tableName: TABLE_WORKFLOW_SNAPSHOT,
2056
- record: data
2057
- });
1616
+ this.db.workflows.set(key, data);
2058
1617
  }
2059
1618
  async loadWorkflowSnapshot({
2060
1619
  workflowName,
2061
1620
  runId
2062
1621
  }) {
2063
1622
  this.logger.debug("Loading workflow snapshot", { workflowName, runId });
2064
- const d = await this.operations.load({
2065
- tableName: TABLE_WORKFLOW_SNAPSHOT,
2066
- keys: { workflow_name: workflowName, run_id: runId }
2067
- });
2068
- return d ? JSON.parse(JSON.stringify(d.snapshot)) : null;
1623
+ const key = this.getWorkflowKey(workflowName, runId);
1624
+ const run = this.db.workflows.get(key);
1625
+ if (!run) {
1626
+ return null;
1627
+ }
1628
+ const snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
1629
+ return snapshot ? JSON.parse(JSON.stringify(snapshot)) : null;
2069
1630
  }
2070
1631
  async listWorkflowRuns({
2071
1632
  workflowName,
@@ -2079,7 +1640,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
2079
1640
  if (page !== void 0 && page < 0) {
2080
1641
  throw new Error("page must be >= 0");
2081
1642
  }
2082
- let runs = Array.from(this.collection.values());
1643
+ let runs = Array.from(this.db.workflows.values());
2083
1644
  if (workflowName) runs = runs.filter((run) => run.workflow_name === workflowName);
2084
1645
  if (status) {
2085
1646
  runs = runs.filter((run) => {
@@ -2133,7 +1694,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
2133
1694
  runId,
2134
1695
  workflowName
2135
1696
  }) {
2136
- const runs = Array.from(this.collection.values()).filter((r) => r.run_id === runId);
1697
+ const runs = Array.from(this.db.workflows.values()).filter((r) => r.run_id === runId);
2137
1698
  let run = runs.find((r) => r.workflow_name === workflowName);
2138
1699
  if (!run) return null;
2139
1700
  const parsedRun = {
@@ -2148,230 +1709,230 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
2148
1709
  return parsedRun;
2149
1710
  }
2150
1711
  async deleteWorkflowRunById({ runId, workflowName }) {
2151
- this.collection.delete(`${workflowName}-${runId}`);
1712
+ const key = this.getWorkflowKey(workflowName, runId);
1713
+ this.db.workflows.delete(key);
2152
1714
  }
2153
1715
  };
2154
1716
 
2155
1717
  // src/storage/mock.ts
2156
1718
  var InMemoryStore = class extends MastraStorage {
2157
1719
  stores;
1720
+ /**
1721
+ * Internal database layer shared across all domains.
1722
+ * This is an implementation detail - domains interact with this
1723
+ * rather than managing their own data structures.
1724
+ */
1725
+ #db;
2158
1726
  constructor({ id = "in-memory" } = {}) {
2159
1727
  super({ id, name: "InMemoryStorage" });
2160
1728
  this.hasInitialized = Promise.resolve(true);
2161
- const operationsStorage = new StoreOperationsInMemory();
2162
- const database = operationsStorage.getDatabase();
2163
- const scoresStorage = new ScoresInMemory({
2164
- collection: database.mastra_scorers
2165
- });
2166
- const workflowsStorage = new WorkflowsInMemory({
2167
- collection: database.mastra_workflow_snapshot,
2168
- operations: operationsStorage
2169
- });
2170
- const memoryStorage = new InMemoryMemory({
2171
- collection: {
2172
- threads: database.mastra_threads,
2173
- resources: database.mastra_resources,
2174
- messages: database.mastra_messages
2175
- },
2176
- operations: operationsStorage
2177
- });
2178
- const observabilityStorage = new ObservabilityInMemory({
2179
- collection: database.mastra_ai_spans,
2180
- operations: operationsStorage
2181
- });
2182
- const agentsCollection = /* @__PURE__ */ new Map();
2183
- const agentsStorage = new InMemoryAgentsStorage({
2184
- collection: agentsCollection
2185
- });
1729
+ this.#db = new InMemoryDB();
2186
1730
  this.stores = {
2187
- operations: operationsStorage,
2188
- workflows: workflowsStorage,
2189
- scores: scoresStorage,
2190
- memory: memoryStorage,
2191
- observability: observabilityStorage,
2192
- agents: agentsStorage
2193
- };
2194
- }
2195
- get supports() {
2196
- return {
2197
- selectByIncludeResourceScope: false,
2198
- resourceWorkingMemory: false,
2199
- hasColumn: false,
2200
- createTable: false,
2201
- deleteMessages: true,
2202
- observabilityInstance: true,
2203
- indexManagement: false,
2204
- listScoresBySpan: true,
2205
- agents: true
1731
+ memory: new InMemoryMemory({ db: this.#db }),
1732
+ workflows: new WorkflowsInMemory({ db: this.#db }),
1733
+ scores: new ScoresInMemory({ db: this.#db }),
1734
+ observability: new ObservabilityInMemory({ db: this.#db }),
1735
+ agents: new InMemoryAgentsStorage({ db: this.#db })
2206
1736
  };
2207
1737
  }
2208
- async persistWorkflowSnapshot({
2209
- workflowName,
2210
- runId,
2211
- resourceId,
2212
- snapshot
2213
- }) {
2214
- await this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
2215
- }
2216
- async loadWorkflowSnapshot({
2217
- workflowName,
2218
- runId
2219
- }) {
2220
- return this.stores.workflows.loadWorkflowSnapshot({ workflowName, runId });
2221
- }
2222
- async createTable({
2223
- tableName,
2224
- schema
2225
- }) {
2226
- await this.stores.operations.createTable({ tableName, schema });
2227
- }
2228
- async alterTable({
2229
- tableName,
2230
- schema,
2231
- ifNotExists
2232
- }) {
2233
- await this.stores.operations.alterTable({ tableName, schema, ifNotExists });
2234
- }
2235
- async clearTable({ tableName }) {
2236
- await this.stores.operations.clearTable({ tableName });
2237
- }
2238
- async dropTable({ tableName }) {
2239
- await this.stores.operations.dropTable({ tableName });
2240
- }
2241
- async insert({ tableName, record }) {
2242
- await this.stores.operations.insert({ tableName, record });
2243
- }
2244
- async updateWorkflowResults({
2245
- workflowName,
2246
- runId,
2247
- stepId,
2248
- result,
2249
- requestContext
2250
- }) {
2251
- return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
2252
- }
2253
- async updateWorkflowState({
2254
- workflowName,
2255
- runId,
2256
- opts
2257
- }) {
2258
- return this.stores.workflows.updateWorkflowState({ workflowName, runId, opts });
2259
- }
2260
- async batchInsert({ tableName, records }) {
2261
- await this.stores.operations.batchInsert({ tableName, records });
2262
- }
2263
- async load({ tableName, keys }) {
2264
- return this.stores.operations.load({ tableName, keys });
2265
- }
2266
- async getThreadById({ threadId }) {
2267
- return this.stores.memory.getThreadById({ threadId });
1738
+ /**
1739
+ * Clears all data from the in-memory database.
1740
+ * Useful for testing.
1741
+ * @deprecated Use dangerouslyClearAll() on individual domains instead.
1742
+ */
1743
+ clear() {
1744
+ this.#db.clear();
2268
1745
  }
2269
- async saveThread({ thread }) {
2270
- return this.stores.memory.saveThread({ thread });
1746
+ };
1747
+ var MockStore = InMemoryStore;
1748
+
1749
+ // src/storage/domains/operations/base.ts
1750
+ var StoreOperations = class extends chunkDGV2FWB4_cjs.MastraBase {
1751
+ constructor() {
1752
+ super({
1753
+ component: "STORAGE",
1754
+ name: "OPERATIONS"
1755
+ });
2271
1756
  }
2272
- async updateThread({
2273
- id,
2274
- title,
2275
- metadata
2276
- }) {
2277
- return this.stores.memory.updateThread({ id, title, metadata });
1757
+ getSqlType(type) {
1758
+ switch (type) {
1759
+ case "text":
1760
+ return "TEXT";
1761
+ case "timestamp":
1762
+ return "TIMESTAMP";
1763
+ case "float":
1764
+ return "FLOAT";
1765
+ case "integer":
1766
+ return "INTEGER";
1767
+ case "bigint":
1768
+ return "BIGINT";
1769
+ case "jsonb":
1770
+ return "JSONB";
1771
+ default:
1772
+ return "TEXT";
1773
+ }
2278
1774
  }
2279
- async deleteThread({ threadId }) {
2280
- return this.stores.memory.deleteThread({ threadId });
1775
+ getDefaultValue(type) {
1776
+ switch (type) {
1777
+ case "text":
1778
+ case "uuid":
1779
+ return "DEFAULT ''";
1780
+ case "timestamp":
1781
+ return "DEFAULT '1970-01-01 00:00:00'";
1782
+ case "integer":
1783
+ case "bigint":
1784
+ case "float":
1785
+ return "DEFAULT 0";
1786
+ case "jsonb":
1787
+ return "DEFAULT '{}'";
1788
+ default:
1789
+ return "DEFAULT ''";
1790
+ }
2281
1791
  }
2282
- async getResourceById({ resourceId }) {
2283
- return this.stores.memory.getResourceById({ resourceId });
1792
+ /**
1793
+ * DATABASE INDEX MANAGEMENT
1794
+ * Optional methods for database index management.
1795
+ * Storage adapters can override these to provide index management capabilities.
1796
+ */
1797
+ /**
1798
+ * Creates a database index on specified columns
1799
+ * @throws {MastraError} if not supported by the storage adapter
1800
+ */
1801
+ async createIndex(_options) {
1802
+ throw new chunk4U7ZLI36_cjs.MastraError({
1803
+ id: "MASTRA_STORAGE_CREATE_INDEX_NOT_SUPPORTED",
1804
+ domain: "STORAGE" /* STORAGE */,
1805
+ category: "SYSTEM" /* SYSTEM */,
1806
+ text: `Index management is not supported by this storage adapter`
1807
+ });
2284
1808
  }
2285
- async saveResource({ resource }) {
2286
- return this.stores.memory.saveResource({ resource });
1809
+ /**
1810
+ * Drops a database index by name
1811
+ * @throws {MastraError} if not supported by the storage adapter
1812
+ */
1813
+ async dropIndex(_indexName) {
1814
+ throw new chunk4U7ZLI36_cjs.MastraError({
1815
+ id: "MASTRA_STORAGE_DROP_INDEX_NOT_SUPPORTED",
1816
+ domain: "STORAGE" /* STORAGE */,
1817
+ category: "SYSTEM" /* SYSTEM */,
1818
+ text: `Index management is not supported by this storage adapter`
1819
+ });
2287
1820
  }
2288
- async updateResource({
2289
- resourceId,
2290
- workingMemory,
2291
- metadata
2292
- }) {
2293
- return this.stores.memory.updateResource({ resourceId, workingMemory, metadata });
1821
+ /**
1822
+ * Lists database indexes for a table or all tables
1823
+ * @throws {MastraError} if not supported by the storage adapter
1824
+ */
1825
+ async listIndexes(_tableName) {
1826
+ throw new chunk4U7ZLI36_cjs.MastraError({
1827
+ id: "MASTRA_STORAGE_LIST_INDEXES_NOT_SUPPORTED",
1828
+ domain: "STORAGE" /* STORAGE */,
1829
+ category: "SYSTEM" /* SYSTEM */,
1830
+ text: `Index management is not supported by this storage adapter`
1831
+ });
2294
1832
  }
2295
- async listMessagesById({ messageIds }) {
2296
- return this.stores.memory.listMessagesById({ messageIds });
1833
+ /**
1834
+ * Gets detailed statistics for a specific index
1835
+ * @throws {MastraError} if not supported by the storage adapter
1836
+ */
1837
+ async describeIndex(_indexName) {
1838
+ throw new chunk4U7ZLI36_cjs.MastraError({
1839
+ id: "MASTRA_STORAGE_DESCRIBE_INDEX_NOT_SUPPORTED",
1840
+ domain: "STORAGE" /* STORAGE */,
1841
+ category: "SYSTEM" /* SYSTEM */,
1842
+ text: `Index management is not supported by this storage adapter`
1843
+ });
2297
1844
  }
2298
- async saveMessages(args) {
2299
- return this.stores.memory.saveMessages(args);
1845
+ /**
1846
+ * Returns definitions for automatic performance indexes
1847
+ * Storage adapters can override this to define indexes that should be created during initialization
1848
+ * @returns Array of index definitions to create automatically
1849
+ */
1850
+ getAutomaticIndexDefinitions() {
1851
+ return [];
2300
1852
  }
2301
- async updateMessages(args) {
2302
- return this.stores.memory.updateMessages(args);
1853
+ };
1854
+
1855
+ // src/storage/domains/operations/inmemory.ts
1856
+ var StoreOperationsInMemory = class extends StoreOperations {
1857
+ data;
1858
+ constructor() {
1859
+ super();
1860
+ this.data = {
1861
+ mastra_workflow_snapshot: /* @__PURE__ */ new Map(),
1862
+ mastra_messages: /* @__PURE__ */ new Map(),
1863
+ mastra_threads: /* @__PURE__ */ new Map(),
1864
+ mastra_traces: /* @__PURE__ */ new Map(),
1865
+ mastra_resources: /* @__PURE__ */ new Map(),
1866
+ mastra_scorers: /* @__PURE__ */ new Map(),
1867
+ mastra_ai_spans: /* @__PURE__ */ new Map(),
1868
+ mastra_agents: /* @__PURE__ */ new Map()
1869
+ };
2303
1870
  }
2304
- async deleteMessages(messageIds) {
2305
- return this.stores.memory.deleteMessages(messageIds);
1871
+ getDatabase() {
1872
+ return this.data;
2306
1873
  }
2307
- async getScoreById({ id }) {
2308
- return this.stores.scores.getScoreById({ id });
1874
+ async insert({ tableName, record }) {
1875
+ const table = this.data[tableName];
1876
+ let key = record.id;
1877
+ if ([chunkNK4UN2LF_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
1878
+ key = record.workflow_name ? `${record.workflow_name}-${record.run_id}` : record.run_id;
1879
+ record.id = key;
1880
+ } else if (!record.id) {
1881
+ key = `auto-${Date.now()}-${Math.random()}`;
1882
+ record.id = key;
1883
+ }
1884
+ table.set(key, record);
2309
1885
  }
2310
- async saveScore(score) {
2311
- return this.stores.scores.saveScore(score);
1886
+ async batchInsert({ tableName, records }) {
1887
+ const table = this.data[tableName];
1888
+ for (const record of records) {
1889
+ let key = record.id;
1890
+ if ([chunkNK4UN2LF_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
1891
+ key = record.run_id;
1892
+ record.id = key;
1893
+ } else if (!record.id) {
1894
+ key = `auto-${Date.now()}-${Math.random()}`;
1895
+ record.id = key;
1896
+ }
1897
+ table.set(key, record);
1898
+ }
2312
1899
  }
2313
- async listScoresByScorerId({
2314
- scorerId,
2315
- entityId,
2316
- entityType,
2317
- source,
2318
- pagination
2319
- }) {
2320
- return this.stores.scores.listScoresByScorerId({ scorerId, entityId, entityType, source, pagination });
1900
+ async load({ tableName, keys }) {
1901
+ this.logger.debug(`MockStore: load called for ${tableName} with keys`, keys);
1902
+ const table = this.data[tableName];
1903
+ const records = Array.from(table.values());
1904
+ return records.filter((record) => Object.keys(keys).every((key) => record[key] === keys[key]))?.[0];
2321
1905
  }
2322
- async listScoresByRunId({
2323
- runId,
2324
- pagination
1906
+ async createTable({
1907
+ tableName,
1908
+ schema
2325
1909
  }) {
2326
- return this.stores.scores.listScoresByRunId({ runId, pagination });
1910
+ this.logger.debug(`MockStore: createTable called for ${tableName} with schema`, schema);
1911
+ this.data[tableName] = /* @__PURE__ */ new Map();
2327
1912
  }
2328
- async listScoresByEntityId({
2329
- entityId,
2330
- entityType,
2331
- pagination
2332
- }) {
2333
- return this.stores.scores.listScoresByEntityId({ entityId, entityType, pagination });
1913
+ async clearTable({ tableName }) {
1914
+ this.logger.debug(`MockStore: clearTable called for ${tableName}`);
1915
+ this.data[tableName].clear();
2334
1916
  }
2335
- async listScoresBySpan({
2336
- traceId,
2337
- spanId,
2338
- pagination
2339
- }) {
2340
- return this.stores.scores.listScoresBySpan({ traceId, spanId, pagination });
1917
+ async dropTable({ tableName }) {
1918
+ this.logger.debug(`MockStore: dropTable called for ${tableName}`);
1919
+ this.data[tableName].clear();
2341
1920
  }
2342
- async getWorkflowRunById({
2343
- runId,
2344
- workflowName
1921
+ async alterTable({
1922
+ tableName,
1923
+ schema
2345
1924
  }) {
2346
- return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
2347
- }
2348
- async deleteWorkflowRunById({ runId, workflowName }) {
2349
- return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
2350
- }
2351
- async createSpan(span) {
2352
- return this.stores.observability.createSpan(span);
2353
- }
2354
- async updateSpan(params) {
2355
- return this.stores.observability.updateSpan(params);
2356
- }
2357
- async getTrace(traceId) {
2358
- return this.stores.observability.getTrace(traceId);
2359
- }
2360
- async batchCreateSpans(args) {
2361
- return this.stores.observability.batchCreateSpans(args);
2362
- }
2363
- async batchUpdateSpans(args) {
2364
- return this.stores.observability.batchUpdateSpans(args);
1925
+ this.logger.debug(`MockStore: alterTable called for ${tableName} with schema`, schema);
2365
1926
  }
2366
- async batchDeleteTraces(args) {
2367
- return this.stores.observability.batchDeleteTraces(args);
1927
+ async hasColumn(table, column) {
1928
+ this.logger.debug(`MockStore: hasColumn called for ${table} with column ${column}`);
1929
+ return true;
2368
1930
  }
2369
1931
  };
2370
- var MockStore = InMemoryStore;
2371
1932
 
2372
- exports.AGENTS_SCHEMA = AGENTS_SCHEMA;
2373
1933
  exports.AgentsStorage = AgentsStorage;
2374
1934
  exports.InMemoryAgentsStorage = InMemoryAgentsStorage;
1935
+ exports.InMemoryDB = InMemoryDB;
2375
1936
  exports.InMemoryMemory = InMemoryMemory;
2376
1937
  exports.InMemoryStore = InMemoryStore;
2377
1938
  exports.MastraStorage = MastraStorage;
@@ -2379,21 +1940,11 @@ exports.MemoryStorage = MemoryStorage;
2379
1940
  exports.MockStore = MockStore;
2380
1941
  exports.ObservabilityInMemory = ObservabilityInMemory;
2381
1942
  exports.ObservabilityStorage = ObservabilityStorage;
2382
- exports.SCORERS_SCHEMA = SCORERS_SCHEMA;
2383
- exports.SPAN_SCHEMA = SPAN_SCHEMA;
2384
1943
  exports.ScoresInMemory = ScoresInMemory;
2385
1944
  exports.ScoresStorage = ScoresStorage;
1945
+ exports.StorageDomain = StorageDomain;
2386
1946
  exports.StoreOperations = StoreOperations;
2387
1947
  exports.StoreOperationsInMemory = StoreOperationsInMemory;
2388
- exports.TABLE_AGENTS = TABLE_AGENTS;
2389
- exports.TABLE_MESSAGES = TABLE_MESSAGES;
2390
- exports.TABLE_RESOURCES = TABLE_RESOURCES;
2391
- exports.TABLE_SCHEMAS = TABLE_SCHEMAS;
2392
- exports.TABLE_SCORERS = TABLE_SCORERS;
2393
- exports.TABLE_SPANS = TABLE_SPANS;
2394
- exports.TABLE_THREADS = TABLE_THREADS;
2395
- exports.TABLE_TRACES = TABLE_TRACES;
2396
- exports.TABLE_WORKFLOW_SNAPSHOT = TABLE_WORKFLOW_SNAPSHOT;
2397
1948
  exports.WorkflowsInMemory = WorkflowsInMemory;
2398
1949
  exports.WorkflowsStorage = WorkflowsStorage;
2399
1950
  exports.calculatePagination = calculatePagination;
@@ -2401,10 +1952,12 @@ exports.createStorageErrorId = createStorageErrorId;
2401
1952
  exports.createStoreErrorId = createStoreErrorId;
2402
1953
  exports.createVectorErrorId = createVectorErrorId;
2403
1954
  exports.ensureDate = ensureDate;
1955
+ exports.getDefaultValue = getDefaultValue;
1956
+ exports.getSqlType = getSqlType;
2404
1957
  exports.normalizePerPage = normalizePerPage;
2405
1958
  exports.safelyParseJSON = safelyParseJSON;
2406
1959
  exports.serializeDate = serializeDate;
2407
1960
  exports.transformRow = transformRow;
2408
1961
  exports.transformScoreRow = transformScoreRow;
2409
- //# sourceMappingURL=chunk-ETWAR2YE.cjs.map
2410
- //# sourceMappingURL=chunk-ETWAR2YE.cjs.map
1962
+ //# sourceMappingURL=chunk-OXV6QFSV.cjs.map
1963
+ //# sourceMappingURL=chunk-OXV6QFSV.cjs.map