@skaile/workspaces 6.5.0 → 6.6.0

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 (239) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/ai-sdk.js +9 -9
  3. package/dist/{asset-feeds-4I6Z4OI3.js → asset-feeds-WQ6YQPHV.js} +20 -20
  4. package/dist/{asset-feeds-4I6Z4OI3.js.map → asset-feeds-WQ6YQPHV.js.map} +1 -1
  5. package/dist/asset-manager/catalog-deployer.js +7 -7
  6. package/dist/asset-manager/index.js +12 -12
  7. package/dist/asset-manager/installer.js +8 -8
  8. package/dist/asset-manager/renderers.js +7 -7
  9. package/dist/bridge/harnesses/claude-sdk.js +10 -10
  10. package/dist/bridge/harnesses/codex.js +11 -11
  11. package/dist/bridge/harnesses/continue.js +10 -10
  12. package/dist/bridge/harnesses/echo.js +3 -3
  13. package/dist/bridge/harnesses/gemini.js +7 -7
  14. package/dist/bridge/harnesses/goose.js +10 -10
  15. package/dist/bridge/harnesses/omp.js +5 -5
  16. package/dist/bridge/harnesses/opencode.js +10 -10
  17. package/dist/bridge/harnesses/qwen.js +7 -7
  18. package/dist/bridge/index.js +15 -15
  19. package/dist/{chunk-J5JWLKLB.js → chunk-2TLPC6TQ.js} +11 -11
  20. package/dist/{chunk-J5JWLKLB.js.map → chunk-2TLPC6TQ.js.map} +1 -1
  21. package/dist/{chunk-2IAWVUW3.js → chunk-4BFEPZ6J.js} +4 -4
  22. package/dist/{chunk-2IAWVUW3.js.map → chunk-4BFEPZ6J.js.map} +1 -1
  23. package/dist/{chunk-KUADKMNX.js → chunk-4J7JQX4G.js} +4 -4
  24. package/dist/{chunk-KUADKMNX.js.map → chunk-4J7JQX4G.js.map} +1 -1
  25. package/dist/{chunk-USVUS4DJ.js → chunk-5ETYBC2X.js} +7 -7
  26. package/dist/{chunk-USVUS4DJ.js.map → chunk-5ETYBC2X.js.map} +1 -1
  27. package/dist/{chunk-X44XKBZX.js → chunk-5XHQBCB5.js} +3 -3
  28. package/dist/{chunk-X44XKBZX.js.map → chunk-5XHQBCB5.js.map} +1 -1
  29. package/dist/{chunk-OLHHN3NO.js → chunk-65UAC3ZR.js} +3 -3
  30. package/dist/{chunk-OLHHN3NO.js.map → chunk-65UAC3ZR.js.map} +1 -1
  31. package/dist/{chunk-7H4GTP7V.js → chunk-6A6HE5LW.js} +3 -3
  32. package/dist/{chunk-7H4GTP7V.js.map → chunk-6A6HE5LW.js.map} +1 -1
  33. package/dist/{chunk-UMLCKKIA.js → chunk-6ARPZHOV.js} +6 -6
  34. package/dist/{chunk-UMLCKKIA.js.map → chunk-6ARPZHOV.js.map} +1 -1
  35. package/dist/{chunk-K4DHYTUM.js → chunk-6RHWTZPT.js} +3 -3
  36. package/dist/{chunk-K4DHYTUM.js.map → chunk-6RHWTZPT.js.map} +1 -1
  37. package/dist/{chunk-IWKKTCXY.js → chunk-6SXSVKQY.js} +7 -5
  38. package/dist/chunk-6SXSVKQY.js.map +1 -0
  39. package/dist/{chunk-OBZ5WQ32.js → chunk-7I5PNB2G.js} +3 -3
  40. package/dist/{chunk-OBZ5WQ32.js.map → chunk-7I5PNB2G.js.map} +1 -1
  41. package/dist/{chunk-SRTWKZP2.js → chunk-7PVGND4J.js} +8 -8
  42. package/dist/{chunk-SRTWKZP2.js.map → chunk-7PVGND4J.js.map} +1 -1
  43. package/dist/{chunk-TROEC2Z2.js → chunk-7SJHSGUV.js} +16 -16
  44. package/dist/{chunk-TROEC2Z2.js.map → chunk-7SJHSGUV.js.map} +1 -1
  45. package/dist/{chunk-TNQLDEM6.js → chunk-AQNW2FET.js} +230 -35
  46. package/dist/chunk-AQNW2FET.js.map +1 -0
  47. package/dist/{chunk-6EKQENAP.js → chunk-B6N653ZG.js} +6 -6
  48. package/dist/{chunk-6EKQENAP.js.map → chunk-B6N653ZG.js.map} +1 -1
  49. package/dist/{chunk-NSIOBKDX.js → chunk-BSMW3PX2.js} +2 -2
  50. package/dist/{chunk-NSIOBKDX.js.map → chunk-BSMW3PX2.js.map} +1 -1
  51. package/dist/{chunk-HTGTNN2B.js → chunk-CMXDFTA2.js} +3 -3
  52. package/dist/{chunk-HTGTNN2B.js.map → chunk-CMXDFTA2.js.map} +1 -1
  53. package/dist/{chunk-2HS357RA.js → chunk-DI6J2PJB.js} +7 -7
  54. package/dist/{chunk-2HS357RA.js.map → chunk-DI6J2PJB.js.map} +1 -1
  55. package/dist/{chunk-T7HGEMNB.js → chunk-DS6UUCFG.js} +3 -3
  56. package/dist/{chunk-T7HGEMNB.js.map → chunk-DS6UUCFG.js.map} +1 -1
  57. package/dist/{chunk-23SG4JRV.js → chunk-E2EC6SAX.js} +3 -3
  58. package/dist/{chunk-23SG4JRV.js.map → chunk-E2EC6SAX.js.map} +1 -1
  59. package/dist/{chunk-ETF6Q3R3.js → chunk-EPXZQIC6.js} +3 -3
  60. package/dist/{chunk-ETF6Q3R3.js.map → chunk-EPXZQIC6.js.map} +1 -1
  61. package/dist/{chunk-SZTHSPRC.js → chunk-F4CZQD3T.js} +3 -3
  62. package/dist/{chunk-SZTHSPRC.js.map → chunk-F4CZQD3T.js.map} +1 -1
  63. package/dist/{chunk-AVFRFGM2.js → chunk-GNUA7XT2.js} +3 -2
  64. package/dist/chunk-GNUA7XT2.js.map +1 -0
  65. package/dist/{chunk-6Y3SC7O4.js → chunk-GTAHU4N4.js} +4 -4
  66. package/dist/{chunk-6Y3SC7O4.js.map → chunk-GTAHU4N4.js.map} +1 -1
  67. package/dist/{chunk-3KSLUVKB.js → chunk-GTGWRKMJ.js} +6 -6
  68. package/dist/{chunk-3KSLUVKB.js.map → chunk-GTGWRKMJ.js.map} +1 -1
  69. package/dist/{chunk-YRC2EFOU.js → chunk-HGZN6JLP.js} +4 -4
  70. package/dist/{chunk-YRC2EFOU.js.map → chunk-HGZN6JLP.js.map} +1 -1
  71. package/dist/{chunk-KYNCY3F3.js → chunk-HQAPUPBE.js} +3 -3
  72. package/dist/{chunk-KYNCY3F3.js.map → chunk-HQAPUPBE.js.map} +1 -1
  73. package/dist/{chunk-HPA3RP5E.js → chunk-I5IF3JCG.js} +3 -3
  74. package/dist/{chunk-HPA3RP5E.js.map → chunk-I5IF3JCG.js.map} +1 -1
  75. package/dist/{chunk-7EMS2GZO.js → chunk-J262X4JU.js} +12 -12
  76. package/dist/{chunk-7EMS2GZO.js.map → chunk-J262X4JU.js.map} +1 -1
  77. package/dist/{chunk-22ZX33H6.js → chunk-J4WKNJHO.js} +4 -4
  78. package/dist/{chunk-22ZX33H6.js.map → chunk-J4WKNJHO.js.map} +1 -1
  79. package/dist/{chunk-G4NCSYWR.js → chunk-JIQUF3X2.js} +4 -4
  80. package/dist/{chunk-G4NCSYWR.js.map → chunk-JIQUF3X2.js.map} +1 -1
  81. package/dist/{chunk-IS3NIZBX.js → chunk-JRVQV7WC.js} +11 -11
  82. package/dist/{chunk-IS3NIZBX.js.map → chunk-JRVQV7WC.js.map} +1 -1
  83. package/dist/{chunk-UZET67SO.js → chunk-LBJ4M5J2.js} +4 -4
  84. package/dist/{chunk-UZET67SO.js.map → chunk-LBJ4M5J2.js.map} +1 -1
  85. package/dist/{chunk-TGUMN5G7.js → chunk-MMOWIRHP.js} +8 -8
  86. package/dist/{chunk-TGUMN5G7.js.map → chunk-MMOWIRHP.js.map} +1 -1
  87. package/dist/{chunk-EO7KGX6P.js → chunk-MXI3XWV6.js} +4 -4
  88. package/dist/{chunk-EO7KGX6P.js.map → chunk-MXI3XWV6.js.map} +1 -1
  89. package/dist/{chunk-LE6QS4PG.js → chunk-N2PBAXAA.js} +3 -3
  90. package/dist/{chunk-LE6QS4PG.js.map → chunk-N2PBAXAA.js.map} +1 -1
  91. package/dist/{chunk-YBEJCQE5.js → chunk-O7QZI6MQ.js} +3 -3
  92. package/dist/{chunk-YBEJCQE5.js.map → chunk-O7QZI6MQ.js.map} +1 -1
  93. package/dist/{chunk-ZUU2PLA3.js → chunk-OY22B7E2.js} +3 -3
  94. package/dist/{chunk-ZUU2PLA3.js.map → chunk-OY22B7E2.js.map} +1 -1
  95. package/dist/{chunk-W5KCAWGN.js → chunk-PTJTOPE5.js} +3 -3
  96. package/dist/{chunk-W5KCAWGN.js.map → chunk-PTJTOPE5.js.map} +1 -1
  97. package/dist/{chunk-WFLQMAR5.js → chunk-RAU5QPI6.js} +5 -5
  98. package/dist/{chunk-WFLQMAR5.js.map → chunk-RAU5QPI6.js.map} +1 -1
  99. package/dist/{chunk-AFTZNR2W.js → chunk-RHCEX2EV.js} +3 -3
  100. package/dist/{chunk-AFTZNR2W.js.map → chunk-RHCEX2EV.js.map} +1 -1
  101. package/dist/{chunk-Z2X7UZEZ.js → chunk-SCRYXAHH.js} +6 -6
  102. package/dist/{chunk-Z2X7UZEZ.js.map → chunk-SCRYXAHH.js.map} +1 -1
  103. package/dist/{chunk-DKXNKFKP.js → chunk-SGI5MRKP.js} +75 -3
  104. package/dist/chunk-SGI5MRKP.js.map +1 -0
  105. package/dist/{chunk-KA2GLAPS.js → chunk-SHTXMERQ.js} +7 -7
  106. package/dist/{chunk-KA2GLAPS.js.map → chunk-SHTXMERQ.js.map} +1 -1
  107. package/dist/{chunk-SN663FCA.js → chunk-SZKCE7EC.js} +5 -5
  108. package/dist/{chunk-SN663FCA.js.map → chunk-SZKCE7EC.js.map} +1 -1
  109. package/dist/{chunk-S7DVT2BV.js → chunk-TCH5UDKT.js} +4 -4
  110. package/dist/{chunk-S7DVT2BV.js.map → chunk-TCH5UDKT.js.map} +1 -1
  111. package/dist/{chunk-THX5EE3K.js → chunk-TUFNY6OD.js} +3 -3
  112. package/dist/{chunk-THX5EE3K.js.map → chunk-TUFNY6OD.js.map} +1 -1
  113. package/dist/{chunk-EN5REMWV.js → chunk-U3UDOX6I.js} +4 -4
  114. package/dist/{chunk-EN5REMWV.js.map → chunk-U3UDOX6I.js.map} +1 -1
  115. package/dist/{chunk-3DA74PLW.js → chunk-USSP43U3.js} +3 -3
  116. package/dist/{chunk-3DA74PLW.js.map → chunk-USSP43U3.js.map} +1 -1
  117. package/dist/{chunk-U6KRTCNA.js → chunk-VJRL6ZK6.js} +3 -3
  118. package/dist/{chunk-U6KRTCNA.js.map → chunk-VJRL6ZK6.js.map} +1 -1
  119. package/dist/{chunk-B4BLJUYN.js → chunk-VXYZ5M7Z.js} +24 -18
  120. package/dist/{chunk-B4BLJUYN.js.map → chunk-VXYZ5M7Z.js.map} +1 -1
  121. package/dist/{chunk-E6UWI3TP.js → chunk-WW5NAU6N.js} +3 -3
  122. package/dist/{chunk-E6UWI3TP.js.map → chunk-WW5NAU6N.js.map} +1 -1
  123. package/dist/{chunk-J6YPKMMY.js → chunk-XD3RYAMR.js} +6 -6
  124. package/dist/{chunk-J6YPKMMY.js.map → chunk-XD3RYAMR.js.map} +1 -1
  125. package/dist/{chunk-DNXPXJ3X.js → chunk-XYCYGN3Q.js} +14 -14
  126. package/dist/{chunk-DNXPXJ3X.js.map → chunk-XYCYGN3Q.js.map} +1 -1
  127. package/dist/{chunk-B436SG5P.js → chunk-YN6N3RBM.js} +7 -7
  128. package/dist/{chunk-B436SG5P.js.map → chunk-YN6N3RBM.js.map} +1 -1
  129. package/dist/{chunk-TDPQOR3C.js → chunk-Z4FERR4U.js} +2 -2
  130. package/dist/{chunk-TDPQOR3C.js.map → chunk-Z4FERR4U.js.map} +1 -1
  131. package/dist/{claude-code-JY6CYEG7.js → claude-code-LZH7Y4Y5.js} +5 -5
  132. package/dist/{claude-code-JY6CYEG7.js.map → claude-code-LZH7Y4Y5.js.map} +1 -1
  133. package/dist/cli/index.js +91 -91
  134. package/dist/connectors/config.js +4 -4
  135. package/dist/connectors/index.js +18 -18
  136. package/dist/connectors/src/connector-manager.d.ts.map +1 -1
  137. package/dist/connectors/src/mount-ledger.d.ts.map +1 -1
  138. package/dist/{connectors-VLFOQNS6.js → connectors-HU5MHSUJ.js} +21 -21
  139. package/dist/{connectors-VLFOQNS6.js.map → connectors-HU5MHSUJ.js.map} +1 -1
  140. package/dist/core/index.js +6 -6
  141. package/dist/core/logging.js +1 -1
  142. package/dist/core/manifest.js +1 -1
  143. package/dist/core/publish-manifest.js +2 -2
  144. package/dist/core/runtime-assets.js +4 -4
  145. package/dist/core/src/logging/index.d.ts +1 -0
  146. package/dist/core/src/logging/index.d.ts.map +1 -1
  147. package/dist/core/src/logging/log-safe-text.d.ts +20 -0
  148. package/dist/core/src/logging/log-safe-text.d.ts.map +1 -0
  149. package/dist/core/src/manifest.d.ts.map +1 -1
  150. package/dist/core/src/workspace-config.d.ts +6 -0
  151. package/dist/core/src/workspace-config.d.ts.map +1 -1
  152. package/dist/core/workspace-config.js +3 -3
  153. package/dist/deploy/index.js +6 -6
  154. package/dist/discovery/index.js +3 -3
  155. package/dist/{ensure-sources-6O54DUQB.js → ensure-sources-CAMWJTMR.js} +24 -24
  156. package/dist/{ensure-sources-6O54DUQB.js.map → ensure-sources-CAMWJTMR.js.map} +1 -1
  157. package/dist/factory-assets/connectors/box.js +18 -18
  158. package/dist/factory-assets/connectors/deploy.js +18 -18
  159. package/dist/factory-assets/connectors/devserver.js +18 -18
  160. package/dist/factory-assets/connectors/flow/adapter.js +18 -18
  161. package/dist/factory-assets/connectors/flow/engine.js +7 -7
  162. package/dist/factory-assets/connectors/flow/run-flow.js +20 -20
  163. package/dist/factory-assets/connectors/flow.js +18 -18
  164. package/dist/factory-assets/connectors/git.js +18 -18
  165. package/dist/factory-assets/connectors/gmail.js +18 -18
  166. package/dist/factory-assets/connectors/googledrive.js +18 -18
  167. package/dist/factory-assets/connectors/local.js +18 -18
  168. package/dist/factory-assets/connectors/mattermost.js +18 -18
  169. package/dist/factory-assets/connectors/memory.js +18 -18
  170. package/dist/factory-assets/connectors/minio.js +18 -18
  171. package/dist/factory-assets/connectors/postgres.js +18 -18
  172. package/dist/factory-assets/connectors/s3.js +18 -18
  173. package/dist/factory-assets/connectors/sharepoint.js +18 -18
  174. package/dist/factory-assets/connectors/sqlite.js +18 -18
  175. package/dist/factory-assets/connectors/static-server.js +18 -18
  176. package/dist/factory-assets/connectors/tunnel.js +18 -18
  177. package/dist/factory-assets/connectors/webdav.js +18 -18
  178. package/dist/factory-assets/connectors/xstate-store.js +18 -18
  179. package/dist/factory-assets/connectors/xstate.js +18 -18
  180. package/dist/{flows-CIUPK7SB.js → flows-GVOVQGQW.js} +11 -11
  181. package/dist/{flows-CIUPK7SB.js.map → flows-GVOVQGQW.js.map} +1 -1
  182. package/dist/{helpers-YHDQHQEQ.js → helpers-WMCCODAV.js} +24 -24
  183. package/dist/{helpers-YHDQHQEQ.js.map → helpers-WMCCODAV.js.map} +1 -1
  184. package/dist/library/index.js +9 -9
  185. package/dist/library/install.js +3 -3
  186. package/dist/{library-publish-MUGUST43.js → library-publish-UQQMHTND.js} +49 -49
  187. package/dist/{library-publish-MUGUST43.js.map → library-publish-UQQMHTND.js.map} +1 -1
  188. package/dist/model-endpoint/index.js +9 -9
  189. package/dist/{open-library-BVQCB37E.js → open-library-OJ4HT2X4.js} +27 -27
  190. package/dist/{open-library-BVQCB37E.js.map → open-library-OJ4HT2X4.js.map} +1 -1
  191. package/dist/{open-registry-JCSIAKEC.js → open-registry-LWGIOJDK.js} +13 -13
  192. package/dist/{open-registry-JCSIAKEC.js.map → open-registry-LWGIOJDK.js.map} +1 -1
  193. package/dist/{paths-XLKCAFRZ.js → paths-FR2752HV.js} +9 -9
  194. package/dist/{paths-XLKCAFRZ.js.map → paths-FR2752HV.js.map} +1 -1
  195. package/dist/{plugin-store-NGRUTCJI.js → plugin-store-IALJUBN2.js} +9 -9
  196. package/dist/{plugin-store-NGRUTCJI.js.map → plugin-store-IALJUBN2.js.map} +1 -1
  197. package/dist/{project-BGYMLAS6.js → project-UQFCYHYS.js} +45 -45
  198. package/dist/{project-BGYMLAS6.js.map → project-UQFCYHYS.js.map} +1 -1
  199. package/dist/resolver/index.js +7 -7
  200. package/dist/runner/index.js +34 -34
  201. package/dist/runner/src/external-mcp.d.ts +22 -0
  202. package/dist/runner/src/external-mcp.d.ts.map +1 -1
  203. package/dist/runner/src/mcp-tools-snapshot.d.ts +13 -0
  204. package/dist/runner/src/mcp-tools-snapshot.d.ts.map +1 -0
  205. package/dist/runner/src/resources.d.ts +14 -0
  206. package/dist/runner/src/resources.d.ts.map +1 -1
  207. package/dist/runner/src/serve.d.ts.map +1 -1
  208. package/dist/sdk/asset-manager.js +12 -12
  209. package/dist/sdk/bridge.js +15 -15
  210. package/dist/sdk/core.js +6 -6
  211. package/dist/sdk/flow.js +7 -7
  212. package/dist/sdk/index.js +34 -34
  213. package/dist/sdk/resolver.js +7 -7
  214. package/dist/sdk/runner.js +34 -34
  215. package/dist/sdk/transport/ws/server.js +7 -7
  216. package/dist/sdk/transport/ws.js +7 -7
  217. package/dist/sdk/transport.js +7 -7
  218. package/dist/{serve-preflight-GQY5DZX6.js → serve-preflight-TYEKHC32.js} +27 -27
  219. package/dist/{serve-preflight-GQY5DZX6.js.map → serve-preflight-TYEKHC32.js.map} +1 -1
  220. package/dist/{setup-2NWSKSCO.js → setup-4JV2IMCB.js} +25 -25
  221. package/dist/{setup-2NWSKSCO.js.map → setup-4JV2IMCB.js.map} +1 -1
  222. package/dist/{skills-PXZOL2FZ.js → skills-6QTKFMLW.js} +12 -12
  223. package/dist/{skills-PXZOL2FZ.js.map → skills-6QTKFMLW.js.map} +1 -1
  224. package/dist/{source-XA3L4H6I.js → source-XYMMJVKR.js} +44 -44
  225. package/dist/{source-XA3L4H6I.js.map → source-XYMMJVKR.js.map} +1 -1
  226. package/dist/{source-manifest-publish-QEGMTS33.js → source-manifest-publish-SZFGGKB4.js} +46 -46
  227. package/dist/{source-manifest-publish-QEGMTS33.js.map → source-manifest-publish-SZFGGKB4.js.map} +1 -1
  228. package/dist/transport/index.js +7 -7
  229. package/dist/transport/ws/server.js +7 -7
  230. package/dist/transport/ws.js +7 -7
  231. package/dist/tui/index.js +34 -34
  232. package/dist/workspace-plugin/adapters/mcp.js +25 -25
  233. package/dist/workspace-plugin/adapters/omp.js +14 -14
  234. package/dist/workspace-plugin/index.js +2 -2
  235. package/package.json +1 -1
  236. package/dist/chunk-AVFRFGM2.js.map +0 -1
  237. package/dist/chunk-DKXNKFKP.js.map +0 -1
  238. package/dist/chunk-IWKKTCXY.js.map +0 -1
  239. package/dist/chunk-TNQLDEM6.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli/src/type-guards.ts","../cli/src/commands/validate-instances.ts"],"names":["parseYaml"],"mappings":";;;;;;AACO,SAAS,SAAS,KAAA,EAAkD;AACzE,EAAA,OAAO,KAAA,KAAU,QAAQ,OAAO,KAAA,KAAU,YAAY,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;;;ACqBA,IAAM,mBAAA,GAAsB,YAAA;AAG5B,IAAM,uBAAA,GAAuF;AAAA,EAC3F,QAAA,EAAU,CAAC,MAAA,EAAQ,QAAQ,CAAA;AAAA,EAC3B,OAAA,EAAS,CAAC,QAAQ,CAAA;AAAA,EAClB,OAAA,EAAS,CAAC,MAAM,CAAA;AAAA,EAChB,KAAA,EAAO,CAAC,OAAO;AACjB,CAAA;AAEA,IAAM,GAAA,GAAM,CAAC,IAAA,EAAc,OAAA,EAAiB,EAAA,MAA4B;AAAA,EACtE,IAAA;AAAA,EACA,QAAA,EAAU,OAAA;AAAA,EACV,OAAA;AAAA,EACA,IAAA,EAAM;AACR,CAAA,CAAA;AAaA,SAAS,eAAe,QAAA,EAA+C;AACrE,EAAA,MAAM,KAAA,GAAoB;AAAA,IACxB,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,KAAA,EAAO,QAAA,CAAS,EAAA,KAAO,MAAA,IAAa,SAAS,EAAA,KAAO,IAAA;AAAA,IACpD,gBAAgB,EAAC;AAAA,IACjB,YAAY,EAAC;AAAA,IACb,YAAY;AAAC,GACf;AACA,EAAA,KAAA,MAAW,IAAA,IAAQ,MAAM,OAAA,CAAQ,QAAA,CAAS,QAAQ,CAAA,GAAI,QAAA,CAAS,QAAA,GAAW,EAAC,EAAG;AAC5E,IAA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AAO,QAAA,GAAW,CAAC,CAAA,CAAE,EAAE,IAAI;AAAC,GACtD;AAEA,EAAA,KAAA,MAAW,CAAC,EAAA,EAAI,QAAQ,KAAK,MAAA,CAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACtD,IAAA,MAAM,MAAA,GAAS,SAAA,CAAU,UAAA,EAAY,EAAA,EAAI,SAAS,GAAG,CAAA;AACrD,IAAA,IAAI,gBAAgB,MAAA,EAAQ;AAE1B,MAAA,WAAA,CAAY,IAAA,CAAK,MAAA,CAAO,UAAA,EAAY,GAAG,aAAA,CAAc,EAAA,EAAI,QAAA,CAAS,QAAA,IAAY,EAAC,EAAG,MAAS,CAAC,CAAA;AAC5F,MAAA;AAAA,IACF;AACA,IAAA,MAAM,EAAE,OAAM,GAAI,MAAA;AAClB,IAAA,MAAM,SAAA,GAAY,QAAA,CAAS,SAAA,IAAa,KAAA,CAAM,SAAA,IAAa,UAAA;AAC3D,IAAA,IAAI,SAAA,KAAc,MAAA,IAAU,CAAC,KAAA,CAAM,KAAA,EAAO;AACxC,MAAA,WAAA,CAAY,IAAA;AAAA,QACV,GAAA;AAAA,UACE,uBAAA;AAAA,UACA,UAAU,EAAE,CAAA,2FAAA,CAAA;AAAA,UACZ,UAAU,EAAE,CAAA,UAAA;AAAA;AACd,OACF;AAAA,IACF;AACA,IAAA,WAAA,CAAY,KAAK,GAAG,eAAA,CAAgB,IAAI,QAAA,EAAU,KAAA,EAAO,YAAY,CAAC,CAAA;AACtE,IAAA,WAAA,CAAY,IAAA,CAAK,GAAG,aAAA,CAAc,EAAA,EAAI,QAAA,CAAS,YAAY,EAAC,EAAG,KAAA,CAAM,UAAU,CAAC,CAAA;AAAA,EAClF;AACA,EAAA,OAAO,WAAA;AACT","file":"chunk-ETF6Q3R3.js","sourcesContent":["/** Narrow to a plain-object-shaped value (not `null`, not an array); fields stay `unknown`. */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n","/**\n * `skaile validate` rules for the root `agents:` map of one `skaile.yaml`.\n *\n * Normalisation errors, the `agent:` + `agents.default` conflict, and the\n * asset-dependent rules: every `ref` resolves to an `agent.yaml`, role\n * instances need the asset's `io`, `connectors` bind real connector slots to\n * real `connectors[]` ids, and trigger ids are unique and known.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n AgentRefResolutionError,\n type AgentInstanceConfig,\n type AgentInstanceTrigger,\n agentBlockKeyDiagnostics,\n agentInstanceDiagnostics,\n type Diagnostic,\n normalizeAgentInstances,\n resolveAgentDefinitionDir,\n} from \"@skaile/workspaces/core\";\nimport { parse as parseYaml } from \"yaml\";\nimport { isRecord } from \"../type-guards.ts\";\n\nconst AGENT_MANIFEST_FILE = \"agent.yaml\";\n\n/** Fields a trigger needs when it declares itself in full (no asset trigger to override). */\nconst TRIGGER_REQUIRED_FIELDS: Record<NonNullable<AgentInstanceTrigger[\"kind\"]>, string[]> = {\n schedule: [\"cron\", \"prompt\"],\n webhook: [\"prompt\"],\n channel: [\"when\"],\n event: [\"event\"],\n};\n\nconst err = (code: string, message: string, at: string): Diagnostic => ({\n code,\n severity: \"error\",\n message,\n path: at,\n});\n\n/** The parts of an agent asset the instance rules read. */\ninterface AssetFacts {\n lifecycle: unknown;\n hasIo: boolean;\n /** `composes[].id` of `kind: connector` items. */\n connectorSlots: string[];\n /** `composes[].id` of every other item that has one. */\n otherSlots: string[];\n triggerIds: string[];\n}\n\nfunction readAssetFacts(manifest: Record<string, unknown>): AssetFacts {\n const facts: AssetFacts = {\n lifecycle: manifest.lifecycle,\n hasIo: manifest.io !== undefined && manifest.io !== null,\n connectorSlots: [],\n otherSlots: [],\n triggerIds: [],\n };\n for (const item of Array.isArray(manifest.composes) ? manifest.composes : []) {\n if (!isRecord(item) || typeof item.id !== \"string\") continue;\n (item.kind === \"connector\" ? facts.connectorSlots : facts.otherSlots).push(item.id);\n }\n for (const t of Array.isArray(manifest.triggers) ? manifest.triggers : []) {\n if (isRecord(t) && typeof t.id === \"string\") facts.triggerIds.push(t.id);\n }\n return facts;\n}\n\n/**\n * Why `agent.definition` does not resolve to an agent directory, or `null` when it does. One\n * rule for `validate` and `serve`, so the two print the same line (p1733): an `agent:` ref no\n * manifest declares, a path with no `agent.yaml`, an `ai-assets://` ref with no `ai-assets/`.\n */\nexport function agentDefinitionProblem(projectDir: string, definition: string): string | null {\n let dir: string | undefined;\n try {\n dir = resolveAgentDefinitionDir(projectDir, definition);\n } catch (e) {\n if (!(e instanceof AgentRefResolutionError)) throw e;\n return e.message;\n }\n if (dir === undefined) {\n return `agent.definition \"${definition}\": no ai-assets/ directory above the project`;\n }\n if (path.basename(dir) === AGENT_MANIFEST_FILE) dir = path.dirname(dir);\n if (!fs.existsSync(path.join(dir, AGENT_MANIFEST_FILE))) {\n return `agent.definition \"${definition}\": no ${AGENT_MANIFEST_FILE} in ${dir}`;\n }\n return null;\n}\n\n/** Resolve an instance `ref` to its parsed `agent.yaml`, or an error diagnostic. */\nfunction loadAsset(\n projectDir: string,\n id: string,\n ref: string,\n): { facts: AssetFacts } | { diagnostic: Diagnostic } {\n const at = `agents.${id}.ref`;\n let dir: string | undefined;\n try {\n dir = resolveAgentDefinitionDir(projectDir, ref);\n } catch (e) {\n if (!(e instanceof AgentRefResolutionError)) throw e;\n return { diagnostic: err(\"agent_ref_unresolved\", `agents.${id}: ${e.message}`, at) };\n }\n if (dir === undefined) {\n return {\n diagnostic: err(\n \"agent_ref_unresolved\",\n `agents.${id}: ref \"${ref}\" cannot be resolved — no ai-assets/ directory above the project`,\n at,\n ),\n };\n }\n const manifestPath = path.join(dir, AGENT_MANIFEST_FILE);\n let text: string;\n try {\n text = fs.readFileSync(manifestPath, \"utf-8\");\n } catch {\n return {\n diagnostic: err(\n \"agent_ref_unresolved\",\n `agents.${id}: ref \"${ref}\" resolves to ${dir}, which has no ${AGENT_MANIFEST_FILE}`,\n at,\n ),\n };\n }\n let manifest: unknown;\n try {\n manifest = parseYaml(text);\n } catch (e) {\n return {\n diagnostic: err(\n \"agent_manifest_invalid\",\n `agents.${id}: ${manifestPath} is not valid YAML: ${e instanceof Error ? e.message : String(e)}`,\n at,\n ),\n };\n }\n if (!isRecord(manifest)) {\n return {\n diagnostic: err(\n \"agent_manifest_invalid\",\n `agents.${id}: ${manifestPath} is not a mapping`,\n at,\n ),\n };\n }\n return { facts: readAssetFacts(manifest) };\n}\n\n/**\n * Trigger rules. Duplicate ids are always an error; the asset-dependent rules\n * (known id, complete full declaration) run only when `assetTriggerIds` is\n * known — i.e. the instance's `ref` resolved.\n */\nfunction checkTriggers(\n id: string,\n triggers: AgentInstanceTrigger[],\n assetTriggerIds: string[] | undefined,\n): Diagnostic[] {\n const out: Diagnostic[] = [];\n const seen = new Set<string>();\n triggers.forEach((trigger, i) => {\n const at = `agents.${id}.triggers[${i}]`;\n if (seen.has(trigger.id)) {\n out.push(\n err(\n \"agent_trigger_duplicate\",\n `agents.${id}: trigger id \"${trigger.id}\" is declared twice`,\n `${at}.id`,\n ),\n );\n return;\n }\n seen.add(trigger.id);\n if (!assetTriggerIds || assetTriggerIds.includes(trigger.id)) return;\n if (!trigger.kind) {\n out.push(\n err(\n \"agent_trigger_unknown\",\n `agents.${id}: trigger \"${trigger.id}\" is not declared by the agent asset (${assetTriggerIds.length > 0 ? `has: ${assetTriggerIds.join(\", \")}` : \"it declares no triggers\"}) — add \\`kind\\` and the trigger's fields to declare a new one`,\n `${at}.id`,\n ),\n );\n return;\n }\n const missing = TRIGGER_REQUIRED_FIELDS[trigger.kind].filter(\n (field) => (trigger as unknown as Record<string, unknown>)[field] === undefined,\n );\n if (missing.length > 0) {\n out.push(\n err(\n \"agent_trigger_incomplete\",\n `agents.${id}: trigger \"${trigger.id}\" (kind ${trigger.kind}) is not in the asset, so it must declare ${missing.join(\", \")}`,\n at,\n ),\n );\n }\n });\n return out;\n}\n\nfunction checkConnectors(\n id: string,\n instance: AgentInstanceConfig,\n facts: AssetFacts,\n connectorIds: string[],\n): Diagnostic[] {\n const out: Diagnostic[] = [];\n for (const [slot, connectorId] of Object.entries(instance.connectors ?? {})) {\n const at = `agents.${id}.connectors.${slot}`;\n if (!facts.connectorSlots.includes(slot)) {\n const hint = facts.otherSlots.includes(slot)\n ? `\"${slot}\" is a slot of a non-connector item`\n : facts.connectorSlots.length > 0\n ? `the asset's connector slots are: ${facts.connectorSlots.join(\", \")}`\n : \"the asset declares no connector slots\";\n out.push(\n err(\n \"agent_connector_slot_unknown\",\n `agents.${id}: connectors.${slot} is not a connector slot id of the agent asset (${hint})`,\n at,\n ),\n );\n }\n if (!connectorIds.includes(connectorId)) {\n out.push(\n err(\n \"agent_connector_unknown\",\n `agents.${id}: connectors.${slot} points at \"${connectorId}\", which is not in skaile.yaml connectors[]${connectorIds.length > 0 ? ` (has: ${connectorIds.join(\", \")})` : \"\"}`,\n at,\n ),\n );\n }\n }\n return out;\n}\n\n/**\n * Diagnostics for the `agents:` map of a parsed `skaile.yaml`.\n *\n * @param projectDir - Directory of the `skaile.yaml`; local and catalog refs resolve against it.\n * @param parsed - The raw YAML document.\n */\nexport function checkAgentInstances(\n projectDir: string,\n parsed: Record<string, unknown>,\n): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const instances = normalizeAgentInstances(parsed.agents, diagnostics);\n const agent = isRecord(parsed.agent) ? parsed.agent : undefined;\n diagnostics.push(...agentBlockKeyDiagnostics(parsed.agent));\n if (agent?.subagents !== undefined) {\n diagnostics.push(\n err(\n \"agent_subagents_removed\",\n \"`agent.subagents` was removed — declare each subagent as an agent asset and bind it under `agents:` with `lifecycle: role`\",\n \"agent.subagents\",\n ),\n );\n }\n if (agent?.instances !== undefined) {\n diagnostics.push(\n err(\n \"misplaced_agent_instances\",\n \"`agent.instances` is not a skaile.yaml key — declare instances under root `agents:`\",\n \"agent.instances\",\n ),\n );\n }\n diagnostics.push(\n ...agentInstanceDiagnostics({\n agent: {\n definition: typeof agent?.definition === \"string\" ? agent.definition : undefined,\n instances,\n },\n }),\n );\n // `serve` refuses an `agent.definition` that does not resolve, so `validate` must too (p1733).\n if (typeof agent?.definition === \"string\" && agent.definition !== \"\") {\n const problem = agentDefinitionProblem(projectDir, agent.definition);\n if (problem) diagnostics.push(err(\"agent_ref_unresolved\", problem, \"agent.definition\"));\n }\n if (!instances) return diagnostics;\n\n const connectorIds = (Array.isArray(parsed.connectors) ? parsed.connectors : []).flatMap((c) =>\n isRecord(c) && typeof c.id === \"string\" ? [c.id] : [],\n );\n\n for (const [id, instance] of Object.entries(instances)) {\n const loaded = loadAsset(projectDir, id, instance.ref);\n if (\"diagnostic\" in loaded) {\n // Asset-independent trigger rules still apply when the ref is broken.\n diagnostics.push(loaded.diagnostic, ...checkTriggers(id, instance.triggers ?? [], undefined));\n continue;\n }\n const { facts } = loaded;\n const lifecycle = instance.lifecycle ?? facts.lifecycle ?? \"standing\";\n if (lifecycle === \"role\" && !facts.hasIo) {\n diagnostics.push(\n err(\n \"agent_role_missing_io\",\n `agents.${id}: lifecycle \"role\" needs the agent asset to declare \\`io\\` ({ input, output } JSON Schemas)`,\n `agents.${id}.lifecycle`,\n ),\n );\n }\n diagnostics.push(...checkConnectors(id, instance, facts, connectorIds));\n diagnostics.push(...checkTriggers(id, instance.triggers ?? [], facts.triggerIds));\n }\n return diagnostics;\n}\n"]}
1
+ {"version":3,"sources":["../cli/src/type-guards.ts","../cli/src/commands/validate-instances.ts"],"names":["parseYaml"],"mappings":";;;;;;AACO,SAAS,SAAS,KAAA,EAAkD;AACzE,EAAA,OAAO,KAAA,KAAU,QAAQ,OAAO,KAAA,KAAU,YAAY,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;;;ACqBA,IAAM,mBAAA,GAAsB,YAAA;AAG5B,IAAM,uBAAA,GAAuF;AAAA,EAC3F,QAAA,EAAU,CAAC,MAAA,EAAQ,QAAQ,CAAA;AAAA,EAC3B,OAAA,EAAS,CAAC,QAAQ,CAAA;AAAA,EAClB,OAAA,EAAS,CAAC,MAAM,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A,IAAU,CAAC,KAAA,CAAM,KAAA,EAAO;AACxC,MAAA,WAAA,CAAY,IAAA;AAAA,QACV,GAAA;AAAA,UACE,uBAAA;AAAA,UACA,UAAU,EAAE,CAAA,2FAAA,CAAA;AAAA,UACZ,UAAU,EAAE,CAAA,UAAA;AAAA;AACd,OACF;AAAA,IACF;AACA,IAAA,WAAA,CAAY,KAAK,GAAG,eAAA,CAAgB,IAAI,QAAA,EAAU,KAAA,EAAO,YAAY,CAAC,CAAA;AACtE,IAAA,WAAA,CAAY,IAAA,CAAK,GAAG,aAAA,CAAc,EAAA,EAAI,QAAA,CAAS,YAAY,EAAC,EAAG,KAAA,CAAM,UAAU,CAAC,CAAA;AAAA,EAClF;AACA,EAAA,OAAO,WAAA;AACT","file":"chunk-EPXZQIC6.js","sourcesContent":["/** Narrow to a plain-object-shaped value (not `null`, not an array); fields stay `unknown`. */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n","/**\n * `skaile validate` rules for the root `agents:` map of one `skaile.yaml`.\n *\n * Normalisation errors, the `agent:` + `agents.default` conflict, and the\n * asset-dependent rules: every `ref` resolves to an `agent.yaml`, role\n * instances need the asset's `io`, `connectors` bind real connector slots to\n * real `connectors[]` ids, and trigger ids are unique and known.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n AgentRefResolutionError,\n type AgentInstanceConfig,\n type AgentInstanceTrigger,\n agentBlockKeyDiagnostics,\n agentInstanceDiagnostics,\n type Diagnostic,\n normalizeAgentInstances,\n resolveAgentDefinitionDir,\n} from \"@skaile/workspaces/core\";\nimport { parse as parseYaml } from \"yaml\";\nimport { isRecord } from \"../type-guards.ts\";\n\nconst AGENT_MANIFEST_FILE = \"agent.yaml\";\n\n/** Fields a trigger needs when it declares itself in full (no asset trigger to override). */\nconst TRIGGER_REQUIRED_FIELDS: Record<NonNullable<AgentInstanceTrigger[\"kind\"]>, string[]> = {\n schedule: [\"cron\", \"prompt\"],\n webhook: [\"prompt\"],\n channel: [\"when\"],\n event: [\"event\"],\n};\n\nconst err = (code: string, message: string, at: string): Diagnostic => ({\n code,\n severity: \"error\",\n message,\n path: at,\n});\n\n/** The parts of an agent asset the instance rules read. */\ninterface AssetFacts {\n lifecycle: unknown;\n hasIo: boolean;\n /** `composes[].id` of `kind: connector` items. */\n connectorSlots: string[];\n /** `composes[].id` of every other item that has one. */\n otherSlots: string[];\n triggerIds: string[];\n}\n\nfunction readAssetFacts(manifest: Record<string, unknown>): AssetFacts {\n const facts: AssetFacts = {\n lifecycle: manifest.lifecycle,\n hasIo: manifest.io !== undefined && manifest.io !== null,\n connectorSlots: [],\n otherSlots: [],\n triggerIds: [],\n };\n for (const item of Array.isArray(manifest.composes) ? manifest.composes : []) {\n if (!isRecord(item) || typeof item.id !== \"string\") continue;\n (item.kind === \"connector\" ? facts.connectorSlots : facts.otherSlots).push(item.id);\n }\n for (const t of Array.isArray(manifest.triggers) ? manifest.triggers : []) {\n if (isRecord(t) && typeof t.id === \"string\") facts.triggerIds.push(t.id);\n }\n return facts;\n}\n\n/**\n * Why `agent.definition` does not resolve to an agent directory, or `null` when it does. One\n * rule for `validate` and `serve`, so the two print the same line (p1733): an `agent:` ref no\n * manifest declares, a path with no `agent.yaml`, an `ai-assets://` ref with no `ai-assets/`.\n */\nexport function agentDefinitionProblem(projectDir: string, definition: string): string | null {\n let dir: string | undefined;\n try {\n dir = resolveAgentDefinitionDir(projectDir, definition);\n } catch (e) {\n if (!(e instanceof AgentRefResolutionError)) throw e;\n return e.message;\n }\n if (dir === undefined) {\n return `agent.definition \"${definition}\": no ai-assets/ directory above the project`;\n }\n if (path.basename(dir) === AGENT_MANIFEST_FILE) dir = path.dirname(dir);\n if (!fs.existsSync(path.join(dir, AGENT_MANIFEST_FILE))) {\n return `agent.definition \"${definition}\": no ${AGENT_MANIFEST_FILE} in ${dir}`;\n }\n return null;\n}\n\n/** Resolve an instance `ref` to its parsed `agent.yaml`, or an error diagnostic. */\nfunction loadAsset(\n projectDir: string,\n id: string,\n ref: string,\n): { facts: AssetFacts } | { diagnostic: Diagnostic } {\n const at = `agents.${id}.ref`;\n let dir: string | undefined;\n try {\n dir = resolveAgentDefinitionDir(projectDir, ref);\n } catch (e) {\n if (!(e instanceof AgentRefResolutionError)) throw e;\n return { diagnostic: err(\"agent_ref_unresolved\", `agents.${id}: ${e.message}`, at) };\n }\n if (dir === undefined) {\n return {\n diagnostic: err(\n \"agent_ref_unresolved\",\n `agents.${id}: ref \"${ref}\" cannot be resolved — no ai-assets/ directory above the project`,\n at,\n ),\n };\n }\n const manifestPath = path.join(dir, AGENT_MANIFEST_FILE);\n let text: string;\n try {\n text = fs.readFileSync(manifestPath, \"utf-8\");\n } catch {\n return {\n diagnostic: err(\n \"agent_ref_unresolved\",\n `agents.${id}: ref \"${ref}\" resolves to ${dir}, which has no ${AGENT_MANIFEST_FILE}`,\n at,\n ),\n };\n }\n let manifest: unknown;\n try {\n manifest = parseYaml(text);\n } catch (e) {\n return {\n diagnostic: err(\n \"agent_manifest_invalid\",\n `agents.${id}: ${manifestPath} is not valid YAML: ${e instanceof Error ? e.message : String(e)}`,\n at,\n ),\n };\n }\n if (!isRecord(manifest)) {\n return {\n diagnostic: err(\n \"agent_manifest_invalid\",\n `agents.${id}: ${manifestPath} is not a mapping`,\n at,\n ),\n };\n }\n return { facts: readAssetFacts(manifest) };\n}\n\n/**\n * Trigger rules. Duplicate ids are always an error; the asset-dependent rules\n * (known id, complete full declaration) run only when `assetTriggerIds` is\n * known — i.e. the instance's `ref` resolved.\n */\nfunction checkTriggers(\n id: string,\n triggers: AgentInstanceTrigger[],\n assetTriggerIds: string[] | undefined,\n): Diagnostic[] {\n const out: Diagnostic[] = [];\n const seen = new Set<string>();\n triggers.forEach((trigger, i) => {\n const at = `agents.${id}.triggers[${i}]`;\n if (seen.has(trigger.id)) {\n out.push(\n err(\n \"agent_trigger_duplicate\",\n `agents.${id}: trigger id \"${trigger.id}\" is declared twice`,\n `${at}.id`,\n ),\n );\n return;\n }\n seen.add(trigger.id);\n if (!assetTriggerIds || assetTriggerIds.includes(trigger.id)) return;\n if (!trigger.kind) {\n out.push(\n err(\n \"agent_trigger_unknown\",\n `agents.${id}: trigger \"${trigger.id}\" is not declared by the agent asset (${assetTriggerIds.length > 0 ? `has: ${assetTriggerIds.join(\", \")}` : \"it declares no triggers\"}) — add \\`kind\\` and the trigger's fields to declare a new one`,\n `${at}.id`,\n ),\n );\n return;\n }\n const missing = TRIGGER_REQUIRED_FIELDS[trigger.kind].filter(\n (field) => (trigger as unknown as Record<string, unknown>)[field] === undefined,\n );\n if (missing.length > 0) {\n out.push(\n err(\n \"agent_trigger_incomplete\",\n `agents.${id}: trigger \"${trigger.id}\" (kind ${trigger.kind}) is not in the asset, so it must declare ${missing.join(\", \")}`,\n at,\n ),\n );\n }\n });\n return out;\n}\n\nfunction checkConnectors(\n id: string,\n instance: AgentInstanceConfig,\n facts: AssetFacts,\n connectorIds: string[],\n): Diagnostic[] {\n const out: Diagnostic[] = [];\n for (const [slot, connectorId] of Object.entries(instance.connectors ?? {})) {\n const at = `agents.${id}.connectors.${slot}`;\n if (!facts.connectorSlots.includes(slot)) {\n const hint = facts.otherSlots.includes(slot)\n ? `\"${slot}\" is a slot of a non-connector item`\n : facts.connectorSlots.length > 0\n ? `the asset's connector slots are: ${facts.connectorSlots.join(\", \")}`\n : \"the asset declares no connector slots\";\n out.push(\n err(\n \"agent_connector_slot_unknown\",\n `agents.${id}: connectors.${slot} is not a connector slot id of the agent asset (${hint})`,\n at,\n ),\n );\n }\n if (!connectorIds.includes(connectorId)) {\n out.push(\n err(\n \"agent_connector_unknown\",\n `agents.${id}: connectors.${slot} points at \"${connectorId}\", which is not in skaile.yaml connectors[]${connectorIds.length > 0 ? ` (has: ${connectorIds.join(\", \")})` : \"\"}`,\n at,\n ),\n );\n }\n }\n return out;\n}\n\n/**\n * Diagnostics for the `agents:` map of a parsed `skaile.yaml`.\n *\n * @param projectDir - Directory of the `skaile.yaml`; local and catalog refs resolve against it.\n * @param parsed - The raw YAML document.\n */\nexport function checkAgentInstances(\n projectDir: string,\n parsed: Record<string, unknown>,\n): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const instances = normalizeAgentInstances(parsed.agents, diagnostics);\n const agent = isRecord(parsed.agent) ? parsed.agent : undefined;\n diagnostics.push(...agentBlockKeyDiagnostics(parsed.agent));\n if (agent?.subagents !== undefined) {\n diagnostics.push(\n err(\n \"agent_subagents_removed\",\n \"`agent.subagents` was removed — declare each subagent as an agent asset and bind it under `agents:` with `lifecycle: role`\",\n \"agent.subagents\",\n ),\n );\n }\n if (agent?.instances !== undefined) {\n diagnostics.push(\n err(\n \"misplaced_agent_instances\",\n \"`agent.instances` is not a skaile.yaml key — declare instances under root `agents:`\",\n \"agent.instances\",\n ),\n );\n }\n diagnostics.push(\n ...agentInstanceDiagnostics({\n agent: {\n definition: typeof agent?.definition === \"string\" ? agent.definition : undefined,\n instances,\n },\n }),\n );\n // `serve` refuses an `agent.definition` that does not resolve, so `validate` must too (p1733).\n if (typeof agent?.definition === \"string\" && agent.definition !== \"\") {\n const problem = agentDefinitionProblem(projectDir, agent.definition);\n if (problem) diagnostics.push(err(\"agent_ref_unresolved\", problem, \"agent.definition\"));\n }\n if (!instances) return diagnostics;\n\n const connectorIds = (Array.isArray(parsed.connectors) ? parsed.connectors : []).flatMap((c) =>\n isRecord(c) && typeof c.id === \"string\" ? [c.id] : [],\n );\n\n for (const [id, instance] of Object.entries(instances)) {\n const loaded = loadAsset(projectDir, id, instance.ref);\n if (\"diagnostic\" in loaded) {\n // Asset-independent trigger rules still apply when the ref is broken.\n diagnostics.push(loaded.diagnostic, ...checkTriggers(id, instance.triggers ?? [], undefined));\n continue;\n }\n const { facts } = loaded;\n const lifecycle = instance.lifecycle ?? facts.lifecycle ?? \"standing\";\n if (lifecycle === \"role\" && !facts.hasIo) {\n diagnostics.push(\n err(\n \"agent_role_missing_io\",\n `agents.${id}: lifecycle \"role\" needs the agent asset to declare \\`io\\` ({ input, output } JSON Schemas)`,\n `agents.${id}.lifecycle`,\n ),\n );\n }\n diagnostics.push(...checkConnectors(id, instance, facts, connectorIds));\n diagnostics.push(...checkTriggers(id, instance.triggers ?? [], facts.triggerIds));\n }\n return diagnostics;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { getProviderPreset, registryCredentialEnv, providerCredentialEnvName, BUILTIN_HARNESS_CATALOG } from './chunk-NSIOBKDX.js';
1
+ import { getProviderPreset, registryCredentialEnv, providerCredentialEnvName, BUILTIN_HARNESS_CATALOG } from './chunk-BSMW3PX2.js';
2
2
  import { mergeRegistries, resolveEntryBaseUrl, normalizeEntryBaseUrl, registryEntries, isEntryEnabled, parseModelRef } from './chunk-RXGPFAMN.js';
3
3
 
4
4
  // bridge/src/provider-materialize/env-harnesses.ts
@@ -137,5 +137,5 @@ function continueRoleBinding(session) {
137
137
  }
138
138
 
139
139
  export { bindSingleProviderEntry, continueRoleBinding, credentialsForEveryProvider, entryBaseUrl, entryModelIds, entrySurface, harnessModelSelector, harnessProviderName, isStockCatalogEndpoint, registryModelEntries, resolveEnvHarnessSession, resolveRegistryBinding, selectableEntries, versionedAnthropicBaseUrl };
140
- //# sourceMappingURL=chunk-SZTHSPRC.js.map
141
- //# sourceMappingURL=chunk-SZTHSPRC.js.map
140
+ //# sourceMappingURL=chunk-F4CZQD3T.js.map
141
+ //# sourceMappingURL=chunk-F4CZQD3T.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../bridge/src/provider-materialize/env-harnesses.ts"],"names":[],"mappings":";;;;AAyEO,SAAS,wBAAA,CACd,MAAA,EACA,UAAA,GAAiD,OAAA,CAAQ,GAAA,EACtC;AACnB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,MAAA,CAAO,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AAAA,IAC/C,WAAW,EAAE,GAAG,UAAA,EAAY,GAAG,OAAO,GAAA,EAAI;AAAA,IAC1C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,IACN,YAAY,OAAA,CAAQ,UAAA;AAAA,IACpB,UAAU,OAAA,CAAQ,iBAAA;AAAA,IAClB,GAAI,QAAQ,eAAA,GAAkB,EAAE,OAAO,OAAA,CAAQ,eAAA,KAAoB,EAAC;AAAA,IACpE,GAAI,OAAA,CAAQ,OAAA,GACR,EAAE,OAAA,EAAS,yBAAA,CAA0B,OAAA,CAAQ,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA,EAAE,GACvE,EAAC;AAAA,IACL,SAAA,EAAW,yBAAA,CAA0B,OAAA,CAAQ,UAAU;AAAA,GACzD;AACF","file":"chunk-SZTHSPRC.js","sourcesContent":["/**\n * Registry adapter for the **env-shaped CLI harnesses** — Gemini, Qwen, OpenCode,\n * Goose and Continue (§2.3).\n *\n * These harnesses take their endpoint from the environment rather than from a\n * config file, so the adapter's job is three things: resolve which registry\n * entry the session's model selector names, refuse at start when that entry\n * speaks a wire surface the harness cannot, and hand the harness the\n * provider-side model id it must put on the command line.\n *\n * Two pluralities meet here (`BUILTIN_HARNESS_CATALOG.providerPlurality`):\n *\n * - `single` — Gemini and Qwen address exactly one endpoint. The bound entry\n * supplies the credential *and* the base URL, and a surface mismatch is\n * fatal: a Gemini CLI pointed at an `openai-completions` endpoint cannot\n * work, and failing at start names the surface instead of leaving the user\n * with an opaque error mid-turn.\n * - `credentials-n` — OpenCode, Goose and Continue accept every enabled\n * entry's credential at once and select one active model. The credential\n * fan-out is `registryCredentialEnv`; the active model is this module's\n * `<provider>/<model>` binding.\n *\n * Writing the per-endpoint config files those three need for *custom*\n * endpoints (`opencode.json`, Goose `custom_providers/*.json`, Continue\n * `config.yaml`) is the file half, and is deliberately not here.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport {\n type AIProviderLlmEntry,\n type AIProviderSurface,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n mergeRegistries,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport type { ModelEntry } from \"../models.js\";\nimport { getProviderPreset } from \"../provider-catalog.js\";\nimport { BUILTIN_HARNESS_CATALOG } from \"../registry.js\";\nimport type { AgentConfig } from \"../types.js\";\nimport { providerCredentialEnvName, registryCredentialEnv } from \"./credential-env.js\";\n\n/**\n * Everything a CLI harness needs to know about this session's AI providers,\n * resolved once from its {@link AgentConfig}.\n */\nexport interface EnvHarnessSession {\n /** The merged registry this session may address. Empty when none was configured. */\n registry: MergedAIProviderRegistry;\n /**\n * Environment `credential.ref` lookups resolve against — the process\n * environment widened with `config.env`, which is where the session\n * boundary delivered every resolved `SKAILE_AIP_<ID>_KEY`.\n */\n lookupEnv: Record<string, string | undefined>;\n /** Model selector: `<providerId>/<modelId>`, a bare id, or `@role`. */\n modelRef?: string;\n /** Roles table an `@role` selector resolves through. */\n roles?: Record<string, string>;\n}\n\n/**\n * Resolve the session's providers once, from its {@link AgentConfig}.\n *\n * `config.env` is folded into `lookupEnv` rather than kept apart: it is part\n * of the session's environment, not an extra, and a credential or\n * `*_BASE_URL` delivered there must be visible exactly as the child will see\n * it.\n */\nexport function resolveEnvHarnessSession(\n config: AgentConfig,\n processEnv: Record<string, string | undefined> = process.env,\n): EnvHarnessSession {\n return {\n registry: config.registry ?? mergeRegistries([]),\n lookupEnv: { ...processEnv, ...config.env },\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n };\n}\n\n/** One resolved endpoint + model — everything a harness needs to spawn. */\nexport interface RegistryModelBinding {\n /** Registry id of the selected entry. */\n providerId: string;\n /** The selected entry itself. */\n entry: AIProviderLlmEntry;\n /** Logical model id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side model id — what goes on the wire / command line. */\n providerModelId?: string;\n /** Wire protocol, from the entry or its preset. */\n surface?: AIProviderSurface;\n /** Resolved endpoint, from the entry, its transport params, or its preset. */\n baseUrl?: string;\n /**\n * The provider name the *harness* knows this endpoint by — a catalog preset\n * id for a stock endpoint, the registry id for anything custom. See\n * {@link harnessProviderName}.\n */\n harnessProviderId: string;\n /** Non-fatal notes from `parseModelRef` (dangling role, disabled provider). */\n warnings: string[];\n}\n\n/** The entry's wire surface: its own, else its preset's. */\nexport function entrySurface(entry: AIProviderLlmEntry): AIProviderSurface | undefined {\n if (entry.surface) return entry.surface;\n return entry.preset ? getProviderPreset(entry.preset)?.surface : undefined;\n}\n\n/**\n * The entry's endpoint: its literal or transport-derived URL, else its\n * preset's literal, in the canonical spelling for its surface\n * (`normalizeEntryBaseUrl`: an `anthropic-messages` endpoint is its host root,\n * so `https://api.anthropic.com/v1` reads as `https://api.anthropic.com`).\n * Transport templates that still carry `{param}` placeholders never come\n * back — `resolveEntryBaseUrl` withholds those, and a preset's template is not\n * a URL.\n *\n * Every adapter reads the endpoint here and only re-spells it for a client\n * that wants something else ({@link versionedAnthropicBaseUrl}).\n */\nexport function entryBaseUrl(entry: AIProviderLlmEntry): string | undefined {\n const resolved =\n resolveEntryBaseUrl(entry) ??\n (entry.preset ? getProviderPreset(entry.preset)?.base_url : undefined);\n return normalizeEntryBaseUrl(resolved, entrySurface(entry));\n}\n\n/**\n * An `anthropic-messages` endpoint spelled for a client that appends only\n * `/messages` — `@ai-sdk/anthropic` (OpenCode) and Continue — rather than\n * `/v1/messages` like the Claude CLI, the Anthropic SDK and Goose. `baseUrl`\n * must already be canonical ({@link entryBaseUrl}); every other surface passes\n * through unchanged.\n */\nexport function versionedAnthropicBaseUrl(\n baseUrl: string,\n surface: AIProviderSurface | undefined,\n): string {\n if (surface !== \"anthropic-messages\") return baseUrl;\n // Append to the path, not the string: a query or fragment stays at the end.\n try {\n const url = new URL(baseUrl);\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/v1`;\n return url.toString();\n } catch {\n return `${baseUrl}/v1`;\n }\n}\n\n/**\n * True when a `credentials-n` harness already knows this endpoint under its\n * own catalog name — the entry names a preset and did not move it somewhere\n * else. Both sides are compared canonically, so `https://api.anthropic.com/v1`\n * is still the `anthropic` preset's endpoint.\n *\n * The one rule both halves of §2.3 read: it decides the name the env half\n * puts on the command line ({@link harnessProviderName}) *and* whether the\n * file half has to describe the endpoint at all. Reading it twice is what\n * keeps `-m <name>/<model>` and the generated provider file talking about the\n * same thing.\n */\nexport function isStockCatalogEndpoint(entry: AIProviderLlmEntry): boolean {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset) return false;\n return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));\n}\n\n/**\n * The provider name to give a `credentials-n` harness (`-m <name>/<model>`,\n * `GOOSE_PROVIDER`).\n *\n * A stock catalog endpoint is named by its preset, because that is the name\n * OpenCode's models.dev list and Goose's built-in provider table already use —\n * `prod-claude: {preset: anthropic}` is still Anthropic to them. An entry with\n * an endpoint of its own is named by its registry id: no built-in table knows\n * it, so the id is what its generated provider file is keyed by (the file half\n * of §2.3).\n */\nexport function harnessProviderName(providerId: string, entry: AIProviderLlmEntry): string {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset || !isStockCatalogEndpoint(entry)) return providerId;\n return preset.id;\n}\n\n/**\n * Enabled `llm`/`embed` entries, in registry order. Also the set the file\n * adapters render (`opencode-config.ts`, `goose-custom-providers.ts`,\n * `continue-config-yaml.ts`): the env half and the file half must agree on\n * which entries exist before they can agree on what to call them.\n */\nexport function selectableEntries(\n registry: MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * The provider-side model ids an entry declares, as `[logicalId, providerId]`\n * pairs in declaration order: every `model_map` entry, plus every\n * `capabilities` key the map does not rename.\n */\nexport function entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logicalIds = [\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}).filter((id) => !(id in (entry.model_map ?? {}))),\n ];\n return logicalIds.map((id) => [id, entry.model_map?.[id] ?? id]);\n}\n\nfunction describeBinding(\n providerId: string,\n entry: AIProviderLlmEntry,\n modelId: string | undefined,\n providerModelId: string | undefined,\n warnings: string[],\n): RegistryModelBinding {\n const surface = entrySurface(entry);\n const baseUrl = entryBaseUrl(entry);\n return {\n providerId,\n entry,\n ...(modelId === undefined ? {} : { modelId }),\n ...(providerModelId === undefined ? {} : { providerModelId }),\n ...(surface ? { surface } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n harnessProviderId: harnessProviderName(providerId, entry),\n warnings,\n };\n}\n\n/**\n * Resolve the session's endpoint + model.\n *\n * With no selector the first entry in registry order wins and the harness\n * keeps its own default model — exactly what an absent `model` meant before\n * the registry existed. Returns `undefined` when no entry can serve a model\n * (an empty, fully-disabled or voice-only registry).\n */\nexport function resolveRegistryBinding(\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const entries = selectableEntries(session.registry);\n if (entries.length === 0) return undefined;\n\n const selector = session.modelRef?.trim();\n if (!selector) {\n const [providerId, entry] = entries[0];\n return describeBinding(providerId, entry, undefined, undefined, []);\n }\n\n // A selector that is exactly an entry id names the endpoint and nothing\n // else: the harness keeps its own default model. `parseModelRef` would read\n // it as a bare *model* id and fall back to registry order.\n const named = entries.find(([id]) => id === selector);\n if (named) return describeBinding(named[0], named[1], undefined, undefined, []);\n\n const resolved = parseModelRef(selector, session.registry, session.roles);\n if (!resolved) return undefined;\n const match = entries.find(([id]) => id === resolved.providerId);\n if (!match) return undefined;\n return describeBinding(\n match[0],\n match[1],\n resolved.modelId,\n resolved.providerModelId,\n resolved.warnings,\n );\n}\n\n/**\n * Every credential a `credentials-n` harness may use: one variable per\n * enabled registry entry. OpenCode, Goose and Continue have always received\n * *all* of them, not just the selected endpoint's, because they route across\n * providers inside a single session.\n */\nexport function credentialsForEveryProvider(session: EnvHarnessSession): Record<string, string> {\n return registryCredentialEnv(session.registry, { env: session.lookupEnv });\n}\n\n/**\n * Throw when the bound entry speaks a wire surface this harness cannot.\n *\n * The message names the offending surface and lists the ones the harness does\n * speak (`BUILTIN_HARNESS_CATALOG[harnessId].surfaces`). An entry that declares\n * no surface and names no preset is not judged — there is nothing to compare.\n */\nexport function assertHarnessSpeaksSurface(\n harnessId: string,\n productName: string,\n binding: RegistryModelBinding,\n): void {\n const supported = BUILTIN_HARNESS_CATALOG[harnessId]?.surfaces;\n if (!supported || supported.length === 0) return;\n const surface = binding.surface;\n if (!surface || supported.includes(surface)) return;\n throw new Error(\n `${productName} cannot speak the '${surface}' surface of AI provider entry ` +\n `'${binding.providerId}'. ${productName} speaks: ${supported.join(\", \")}. ` +\n `Point this session's model at an entry with one of those surfaces, ` +\n `or run it on a harness that speaks '${surface}'.`,\n );\n}\n\n/**\n * The models a `credentials-n` harness can be pointed at, straight from the\n * registry: every enabled entry's mapped ids, namespaced the way the harness\n * takes them (`-m <provider>/<model>`).\n *\n * These harnesses have no model-list endpoint of their own — OpenCode reads\n * models.dev, Goose and Continue read their config — so the registry is the\n * only list that describes *this* session's reachable models, and it needs no\n * network call to produce.\n */\nexport function registryModelEntries(session: EnvHarnessSession): ModelEntry[] {\n const out: ModelEntry[] = [];\n const seen = new Set<string>();\n for (const [providerId, entry] of selectableEntries(session.registry)) {\n const harnessId = harnessProviderName(providerId, entry);\n const label = entry.label ?? providerId;\n for (const [logicalId, providerModelId] of entryModelIds(entry)) {\n const id = `${harnessId}/${providerModelId}`;\n if (seen.has(id)) continue;\n seen.add(id);\n out.push({ id, name: `${label} ${logicalId}` });\n }\n }\n return out;\n}\n\n/**\n * Resolve the binding and enforce the surface — what a `single`-plurality\n * harness does at start.\n *\n * The registry is authoritative: pointing the harness at an entry it cannot\n * speak throws rather than silently running somewhere else. `undefined` when\n * the session configured no endpoint at all, which leaves the harness on its\n * own native auth.\n */\nexport function bindSingleProviderEntry(\n harnessId: string,\n productName: string,\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n assertHarnessSpeaksSurface(harnessId, productName, binding);\n return binding;\n}\n\n/**\n * The `<provider>/<model>` selector a `credentials-n` harness takes on its\n * command line (`opencode -m`). `undefined` when no model was selected — the\n * harness then uses its own default rather than being handed a bare provider.\n */\nexport function harnessModelSelector(binding: RegistryModelBinding): string | undefined {\n if (!binding.providerModelId) return undefined;\n return `${binding.harnessProviderId}/${binding.providerModelId}`;\n}\n\n/**\n * Continue's model selection is a **role binding**, not a flag: `cn` has no\n * `--model` option (only `--config <slug>`), and its `config.yaml` binds each\n * model to roles (`chat`, `edit`, `apply`, …). This is the binding for the\n * role a headless `cn -p` turn runs as, and the shape its generated\n * `config.yaml` is rendered from.\n *\n * `apiKeyEnv` is a variable *name*: the secret travels in the child\n * environment, never in a rendered config.\n */\nexport interface ContinueRoleBinding {\n /** Continue role this model serves. A headless prompt is a `chat` turn. */\n role: \"chat\";\n /** Registry id of the entry. */\n providerId: string;\n /** Provider name Continue knows the endpoint by. */\n provider: string;\n /** Provider-side model id. */\n model?: string;\n /** Endpoint, when the entry states one, spelled the way Continue's `apiBase` wants it. */\n apiBase?: string;\n /** Env var holding the credential — the name, never the value. */\n apiKeyEnv: string;\n}\n\n/**\n * Map the session's chosen endpoint onto the Continue role a headless turn\n * runs as. `undefined` when the session configured no endpoint — `cn` then\n * runs against whatever its own `config.yaml` / Hub login provides.\n */\nexport function continueRoleBinding(session: EnvHarnessSession): ContinueRoleBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n return {\n role: \"chat\",\n providerId: binding.providerId,\n provider: binding.harnessProviderId,\n ...(binding.providerModelId ? { model: binding.providerModelId } : {}),\n ...(binding.baseUrl\n ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) }\n : {}),\n apiKeyEnv: providerCredentialEnvName(binding.providerId),\n };\n}\n"]}
1
+ {"version":3,"sources":["../bridge/src/provider-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C,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,iBAAiB,CAAA,CAAA,EAAI,QAAQ,eAAe,CAAA,CAAA;AAChE;AAgCO,SAAS,oBAAoB,OAAA,EAA6D;AAC/F,EAAA,MAAM,OAAA,GAAU,uBAAuB,OAAO,CAAA;AAC9C,EAAA,IAAI,CAAC,SAAS,OAAO,MAAA;AACrB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA;AAAA,IACN,YAAY,OAAA,CAAQ,UAAA;AAAA,IACpB,UAAU,OAAA,CAAQ,iBAAA;AAAA,IAClB,GAAI,QAAQ,eAAA,GAAkB,EAAE,OAAO,OAAA,CAAQ,eAAA,KAAoB,EAAC;AAAA,IACpE,GAAI,OAAA,CAAQ,OAAA,GACR,EAAE,OAAA,EAAS,yBAAA,CAA0B,OAAA,CAAQ,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA,EAAE,GACvE,EAAC;AAAA,IACL,SAAA,EAAW,yBAAA,CAA0B,OAAA,CAAQ,UAAU;AAAA,GACzD;AACF","file":"chunk-F4CZQD3T.js","sourcesContent":["/**\n * Registry adapter for the **env-shaped CLI harnesses** — Gemini, Qwen, OpenCode,\n * Goose and Continue (§2.3).\n *\n * These harnesses take their endpoint from the environment rather than from a\n * config file, so the adapter's job is three things: resolve which registry\n * entry the session's model selector names, refuse at start when that entry\n * speaks a wire surface the harness cannot, and hand the harness the\n * provider-side model id it must put on the command line.\n *\n * Two pluralities meet here (`BUILTIN_HARNESS_CATALOG.providerPlurality`):\n *\n * - `single` — Gemini and Qwen address exactly one endpoint. The bound entry\n * supplies the credential *and* the base URL, and a surface mismatch is\n * fatal: a Gemini CLI pointed at an `openai-completions` endpoint cannot\n * work, and failing at start names the surface instead of leaving the user\n * with an opaque error mid-turn.\n * - `credentials-n` — OpenCode, Goose and Continue accept every enabled\n * entry's credential at once and select one active model. The credential\n * fan-out is `registryCredentialEnv`; the active model is this module's\n * `<provider>/<model>` binding.\n *\n * Writing the per-endpoint config files those three need for *custom*\n * endpoints (`opencode.json`, Goose `custom_providers/*.json`, Continue\n * `config.yaml`) is the file half, and is deliberately not here.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport {\n type AIProviderLlmEntry,\n type AIProviderSurface,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n mergeRegistries,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport type { ModelEntry } from \"../models.js\";\nimport { getProviderPreset } from \"../provider-catalog.js\";\nimport { BUILTIN_HARNESS_CATALOG } from \"../registry.js\";\nimport type { AgentConfig } from \"../types.js\";\nimport { providerCredentialEnvName, registryCredentialEnv } from \"./credential-env.js\";\n\n/**\n * Everything a CLI harness needs to know about this session's AI providers,\n * resolved once from its {@link AgentConfig}.\n */\nexport interface EnvHarnessSession {\n /** The merged registry this session may address. Empty when none was configured. */\n registry: MergedAIProviderRegistry;\n /**\n * Environment `credential.ref` lookups resolve against — the process\n * environment widened with `config.env`, which is where the session\n * boundary delivered every resolved `SKAILE_AIP_<ID>_KEY`.\n */\n lookupEnv: Record<string, string | undefined>;\n /** Model selector: `<providerId>/<modelId>`, a bare id, or `@role`. */\n modelRef?: string;\n /** Roles table an `@role` selector resolves through. */\n roles?: Record<string, string>;\n}\n\n/**\n * Resolve the session's providers once, from its {@link AgentConfig}.\n *\n * `config.env` is folded into `lookupEnv` rather than kept apart: it is part\n * of the session's environment, not an extra, and a credential or\n * `*_BASE_URL` delivered there must be visible exactly as the child will see\n * it.\n */\nexport function resolveEnvHarnessSession(\n config: AgentConfig,\n processEnv: Record<string, string | undefined> = process.env,\n): EnvHarnessSession {\n return {\n registry: config.registry ?? mergeRegistries([]),\n lookupEnv: { ...processEnv, ...config.env },\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n };\n}\n\n/** One resolved endpoint + model — everything a harness needs to spawn. */\nexport interface RegistryModelBinding {\n /** Registry id of the selected entry. */\n providerId: string;\n /** The selected entry itself. */\n entry: AIProviderLlmEntry;\n /** Logical model id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side model id — what goes on the wire / command line. */\n providerModelId?: string;\n /** Wire protocol, from the entry or its preset. */\n surface?: AIProviderSurface;\n /** Resolved endpoint, from the entry, its transport params, or its preset. */\n baseUrl?: string;\n /**\n * The provider name the *harness* knows this endpoint by — a catalog preset\n * id for a stock endpoint, the registry id for anything custom. See\n * {@link harnessProviderName}.\n */\n harnessProviderId: string;\n /** Non-fatal notes from `parseModelRef` (dangling role, disabled provider). */\n warnings: string[];\n}\n\n/** The entry's wire surface: its own, else its preset's. */\nexport function entrySurface(entry: AIProviderLlmEntry): AIProviderSurface | undefined {\n if (entry.surface) return entry.surface;\n return entry.preset ? getProviderPreset(entry.preset)?.surface : undefined;\n}\n\n/**\n * The entry's endpoint: its literal or transport-derived URL, else its\n * preset's literal, in the canonical spelling for its surface\n * (`normalizeEntryBaseUrl`: an `anthropic-messages` endpoint is its host root,\n * so `https://api.anthropic.com/v1` reads as `https://api.anthropic.com`).\n * Transport templates that still carry `{param}` placeholders never come\n * back — `resolveEntryBaseUrl` withholds those, and a preset's template is not\n * a URL.\n *\n * Every adapter reads the endpoint here and only re-spells it for a client\n * that wants something else ({@link versionedAnthropicBaseUrl}).\n */\nexport function entryBaseUrl(entry: AIProviderLlmEntry): string | undefined {\n const resolved =\n resolveEntryBaseUrl(entry) ??\n (entry.preset ? getProviderPreset(entry.preset)?.base_url : undefined);\n return normalizeEntryBaseUrl(resolved, entrySurface(entry));\n}\n\n/**\n * An `anthropic-messages` endpoint spelled for a client that appends only\n * `/messages` — `@ai-sdk/anthropic` (OpenCode) and Continue — rather than\n * `/v1/messages` like the Claude CLI, the Anthropic SDK and Goose. `baseUrl`\n * must already be canonical ({@link entryBaseUrl}); every other surface passes\n * through unchanged.\n */\nexport function versionedAnthropicBaseUrl(\n baseUrl: string,\n surface: AIProviderSurface | undefined,\n): string {\n if (surface !== \"anthropic-messages\") return baseUrl;\n // Append to the path, not the string: a query or fragment stays at the end.\n try {\n const url = new URL(baseUrl);\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/v1`;\n return url.toString();\n } catch {\n return `${baseUrl}/v1`;\n }\n}\n\n/**\n * True when a `credentials-n` harness already knows this endpoint under its\n * own catalog name — the entry names a preset and did not move it somewhere\n * else. Both sides are compared canonically, so `https://api.anthropic.com/v1`\n * is still the `anthropic` preset's endpoint.\n *\n * The one rule both halves of §2.3 read: it decides the name the env half\n * puts on the command line ({@link harnessProviderName}) *and* whether the\n * file half has to describe the endpoint at all. Reading it twice is what\n * keeps `-m <name>/<model>` and the generated provider file talking about the\n * same thing.\n */\nexport function isStockCatalogEndpoint(entry: AIProviderLlmEntry): boolean {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset) return false;\n return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));\n}\n\n/**\n * The provider name to give a `credentials-n` harness (`-m <name>/<model>`,\n * `GOOSE_PROVIDER`).\n *\n * A stock catalog endpoint is named by its preset, because that is the name\n * OpenCode's models.dev list and Goose's built-in provider table already use —\n * `prod-claude: {preset: anthropic}` is still Anthropic to them. An entry with\n * an endpoint of its own is named by its registry id: no built-in table knows\n * it, so the id is what its generated provider file is keyed by (the file half\n * of §2.3).\n */\nexport function harnessProviderName(providerId: string, entry: AIProviderLlmEntry): string {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset || !isStockCatalogEndpoint(entry)) return providerId;\n return preset.id;\n}\n\n/**\n * Enabled `llm`/`embed` entries, in registry order. Also the set the file\n * adapters render (`opencode-config.ts`, `goose-custom-providers.ts`,\n * `continue-config-yaml.ts`): the env half and the file half must agree on\n * which entries exist before they can agree on what to call them.\n */\nexport function selectableEntries(\n registry: MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * The provider-side model ids an entry declares, as `[logicalId, providerId]`\n * pairs in declaration order: every `model_map` entry, plus every\n * `capabilities` key the map does not rename.\n */\nexport function entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logicalIds = [\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}).filter((id) => !(id in (entry.model_map ?? {}))),\n ];\n return logicalIds.map((id) => [id, entry.model_map?.[id] ?? id]);\n}\n\nfunction describeBinding(\n providerId: string,\n entry: AIProviderLlmEntry,\n modelId: string | undefined,\n providerModelId: string | undefined,\n warnings: string[],\n): RegistryModelBinding {\n const surface = entrySurface(entry);\n const baseUrl = entryBaseUrl(entry);\n return {\n providerId,\n entry,\n ...(modelId === undefined ? {} : { modelId }),\n ...(providerModelId === undefined ? {} : { providerModelId }),\n ...(surface ? { surface } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n harnessProviderId: harnessProviderName(providerId, entry),\n warnings,\n };\n}\n\n/**\n * Resolve the session's endpoint + model.\n *\n * With no selector the first entry in registry order wins and the harness\n * keeps its own default model — exactly what an absent `model` meant before\n * the registry existed. Returns `undefined` when no entry can serve a model\n * (an empty, fully-disabled or voice-only registry).\n */\nexport function resolveRegistryBinding(\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const entries = selectableEntries(session.registry);\n if (entries.length === 0) return undefined;\n\n const selector = session.modelRef?.trim();\n if (!selector) {\n const [providerId, entry] = entries[0];\n return describeBinding(providerId, entry, undefined, undefined, []);\n }\n\n // A selector that is exactly an entry id names the endpoint and nothing\n // else: the harness keeps its own default model. `parseModelRef` would read\n // it as a bare *model* id and fall back to registry order.\n const named = entries.find(([id]) => id === selector);\n if (named) return describeBinding(named[0], named[1], undefined, undefined, []);\n\n const resolved = parseModelRef(selector, session.registry, session.roles);\n if (!resolved) return undefined;\n const match = entries.find(([id]) => id === resolved.providerId);\n if (!match) return undefined;\n return describeBinding(\n match[0],\n match[1],\n resolved.modelId,\n resolved.providerModelId,\n resolved.warnings,\n );\n}\n\n/**\n * Every credential a `credentials-n` harness may use: one variable per\n * enabled registry entry. OpenCode, Goose and Continue have always received\n * *all* of them, not just the selected endpoint's, because they route across\n * providers inside a single session.\n */\nexport function credentialsForEveryProvider(session: EnvHarnessSession): Record<string, string> {\n return registryCredentialEnv(session.registry, { env: session.lookupEnv });\n}\n\n/**\n * Throw when the bound entry speaks a wire surface this harness cannot.\n *\n * The message names the offending surface and lists the ones the harness does\n * speak (`BUILTIN_HARNESS_CATALOG[harnessId].surfaces`). An entry that declares\n * no surface and names no preset is not judged — there is nothing to compare.\n */\nexport function assertHarnessSpeaksSurface(\n harnessId: string,\n productName: string,\n binding: RegistryModelBinding,\n): void {\n const supported = BUILTIN_HARNESS_CATALOG[harnessId]?.surfaces;\n if (!supported || supported.length === 0) return;\n const surface = binding.surface;\n if (!surface || supported.includes(surface)) return;\n throw new Error(\n `${productName} cannot speak the '${surface}' surface of AI provider entry ` +\n `'${binding.providerId}'. ${productName} speaks: ${supported.join(\", \")}. ` +\n `Point this session's model at an entry with one of those surfaces, ` +\n `or run it on a harness that speaks '${surface}'.`,\n );\n}\n\n/**\n * The models a `credentials-n` harness can be pointed at, straight from the\n * registry: every enabled entry's mapped ids, namespaced the way the harness\n * takes them (`-m <provider>/<model>`).\n *\n * These harnesses have no model-list endpoint of their own — OpenCode reads\n * models.dev, Goose and Continue read their config — so the registry is the\n * only list that describes *this* session's reachable models, and it needs no\n * network call to produce.\n */\nexport function registryModelEntries(session: EnvHarnessSession): ModelEntry[] {\n const out: ModelEntry[] = [];\n const seen = new Set<string>();\n for (const [providerId, entry] of selectableEntries(session.registry)) {\n const harnessId = harnessProviderName(providerId, entry);\n const label = entry.label ?? providerId;\n for (const [logicalId, providerModelId] of entryModelIds(entry)) {\n const id = `${harnessId}/${providerModelId}`;\n if (seen.has(id)) continue;\n seen.add(id);\n out.push({ id, name: `${label} ${logicalId}` });\n }\n }\n return out;\n}\n\n/**\n * Resolve the binding and enforce the surface — what a `single`-plurality\n * harness does at start.\n *\n * The registry is authoritative: pointing the harness at an entry it cannot\n * speak throws rather than silently running somewhere else. `undefined` when\n * the session configured no endpoint at all, which leaves the harness on its\n * own native auth.\n */\nexport function bindSingleProviderEntry(\n harnessId: string,\n productName: string,\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n assertHarnessSpeaksSurface(harnessId, productName, binding);\n return binding;\n}\n\n/**\n * The `<provider>/<model>` selector a `credentials-n` harness takes on its\n * command line (`opencode -m`). `undefined` when no model was selected — the\n * harness then uses its own default rather than being handed a bare provider.\n */\nexport function harnessModelSelector(binding: RegistryModelBinding): string | undefined {\n if (!binding.providerModelId) return undefined;\n return `${binding.harnessProviderId}/${binding.providerModelId}`;\n}\n\n/**\n * Continue's model selection is a **role binding**, not a flag: `cn` has no\n * `--model` option (only `--config <slug>`), and its `config.yaml` binds each\n * model to roles (`chat`, `edit`, `apply`, …). This is the binding for the\n * role a headless `cn -p` turn runs as, and the shape its generated\n * `config.yaml` is rendered from.\n *\n * `apiKeyEnv` is a variable *name*: the secret travels in the child\n * environment, never in a rendered config.\n */\nexport interface ContinueRoleBinding {\n /** Continue role this model serves. A headless prompt is a `chat` turn. */\n role: \"chat\";\n /** Registry id of the entry. */\n providerId: string;\n /** Provider name Continue knows the endpoint by. */\n provider: string;\n /** Provider-side model id. */\n model?: string;\n /** Endpoint, when the entry states one, spelled the way Continue's `apiBase` wants it. */\n apiBase?: string;\n /** Env var holding the credential — the name, never the value. */\n apiKeyEnv: string;\n}\n\n/**\n * Map the session's chosen endpoint onto the Continue role a headless turn\n * runs as. `undefined` when the session configured no endpoint — `cn` then\n * runs against whatever its own `config.yaml` / Hub login provides.\n */\nexport function continueRoleBinding(session: EnvHarnessSession): ContinueRoleBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n return {\n role: \"chat\",\n providerId: binding.providerId,\n provider: binding.harnessProviderId,\n ...(binding.providerModelId ? { model: binding.providerModelId } : {}),\n ...(binding.baseUrl\n ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) }\n : {}),\n apiKeyEnv: providerCredentialEnvName(binding.providerId),\n };\n}\n"]}
@@ -428,6 +428,7 @@ function fromMcpServerMdContent(content, repoName, filePath) {
428
428
  if (Array.isArray(meta.fields)) {
429
429
  metadata.fields = meta.fields;
430
430
  }
431
+ if (typeof meta.lazy === "boolean") metadata.lazy = meta.lazy;
431
432
  return {
432
433
  name: String(meta.name ?? basename(dirname(filePath))),
433
434
  kind: "mcp-server",
@@ -760,5 +761,5 @@ function readAssetBody(file, text) {
760
761
  }
761
762
 
762
763
  export { DEFAULT_FS_DEADLINE_MS, DEFAULT_WALK_BUDGET_MS, DEFAULT_WALK_MAX_DEPTH, DEFAULT_WALK_MAX_ENTRIES, FS_DEADLINE_ENV_VAR, FsDeadlineError, ManifestKindError, WALK_BUDGET_MS_ENV_VAR, WALK_MAX_DEPTH_ENV_VAR, WALK_MAX_ENTRIES_ENV_VAR, agentYamlRequires, assetDepRefs, dedupeRequirementRefs, dedupeRequirements, fromAgentMd, fromAgentYaml, fromConnectorMd, fromContractMd, fromFlowYaml, fromKnowledgeYaml, fromMcpServerMd, fromMcpServerMdContent, fromPresetYaml, fromPromptMd, fromSkillMd, frontmatterYamlProblem, fsDeadlineMs, isManifestName, manifestKindDiagnostic, parseFrontmatter, parseRequires, presetItemRefs, readAssetBody, requirementKey, scanDirectory, setWalkTruncationSink, tryWithFsDeadline, walkDir, withFsDeadline, withYamlQuotingHint, yamlQuotingHint };
763
- //# sourceMappingURL=chunk-AVFRFGM2.js.map
764
- //# sourceMappingURL=chunk-AVFRFGM2.js.map
764
+ //# sourceMappingURL=chunk-GNUA7XT2.js.map
765
+ //# sourceMappingURL=chunk-GNUA7XT2.js.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AAA,IAAI,KAAK,QAAA,CAAS,KAAK,GAAG,OAAO,gBAAA,CAAiB,IAAI,CAAA,CAAE,IAAA;AACxD,EAAA,IAAI,QAAA,CAAS,IAAI,CAAA,KAAM,YAAA,EAAc,OAAO,MAAA;AAC5C,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,IAAI,GAAG,SAAS,CAAA;AAC1C,EAAA,OAAO,UAAA,CAAW,IAAI,CAAA,GAAI,YAAA,CAAa,MAAM,MAAM,CAAA,CAAE,MAAK,GAAI,MAAA;AAChE","file":"chunk-GNUA7XT2.js","sourcesContent":["/**\n * Deadline guards for filesystem work that can land on a network mount.\n *\n * Inside the agent container `/skaile/workspace` **is** an rclone FUSE mount\n * (SharePoint / OneDrive / WebDAV). When the host rclone process wedges, a\n * filesystem call against that path parks in an uninterruptible kernel wait.\n * A **synchronous** call there stops the entire single-threaded event loop —\n * the whole `skaile serve` process stops serving, and the platform reads the\n * session as dead or idle. A hang is not an error, so `try/catch` never fires.\n *\n * Two rules follow, and both matter:\n *\n * 1. **Never touch a mount synchronously.** Async `node:fs/promises` keeps the\n * loop free, so a wedged mount degrades to one stuck request instead of a\n * dead session. This is the actual fix.\n * 2. **Bound the wait.** {@link withFsDeadline} converts an unbounded wait into\n * a bounded failure so the requester gets an error rather than nothing.\n *\n * `withFsDeadline` does **not** cancel the underlying operation — Node cannot\n * abort a syscall already in the kernel. The losing promise stays pending until\n * the mount recovers or the process exits. That is acceptable precisely because\n * rule 1 holds: a pending promise costs one handle, not the event loop.\n *\n * Modelled on `connectors/src/fleet-utils.ts` (`ensureFleetMounted`), which\n * already does async-stat-with-deadline correctly.\n */\n\n/** Default deadline for a single filesystem operation on a possibly-networked mount. */\nexport const DEFAULT_FS_DEADLINE_MS = 15_000;\n\n/**\n * Env override for {@link DEFAULT_FS_DEADLINE_MS}, in milliseconds.\n *\n * A cloud-backed mount over a slow link can legitimately need longer than the\n * default; operators raise this rather than patching call sites.\n */\nexport const FS_DEADLINE_ENV_VAR = \"SKAILE_FS_DEADLINE_MS\";\n\n/**\n * Thrown when a filesystem operation misses its deadline.\n *\n * Distinct from a plain `Error` so callers can tell \"the mount is wedged\" apart\n * from \"the file does not exist\" and surface the right message to the frontend.\n */\nexport class FsDeadlineError extends Error {\n readonly timeoutMs: number;\n readonly operation: string;\n\n constructor(operation: string, timeoutMs: number) {\n super(\n `filesystem operation \"${operation}\" exceeded ${timeoutMs}ms — the mount may be unresponsive`,\n );\n this.name = \"FsDeadlineError\";\n this.operation = operation;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Resolve the effective filesystem deadline.\n *\n * Reads {@link FS_DEADLINE_ENV_VAR} on every call rather than caching it: the\n * runner mutates `process.env` while wiring a session, so a module-load-time\n * snapshot would pin the value set before configuration ran.\n *\n * @param fallback - Deadline to use when the env var is absent or unusable.\n * @returns The deadline in milliseconds.\n */\nexport function fsDeadlineMs(fallback: number = DEFAULT_FS_DEADLINE_MS): number {\n const raw = process.env[FS_DEADLINE_ENV_VAR];\n if (raw === undefined) return fallback;\n const parsed = Number.parseInt(raw, 10);\n // A non-positive or non-numeric override would disable the guard entirely,\n // which is exactly the failure mode this module exists to prevent.\n return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\n/**\n * Run an async filesystem operation under a deadline.\n *\n * @param operation - Short label used in the timeout message (e.g. `\"readdir /skaile/workspace\"`).\n * @param fn - Thunk performing the operation. Called immediately.\n * @param timeoutMs - Deadline override; defaults to {@link fsDeadlineMs}.\n * @returns The operation's result.\n * @throws {FsDeadlineError} when the deadline elapses first.\n * @throws Whatever `fn` rejects with, unchanged, when it loses no race.\n * @docLink packages/core/api-reference#with-fs-deadline\n */\nexport async function withFsDeadline<T>(\n operation: string,\n fn: () => Promise<T>,\n timeoutMs: number = fsDeadlineMs(),\n): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n fn(),\n new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => reject(new FsDeadlineError(operation, timeoutMs)), timeoutMs);\n // Never hold the process open on the guard alone — without unref a\n // pending deadline would keep `skaile serve` alive after shutdown.\n timer.unref?.();\n }),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\n/**\n * Run an async filesystem operation under a deadline, mapping every failure to\n * `fallback`.\n *\n * For best-effort probes that previously used `existsSync` — a missing file, an\n * unreadable file, and a wedged mount are all \"nothing usable here\", and the\n * caller has no better move than to continue without it.\n *\n * @param operation - Short label used in the timeout message.\n * @param fn - Thunk performing the operation.\n * @param fallback - Value returned when `fn` rejects or the deadline elapses.\n * @param timeoutMs - Deadline override; defaults to {@link fsDeadlineMs}.\n */\nexport async function tryWithFsDeadline<T>(\n operation: string,\n fn: () => Promise<T>,\n fallback: T,\n timeoutMs: number = fsDeadlineMs(),\n): Promise<T> {\n try {\n return await withFsDeadline(operation, fn, timeoutMs);\n } catch {\n return fallback;\n }\n}\n","/**\n * Requirement identity — one key for \"asset X requires asset Y\", wherever the\n * declaration comes from (a SKILL.md `metadata.requires` entry, a manifest\n * `dependencies:` entry, a lock-time edge).\n *\n * A requirement is identified by `publisher/kind:name`. A declaration that names\n * no publisher means \"the declaring asset's own publisher\", so `report-table` on a\n * `@skaile-ai` asset and `skill:@skaile-ai/report-table` are the same requirement.\n * Every command that lists, dedupes or compares requirements goes through here.\n */\n\nimport { type Dependency, depToStr, parseDep } from \"./models.js\";\n\n/**\n * `publisher/kind:name` identity of a requirement. A dependency that names no\n * publisher takes `fallbackPublisher` (the declaring asset's); without either, the\n * key is the unqualified `kind:name`.\n */\nexport function requirementKey(dep: Dependency, fallbackPublisher?: string): string {\n const publisher = dep.publisher ?? fallbackPublisher ?? \"\";\n return publisher ? `${publisher}/${dep.kind}:${dep.name}` : `${dep.kind}:${dep.name}`;\n}\n\n/**\n * Each requirement once, in first-seen order. Two declarations of the same\n * {@link requirementKey} collapse into one; the surviving entry carries the\n * publisher and the pin of whichever declaration named them.\n */\nexport function dedupeRequirements(\n deps: readonly Dependency[],\n fallbackPublisher?: string,\n): Dependency[] {\n const out: Dependency[] = [];\n const at = new Map<string, number>();\n for (const dep of deps) {\n const key = requirementKey(dep, fallbackPublisher);\n const i = at.get(key);\n if (i === undefined) {\n at.set(key, out.length);\n out.push({ ...dep });\n continue;\n }\n const kept = out[i] as Dependency;\n if (!kept.publisher && dep.publisher) kept.publisher = dep.publisher;\n if (!kept.pin && dep.pin) kept.pin = dep.pin;\n }\n return out;\n}\n\n/** {@link dedupeRequirements} for requirement strings (`kind:name[#pin]`, `kind:@pub/name[#pin]`). */\nexport function dedupeRequirementRefs(\n refs: readonly string[],\n fallbackPublisher?: string,\n): string[] {\n const parse = (ref: string): Dependency => {\n const dep = parseDep(ref);\n // The scoped form carries its own pin; a bare `kind:name#pin` keeps it in the name.\n const hash = dep.name.indexOf(\"#\");\n if (hash === -1) return dep;\n const pin = dep.name.slice(hash + 1).trim();\n dep.name = dep.name.slice(0, hash);\n if (pin && !dep.pin) dep.pin = pin;\n return dep;\n };\n return dedupeRequirements(refs.map(parse), fallbackPublisher).map(depToStr);\n}\n","/**\n * Manifest parsing — reads SKILL.md, AGENT.md, agent.yaml, CONTRACT.md,\n * CONNECTOR.md, *.prompt.md, *.flow.yaml, *.preset.yaml files and\n * produces CatalogEntry objects.\n * Used by @skaile/asset-manager for on-demand repo scanning.\n *\n * **All filesystem access here is async and bounded** (issue #454). A repo root\n * can resolve onto the rclone FUSE mount at `/skaile/workspace` — either\n * directly (a `sources[].path` pointing into the workspace) or indirectly, since\n * the walk follows symlinks and an off-mount tree can link into one. A\n * synchronous `readdirSync`/`statSync`/`readFileSync` there parks the whole\n * `skaile serve` event loop in an uninterruptible kernel wait, and a hang is not\n * an error so `try/catch` never fires. Every call goes through\n * {@link withFsDeadline}/{@link tryWithFsDeadline}, and the walk itself is\n * bounded by depth, entry count, a wall-clock budget, and an ancestor-inode set.\n */\n\nimport type { Dirent } from \"node:fs\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { opendir, readFile, stat } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { parse } from \"yaml\";\nimport { fsDeadlineMs, tryWithFsDeadline, withFsDeadline } from \"./fs-deadline.js\";\nimport { createLogger } from \"./logging/create-logger.js\";\nimport type { AssetKind, CatalogEntry, Dependency } from \"./models.js\";\nimport { isValidAssetName, parseDep, slugifyAssetName } from \"./models.js\";\nimport { dedupeRequirements } from \"./requirements.js\";\nimport type { Diagnostic } from \"./workspace-config.js\";\n\n// ── Bounded manifest I/O ──────────────────────────────────────────────────────\n\n/**\n * Read one manifest file under a deadline.\n *\n * @param filePath - Absolute path to the manifest.\n * @param timeoutMs - Per-operation deadline; defaults to {@link fsDeadlineMs}.\n * @throws {import(\"./fs-deadline.js\").FsDeadlineError} when the read outlives the deadline.\n */\nfunction readManifestFile(filePath: string, timeoutMs?: number): Promise<string> {\n return withFsDeadline(`readFile ${filePath}`, () => readFile(filePath, \"utf8\"), timeoutMs);\n}\n\n/**\n * Read one manifest file under a deadline, degrading an unreadable/slow file to\n * an empty document. Mirrors the pre-#454 `try { readFileSync } catch {}` shape\n * of the YAML parsers: a file we cannot read yields `{}` metadata rather than\n * aborting the caller.\n */\nfunction readManifestFileOrEmpty(filePath: string, timeoutMs?: number): Promise<string> {\n return tryWithFsDeadline(`readFile ${filePath}`, () => readFile(filePath, \"utf8\"), \"\", timeoutMs);\n}\n\n// ── Frontmatter helpers ───────────────────────────────────────────────────────\n\n/**\n * Result of parsing YAML frontmatter from a markdown file.\n * @docLink packages/core/concepts#frontmatter-result\n */\nexport interface FrontmatterResult {\n /** Parsed YAML data. Empty object if no frontmatter block is present. */\n data: Record<string, unknown>;\n /** Markdown body below the frontmatter block (trimmed). */\n body: string;\n}\n\n/**\n * Parse YAML frontmatter from a markdown file (`---` delimited).\n * Returns `{ data: {}, body: text }` when no frontmatter block is present.\n * A leading UTF-8 byte-order mark and `\\r\\n` line endings (Windows editors, `git` autocrlf)\n * are read as plain `\\n` text: the same file parses the same on every platform, and a\n * scalar never carries a trailing `\\r`.\n *\n * @param raw - Raw file contents\n * @returns Parsed frontmatter data and the remaining body text\n * @docLink packages/core/concepts#parse-frontmatter\n */\nexport function parseFrontmatter(raw: string): FrontmatterResult {\n const text = raw.replace(/^\\uFEFF/, \"\").replace(/\\r\\n/g, \"\\n\");\n const m = text.match(/^---\\s*\\n([\\s\\S]*?)\\n---/);\n if (!m) return { data: {}, body: text.trim() };\n try {\n const data = (parse(m[1]!) as Record<string, unknown>) ?? {};\n const body = text.slice(m[0].length).trim();\n return { data, body };\n } catch {\n return { data: {}, body: text.trim() };\n }\n}\n\n/**\n * The 1-based line a YAML parser message points at (`at line 5, column 5` of the `yaml` package,\n * `(5:5)` of js-yaml), or `undefined` when the message names none.\n */\nfunction yamlErrorLine(message: string): number | undefined {\n const m = /at line (\\d+)|\\((\\d+):\\d+\\)/.exec(message);\n const line = m?.[1] ?? m?.[2];\n return line === undefined ? undefined : Number(line);\n}\n\n/** A line of YAML without its quoted strings and its comment. */\nfunction unquotedYamlLine(line: string): string {\n return line.replace(/\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^']|'')*'/g, '\"\"').replace(/(^|\\s)#.*$/, \"\");\n}\n\n/**\n * The sentence that tells an author to quote a value YAML cannot start (`- @acme/dep-a`), or `\"\"`.\n * Read from the parser's `cause` (`Plain value cannot start with reserved character @`) or, for\n * a parser that words it otherwise (`bad indentation of a sequence entry`, `missed comma between\n * flow collection entries`), from the line of `text` the error points at: a value that starts with\n * `@` in a list item, after a key or inside a flow list on that line. An error on a line without\n * an unquoted `@` value (an unclosed `[` further down, `@` inside a quoted string or a comment)\n * gets no hint. One text for every YAML file skaile reads (p1750).\n *\n * @param cause - The parser message (its first line)\n * @param text - The YAML the parser read\n * @param line - 1-based error line in `text`; read from `cause` when omitted\n */\nexport function yamlQuotingHint(cause: string, text?: string, line?: number): string {\n const reserved = /reserved character|cannot start/i.test(cause);\n const at = line ?? yamlErrorLine(cause);\n const errorLine = text !== undefined && at !== undefined ? text.split(\"\\n\")[at - 1] : undefined;\n const startsWithAt =\n errorLine !== undefined &&\n /^\\s*-\\s+@|^\\s*[^\\s#][^#]*?:\\s+@|[[,]\\s*@/.test(unquotedYamlLine(errorLine));\n if (!reserved && !startsWithAt) return \"\";\n const example = startsWithAt || /character @/.test(cause) ? ', e.g. \"@publisher/name\"' : \"\";\n return ` Put the value in double quotes${example}.`;\n}\n\n/**\n * A YAML parser message with {@link yamlQuotingHint} after its first line (the cause); the source\n * excerpt the parser appends below it stays where it was. `message` unchanged when no hint applies.\n */\nexport function withYamlQuotingHint(message: string, text: string): string {\n const [first = \"\", ...rest] = message.split(\"\\n\");\n const hint = yamlQuotingHint(first, text);\n if (hint === \"\" || first.includes(\"double quotes\")) return message;\n const cause = first.replace(/[.:]$/, \"\");\n return [`${cause}.${hint}`, ...rest].join(\"\\n\");\n}\n\n/**\n * Why a `---` front matter block is not valid YAML, `undefined` when the file has no block or the\n * block parses. {@link parseFrontmatter} reads such a block as no front matter at all, so a\n * caller that says \"no front matter\" for a file that has one names the YAML error here instead:\n * the cause, the file line, and for a value YAML cannot start (`- @acme/dep-a`) the quoting fix\n * (p1551).\n *\n * @param raw - Raw file contents\n */\nexport function frontmatterYamlProblem(raw: string): string | undefined {\n const text = raw.replace(/^\\uFEFF/, \"\").replace(/\\r\\n/g, \"\\n\");\n const m = text.match(/^---\\s*\\n([\\s\\S]*?)\\n---/);\n if (!m) return undefined;\n try {\n parse(m[1]!);\n return undefined;\n } catch (e) {\n const err = e as { message?: string; linePos?: Array<{ line: number }> };\n const cause = (err.message ?? String(e)).split(\" at line \")[0]!.trim();\n const before = text.slice(0, m[0].length - m[1]!.length - 4).split(\"\\n\").length - 1;\n const line = err.linePos?.[0]?.line;\n const where = line === undefined ? \"\" : ` (line ${before + line} of the file)`;\n const quoting = yamlQuotingHint(cause, m[1], line);\n return `the front matter is not valid YAML: ${cause}${where}.${quoting}`;\n }\n}\n\n/** Extract version from frontmatter, checking both top-level and metadata.version. */\nfunction extractVersion(meta: Record<string, unknown>): string {\n return String(\n meta.version ?? (meta.metadata as Record<string, unknown> | undefined)?.version ?? \"\",\n );\n}\n\n/**\n * Parse the `requires:` field from manifest frontmatter into typed `Dependency` objects.\n * Accepts a comma-separated string or an array of `\"kind:name\"` strings. Reads from either\n * the root or `metadata.requires` (matching `extractVersion`'s dual-location behavior) so\n * skill authors can follow the agentskills.io convention of placing skaile extensions under\n * `metadata:` while remaining backward-compatible with root-level declarations.\n *\n * @param meta - Parsed frontmatter data object\n * @returns Array of `Dependency` objects (empty when `requires` is absent)\n * @docLink packages/core/concepts#parse-requires\n */\nexport function parseRequires(meta: Record<string, unknown>): Dependency[] {\n const raw = meta.requires ?? (meta.metadata as Record<string, unknown> | undefined)?.requires;\n if (!raw) return [];\n const list =\n typeof raw === \"string\"\n ? raw.split(\",\").map((s) => s.trim())\n : Array.isArray(raw)\n ? (raw as string[])\n : [];\n return list.filter(Boolean).map(parseDep);\n}\n\n// ── agent.yaml composes → requires ─────────────────────────────────────────────\n\n/**\n * Collect the catalog refs of an `agent.yaml` `composes[]` list as requires so\n * `skaile install` pulls them automatically. Local paths (`.`/`/`) and\n * `library://` instance refs are skipped — not catalog assets. A ref without a\n * `kind:` prefix takes the item's `kind`; the publisher scope, `@version` and\n * `#pin` are stripped so only `kind:name` is tracked.\n */\nfunction collectComposeRefs(raw: unknown, out: Dependency[]): void {\n if (!Array.isArray(raw)) return;\n for (const item of raw) {\n if (typeof item !== \"object\" || item === null) continue;\n const { kind: itemKind, ref } = item as Record<string, unknown>;\n if (typeof ref !== \"string\" || !ref) continue;\n if (ref.startsWith(\".\") || ref.startsWith(\"/\") || ref.includes(\"://\")) continue;\n if (typeof itemKind !== \"string\" || !itemKind) continue;\n const normalized = ref.includes(\":\") ? ref : `${itemKind}:${ref}`;\n const colonIdx = normalized.indexOf(\":\");\n const kind = normalized.slice(0, colonIdx).trim();\n let rest = normalized.slice(colonIdx + 1).trim();\n const hashIdx = rest.indexOf(\"#\");\n if (hashIdx !== -1) rest = rest.slice(0, hashIdx).trim();\n if (rest.startsWith(\"@\")) {\n // Scoped form @publisher/name → name is the segment after the slash.\n const slashIdx = rest.indexOf(\"/\");\n rest = slashIdx !== -1 ? rest.slice(slashIdx + 1).trim() : \"\";\n }\n // A trailing `@<version>` range (`name@^1`) is not part of the name.\n const atIdx = rest.indexOf(\"@\");\n const name = atIdx !== -1 ? rest.slice(0, atIdx).trim() : rest;\n if (name) out.push({ kind, name });\n }\n}\n\n// ── Manifest parsers ──────────────────────────────────────────────────────────\n\n/**\n * Thrown when a `SKILL.md`-style manifest declares a `type:` that is not a\n * registered asset kind. The kind registry is the only authority on kinds, so an\n * unregistered `type:` is reported (see {@link manifestKindDiagnostic}) instead\n * of being silently catalogued as a skill.\n */\nexport class ManifestKindError extends Error {\n constructor(\n readonly filePath: string,\n readonly kind: string,\n ) {\n super(`${filePath}: unknown asset kind \"${kind}\" in frontmatter \\`type:\\``);\n this.name = \"ManifestKindError\";\n }\n}\n\n/** Convert a {@link ManifestKindError} into the `unknown_asset_kind` error diagnostic. */\nexport function manifestKindDiagnostic(err: ManifestKindError): Diagnostic {\n return {\n code: \"unknown_asset_kind\",\n severity: \"error\",\n message: `${err.filePath}: asset kind \"${err.kind}\" is not registered`,\n path: err.filePath,\n };\n}\n\n/**\n * Parse a `SKILL.md` file into a `CatalogEntry`.\n * The `kind` field defaults to `\"skill\"` but can be overridden via the `type:`\n * frontmatter key to any registered kind. Falls back to the parent directory name\n * when `name:` is absent.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `SKILL.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @param knownKinds - Registered asset kinds (`registry.getAllKinds()`); a `type:` outside it throws\n * @returns Populated `CatalogEntry` with kind, name, description, version, and requires\n * @throws {ManifestKindError} when `type:` names an unregistered kind\n * @docLink packages/core/concepts#from-skill-md\n */\nexport async function fromSkillMd(\n filePath: string,\n repoName: string,\n knownKinds: ReadonlySet<string>,\n): Promise<CatalogEntry> {\n return fromSkillMdContent(await readManifestFile(filePath), repoName, filePath, knownKinds);\n}\n\n/** Pure {@link fromSkillMd} core over already-read content (no I/O). */\nfunction fromSkillMdContent(\n content: string,\n repoName: string,\n filePath: string,\n knownKinds: ReadonlySet<string>,\n): CatalogEntry {\n const { data: meta } = parseFrontmatter(content);\n // An absent `type:` is the SKILL.md default; an explicit one must be registered.\n const kind = meta.type === undefined ? \"skill\" : String(meta.type);\n if (meta.type !== undefined && !knownKinds.has(kind)) throw new ManifestKindError(filePath, kind);\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind,\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse an `AGENT.md` file into a `CatalogEntry` with `kind: \"agent\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `AGENT.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"agent\"`\n * @docLink packages/core/concepts#from-agent-md\n */\nexport async function fromAgentMd(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromAgentMdContent(await readManifestFile(filePath), repoName, filePath);\n}\n\n/** Pure {@link fromAgentMd} core over already-read content (no I/O). */\nfunction fromAgentMdContent(content: string, repoName: string, filePath: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(content);\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"agent\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse an `agent.yaml` file into a `CatalogEntry` with `kind: \"agent\"`.\n * `requires` lists the catalog refs of `composes[]` (local paths and `library://`\n * instances excluded). The deprecated 0.1 fields (`skills`, `requires`, `persona`,\n * …) are not read; `skaile validate` reports them.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `agent.yaml` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"agent\"` and full dependency graph\n * @docLink packages/core/concepts#from-agent-yaml\n */\nexport async function fromAgentYaml(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromAgentYamlContent(await readManifestFileOrEmpty(filePath), repoName, filePath);\n}\n\n/**\n * The catalog requirements of an `agent.yaml` text: its `composes[]` refs (see\n * {@link collectComposeRefs}). Empty for text that is not YAML.\n */\nexport function agentYamlRequires(content: string): Dependency[] {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(content) as Record<string, unknown>) ?? {};\n } catch {}\n const requires: Dependency[] = [];\n collectComposeRefs(meta.composes, requires);\n return requires;\n}\n\n/** Pure {@link fromAgentYaml} core over already-read content (no I/O). */\nfunction fromAgentYamlContent(content: string, repoName: string, filePath: string): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(content) as Record<string, unknown>) ?? {};\n } catch {}\n\n const requires = agentYamlRequires(content);\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"agent\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires,\n dependencies: [],\n };\n}\n\n/**\n * Parse a `*.prompt.md` file into a `CatalogEntry` with `kind: \"prompt\"`.\n * The name defaults to the filename stem (without the `.prompt.md` suffix)\n * when no `name:` frontmatter key is present.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `.prompt.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"prompt\"`\n * @docLink packages/core/concepts#from-prompt-md\n */\nexport async function fromPromptMd(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromPromptMdContent(await readManifestFile(filePath), repoName, filePath);\n}\n\n/** Pure {@link fromPromptMd} core over already-read content (no I/O). */\nfunction fromPromptMdContent(content: string, repoName: string, filePath: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(content);\n const name = String(meta.name ?? basename(filePath).replace(/\\.prompt\\.md$/, \"\"));\n return {\n name,\n kind: \"prompt\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse a `*.flow.yaml` or `*.flow.json` file into a `CatalogEntry` with `kind: \"flow\"`.\n * The name resolves from `id:` (a flow asset is named by its id, which the flow engine loads it\n * by), then `name:`, falling back to the filename stem; `name:` stays a display label.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the flow definition file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"flow\"`\n * @docLink packages/core/concepts#from-flow-yaml\n */\nexport async function fromFlowYaml(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromFlowYamlContent(await readManifestFileOrEmpty(filePath), repoName, filePath);\n}\n\n/**\n * The `kind:name[#pin]` refs the nodes of a v2 flow name in `run.assets`, deduped. They are the\n * flow's dependencies: `add flow:…` deploys them and `info` / `check` list them (p676). A string\n * without a `kind:` prefix is no asset ref and is left out.\n */\nfunction flowNodeAssetRefs(meta: Record<string, unknown>): string[] {\n const refs = new Set<string>();\n if (!Array.isArray(meta.nodes)) return [];\n for (const node of meta.nodes) {\n const run = (node as { run?: { assets?: unknown } } | null)?.run;\n if (!Array.isArray(run?.assets)) continue;\n for (const asset of run.assets) {\n if (typeof asset === \"string\" && /^[a-z][a-z-]*:/.test(asset.trim())) refs.add(asset.trim());\n }\n }\n return [...refs];\n}\n\n/** Pure {@link fromFlowYaml} core over already-read content (no I/O). */\nfunction fromFlowYamlContent(content: string, repoName: string, filePath: string): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(content) as Record<string, unknown>) ?? {};\n } catch {}\n\n const stem = basename(filePath)\n .replace(/\\.flow\\.yaml$/, \"\")\n .replace(/\\.flow\\.json$/, \"\");\n return {\n name: String(meta.id ?? meta.name ?? stem),\n kind: \"flow\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires: parseRequires(meta),\n dependencies: flowNodeAssetRefs(meta),\n };\n}\n\n/**\n * Split a preset's `items[]` into the asset refs a dependency expansion installs\n * and the instance items it cannot: `library://` instance refs, `#item` cross\n * references, items that prompt for `placeholders`, and `connector:`/`mcp:` items\n * with an `id` (those become `skaile.yaml` declarations through\n * `skaile preset apply`). Refs are kept verbatim — publisher/pin qualifiers\n * preserved, nested `preset:` refs included.\n *\n * @param items - The raw `items` value of a parsed preset manifest.\n * @returns Deduped asset refs plus the count of skipped instance items.\n * @docLink packages/core/concepts#preset-item-refs\n */\nexport function presetItemRefs(items: unknown): { refs: string[]; skipped: number } {\n const refs = new Set<string>();\n let skipped = 0;\n if (!Array.isArray(items)) return { refs: [], skipped };\n for (const raw of items) {\n if (raw === null || typeof raw !== \"object\") continue;\n const item = raw as Record<string, unknown>;\n const ref = typeof item.ref === \"string\" ? item.ref.trim() : \"\";\n if (!ref) continue;\n const hasPlaceholders = Array.isArray(item.placeholders) && item.placeholders.length > 0;\n const declaresInstance =\n typeof item.id === \"string\" && (ref.startsWith(\"connector:\") || ref.startsWith(\"mcp:\"));\n if (\n ref.startsWith(\"library://\") ||\n ref.startsWith(\"#\") ||\n hasPlaceholders ||\n declaresInstance\n ) {\n skipped++;\n continue;\n }\n refs.add(ref);\n }\n return { refs: [...refs], skipped };\n}\n\n/**\n * Parse a `*.preset.yaml` file into a `CatalogEntry` with `kind: \"preset\"`.\n * `dependencies` carries the asset refs of its items (see {@link presetItemRefs}).\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the preset YAML file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"preset\"`\n * @docLink packages/core/concepts#from-preset-yaml\n */\nexport async function fromPresetYaml(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromPresetYamlContent(await readManifestFileOrEmpty(filePath), repoName, filePath);\n}\n\n/** Pure {@link fromPresetYaml} core over already-read content (no I/O). */\nfunction fromPresetYamlContent(content: string, repoName: string, filePath: string): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(content) as Record<string, unknown>) ?? {};\n } catch {}\n\n const { refs, skipped } = presetItemRefs(meta.items);\n return {\n name: String(meta.name ?? basename(filePath).replace(/\\.preset\\.yaml$/, \"\")),\n kind: \"preset\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires: [],\n dependencies: refs,\n ...(skipped > 0 ? { skippedItems: skipped } : {}),\n };\n}\n\n/**\n * Extract an asset's raw transitive dependency ref strings from its manifest\n * file, kept verbatim (publisher/pin qualifiers preserved, comments dropped by\n * the parser): a `*.preset.yaml`'s asset items (see {@link presetItemRefs}) or the\n * union of a `*.flow.{yaml,json}`'s top-level `requires` / `dependencies`. Unlike\n * {@link parseRequires}, refs are returned as-is — the resolver needs the full\n * `kind:@<publisher>/name[#pin]` form, not a publisher-stripped {@link Dependency}.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to a `.preset.yaml` or `.flow.{yaml,json}`.\n * @returns Deduped `refs` (`[]` on parse failure or no deps) and the count of\n * preset instance items that are not expanded.\n * @docLink packages/core/concepts#asset-dep-refs\n */\nexport async function assetDepRefs(filePath: string): Promise<{ refs: string[]; skipped: number }> {\n return assetDepRefsFromContent(await readManifestFileOrEmpty(filePath), filePath);\n}\n\n/** Pure {@link assetDepRefs} core over already-read content (no I/O). */\nfunction assetDepRefsFromContent(\n content: string,\n filePath: string,\n): { refs: string[]; skipped: number } {\n // YAML is a JSON superset, so `parse` reads `.flow.json` too.\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(content) as Record<string, unknown>) ?? {};\n } catch {\n return { refs: [], skipped: 0 };\n }\n if (filePath.endsWith(\".preset.yaml\")) return presetItemRefs(meta.items);\n const out: string[] = [];\n const collect = (v: unknown) => {\n if (Array.isArray(v))\n for (const x of v) if (typeof x === \"string\" && x.trim()) out.push(x.trim());\n };\n collect(meta.requires);\n collect((meta.metadata as Record<string, unknown> | undefined)?.requires);\n collect(meta.dependencies);\n return { refs: [...new Set(out)], skipped: 0 };\n}\n\n/**\n * Parse a `CONTRACT.md` file into a `CatalogEntry` with `kind: \"contract\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `CONTRACT.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"contract\"`\n * @docLink packages/core/concepts#from-contract-md\n */\nexport async function fromContractMd(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromContractMdContent(await readManifestFile(filePath), repoName, filePath);\n}\n\n/** Pure {@link fromContractMd} core over already-read content (no I/O). */\nfunction fromContractMdContent(content: string, repoName: string, filePath: string): CatalogEntry {\n const { data: meta } = parseFrontmatter(content);\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"contract\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Pure core of a standalone, composition-only markdown asset (`PERSONA.md`, `RULESET.md`):\n * identity from the frontmatter, the parent directory name when `name:` is absent. A library\n * lists these in its manifest, validates and indexes them like every other kind (p1041).\n */\nfunction fromComposableMdContent(\n kind: \"persona\" | \"ruleset\",\n content: string,\n repoName: string,\n filePath: string,\n): CatalogEntry {\n const { data: meta } = parseFrontmatter(content);\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind,\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: [],\n dependencies: [],\n };\n}\n\n/**\n * Parse an `MCP.md` file into a `CatalogEntry` with `kind: \"mcp-server\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * Frontmatter fields (catalog identity):\n * - `name` — server name (default: parent dir name)\n * - `description` — short description\n * - `version` — semver\n * - `keywords` — array of discovery tags\n *\n * Frontmatter fields (runtime defaults, stored in `metadata`):\n * - `transport` — \"stdio\" | \"sse\" | \"http\" (default: \"stdio\")\n * - `command` — command to execute (stdio)\n * - `args` — command arguments (stdio)\n * - `env` — environment variables (stdio)\n * - `url` — server URL (sse/http)\n * - `headers` — HTTP headers (sse/http)\n *\n * When `mcp:name` appears in `skaile.yaml` `dependencies`, the runner reads\n * these defaults from `metadata` to build a `McpServerDeclaration` without\n * requiring verbose inline config.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `MCP.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"mcp-server\"`\n * @docLink packages/core/concepts#from-mcp-server-md\n */\nexport async function fromMcpServerMd(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromMcpServerMdContent(await readManifestFile(filePath), repoName, filePath);\n}\n\n/**\n * Parse pre-read MCP.md content into a `CatalogEntry`.\n * Callers that already hold the file content (e.g. to avoid a second read) use\n * this directly; `fromMcpServerMd` is a thin wrapper that reads then delegates here.\n *\n * @param content - UTF-8 content of the `MCP.md` file\n * @param repoName - Repository name used as the `publisher` field of the entry\n * @param filePath - Absolute path (used as `source` and for name fallback)\n * @returns Populated `CatalogEntry` with kind `\"mcp-server\"`\n */\nexport function fromMcpServerMdContent(\n content: string,\n repoName: string,\n filePath: string,\n): CatalogEntry {\n const { data: meta } = parseFrontmatter(content);\n\n // Extract runtime defaults into metadata\n const metadata: Record<string, unknown> = {};\n if (meta.transport) metadata.transport = String(meta.transport);\n if (meta.command) metadata.command = String(meta.command);\n if (Array.isArray(meta.args)) metadata.args = meta.args.map(String);\n if (meta.env && typeof meta.env === \"object\" && !Array.isArray(meta.env)) {\n metadata.env = meta.env as Record<string, string>;\n }\n if (meta.url) metadata.url = String(meta.url);\n if (typeof meta.ca === \"string\") metadata.ca = meta.ca;\n if (meta.headers && typeof meta.headers === \"object\" && !Array.isArray(meta.headers)) {\n metadata.headers = meta.headers as Record<string, string>;\n }\n if (meta.recipe && typeof meta.recipe === \"object\" && !Array.isArray(meta.recipe)) {\n metadata.recipe = meta.recipe;\n }\n if (meta.payload && typeof meta.payload === \"object\" && !Array.isArray(meta.payload)) {\n metadata.payload = meta.payload;\n }\n if (Array.isArray(meta.fields)) {\n metadata.fields = meta.fields;\n }\n if (typeof meta.lazy === \"boolean\") metadata.lazy = meta.lazy;\n\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"mcp-server\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n metadata: Object.keys(metadata).length > 0 ? metadata : undefined,\n };\n}\n\n/**\n * Parse a `knowledge.yaml` file into a `CatalogEntry` with `kind: \"knowledge\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `knowledge.yaml` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"knowledge\"`\n * @docLink packages/core/concepts#from-knowledge-yaml\n */\nexport async function fromKnowledgeYaml(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromKnowledgeYamlContent(await readManifestFileOrEmpty(filePath), repoName, filePath);\n}\n\n/** Pure {@link fromKnowledgeYaml} core over already-read content (no I/O). */\nfunction fromKnowledgeYamlContent(\n content: string,\n repoName: string,\n filePath: string,\n): CatalogEntry {\n let meta: Record<string, unknown> = {};\n try {\n meta = (parse(content) as Record<string, unknown>) ?? {};\n } catch {}\n return {\n name: String(meta.name ?? basename(dirname(filePath))),\n kind: \"knowledge\",\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: String(meta.version ?? \"\"),\n requires: parseRequires(meta),\n dependencies: [],\n };\n}\n\n/**\n * Parse a `CONNECTOR.md` file into a `CatalogEntry` with `kind: \"connector\"`.\n * Falls back to the parent directory name when `name:` is absent.\n *\n * Frontmatter fields (catalog identity):\n * - `name` — connector name (default: parent dir name)\n * - `description` — short description\n * - `version` — semver\n *\n * Frontmatter fields (runtime defaults, stored in `metadata`):\n * - `entry` — adapter entry point (default: \"./adapter.ts\")\n * - `npm_deps` — npm dependencies required by the adapter\n * - `fields` — configuration fields the adapter expects\n * - `health_check` — whether to run a health check on connect\n *\n * The markdown body (below the frontmatter) is stored in `metadata.body`\n * so the runner can inject the connector's skill description into the\n * system prompt when `expose_as_skill` is enabled.\n *\n * Async since #454 — the file may live on the FUSE workspace mount.\n *\n * @param filePath - Absolute path to the `CONNECTOR.md` file\n * @param repoName - Repository name used as the `repository` field of the entry\n * @returns Populated `CatalogEntry` with kind `\"connector\"`\n * @docLink packages/core/concepts#from-connector-md\n */\nexport async function fromConnectorMd(filePath: string, repoName: string): Promise<CatalogEntry> {\n return fromConnectorMdContent(await readManifestFile(filePath), repoName, filePath);\n}\n\n/** Pure {@link fromConnectorMd} core over already-read content (no I/O). */\nfunction fromConnectorMdContent(content: string, repoName: string, filePath: string): CatalogEntry {\n const { data: meta, body } = parseFrontmatter(content);\n const name = String(meta.name ?? basename(dirname(filePath)));\n return {\n name,\n kind: \"connector\" as AssetKind,\n description: String(meta.description ?? \"\"),\n source: filePath,\n publisher: repoName,\n version: extractVersion(meta),\n requires: parseRequires(meta),\n dependencies: [],\n metadata: {\n entry: meta.entry ?? \"./adapter.ts\",\n npm_deps: meta.npm_deps ?? {},\n fields: meta.fields ?? [],\n health_check: meta.health_check ?? null,\n body,\n },\n };\n}\n\n// ── Recursive walker ──────────────────────────────────────────────────────────\n\ninterface WalkEntry {\n path: string;\n name: string;\n}\n\n/** Default maximum directory nesting the walk descends into. */\nexport const DEFAULT_WALK_MAX_DEPTH = 32;\n\n/** Default maximum number of directory entries a single walk may examine. */\nexport const DEFAULT_WALK_MAX_ENTRIES = 50_000;\n\n/** Default wall-clock budget for one whole walk / scan pass, in milliseconds. */\nexport const DEFAULT_WALK_BUDGET_MS = 60_000;\n\n/** Env override for {@link DEFAULT_WALK_MAX_DEPTH}. */\nexport const WALK_MAX_DEPTH_ENV_VAR = \"SKAILE_SCAN_MAX_DEPTH\";\n\n/** Env override for {@link DEFAULT_WALK_MAX_ENTRIES}. */\nexport const WALK_MAX_ENTRIES_ENV_VAR = \"SKAILE_SCAN_MAX_ENTRIES\";\n\n/** Env override for {@link DEFAULT_WALK_BUDGET_MS}. */\nexport const WALK_BUDGET_MS_ENV_VAR = \"SKAILE_SCAN_DEADLINE_MS\";\n\n/** Read a positive-integer env override, falling back when absent or unusable. */\nfunction envInt(name: string, fallback: number): number {\n const raw = process.env[name];\n if (raw === undefined) return fallback;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\n/**\n * Why a walk stopped early. Every one of these means the returned entries are a\n * **partial** view of the tree — never present a truncated walk as complete.\n *\n * @docLink packages/core/concepts#walk-dir\n */\nexport interface WalkTruncation {\n reason: \"depth\" | \"entries\" | \"budget\" | \"cycle\" | \"unreadable\";\n /** Directory (or symlink) at which the bound was hit. */\n path: string;\n /** The bound that was hit, when the reason has a numeric limit. */\n limit?: number;\n}\n\n/**\n * Bounds for {@link walkDir} / {@link scanDirectory}.\n *\n * @docLink packages/core/concepts#walk-dir\n */\nexport interface WalkOptions {\n /** Maximum nesting depth below the root. Default {@link DEFAULT_WALK_MAX_DEPTH}. */\n maxDepth?: number;\n /** Maximum directory entries examined across the whole walk. Default {@link DEFAULT_WALK_MAX_ENTRIES}. */\n maxEntries?: number;\n /**\n * Wall-clock budget for the whole walk. Default {@link DEFAULT_WALK_BUDGET_MS}.\n * The check is inclusive, so `0` yields no entries at all.\n */\n budgetMs?: number;\n /** Per-`opendir`/`stat`/`readFile` deadline. Default {@link fsDeadlineMs}. */\n opTimeoutMs?: number;\n /**\n * Called once per distinct truncation reason. Defaults to a `warn` on the\n * core logger — override to route the signal somewhere the caller can act on.\n */\n onTruncate?: (info: WalkTruncation) => void;\n}\n\n/**\n * Options for {@link scanDirectory}: the walk bounds plus the registered kind set\n * (`new Set(registry.getAllKinds())`) that typed frontmatter is checked against.\n */\nexport interface ScanOptions extends WalkOptions {\n /** Registered asset kinds; a `SKILL.md` `type:` outside it is reported, not catalogued. */\n knownKinds: ReadonlySet<string>;\n /** Sink for scan diagnostics (`unknown_asset_kind`). Defaults to a `warn` on the core logger. */\n onDiagnostic?: (diagnostic: Diagnostic) => void;\n /**\n * Return every asset found instead of one per `kind:name`. The default keeps the\n * alphabetically later source path, which hides a second directory holding the\n * same asset; a caller that must report such duplicates (`library index`) sets this.\n */\n keepDuplicates?: boolean;\n}\n\n/** Mutable bookkeeping threaded through one walk. */\ninterface WalkState {\n maxDepth: number;\n maxEntries: number;\n opTimeoutMs: number | undefined;\n deadlineAt: number;\n examined: number;\n /**\n * `dev:ino` of the directories on the **current path from the root** — an\n * ancestor stack, not an ever-visited set. Re-entering an ancestor is a cycle;\n * re-reaching a directory off the current path is a diamond, and must be walked.\n */\n ancestors: Set<string>;\n reported: Set<WalkTruncation[\"reason\"]>;\n onTruncate: (info: WalkTruncation) => void;\n}\n\nlet walkLogger: ReturnType<typeof createLogger> | undefined;\n\n/** `root` + reason pairs already warned about in this process (see {@link warnTruncation}). */\nconst warnedTruncations = new Set<string>();\n\n/**\n * Where the default truncation warning goes. A library embedded in a program leaves it unset and\n * gets a `warn` on the core logger; the CLI sets it to print one `!` line of its own instead of a\n * raw timestamped log record in the middle of a command's output (p1622).\n */\nlet truncationSink: ((info: WalkTruncation, root: string) => void) | undefined;\n\n/** Route the default truncation warning of {@link walkDir} / {@link scanDirectory} (see above). */\nexport function setWalkTruncationSink(\n sink: ((info: WalkTruncation, root: string) => void) | undefined,\n): void {\n truncationSink = sink;\n}\n\n/**\n * Default truncation sink: a warning naming the walked directory (the library) and the bound\n * that was hit, once per directory and reason for the whole process. A command that looks at\n * several libraries (`add`, `search --local`) walks each more than once; a symlink cycle in one\n * of them must not repeat on every walk (p524). A cycle says what to do: remove the symlink.\n */\nfunction warnTruncation(info: WalkTruncation, root: string): void {\n const key = `${root}\\0${info.reason}`;\n if (warnedTruncations.has(key)) return;\n warnedTruncations.add(key);\n if (truncationSink) {\n truncationSink(info, root);\n return;\n }\n walkLogger ??= createLogger({ kind: \"runner\", subkind: \"asset-scan\" });\n if (info.reason === \"cycle\") {\n walkLogger.warn(\n `asset scan truncated (cycle) — results are incomplete: in ${root}, the symlink ${info.path} points back into the tree; remove the symlink`,\n );\n return;\n }\n walkLogger.warn(`asset scan truncated (${info.reason}) — results are incomplete: ${root}`, {\n ...info,\n });\n}\n\n/** Default diagnostic sink for {@link scanDirectory}. */\nfunction warnDiagnostic(d: Diagnostic): void {\n walkLogger ??= createLogger({ kind: \"runner\", subkind: \"asset-scan\" });\n walkLogger.warn(d.message, { code: d.code, path: d.path });\n}\n\n/** Record a truncation once per reason so a wide tree does not spam the log. */\nfunction truncate(state: WalkState, info: WalkTruncation): void {\n if (state.reported.has(info.reason)) return;\n state.reported.add(info.reason);\n state.onTruncate(info);\n}\n\n/**\n * Stable identity (`dev:ino`) of the directory `path` resolves to, or `null`\n * when it cannot be stat'ed within the deadline. Used to terminate symlink\n * cycles — the pre-#454 walker recursed forever on `a/link -> a`.\n */\nasync function dirIdentity(path: string, timeoutMs: number | undefined): Promise<string | null> {\n const st = await tryWithFsDeadline(`stat ${path}`, () => stat(path), null, timeoutMs);\n return st ? `${st.dev}:${st.ino}` : null;\n}\n\n/**\n * Read one directory's entries under a deadline, capped at the walk's remaining\n * entry budget. Uses `opendir` rather than `readdir` so a pathological directory\n * streams instead of materialising in full; entries are collected and sorted\n * because the `scanDirectory` dedup rule (\"alphabetically later source wins\")\n * depends on a deterministic per-level order.\n */\nasync function readDirEntries(\n dir: string,\n state: WalkState,\n): Promise<{ entries: Dirent[]; capped: boolean } | null> {\n const remaining = state.maxEntries - state.examined;\n if (remaining <= 0) return { entries: [], capped: true };\n try {\n return await withFsDeadline(\n `opendir ${dir}`,\n async () => {\n const handle = await opendir(dir);\n const entries: Dirent[] = [];\n let capped = false;\n for await (const e of handle) {\n // Stop *before* keeping the over-budget entry, so `capped` means \"an\n // entry was actually dropped\". Breaking after the push instead marked\n // a directory of exactly `remaining` entries as truncated — and since\n // `truncate()` reports once per reason for the whole walk, that\n // spurious first report swallowed a later genuine one.\n if (entries.length >= remaining) {\n capped = true;\n break;\n }\n entries.push(e);\n }\n entries.sort((a, b) => (a.name < b.name ? -1 : 1));\n return { entries, capped };\n },\n state.opTimeoutMs,\n );\n } catch {\n // Unreadable (permissions, vanished mid-walk) or the mount missed its\n // deadline. Either way this subtree contributes nothing; keep walking.\n truncate(state, { reason: \"unreadable\", path: dir });\n return null;\n }\n}\n\n/**\n * Recursively yield every file entry under `dir`, sorted alphabetically at each\n * level. Skips `.git` and `node_modules` directories and follows symlinks\n * (resolving to the stat target). `node_modules` is excluded because Bun's\n * `node_modules/.bun/...` layout contains symlink farms that form cycles when\n * packages reference each other transitively.\n *\n * **Async and bounded since #454.** A repo root can resolve onto the rclone FUSE\n * mount, where the previous synchronous `readdirSync`/`statSync` walk parked the\n * whole event loop. Four bounds now hold, and hitting any of them reports a\n * {@link WalkTruncation} — a truncated walk is never presented as a complete one:\n *\n * - **depth** ({@link WalkOptions.maxDepth}) — also the backstop for a cycle no\n * inode check can see, e.g. a bind mount of the root inside itself.\n * - **entry count** ({@link WalkOptions.maxEntries}) — total directory entries\n * examined, so an enormous tree cannot run unbounded.\n * - **wall-clock budget** ({@link WalkOptions.budgetMs}) — a wedged mount that\n * times out one operation at a time cannot add up to an unbounded scan.\n * - **ancestor inodes** — the `dev:ino` of every directory on the path from the\n * root is held while its subtree is walked, so `a/link -> a` terminates\n * instead of recursing forever. Two sibling symlinks onto one shared\n * directory are a diamond, not a cycle: both are walked, at the price of\n * visiting the shared subtree twice — bounded by the entry and time budgets.\n *\n * @param dir - Absolute path to the directory to walk\n * @param options - Bounds and truncation sink; see {@link WalkOptions}\n * @docLink packages/core/concepts#walk-dir\n */\nexport async function* walkDir(dir: string, options: WalkOptions = {}): AsyncGenerator<WalkEntry> {\n const state: WalkState = {\n maxDepth: options.maxDepth ?? envInt(WALK_MAX_DEPTH_ENV_VAR, DEFAULT_WALK_MAX_DEPTH),\n maxEntries: options.maxEntries ?? envInt(WALK_MAX_ENTRIES_ENV_VAR, DEFAULT_WALK_MAX_ENTRIES),\n opTimeoutMs: options.opTimeoutMs,\n deadlineAt:\n Date.now() + (options.budgetMs ?? envInt(WALK_BUDGET_MS_ENV_VAR, DEFAULT_WALK_BUDGET_MS)),\n examined: 0,\n ancestors: new Set<string>(),\n reported: new Set<WalkTruncation[\"reason\"]>(),\n onTruncate: options.onTruncate ?? ((info) => warnTruncation(info, dir)),\n };\n // The root is an ancestor of everything, so it is seeded here and never\n // popped — a self-referential `root/link -> root` is caught on first descent.\n const rootId = await dirIdentity(dir, state.opTimeoutMs);\n if (rootId) state.ancestors.add(rootId);\n yield* walkFrom(dir, 0, state);\n}\n\nasync function* walkFrom(dir: string, depth: number, state: WalkState): AsyncGenerator<WalkEntry> {\n if (depth > state.maxDepth) {\n truncate(state, { reason: \"depth\", path: dir, limit: state.maxDepth });\n return;\n }\n if (Date.now() >= state.deadlineAt) {\n truncate(state, { reason: \"budget\", path: dir });\n return;\n }\n\n const read = await readDirEntries(dir, state);\n if (!read) return;\n if (read.capped) truncate(state, { reason: \"entries\", path: dir, limit: state.maxEntries });\n\n for (const e of read.entries) {\n if (state.examined >= state.maxEntries) {\n truncate(state, { reason: \"entries\", path: dir, limit: state.maxEntries });\n return;\n }\n if (Date.now() >= state.deadlineAt) {\n truncate(state, { reason: \"budget\", path: dir });\n return;\n }\n state.examined++;\n const full = join(dir, e.name);\n\n if (e.isSymbolicLink()) {\n // A symlink is the only way a cycle can enter this walk, so identity is\n // resolved here and nowhere else — one extra stat per link, none per\n // ordinary directory.\n const st = await tryWithFsDeadline(`stat ${full}`, () => stat(full), null, state.opTimeoutMs);\n if (!st) continue;\n if (st.isDirectory()) {\n if (e.name === \".git\" || e.name === \"node_modules\") continue;\n const id = `${st.dev}:${st.ino}`;\n // Only an *ancestor* is a cycle. A target already walked elsewhere in\n // the tree is a diamond (`a/link -> shared`, `b/link -> shared`) and\n // dropping it would silently lose that subtree from the scan.\n if (state.ancestors.has(id)) {\n truncate(state, { reason: \"cycle\", path: full });\n continue;\n }\n state.ancestors.add(id);\n try {\n yield* walkFrom(full, depth + 1, state);\n } finally {\n // finally, not a trailing delete: an early `return` from the bounds\n // checks — or an abandoned consumer — would otherwise leave the\n // ancestor stack holding a directory the walk has already left.\n state.ancestors.delete(id);\n }\n } else {\n yield { path: full, name: e.name };\n }\n } else if (e.isDirectory()) {\n if (e.name !== \".git\" && e.name !== \"node_modules\") yield* walkFrom(full, depth + 1, state);\n } else if (e.isFile()) {\n yield { path: full, name: e.name };\n }\n }\n}\n\n// ── Public scanner ────────────────────────────────────────────────────────────\n\n/**\n * Coerce a scanned entry's `name` to a canonical asset name in place. When the\n * raw name is already canonical this is a no-op; otherwise the original is stashed\n * on `metadata.displayName` (only when not already set) so callers keep the pretty\n * label for display while identity uses the slug. A name that slugifies to empty\n * is left untouched — `parseAssetRef` will reject it downstream with its full hint.\n */\nfunction normalizeEntryName(e: CatalogEntry): void {\n if (isValidAssetName(e.name)) return;\n let slug: string;\n try {\n slug = slugifyAssetName(e.name);\n } catch {\n return;\n }\n const original = e.name;\n e.name = slug;\n if (e.metadata?.displayName === undefined) {\n e.metadata = { ...e.metadata, displayName: original };\n }\n}\n\n/**\n * Build a `CatalogEntry` from an already-read manifest, dispatching on filename.\n * Returns `null` when the filename is not a recognized manifest.\n */\nfunction entryFromManifest(\n name: string,\n content: string,\n filePath: string,\n repoName: string,\n knownKinds: ReadonlySet<string>,\n): CatalogEntry | null {\n if (name === \"SKILL.md\") return fromSkillMdContent(content, repoName, filePath, knownKinds);\n if (name === \"AGENT.md\") return fromAgentMdContent(content, repoName, filePath);\n if (name === \"agent.yaml\") return fromAgentYamlContent(content, repoName, filePath);\n if (name === \"CONTRACT.md\") return fromContractMdContent(content, repoName, filePath);\n if (name === \"PERSONA.md\") return fromComposableMdContent(\"persona\", content, repoName, filePath);\n if (name === \"RULESET.md\") return fromComposableMdContent(\"ruleset\", content, repoName, filePath);\n if (name === \"MCP.md\") return fromMcpServerMdContent(content, repoName, filePath);\n if (name === \"CONNECTOR.md\") return fromConnectorMdContent(content, repoName, filePath);\n if (name === \"knowledge.yaml\") return fromKnowledgeYamlContent(content, repoName, filePath);\n if (name.endsWith(\".prompt.md\")) return fromPromptMdContent(content, repoName, filePath);\n if (name.endsWith(\".preset.yaml\")) return fromPresetYamlContent(content, repoName, filePath);\n if (name.endsWith(\".flow.yaml\") || name.endsWith(\".flow.json\"))\n return fromFlowYamlContent(content, repoName, filePath);\n return null;\n}\n\n/** Filenames {@link scanDirectory} recognises as asset manifests. */\nexport function isManifestName(name: string): boolean {\n return (\n name === \"SKILL.md\" ||\n name === \"AGENT.md\" ||\n name === \"agent.yaml\" ||\n name === \"CONTRACT.md\" ||\n name === \"PERSONA.md\" ||\n name === \"RULESET.md\" ||\n name === \"MCP.md\" ||\n name === \"CONNECTOR.md\" ||\n name === \"knowledge.yaml\" ||\n name.endsWith(\".prompt.md\") ||\n name.endsWith(\".preset.yaml\") ||\n name.endsWith(\".flow.yaml\") ||\n name.endsWith(\".flow.json\")\n );\n}\n\n/** Per-asset values a `skaile.manifest.yaml` `assets[]` entry overrides on the scanned entry. */\ninterface ManifestAssetOverride {\n publisher?: string;\n version?: string;\n dependencies: string[];\n}\n\n/**\n * Per-asset overrides declared in `<root>/skaile.manifest.yaml` `assets[]` (`publisher`,\n * `dependencies`), keyed `kind:name`. Empty when the manifest is absent, unreadable within\n * the deadline, or not valid YAML — a scan never fails on it.\n */\nasync function readManifestAssetOverrides(\n root: string,\n opTimeoutMs: number,\n): Promise<Record<string, ManifestAssetOverride>> {\n const out: Record<string, ManifestAssetOverride> = {};\n const file = join(root, \"skaile.manifest.yaml\");\n const content = await tryWithFsDeadline(\n `readFile ${file}`,\n () => readFile(file, \"utf8\"),\n null,\n opTimeoutMs,\n );\n if (content === null) return out;\n let doc: unknown;\n try {\n doc = parse(content);\n } catch {\n return out;\n }\n const assets = (doc as { assets?: unknown } | null)?.assets;\n if (!Array.isArray(assets)) return out;\n for (const a of assets) {\n const { kind, name, publisher, dependencies, version } = (a ?? {}) as Record<string, unknown>;\n if (typeof kind !== \"string\" || typeof name !== \"string\") continue;\n const override: ManifestAssetOverride = {\n dependencies: Array.isArray(dependencies)\n ? dependencies.filter((d): d is string => typeof d === \"string\" && d.trim().length > 0)\n : [],\n };\n const bare = typeof publisher === \"string\" ? publisher.trim().replace(/^@/, \"\") : \"\";\n if (bare) override.publisher = bare;\n if (typeof version === \"string\" && version.trim() !== \"\") override.version = version.trim();\n if (override.publisher || override.version || override.dependencies.length > 0)\n out[`${kind}:${name}`] = override;\n }\n return out;\n}\n\n/**\n * Fold a manifest entry's `dependencies` into `entry.requires`: the manifest field is the\n * author-declared requirement list of the entry (same meaning as `requires`), so every\n * consumer of the scanned entry (`add`, `install`, `info`, `check`, `doctor`) sees it.\n * A requirement the file already declares is not repeated, by {@link requirementKey}\n * identity: the file's bare `report-table` and the manifest's `skill:@pub/report-table`\n * are one requirement when `pub` is the entry's own publisher.\n */\nfunction mergeManifestDependencies(entry: CatalogEntry, dependencies: readonly string[]): void {\n entry.requires = dedupeRequirements(\n [...entry.requires, ...dependencies.map((raw) => parseDep(raw))],\n entry.publisher,\n );\n}\n\n/**\n * Walk `root` recursively and return a `CatalogEntry` for every recognized asset manifest found.\n *\n * Recognized filenames: `SKILL.md`, `AGENT.md`, `agent.yaml`, `CONTRACT.md`, `MCP.md`,\n * `CONNECTOR.md`, `knowledge.yaml`, `*.prompt.md`, `*.preset.yaml`, `*.flow.yaml`, `*.flow.json`.\n *\n * When two entries share the same `kind:name` key, the one with the alphabetically\n * later source path wins (consistent with catalog precedence rules), unless\n * {@link ScanOptions.keepDuplicates} asks for every copy.\n *\n * **Async and bounded since #454.** `root` can resolve onto the rclone FUSE mount\n * (a `sources[].path` under `/skaile/workspace`), and the walk follows symlinks, so\n * even an off-mount root can descend into one. Every `opendir`/`stat`/`readFile`\n * is deadline-bounded and the walk is capped by depth, entry count, a wall-clock\n * budget, and an ancestor-inode set — see {@link walkDir}. Hitting any bound reports\n * a {@link WalkTruncation} through {@link WalkOptions.onTruncate} (a `warn` by\n * default); the returned array is then a **partial** scan, never a complete one.\n *\n * A manifest that cannot be read within its deadline is skipped rather than\n * failing the whole scan — one unreachable file must not cost the whole catalog.\n *\n * **Per-asset publisher.** When `root` holds a `skaile.manifest.yaml` whose `assets[]`\n * entry names a `publisher` for a scanned `kind`/`name`, that publisher replaces\n * `repoName` on the produced entry — the same identity the library index and\n * `library create --publisher` write, so `kind:@<publisher>/<name>` resolves.\n *\n * **Per-asset dependencies.** The same entry's `dependencies` (`kind:@<publisher>/name[#pin]`)\n * are appended to the produced entry's `requires`, next to the file's own `requires`.\n *\n * @param root - Absolute path to the directory tree to scan\n * @param repoName - Publisher attached to every produced entry without a per-asset override\n * @param options - Walk bounds and truncation sink; see {@link WalkOptions}\n * @returns Array of deduplicated `CatalogEntry` objects, one per manifest file\n * @docLink packages/core/concepts#scan-directory\n */\nexport async function scanDirectory(\n root: string,\n repoName: string,\n options: ScanOptions,\n): Promise<CatalogEntry[]> {\n const entries = new Map<string, CatalogEntry>();\n const copies: CatalogEntry[] = [];\n const onTruncate = options.onTruncate ?? ((info: WalkTruncation) => warnTruncation(info, root));\n const reported = new Set<WalkTruncation[\"reason\"]>();\n const relay = (info: WalkTruncation) => {\n reported.add(info.reason);\n onTruncate(info);\n };\n const opTimeoutMs = options.opTimeoutMs ?? fsDeadlineMs();\n const manifestOverrides = await readManifestAssetOverrides(root, opTimeoutMs);\n\n function add(e: CatalogEntry): void {\n // Boundary normalization: a third-party source we don't control may name an\n // asset with a human-styled identity (\"Complex App\"). Slugify it to a\n // canonical name so the ref it produces parses, preserving the original on\n // `metadata.displayName` for display. No-op for already-canonical names.\n normalizeEntryName(e);\n const key = `${e.kind}:${e.name}`;\n const override = manifestOverrides[key];\n if (override?.publisher) e.publisher = override.publisher;\n // A file that declares no version (AGENT.md, agent.yaml) has the manifest entry's, so every\n // library holding it agrees on the version.\n if (!e.version && override?.version) e.version = override.version;\n if (override) mergeManifestDependencies(e, override.dependencies);\n if (options.keepDuplicates) {\n copies.push(e);\n return;\n }\n const existing = entries.get(key);\n if (!existing) {\n entries.set(key, e);\n return;\n }\n // Among duplicates, alphabetically later source path wins\n if (e.source > existing.source) entries.set(key, e);\n }\n\n for await (const { path: filePath, name } of walkDir(root, {\n ...options,\n opTimeoutMs,\n onTruncate: relay,\n })) {\n if (!isManifestName(name)) continue;\n const content = await tryWithFsDeadline(\n `readFile ${filePath}`,\n () => readFile(filePath, \"utf8\"),\n null,\n opTimeoutMs,\n );\n if (content === null) {\n // Unreadable or past its deadline — the catalog loses this asset, not the\n // whole scan. Reported once so a wedged mount is visible in the logs.\n if (!reported.has(\"unreadable\")) relay({ reason: \"unreadable\", path: filePath });\n continue;\n }\n try {\n const entry = entryFromManifest(name, content, filePath, repoName, options.knownKinds);\n if (entry) add(entry);\n } catch (err) {\n if (err instanceof ManifestKindError) {\n (options.onDiagnostic ?? warnDiagnostic)(manifestKindDiagnostic(err));\n }\n }\n }\n\n return options.keepDuplicates ? copies : [...entries.values()];\n}\n\n/**\n * The prompt text of a manifest file, as the scaffold-body check wants it: the\n * markdown body of a `.md` marker (`SKILL.md`, `AGENT.md`, …), the `SOUL.md` next to\n * an `agent.yaml` agent, `undefined` for every other YAML manifest.\n *\n * @param file Absolute path of the manifest file.\n * @param text The file's content.\n */\nexport function readAssetBody(file: string, text: string): string | undefined {\n if (file.endsWith(\".md\")) return parseFrontmatter(text).body;\n if (basename(file) !== \"agent.yaml\") return undefined;\n const soul = join(dirname(file), \"SOUL.md\");\n return existsSync(soul) ? readFileSync(soul, \"utf8\").trim() : undefined;\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { findAiAssetsRoot } from './chunk-KYNCY3F3.js';
1
+ import { findAiAssetsRoot } from './chunk-HQAPUPBE.js';
2
2
  import { okJson, err, ok } from './chunk-3MWQKQUB.js';
3
- import { parseSkillRequirements, validateRequirements, buildRequiresPreamble, parseSkillFrontmatter } from './chunk-W5KCAWGN.js';
3
+ import { parseSkillRequirements, validateRequirements, buildRequiresPreamble, parseSkillFrontmatter } from './chunk-PTJTOPE5.js';
4
4
  import { findKindDirs } from './chunk-MWXYN6NY.js';
5
5
  import fs from 'fs/promises';
6
6
  import path from 'path';
@@ -136,5 +136,5 @@ async function skillGetPreamble(projectDir, skillId) {
136
136
  }
137
137
 
138
138
  export { skillCheckRequirements, skillGetPreamble, skillList, skillSearch, skillShow };
139
- //# sourceMappingURL=chunk-6Y3SC7O4.js.map
140
- //# sourceMappingURL=chunk-6Y3SC7O4.js.map
139
+ //# sourceMappingURL=chunk-GTAHU4N4.js.map
140
+ //# sourceMappingURL=chunk-GTAHU4N4.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../workspace-plugin/src/tools/skills.ts"],"names":[],"mappings":";;;;;;;AA0BA,eAAe,cAAA,CAAe,KAAa,GAAA,EAAkC;AAC3E,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,MAAM,EAAA,CAAG,OAAA,CAAQ,KAAK,EAAE,aAAA,EAAe,MAAM,CAAA;AAAA,EACzD,CAAA,CAAA,MAAQ;AACN,IAAA;AAAA,EACF;AAGA,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,MAAA,EAAO,IAAK,CAAA,CAAE,IAAA,KAAS,UAAU,C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,SAAS,CAAA;AAC1E,IAAA,OAAO,OAAO,MAAM,CAAA;AAAA,EACtB,SAAS,CAAA,EAAY;AACnB,IAAA,OAAO,IAAI,CAAA,YAAa,KAAA,GAAQ,EAAE,OAAA,GAAU,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,EACvD;AACF;AAcA,eAAsB,gBAAA,CAAiB,YAAoB,OAAA,EAAsC;AAC/F,EAAA,IAAI;AACF,IAAA,MAAM,YAAA,GAAe,MAAM,gBAAA,CAAiB,UAAU,CAAA;AACtD,IAAA,IAAI,CAAC,YAAA,EAAc,OAAO,GAAA,CAAI,CAAA,iBAAA,EAAoB,OAAO,CAAA,CAAE,CAAA;AAC3D,IAAA,MAAM,MAAA,GAAS,MAAM,UAAA,CAAW,YAAY,CAAA;AAC5C,IAAA,MAAM,QAAQ,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,OAAO,CAAA;AACjD,IAAA,IAAI,CAAC,KAAA,EAAO,OAAO,GAAA,CAAI,CAAA,iBAAA,EAAoB,OAAO,CAAA,CAAE,CAAA;AACpD,IAAA,MAAM,UAAU,MAAM,EAAA,CAAG,QAAA,CAAS,KAAA,CAAM,MAAM,OAAO,CAAA;AAErD,IAAA,MAAM,YAAA,GAAe,uBAAuB,OAAO,CAAA;AACnD,IAAA,MAAM,QAAA,GAAW,qBAAA,CAAsB,YAAA,EAAc,OAAO,CAAA;AAC5D,IAAA,OAAO,EAAA,CAAG,YAAY,4BAA4B,CAAA;AAAA,EACpD,SAAS,CAAA,EAAY;AACnB,IAAA,OAAO,IAAI,CAAA,YAAa,KAAA,GAAQ,EAAE,OAAA,GAAU,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,EACvD;AACF","file":"chunk-6Y3SC7O4.js","sourcesContent":["// src/tools/skills.ts\n\nimport type { Dirent } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { findKindDirs } from \"@skaile/workspaces/core/discovery\";\nimport {\n buildRequiresPreamble,\n parseSkillFrontmatter,\n parseSkillRequirements,\n validateRequirements,\n} from \"@skaile/workspaces/resolver\";\nimport type { ToolResult } from \"../types.js\";\nimport { err, ok, okJson } from \"../types.js\";\nimport { findAiAssetsRoot } from \"../utils/ai-assets.js\";\n\ninterface SkillEntry {\n id: string;\n name: string;\n description: string;\n source?: string;\n version?: string;\n keywords?: string[];\n path: string;\n}\n\nasync function walkForSkillMd(dir: string, acc: SkillEntry[]): Promise<void> {\n let entries: Dirent<string>[];\n try {\n entries = await fs.readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n // Check if this directory contains a SKILL.md\n const hasSkillMd = entries.some((e) => e.isFile() && e.name === \"SKILL.md\");\n if (hasSkillMd) {\n const skillMdPath = path.join(dir, \"SKILL.md\");\n try {\n const content = await fs.readFile(skillMdPath, \"utf-8\");\n const fm = parseSkillFrontmatter(content);\n const name = typeof fm.name === \"string\" ? fm.name : path.basename(dir);\n const description = typeof fm.description === \"string\" ? fm.description : \"\";\n const source = typeof fm.source === \"string\" ? fm.source : undefined;\n const version = typeof fm.version === \"string\" ? fm.version : undefined;\n const keywords = Array.isArray(fm.keywords) ? (fm.keywords as string[]) : undefined;\n acc.push({\n id: path.basename(dir),\n name,\n description,\n source,\n version,\n keywords,\n path: skillMdPath,\n });\n } catch {\n // skip unreadable files\n }\n return; // don't recurse inside a skill directory\n }\n\n // Recurse into subdirectories\n for (const entry of entries) {\n if (entry.isDirectory()) {\n await walkForSkillMd(path.join(dir, entry.name), acc);\n }\n }\n}\n\nasync function scanSkills(aiAssetsRoot: string): Promise<SkillEntry[]> {\n const acc: SkillEntry[] = [];\n for (const skillsDir of findKindDirs(aiAssetsRoot, \"skills\")) {\n await walkForSkillMd(skillsDir, acc);\n }\n // A `skills/` dir nested inside another is walked twice; keep each SKILL.md once.\n return [...new Map(acc.map((s) => [s.path, s])).values()];\n}\n\n// ── Exported tool functions ────────────────────────────────────────────────────\n\n/**\n * List all skills in the `ai-assets` catalog.\n *\n * Walks every `skills/` directory at any depth under the `ai-assets` root\n * looking for `SKILL.md` files. Returns a JSON array of skill summaries\n * `{ id, name, description, source, version, keywords }`.\n *\n * @param projectDir - Absolute path to the skaile project root.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillList(projectDir: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return okJson([]);\n const skills = await scanSkills(aiAssetsRoot);\n return okJson(\n skills.map((s) => ({\n id: s.id,\n name: s.name,\n description: s.description,\n source: s.source,\n version: s.version,\n keywords: s.keywords,\n })),\n );\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Show the full `SKILL.md` content for a skill.\n *\n * @param projectDir - Absolute path to the skaile project root.\n * @param skillId - Skill ID (directory name) as returned by {@link skillList}.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillShow(projectDir: string, skillId: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return err(`Skill not found: ${skillId}`);\n const skills = await scanSkills(aiAssetsRoot);\n const skill = skills.find((s) => s.id === skillId);\n if (!skill) return err(`Skill not found: ${skillId}`);\n const content = await fs.readFile(skill.path, \"utf-8\");\n return ok(content);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Search skills by name, description, ID, or keywords.\n *\n * Case-insensitive substring match against all text fields in every skill\n * entry. Returns the same summary shape as {@link skillList}.\n *\n * @param projectDir - Absolute path to the skaile project root.\n * @param query - Search string.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillSearch(projectDir: string, query: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return okJson([]);\n const skills = await scanSkills(aiAssetsRoot);\n const q = query.toLowerCase();\n const matched = skills.filter(\n (s) =>\n s.name.toLowerCase().includes(q) ||\n s.description.toLowerCase().includes(q) ||\n s.id.toLowerCase().includes(q) ||\n (s.keywords ?? []).some((k) => k.toLowerCase().includes(q)),\n );\n return okJson(\n matched.map((s) => ({\n id: s.id,\n name: s.name,\n description: s.description,\n source: s.source,\n version: s.version,\n keywords: s.keywords,\n })),\n );\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Validate that all prerequisites declared in a skill's `SKILL.md` are\n * satisfied in `targetDir`.\n *\n * Uses `@skaile/workspaces/resolver` to parse the `REQUIRES` / `READS` / `WRITES`\n * DSL and run the requirement checks against the filesystem. Returns a\n * validation report as JSON.\n *\n * @param projectDir - Absolute path to the skaile project root (for skill lookup).\n * @param skillId - Skill ID as returned by {@link skillList}.\n * @param targetDir - Directory to validate against (typically the user's project).\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillCheckRequirements(\n projectDir: string,\n skillId: string,\n targetDir: string,\n): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return err(`Skill not found: ${skillId}`);\n const skills = await scanSkills(aiAssetsRoot);\n const skill = skills.find((s) => s.id === skillId);\n if (!skill) return err(`Skill not found: ${skillId}`);\n const content = await fs.readFile(skill.path, \"utf-8\");\n\n const requirements = parseSkillRequirements(content);\n const report = await validateRequirements(skillId, requirements, targetDir);\n return okJson(report);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Get the formatted `REQUIRES`/`INPUT`/`READS`/`WRITES` DSL preamble for a skill.\n *\n * Uses `@skaile/workspaces/resolver` to build the requirements preamble that can be\n * prepended to the skill prompt for injection into the agent's context.\n * Returns `\"(no requirements declared)\"` when the skill has no requirements.\n *\n * @param projectDir - Absolute path to the skaile project root.\n * @param skillId - Skill ID as returned by {@link skillList}.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillGetPreamble(projectDir: string, skillId: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return err(`Skill not found: ${skillId}`);\n const skills = await scanSkills(aiAssetsRoot);\n const skill = skills.find((s) => s.id === skillId);\n if (!skill) return err(`Skill not found: ${skillId}`);\n const content = await fs.readFile(skill.path, \"utf-8\");\n\n const requirements = parseSkillRequirements(content);\n const preamble = buildRequiresPreamble(requirements, skillId);\n return ok(preamble || \"(no requirements declared)\");\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n"]}
1
+ {"version":3,"sources":["../workspace-plugin/src/tools/skills.ts"],"names":[],"mappings":";;;;;;;AA0BA,eAAe,cAAA,CAAe,KAAa,GAAA,EAAkC;AAC3E,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,MAAM,EAAA,CAAG,OAAA,CAAQ,KAAK,EAAE,aAAA,EAAe,MAAM,CAAA;AAAA,EACzD,CAAA,CAAA,MAAQ;AACN,IAAA;AAAA,EACF;AAGA,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,MAAA,EAAO,IAAK,CAAA,CAAE,IAAA,KAAS,UAAU,CAAA;AAC1E,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,IAAA,CAAK,GAAA,EAAK,UAAU,CAAA;AAC7C,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,MAAM,EAAA,CAAG,QAAA,CAAS,aAAa,OAAO,CAAA;AACtD,MAAA,MAAM,EAAA,GAAK,sBAAsB,OAAO,CAAA;AACxC,MAAA,MAAM,IAAA,GAAO,OAAO,EAAA,CAAG,IAAA,KAAS,WAAW,EAAA,CAAG,IAAA,GAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA;AACtE,MAAA,MAAM,cAAc,OAAO,EAAA,CAAG,WA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AAA,MAAM,MAAA,GAAS,MAAM,UAAA,CAAW,YAAY,CAAA;AAC5C,IAAA,MAAM,QAAQ,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,OAAO,CAAA;AACjD,IAAA,IAAI,CAAC,KAAA,EAAO,OAAO,GAAA,CAAI,CAAA,iBAAA,EAAoB,OAAO,CAAA,CAAE,CAAA;AACpD,IAAA,MAAM,UAAU,MAAM,EAAA,CAAG,QAAA,CAAS,KAAA,CAAM,MAAM,OAAO,CAAA;AAErD,IAAA,MAAM,YAAA,GAAe,uBAAuB,OAAO,CAAA;AACnD,IAAA,MAAM,QAAA,GAAW,qBAAA,CAAsB,YAAA,EAAc,OAAO,CAAA;AAC5D,IAAA,OAAO,EAAA,CAAG,YAAY,4BAA4B,CAAA;AAAA,EACpD,SAAS,CAAA,EAAY;AACnB,IAAA,OAAO,IAAI,CAAA,YAAa,KAAA,GAAQ,EAAE,OAAA,GAAU,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,EACvD;AACF","file":"chunk-GTAHU4N4.js","sourcesContent":["// src/tools/skills.ts\n\nimport type { Dirent } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { findKindDirs } from \"@skaile/workspaces/core/discovery\";\nimport {\n buildRequiresPreamble,\n parseSkillFrontmatter,\n parseSkillRequirements,\n validateRequirements,\n} from \"@skaile/workspaces/resolver\";\nimport type { ToolResult } from \"../types.js\";\nimport { err, ok, okJson } from \"../types.js\";\nimport { findAiAssetsRoot } from \"../utils/ai-assets.js\";\n\ninterface SkillEntry {\n id: string;\n name: string;\n description: string;\n source?: string;\n version?: string;\n keywords?: string[];\n path: string;\n}\n\nasync function walkForSkillMd(dir: string, acc: SkillEntry[]): Promise<void> {\n let entries: Dirent<string>[];\n try {\n entries = await fs.readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n // Check if this directory contains a SKILL.md\n const hasSkillMd = entries.some((e) => e.isFile() && e.name === \"SKILL.md\");\n if (hasSkillMd) {\n const skillMdPath = path.join(dir, \"SKILL.md\");\n try {\n const content = await fs.readFile(skillMdPath, \"utf-8\");\n const fm = parseSkillFrontmatter(content);\n const name = typeof fm.name === \"string\" ? fm.name : path.basename(dir);\n const description = typeof fm.description === \"string\" ? fm.description : \"\";\n const source = typeof fm.source === \"string\" ? fm.source : undefined;\n const version = typeof fm.version === \"string\" ? fm.version : undefined;\n const keywords = Array.isArray(fm.keywords) ? (fm.keywords as string[]) : undefined;\n acc.push({\n id: path.basename(dir),\n name,\n description,\n source,\n version,\n keywords,\n path: skillMdPath,\n });\n } catch {\n // skip unreadable files\n }\n return; // don't recurse inside a skill directory\n }\n\n // Recurse into subdirectories\n for (const entry of entries) {\n if (entry.isDirectory()) {\n await walkForSkillMd(path.join(dir, entry.name), acc);\n }\n }\n}\n\nasync function scanSkills(aiAssetsRoot: string): Promise<SkillEntry[]> {\n const acc: SkillEntry[] = [];\n for (const skillsDir of findKindDirs(aiAssetsRoot, \"skills\")) {\n await walkForSkillMd(skillsDir, acc);\n }\n // A `skills/` dir nested inside another is walked twice; keep each SKILL.md once.\n return [...new Map(acc.map((s) => [s.path, s])).values()];\n}\n\n// ── Exported tool functions ────────────────────────────────────────────────────\n\n/**\n * List all skills in the `ai-assets` catalog.\n *\n * Walks every `skills/` directory at any depth under the `ai-assets` root\n * looking for `SKILL.md` files. Returns a JSON array of skill summaries\n * `{ id, name, description, source, version, keywords }`.\n *\n * @param projectDir - Absolute path to the skaile project root.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillList(projectDir: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return okJson([]);\n const skills = await scanSkills(aiAssetsRoot);\n return okJson(\n skills.map((s) => ({\n id: s.id,\n name: s.name,\n description: s.description,\n source: s.source,\n version: s.version,\n keywords: s.keywords,\n })),\n );\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Show the full `SKILL.md` content for a skill.\n *\n * @param projectDir - Absolute path to the skaile project root.\n * @param skillId - Skill ID (directory name) as returned by {@link skillList}.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillShow(projectDir: string, skillId: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return err(`Skill not found: ${skillId}`);\n const skills = await scanSkills(aiAssetsRoot);\n const skill = skills.find((s) => s.id === skillId);\n if (!skill) return err(`Skill not found: ${skillId}`);\n const content = await fs.readFile(skill.path, \"utf-8\");\n return ok(content);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Search skills by name, description, ID, or keywords.\n *\n * Case-insensitive substring match against all text fields in every skill\n * entry. Returns the same summary shape as {@link skillList}.\n *\n * @param projectDir - Absolute path to the skaile project root.\n * @param query - Search string.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillSearch(projectDir: string, query: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return okJson([]);\n const skills = await scanSkills(aiAssetsRoot);\n const q = query.toLowerCase();\n const matched = skills.filter(\n (s) =>\n s.name.toLowerCase().includes(q) ||\n s.description.toLowerCase().includes(q) ||\n s.id.toLowerCase().includes(q) ||\n (s.keywords ?? []).some((k) => k.toLowerCase().includes(q)),\n );\n return okJson(\n matched.map((s) => ({\n id: s.id,\n name: s.name,\n description: s.description,\n source: s.source,\n version: s.version,\n keywords: s.keywords,\n })),\n );\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Validate that all prerequisites declared in a skill's `SKILL.md` are\n * satisfied in `targetDir`.\n *\n * Uses `@skaile/workspaces/resolver` to parse the `REQUIRES` / `READS` / `WRITES`\n * DSL and run the requirement checks against the filesystem. Returns a\n * validation report as JSON.\n *\n * @param projectDir - Absolute path to the skaile project root (for skill lookup).\n * @param skillId - Skill ID as returned by {@link skillList}.\n * @param targetDir - Directory to validate against (typically the user's project).\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillCheckRequirements(\n projectDir: string,\n skillId: string,\n targetDir: string,\n): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return err(`Skill not found: ${skillId}`);\n const skills = await scanSkills(aiAssetsRoot);\n const skill = skills.find((s) => s.id === skillId);\n if (!skill) return err(`Skill not found: ${skillId}`);\n const content = await fs.readFile(skill.path, \"utf-8\");\n\n const requirements = parseSkillRequirements(content);\n const report = await validateRequirements(skillId, requirements, targetDir);\n return okJson(report);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Get the formatted `REQUIRES`/`INPUT`/`READS`/`WRITES` DSL preamble for a skill.\n *\n * Uses `@skaile/workspaces/resolver` to build the requirements preamble that can be\n * prepended to the skill prompt for injection into the agent's context.\n * Returns `\"(no requirements declared)\"` when the skill has no requirements.\n *\n * @param projectDir - Absolute path to the skaile project root.\n * @param skillId - Skill ID as returned by {@link skillList}.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function skillGetPreamble(projectDir: string, skillId: string): Promise<ToolResult> {\n try {\n const aiAssetsRoot = await findAiAssetsRoot(projectDir);\n if (!aiAssetsRoot) return err(`Skill not found: ${skillId}`);\n const skills = await scanSkills(aiAssetsRoot);\n const skill = skills.find((s) => s.id === skillId);\n if (!skill) return err(`Skill not found: ${skillId}`);\n const content = await fs.readFile(skill.path, \"utf-8\");\n\n const requirements = parseSkillRequirements(content);\n const preamble = buildRequiresPreamble(requirements, skillId);\n return ok(preamble || \"(no requirements declared)\");\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n"]}