@mastra/server 1.53.0-alpha.2 → 1.53.0-alpha.4

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 (245) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{api-schema-manifest-XUZGITBV.cjs → api-schema-manifest-HHPOQOBA.cjs} +4 -4
  3. package/dist/{api-schema-manifest-XUZGITBV.cjs.map → api-schema-manifest-HHPOQOBA.cjs.map} +1 -1
  4. package/dist/{api-schema-manifest-O4VMTNLT.js → api-schema-manifest-YZ2UQAKW.js} +3 -3
  5. package/dist/{api-schema-manifest-O4VMTNLT.js.map → api-schema-manifest-YZ2UQAKW.js.map} +1 -1
  6. package/dist/{chunk-7X3YWKHD.cjs → chunk-24GG74PF.cjs} +19 -19
  7. package/dist/{chunk-7X3YWKHD.cjs.map → chunk-24GG74PF.cjs.map} +1 -1
  8. package/dist/{chunk-O4PNIMVX.cjs → chunk-2XPHKO5K.cjs} +11 -11
  9. package/dist/{chunk-O4PNIMVX.cjs.map → chunk-2XPHKO5K.cjs.map} +1 -1
  10. package/dist/{chunk-LJNTC2CX.cjs → chunk-3BNDX3X4.cjs} +14 -14
  11. package/dist/{chunk-LJNTC2CX.cjs.map → chunk-3BNDX3X4.cjs.map} +1 -1
  12. package/dist/{chunk-LVGKXQCC.cjs → chunk-3GMKZKUD.cjs} +3 -3
  13. package/dist/{chunk-LVGKXQCC.cjs.map → chunk-3GMKZKUD.cjs.map} +1 -1
  14. package/dist/{chunk-FZLA552S.js → chunk-3QCPLI6I.js} +4 -4
  15. package/dist/{chunk-FZLA552S.js.map → chunk-3QCPLI6I.js.map} +1 -1
  16. package/dist/{chunk-ETR4XOVD.js → chunk-3TTDIOEU.js} +3 -3
  17. package/dist/{chunk-ETR4XOVD.js.map → chunk-3TTDIOEU.js.map} +1 -1
  18. package/dist/{chunk-UTOKVLFZ.cjs → chunk-4AURMJAJ.cjs} +312 -312
  19. package/dist/{chunk-UTOKVLFZ.cjs.map → chunk-4AURMJAJ.cjs.map} +1 -1
  20. package/dist/{chunk-7OY3AGJJ.js → chunk-4IPX4EPA.js} +4 -4
  21. package/dist/{chunk-7OY3AGJJ.js.map → chunk-4IPX4EPA.js.map} +1 -1
  22. package/dist/{chunk-5ZFBQKCW.js → chunk-4YZLXIS4.js} +4 -4
  23. package/dist/{chunk-5ZFBQKCW.js.map → chunk-4YZLXIS4.js.map} +1 -1
  24. package/dist/{chunk-WMS7BOP7.cjs → chunk-5GRNWZZS.cjs} +3 -3
  25. package/dist/{chunk-WMS7BOP7.cjs.map → chunk-5GRNWZZS.cjs.map} +1 -1
  26. package/dist/{chunk-TH7EIZLU.cjs → chunk-67C55FXM.cjs} +65 -65
  27. package/dist/{chunk-TH7EIZLU.cjs.map → chunk-67C55FXM.cjs.map} +1 -1
  28. package/dist/{chunk-YQDPAOM2.js → chunk-6DFQUXJB.js} +6 -6
  29. package/dist/{chunk-YQDPAOM2.js.map → chunk-6DFQUXJB.js.map} +1 -1
  30. package/dist/{chunk-EAVV7J77.cjs → chunk-73ZRTS7S.cjs} +12 -3
  31. package/dist/chunk-73ZRTS7S.cjs.map +1 -0
  32. package/dist/{chunk-LERI4STI.cjs → chunk-773UBYWJ.cjs} +63 -63
  33. package/dist/{chunk-LERI4STI.cjs.map → chunk-773UBYWJ.cjs.map} +1 -1
  34. package/dist/{chunk-LOGRPGIH.js → chunk-7BT3XVWU.js} +12 -4
  35. package/dist/chunk-7BT3XVWU.js.map +1 -0
  36. package/dist/{chunk-PPJXCZCX.cjs → chunk-7JLKJOVG.cjs} +8 -8
  37. package/dist/{chunk-PPJXCZCX.cjs.map → chunk-7JLKJOVG.cjs.map} +1 -1
  38. package/dist/{chunk-DTJXVPYD.js → chunk-ALHEBK6S.js} +4 -4
  39. package/dist/{chunk-DTJXVPYD.js.map → chunk-ALHEBK6S.js.map} +1 -1
  40. package/dist/{chunk-ZD4SKL6I.js → chunk-CCH25WG6.js} +6 -6
  41. package/dist/{chunk-ZD4SKL6I.js.map → chunk-CCH25WG6.js.map} +1 -1
  42. package/dist/{chunk-4ESLXJ4G.js → chunk-CM6KRKF6.js} +5 -5
  43. package/dist/{chunk-4ESLXJ4G.js.map → chunk-CM6KRKF6.js.map} +1 -1
  44. package/dist/{chunk-ET73PQRG.js → chunk-CMDXDKJX.js} +5 -5
  45. package/dist/{chunk-ET73PQRG.js.map → chunk-CMDXDKJX.js.map} +1 -1
  46. package/dist/{chunk-J24BKQPK.js → chunk-D33KJE2C.js} +6 -6
  47. package/dist/{chunk-J24BKQPK.js.map → chunk-D33KJE2C.js.map} +1 -1
  48. package/dist/{chunk-W543ZJQB.cjs → chunk-EASJIOMB.cjs} +14 -14
  49. package/dist/{chunk-W543ZJQB.cjs.map → chunk-EASJIOMB.cjs.map} +1 -1
  50. package/dist/{chunk-VXN5FEWC.js → chunk-FDGZRSSA.js} +7 -7
  51. package/dist/{chunk-VXN5FEWC.js.map → chunk-FDGZRSSA.js.map} +1 -1
  52. package/dist/{chunk-GHTMFCWF.cjs → chunk-FLFWTZIS.cjs} +11 -11
  53. package/dist/{chunk-GHTMFCWF.cjs.map → chunk-FLFWTZIS.cjs.map} +1 -1
  54. package/dist/{chunk-SQSAIKSL.js → chunk-FP6SUEJ5.js} +6 -6
  55. package/dist/{chunk-SQSAIKSL.js.map → chunk-FP6SUEJ5.js.map} +1 -1
  56. package/dist/{chunk-RA26ZEMJ.js → chunk-G2XVC7BX.js} +6 -6
  57. package/dist/{chunk-RA26ZEMJ.js.map → chunk-G2XVC7BX.js.map} +1 -1
  58. package/dist/{chunk-S7Y6AP64.cjs → chunk-GV6TKASG.cjs} +4 -4
  59. package/dist/{chunk-S7Y6AP64.cjs.map → chunk-GV6TKASG.cjs.map} +1 -1
  60. package/dist/{chunk-AJXH4AOX.js → chunk-GVEZESOH.js} +4 -4
  61. package/dist/{chunk-AJXH4AOX.js.map → chunk-GVEZESOH.js.map} +1 -1
  62. package/dist/{chunk-C5QHQN5G.cjs → chunk-GXTPE32B.cjs} +14 -14
  63. package/dist/{chunk-C5QHQN5G.cjs.map → chunk-GXTPE32B.cjs.map} +1 -1
  64. package/dist/{chunk-XNUACBMX.cjs → chunk-IGPF637U.cjs} +6 -6
  65. package/dist/{chunk-XNUACBMX.cjs.map → chunk-IGPF637U.cjs.map} +1 -1
  66. package/dist/{chunk-PXA4EGKL.cjs → chunk-IK5UTS7Q.cjs} +13 -13
  67. package/dist/{chunk-PXA4EGKL.cjs.map → chunk-IK5UTS7Q.cjs.map} +1 -1
  68. package/dist/{chunk-RPPHTS6D.js → chunk-IP73WGJO.js} +4 -4
  69. package/dist/{chunk-RPPHTS6D.js.map → chunk-IP73WGJO.js.map} +1 -1
  70. package/dist/{chunk-EVOVAWN6.cjs → chunk-ITROB3E5.cjs} +3 -3
  71. package/dist/{chunk-EVOVAWN6.cjs.map → chunk-ITROB3E5.cjs.map} +1 -1
  72. package/dist/{chunk-TKOUI25C.js → chunk-JPOJK4HE.js} +6 -6
  73. package/dist/{chunk-TKOUI25C.js.map → chunk-JPOJK4HE.js.map} +1 -1
  74. package/dist/{chunk-RZZJ4L32.js → chunk-KUXC22PN.js} +5 -5
  75. package/dist/{chunk-RZZJ4L32.js.map → chunk-KUXC22PN.js.map} +1 -1
  76. package/dist/{chunk-COBVX6FO.js → chunk-KWBDEZA7.js} +4 -4
  77. package/dist/{chunk-COBVX6FO.js.map → chunk-KWBDEZA7.js.map} +1 -1
  78. package/dist/{chunk-RJFQV7QJ.cjs → chunk-L4LO7SXL.cjs} +38 -38
  79. package/dist/{chunk-RJFQV7QJ.cjs.map → chunk-L4LO7SXL.cjs.map} +1 -1
  80. package/dist/{chunk-OCDUNF52.cjs → chunk-LFITIFN4.cjs} +8 -8
  81. package/dist/{chunk-OCDUNF52.cjs.map → chunk-LFITIFN4.cjs.map} +1 -1
  82. package/dist/{chunk-5QBM7JJC.cjs → chunk-LZMLLK22.cjs} +16 -16
  83. package/dist/{chunk-5QBM7JJC.cjs.map → chunk-LZMLLK22.cjs.map} +1 -1
  84. package/dist/{chunk-ZVTNACHY.js → chunk-MTZKPV6D.js} +4 -12
  85. package/dist/chunk-MTZKPV6D.js.map +1 -0
  86. package/dist/{chunk-Q632CERJ.js → chunk-NHVVEZW2.js} +5 -5
  87. package/dist/{chunk-Q632CERJ.js.map → chunk-NHVVEZW2.js.map} +1 -1
  88. package/dist/{chunk-QQJHGSB2.cjs → chunk-NWXAU2T5.cjs} +3 -3
  89. package/dist/{chunk-QQJHGSB2.cjs.map → chunk-NWXAU2T5.cjs.map} +1 -1
  90. package/dist/{chunk-SPNWC52V.js → chunk-PJHUFD5O.js} +3 -3
  91. package/dist/{chunk-SPNWC52V.js.map → chunk-PJHUFD5O.js.map} +1 -1
  92. package/dist/{chunk-6QSLKMKV.cjs → chunk-PLXKFGJB.cjs} +5 -5
  93. package/dist/{chunk-6QSLKMKV.cjs.map → chunk-PLXKFGJB.cjs.map} +1 -1
  94. package/dist/{chunk-ODT3BA2T.js → chunk-Q5L74UGI.js} +4 -4
  95. package/dist/{chunk-ODT3BA2T.js.map → chunk-Q5L74UGI.js.map} +1 -1
  96. package/dist/{chunk-NKG3PCTS.cjs → chunk-QPPCEY5W.cjs} +45 -45
  97. package/dist/{chunk-NKG3PCTS.cjs.map → chunk-QPPCEY5W.cjs.map} +1 -1
  98. package/dist/{chunk-LPM2IGPA.cjs → chunk-R4IYLTSR.cjs} +4 -4
  99. package/dist/{chunk-LPM2IGPA.cjs.map → chunk-R4IYLTSR.cjs.map} +1 -1
  100. package/dist/{chunk-4GWTCVFL.js → chunk-RCRKB2TG.js} +3 -3
  101. package/dist/{chunk-4GWTCVFL.js.map → chunk-RCRKB2TG.js.map} +1 -1
  102. package/dist/{chunk-BMVLDSDJ.cjs → chunk-RFWX53ED.cjs} +23 -23
  103. package/dist/{chunk-BMVLDSDJ.cjs.map → chunk-RFWX53ED.cjs.map} +1 -1
  104. package/dist/{chunk-CLZVCJJX.js → chunk-RRKCV7QT.js} +4 -4
  105. package/dist/{chunk-CLZVCJJX.js.map → chunk-RRKCV7QT.js.map} +1 -1
  106. package/dist/{chunk-LYZLM7TQ.cjs → chunk-SBVDQ2PB.cjs} +11 -11
  107. package/dist/{chunk-LYZLM7TQ.cjs.map → chunk-SBVDQ2PB.cjs.map} +1 -1
  108. package/dist/{chunk-YYJ2TLFP.js → chunk-T2GYY7P5.js} +4 -4
  109. package/dist/{chunk-YYJ2TLFP.js.map → chunk-T2GYY7P5.js.map} +1 -1
  110. package/dist/{chunk-5AM2O3JF.js → chunk-T64IQJHY.js} +4 -4
  111. package/dist/{chunk-5AM2O3JF.js.map → chunk-T64IQJHY.js.map} +1 -1
  112. package/dist/{chunk-A7APTIYJ.js → chunk-T65G3E5M.js} +3 -3
  113. package/dist/{chunk-A7APTIYJ.js.map → chunk-T65G3E5M.js.map} +1 -1
  114. package/dist/{chunk-26PD32NV.cjs → chunk-T7QRJ6CC.cjs} +97 -97
  115. package/dist/{chunk-26PD32NV.cjs.map → chunk-T7QRJ6CC.cjs.map} +1 -1
  116. package/dist/{chunk-WCTXV424.cjs → chunk-TCA2QMPR.cjs} +46 -54
  117. package/dist/chunk-TCA2QMPR.cjs.map +1 -0
  118. package/dist/{chunk-HPMLQ4AV.js → chunk-TQ5KIKVK.js} +3 -3
  119. package/dist/{chunk-HPMLQ4AV.js.map → chunk-TQ5KIKVK.js.map} +1 -1
  120. package/dist/{chunk-C5RH6NNS.js → chunk-U3D7DWOU.js} +7 -7
  121. package/dist/{chunk-C5RH6NNS.js.map → chunk-U3D7DWOU.js.map} +1 -1
  122. package/dist/{chunk-HVMCICMF.js → chunk-U3ZA2A36.js} +4 -4
  123. package/dist/{chunk-HVMCICMF.js.map → chunk-U3ZA2A36.js.map} +1 -1
  124. package/dist/{chunk-MG4AA326.js → chunk-U4MYHXYB.js} +4 -4
  125. package/dist/{chunk-MG4AA326.js.map → chunk-U4MYHXYB.js.map} +1 -1
  126. package/dist/{chunk-2A4R6GSR.js → chunk-UB3FCZK2.js} +4 -4
  127. package/dist/{chunk-2A4R6GSR.js.map → chunk-UB3FCZK2.js.map} +1 -1
  128. package/dist/{chunk-USKSOKOS.cjs → chunk-UFREN5I5.cjs} +8 -8
  129. package/dist/{chunk-USKSOKOS.cjs.map → chunk-UFREN5I5.cjs.map} +1 -1
  130. package/dist/{chunk-UL3UXUNU.cjs → chunk-UZRS4E2K.cjs} +11 -11
  131. package/dist/{chunk-UL3UXUNU.cjs.map → chunk-UZRS4E2K.cjs.map} +1 -1
  132. package/dist/{chunk-OFF7L43B.cjs → chunk-VC5L737D.cjs} +7 -7
  133. package/dist/{chunk-OFF7L43B.cjs.map → chunk-VC5L737D.cjs.map} +1 -1
  134. package/dist/{chunk-QUCQNTXT.cjs → chunk-VCRTOLAT.cjs} +9 -9
  135. package/dist/{chunk-QUCQNTXT.cjs.map → chunk-VCRTOLAT.cjs.map} +1 -1
  136. package/dist/{chunk-JVE5HOUL.cjs → chunk-VGGYQ246.cjs} +4 -4
  137. package/dist/{chunk-JVE5HOUL.cjs.map → chunk-VGGYQ246.cjs.map} +1 -1
  138. package/dist/{chunk-6B65YSQN.cjs → chunk-W55OO342.cjs} +34 -34
  139. package/dist/{chunk-6B65YSQN.cjs.map → chunk-W55OO342.cjs.map} +1 -1
  140. package/dist/{chunk-TTE75FML.js → chunk-WINDACJX.js} +35 -35
  141. package/dist/{chunk-TTE75FML.js.map → chunk-WINDACJX.js.map} +1 -1
  142. package/dist/{chunk-NZZLZSVD.js → chunk-X5ROLVN2.js} +3 -3
  143. package/dist/{chunk-NZZLZSVD.js.map → chunk-X5ROLVN2.js.map} +1 -1
  144. package/dist/{chunk-KAWV7C5E.cjs → chunk-X6MKRXGS.cjs} +14 -14
  145. package/dist/{chunk-KAWV7C5E.cjs.map → chunk-X6MKRXGS.cjs.map} +1 -1
  146. package/dist/{chunk-WFGFCWLV.js → chunk-XX25W323.js} +6 -6
  147. package/dist/{chunk-WFGFCWLV.js.map → chunk-XX25W323.js.map} +1 -1
  148. package/dist/{chunk-NTS3DORC.cjs → chunk-YUSXKTBJ.cjs} +14 -14
  149. package/dist/{chunk-NTS3DORC.cjs.map → chunk-YUSXKTBJ.cjs.map} +1 -1
  150. package/dist/{chunk-2K3GCDOX.js → chunk-ZJOIVM5L.js} +3 -3
  151. package/dist/{chunk-2K3GCDOX.js.map → chunk-ZJOIVM5L.js.map} +1 -1
  152. package/dist/{chunk-RWL3CJF7.js → chunk-ZLVFK6NZ.js} +5 -5
  153. package/dist/{chunk-RWL3CJF7.js.map → chunk-ZLVFK6NZ.js.map} +1 -1
  154. package/dist/{chunk-A773U2QJ.cjs → chunk-ZMMOLM35.cjs} +54 -54
  155. package/dist/{chunk-A773U2QJ.cjs.map → chunk-ZMMOLM35.cjs.map} +1 -1
  156. package/dist/{chunk-A7MIAAKW.cjs → chunk-ZTE7FRYI.cjs} +6 -6
  157. package/dist/{chunk-A7MIAAKW.cjs.map → chunk-ZTE7FRYI.cjs.map} +1 -1
  158. package/dist/docs/SKILL.md +1 -1
  159. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  160. package/dist/server/handlers/a2a.cjs +14 -14
  161. package/dist/server/handlers/a2a.js +1 -1
  162. package/dist/server/handlers/agent-builder.cjs +17 -17
  163. package/dist/server/handlers/agent-builder.js +1 -1
  164. package/dist/server/handlers/agent-versions.cjs +8 -8
  165. package/dist/server/handlers/agent-versions.js +1 -1
  166. package/dist/server/handlers/agents.cjs +48 -48
  167. package/dist/server/handlers/agents.js +1 -1
  168. package/dist/server/handlers/auth.cjs +13 -13
  169. package/dist/server/handlers/auth.js +1 -1
  170. package/dist/server/handlers/authorship.cjs +12 -12
  171. package/dist/server/handlers/authorship.js +1 -1
  172. package/dist/server/handlers/builder-registry.cjs +6 -6
  173. package/dist/server/handlers/builder-registry.js +1 -1
  174. package/dist/server/handlers/channels.cjs +5 -5
  175. package/dist/server/handlers/channels.js +1 -1
  176. package/dist/server/handlers/conversations.cjs +5 -5
  177. package/dist/server/handlers/conversations.js +1 -1
  178. package/dist/server/handlers/datasets.cjs +26 -26
  179. package/dist/server/handlers/datasets.js +1 -1
  180. package/dist/server/handlers/editor-builder.cjs +6 -6
  181. package/dist/server/handlers/editor-builder.js +1 -1
  182. package/dist/server/handlers/favorites-enrichment.cjs +4 -4
  183. package/dist/server/handlers/favorites-enrichment.js +1 -1
  184. package/dist/server/handlers/logs.cjs +4 -4
  185. package/dist/server/handlers/logs.js +1 -1
  186. package/dist/server/handlers/mcp-client-versions.cjs +8 -8
  187. package/dist/server/handlers/mcp-client-versions.js +1 -1
  188. package/dist/server/handlers/memory.cjs +27 -27
  189. package/dist/server/handlers/memory.js +1 -1
  190. package/dist/server/handlers/observability-new-endpoints.cjs +29 -29
  191. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  192. package/dist/server/handlers/observability-shared.cjs +13 -9
  193. package/dist/server/handlers/observability-shared.d.ts +4 -2
  194. package/dist/server/handlers/observability-shared.d.ts.map +1 -1
  195. package/dist/server/handlers/observability-shared.js +1 -1
  196. package/dist/server/handlers/observability.cjs +40 -40
  197. package/dist/server/handlers/observability.d.ts.map +1 -1
  198. package/dist/server/handlers/observability.js +2 -2
  199. package/dist/server/handlers/prompt-block-versions.cjs +8 -8
  200. package/dist/server/handlers/prompt-block-versions.js +1 -1
  201. package/dist/server/handlers/responses.cjs +4 -4
  202. package/dist/server/handlers/responses.js +1 -1
  203. package/dist/server/handlers/responses.storage.cjs +8 -8
  204. package/dist/server/handlers/responses.storage.js +1 -1
  205. package/dist/server/handlers/scorer-versions.cjs +8 -8
  206. package/dist/server/handlers/scorer-versions.js +1 -1
  207. package/dist/server/handlers/scores.cjs +7 -7
  208. package/dist/server/handlers/scores.js +1 -1
  209. package/dist/server/handlers/stored-agent-favorites.cjs +3 -3
  210. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  211. package/dist/server/handlers/stored-agents.cjs +10 -10
  212. package/dist/server/handlers/stored-agents.js +1 -1
  213. package/dist/server/handlers/stored-mcp-clients.cjs +6 -6
  214. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  215. package/dist/server/handlers/stored-prompt-blocks.cjs +6 -6
  216. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  217. package/dist/server/handlers/stored-scorers.cjs +6 -6
  218. package/dist/server/handlers/stored-scorers.js +1 -1
  219. package/dist/server/handlers/stored-skill-favorites.cjs +3 -3
  220. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  221. package/dist/server/handlers/stored-skills.cjs +7 -7
  222. package/dist/server/handlers/stored-skills.js +1 -1
  223. package/dist/server/handlers/stored-workspaces.cjs +6 -6
  224. package/dist/server/handlers/stored-workspaces.js +1 -1
  225. package/dist/server/handlers/system.cjs +3 -3
  226. package/dist/server/handlers/system.js +1 -1
  227. package/dist/server/handlers/tool-providers.cjs +14 -14
  228. package/dist/server/handlers/tool-providers.js +1 -1
  229. package/dist/server/handlers/tools.cjs +6 -6
  230. package/dist/server/handlers/tools.js +1 -1
  231. package/dist/server/handlers/utils.cjs +11 -11
  232. package/dist/server/handlers/utils.js +1 -1
  233. package/dist/server/handlers/workflows.cjs +27 -27
  234. package/dist/server/handlers/workflows.js +1 -1
  235. package/dist/server/handlers.cjs +22 -22
  236. package/dist/server/handlers.js +11 -11
  237. package/dist/server/schemas/index.cjs +152 -152
  238. package/dist/server/schemas/index.js +4 -4
  239. package/dist/server/server-adapter/index.cjs +42 -42
  240. package/dist/server/server-adapter/index.js +6 -6
  241. package/package.json +6 -6
  242. package/dist/chunk-EAVV7J77.cjs.map +0 -1
  243. package/dist/chunk-LOGRPGIH.js.map +0 -1
  244. package/dist/chunk-WCTXV424.cjs.map +0 -1
  245. package/dist/chunk-ZVTNACHY.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkC5V2PEPJ_cjs = require('./chunk-C5V2PEPJ.cjs');
4
3
  var chunk2XZ2466F_cjs = require('./chunk-2XZ2466F.cjs');
5
- var chunkEVOVAWN6_cjs = require('./chunk-EVOVAWN6.cjs');
4
+ var chunkC5V2PEPJ_cjs = require('./chunk-C5V2PEPJ.cjs');
5
+ var chunkITROB3E5_cjs = require('./chunk-ITROB3E5.cjs');
6
6
  var chunkZ7LCIYK7_cjs = require('./chunk-Z7LCIYK7.cjs');
7
7
  var chunkRTTQ6WVP_cjs = require('./chunk-RTTQ6WVP.cjs');
8
8
  var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
@@ -34,7 +34,7 @@ var LIST_PROMPT_BLOCK_VERSIONS_ROUTE = chunkRTTQ6WVP_cjs.createRoute({
34
34
  if (!promptBlock) {
35
35
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });
36
36
  }
37
- chunkEVOVAWN6_cjs.assertStoredResourceScope(promptBlock, await chunkEVOVAWN6_cjs.getStoredResourceScope(mastra, requestContext));
37
+ chunkITROB3E5_cjs.assertStoredResourceScope(promptBlock, await chunkITROB3E5_cjs.getStoredResourceScope(mastra, requestContext));
38
38
  const result = await promptBlockStore.listVersions({
39
39
  blockId: promptBlockId,
40
40
  page,
@@ -72,7 +72,7 @@ var CREATE_PROMPT_BLOCK_VERSION_ROUTE = chunkRTTQ6WVP_cjs.createRoute({
72
72
  if (!promptBlock) {
73
73
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });
74
74
  }
75
- chunkEVOVAWN6_cjs.assertStoredResourceScope(promptBlock, await chunkEVOVAWN6_cjs.getStoredResourceScope(mastra, requestContext));
75
+ chunkITROB3E5_cjs.assertStoredResourceScope(promptBlock, await chunkITROB3E5_cjs.getStoredResourceScope(mastra, requestContext));
76
76
  let currentConfig = {};
77
77
  if (promptBlock.activeVersionId) {
78
78
  const activeVersion = await promptBlockStore.getVersion(promptBlock.activeVersionId);
@@ -146,7 +146,7 @@ var GET_PROMPT_BLOCK_VERSION_ROUTE = chunkRTTQ6WVP_cjs.createRoute({
146
146
  });
147
147
  }
148
148
  const promptBlock = await promptBlockStore.getById(promptBlockId);
149
- chunkEVOVAWN6_cjs.assertStoredResourceScope(promptBlock, await chunkEVOVAWN6_cjs.getStoredResourceScope(mastra, requestContext));
149
+ chunkITROB3E5_cjs.assertStoredResourceScope(promptBlock, await chunkITROB3E5_cjs.getStoredResourceScope(mastra, requestContext));
150
150
  return version;
151
151
  } catch (error) {
152
152
  return chunkZ7LCIYK7_cjs.handleError(error, "Error getting prompt block version");
@@ -177,7 +177,7 @@ var ACTIVATE_PROMPT_BLOCK_VERSION_ROUTE = chunkRTTQ6WVP_cjs.createRoute({
177
177
  if (!promptBlock) {
178
178
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });
179
179
  }
180
- chunkEVOVAWN6_cjs.assertStoredResourceScope(promptBlock, await chunkEVOVAWN6_cjs.getStoredResourceScope(mastra, requestContext));
180
+ chunkITROB3E5_cjs.assertStoredResourceScope(promptBlock, await chunkITROB3E5_cjs.getStoredResourceScope(mastra, requestContext));
181
181
  const version = await promptBlockStore.getVersion(versionId);
182
182
  if (!version) {
183
183
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Version with id ${versionId} not found` });
@@ -227,7 +227,7 @@ var RESTORE_PROMPT_BLOCK_VERSION_ROUTE = chunkRTTQ6WVP_cjs.createRoute({
227
227
  if (!promptBlock) {
228
228
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });
229
229
  }
230
- chunkEVOVAWN6_cjs.assertStoredResourceScope(promptBlock, await chunkEVOVAWN6_cjs.getStoredResourceScope(mastra, requestContext));
230
+ chunkITROB3E5_cjs.assertStoredResourceScope(promptBlock, await chunkITROB3E5_cjs.getStoredResourceScope(mastra, requestContext));
231
231
  const versionToRestore = await promptBlockStore.getVersion(versionId);
232
232
  if (!versionToRestore) {
233
233
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Version with id ${versionId} not found` });
@@ -299,7 +299,7 @@ var DELETE_PROMPT_BLOCK_VERSION_ROUTE = chunkRTTQ6WVP_cjs.createRoute({
299
299
  if (!promptBlock) {
300
300
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });
301
301
  }
302
- chunkEVOVAWN6_cjs.assertStoredResourceScope(promptBlock, await chunkEVOVAWN6_cjs.getStoredResourceScope(mastra, requestContext));
302
+ chunkITROB3E5_cjs.assertStoredResourceScope(promptBlock, await chunkITROB3E5_cjs.getStoredResourceScope(mastra, requestContext));
303
303
  const version = await promptBlockStore.getVersion(versionId);
304
304
  if (!version) {
305
305
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Version with id ${versionId} not found` });
@@ -347,7 +347,7 @@ var COMPARE_PROMPT_BLOCK_VERSIONS_ROUTE = chunkRTTQ6WVP_cjs.createRoute({
347
347
  throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Prompt blocks storage domain is not available" });
348
348
  }
349
349
  const promptBlock = await promptBlockStore.getById(promptBlockId);
350
- chunkEVOVAWN6_cjs.assertStoredResourceScope(promptBlock, await chunkEVOVAWN6_cjs.getStoredResourceScope(mastra, requestContext));
350
+ chunkITROB3E5_cjs.assertStoredResourceScope(promptBlock, await chunkITROB3E5_cjs.getStoredResourceScope(mastra, requestContext));
351
351
  const fromVersion = await promptBlockStore.getVersion(from);
352
352
  if (!fromVersion) {
353
353
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Version with id ${from} not found` });
@@ -393,5 +393,5 @@ exports.DELETE_PROMPT_BLOCK_VERSION_ROUTE = DELETE_PROMPT_BLOCK_VERSION_ROUTE;
393
393
  exports.GET_PROMPT_BLOCK_VERSION_ROUTE = GET_PROMPT_BLOCK_VERSION_ROUTE;
394
394
  exports.LIST_PROMPT_BLOCK_VERSIONS_ROUTE = LIST_PROMPT_BLOCK_VERSIONS_ROUTE;
395
395
  exports.RESTORE_PROMPT_BLOCK_VERSION_ROUTE = RESTORE_PROMPT_BLOCK_VERSION_ROUTE;
396
- //# sourceMappingURL=chunk-GHTMFCWF.cjs.map
397
- //# sourceMappingURL=chunk-GHTMFCWF.cjs.map
396
+ //# sourceMappingURL=chunk-FLFWTZIS.cjs.map
397
+ //# sourceMappingURL=chunk-FLFWTZIS.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/handlers/prompt-block-versions.ts"],"names":["createRoute","promptBlockVersionPathParams","listPromptBlockVersionsQuerySchema","listPromptBlockVersionsResponseSchema","HTTPException","assertStoredResourceScope","getStoredResourceScope","handleError","createPromptBlockVersionBodySchema","createPromptBlockVersionResponseSchema","extractConfigFromVersion","calculateChangedFields","createVersionWithRetry","enforceRetentionLimit","promptBlockVersionIdPathParams","getPromptBlockVersionResponseSchema","activatePromptBlockVersionResponseSchema","restorePromptBlockVersionResponseSchema","deletePromptBlockVersionResponseSchema","comparePromptBlockVersionsQuerySchema","comparePromptBlockVersionsResponseSchema","computeVersionDiffs"],"mappings":";;;;;;;;;;AA4BA,IAAM,sBAAA,GAAyB,CAAC,MAAA,EAAQ,aAAA,EAAe,WAAW,OAAO,CAAA;AAKlE,IAAM,mCAAmCA,6BAAA,CAAY;AAAA,EAC1D,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,+CAAA;AAAA,EACN,YAAA,EAAc,IAAA;AAAA,EACd,YAAA,EAAc,MAAA;AAAA,EACd,eAAA,EAAiBC,8CAAA;AAAA,EACjB,gBAAA,EAAkBC,oDAAA;AAAA,EAClB,cAAA,EAAgBC,uDAAA;AAAA,EAChB,OAAA,EAAS,4BAAA;AAAA,EACT,WAAA,EAAa,oEAAA;AAAA,EACb,IAAA,EAAM,CAAC,uBAAuB,CAAA;AAAA,EAC9B,OAAA,EAAS,OAAO,EAAE,MAAA,EAAQ,eAAe,IAAA,EAAM,OAAA,EAAS,OAAA,EAAS,cAAA,EAAe,KAAM;AACpF,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAElC,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ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AM,IAAIA,gCAAc,GAAA,EAAK;AAAA,UAC3B,OAAA,EAAS,CAAA,gBAAA,EAAmB,EAAE,CAAA,4BAAA,EAA+B,aAAa,CAAA;AAAA,SAC3E,CAAA;AAAA,MACH;AAEA,MAAA,MAAM,UAAA,GAAaM,0CAAA;AAAA,QACjB,WAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,MAAM,QAAA,GAAWA,0CAAA;AAAA,QACf,SAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAA,MAAM,KAAA,GAAQW,qCAAA,CAAoB,UAAA,EAAY,QAAQ,CAAA;AAEtD,MAAA,OAAO;AAAA,QACL,KAAA;AAAA,QACA,WAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,OAAOd,6BAAA,CAAY,OAAO,uCAAuC,CAAA;AAAA,IACnE;AAAA,EACF;AACF,CAAC","file":"chunk-GHTMFCWF.cjs","sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n promptBlockVersionPathParams,\n promptBlockVersionIdPathParams,\n listPromptBlockVersionsQuerySchema,\n createPromptBlockVersionBodySchema,\n comparePromptBlockVersionsQuerySchema,\n listPromptBlockVersionsResponseSchema,\n getPromptBlockVersionResponseSchema,\n createPromptBlockVersionResponseSchema,\n activatePromptBlockVersionResponseSchema,\n restorePromptBlockVersionResponseSchema,\n deletePromptBlockVersionResponseSchema,\n comparePromptBlockVersionsResponseSchema,\n} from '../schemas/prompt-block-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} from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst SNAPSHOT_CONFIG_FIELDS = ['name', 'description', 'content', 'rules'] as const;\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions - List all versions for a prompt block\n */\nexport const LIST_PROMPT_BLOCK_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n queryParamSchema: listPromptBlockVersionsQuerySchema,\n responseSchema: listPromptBlockVersionsResponseSchema,\n summary: 'List prompt block versions',\n description: 'Returns a paginated list of all versions for a stored prompt block',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const result = await promptBlockStore.listVersions({\n blockId: promptBlockId,\n page,\n perPage,\n orderBy,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing prompt block versions');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions - Create a new version snapshot\n */\nexport const CREATE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n bodySchema: createPromptBlockVersionBodySchema,\n responseSchema: createPromptBlockVersionResponseSchema,\n summary: 'Create prompt block version',\n description: 'Creates a new version snapshot of the current prompt block configuration',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n let currentConfig: Record<string, unknown> = {};\n if (promptBlock.activeVersionId) {\n const activeVersion = await promptBlockStore.getVersion(promptBlock.activeVersionId);\n if (activeVersion) {\n currentConfig = extractConfigFromVersion(\n activeVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n }\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(promptBlockId);\n\n // If no activeVersionId, fall back to latest version config\n if (!promptBlock.activeVersionId && latestVersion) {\n currentConfig = extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n }\n const previousConfig = latestVersion\n ? extractConfigFromVersion(latestVersion as unknown as Record<string, unknown>, SNAPSHOT_CONFIG_FIELDS)\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, currentConfig);\n\n const { versionId } = await createVersionWithRetry(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n currentConfig,\n changedFields,\n { changeMessage },\n );\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n promptBlock.activeVersionId,\n );\n\n return version;\n } catch (error) {\n return handleError(error, 'Error creating prompt block version');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions/:versionId - Get a specific version\n */\nexport const GET_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: getPromptBlockVersionResponseSchema,\n summary: 'Get prompt block version',\n description: 'Returns a specific version of a prompt block by its version ID',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const version = await promptBlockStore.getVersion(versionId);\n\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n return version;\n } catch (error) {\n return handleError(error, 'Error getting prompt block version');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions/:versionId/activate - Set a version as active\n */\nexport const ACTIVATE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId/activate',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: activatePromptBlockVersionResponseSchema,\n summary: 'Activate prompt block version',\n description: 'Sets a specific version as the active version for the prompt block',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n await promptBlockStore.update({\n id: promptBlockId,\n activeVersionId: versionId,\n status: 'published',\n });\n\n // Clear the editor cache so subsequent requests see the new active version\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\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 prompt block version');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions/:versionId/restore - Restore prompt block to a version\n */\nexport const RESTORE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId/restore',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: restorePromptBlockVersionResponseSchema,\n summary: 'Restore prompt block version',\n description: 'Restores the prompt block configuration from a version, creating a new version',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const versionToRestore = await promptBlockStore.getVersion(versionId);\n if (!versionToRestore) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (versionToRestore.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const restoredConfig = extractConfigFromVersion(\n versionToRestore as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n\n await promptBlockStore.update({\n id: promptBlockId,\n ...restoredConfig,\n });\n\n const latestVersion = await promptBlockStore.getLatestVersion(promptBlockId);\n const previousConfig = latestVersion\n ? extractConfigFromVersion(latestVersion as unknown as Record<string, unknown>, SNAPSHOT_CONFIG_FIELDS)\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, restoredConfig);\n\n const { versionId: newVersionId } = await createVersionWithRetry(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n restoredConfig,\n changedFields,\n {\n changeMessage: `Restored from version ${versionToRestore.versionNumber}`,\n },\n );\n\n const newVersion = await promptBlockStore.getVersion(newVersionId);\n if (!newVersion) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n promptBlock.activeVersionId,\n );\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\n\n return newVersion;\n } catch (error) {\n return handleError(error, 'Error restoring prompt block version');\n }\n },\n});\n\n/**\n * DELETE /stored/prompt-blocks/:promptBlockId/versions/:versionId - Delete a version\n */\nexport const DELETE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: deletePromptBlockVersionResponseSchema,\n summary: 'Delete prompt block version',\n description: 'Deletes a specific version (cannot delete the active version)',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n if (promptBlock.activeVersionId === versionId) {\n throw new HTTPException(400, {\n message: 'Cannot delete the active version. Activate a different version first.',\n });\n }\n\n await promptBlockStore.deleteVersion(versionId);\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting prompt block version');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions/compare - Compare two versions\n */\nexport const COMPARE_PROMPT_BLOCK_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions/compare',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n queryParamSchema: comparePromptBlockVersionsQuerySchema,\n responseSchema: comparePromptBlockVersionsResponseSchema,\n summary: 'Compare prompt block versions',\n description: 'Compares two versions and returns the differences between them',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const fromVersion = await promptBlockStore.getVersion(from);\n if (!fromVersion) {\n throw new HTTPException(404, { message: `Version with id ${from} not found` });\n }\n if (fromVersion.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${from} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const toVersion = await promptBlockStore.getVersion(to);\n if (!toVersion) {\n throw new HTTPException(404, { message: `Version with id ${to} not found` });\n }\n if (toVersion.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${to} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const fromConfig = extractConfigFromVersion(\n fromVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n const toConfig = extractConfigFromVersion(\n toVersion as unknown as Record<string, unknown>,\n 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 prompt block versions');\n }\n },\n});\n"]}
1
+ {"version":3,"sources":["../src/server/handlers/prompt-block-versions.ts"],"names":["createRoute","promptBlockVersionPathParams","listPromptBlockVersionsQuerySchema","listPromptBlockVersionsResponseSchema","HTTPException","assertStoredResourceScope","getStoredResourceScope","handleError","createPromptBlockVersionBodySchema","createPromptBlockVersionResponseSchema","extractConfigFromVersion","calculateChangedFields","createVersionWithRetry","enforceRetentionLimit","promptBlockVersionIdPathParams","getPromptBlockVersionResponseSchema","activatePromptBlockVersionResponseSchema","restorePromptBlockVersionResponseSchema","deletePromptBlockVersionResponseSchema","comparePromptBlockVersionsQuerySchema","comparePromptBlockVersionsResponseSchema","computeVersionDiffs"],"mappings":";;;;;;;;;;AA4BA,IAAM,sB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import { HTTPException } from '../http-exception';\nimport {\n promptBlockVersionPathParams,\n promptBlockVersionIdPathParams,\n listPromptBlockVersionsQuerySchema,\n createPromptBlockVersionBodySchema,\n comparePromptBlockVersionsQuerySchema,\n listPromptBlockVersionsResponseSchema,\n getPromptBlockVersionResponseSchema,\n createPromptBlockVersionResponseSchema,\n activatePromptBlockVersionResponseSchema,\n restorePromptBlockVersionResponseSchema,\n deletePromptBlockVersionResponseSchema,\n comparePromptBlockVersionsResponseSchema,\n} from '../schemas/prompt-block-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} from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst SNAPSHOT_CONFIG_FIELDS = ['name', 'description', 'content', 'rules'] as const;\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions - List all versions for a prompt block\n */\nexport const LIST_PROMPT_BLOCK_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n queryParamSchema: listPromptBlockVersionsQuerySchema,\n responseSchema: listPromptBlockVersionsResponseSchema,\n summary: 'List prompt block versions',\n description: 'Returns a paginated list of all versions for a stored prompt block',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const result = await promptBlockStore.listVersions({\n blockId: promptBlockId,\n page,\n perPage,\n orderBy,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing prompt block versions');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions - Create a new version snapshot\n */\nexport const CREATE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n bodySchema: createPromptBlockVersionBodySchema,\n responseSchema: createPromptBlockVersionResponseSchema,\n summary: 'Create prompt block version',\n description: 'Creates a new version snapshot of the current prompt block configuration',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n let currentConfig: Record<string, unknown> = {};\n if (promptBlock.activeVersionId) {\n const activeVersion = await promptBlockStore.getVersion(promptBlock.activeVersionId);\n if (activeVersion) {\n currentConfig = extractConfigFromVersion(\n activeVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n }\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(promptBlockId);\n\n // If no activeVersionId, fall back to latest version config\n if (!promptBlock.activeVersionId && latestVersion) {\n currentConfig = extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n }\n const previousConfig = latestVersion\n ? extractConfigFromVersion(latestVersion as unknown as Record<string, unknown>, SNAPSHOT_CONFIG_FIELDS)\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, currentConfig);\n\n const { versionId } = await createVersionWithRetry(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n currentConfig,\n changedFields,\n { changeMessage },\n );\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n promptBlock.activeVersionId,\n );\n\n return version;\n } catch (error) {\n return handleError(error, 'Error creating prompt block version');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions/:versionId - Get a specific version\n */\nexport const GET_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: getPromptBlockVersionResponseSchema,\n summary: 'Get prompt block version',\n description: 'Returns a specific version of a prompt block by its version ID',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const version = await promptBlockStore.getVersion(versionId);\n\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n return version;\n } catch (error) {\n return handleError(error, 'Error getting prompt block version');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions/:versionId/activate - Set a version as active\n */\nexport const ACTIVATE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId/activate',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: activatePromptBlockVersionResponseSchema,\n summary: 'Activate prompt block version',\n description: 'Sets a specific version as the active version for the prompt block',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n await promptBlockStore.update({\n id: promptBlockId,\n activeVersionId: versionId,\n status: 'published',\n });\n\n // Clear the editor cache so subsequent requests see the new active version\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\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 prompt block version');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions/:versionId/restore - Restore prompt block to a version\n */\nexport const RESTORE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId/restore',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: restorePromptBlockVersionResponseSchema,\n summary: 'Restore prompt block version',\n description: 'Restores the prompt block configuration from a version, creating a new version',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const versionToRestore = await promptBlockStore.getVersion(versionId);\n if (!versionToRestore) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (versionToRestore.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const restoredConfig = extractConfigFromVersion(\n versionToRestore as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n\n await promptBlockStore.update({\n id: promptBlockId,\n ...restoredConfig,\n });\n\n const latestVersion = await promptBlockStore.getLatestVersion(promptBlockId);\n const previousConfig = latestVersion\n ? extractConfigFromVersion(latestVersion as unknown as Record<string, unknown>, SNAPSHOT_CONFIG_FIELDS)\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, restoredConfig);\n\n const { versionId: newVersionId } = await createVersionWithRetry(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n restoredConfig,\n changedFields,\n {\n changeMessage: `Restored from version ${versionToRestore.versionNumber}`,\n },\n );\n\n const newVersion = await promptBlockStore.getVersion(newVersionId);\n if (!newVersion) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n promptBlock.activeVersionId,\n );\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\n\n return newVersion;\n } catch (error) {\n return handleError(error, 'Error restoring prompt block version');\n }\n },\n});\n\n/**\n * DELETE /stored/prompt-blocks/:promptBlockId/versions/:versionId - Delete a version\n */\nexport const DELETE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: deletePromptBlockVersionResponseSchema,\n summary: 'Delete prompt block version',\n description: 'Deletes a specific version (cannot delete the active version)',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n if (promptBlock.activeVersionId === versionId) {\n throw new HTTPException(400, {\n message: 'Cannot delete the active version. Activate a different version first.',\n });\n }\n\n await promptBlockStore.deleteVersion(versionId);\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting prompt block version');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions/compare - Compare two versions\n */\nexport const COMPARE_PROMPT_BLOCK_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions/compare',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n queryParamSchema: comparePromptBlockVersionsQuerySchema,\n responseSchema: comparePromptBlockVersionsResponseSchema,\n summary: 'Compare prompt block versions',\n description: 'Compares two versions and returns the differences between them',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, 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 promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n const fromVersion = await promptBlockStore.getVersion(from);\n if (!fromVersion) {\n throw new HTTPException(404, { message: `Version with id ${from} not found` });\n }\n if (fromVersion.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${from} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const toVersion = await promptBlockStore.getVersion(to);\n if (!toVersion) {\n throw new HTTPException(404, { message: `Version with id ${to} not found` });\n }\n if (toVersion.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${to} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const fromConfig = extractConfigFromVersion(\n fromVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n const toConfig = extractConfigFromVersion(\n toVersion as unknown as Record<string, unknown>,\n 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 prompt block versions');\n }\n },\n});\n"]}
@@ -1,8 +1,8 @@
1
+ import { stripFavoriteFields, prepareFavoritesEnrichment, enrichOrStripFavorites } from './chunk-T2GYY7P5.js';
2
+ import { isBuilderFeatureEnabled } from './chunk-TQ5KIKVK.js';
3
+ import { resolveAuthorFilter, getCallerAuthorId, matchesAuthorFilter, assertReadAccess, assertWriteAccess } from './chunk-3TTDIOEU.js';
1
4
  import { listStoredSkillsResponseSchema, listStoredSkillsQuerySchema, getStoredSkillResponseSchema, storedSkillIdPathParams, createStoredSkillResponseSchema, createStoredSkillBodySchema, updateStoredSkillResponseSchema, updateStoredSkillBodySchema, deleteStoredSkillResponseSchema, publishStoredSkillResponseSchema, publishStoredSkillBodySchema } from './chunk-FBI32AWY.js';
2
- import { stripFavoriteFields, prepareFavoritesEnrichment, enrichOrStripFavorites } from './chunk-YYJ2TLFP.js';
3
- import { isBuilderFeatureEnabled } from './chunk-HPMLQ4AV.js';
4
- import { resolveAuthorFilter, getCallerAuthorId, matchesAuthorFilter, assertReadAccess, assertWriteAccess } from './chunk-ETR4XOVD.js';
5
- import { getStoredResourceScope, scopeStoredResourceMetadata, assertStoredResourceScope, toSlug } from './chunk-4GWTCVFL.js';
5
+ import { getStoredResourceScope, scopeStoredResourceMetadata, assertStoredResourceScope, toSlug } from './chunk-RCRKB2TG.js';
6
6
  import { handleError } from './chunk-7ZWJX3AN.js';
7
7
  import { createRoute } from './chunk-H5LXHGEJ.js';
8
8
  import { HTTPException } from './chunk-6QWQZI4Q.js';
@@ -489,5 +489,5 @@ var PUBLISH_STORED_SKILL_ROUTE = createRoute({
489
489
  });
490
490
 
491
491
  export { CREATE_STORED_SKILL_ROUTE, DELETE_STORED_SKILL_ROUTE, GET_STORED_SKILL_ROUTE, LIST_STORED_SKILLS_ROUTE, PUBLISH_STORED_SKILL_ROUTE, UPDATE_STORED_SKILL_ROUTE };
492
- //# sourceMappingURL=chunk-SQSAIKSL.js.map
493
- //# sourceMappingURL=chunk-SQSAIKSL.js.map
492
+ //# sourceMappingURL=chunk-FP6SUEJ5.js.map
493
+ //# sourceMappingURL=chunk-FP6SUEJ5.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/handlers/stored-skills.ts"],"names":["annotated"],"mappings":";;;;;;;;;;AAuCA,IAAM,eAAA,GAAkB,CAAC,YAAA,EAAc,SAAA,EAAW,QAAQ,CAAA;AAQ1D,SAAS,4BAAA,CACP,OACA,QAAA,EASA;AACA,EAAA,IAAI,CAAC,KAAA,IAAS,KAAA,CAAM,MAAA,KAAW,CAAA,SAAU,EAAC;AAG1C,EAAA,MAAM,OAAO,KAAA,CAAM,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,SAAS,QAAQ,CAAA;AAChD,EAAA,IAAI,CAAC,IAAA,EAAM,QAAA,EAAU,OAAO,EAAC;AAE7B,EAAA,MAAM,SAAmC,EAAC;AAE1C,EAAA,KAAA,MAAW,cAAc,eAAA,EAAiB;AACxC,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,CAAA,CAAA,KAAK,EAAE,IAAA,KAAS,QAAA,IAAY,CAAA,CAAE,IAAA,KAAS,UAAU,CAAA;AACnF,IAAA,IAAI,CAAC,MAAA,EAAQ,QAAA,IAAY,MAAA,CAAO,QAAA,CAAS,WAAW,CAAA,EAAG;AAEvD,IAAA,MAAM,gBAAgB,IAAI,GAAA,CAAI,SAAS,UAAU,CAAA,IAAK,EAAE,CAAA;AACxD,IAAA,MAAM,KAAA,GAAkB,CAAC,GAAG,aAAa,CAAA;AAEzC,IAAA,gBAAA,CAAiB,MAAA,CAAO,QAAA,EAAU,UAAA,EAAY,aAAA,EAAe,KAAK,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,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,yCAAyC,CAAA;AAAA,MACnF;AAEA,MAAA,OAAO,sBAAA,CAAuB,MAAA,EAAQ,cAAA,EAAgB,OAAA,EAAS,QAAQ,CAAA;AAAA,IACzE,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,+BAA+B,CAAA;AAAA,IAC3D;AAAA,EACF;AACF,CAAC","file":"chunk-SQSAIKSL.js","sourcesContent":["import type { StorageSkillFileNode } from '@mastra/core/storage';\nimport { LocalSkillSource } from '@mastra/core/workspace';\n\nimport { HTTPException } from '../http-exception';\nimport {\n storedSkillIdPathParams,\n listStoredSkillsQuerySchema,\n createStoredSkillBodySchema,\n updateStoredSkillBodySchema,\n publishStoredSkillBodySchema,\n listStoredSkillsResponseSchema,\n getStoredSkillResponseSchema,\n createStoredSkillResponseSchema,\n updateStoredSkillResponseSchema,\n deleteStoredSkillResponseSchema,\n publishStoredSkillResponseSchema,\n} from '../schemas/stored-skills';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug, assertStoredResourceScope, getStoredResourceScope, scopeStoredResourceMetadata } from '../utils';\n\nimport {\n assertReadAccess,\n assertWriteAccess,\n getCallerAuthorId,\n matchesAuthorFilter,\n resolveAuthorFilter,\n} from './authorship';\nimport { isBuilderFeatureEnabled } from './editor-builder';\nimport { handleError } from './error';\nimport { enrichOrStripFavorites, prepareFavoritesEnrichment, stripFavoriteFields } from './favorites-enrichment';\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Well-known folder names in the skill file tree whose children represent\n * indexable path arrays (references, scripts, assets).\n */\nconst INDEXED_FOLDERS = ['references', 'scripts', 'assets'] as const;\n\n/**\n * Walks the `files` tree and collects relative file paths for each well-known\n * folder (references, scripts, assets). Returned arrays only include entries\n * that are not already present in any explicitly-provided arrays so callers\n * can pass both `files` and `references` without creating duplicates.\n */\nfunction extractIndexedPathsFromFiles(\n files: StorageSkillFileNode[] | undefined,\n existing: {\n references?: string[];\n scripts?: string[];\n assets?: string[];\n },\n): {\n references?: string[];\n scripts?: string[];\n assets?: string[];\n} {\n if (!files || files.length === 0) return {};\n\n // Find the root folder (first folder node, usually id=\"root\")\n const root = files.find(n => n.type === 'folder');\n if (!root?.children) return {};\n\n const result: Record<string, string[]> = {};\n\n for (const folderName of INDEXED_FOLDERS) {\n const folder = root.children.find(n => n.type === 'folder' && n.name === folderName);\n if (!folder?.children || folder.children.length === 0) continue;\n\n const existingPaths = new Set(existing[folderName] ?? []);\n const paths: string[] = [...existingPaths];\n\n collectFilePaths(folder.children, folderName, existingPaths, paths);\n\n if (paths.length > 0) {\n result[folderName] = paths;\n }\n }\n\n return result;\n}\n\n/** Recursively collects file paths from a subtree, building relative paths. */\nfunction collectFilePaths(\n nodes: StorageSkillFileNode[],\n prefix: string,\n existingPaths: Set<string>,\n out: string[],\n): void {\n for (const node of nodes) {\n if (node.type === 'file') {\n const relativePath = `${prefix}/${node.name}`;\n if (!existingPaths.has(relativePath)) {\n out.push(relativePath);\n }\n } else if (node.type === 'folder' && node.children) {\n collectFilePaths(node.children, `${prefix}/${node.name}`, existingPaths, out);\n }\n }\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/skills - List all stored skills\n */\nexport const LIST_STORED_SKILLS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/skills',\n responseType: 'json',\n queryParamSchema: listStoredSkillsQuerySchema,\n responseSchema: listStoredSkillsResponseSchema,\n summary: 'List stored skills',\n description: 'Returns a paginated list of all skill configurations stored in the database',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n page,\n perPage,\n orderBy,\n status,\n authorId,\n visibility,\n metadata,\n favoritedOnly,\n pinFavoritedFor,\n }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n const filter = resolveAuthorFilter({\n requestContext,\n resource: 'stored-skills',\n queryAuthorId: authorId,\n queryVisibility: visibility,\n });\n\n const scope = await getStoredResourceScope(mastra, requestContext);\n const scopedMetadata = scopeStoredResourceMetadata(metadata, scope);\n\n const callerId = getCallerAuthorId(requestContext);\n const favoritesEnabled = await isBuilderFeatureEnabled(mastra, 'favorites');\n const honoredStarredOnly = favoritesEnabled && favoritedOnly === true;\n const favoriteSubjectId = pinFavoritedFor ?? callerId;\n\n // `?favoritedOnly=true` flow: fetch caller's favorited IDs, restrict the list\n // to that set, then post-filter by visibility and recompute total/pages.\n if (honoredStarredOnly) {\n const effectivePerPage: number = perPage ?? 100;\n if (!favoriteSubjectId) {\n // Caller cannot have favorited anything without an identity.\n return { skills: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) {\n throw new HTTPException(500, { message: 'Favorites storage domain is not available' });\n }\n const starredIds = await favoritesStore.listFavoritedIds({ userId: favoriteSubjectId, entityType: 'skill' });\n if (starredIds.length === 0) {\n return { skills: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const allMatching = await skillStore.listResolved({\n perPage: false,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n entityIds: starredIds,\n });\n const visible = allMatching.skills.filter(record => matchesAuthorFilter(record, filter));\n const total = visible.length;\n const startIdx = effectivePerPage === 0 ? 0 : page * effectivePerPage;\n const endIdx = effectivePerPage === 0 ? 0 : startIdx + effectivePerPage;\n const sliced = effectivePerPage === 0 ? [] : visible.slice(startIdx, endIdx);\n const annotated = sliced.map(record => ({ ...record, isFavorited: true }));\n const hasMore = effectivePerPage > 0 && endIdx < total;\n return {\n skills: annotated,\n total,\n page,\n perPage: effectivePerPage,\n hasMore,\n };\n }\n\n const result = await skillStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n });\n\n // Post-filter to enforce ownership + visibility rules across all backends.\n // Storage adapters can only do an equality filter on authorId, so we apply\n // the ownedOrPublic / publicOnly logic here.\n // Note: `result.total` / `result.hasMore` reflect the storage-reported\n // count before this post-filter. For `unrestricted` / `exact` filters\n // nothing is removed; for `ownedOrPublic` / `publicOnly`, downstream UIs\n // should treat the filter as a view over the caller's scope — an\n // approximation is OK and preserves pagination math.\n const visibleSkills = result.skills.filter(record => matchesAuthorFilter(record, filter));\n\n if (!favoritesEnabled) {\n return { ...result, skills: visibleSkills.map(stripFavoriteFields) };\n }\n\n const enrichment = await prepareFavoritesEnrichment(\n mastra,\n requestContext,\n 'skill',\n visibleSkills.map(s => s.id),\n );\n const annotated = enrichment\n ? visibleSkills.map(record => ({ ...record, isFavorited: enrichment.starredIds.has(record.id) }))\n : visibleSkills.map(stripFavoriteFields);\n\n return { ...result, skills: annotated };\n } catch (error) {\n return handleError(error, 'Error listing stored skills');\n }\n },\n});\n\n/**\n * GET /stored/skills/:storedSkillId - Get a stored skill by ID\n */\nexport const GET_STORED_SKILL_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/skills/:storedSkillId',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: getStoredSkillResponseSchema,\n summary: 'Get stored skill by ID',\n description: 'Returns a specific skill from storage by its unique identifier (resolved with active version config)',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedSkillId }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n const skill = await skillStore.getByIdResolved(storedSkillId);\n\n if (!skill) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(skill, await getStoredResourceScope(mastra, requestContext));\n\n assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', skill);\n } catch (error) {\n return handleError(error, 'Error getting stored skill');\n }\n },\n});\n\n/**\n * POST /stored/skills - Create a new stored skill\n */\nexport const CREATE_STORED_SKILL_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/skills',\n responseType: 'json',\n bodySchema: createStoredSkillBodySchema,\n responseSchema: createStoredSkillResponseSchema,\n summary: 'Create stored skill',\n description: 'Creates a new skill configuration in storage with the provided details',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n id: providedId,\n name,\n description,\n instructions,\n license,\n compatibility,\n source,\n references,\n scripts,\n assets,\n files,\n metadata,\n visibility: bodyVisibility,\n }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive skill ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if skill with this ID already exists\n const existing = await skillStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Skill with id ${id} already exists` });\n }\n\n // Force authorId from the authenticated caller; ignore any body-provided value.\n // No owner = always public (no auth / no user context).\n // With an owner, respect the client's choice, defaulting to 'private'.\n const authorId = getCallerAuthorId(requestContext) ?? undefined;\n const visibility: 'private' | 'public' = authorId ? (bodyVisibility ?? 'private') : 'public';\n\n // Derive references/scripts/assets path arrays from the files tree\n // so agents can discover them via skill_read even when only `files` is provided.\n const indexedPaths = extractIndexedPathsFromFiles(files, { references, scripts, assets });\n\n await skillStore.create({\n skill: {\n id,\n authorId,\n visibility,\n name,\n description,\n instructions,\n license,\n compatibility,\n source,\n references: indexedPaths.references ?? references,\n scripts: indexedPaths.scripts ?? scripts,\n assets: indexedPaths.assets ?? assets,\n files,\n metadata: scopeStoredResourceMetadata(metadata, await getStoredResourceScope(mastra, requestContext)),\n },\n });\n\n // Return the resolved skill (thin record + version config)\n const resolved = await skillStore.getByIdResolved(id);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created skill' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n } catch (error) {\n return handleError(error, 'Error creating stored skill');\n }\n },\n});\n\n/**\n * PATCH /stored/skills/:storedSkillId - Update a stored skill\n */\nexport const UPDATE_STORED_SKILL_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/skills/:storedSkillId',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n bodySchema: updateStoredSkillBodySchema,\n responseSchema: updateStoredSkillResponseSchema,\n summary: 'Update stored skill',\n description: 'Updates an existing skill in storage with the provided fields',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n storedSkillId,\n // Entity-level fields\n authorId,\n visibility,\n // Config fields (snapshot-level)\n name,\n description,\n instructions,\n license,\n compatibility,\n source,\n references,\n scripts,\n assets,\n files,\n metadata,\n }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n // Check if skill exists. Skill metadata lives on the resolved snapshot.\n const existing = await skillStore.getByIdResolved(storedSkillId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n const scope = await getStoredResourceScope(mastra, requestContext);\n assertStoredResourceScope(existing, scope);\n\n // Throws 404 if the caller isn't the owner, admin, or `stored-skills:write[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-skills',\n resourceId: storedSkillId,\n action: 'edit',\n record: existing,\n });\n\n // No owner = always public, regardless of what the client sent.\n const callerAuthorId = getCallerAuthorId(requestContext) ?? undefined;\n const resolvedVisibility = callerAuthorId ? visibility : visibility != null ? 'public' : undefined;\n\n // Derive references/scripts/assets path arrays from the files tree\n const indexedPaths = files ? extractIndexedPathsFromFiles(files, { references, scripts, assets }) : {};\n\n // Update the skill with both entity-level and config-level fields.\n // The storage layer handles separating these into record updates vs\n // new-version creation, but it uses `field in updates` to detect config\n // changes — so we must only include fields the caller actually sent.\n // Forwarding `undefined` keys would trigger a spurious version create\n // and pass `undefined` into the database driver.\n const update: Record<string, unknown> = { id: storedSkillId };\n if (authorId !== undefined) update.authorId = authorId;\n if (resolvedVisibility !== undefined) update.visibility = resolvedVisibility;\n if (name !== undefined) update.name = name;\n if (description !== undefined) update.description = description;\n if (instructions !== undefined) update.instructions = instructions;\n if (license !== undefined) update.license = license;\n if (compatibility !== undefined) update.compatibility = compatibility;\n if (source !== undefined) update.source = source;\n const resolvedReferences = indexedPaths.references ?? references;\n const resolvedScripts = indexedPaths.scripts ?? scripts;\n const resolvedAssets = indexedPaths.assets ?? assets;\n if (resolvedReferences !== undefined) update.references = resolvedReferences;\n if (resolvedScripts !== undefined) update.scripts = resolvedScripts;\n if (resolvedAssets !== undefined) update.assets = resolvedAssets;\n if (files !== undefined) update.files = files;\n if (metadata !== undefined) {\n update.metadata = scopeStoredResourceMetadata({ ...(existing.metadata ?? {}), ...metadata }, scope);\n }\n\n await skillStore.update(update as Parameters<typeof skillStore.update>[0]);\n\n // Return the resolved skill with the updated config\n const resolved = await skillStore.getByIdResolved(storedSkillId);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated skill' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n } catch (error) {\n return handleError(error, 'Error updating stored skill');\n }\n },\n});\n\n/**\n * DELETE /stored/skills/:storedSkillId - Delete a stored skill\n */\nexport const DELETE_STORED_SKILL_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/skills/:storedSkillId',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: deleteStoredSkillResponseSchema,\n summary: 'Delete stored skill',\n description: 'Deletes a skill from storage by its unique identifier',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedSkillId }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n // Check if skill exists. Skill metadata lives on the resolved snapshot.\n const existing = await skillStore.getByIdResolved(storedSkillId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(existing, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, or `skills:delete[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-skills',\n resourceId: storedSkillId,\n action: 'delete',\n record: existing,\n });\n\n await skillStore.delete(storedSkillId);\n\n // Cascade: drop any favorite rows referencing this skill. Failure must not\n // abort the delete.\n try {\n const favoritesStore = await storage.getStore('favorites');\n await favoritesStore?.deleteFavoritesForEntity({ entityType: 'skill', entityId: storedSkillId });\n } catch (cascadeError) {\n mastra\n .getLogger?.()\n ?.warn?.('Failed to cascade-delete favorites for skill', { storedSkillId, error: cascadeError });\n }\n\n return {\n success: true,\n message: `Skill ${storedSkillId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored skill');\n }\n },\n});\n\n/**\n * POST /stored/skills/:storedSkillId/publish - Publish a skill from filesystem\n * Walks the skill directory, hashes files into blob store, creates a new version\n * with the tree manifest, and sets activeVersionId.\n */\nexport const PUBLISH_STORED_SKILL_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/skills/:storedSkillId/publish',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n bodySchema: publishStoredSkillBodySchema,\n responseSchema: publishStoredSkillResponseSchema,\n summary: 'Publish stored skill',\n description:\n 'Snapshots the skill directory from the filesystem into content-addressable blob storage, creates a new version with a tree manifest, and marks the skill as published',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedSkillId, skillPath }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n const blobStore = await storage.getStore('blobs');\n if (!blobStore) {\n throw new HTTPException(500, { message: 'Blob storage domain is not available' });\n }\n\n // Verify skill exists. Skill metadata lives on the resolved snapshot.\n const existing = await skillStore.getByIdResolved(storedSkillId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(existing, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, or `stored-skills:write[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-skills',\n resourceId: storedSkillId,\n action: 'edit',\n record: existing,\n });\n\n // Validate skillPath to prevent path traversal\n const path = await import('node:path');\n const fs = await import('node:fs/promises');\n const resolvedPath = path.default.resolve(skillPath);\n const allowedBase = path.default.resolve(process.env.SKILLS_BASE_DIR || process.cwd());\n if (!resolvedPath.startsWith(allowedBase + path.default.sep) && resolvedPath !== allowedBase) {\n throw new HTTPException(400, {\n message: `skillPath must be within the allowed directory: ${allowedBase}`,\n });\n }\n\n // Verify the source directory exists and contains a SKILL.md before attempting\n // to publish, so callers get a 400 with context instead of a raw 500/ENOENT.\n try {\n const stat = await fs.stat(resolvedPath);\n if (!stat.isDirectory()) {\n throw new HTTPException(400, { message: `skillPath is not a directory: ${resolvedPath}` });\n }\n } catch (err) {\n if (err instanceof HTTPException) throw err;\n if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') {\n throw new HTTPException(400, {\n message: `skillPath does not exist on the server filesystem: ${resolvedPath}. Create the skill directory (with a SKILL.md) before publishing, or use a skill that was materialized to disk.`,\n });\n }\n throw err;\n }\n try {\n await fs.stat(path.default.join(resolvedPath, 'SKILL.md'));\n } catch (err) {\n if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') {\n throw new HTTPException(400, {\n message: `skillPath is missing SKILL.md: ${resolvedPath}`,\n });\n }\n throw err;\n }\n\n // Use LocalSkillSource to read from the server filesystem\n const source = new LocalSkillSource();\n const { publishSkillFromSource } = await import('@mastra/core/workspace');\n\n const { snapshot, tree, files } = await publishSkillFromSource(source, resolvedPath, blobStore);\n\n // Strip undefined keys from the snapshot before passing to update(). The\n // storage layer treats \"field present\" as \"field changed\"; forwarding\n // undefined would overwrite populated columns with undefined and trip\n // NOT NULL / \"undefined cannot be passed as argument\" errors in\n // adapters that bind args raw (libsql, pg).\n const snapshotUpdate: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(snapshot)) {\n if (value !== undefined) snapshotUpdate[key] = value;\n }\n\n // Update the skill with new version data + tree + UI-facing file tree.\n // `files` is the nested folder/file structure shown in the editor; without\n // it the column would stay null and the UI would render an empty tree.\n await skillStore.update({\n id: storedSkillId,\n ...snapshotUpdate,\n tree,\n files,\n status: 'published',\n });\n\n // Point activeVersionId to the newly created version\n const latestVersion = await skillStore.getLatestVersion(storedSkillId);\n if (latestVersion) {\n await skillStore.update({\n id: storedSkillId,\n activeVersionId: latestVersion.id,\n });\n }\n\n const resolved = await skillStore.getByIdResolved(storedSkillId);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve skill after publish' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n } catch (error) {\n return handleError(error, 'Error publishing stored skill');\n }\n },\n});\n"]}
1
+ {"version":3,"sources":["../src/server/handlers/stored-skills.ts"],"names":["annotated"],"mappings":";;;;;;;;;;AAuCA,IAAM,eAAA,GAAkB,CAAC,YAAA,EA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ExE,MAAA,MAAM,EAAE,UAAU,IAAA,EAAM,KAAA,KAAU,MAAM,sBAAA,CAAuB,MAAA,EAAQ,YAAA,EAAc,SAAS,CAAA;AAO9F,MAAA,MAAM,iBAA0C,EAAC;AACjD,MAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,EAAG;AACnD,QAAA,IAAI,KAAA,KAAU,MAAA,EAAW,cAAA,CAAe,GAAG,CAAA,GAAI,KAAA;AAAA,MACjD;AAKA,MAAA,MAAM,WAAW,MAAA,CAAO;AAAA,QACtB,EAAA,EAAI,aAAA;AAAA,QACJ,GAAG,cAAA;AAAA,QACH,IAAA;AAAA,QACA,KAAA;AAAA,QACA,MAAA,EAAQ;AAAA,OACT,CAAA;AAGD,MAAA,MAAM,aAAA,GAAgB,MAAM,UAAA,CAAW,gBAAA,CAAiB,aAAa,CAAA;AACrE,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,MAAM,WAAW,MAAA,CAAO;AAAA,UACtB,EAAA,EAAI,aAAA;AAAA,UACJ,iBAAiB,aAAA,CAAc;AAAA,SAChC,CAAA;AAAA,MACH;AAEA,MAAA,MAAM,QAAA,GAAW,MAAM,UAAA,CAAW,eAAA,CAAgB,aAAa,CAAA;AAC/D,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,yCAAyC,CAAA;AAAA,MACnF;AAEA,MAAA,OAAO,sBAAA,CAAuB,MAAA,EAAQ,cAAA,EAAgB,OAAA,EAAS,QAAQ,CAAA;AAAA,IACzE,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,+BAA+B,CAAA;AAAA,IAC3D;AAAA,EACF;AACF,CAAC","file":"chunk-FP6SUEJ5.js","sourcesContent":["import type { StorageSkillFileNode } from '@mastra/core/storage';\nimport { LocalSkillSource } from '@mastra/core/workspace';\n\nimport { HTTPException } from '../http-exception';\nimport {\n storedSkillIdPathParams,\n listStoredSkillsQuerySchema,\n createStoredSkillBodySchema,\n updateStoredSkillBodySchema,\n publishStoredSkillBodySchema,\n listStoredSkillsResponseSchema,\n getStoredSkillResponseSchema,\n createStoredSkillResponseSchema,\n updateStoredSkillResponseSchema,\n deleteStoredSkillResponseSchema,\n publishStoredSkillResponseSchema,\n} from '../schemas/stored-skills';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug, assertStoredResourceScope, getStoredResourceScope, scopeStoredResourceMetadata } from '../utils';\n\nimport {\n assertReadAccess,\n assertWriteAccess,\n getCallerAuthorId,\n matchesAuthorFilter,\n resolveAuthorFilter,\n} from './authorship';\nimport { isBuilderFeatureEnabled } from './editor-builder';\nimport { handleError } from './error';\nimport { enrichOrStripFavorites, prepareFavoritesEnrichment, stripFavoriteFields } from './favorites-enrichment';\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Well-known folder names in the skill file tree whose children represent\n * indexable path arrays (references, scripts, assets).\n */\nconst INDEXED_FOLDERS = ['references', 'scripts', 'assets'] as const;\n\n/**\n * Walks the `files` tree and collects relative file paths for each well-known\n * folder (references, scripts, assets). Returned arrays only include entries\n * that are not already present in any explicitly-provided arrays so callers\n * can pass both `files` and `references` without creating duplicates.\n */\nfunction extractIndexedPathsFromFiles(\n files: StorageSkillFileNode[] | undefined,\n existing: {\n references?: string[];\n scripts?: string[];\n assets?: string[];\n },\n): {\n references?: string[];\n scripts?: string[];\n assets?: string[];\n} {\n if (!files || files.length === 0) return {};\n\n // Find the root folder (first folder node, usually id=\"root\")\n const root = files.find(n => n.type === 'folder');\n if (!root?.children) return {};\n\n const result: Record<string, string[]> = {};\n\n for (const folderName of INDEXED_FOLDERS) {\n const folder = root.children.find(n => n.type === 'folder' && n.name === folderName);\n if (!folder?.children || folder.children.length === 0) continue;\n\n const existingPaths = new Set(existing[folderName] ?? []);\n const paths: string[] = [...existingPaths];\n\n collectFilePaths(folder.children, folderName, existingPaths, paths);\n\n if (paths.length > 0) {\n result[folderName] = paths;\n }\n }\n\n return result;\n}\n\n/** Recursively collects file paths from a subtree, building relative paths. */\nfunction collectFilePaths(\n nodes: StorageSkillFileNode[],\n prefix: string,\n existingPaths: Set<string>,\n out: string[],\n): void {\n for (const node of nodes) {\n if (node.type === 'file') {\n const relativePath = `${prefix}/${node.name}`;\n if (!existingPaths.has(relativePath)) {\n out.push(relativePath);\n }\n } else if (node.type === 'folder' && node.children) {\n collectFilePaths(node.children, `${prefix}/${node.name}`, existingPaths, out);\n }\n }\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/skills - List all stored skills\n */\nexport const LIST_STORED_SKILLS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/skills',\n responseType: 'json',\n queryParamSchema: listStoredSkillsQuerySchema,\n responseSchema: listStoredSkillsResponseSchema,\n summary: 'List stored skills',\n description: 'Returns a paginated list of all skill configurations stored in the database',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n page,\n perPage,\n orderBy,\n status,\n authorId,\n visibility,\n metadata,\n favoritedOnly,\n pinFavoritedFor,\n }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n const filter = resolveAuthorFilter({\n requestContext,\n resource: 'stored-skills',\n queryAuthorId: authorId,\n queryVisibility: visibility,\n });\n\n const scope = await getStoredResourceScope(mastra, requestContext);\n const scopedMetadata = scopeStoredResourceMetadata(metadata, scope);\n\n const callerId = getCallerAuthorId(requestContext);\n const favoritesEnabled = await isBuilderFeatureEnabled(mastra, 'favorites');\n const honoredStarredOnly = favoritesEnabled && favoritedOnly === true;\n const favoriteSubjectId = pinFavoritedFor ?? callerId;\n\n // `?favoritedOnly=true` flow: fetch caller's favorited IDs, restrict the list\n // to that set, then post-filter by visibility and recompute total/pages.\n if (honoredStarredOnly) {\n const effectivePerPage: number = perPage ?? 100;\n if (!favoriteSubjectId) {\n // Caller cannot have favorited anything without an identity.\n return { skills: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) {\n throw new HTTPException(500, { message: 'Favorites storage domain is not available' });\n }\n const starredIds = await favoritesStore.listFavoritedIds({ userId: favoriteSubjectId, entityType: 'skill' });\n if (starredIds.length === 0) {\n return { skills: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const allMatching = await skillStore.listResolved({\n perPage: false,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n entityIds: starredIds,\n });\n const visible = allMatching.skills.filter(record => matchesAuthorFilter(record, filter));\n const total = visible.length;\n const startIdx = effectivePerPage === 0 ? 0 : page * effectivePerPage;\n const endIdx = effectivePerPage === 0 ? 0 : startIdx + effectivePerPage;\n const sliced = effectivePerPage === 0 ? [] : visible.slice(startIdx, endIdx);\n const annotated = sliced.map(record => ({ ...record, isFavorited: true }));\n const hasMore = effectivePerPage > 0 && endIdx < total;\n return {\n skills: annotated,\n total,\n page,\n perPage: effectivePerPage,\n hasMore,\n };\n }\n\n const result = await skillStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n });\n\n // Post-filter to enforce ownership + visibility rules across all backends.\n // Storage adapters can only do an equality filter on authorId, so we apply\n // the ownedOrPublic / publicOnly logic here.\n // Note: `result.total` / `result.hasMore` reflect the storage-reported\n // count before this post-filter. For `unrestricted` / `exact` filters\n // nothing is removed; for `ownedOrPublic` / `publicOnly`, downstream UIs\n // should treat the filter as a view over the caller's scope — an\n // approximation is OK and preserves pagination math.\n const visibleSkills = result.skills.filter(record => matchesAuthorFilter(record, filter));\n\n if (!favoritesEnabled) {\n return { ...result, skills: visibleSkills.map(stripFavoriteFields) };\n }\n\n const enrichment = await prepareFavoritesEnrichment(\n mastra,\n requestContext,\n 'skill',\n visibleSkills.map(s => s.id),\n );\n const annotated = enrichment\n ? visibleSkills.map(record => ({ ...record, isFavorited: enrichment.starredIds.has(record.id) }))\n : visibleSkills.map(stripFavoriteFields);\n\n return { ...result, skills: annotated };\n } catch (error) {\n return handleError(error, 'Error listing stored skills');\n }\n },\n});\n\n/**\n * GET /stored/skills/:storedSkillId - Get a stored skill by ID\n */\nexport const GET_STORED_SKILL_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/skills/:storedSkillId',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: getStoredSkillResponseSchema,\n summary: 'Get stored skill by ID',\n description: 'Returns a specific skill from storage by its unique identifier (resolved with active version config)',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedSkillId }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n const skill = await skillStore.getByIdResolved(storedSkillId);\n\n if (!skill) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(skill, await getStoredResourceScope(mastra, requestContext));\n\n assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', skill);\n } catch (error) {\n return handleError(error, 'Error getting stored skill');\n }\n },\n});\n\n/**\n * POST /stored/skills - Create a new stored skill\n */\nexport const CREATE_STORED_SKILL_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/skills',\n responseType: 'json',\n bodySchema: createStoredSkillBodySchema,\n responseSchema: createStoredSkillResponseSchema,\n summary: 'Create stored skill',\n description: 'Creates a new skill configuration in storage with the provided details',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n id: providedId,\n name,\n description,\n instructions,\n license,\n compatibility,\n source,\n references,\n scripts,\n assets,\n files,\n metadata,\n visibility: bodyVisibility,\n }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive skill ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if skill with this ID already exists\n const existing = await skillStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Skill with id ${id} already exists` });\n }\n\n // Force authorId from the authenticated caller; ignore any body-provided value.\n // No owner = always public (no auth / no user context).\n // With an owner, respect the client's choice, defaulting to 'private'.\n const authorId = getCallerAuthorId(requestContext) ?? undefined;\n const visibility: 'private' | 'public' = authorId ? (bodyVisibility ?? 'private') : 'public';\n\n // Derive references/scripts/assets path arrays from the files tree\n // so agents can discover them via skill_read even when only `files` is provided.\n const indexedPaths = extractIndexedPathsFromFiles(files, { references, scripts, assets });\n\n await skillStore.create({\n skill: {\n id,\n authorId,\n visibility,\n name,\n description,\n instructions,\n license,\n compatibility,\n source,\n references: indexedPaths.references ?? references,\n scripts: indexedPaths.scripts ?? scripts,\n assets: indexedPaths.assets ?? assets,\n files,\n metadata: scopeStoredResourceMetadata(metadata, await getStoredResourceScope(mastra, requestContext)),\n },\n });\n\n // Return the resolved skill (thin record + version config)\n const resolved = await skillStore.getByIdResolved(id);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created skill' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n } catch (error) {\n return handleError(error, 'Error creating stored skill');\n }\n },\n});\n\n/**\n * PATCH /stored/skills/:storedSkillId - Update a stored skill\n */\nexport const UPDATE_STORED_SKILL_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/skills/:storedSkillId',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n bodySchema: updateStoredSkillBodySchema,\n responseSchema: updateStoredSkillResponseSchema,\n summary: 'Update stored skill',\n description: 'Updates an existing skill in storage with the provided fields',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n storedSkillId,\n // Entity-level fields\n authorId,\n visibility,\n // Config fields (snapshot-level)\n name,\n description,\n instructions,\n license,\n compatibility,\n source,\n references,\n scripts,\n assets,\n files,\n metadata,\n }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n // Check if skill exists. Skill metadata lives on the resolved snapshot.\n const existing = await skillStore.getByIdResolved(storedSkillId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n const scope = await getStoredResourceScope(mastra, requestContext);\n assertStoredResourceScope(existing, scope);\n\n // Throws 404 if the caller isn't the owner, admin, or `stored-skills:write[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-skills',\n resourceId: storedSkillId,\n action: 'edit',\n record: existing,\n });\n\n // No owner = always public, regardless of what the client sent.\n const callerAuthorId = getCallerAuthorId(requestContext) ?? undefined;\n const resolvedVisibility = callerAuthorId ? visibility : visibility != null ? 'public' : undefined;\n\n // Derive references/scripts/assets path arrays from the files tree\n const indexedPaths = files ? extractIndexedPathsFromFiles(files, { references, scripts, assets }) : {};\n\n // Update the skill with both entity-level and config-level fields.\n // The storage layer handles separating these into record updates vs\n // new-version creation, but it uses `field in updates` to detect config\n // changes — so we must only include fields the caller actually sent.\n // Forwarding `undefined` keys would trigger a spurious version create\n // and pass `undefined` into the database driver.\n const update: Record<string, unknown> = { id: storedSkillId };\n if (authorId !== undefined) update.authorId = authorId;\n if (resolvedVisibility !== undefined) update.visibility = resolvedVisibility;\n if (name !== undefined) update.name = name;\n if (description !== undefined) update.description = description;\n if (instructions !== undefined) update.instructions = instructions;\n if (license !== undefined) update.license = license;\n if (compatibility !== undefined) update.compatibility = compatibility;\n if (source !== undefined) update.source = source;\n const resolvedReferences = indexedPaths.references ?? references;\n const resolvedScripts = indexedPaths.scripts ?? scripts;\n const resolvedAssets = indexedPaths.assets ?? assets;\n if (resolvedReferences !== undefined) update.references = resolvedReferences;\n if (resolvedScripts !== undefined) update.scripts = resolvedScripts;\n if (resolvedAssets !== undefined) update.assets = resolvedAssets;\n if (files !== undefined) update.files = files;\n if (metadata !== undefined) {\n update.metadata = scopeStoredResourceMetadata({ ...(existing.metadata ?? {}), ...metadata }, scope);\n }\n\n await skillStore.update(update as Parameters<typeof skillStore.update>[0]);\n\n // Return the resolved skill with the updated config\n const resolved = await skillStore.getByIdResolved(storedSkillId);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated skill' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n } catch (error) {\n return handleError(error, 'Error updating stored skill');\n }\n },\n});\n\n/**\n * DELETE /stored/skills/:storedSkillId - Delete a stored skill\n */\nexport const DELETE_STORED_SKILL_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/skills/:storedSkillId',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: deleteStoredSkillResponseSchema,\n summary: 'Delete stored skill',\n description: 'Deletes a skill from storage by its unique identifier',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedSkillId }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n // Check if skill exists. Skill metadata lives on the resolved snapshot.\n const existing = await skillStore.getByIdResolved(storedSkillId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(existing, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, or `skills:delete[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-skills',\n resourceId: storedSkillId,\n action: 'delete',\n record: existing,\n });\n\n await skillStore.delete(storedSkillId);\n\n // Cascade: drop any favorite rows referencing this skill. Failure must not\n // abort the delete.\n try {\n const favoritesStore = await storage.getStore('favorites');\n await favoritesStore?.deleteFavoritesForEntity({ entityType: 'skill', entityId: storedSkillId });\n } catch (cascadeError) {\n mastra\n .getLogger?.()\n ?.warn?.('Failed to cascade-delete favorites for skill', { storedSkillId, error: cascadeError });\n }\n\n return {\n success: true,\n message: `Skill ${storedSkillId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored skill');\n }\n },\n});\n\n/**\n * POST /stored/skills/:storedSkillId/publish - Publish a skill from filesystem\n * Walks the skill directory, hashes files into blob store, creates a new version\n * with the tree manifest, and sets activeVersionId.\n */\nexport const PUBLISH_STORED_SKILL_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/skills/:storedSkillId/publish',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n bodySchema: publishStoredSkillBodySchema,\n responseSchema: publishStoredSkillResponseSchema,\n summary: 'Publish stored skill',\n description:\n 'Snapshots the skill directory from the filesystem into content-addressable blob storage, creates a new version with a tree manifest, and marks the skill as published',\n tags: ['Stored Skills'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedSkillId, skillPath }) => {\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 skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n const blobStore = await storage.getStore('blobs');\n if (!blobStore) {\n throw new HTTPException(500, { message: 'Blob storage domain is not available' });\n }\n\n // Verify skill exists. Skill metadata lives on the resolved snapshot.\n const existing = await skillStore.getByIdResolved(storedSkillId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(existing, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, or `stored-skills:write[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-skills',\n resourceId: storedSkillId,\n action: 'edit',\n record: existing,\n });\n\n // Validate skillPath to prevent path traversal\n const path = await import('node:path');\n const fs = await import('node:fs/promises');\n const resolvedPath = path.default.resolve(skillPath);\n const allowedBase = path.default.resolve(process.env.SKILLS_BASE_DIR || process.cwd());\n if (!resolvedPath.startsWith(allowedBase + path.default.sep) && resolvedPath !== allowedBase) {\n throw new HTTPException(400, {\n message: `skillPath must be within the allowed directory: ${allowedBase}`,\n });\n }\n\n // Verify the source directory exists and contains a SKILL.md before attempting\n // to publish, so callers get a 400 with context instead of a raw 500/ENOENT.\n try {\n const stat = await fs.stat(resolvedPath);\n if (!stat.isDirectory()) {\n throw new HTTPException(400, { message: `skillPath is not a directory: ${resolvedPath}` });\n }\n } catch (err) {\n if (err instanceof HTTPException) throw err;\n if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') {\n throw new HTTPException(400, {\n message: `skillPath does not exist on the server filesystem: ${resolvedPath}. Create the skill directory (with a SKILL.md) before publishing, or use a skill that was materialized to disk.`,\n });\n }\n throw err;\n }\n try {\n await fs.stat(path.default.join(resolvedPath, 'SKILL.md'));\n } catch (err) {\n if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') {\n throw new HTTPException(400, {\n message: `skillPath is missing SKILL.md: ${resolvedPath}`,\n });\n }\n throw err;\n }\n\n // Use LocalSkillSource to read from the server filesystem\n const source = new LocalSkillSource();\n const { publishSkillFromSource } = await import('@mastra/core/workspace');\n\n const { snapshot, tree, files } = await publishSkillFromSource(source, resolvedPath, blobStore);\n\n // Strip undefined keys from the snapshot before passing to update(). The\n // storage layer treats \"field present\" as \"field changed\"; forwarding\n // undefined would overwrite populated columns with undefined and trip\n // NOT NULL / \"undefined cannot be passed as argument\" errors in\n // adapters that bind args raw (libsql, pg).\n const snapshotUpdate: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(snapshot)) {\n if (value !== undefined) snapshotUpdate[key] = value;\n }\n\n // Update the skill with new version data + tree + UI-facing file tree.\n // `files` is the nested folder/file structure shown in the editor; without\n // it the column would stay null and the UI would render an empty tree.\n await skillStore.update({\n id: storedSkillId,\n ...snapshotUpdate,\n tree,\n files,\n status: 'published',\n });\n\n // Point activeVersionId to the newly created version\n const latestVersion = await skillStore.getLatestVersion(storedSkillId);\n if (latestVersion) {\n await skillStore.update({\n id: storedSkillId,\n activeVersionId: latestVersion.id,\n });\n }\n\n const resolved = await skillStore.getByIdResolved(storedSkillId);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve skill after publish' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n } catch (error) {\n return handleError(error, 'Error publishing stored skill');\n }\n },\n});\n"]}
@@ -1,8 +1,8 @@
1
- import { storedSkillIdPathParams } from './chunk-FBI32AWY.js';
2
1
  import { favoriteToggleResponseSchema } from './chunk-SFPN7SHZ.js';
3
- import { requireBuilderFeature } from './chunk-HPMLQ4AV.js';
4
- import { getCallerAuthorId, assertReadAccess } from './chunk-ETR4XOVD.js';
5
- import { assertStoredResourceScope, getStoredResourceScope } from './chunk-4GWTCVFL.js';
2
+ import { requireBuilderFeature } from './chunk-TQ5KIKVK.js';
3
+ import { getCallerAuthorId, assertReadAccess } from './chunk-3TTDIOEU.js';
4
+ import { storedSkillIdPathParams } from './chunk-FBI32AWY.js';
5
+ import { assertStoredResourceScope, getStoredResourceScope } from './chunk-RCRKB2TG.js';
6
6
  import { handleError } from './chunk-7ZWJX3AN.js';
7
7
  import { createRoute } from './chunk-H5LXHGEJ.js';
8
8
  import { HTTPException } from './chunk-6QWQZI4Q.js';
@@ -97,5 +97,5 @@ var UNFAVORITE_STORED_SKILL_ROUTE = createRoute({
97
97
  });
98
98
 
99
99
  export { FAVORITE_STORED_SKILL_ROUTE, UNFAVORITE_STORED_SKILL_ROUTE };
100
- //# sourceMappingURL=chunk-RA26ZEMJ.js.map
101
- //# sourceMappingURL=chunk-RA26ZEMJ.js.map
100
+ //# sourceMappingURL=chunk-G2XVC7BX.js.map
101
+ //# sourceMappingURL=chunk-G2XVC7BX.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/handlers/stored-skill-favorites.ts"],"names":[],"mappings":";;;;;;;;;;AAaA,eAAe,oBAAoB,MAAA,EAAqD;AACtF,EAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAClC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6BAA6B,CAAA;AAAA,EACvE;AACA,EAAA,MAAM,UAAA,GAAa,MAAM,OAAA,CAAQ,QAAA,CAAS,QAAQ,CAAA;AAClD,EAAA,IAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0CAA0C,CAAA;AAAA,EACpF;AACA,EAAA,MAAM,cAAA,GAAiB,MAAM,OAAA,CAAQ,QAAA,CAAS,WAAW,CAAA;AACzD,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6CAA6C,CAAA;AAAA,EACvF;AACA,EAAA,OAAO,EAAE,YAAY,cAAA,EAAe;AACtC;AAKO,IAAM,8BAA8B,WAAA,CAAY;AAAA,EACrD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,wCAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,eAAA,E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,MAAA,EAAQ,OAAO,CAAA;AAExG,MAAA,MAAM,MAAA,GAAS,MAAM,cAAA,CAAe,UAAA,CAAW;AAAA,QAC7C,MAAA,EAAQ,QAAA;AAAA,QACR,UAAA,EAAY,OAAA;AAAA,QACZ,QAAA,EAAU;AAAA,OACX,CAAA;AACD,MAAA,OAAO,MAAA;AAAA,IACT,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-RA26ZEMJ.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport { favoriteToggleResponseSchema } from '../schemas/favorites';\nimport { storedSkillIdPathParams } from '../schemas/stored-skills';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { assertStoredResourceScope, getStoredResourceScope } from '../utils';\n\nimport { assertReadAccess, getCallerAuthorId } from './authorship';\nimport { requireBuilderFeature } from './editor-builder';\nimport { handleError } from './error';\n\n/**\n * Resolves the storage and favorites domains, throwing 500 if unavailable.\n */\nasync function getFavoritesContext(mastra: Parameters<typeof requireBuilderFeature>[0]) {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n const skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) {\n throw new HTTPException(500, { message: 'Favorites storage domain is not available' });\n }\n return { skillStore, favoritesStore };\n}\n\n/**\n * PUT /stored/skills/:storedSkillId/favorite\n */\nexport const FAVORITE_STORED_SKILL_ROUTE = createRoute({\n method: 'PUT',\n path: '/stored/skills/:storedSkillId/favorite',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: favoriteToggleResponseSchema,\n summary: 'Favorite a stored skill',\n description: 'Marks the stored skill as favorited by the calling user. Idempotent.',\n tags: ['Stored Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra, requestContext, storedSkillId }) => {\n try {\n await requireBuilderFeature(mastra, 'favorites');\n\n const callerId = getCallerAuthorId(requestContext);\n if (!callerId) {\n throw new HTTPException(401, { message: 'Authentication required' });\n }\n\n const { skillStore, favoritesStore } = await getFavoritesContext(mastra);\n\n const skill = await skillStore.getByIdResolved(storedSkillId);\n if (!skill) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(skill, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller cannot read the skill (private + not owner/admin).\n assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n const result = await favoritesStore.favorite({\n userId: callerId,\n entityType: 'skill',\n entityId: storedSkillId,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error favoriting stored skill');\n }\n },\n});\n\n/**\n * DELETE /stored/skills/:storedSkillId/favorite\n */\nexport const UNFAVORITE_STORED_SKILL_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/skills/:storedSkillId/favorite',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: favoriteToggleResponseSchema,\n summary: 'Unfavorite a stored skill',\n description: 'Removes the caller’s favorite from the stored skill. Idempotent.',\n tags: ['Stored Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra, requestContext, storedSkillId }) => {\n try {\n await requireBuilderFeature(mastra, 'favorites');\n\n const callerId = getCallerAuthorId(requestContext);\n if (!callerId) {\n throw new HTTPException(401, { message: 'Authentication required' });\n }\n\n const { skillStore, favoritesStore } = await getFavoritesContext(mastra);\n\n const skill = await skillStore.getByIdResolved(storedSkillId);\n if (!skill) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(skill, await getStoredResourceScope(mastra, requestContext));\n\n assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n const result = await favoritesStore.unfavorite({\n userId: callerId,\n entityType: 'skill',\n entityId: storedSkillId,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error unfavoriting stored skill');\n }\n },\n});\n"]}
1
+ {"version":3,"sources":["../src/server/handlers/stored-skill-favorites.ts"],"names":[],"mappings":";;;;;;;;;;AAaA,eAAe,oBAAoB,MAAA,EAAqD;AACtF,EAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAClC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6BAA6B,CAAA;AAAA,EACvE;AACA,EAAA,MAAM,UAAA,GAAa,MAAM,OAAA,CAAQ,QAAA,CAAS,QAAQ,CAAA;AAClD,EAAA,IAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0CAA0C,CAAA;AAAA,EACpF;AACA,EAAA,MAAM,cAAA,GAAiB,MAAM,OAAA,CAAQ,QAAA,CAAS,WAAW,CAAA;AACzD,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6CAA6C,CAAA;AAAA,EACvF;AACA,EAAA,OAAO,EAAE,YAAY,cAAA,EAAe;AACtC;AAKO,IAAM,8BAA8B,WAAA,CAAY;AAAA,EACrD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,wCAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,eAAA,EAAiB,uBAAA;AAAA,EACjB,cAAA,EAAgB,4BAAA;AAAA,EAChB,OAAA,EAAS,yBAAA;AAAA,EACT,WAAA,EAAa,sEAAA;AAAA,EACb,IAAA,EAAM,CAAC,eAAe,CAAA;AAAA,EACtB,YAAA,EAAc,IAAA;AAAA,EACd,kBAAA,EAAoB,oBAAA;AAAA,EACpB,SAAS,OAAO,EAAE,MAAA,E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AA,OAAO,WAAA,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-G2XVC7BX.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport { favoriteToggleResponseSchema } from '../schemas/favorites';\nimport { storedSkillIdPathParams } from '../schemas/stored-skills';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { assertStoredResourceScope, getStoredResourceScope } from '../utils';\n\nimport { assertReadAccess, getCallerAuthorId } from './authorship';\nimport { requireBuilderFeature } from './editor-builder';\nimport { handleError } from './error';\n\n/**\n * Resolves the storage and favorites domains, throwing 500 if unavailable.\n */\nasync function getFavoritesContext(mastra: Parameters<typeof requireBuilderFeature>[0]) {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n const skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) {\n throw new HTTPException(500, { message: 'Favorites storage domain is not available' });\n }\n return { skillStore, favoritesStore };\n}\n\n/**\n * PUT /stored/skills/:storedSkillId/favorite\n */\nexport const FAVORITE_STORED_SKILL_ROUTE = createRoute({\n method: 'PUT',\n path: '/stored/skills/:storedSkillId/favorite',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: favoriteToggleResponseSchema,\n summary: 'Favorite a stored skill',\n description: 'Marks the stored skill as favorited by the calling user. Idempotent.',\n tags: ['Stored Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra, requestContext, storedSkillId }) => {\n try {\n await requireBuilderFeature(mastra, 'favorites');\n\n const callerId = getCallerAuthorId(requestContext);\n if (!callerId) {\n throw new HTTPException(401, { message: 'Authentication required' });\n }\n\n const { skillStore, favoritesStore } = await getFavoritesContext(mastra);\n\n const skill = await skillStore.getByIdResolved(storedSkillId);\n if (!skill) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(skill, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller cannot read the skill (private + not owner/admin).\n assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n const result = await favoritesStore.favorite({\n userId: callerId,\n entityType: 'skill',\n entityId: storedSkillId,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error favoriting stored skill');\n }\n },\n});\n\n/**\n * DELETE /stored/skills/:storedSkillId/favorite\n */\nexport const UNFAVORITE_STORED_SKILL_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/skills/:storedSkillId/favorite',\n responseType: 'json',\n pathParamSchema: storedSkillIdPathParams,\n responseSchema: favoriteToggleResponseSchema,\n summary: 'Unfavorite a stored skill',\n description: 'Removes the caller’s favorite from the stored skill. Idempotent.',\n tags: ['Stored Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra, requestContext, storedSkillId }) => {\n try {\n await requireBuilderFeature(mastra, 'favorites');\n\n const callerId = getCallerAuthorId(requestContext);\n if (!callerId) {\n throw new HTTPException(401, { message: 'Authentication required' });\n }\n\n const { skillStore, favoritesStore } = await getFavoritesContext(mastra);\n\n const skill = await skillStore.getByIdResolved(storedSkillId);\n if (!skill) {\n throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n }\n assertStoredResourceScope(skill, await getStoredResourceScope(mastra, requestContext));\n\n assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n const result = await favoritesStore.unfavorite({\n userId: callerId,\n entityType: 'skill',\n entityId: storedSkillId,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error unfavoriting stored skill');\n }\n },\n});\n"]}
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkAEQ33POL_cjs = require('./chunk-AEQ33POL.cjs');
4
- var chunk3JVOIOO6_cjs = require('./chunk-3JVOIOO6.cjs');
5
- var chunkVK4EOZXR_cjs = require('./chunk-VK4EOZXR.cjs');
6
4
  var chunkZ7LCIYK7_cjs = require('./chunk-Z7LCIYK7.cjs');
7
5
  var chunkRTTQ6WVP_cjs = require('./chunk-RTTQ6WVP.cjs');
8
6
  var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
7
+ var chunkVK4EOZXR_cjs = require('./chunk-VK4EOZXR.cjs');
8
+ var chunk3JVOIOO6_cjs = require('./chunk-3JVOIOO6.cjs');
9
9
  var agent = require('@mastra/core/agent');
10
10
  var error = require('@mastra/core/error');
11
11
  var features = require('@mastra/core/features');
@@ -1058,5 +1058,5 @@ exports.TRIGGER_EXPERIMENT_ROUTE = TRIGGER_EXPERIMENT_ROUTE;
1058
1058
  exports.UPDATE_DATASET_ROUTE = UPDATE_DATASET_ROUTE;
1059
1059
  exports.UPDATE_EXPERIMENT_RESULT_ROUTE = UPDATE_EXPERIMENT_RESULT_ROUTE;
1060
1060
  exports.UPDATE_ITEM_ROUTE = UPDATE_ITEM_ROUTE;
1061
- //# sourceMappingURL=chunk-S7Y6AP64.cjs.map
1062
- //# sourceMappingURL=chunk-S7Y6AP64.cjs.map
1061
+ //# sourceMappingURL=chunk-GV6TKASG.cjs.map
1062
+ //# sourceMappingURL=chunk-GV6TKASG.cjs.map