@mastra/server 1.79.0-alpha.10 → 1.79.0-alpha.11

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 (381) hide show
  1. package/dist/{a2a-CHBSYHxu.js → a2a-BqLB3McP.js} +17 -16
  2. package/dist/a2a-BqLB3McP.js.map +1 -0
  3. package/dist/{a2a-B465DD1u.cjs → a2a-Uood_0DN.cjs} +19 -18
  4. package/dist/a2a-Uood_0DN.cjs.map +1 -0
  5. package/dist/agent-builder-CuBD1tpv.cjs +728 -0
  6. package/dist/agent-builder-CuBD1tpv.cjs.map +1 -0
  7. package/dist/agent-builder-VhM8ADW-.js +627 -0
  8. package/dist/agent-builder-VhM8ADW-.js.map +1 -0
  9. package/dist/{agents-X1E7fW3p.js → agents-BHLTMBff.js} +2 -2
  10. package/dist/{agents-X1E7fW3p.js.map → agents-BHLTMBff.js.map} +1 -1
  11. package/dist/agents-BOWEUKyV.cjs +3127 -0
  12. package/dist/agents-BOWEUKyV.cjs.map +1 -0
  13. package/dist/agents-DRQ3ScbX.js +2828 -0
  14. package/dist/agents-DRQ3ScbX.js.map +1 -0
  15. package/dist/{agents-DoNMSCMt.cjs → agents-T-OIM9IK.cjs} +2 -2
  16. package/dist/{agents-DoNMSCMt.cjs.map → agents-T-OIM9IK.cjs.map} +1 -1
  17. package/dist/{api-schema-manifest-DUseI2VG.cjs → api-schema-manifest-A2qfi54Y.cjs} +4 -4
  18. package/dist/{api-schema-manifest-DUseI2VG.cjs.map → api-schema-manifest-A2qfi54Y.cjs.map} +1 -1
  19. package/dist/{api-schema-manifest-CWRIJP-B.js → api-schema-manifest-Dun5VMRT.js} +3 -3
  20. package/dist/{api-schema-manifest-CWRIJP-B.js.map → api-schema-manifest-Dun5VMRT.js.map} +1 -1
  21. package/dist/{background-tasks-CabImVak.cjs → background-tasks-B3VAKTJh.cjs} +3 -3
  22. package/dist/{background-tasks-CabImVak.cjs.map → background-tasks-B3VAKTJh.cjs.map} +1 -1
  23. package/dist/{background-tasks-oBaLtnCn.js → background-tasks-Du2zYOPl.js} +2 -2
  24. package/dist/{background-tasks-oBaLtnCn.js.map → background-tasks-Du2zYOPl.js.map} +1 -1
  25. package/dist/{builder-registry-DOkLe8ES.js → builder-registry-DLdu9bWH.js} +3 -3
  26. package/dist/{builder-registry-DOkLe8ES.js.map → builder-registry-DLdu9bWH.js.map} +1 -1
  27. package/dist/{builder-registry-D0frV8lQ.cjs → builder-registry-DaFAaMTf.cjs} +3 -3
  28. package/dist/{builder-registry-D0frV8lQ.cjs.map → builder-registry-DaFAaMTf.cjs.map} +1 -1
  29. package/dist/{channels-CBIopVWd.cjs → channels-BnVRmnzK.cjs} +6 -3
  30. package/dist/{channels-CBIopVWd.cjs.map → channels-BnVRmnzK.cjs.map} +1 -1
  31. package/dist/{channels-BOxgHvzI.js → channels-Db-4pXVZ.js} +6 -3
  32. package/dist/{channels-BOxgHvzI.js.map → channels-Db-4pXVZ.js.map} +1 -1
  33. package/dist/conversations-8BWryNlF.js +165 -0
  34. package/dist/conversations-8BWryNlF.js.map +1 -0
  35. package/dist/conversations-C5MkQBB8.cjs +194 -0
  36. package/dist/conversations-C5MkQBB8.cjs.map +1 -0
  37. package/dist/{conversations-Bj5TLNqF.cjs → conversations-DasqEDCF.cjs} +3 -3
  38. package/dist/{conversations-Bj5TLNqF.cjs.map → conversations-DasqEDCF.cjs.map} +1 -1
  39. package/dist/{dist-9c3PXXpk.cjs → dist-B-bEVWlJ.cjs} +4733 -1251
  40. package/dist/dist-B-bEVWlJ.cjs.map +1 -0
  41. package/dist/dist-B3kC8Yd0.cjs +3 -0
  42. package/dist/{dist-CQ3FSKT-.cjs → dist-B9ery9Zw.cjs} +38 -35
  43. package/dist/{dist-CQ3FSKT-.cjs.map → dist-B9ery9Zw.cjs.map} +1 -1
  44. package/dist/{dist-BxMmGD3n.js → dist-BBOnrL_A.js} +10 -12
  45. package/dist/{dist-BxMmGD3n.js.map → dist-BBOnrL_A.js.map} +1 -1
  46. package/dist/{dist-DOWsEmo6.js → dist-BIrQLUV9.js} +20 -20
  47. package/dist/{dist-DOWsEmo6.js.map → dist-BIrQLUV9.js.map} +1 -1
  48. package/dist/dist-BM9J-PTK.js +1 -0
  49. package/dist/{dist-DC1Pewf5.cjs → dist-Bo3GdQwf.cjs} +21 -21
  50. package/dist/{dist-DC1Pewf5.cjs.map → dist-Bo3GdQwf.cjs.map} +1 -1
  51. package/dist/{dist-BwYL7Ykb.js → dist-CREG82cy.js} +37 -34
  52. package/dist/{dist-BwYL7Ykb.js.map → dist-CREG82cy.js.map} +1 -1
  53. package/dist/{dist-rDRetJVY.cjs → dist-CeTLA-e5.cjs} +2 -3
  54. package/dist/{dist-rDRetJVY.cjs.map → dist-CeTLA-e5.cjs.map} +1 -1
  55. package/dist/{dist-CBRJax5e.js → dist-DLld1qjf.js} +25 -31
  56. package/dist/{dist-CBRJax5e.js.map → dist-DLld1qjf.js.map} +1 -1
  57. package/dist/{dist-B_bet8uz.js → dist-DjkPkAzV.js} +2 -3
  58. package/dist/{dist-B_bet8uz.js.map → dist-DjkPkAzV.js.map} +1 -1
  59. package/dist/{dist-UKEksCGq.cjs → dist-DsrJXwic.cjs} +11 -13
  60. package/dist/{dist-UKEksCGq.cjs.map → dist-DsrJXwic.cjs.map} +1 -1
  61. package/dist/{dist-DGCnbhNe.js → dist-k77XQGUn.js} +4493 -1043
  62. package/dist/dist-k77XQGUn.js.map +1 -0
  63. package/dist/{dist-3FPW9nVj.cjs → dist-lT2rqyY9.cjs} +26 -32
  64. package/dist/{dist-3FPW9nVj.cjs.map → dist-lT2rqyY9.cjs.map} +1 -1
  65. package/dist/docs/SKILL.md +1 -1
  66. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  67. package/dist/{dynamic-workflows-Rr_6ac1y.js → dynamic-workflows-CTUO0SFu.js} +3 -3
  68. package/dist/{dynamic-workflows-Rr_6ac1y.js.map → dynamic-workflows-CTUO0SFu.js.map} +1 -1
  69. package/dist/{dynamic-workflows-DXlkr-jK.cjs → dynamic-workflows-HwPX3mcf.cjs} +3 -3
  70. package/dist/{dynamic-workflows-DXlkr-jK.cjs.map → dynamic-workflows-HwPX3mcf.cjs.map} +1 -1
  71. package/dist/{editor-builder-BclcHxN6.cjs → editor-builder-BDtiWw0f.cjs} +2 -2
  72. package/dist/{editor-builder-BclcHxN6.cjs.map → editor-builder-BDtiWw0f.cjs.map} +1 -1
  73. package/dist/{editor-builder-D16kc1P6.js → editor-builder-ClFlGXoX.js} +4 -4
  74. package/dist/{editor-builder-D16kc1P6.js.map → editor-builder-ClFlGXoX.js.map} +1 -1
  75. package/dist/{editor-builder-s9WqPJgA.js → editor-builder-DnLCfqnY.js} +2 -2
  76. package/dist/{editor-builder-s9WqPJgA.js.map → editor-builder-DnLCfqnY.js.map} +1 -1
  77. package/dist/{editor-builder-DXHiPX1A.cjs → editor-builder-DtpP1FtW.cjs} +5 -5
  78. package/dist/{editor-builder-DXHiPX1A.cjs.map → editor-builder-DtpP1FtW.cjs.map} +1 -1
  79. package/dist/{helpers-ElhPeCSK.cjs → helpers-CAcEhq38.cjs} +21 -17
  80. package/dist/{helpers-ElhPeCSK.cjs.map → helpers-CAcEhq38.cjs.map} +1 -1
  81. package/dist/{helpers-DLhX1fqc.js → helpers-vrqddDd5.js} +21 -17
  82. package/dist/{helpers-DLhX1fqc.js.map → helpers-vrqddDd5.js.map} +1 -1
  83. package/dist/index.cjs +1 -1
  84. package/dist/logs-CiSw7r0s.cjs +119 -0
  85. package/dist/logs-CiSw7r0s.cjs.map +1 -0
  86. package/dist/logs-CxfPk-iL.js +96 -0
  87. package/dist/logs-CxfPk-iL.js.map +1 -0
  88. package/dist/mcp-BTdLh6E_.js +274 -0
  89. package/dist/mcp-BTdLh6E_.js.map +1 -0
  90. package/dist/mcp-BYqFR5q-.cjs +339 -0
  91. package/dist/mcp-BYqFR5q-.cjs.map +1 -0
  92. package/dist/memory-BHtTSzvJ.js +1739 -0
  93. package/dist/memory-BHtTSzvJ.js.map +1 -0
  94. package/dist/memory-CwwkVDh1.cjs +1906 -0
  95. package/dist/memory-CwwkVDh1.cjs.map +1 -0
  96. package/dist/observability-BBMCMeT-.cjs +502 -0
  97. package/dist/observability-BBMCMeT-.cjs.map +1 -0
  98. package/dist/observability-ZRgRcvoX.js +431 -0
  99. package/dist/observability-ZRgRcvoX.js.map +1 -0
  100. package/dist/{observability-new-endpoints-BU8JYPfh.js → observability-new-endpoints-fjoZzEtk.js} +10 -9
  101. package/dist/{observability-new-endpoints-BU8JYPfh.js.map → observability-new-endpoints-fjoZzEtk.js.map} +1 -1
  102. package/dist/{observability-new-endpoints-AMp9bnMV.cjs → observability-new-endpoints-tG3-odLa.cjs} +11 -10
  103. package/dist/observability-new-endpoints-tG3-odLa.cjs.map +1 -0
  104. package/dist/plans-CiPgWBhO.cjs +68 -0
  105. package/dist/plans-CiPgWBhO.cjs.map +1 -0
  106. package/dist/plans-DCepEY7n.js +57 -0
  107. package/dist/plans-DCepEY7n.js.map +1 -0
  108. package/dist/{probe-image-size-DBGjhUtJ.cjs → probe-image-size-Alv3gwKl.cjs} +194 -184
  109. package/dist/probe-image-size-Alv3gwKl.cjs.map +1 -0
  110. package/dist/{probe-image-size-Dmoxv93t.js → probe-image-size-BdfbUHxx.js} +158 -148
  111. package/dist/probe-image-size-BdfbUHxx.js.map +1 -0
  112. package/dist/responses-4FwMNxoJ.js +628 -0
  113. package/dist/responses-4FwMNxoJ.js.map +1 -0
  114. package/dist/responses-CCRijwDF.cjs +651 -0
  115. package/dist/responses-CCRijwDF.cjs.map +1 -0
  116. package/dist/{responses-CKNdSRkS.cjs → responses-CfcIc53b.cjs} +2 -2
  117. package/dist/{responses-CKNdSRkS.cjs.map → responses-CfcIc53b.cjs.map} +1 -1
  118. package/dist/{rolldown-runtime-Bd6kNlEP.cjs → rolldown-runtime-BwC_XMyb.cjs} +2 -2
  119. package/dist/{rolldown-runtime-maW3aOIk.js → rolldown-runtime-D3Hj5m0v.js} +2 -2
  120. package/dist/{route-builder-BNZs643f.cjs → route-builder-B2Qhhd7C.cjs} +52 -66
  121. package/dist/route-builder-B2Qhhd7C.cjs.map +1 -0
  122. package/dist/{route-builder-BfQYtclb.js → route-builder-CjkWxv4E.js} +51 -65
  123. package/dist/route-builder-CjkWxv4E.js.map +1 -0
  124. package/dist/{routes-Dl6_kWm7.js → routes-CKfXiwRc.js} +5 -3
  125. package/dist/routes-CKfXiwRc.js.map +1 -0
  126. package/dist/{routes-rwufkyUe.js → routes-D1cP2OeF.js} +26 -26
  127. package/dist/{routes-rwufkyUe.js.map → routes-D1cP2OeF.js.map} +1 -1
  128. package/dist/{routes-DPojsNf1.cjs → routes-bxG4x1MV.cjs} +199 -199
  129. package/dist/{routes-DPojsNf1.cjs.map → routes-bxG4x1MV.cjs.map} +1 -1
  130. package/dist/{routes-BULZI-PU.cjs → routes-jXksmX9G.cjs} +5 -3
  131. package/dist/routes-jXksmX9G.cjs.map +1 -0
  132. package/dist/{schedules-Bj-giFbc.cjs → schedules-CTTTCgbk.cjs} +3 -3
  133. package/dist/{schedules-Bj-giFbc.cjs.map → schedules-CTTTCgbk.cjs.map} +1 -1
  134. package/dist/{schedules-BQYgaz66.js → schedules-DXh37n6-.js} +2 -2
  135. package/dist/{schedules-BQYgaz66.js.map → schedules-DXh37n6-.js.map} +1 -1
  136. package/dist/{schema-e0VHpMt0-C0452jOk.cjs → schema-CzbEIyhE-20gGIWkz.cjs} +83 -88
  137. package/dist/schema-CzbEIyhE-20gGIWkz.cjs.map +1 -0
  138. package/dist/{schema-e0VHpMt0-CVP5Hnxy.js → schema-CzbEIyhE-BsMcj9Ws.js} +82 -87
  139. package/dist/schema-CzbEIyhE-BsMcj9Ws.js.map +1 -0
  140. package/dist/scores-D9UgETt_.js +288 -0
  141. package/dist/scores-D9UgETt_.js.map +1 -0
  142. package/dist/scores-DRdtS7NT.cjs +329 -0
  143. package/dist/scores-DRdtS7NT.cjs.map +1 -0
  144. package/dist/server/a2a/store.cjs +1 -1
  145. package/dist/server/auth/index.cjs +2 -2
  146. package/dist/server/auth/index.js +1 -1
  147. package/dist/server/browser-stream/index.cjs +9 -11
  148. package/dist/server/browser-stream/index.cjs.map +1 -1
  149. package/dist/server/browser-stream/index.js +8 -10
  150. package/dist/server/browser-stream/index.js.map +1 -1
  151. package/dist/server/handlers/a2a.cjs +2 -2
  152. package/dist/server/handlers/a2a.js +1 -2
  153. package/dist/server/handlers/agent-builder.cjs +18 -648
  154. package/dist/server/handlers/agent-builder.js +1 -627
  155. package/dist/server/handlers/agent-controller.cjs +5 -5
  156. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  157. package/dist/server/handlers/agent-controller.js +11 -9
  158. package/dist/server/handlers/agent-controller.js.map +1 -1
  159. package/dist/server/handlers/agent-versions.cjs +15 -8
  160. package/dist/server/handlers/agent-versions.cjs.map +1 -1
  161. package/dist/server/handlers/agent-versions.js +14 -7
  162. package/dist/server/handlers/agent-versions.js.map +1 -1
  163. package/dist/server/handlers/agents.cjs +51 -2860
  164. package/dist/server/handlers/agents.js +1 -2806
  165. package/dist/server/handlers/auth.cjs +14 -12
  166. package/dist/server/handlers/auth.cjs.map +1 -1
  167. package/dist/server/handlers/auth.js +20 -16
  168. package/dist/server/handlers/auth.js.map +1 -1
  169. package/dist/server/handlers/author-enrichment.cjs +1 -1
  170. package/dist/server/handlers/authorship.cjs +1 -1
  171. package/dist/server/handlers/authorship.cjs.map +1 -1
  172. package/dist/server/handlers/background-tasks.cjs +2 -2
  173. package/dist/server/handlers/background-tasks.js +1 -2
  174. package/dist/server/handlers/builder-registry.cjs +2 -2
  175. package/dist/server/handlers/builder-registry.js +1 -2
  176. package/dist/server/handlers/channels.cjs +2 -2
  177. package/dist/server/handlers/channels.js +1 -2
  178. package/dist/server/handlers/conversations.cjs +6 -171
  179. package/dist/server/handlers/conversations.js +1 -162
  180. package/dist/server/handlers/datasets.cjs +2 -2
  181. package/dist/server/handlers/datasets.cjs.map +1 -1
  182. package/dist/server/handlers/datasets.js +1 -1
  183. package/dist/server/handlers/dynamic-workflows.cjs +2 -2
  184. package/dist/server/handlers/dynamic-workflows.js +1 -2
  185. package/dist/server/handlers/editor-builder.cjs +2 -2
  186. package/dist/server/handlers/editor-builder.js +1 -2
  187. package/dist/server/handlers/error.cjs +18 -13
  188. package/dist/server/handlers/error.cjs.map +1 -1
  189. package/dist/server/handlers/error.js +17 -12
  190. package/dist/server/handlers/error.js.map +1 -1
  191. package/dist/server/handlers/favorites-enrichment.cjs +2 -2
  192. package/dist/server/handlers/favorites-enrichment.js +1 -1
  193. package/dist/server/handlers/gateway-memory-client.cjs +1 -1
  194. package/dist/server/handlers/logs.cjs +5 -104
  195. package/dist/server/handlers/logs.js +1 -96
  196. package/dist/server/handlers/mcp-client-versions.cjs +15 -8
  197. package/dist/server/handlers/mcp-client-versions.cjs.map +1 -1
  198. package/dist/server/handlers/mcp-client-versions.js +14 -7
  199. package/dist/server/handlers/mcp-client-versions.js.map +1 -1
  200. package/dist/server/handlers/mcp.cjs +12 -289
  201. package/dist/server/handlers/mcp.js +1 -274
  202. package/dist/server/handlers/memory.cjs +29 -1763
  203. package/dist/server/handlers/memory.js +1 -1731
  204. package/dist/server/handlers/observability-list-query-schemas.cjs +1 -1
  205. package/dist/server/handlers/observability-new-endpoints.cjs +2 -2
  206. package/dist/server/handlers/observability-new-endpoints.js +1 -2
  207. package/dist/server/handlers/observability-shared.cjs +2 -2
  208. package/dist/server/handlers/observability-shared.js +1 -1
  209. package/dist/server/handlers/observability-storage-schemas.cjs +1 -1
  210. package/dist/server/handlers/observability.cjs +14 -445
  211. package/dist/server/handlers/observability.js +3 -429
  212. package/dist/server/handlers/plans.cjs +3 -63
  213. package/dist/server/handlers/plans.js +1 -57
  214. package/dist/server/handlers/processor-providers.cjs +2 -2
  215. package/dist/server/handlers/processor-providers.cjs.map +1 -1
  216. package/dist/server/handlers/processor-providers.js +1 -1
  217. package/dist/server/handlers/processors.cjs +13 -15
  218. package/dist/server/handlers/processors.cjs.map +1 -1
  219. package/dist/server/handlers/processors.js +12 -14
  220. package/dist/server/handlers/processors.js.map +1 -1
  221. package/dist/server/handlers/prompt-block-versions.cjs +15 -8
  222. package/dist/server/handlers/prompt-block-versions.cjs.map +1 -1
  223. package/dist/server/handlers/prompt-block-versions.js +14 -7
  224. package/dist/server/handlers/prompt-block-versions.js.map +1 -1
  225. package/dist/server/handlers/responses.adapter.cjs +1 -1
  226. package/dist/server/handlers/responses.adapter.cjs.map +1 -1
  227. package/dist/server/handlers/responses.cjs +5 -632
  228. package/dist/server/handlers/responses.js +1 -624
  229. package/dist/server/handlers/responses.storage.cjs +2 -2
  230. package/dist/server/handlers/schedules-workflows-shim.cjs +1 -1
  231. package/dist/server/handlers/schedules.cjs +2 -2
  232. package/dist/server/handlers/schedules.js +1 -2
  233. package/dist/server/handlers/scorer-versions.cjs +15 -8
  234. package/dist/server/handlers/scorer-versions.cjs.map +1 -1
  235. package/dist/server/handlers/scorer-versions.js +14 -7
  236. package/dist/server/handlers/scorer-versions.js.map +1 -1
  237. package/dist/server/handlers/scores.cjs +8 -299
  238. package/dist/server/handlers/scores.js +1 -288
  239. package/dist/server/handlers/skills-sh-shared.cjs +1 -1
  240. package/dist/server/handlers/stored-agent-favorites.cjs +4 -4
  241. package/dist/server/handlers/stored-agent-favorites.js +3 -3
  242. package/dist/server/handlers/stored-agents.cjs +19 -13
  243. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  244. package/dist/server/handlers/stored-agents.js +18 -12
  245. package/dist/server/handlers/stored-agents.js.map +1 -1
  246. package/dist/server/handlers/stored-mcp-clients.cjs +8 -6
  247. package/dist/server/handlers/stored-mcp-clients.cjs.map +1 -1
  248. package/dist/server/handlers/stored-mcp-clients.js +7 -5
  249. package/dist/server/handlers/stored-mcp-clients.js.map +1 -1
  250. package/dist/server/handlers/stored-prompt-blocks.cjs +3 -3
  251. package/dist/server/handlers/stored-prompt-blocks.js +2 -2
  252. package/dist/server/handlers/stored-scorers.cjs +3 -3
  253. package/dist/server/handlers/stored-scorers.js +2 -2
  254. package/dist/server/handlers/stored-skill-favorites.cjs +4 -4
  255. package/dist/server/handlers/stored-skill-favorites.js +3 -3
  256. package/dist/server/handlers/stored-skills.cjs +6 -5
  257. package/dist/server/handlers/stored-skills.cjs.map +1 -1
  258. package/dist/server/handlers/stored-skills.js +5 -4
  259. package/dist/server/handlers/stored-skills.js.map +1 -1
  260. package/dist/server/handlers/stored-workspaces.cjs +3 -3
  261. package/dist/server/handlers/stored-workspaces.js +2 -2
  262. package/dist/server/handlers/system.cjs +3 -3
  263. package/dist/server/handlers/system.cjs.map +1 -1
  264. package/dist/server/handlers/system.js +2 -2
  265. package/dist/server/handlers/test-utils.cjs +1 -1
  266. package/dist/server/handlers/tool-providers.cjs +2 -2
  267. package/dist/server/handlers/tool-providers.js +1 -1
  268. package/dist/server/handlers/tool-schema-overrides.cjs +1 -1
  269. package/dist/server/handlers/tools.cjs +7 -267
  270. package/dist/server/handlers/tools.js +1 -257
  271. package/dist/server/handlers/utils.cjs +2 -2
  272. package/dist/server/handlers/utils.js +1 -2
  273. package/dist/server/handlers/validate-agent-instructions.cjs +2 -2
  274. package/dist/server/handlers/validate-agent-instructions.js +1 -1
  275. package/dist/server/handlers/validate-avatar.cjs +2 -2
  276. package/dist/server/handlers/validate-avatar.cjs.map +1 -1
  277. package/dist/server/handlers/validate-avatar.js +1 -1
  278. package/dist/server/handlers/validate-avatar.js.map +1 -1
  279. package/dist/server/handlers/vector.cjs +17 -334
  280. package/dist/server/handlers/vector.js +1 -314
  281. package/dist/server/handlers/version-helpers.cjs +1 -1
  282. package/dist/server/handlers/voice.cjs +9 -35
  283. package/dist/server/handlers/voice.js +1 -23
  284. package/dist/server/handlers/workflow-builder.cjs +2 -2
  285. package/dist/server/handlers/workflow-builder.js +1 -2
  286. package/dist/server/handlers/workflows.cjs +30 -1293
  287. package/dist/server/handlers/workflows.js +1 -1257
  288. package/dist/server/handlers/workspace.cjs +27 -1176
  289. package/dist/server/handlers/workspace.js +1 -1146
  290. package/dist/server/handlers.cjs +33 -33
  291. package/dist/server/handlers.js +17 -17
  292. package/dist/server/schemas/index.cjs +6 -6
  293. package/dist/server/schemas/index.js +3 -3
  294. package/dist/server/server-adapter/index.cjs +5 -5
  295. package/dist/server/server-adapter/index.cjs.map +1 -1
  296. package/dist/server/server-adapter/index.js +4 -4
  297. package/dist/server/server-adapter/index.js.map +1 -1
  298. package/dist/tools-CmFSfDMn.js +256 -0
  299. package/dist/tools-CmFSfDMn.js.map +1 -0
  300. package/dist/tools-SPJtxG9N.cjs +291 -0
  301. package/dist/tools-SPJtxG9N.cjs.map +1 -0
  302. package/dist/{utils-DCgeTrq2.cjs → utils-CF76qzZR.cjs} +12 -17
  303. package/dist/{utils-DCgeTrq2.cjs.map → utils-CF76qzZR.cjs.map} +1 -1
  304. package/dist/{utils-DCAUeb6M.js → utils-aoLN3Wfi.js} +11 -16
  305. package/dist/{utils-DCAUeb6M.js.map → utils-aoLN3Wfi.js.map} +1 -1
  306. package/dist/{utils-Du-EpvDs.cjs → utils-dDLIDg8O.cjs} +2 -2
  307. package/dist/{utils-Du-EpvDs.cjs.map → utils-dDLIDg8O.cjs.map} +1 -1
  308. package/dist/vector-BKDD1kwc.cjs +409 -0
  309. package/dist/vector-BKDD1kwc.cjs.map +1 -0
  310. package/dist/vector-TWv4t-4g.js +314 -0
  311. package/dist/vector-TWv4t-4g.js.map +1 -0
  312. package/dist/voice-BnGwlZ75.cjs +70 -0
  313. package/dist/voice-BnGwlZ75.cjs.map +1 -0
  314. package/dist/voice-DjG8tBAD.js +23 -0
  315. package/dist/voice-DjG8tBAD.js.map +1 -0
  316. package/dist/{workflow-builder-Brj3IArM.cjs → workflow-builder-C9-8ZOWF.cjs} +5 -5
  317. package/dist/{workflow-builder-Brj3IArM.cjs.map → workflow-builder-C9-8ZOWF.cjs.map} +1 -1
  318. package/dist/{workflow-builder-DOa1Vx6w.js → workflow-builder-CjlLoQvo.js} +10 -8
  319. package/dist/{workflow-builder-DOa1Vx6w.js.map → workflow-builder-CjlLoQvo.js.map} +1 -1
  320. package/dist/workflows-DjqeJcdJ.cjs +1446 -0
  321. package/dist/workflows-DjqeJcdJ.cjs.map +1 -0
  322. package/dist/workflows-bb-otd2o.js +1273 -0
  323. package/dist/workflows-bb-otd2o.js.map +1 -0
  324. package/dist/workspace-B6kzp-bo.js +1154 -0
  325. package/dist/workspace-B6kzp-bo.js.map +1 -0
  326. package/dist/workspace-COKR1SxH.cjs +1309 -0
  327. package/dist/workspace-COKR1SxH.cjs.map +1 -0
  328. package/package.json +4 -4
  329. package/dist/a2a-B465DD1u.cjs.map +0 -1
  330. package/dist/a2a-CHBSYHxu.js.map +0 -1
  331. package/dist/dist-9c3PXXpk.cjs.map +0 -1
  332. package/dist/dist-B5OwHWTo.cjs +0 -2294
  333. package/dist/dist-B5OwHWTo.cjs.map +0 -1
  334. package/dist/dist-DGCnbhNe.js.map +0 -1
  335. package/dist/dist-DcoIg_tp.js +0 -2293
  336. package/dist/dist-DcoIg_tp.js.map +0 -1
  337. package/dist/observability-new-endpoints-AMp9bnMV.cjs.map +0 -1
  338. package/dist/probe-image-size-DBGjhUtJ.cjs.map +0 -1
  339. package/dist/probe-image-size-Dmoxv93t.js.map +0 -1
  340. package/dist/route-builder-BNZs643f.cjs.map +0 -1
  341. package/dist/route-builder-BfQYtclb.js.map +0 -1
  342. package/dist/routes-BULZI-PU.cjs.map +0 -1
  343. package/dist/routes-Dl6_kWm7.js.map +0 -1
  344. package/dist/schema-Drf2W04o.js +0 -2
  345. package/dist/schema-EQanefYq.cjs +0 -1
  346. package/dist/schema-e0VHpMt0-C0452jOk.cjs.map +0 -1
  347. package/dist/schema-e0VHpMt0-CVP5Hnxy.js.map +0 -1
  348. package/dist/server/handlers/agent-builder.cjs.map +0 -1
  349. package/dist/server/handlers/agent-builder.js.map +0 -1
  350. package/dist/server/handlers/agents.cjs.map +0 -1
  351. package/dist/server/handlers/agents.js.map +0 -1
  352. package/dist/server/handlers/conversations.cjs.map +0 -1
  353. package/dist/server/handlers/conversations.js.map +0 -1
  354. package/dist/server/handlers/logs.cjs.map +0 -1
  355. package/dist/server/handlers/logs.js.map +0 -1
  356. package/dist/server/handlers/mcp.cjs.map +0 -1
  357. package/dist/server/handlers/mcp.js.map +0 -1
  358. package/dist/server/handlers/memory.cjs.map +0 -1
  359. package/dist/server/handlers/memory.js.map +0 -1
  360. package/dist/server/handlers/observability.cjs.map +0 -1
  361. package/dist/server/handlers/observability.js.map +0 -1
  362. package/dist/server/handlers/plans.cjs.map +0 -1
  363. package/dist/server/handlers/plans.js.map +0 -1
  364. package/dist/server/handlers/responses.cjs.map +0 -1
  365. package/dist/server/handlers/responses.js.map +0 -1
  366. package/dist/server/handlers/scores.cjs.map +0 -1
  367. package/dist/server/handlers/scores.js.map +0 -1
  368. package/dist/server/handlers/tools.cjs.map +0 -1
  369. package/dist/server/handlers/tools.js.map +0 -1
  370. package/dist/server/handlers/vector.cjs.map +0 -1
  371. package/dist/server/handlers/vector.js.map +0 -1
  372. package/dist/server/handlers/voice.cjs.map +0 -1
  373. package/dist/server/handlers/voice.js.map +0 -1
  374. package/dist/server/handlers/workflows.cjs.map +0 -1
  375. package/dist/server/handlers/workflows.js.map +0 -1
  376. package/dist/server/handlers/workspace.cjs.map +0 -1
  377. package/dist/server/handlers/workspace.js.map +0 -1
  378. package/dist/sync-Ai_ZDz7U.js +0 -1700
  379. package/dist/sync-Ai_ZDz7U.js.map +0 -1
  380. package/dist/sync-BrO5MtSe.cjs +0 -1729
  381. package/dist/sync-BrO5MtSe.cjs.map +0 -1
@@ -1,1146 +1 @@
1
- import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
2
- import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
3
- import { n as createRoute } from "../../route-builder-BfQYtclb.js";
4
- import { handleError } from "./error.js";
5
- import { B as skillsShPopularQuerySchema, C as searchQuerySchema, D as searchSkillsResponseSchema, E as searchSkillsQuerySchema, G as skillsShSearchQuerySchema, H as skillsShPreviewResponseSchema, K as skillsShSearchResponseSchema, L as skillsShInstallBodySchema, M as skillReferencePathParams, N as skillReferenceResponseSchema, O as skillDisambiguationQuerySchema, Q as workspaceInfoResponseSchema, R as skillsShInstallResponseSchema, U as skillsShRemoveBodySchema, V as skillsShPreviewQuerySchema, W as skillsShRemoveResponseSchema, X as skillsShUpdateResponseSchema, Y as skillsShUpdateBodySchema, Z as workspaceIdPathParams, _ as indexBodySchema, a as fsListResponseSchema, b as listSkillsResponseSchema, d as fsStatQuerySchema, f as fsStatResponseSchema, g as getSkillResponseSchema, i as fsListQuerySchema, j as skillNamePathParams, l as fsReadQuerySchema, m as fsWriteResponseSchema, n as fsDeleteQuerySchema, o as fsMkdirBodySchema, p as fsWriteBodySchema, r as fsDeleteResponseSchema, s as fsMkdirResponseSchema, u as fsReadResponseSchema, v as indexResponseSchema, w as searchResponseSchema, x as listWorkspacesResponseSchema, y as listReferencesResponseSchema, z as skillsShListResponseSchema } from "../../workspace-4dBGFdV2.js";
6
- import { coreFeatures } from "@mastra/core/features";
7
- //#region src/server/handlers/workspace.ts
8
- /**
9
- * Workspace Handlers
10
- *
11
- * Unified handlers for workspace operations including:
12
- * - Filesystem operations (read, write, list, delete, mkdir, stat)
13
- * - Search operations (search, index)
14
- * - Skills operations (list, get, search, references)
15
- */
16
- var workspace_exports = /* @__PURE__ */ __exportAll({
17
- GET_WORKSPACE_ROUTE: () => GET_WORKSPACE_ROUTE,
18
- LIST_WORKSPACES_ROUTE: () => LIST_WORKSPACES_ROUTE,
19
- WORKSPACE_FS_DELETE_ROUTE: () => WORKSPACE_FS_DELETE_ROUTE,
20
- WORKSPACE_FS_LIST_ROUTE: () => WORKSPACE_FS_LIST_ROUTE,
21
- WORKSPACE_FS_MKDIR_ROUTE: () => WORKSPACE_FS_MKDIR_ROUTE,
22
- WORKSPACE_FS_READ_ROUTE: () => WORKSPACE_FS_READ_ROUTE,
23
- WORKSPACE_FS_ROUTES: () => WORKSPACE_FS_ROUTES,
24
- WORKSPACE_FS_STAT_ROUTE: () => WORKSPACE_FS_STAT_ROUTE,
25
- WORKSPACE_FS_WRITE_ROUTE: () => WORKSPACE_FS_WRITE_ROUTE,
26
- WORKSPACE_GET_SKILL_REFERENCE_ROUTE: () => WORKSPACE_GET_SKILL_REFERENCE_ROUTE,
27
- WORKSPACE_GET_SKILL_ROUTE: () => WORKSPACE_GET_SKILL_ROUTE,
28
- WORKSPACE_INDEX_ROUTE: () => WORKSPACE_INDEX_ROUTE,
29
- WORKSPACE_LIST_SKILLS_ROUTE: () => WORKSPACE_LIST_SKILLS_ROUTE,
30
- WORKSPACE_LIST_SKILL_REFERENCES_ROUTE: () => WORKSPACE_LIST_SKILL_REFERENCES_ROUTE,
31
- WORKSPACE_SEARCH_ROUTE: () => WORKSPACE_SEARCH_ROUTE,
32
- WORKSPACE_SEARCH_ROUTES: () => WORKSPACE_SEARCH_ROUTES,
33
- WORKSPACE_SEARCH_SKILLS_ROUTE: () => WORKSPACE_SEARCH_SKILLS_ROUTE,
34
- WORKSPACE_SKILLS_ROUTES: () => WORKSPACE_SKILLS_ROUTES,
35
- WORKSPACE_SKILLS_SH_INSTALL_ROUTE: () => WORKSPACE_SKILLS_SH_INSTALL_ROUTE,
36
- WORKSPACE_SKILLS_SH_POPULAR_ROUTE: () => WORKSPACE_SKILLS_SH_POPULAR_ROUTE,
37
- WORKSPACE_SKILLS_SH_PREVIEW_ROUTE: () => WORKSPACE_SKILLS_SH_PREVIEW_ROUTE,
38
- WORKSPACE_SKILLS_SH_REMOVE_ROUTE: () => WORKSPACE_SKILLS_SH_REMOVE_ROUTE,
39
- WORKSPACE_SKILLS_SH_ROUTES: () => WORKSPACE_SKILLS_SH_ROUTES,
40
- WORKSPACE_SKILLS_SH_SEARCH_ROUTE: () => WORKSPACE_SKILLS_SH_SEARCH_ROUTE,
41
- WORKSPACE_SKILLS_SH_UPDATE_ROUTE: () => WORKSPACE_SKILLS_SH_UPDATE_ROUTE
42
- });
43
- /** Directory path for skills installed via skills.sh */
44
- const SKILLS_SH_DIR = ".agents/skills";
45
- /**
46
- * Runtime check for CompositeFilesystem using duck typing.
47
- * Uses a type-only import so older @mastra/core versions (< 1.3.0) work fine.
48
- */
49
- function isCompositeFilesystem(fs) {
50
- return !!fs && typeof fs === "object" && "mounts" in fs && fs.mounts instanceof Map;
51
- }
52
- /**
53
- * Check if an error is a workspace filesystem not-found error.
54
- * Handles Node.js ENOENT and workspace FileNotFoundError/DirectoryNotFoundError.
55
- */
56
- function isFilesystemNotFoundError(error) {
57
- if (!error || typeof error !== "object") return false;
58
- if ("code" in error && error.code === "ENOENT") return true;
59
- if ("name" in error) {
60
- const name = error.name;
61
- if (name === "FileNotFoundError" || name === "DirectoryNotFoundError") return true;
62
- }
63
- return false;
64
- }
65
- /**
66
- * Check if an error is a workspace filesystem permission error.
67
- * Handles Node.js EACCES and workspace PermissionError.
68
- */
69
- function isFilesystemPermissionError(error) {
70
- if (!error || typeof error !== "object") return false;
71
- if ("code" in error && error.code === "EACCES") return true;
72
- if ("name" in error && error.name === "PermissionError") return true;
73
- return false;
74
- }
75
- /**
76
- * Workspace-specific error handler.
77
- * Converts filesystem errors to appropriate HTTP status codes,
78
- * then falls back to generic handler.
79
- */
80
- function handleWorkspaceError(error, defaultMessage) {
81
- if (isFilesystemNotFoundError(error)) throw new HTTPException(404, { message: error instanceof Error ? error.message : "Not found" });
82
- if (isFilesystemPermissionError(error)) throw new HTTPException(403, { message: error instanceof Error ? error.message : "Permission denied" });
83
- return handleError(error, defaultMessage);
84
- }
85
- /**
86
- * Throws if workspace v1 is not supported by the current version of @mastra/core.
87
- */
88
- function requireWorkspaceV1Support() {
89
- if (!coreFeatures.has("workspaces-v1")) throw new HTTPException(501, { message: "Workspace v1 not supported by this version of @mastra/core. Please upgrade to a newer version." });
90
- }
91
- /**
92
- * Get a workspace by ID from Mastra's workspace registry.
93
- *
94
- * Backwards compatible: Falls back to searching through agents if
95
- * mastra.getWorkspaceById() is not available (older @mastra/core versions).
96
- */
97
- async function getWorkspaceById(mastra, workspaceId) {
98
- requireWorkspaceV1Support();
99
- const globalWorkspace = mastra.getWorkspace?.();
100
- if (globalWorkspace?.id === workspaceId) return globalWorkspace;
101
- if (typeof mastra.getWorkspaceById === "function") try {
102
- return mastra.getWorkspaceById(workspaceId);
103
- } catch {
104
- return;
105
- }
106
- const agents = mastra.listAgents?.() ?? {};
107
- for (const agent of Object.values(agents)) if (agent.hasOwnWorkspace?.()) {
108
- const agentWorkspace = await agent.getWorkspace?.();
109
- if (agentWorkspace?.id === workspaceId) return agentWorkspace;
110
- }
111
- }
112
- /**
113
- * Get skills from a specific workspace by ID.
114
- * Note: getWorkspaceById already checks for workspace v1 support.
115
- */
116
- async function getSkillsById(mastra, workspaceId) {
117
- return (await getWorkspaceById(mastra, workspaceId))?.skills;
118
- }
119
- /**
120
- * Build the install path for a skill from skills.sh.
121
- *
122
- * For CompositeFilesystem: resolves the requested mount (or first writable),
123
- * validates it is writable, and returns `<mount>/.agents/skills/<skillId>`.
124
- * For non-composite: returns `.agents/skills/<skillId>` (unchanged behavior).
125
- */
126
- /** Strip a single trailing slash (leaves `/` alone). */
127
- function stripTrailingSlash(p) {
128
- return p.length > 1 && p.endsWith("/") ? p.slice(0, -1) : p;
129
- }
130
- function buildSkillInstallPath(filesystem, safeSkillId, requestedMount) {
131
- if (isCompositeFilesystem(filesystem)) {
132
- if (requestedMount) {
133
- const mountFs = filesystem.mounts.get(requestedMount);
134
- if (!mountFs) throw new HTTPException(400, { message: `Mount "${requestedMount}" not found. Available mounts: ${filesystem.mountPaths.join(", ")}` });
135
- if (mountFs.readOnly) throw new HTTPException(403, { message: `Mount "${requestedMount}" is read-only` });
136
- return `${stripTrailingSlash(requestedMount)}/${SKILLS_SH_DIR}/${safeSkillId}`;
137
- }
138
- for (const [mountPath, mountFs] of filesystem.mounts) if (!mountFs.readOnly) return `${stripTrailingSlash(mountPath)}/${SKILLS_SH_DIR}/${safeSkillId}`;
139
- throw new HTTPException(403, { message: "No writable mount available for skill installation" });
140
- }
141
- return `${SKILLS_SH_DIR}/${safeSkillId}`;
142
- }
143
- const LIST_WORKSPACES_ROUTE = createRoute({
144
- method: "GET",
145
- path: "/workspaces",
146
- responseType: "json",
147
- responseSchema: listWorkspacesResponseSchema,
148
- summary: "List all workspaces",
149
- description: "Returns all workspaces from both Mastra instance and agents",
150
- tags: ["Workspace"],
151
- handler: async ({ mastra }) => {
152
- try {
153
- requireWorkspaceV1Support();
154
- const workspaces = [];
155
- if (typeof mastra.listWorkspaces === "function") {
156
- const registeredWorkspaces = mastra.listWorkspaces();
157
- for (const [, entry] of Object.entries(registeredWorkspaces)) {
158
- const ws = entry.workspace ?? entry;
159
- const source = entry.source ?? "mastra";
160
- const agentId = entry.agentId;
161
- const agentName = entry.agentName;
162
- workspaces.push({
163
- id: ws.id,
164
- name: ws.name,
165
- status: ws.status,
166
- source,
167
- ...source === "agent" && agentId ? {
168
- agentId,
169
- ...agentName != null ? { agentName } : {}
170
- } : {},
171
- capabilities: {
172
- hasFilesystem: !!ws.filesystem,
173
- hasSandbox: !!ws.sandbox,
174
- canBM25: ws.canBM25,
175
- canVector: ws.canVector,
176
- canHybrid: ws.canHybrid,
177
- hasSkills: !!ws.skills
178
- },
179
- safety: { readOnly: ws.filesystem?.readOnly ?? false }
180
- });
181
- }
182
- } else {
183
- const seenIds = /* @__PURE__ */ new Set();
184
- const globalWorkspace = mastra.getWorkspace?.();
185
- if (globalWorkspace) {
186
- seenIds.add(globalWorkspace.id);
187
- workspaces.push({
188
- id: globalWorkspace.id,
189
- name: globalWorkspace.name,
190
- status: globalWorkspace.status,
191
- source: "mastra",
192
- capabilities: {
193
- hasFilesystem: !!globalWorkspace.filesystem,
194
- hasSandbox: !!globalWorkspace.sandbox,
195
- canBM25: globalWorkspace.canBM25,
196
- canVector: globalWorkspace.canVector,
197
- canHybrid: globalWorkspace.canHybrid,
198
- hasSkills: !!globalWorkspace.skills
199
- },
200
- safety: { readOnly: globalWorkspace.filesystem?.readOnly ?? false }
201
- });
202
- }
203
- const agents = mastra.listAgents?.() ?? {};
204
- for (const [agentId, agent] of Object.entries(agents)) if (agent.hasOwnWorkspace?.()) try {
205
- const agentWorkspace = await agent.getWorkspace?.();
206
- if (agentWorkspace && !seenIds.has(agentWorkspace.id)) {
207
- seenIds.add(agentWorkspace.id);
208
- workspaces.push({
209
- id: agentWorkspace.id,
210
- name: agentWorkspace.name,
211
- status: agentWorkspace.status,
212
- source: "agent",
213
- agentId,
214
- agentName: agent.name,
215
- capabilities: {
216
- hasFilesystem: !!agentWorkspace.filesystem,
217
- hasSandbox: !!agentWorkspace.sandbox,
218
- canBM25: agentWorkspace.canBM25,
219
- canVector: agentWorkspace.canVector,
220
- canHybrid: agentWorkspace.canHybrid,
221
- hasSkills: !!agentWorkspace.skills
222
- },
223
- safety: { readOnly: agentWorkspace.filesystem?.readOnly ?? false }
224
- });
225
- }
226
- } catch {
227
- continue;
228
- }
229
- }
230
- return { workspaces };
231
- } catch (error) {
232
- return handleWorkspaceError(error, "Error listing workspaces");
233
- }
234
- }
235
- });
236
- const GET_WORKSPACE_ROUTE = createRoute({
237
- method: "GET",
238
- path: "/workspaces/:workspaceId",
239
- responseType: "json",
240
- pathParamSchema: workspaceIdPathParams,
241
- responseSchema: workspaceInfoResponseSchema,
242
- summary: "Get workspace info",
243
- description: "Returns information about a specific workspace and its capabilities",
244
- tags: ["Workspace"],
245
- handler: async ({ mastra, workspaceId }) => {
246
- try {
247
- const workspace = await getWorkspaceById(mastra, workspaceId);
248
- if (!workspace) return { isWorkspaceConfigured: false };
249
- const fsInfo = await workspace.filesystem?.getInfo?.();
250
- let mounts;
251
- if (isCompositeFilesystem(workspace.filesystem)) {
252
- mounts = [];
253
- for (const [mountPath, mountFs] of workspace.filesystem.mounts) try {
254
- const info = await mountFs.getInfo?.();
255
- mounts.push({
256
- path: mountPath,
257
- provider: info?.provider ?? mountFs.provider ?? "unknown",
258
- readOnly: mountFs.readOnly ?? false,
259
- displayName: info?.name ?? mountFs.name,
260
- icon: info?.icon,
261
- name: mountFs.name
262
- });
263
- } catch {
264
- mounts.push({
265
- path: mountPath,
266
- provider: mountFs.provider ?? "unknown",
267
- readOnly: mountFs.readOnly ?? true,
268
- name: mountFs.name
269
- });
270
- }
271
- }
272
- return {
273
- isWorkspaceConfigured: true,
274
- id: workspace.id,
275
- name: workspace.name,
276
- status: workspace.status,
277
- capabilities: {
278
- hasFilesystem: !!workspace.filesystem,
279
- hasSandbox: !!workspace.sandbox,
280
- canBM25: workspace.canBM25,
281
- canVector: workspace.canVector,
282
- canHybrid: workspace.canHybrid,
283
- hasSkills: !!workspace.skills
284
- },
285
- safety: { readOnly: workspace.filesystem?.readOnly ?? false },
286
- filesystem: fsInfo ? {
287
- id: fsInfo.id,
288
- name: fsInfo.name,
289
- provider: fsInfo.provider,
290
- status: fsInfo.status,
291
- error: fsInfo.error,
292
- readOnly: fsInfo.readOnly,
293
- icon: fsInfo.icon,
294
- metadata: fsInfo.metadata
295
- } : void 0,
296
- mounts
297
- };
298
- } catch (error) {
299
- return handleWorkspaceError(error, "Error getting workspace info");
300
- }
301
- }
302
- });
303
- const WORKSPACE_FS_READ_ROUTE = createRoute({
304
- method: "GET",
305
- path: "/workspaces/:workspaceId/fs/read",
306
- responseType: "json",
307
- pathParamSchema: workspaceIdPathParams,
308
- queryParamSchema: fsReadQuerySchema,
309
- responseSchema: fsReadResponseSchema,
310
- summary: "Read file content",
311
- description: "Returns the content of a file at the specified path",
312
- tags: ["Workspace"],
313
- handler: async ({ mastra, path, encoding, workspaceId }) => {
314
- try {
315
- requireWorkspaceV1Support();
316
- if (!path) throw new HTTPException(400, { message: "Path is required" });
317
- const workspace = await getWorkspaceById(mastra, workspaceId);
318
- if (!workspace?.filesystem) throw new HTTPException(404, { message: "No workspace filesystem configured" });
319
- const decodedPath = path;
320
- if (!await workspace.filesystem.exists(decodedPath)) throw new HTTPException(404, { message: `Path "${decodedPath}" not found` });
321
- const content = await workspace.filesystem.readFile(decodedPath, { encoding: encoding || "utf-8" });
322
- return {
323
- path: decodedPath,
324
- content: typeof content === "string" ? content : content.toString("utf-8"),
325
- type: "file"
326
- };
327
- } catch (error) {
328
- return handleWorkspaceError(error, "Error reading file");
329
- }
330
- }
331
- });
332
- const WORKSPACE_FS_WRITE_ROUTE = createRoute({
333
- method: "POST",
334
- path: "/workspaces/:workspaceId/fs/write",
335
- responseType: "json",
336
- pathParamSchema: workspaceIdPathParams,
337
- bodySchema: fsWriteBodySchema,
338
- responseSchema: fsWriteResponseSchema,
339
- summary: "Write file content",
340
- description: "Writes content to a file at the specified path. Supports base64 encoding for binary files.",
341
- tags: ["Workspace"],
342
- handler: async ({ mastra, path, content, encoding, recursive, workspaceId }) => {
343
- try {
344
- requireWorkspaceV1Support();
345
- if (!path || content === void 0) throw new HTTPException(400, { message: "Path and content are required" });
346
- const workspace = await getWorkspaceById(mastra, workspaceId);
347
- if (!workspace?.filesystem) throw new HTTPException(404, { message: "No workspace filesystem configured" });
348
- if (workspace.filesystem?.readOnly) throw new HTTPException(403, { message: "Workspace is in read-only mode" });
349
- const decodedPath = path;
350
- let fileContent = content;
351
- if (encoding === "base64") fileContent = Buffer.from(content, "base64");
352
- await workspace.filesystem.writeFile(decodedPath, fileContent, { recursive: recursive ?? true });
353
- return {
354
- success: true,
355
- path: decodedPath
356
- };
357
- } catch (error) {
358
- return handleWorkspaceError(error, "Error writing file");
359
- }
360
- }
361
- });
362
- const WORKSPACE_FS_LIST_ROUTE = createRoute({
363
- method: "GET",
364
- path: "/workspaces/:workspaceId/fs/list",
365
- responseType: "json",
366
- pathParamSchema: workspaceIdPathParams,
367
- queryParamSchema: fsListQuerySchema,
368
- responseSchema: fsListResponseSchema,
369
- summary: "List directory contents",
370
- description: "Returns a list of files and directories at the specified path",
371
- tags: ["Workspace"],
372
- handler: async ({ mastra, path, recursive, workspaceId }) => {
373
- try {
374
- requireWorkspaceV1Support();
375
- if (!path) throw new HTTPException(400, { message: "Path is required" });
376
- const workspace = await getWorkspaceById(mastra, workspaceId);
377
- if (!workspace?.filesystem) return {
378
- path,
379
- entries: [],
380
- error: "No workspace filesystem configured"
381
- };
382
- const decodedPath = path;
383
- if (!await workspace.filesystem.exists(decodedPath)) throw new HTTPException(404, { message: `Path "${decodedPath}" not found` });
384
- return {
385
- path: decodedPath,
386
- entries: await workspace.filesystem.readdir(decodedPath, { recursive })
387
- };
388
- } catch (error) {
389
- return handleWorkspaceError(error, "Error listing directory");
390
- }
391
- }
392
- });
393
- const WORKSPACE_FS_DELETE_ROUTE = createRoute({
394
- method: "DELETE",
395
- path: "/workspaces/:workspaceId/fs/delete",
396
- responseType: "json",
397
- pathParamSchema: workspaceIdPathParams,
398
- queryParamSchema: fsDeleteQuerySchema,
399
- responseSchema: fsDeleteResponseSchema,
400
- summary: "Delete file or directory",
401
- description: "Deletes a file or directory at the specified path",
402
- tags: ["Workspace"],
403
- handler: async ({ mastra, path, recursive, force, workspaceId }) => {
404
- try {
405
- requireWorkspaceV1Support();
406
- if (!path) throw new HTTPException(400, { message: "Path is required" });
407
- const workspace = await getWorkspaceById(mastra, workspaceId);
408
- if (!workspace?.filesystem) throw new HTTPException(404, { message: "No workspace filesystem configured" });
409
- if (workspace.filesystem?.readOnly) throw new HTTPException(403, { message: "Workspace is in read-only mode" });
410
- const decodedPath = path;
411
- const exists = await workspace.filesystem.exists(decodedPath);
412
- if (!exists && !force) throw new HTTPException(404, { message: `Path "${decodedPath}" not found` });
413
- if (exists) try {
414
- await workspace.filesystem.deleteFile(decodedPath, { force });
415
- } catch {
416
- await workspace.filesystem.rmdir(decodedPath, {
417
- recursive,
418
- force
419
- });
420
- }
421
- return {
422
- success: true,
423
- path: decodedPath
424
- };
425
- } catch (error) {
426
- return handleWorkspaceError(error, "Error deleting path");
427
- }
428
- }
429
- });
430
- const WORKSPACE_FS_MKDIR_ROUTE = createRoute({
431
- method: "POST",
432
- path: "/workspaces/:workspaceId/fs/mkdir",
433
- responseType: "json",
434
- pathParamSchema: workspaceIdPathParams,
435
- bodySchema: fsMkdirBodySchema,
436
- responseSchema: fsMkdirResponseSchema,
437
- summary: "Create directory",
438
- description: "Creates a directory at the specified path",
439
- tags: ["Workspace"],
440
- handler: async ({ mastra, path, recursive, workspaceId }) => {
441
- try {
442
- requireWorkspaceV1Support();
443
- if (!path) throw new HTTPException(400, { message: "Path is required" });
444
- const workspace = await getWorkspaceById(mastra, workspaceId);
445
- if (!workspace?.filesystem) throw new HTTPException(404, { message: "No workspace filesystem configured" });
446
- if (workspace.filesystem?.readOnly) throw new HTTPException(403, { message: "Workspace is in read-only mode" });
447
- const decodedPath = path;
448
- await workspace.filesystem.mkdir(decodedPath, { recursive: recursive ?? true });
449
- return {
450
- success: true,
451
- path: decodedPath
452
- };
453
- } catch (error) {
454
- return handleWorkspaceError(error, "Error creating directory");
455
- }
456
- }
457
- });
458
- const WORKSPACE_FS_STAT_ROUTE = createRoute({
459
- method: "GET",
460
- path: "/workspaces/:workspaceId/fs/stat",
461
- responseType: "json",
462
- pathParamSchema: workspaceIdPathParams,
463
- queryParamSchema: fsStatQuerySchema,
464
- responseSchema: fsStatResponseSchema,
465
- summary: "Get file/directory info",
466
- description: "Returns metadata about a file or directory",
467
- tags: ["Workspace"],
468
- handler: async ({ mastra, path, workspaceId }) => {
469
- try {
470
- requireWorkspaceV1Support();
471
- if (!path) throw new HTTPException(400, { message: "Path is required" });
472
- const workspace = await getWorkspaceById(mastra, workspaceId);
473
- if (!workspace?.filesystem) throw new HTTPException(404, { message: "No workspace filesystem configured" });
474
- const decodedPath = path;
475
- if (!await workspace.filesystem.exists(decodedPath)) throw new HTTPException(404, { message: `Path "${decodedPath}" not found` });
476
- const stat = await workspace.filesystem.stat(decodedPath);
477
- return {
478
- path: stat.path,
479
- type: stat.type,
480
- size: stat.size,
481
- createdAt: stat.createdAt?.toISOString(),
482
- modifiedAt: stat.modifiedAt?.toISOString(),
483
- mimeType: stat.mimeType
484
- };
485
- } catch (error) {
486
- return handleWorkspaceError(error, "Error getting file info");
487
- }
488
- }
489
- });
490
- const WORKSPACE_SEARCH_ROUTE = createRoute({
491
- method: "GET",
492
- path: "/workspaces/:workspaceId/search",
493
- responseType: "json",
494
- pathParamSchema: workspaceIdPathParams,
495
- queryParamSchema: searchQuerySchema,
496
- responseSchema: searchResponseSchema,
497
- summary: "Search workspace content",
498
- description: "Searches across indexed workspace content using BM25, vector, or hybrid search",
499
- tags: ["Workspace"],
500
- handler: async ({ mastra, query, topK, mode, minScore, workspaceId }) => {
501
- try {
502
- requireWorkspaceV1Support();
503
- if (!query) throw new HTTPException(400, { message: "Search query is required" });
504
- const workspace = await getWorkspaceById(mastra, workspaceId);
505
- if (!workspace) return {
506
- results: [],
507
- query,
508
- mode: mode || "bm25"
509
- };
510
- if (!(workspace.canBM25 || workspace.canVector)) return {
511
- results: [],
512
- query,
513
- mode: mode || "bm25"
514
- };
515
- let searchMode = mode;
516
- if (!searchMode) if (workspace.canHybrid) searchMode = "hybrid";
517
- else if (workspace.canVector) searchMode = "vector";
518
- else searchMode = "bm25";
519
- return {
520
- results: (await workspace.search(query, {
521
- topK: topK || 5,
522
- mode: searchMode,
523
- minScore
524
- })).map((r) => ({
525
- id: r.id,
526
- content: r.content,
527
- score: r.score,
528
- lineRange: r.lineRange,
529
- scoreDetails: r.scoreDetails
530
- })),
531
- query,
532
- mode: searchMode
533
- };
534
- } catch (error) {
535
- return handleWorkspaceError(error, "Error searching workspace");
536
- }
537
- }
538
- });
539
- const WORKSPACE_INDEX_ROUTE = createRoute({
540
- method: "POST",
541
- path: "/workspaces/:workspaceId/index",
542
- responseType: "json",
543
- pathParamSchema: workspaceIdPathParams,
544
- bodySchema: indexBodySchema,
545
- responseSchema: indexResponseSchema,
546
- summary: "Index content for search",
547
- description: "Indexes content for later search operations",
548
- tags: ["Workspace"],
549
- handler: async ({ mastra, path, content, metadata, workspaceId }) => {
550
- try {
551
- requireWorkspaceV1Support();
552
- if (!path || content === void 0) throw new HTTPException(400, { message: "Path and content are required" });
553
- const workspace = await getWorkspaceById(mastra, workspaceId);
554
- if (!workspace) throw new HTTPException(404, { message: "No workspace configured" });
555
- if (!(workspace.canBM25 || workspace.canVector)) throw new HTTPException(400, { message: "Workspace does not have search configured" });
556
- await workspace.index(path, content, { metadata });
557
- return {
558
- success: true,
559
- path
560
- };
561
- } catch (error) {
562
- return handleWorkspaceError(error, "Error indexing content");
563
- }
564
- }
565
- });
566
- /** Path prefix for skills installed via skills.sh (with trailing slash for prefix matching) */
567
- const SKILLS_SH_PATH_PREFIX = `${SKILLS_SH_DIR}/`;
568
- const WORKSPACE_LIST_SKILLS_ROUTE = createRoute({
569
- method: "GET",
570
- path: "/workspaces/:workspaceId/skills",
571
- responseType: "json",
572
- pathParamSchema: workspaceIdPathParams,
573
- responseSchema: listSkillsResponseSchema,
574
- summary: "List all skills",
575
- description: "Returns a list of all discovered skills with their metadata",
576
- tags: ["Workspace", "Skills"],
577
- handler: async ({ mastra, workspaceId, requestContext }) => {
578
- try {
579
- requireWorkspaceV1Support();
580
- const workspace = await getWorkspaceById(mastra, workspaceId);
581
- const skills = workspace?.skills;
582
- if (!skills) return {
583
- skills: [],
584
- isSkillsConfigured: false
585
- };
586
- await skills.maybeRefresh({ requestContext });
587
- const skillsList = await skills.list();
588
- return {
589
- skills: await Promise.all(skillsList.map(async (skillMeta) => {
590
- let skillsShSource;
591
- if (skillMeta.path.includes(SKILLS_SH_PATH_PREFIX) && workspace.filesystem) try {
592
- const metaPath = `${skillMeta.path}/.meta.json`;
593
- const metaContent = await workspace.filesystem.readFile(metaPath);
594
- const metaText = typeof metaContent === "string" ? metaContent : metaContent.toString("utf-8");
595
- const meta = JSON.parse(metaText);
596
- if (meta.owner && meta.repo) skillsShSource = {
597
- owner: meta.owner,
598
- repo: meta.repo
599
- };
600
- } catch {}
601
- return {
602
- name: skillMeta.name,
603
- description: skillMeta.description,
604
- license: skillMeta.license,
605
- compatibility: skillMeta.compatibility,
606
- metadata: skillMeta.metadata,
607
- path: skillMeta.path,
608
- skillsShSource
609
- };
610
- })),
611
- isSkillsConfigured: true
612
- };
613
- } catch (error) {
614
- return handleWorkspaceError(error, "Error listing skills");
615
- }
616
- }
617
- });
618
- const WORKSPACE_GET_SKILL_ROUTE = createRoute({
619
- method: "GET",
620
- path: "/workspaces/:workspaceId/skills/:skillName",
621
- responseType: "json",
622
- pathParamSchema: skillNamePathParams,
623
- queryParamSchema: skillDisambiguationQuerySchema,
624
- responseSchema: getSkillResponseSchema,
625
- summary: "Get skill details",
626
- description: "Returns the full details of a specific skill including instructions and file lists",
627
- tags: ["Workspace", "Skills"],
628
- handler: async ({ mastra, skillName, path, workspaceId, requestContext }) => {
629
- try {
630
- requireWorkspaceV1Support();
631
- if (!skillName) throw new HTTPException(400, { message: "Skill name is required" });
632
- const identifier = path ?? skillName;
633
- const skills = await getSkillsById(mastra, workspaceId);
634
- if (!skills) throw new HTTPException(404, { message: "No workspace with skills configured" });
635
- await skills.maybeRefresh({ requestContext });
636
- const skill = await skills.get(identifier);
637
- if (!skill) throw new HTTPException(404, { message: `Skill "${identifier}" not found` });
638
- return {
639
- name: skill.name,
640
- description: skill.description,
641
- license: skill.license,
642
- compatibility: skill.compatibility,
643
- metadata: skill.metadata,
644
- path: skill.path,
645
- instructions: skill.instructions,
646
- source: skill.source,
647
- references: skill.references,
648
- scripts: skill.scripts,
649
- assets: skill.assets
650
- };
651
- } catch (error) {
652
- return handleWorkspaceError(error, "Error getting skill");
653
- }
654
- }
655
- });
656
- const WORKSPACE_LIST_SKILL_REFERENCES_ROUTE = createRoute({
657
- method: "GET",
658
- path: "/workspaces/:workspaceId/skills/:skillName/references",
659
- responseType: "json",
660
- pathParamSchema: skillNamePathParams,
661
- queryParamSchema: skillDisambiguationQuerySchema,
662
- responseSchema: listReferencesResponseSchema,
663
- summary: "List skill references",
664
- description: "Returns a list of all reference file paths for a skill",
665
- tags: ["Workspace", "Skills"],
666
- handler: async ({ mastra, skillName, path, workspaceId, requestContext }) => {
667
- try {
668
- requireWorkspaceV1Support();
669
- if (!skillName) throw new HTTPException(400, { message: "Skill name is required" });
670
- const identifier = path ?? skillName;
671
- const skills = await getSkillsById(mastra, workspaceId);
672
- if (!skills) throw new HTTPException(404, { message: "No workspace with skills configured" });
673
- await skills.maybeRefresh({ requestContext });
674
- const skill = await skills.get(identifier);
675
- if (!skill) throw new HTTPException(404, { message: `Skill "${identifier}" not found` });
676
- const references = await skills.listReferences(identifier);
677
- return {
678
- skillName: skill.name,
679
- references
680
- };
681
- } catch (error) {
682
- return handleWorkspaceError(error, "Error listing skill references");
683
- }
684
- }
685
- });
686
- const WORKSPACE_GET_SKILL_REFERENCE_ROUTE = createRoute({
687
- method: "GET",
688
- path: "/workspaces/:workspaceId/skills/:skillName/references/:referencePath",
689
- responseType: "json",
690
- pathParamSchema: skillReferencePathParams,
691
- queryParamSchema: skillDisambiguationQuerySchema,
692
- responseSchema: skillReferenceResponseSchema,
693
- summary: "Get skill reference content",
694
- description: "Returns the content of a specific reference file from a skill",
695
- tags: ["Workspace", "Skills"],
696
- handler: async ({ mastra, skillName, path: skillPath, referencePath, workspaceId, requestContext }) => {
697
- try {
698
- requireWorkspaceV1Support();
699
- const identifier = skillPath ?? skillName;
700
- const skills = await getSkillsById(mastra, workspaceId);
701
- if (!skills) throw new HTTPException(404, { message: "No workspace with skills configured" });
702
- await skills.maybeRefresh({ requestContext });
703
- const skill = await skills.get(identifier);
704
- if (!skill) throw new HTTPException(404, { message: `Skill "${identifier}" not found` });
705
- const decodedPath = referencePath;
706
- assertSafeFilePath(decodedPath);
707
- const content = await skills.getReference(identifier, `references/${decodedPath}`);
708
- if (content === null) throw new HTTPException(404, { message: `Reference "${decodedPath}" not found in skill "${identifier}"` });
709
- return {
710
- skillName: skill.name,
711
- referencePath: decodedPath,
712
- content
713
- };
714
- } catch (error) {
715
- return handleWorkspaceError(error, "Error getting skill reference");
716
- }
717
- }
718
- });
719
- const WORKSPACE_SEARCH_SKILLS_ROUTE = createRoute({
720
- method: "GET",
721
- path: "/workspaces/:workspaceId/skills/search",
722
- responseType: "json",
723
- pathParamSchema: workspaceIdPathParams,
724
- queryParamSchema: searchSkillsQuerySchema,
725
- responseSchema: searchSkillsResponseSchema,
726
- summary: "Search skills",
727
- description: "Searches across all skills content using BM25 keyword search",
728
- tags: ["Workspace", "Skills"],
729
- handler: async ({ mastra, query, topK, minScore, skillNames, includeReferences, workspaceId, requestContext }) => {
730
- try {
731
- requireWorkspaceV1Support();
732
- if (!query) throw new HTTPException(400, { message: "Search query is required" });
733
- const skills = await getSkillsById(mastra, workspaceId);
734
- if (!skills) return {
735
- results: [],
736
- query
737
- };
738
- await skills.maybeRefresh({ requestContext });
739
- const skillNamesList = skillNames ? skillNames.split(",").map((s) => s.trim()) : void 0;
740
- return {
741
- results: (await skills.search(query, {
742
- topK: topK || 5,
743
- minScore,
744
- skillNames: skillNamesList,
745
- includeReferences: includeReferences ?? true
746
- })).map((r) => ({
747
- skillName: r.skillName,
748
- skillPath: r.skillPath,
749
- source: r.source,
750
- content: r.content,
751
- score: r.score,
752
- lineRange: r.lineRange,
753
- scoreDetails: r.scoreDetails
754
- })),
755
- query
756
- };
757
- } catch (error) {
758
- return handleWorkspaceError(error, "Error searching skills");
759
- }
760
- }
761
- });
762
- const SKILLS_SH_API_URL = "https://skills-api-production.up.railway.app";
763
- const WORKSPACE_SKILLS_SH_SEARCH_ROUTE = createRoute({
764
- method: "GET",
765
- path: "/workspaces/:workspaceId/skills-sh/search",
766
- responseType: "json",
767
- pathParamSchema: workspaceIdPathParams,
768
- queryParamSchema: skillsShSearchQuerySchema,
769
- responseSchema: skillsShSearchResponseSchema,
770
- summary: "Search skills on skills.sh",
771
- description: "Proxies search requests to skills.sh API to avoid CORS issues",
772
- tags: ["Workspace", "Skills"],
773
- handler: async ({ q, limit }) => {
774
- try {
775
- const controller = new AbortController();
776
- const timeoutId = setTimeout(() => controller.abort(), 1e4);
777
- const url = `${SKILLS_SH_API_URL}/api/skills?query=${encodeURIComponent(q)}&pageSize=${limit}`;
778
- const response = await fetch(url, { signal: controller.signal });
779
- clearTimeout(timeoutId);
780
- if (!response.ok) throw new HTTPException(502, { message: `Skills API error: ${response.status} ${response.statusText}` });
781
- const data = await response.json();
782
- return {
783
- query: q,
784
- searchType: "query",
785
- skills: data.skills.map((s) => ({
786
- id: s.skillId,
787
- name: s.name,
788
- installs: s.installs,
789
- topSource: s.source
790
- })),
791
- count: data.total
792
- };
793
- } catch (error) {
794
- if (error instanceof HTTPException) throw error;
795
- return handleError(error, "Error searching skills");
796
- }
797
- }
798
- });
799
- const WORKSPACE_SKILLS_SH_POPULAR_ROUTE = createRoute({
800
- method: "GET",
801
- path: "/workspaces/:workspaceId/skills-sh/popular",
802
- responseType: "json",
803
- pathParamSchema: workspaceIdPathParams,
804
- queryParamSchema: skillsShPopularQuerySchema,
805
- responseSchema: skillsShListResponseSchema,
806
- summary: "Get popular skills from skills.sh",
807
- description: "Proxies popular skills requests to skills.sh API to avoid CORS issues",
808
- tags: ["Workspace", "Skills"],
809
- handler: async ({ limit, offset }) => {
810
- try {
811
- const controller = new AbortController();
812
- const timeoutId = setTimeout(() => controller.abort(), 1e4);
813
- const page = offset > 0 ? Math.floor(offset / limit) + 1 : 1;
814
- const url = `${SKILLS_SH_API_URL}/api/skills/top?pageSize=${limit}&page=${page}`;
815
- const response = await fetch(url, { signal: controller.signal });
816
- clearTimeout(timeoutId);
817
- if (!response.ok) throw new HTTPException(502, { message: `Skills API error: ${response.status} ${response.statusText}` });
818
- const data = await response.json();
819
- return {
820
- skills: data.skills.map((s) => ({
821
- id: s.skillId,
822
- name: s.name,
823
- installs: s.installs,
824
- topSource: s.source
825
- })),
826
- count: data.total,
827
- limit,
828
- offset
829
- };
830
- } catch (error) {
831
- if (error instanceof HTTPException) throw error;
832
- return handleError(error, "Error fetching popular skills");
833
- }
834
- }
835
- });
836
- /**
837
- * Validate skill name to prevent path traversal attacks.
838
- * Only allows alphanumeric characters, hyphens, and underscores.
839
- */
840
- const SKILL_NAME_REGEX = /^[a-z0-9][a-z0-9-_]*$/i;
841
- function assertSafeSkillName(name) {
842
- if (!SKILL_NAME_REGEX.test(name)) throw new HTTPException(400, { message: `Invalid skill name "${name}". Names must start with alphanumeric and contain only letters, numbers, hyphens, and underscores.` });
843
- return name;
844
- }
845
- /**
846
- * Validate that a file path is safe (no traversal, no absolute paths).
847
- * Prevents malicious API responses from writing files outside the skill directory.
848
- */
849
- function assertSafeFilePath(filePath) {
850
- if (filePath.startsWith("/") || /^[a-zA-Z]:/.test(filePath)) throw new HTTPException(400, { message: `Invalid file path "${filePath}". Absolute paths are not allowed.` });
851
- const segments = filePath.split("/");
852
- for (const segment of segments) if (segment === ".." || segment === ".") throw new HTTPException(400, { message: `Invalid file path "${filePath}". Path traversal is not allowed.` });
853
- return filePath;
854
- }
855
- /**
856
- * Fetch skill files from the Skills API.
857
- * Returns all files for a skill with their content.
858
- */
859
- async function fetchSkillFiles(owner, repo, skillName) {
860
- const controller = new AbortController();
861
- const timeoutId = setTimeout(() => controller.abort(), 3e4);
862
- const url = `${SKILLS_SH_API_URL}/api/skills/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${encodeURIComponent(skillName)}/files`;
863
- const response = await fetch(url, { signal: controller.signal });
864
- clearTimeout(timeoutId);
865
- if (!response.ok) {
866
- if (response.status === 404) return null;
867
- throw new Error(`Skills API error: ${response.status} ${response.statusText}`);
868
- }
869
- return await response.json();
870
- }
871
- const WORKSPACE_SKILLS_SH_PREVIEW_ROUTE = createRoute({
872
- method: "GET",
873
- path: "/workspaces/:workspaceId/skills-sh/preview",
874
- responseType: "json",
875
- pathParamSchema: workspaceIdPathParams,
876
- queryParamSchema: skillsShPreviewQuerySchema,
877
- responseSchema: skillsShPreviewResponseSchema,
878
- summary: "Preview skill content",
879
- description: "Fetches the skill content from the Skills API.",
880
- tags: ["Workspace", "Skills"],
881
- handler: async ({ owner, repo, path: skillName }) => {
882
- try {
883
- const controller = new AbortController();
884
- const timeoutId = setTimeout(() => controller.abort(), 1e4);
885
- const url = `${SKILLS_SH_API_URL}/api/skills/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${encodeURIComponent(skillName)}/content`;
886
- const response = await fetch(url, { signal: controller.signal });
887
- clearTimeout(timeoutId);
888
- if (!response.ok) throw new HTTPException(404, { message: `Could not find skill "${skillName}" for ${owner}/${repo}` });
889
- const data = await response.json();
890
- const content = data.instructions || data.raw || "";
891
- if (!content) throw new HTTPException(404, { message: `No content available for skill "${skillName}"` });
892
- return { content };
893
- } catch (error) {
894
- if (error instanceof HTTPException) throw error;
895
- return handleError(error, "Error fetching skill preview");
896
- }
897
- }
898
- });
899
- const WORKSPACE_SKILLS_SH_INSTALL_ROUTE = createRoute({
900
- method: "POST",
901
- path: "/workspaces/:workspaceId/skills-sh/install",
902
- responseType: "json",
903
- pathParamSchema: workspaceIdPathParams,
904
- bodySchema: skillsShInstallBodySchema,
905
- responseSchema: skillsShInstallResponseSchema,
906
- summary: "Install skill from Skills API",
907
- description: "Installs a skill by fetching files from the Skills API and writing to workspace filesystem.",
908
- tags: ["Workspace", "Skills"],
909
- handler: async ({ mastra, workspaceId, owner, repo, skillName, mount }) => {
910
- try {
911
- requireWorkspaceV1Support();
912
- const workspace = await getWorkspaceById(mastra, workspaceId);
913
- if (!workspace) throw new HTTPException(404, { message: "Workspace not found" });
914
- if (!workspace.filesystem) throw new HTTPException(400, { message: "Workspace filesystem not available" });
915
- if (workspace.filesystem.readOnly) throw new HTTPException(403, { message: "Workspace is read-only" });
916
- const result = await fetchSkillFiles(owner, repo, skillName);
917
- if (!result || result.files.length === 0) throw new HTTPException(404, { message: `Could not find skill "${skillName}" in ${owner}/${repo}.` });
918
- const safeSkillId = assertSafeSkillName(result.skillId);
919
- const installPath = buildSkillInstallPath(workspace.filesystem, safeSkillId, mount);
920
- try {
921
- await workspace.filesystem.mkdir(installPath, { recursive: true });
922
- } catch {}
923
- let filesWritten = 0;
924
- for (const file of result.files) {
925
- const safePath = assertSafeFilePath(file.path);
926
- const filePath = `${installPath}/${safePath}`;
927
- if (safePath.includes("/")) {
928
- const dirPath = filePath.substring(0, filePath.lastIndexOf("/"));
929
- try {
930
- await workspace.filesystem.mkdir(dirPath, { recursive: true });
931
- } catch {}
932
- }
933
- const content = file.encoding === "base64" ? Buffer.from(file.content, "base64") : file.content;
934
- await workspace.filesystem.writeFile(filePath, content);
935
- filesWritten++;
936
- }
937
- const metadata = {
938
- skillName: result.skillId,
939
- owner: result.owner,
940
- repo: result.repo,
941
- branch: result.branch,
942
- installedAt: (/* @__PURE__ */ new Date()).toISOString()
943
- };
944
- await workspace.filesystem.writeFile(`${installPath}/.meta.json`, JSON.stringify(metadata, null, 2));
945
- filesWritten++;
946
- if (workspace.skills?.addSkill) try {
947
- await workspace.skills.addSkill(installPath);
948
- } catch (cacheError) {
949
- console.warn(`[skills-sh] Failed to update cache after install: ${cacheError instanceof Error ? cacheError.message : String(cacheError)}`);
950
- }
951
- return {
952
- success: true,
953
- skillName: result.skillId,
954
- installedPath: installPath,
955
- filesWritten
956
- };
957
- } catch (error) {
958
- if (error instanceof HTTPException) throw error;
959
- return handleError(error, "Error installing skill");
960
- }
961
- }
962
- });
963
- const WORKSPACE_SKILLS_SH_REMOVE_ROUTE = createRoute({
964
- method: "POST",
965
- path: "/workspaces/:workspaceId/skills-sh/remove",
966
- responseType: "json",
967
- pathParamSchema: workspaceIdPathParams,
968
- bodySchema: skillsShRemoveBodySchema,
969
- responseSchema: skillsShRemoveResponseSchema,
970
- summary: "Remove an installed skill",
971
- description: "Removes an installed skill by deleting its directory. Does not require sandbox.",
972
- tags: ["Workspace", "Skills"],
973
- handler: async ({ mastra, workspaceId, skillName }) => {
974
- try {
975
- requireWorkspaceV1Support();
976
- const workspace = await getWorkspaceById(mastra, workspaceId);
977
- if (!workspace) throw new HTTPException(404, { message: "Workspace not found" });
978
- if (!workspace.filesystem) throw new HTTPException(400, { message: "Workspace filesystem not available" });
979
- if (workspace.filesystem.readOnly) throw new HTTPException(403, { message: "Workspace is read-only" });
980
- const safeSkillName = assertSafeSkillName(skillName);
981
- const skillPath = ((await workspace.skills?.list())?.find((s) => s.name === safeSkillName && s.path.includes(SKILLS_SH_PATH_PREFIX)))?.path ?? buildSkillInstallPath(workspace.filesystem, safeSkillName);
982
- try {
983
- await workspace.filesystem.stat(skillPath);
984
- } catch {
985
- throw new HTTPException(404, { message: `Skill "${skillName}" not found at ${skillPath}` });
986
- }
987
- await workspace.filesystem.rmdir(skillPath, { recursive: true });
988
- if (workspace.skills?.removeSkill) try {
989
- await workspace.skills.removeSkill(skillPath);
990
- } catch (cacheError) {
991
- console.warn(`[skills-sh] Failed to update cache after remove: ${cacheError instanceof Error ? cacheError.message : String(cacheError)}`);
992
- }
993
- return {
994
- success: true,
995
- skillName,
996
- removedPath: skillPath
997
- };
998
- } catch (error) {
999
- if (error instanceof HTTPException) throw error;
1000
- return handleError(error, "Error removing skill");
1001
- }
1002
- }
1003
- });
1004
- const WORKSPACE_SKILLS_SH_UPDATE_ROUTE = createRoute({
1005
- method: "POST",
1006
- path: "/workspaces/:workspaceId/skills-sh/update",
1007
- responseType: "json",
1008
- pathParamSchema: workspaceIdPathParams,
1009
- bodySchema: skillsShUpdateBodySchema,
1010
- responseSchema: skillsShUpdateResponseSchema,
1011
- summary: "Update installed skills",
1012
- description: "Updates installed skills by re-fetching from GitHub. Specify skillName to update one, or omit to update all.",
1013
- tags: ["Workspace", "Skills"],
1014
- handler: async ({ mastra, workspaceId, skillName }) => {
1015
- try {
1016
- requireWorkspaceV1Support();
1017
- const workspace = await getWorkspaceById(mastra, workspaceId);
1018
- if (!workspace) throw new HTTPException(404, { message: "Workspace not found" });
1019
- if (!workspace.filesystem) throw new HTTPException(400, { message: "Workspace filesystem not available" });
1020
- if (workspace.filesystem.readOnly) throw new HTTPException(403, { message: "Workspace is read-only" });
1021
- const results = [];
1022
- let skillsToUpdate;
1023
- if (skillName) {
1024
- const safeName = assertSafeSkillName(skillName);
1025
- const discoveredSkill = (await workspace.skills?.list())?.find((s) => s.name === safeName && s.path.includes(SKILLS_SH_PATH_PREFIX));
1026
- let basePath;
1027
- if (discoveredSkill?.path) basePath = discoveredSkill.path.substring(0, discoveredSkill.path.lastIndexOf("/"));
1028
- else basePath = SKILLS_SH_DIR;
1029
- skillsToUpdate = [{
1030
- name: safeName,
1031
- basePath
1032
- }];
1033
- } else {
1034
- skillsToUpdate = [];
1035
- const dirsToScan = [];
1036
- if (isCompositeFilesystem(workspace.filesystem)) {
1037
- for (const [mountPath, mountFs] of workspace.filesystem.mounts) if (!mountFs.readOnly) dirsToScan.push(`${stripTrailingSlash(mountPath)}/${SKILLS_SH_DIR}`);
1038
- } else dirsToScan.push(SKILLS_SH_DIR);
1039
- for (const dir of dirsToScan) try {
1040
- const entries = await workspace.filesystem.readdir(dir);
1041
- for (const e of entries) if (e.type === "directory") skillsToUpdate.push({
1042
- name: e.name,
1043
- basePath: dir
1044
- });
1045
- } catch {}
1046
- if (skillsToUpdate.length === 0) return { updated: [] };
1047
- }
1048
- for (const { name: skill, basePath } of skillsToUpdate) {
1049
- try {
1050
- assertSafeSkillName(skill);
1051
- } catch {
1052
- results.push({
1053
- skillName: skill,
1054
- success: false,
1055
- error: "Invalid skill name"
1056
- });
1057
- continue;
1058
- }
1059
- const installPath = `${basePath}/${skill}`;
1060
- const metaPath = `${installPath}/.meta.json`;
1061
- try {
1062
- const metaContent = await workspace.filesystem.readFile(metaPath, { encoding: "utf-8" });
1063
- const meta = JSON.parse(metaContent);
1064
- const fetchResult = await fetchSkillFiles(meta.owner, meta.repo, meta.skillName);
1065
- if (!fetchResult || fetchResult.files.length === 0) {
1066
- results.push({
1067
- skillName: skill,
1068
- success: false,
1069
- error: "No files found in skill directory"
1070
- });
1071
- continue;
1072
- }
1073
- let filesWritten = 0;
1074
- for (const file of fetchResult.files) {
1075
- const safePath = assertSafeFilePath(file.path);
1076
- const filePath = `${installPath}/${safePath}`;
1077
- if (safePath.includes("/")) {
1078
- const dirPath = filePath.substring(0, filePath.lastIndexOf("/"));
1079
- try {
1080
- await workspace.filesystem.mkdir(dirPath, { recursive: true });
1081
- } catch {}
1082
- }
1083
- const content = file.encoding === "base64" ? Buffer.from(file.content, "base64") : file.content;
1084
- await workspace.filesystem.writeFile(filePath, content);
1085
- filesWritten++;
1086
- }
1087
- const updatedMeta = {
1088
- ...meta,
1089
- branch: fetchResult.branch,
1090
- installedAt: (/* @__PURE__ */ new Date()).toISOString()
1091
- };
1092
- await workspace.filesystem.writeFile(metaPath, JSON.stringify(updatedMeta, null, 2));
1093
- filesWritten++;
1094
- if (workspace.skills?.addSkill) try {
1095
- await workspace.skills.addSkill(installPath);
1096
- } catch (cacheError) {
1097
- console.warn(`[skills-sh] Failed to update cache after update: ${cacheError instanceof Error ? cacheError.message : String(cacheError)}`);
1098
- }
1099
- results.push({
1100
- skillName: skill,
1101
- success: true,
1102
- filesWritten
1103
- });
1104
- } catch (error) {
1105
- results.push({
1106
- skillName: skill,
1107
- success: false,
1108
- error: error instanceof Error ? error.message : "Unknown error"
1109
- });
1110
- }
1111
- }
1112
- return { updated: results };
1113
- } catch (error) {
1114
- if (error instanceof HTTPException) throw error;
1115
- return handleError(error, "Error updating skills");
1116
- }
1117
- }
1118
- });
1119
- const WORKSPACE_SKILLS_SH_ROUTES = [
1120
- WORKSPACE_SKILLS_SH_SEARCH_ROUTE,
1121
- WORKSPACE_SKILLS_SH_POPULAR_ROUTE,
1122
- WORKSPACE_SKILLS_SH_PREVIEW_ROUTE,
1123
- WORKSPACE_SKILLS_SH_INSTALL_ROUTE,
1124
- WORKSPACE_SKILLS_SH_REMOVE_ROUTE,
1125
- WORKSPACE_SKILLS_SH_UPDATE_ROUTE
1126
- ];
1127
- const WORKSPACE_FS_ROUTES = [
1128
- WORKSPACE_FS_READ_ROUTE,
1129
- WORKSPACE_FS_WRITE_ROUTE,
1130
- WORKSPACE_FS_LIST_ROUTE,
1131
- WORKSPACE_FS_DELETE_ROUTE,
1132
- WORKSPACE_FS_MKDIR_ROUTE,
1133
- WORKSPACE_FS_STAT_ROUTE
1134
- ];
1135
- const WORKSPACE_SEARCH_ROUTES = [WORKSPACE_SEARCH_ROUTE, WORKSPACE_INDEX_ROUTE];
1136
- const WORKSPACE_SKILLS_ROUTES = [
1137
- WORKSPACE_SEARCH_SKILLS_ROUTE,
1138
- WORKSPACE_LIST_SKILLS_ROUTE,
1139
- WORKSPACE_GET_SKILL_ROUTE,
1140
- WORKSPACE_LIST_SKILL_REFERENCES_ROUTE,
1141
- WORKSPACE_GET_SKILL_REFERENCE_ROUTE
1142
- ];
1143
- //#endregion
1144
- export { GET_WORKSPACE_ROUTE, LIST_WORKSPACES_ROUTE, WORKSPACE_FS_DELETE_ROUTE, WORKSPACE_FS_LIST_ROUTE, WORKSPACE_FS_MKDIR_ROUTE, WORKSPACE_FS_READ_ROUTE, WORKSPACE_FS_ROUTES, WORKSPACE_FS_STAT_ROUTE, WORKSPACE_FS_WRITE_ROUTE, WORKSPACE_GET_SKILL_REFERENCE_ROUTE, WORKSPACE_GET_SKILL_ROUTE, WORKSPACE_INDEX_ROUTE, WORKSPACE_LIST_SKILLS_ROUTE, WORKSPACE_LIST_SKILL_REFERENCES_ROUTE, WORKSPACE_SEARCH_ROUTE, WORKSPACE_SEARCH_ROUTES, WORKSPACE_SEARCH_SKILLS_ROUTE, WORKSPACE_SKILLS_ROUTES, WORKSPACE_SKILLS_SH_INSTALL_ROUTE, WORKSPACE_SKILLS_SH_POPULAR_ROUTE, WORKSPACE_SKILLS_SH_PREVIEW_ROUTE, WORKSPACE_SKILLS_SH_REMOVE_ROUTE, WORKSPACE_SKILLS_SH_ROUTES, WORKSPACE_SKILLS_SH_SEARCH_ROUTE, WORKSPACE_SKILLS_SH_UPDATE_ROUTE, workspace_exports as t };
1145
-
1146
- //# sourceMappingURL=workspace.js.map
1
+ export { t as GET_WORKSPACE_ROUTE, n as LIST_WORKSPACES_ROUTE, r as WORKSPACE_FS_DELETE_ROUTE, i as WORKSPACE_FS_LIST_ROUTE, a as WORKSPACE_FS_MKDIR_ROUTE, o as WORKSPACE_FS_READ_ROUTE, s as WORKSPACE_FS_ROUTES, c as WORKSPACE_FS_STAT_ROUTE, l as WORKSPACE_FS_WRITE_ROUTE, u as WORKSPACE_GET_SKILL_REFERENCE_ROUTE, d as WORKSPACE_GET_SKILL_ROUTE, f as WORKSPACE_INDEX_ROUTE, p as WORKSPACE_LIST_SKILLS_ROUTE, m as WORKSPACE_LIST_SKILL_REFERENCES_ROUTE, h as WORKSPACE_SEARCH_ROUTE, g as WORKSPACE_SEARCH_ROUTES, _ as WORKSPACE_SEARCH_SKILLS_ROUTE, v as WORKSPACE_SKILLS_ROUTES, y as WORKSPACE_SKILLS_SH_INSTALL_ROUTE, b as WORKSPACE_SKILLS_SH_POPULAR_ROUTE, x as WORKSPACE_SKILLS_SH_PREVIEW_ROUTE, S as WORKSPACE_SKILLS_SH_REMOVE_ROUTE, C as WORKSPACE_SKILLS_SH_ROUTES, w as WORKSPACE_SKILLS_SH_SEARCH_ROUTE, T as WORKSPACE_SKILLS_SH_UPDATE_ROUTE } from "../../workspace-B6kzp-bo.js";