@mastra/server 1.60.0-alpha.10 → 1.60.0-alpha.12

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 (246) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/{a2a-B5m54dOP.js → a2a-B2yosTel.js} +2 -2
  3. package/dist/{a2a-B5m54dOP.js.map → a2a-B2yosTel.js.map} +1 -1
  4. package/dist/{a2a-Eeib3vfP.cjs → a2a-C4JIRtLT.cjs} +4 -4
  5. package/dist/{a2a-Eeib3vfP.cjs.map → a2a-C4JIRtLT.cjs.map} +1 -1
  6. package/dist/{agent-versions-xeysPGel.cjs → agent-versions-MYjO6Wl1.cjs} +2 -2
  7. package/dist/{agent-versions-xeysPGel.cjs.map → agent-versions-MYjO6Wl1.cjs.map} +1 -1
  8. package/dist/{agent-versions-CWEnD62A.js → agent-versions-mFXaw5ma.js} +2 -2
  9. package/dist/{agent-versions-CWEnD62A.js.map → agent-versions-mFXaw5ma.js.map} +1 -1
  10. package/dist/{api-schema-manifest-BKTXRheC.js → api-schema-manifest-Cq7dyGz7.js} +2 -2
  11. package/dist/{api-schema-manifest-BKTXRheC.js.map → api-schema-manifest-Cq7dyGz7.js.map} +1 -1
  12. package/dist/{api-schema-manifest-BbNdh5Ck.cjs → api-schema-manifest-DBTuPeWn.cjs} +4 -3
  13. package/dist/{api-schema-manifest-BbNdh5Ck.cjs.map → api-schema-manifest-DBTuPeWn.cjs.map} +1 -1
  14. package/dist/{background-tasks-C5G2jJax.cjs → background-tasks-8M9W_27g.cjs} +2 -2
  15. package/dist/{background-tasks-C5G2jJax.cjs.map → background-tasks-8M9W_27g.cjs.map} +1 -1
  16. package/dist/{builder-registry-CyaUg_iP.cjs → builder-registry-C-NVj8w5.cjs} +3 -3
  17. package/dist/{builder-registry-CyaUg_iP.cjs.map → builder-registry-C-NVj8w5.cjs.map} +1 -1
  18. package/dist/{channels-Dzy6VM3w.cjs → channels-Bn2aN-6o.cjs} +2 -2
  19. package/dist/{channels-Dzy6VM3w.cjs.map → channels-Bn2aN-6o.cjs.map} +1 -1
  20. package/dist/{conversations-CcFLCCeF.cjs → conversations-PF0eKhIu.cjs} +3 -3
  21. package/dist/{conversations-CcFLCCeF.cjs.map → conversations-PF0eKhIu.cjs.map} +1 -1
  22. package/dist/{dist-CAVC0nWG.cjs → dist-2zVeGGHi.cjs} +3 -2
  23. package/dist/{dist-CAVC0nWG.cjs.map → dist-2zVeGGHi.cjs.map} +1 -1
  24. package/dist/{dist-D7GkGue6.cjs → dist-8-Z5v77M.cjs} +3 -2
  25. package/dist/{dist-D7GkGue6.cjs.map → dist-8-Z5v77M.cjs.map} +1 -1
  26. package/dist/{dist-SKhVwZMV.cjs → dist-Be7Caz3Z.cjs} +3 -2
  27. package/dist/{dist-SKhVwZMV.cjs.map → dist-Be7Caz3Z.cjs.map} +1 -1
  28. package/dist/{dist-18h28zlO.cjs → dist-BfVTO0pC.cjs} +3 -2
  29. package/dist/{dist-18h28zlO.cjs.map → dist-BfVTO0pC.cjs.map} +1 -1
  30. package/dist/{dist-C2O8fRb-.cjs → dist-BrbvwbbJ.cjs} +13 -13
  31. package/dist/{dist-C2O8fRb-.cjs.map → dist-BrbvwbbJ.cjs.map} +1 -1
  32. package/dist/{dist-BD0I5lxM.js → dist-CHJcZQdS.js} +2 -2
  33. package/dist/{dist-BD0I5lxM.js.map → dist-CHJcZQdS.js.map} +1 -1
  34. package/dist/{dist-BpRGQqjE.cjs → dist-CJKQBH69.cjs} +2 -2
  35. package/dist/{dist-BpRGQqjE.cjs.map → dist-CJKQBH69.cjs.map} +1 -1
  36. package/dist/{dist-sUhxlnJz.js → dist-CRgxcDTg.js} +2 -2
  37. package/dist/{dist-sUhxlnJz.js.map → dist-CRgxcDTg.js.map} +1 -1
  38. package/dist/{dist-JdnTASYe.js → dist-CscF1cF8.js} +2 -2
  39. package/dist/{dist-JdnTASYe.js.map → dist-CscF1cF8.js.map} +1 -1
  40. package/dist/{dist-DBP9kw_8.cjs → dist-D4NzuG3G.cjs} +3 -2
  41. package/dist/{dist-DBP9kw_8.cjs.map → dist-D4NzuG3G.cjs.map} +1 -1
  42. package/dist/{dist-DNaReo7-.js → dist-DR_dRdv7.js} +11 -11
  43. package/dist/{dist-DNaReo7-.js.map → dist-DR_dRdv7.js.map} +1 -1
  44. package/dist/{dist-mcwHCl2a.js → dist-F_Ql1co6.js} +2 -2
  45. package/dist/{dist-mcwHCl2a.js.map → dist-F_Ql1co6.js.map} +1 -1
  46. package/dist/{dist-C-9xUY65.js → dist-Jn3uXsoB.js} +2 -2
  47. package/dist/{dist-C-9xUY65.js.map → dist-Jn3uXsoB.js.map} +1 -1
  48. package/dist/{dist-DyBO3IVt.js → dist-bAFqx06T.js} +2 -2
  49. package/dist/{dist-DyBO3IVt.js.map → dist-bAFqx06T.js.map} +1 -1
  50. package/dist/docs/SKILL.md +1 -1
  51. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  52. package/dist/{dynamic-workflows-C-6vmau5.cjs → dynamic-workflows-BZ5ru36x.cjs} +3 -3
  53. package/dist/{dynamic-workflows-C-6vmau5.cjs.map → dynamic-workflows-BZ5ru36x.cjs.map} +1 -1
  54. package/dist/{dynamic-workflows-B0TE8mjA.js → dynamic-workflows-C6U0Rdoc.js} +2 -2
  55. package/dist/{dynamic-workflows-B0TE8mjA.js.map → dynamic-workflows-C6U0Rdoc.js.map} +1 -1
  56. package/dist/{editor-builder-1L3OIY4K.cjs → editor-builder-BmRQift0.cjs} +2 -2
  57. package/dist/{editor-builder-1L3OIY4K.cjs.map → editor-builder-BmRQift0.cjs.map} +1 -1
  58. package/dist/index.cjs +1 -0
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/{observability-new-endpoints-BC-dasRY.cjs → observability-new-endpoints-gRCFhnRr.cjs} +2 -2
  61. package/dist/{observability-new-endpoints-BC-dasRY.cjs.map → observability-new-endpoints-gRCFhnRr.cjs.map} +1 -1
  62. package/dist/{probe-image-size-C2F59z8Z.cjs → probe-image-size-CDCRrXNo.cjs} +140 -33
  63. package/dist/probe-image-size-CDCRrXNo.cjs.map +1 -0
  64. package/dist/{probe-image-size-mXCWYNrz.js → probe-image-size-Tf8sNZhU.js} +137 -33
  65. package/dist/probe-image-size-Tf8sNZhU.js.map +1 -0
  66. package/dist/{responses-BI25doe1.cjs → responses-CKNdSRkS.cjs} +2 -2
  67. package/dist/{responses-BI25doe1.cjs.map → responses-CKNdSRkS.cjs.map} +1 -1
  68. package/dist/{rolldown-runtime-CVvi-lCc.cjs → rolldown-runtime-Bd6kNlEP.cjs} +21 -0
  69. package/dist/{rolldown-runtime-DuvcJU0W.js → rolldown-runtime-maW3aOIk.js} +10 -1
  70. package/dist/{route-builder-BAAedfru.cjs → route-builder-CWsok5ci.cjs} +2 -2
  71. package/dist/{route-builder-BAAedfru.cjs.map → route-builder-CWsok5ci.cjs.map} +1 -1
  72. package/dist/{routes-mK_LlDMo.cjs → routes-DHRnM_bB.cjs} +10 -10
  73. package/dist/{routes-mK_LlDMo.cjs.map → routes-DHRnM_bB.cjs.map} +1 -1
  74. package/dist/{routes-iUe0w9eL.js → routes-DMs0TJQw.js} +3 -3
  75. package/dist/{routes-iUe0w9eL.js.map → routes-DMs0TJQw.js.map} +1 -1
  76. package/dist/{schedules-DOK225ZZ.cjs → schedules-7YUg_TRM.cjs} +2 -2
  77. package/dist/{schedules-DOK225ZZ.cjs.map → schedules-7YUg_TRM.cjs.map} +1 -1
  78. package/dist/{schema-Bv9OdW1f-CHHI-NTr.cjs → schema-Bv9OdW1f-CxTiW8RD.cjs} +2 -2
  79. package/dist/{schema-Bv9OdW1f-CHHI-NTr.cjs.map → schema-Bv9OdW1f-CxTiW8RD.cjs.map} +1 -1
  80. package/dist/schema-CNKnRmv1.cjs +1 -0
  81. package/dist/{scorer-versions-CdVjOtQO.js → scorer-versions-D0_KP67E.js} +2 -2
  82. package/dist/{scorer-versions-CdVjOtQO.js.map → scorer-versions-D0_KP67E.js.map} +1 -1
  83. package/dist/{scorer-versions-CYXtxMTU.cjs → scorer-versions-mL--H4LL.cjs} +2 -2
  84. package/dist/{scorer-versions-CYXtxMTU.cjs.map → scorer-versions-mL--H4LL.cjs.map} +1 -1
  85. package/dist/server/a2a/store.cjs +1 -0
  86. package/dist/server/a2a/store.cjs.map +1 -1
  87. package/dist/server/auth/index.cjs +1 -0
  88. package/dist/server/browser-stream/index.cjs +1 -0
  89. package/dist/server/browser-stream/index.cjs.map +1 -1
  90. package/dist/server/handlers/a2a.cjs +2 -1
  91. package/dist/server/handlers/a2a.js +1 -1
  92. package/dist/server/handlers/agent-builder.cjs +4 -4
  93. package/dist/server/handlers/agent-builder.js +2 -2
  94. package/dist/server/handlers/agent-controller.cjs +41 -25
  95. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  96. package/dist/server/handlers/agent-controller.d.ts +22 -2
  97. package/dist/server/handlers/agent-controller.d.ts.map +1 -1
  98. package/dist/server/handlers/agent-controller.js +39 -24
  99. package/dist/server/handlers/agent-controller.js.map +1 -1
  100. package/dist/server/handlers/agent-versions.cjs +4 -3
  101. package/dist/server/handlers/agent-versions.cjs.map +1 -1
  102. package/dist/server/handlers/agent-versions.js +1 -1
  103. package/dist/server/handlers/agents.cjs +7 -7
  104. package/dist/server/handlers/agents.d.ts +8 -0
  105. package/dist/server/handlers/agents.d.ts.map +1 -1
  106. package/dist/server/handlers/agents.js +2 -2
  107. package/dist/server/handlers/auth.cjs +2 -1
  108. package/dist/server/handlers/auth.cjs.map +1 -1
  109. package/dist/server/handlers/author-enrichment.cjs +1 -0
  110. package/dist/server/handlers/author-enrichment.cjs.map +1 -1
  111. package/dist/server/handlers/authorship.cjs +1 -0
  112. package/dist/server/handlers/authorship.cjs.map +1 -1
  113. package/dist/server/handlers/background-tasks.cjs +2 -1
  114. package/dist/server/handlers/builder-registry.cjs +2 -1
  115. package/dist/server/handlers/channels.cjs +2 -1
  116. package/dist/server/handlers/conversations.cjs +4 -4
  117. package/dist/server/handlers/conversations.js +1 -1
  118. package/dist/server/handlers/datasets.cjs +2 -1
  119. package/dist/server/handlers/datasets.cjs.map +1 -1
  120. package/dist/server/handlers/dynamic-workflows.cjs +2 -1
  121. package/dist/server/handlers/dynamic-workflows.js +1 -1
  122. package/dist/server/handlers/editor-builder.cjs +2 -1
  123. package/dist/server/handlers/error.cjs +1 -0
  124. package/dist/server/handlers/error.cjs.map +1 -1
  125. package/dist/server/handlers/favorites-enrichment.cjs +2 -1
  126. package/dist/server/handlers/favorites-enrichment.cjs.map +1 -1
  127. package/dist/server/handlers/gateway-memory-client.cjs +1 -0
  128. package/dist/server/handlers/gateway-memory-client.cjs.map +1 -1
  129. package/dist/server/handlers/logs.cjs +3 -3
  130. package/dist/server/handlers/logs.js +1 -1
  131. package/dist/server/handlers/mcp-client-versions.cjs +3 -2
  132. package/dist/server/handlers/mcp-client-versions.cjs.map +1 -1
  133. package/dist/server/handlers/mcp.cjs +2 -2
  134. package/dist/server/handlers/mcp.js +1 -1
  135. package/dist/server/handlers/memory.cjs +3 -3
  136. package/dist/server/handlers/memory.js +1 -1
  137. package/dist/server/handlers/observability-list-query-schemas.cjs +1 -0
  138. package/dist/server/handlers/observability-list-query-schemas.cjs.map +1 -1
  139. package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
  140. package/dist/server/handlers/observability-shared.cjs +2 -1
  141. package/dist/server/handlers/observability-shared.cjs.map +1 -1
  142. package/dist/server/handlers/observability-storage-schemas.cjs +1 -1
  143. package/dist/server/handlers/observability.cjs +3 -3
  144. package/dist/server/handlers/observability.js +1 -1
  145. package/dist/server/handlers/plans.cjs +3 -3
  146. package/dist/server/handlers/plans.js +1 -1
  147. package/dist/server/handlers/processor-providers.cjs +2 -1
  148. package/dist/server/handlers/processor-providers.cjs.map +1 -1
  149. package/dist/server/handlers/processors.cjs +2 -1
  150. package/dist/server/handlers/processors.cjs.map +1 -1
  151. package/dist/server/handlers/prompt-block-versions.cjs +3 -2
  152. package/dist/server/handlers/prompt-block-versions.cjs.map +1 -1
  153. package/dist/server/handlers/responses.adapter.cjs +1 -0
  154. package/dist/server/handlers/responses.adapter.cjs.map +1 -1
  155. package/dist/server/handlers/responses.cjs +4 -4
  156. package/dist/server/handlers/responses.js +1 -1
  157. package/dist/server/handlers/responses.storage.cjs +2 -1
  158. package/dist/server/handlers/responses.storage.cjs.map +1 -1
  159. package/dist/server/handlers/schedules-workflows-shim.cjs +1 -1
  160. package/dist/server/handlers/schedules.cjs +2 -1
  161. package/dist/server/handlers/scorer-versions.cjs +4 -3
  162. package/dist/server/handlers/scorer-versions.cjs.map +1 -1
  163. package/dist/server/handlers/scorer-versions.js +1 -1
  164. package/dist/server/handlers/scores.cjs +2 -2
  165. package/dist/server/handlers/scores.js +1 -1
  166. package/dist/server/handlers/skills-sh-shared.cjs +1 -0
  167. package/dist/server/handlers/skills-sh-shared.cjs.map +1 -1
  168. package/dist/server/handlers/stored-agent-favorites.cjs +5 -4
  169. package/dist/server/handlers/stored-agent-favorites.cjs.map +1 -1
  170. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  171. package/dist/server/handlers/stored-agents.cjs +7 -5
  172. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  173. package/dist/server/handlers/stored-agents.d.ts +32 -0
  174. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  175. package/dist/server/handlers/stored-agents.js +3 -2
  176. package/dist/server/handlers/stored-agents.js.map +1 -1
  177. package/dist/server/handlers/stored-mcp-clients.cjs +3 -2
  178. package/dist/server/handlers/stored-mcp-clients.cjs.map +1 -1
  179. package/dist/server/handlers/stored-prompt-blocks.cjs +3 -2
  180. package/dist/server/handlers/stored-prompt-blocks.cjs.map +1 -1
  181. package/dist/server/handlers/stored-scorers.cjs +4 -3
  182. package/dist/server/handlers/stored-scorers.cjs.map +1 -1
  183. package/dist/server/handlers/stored-scorers.js +1 -1
  184. package/dist/server/handlers/stored-skill-favorites.cjs +4 -3
  185. package/dist/server/handlers/stored-skill-favorites.cjs.map +1 -1
  186. package/dist/server/handlers/stored-skills.cjs +4 -3
  187. package/dist/server/handlers/stored-skills.cjs.map +1 -1
  188. package/dist/server/handlers/stored-workspaces.cjs +3 -2
  189. package/dist/server/handlers/stored-workspaces.cjs.map +1 -1
  190. package/dist/server/handlers/system.cjs +3 -2
  191. package/dist/server/handlers/system.cjs.map +1 -1
  192. package/dist/server/handlers/system.js +1 -1
  193. package/dist/server/handlers/test-utils.cjs +1 -0
  194. package/dist/server/handlers/test-utils.cjs.map +1 -1
  195. package/dist/server/handlers/tool-providers.cjs +2 -1
  196. package/dist/server/handlers/tool-providers.cjs.map +1 -1
  197. package/dist/server/handlers/tool-schema-overrides.cjs +1 -0
  198. package/dist/server/handlers/tool-schema-overrides.cjs.map +1 -1
  199. package/dist/server/handlers/tools.cjs +6 -6
  200. package/dist/server/handlers/tools.js +1 -1
  201. package/dist/server/handlers/utils.cjs +2 -1
  202. package/dist/server/handlers/validate-agent-instructions.cjs +2 -1
  203. package/dist/server/handlers/validate-agent-instructions.cjs.map +1 -1
  204. package/dist/server/handlers/validate-avatar.cjs +1 -0
  205. package/dist/server/handlers/validate-avatar.cjs.map +1 -1
  206. package/dist/server/handlers/vector.cjs +2 -2
  207. package/dist/server/handlers/vector.js +1 -1
  208. package/dist/server/handlers/version-helpers.cjs +1 -0
  209. package/dist/server/handlers/version-helpers.cjs.map +1 -1
  210. package/dist/server/handlers/voice.cjs +1 -1
  211. package/dist/server/handlers/voice.js +1 -1
  212. package/dist/server/handlers/workflows.cjs +4 -4
  213. package/dist/server/handlers/workflows.js +1 -1
  214. package/dist/server/handlers/workspace.cjs +2 -2
  215. package/dist/server/handlers/workspace.js +1 -1
  216. package/dist/server/handlers.cjs +3 -2
  217. package/dist/server/handlers.js +2 -2
  218. package/dist/server/schemas/index.cjs +7 -6
  219. package/dist/server/schemas/index.js +4 -4
  220. package/dist/server/schemas/stored-agents.d.ts +40 -7
  221. package/dist/server/schemas/stored-agents.d.ts.map +1 -1
  222. package/dist/server/server-adapter/index.cjs +4 -3
  223. package/dist/server/server-adapter/index.cjs.map +1 -1
  224. package/dist/server/server-adapter/index.js +1 -1
  225. package/dist/{stored-agents-CPxfYRH9.cjs → stored-agents-D6JEb3zN.cjs} +15 -3
  226. package/dist/stored-agents-D6JEb3zN.cjs.map +1 -0
  227. package/dist/{stored-agents-BRBZM-Xl.js → stored-agents-DMW5wrF7.js} +15 -3
  228. package/dist/stored-agents-DMW5wrF7.js.map +1 -0
  229. package/dist/{stored-scorers-B__LF0Cy.js → stored-scorers-BA4suzgn.js} +2 -2
  230. package/dist/{stored-scorers-B__LF0Cy.js.map → stored-scorers-BA4suzgn.js.map} +1 -1
  231. package/dist/{stored-scorers-Cml7jPJv.cjs → stored-scorers-D8IwVM0S.cjs} +2 -2
  232. package/dist/{stored-scorers-Cml7jPJv.cjs.map → stored-scorers-D8IwVM0S.cjs.map} +1 -1
  233. package/dist/{sync-djJ8Lmds.js → sync-BG15Yae1.js} +22 -22
  234. package/dist/{sync-djJ8Lmds.js.map → sync-BG15Yae1.js.map} +1 -1
  235. package/dist/{sync-BHatXKfg.cjs → sync-C4LbbSKR.cjs} +22 -22
  236. package/dist/{sync-BHatXKfg.cjs.map → sync-C4LbbSKR.cjs.map} +1 -1
  237. package/dist/{utils-CXbhpYYv.cjs → utils-Xnn91QBW.cjs} +2 -2
  238. package/dist/{utils-CXbhpYYv.cjs.map → utils-Xnn91QBW.cjs.map} +1 -1
  239. package/dist/{utils-BkPZAGxS.cjs → utils-zkjmP1OK.cjs} +3 -3
  240. package/dist/{utils-BkPZAGxS.cjs.map → utils-zkjmP1OK.cjs.map} +1 -1
  241. package/package.json +4 -4
  242. package/dist/probe-image-size-C2F59z8Z.cjs.map +0 -1
  243. package/dist/probe-image-size-mXCWYNrz.js.map +0 -1
  244. package/dist/schema-DkBbires.cjs +0 -1
  245. package/dist/stored-agents-BRBZM-Xl.js.map +0 -1
  246. package/dist/stored-agents-CPxfYRH9.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"favorites-enrichment.cjs","names":["isBuilderFeatureEnabled","getCallerAuthorId"],"sources":["../../../src/server/handlers/favorites-enrichment.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { FavoritesStorage, StorageFavoriteEntityType } from '@mastra/core/storage';\n\nimport { getCallerAuthorId } from './authorship';\nimport { isBuilderFeatureEnabled } from './editor-builder';\n\n/**\n * Result of `prepareFavoritesEnrichment` — `null` when the `favorites` EE feature is off.\n * When non-null the caller may use `starredIds` to set `isFavorited` on records\n * and may pass `userId` along to storage list paths for pin-favorited-first\n * sorting (`pinFavoritedFor`).\n */\nexport type FavoritesEnrichmentContext = {\n userId: string;\n starredIds: Set<string>;\n favoritesStore: FavoritesStorage;\n} | null;\n\n/**\n * Resolve the EE feature flag plus the caller's favorited set for a list of\n * candidate entity IDs in one shot. Soft-gated: returns `null` if the feature\n * is off or there's no caller — handlers should drop `isFavorited` / `favoriteCount`\n * fields and ignore `?favoritedOnly=true` in that case.\n */\nexport async function prepareFavoritesEnrichment(\n mastra: Mastra,\n requestContext: RequestContext,\n entityType: StorageFavoriteEntityType,\n entityIds: string[],\n): Promise<FavoritesEnrichmentContext> {\n if (!(await isBuilderFeatureEnabled(mastra, 'favorites'))) return null;\n\n const userId = getCallerAuthorId(requestContext);\n if (!userId) return null;\n\n const storage = mastra.getStorage();\n if (!storage) return null;\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) return null;\n\n const starredIds =\n entityIds.length === 0\n ? new Set<string>()\n : await favoritesStore.isFavoritedBatch({ userId, entityType, entityIds });\n return { userId, starredIds, favoritesStore };\n}\n\n/**\n * Strip the favorites EE fields from a record. Used when the feature is off so\n * stale values from storage do not leak through the API.\n */\nexport function stripFavoriteFields<T extends object>(record: T): T {\n if ('isFavorited' in record || 'favoriteCount' in record) {\n const copy = { ...record } as Record<string, unknown>;\n delete copy.isFavorited;\n delete copy.favoriteCount;\n return copy as T;\n }\n return record;\n}\n\n/**\n * Convenience for single-entity handlers (GET / POST / PATCH): annotate\n * `isFavorited` from the caller's favorites set when enrichment is available,\n * otherwise strip both favorite fields. `favoriteCount` is the canonical\n * mirrored counter and is left in place so callers can render share-count UI\n * (it's identical across viewers).\n */\nexport async function enrichOrStripFavorites<T extends { id: string }>(\n mastra: Mastra,\n requestContext: RequestContext,\n entityType: StorageFavoriteEntityType,\n record: T,\n): Promise<T> {\n const enrichment = await prepareFavoritesEnrichment(mastra, requestContext, entityType, [record.id]);\n if (enrichment) {\n return { ...record, isFavorited: enrichment.starredIds.has(record.id) };\n }\n return stripFavoriteFields(record);\n}\n"],"mappings":";;;;;;;;;;AAyBA,eAAsB,2BACpB,QACA,gBACA,YACA,WACqC;CACrC,IAAI,CAAE,MAAMA,uBAAAA,wBAAwB,QAAQ,WAAW,GAAI,OAAO;CAElE,MAAM,SAASC,mCAAAA,kBAAkB,cAAc;CAC/C,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,iBAAiB,MAAM,QAAQ,SAAS,WAAW;CACzD,IAAI,CAAC,gBAAgB,OAAO;CAM5B,OAAO;EAAE;EAAQ,YAHf,UAAU,WAAW,oBACjB,IAAI,IAAY,IAChB,MAAM,eAAe,iBAAiB;GAAE;GAAQ;GAAY;EAAU,CAAC;EAChD;CAAe;AAC9C;;;;;AAMA,SAAgB,oBAAsC,QAAc;CAClE,IAAI,iBAAiB,UAAU,mBAAmB,QAAQ;EACxD,MAAM,OAAO,EAAE,GAAG,OAAO;EACzB,OAAO,KAAK;EACZ,OAAO,KAAK;EACZ,OAAO;CACT;CACA,OAAO;AACT;;;;;;;;AASA,eAAsB,uBACpB,QACA,gBACA,YACA,QACY;CACZ,MAAM,aAAa,MAAM,2BAA2B,QAAQ,gBAAgB,YAAY,CAAC,OAAO,EAAE,CAAC;CACnG,IAAI,YACF,OAAO;EAAE,GAAG;EAAQ,aAAa,WAAW,WAAW,IAAI,OAAO,EAAE;CAAE;CAExE,OAAO,oBAAoB,MAAM;AACnC"}
1
+ {"version":3,"file":"favorites-enrichment.cjs","names":["isBuilderFeatureEnabled","getCallerAuthorId"],"sources":["../../../src/server/handlers/favorites-enrichment.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { FavoritesStorage, StorageFavoriteEntityType } from '@mastra/core/storage';\n\nimport { getCallerAuthorId } from './authorship';\nimport { isBuilderFeatureEnabled } from './editor-builder';\n\n/**\n * Result of `prepareFavoritesEnrichment` — `null` when the `favorites` EE feature is off.\n * When non-null the caller may use `starredIds` to set `isFavorited` on records\n * and may pass `userId` along to storage list paths for pin-favorited-first\n * sorting (`pinFavoritedFor`).\n */\nexport type FavoritesEnrichmentContext = {\n userId: string;\n starredIds: Set<string>;\n favoritesStore: FavoritesStorage;\n} | null;\n\n/**\n * Resolve the EE feature flag plus the caller's favorited set for a list of\n * candidate entity IDs in one shot. Soft-gated: returns `null` if the feature\n * is off or there's no caller — handlers should drop `isFavorited` / `favoriteCount`\n * fields and ignore `?favoritedOnly=true` in that case.\n */\nexport async function prepareFavoritesEnrichment(\n mastra: Mastra,\n requestContext: RequestContext,\n entityType: StorageFavoriteEntityType,\n entityIds: string[],\n): Promise<FavoritesEnrichmentContext> {\n if (!(await isBuilderFeatureEnabled(mastra, 'favorites'))) return null;\n\n const userId = getCallerAuthorId(requestContext);\n if (!userId) return null;\n\n const storage = mastra.getStorage();\n if (!storage) return null;\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) return null;\n\n const starredIds =\n entityIds.length === 0\n ? new Set<string>()\n : await favoritesStore.isFavoritedBatch({ userId, entityType, entityIds });\n return { userId, starredIds, favoritesStore };\n}\n\n/**\n * Strip the favorites EE fields from a record. Used when the feature is off so\n * stale values from storage do not leak through the API.\n */\nexport function stripFavoriteFields<T extends object>(record: T): T {\n if ('isFavorited' in record || 'favoriteCount' in record) {\n const copy = { ...record } as Record<string, unknown>;\n delete copy.isFavorited;\n delete copy.favoriteCount;\n return copy as T;\n }\n return record;\n}\n\n/**\n * Convenience for single-entity handlers (GET / POST / PATCH): annotate\n * `isFavorited` from the caller's favorites set when enrichment is available,\n * otherwise strip both favorite fields. `favoriteCount` is the canonical\n * mirrored counter and is left in place so callers can render share-count UI\n * (it's identical across viewers).\n */\nexport async function enrichOrStripFavorites<T extends { id: string }>(\n mastra: Mastra,\n requestContext: RequestContext,\n entityType: StorageFavoriteEntityType,\n record: T,\n): Promise<T> {\n const enrichment = await prepareFavoritesEnrichment(mastra, requestContext, entityType, [record.id]);\n if (enrichment) {\n return { ...record, isFavorited: enrichment.starredIds.has(record.id) };\n }\n return stripFavoriteFields(record);\n}\n"],"mappings":";;;;;;;;;;;AAyBA,eAAsB,2BACpB,QACA,gBACA,YACA,WACqC;CACrC,IAAI,CAAE,MAAMA,uBAAAA,wBAAwB,QAAQ,WAAW,GAAI,OAAO;CAElE,MAAM,SAASC,mCAAAA,kBAAkB,cAAc;CAC/C,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,iBAAiB,MAAM,QAAQ,SAAS,WAAW;CACzD,IAAI,CAAC,gBAAgB,OAAO;CAM5B,OAAO;EAAE;EAAQ,YAHf,UAAU,WAAW,oBACjB,IAAI,IAAY,IAChB,MAAM,eAAe,iBAAiB;GAAE;GAAQ;GAAY;EAAU,CAAC;EAChD;CAAe;AAC9C;;;;;AAMA,SAAgB,oBAAsC,QAAc;CAClE,IAAI,iBAAiB,UAAU,mBAAmB,QAAQ;EACxD,MAAM,OAAO,EAAE,GAAG,OAAO;EACzB,OAAO,KAAK;EACZ,OAAO,KAAK;EACZ,OAAO;CACT;CACA,OAAO;AACT;;;;;;;;AASA,eAAsB,uBACpB,QACA,gBACA,YACA,QACY;CACZ,MAAM,aAAa,MAAM,2BAA2B,QAAQ,gBAAgB,YAAY,CAAC,OAAO,EAAE,CAAC;CACnG,IAAI,YACF,OAAO;EAAE,GAAG;EAAQ,aAAa,WAAW,WAAW,IAAI,OAAO,EAAE;CAAE;CAExE,OAAO,oBAAoB,MAAM;AACnC"}
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../rolldown-runtime-Bd6kNlEP.cjs");
2
3
  //#region src/server/handlers/gateway-memory-client.ts
3
4
  var GatewayMemoryClient = class {
4
5
  baseUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"gateway-memory-client.cjs","names":[],"sources":["../../../src/server/handlers/gateway-memory-client.ts"],"sourcesContent":["/**\n * HTTP client for the Gateway memory REST API.\n * Used to proxy memory operations from the local Mastra server to the remote gateway\n * when agents use `mastra/` model strings.\n */\n\ninterface GatewayThread {\n id: string;\n projectId: string;\n resourceId: string;\n title: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface GatewayMessage {\n id: string;\n threadId: string;\n role: string;\n content: unknown;\n type: string;\n createdAt: string;\n}\n\ninterface GatewayBufferedObservationChunk {\n id?: string;\n cycleId: string;\n observations: string;\n tokenCount: number;\n messageIds?: string[];\n messageTokens: number;\n lastObservedAt?: string | null;\n createdAt?: string | null;\n suggestedContinuation?: string;\n currentTask?: string;\n threadTitle?: string;\n extractedValues?: Record<string, unknown>;\n extractionFailures?: Array<{ slug: string; error: string }>;\n}\n\ninterface GatewayOMRecord {\n id: string;\n scope: string;\n threadId: string | null;\n resourceId: string;\n createdAt: string;\n updatedAt: string;\n lastObservedAt: string | null;\n originType: string;\n generationCount: number;\n activeObservations: unknown;\n totalTokensObserved: number;\n observationTokenCount: number;\n pendingMessageTokens: number;\n isReflecting: boolean;\n isObserving: boolean;\n isBufferingObservation: boolean;\n isBufferingReflection: boolean;\n config?: Record<string, unknown>;\n bufferedObservationChunks?: GatewayBufferedObservationChunk[];\n bufferedReflection?: string | null;\n bufferedReflectionTokens?: number | null;\n bufferedReflectionInputTokens?: number | null;\n}\n\nexport class GatewayMemoryClient {\n private baseUrl: string;\n private apiKey: string;\n\n constructor(baseUrl: string, apiKey: string) {\n // Strip trailing slashes and /v1 suffix so both URL forms resolve correctly\n this.baseUrl = baseUrl.replace(/\\/+$/, '').replace(/\\/v1$/, '') + '/v1/memory';\n this.apiKey = apiKey;\n }\n\n private threadPath(threadId: string): string {\n return `/threads/${encodeURIComponent(threadId)}`;\n }\n\n private async request<T>(path: string, options: RequestInit = {}): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 10_000);\n try {\n const res = await fetch(url, {\n ...options,\n signal: options.signal ?? controller.signal,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.apiKey}`,\n ...((options.headers as Record<string, string>) || {}),\n },\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => '');\n throw new Error(`Gateway API error ${res.status}: ${body}`);\n }\n\n return res.json() as Promise<T>;\n } finally {\n clearTimeout(timeout);\n }\n }\n\n // ── Threads ──────────────────────────────────────────────────\n\n async listThreads(params: {\n resourceId?: string;\n limit?: number;\n offset?: number;\n }): Promise<{ threads: GatewayThread[]; total: number }> {\n const query = new URLSearchParams();\n if (params.resourceId) query.set('resourceId', params.resourceId);\n if (params.limit != null) query.set('limit', String(params.limit));\n if (params.offset != null) query.set('offset', String(params.offset));\n const qs = query.toString();\n return this.request(`/threads${qs ? '?' + qs : ''}`);\n }\n\n async getThread(threadId: string): Promise<{ thread: GatewayThread } | null> {\n try {\n return await this.request(this.threadPath(threadId));\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return null;\n throw e;\n }\n }\n\n async createThread(params: {\n id?: string;\n resourceId: string;\n title?: string;\n metadata?: Record<string, unknown>;\n }): Promise<{ thread: GatewayThread }> {\n return this.request('/threads', {\n method: 'POST',\n body: JSON.stringify(params),\n });\n }\n\n async updateThread(\n threadId: string,\n params: { title?: string; metadata?: Record<string, unknown> },\n ): Promise<{ thread: GatewayThread } | null> {\n try {\n return await this.request(this.threadPath(threadId), {\n method: 'PATCH',\n body: JSON.stringify(params),\n });\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return null;\n throw e;\n }\n }\n\n async deleteThread(threadId: string): Promise<{ ok: boolean }> {\n try {\n return await this.request(this.threadPath(threadId), { method: 'DELETE' });\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return { ok: false };\n throw e;\n }\n }\n\n // ── Messages ─────────────────────────────────────────────────\n\n async listMessages(\n threadId: string,\n params: { limit?: number; offset?: number; order?: string },\n ): Promise<{ messages: GatewayMessage[]; total: number } | null> {\n const query = new URLSearchParams();\n if (params.limit != null) query.set('limit', String(params.limit));\n if (params.offset != null) query.set('offset', String(params.offset));\n if (params.order) query.set('order', params.order);\n const qs = query.toString();\n try {\n return await this.request(`${this.threadPath(threadId)}/messages${qs ? '?' + qs : ''}`);\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return null;\n throw e;\n }\n }\n\n // ── Observational Memory ─────────────────────────────────────\n\n async getObservations(threadId: string, resourceId?: string): Promise<{ observations: unknown }> {\n const query = new URLSearchParams();\n if (resourceId) query.set('resourceId', resourceId);\n const qs = query.toString();\n return this.request(`${this.threadPath(threadId)}/observations${qs ? '?' + qs : ''}`);\n }\n\n async getObservationRecord(threadId: string, resourceId?: string): Promise<{ record: GatewayOMRecord | null }> {\n const query = new URLSearchParams();\n if (resourceId) query.set('resourceId', resourceId);\n const qs = query.toString();\n try {\n return await this.request(`${this.threadPath(threadId)}/observations/record${qs ? '?' + qs : ''}`);\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return { record: null };\n throw e;\n }\n }\n\n async getObservationHistory(\n threadId: string,\n params: { resourceId?: string; limit?: number; from?: Date; to?: Date; offset?: number },\n ): Promise<{ records: GatewayOMRecord[] }> {\n const query = new URLSearchParams();\n if (params.resourceId) query.set('resourceId', params.resourceId);\n if (params.limit != null) query.set('limit', String(params.limit));\n if (params.from) query.set('from', params.from.toISOString());\n if (params.to) query.set('to', params.to.toISOString());\n if (params.offset != null) query.set('offset', String(params.offset));\n const qs = query.toString();\n try {\n return await this.request(`${this.threadPath(threadId)}/observations/history${qs ? '?' + qs : ''}`);\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return { records: [] };\n throw e;\n }\n }\n}\n\n// ── Helpers ──────────────────────────────────────────────────────\n\n/**\n * Convert a gateway thread to the local server thread format.\n */\nexport function toLocalThread(gt: GatewayThread) {\n return {\n id: gt.id,\n resourceId: gt.resourceId,\n title: gt.title ?? '',\n metadata: gt.metadata ?? {},\n createdAt: new Date(gt.createdAt),\n updatedAt: new Date(gt.updatedAt),\n };\n}\n\n/**\n * Convert a gateway message to the local server message format.\n */\nexport function toLocalMessage(gm: GatewayMessage) {\n return {\n id: gm.id,\n threadId: gm.threadId,\n role: gm.role,\n content: gm.content,\n type: gm.type,\n createdAt: new Date(gm.createdAt),\n };\n}\n\n/**\n * Convert a gateway OM record to the local server OM record format.\n */\nexport function toLocalOMRecord(gr: GatewayOMRecord) {\n return {\n id: gr.id,\n scope: gr.scope as 'thread' | 'resource',\n threadId: gr.threadId,\n resourceId: gr.resourceId,\n createdAt: new Date(gr.createdAt),\n updatedAt: new Date(gr.updatedAt),\n lastObservedAt: gr.lastObservedAt ? new Date(gr.lastObservedAt) : undefined,\n originType: gr.originType as 'initial' | 'reflection' | 'observation',\n generationCount: gr.generationCount,\n activeObservations: (gr.activeObservations ?? '') as string,\n totalTokensObserved: gr.totalTokensObserved,\n observationTokenCount: gr.observationTokenCount,\n pendingMessageTokens: gr.pendingMessageTokens,\n isReflecting: gr.isReflecting,\n isObserving: gr.isObserving,\n isBufferingObservation: gr.isBufferingObservation,\n isBufferingReflection: gr.isBufferingReflection,\n config: gr.config ?? {},\n bufferedObservationChunks: gr.bufferedObservationChunks?.map(chunk => ({\n ...chunk,\n lastObservedAt: chunk.lastObservedAt ? new Date(chunk.lastObservedAt) : undefined,\n createdAt: chunk.createdAt ? new Date(chunk.createdAt) : undefined,\n })),\n bufferedReflection: gr.bufferedReflection ?? undefined,\n bufferedReflectionTokens: gr.bufferedReflectionTokens ?? undefined,\n bufferedReflectionInputTokens: gr.bufferedReflectionInputTokens ?? undefined,\n };\n}\n\n// Singleton-ish lazy instance\nlet _gatewayClient: GatewayMemoryClient | null | undefined;\n\n/**\n * Get a GatewayMemoryClient instance, or null if gateway is not configured.\n */\nexport function getGatewayClient(): GatewayMemoryClient | null {\n if (_gatewayClient !== undefined) return _gatewayClient;\n const url = process.env.MASTRA_GATEWAY_URL || 'https://gateway-api.mastra.ai';\n const key = process.env.MASTRA_GATEWAY_API_KEY;\n if (!key) {\n _gatewayClient = null;\n return null;\n }\n _gatewayClient = new GatewayMemoryClient(url, key);\n return _gatewayClient;\n}\n\n/**\n * Check if an agent uses a gateway model (mastra/ prefix).\n * Sync version — can only check agent.model string directly.\n */\n\nexport function isGatewayAgent(agent: any): boolean {\n if (!agent) return false;\n try {\n const agentAny = agent as Record<string, unknown>;\n if (typeof agentAny.model === 'string' && agentAny.model.startsWith('mastra/')) {\n return true;\n }\n } catch {\n // Ignore errors during detection\n }\n return false;\n}\n\n/**\n * Async version of isGatewayAgent that can await getLLM().\n * Checks multiple paths to detect if an agent uses a mastra/ gateway model:\n * 1. agent.model as raw string (most reliable for directly configured agents)\n * 2. Resolved LLM's underlying ModelRouterLanguageModel config.routerId\n * 3. Resolved LLM's getModel() to access the router's config\n */\n\nexport async function isGatewayAgentAsync(agent: any): Promise<boolean> {\n if (!agent) return false;\n try {\n const agentAny = agent as Record<string, unknown>;\n\n // Check 1: agent.model is a raw string like 'mastra/openai/gpt-5-mini'\n if (typeof agentAny.model === 'string' && agentAny.model.startsWith('mastra/')) {\n return true;\n }\n\n // Check 2: Resolve the LLM and check the router's config.routerId\n // llm.getModelId() returns stripped ID (e.g., 'gpt-5-mini'), so we need\n // to access the underlying ModelRouterLanguageModel's config.routerId\n if (typeof agent.getLLM === 'function') {\n const llm = await Promise.resolve(agent.getLLM({}));\n if (llm) {\n // Try to access the underlying model's routerId via getModel()\n const llmAny = llm as Record<string, unknown>;\n if (typeof llmAny.getModel === 'function') {\n const underlyingModel = (llmAny as { getModel: () => unknown }).getModel();\n const modelAny = underlyingModel as Record<string, unknown>;\n // ModelRouterLanguageModel stores routerId in private config\n if (modelAny?.config && typeof modelAny.config === 'object') {\n const routerId = (modelAny.config as Record<string, unknown>).routerId;\n if (typeof routerId === 'string' && routerId.startsWith('mastra/')) {\n return true;\n }\n }\n }\n }\n }\n } catch {\n // Detection failed — not a gateway agent\n }\n return false;\n}\n"],"mappings":";;AAkEA,IAAa,sBAAb,MAAiC;CAC/B;CACA;CAEA,YAAY,SAAiB,QAAgB;EAE3C,KAAK,UAAU,QAAQ,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,SAAS,EAAE,IAAI;EAClE,KAAK,SAAS;CAChB;CAEA,WAAmB,UAA0B;EAC3C,OAAO,YAAY,mBAAmB,QAAQ;CAChD;CAEA,MAAc,QAAW,MAAc,UAAuB,CAAC,GAAe;EAC5E,MAAM,MAAM,GAAG,KAAK,UAAU;EAC9B,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,UAAU,iBAAiB,WAAW,MAAM,GAAG,GAAM;EAC3D,IAAI;GACF,MAAM,MAAM,MAAM,MAAM,KAAK;IAC3B,GAAG;IACH,QAAQ,QAAQ,UAAU,WAAW;IACrC,SAAS;KACP,gBAAgB;KAChB,eAAe,UAAU,KAAK;KAC9B,GAAK,QAAQ,WAAsC,CAAC;IACtD;GACF,CAAC;GAED,IAAI,CAAC,IAAI,IAAI;IACX,MAAM,OAAO,MAAM,IAAI,KAAK,CAAC,CAAC,YAAY,EAAE;IAC5C,MAAM,IAAI,MAAM,qBAAqB,IAAI,OAAO,IAAI,MAAM;GAC5D;GAEA,OAAO,IAAI,KAAK;EAClB,UAAU;GACR,aAAa,OAAO;EACtB;CACF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AM,WADmB,OAAuC,SACjC;KAE/B,IAAI,UAAU,UAAU,OAAO,SAAS,WAAW,UAAU;MAC3D,MAAM,WAAY,SAAS,OAAmC;MAC9D,IAAI,OAAO,aAAa,YAAY,SAAS,WAAW,SAAS,GAC/D,OAAO;KAEX;IACF;GACF;EACF;CACF,QAAQ,CAER;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"gateway-memory-client.cjs","names":[],"sources":["../../../src/server/handlers/gateway-memory-client.ts"],"sourcesContent":["/**\n * HTTP client for the Gateway memory REST API.\n * Used to proxy memory operations from the local Mastra server to the remote gateway\n * when agents use `mastra/` model strings.\n */\n\ninterface GatewayThread {\n id: string;\n projectId: string;\n resourceId: string;\n title: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface GatewayMessage {\n id: string;\n threadId: string;\n role: string;\n content: unknown;\n type: string;\n createdAt: string;\n}\n\ninterface GatewayBufferedObservationChunk {\n id?: string;\n cycleId: string;\n observations: string;\n tokenCount: number;\n messageIds?: string[];\n messageTokens: number;\n lastObservedAt?: string | null;\n createdAt?: string | null;\n suggestedContinuation?: string;\n currentTask?: string;\n threadTitle?: string;\n extractedValues?: Record<string, unknown>;\n extractionFailures?: Array<{ slug: string; error: string }>;\n}\n\ninterface GatewayOMRecord {\n id: string;\n scope: string;\n threadId: string | null;\n resourceId: string;\n createdAt: string;\n updatedAt: string;\n lastObservedAt: string | null;\n originType: string;\n generationCount: number;\n activeObservations: unknown;\n totalTokensObserved: number;\n observationTokenCount: number;\n pendingMessageTokens: number;\n isReflecting: boolean;\n isObserving: boolean;\n isBufferingObservation: boolean;\n isBufferingReflection: boolean;\n config?: Record<string, unknown>;\n bufferedObservationChunks?: GatewayBufferedObservationChunk[];\n bufferedReflection?: string | null;\n bufferedReflectionTokens?: number | null;\n bufferedReflectionInputTokens?: number | null;\n}\n\nexport class GatewayMemoryClient {\n private baseUrl: string;\n private apiKey: string;\n\n constructor(baseUrl: string, apiKey: string) {\n // Strip trailing slashes and /v1 suffix so both URL forms resolve correctly\n this.baseUrl = baseUrl.replace(/\\/+$/, '').replace(/\\/v1$/, '') + '/v1/memory';\n this.apiKey = apiKey;\n }\n\n private threadPath(threadId: string): string {\n return `/threads/${encodeURIComponent(threadId)}`;\n }\n\n private async request<T>(path: string, options: RequestInit = {}): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 10_000);\n try {\n const res = await fetch(url, {\n ...options,\n signal: options.signal ?? controller.signal,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.apiKey}`,\n ...((options.headers as Record<string, string>) || {}),\n },\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => '');\n throw new Error(`Gateway API error ${res.status}: ${body}`);\n }\n\n return res.json() as Promise<T>;\n } finally {\n clearTimeout(timeout);\n }\n }\n\n // ── Threads ──────────────────────────────────────────────────\n\n async listThreads(params: {\n resourceId?: string;\n limit?: number;\n offset?: number;\n }): Promise<{ threads: GatewayThread[]; total: number }> {\n const query = new URLSearchParams();\n if (params.resourceId) query.set('resourceId', params.resourceId);\n if (params.limit != null) query.set('limit', String(params.limit));\n if (params.offset != null) query.set('offset', String(params.offset));\n const qs = query.toString();\n return this.request(`/threads${qs ? '?' + qs : ''}`);\n }\n\n async getThread(threadId: string): Promise<{ thread: GatewayThread } | null> {\n try {\n return await this.request(this.threadPath(threadId));\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return null;\n throw e;\n }\n }\n\n async createThread(params: {\n id?: string;\n resourceId: string;\n title?: string;\n metadata?: Record<string, unknown>;\n }): Promise<{ thread: GatewayThread }> {\n return this.request('/threads', {\n method: 'POST',\n body: JSON.stringify(params),\n });\n }\n\n async updateThread(\n threadId: string,\n params: { title?: string; metadata?: Record<string, unknown> },\n ): Promise<{ thread: GatewayThread } | null> {\n try {\n return await this.request(this.threadPath(threadId), {\n method: 'PATCH',\n body: JSON.stringify(params),\n });\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return null;\n throw e;\n }\n }\n\n async deleteThread(threadId: string): Promise<{ ok: boolean }> {\n try {\n return await this.request(this.threadPath(threadId), { method: 'DELETE' });\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return { ok: false };\n throw e;\n }\n }\n\n // ── Messages ─────────────────────────────────────────────────\n\n async listMessages(\n threadId: string,\n params: { limit?: number; offset?: number; order?: string },\n ): Promise<{ messages: GatewayMessage[]; total: number } | null> {\n const query = new URLSearchParams();\n if (params.limit != null) query.set('limit', String(params.limit));\n if (params.offset != null) query.set('offset', String(params.offset));\n if (params.order) query.set('order', params.order);\n const qs = query.toString();\n try {\n return await this.request(`${this.threadPath(threadId)}/messages${qs ? '?' + qs : ''}`);\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return null;\n throw e;\n }\n }\n\n // ── Observational Memory ─────────────────────────────────────\n\n async getObservations(threadId: string, resourceId?: string): Promise<{ observations: unknown }> {\n const query = new URLSearchParams();\n if (resourceId) query.set('resourceId', resourceId);\n const qs = query.toString();\n return this.request(`${this.threadPath(threadId)}/observations${qs ? '?' + qs : ''}`);\n }\n\n async getObservationRecord(threadId: string, resourceId?: string): Promise<{ record: GatewayOMRecord | null }> {\n const query = new URLSearchParams();\n if (resourceId) query.set('resourceId', resourceId);\n const qs = query.toString();\n try {\n return await this.request(`${this.threadPath(threadId)}/observations/record${qs ? '?' + qs : ''}`);\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return { record: null };\n throw e;\n }\n }\n\n async getObservationHistory(\n threadId: string,\n params: { resourceId?: string; limit?: number; from?: Date; to?: Date; offset?: number },\n ): Promise<{ records: GatewayOMRecord[] }> {\n const query = new URLSearchParams();\n if (params.resourceId) query.set('resourceId', params.resourceId);\n if (params.limit != null) query.set('limit', String(params.limit));\n if (params.from) query.set('from', params.from.toISOString());\n if (params.to) query.set('to', params.to.toISOString());\n if (params.offset != null) query.set('offset', String(params.offset));\n const qs = query.toString();\n try {\n return await this.request(`${this.threadPath(threadId)}/observations/history${qs ? '?' + qs : ''}`);\n } catch (e: unknown) {\n if (e instanceof Error && e.message.includes('404')) return { records: [] };\n throw e;\n }\n }\n}\n\n// ── Helpers ──────────────────────────────────────────────────────\n\n/**\n * Convert a gateway thread to the local server thread format.\n */\nexport function toLocalThread(gt: GatewayThread) {\n return {\n id: gt.id,\n resourceId: gt.resourceId,\n title: gt.title ?? '',\n metadata: gt.metadata ?? {},\n createdAt: new Date(gt.createdAt),\n updatedAt: new Date(gt.updatedAt),\n };\n}\n\n/**\n * Convert a gateway message to the local server message format.\n */\nexport function toLocalMessage(gm: GatewayMessage) {\n return {\n id: gm.id,\n threadId: gm.threadId,\n role: gm.role,\n content: gm.content,\n type: gm.type,\n createdAt: new Date(gm.createdAt),\n };\n}\n\n/**\n * Convert a gateway OM record to the local server OM record format.\n */\nexport function toLocalOMRecord(gr: GatewayOMRecord) {\n return {\n id: gr.id,\n scope: gr.scope as 'thread' | 'resource',\n threadId: gr.threadId,\n resourceId: gr.resourceId,\n createdAt: new Date(gr.createdAt),\n updatedAt: new Date(gr.updatedAt),\n lastObservedAt: gr.lastObservedAt ? new Date(gr.lastObservedAt) : undefined,\n originType: gr.originType as 'initial' | 'reflection' | 'observation',\n generationCount: gr.generationCount,\n activeObservations: (gr.activeObservations ?? '') as string,\n totalTokensObserved: gr.totalTokensObserved,\n observationTokenCount: gr.observationTokenCount,\n pendingMessageTokens: gr.pendingMessageTokens,\n isReflecting: gr.isReflecting,\n isObserving: gr.isObserving,\n isBufferingObservation: gr.isBufferingObservation,\n isBufferingReflection: gr.isBufferingReflection,\n config: gr.config ?? {},\n bufferedObservationChunks: gr.bufferedObservationChunks?.map(chunk => ({\n ...chunk,\n lastObservedAt: chunk.lastObservedAt ? new Date(chunk.lastObservedAt) : undefined,\n createdAt: chunk.createdAt ? new Date(chunk.createdAt) : undefined,\n })),\n bufferedReflection: gr.bufferedReflection ?? undefined,\n bufferedReflectionTokens: gr.bufferedReflectionTokens ?? undefined,\n bufferedReflectionInputTokens: gr.bufferedReflectionInputTokens ?? undefined,\n };\n}\n\n// Singleton-ish lazy instance\nlet _gatewayClient: GatewayMemoryClient | null | undefined;\n\n/**\n * Get a GatewayMemoryClient instance, or null if gateway is not configured.\n */\nexport function getGatewayClient(): GatewayMemoryClient | null {\n if (_gatewayClient !== undefined) return _gatewayClient;\n const url = process.env.MASTRA_GATEWAY_URL || 'https://gateway-api.mastra.ai';\n const key = process.env.MASTRA_GATEWAY_API_KEY;\n if (!key) {\n _gatewayClient = null;\n return null;\n }\n _gatewayClient = new GatewayMemoryClient(url, key);\n return _gatewayClient;\n}\n\n/**\n * Check if an agent uses a gateway model (mastra/ prefix).\n * Sync version — can only check agent.model string directly.\n */\n\nexport function isGatewayAgent(agent: any): boolean {\n if (!agent) return false;\n try {\n const agentAny = agent as Record<string, unknown>;\n if (typeof agentAny.model === 'string' && agentAny.model.startsWith('mastra/')) {\n return true;\n }\n } catch {\n // Ignore errors during detection\n }\n return false;\n}\n\n/**\n * Async version of isGatewayAgent that can await getLLM().\n * Checks multiple paths to detect if an agent uses a mastra/ gateway model:\n * 1. agent.model as raw string (most reliable for directly configured agents)\n * 2. Resolved LLM's underlying ModelRouterLanguageModel config.routerId\n * 3. Resolved LLM's getModel() to access the router's config\n */\n\nexport async function isGatewayAgentAsync(agent: any): Promise<boolean> {\n if (!agent) return false;\n try {\n const agentAny = agent as Record<string, unknown>;\n\n // Check 1: agent.model is a raw string like 'mastra/openai/gpt-5-mini'\n if (typeof agentAny.model === 'string' && agentAny.model.startsWith('mastra/')) {\n return true;\n }\n\n // Check 2: Resolve the LLM and check the router's config.routerId\n // llm.getModelId() returns stripped ID (e.g., 'gpt-5-mini'), so we need\n // to access the underlying ModelRouterLanguageModel's config.routerId\n if (typeof agent.getLLM === 'function') {\n const llm = await Promise.resolve(agent.getLLM({}));\n if (llm) {\n // Try to access the underlying model's routerId via getModel()\n const llmAny = llm as Record<string, unknown>;\n if (typeof llmAny.getModel === 'function') {\n const underlyingModel = (llmAny as { getModel: () => unknown }).getModel();\n const modelAny = underlyingModel as Record<string, unknown>;\n // ModelRouterLanguageModel stores routerId in private config\n if (modelAny?.config && typeof modelAny.config === 'object') {\n const routerId = (modelAny.config as Record<string, unknown>).routerId;\n if (typeof routerId === 'string' && routerId.startsWith('mastra/')) {\n return true;\n }\n }\n }\n }\n }\n } catch {\n // Detection failed — not a gateway agent\n }\n return false;\n}\n"],"mappings":";;;AAkEA,IAAa,sBAAb,MAAiC;CAC/B;CACA;CAEA,YAAY,SAAiB,QAAgB;EAE3C,KAAK,UAAU,QAAQ,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,SAAS,EAAE,IAAI;EAClE,KAAK,SAAS;CAChB;CAEA,WAAmB,UAA0B;EAC3C,OAAO,YAAY,mBAAmB,QAAQ;CAChD;CAEA,MAAc,QAAW,MAAc,UAAuB,CAAC,GAAe;EAC5E,MAAM,MAAM,GAAG,KAAK,UAAU;EAC9B,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,UAAU,iBAAiB,WAAW,MAAM,GAAG,GAAM;EAC3D,IAAI;GACF,MAAM,MAAM,MAAM,MAAM,KAAK;IAC3B,GAAG;IACH,QAAQ,QAAQ,UAAU,WAAW;IACrC,SAAS;KACP,gBAAgB;KAChB,eAAe,UAAU,KAAK;KAC9B,GAAK,QAAQ,WAAsC,CAAC;IACtD;GACF,CAAC;GAED,IAAI,CAAC,IAAI,IAAI;IACX,MAAM,OAAO,MAAM,IAAI,KAAK,CAAC,CAAC,YAAY,EAAE;IAC5C,MAAM,IAAI,MAAM,qBAAqB,IAAI,OAAO,IAAI,MAAM;GAC5D;GAEA,OAAO,IAAI,KAAK;EAClB,UAAU;GACR,aAAa,OAAO;EACtB;CACF;CAIA,MAAM,YAAY,QAIuC;EACvD,MAAM,QAAQ,IAAI,gBAAgB;EAClC,IAAI,OAAO,YAAY,MAAM,IAAI,cAAc,OAAO,UA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,IAAI,OAAO,aAAa,YAAY,SAAS,WAAW,SAAS,GAC/D,OAAO;KAEX;IACF;GACF;EACF;CACF,QAAQ,CAER;CACA,OAAO;AACT"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
2
+ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
3
3
  const require_common = require("../../common-DQn8jX5T.cjs");
4
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
5
5
  const require_server_handlers_error = require("./error.cjs");
6
- const require_utils = require("../../utils-CXbhpYYv.cjs");
6
+ const require_utils = require("../../utils-Xnn91QBW.cjs");
7
7
  const require_logs = require("../../logs-BDuGFqxu.cjs");
8
8
  //#region src/server/handlers/logs.ts
9
9
  var logs_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../../rolldown-runtime-DuvcJU0W.js";
1
+ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
2
2
  import { l as runIdSchema } from "../../common-5ZZuR6wj.js";
3
3
  import { n as createRoute } from "../../route-builder-YQ_gLIvW.js";
4
4
  import { handleError } from "./error.js";
@@ -1,7 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../rolldown-runtime-Bd6kNlEP.cjs");
2
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
3
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
- const require_utils = require("../../utils-BkPZAGxS.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
5
+ const require_utils = require("../../utils-zkjmP1OK.cjs");
5
6
  const require_server_handlers_error = require("./error.cjs");
6
7
  const require_server_handlers_version_helpers = require("./version-helpers.cjs");
7
8
  const require_mcp_client_versions = require("../../mcp-client-versions-CG7po4hq.cjs");
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-client-versions.cjs","names":["createRoute","mcpClientVersionPathParams","listMCPClientVersionsQuerySchema","listMCPClientVersionsResponseSchema","HTTPException","getStoredResourceScope","handleError","createMCPClientVersionBodySchema","createMCPClientVersionResponseSchema","extractConfigFromVersion","MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS","calculateChangedFields","createVersionWithRetry","enforceRetentionLimit","mcpClientVersionIdPathParams","getMCPClientVersionResponseSchema","activateMCPClientVersionResponseSchema","restoreMCPClientVersionResponseSchema","deleteMCPClientVersionResponseSchema","compareMCPClientVersionsQuerySchema","compareMCPClientVersionsResponseSchema","computeVersionDiffs"],"sources":["../../../src/server/handlers/mcp-client-versions.ts"],"sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n mcpClientVersionPathParams,\n mcpClientVersionIdPathParams,\n listMCPClientVersionsQuerySchema,\n createMCPClientVersionBodySchema,\n compareMCPClientVersionsQuerySchema,\n listMCPClientVersionsResponseSchema,\n getMCPClientVersionResponseSchema,\n createMCPClientVersionResponseSchema,\n activateMCPClientVersionResponseSchema,\n restoreMCPClientVersionResponseSchema,\n deleteMCPClientVersionResponseSchema,\n compareMCPClientVersionsResponseSchema,\n} from '../schemas/mcp-client-versions';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { assertStoredResourceScope, getStoredResourceScope } from '../utils';\n\nimport { handleError } from './error';\nimport {\n extractConfigFromVersion,\n calculateChangedFields,\n computeVersionDiffs,\n createVersionWithRetry,\n enforceRetentionLimit,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n} from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\n/**\n * GET /stored/mcp-clients/:mcpClientId/versions - List all versions for an MCP client\n */\nexport const LIST_MCP_CLIENT_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/mcp-clients/:mcpClientId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionPathParams,\n queryParamSchema: listMCPClientVersionsQuerySchema,\n responseSchema: listMCPClientVersionsResponseSchema,\n summary: 'List MCP client versions',\n description: 'Returns a paginated list of all versions for a stored MCP client',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, page, perPage, orderBy, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const result = await mcpClientStore.listVersions({\n mcpClientId,\n page,\n perPage,\n orderBy,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing MCP client versions');\n }\n },\n});\n\n/**\n * POST /stored/mcp-clients/:mcpClientId/versions - Create a new version snapshot\n */\nexport const CREATE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/mcp-clients/:mcpClientId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionPathParams,\n bodySchema: createMCPClientVersionBodySchema,\n responseSchema: createMCPClientVersionResponseSchema,\n summary: 'Create MCP client version',\n description: 'Creates a new version snapshot of the current MCP client configuration',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, changeMessage, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n let currentConfig: Record<string, unknown> = {};\n if (mcpClient.activeVersionId) {\n const activeVersion = await mcpClientStore.getVersion(mcpClient.activeVersionId);\n if (activeVersion) {\n currentConfig = extractConfigFromVersion(\n activeVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n }\n }\n\n const latestVersion = await mcpClientStore.getLatestVersion(mcpClientId);\n\n // If no activeVersionId, fall back to latest version config\n if (!mcpClient.activeVersionId && latestVersion) {\n currentConfig = extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n }\n const previousConfig = latestVersion\n ? extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n )\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, currentConfig);\n\n const { versionId } = await createVersionWithRetry(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n currentConfig,\n changedFields,\n { changeMessage },\n );\n\n const version = await mcpClientStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n mcpClient.activeVersionId,\n );\n\n return version;\n } catch (error) {\n return handleError(error, 'Error creating MCP client version');\n }\n },\n});\n\n/**\n * GET /stored/mcp-clients/:mcpClientId/versions/:versionId - Get a specific version\n */\nexport const GET_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: getMCPClientVersionResponseSchema,\n summary: 'Get MCP client version',\n description: 'Returns a specific version of an MCP client by its version ID',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const version = await mcpClientStore.getVersion(versionId);\n\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n\n if (version.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n return version;\n } catch (error) {\n return handleError(error, 'Error getting MCP client version');\n }\n },\n});\n\n/**\n * POST /stored/mcp-clients/:mcpClientId/versions/:versionId/activate - Set a version as active\n */\nexport const ACTIVATE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId/activate',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: activateMCPClientVersionResponseSchema,\n summary: 'Activate MCP client version',\n description: 'Sets a specific version as the active version for the MCP client',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const version = await mcpClientStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n\n await mcpClientStore.update({\n id: mcpClientId,\n activeVersionId: versionId,\n status: 'published',\n });\n\n // Clear the editor cache so subsequent requests see the new active version\n mastra.getEditor()?.mcp.clearCache(mcpClientId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} is now active`,\n activeVersionId: versionId,\n };\n } catch (error) {\n return handleError(error, 'Error activating MCP client version');\n }\n },\n});\n\n/**\n * POST /stored/mcp-clients/:mcpClientId/versions/:versionId/restore - Restore MCP client to a version\n */\nexport const RESTORE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId/restore',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: restoreMCPClientVersionResponseSchema,\n summary: 'Restore MCP client version',\n description: 'Restores the MCP client configuration from a version, creating a new version',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const versionToRestore = await mcpClientStore.getVersion(versionId);\n if (!versionToRestore) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (versionToRestore.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n\n const restoredConfig = extractConfigFromVersion(\n versionToRestore as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n\n await mcpClientStore.update({\n id: mcpClientId,\n ...restoredConfig,\n });\n\n const latestVersion = await mcpClientStore.getLatestVersion(mcpClientId);\n const previousConfig = latestVersion\n ? extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n )\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, restoredConfig);\n\n const { versionId: newVersionId } = await createVersionWithRetry(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n restoredConfig,\n changedFields,\n {\n changeMessage: `Restored from version ${versionToRestore.versionNumber}`,\n },\n );\n\n const newVersion = await mcpClientStore.getVersion(newVersionId);\n if (!newVersion) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n mcpClient.activeVersionId,\n );\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.mcp.clearCache(mcpClientId);\n\n return newVersion;\n } catch (error) {\n return handleError(error, 'Error restoring MCP client version');\n }\n },\n});\n\n/**\n * DELETE /stored/mcp-clients/:mcpClientId/versions/:versionId - Delete a version\n */\nexport const DELETE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: deleteMCPClientVersionResponseSchema,\n summary: 'Delete MCP client version',\n description: 'Deletes a specific version (cannot delete the active version)',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const version = await mcpClientStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n\n if (mcpClient.activeVersionId === versionId) {\n throw new HTTPException(400, {\n message: 'Cannot delete the active version. Activate a different version first.',\n });\n }\n\n await mcpClientStore.deleteVersion(versionId);\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.mcp.clearCache(mcpClientId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting MCP client version');\n }\n },\n});\n\n/**\n * GET /stored/mcp-clients/:mcpClientId/versions/compare - Compare two versions\n */\nexport const COMPARE_MCP_CLIENT_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/mcp-clients/:mcpClientId/versions/compare',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionPathParams,\n queryParamSchema: compareMCPClientVersionsQuerySchema,\n responseSchema: compareMCPClientVersionsResponseSchema,\n summary: 'Compare MCP client versions',\n description: 'Compares two versions and returns the differences between them',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, from, to, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const fromVersion = await mcpClientStore.getVersion(from);\n if (!fromVersion) {\n throw new HTTPException(404, { message: `Version with id ${from} not found` });\n }\n if (fromVersion.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${from} not found for MCP client ${mcpClientId}`,\n });\n }\n\n const toVersion = await mcpClientStore.getVersion(to);\n if (!toVersion) {\n throw new HTTPException(404, { message: `Version with id ${to} not found` });\n }\n if (toVersion.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${to} not found for MCP client ${mcpClientId}`,\n });\n }\n\n const fromConfig = extractConfigFromVersion(\n fromVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n const toConfig = extractConfigFromVersion(\n toVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n\n const diffs = computeVersionDiffs(fromConfig, toConfig);\n\n return {\n diffs,\n fromVersion,\n toVersion,\n };\n } catch (error) {\n return handleError(error, 'Error comparing MCP client versions');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;AAgCA,MAAa,iCAAiCA,sBAAAA,YAAY;CACxD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,cAAc;CACd,iBAAiBC,4BAAAA;CACjB,kBAAkBC,4BAAAA;CAClB,gBAAgBC,4BAAAA;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,qBAAqB;CAC5B,SAAS,OAAO,EAAE,QAAQ,aAAa,MAAM,SAAS,SAAS,qBAAqB;EAClF,IAAI;GACF,MAAM,UAAU,OAAO,WAAW;GAElC,IAAI,CAAC,SACH,MAAM,IAAIC,uBAAAA,cAAc,KAAK,EAAE,SAAS,4BAA4B,CAAC;GAGvE,MAAM,iBAAiB,MAAM,QAAQ,SAAS,YAAY;GAC1D,IAAI,CAAC,gBACH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SA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YAAY;GAC1D,IAAI,CAAC,gBACH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SAAS,8CAA8C,CAAC;GAGzF,cAAA,0BAA0B,MADF,eAAe,QAAQ,WAAW,GACrB,MAAMC,cAAAA,uBAAuB,QAAQ,cAAc,CAAC;GAEzF,MAAM,cAAc,MAAM,eAAe,WAAW,IAAI;GACxD,IAAI,CAAC,aACH,MAAM,IAAID,uBAAAA,cAAc,KAAK,EAAE,SAAS,mBAAmB,KAAK,YAAY,CAAC;GAE/E,IAAI,YAAY,gBAAgB,aAC9B,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAC3B,SAAS,mBAAmB,KAAK,4BAA4B,cAC/D,CAAC;GAGH,MAAM,YAAY,MAAM,eAAe,WAAW,EAAE;GACpD,IAAI,CAAC,WACH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SAAS,mBAAmB,GAAG,YAAY,CAAC;GAE7E,IAAI,UAAU,gBAAgB,aAC5B,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAC3B,SAAS,mBAAmB,GAAG,4BAA4B,cAC7D,CAAC;GAcH,OAAO;IACL,OAHYiB,wCAAAA,oBATKZ,wCAAAA,yBACjB,aACAC,wCAAAA,iCAOyC,GAL1BD,wCAAAA,yBACf,WACAC,wCAAAA,iCAGmD,CAG/C;IACJ;IACA;GACF;EACF,SAAS,OAAO;GACd,OAAOJ,8BAAAA,YAAY,OAAO,qCAAqC;EACjE;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"mcp-client-versions.cjs","names":["createRoute","mcpClientVersionPathParams","listMCPClientVersionsQuerySchema","listMCPClientVersionsResponseSchema","HTTPException","getStoredResourceScope","handleError","createMCPClientVersionBodySchema","createMCPClientVersionResponseSchema","extractConfigFromVersion","MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS","calculateChangedFields","createVersionWithRetry","enforceRetentionLimit","mcpClientVersionIdPathParams","getMCPClientVersionResponseSchema","activateMCPClientVersionResponseSchema","restoreMCPClientVersionResponseSchema","deleteMCPClientVersionResponseSchema","compareMCPClientVersionsQuerySchema","compareMCPClientVersionsResponseSchema","computeVersionDiffs"],"sources":["../../../src/server/handlers/mcp-client-versions.ts"],"sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n mcpClientVersionPathParams,\n mcpClientVersionIdPathParams,\n listMCPClientVersionsQuerySchema,\n createMCPClientVersionBodySchema,\n compareMCPClientVersionsQuerySchema,\n listMCPClientVersionsResponseSchema,\n getMCPClientVersionResponseSchema,\n createMCPClientVersionResponseSchema,\n activateMCPClientVersionResponseSchema,\n restoreMCPClientVersionResponseSchema,\n deleteMCPClientVersionResponseSchema,\n compareMCPClientVersionsResponseSchema,\n} from '../schemas/mcp-client-versions';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { assertStoredResourceScope, getStoredResourceScope } from '../utils';\n\nimport { handleError } from './error';\nimport {\n extractConfigFromVersion,\n calculateChangedFields,\n computeVersionDiffs,\n createVersionWithRetry,\n enforceRetentionLimit,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n} from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\n/**\n * GET /stored/mcp-clients/:mcpClientId/versions - List all versions for an MCP client\n */\nexport const LIST_MCP_CLIENT_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/mcp-clients/:mcpClientId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionPathParams,\n queryParamSchema: listMCPClientVersionsQuerySchema,\n responseSchema: listMCPClientVersionsResponseSchema,\n summary: 'List MCP client versions',\n description: 'Returns a paginated list of all versions for a stored MCP client',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, page, perPage, orderBy, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const result = await mcpClientStore.listVersions({\n mcpClientId,\n page,\n perPage,\n orderBy,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing MCP client versions');\n }\n },\n});\n\n/**\n * POST /stored/mcp-clients/:mcpClientId/versions - Create a new version snapshot\n */\nexport const CREATE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/mcp-clients/:mcpClientId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionPathParams,\n bodySchema: createMCPClientVersionBodySchema,\n responseSchema: createMCPClientVersionResponseSchema,\n summary: 'Create MCP client version',\n description: 'Creates a new version snapshot of the current MCP client configuration',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, changeMessage, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n let currentConfig: Record<string, unknown> = {};\n if (mcpClient.activeVersionId) {\n const activeVersion = await mcpClientStore.getVersion(mcpClient.activeVersionId);\n if (activeVersion) {\n currentConfig = extractConfigFromVersion(\n activeVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n }\n }\n\n const latestVersion = await mcpClientStore.getLatestVersion(mcpClientId);\n\n // If no activeVersionId, fall back to latest version config\n if (!mcpClient.activeVersionId && latestVersion) {\n currentConfig = extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n }\n const previousConfig = latestVersion\n ? extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n )\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, currentConfig);\n\n const { versionId } = await createVersionWithRetry(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n currentConfig,\n changedFields,\n { changeMessage },\n );\n\n const version = await mcpClientStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n mcpClient.activeVersionId,\n );\n\n return version;\n } catch (error) {\n return handleError(error, 'Error creating MCP client version');\n }\n },\n});\n\n/**\n * GET /stored/mcp-clients/:mcpClientId/versions/:versionId - Get a specific version\n */\nexport const GET_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: getMCPClientVersionResponseSchema,\n summary: 'Get MCP client version',\n description: 'Returns a specific version of an MCP client by its version ID',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const version = await mcpClientStore.getVersion(versionId);\n\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n\n if (version.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n return version;\n } catch (error) {\n return handleError(error, 'Error getting MCP client version');\n }\n },\n});\n\n/**\n * POST /stored/mcp-clients/:mcpClientId/versions/:versionId/activate - Set a version as active\n */\nexport const ACTIVATE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId/activate',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: activateMCPClientVersionResponseSchema,\n summary: 'Activate MCP client version',\n description: 'Sets a specific version as the active version for the MCP client',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const version = await mcpClientStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n\n await mcpClientStore.update({\n id: mcpClientId,\n activeVersionId: versionId,\n status: 'published',\n });\n\n // Clear the editor cache so subsequent requests see the new active version\n mastra.getEditor()?.mcp.clearCache(mcpClientId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} is now active`,\n activeVersionId: versionId,\n };\n } catch (error) {\n return handleError(error, 'Error activating MCP client version');\n }\n },\n});\n\n/**\n * POST /stored/mcp-clients/:mcpClientId/versions/:versionId/restore - Restore MCP client to a version\n */\nexport const RESTORE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId/restore',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: restoreMCPClientVersionResponseSchema,\n summary: 'Restore MCP client version',\n description: 'Restores the MCP client configuration from a version, creating a new version',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const versionToRestore = await mcpClientStore.getVersion(versionId);\n if (!versionToRestore) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (versionToRestore.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n\n const restoredConfig = extractConfigFromVersion(\n versionToRestore as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n\n await mcpClientStore.update({\n id: mcpClientId,\n ...restoredConfig,\n });\n\n const latestVersion = await mcpClientStore.getLatestVersion(mcpClientId);\n const previousConfig = latestVersion\n ? extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n )\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, restoredConfig);\n\n const { versionId: newVersionId } = await createVersionWithRetry(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n restoredConfig,\n changedFields,\n {\n changeMessage: `Restored from version ${versionToRestore.versionNumber}`,\n },\n );\n\n const newVersion = await mcpClientStore.getVersion(newVersionId);\n if (!newVersion) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n mcpClientStore as unknown as VersionedStoreInterface,\n mcpClientId,\n 'mcpClientId',\n mcpClient.activeVersionId,\n );\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.mcp.clearCache(mcpClientId);\n\n return newVersion;\n } catch (error) {\n return handleError(error, 'Error restoring MCP client version');\n }\n },\n});\n\n/**\n * DELETE /stored/mcp-clients/:mcpClientId/versions/:versionId - Delete a version\n */\nexport const DELETE_MCP_CLIENT_VERSION_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/mcp-clients/:mcpClientId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionIdPathParams,\n responseSchema: deleteMCPClientVersionResponseSchema,\n summary: 'Delete MCP client version',\n description: 'Deletes a specific version (cannot delete the active version)',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, versionId, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n if (!mcpClient) {\n throw new HTTPException(404, { message: `MCP client with id ${mcpClientId} not found` });\n }\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const version = await mcpClientStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for MCP client ${mcpClientId}`,\n });\n }\n\n if (mcpClient.activeVersionId === versionId) {\n throw new HTTPException(400, {\n message: 'Cannot delete the active version. Activate a different version first.',\n });\n }\n\n await mcpClientStore.deleteVersion(versionId);\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.mcp.clearCache(mcpClientId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting MCP client version');\n }\n },\n});\n\n/**\n * GET /stored/mcp-clients/:mcpClientId/versions/compare - Compare two versions\n */\nexport const COMPARE_MCP_CLIENT_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/mcp-clients/:mcpClientId/versions/compare',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: mcpClientVersionPathParams,\n queryParamSchema: compareMCPClientVersionsQuerySchema,\n responseSchema: compareMCPClientVersionsResponseSchema,\n summary: 'Compare MCP client versions',\n description: 'Compares two versions and returns the differences between them',\n tags: ['MCP Client Versions'],\n handler: async ({ mastra, mcpClientId, from, to, requestContext }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const mcpClientStore = await storage.getStore('mcpClients');\n if (!mcpClientStore) {\n throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n }\n const mcpClient = await mcpClientStore.getById(mcpClientId);\n assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n const fromVersion = await mcpClientStore.getVersion(from);\n if (!fromVersion) {\n throw new HTTPException(404, { message: `Version with id ${from} not found` });\n }\n if (fromVersion.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${from} not found for MCP client ${mcpClientId}`,\n });\n }\n\n const toVersion = await mcpClientStore.getVersion(to);\n if (!toVersion) {\n throw new HTTPException(404, { message: `Version with id ${to} not found` });\n }\n if (toVersion.mcpClientId !== mcpClientId) {\n throw new HTTPException(404, {\n message: `Version with id ${to} not found for MCP client ${mcpClientId}`,\n });\n }\n\n const fromConfig = extractConfigFromVersion(\n fromVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n const toConfig = extractConfigFromVersion(\n toVersion as unknown as Record<string, unknown>,\n MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n );\n\n const diffs = computeVersionDiffs(fromConfig, toConfig);\n\n return {\n diffs,\n fromVersion,\n toVersion,\n };\n } catch (error) {\n return handleError(error, 'Error comparing MCP client versions');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;AAgCA,MAAa,iCAAiCA,sBAAAA,YAAY;CACxD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,cAAc;CACd,iBAAiBC,4BAAAA;CACjB,kBAAkBC,4BAAAA;CAClB,gBAAgBC,4BAAAA;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,qBAAqB;CAC5B,SAAS,OAAO,EAAE,QAAQ,aAAa,MAAM,SAAS,SAAS,qBAAqB;EAClF,IAAI;GACF,MAAM,UAAU,OAAO,WAAW;GAElC,IAAI,CAAC,SACH,MAAM,IAAIC,uBAAAA,cAAc,KAAK,EAAE,SAAS,4BAA4B,CAAC;GAGvE,MAAM,iBAAiB,MAAM,QAAQ,SAAS,YAAY;GAC1D,IAAI,CAAC,gBACH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SAAS,8CAA8C,CAAC;GAGzF,MAAM,YAAY,MAAM,eAAe,QAAQ,WAAW;GAC1D,IAAI,CAAC,WACH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SAAS,sBAAsB,YAAY,YAAY,CAAC;GAEzF,cAAA,0BAA0B,WAAW,MAAMC,cAAAA,uBAAuB,QAAQ,cAAc,CAAC;GASzF,OAAO,MAPc,eAAe,aAAa;IAC/C;IACA;IACA;IACA;GACF,CAAC;EAGH,SAAS,OAAO;GACd,OAAOC,8BAAAA,YAAY,OA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AY,gBAAgB,aAC9B,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAC3B,SAAS,mBAAmB,KAAK,4BAA4B,cAC/D,CAAC;GAGH,MAAM,YAAY,MAAM,eAAe,WAAW,EAAE;GACpD,IAAI,CAAC,WACH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SAAS,mBAAmB,GAAG,YAAY,CAAC;GAE7E,IAAI,UAAU,gBAAgB,aAC5B,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAC3B,SAAS,mBAAmB,GAAG,4BAA4B,cAC7D,CAAC;GAcH,OAAO;IACL,OAHYiB,wCAAAA,oBATKZ,wCAAAA,yBACjB,aACAC,wCAAAA,iCAOyC,GAL1BD,wCAAAA,yBACf,WACAC,wCAAAA,iCAGmD,CAG/C;IACJ;IACA;GACF;EACF,SAAS,OAAO;GACd,OAAOJ,8BAAAA,YAAY,OAAO,qCAAqC;EACjE;CACF;AACF,CAAC"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
2
+ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
3
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
4
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
5
5
  const require_mcp = require("../../mcp-Buvksst5.cjs");
6
6
  //#region src/server/handlers/mcp.ts
7
7
  var mcp_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../../rolldown-runtime-DuvcJU0W.js";
1
+ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
2
2
  import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
3
3
  import { n as createRoute } from "../../route-builder-YQ_gLIvW.js";
4
4
  import { a as listMcpServerToolsResponseSchema, c as listResourcesResponseSchema, d as mcpServerResourcePathParams, f as mcpServerToolPathParams, g as serverDetailSchema, h as readResourceResponseSchema, l as mcpServerDetailPathParams, m as readResourceBodySchema, n as executeToolResponseSchema, o as listMcpServersQuerySchema, p as mcpToolInfoSchema, r as getMcpServerDetailQuerySchema, s as listMcpServersResponseSchema, t as executeToolBodySchema, u as mcpServerIdPathParams } from "../../mcp-oOFVSK8L.js";
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
2
+ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
3
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
4
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
5
5
  const require_server_handlers_error = require("./error.cjs");
6
- const require_utils = require("../../utils-CXbhpYYv.cjs");
6
+ const require_utils = require("../../utils-Xnn91QBW.cjs");
7
7
  const require_memory = require("../../memory-D0prxytx.cjs");
8
8
  const require_server_handlers_gateway_memory_client = require("./gateway-memory-client.cjs");
9
9
  let _mastra_core_agent = require("@mastra/core/agent");
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../../rolldown-runtime-DuvcJU0W.js";
1
+ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
2
2
  import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
3
3
  import { n as createRoute } from "../../route-builder-YQ_gLIvW.js";
4
4
  import { handleError } from "./error.js";
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../rolldown-runtime-Bd6kNlEP.cjs");
2
3
  let zod_v4 = require("zod/v4");
3
4
  //#region src/server/handlers/observability-list-query-schemas.ts
4
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"observability-list-query-schemas.cjs","names":["z"],"sources":["../../../src/server/handlers/observability-list-query-schemas.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n/**\n * Server-local route-layer query schemas for observability list endpoints.\n *\n * Why these live in @mastra/server instead of importing the newer shared core\n * exports directly:\n * - `mode`, `after`, and `limit` were added after older @mastra/core versions\n * that @mastra/server still needs to tolerate at runtime.\n * - Direct named imports of newly-added schema exports create module-link-time\n * failures when a newer server is paired with an older core.\n * - These are route parsing concerns, so mirroring the current core schema\n * semantics here keeps the server backward-compatible without forcing a peer\n * dependency lockstep upgrade.\n *\n * TODO(Mastra 2.0): remove this shim and import the shared observability list\n * query schemas directly once server/core no longer need to tolerate older\n * mixed-version pairings.\n */\n\nexport const paginationArgsSchema = z\n .object({\n page: z.coerce.number().int().min(0).optional().default(0).describe('Zero-indexed page number'),\n perPage: z.coerce.number().int().min(1).max(100).optional().default(10).describe('Number of items per page'),\n })\n .describe('Pagination options for list queries');\n\nexport const deltaCursorSchema = z.string().min(1).describe('Opaque cursor value for incremental polling');\n\nexport const listModeSchema = z\n .enum(['page', 'delta'])\n .describe(\"List mode: 'page' | 'delta', defaults to 'page' when omitted.\");\n\nexport const deltaLimitSchema = z.coerce\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of updates to return in one delta poll');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,uBAAuBA,OAAAA,EACjC,OAAO;CACN,MAAMA,OAAAA,EAAE,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,0BAA0B;CAC9F,SAASA,OAAAA,EAAE,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,0BAA0B;AAC7G,CAAC,CAAC,CACD,SAAS,qCAAqC;AAEjD,MAAa,oBAAoBA,OAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,6CAA6C;AAEzG,MAAa,iBAAiBA,OAAAA,EAC3B,KAAK,CAAC,QAAQ,OAAO,CAAC,CAAC,CACvB,SAAS,+DAA+D;AAE3E,MAAa,mBAAmBA,OAAAA,EAAE,OAC/B,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,uDAAuD"}
1
+ {"version":3,"file":"observability-list-query-schemas.cjs","names":["z"],"sources":["../../../src/server/handlers/observability-list-query-schemas.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n/**\n * Server-local route-layer query schemas for observability list endpoints.\n *\n * Why these live in @mastra/server instead of importing the newer shared core\n * exports directly:\n * - `mode`, `after`, and `limit` were added after older @mastra/core versions\n * that @mastra/server still needs to tolerate at runtime.\n * - Direct named imports of newly-added schema exports create module-link-time\n * failures when a newer server is paired with an older core.\n * - These are route parsing concerns, so mirroring the current core schema\n * semantics here keeps the server backward-compatible without forcing a peer\n * dependency lockstep upgrade.\n *\n * TODO(Mastra 2.0): remove this shim and import the shared observability list\n * query schemas directly once server/core no longer need to tolerate older\n * mixed-version pairings.\n */\n\nexport const paginationArgsSchema = z\n .object({\n page: z.coerce.number().int().min(0).optional().default(0).describe('Zero-indexed page number'),\n perPage: z.coerce.number().int().min(1).max(100).optional().default(10).describe('Number of items per page'),\n })\n .describe('Pagination options for list queries');\n\nexport const deltaCursorSchema = z.string().min(1).describe('Opaque cursor value for incremental polling');\n\nexport const listModeSchema = z\n .enum(['page', 'delta'])\n .describe(\"List mode: 'page' | 'delta', defaults to 'page' when omitted.\");\n\nexport const deltaLimitSchema = z.coerce\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe('Maximum number of updates to return in one delta poll');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,uBAAuBA,OAAAA,EACjC,OAAO;CACN,MAAMA,OAAAA,EAAE,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,0BAA0B;CAC9F,SAASA,OAAAA,EAAE,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,0BAA0B;AAC7G,CAAC,CAAC,CACD,SAAS,qCAAqC;AAEjD,MAAa,oBAAoBA,OAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,6CAA6C;AAEzG,MAAa,iBAAiBA,OAAAA,EAC3B,KAAK,CAAC,QAAQ,OAAO,CAAC,CAAC,CACvB,SAAS,+DAA+D;AAE3E,MAAa,mBAAmBA,OAAAA,EAAE,OAC/B,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,uDAAuD"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_observability_new_endpoints = require("../../observability-new-endpoints-BC-dasRY.cjs");
2
+ require("../../rolldown-runtime-Bd6kNlEP.cjs");
3
+ const require_observability_new_endpoints = require("../../observability-new-endpoints-gRCFhnRr.cjs");
3
4
  exports.CREATE_FEEDBACK = require_observability_new_endpoints.CREATE_FEEDBACK;
4
5
  exports.CREATE_SCORE = require_observability_new_endpoints.CREATE_SCORE;
5
6
  exports.GET_ENTITY_NAMES = require_observability_new_endpoints.GET_ENTITY_NAMES;
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../rolldown-runtime-Bd6kNlEP.cjs");
2
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
3
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
4
5
  const require_server_handlers_observability_list_query_schemas = require("./observability-list-query-schemas.cjs");
5
6
  let zod_v4 = require("zod/v4");
6
7
  let _mastra_core_features = require("@mastra/core/features");
@@ -1 +1 @@
1
- {"version":3,"file":"observability-shared.cjs","names":["candidate","HTTPException","coreFeatures","z","paginationArgsSchema","wrapSchemaForQueryParams","listModeSchema","deltaCursorSchema","deltaLimitSchema"],"sources":["../../../src/server/handlers/observability-shared.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport { coreFeatures } from '@mastra/core/features';\nimport type { MastraCompositeStore, ObservabilityStorage, ScoresStorage } from '@mastra/core/storage';\nimport { z } from 'zod/v4';\nimport { HTTPException } from '../http-exception';\nimport type { ServerRoute } from '../server-adapter/routes';\nimport { wrapSchemaForQueryParams } from '../server-adapter/routes/route-builder';\nimport {\n deltaCursorSchema,\n deltaLimitSchema,\n listModeSchema,\n paginationArgsSchema,\n} from './observability-list-query-schemas';\n\nexport const OBSERVABILITY_DELTA_POLLING_FEATURE = 'observability-delta-polling';\nexport const OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE =\n 'Delta polling requires a newer @mastra/core with observability delta polling support. Please upgrade.';\n\nexport const OBSERVABILITY_LIST_ENDPOINTS = {\n traces: 'traces',\n branches: 'branches',\n logs: 'logs',\n metrics: 'metrics',\n scores: 'scores',\n feedback: 'feedback',\n} as const;\n\nexport type ObservabilityListEndpoint =\n (typeof OBSERVABILITY_LIST_ENDPOINTS)[keyof typeof OBSERVABILITY_LIST_ENDPOINTS];\nconst OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE = 'delta-polling';\n\nfunction getFeatures(observabilityStore: ObservabilityStorage): readonly string[] | undefined {\n const candidate = observabilityStore as ObservabilityStorage & {\n getFeatures?: () => readonly string[] | undefined;\n };\n return candidate.getFeatures?.();\n}\n\n/** Retrieves MastraCompositeStore or throws 500 if unavailable. */\nexport function getStorage(mastra: Mastra): MastraCompositeStore {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n return storage;\n}\n\n/** Retrieves the observability storage domain or throws 501 if unavailable. */\nexport async function getObservabilityStore(mastra: Mastra): Promise<ObservabilityStorage> {\n const storage = getStorage(mastra);\n const observability = await storage.getStore('observability');\n if (!observability) {\n // 501, not 500: a missing or explicitly disabled observability domain\n // (e.g. `domains: { observability: false }`) is a capability gap, not a\n // server failure — matching the other 501s in this file.\n throw new HTTPException(501, { message: 'Observability storage domain is not available' });\n }\n return observability;\n}\n\n/** Retrieves the scores storage domain or throws 501 if unavailable. */\nexport async function getScoresStore(mastra: Mastra): Promise<ScoresStorage> {\n const storage = getStorage(mastra);\n const scores = await storage.getStore('scores');\n if (!scores) {\n throw new HTTPException(501, { message: 'Scores storage domain is not available' });\n }\n return scores;\n}\n\nexport function assertObservabilityDeltaSupported(\n observabilityStore: ObservabilityStorage,\n endpoint: ObservabilityListEndpoint,\n) {\n if (!coreFeatures.has(OBSERVABILITY_DELTA_POLLING_FEATURE)) {\n throw new HTTPException(501, {\n message: `${OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE} (endpoint: ${endpoint})`,\n });\n }\n\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE)) {\n return;\n }\n\n throw new HTTPException(501, {\n message: `Delta polling is not supported by the configured observability store for ${endpoint}`,\n });\n}\n\nexport interface RouteDetails {\n method: ServerRoute['method'];\n path: `/${string}`;\n summary: string;\n description: string;\n requiresPermission?: ServerRoute['requiresPermission'];\n}\n\nexport const NEW_ROUTE_DEFS = {\n LIST_METRICS: {\n method: 'GET',\n path: '/observability/metrics',\n summary: 'List metrics',\n description: 'Returns a paginated list of metrics with optional filtering and sorting',\n },\n\n LIST_LOGS: {\n method: 'GET',\n path: '/observability/logs',\n summary: 'List logs',\n description: 'Returns a paginated list of logs with optional filtering and sorting',\n },\n\n LIST_SCORES: {\n method: 'GET',\n path: '/observability/scores',\n summary: 'List scores',\n description: 'Returns a paginated list of scores with optional filtering and sorting',\n },\n\n CREATE_SCORE: {\n method: 'POST',\n path: '/observability/scores',\n summary: 'Create a score',\n description: 'Creates a single score record in the observability store',\n },\n\n GET_SCORE: {\n method: 'GET',\n path: '/observability/scores/:scoreId',\n summary: 'Get score',\n description: 'Returns a single score by scoreId',\n },\n\n GET_SCORE_AGGREGATE: {\n method: 'POST',\n path: '/observability/scores/aggregate',\n summary: 'Get score aggregate',\n description: 'Returns an aggregated score value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_BREAKDOWN: {\n method: 'POST',\n path: '/observability/scores/breakdown',\n summary: 'Get score breakdown',\n description: 'Returns score values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_TIME_SERIES: {\n method: 'POST',\n path: '/observability/scores/timeseries',\n summary: 'Get score time series',\n description: 'Returns score values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_PERCENTILES: {\n method: 'POST',\n path: '/observability/scores/percentiles',\n summary: 'Get score percentiles',\n description: 'Returns percentile values for a score bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n LIST_FEEDBACK: {\n method: 'GET',\n path: '/observability/feedback',\n summary: 'List feedback',\n description: 'Returns a paginated list of feedback with optional filtering and sorting',\n },\n\n CREATE_FEEDBACK: {\n method: 'POST',\n path: '/observability/feedback',\n summary: 'Create feedback',\n description: 'Creates a single feedback record in the observability store',\n },\n\n GET_FEEDBACK_AGGREGATE: {\n method: 'POST',\n path: '/observability/feedback/aggregate',\n summary: 'Get feedback aggregate',\n description: 'Returns an aggregated numeric feedback value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_BREAKDOWN: {\n method: 'POST',\n path: '/observability/feedback/breakdown',\n summary: 'Get feedback breakdown',\n description: 'Returns numeric feedback values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_TIME_SERIES: {\n method: 'POST',\n path: '/observability/feedback/timeseries',\n summary: 'Get feedback time series',\n description: 'Returns numeric feedback values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_PERCENTILES: {\n method: 'POST',\n path: '/observability/feedback/percentiles',\n summary: 'Get feedback percentiles',\n description: 'Returns percentile values for numeric feedback bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_AGGREGATE: {\n method: 'POST',\n path: '/observability/metrics/aggregate',\n summary: 'Get metric aggregate',\n description: 'Returns an aggregated metric value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_BREAKDOWN: {\n method: 'POST',\n path: '/observability/metrics/breakdown',\n summary: 'Get metric breakdown',\n description: 'Returns metric values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_TIME_SERIES: {\n method: 'POST',\n path: '/observability/metrics/timeseries',\n summary: 'Get metric time series',\n description: 'Returns metric values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_PERCENTILES: {\n method: 'POST',\n path: '/observability/metrics/percentiles',\n summary: 'Get metric percentiles',\n description: 'Returns percentile values for a metric bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_NAMES: {\n method: 'GET',\n path: '/observability/discovery/metric-names',\n summary: 'Get metric names',\n description: 'Returns distinct metric names with optional prefix filtering',\n },\n\n GET_METRIC_LABEL_KEYS: {\n method: 'GET',\n path: '/observability/discovery/metric-label-keys',\n summary: 'Get metric label keys',\n description: 'Returns distinct label keys for a given metric',\n },\n\n GET_METRIC_LABEL_VALUES: {\n method: 'GET',\n path: '/observability/discovery/metric-label-values',\n summary: 'Get label values',\n description: 'Returns distinct values for a given metric label key',\n },\n\n GET_ENTITY_TYPES: {\n method: 'GET',\n path: '/observability/discovery/entity-types',\n summary: 'Get entity types',\n description: 'Returns distinct entity types from observability data',\n },\n\n GET_ENTITY_NAMES: {\n method: 'GET',\n path: '/observability/discovery/entity-names',\n summary: 'Get entity names',\n description: 'Returns distinct entity names with optional type filtering',\n },\n\n GET_SERVICE_NAMES: {\n method: 'GET',\n path: '/observability/discovery/service-names',\n summary: 'Get service names',\n description: 'Returns distinct service names from observability data',\n },\n\n GET_ENVIRONMENTS: {\n method: 'GET',\n path: '/observability/discovery/environments',\n summary: 'Get environments',\n description: 'Returns distinct environments from observability data',\n },\n\n GET_TAGS: {\n method: 'GET',\n path: '/observability/discovery/tags',\n summary: 'Get tags',\n description: 'Returns distinct tags with optional entity type filtering',\n },\n} as const satisfies Record<string, RouteDetails>;\n\nexport type NewRoutesKey = keyof typeof NEW_ROUTE_DEFS;\nexport type NewRoutesDefinitions = (typeof NEW_ROUTE_DEFS)[NewRoutesKey];\n\nexport function createObservabilityListQuerySchema<\n TFilter extends z.ZodObject<z.ZodRawShape>,\n TOrderBy extends z.ZodObject<z.ZodRawShape>,\n>(filterSchema: TFilter, orderBySchema: TOrderBy) {\n const unwrapDefault = (schema: unknown) => {\n const zodSchema = schema as z.ZodTypeAny;\n return zodSchema instanceof z.ZodDefault ? zodSchema.unwrap() : zodSchema;\n };\n const paginationShape = paginationArgsSchema.shape as unknown as Record<string, z.ZodTypeAny>;\n const orderByShape = orderBySchema.shape as unknown as Record<string, z.ZodTypeAny>;\n\n const pageSchema = unwrapDefault(paginationShape.page);\n const perPageSchema = unwrapDefault(paginationShape.perPage);\n const fieldSchema = orderByShape.field ? unwrapDefault(orderByShape.field) : z.never().optional();\n const directionSchema = orderByShape.direction ? unwrapDefault(orderByShape.direction) : z.never().optional();\n\n return wrapSchemaForQueryParams(\n z\n .object({\n ...filterSchema.shape,\n page: pageSchema,\n perPage: perPageSchema,\n field: fieldSchema,\n direction: directionSchema,\n mode: listModeSchema.optional(),\n after: deltaCursorSchema.optional(),\n limit: deltaLimitSchema,\n })\n .partial(),\n ).superRefine((value, ctx) => {\n const isDelta = value.mode === 'delta';\n const hasPagination = value.page !== undefined || value.perPage !== undefined;\n const hasOrderBy = value.field !== undefined || value.direction !== undefined;\n const hasAfter = value.after !== undefined;\n const hasLimit = value.limit !== undefined;\n\n if (isDelta) {\n if (hasPagination) {\n if (value.page !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['page'],\n message: '`page` is not allowed when `mode=delta`',\n });\n }\n if (value.perPage !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['perPage'],\n message: '`perPage` is not allowed when `mode=delta`',\n });\n }\n }\n if (hasOrderBy) {\n if (value.field !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['field'],\n message: '`field` is not allowed when `mode=delta`',\n });\n }\n if (value.direction !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['direction'],\n message: '`direction` is not allowed when `mode=delta`',\n });\n }\n }\n return;\n }\n\n if (hasAfter) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['after'],\n message: '`after` is only allowed when `mode=delta`',\n });\n }\n if (hasLimit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['limit'],\n message: '`limit` is only allowed when `mode=delta`',\n });\n }\n });\n}\n"],"mappings":";;;;;;;AAcA,MAAa,sCAAsC;AACnD,MAAa,8CACX;AAEF,MAAa,+BAA+B;CAC1C,QAAQ;CACR,UAAU;CACV,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;AACZ;AAIA,MAAM,8CAA8C;AAEpD,SAAS,YAAY,oBAAyE;CAI5F,OAAOA,mBAAU,cAAc;AACjC;;AAGA,SAAgB,WAAW,QAAsC;CAC/D,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,CAAC,SACH,MAAM,IAAIC,uBAAAA,cAAc,KAAK,EAAE,SAAS,2BAA2B,CAAC;CAEtE,OAAO;AACT;;AAGA,eAAsB,sBAAsB,QAA+C;CAEzF,MAAM,gBAAgB,M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IAEH,IAAI,MAAM,YAAY,KAAA,GACpB,IAAI,SAAS;KACX,MAAMA,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,SAAS;KAChB,SAAS;IACX,CAAC;GAEL;GACA,IAAI,YAAY;IACd,IAAI,MAAM,UAAU,KAAA,GAClB,IAAI,SAAS;KACX,MAAMA,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,OAAO;KACd,SAAS;IACX,CAAC;IAEH,IAAI,MAAM,cAAc,KAAA,GACtB,IAAI,SAAS;KACX,MAAMA,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,WAAW;KAClB,SAAS;IACX,CAAC;GAEL;GACA;EACF;EAEA,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;EAEH,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;CAEL,CAAC;AACH"}
1
+ {"version":3,"file":"observability-shared.cjs","names":["candidate","HTTPException","coreFeatures","z","paginationArgsSchema","wrapSchemaForQueryParams","listModeSchema","deltaCursorSchema","deltaLimitSchema"],"sources":["../../../src/server/handlers/observability-shared.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport { coreFeatures } from '@mastra/core/features';\nimport type { MastraCompositeStore, ObservabilityStorage, ScoresStorage } from '@mastra/core/storage';\nimport { z } from 'zod/v4';\nimport { HTTPException } from '../http-exception';\nimport type { ServerRoute } from '../server-adapter/routes';\nimport { wrapSchemaForQueryParams } from '../server-adapter/routes/route-builder';\nimport {\n deltaCursorSchema,\n deltaLimitSchema,\n listModeSchema,\n paginationArgsSchema,\n} from './observability-list-query-schemas';\n\nexport const OBSERVABILITY_DELTA_POLLING_FEATURE = 'observability-delta-polling';\nexport const OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE =\n 'Delta polling requires a newer @mastra/core with observability delta polling support. Please upgrade.';\n\nexport const OBSERVABILITY_LIST_ENDPOINTS = {\n traces: 'traces',\n branches: 'branches',\n logs: 'logs',\n metrics: 'metrics',\n scores: 'scores',\n feedback: 'feedback',\n} as const;\n\nexport type ObservabilityListEndpoint =\n (typeof OBSERVABILITY_LIST_ENDPOINTS)[keyof typeof OBSERVABILITY_LIST_ENDPOINTS];\nconst OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE = 'delta-polling';\n\nfunction getFeatures(observabilityStore: ObservabilityStorage): readonly string[] | undefined {\n const candidate = observabilityStore as ObservabilityStorage & {\n getFeatures?: () => readonly string[] | undefined;\n };\n return candidate.getFeatures?.();\n}\n\n/** Retrieves MastraCompositeStore or throws 500 if unavailable. */\nexport function getStorage(mastra: Mastra): MastraCompositeStore {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n return storage;\n}\n\n/** Retrieves the observability storage domain or throws 501 if unavailable. */\nexport async function getObservabilityStore(mastra: Mastra): Promise<ObservabilityStorage> {\n const storage = getStorage(mastra);\n const observability = await storage.getStore('observability');\n if (!observability) {\n // 501, not 500: a missing or explicitly disabled observability domain\n // (e.g. `domains: { observability: false }`) is a capability gap, not a\n // server failure — matching the other 501s in this file.\n throw new HTTPException(501, { message: 'Observability storage domain is not available' });\n }\n return observability;\n}\n\n/** Retrieves the scores storage domain or throws 501 if unavailable. */\nexport async function getScoresStore(mastra: Mastra): Promise<ScoresStorage> {\n const storage = getStorage(mastra);\n const scores = await storage.getStore('scores');\n if (!scores) {\n throw new HTTPException(501, { message: 'Scores storage domain is not available' });\n }\n return scores;\n}\n\nexport function assertObservabilityDeltaSupported(\n observabilityStore: ObservabilityStorage,\n endpoint: ObservabilityListEndpoint,\n) {\n if (!coreFeatures.has(OBSERVABILITY_DELTA_POLLING_FEATURE)) {\n throw new HTTPException(501, {\n message: `${OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE} (endpoint: ${endpoint})`,\n });\n }\n\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE)) {\n return;\n }\n\n throw new HTTPException(501, {\n message: `Delta polling is not supported by the configured observability store for ${endpoint}`,\n });\n}\n\nexport interface RouteDetails {\n method: ServerRoute['method'];\n path: `/${string}`;\n summary: string;\n description: string;\n requiresPermission?: ServerRoute['requiresPermission'];\n}\n\nexport const NEW_ROUTE_DEFS = {\n LIST_METRICS: {\n method: 'GET',\n path: '/observability/metrics',\n summary: 'List metrics',\n description: 'Returns a paginated list of metrics with optional filtering and sorting',\n },\n\n LIST_LOGS: {\n method: 'GET',\n path: '/observability/logs',\n summary: 'List logs',\n description: 'Returns a paginated list of logs with optional filtering and sorting',\n },\n\n LIST_SCORES: {\n method: 'GET',\n path: '/observability/scores',\n summary: 'List scores',\n description: 'Returns a paginated list of scores with optional filtering and sorting',\n },\n\n CREATE_SCORE: {\n method: 'POST',\n path: '/observability/scores',\n summary: 'Create a score',\n description: 'Creates a single score record in the observability store',\n },\n\n GET_SCORE: {\n method: 'GET',\n path: '/observability/scores/:scoreId',\n summary: 'Get score',\n description: 'Returns a single score by scoreId',\n },\n\n GET_SCORE_AGGREGATE: {\n method: 'POST',\n path: '/observability/scores/aggregate',\n summary: 'Get score aggregate',\n description: 'Returns an aggregated score value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_BREAKDOWN: {\n method: 'POST',\n path: '/observability/scores/breakdown',\n summary: 'Get score breakdown',\n description: 'Returns score values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_TIME_SERIES: {\n method: 'POST',\n path: '/observability/scores/timeseries',\n summary: 'Get score time series',\n description: 'Returns score values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_PERCENTILES: {\n method: 'POST',\n path: '/observability/scores/percentiles',\n summary: 'Get score percentiles',\n description: 'Returns percentile values for a score bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n LIST_FEEDBACK: {\n method: 'GET',\n path: '/observability/feedback',\n summary: 'List feedback',\n description: 'Returns a paginated list of feedback with optional filtering and sorting',\n },\n\n CREATE_FEEDBACK: {\n method: 'POST',\n path: '/observability/feedback',\n summary: 'Create feedback',\n description: 'Creates a single feedback record in the observability store',\n },\n\n GET_FEEDBACK_AGGREGATE: {\n method: 'POST',\n path: '/observability/feedback/aggregate',\n summary: 'Get feedback aggregate',\n description: 'Returns an aggregated numeric feedback value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_BREAKDOWN: {\n method: 'POST',\n path: '/observability/feedback/breakdown',\n summary: 'Get feedback breakdown',\n description: 'Returns numeric feedback values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_TIME_SERIES: {\n method: 'POST',\n path: '/observability/feedback/timeseries',\n summary: 'Get feedback time series',\n description: 'Returns numeric feedback values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_PERCENTILES: {\n method: 'POST',\n path: '/observability/feedback/percentiles',\n summary: 'Get feedback percentiles',\n description: 'Returns percentile values for numeric feedback bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_AGGREGATE: {\n method: 'POST',\n path: '/observability/metrics/aggregate',\n summary: 'Get metric aggregate',\n description: 'Returns an aggregated metric value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_BREAKDOWN: {\n method: 'POST',\n path: '/observability/metrics/breakdown',\n summary: 'Get metric breakdown',\n description: 'Returns metric values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_TIME_SERIES: {\n method: 'POST',\n path: '/observability/metrics/timeseries',\n summary: 'Get metric time series',\n description: 'Returns metric values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_PERCENTILES: {\n method: 'POST',\n path: '/observability/metrics/percentiles',\n summary: 'Get metric percentiles',\n description: 'Returns percentile values for a metric bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_NAMES: {\n method: 'GET',\n path: '/observability/discovery/metric-names',\n summary: 'Get metric names',\n description: 'Returns distinct metric names with optional prefix filtering',\n },\n\n GET_METRIC_LABEL_KEYS: {\n method: 'GET',\n path: '/observability/discovery/metric-label-keys',\n summary: 'Get metric label keys',\n description: 'Returns distinct label keys for a given metric',\n },\n\n GET_METRIC_LABEL_VALUES: {\n method: 'GET',\n path: '/observability/discovery/metric-label-values',\n summary: 'Get label values',\n description: 'Returns distinct values for a given metric label key',\n },\n\n GET_ENTITY_TYPES: {\n method: 'GET',\n path: '/observability/discovery/entity-types',\n summary: 'Get entity types',\n description: 'Returns distinct entity types from observability data',\n },\n\n GET_ENTITY_NAMES: {\n method: 'GET',\n path: '/observability/discovery/entity-names',\n summary: 'Get entity names',\n description: 'Returns distinct entity names with optional type filtering',\n },\n\n GET_SERVICE_NAMES: {\n method: 'GET',\n path: '/observability/discovery/service-names',\n summary: 'Get service names',\n description: 'Returns distinct service names from observability data',\n },\n\n GET_ENVIRONMENTS: {\n method: 'GET',\n path: '/observability/discovery/environments',\n summary: 'Get environments',\n description: 'Returns distinct environments from observability data',\n },\n\n GET_TAGS: {\n method: 'GET',\n path: '/observability/discovery/tags',\n summary: 'Get tags',\n description: 'Returns distinct tags with optional entity type filtering',\n },\n} as const satisfies Record<string, RouteDetails>;\n\nexport type NewRoutesKey = keyof typeof NEW_ROUTE_DEFS;\nexport type NewRoutesDefinitions = (typeof NEW_ROUTE_DEFS)[NewRoutesKey];\n\nexport function createObservabilityListQuerySchema<\n TFilter extends z.ZodObject<z.ZodRawShape>,\n TOrderBy extends z.ZodObject<z.ZodRawShape>,\n>(filterSchema: TFilter, orderBySchema: TOrderBy) {\n const unwrapDefault = (schema: unknown) => {\n const zodSchema = schema as z.ZodTypeAny;\n return zodSchema instanceof z.ZodDefault ? zodSchema.unwrap() : zodSchema;\n };\n const paginationShape = paginationArgsSchema.shape as unknown as Record<string, z.ZodTypeAny>;\n const orderByShape = orderBySchema.shape as unknown as Record<string, z.ZodTypeAny>;\n\n const pageSchema = unwrapDefault(paginationShape.page);\n const perPageSchema = unwrapDefault(paginationShape.perPage);\n const fieldSchema = orderByShape.field ? unwrapDefault(orderByShape.field) : z.never().optional();\n const directionSchema = orderByShape.direction ? unwrapDefault(orderByShape.direction) : z.never().optional();\n\n return wrapSchemaForQueryParams(\n z\n .object({\n ...filterSchema.shape,\n page: pageSchema,\n perPage: perPageSchema,\n field: fieldSchema,\n direction: directionSchema,\n mode: listModeSchema.optional(),\n after: deltaCursorSchema.optional(),\n limit: deltaLimitSchema,\n })\n .partial(),\n ).superRefine((value, ctx) => {\n const isDelta = value.mode === 'delta';\n const hasPagination = value.page !== undefined || value.perPage !== undefined;\n const hasOrderBy = value.field !== undefined || value.direction !== undefined;\n const hasAfter = value.after !== undefined;\n const hasLimit = value.limit !== undefined;\n\n if (isDelta) {\n if (hasPagination) {\n if (value.page !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['page'],\n message: '`page` is not allowed when `mode=delta`',\n });\n }\n if (value.perPage !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['perPage'],\n message: '`perPage` is not allowed when `mode=delta`',\n });\n }\n }\n if (hasOrderBy) {\n if (value.field !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['field'],\n message: '`field` is not allowed when `mode=delta`',\n });\n }\n if (value.direction !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['direction'],\n message: '`direction` is not allowed when `mode=delta`',\n });\n }\n }\n return;\n }\n\n if (hasAfter) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['after'],\n message: '`after` is only allowed when `mode=delta`',\n });\n }\n if (hasLimit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['limit'],\n message: '`limit` is only allowed when `mode=delta`',\n });\n }\n });\n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ACT,CAAC,CAAC,CACD,QAAQ,CACb,CAAC,CAAC,aAAa,OAAO,QAAQ;EAC5B,MAAM,UAAU,MAAM,SAAS;EAC/B,MAAM,gBAAgB,MAAM,SAAS,KAAA,KAAa,MAAM,YAAY,KAAA;EACpE,MAAM,aAAa,MAAM,UAAU,KAAA,KAAa,MAAM,cAAc,KAAA;EACpE,MAAM,WAAW,MAAM,UAAU,KAAA;EACjC,MAAM,WAAW,MAAM,UAAU,KAAA;EAEjC,IAAI,SAAS;GACX,IAAI,eAAe;IACjB,IAAI,MAAM,SAAS,KAAA,GACjB,IAAI,SAAS;KACX,MAAML,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,MAAM;KACb,SAAS;IACX,CAAC;IAEH,IAAI,MAAM,YAAY,KAAA,GACpB,IAAI,SAAS;KACX,MAAMA,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,SAAS;KAChB,SAAS;IACX,CAAC;GAEL;GACA,IAAI,YAAY;IACd,IAAI,MAAM,UAAU,KAAA,GAClB,IAAI,SAAS;KACX,MAAMA,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,OAAO;KACd,SAAS;IACX,CAAC;IAEH,IAAI,MAAM,cAAc,KAAA,GACtB,IAAI,SAAS;KACX,MAAMA,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,WAAW;KAClB,SAAS;IACX,CAAC;GAEL;GACA;EACF;EAEA,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;EAEH,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;CAEL,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
2
+ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
3
3
  let zod_v4 = require("zod/v4");
4
4
  let _mastra_core_storage = require("@mastra/core/storage");
5
5
  _mastra_core_storage = require_rolldown_runtime.__toESM(_mastra_core_storage, 1);
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
2
+ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
3
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
4
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
5
5
  const require_server_handlers_error = require("./error.cjs");
6
6
  const require_server_handlers_observability_list_query_schemas = require("./observability-list-query-schemas.cjs");
7
7
  const require_server_handlers_observability_shared = require("./observability-shared.cjs");
8
8
  const require_server_handlers_observability_storage_schemas = require("./observability-storage-schemas.cjs");
9
- const require_observability_new_endpoints = require("../../observability-new-endpoints-BC-dasRY.cjs");
9
+ const require_observability_new_endpoints = require("../../observability-new-endpoints-gRCFhnRr.cjs");
10
10
  let zod_v4 = require("zod/v4");
11
11
  let _mastra_core_evals = require("@mastra/core/evals");
12
12
  let _mastra_core_evals_scoreTraces = require("@mastra/core/evals/scoreTraces");
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../../rolldown-runtime-DuvcJU0W.js";
1
+ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
2
2
  import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
3
3
  import { a as wrapSchemaForQueryParams, i as pickParams, n as createRoute } from "../../route-builder-YQ_gLIvW.js";
4
4
  import { handleError } from "./error.js";
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
2
+ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
3
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
4
4
  const require_agents = require("../../agents-CLv_RFQx.cjs");
5
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
5
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
6
6
  const require_server_handlers_error = require("./error.cjs");
7
- const require_utils = require("../../utils-CXbhpYYv.cjs");
7
+ const require_utils = require("../../utils-Xnn91QBW.cjs");
8
8
  const require_server_handlers_agents = require("./agents.cjs");
9
9
  let _mastra_core_tools = require("@mastra/core/tools");
10
10
  //#region src/server/handlers/plans.ts
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../../rolldown-runtime-DuvcJU0W.js";
1
+ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
2
2
  import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
3
3
  import { a as agentIdPathParams, o as agentPlanQuerySchema, s as agentPlanResponseSchema } from "../../agents-BetrUB_N.js";
4
4
  import { n as createRoute } from "../../route-builder-YQ_gLIvW.js";
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../rolldown-runtime-Bd6kNlEP.cjs");
2
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
3
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
4
5
  const require_server_handlers_error = require("./error.cjs");
5
6
  const require_processor_providers = require("../../processor-providers-DHvTA9AL.cjs");
6
7
  let _mastra_core_utils_zod_to_json = require("@mastra/core/utils/zod-to-json");
@@ -1 +1 @@
1
- {"version":3,"file":"processor-providers.cjs","names":["createRoute","getProcessorProvidersResponseSchema","HTTPException","handleError","processorProviderIdPathParams","getProcessorProviderResponseSchema"],"sources":["../../../src/server/handlers/processor-providers.ts"],"sourcesContent":["import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\n\nimport { HTTPException } from '../http-exception';\nimport {\n processorProviderIdPathParams,\n getProcessorProvidersResponseSchema,\n getProcessorProviderResponseSchema,\n} from '../schemas/processor-providers';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { handleError } from './error';\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /processor-providers - List all registered processor providers\n */\nexport const LIST_PROCESSOR_PROVIDERS_ROUTE = createRoute({\n method: 'GET',\n path: '/processor-providers',\n responseType: 'json',\n responseSchema: getProcessorProvidersResponseSchema,\n summary: 'List processor providers',\n description: 'Returns a list of all registered processor providers with their info and available phases',\n tags: ['Processor Providers'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n try {\n const editor = mastra.getEditor();\n\n if (!editor) {\n throw new HTTPException(500, { message: 'Editor is not configured' });\n }\n\n const providers = editor.getProcessorProviders();\n\n return {\n providers: Object.values(providers).map(provider => ({\n ...provider.info,\n availablePhases: provider.availablePhases,\n })),\n };\n } catch (error) {\n return handleError(error, 'Error listing processor providers');\n }\n },\n});\n\n/**\n * GET /processor-providers/:providerId - Get a specific processor provider with config schema\n */\nexport const GET_PROCESSOR_PROVIDER_ROUTE = createRoute({\n method: 'GET',\n path: '/processor-providers/:providerId',\n responseType: 'json',\n pathParamSchema: processorProviderIdPathParams,\n responseSchema: getProcessorProviderResponseSchema,\n summary: 'Get processor provider details',\n description: 'Returns details about a specific processor provider, including its configuration schema',\n tags: ['Processor Providers'],\n requiresAuth: true,\n handler: async ({ mastra, providerId }) => {\n try {\n const editor = mastra.getEditor();\n\n if (!editor) {\n throw new HTTPException(500, { message: 'Editor is not configured' });\n }\n\n const provider = editor.getProcessorProvider(providerId);\n\n if (!provider) {\n throw new HTTPException(404, { message: `Processor provider with id ${providerId} not found` });\n }\n\n return {\n ...provider.info,\n availablePhases: provider.availablePhases,\n configSchema: zodToJsonSchema(provider.configSchema) as Record<string, unknown>,\n };\n } catch (error) {\n return handleError(error, 'Error getting processor provider');\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAmBA,MAAa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-providers.cjs","names":["createRoute","getProcessorProvidersResponseSchema","HTTPException","handleError","processorProviderIdPathParams","getProcessorProviderResponseSchema"],"sources":["../../../src/server/handlers/processor-providers.ts"],"sourcesContent":["import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\n\nimport { HTTPException } from '../http-exception';\nimport {\n processorProviderIdPathParams,\n getProcessorProvidersResponseSchema,\n getProcessorProviderResponseSchema,\n} from '../schemas/processor-providers';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { handleError } from './error';\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /processor-providers - List all registered processor providers\n */\nexport const LIST_PROCESSOR_PROVIDERS_ROUTE = createRoute({\n method: 'GET',\n path: '/processor-providers',\n responseType: 'json',\n responseSchema: getProcessorProvidersResponseSchema,\n summary: 'List processor providers',\n description: 'Returns a list of all registered processor providers with their info and available phases',\n tags: ['Processor Providers'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n try {\n const editor = mastra.getEditor();\n\n if (!editor) {\n throw new HTTPException(500, { message: 'Editor is not configured' });\n }\n\n const providers = editor.getProcessorProviders();\n\n return {\n providers: Object.values(providers).map(provider => ({\n ...provider.info,\n availablePhases: provider.availablePhases,\n })),\n };\n } catch (error) {\n return handleError(error, 'Error listing processor providers');\n }\n },\n});\n\n/**\n * GET /processor-providers/:providerId - Get a specific processor provider with config schema\n */\nexport const GET_PROCESSOR_PROVIDER_ROUTE = createRoute({\n method: 'GET',\n path: '/processor-providers/:providerId',\n responseType: 'json',\n pathParamSchema: processorProviderIdPathParams,\n responseSchema: getProcessorProviderResponseSchema,\n summary: 'Get processor provider details',\n description: 'Returns details about a specific processor provider, including its configuration schema',\n tags: ['Processor Providers'],\n requiresAuth: true,\n handler: async ({ mastra, providerId }) => {\n try {\n const editor = mastra.getEditor();\n\n if (!editor) {\n throw new HTTPException(500, { message: 'Editor is not configured' });\n }\n\n const provider = editor.getProcessorProvider(providerId);\n\n if (!provider) {\n throw new HTTPException(404, { message: `Processor provider with id ${providerId} not found` });\n }\n\n return {\n ...provider.info,\n availablePhases: provider.availablePhases,\n configSchema: zodToJsonSchema(provider.configSchema) as Record<string, unknown>,\n };\n } catch (error) {\n return handleError(error, 'Error getting processor provider');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,iCAAiCA,sBAAAA,YAAY;CACxD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,gBAAgBC,4BAAAA;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,qBAAqB;CAC5B,cAAc;CACd,SAAS,OAAO,EAAE,aAAa;EAC7B,IAAI;GACF,MAAM,SAAS,OAAO,UAAU;GAEhC,IAAI,CAAC,QACH,MAAM,IAAIC,uBAAAA,cAAc,KAAK,EAAE,SAAS,2BAA2B,CAAC;GAGtE,MAAM,YAAY,OAAO,sBAAsB;GAE/C,OAAO,EACL,WAAW,OAAO,OAAO,SAAS,CAAC,CAAC,KAAI,cAAa;IACnD,GAAG,SAAS;IACZ,iBAAiB,SAAS;GAC5B,EAAE,EACJ;EACF,SAAS,OAAO;GACd,OAAOC,8BAAAA,YAAY,OAAO,mCAAmC;EAC/D;CACF;AACF,CAAC;;;;AAKD,MAAa,+BAA+BH,sBAAAA,YAAY;CACtD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiBI,4BAAAA;CACjB,gBAAgBC,4BAAAA;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,qBAAqB;CAC5B,cAAc;CACd,SAAS,OAAO,EAAE,QAAQ,iBAAiB;EACzC,IAAI;GACF,MAAM,SAAS,OAAO,UAAU;GAEhC,IAAI,CAAC,QACH,MAAM,IAAIH,uBAAAA,cAAc,KAAK,EAAE,SAAS,2BAA2B,CAAC;GAGtE,MAAM,WAAW,OAAO,qBAAqB,UAAU;GAEvD,IAAI,CAAC,UACH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SAAS,8BAA8B,WAAW,YAAY,CAAC;GAGhG,OAAO;IACL,GAAG,SAAS;IACZ,iBAAiB,SAAS;IAC1B,eAAA,GAAA,+BAAA,gBAAA,CAA8B,SAAS,YAAY;GACrD;EACF,SAAS,OAAO;GACd,OAAOC,8BAAAA,YAAY,OAAO,kCAAkC;EAC9D;CACF;AACF,CAAC"}
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../rolldown-runtime-Bd6kNlEP.cjs");
2
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
3
- const require_route_builder = require("../../route-builder-BAAedfru.cjs");
4
+ const require_route_builder = require("../../route-builder-CWsok5ci.cjs");
4
5
  const require_server_handlers_error = require("./error.cjs");
5
6
  const require_processors = require("../../processors-D6lRjS0e.cjs");
6
7
  let _mastra_core_agent = require("@mastra/core/agent");