@mastra/core 1.4.0 → 1.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/dist/agent/agent.d.ts +3 -2
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/index.cjs +13 -13
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
  7. package/dist/agent/message-list/index.cjs +18 -18
  8. package/dist/agent/message-list/index.js +1 -1
  9. package/dist/agent/message-list/merge/MessageMerger.d.ts.map +1 -1
  10. package/dist/agent/message-list/message-list.d.ts.map +1 -1
  11. package/dist/agent/types.d.ts +2 -2
  12. package/dist/agent/types.d.ts.map +1 -1
  13. package/dist/agent/workflows/prepare-stream/index.d.ts +1 -0
  14. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  15. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +1 -0
  16. package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
  17. package/dist/agent/workflows/prepare-stream/schema.d.ts +8 -0
  18. package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
  19. package/dist/{chunk-Y3TQ52UE.js → chunk-33TGTTTS.js} +4 -3
  20. package/dist/chunk-33TGTTTS.js.map +1 -0
  21. package/dist/{chunk-3X3CZUXI.js → chunk-3KJW4EMO.js} +660 -206
  22. package/dist/chunk-3KJW4EMO.js.map +1 -0
  23. package/dist/{chunk-YNNJLLFN.cjs → chunk-3YMDR4OL.cjs} +661 -207
  24. package/dist/chunk-3YMDR4OL.cjs.map +1 -0
  25. package/dist/{chunk-NJ7TL3LQ.js → chunk-5EOLBHHS.js} +26 -15
  26. package/dist/chunk-5EOLBHHS.js.map +1 -0
  27. package/dist/{chunk-RZ4CIIZR.js → chunk-6DUTLERJ.js} +4 -4
  28. package/dist/{chunk-RZ4CIIZR.js.map → chunk-6DUTLERJ.js.map} +1 -1
  29. package/dist/{chunk-VTE2OBKS.cjs → chunk-A6EWCOGA.cjs} +417 -77
  30. package/dist/chunk-A6EWCOGA.cjs.map +1 -0
  31. package/dist/{chunk-4XSAZPPS.js → chunk-A7V2NSY3.js} +313 -137
  32. package/dist/chunk-A7V2NSY3.js.map +1 -0
  33. package/dist/{chunk-FLPEGTEK.js → chunk-AIRMLZ43.js} +5 -5
  34. package/dist/{chunk-FLPEGTEK.js.map → chunk-AIRMLZ43.js.map} +1 -1
  35. package/dist/{chunk-DBSVT6AR.cjs → chunk-BKQAP27M.cjs} +9 -9
  36. package/dist/{chunk-DBSVT6AR.cjs.map → chunk-BKQAP27M.cjs.map} +1 -1
  37. package/dist/{chunk-RS6CZXGA.js → chunk-BQHWJLXU.js} +15 -4
  38. package/dist/chunk-BQHWJLXU.js.map +1 -0
  39. package/dist/{chunk-V2MLGA7T.js → chunk-CXVMDV2B.js} +417 -78
  40. package/dist/chunk-CXVMDV2B.js.map +1 -0
  41. package/dist/{chunk-NKYWDNCI.cjs → chunk-E2FHTXAI.cjs} +7 -7
  42. package/dist/{chunk-NKYWDNCI.cjs.map → chunk-E2FHTXAI.cjs.map} +1 -1
  43. package/dist/{chunk-7UWHFWST.cjs → chunk-EAZ6YDCQ.cjs} +15 -3
  44. package/dist/chunk-EAZ6YDCQ.cjs.map +1 -0
  45. package/dist/{chunk-64WGYTQK.cjs → chunk-FTBLAVTF.cjs} +55 -55
  46. package/dist/{chunk-64WGYTQK.cjs.map → chunk-FTBLAVTF.cjs.map} +1 -1
  47. package/dist/{chunk-4EHGOATH.js → chunk-FZ5DRHKE.js} +1337 -547
  48. package/dist/chunk-FZ5DRHKE.js.map +1 -0
  49. package/dist/{chunk-4TQ4EBYX.js → chunk-GEDGDKQ6.js} +9 -9
  50. package/dist/chunk-GEDGDKQ6.js.map +1 -0
  51. package/dist/{chunk-QTTWRCB5.js → chunk-I3AWF54W.js} +5 -5
  52. package/dist/{chunk-QTTWRCB5.js.map → chunk-I3AWF54W.js.map} +1 -1
  53. package/dist/{chunk-U2HKJZCI.js → chunk-IBNCZTNQ.js} +6 -6
  54. package/dist/{chunk-U2HKJZCI.js.map → chunk-IBNCZTNQ.js.map} +1 -1
  55. package/dist/{chunk-3JVFFAJX.cjs → chunk-IJIE3ZID.cjs} +27 -16
  56. package/dist/chunk-IJIE3ZID.cjs.map +1 -0
  57. package/dist/{chunk-NZG2JAKS.cjs → chunk-JWG272ZZ.cjs} +19 -19
  58. package/dist/chunk-JWG272ZZ.cjs.map +1 -0
  59. package/dist/{chunk-BP7VYTOP.cjs → chunk-JZ6TH4HQ.cjs} +954 -401
  60. package/dist/chunk-JZ6TH4HQ.cjs.map +1 -0
  61. package/dist/{chunk-SU5APAM6.cjs → chunk-KNXZ7KYL.cjs} +94 -6
  62. package/dist/chunk-KNXZ7KYL.cjs.map +1 -0
  63. package/dist/{chunk-CYUP7QWT.cjs → chunk-KRAGJ433.cjs} +4 -3
  64. package/dist/chunk-KRAGJ433.cjs.map +1 -0
  65. package/dist/{chunk-XDD5V446.cjs → chunk-MDC6VYA6.cjs} +6 -2
  66. package/dist/{chunk-XDD5V446.cjs.map → chunk-MDC6VYA6.cjs.map} +1 -1
  67. package/dist/{chunk-AXHBJ4GX.js → chunk-NN26FSKL.js} +10 -8
  68. package/dist/chunk-NN26FSKL.js.map +1 -0
  69. package/dist/{chunk-AY6DBRS3.js → chunk-OHLVZVIK.js} +36 -2
  70. package/dist/chunk-OHLVZVIK.js.map +1 -0
  71. package/dist/{chunk-5Q5Y34SS.js → chunk-PECKKR4C.js} +4 -4
  72. package/dist/{chunk-5Q5Y34SS.js.map → chunk-PECKKR4C.js.map} +1 -1
  73. package/dist/{chunk-HYRYTTMT.cjs → chunk-PHHJLGZU.cjs} +9 -9
  74. package/dist/{chunk-HYRYTTMT.cjs.map → chunk-PHHJLGZU.cjs.map} +1 -1
  75. package/dist/{chunk-65PHUUMF.cjs → chunk-QDH6MVJ7.cjs} +24 -22
  76. package/dist/chunk-QDH6MVJ7.cjs.map +1 -0
  77. package/dist/{chunk-VD5YA6RH.cjs → chunk-QSN5KQXZ.cjs} +18 -18
  78. package/dist/{chunk-VD5YA6RH.cjs.map → chunk-QSN5KQXZ.cjs.map} +1 -1
  79. package/dist/{chunk-4IJ4UDZX.cjs → chunk-RH2K66O2.cjs} +399 -223
  80. package/dist/chunk-RH2K66O2.cjs.map +1 -0
  81. package/dist/{chunk-4KFEMXTV.cjs → chunk-S4VVZI4E.cjs} +1361 -546
  82. package/dist/chunk-S4VVZI4E.cjs.map +1 -0
  83. package/dist/{chunk-ZATLLPIH.js → chunk-TPDMP7OD.js} +6 -2
  84. package/dist/chunk-TPDMP7OD.js.map +1 -0
  85. package/dist/{chunk-PS5ONCXY.js → chunk-UZFGMMKU.js} +82 -4
  86. package/dist/chunk-UZFGMMKU.js.map +1 -0
  87. package/dist/{chunk-7NKUSQEV.js → chunk-YIN5F7VO.js} +936 -389
  88. package/dist/chunk-YIN5F7VO.js.map +1 -0
  89. package/dist/{chunk-CZ4NQANZ.cjs → chunk-YW54RH77.cjs} +36 -2
  90. package/dist/chunk-YW54RH77.cjs.map +1 -0
  91. package/dist/datasets/experiment/executor.d.ts.map +1 -1
  92. package/dist/datasets/index.cjs +17 -17
  93. package/dist/datasets/index.js +2 -2
  94. package/dist/docs/SKILL.md +27 -1
  95. package/dist/docs/assets/SOURCE_MAP.json +463 -389
  96. package/dist/docs/references/docs-agents-processors.md +52 -0
  97. package/dist/docs/references/docs-observability-datasets-overview.md +188 -0
  98. package/dist/docs/references/docs-observability-datasets-running-experiments.md +266 -0
  99. package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +7 -4
  100. package/dist/docs/references/reference-agents-generate.md +1 -1
  101. package/dist/docs/references/reference-configuration.md +3 -4
  102. package/dist/docs/references/reference-datasets-addItem.md +35 -0
  103. package/dist/docs/references/reference-datasets-addItems.md +33 -0
  104. package/dist/docs/references/reference-datasets-compareExperiments.md +48 -0
  105. package/dist/docs/references/reference-datasets-create.md +49 -0
  106. package/dist/docs/references/reference-datasets-dataset.md +78 -0
  107. package/dist/docs/references/reference-datasets-datasets-manager.md +84 -0
  108. package/dist/docs/references/reference-datasets-delete.md +23 -0
  109. package/dist/docs/references/reference-datasets-deleteExperiment.md +25 -0
  110. package/dist/docs/references/reference-datasets-deleteItem.md +25 -0
  111. package/dist/docs/references/reference-datasets-deleteItems.md +27 -0
  112. package/dist/docs/references/reference-datasets-get.md +29 -0
  113. package/dist/docs/references/reference-datasets-getDetails.md +45 -0
  114. package/dist/docs/references/reference-datasets-getExperiment.md +28 -0
  115. package/dist/docs/references/reference-datasets-getItem.md +31 -0
  116. package/dist/docs/references/reference-datasets-getItemHistory.md +29 -0
  117. package/dist/docs/references/reference-datasets-list.md +29 -0
  118. package/dist/docs/references/reference-datasets-listExperimentResults.md +37 -0
  119. package/dist/docs/references/reference-datasets-listExperiments.md +31 -0
  120. package/dist/docs/references/reference-datasets-listItems.md +44 -0
  121. package/dist/docs/references/reference-datasets-listVersions.md +31 -0
  122. package/dist/docs/references/reference-datasets-startExperiment.md +60 -0
  123. package/dist/docs/references/reference-datasets-startExperimentAsync.md +41 -0
  124. package/dist/docs/references/reference-datasets-update.md +46 -0
  125. package/dist/docs/references/reference-datasets-updateItem.md +36 -0
  126. package/dist/docs/references/reference-memory-observational-memory.md +36 -0
  127. package/dist/docs/references/reference-processors-processor-interface.md +4 -0
  128. package/dist/docs/references/reference-tools-create-tool.md +1 -1
  129. package/dist/docs/references/reference.md +24 -0
  130. package/dist/editor/index.d.ts +1 -1
  131. package/dist/editor/index.d.ts.map +1 -1
  132. package/dist/editor/types.d.ts +108 -2
  133. package/dist/editor/types.d.ts.map +1 -1
  134. package/dist/evals/index.cjs +20 -20
  135. package/dist/evals/index.js +3 -3
  136. package/dist/evals/scoreTraces/index.cjs +5 -5
  137. package/dist/evals/scoreTraces/index.js +2 -2
  138. package/dist/harness/harness.d.ts +281 -0
  139. package/dist/harness/harness.d.ts.map +1 -0
  140. package/dist/harness/index.cjs +1728 -0
  141. package/dist/harness/index.cjs.map +1 -0
  142. package/dist/harness/index.d.ts +4 -0
  143. package/dist/harness/index.d.ts.map +1 -0
  144. package/dist/harness/index.js +1723 -0
  145. package/dist/harness/index.js.map +1 -0
  146. package/dist/harness/tools.d.ts +65 -0
  147. package/dist/harness/tools.d.ts.map +1 -0
  148. package/dist/harness/types.d.ts +561 -0
  149. package/dist/harness/types.d.ts.map +1 -0
  150. package/dist/index.cjs +2 -2
  151. package/dist/index.js +1 -1
  152. package/dist/integration/index.cjs +2 -2
  153. package/dist/integration/index.js +1 -1
  154. package/dist/llm/index.cjs +20 -20
  155. package/dist/llm/index.js +3 -3
  156. package/dist/llm/model/gateways/constants.d.ts.map +1 -1
  157. package/dist/llm/model/gateways/models-dev.d.ts +2 -3
  158. package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
  159. package/dist/llm/model/provider-types.generated.d.ts +312 -93
  160. package/dist/loop/index.cjs +12 -12
  161. package/dist/loop/index.js +1 -1
  162. package/dist/loop/network/index.d.ts.map +1 -1
  163. package/dist/loop/test-utils/options.d.ts.map +1 -1
  164. package/dist/loop/test-utils/tools.d.ts.map +1 -1
  165. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  166. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  167. package/dist/loop/workflows/stream.d.ts.map +1 -1
  168. package/dist/mastra/index.cjs +2 -2
  169. package/dist/mastra/index.d.ts +3 -3
  170. package/dist/mastra/index.d.ts.map +1 -1
  171. package/dist/mastra/index.js +1 -1
  172. package/dist/memory/index.cjs +14 -14
  173. package/dist/memory/index.js +1 -1
  174. package/dist/memory/memory.d.ts +10 -0
  175. package/dist/memory/memory.d.ts.map +1 -1
  176. package/dist/memory/types.d.ts +24 -0
  177. package/dist/memory/types.d.ts.map +1 -1
  178. package/dist/models-dev-BW2GAM3K.cjs +12 -0
  179. package/dist/{models-dev-PPIXUUCU.cjs.map → models-dev-BW2GAM3K.cjs.map} +1 -1
  180. package/dist/models-dev-MDI5E2YA.js +3 -0
  181. package/dist/{models-dev-FQVUTQ7L.js.map → models-dev-MDI5E2YA.js.map} +1 -1
  182. package/dist/observability/index.cjs +11 -11
  183. package/dist/observability/index.js +1 -1
  184. package/dist/observability/utils.d.ts.map +1 -1
  185. package/dist/processors/index.cjs +41 -41
  186. package/dist/processors/index.js +1 -1
  187. package/dist/processors/processors/skills.d.ts +5 -0
  188. package/dist/processors/processors/skills.d.ts.map +1 -1
  189. package/dist/processors/runner.d.ts +2 -2
  190. package/dist/processors/runner.d.ts.map +1 -1
  191. package/dist/processors/step-schema.d.ts +218 -49453
  192. package/dist/processors/step-schema.d.ts.map +1 -1
  193. package/dist/provider-registry-4PH2JPIA.cjs +40 -0
  194. package/dist/{provider-registry-6LZAGQET.cjs.map → provider-registry-4PH2JPIA.cjs.map} +1 -1
  195. package/dist/provider-registry-VEJ3PN4S.js +3 -0
  196. package/dist/{provider-registry-QUNT7S55.js.map → provider-registry-VEJ3PN4S.js.map} +1 -1
  197. package/dist/provider-registry.json +657 -203
  198. package/dist/relevance/index.cjs +3 -3
  199. package/dist/relevance/index.js +1 -1
  200. package/dist/server/composite-auth.d.ts.map +1 -1
  201. package/dist/server/index.cjs +6 -1
  202. package/dist/server/index.cjs.map +1 -1
  203. package/dist/server/index.js +6 -1
  204. package/dist/server/index.js.map +1 -1
  205. package/dist/storage/base.d.ts +4 -1
  206. package/dist/storage/base.d.ts.map +1 -1
  207. package/dist/storage/constants.cjs +82 -42
  208. package/dist/storage/constants.d.ts +11 -1
  209. package/dist/storage/constants.d.ts.map +1 -1
  210. package/dist/storage/constants.js +1 -1
  211. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  212. package/dist/storage/domains/blobs/base.d.ts +47 -0
  213. package/dist/storage/domains/blobs/base.d.ts.map +1 -0
  214. package/dist/storage/domains/blobs/index.d.ts +3 -0
  215. package/dist/storage/domains/blobs/index.d.ts.map +1 -0
  216. package/dist/storage/domains/blobs/inmemory.d.ts +17 -0
  217. package/dist/storage/domains/blobs/inmemory.d.ts.map +1 -0
  218. package/dist/storage/domains/datasets/inmemory.d.ts.map +1 -1
  219. package/dist/storage/domains/index.d.ts +3 -0
  220. package/dist/storage/domains/index.d.ts.map +1 -1
  221. package/dist/storage/domains/inmemory-db.d.ts +7 -1
  222. package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
  223. package/dist/storage/domains/mcp-clients/inmemory.d.ts.map +1 -1
  224. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  225. package/dist/storage/domains/prompt-blocks/inmemory.d.ts.map +1 -1
  226. package/dist/storage/domains/scorer-definitions/inmemory.d.ts.map +1 -1
  227. package/dist/storage/domains/skills/base.d.ts +47 -0
  228. package/dist/storage/domains/skills/base.d.ts.map +1 -0
  229. package/dist/storage/domains/skills/index.d.ts +3 -0
  230. package/dist/storage/domains/skills/index.d.ts.map +1 -0
  231. package/dist/storage/domains/skills/inmemory.d.ts +31 -0
  232. package/dist/storage/domains/skills/inmemory.d.ts.map +1 -0
  233. package/dist/storage/domains/versioned.d.ts +12 -3
  234. package/dist/storage/domains/versioned.d.ts.map +1 -1
  235. package/dist/storage/domains/workspaces/base.d.ts +47 -0
  236. package/dist/storage/domains/workspaces/base.d.ts.map +1 -0
  237. package/dist/storage/domains/workspaces/index.d.ts +3 -0
  238. package/dist/storage/domains/workspaces/index.d.ts.map +1 -0
  239. package/dist/storage/domains/workspaces/inmemory.d.ts +31 -0
  240. package/dist/storage/domains/workspaces/inmemory.d.ts.map +1 -0
  241. package/dist/storage/index.cjs +202 -138
  242. package/dist/storage/index.js +2 -2
  243. package/dist/storage/mock.d.ts.map +1 -1
  244. package/dist/storage/types.d.ts +422 -12
  245. package/dist/storage/types.d.ts.map +1 -1
  246. package/dist/stream/base/output.d.ts.map +1 -1
  247. package/dist/stream/index.cjs +11 -11
  248. package/dist/stream/index.js +2 -2
  249. package/dist/test-utils/llm-mock.cjs +4 -4
  250. package/dist/test-utils/llm-mock.js +1 -1
  251. package/dist/tool-loop-agent/index.cjs +4 -4
  252. package/dist/tool-loop-agent/index.js +1 -1
  253. package/dist/tools/index.cjs +8 -4
  254. package/dist/tools/index.js +1 -1
  255. package/dist/tools/is-vercel-tool.cjs +2 -2
  256. package/dist/tools/is-vercel-tool.js +1 -1
  257. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  258. package/dist/tools/tool.d.ts +13 -0
  259. package/dist/tools/tool.d.ts.map +1 -1
  260. package/dist/tools/toolchecks.d.ts.map +1 -1
  261. package/dist/tools/types.d.ts +24 -0
  262. package/dist/tools/types.d.ts.map +1 -1
  263. package/dist/types/zod-compat.d.ts +27 -6
  264. package/dist/types/zod-compat.d.ts.map +1 -1
  265. package/dist/utils.cjs +23 -23
  266. package/dist/utils.js +1 -1
  267. package/dist/vector/index.cjs +12 -12
  268. package/dist/vector/index.js +2 -2
  269. package/dist/workflows/evented/index.cjs +10 -10
  270. package/dist/workflows/evented/index.js +1 -1
  271. package/dist/workflows/handlers/entry.d.ts.map +1 -1
  272. package/dist/workflows/index.cjs +25 -25
  273. package/dist/workflows/index.js +1 -1
  274. package/dist/workflows/workflow.d.ts +2 -2
  275. package/dist/workflows/workflow.d.ts.map +1 -1
  276. package/dist/workspace/constants/index.d.ts +1 -0
  277. package/dist/workspace/constants/index.d.ts.map +1 -1
  278. package/dist/workspace/errors.d.ts +3 -0
  279. package/dist/workspace/errors.d.ts.map +1 -1
  280. package/dist/workspace/filesystem/composite-filesystem.d.ts +75 -6
  281. package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -1
  282. package/dist/workspace/filesystem/local-filesystem.d.ts +42 -0
  283. package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
  284. package/dist/workspace/glob.d.ts +61 -0
  285. package/dist/workspace/glob.d.ts.map +1 -0
  286. package/dist/workspace/index.cjs +133 -41
  287. package/dist/workspace/index.d.ts +8 -1
  288. package/dist/workspace/index.d.ts.map +1 -1
  289. package/dist/workspace/index.js +1 -1
  290. package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
  291. package/dist/workspace/skills/composite-versioned-skill-source.d.ts +44 -0
  292. package/dist/workspace/skills/composite-versioned-skill-source.d.ts.map +1 -0
  293. package/dist/workspace/skills/index.d.ts +3 -0
  294. package/dist/workspace/skills/index.d.ts.map +1 -1
  295. package/dist/workspace/skills/local-skill-source.d.ts.map +1 -1
  296. package/dist/workspace/skills/publish.d.ts +34 -0
  297. package/dist/workspace/skills/publish.d.ts.map +1 -0
  298. package/dist/workspace/skills/skill-source.d.ts +2 -0
  299. package/dist/workspace/skills/skill-source.d.ts.map +1 -1
  300. package/dist/workspace/skills/types.d.ts +16 -0
  301. package/dist/workspace/skills/types.d.ts.map +1 -1
  302. package/dist/workspace/skills/versioned-skill-source.d.ts +20 -0
  303. package/dist/workspace/skills/versioned-skill-source.d.ts.map +1 -0
  304. package/dist/workspace/skills/workspace-skills.d.ts +5 -0
  305. package/dist/workspace/skills/workspace-skills.d.ts.map +1 -1
  306. package/dist/workspace/tools/delete-file.d.ts +5 -0
  307. package/dist/workspace/tools/delete-file.d.ts.map +1 -0
  308. package/dist/workspace/tools/edit-file.d.ts +7 -0
  309. package/dist/workspace/tools/edit-file.d.ts.map +1 -0
  310. package/dist/workspace/tools/execute-command.d.ts +7 -0
  311. package/dist/workspace/tools/execute-command.d.ts.map +1 -0
  312. package/dist/workspace/tools/file-stat.d.ts +4 -0
  313. package/dist/workspace/tools/file-stat.d.ts.map +1 -0
  314. package/dist/workspace/tools/grep.d.ts +9 -0
  315. package/dist/workspace/tools/grep.d.ts.map +1 -0
  316. package/dist/workspace/tools/helpers.d.ts +36 -0
  317. package/dist/workspace/tools/helpers.d.ts.map +1 -0
  318. package/dist/workspace/tools/index-content.d.ts +6 -0
  319. package/dist/workspace/tools/index-content.d.ts.map +1 -0
  320. package/dist/workspace/tools/index.d.ts +13 -1
  321. package/dist/workspace/tools/index.d.ts.map +1 -1
  322. package/dist/workspace/tools/list-files.d.ts +10 -0
  323. package/dist/workspace/tools/list-files.d.ts.map +1 -0
  324. package/dist/workspace/tools/mkdir.d.ts +5 -0
  325. package/dist/workspace/tools/mkdir.d.ts.map +1 -0
  326. package/dist/workspace/tools/read-file.d.ts +8 -0
  327. package/dist/workspace/tools/read-file.d.ts.map +1 -0
  328. package/dist/workspace/tools/search.d.ts +7 -0
  329. package/dist/workspace/tools/search.d.ts.map +1 -0
  330. package/dist/workspace/tools/tools.d.ts +5 -7
  331. package/dist/workspace/tools/tools.d.ts.map +1 -1
  332. package/dist/workspace/tools/tree-formatter.d.ts +2 -0
  333. package/dist/workspace/tools/tree-formatter.d.ts.map +1 -1
  334. package/dist/workspace/tools/write-file.d.ts +6 -0
  335. package/dist/workspace/tools/write-file.d.ts.map +1 -0
  336. package/dist/workspace/workspace.d.ts +56 -10
  337. package/dist/workspace/workspace.d.ts.map +1 -1
  338. package/harness.d.ts +1 -0
  339. package/package.json +8 -6
  340. package/src/llm/model/provider-types.generated.d.ts +312 -93
  341. package/dist/chunk-3JVFFAJX.cjs.map +0 -1
  342. package/dist/chunk-3X3CZUXI.js.map +0 -1
  343. package/dist/chunk-4EHGOATH.js.map +0 -1
  344. package/dist/chunk-4IJ4UDZX.cjs.map +0 -1
  345. package/dist/chunk-4KFEMXTV.cjs.map +0 -1
  346. package/dist/chunk-4TQ4EBYX.js.map +0 -1
  347. package/dist/chunk-4XSAZPPS.js.map +0 -1
  348. package/dist/chunk-65PHUUMF.cjs.map +0 -1
  349. package/dist/chunk-7NKUSQEV.js.map +0 -1
  350. package/dist/chunk-7UWHFWST.cjs.map +0 -1
  351. package/dist/chunk-AXHBJ4GX.js.map +0 -1
  352. package/dist/chunk-AY6DBRS3.js.map +0 -1
  353. package/dist/chunk-BP7VYTOP.cjs.map +0 -1
  354. package/dist/chunk-CYUP7QWT.cjs.map +0 -1
  355. package/dist/chunk-CZ4NQANZ.cjs.map +0 -1
  356. package/dist/chunk-NJ7TL3LQ.js.map +0 -1
  357. package/dist/chunk-NZG2JAKS.cjs.map +0 -1
  358. package/dist/chunk-PS5ONCXY.js.map +0 -1
  359. package/dist/chunk-RS6CZXGA.js.map +0 -1
  360. package/dist/chunk-SU5APAM6.cjs.map +0 -1
  361. package/dist/chunk-V2MLGA7T.js.map +0 -1
  362. package/dist/chunk-VTE2OBKS.cjs.map +0 -1
  363. package/dist/chunk-Y3TQ52UE.js.map +0 -1
  364. package/dist/chunk-YNNJLLFN.cjs.map +0 -1
  365. package/dist/chunk-ZATLLPIH.js.map +0 -1
  366. package/dist/models-dev-FQVUTQ7L.js +0 -3
  367. package/dist/models-dev-PPIXUUCU.cjs +0 -12
  368. package/dist/provider-registry-6LZAGQET.cjs +0 -40
  369. package/dist/provider-registry-QUNT7S55.js +0 -3
@@ -1,8 +1,9 @@
1
- import { MessageList } from './chunk-AY6DBRS3.js';
2
- import { TABLE_SCHEMAS, TABLE_SCORERS, listTracesArgsSchema, toTraceSpans, TABLE_WORKFLOW_SNAPSHOT } from './chunk-PS5ONCXY.js';
3
- import { deepEqual } from './chunk-AXHBJ4GX.js';
1
+ import { MessageList } from './chunk-OHLVZVIK.js';
2
+ import { TABLE_SCHEMAS, TABLE_SCORERS, listTracesArgsSchema, toTraceSpans, TABLE_WORKFLOW_SNAPSHOT } from './chunk-UZFGMMKU.js';
3
+ import { deepEqual } from './chunk-NN26FSKL.js';
4
4
  import { MastraError } from './chunk-FJEVLHJT.js';
5
5
  import { MastraBase } from './chunk-WCAFTXGK.js';
6
+ import { randomUUID } from 'crypto';
6
7
  import { jsonSchemaToZod } from '@mastra/schema-compat/json-to-zod';
7
8
  import { z } from 'zod';
8
9
 
@@ -65,7 +66,9 @@ var MastraCompositeStore = class extends MastraBase {
65
66
  experiments: domainOverrides.experiments ?? defaultStores?.experiments,
66
67
  promptBlocks: domainOverrides.promptBlocks ?? defaultStores?.promptBlocks,
67
68
  scorerDefinitions: domainOverrides.scorerDefinitions ?? defaultStores?.scorerDefinitions,
68
- mcpClients: domainOverrides.mcpClients ?? defaultStores?.mcpClients
69
+ mcpClients: domainOverrides.mcpClients ?? defaultStores?.mcpClients,
70
+ workspaces: domainOverrides.workspaces ?? defaultStores?.workspaces,
71
+ skills: domainOverrides.skills ?? defaultStores?.skills
69
72
  };
70
73
  }
71
74
  }
@@ -125,6 +128,15 @@ var MastraCompositeStore = class extends MastraBase {
125
128
  if (this.stores?.mcpClients) {
126
129
  initTasks.push(this.stores.mcpClients.init());
127
130
  }
131
+ if (this.stores?.workspaces) {
132
+ initTasks.push(this.stores.workspaces.init());
133
+ }
134
+ if (this.stores?.skills) {
135
+ initTasks.push(this.stores.skills.init());
136
+ }
137
+ if (this.stores?.blobs) {
138
+ initTasks.push(this.stores.blobs.init());
139
+ }
128
140
  this.hasInitialized = Promise.all(initTasks).then(() => true);
129
141
  await this.hasInitialized;
130
142
  }
@@ -174,22 +186,28 @@ var VersionedStorageDomain = class extends StorageDomain {
174
186
  return result;
175
187
  }
176
188
  /**
177
- * Resolves an entity by merging its thin record with the active (or latest) version config.
189
+ * Resolves an entity by merging its thin record with the active or latest version config.
190
+ * Pass `{ status: 'draft' }` to resolve with the latest version instead of the active one.
178
191
  */
179
- async getByIdResolved(id) {
192
+ async getByIdResolved(id, options) {
180
193
  const entity = await this.getById(id);
181
194
  if (!entity) {
182
195
  return null;
183
196
  }
184
- return this.resolveEntity(entity);
197
+ return this.resolveEntity(entity, options);
185
198
  }
186
199
  /**
187
200
  * Lists entities with version resolution.
201
+ * When `status` is `'draft'`, each entity is resolved with its latest version.
202
+ * When `status` is `'published'` (default), each entity is resolved with its active version.
188
203
  */
189
204
  async listResolved(args) {
190
205
  const result = await this.list(args);
206
+ const status = args?.status;
191
207
  const entities = result[this.listKey];
192
- const resolved = await Promise.all(entities.map((entity) => this.resolveEntity(entity)));
208
+ const resolved = await Promise.all(
209
+ entities.map((entity) => this.resolveEntity(entity, { status }))
210
+ );
193
211
  return {
194
212
  ...result,
195
213
  [this.listKey]: resolved
@@ -197,25 +215,33 @@ var VersionedStorageDomain = class extends StorageDomain {
197
215
  }
198
216
  /**
199
217
  * Resolves a single entity by merging it with its active or latest version.
218
+ * - `status: 'published'` (default) — use activeVersionId, fall back to latest.
219
+ * - `status: 'draft'` — always use the latest version.
200
220
  */
201
- async resolveEntity(entity) {
221
+ async resolveEntity(entity, options) {
222
+ const status = options?.status || "published";
202
223
  let version = null;
203
- if (entity.activeVersionId) {
204
- version = await this.getVersion(entity.activeVersionId);
224
+ if (status === "draft") {
225
+ version = await this.getLatestVersion(entity.id);
226
+ } else {
227
+ if (entity.activeVersionId) {
228
+ version = await this.getVersion(entity.activeVersionId);
229
+ if (!version) {
230
+ this.logger?.warn?.(
231
+ `Entity ${entity.id} has activeVersionId ${entity.activeVersionId} but version not found. Falling back to latest version.`
232
+ );
233
+ }
234
+ }
205
235
  if (!version) {
206
- this.logger?.warn?.(
207
- `Entity ${entity.id} has activeVersionId ${entity.activeVersionId} but version not found. Falling back to latest version.`
208
- );
236
+ version = await this.getLatestVersion(entity.id);
209
237
  }
210
238
  }
211
- if (!version) {
212
- version = await this.getLatestVersion(entity.id);
213
- }
214
239
  if (version) {
215
240
  const snapshotConfig = this.extractSnapshotConfig(version);
216
241
  return {
217
242
  ...entity,
218
- ...snapshotConfig
243
+ ...snapshotConfig,
244
+ resolvedVersionId: version.id
219
245
  };
220
246
  }
221
247
  return entity;
@@ -311,25 +337,7 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
311
337
  if (!existingAgent) {
312
338
  throw new Error(`Agent with id ${id} not found`);
313
339
  }
314
- const { authorId, activeVersionId, metadata, ...configFields } = updates;
315
- const configFieldNames = [
316
- "name",
317
- "description",
318
- "instructions",
319
- "model",
320
- "tools",
321
- "defaultOptions",
322
- "workflows",
323
- "agents",
324
- "integrationTools",
325
- "inputProcessors",
326
- "outputProcessors",
327
- "memory",
328
- "scorers",
329
- "mcpClients",
330
- "requestContextSchema"
331
- ];
332
- const hasConfigUpdate = configFieldNames.some((field) => field in configFields);
340
+ const { authorId, activeVersionId, metadata, status } = updates;
333
341
  const updatedAgent = {
334
342
  ...existingAgent,
335
343
  ...authorId !== void 0 && { authorId },
@@ -337,48 +345,9 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
337
345
  ...metadata !== void 0 && {
338
346
  metadata: { ...existingAgent.metadata, ...metadata }
339
347
  },
348
+ ...status !== void 0 && { status },
340
349
  updatedAt: /* @__PURE__ */ new Date()
341
350
  };
342
- if (activeVersionId !== void 0) {
343
- updatedAgent.status = "published";
344
- }
345
- if (hasConfigUpdate) {
346
- const latestVersion = await this.getLatestVersion(id);
347
- if (!latestVersion) {
348
- throw new Error(`No versions found for agent ${id}`);
349
- }
350
- const {
351
- id: _versionId,
352
- agentId: _agentId,
353
- versionNumber: _versionNumber,
354
- changedFields: _changedFields,
355
- changeMessage: _changeMessage,
356
- createdAt: _createdAt,
357
- ...latestConfig
358
- } = latestVersion;
359
- const sanitizedConfigFields = Object.fromEntries(
360
- Object.entries(configFields).map(([key, value]) => [key, value === null ? void 0 : value])
361
- );
362
- const newConfig = {
363
- ...latestConfig,
364
- ...sanitizedConfigFields
365
- };
366
- const changedFields = configFieldNames.filter(
367
- (field) => field in configFields && JSON.stringify(configFields[field]) !== JSON.stringify(latestConfig[field])
368
- );
369
- if (changedFields.length > 0) {
370
- const newVersionId = crypto.randomUUID();
371
- const newVersionNumber = latestVersion.versionNumber + 1;
372
- await this.createVersion({
373
- id: newVersionId,
374
- agentId: id,
375
- versionNumber: newVersionNumber,
376
- ...newConfig,
377
- changedFields,
378
- changeMessage: `Updated ${changedFields.join(", ")}`
379
- });
380
- }
381
- }
382
351
  this.db.agents.set(id, updatedAgent);
383
352
  return this.deepCopyAgent(updatedAgent);
384
353
  }
@@ -388,7 +357,7 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
388
357
  await this.deleteVersionsByParentId(id);
389
358
  }
390
359
  async list(args) {
391
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
360
+ const { page = 0, perPage: perPageInput, orderBy, authorId, metadata, status } = args || {};
392
361
  const { field, direction } = this.parseOrderBy(orderBy);
393
362
  this.logger.debug(`InMemoryAgentsStorage: list called`);
394
363
  const perPage = normalizePerPage(perPageInput, 100);
@@ -400,6 +369,9 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
400
369
  throw new Error("page value too large");
401
370
  }
402
371
  let agents = Array.from(this.db.agents.values());
372
+ if (status) {
373
+ agents = agents.filter((agent) => agent.status === status);
374
+ }
403
375
  if (authorId !== void 0) {
404
376
  agents = agents.filter((agent) => agent.authorId === authorId);
405
377
  }
@@ -575,6 +547,10 @@ var InMemoryDB = class {
575
547
  scorerDefinitionVersions = /* @__PURE__ */ new Map();
576
548
  mcpClients = /* @__PURE__ */ new Map();
577
549
  mcpClientVersions = /* @__PURE__ */ new Map();
550
+ workspaces = /* @__PURE__ */ new Map();
551
+ workspaceVersions = /* @__PURE__ */ new Map();
552
+ skills = /* @__PURE__ */ new Map();
553
+ skillVersions = /* @__PURE__ */ new Map();
578
554
  /** Observational memory records, keyed by resourceId, each holding array of records (generations) */
579
555
  observationalMemory = /* @__PURE__ */ new Map();
580
556
  // Dataset domain maps
@@ -603,6 +579,10 @@ var InMemoryDB = class {
603
579
  this.scorerDefinitionVersions.clear();
604
580
  this.mcpClients.clear();
605
581
  this.mcpClientVersions.clear();
582
+ this.workspaces.clear();
583
+ this.workspaceVersions.clear();
584
+ this.skills.clear();
585
+ this.skillVersions.clear();
606
586
  this.observationalMemory.clear();
607
587
  this.datasets.clear();
608
588
  this.datasetItems.clear();
@@ -686,9 +666,7 @@ var InMemoryMCPClientsStorage = class extends MCPClientsStorage {
686
666
  if (!existingConfig) {
687
667
  throw new Error(`MCP client with id ${id} not found`);
688
668
  }
689
- const { authorId, activeVersionId, metadata, status, ...configFields } = updates;
690
- const configFieldNames = ["name", "description", "servers"];
691
- const hasConfigUpdate = configFieldNames.some((field) => field in configFields);
669
+ const { authorId, activeVersionId, metadata, status } = updates;
692
670
  const updatedConfig = {
693
671
  ...existingConfig,
694
672
  ...authorId !== void 0 && { authorId },
@@ -699,43 +677,6 @@ var InMemoryMCPClientsStorage = class extends MCPClientsStorage {
699
677
  },
700
678
  updatedAt: /* @__PURE__ */ new Date()
701
679
  };
702
- if (activeVersionId !== void 0 && status === void 0) {
703
- updatedConfig.status = "published";
704
- }
705
- if (hasConfigUpdate) {
706
- const latestVersion = await this.getLatestVersion(id);
707
- if (!latestVersion) {
708
- throw new Error(`No versions found for MCP client ${id}`);
709
- }
710
- const {
711
- id: _versionId,
712
- mcpClientId: _mcpClientId,
713
- versionNumber: _versionNumber,
714
- changedFields: _changedFields,
715
- changeMessage: _changeMessage,
716
- createdAt: _createdAt,
717
- ...latestConfig
718
- } = latestVersion;
719
- const newConfig = {
720
- ...latestConfig,
721
- ...configFields
722
- };
723
- const changedFields = configFieldNames.filter(
724
- (field) => field in configFields && JSON.stringify(configFields[field]) !== JSON.stringify(latestConfig[field])
725
- );
726
- if (changedFields.length > 0) {
727
- const newVersionId = crypto.randomUUID();
728
- const newVersionNumber = latestVersion.versionNumber + 1;
729
- await this.createVersion({
730
- id: newVersionId,
731
- mcpClientId: id,
732
- versionNumber: newVersionNumber,
733
- ...newConfig,
734
- changedFields,
735
- changeMessage: `Updated ${changedFields.join(", ")}`
736
- });
737
- }
738
- }
739
680
  this.db.mcpClients.set(id, updatedConfig);
740
681
  return this.deepCopyConfig(updatedConfig);
741
682
  }
@@ -745,7 +686,7 @@ var InMemoryMCPClientsStorage = class extends MCPClientsStorage {
745
686
  await this.deleteVersionsByParentId(id);
746
687
  }
747
688
  async list(args) {
748
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
689
+ const { page = 0, perPage: perPageInput, orderBy, authorId, metadata, status } = args || {};
749
690
  const { field, direction } = this.parseOrderBy(orderBy);
750
691
  this.logger.debug(`InMemoryMCPClientsStorage: list called`);
751
692
  const perPage = normalizePerPage(perPageInput, 100);
@@ -757,6 +698,9 @@ var InMemoryMCPClientsStorage = class extends MCPClientsStorage {
757
698
  throw new Error("page value too large");
758
699
  }
759
700
  let configs = Array.from(this.db.mcpClients.values());
701
+ if (status) {
702
+ configs = configs.filter((config) => config.status === status);
703
+ }
760
704
  if (authorId !== void 0) {
761
705
  configs = configs.filter((config) => config.authorId === authorId);
762
706
  }
@@ -2745,9 +2689,7 @@ var InMemoryPromptBlocksStorage = class extends PromptBlocksStorage {
2745
2689
  if (!existingBlock) {
2746
2690
  throw new Error(`Prompt block with id ${id} not found`);
2747
2691
  }
2748
- const { authorId, activeVersionId, metadata, status, ...configFields } = updates;
2749
- const configFieldNames = ["name", "description", "content", "rules"];
2750
- const hasConfigUpdate = configFieldNames.some((field) => field in configFields);
2692
+ const { authorId, activeVersionId, metadata, status } = updates;
2751
2693
  const updatedBlock = {
2752
2694
  ...existingBlock,
2753
2695
  ...authorId !== void 0 && { authorId },
@@ -2758,43 +2700,6 @@ var InMemoryPromptBlocksStorage = class extends PromptBlocksStorage {
2758
2700
  },
2759
2701
  updatedAt: /* @__PURE__ */ new Date()
2760
2702
  };
2761
- if (activeVersionId !== void 0) {
2762
- updatedBlock.status = "published";
2763
- }
2764
- if (hasConfigUpdate) {
2765
- const latestVersion = await this.getLatestVersion(id);
2766
- if (!latestVersion) {
2767
- throw new Error(`No versions found for prompt block ${id}`);
2768
- }
2769
- const {
2770
- id: _versionId,
2771
- blockId: _blockId,
2772
- versionNumber: _versionNumber,
2773
- changedFields: _changedFields,
2774
- changeMessage: _changeMessage,
2775
- createdAt: _createdAt,
2776
- ...latestConfig
2777
- } = latestVersion;
2778
- const newConfig = {
2779
- ...latestConfig,
2780
- ...configFields
2781
- };
2782
- const changedFields = configFieldNames.filter(
2783
- (field) => field in configFields && JSON.stringify(configFields[field]) !== JSON.stringify(latestConfig[field])
2784
- );
2785
- if (changedFields.length > 0) {
2786
- const newVersionId = crypto.randomUUID();
2787
- const newVersionNumber = latestVersion.versionNumber + 1;
2788
- await this.createVersion({
2789
- id: newVersionId,
2790
- blockId: id,
2791
- versionNumber: newVersionNumber,
2792
- ...newConfig,
2793
- changedFields,
2794
- changeMessage: `Updated ${changedFields.join(", ")}`
2795
- });
2796
- }
2797
- }
2798
2703
  this.db.promptBlocks.set(id, updatedBlock);
2799
2704
  return this.deepCopyBlock(updatedBlock);
2800
2705
  }
@@ -2804,7 +2709,7 @@ var InMemoryPromptBlocksStorage = class extends PromptBlocksStorage {
2804
2709
  await this.deleteVersionsByParentId(id);
2805
2710
  }
2806
2711
  async list(args) {
2807
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
2712
+ const { page = 0, perPage: perPageInput, orderBy, authorId, metadata, status } = args || {};
2808
2713
  const { field, direction } = this.parseOrderBy(orderBy);
2809
2714
  this.logger.debug(`InMemoryPromptBlocksStorage: list called`);
2810
2715
  const perPage = normalizePerPage(perPageInput, 100);
@@ -2816,6 +2721,9 @@ var InMemoryPromptBlocksStorage = class extends PromptBlocksStorage {
2816
2721
  throw new Error("page value too large");
2817
2722
  }
2818
2723
  let blocks = Array.from(this.db.promptBlocks.values());
2724
+ if (status) {
2725
+ blocks = blocks.filter((block) => block.status === status);
2726
+ }
2819
2727
  if (authorId !== void 0) {
2820
2728
  blocks = blocks.filter((block) => block.authorId === authorId);
2821
2729
  }
@@ -3047,18 +2955,7 @@ var InMemoryScorerDefinitionsStorage = class extends ScorerDefinitionsStorage {
3047
2955
  if (!existingScorer) {
3048
2956
  throw new Error(`Scorer definition with id ${id} not found`);
3049
2957
  }
3050
- const { authorId, activeVersionId, metadata, status, ...configFields } = updates;
3051
- const configFieldNames = [
3052
- "name",
3053
- "description",
3054
- "type",
3055
- "model",
3056
- "instructions",
3057
- "scoreRange",
3058
- "presetConfig",
3059
- "defaultSampling"
3060
- ];
3061
- const hasConfigUpdate = configFieldNames.some((field) => field in configFields);
2958
+ const { authorId, activeVersionId, metadata, status } = updates;
3062
2959
  const updatedScorer = {
3063
2960
  ...existingScorer,
3064
2961
  ...authorId !== void 0 && { authorId },
@@ -3069,43 +2966,6 @@ var InMemoryScorerDefinitionsStorage = class extends ScorerDefinitionsStorage {
3069
2966
  },
3070
2967
  updatedAt: /* @__PURE__ */ new Date()
3071
2968
  };
3072
- if (activeVersionId !== void 0) {
3073
- updatedScorer.status = "published";
3074
- }
3075
- if (hasConfigUpdate) {
3076
- const latestVersion = await this.getLatestVersion(id);
3077
- if (!latestVersion) {
3078
- throw new Error(`No versions found for scorer definition ${id}`);
3079
- }
3080
- const {
3081
- id: _versionId,
3082
- scorerDefinitionId: _scorerDefinitionId,
3083
- versionNumber: _versionNumber,
3084
- changedFields: _changedFields,
3085
- changeMessage: _changeMessage,
3086
- createdAt: _createdAt,
3087
- ...latestConfig
3088
- } = latestVersion;
3089
- const newConfig = {
3090
- ...latestConfig,
3091
- ...configFields
3092
- };
3093
- const changedFields = configFieldNames.filter(
3094
- (field) => field in configFields && JSON.stringify(configFields[field]) !== JSON.stringify(latestConfig[field])
3095
- );
3096
- if (changedFields.length > 0) {
3097
- const newVersionId = crypto.randomUUID();
3098
- const newVersionNumber = latestVersion.versionNumber + 1;
3099
- await this.createVersion({
3100
- id: newVersionId,
3101
- scorerDefinitionId: id,
3102
- versionNumber: newVersionNumber,
3103
- ...newConfig,
3104
- changedFields,
3105
- changeMessage: `Updated ${changedFields.join(", ")}`
3106
- });
3107
- }
3108
- }
3109
2969
  this.db.scorerDefinitions.set(id, updatedScorer);
3110
2970
  return this.deepCopyScorer(updatedScorer);
3111
2971
  }
@@ -3115,7 +2975,7 @@ var InMemoryScorerDefinitionsStorage = class extends ScorerDefinitionsStorage {
3115
2975
  await this.deleteVersionsByParentId(id);
3116
2976
  }
3117
2977
  async list(args) {
3118
- const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
2978
+ const { page = 0, perPage: perPageInput, orderBy, authorId, metadata, status } = args || {};
3119
2979
  const { field, direction } = this.parseOrderBy(orderBy);
3120
2980
  this.logger.debug(`InMemoryScorerDefinitionsStorage: list called`);
3121
2981
  const perPage = normalizePerPage(perPageInput, 100);
@@ -3127,6 +2987,9 @@ var InMemoryScorerDefinitionsStorage = class extends ScorerDefinitionsStorage {
3127
2987
  throw new Error("page value too large");
3128
2988
  }
3129
2989
  let scorers = Array.from(this.db.scorerDefinitions.values());
2990
+ if (status) {
2991
+ scorers = scorers.filter((scorer) => scorer.status === status);
2992
+ }
3130
2993
  if (authorId !== void 0) {
3131
2994
  scorers = scorers.filter((scorer) => scorer.authorId === authorId);
3132
2995
  }
@@ -3446,84 +3309,393 @@ var ScoresInMemory = class extends ScoresStorage {
3446
3309
  }
3447
3310
  };
3448
3311
 
3449
- // src/workflows/evented/types.ts
3450
- var PENDING_MARKER_KEY = "__mastra_pending__";
3451
- function createPendingMarker() {
3452
- return { [PENDING_MARKER_KEY]: true };
3453
- }
3454
- function isPendingMarker(val) {
3455
- return val !== null && typeof val === "object" && PENDING_MARKER_KEY in val && val[PENDING_MARKER_KEY] === true;
3456
- }
3457
-
3458
- // src/storage/domains/workflows/base.ts
3459
- var WorkflowsStorage = class extends StorageDomain {
3312
+ // src/storage/domains/skills/base.ts
3313
+ var SkillsStorage = class extends VersionedStorageDomain {
3314
+ listKey = "skills";
3315
+ versionMetadataFields = [
3316
+ "id",
3317
+ "skillId",
3318
+ "versionNumber",
3319
+ "changedFields",
3320
+ "changeMessage",
3321
+ "createdAt"
3322
+ ];
3460
3323
  constructor() {
3461
3324
  super({
3462
3325
  component: "STORAGE",
3463
- name: "WORKFLOWS"
3326
+ name: "SKILLS"
3464
3327
  });
3465
3328
  }
3466
3329
  };
3467
3330
 
3468
- // src/storage/domains/workflows/inmemory.ts
3469
- var WorkflowsInMemory = class extends WorkflowsStorage {
3331
+ // src/storage/domains/skills/inmemory.ts
3332
+ var InMemorySkillsStorage = class extends SkillsStorage {
3470
3333
  db;
3471
3334
  constructor({ db }) {
3472
3335
  super();
3473
3336
  this.db = db;
3474
3337
  }
3475
3338
  async dangerouslyClearAll() {
3476
- this.db.workflows.clear();
3339
+ this.db.skills.clear();
3340
+ this.db.skillVersions.clear();
3477
3341
  }
3478
- getWorkflowKey(workflowName, runId) {
3479
- return `${workflowName}-${runId}`;
3342
+ // ==========================================================================
3343
+ // Skill CRUD Methods
3344
+ // ==========================================================================
3345
+ async getById(id) {
3346
+ this.logger.debug(`InMemorySkillsStorage: getById called for ${id}`);
3347
+ const config = this.db.skills.get(id);
3348
+ return config ? this.deepCopyConfig(config) : null;
3480
3349
  }
3481
- async updateWorkflowResults({
3482
- workflowName,
3483
- runId,
3484
- stepId,
3485
- result,
3486
- requestContext
3487
- }) {
3488
- this.logger.debug(`WorkflowsInMemory: updateWorkflowResults called for ${workflowName} ${runId} ${stepId}`, result);
3489
- const key = this.getWorkflowKey(workflowName, runId);
3490
- const run = this.db.workflows.get(key);
3491
- if (!run) {
3492
- return {};
3350
+ async create(input) {
3351
+ const { skill } = input;
3352
+ this.logger.debug(`InMemorySkillsStorage: create called for ${skill.id}`);
3353
+ if (this.db.skills.has(skill.id)) {
3354
+ throw new Error(`Skill with id ${skill.id} already exists`);
3493
3355
  }
3494
- let snapshot;
3495
- if (!run.snapshot) {
3496
- snapshot = {
3497
- context: {},
3498
- activePaths: [],
3499
- activeStepsPath: {},
3500
- timestamp: Date.now(),
3501
- suspendedPaths: {},
3502
- resumeLabels: {},
3503
- serializedStepGraph: [],
3504
- value: {},
3505
- waitingPaths: {},
3506
- status: "pending",
3507
- runId: run.run_id
3508
- };
3509
- this.db.workflows.set(key, {
3510
- ...run,
3511
- snapshot
3356
+ const now = /* @__PURE__ */ new Date();
3357
+ const newConfig = {
3358
+ id: skill.id,
3359
+ status: "draft",
3360
+ activeVersionId: void 0,
3361
+ authorId: skill.authorId,
3362
+ createdAt: now,
3363
+ updatedAt: now
3364
+ };
3365
+ this.db.skills.set(skill.id, newConfig);
3366
+ const { id: _id, authorId: _authorId, ...snapshotConfig } = skill;
3367
+ const versionId = randomUUID();
3368
+ try {
3369
+ await this.createVersion({
3370
+ id: versionId,
3371
+ skillId: skill.id,
3372
+ versionNumber: 1,
3373
+ ...snapshotConfig,
3374
+ changedFields: Object.keys(snapshotConfig),
3375
+ changeMessage: "Initial version"
3512
3376
  });
3513
- } else {
3514
- snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
3377
+ } catch (error) {
3378
+ this.db.skills.delete(skill.id);
3379
+ throw error;
3515
3380
  }
3516
- if (!snapshot || !snapshot?.context) {
3517
- throw new Error(`Snapshot not found for runId ${runId}`);
3381
+ return this.deepCopyConfig(newConfig);
3382
+ }
3383
+ async update(input) {
3384
+ const { id, ...updates } = input;
3385
+ this.logger.debug(`InMemorySkillsStorage: update called for ${id}`);
3386
+ const existingConfig = this.db.skills.get(id);
3387
+ if (!existingConfig) {
3388
+ throw new Error(`Skill with id ${id} not found`);
3518
3389
  }
3519
- const existingResult = snapshot.context[stepId];
3520
- if (existingResult && "output" in existingResult && Array.isArray(existingResult.output) && result && typeof result === "object" && "output" in result && Array.isArray(result.output)) {
3521
- const existingOutput = existingResult.output;
3522
- const newOutput = result.output;
3523
- const mergedOutput = [...existingOutput];
3524
- for (let i = 0; i < Math.max(existingOutput.length, newOutput.length); i++) {
3525
- if (i < newOutput.length) {
3526
- const newVal = newOutput[i];
3390
+ const { authorId, activeVersionId, status, ...configFields } = updates;
3391
+ const configFieldNames = [
3392
+ "name",
3393
+ "description",
3394
+ "instructions",
3395
+ "license",
3396
+ "compatibility",
3397
+ "source",
3398
+ "references",
3399
+ "scripts",
3400
+ "assets",
3401
+ "metadata",
3402
+ "tree"
3403
+ ];
3404
+ const hasConfigUpdate = configFieldNames.some((field) => field in configFields);
3405
+ const updatedConfig = {
3406
+ ...existingConfig,
3407
+ ...authorId !== void 0 && { authorId },
3408
+ ...activeVersionId !== void 0 && { activeVersionId },
3409
+ ...status !== void 0 && { status },
3410
+ updatedAt: /* @__PURE__ */ new Date()
3411
+ };
3412
+ if (activeVersionId !== void 0 && status === void 0) {
3413
+ updatedConfig.status = "published";
3414
+ }
3415
+ if (hasConfigUpdate) {
3416
+ const latestVersion = await this.getLatestVersion(id);
3417
+ if (!latestVersion) {
3418
+ throw new Error(`No versions found for skill ${id}`);
3419
+ }
3420
+ const {
3421
+ id: _versionId,
3422
+ skillId: _skillId,
3423
+ versionNumber: _versionNumber,
3424
+ changedFields: _changedFields,
3425
+ changeMessage: _changeMessage,
3426
+ createdAt: _createdAt,
3427
+ ...latestConfig
3428
+ } = latestVersion;
3429
+ const newConfig = {
3430
+ ...latestConfig,
3431
+ ...configFields
3432
+ };
3433
+ const changedFields = configFieldNames.filter(
3434
+ (field) => field in configFields && JSON.stringify(configFields[field]) !== JSON.stringify(latestConfig[field])
3435
+ );
3436
+ if (changedFields.length > 0) {
3437
+ const newVersionId = randomUUID();
3438
+ const newVersionNumber = latestVersion.versionNumber + 1;
3439
+ await this.createVersion({
3440
+ id: newVersionId,
3441
+ skillId: id,
3442
+ versionNumber: newVersionNumber,
3443
+ ...newConfig,
3444
+ changedFields,
3445
+ changeMessage: `Updated ${changedFields.join(", ")}`
3446
+ });
3447
+ }
3448
+ }
3449
+ this.db.skills.set(id, updatedConfig);
3450
+ return this.deepCopyConfig(updatedConfig);
3451
+ }
3452
+ async delete(id) {
3453
+ this.logger.debug(`InMemorySkillsStorage: delete called for ${id}`);
3454
+ this.db.skills.delete(id);
3455
+ await this.deleteVersionsByParentId(id);
3456
+ }
3457
+ async list(args) {
3458
+ const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
3459
+ const { field, direction } = this.parseOrderBy(orderBy);
3460
+ this.logger.debug(`InMemorySkillsStorage: list called`);
3461
+ const perPage = normalizePerPage(perPageInput, 100);
3462
+ if (page < 0) {
3463
+ throw new Error("page must be >= 0");
3464
+ }
3465
+ const maxOffset = Number.MAX_SAFE_INTEGER / 2;
3466
+ if (page * perPage > maxOffset) {
3467
+ throw new Error("page value too large");
3468
+ }
3469
+ let configs = Array.from(this.db.skills.values());
3470
+ if (authorId !== void 0) {
3471
+ configs = configs.filter((config) => config.authorId === authorId);
3472
+ }
3473
+ if (metadata && Object.keys(metadata).length > 0) {
3474
+ configs = configs.filter((_config) => {
3475
+ return false;
3476
+ });
3477
+ }
3478
+ const sortedConfigs = this.sortConfigs(configs, field, direction);
3479
+ const clonedConfigs = sortedConfigs.map((config) => this.deepCopyConfig(config));
3480
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
3481
+ return {
3482
+ skills: clonedConfigs.slice(offset, offset + perPage),
3483
+ total: clonedConfigs.length,
3484
+ page,
3485
+ perPage: perPageForResponse,
3486
+ hasMore: offset + perPage < clonedConfigs.length
3487
+ };
3488
+ }
3489
+ // ==========================================================================
3490
+ // Skill Version Methods
3491
+ // ==========================================================================
3492
+ async createVersion(input) {
3493
+ this.logger.debug(`InMemorySkillsStorage: createVersion called for skill ${input.skillId}`);
3494
+ if (this.db.skillVersions.has(input.id)) {
3495
+ throw new Error(`Version with id ${input.id} already exists`);
3496
+ }
3497
+ for (const version2 of this.db.skillVersions.values()) {
3498
+ if (version2.skillId === input.skillId && version2.versionNumber === input.versionNumber) {
3499
+ throw new Error(`Version number ${input.versionNumber} already exists for skill ${input.skillId}`);
3500
+ }
3501
+ }
3502
+ const version = {
3503
+ ...input,
3504
+ createdAt: /* @__PURE__ */ new Date()
3505
+ };
3506
+ this.db.skillVersions.set(input.id, this.deepCopyVersion(version));
3507
+ return this.deepCopyVersion(version);
3508
+ }
3509
+ async getVersion(id) {
3510
+ this.logger.debug(`InMemorySkillsStorage: getVersion called for ${id}`);
3511
+ const version = this.db.skillVersions.get(id);
3512
+ return version ? this.deepCopyVersion(version) : null;
3513
+ }
3514
+ async getVersionByNumber(skillId, versionNumber) {
3515
+ this.logger.debug(`InMemorySkillsStorage: getVersionByNumber called for skill ${skillId}, v${versionNumber}`);
3516
+ for (const version of this.db.skillVersions.values()) {
3517
+ if (version.skillId === skillId && version.versionNumber === versionNumber) {
3518
+ return this.deepCopyVersion(version);
3519
+ }
3520
+ }
3521
+ return null;
3522
+ }
3523
+ async getLatestVersion(skillId) {
3524
+ this.logger.debug(`InMemorySkillsStorage: getLatestVersion called for skill ${skillId}`);
3525
+ let latest = null;
3526
+ for (const version of this.db.skillVersions.values()) {
3527
+ if (version.skillId === skillId) {
3528
+ if (!latest || version.versionNumber > latest.versionNumber) {
3529
+ latest = version;
3530
+ }
3531
+ }
3532
+ }
3533
+ return latest ? this.deepCopyVersion(latest) : null;
3534
+ }
3535
+ async listVersions(input) {
3536
+ const { skillId, page = 0, perPage: perPageInput, orderBy } = input;
3537
+ const { field, direction } = this.parseVersionOrderBy(orderBy);
3538
+ this.logger.debug(`InMemorySkillsStorage: listVersions called for skill ${skillId}`);
3539
+ const perPage = normalizePerPage(perPageInput, 20);
3540
+ if (page < 0) {
3541
+ throw new Error("page must be >= 0");
3542
+ }
3543
+ const maxOffset = Number.MAX_SAFE_INTEGER / 2;
3544
+ if (page * perPage > maxOffset) {
3545
+ throw new Error("page value too large");
3546
+ }
3547
+ let versions = Array.from(this.db.skillVersions.values()).filter((v) => v.skillId === skillId);
3548
+ versions = this.sortVersions(versions, field, direction);
3549
+ const clonedVersions = versions.map((v) => this.deepCopyVersion(v));
3550
+ const total = clonedVersions.length;
3551
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
3552
+ const paginatedVersions = clonedVersions.slice(offset, offset + perPage);
3553
+ return {
3554
+ versions: paginatedVersions,
3555
+ total,
3556
+ page,
3557
+ perPage: perPageForResponse,
3558
+ hasMore: offset + perPage < total
3559
+ };
3560
+ }
3561
+ async deleteVersion(id) {
3562
+ this.logger.debug(`InMemorySkillsStorage: deleteVersion called for ${id}`);
3563
+ this.db.skillVersions.delete(id);
3564
+ }
3565
+ async deleteVersionsByParentId(entityId) {
3566
+ this.logger.debug(`InMemorySkillsStorage: deleteVersionsByParentId called for skill ${entityId}`);
3567
+ const idsToDelete = [];
3568
+ for (const [id, version] of this.db.skillVersions.entries()) {
3569
+ if (version.skillId === entityId) {
3570
+ idsToDelete.push(id);
3571
+ }
3572
+ }
3573
+ for (const id of idsToDelete) {
3574
+ this.db.skillVersions.delete(id);
3575
+ }
3576
+ }
3577
+ async countVersions(skillId) {
3578
+ this.logger.debug(`InMemorySkillsStorage: countVersions called for skill ${skillId}`);
3579
+ let count = 0;
3580
+ for (const version of this.db.skillVersions.values()) {
3581
+ if (version.skillId === skillId) {
3582
+ count++;
3583
+ }
3584
+ }
3585
+ return count;
3586
+ }
3587
+ // ==========================================================================
3588
+ // Private Helper Methods
3589
+ // ==========================================================================
3590
+ deepCopyConfig(config) {
3591
+ return {
3592
+ ...config
3593
+ };
3594
+ }
3595
+ deepCopyVersion(version) {
3596
+ return structuredClone(version);
3597
+ }
3598
+ sortConfigs(configs, field, direction) {
3599
+ return configs.sort((a, b) => {
3600
+ const aValue = a[field].getTime();
3601
+ const bValue = b[field].getTime();
3602
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
3603
+ });
3604
+ }
3605
+ sortVersions(versions, field, direction) {
3606
+ return versions.sort((a, b) => {
3607
+ let aVal;
3608
+ let bVal;
3609
+ if (field === "createdAt") {
3610
+ aVal = a.createdAt.getTime();
3611
+ bVal = b.createdAt.getTime();
3612
+ } else {
3613
+ aVal = a.versionNumber;
3614
+ bVal = b.versionNumber;
3615
+ }
3616
+ return direction === "ASC" ? aVal - bVal : bVal - aVal;
3617
+ });
3618
+ }
3619
+ };
3620
+
3621
+ // src/workflows/evented/types.ts
3622
+ var PENDING_MARKER_KEY = "__mastra_pending__";
3623
+ function createPendingMarker() {
3624
+ return { [PENDING_MARKER_KEY]: true };
3625
+ }
3626
+ function isPendingMarker(val) {
3627
+ return val !== null && typeof val === "object" && PENDING_MARKER_KEY in val && val[PENDING_MARKER_KEY] === true;
3628
+ }
3629
+
3630
+ // src/storage/domains/workflows/base.ts
3631
+ var WorkflowsStorage = class extends StorageDomain {
3632
+ constructor() {
3633
+ super({
3634
+ component: "STORAGE",
3635
+ name: "WORKFLOWS"
3636
+ });
3637
+ }
3638
+ };
3639
+
3640
+ // src/storage/domains/workflows/inmemory.ts
3641
+ var WorkflowsInMemory = class extends WorkflowsStorage {
3642
+ db;
3643
+ constructor({ db }) {
3644
+ super();
3645
+ this.db = db;
3646
+ }
3647
+ async dangerouslyClearAll() {
3648
+ this.db.workflows.clear();
3649
+ }
3650
+ getWorkflowKey(workflowName, runId) {
3651
+ return `${workflowName}-${runId}`;
3652
+ }
3653
+ async updateWorkflowResults({
3654
+ workflowName,
3655
+ runId,
3656
+ stepId,
3657
+ result,
3658
+ requestContext
3659
+ }) {
3660
+ this.logger.debug(`WorkflowsInMemory: updateWorkflowResults called for ${workflowName} ${runId} ${stepId}`, result);
3661
+ const key = this.getWorkflowKey(workflowName, runId);
3662
+ const run = this.db.workflows.get(key);
3663
+ if (!run) {
3664
+ return {};
3665
+ }
3666
+ let snapshot;
3667
+ if (!run.snapshot) {
3668
+ snapshot = {
3669
+ context: {},
3670
+ activePaths: [],
3671
+ activeStepsPath: {},
3672
+ timestamp: Date.now(),
3673
+ suspendedPaths: {},
3674
+ resumeLabels: {},
3675
+ serializedStepGraph: [],
3676
+ value: {},
3677
+ waitingPaths: {},
3678
+ status: "pending",
3679
+ runId: run.run_id
3680
+ };
3681
+ this.db.workflows.set(key, {
3682
+ ...run,
3683
+ snapshot
3684
+ });
3685
+ } else {
3686
+ snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
3687
+ }
3688
+ if (!snapshot || !snapshot?.context) {
3689
+ throw new Error(`Snapshot not found for runId ${runId}`);
3690
+ }
3691
+ const existingResult = snapshot.context[stepId];
3692
+ if (existingResult && "output" in existingResult && Array.isArray(existingResult.output) && result && typeof result === "object" && "output" in result && Array.isArray(result.output)) {
3693
+ const existingOutput = existingResult.output;
3694
+ const newOutput = result.output;
3695
+ const mergedOutput = [...existingOutput];
3696
+ for (let i = 0; i < Math.max(existingOutput.length, newOutput.length); i++) {
3697
+ if (i < newOutput.length) {
3698
+ const newVal = newOutput[i];
3527
3699
  if (isPendingMarker(newVal)) {
3528
3700
  mergedOutput[i] = null;
3529
3701
  } else if (newVal !== null) {
@@ -3578,132 +3750,443 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
3578
3750
  } else {
3579
3751
  snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
3580
3752
  }
3581
- if (!snapshot || !snapshot?.context) {
3582
- throw new Error(`Snapshot not found for runId ${runId}`);
3753
+ if (!snapshot || !snapshot?.context) {
3754
+ throw new Error(`Snapshot not found for runId ${runId}`);
3755
+ }
3756
+ snapshot = { ...snapshot, ...opts };
3757
+ this.db.workflows.set(key, {
3758
+ ...run,
3759
+ snapshot
3760
+ });
3761
+ return snapshot;
3762
+ }
3763
+ async persistWorkflowSnapshot({
3764
+ workflowName,
3765
+ runId,
3766
+ resourceId,
3767
+ snapshot,
3768
+ createdAt,
3769
+ updatedAt
3770
+ }) {
3771
+ const key = this.getWorkflowKey(workflowName, runId);
3772
+ const now = /* @__PURE__ */ new Date();
3773
+ const data = {
3774
+ workflow_name: workflowName,
3775
+ run_id: runId,
3776
+ resourceId,
3777
+ snapshot,
3778
+ createdAt: createdAt ?? now,
3779
+ updatedAt: updatedAt ?? now
3780
+ };
3781
+ this.db.workflows.set(key, data);
3782
+ }
3783
+ async loadWorkflowSnapshot({
3784
+ workflowName,
3785
+ runId
3786
+ }) {
3787
+ this.logger.debug("Loading workflow snapshot", { workflowName, runId });
3788
+ const key = this.getWorkflowKey(workflowName, runId);
3789
+ const run = this.db.workflows.get(key);
3790
+ if (!run) {
3791
+ return null;
3792
+ }
3793
+ const snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
3794
+ return snapshot ? JSON.parse(JSON.stringify(snapshot)) : null;
3795
+ }
3796
+ async listWorkflowRuns({
3797
+ workflowName,
3798
+ fromDate,
3799
+ toDate,
3800
+ perPage,
3801
+ page,
3802
+ resourceId,
3803
+ status
3804
+ } = {}) {
3805
+ if (page !== void 0 && page < 0) {
3806
+ throw new Error("page must be >= 0");
3807
+ }
3808
+ let runs = Array.from(this.db.workflows.values());
3809
+ if (workflowName) runs = runs.filter((run) => run.workflow_name === workflowName);
3810
+ if (status) {
3811
+ runs = runs.filter((run) => {
3812
+ let snapshot = run?.snapshot;
3813
+ if (!snapshot) {
3814
+ return false;
3815
+ }
3816
+ if (typeof snapshot === "string") {
3817
+ try {
3818
+ snapshot = JSON.parse(snapshot);
3819
+ } catch {
3820
+ return false;
3821
+ }
3822
+ } else {
3823
+ snapshot = JSON.parse(JSON.stringify(snapshot));
3824
+ }
3825
+ return snapshot.status === status;
3826
+ });
3827
+ }
3828
+ if (fromDate && toDate) {
3829
+ runs = runs.filter(
3830
+ (run) => new Date(run.createdAt).getTime() >= fromDate.getTime() && new Date(run.createdAt).getTime() <= toDate.getTime()
3831
+ );
3832
+ } else if (fromDate) {
3833
+ runs = runs.filter((run) => new Date(run.createdAt).getTime() >= fromDate.getTime());
3834
+ } else if (toDate) {
3835
+ runs = runs.filter((run) => new Date(run.createdAt).getTime() <= toDate.getTime());
3836
+ }
3837
+ if (resourceId) runs = runs.filter((run) => run.resourceId === resourceId);
3838
+ const total = runs.length;
3839
+ runs.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
3840
+ if (perPage !== void 0 && page !== void 0) {
3841
+ const normalizedPerPage = normalizePerPage(perPage, Number.MAX_SAFE_INTEGER);
3842
+ const offset = page * normalizedPerPage;
3843
+ const start = offset;
3844
+ const end = start + normalizedPerPage;
3845
+ runs = runs.slice(start, end);
3846
+ }
3847
+ const parsedRuns = runs.map((run) => ({
3848
+ ...run,
3849
+ snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : JSON.parse(JSON.stringify(run.snapshot)),
3850
+ createdAt: new Date(run.createdAt),
3851
+ updatedAt: new Date(run.updatedAt),
3852
+ runId: run.run_id,
3853
+ workflowName: run.workflow_name,
3854
+ resourceId: run.resourceId
3855
+ }));
3856
+ return { runs: parsedRuns, total };
3857
+ }
3858
+ async getWorkflowRunById({
3859
+ runId,
3860
+ workflowName
3861
+ }) {
3862
+ const runs = Array.from(this.db.workflows.values()).filter((r) => r.run_id === runId);
3863
+ let run = runs.find((r) => r.workflow_name === workflowName);
3864
+ if (!run) return null;
3865
+ const parsedRun = {
3866
+ ...run,
3867
+ snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : JSON.parse(JSON.stringify(run.snapshot)),
3868
+ createdAt: new Date(run.createdAt),
3869
+ updatedAt: new Date(run.updatedAt),
3870
+ runId: run.run_id,
3871
+ workflowName: run.workflow_name,
3872
+ resourceId: run.resourceId
3873
+ };
3874
+ return parsedRun;
3875
+ }
3876
+ async deleteWorkflowRunById({ runId, workflowName }) {
3877
+ const key = this.getWorkflowKey(workflowName, runId);
3878
+ this.db.workflows.delete(key);
3879
+ }
3880
+ };
3881
+
3882
+ // src/storage/domains/workspaces/base.ts
3883
+ var WorkspacesStorage = class extends VersionedStorageDomain {
3884
+ listKey = "workspaces";
3885
+ versionMetadataFields = [
3886
+ "id",
3887
+ "workspaceId",
3888
+ "versionNumber",
3889
+ "changedFields",
3890
+ "changeMessage",
3891
+ "createdAt"
3892
+ ];
3893
+ constructor() {
3894
+ super({
3895
+ component: "STORAGE",
3896
+ name: "WORKSPACES"
3897
+ });
3898
+ }
3899
+ };
3900
+
3901
+ // src/storage/domains/workspaces/inmemory.ts
3902
+ var InMemoryWorkspacesStorage = class extends WorkspacesStorage {
3903
+ db;
3904
+ constructor({ db }) {
3905
+ super();
3906
+ this.db = db;
3907
+ }
3908
+ async dangerouslyClearAll() {
3909
+ this.db.workspaces.clear();
3910
+ this.db.workspaceVersions.clear();
3911
+ }
3912
+ // ==========================================================================
3913
+ // Workspace CRUD Methods
3914
+ // ==========================================================================
3915
+ async getById(id) {
3916
+ this.logger.debug(`InMemoryWorkspacesStorage: getById called for ${id}`);
3917
+ const config = this.db.workspaces.get(id);
3918
+ return config ? this.deepCopyConfig(config) : null;
3919
+ }
3920
+ async create(input) {
3921
+ const { workspace } = input;
3922
+ this.logger.debug(`InMemoryWorkspacesStorage: create called for ${workspace.id}`);
3923
+ if (this.db.workspaces.has(workspace.id)) {
3924
+ throw new Error(`Workspace with id ${workspace.id} already exists`);
3925
+ }
3926
+ const now = /* @__PURE__ */ new Date();
3927
+ const newConfig = {
3928
+ id: workspace.id,
3929
+ status: "draft",
3930
+ activeVersionId: void 0,
3931
+ authorId: workspace.authorId,
3932
+ metadata: workspace.metadata,
3933
+ createdAt: now,
3934
+ updatedAt: now
3935
+ };
3936
+ this.db.workspaces.set(workspace.id, newConfig);
3937
+ const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = workspace;
3938
+ const versionId = crypto.randomUUID();
3939
+ await this.createVersion({
3940
+ id: versionId,
3941
+ workspaceId: workspace.id,
3942
+ versionNumber: 1,
3943
+ ...snapshotConfig,
3944
+ changedFields: Object.keys(snapshotConfig),
3945
+ changeMessage: "Initial version"
3946
+ });
3947
+ return this.deepCopyConfig(newConfig);
3948
+ }
3949
+ async update(input) {
3950
+ const { id, ...updates } = input;
3951
+ this.logger.debug(`InMemoryWorkspacesStorage: update called for ${id}`);
3952
+ const existingConfig = this.db.workspaces.get(id);
3953
+ if (!existingConfig) {
3954
+ throw new Error(`Workspace with id ${id} not found`);
3955
+ }
3956
+ const { authorId, activeVersionId, metadata, status, ...configFields } = updates;
3957
+ const configFieldNames = [
3958
+ "name",
3959
+ "description",
3960
+ "filesystem",
3961
+ "sandbox",
3962
+ "mounts",
3963
+ "search",
3964
+ "skills",
3965
+ "tools",
3966
+ "autoSync",
3967
+ "operationTimeout"
3968
+ ];
3969
+ const hasConfigUpdate = configFieldNames.some((field) => field in configFields);
3970
+ const updatedConfig = {
3971
+ ...existingConfig,
3972
+ ...authorId !== void 0 && { authorId },
3973
+ ...activeVersionId !== void 0 && { activeVersionId },
3974
+ ...status !== void 0 && { status },
3975
+ ...metadata !== void 0 && {
3976
+ metadata: { ...existingConfig.metadata, ...metadata }
3977
+ },
3978
+ updatedAt: /* @__PURE__ */ new Date()
3979
+ };
3980
+ if (activeVersionId !== void 0 && status === void 0) {
3981
+ updatedConfig.status = "published";
3982
+ }
3983
+ if (hasConfigUpdate) {
3984
+ const latestVersion = await this.getLatestVersion(id);
3985
+ if (!latestVersion) {
3986
+ throw new Error(`No versions found for workspace ${id}`);
3987
+ }
3988
+ const {
3989
+ id: _versionId,
3990
+ workspaceId: _workspaceId,
3991
+ versionNumber: _versionNumber,
3992
+ changedFields: _changedFields,
3993
+ changeMessage: _changeMessage,
3994
+ createdAt: _createdAt,
3995
+ ...latestConfig
3996
+ } = latestVersion;
3997
+ const newConfig = {
3998
+ ...latestConfig,
3999
+ ...configFields
4000
+ };
4001
+ const changedFields = configFieldNames.filter(
4002
+ (field) => field in configFields && JSON.stringify(configFields[field]) !== JSON.stringify(latestConfig[field])
4003
+ );
4004
+ if (changedFields.length > 0) {
4005
+ const newVersionId = crypto.randomUUID();
4006
+ const newVersionNumber = latestVersion.versionNumber + 1;
4007
+ await this.createVersion({
4008
+ id: newVersionId,
4009
+ workspaceId: id,
4010
+ versionNumber: newVersionNumber,
4011
+ ...newConfig,
4012
+ changedFields,
4013
+ changeMessage: `Updated ${changedFields.join(", ")}`
4014
+ });
4015
+ }
4016
+ }
4017
+ this.db.workspaces.set(id, updatedConfig);
4018
+ return this.deepCopyConfig(updatedConfig);
4019
+ }
4020
+ async delete(id) {
4021
+ this.logger.debug(`InMemoryWorkspacesStorage: delete called for ${id}`);
4022
+ this.db.workspaces.delete(id);
4023
+ await this.deleteVersionsByParentId(id);
4024
+ }
4025
+ async list(args) {
4026
+ const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};
4027
+ const { field, direction } = this.parseOrderBy(orderBy);
4028
+ this.logger.debug(`InMemoryWorkspacesStorage: list called`);
4029
+ const perPage = normalizePerPage(perPageInput, 100);
4030
+ if (page < 0) {
4031
+ throw new Error("page must be >= 0");
4032
+ }
4033
+ const maxOffset = Number.MAX_SAFE_INTEGER / 2;
4034
+ if (page * perPage > maxOffset) {
4035
+ throw new Error("page value too large");
3583
4036
  }
3584
- snapshot = { ...snapshot, ...opts };
3585
- this.db.workflows.set(key, {
3586
- ...run,
3587
- snapshot
3588
- });
3589
- return snapshot;
4037
+ let configs = Array.from(this.db.workspaces.values());
4038
+ if (authorId !== void 0) {
4039
+ configs = configs.filter((config) => config.authorId === authorId);
4040
+ }
4041
+ if (metadata && Object.keys(metadata).length > 0) {
4042
+ configs = configs.filter((config) => {
4043
+ if (!config.metadata) return false;
4044
+ return Object.entries(metadata).every(([key, value]) => deepEqual(config.metadata[key], value));
4045
+ });
4046
+ }
4047
+ const sortedConfigs = this.sortConfigs(configs, field, direction);
4048
+ const clonedConfigs = sortedConfigs.map((config) => this.deepCopyConfig(config));
4049
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
4050
+ return {
4051
+ workspaces: clonedConfigs.slice(offset, offset + perPage),
4052
+ total: clonedConfigs.length,
4053
+ page,
4054
+ perPage: perPageForResponse,
4055
+ hasMore: offset + perPage < clonedConfigs.length
4056
+ };
3590
4057
  }
3591
- async persistWorkflowSnapshot({
3592
- workflowName,
3593
- runId,
3594
- resourceId,
3595
- snapshot,
3596
- createdAt,
3597
- updatedAt
3598
- }) {
3599
- const key = this.getWorkflowKey(workflowName, runId);
3600
- const now = /* @__PURE__ */ new Date();
3601
- const data = {
3602
- workflow_name: workflowName,
3603
- run_id: runId,
3604
- resourceId,
3605
- snapshot,
3606
- createdAt: createdAt ?? now,
3607
- updatedAt: updatedAt ?? now
4058
+ // ==========================================================================
4059
+ // Workspace Version Methods
4060
+ // ==========================================================================
4061
+ async createVersion(input) {
4062
+ this.logger.debug(`InMemoryWorkspacesStorage: createVersion called for workspace ${input.workspaceId}`);
4063
+ if (this.db.workspaceVersions.has(input.id)) {
4064
+ throw new Error(`Version with id ${input.id} already exists`);
4065
+ }
4066
+ for (const version2 of this.db.workspaceVersions.values()) {
4067
+ if (version2.workspaceId === input.workspaceId && version2.versionNumber === input.versionNumber) {
4068
+ throw new Error(`Version number ${input.versionNumber} already exists for workspace ${input.workspaceId}`);
4069
+ }
4070
+ }
4071
+ const version = {
4072
+ ...input,
4073
+ createdAt: /* @__PURE__ */ new Date()
3608
4074
  };
3609
- this.db.workflows.set(key, data);
4075
+ this.db.workspaceVersions.set(input.id, this.deepCopyVersion(version));
4076
+ return this.deepCopyVersion(version);
3610
4077
  }
3611
- async loadWorkflowSnapshot({
3612
- workflowName,
3613
- runId
3614
- }) {
3615
- this.logger.debug("Loading workflow snapshot", { workflowName, runId });
3616
- const key = this.getWorkflowKey(workflowName, runId);
3617
- const run = this.db.workflows.get(key);
3618
- if (!run) {
3619
- return null;
4078
+ async getVersion(id) {
4079
+ this.logger.debug(`InMemoryWorkspacesStorage: getVersion called for ${id}`);
4080
+ const version = this.db.workspaceVersions.get(id);
4081
+ return version ? this.deepCopyVersion(version) : null;
4082
+ }
4083
+ async getVersionByNumber(workspaceId, versionNumber) {
4084
+ this.logger.debug(
4085
+ `InMemoryWorkspacesStorage: getVersionByNumber called for workspace ${workspaceId}, v${versionNumber}`
4086
+ );
4087
+ for (const version of this.db.workspaceVersions.values()) {
4088
+ if (version.workspaceId === workspaceId && version.versionNumber === versionNumber) {
4089
+ return this.deepCopyVersion(version);
4090
+ }
3620
4091
  }
3621
- const snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
3622
- return snapshot ? JSON.parse(JSON.stringify(snapshot)) : null;
4092
+ return null;
3623
4093
  }
3624
- async listWorkflowRuns({
3625
- workflowName,
3626
- fromDate,
3627
- toDate,
3628
- perPage,
3629
- page,
3630
- resourceId,
3631
- status
3632
- } = {}) {
3633
- if (page !== void 0 && page < 0) {
4094
+ async getLatestVersion(workspaceId) {
4095
+ this.logger.debug(`InMemoryWorkspacesStorage: getLatestVersion called for workspace ${workspaceId}`);
4096
+ let latest = null;
4097
+ for (const version of this.db.workspaceVersions.values()) {
4098
+ if (version.workspaceId === workspaceId) {
4099
+ if (!latest || version.versionNumber > latest.versionNumber) {
4100
+ latest = version;
4101
+ }
4102
+ }
4103
+ }
4104
+ return latest ? this.deepCopyVersion(latest) : null;
4105
+ }
4106
+ async listVersions(input) {
4107
+ const { workspaceId, page = 0, perPage: perPageInput, orderBy } = input;
4108
+ const { field, direction } = this.parseVersionOrderBy(orderBy);
4109
+ this.logger.debug(`InMemoryWorkspacesStorage: listVersions called for workspace ${workspaceId}`);
4110
+ const perPage = normalizePerPage(perPageInput, 20);
4111
+ if (page < 0) {
3634
4112
  throw new Error("page must be >= 0");
3635
4113
  }
3636
- let runs = Array.from(this.db.workflows.values());
3637
- if (workflowName) runs = runs.filter((run) => run.workflow_name === workflowName);
3638
- if (status) {
3639
- runs = runs.filter((run) => {
3640
- let snapshot = run?.snapshot;
3641
- if (!snapshot) {
3642
- return false;
3643
- }
3644
- if (typeof snapshot === "string") {
3645
- try {
3646
- snapshot = JSON.parse(snapshot);
3647
- } catch {
3648
- return false;
3649
- }
3650
- } else {
3651
- snapshot = JSON.parse(JSON.stringify(snapshot));
3652
- }
3653
- return snapshot.status === status;
3654
- });
4114
+ const maxOffset = Number.MAX_SAFE_INTEGER / 2;
4115
+ if (page * perPage > maxOffset) {
4116
+ throw new Error("page value too large");
3655
4117
  }
3656
- if (fromDate && toDate) {
3657
- runs = runs.filter(
3658
- (run) => new Date(run.createdAt).getTime() >= fromDate.getTime() && new Date(run.createdAt).getTime() <= toDate.getTime()
3659
- );
3660
- } else if (fromDate) {
3661
- runs = runs.filter((run) => new Date(run.createdAt).getTime() >= fromDate.getTime());
3662
- } else if (toDate) {
3663
- runs = runs.filter((run) => new Date(run.createdAt).getTime() <= toDate.getTime());
4118
+ let versions = Array.from(this.db.workspaceVersions.values()).filter((v) => v.workspaceId === workspaceId);
4119
+ versions = this.sortVersions(versions, field, direction);
4120
+ const clonedVersions = versions.map((v) => this.deepCopyVersion(v));
4121
+ const total = clonedVersions.length;
4122
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
4123
+ const paginatedVersions = clonedVersions.slice(offset, offset + perPage);
4124
+ return {
4125
+ versions: paginatedVersions,
4126
+ total,
4127
+ page,
4128
+ perPage: perPageForResponse,
4129
+ hasMore: offset + perPage < total
4130
+ };
4131
+ }
4132
+ async deleteVersion(id) {
4133
+ this.logger.debug(`InMemoryWorkspacesStorage: deleteVersion called for ${id}`);
4134
+ this.db.workspaceVersions.delete(id);
4135
+ }
4136
+ async deleteVersionsByParentId(entityId) {
4137
+ this.logger.debug(`InMemoryWorkspacesStorage: deleteVersionsByParentId called for workspace ${entityId}`);
4138
+ const idsToDelete = [];
4139
+ for (const [id, version] of this.db.workspaceVersions.entries()) {
4140
+ if (version.workspaceId === entityId) {
4141
+ idsToDelete.push(id);
4142
+ }
3664
4143
  }
3665
- if (resourceId) runs = runs.filter((run) => run.resourceId === resourceId);
3666
- const total = runs.length;
3667
- runs.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
3668
- if (perPage !== void 0 && page !== void 0) {
3669
- const normalizedPerPage = normalizePerPage(perPage, Number.MAX_SAFE_INTEGER);
3670
- const offset = page * normalizedPerPage;
3671
- const start = offset;
3672
- const end = start + normalizedPerPage;
3673
- runs = runs.slice(start, end);
4144
+ for (const id of idsToDelete) {
4145
+ this.db.workspaceVersions.delete(id);
3674
4146
  }
3675
- const parsedRuns = runs.map((run) => ({
3676
- ...run,
3677
- snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : JSON.parse(JSON.stringify(run.snapshot)),
3678
- createdAt: new Date(run.createdAt),
3679
- updatedAt: new Date(run.updatedAt),
3680
- runId: run.run_id,
3681
- workflowName: run.workflow_name,
3682
- resourceId: run.resourceId
3683
- }));
3684
- return { runs: parsedRuns, total };
3685
4147
  }
3686
- async getWorkflowRunById({
3687
- runId,
3688
- workflowName
3689
- }) {
3690
- const runs = Array.from(this.db.workflows.values()).filter((r) => r.run_id === runId);
3691
- let run = runs.find((r) => r.workflow_name === workflowName);
3692
- if (!run) return null;
3693
- const parsedRun = {
3694
- ...run,
3695
- snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : JSON.parse(JSON.stringify(run.snapshot)),
3696
- createdAt: new Date(run.createdAt),
3697
- updatedAt: new Date(run.updatedAt),
3698
- runId: run.run_id,
3699
- workflowName: run.workflow_name,
3700
- resourceId: run.resourceId
4148
+ async countVersions(workspaceId) {
4149
+ this.logger.debug(`InMemoryWorkspacesStorage: countVersions called for workspace ${workspaceId}`);
4150
+ let count = 0;
4151
+ for (const version of this.db.workspaceVersions.values()) {
4152
+ if (version.workspaceId === workspaceId) {
4153
+ count++;
4154
+ }
4155
+ }
4156
+ return count;
4157
+ }
4158
+ // ==========================================================================
4159
+ // Private Helper Methods
4160
+ // ==========================================================================
4161
+ deepCopyConfig(config) {
4162
+ return {
4163
+ ...config,
4164
+ metadata: config.metadata ? { ...config.metadata } : config.metadata
3701
4165
  };
3702
- return parsedRun;
3703
4166
  }
3704
- async deleteWorkflowRunById({ runId, workflowName }) {
3705
- const key = this.getWorkflowKey(workflowName, runId);
3706
- this.db.workflows.delete(key);
4167
+ deepCopyVersion(version) {
4168
+ return structuredClone(version);
4169
+ }
4170
+ sortConfigs(configs, field, direction) {
4171
+ return configs.sort((a, b) => {
4172
+ const aValue = a[field].getTime();
4173
+ const bValue = b[field].getTime();
4174
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
4175
+ });
4176
+ }
4177
+ sortVersions(versions, field, direction) {
4178
+ return versions.sort((a, b) => {
4179
+ let aVal;
4180
+ let bVal;
4181
+ if (field === "createdAt") {
4182
+ aVal = a.createdAt.getTime();
4183
+ bVal = b.createdAt.getTime();
4184
+ } else {
4185
+ aVal = a.versionNumber;
4186
+ bVal = b.versionNumber;
4187
+ }
4188
+ return direction === "ASC" ? aVal - bVal : bVal - aVal;
4189
+ });
3707
4190
  }
3708
4191
  };
3709
4192
 
@@ -3728,7 +4211,9 @@ var InMemoryStore = class extends MastraCompositeStore {
3728
4211
  agents: new InMemoryAgentsStorage({ db: this.#db }),
3729
4212
  promptBlocks: new InMemoryPromptBlocksStorage({ db: this.#db }),
3730
4213
  scorerDefinitions: new InMemoryScorerDefinitionsStorage({ db: this.#db }),
3731
- mcpClients: new InMemoryMCPClientsStorage({ db: this.#db })
4214
+ mcpClients: new InMemoryMCPClientsStorage({ db: this.#db }),
4215
+ workspaces: new InMemoryWorkspacesStorage({ db: this.#db }),
4216
+ skills: new InMemorySkillsStorage({ db: this.#db })
3732
4217
  };
3733
4218
  }
3734
4219
  /**
@@ -3742,6 +4227,55 @@ var InMemoryStore = class extends MastraCompositeStore {
3742
4227
  };
3743
4228
  var MockStore = InMemoryStore;
3744
4229
 
4230
+ // src/storage/domains/blobs/base.ts
4231
+ var BlobStore = class extends MastraBase {
4232
+ constructor() {
4233
+ super({
4234
+ component: "STORAGE",
4235
+ name: "BLOBS"
4236
+ });
4237
+ }
4238
+ };
4239
+
4240
+ // src/storage/domains/blobs/inmemory.ts
4241
+ var InMemoryBlobStore = class extends BlobStore {
4242
+ #blobs = /* @__PURE__ */ new Map();
4243
+ async init() {
4244
+ }
4245
+ async put(entry) {
4246
+ if (!this.#blobs.has(entry.hash)) {
4247
+ this.#blobs.set(entry.hash, entry);
4248
+ }
4249
+ }
4250
+ async get(hash) {
4251
+ return this.#blobs.get(hash) ?? null;
4252
+ }
4253
+ async has(hash) {
4254
+ return this.#blobs.has(hash);
4255
+ }
4256
+ async delete(hash) {
4257
+ return this.#blobs.delete(hash);
4258
+ }
4259
+ async putMany(entries) {
4260
+ for (const entry of entries) {
4261
+ await this.put(entry);
4262
+ }
4263
+ }
4264
+ async getMany(hashes) {
4265
+ const result = /* @__PURE__ */ new Map();
4266
+ for (const hash of hashes) {
4267
+ const blob = this.#blobs.get(hash);
4268
+ if (blob) {
4269
+ result.set(hash, blob);
4270
+ }
4271
+ }
4272
+ return result;
4273
+ }
4274
+ async dangerouslyClearAll() {
4275
+ this.#blobs.clear();
4276
+ }
4277
+ };
4278
+
3745
4279
  // src/storage/domains/operations/base.ts
3746
4280
  var StoreOperations = class extends MastraBase {
3747
4281
  constructor() {
@@ -3870,6 +4404,11 @@ var StoreOperationsInMemory = class extends StoreOperations {
3870
4404
  mastra_scorer_definition_versions: /* @__PURE__ */ new Map(),
3871
4405
  mastra_mcp_clients: /* @__PURE__ */ new Map(),
3872
4406
  mastra_mcp_client_versions: /* @__PURE__ */ new Map(),
4407
+ mastra_workspaces: /* @__PURE__ */ new Map(),
4408
+ mastra_workspace_versions: /* @__PURE__ */ new Map(),
4409
+ mastra_skills: /* @__PURE__ */ new Map(),
4410
+ mastra_skill_versions: /* @__PURE__ */ new Map(),
4411
+ mastra_skill_blobs: /* @__PURE__ */ new Map(),
3873
4412
  mastra_datasets: /* @__PURE__ */ new Map(),
3874
4413
  mastra_dataset_items: /* @__PURE__ */ new Map(),
3875
4414
  mastra_dataset_versions: /* @__PURE__ */ new Map(),
@@ -4187,6 +4726,13 @@ function toDatasetItem(row) {
4187
4726
  updatedAt: row.updatedAt
4188
4727
  };
4189
4728
  }
4729
+ function toDatasetRecord(record) {
4730
+ return {
4731
+ ...record,
4732
+ inputSchema: record.inputSchema ?? void 0,
4733
+ groundTruthSchema: record.groundTruthSchema ?? void 0
4734
+ };
4735
+ }
4190
4736
  var DatasetsInMemory = class extends DatasetsStorage {
4191
4737
  db;
4192
4738
  constructor({ db }) {
@@ -4214,10 +4760,11 @@ var DatasetsInMemory = class extends DatasetsStorage {
4214
4760
  updatedAt: now
4215
4761
  };
4216
4762
  this.db.datasets.set(id, dataset);
4217
- return dataset;
4763
+ return toDatasetRecord(dataset);
4218
4764
  }
4219
4765
  async getDatasetById({ id }) {
4220
- return this.db.datasets.get(id) ?? null;
4766
+ const record = this.db.datasets.get(id);
4767
+ return record ? toDatasetRecord(record) : null;
4221
4768
  }
4222
4769
  async _doUpdateDataset(args) {
4223
4770
  const existing = this.db.datasets.get(args.id);
@@ -4234,7 +4781,7 @@ var DatasetsInMemory = class extends DatasetsStorage {
4234
4781
  updatedAt: /* @__PURE__ */ new Date()
4235
4782
  };
4236
4783
  this.db.datasets.set(args.id, updated);
4237
- return updated;
4784
+ return toDatasetRecord(updated);
4238
4785
  }
4239
4786
  async deleteDataset({ id }) {
4240
4787
  for (const [itemId, rows] of this.db.datasetItems) {
@@ -4262,7 +4809,7 @@ var DatasetsInMemory = class extends DatasetsStorage {
4262
4809
  const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
4263
4810
  const end = perPageInput === false ? datasets.length : start + perPage;
4264
4811
  return {
4265
- datasets: datasets.slice(start, end),
4812
+ datasets: datasets.slice(start, end).map(toDatasetRecord),
4266
4813
  pagination: {
4267
4814
  total: datasets.length,
4268
4815
  page,
@@ -4679,6 +5226,6 @@ var ExperimentsInMemory = class extends ExperimentsStorage {
4679
5226
  }
4680
5227
  };
4681
5228
 
4682
- export { AgentsStorage, DatasetsInMemory, DatasetsStorage, ExperimentsInMemory, ExperimentsStorage, InMemoryAgentsStorage, InMemoryDB, InMemoryMCPClientsStorage, InMemoryMemory, InMemoryPromptBlocksStorage, InMemoryScorerDefinitionsStorage, InMemoryStore, MCPClientsStorage, MastraCompositeStore, MastraStorage, MemoryStorage, MockStore, ObservabilityInMemory, ObservabilityStorage, PromptBlocksStorage, SchemaUpdateValidationError, SchemaValidationError, SchemaValidator, ScorerDefinitionsStorage, ScoresInMemory, ScoresStorage, StorageDomain, StoreOperations, StoreOperationsInMemory, VersionedStorageDomain, WorkflowsInMemory, WorkflowsStorage, calculatePagination, createPendingMarker, createStorageErrorId, createStoreErrorId, createValidator, createVectorErrorId, ensureDate, filterByDateRange, getDefaultValue, getSchemaValidator, getSqlType, jsonValueEquals, normalizePerPage, safelyParseJSON, serializeDate, transformRow, transformScoreRow };
4683
- //# sourceMappingURL=chunk-7NKUSQEV.js.map
4684
- //# sourceMappingURL=chunk-7NKUSQEV.js.map
5229
+ export { AgentsStorage, BlobStore, DatasetsInMemory, DatasetsStorage, ExperimentsInMemory, ExperimentsStorage, InMemoryAgentsStorage, InMemoryBlobStore, InMemoryDB, InMemoryMCPClientsStorage, InMemoryMemory, InMemoryPromptBlocksStorage, InMemoryScorerDefinitionsStorage, InMemorySkillsStorage, InMemoryStore, InMemoryWorkspacesStorage, MCPClientsStorage, MastraCompositeStore, MastraStorage, MemoryStorage, MockStore, ObservabilityInMemory, ObservabilityStorage, PromptBlocksStorage, SchemaUpdateValidationError, SchemaValidationError, SchemaValidator, ScorerDefinitionsStorage, ScoresInMemory, ScoresStorage, SkillsStorage, StorageDomain, StoreOperations, StoreOperationsInMemory, VersionedStorageDomain, WorkflowsInMemory, WorkflowsStorage, WorkspacesStorage, calculatePagination, createPendingMarker, createStorageErrorId, createStoreErrorId, createValidator, createVectorErrorId, ensureDate, filterByDateRange, getDefaultValue, getSchemaValidator, getSqlType, jsonValueEquals, normalizePerPage, safelyParseJSON, serializeDate, transformRow, transformScoreRow };
5230
+ //# sourceMappingURL=chunk-YIN5F7VO.js.map
5231
+ //# sourceMappingURL=chunk-YIN5F7VO.js.map