@skaile/workspaces 6.9.0 → 6.10.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 (345) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/ai-sdk.js +8 -8
  3. package/dist/{asset-feeds-JWRIWLVX.js → asset-feeds-UG3PG423.js} +22 -22
  4. package/dist/{asset-feeds-JWRIWLVX.js.map → asset-feeds-UG3PG423.js.map} +1 -1
  5. package/dist/asset-manager/catalog-deployer.js +8 -8
  6. package/dist/asset-manager/history.js +8 -8
  7. package/dist/asset-manager/index.js +14 -14
  8. package/dist/asset-manager/installer.js +9 -9
  9. package/dist/asset-manager/renderers.js +8 -8
  10. package/dist/asset-manager/src/harness-switch-state.d.ts +30 -0
  11. package/dist/asset-manager/src/harness-switch-state.d.ts.map +1 -0
  12. package/dist/asset-manager/src/index.d.ts +49 -12
  13. package/dist/asset-manager/src/index.d.ts.map +1 -1
  14. package/dist/asset-manager/src/mcp-config.d.ts +6 -0
  15. package/dist/asset-manager/src/mcp-config.d.ts.map +1 -1
  16. package/dist/bridge/codex-app-server.js +1 -2
  17. package/dist/bridge/harnesses/claude-sdk.js +11 -11
  18. package/dist/bridge/harnesses/codex.js +15 -1926
  19. package/dist/bridge/harnesses/codex.js.map +1 -1
  20. package/dist/bridge/harnesses/continue.js +11 -11
  21. package/dist/bridge/harnesses/echo.js +3 -3
  22. package/dist/bridge/harnesses/gemini.js +6 -6
  23. package/dist/bridge/harnesses/goose.js +11 -11
  24. package/dist/bridge/harnesses/omp.js +61 -9
  25. package/dist/bridge/harnesses/omp.js.map +1 -1
  26. package/dist/bridge/harnesses/opencode.js +11 -11
  27. package/dist/bridge/harnesses/qwen.js +6 -6
  28. package/dist/bridge/index.js +17 -16
  29. package/dist/bridge/src/harness-model-check.d.ts +5 -4
  30. package/dist/bridge/src/harness-model-check.d.ts.map +1 -1
  31. package/dist/bridge/src/harnesses/codex.d.ts +13 -0
  32. package/dist/bridge/src/harnesses/codex.d.ts.map +1 -1
  33. package/dist/bridge/src/harnesses/omp.d.ts +22 -0
  34. package/dist/bridge/src/harnesses/omp.d.ts.map +1 -1
  35. package/dist/bridge/src/index.d.ts +1 -0
  36. package/dist/bridge/src/index.d.ts.map +1 -1
  37. package/dist/{chunk-XPKUFOS3.js → chunk-2D6HZAO5.js} +8 -8
  38. package/dist/{chunk-XPKUFOS3.js.map → chunk-2D6HZAO5.js.map} +1 -1
  39. package/dist/chunk-2MUUPRIG.js +688 -0
  40. package/dist/chunk-2MUUPRIG.js.map +1 -0
  41. package/dist/{chunk-TMQFOJ6F.js → chunk-2PVYDAFN.js} +3 -3
  42. package/dist/{chunk-TMQFOJ6F.js.map → chunk-2PVYDAFN.js.map} +1 -1
  43. package/dist/{chunk-YGT3CGPD.js → chunk-2U67XYZM.js} +3 -3
  44. package/dist/{chunk-YGT3CGPD.js.map → chunk-2U67XYZM.js.map} +1 -1
  45. package/dist/{chunk-5NTB64PW.js → chunk-375HN3FD.js} +18 -14
  46. package/dist/chunk-375HN3FD.js.map +1 -0
  47. package/dist/{chunk-23Q5LT4U.js → chunk-4I4SBOCS.js} +345 -88
  48. package/dist/chunk-4I4SBOCS.js.map +1 -0
  49. package/dist/{chunk-WPLZGT5Z.js → chunk-4Z4RULWQ.js} +59 -31
  50. package/dist/chunk-4Z4RULWQ.js.map +1 -0
  51. package/dist/{chunk-72BDCGBB.js → chunk-5JBMYZNA.js} +3 -3
  52. package/dist/{chunk-72BDCGBB.js.map → chunk-5JBMYZNA.js.map} +1 -1
  53. package/dist/{chunk-3EPRTMXY.js → chunk-5KQFR4D7.js} +6 -6
  54. package/dist/{chunk-3EPRTMXY.js.map → chunk-5KQFR4D7.js.map} +1 -1
  55. package/dist/{chunk-KNY356I3.js → chunk-5KSGZP3E.js} +11 -4
  56. package/dist/chunk-5KSGZP3E.js.map +1 -0
  57. package/dist/{chunk-DZRN3SNG.js → chunk-5P7LTPBR.js} +5 -5
  58. package/dist/{chunk-DZRN3SNG.js.map → chunk-5P7LTPBR.js.map} +1 -1
  59. package/dist/{chunk-PTJZCOBH.js → chunk-6O7VDKX3.js} +2 -2
  60. package/dist/{chunk-PTJZCOBH.js.map → chunk-6O7VDKX3.js.map} +1 -1
  61. package/dist/{chunk-B2DGCYVC.js → chunk-7DUOKE73.js} +27 -33
  62. package/dist/chunk-7DUOKE73.js.map +1 -0
  63. package/dist/{chunk-V5KG6CCV.js → chunk-7HRZACI4.js} +7 -2
  64. package/dist/chunk-7HRZACI4.js.map +1 -0
  65. package/dist/{chunk-U3FI4DVT.js → chunk-7K73MCI6.js} +7 -5
  66. package/dist/chunk-7K73MCI6.js.map +1 -0
  67. package/dist/{chunk-SE6OL7Y5.js → chunk-BCID52M5.js} +6 -6
  68. package/dist/{chunk-SE6OL7Y5.js.map → chunk-BCID52M5.js.map} +1 -1
  69. package/dist/{chunk-FZO64PLQ.js → chunk-BNLXZXZN.js} +81 -8
  70. package/dist/chunk-BNLXZXZN.js.map +1 -0
  71. package/dist/{chunk-O3FYOS64.js → chunk-C5UKYTTD.js} +13 -23
  72. package/dist/chunk-C5UKYTTD.js.map +1 -0
  73. package/dist/{chunk-LYVLDGML.js → chunk-CG63XGVV.js} +3 -3
  74. package/dist/{chunk-LYVLDGML.js.map → chunk-CG63XGVV.js.map} +1 -1
  75. package/dist/{chunk-4ROXSQEG.js → chunk-CJO3XKO7.js} +4 -4
  76. package/dist/{chunk-4ROXSQEG.js.map → chunk-CJO3XKO7.js.map} +1 -1
  77. package/dist/{chunk-OSABUEWA.js → chunk-CVUMZTNO.js} +4 -4
  78. package/dist/{chunk-OSABUEWA.js.map → chunk-CVUMZTNO.js.map} +1 -1
  79. package/dist/{chunk-E675QKFG.js → chunk-DOMRBOJZ.js} +5 -5
  80. package/dist/{chunk-E675QKFG.js.map → chunk-DOMRBOJZ.js.map} +1 -1
  81. package/dist/{chunk-GTAHU4N4.js → chunk-EB2LKPI6.js} +4 -4
  82. package/dist/{chunk-GTAHU4N4.js.map → chunk-EB2LKPI6.js.map} +1 -1
  83. package/dist/{chunk-GZL6RN4Z.js → chunk-FXBKBOI5.js} +169 -49
  84. package/dist/chunk-FXBKBOI5.js.map +1 -0
  85. package/dist/{chunk-AERQFD6T.js → chunk-GA4GUDTL.js} +4 -4
  86. package/dist/{chunk-AERQFD6T.js.map → chunk-GA4GUDTL.js.map} +1 -1
  87. package/dist/{chunk-NJVHGS7X.js → chunk-HE3TZYNG.js} +4 -4
  88. package/dist/{chunk-NJVHGS7X.js.map → chunk-HE3TZYNG.js.map} +1 -1
  89. package/dist/chunk-HLFLET7S.js +2443 -0
  90. package/dist/chunk-HLFLET7S.js.map +1 -0
  91. package/dist/{chunk-Y2BQWZXT.js → chunk-HQUF6O4B.js} +27 -56
  92. package/dist/chunk-HQUF6O4B.js.map +1 -0
  93. package/dist/{chunk-T5EIWWEJ.js → chunk-IMO4EHND.js} +5 -5
  94. package/dist/{chunk-T5EIWWEJ.js.map → chunk-IMO4EHND.js.map} +1 -1
  95. package/dist/{chunk-TUOHA6BM.js → chunk-IOXFT5D7.js} +3 -3
  96. package/dist/{chunk-TUOHA6BM.js.map → chunk-IOXFT5D7.js.map} +1 -1
  97. package/dist/{chunk-5AQLCRR7.js → chunk-JDZUQFN7.js} +4 -4
  98. package/dist/{chunk-5AQLCRR7.js.map → chunk-JDZUQFN7.js.map} +1 -1
  99. package/dist/{chunk-SQMDFM4N.js → chunk-KE5HDORU.js} +2 -2
  100. package/dist/{chunk-SQMDFM4N.js.map → chunk-KE5HDORU.js.map} +1 -1
  101. package/dist/{chunk-PTJTOPE5.js → chunk-KOI7QFDH.js} +3 -3
  102. package/dist/{chunk-PTJTOPE5.js.map → chunk-KOI7QFDH.js.map} +1 -1
  103. package/dist/{chunk-NDBHEOIA.js → chunk-KRL53RZB.js} +8 -8
  104. package/dist/{chunk-NDBHEOIA.js.map → chunk-KRL53RZB.js.map} +1 -1
  105. package/dist/{chunk-7QYBKUAS.js → chunk-LKBRBVVS.js} +3 -3
  106. package/dist/{chunk-7QYBKUAS.js.map → chunk-LKBRBVVS.js.map} +1 -1
  107. package/dist/{chunk-USSP43U3.js → chunk-LQWOU7S2.js} +3 -3
  108. package/dist/{chunk-USSP43U3.js.map → chunk-LQWOU7S2.js.map} +1 -1
  109. package/dist/{chunk-4KPQ6ILH.js → chunk-MEU2HHGV.js} +18 -9
  110. package/dist/chunk-MEU2HHGV.js.map +1 -0
  111. package/dist/{chunk-QC5BYUED.js → chunk-MS2IXLTC.js} +4 -4
  112. package/dist/{chunk-QC5BYUED.js.map → chunk-MS2IXLTC.js.map} +1 -1
  113. package/dist/{chunk-X2B5GMJO.js → chunk-NCJSYU6A.js} +16 -14
  114. package/dist/chunk-NCJSYU6A.js.map +1 -0
  115. package/dist/{chunk-CFTTXUM2.js → chunk-NFFBYG2W.js} +3 -3
  116. package/dist/{chunk-CFTTXUM2.js.map → chunk-NFFBYG2W.js.map} +1 -1
  117. package/dist/{chunk-AVRTZAH2.js → chunk-NTFP2XF4.js} +10 -10
  118. package/dist/chunk-NTFP2XF4.js.map +1 -0
  119. package/dist/{chunk-V2CONXKD.js → chunk-PSPFWTJI.js} +4 -4
  120. package/dist/{chunk-V2CONXKD.js.map → chunk-PSPFWTJI.js.map} +1 -1
  121. package/dist/{chunk-C7L5MFUL.js → chunk-PTXQMTCG.js} +3 -3
  122. package/dist/{chunk-C7L5MFUL.js.map → chunk-PTXQMTCG.js.map} +1 -1
  123. package/dist/{chunk-Y242OE4B.js → chunk-QBJQ426X.js} +3 -3
  124. package/dist/{chunk-Y242OE4B.js.map → chunk-QBJQ426X.js.map} +1 -1
  125. package/dist/{chunk-QBUJTVMY.js → chunk-R3ZNAPBV.js} +3 -3
  126. package/dist/{chunk-QBUJTVMY.js.map → chunk-R3ZNAPBV.js.map} +1 -1
  127. package/dist/{chunk-4WB4KSSQ.js → chunk-RTFH2QR2.js} +3 -3
  128. package/dist/{chunk-4WB4KSSQ.js.map → chunk-RTFH2QR2.js.map} +1 -1
  129. package/dist/{chunk-5KWQMCH7.js → chunk-RZ5R6GDJ.js} +5 -5
  130. package/dist/{chunk-5KWQMCH7.js.map → chunk-RZ5R6GDJ.js.map} +1 -1
  131. package/dist/{chunk-MDCI4RSG.js → chunk-RZL4TOK3.js} +20 -6
  132. package/dist/chunk-RZL4TOK3.js.map +1 -0
  133. package/dist/{chunk-LMADWO4Q.js → chunk-SBAUZ7XH.js} +4 -4
  134. package/dist/{chunk-LMADWO4Q.js.map → chunk-SBAUZ7XH.js.map} +1 -1
  135. package/dist/{chunk-MPRWVZXF.js → chunk-SKG6G4HO.js} +108 -44
  136. package/dist/chunk-SKG6G4HO.js.map +1 -0
  137. package/dist/{chunk-HQAPUPBE.js → chunk-V2VDTQ7A.js} +3 -3
  138. package/dist/{chunk-HQAPUPBE.js.map → chunk-V2VDTQ7A.js.map} +1 -1
  139. package/dist/{chunk-GNUA7XT2.js → chunk-VS6XC5JE.js} +3 -3
  140. package/dist/{chunk-GNUA7XT2.js.map → chunk-VS6XC5JE.js.map} +1 -1
  141. package/dist/{chunk-5J6JWGY4.js → chunk-WDG5IVEA.js} +3 -3
  142. package/dist/{chunk-5J6JWGY4.js.map → chunk-WDG5IVEA.js.map} +1 -1
  143. package/dist/{chunk-M4G2SVXI.js → chunk-XWCV2A2F.js} +4 -4
  144. package/dist/{chunk-M4G2SVXI.js.map → chunk-XWCV2A2F.js.map} +1 -1
  145. package/dist/{chunk-UWD7YBDR.js → chunk-ZLDAPZIX.js} +4 -4
  146. package/dist/{chunk-UWD7YBDR.js.map → chunk-ZLDAPZIX.js.map} +1 -1
  147. package/dist/{claude-code-YRJIGXTL.js → claude-code-CMFGCDMX.js} +5 -5
  148. package/dist/{claude-code-YRJIGXTL.js.map → claude-code-CMFGCDMX.js.map} +1 -1
  149. package/dist/cli/index.js +322 -196
  150. package/dist/cli/index.js.map +1 -1
  151. package/dist/cli/src/commands/asset-cmd.d.ts.map +1 -1
  152. package/dist/cli/src/commands/catalog.d.ts.map +1 -1
  153. package/dist/cli/src/commands/config.d.ts.map +1 -1
  154. package/dist/cli/src/commands/connector.d.ts.map +1 -1
  155. package/dist/cli/src/commands/harness-preflight.d.ts +3 -1
  156. package/dist/cli/src/commands/harness-preflight.d.ts.map +1 -1
  157. package/dist/cli/src/commands/harness.d.ts.map +1 -1
  158. package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
  159. package/dist/cli/src/commands/library-index.d.ts +3 -3
  160. package/dist/cli/src/commands/library-index.d.ts.map +1 -1
  161. package/dist/cli/src/commands/migrate-files.d.ts +8 -0
  162. package/dist/cli/src/commands/migrate-files.d.ts.map +1 -1
  163. package/dist/cli/src/commands/migrate-harness.d.ts.map +1 -1
  164. package/dist/cli/src/commands/migrate-providers.d.ts.map +1 -1
  165. package/dist/cli/src/commands/migrate.d.ts.map +1 -1
  166. package/dist/cli/src/commands/outdated.d.ts.map +1 -1
  167. package/dist/cli/src/commands/project.d.ts.map +1 -1
  168. package/dist/cli/src/commands/run.d.ts.map +1 -1
  169. package/dist/cli/src/commands/serve-preflight.d.ts +7 -5
  170. package/dist/cli/src/commands/serve-preflight.d.ts.map +1 -1
  171. package/dist/cli/src/commands/serve.d.ts.map +1 -1
  172. package/dist/cli/src/commands/source.d.ts.map +1 -1
  173. package/dist/cli/src/commands/validate.d.ts.map +1 -1
  174. package/dist/cli/src/config-checks.d.ts +50 -12
  175. package/dist/cli/src/config-checks.d.ts.map +1 -1
  176. package/dist/cli/src/ensure-sources.d.ts.map +1 -1
  177. package/dist/cli/src/harness-error.d.ts +7 -0
  178. package/dist/cli/src/harness-error.d.ts.map +1 -1
  179. package/dist/cli/src/helpers.d.ts.map +1 -1
  180. package/dist/connectors/config.js +5 -5
  181. package/dist/connectors/index.js +20 -19
  182. package/dist/connectors/src/index.d.ts +1 -1
  183. package/dist/connectors/src/index.d.ts.map +1 -1
  184. package/dist/connectors/src/managed-gitconfig.d.ts +12 -0
  185. package/dist/connectors/src/managed-gitconfig.d.ts.map +1 -1
  186. package/dist/{connectors-JKT32HZT.js → connectors-P5M2D4MH.js} +23 -22
  187. package/dist/{connectors-JKT32HZT.js.map → connectors-P5M2D4MH.js.map} +1 -1
  188. package/dist/core/index.js +7 -7
  189. package/dist/core/logging.js +1 -1
  190. package/dist/core/manifest.js +2 -2
  191. package/dist/core/models.js +1 -1
  192. package/dist/core/publish-manifest.js +3 -3
  193. package/dist/core/ref.js +1 -1
  194. package/dist/core/runtime-assets.js +5 -5
  195. package/dist/core/src/index.d.ts +2 -2
  196. package/dist/core/src/index.d.ts.map +1 -1
  197. package/dist/core/src/lock.d.ts +7 -1
  198. package/dist/core/src/lock.d.ts.map +1 -1
  199. package/dist/core/src/models.d.ts.map +1 -1
  200. package/dist/core/src/repo-manager.d.ts +28 -0
  201. package/dist/core/src/repo-manager.d.ts.map +1 -1
  202. package/dist/core/src/run-state-ignore.d.ts +5 -3
  203. package/dist/core/src/run-state-ignore.d.ts.map +1 -1
  204. package/dist/core/src/workspace-config.d.ts.map +1 -1
  205. package/dist/core/workspace-config.js +4 -4
  206. package/dist/deploy/index.js +7 -7
  207. package/dist/discovery/index.js +4 -4
  208. package/dist/{ensure-sources-GUJODKY5.js → ensure-sources-MOGLBEUF.js} +31 -29
  209. package/dist/ensure-sources-MOGLBEUF.js.map +1 -0
  210. package/dist/factory-assets/connectors/box.js +20 -19
  211. package/dist/factory-assets/connectors/deploy.js +20 -19
  212. package/dist/factory-assets/connectors/devserver.js +20 -19
  213. package/dist/factory-assets/connectors/flow/adapter.js +20 -19
  214. package/dist/factory-assets/connectors/flow/engine.js +8 -8
  215. package/dist/factory-assets/connectors/flow/run-flow.js +22 -21
  216. package/dist/factory-assets/connectors/flow.js +20 -19
  217. package/dist/factory-assets/connectors/git/exec.d.ts +7 -0
  218. package/dist/factory-assets/connectors/git/exec.d.ts.map +1 -1
  219. package/dist/factory-assets/connectors/git/repo.d.ts.map +1 -1
  220. package/dist/factory-assets/connectors/git.js +20 -19
  221. package/dist/factory-assets/connectors/gmail/adapter.d.ts.map +1 -1
  222. package/dist/factory-assets/connectors/gmail.js +20 -19
  223. package/dist/factory-assets/connectors/googledrive.js +20 -19
  224. package/dist/factory-assets/connectors/local.js +20 -19
  225. package/dist/factory-assets/connectors/mattermost.js +20 -19
  226. package/dist/factory-assets/connectors/memory.js +20 -19
  227. package/dist/factory-assets/connectors/minio/adapter.d.ts.map +1 -1
  228. package/dist/factory-assets/connectors/minio.js +20 -19
  229. package/dist/factory-assets/connectors/postgres/adapter.d.ts.map +1 -1
  230. package/dist/factory-assets/connectors/postgres.js +20 -19
  231. package/dist/factory-assets/connectors/s3/driver.d.ts.map +1 -1
  232. package/dist/factory-assets/connectors/s3.js +20 -19
  233. package/dist/factory-assets/connectors/sharepoint.js +20 -19
  234. package/dist/factory-assets/connectors/sqlite/adapter.d.ts.map +1 -1
  235. package/dist/factory-assets/connectors/sqlite.js +20 -19
  236. package/dist/factory-assets/connectors/static-server.js +20 -19
  237. package/dist/factory-assets/connectors/tunnel.js +20 -19
  238. package/dist/factory-assets/connectors/webdav.js +20 -19
  239. package/dist/factory-assets/connectors/xstate-store.js +20 -19
  240. package/dist/factory-assets/connectors/xstate.js +20 -19
  241. package/dist/{flows-UCP6ZUYS.js → flows-J64L5MGJ.js} +12 -12
  242. package/dist/{flows-UCP6ZUYS.js.map → flows-J64L5MGJ.js.map} +1 -1
  243. package/dist/{helpers-SO53MRHF.js → helpers-JL5AEGDT.js} +28 -26
  244. package/dist/{helpers-SO53MRHF.js.map → helpers-JL5AEGDT.js.map} +1 -1
  245. package/dist/library/index.js +10 -10
  246. package/dist/library/install.js +4 -4
  247. package/dist/library/src/index.d.ts +2 -2
  248. package/dist/library/src/index.d.ts.map +1 -1
  249. package/dist/library/src/library.d.ts +6 -2
  250. package/dist/library/src/library.d.ts.map +1 -1
  251. package/dist/library/src/local/db.d.ts.map +1 -1
  252. package/dist/library/src/local/library.d.ts +10 -3
  253. package/dist/library/src/local/library.d.ts.map +1 -1
  254. package/dist/library/src/local/local-catalog-source.d.ts +0 -9
  255. package/dist/library/src/local/local-catalog-source.d.ts.map +1 -1
  256. package/dist/library/src/local/schema.d.ts +27 -20
  257. package/dist/library/src/local/schema.d.ts.map +1 -1
  258. package/dist/library/src/manifest-writer.d.ts +13 -0
  259. package/dist/library/src/manifest-writer.d.ts.map +1 -1
  260. package/dist/library/src/remote/index.d.ts +1 -1
  261. package/dist/library/src/remote/index.d.ts.map +1 -1
  262. package/dist/library/src/remote/remote-catalog-source.d.ts +6 -0
  263. package/dist/library/src/remote/remote-catalog-source.d.ts.map +1 -1
  264. package/dist/library/src/sync/git-driver.d.ts.map +1 -1
  265. package/dist/{library-publish-Z5E3YZCZ.js → library-publish-DZNNZNMB.js} +49 -50
  266. package/dist/library-publish-DZNNZNMB.js.map +1 -0
  267. package/dist/model-endpoint/index.js +10 -10
  268. package/dist/open-library-OJREQ22B.js +61 -0
  269. package/dist/{open-library-A5OB72FD.js.map → open-library-OJREQ22B.js.map} +1 -1
  270. package/dist/{open-registry-BHBHQMBA.js → open-registry-OEU6QUK2.js} +14 -14
  271. package/dist/{open-registry-BHBHQMBA.js.map → open-registry-OEU6QUK2.js.map} +1 -1
  272. package/dist/paths-PXBWY532.js +22 -0
  273. package/dist/{paths-77PXOXZY.js.map → paths-PXBWY532.js.map} +1 -1
  274. package/dist/{plugin-store-XQP2CRYH.js → plugin-store-ZC3EGZ3D.js} +10 -10
  275. package/dist/{plugin-store-XQP2CRYH.js.map → plugin-store-ZC3EGZ3D.js.map} +1 -1
  276. package/dist/{project-KTEUN7KR.js → project-52UABBD5.js} +45 -46
  277. package/dist/{project-KTEUN7KR.js.map → project-52UABBD5.js.map} +1 -1
  278. package/dist/resolver/index.js +8 -8
  279. package/dist/runner/index.js +35 -35
  280. package/dist/runner/src/agent-loop.d.ts.map +1 -1
  281. package/dist/runner/src/serve.d.ts.map +1 -1
  282. package/dist/runner/src/turn-end-contract.d.ts.map +1 -1
  283. package/dist/runner/src/turn-scheduler.d.ts +8 -0
  284. package/dist/runner/src/turn-scheduler.d.ts.map +1 -1
  285. package/dist/sdk/asset-manager.js +14 -14
  286. package/dist/sdk/bridge.js +17 -16
  287. package/dist/sdk/core.js +7 -7
  288. package/dist/sdk/flow.js +8 -8
  289. package/dist/sdk/index.js +35 -35
  290. package/dist/sdk/resolver.js +8 -8
  291. package/dist/sdk/runner.js +35 -35
  292. package/dist/sdk/transport/ws/server.js +8 -8
  293. package/dist/sdk/transport/ws.js +8 -8
  294. package/dist/sdk/transport.js +8 -8
  295. package/dist/{serve-preflight-ODQGVUFL.js → serve-preflight-HOQ7CGYR.js} +30 -30
  296. package/dist/{serve-preflight-ODQGVUFL.js.map → serve-preflight-HOQ7CGYR.js.map} +1 -1
  297. package/dist/{setup-QJDI5YAW.js → setup-JIDZ372C.js} +29 -27
  298. package/dist/setup-JIDZ372C.js.map +1 -0
  299. package/dist/{skills-DE2BDQ6G.js → skills-5D4KDVPJ.js} +13 -13
  300. package/dist/{skills-DE2BDQ6G.js.map → skills-5D4KDVPJ.js.map} +1 -1
  301. package/dist/{source-FKOUYMEM.js → source-P6ZFSSZZ.js} +47 -46
  302. package/dist/{source-FKOUYMEM.js.map → source-P6ZFSSZZ.js.map} +1 -1
  303. package/dist/{source-manifest-publish-JA4TY4Z6.js → source-manifest-publish-Y36FHVDS.js} +49 -48
  304. package/dist/source-manifest-publish-Y36FHVDS.js.map +1 -0
  305. package/dist/transport/index.js +8 -8
  306. package/dist/transport/src/ws/server.d.ts.map +1 -1
  307. package/dist/transport/ws/server.js +8 -8
  308. package/dist/transport/ws.js +8 -8
  309. package/dist/tui/index.js +35 -35
  310. package/dist/workspace-plugin/adapters/mcp.js +27 -26
  311. package/dist/workspace-plugin/adapters/omp.js +14 -14
  312. package/dist/workspace-plugin/index.js +2 -2
  313. package/package.json +1 -1
  314. package/dist/chunk-23Q5LT4U.js.map +0 -1
  315. package/dist/chunk-4KPQ6ILH.js.map +0 -1
  316. package/dist/chunk-5NTB64PW.js.map +0 -1
  317. package/dist/chunk-AVRTZAH2.js.map +0 -1
  318. package/dist/chunk-B2DGCYVC.js.map +0 -1
  319. package/dist/chunk-FZO64PLQ.js.map +0 -1
  320. package/dist/chunk-GYBDWW6K.js +0 -160
  321. package/dist/chunk-GYBDWW6K.js.map +0 -1
  322. package/dist/chunk-GYPPVANR.js +0 -357
  323. package/dist/chunk-GYPPVANR.js.map +0 -1
  324. package/dist/chunk-GZL6RN4Z.js.map +0 -1
  325. package/dist/chunk-JY2JXCL6.js +0 -334
  326. package/dist/chunk-JY2JXCL6.js.map +0 -1
  327. package/dist/chunk-KNY356I3.js.map +0 -1
  328. package/dist/chunk-LOO5CB5M.js +0 -12
  329. package/dist/chunk-LOO5CB5M.js.map +0 -1
  330. package/dist/chunk-MDCI4RSG.js.map +0 -1
  331. package/dist/chunk-MPRWVZXF.js.map +0 -1
  332. package/dist/chunk-O3FYOS64.js.map +0 -1
  333. package/dist/chunk-U3FI4DVT.js.map +0 -1
  334. package/dist/chunk-V3EJYOP2.js +0 -299
  335. package/dist/chunk-V3EJYOP2.js.map +0 -1
  336. package/dist/chunk-V5KG6CCV.js.map +0 -1
  337. package/dist/chunk-WPLZGT5Z.js.map +0 -1
  338. package/dist/chunk-X2B5GMJO.js.map +0 -1
  339. package/dist/chunk-Y2BQWZXT.js.map +0 -1
  340. package/dist/ensure-sources-GUJODKY5.js.map +0 -1
  341. package/dist/library-publish-Z5E3YZCZ.js.map +0 -1
  342. package/dist/open-library-A5OB72FD.js +0 -59
  343. package/dist/paths-77PXOXZY.js +0 -22
  344. package/dist/setup-QJDI5YAW.js.map +0 -1
  345. package/dist/source-manifest-publish-JA4TY4Z6.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../cli/src/type-guards.ts","../cli/src/commands/validate-instances.ts","../cli/src/harness-error.ts","../cli/src/config-checks.ts","../cli/src/helpers.ts"],"names":["path","parseYaml","err","fs","agentInstanceDiagnostics"],"mappings":";;;;;;;;;;;;;;;AACO,SAAS,SAAS,KA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AAI,SAAA,CAAU,WAAW,CAAA,EAAG;AAC5B,EAAA,OAAA;AAAA,IACE,CAAA,uCAAA,EAA0C,SAAA,CAAU,IAAA,CAAK,IAAI,CAAC,CAAA,wFAAA;AAAA,GAChE;AACF","file":"chunk-2MUUPRIG.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 * Why the `ref` of an `agents:` instance does not resolve, as the `agent_ref_unresolved` line\n * `validate` prints (`agents.<id>: …`), or `null` when it resolves. `serve` refuses a project\n * with such an instance like `validate` does.\n */\nexport function instanceRefProblem(projectDir: string, id: string, ref: string): string | null {\n const loaded = loadAsset(projectDir, id, ref);\n return \"diagnostic\" in loaded && loaded.diagnostic.code === \"agent_ref_unresolved\"\n ? loaded.diagnostic.message\n : null;\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","import { listHarnesses } from \"@skaile/workspaces/bridge\";\nimport { SUPPORTED_HARNESSES } from \"@skaile/workspaces/core\";\nimport { Option } from \"commander\";\n\n/**\n * The refusal for a harness name nothing registers, or `undefined` when it is known. One check\n * for `run` (also with `--dry-run`, so the plan never names a harness the real run refuses),\n * `repl` and `config set harness` (p1022). Load the project's plugins first: a plugin's harness\n * counts. The line names the other command group's names too (p1753), see\n * {@link unknownHarnessTargetMessage}.\n */\nexport function unknownHarnessMessage(harness: string): string | undefined {\n const known = listHarnesses().map((d) => d.id);\n if (known.includes(harness)) return undefined;\n return (\n `Unknown agent harness: \"${harness}\". Available: ${known.join(\", \")}. ` +\n `${DEPLOY_COMMANDS} take: ${SUPPORTED_HARNESSES.join(\", \")}.`\n );\n}\n\n/** The commands that write harness files, so they take the harness targets only. */\nconst DEPLOY_COMMANDS = \"harness set, init --harness and add --harness\";\n\n/**\n * The refusal for a name that is no harness target, for the commands that deploy files\n * (`harness set`, `init --harness`, `add --harness`, `integration --harness`). Same wording as\n * {@link unknownHarnessMessage}: the list is the targets, and the line names the commands that\n * run a session and take every registered harness (p1753).\n *\n * @param harness - The name the user typed.\n * @param extra - Further names the command takes, such as `all`.\n */\nexport function unknownHarnessTargetMessage(\n harness: string,\n extra: readonly string[] = [],\n): string {\n const targets = [...SUPPORTED_HARNESSES, ...extra];\n const registered = listHarnesses().map((d) => d.id);\n return (\n `Unknown agent harness: \"${harness}\". Available: ${targets.join(\", \")}. ` +\n `run, repl and config set harness take: ${registered.join(\", \")}.`\n );\n}\n\n/**\n * The bridge harness id of a name a user typed: `claude-code`, the name `init --harness` and\n * `harness set` take, is `claude-sdk` for the commands that run a session. Any other name is\n * returned as it is.\n */\nexport function canonicalHarnessId<T extends string | undefined>(harness: T): T {\n return (harness === \"claude-code\" ? \"claude-sdk\" : harness) as T;\n}\n\nlet warnedDriverFlag = false;\n\n/** Print the `--driver` deprecation line to stderr, once per process. */\nexport function warnDriverFlagDeprecated(): void {\n if (warnedDriverFlag) return;\n warnedDriverFlag = true;\n console.error(\"--driver is deprecated; use --harness\");\n}\n\n/**\n * The hidden `--driver <name>` option every command with `--harness <name>` keeps for one\n * major release: an alias that sets the same value (`--harness` wins when both are given).\n */\nexport function driverAliasOption(): Option {\n return new Option(\"--driver <name>\", \"Deprecated alias of --harness\").hideHelp();\n}\n\n/**\n * Fold a parsed `--driver` alias into `harness`: when `--driver` was given, print the\n * deprecation line once and use its value unless `--harness` (or `fallback`, when neither\n * flag was given) already decided. Returns `opts` with `harness` set and `driver` removed.\n * The name is kept as typed: the commands that run a session apply {@link canonicalHarnessId}.\n */\nexport function foldDriverFlag<T extends { harness?: string; driver?: string }>(\n opts: T,\n fallback?: string,\n): Omit<T, \"driver\"> & { harness?: string } {\n const { driver, ...rest } = opts;\n if (driver !== undefined) warnDriverFlagDeprecated();\n return { ...rest, harness: rest.harness ?? driver ?? fallback };\n}\n\n/**\n * Turn a harness-start/prompt failure into a friendly, actionable message when the\n * cause is a missing/unusable agent binary; otherwise return `null` so the caller\n * surfaces the raw error unchanged.\n *\n * The bridge classifies these as `category: \"config\"` and carries a `hint`, but the\n * shape reaching the CLI varies: omp's `start()` rejects with the raw spawn error\n * (`code === \"ENOENT\"`), while the subprocess CLI harnesses reject with the classified\n * `AgentError` attached under `.detail`. Duck-type across all of them.\n */\nexport function friendlyHarnessError(err: unknown): string | null {\n const e = err as\n | {\n code?: string;\n syscall?: string;\n message?: string;\n category?: string;\n hint?: string;\n detail?: { category?: string; hint?: string };\n }\n | null\n | undefined;\n if (!e) return null;\n\n // A missing binary is a *spawn* ENOENT (`syscall: \"spawn <bin>\"` / \"spawn … ENOENT\");\n // a bare ENOENT from connector/mount setup is a different failure, not the harness.\n const isSpawnEnoent =\n e.code === \"ENOENT\" &&\n (e.syscall?.startsWith(\"spawn\") === true || /^spawn .*ENOENT/.test(e.message ?? \"\"));\n const isConfig = e.category === \"config\" || e.detail?.category === \"config\";\n if (!isSpawnEnoent && !isConfig) return null;\n\n const hint = e.hint ?? e.detail?.hint;\n const base = hint ?? \"The configured agent binary is not installed or not on your PATH.\";\n return `${base}\\nTry a different harness with \\`--harness claude-sdk\\`.`;\n}\n\n/**\n * Lines that follow the single `✗` line of a failed turn: the classifier's hint\n * (or, for a rejected credential, a pointer at the key), and where the full\n * records are. The JSON records themselves are not printed on the terminal:\n * they live in the project's log database. The pointer names the session whose records\n * the failure left (`logSessionId`); a failure before any session started has none and\n * gets no pointer.\n */\nexport function harnessErrorNotes(err: unknown): string[] {\n const e = err as\n | {\n category?: string;\n hint?: string;\n logSessionId?: string;\n detail?: { category?: string; hint?: string };\n }\n | null\n | undefined;\n const notes: string[] = [];\n const category = e?.category ?? e?.detail?.category;\n const hint = e?.hint ?? e?.detail?.hint;\n if (hint && category !== \"config\") notes.push(hint);\n else if (category === \"auth\") notes.push(\"Check your API key or login.\");\n if (e?.logSessionId) {\n notes.push(`Full records: .skaile/logs.db (skaile session logs ${e.logSessionId}).`);\n }\n return notes;\n}\n","/**\n * Checks of a project's `skaile.yaml` that `validate`, `check`, `doctor` and `run` share:\n * keys nothing reads (p1474) and a `harness:` no harness registers (p1022).\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n ConnectorDeclaration,\n Diagnostic,\n SkWorkspaceConfig,\n SkWorkspaceConfigFile,\n} from \"@skaile/workspaces/core\";\nimport {\n isInsideProject,\n loadSkWorkspaceConfig,\n localConnectorMountDir,\n resolveRuntimeAssets,\n SKAILE_YAML_DEFAULT,\n symlinkEscapeOfProject,\n} from \"@skaile/workspaces/core\";\nimport { parse as parseYaml } from \"yaml\";\nimport { checkAgentInstances } from \"./commands/validate-instances.ts\";\nimport { unknownHarnessMessage } from \"./harness-error.ts\";\nimport { logErr, logWarn, logWarnErr } from \"./helpers.ts\";\nimport { loadDeclaredPlugins } from \"./plugin-store/index.ts\";\n\n/** One warning line per key of the file that nothing reads. */\nexport function unknownKeyWarnings(diagnostics: readonly Diagnostic[], label: string): string[] {\n return diagnostics\n .filter((d) => d.code === \"unknown_config_key\" || d.code === \"unknown_profile_key\")\n .map((d) => `${label}: ${d.message}`);\n}\n\n/** `skaile.yaml` connector diagnostics that fail `validate` and refuse `serve` (the runner cannot mount it right). */\nexport const CONNECTOR_ERROR_CODES: readonly string[] = [\n \"connector_missing_driver\",\n \"connector_missing_id\",\n \"connector_duplicate_id\",\n \"connector_invalid_access\",\n];\n\n/**\n * One error line per connector the runner cannot mount or mounts wrongly: no `driver`, no `id`, a\n * duplicate `id`, an unknown `access`. `validate` and `serve` print the same lines.\n */\nexport function connectorErrorLines(diagnostics: readonly Diagnostic[], label: string): string[] {\n return diagnostics\n .filter((d) => CONNECTOR_ERROR_CODES.includes(d.code))\n .map((d) => `${label} [connectors] — ${d.code}: ${d.path ? `${d.path}: ` : \"\"}${d.message}`);\n}\n\n/**\n * A `local` connector's `mountPath` is mounted read-write as given: one that does not exist\n * fails, one that reaches outside the project through a symlink fails, one outside the project\n * only warns. `validate` and `serve` print the same lines.\n *\n * @param projectDir - Directory a relative `mountPath` is read from.\n * @param label - File name for the line.\n * @param connectors - The declared connectors.\n */\nexport function connectorMountPathChecks(\n projectDir: string,\n label: string,\n connectors: ReadonlyArray<ConnectorDeclaration>,\n): { errors: string[]; warnings: string[] } {\n const errors: string[] = [];\n const warnings: string[] = [];\n for (const c of connectors) {\n // A connector without an id is reported once, as `connector_missing_id`; it has no\n // `connectors.<id>` to name in a second error.\n if (typeof c.id !== \"string\" || c.id === \"\") continue;\n if (c.driver !== \"local\" || c.mount) continue;\n const dir = localConnectorMountDir(c, projectDir);\n if (!dir) continue;\n const escapesTo = symlinkEscapeOfProject(dir, projectDir);\n if (!fs.existsSync(dir)) {\n errors.push(\n `${label} [connectors] — connector_mount_path_missing: connectors.${c.id}.mountPath: ${dir} does not exist; create the directory or fix the path`,\n );\n } else if (escapesTo !== null) {\n errors.push(\n `${label} [connectors] — connector_mount_path_symlink: connectors.${c.id}.mountPath: ${dir} is a symlink to ${escapesTo}, outside the project ${projectDir}; point mountPath at the real directory`,\n );\n } else if (!isInsideProject(dir, projectDir)) {\n warnings.push(\n `${label} [connectors] — connectors.${c.id}.mountPath: ${dir} is outside the project ${projectDir}; the agent reads${c.access === \"read-write\" ? \" and writes\" : \"\"} there`,\n );\n }\n }\n return { errors, warnings };\n}\n\n/**\n * One error line per connector whose `driver` no catalog entry and no loaded plugin provides.\n * The text is the one `serve` logs as a `validation_warning`. An unreachable source (not cloned\n * yet) may hold the driver, so nothing is reported while one is missing. The project's plugins\n * are loaded first, as `serve` loads them.\n *\n * @param projectDir - Project whose sources and plugins are read.\n * @param label - File name for the line.\n * @param connectors - The declared connectors.\n */\nexport async function unknownConnectorDriverErrors(\n projectDir: string,\n label: string,\n connectors: ReadonlyArray<ConnectorDeclaration>,\n): Promise<string[]> {\n if (connectors.length === 0) return [];\n await loadDeclaredPlugins(projectDir);\n // Lazy: only a project with connectors loads the connectors package.\n const { listConnectors } = await import(\"@skaile/workspaces/connectors\");\n const assets = await resolveRuntimeAssets(projectDir, {\n isDriverRegistered: (driver) => listConnectors().includes(driver),\n });\n if (assets.warnings.some((w) => w.code === \"repo_unavailable\")) return [];\n return assets.warnings\n .filter((w) => w.code === \"missing_driver\" && w.name)\n .map((w) => `${label} [connectors] — ${w.code}: ${w.message}`);\n}\n\n/** The `agent-config` key diagnostics that name a replacement: the old `driver` and the retired `agent`. */\nexport const AGENT_CONFIG_KEY_CODES = [\"deprecated_harness_key\", \"retired_agent_key\"] as const;\n\n/**\n * One warning line per `agent-config` key that is deprecated (`driver`, p1873) or retired\n * (`agent`, p1874): still read or ignored, and `skaile migrate harness` fixes it. `validate`,\n * `check`, `doctor`, `run` and `config show` print the same line.\n */\nexport function agentConfigKeyWarnings(\n diagnostics: readonly Diagnostic[],\n label: string,\n): string[] {\n return diagnostics\n .filter((d) => (AGENT_CONFIG_KEY_CODES as readonly string[]).includes(d.code))\n .map((d) => `${label} [agent-config] — ${d.code}: ${d.message}`);\n}\n\n/**\n * One error line per `agent-config` profile that sets both `harness` and `driver`: `harness` wins,\n * but the file is wrong, so every command that reads it says so as `validate` does.\n */\nexport function harnessKeyConflictErrors(\n diagnostics: readonly Diagnostic[],\n label: string,\n): string[] {\n return diagnostics\n .filter((d) => d.code === \"harness_key_conflict\")\n .map((d) => `${label} [agent-config] — ${d.code}: ${d.message}`);\n}\n\n/**\n * One error line per `agent-config` profile whose `harness:` nothing registers. The harnesses of\n * the plugins the project declares count, so they are loaded before the verdict, and only when\n * some profile names a harness the built-in ones do not.\n *\n * @param projectDir - Project whose `plugins:` are loaded.\n * @param config - The decoded config file.\n * @param label - File name for the line.\n */\nexport async function unknownHarnessErrors(\n projectDir: string,\n config: SkWorkspaceConfig,\n label: string,\n): Promise<string[]> {\n const profiles = Object.entries(config.agent_config ?? {}).filter(\n (e): e is [string, { harness: string }] => typeof e[1]?.harness === \"string\",\n );\n if (profiles.every(([, p]) => unknownHarnessMessage(p.harness) === undefined)) return [];\n await loadDeclaredPlugins(projectDir);\n const errors: string[] = [];\n for (const [name, p] of profiles) {\n const refusal = unknownHarnessMessage(p.harness);\n if (refusal) errors.push(`${label}: agent-config.${name}.harness: ${refusal}`);\n }\n return errors;\n}\n\n/**\n * Print the `✗` line for each `agent-config` profile whose `harness:` nothing registers or that\n * sets both `harness` and `driver`, and return how many were printed. The harness check `install`, `list` and `config show` share with\n * `validate`, `check` and `run` (p1754); a file that does not load is not this function's to\n * report.\n */\nexport async function reportUnknownHarnesses(projectDir: string): Promise<number> {\n let file: SkWorkspaceConfigFile | null;\n try {\n file = loadSkWorkspaceConfig(projectDir);\n } catch {\n return 0;\n }\n const config = file?.config;\n if (!config) return 0;\n const errors = [\n ...harnessKeyConflictErrors(file?.diagnostics ?? [], \"skaile.yaml\"),\n ...(await unknownHarnessErrors(projectDir, config, \"skaile.yaml\")),\n ];\n for (const line of errors) logErr(line);\n return errors.length;\n}\n\n/** The `agents:` / `agent:` diagnostics of the project's `skaile.yaml` as `validate` gives them. */\nfunction agentInstanceDiagnostics(projectDir: string): Diagnostic[] {\n let parsed: unknown;\n try {\n parsed = parseYaml(fs.readFileSync(path.join(projectDir, SKAILE_YAML_DEFAULT), \"utf-8\"));\n } catch {\n return [];\n }\n if (typeof parsed !== \"object\" || parsed === null) return [];\n return checkAgentInstances(projectDir, parsed as Record<string, unknown>);\n}\n\n/** One line the way `validate` prints a diagnostic of the `agents:` map. */\nfunction agentInstanceLine(d: Diagnostic): string {\n return `${SKAILE_YAML_DEFAULT} [agents] — ${d.code}: ${d.path ? `${d.path}: ` : \"\"}${d.message}`;\n}\n\n/**\n * The errors `skaile validate` gives the `agents:` map of the project's `skaile.yaml`, as the\n * lines `validate` prints (p1512): a lifecycle or memory scope that is none of the known ones, a\n * `role` instance whose agent declares no `io`, a connector or trigger the agent does not have.\n * `install`, `check`, `run`, `repl` and `rebuild` refuse the project with them, so they never\n * accept what `validate` rejects. A ref that does not resolve is left out: `install` resolves a\n * catalog ref itself and `check` reports an unbound ref as a gap.\n *\n * @param projectDir - Project directory.\n */\nexport function agentInstanceErrorLines(projectDir: string): string[] {\n return agentInstanceDiagnostics(projectDir)\n .filter((d) => d.severity === \"error\" && d.code !== \"agent_ref_unresolved\")\n .map(agentInstanceLine);\n}\n\n/**\n * The warnings `skaile validate` gives for keys of `agent:` and `agents:` that nothing reads\n * (p1712), as the lines `validate` prints: `agents.audit.colour`, `agent.modle`,\n * `agents.<id>.model.preffered`. Without them a typo leaves the default model or budget in\n * place and says nothing.\n *\n * @param projectDir - Project directory.\n */\nexport function agentInstanceWarningLines(projectDir: string): string[] {\n return agentInstanceDiagnostics(projectDir)\n .filter(\n (d) =>\n d.severity === \"warning\" &&\n (d.code === \"unknown_agent_instance_key\" || d.code === \"unknown_agent_key\"),\n )\n .map(agentInstanceLine);\n}\n\n/** Projects whose key warnings this process printed already (a command can reach the check twice). */\nconst warnedProjects = new Set<string>();\n\n/**\n * Print the warnings for keys of the project's `skaile.yaml` that nothing reads: top-level and\n * `agent-config` keys, `agent:` and `agents:` keys. Every command that loads the file prints\n * them through here (`requireProjectConfig` calls it), so a typo shows in whichever command the\n * user runs first. Prints once per project and process. A file that is missing or does not load\n * prints nothing: the command says so itself.\n *\n * @param projectDir - Project directory.\n * @param opts.file - The loaded file, when the caller has it.\n * @param opts.stderr - Print on stderr, for a command whose stdout a script reads (`list --json`).\n */\nexport function warnProjectConfig(\n projectDir: string,\n opts: { file?: SkWorkspaceConfigFile | null; stderr?: boolean } = {},\n): void {\n const key = path.resolve(projectDir);\n if (warnedProjects.has(key)) return;\n let file = opts.file;\n if (file === undefined) {\n try {\n file = loadSkWorkspaceConfig(projectDir);\n } catch {\n return;\n }\n }\n if (!file) return;\n warnedProjects.add(key);\n const warn = opts.stderr ? logWarnErr : logWarn;\n for (const line of unknownKeyWarnings(file.diagnostics ?? [], \"skaile.yaml\")) warn(line);\n for (const line of agentConfigKeyWarnings(file.diagnostics ?? [], \"skaile.yaml\")) warn(line);\n for (const line of agentInstanceWarningLines(projectDir)) warn(line);\n}\n\n/**\n * The checks of the project's own `skaile.yaml`, printed: `!` lines for unknown keys (also the\n * ones of `agent:` and `agents:`, p1712), `✗` lines for a profile that sets both `harness` and\n * `driver`, for an unknown harness and for an `agents:` map `validate` rejects. Returns the number of errors printed. A file that does not load is not\n * this function's to report: the command reads it again and says so.\n *\n * @param projectDir - Project directory.\n * @param opts.harness - Also refuse an unknown `harness:` (`check`, `doctor`).\n * @param opts.instances - Also refuse an `agents:` map `validate` rejects (p1512).\n */\nexport async function reportProjectConfig(\n projectDir: string,\n opts: { harness: boolean; instances?: boolean },\n): Promise<number> {\n let file: SkWorkspaceConfigFile | null;\n try {\n file = loadSkWorkspaceConfig(projectDir);\n } catch {\n return 0;\n }\n if (!file) return 0;\n warnProjectConfig(projectDir, { file });\n const errors = [\n ...harnessKeyConflictErrors(file.diagnostics ?? [], \"skaile.yaml\"),\n ...(opts.harness ? await unknownHarnessErrors(projectDir, file.config, \"skaile.yaml\") : []),\n ...(opts.instances ? agentInstanceErrorLines(projectDir) : []),\n ];\n for (const line of errors) logErr(line);\n return errors.length;\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport { softDepName } from \"@skaile/workspaces/asset-manager\";\nimport {\n type HarnessName,\n LockParseError,\n readLock,\n resolveSkWorkspaceConfig,\n SKAILE_YAML_DEFAULT,\n SUPPORTED_HARNESSES,\n} from \"@skaile/workspaces/core\";\nimport pc from \"picocolors\";\nimport { warnProjectConfig } from \"./config-checks.ts\";\nimport { unknownHarnessTargetMessage } from \"./harness-error.ts\";\n\n/**\n * Terminal styling helpers used across all CLI commands.\n *\n * @docLink cli/dev-guide#helpers\n */\nexport const S = {\n brand: (s: string) => pc.cyan(pc.bold(s)),\n cmd: (s: string) => pc.cyan(s),\n heading: (s: string) => pc.bold(s),\n bold: (s: string) => pc.bold(s),\n dim: (s: string) => pc.dim(s),\n ok: (s: string) => pc.green(s),\n warn: (s: string) => pc.yellow(s),\n err: (s: string) => pc.red(s),\n label: (s: string) => pc.dim(s),\n rule: (w = 40) => pc.dim(\"─\".repeat(w)),\n};\n\nconst KIND_COLORS: Record<string, (s: string) => string> = {\n skill: pc.blue,\n agent: pc.magenta,\n prompt: pc.yellow,\n flow: pc.green,\n preset: pc.cyan,\n contract: pc.red,\n connector: pc.green,\n knowledge: pc.cyan,\n persona: pc.cyan,\n ruleset: pc.cyan,\n \"mcp-server\": pc.magenta,\n};\n\n/**\n * Fit a plain (ANSI-free) string into exactly `width` columns: truncate with a\n * trailing `…` when too long, pad with spaces when too short. Keeps fixed-width\n * columns from overflowing the row when a value (e.g. an asset name) is wider\n * than its budget.\n */\nexport function fitWidth(s: string, width: number): string {\n if (width <= 0) return \"\";\n if (s.length > width) return width === 1 ? \"…\" : `${s.slice(0, width - 1)}…`;\n return s.padEnd(width);\n}\n\n/** Color-code an asset kind string. */\nexport function kindColor(kind: string): string {\n const colorFn = KIND_COLORS[kind] ?? pc.dim;\n return colorFn(kind);\n}\n\n/**\n * Widest kind label (`mcp-server`); the default kind-column width fits it so\n * long kinds don't shove the rest of the row out of alignment.\n */\nexport const KIND_COL_WIDTH = 10;\n\n/**\n * Shared `--target` help suffix: with no flag, the manager deploys into the\n * harness the project is configured for (the harness `skaile config show`\n * resolves), and only then falls back to `claude-code`.\n */\nexport const TARGET_DEFAULT_HINT = \"default: the project's configured harness, else claude-code\";\n\n/**\n * Color-code an asset kind string fit to exactly `width` columns — pads short\n * kinds, truncates over-long ones (via {@link fitWidth}) so the column can never\n * overflow and break row alignment.\n */\nexport function kindColorPad(kind: string, width = KIND_COL_WIDTH): string {\n const colorFn = KIND_COLORS[kind] ?? pc.dim;\n return colorFn(fitWidth(kind, width));\n}\n\n/** Color-code a \"kind:name\" reference string. */\nexport function colorRef(ref: string): string {\n const colonIdx = ref.indexOf(\":\");\n if (colonIdx === -1) return ref;\n const kind = ref.slice(0, colonIdx);\n const rest = ref.slice(colonIdx);\n return `${kindColor(kind)}${rest}`;\n}\n\n/**\n * Print a success line prefixed with a green check mark.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logOk(msg: string) {\n console.log(` ${pc.green(\"✓\")} ${msg}`);\n}\n/**\n * Print an error line prefixed with a red cross to stderr.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logErr(msg: string) {\n console.error(` ${pc.red(\"✗\")} ${msg}`);\n}\n/**\n * Print a warning line prefixed with a yellow exclamation mark.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logWarn(msg: string) {\n console.log(` ${pc.yellow(\"!\")} ${msg}`);\n}\n/**\n * Like {@link logWarn}, on stderr: a warning about the run itself (an asset scan that stopped\n * early) that must not land in the output a script reads from stdout.\n *\n * @param msg - Message to display.\n */\nexport function logWarnErr(msg: string) {\n console.error(` ${pc.yellow(\"!\")} ${msg}`);\n}\n/**\n * One `!` line per deployed library asset whose body or description is still the untouched\n * `library create` scaffold: `validate` and the publish plan fail both, so `add`, `install` and\n * `update` name every placeholder they fail (p926).\n *\n * @param bodies - Canonical refs the asset manager reported as placeholder bodies.\n * @param descriptions - Canonical refs the asset manager reported as placeholder descriptions.\n */\nexport function warnPlaceholderBodies(\n bodies: readonly string[] | undefined,\n descriptions?: readonly string[],\n) {\n const refs = [...new Set([...(bodies ?? []), ...(descriptions ?? [])])];\n for (const ref of refs) {\n const parts = [\n ...(descriptions?.includes(ref) ? [\"description\"] : []),\n ...(bodies?.includes(ref) ? [\"body\"] : []),\n ];\n const both = parts.length > 1;\n logWarn(\n `${ref} ${parts.join(\" and \")} ${both ? \"are\" : \"is\"} still the scaffold placeholder; write ${both ? \"them\" : \"it\"} (\\`skaile validate\\` fails ${both ? \"them\" : \"it\"})`,\n );\n }\n}\n/**\n * Print an info line prefixed with a dim dot.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logInfo(msg: string) {\n console.log(` ${pc.dim(\"·\")} ${msg}`);\n}\n\n/** Full command path of the command being run (`harness set`), set before its action runs. */\nlet activeCommandPath: string | undefined;\n\n/**\n * Record the command that is about to run, as the path of subcommand names from the root\n * (`harness set`), so advice that repeats the command shows the whole path (p1656).\n */\nexport function setActiveCommand(cmd: { name(): string; parent: unknown }): void {\n const names: string[] = [];\n for (\n let c: { name(): string; parent: unknown } | null = cmd;\n c && c.parent;\n c = c.parent as { name(): string; parent: unknown } | null\n ) {\n names.unshift(c.name());\n }\n activeCommandPath = names.length > 0 ? names.join(\" \") : undefined;\n}\n\n/** The nearest parent directory of `dir` that holds a `skaile.yaml`, or `undefined`. */\nfunction nearestParentProject(dir: string): string | undefined {\n for (let up = path.dirname(dir); up !== dir; dir = up, up = path.dirname(dir)) {\n if (existsSync(path.join(up, SKAILE_YAML_DEFAULT))) return up;\n }\n return undefined;\n}\n\n/**\n * Print the `No skaile.yaml found` line for `projectDir`, plus a second line naming the nearest\n * parent directory that holds a `skaile.yaml`, when there is one: skaile does not search parent\n * directories. The line shows `--project-dir` after the full command path (`skaile harness set\n * --project-dir /x`), the only place the option is accepted (p1656).\n */\nexport function logNoProject(projectDir: string): void {\n const dir = path.resolve(projectDir);\n logErr(`No ${S.cmd(\"skaile.yaml\")} found. Run ${S.cmd(\"skaile init\")} to create one.`);\n const parent = nearestParentProject(dir);\n if (parent) {\n const command =\n activeCommandPath ?? process.argv.slice(2).find((a) => !a.startsWith(\"-\")) ?? \"<command>\";\n logErr(\n `${S.cmd(parent)} holds a ${S.cmd(\"skaile.yaml\")}: run from there or put the option after the command name: ${S.cmd(`skaile ${command} --project-dir ${parent}`)}.`,\n );\n }\n}\n\n/**\n * Stop a project command that has no usable project: print one `✗` line and exit 1, before\n * the command deploys, undeploys, locks or clones anything. Two causes: no `skaile.yaml` in\n * `projectDir` (`No skaile.yaml found`), or a `skaile.yaml` — project, app or user scope —\n * that does not parse (`<file> — parse error: …`, a duplicate key included). Without this a\n * broken file would read as \"nothing declared\" and `install` would undeploy every asset.\n *\n * Library-level commands (`library …`, `search`, `init`) have no project and do not call it.\n */\nexport function requireProjectConfig(\n projectDir: string,\n opts: { allowMissing?: boolean } = {},\n): void {\n const dir = path.resolve(projectDir);\n if (!existsSync(path.join(dir, SKAILE_YAML_DEFAULT))) {\n if (opts.allowMissing) return;\n logNoProject(dir);\n process.exit(1);\n }\n try {\n resolveSkWorkspaceConfig(dir);\n } catch (err) {\n logErr(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n // A lock that is not valid YAML is not \"nothing locked\": `update` would overwrite it and\n // `outdated`/`why`/`check` would call every asset unlocked. One line, exit 1 (p1892).\n try {\n readLock(path.join(dir, \"skaile.lock.yaml\"));\n } catch (err) {\n if (err instanceof LockParseError) {\n logErr(err.message);\n process.exit(1);\n }\n // Another lock problem (an old schema) has its own message where the lock is used.\n }\n // Keys of the file that nothing reads: every command that loads it says so, not only\n // `validate` and `check`, so a typo is seen in whichever command runs first.\n warnProjectConfig(dir);\n}\n\n/**\n * Hold warnings raised while a spinner animates and print them once it stops:\n * on a TTY a line written mid-spin is overwritten by the next frame. Pass\n * `push` as `AssetManager`'s `onLibraryCollision`, call `flush()` after\n * `spinner.stop(...)`. Warnings pushed after `flush()` print immediately.\n */\nexport function deferredWarnings(): { push: (msg: string) => void; flush: () => void } {\n const held: string[] = [];\n let live = false;\n return {\n push: (msg) => {\n if (live) logWarn(msg);\n else held.push(msg);\n },\n flush: () => {\n for (const msg of held.splice(0)) logWarn(msg);\n live = true;\n },\n };\n}\n\n/** Max stale copies of one harness named inline by {@link warnStaleHarnessCopies}. */\nconst STALE_COPY_LIST_MAX = 5;\n\n/**\n * Print one warning per harness whose project dir (`.claude/`, `.omp/`, `.codex/`) still holds\n * copies of tracked assets although the project deploys to another harness: after `skaile\n * harness set`, or when a project moved off the old default. Those copies are orphans: `remove`\n * / `clean` / `list` only look in the active harness dir. Every file a deploy created is named\n * (p1671). Nothing is deleted here; `skaile harness set <name> --clean` deletes them. Silent when\n * there are none.\n */\nexport function warnStaleHarnessCopies(am: {\n projectDir: string;\n harness: string;\n listStaleHarnessCopies(): Array<{ harness: HarnessName; path: string }>;\n}): void {\n let stale: Array<{ harness: HarnessName; path: string }>;\n try {\n stale = am.listStaleHarnessCopies();\n } catch {\n return; // advisory only — never fail the command\n }\n for (const harness of SUPPORTED_HARNESSES) {\n const rel = stale\n .filter((s) => s.harness === harness)\n .map((s) => path.relative(am.projectDir, s.path));\n if (rel.length === 0) continue;\n const dir = `${rel[0]?.split(path.sep)[0] ?? harness}/`;\n const shown = rel.slice(0, STALE_COPY_LIST_MAX).join(\", \");\n const more =\n rel.length > STALE_COPY_LIST_MAX ? `, +${rel.length - STALE_COPY_LIST_MAX} more` : \"\";\n logWarn(\n `Stale ${S.cmd(dir)} copies no longer managed (deploying to ${am.harness}): ${shown}${more}. ` +\n `Delete them with ${S.cmd(`skaile harness set ${am.harness} --clean`)}, or pass ${S.cmd(`--target ${harness}`)} to keep using ${dir}.`,\n );\n }\n}\n\n/**\n * Bare asset name of a canonical soft-dep target ref (`@pub/name@ver` → `name`),\n * for compact rendering in `info` / `tree` / `why`. Delegates to the asset-manager\n * parser (the soft-dep read surface) so the two never diverge.\n */\nexport function bareSoftDepName(ref: string): string {\n return softDepName(ref);\n}\n\n/**\n * The report-only soft-dep hint line shared by the `add` no-TTY branch and the\n * `install` surface, so the two user-facing wordings can't drift. Appends a\n * runnable `skaile add` suffix only when the target has a parseable ref.\n */\nexport function formatSoftDepHint(edge: { from: string; to: string; toRef?: string }): string {\n const suffix = edge.toRef ? ` — run \\`skaile add ${edge.toRef}\\` to include it.` : \"\";\n return `${bareSoftDepName(edge.from)} references ${bareSoftDepName(edge.to)} (soft dependency)${suffix}`;\n}\n\n/**\n * Build the \"Soft dependencies (inferred)\" section for `skaile info`. Returns one\n * header line plus one line per soft-dep target, each marked `(soft)` to read\n * differently from a typed `requires`. Empty array when there are no soft deps,\n * so the caller prints nothing.\n */\nexport function formatSoftDepSection(targets: string[]): string[] {\n if (targets.length === 0) return [];\n const out = [` ${S.label(\"Soft dependencies (inferred)\")}:`];\n for (const t of targets) out.push(` ${S.dim(\"·\")} ${t} ${S.dim(\"(soft)\")}`);\n return out;\n}\n\n/**\n * Footer line previewing the soft deps that *adding* the highlighted asset would\n * reference (manage TUI). \"references\" + \"not auto-added\" makes clear the pull is\n * report-only. Empty string when there are no targets, so the caller clears.\n */\nexport function formatSoftDepAddPreview(name: string, targets: string[]): string {\n if (targets.length === 0) return \"\";\n return S.dim(`${name} references ${targets.join(\", \")} (soft dep, not auto-added)`);\n}\n\n/**\n * Footer line previewing the soft deps that *removing* the highlighted asset\n * would orphan (manage TUI) — symmetric with {@link formatSoftDepAddPreview}.\n * Empty string when nothing would be orphaned, so the caller clears.\n */\nexport function formatSoftDepRemovePreview(name: string, targets: string[]): string {\n if (targets.length === 0) return \"\";\n return S.dim(`removing ${name} would orphan ${targets.join(\", \")} (soft dep)`);\n}\n\n/** Format a Date as a human-readable relative time string (e.g. \"5m ago\"). */\nexport function formatRelativeTime(date: Date): string {\n const diff = Date.now() - date.getTime();\n const seconds = Math.floor(diff / 1000);\n if (seconds < 60) return \"just now\";\n const minutes = Math.floor(seconds / 60);\n if (minutes < 60) return `${minutes}m ago`;\n const hours = Math.floor(minutes / 60);\n if (hours < 24) return `${hours}h ago`;\n const days = Math.floor(hours / 24);\n return `${days}d ago`;\n}\n\n/** Name the old `~/.omp/<dir>` copies a global deploy replaced (omp reads `~/.omp/agent/<dir>`). */\nexport function reportLegacyOmpCopies(removed: string[], kept: string[] = []): void {\n for (const p of removed) {\n logInfo(\n S.dim(`removed the old omp copy ${p.replace(homedir(), \"~\")} (omp reads ~/.omp/agent)`),\n );\n }\n for (const p of kept) {\n logWarn(\n `${p.replace(homedir(), \"~\")} is an old omp location and skaile did not write this copy, so it was kept: delete it if you do not need it`,\n );\n }\n}\n\n/**\n * Parse a `--harness a,b` value into validated {@link HarnessName}s, exiting on\n * an unknown id. Returns `undefined` when the flag is absent (the caller then\n * resolves the full global harness set).\n */\nexport function parseHarnessFilter(raw: string | undefined): HarnessName[] | undefined {\n if (!raw) return undefined;\n const ids = raw\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n const out: HarnessName[] = [];\n for (const id of ids) {\n if (!(SUPPORTED_HARNESSES as string[]).includes(id)) {\n logErr(unknownHarnessTargetMessage(id));\n process.exit(1);\n }\n out.push(id as HarnessName);\n }\n return out.length > 0 ? out : undefined;\n}\n\n/** The sentence the agent renderer puts into a delegate sub-agent's file (`asset-manager` fragments). */\nconst SUB_AGENT_MARKER = \"You are a sub-agent:\";\n\n/**\n * One line when a Codex project holds delegate sub-agents. Codex does not load\n * `.codex/agents/*.toml` as spawnable agents (its `spawn_agent` has no `agent_type`), so the\n * delegate exists only as a file there and the orchestrator cannot call it (p428). A delegate is\n * found by the sentence the renderer writes into its file. Silent for every other harness.\n */\nexport function warnFilesOnlyDelegates(projectDir: string, target: string): void {\n if (target !== \"codex\") return;\n const dir = path.join(projectDir, \".codex\", \"skaile-agents\");\n let names: string[];\n try {\n names = readdirSync(dir).filter((f) => f.endsWith(\".md\"));\n } catch {\n return;\n }\n const delegates = names\n .filter((f) => {\n try {\n return readFileSync(path.join(dir, f), \"utf8\").includes(SUB_AGENT_MARKER);\n } catch {\n return false;\n }\n })\n .map((f) => f.replace(/\\.md$/, \"\"))\n .sort();\n if (delegates.length === 0) return;\n logWarn(\n `codex: delegate agents are files only (${delegates.join(\", \")}): Codex does not load .codex/agents as sub-agents, so the orchestrator cannot call them`,\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { pluginRegistry } from './chunk-G5SUWZEU.js';
2
- import { readPluginsLockSlice } from './chunk-4KPQ6ILH.js';
2
+ import { readPluginsLockSlice } from './chunk-MEU2HHGV.js';
3
3
  import path, { join, resolve } from 'path';
4
4
  import pc from 'picocolors';
5
5
  import { pathToFileURL } from 'url';
@@ -362,5 +362,5 @@ async function loadDeclaredPluginsOnce(projectDir) {
362
362
  }
363
363
 
364
364
  export { condensePluginFailure, ensurePluginsLoaded, loadDeclaredPlugins, loadPlugins, npmSpecError, pluginFailureReasons, projectRelativeFileSpec, reconcilePlugins, resolveFileSpec, rollbackPluginStore, specName };
365
- //# sourceMappingURL=chunk-TMQFOJ6F.js.map
366
- //# sourceMappingURL=chunk-TMQFOJ6F.js.map
365
+ //# sourceMappingURL=chunk-2PVYDAFN.js.map
366
+ //# sourceMappingURL=chunk-2PVYDAFN.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli/src/plugin-store/paths.ts","../cli/src/plugin-store/spec.ts","../cli/src/plugin-store/load.ts","../cli/src/plugin-store/reconcile.ts","../cli/src/plugin-store/index.ts"],"names":["existsSync","readFileSync","join","resolvePath"],"mappings":";;;;;;;;AAWO,SAAS,WAAW,UAAA,EAA4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store.\n *\n * The store is a self-contained npm workspace owned by the CLI under\n * `<projectDir>/.skaile/plugins/`. Only `resolvePluginEntry` reads the filesystem.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\n/** `<projectDir>/.skaile/plugins` — the store root. */\nexport function pluginsDir(projectDir: string): string {\n return join(projectDir, \".skaile\", \"plugins\");\n}\n\n/** `<store>/package.json` — generated, never user-edited. */\nexport function pluginsPkgJson(projectDir: string): string {\n return join(pluginsDir(projectDir), \"package.json\");\n}\n\n/** `<store>/node_modules` — where reconciled plugin packages land. */\nexport function nodeModulesDir(projectDir: string): string {\n return join(pluginsDir(projectDir), \"node_modules\");\n}\n\n/** `<store>/.reconcile-hash` — SHA of plugins-list + lock slice; skip reinstall when unchanged. */\nexport function reconcileHashFile(projectDir: string): string {\n return join(pluginsDir(projectDir), \".reconcile-hash\");\n}\n\n/** Pick the file an `exports` target points at, preferring the ESM-friendly conditions. */\nfunction exportsTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n if (Array.isArray(target)) {\n for (const t of target) {\n const hit = exportsTarget(t);\n if (hit) return hit;\n }\n return undefined;\n }\n if (target && typeof target === \"object\") {\n const map = target as Record<string, unknown>;\n for (const cond of [\"import\", \"node\", \"default\", \"require\"]) {\n if (cond in map) {\n const hit = exportsTarget(map[cond]);\n if (hit) return hit;\n }\n }\n }\n return undefined;\n}\n\n/**\n * Absolute path to a plugin package's entry file under the store's\n * `node_modules`, resolved from its `package.json` (`exports[\".\"]`, then\n * `module`, then `main`, then `index.js`). Node's ESM loader rejects directory\n * imports, so the entry must be a file; `import()` of the result works inside\n * compiled binaries via `pathToFileURL`.\n *\n * @throws When the package is not installed or declares no resolvable entry.\n */\nexport function resolvePluginEntry(projectDir: string, pkgName: string): string {\n const pkgDir = join(nodeModulesDir(projectDir), pkgName);\n const pkgJsonPath = join(pkgDir, \"package.json\");\n if (!existsSync(pkgJsonPath)) {\n throw new Error(`package \"${pkgName}\" is not installed in ${nodeModulesDir(projectDir)}`);\n }\n const pkg = JSON.parse(readFileSync(pkgJsonPath, \"utf8\")) as {\n exports?: unknown;\n module?: string;\n main?: string;\n };\n let rel: string | undefined;\n if (pkg.exports !== undefined) {\n const root =\n typeof pkg.exports === \"object\" && pkg.exports !== null && !Array.isArray(pkg.exports)\n ? ((pkg.exports as Record<string, unknown>)[\".\"] ?? pkg.exports)\n : pkg.exports;\n rel = exportsTarget(root);\n }\n rel ??= pkg.module ?? pkg.main ?? \"index.js\";\n const entry = resolve(pkgDir, rel);\n if (!existsSync(entry)) {\n throw new Error(`package \"${pkgName}\" entry ${rel} does not exist`);\n }\n return entry;\n}\n","/**\n * Parse npm package specifiers from the `plugins:` list into name + range.\n *\n * The leading `@` of a scope is NOT a separator: the first `@` at a non-zero\n * index splits the package name (which never holds an `@`) from its range, so a\n * range may hold one itself (`foo@npm:bar@1.0.0`, `foo@file:/a@b/dir`).\n * \"@skaile/provider-fly@^0.1.0\" → { name: \"@skaile/provider-fly\", range: \"^0.1.0\" }\n * \"@skaile/connector-redis\" → { name: \"@skaile/connector-redis\", range: \"*\" }\n * \"lodash@^4\" → { name: \"lodash\", range: \"^4\" }\n */\nimport path from \"node:path\";\n\n/** A parsed plugin specifier: package name plus a semver range (`\"*\"` when omitted). */\nexport interface PluginSpec {\n name: string;\n range: string;\n}\n\n/**\n * Parse a single plugin specifier into `{ name, range }`.\n *\n * @param spec - An npm specifier, e.g. `\"@skaile/provider-fly@^0.1.0\"` or `\"lodash\"`.\n * @returns The package name and semver range (range defaults to `\"*\"`).\n * @throws Error when the specifier is empty.\n */\nexport function parseSpec(spec: string): PluginSpec {\n const trimmed = spec.trim();\n if (!trimmed) throw new Error(\"parseSpec: empty specifier\");\n\n // Find the version-separating `@` — the first one that is not the scope `@`\n // at index 0. A bare `@scope/name` has its only `@` at index 0 (no range).\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) {\n return { name: trimmed, range: \"*\" };\n }\n const name = trimmed.slice(0, at);\n const range = trimmed.slice(at + 1);\n return { name, range: range.length > 0 ? range : \"*\" };\n}\n\n/** Convenience: just the package name of a specifier. */\nexport function specName(spec: string): string {\n return parseSpec(spec).name;\n}\n\n/** A package name as the registry and `package.json` keys hold it (legacy uppercase included). */\nconst PACKAGE_NAME = /^(?:@[A-Za-z0-9][A-Za-z0-9._~-]*\\/)?[A-Za-z0-9][A-Za-z0-9._~-]*$/;\n\n/**\n * The refusal for a specifier that does not start with a package name, or `undefined` when it\n * does: `name`, `@scope/name`, or `name@<any range>` (`name@^1`, `name@npm:other@1`,\n * `name@github:user/repo`, `name@git+https://...`, `name@https://...tgz`, `name@file:/abs/dir`).\n * A range may hold a space (`name@>=0.1.0 <1`); an empty range (`name@`) is refused.\n * A bare path, a `file:` URL, a `github:` / `git+` / `https:` source or `user/repo` has no name:\n * the package manager would send it to the registry or key `package.json` by the URL, and fail\n * late (p1737). Such a source is installed under its package name, `<name>@<spec>`.\n */\nexport function npmSpecError(spec: string): string | undefined {\n const trimmed = spec.trim();\n if (trimmed !== \"\" && !/@file:$/i.test(trimmed)) {\n // Only the name is checked for white space (PACKAGE_NAME has none): an npm range may hold a\n // space (`>=0.1.0 <1`) and the package manager takes it as one argument.\n const at = trimmed.indexOf(\"@\", 1);\n const nameEnd = at > 0 ? at : trimmed.length;\n if (PACKAGE_NAME.test(trimmed.slice(0, nameEnd))) {\n if (at > 0 && trimmed.slice(at + 1).trim() === \"\") {\n return (\n `plugin spec '${trimmed}' has an empty version range after '@'. ` +\n `Write ${trimmed.slice(0, at)} for any version, or ${trimmed.slice(0, at)}@<range>, for example @1.2.0.`\n );\n }\n return undefined;\n }\n }\n return (\n `plugin spec '${spec}' is not an npm package name. Give an npm name with an optional version ` +\n \"range, for example @scope/name@1.2.0, or write <name>@<spec> for a git, URL or local source, \" +\n \"for example name@github:user/repo or name@file:/path/to/dir.\"\n );\n}\n\n/** The folder a `file:` range names, or `undefined` for any other spec or an absolute / URL target. */\nfunction relativeFileTarget(spec: string): { head: string; target: string } | undefined {\n const trimmed = spec.trim();\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) return undefined;\n const range = trimmed.slice(at + 1);\n if (!/^file:/i.test(range)) return undefined;\n const target = range.slice(\"file:\".length);\n if (\n target === \"\" ||\n target.startsWith(\"//\") ||\n path.isAbsolute(target) ||\n /^[A-Za-z]:[\\\\/]/.test(target)\n ) {\n return undefined;\n }\n return { head: trimmed.slice(0, at), target };\n}\n\n/**\n * The form of a spec to write into `skaile.yaml`. A relative `file:` range is typed relative to\n * `cwd`; `skaile.yaml` is committed and read on other machines, so it holds the folder relative\n * to the project instead (`name@file:./plugins/x`, `name@file:../x`), never a machine path\n * (p1737). Any other spec is returned as written.\n */\nexport function projectRelativeFileSpec(spec: string, cwd: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n const rel = path.relative(path.resolve(projectDir), path.resolve(cwd, parts.target));\n if (path.isAbsolute(rel)) return `${parts.head}@file:${rel}`;\n const posix = rel.split(path.sep).join(\"/\") || \".\";\n return `${parts.head}@file:${posix.startsWith(\"..\") || posix === \".\" ? posix : `./${posix}`}`;\n}\n\n/**\n * The form of a spec to hand to the package manager. It runs in `.skaile/plugins/`, so a\n * project-relative `file:` range is resolved to an absolute path against `projectDir` here, and\n * only here (p1737). Any other spec is returned as written.\n */\nexport function resolveFileSpec(spec: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n return `${parts.head}@file:${path.resolve(projectDir, parts.target)}`;\n}\n","/**\n * Runtime plugin loader: dynamic-import each reconciled plugin and let it\n * self-register into the `pluginRegistry`.\n *\n * Each plugin specifier resolves to an absolute path under the store's\n * `node_modules`; we import it via a `file://` URL so the import works inside\n * `bun --compile` binaries (which bundle only the literal-string switches, but\n * can still execute a `file://` import against the unpacked store on disk).\n * Failures are caught per-plugin so one broken plugin never aborts the rest.\n */\n\nimport { pathToFileURL } from \"node:url\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport { resolvePluginEntry } from \"./paths.js\";\nimport { parseSpec } from \"./spec.js\";\n\n/** Options for {@link loadPlugins}. */\nexport interface LoadOptions {\n log?: Logger;\n}\n\n/** Result of a load pass: which specs registered and which failed. */\nexport interface LoadResult {\n loaded: string[];\n failed: { spec: string; error: string; reason: string }[];\n}\n\n/** The self-registration entrypoint a plugin module is expected to export. */\ntype PluginModule = { register?: (registry: PluginRegistry) => void };\n\n/**\n * Load and register each plugin in `plugins` into `registry`.\n *\n * @param projectDir - Project root holding `.skaile/plugins/node_modules`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param registry - Registry to register into. Defaults to the process-wide `pluginRegistry`.\n * @param opts - Optional logger.\n * @returns Loaded specs + per-plugin failures (never throws).\n */\nexport async function loadPlugins(\n projectDir: string,\n plugins: string[],\n registry: PluginRegistry = pluginRegistry,\n opts: LoadOptions = {},\n): Promise<LoadResult> {\n const loaded: string[] = [];\n const failed: { spec: string; error: string; reason: string }[] = [];\n\n for (const spec of plugins) {\n try {\n const { name } = parseSpec(spec);\n const entry = resolvePluginEntry(projectDir, name);\n const mod = (await import(pathToFileURL(entry).href)) as PluginModule;\n if (typeof mod.register !== \"function\") {\n throw new Error(`plugin \"${name}\" does not export a register() function`);\n }\n mod.register(registry);\n loaded.push(spec);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n failed.push({ spec, error: `failed to load plugin \"${spec}\": ${message}`, reason: message });\n opts.log?.warn(`plugin load failed: ${spec}`, { error: message });\n }\n }\n\n return { loaded, failed };\n}\n","/**\n * Reconcile the project-local plugin store (`<projectDir>/.skaile/plugins/`).\n *\n * The reconciler is hash-skipped: it computes a SHA-256 over the sorted plugin\n * list plus the lock file's `plugins` slice and compares it to the stored\n * `.reconcile-hash`. On a match it returns with zero further I/O; otherwise it\n * regenerates the store's `package.json` and runs `bun install` against it.\n *\n * The install step is injectable (`InstallFn`) so tests stay hermetic — they\n * pass a fake installer that records calls and writes a stub `node_modules`.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPluginsLockSlice } from \"@skaile/workspaces/core\";\nimport { nodeModulesDir, pluginsDir, pluginsPkgJson, reconcileHashFile } from \"./paths.js\";\nimport { parseSpec, resolveFileSpec } from \"./spec.js\";\n\n/** How `InstallFn` may treat the store's lock: `frozen` forbids lock changes. */\nexport interface InstallOptions {\n /**\n * `false` when the spec list changed since the last `package.json`, so the\n * lock has to change too. Defaults to `true` (frozen when a lock exists).\n */\n frozen?: boolean;\n}\n\n/**\n * Installs the store's dependencies. Returns `ok: false` (never throws) on a\n * failed install so the reconciler can surface the captured `output`.\n */\nexport type InstallFn = (\n pluginsDir: string,\n opts?: InstallOptions,\n) => Promise<{ ok: boolean; output: string }>;\n\n/** Options for {@link reconcilePlugins}. */\nexport interface ReconcileOptions {\n /** Injectable installer. Defaults to a real `bun install` of the store. */\n runInstall?: InstallFn;\n /**\n * Lock slice to fold into the reconcile-hash. Defaults to\n * `readPluginsLockSlice(projectDir)` so a lock edit invalidates the hash.\n */\n lockSlice?: unknown;\n}\n\n/** Result of a reconcile pass. */\nexport interface ReconcileResult {\n changed: boolean;\n reason: \"no-plugins\" | \"up-to-date\" | \"reconciled\";\n}\n\n/** Run a command to completion, capturing stdout+stderr. `started: false` when it cannot spawn. */\nasync function runCapture(\n args: string[],\n cwd: string,\n): Promise<{ started: boolean; code: number; output: string }> {\n const { portableSpawn } = await import(\"@skaile/workspaces/core\");\n const proc = portableSpawn(args, { cwd });\n const chunks: string[] = [];\n const decoder = new TextDecoder();\n const pump = async (stream: ReadableStream<Uint8Array>) => {\n const reader = stream.getReader();\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n if (value) chunks.push(decoder.decode(value, { stream: true }));\n }\n };\n await Promise.all([pump(proc.stdout), pump(proc.stderr)]);\n const code = await proc.exited;\n // `portableSpawn` reports a spawn error (ENOENT) as exit -1 with no pid.\n return { started: proc.pid !== -1, code, output: chunks.join(\"\") };\n}\n\n/**\n * The default real installer: `bun install` inside the store directory, or\n * `npm install` when `bun` is not on PATH. Frozen only when a lock exists and\n * the spec list did not change (`opts.frozen !== false`): a changed list has to\n * rewrite the lock, which a frozen install refuses.\n */\nexport const defaultInstall: InstallFn = async (dir, opts = {}) => {\n const hasBunLock = existsSync(`${dir}/bun.lock`) || existsSync(`${dir}/bun.lockb`);\n const hasNpmLock = existsSync(`${dir}/package-lock.json`);\n const frozen = opts.frozen !== false;\n\n const bunArgs =\n frozen && (hasBunLock || hasNpmLock)\n ? [\"bun\", \"install\", \"--frozen-lockfile\"]\n : [\"bun\", \"install\"];\n const withBun = await runCapture(bunArgs, dir);\n if (withBun.started) return { ok: withBun.code === 0, output: withBun.output };\n\n const npmArgs =\n frozen && hasNpmLock\n ? [\"npm\", \"ci\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"]\n : [\"npm\", \"install\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"];\n const withNpm = await runCapture(npmArgs, dir);\n if (withNpm.started) return { ok: withNpm.code === 0, output: withNpm.output };\n return {\n ok: false,\n output:\n \"neither bun nor npm found on PATH; plugin install needs one of them (https://bun.sh or https://nodejs.org)\",\n };\n};\n\n/**\n * Generate the store's `package.json` from the plugin specs. Returns the\n * previous file content (`undefined` when there was none) and whether the\n * dependency set changed.\n */\nfunction writePackageJson(\n projectDir: string,\n plugins: string[],\n): { previous: string | undefined; depsChanged: boolean; removedDep: boolean } {\n const dependencies: Record<string, string> = {};\n for (const spec of plugins) {\n const { name, range } = parseSpec(resolveFileSpec(spec, projectDir));\n dependencies[name] = range;\n }\n const pkg = {\n name: \"skaile-project-plugins\",\n private: true,\n dependencies,\n };\n const file = pluginsPkgJson(projectDir);\n const previous = existsSync(file) ? readFileSync(file, \"utf8\") : undefined;\n let before: Record<string, string> | undefined;\n try {\n before = previous === undefined ? undefined : JSON.parse(previous).dependencies;\n } catch {\n before = undefined;\n }\n const sortedJson = (d: Record<string, string> | undefined) =>\n JSON.stringify(Object.entries(d ?? {}).sort(([a], [b]) => a.localeCompare(b)));\n const depsChanged = before === undefined || sortedJson(before) !== sortedJson(dependencies);\n // A plugin the list no longer names: the package manager prunes a registry package, but not a\n // `file:` one and not what a failed install left, so the caller rebuilds `node_modules`.\n const removedDep = Object.keys(before ?? {}).some((name) => !(name in dependencies));\n mkdirSync(pluginsDir(projectDir), { recursive: true });\n writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\\n`);\n return { previous, depsChanged, removedDep };\n}\n\n/** Whether `node_modules` holds a `package.json` for every declared plugin (by package name). */\nfunction allPluginsInstalled(projectDir: string, plugins: string[]): boolean {\n return plugins.every((spec) => {\n const { name } = parseSpec(resolveFileSpec(spec, projectDir));\n return existsSync(join(nodeModulesDir(projectDir), name, \"package.json\"));\n });\n}\n\n/**\n * Reconcile the plugin store for a project.\n *\n * @param projectDir - Project root containing `skaile.yaml` / `skaile.lock.yaml`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param opts - Optional injectable installer + lock slice override.\n * @returns Whether the store changed and why.\n */\nexport async function reconcilePlugins(\n projectDir: string,\n plugins: string[],\n opts: ReconcileOptions = {},\n): Promise<ReconcileResult> {\n if (plugins.length === 0) {\n return { changed: false, reason: \"no-plugins\" };\n }\n\n const lockSlice = opts.lockSlice ?? readPluginsLockSlice(projectDir);\n const wantHash = createHash(\"sha256\")\n .update(\n JSON.stringify({\n plugins: plugins.map((spec) => resolveFileSpec(spec, projectDir)).sort(),\n lock: lockSlice,\n }),\n )\n .digest(\"hex\");\n\n const hashFile = reconcileHashFile(projectDir);\n if (existsSync(hashFile)) {\n const have = readFileSync(hashFile, \"utf8\").trim();\n // The hash only says what was installed where it was written. A clone or a copied store comes\n // with the hash but without `node_modules`; trust the hash only while every declared package\n // is on disk.\n if (have === wantHash && allPluginsInstalled(projectDir, plugins)) {\n return { changed: false, reason: \"up-to-date\" };\n }\n }\n\n const { previous, depsChanged, removedDep } = writePackageJson(projectDir, plugins);\n if (removedDep) rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n\n const install = opts.runInstall ?? defaultInstall;\n const result = await install(pluginsDir(projectDir), { frozen: !depsChanged });\n if (!result.ok) {\n // A failed install must not leave the spec behind: the next reconcile\n // would compare against it and treat the store as already changed.\n if (previous === undefined) rmSync(pluginsPkgJson(projectDir), { force: true });\n else writeFileSync(pluginsPkgJson(projectDir), previous);\n throw new Error(`plugin install failed:\\n${result.output}`);\n }\n\n writeFileSync(hashFile, wantHash);\n return { changed: true, reason: \"reconciled\" };\n}\n\n/**\n * Put the store back to `previousPlugins` after `plugin install` failed past\n * the reconcile (the plugin installed but does not load). Best effort: a\n * failing reinstall is swallowed, the store is then rebuilt by the next\n * reconcile because the hash no longer matches the declared list.\n *\n * With no previous plugins every generated file of the store goes away\n * (`package.json`, hash, lock file and `node_modules`), so the store keeps\n * neither the rejected spec nor its installed package.\n */\nexport async function rollbackPluginStore(\n projectDir: string,\n previousPlugins: string[],\n opts: ReconcileOptions = {},\n): Promise<void> {\n if (previousPlugins.length === 0) {\n const dir = pluginsDir(projectDir);\n rmSync(pluginsPkgJson(projectDir), { force: true });\n rmSync(reconcileHashFile(projectDir), { force: true });\n rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n for (const lock of [\"bun.lock\", \"bun.lockb\", \"package-lock.json\"]) {\n rmSync(join(dir, lock), { force: true });\n }\n try {\n // The folder goes when nothing else of the user's is in it.\n rmdirSync(dir);\n } catch {\n // not empty, or already gone\n }\n return;\n }\n try {\n await reconcilePlugins(projectDir, previousPlugins, opts);\n } catch {\n // the next reconcile retries\n }\n}\n","/**\n * The project-local plugin store: reconcile (`<projectDir>/.skaile/plugins/`)\n * then load the reconciled plugins into the `pluginRegistry`.\n *\n * `ensurePluginsLoaded` is the single entrypoint commands wire in. It is a\n * guarded no-op when `plugins` is empty/undefined — zero overhead for the\n * common case where no project declares `plugins:` in `skaile.yaml`.\n */\n\nimport { resolve as resolvePath } from \"node:path\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport pc from \"picocolors\";\nimport { type LoadResult, loadPlugins } from \"./load.js\";\nimport { type ReconcileOptions, reconcilePlugins } from \"./reconcile.js\";\nimport { specName } from \"./spec.js\";\n\nexport type { LoadResult } from \"./load.js\";\nexport { loadPlugins } from \"./load.js\";\nexport type { ReconcileOptions } from \"./reconcile.js\";\nexport { reconcilePlugins, rollbackPluginStore } from \"./reconcile.js\";\nexport { npmSpecError, projectRelativeFileSpec, resolveFileSpec, specName } from \"./spec.js\";\n\n/** Options for {@link ensurePluginsLoaded}. */\nexport interface EnsurePluginsOptions extends ReconcileOptions {\n log?: Logger;\n}\n\n/**\n * Reconcile the plugin store then load each plugin into `registry`.\n *\n * No-op (returns immediately) when `plugins` is empty/undefined, so the common\n * no-plugins path costs nothing.\n *\n * @param projectDir - Project root.\n * @param plugins - The `skaile.yaml` `plugins:` list (may be undefined).\n * @param registry - Registry to register into. Defaults to `pluginRegistry`.\n * @param opts - Injectable installer / lock slice + optional logger.\n * @returns The load result, or an empty result when there are no plugins.\n */\nexport async function ensurePluginsLoaded(\n projectDir: string,\n plugins: string[] | undefined,\n registry: PluginRegistry = pluginRegistry,\n opts: EnsurePluginsOptions = {},\n): Promise<LoadResult> {\n if (!plugins || plugins.length === 0) {\n return { loaded: [], failed: [] };\n }\n await reconcilePlugins(projectDir, plugins, opts);\n return loadPlugins(projectDir, plugins, registry, { log: opts.log });\n}\n\n/**\n * The installer's output of a failed `plugin install` is a dump (bun's banner, resolver\n * progress, then the `error:` lines). A load warning keeps the first line and the cause of it\n * (p1113); `skaile plugin install <spec>` prints the whole output.\n *\n * bun: the last `error:` line. npm: its `code` line and the first detail line after it\n * (`E404: 404 Not Found - GET …`), never the trailing `A complete log of this run can be found\n * in: …` pointer (p1272).\n */\nexport function condensePluginFailure(reason: string): string {\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\");\n const [first, ...rest] = lines;\n if (!reason.startsWith(\"plugin install failed\") || first === undefined || rest.length === 0) {\n return reason;\n }\n const head = first.replace(/:$/, \"\");\n const npmPrefix = /^npm (ERR!|error)\\s*/i;\n const npmLines = rest\n .filter((l) => npmPrefix.test(l) && !/^npm \\S+\\s+A complete log of this run\\b/i.test(l))\n .map((l) => l.replace(npmPrefix, \"\"))\n .filter((l) => l !== \"\");\n const codeLine = npmLines.find((l) => /^code\\s+\\S+/i.test(l));\n if (codeLine) {\n const code = codeLine.replace(/^code\\s+/i, \"\");\n const detail = npmLines.find((l) => l !== codeLine && !/^code\\s/i.test(l));\n return `${head}: npm ${code}${detail ? `: ${detail}` : \"\"}`;\n }\n const causes = rest.filter(\n (l) => /^error\\b/i.test(l) || (npmPrefix.test(l) && !/A complete log of this run\\b/i.test(l)),\n );\n const cause =\n causes.at(-1) ?? rest.filter((l) => !/A complete log of this run\\b/i.test(l)).at(-1);\n return `${head}: ${cause ?? rest.at(-1)}`;\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\/]/g, \"\\\\$&\");\n}\n\n/**\n * Split the output of one failed install of the whole plugin store into one reason per plugin\n * (p1272): the package manager runs once for every spec, so its output names the plugins that\n * failed. A plugin gets the line that names it (also its URL-encoded form `@scope%2fname`); a\n * plugin the output never names says it was not installed and which plugin the install stopped\n * at. With one plugin, or when the output names none (no `bun` and no `npm`), every plugin keeps\n * the whole condensed reason.\n */\nexport function pluginFailureReasons(\n reason: string,\n specs: readonly string[],\n): Map<string, string> {\n const out = new Map<string, string>();\n const condensed = condensePluginFailure(reason);\n if (specs.length < 2 || !reason.startsWith(\"plugin install failed\")) return out;\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\" && !/A complete log of this run\\b/i.test(l));\n const names = specs.map((spec) => {\n try {\n return specName(spec);\n } catch {\n return spec;\n }\n });\n const mentions = (text: string, name: string): boolean => {\n const forms = [name, name.replace(\"/\", \"%2f\"), name.replace(\"/\", \"%2F\")];\n return forms.some((f) =>\n new RegExp(`(?<![\\\\w@.-])(?<!@[\\\\w.~-]+/)${escapeRegExp(f)}(?![\\\\w-]|\\\\.\\\\w)`).test(text),\n );\n };\n const cause = /\\berror\\b|\\bE[A-Z0-9]{3,}\\b|\\b404\\b|notarget|failed to resolve/i;\n const named: string[] = [];\n specs.forEach((spec, i) => {\n const name = names[i] as string;\n const line = mentions(condensed, name)\n ? condensed.replace(/^plugin install failed:\\s*/, \"\")\n : lines.filter((l) => mentions(l, name) && cause.test(l)).at(-1);\n if (line === undefined) return;\n named.push(name);\n out.set(spec, `plugin install failed: ${line.replace(/^(npm\\s+)?(ERR!|error:?)\\s*/i, \"\")}`);\n });\n if (named.length === 0) return new Map();\n specs.forEach((spec, i) => {\n if (!out.has(spec)) {\n out.set(\n spec,\n `plugin install failed: ${names[i]} was not installed, the install stopped at ${named.join(\", \")}`,\n );\n }\n });\n return out;\n}\n\n/** One `! plugin <name> failed to load: <reason>` line on stderr (stdout carries a run's answer). */\nfunction warnPluginFailed(spec: string, reason: string): void {\n let name = spec;\n try {\n name = specName(spec);\n } catch {\n /* a spec that does not parse is named as written */\n }\n process.stderr.write(\n ` ${pc.yellow(\"!\")} plugin ${name} failed to load: ${condensePluginFailure(reason)}\\n`,\n );\n}\n\n/**\n * Reconcile + load the `plugins:` of the project's `skaile.yaml` into the process registry, so a\n * plugin's harness is known to `run`, `repl` and `config set harness`. A plugin that fails to\n * reconcile or load is skipped (its harness stays unknown, the command goes on) and named in one\n * `! plugin <name> failed to load: <reason>` line on stderr. An unreadable config is not this\n * function's to report: the command reads it again and says so.\n */\nexport function loadDeclaredPlugins(projectDir: string): Promise<void> {\n // A plugin registers once per process: a second `register()` is a duplicate.\n const key = resolvePath(projectDir);\n let pending = declaredPluginLoads.get(key);\n if (!pending) {\n pending = loadDeclaredPluginsOnce(projectDir);\n declaredPluginLoads.set(key, pending);\n }\n return pending;\n}\n\nconst declaredPluginLoads = new Map<string, Promise<void>>();\n\nasync function loadDeclaredPluginsOnce(projectDir: string): Promise<void> {\n let plugins: string[] | undefined;\n try {\n const { resolveSkWorkspaceConfig } = await import(\"@skaile/workspaces/core\");\n plugins = resolveSkWorkspaceConfig(projectDir).plugins;\n } catch {\n return;\n }\n if (!plugins || plugins.length === 0) return;\n try {\n const result = await ensurePluginsLoaded(projectDir, plugins, pluginRegistry);\n for (const f of result.failed) warnPluginFailed(f.spec, f.reason);\n } catch (err) {\n // The store could not be reconciled: no plugin was loaded.\n const reason = err instanceof Error ? err.message : String(err);\n const reasons = pluginFailureReasons(reason, plugins);\n for (const spec of plugins) warnPluginFailed(spec, reasons.get(spec) ?? reason);\n }\n}\n"]}
1
+ {"version":3,"sources":["../cli/src/plugin-store/paths.ts","../cli/src/plugin-store/spec.ts","../cli/src/plugin-store/load.ts","../cli/src/plugin-store/reconcile.ts","../cli/src/plugin-store/index.ts"],"names":["existsSync","readFileSync","join","resolvePath"],"mappings":";;;;;;;;AAWO,SAAS,WAAW,UAAA,EAA4B;AACrD,EAAA,OAAO,IAAA,CAAK,UAAA,EAAY,SAAA,EAAW,SAAS,CAAA;AAC9C;AAGO,SAAS,eAAe,UAAA,EAA4B;AACzD,EAAA,OAAO,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,EAAG,cAAc,CAAA;AACpD;AAGO,SAAS,eAAe,UAAA,EAA4B;AACzD,EAAA,OAAO,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,EAAG,cAAc,CAAA;AACpD;AAGO,SAAS,kBAAkB,UAAA,EAA4B;AAC5D,EAAA,OAAO,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,EAAG,iBAAiB,CAAA;AACvD;AAGA,SAAS,cAAc,MAAA,EAAqC;AAC1D,EAAA,IAAI,OAAO,MAAA,KA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AA,OAAA,GAAU,wBAAA,CAAyB,UAAU,CAAA,CAAE,OAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA;AAAA,EACF;AACA,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG;AACtC,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,MAAM,mBAAA,CAAoB,UAAA,EAAY,SAAS,cAAc,CAAA;AAC5E,IAAA,KAAA,MAAW,KAAK,MAAA,CAAO,MAAA,mBAAyB,CAAA,CAAE,IAAA,EAAM,EAAE,MAAM,CAAA;AAAA,EAClE,SAAS,GAAA,EAAK;AAEZ,IAAA,MAAM,SAAS,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,OAAO,GAAG,CAAA;AAC9D,IAAA,MAAM,OAAA,GAAU,oBAAA,CAAqB,MAAA,EAAQ,OAAO,CAAA;AACpD,IAAA,KAAA,MAAW,IAAA,IAAQ,SAAS,gBAAA,CAAiB,IAAA,EAAM,QAAQ,GAAA,CAAI,IAAI,KAAK,MAAM,CAAA;AAAA,EAChF;AACF","file":"chunk-2PVYDAFN.js","sourcesContent":["/**\n * Pure path helpers for the project-local plugin store.\n *\n * The store is a self-contained npm workspace owned by the CLI under\n * `<projectDir>/.skaile/plugins/`. Only `resolvePluginEntry` reads the filesystem.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\n/** `<projectDir>/.skaile/plugins` — the store root. */\nexport function pluginsDir(projectDir: string): string {\n return join(projectDir, \".skaile\", \"plugins\");\n}\n\n/** `<store>/package.json` — generated, never user-edited. */\nexport function pluginsPkgJson(projectDir: string): string {\n return join(pluginsDir(projectDir), \"package.json\");\n}\n\n/** `<store>/node_modules` — where reconciled plugin packages land. */\nexport function nodeModulesDir(projectDir: string): string {\n return join(pluginsDir(projectDir), \"node_modules\");\n}\n\n/** `<store>/.reconcile-hash` — SHA of plugins-list + lock slice; skip reinstall when unchanged. */\nexport function reconcileHashFile(projectDir: string): string {\n return join(pluginsDir(projectDir), \".reconcile-hash\");\n}\n\n/** Pick the file an `exports` target points at, preferring the ESM-friendly conditions. */\nfunction exportsTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n if (Array.isArray(target)) {\n for (const t of target) {\n const hit = exportsTarget(t);\n if (hit) return hit;\n }\n return undefined;\n }\n if (target && typeof target === \"object\") {\n const map = target as Record<string, unknown>;\n for (const cond of [\"import\", \"node\", \"default\", \"require\"]) {\n if (cond in map) {\n const hit = exportsTarget(map[cond]);\n if (hit) return hit;\n }\n }\n }\n return undefined;\n}\n\n/**\n * Absolute path to a plugin package's entry file under the store's\n * `node_modules`, resolved from its `package.json` (`exports[\".\"]`, then\n * `module`, then `main`, then `index.js`). Node's ESM loader rejects directory\n * imports, so the entry must be a file; `import()` of the result works inside\n * compiled binaries via `pathToFileURL`.\n *\n * @throws When the package is not installed or declares no resolvable entry.\n */\nexport function resolvePluginEntry(projectDir: string, pkgName: string): string {\n const pkgDir = join(nodeModulesDir(projectDir), pkgName);\n const pkgJsonPath = join(pkgDir, \"package.json\");\n if (!existsSync(pkgJsonPath)) {\n throw new Error(`package \"${pkgName}\" is not installed in ${nodeModulesDir(projectDir)}`);\n }\n const pkg = JSON.parse(readFileSync(pkgJsonPath, \"utf8\")) as {\n exports?: unknown;\n module?: string;\n main?: string;\n };\n let rel: string | undefined;\n if (pkg.exports !== undefined) {\n const root =\n typeof pkg.exports === \"object\" && pkg.exports !== null && !Array.isArray(pkg.exports)\n ? ((pkg.exports as Record<string, unknown>)[\".\"] ?? pkg.exports)\n : pkg.exports;\n rel = exportsTarget(root);\n }\n rel ??= pkg.module ?? pkg.main ?? \"index.js\";\n const entry = resolve(pkgDir, rel);\n if (!existsSync(entry)) {\n throw new Error(`package \"${pkgName}\" entry ${rel} does not exist`);\n }\n return entry;\n}\n","/**\n * Parse npm package specifiers from the `plugins:` list into name + range.\n *\n * The leading `@` of a scope is NOT a separator: the first `@` at a non-zero\n * index splits the package name (which never holds an `@`) from its range, so a\n * range may hold one itself (`foo@npm:bar@1.0.0`, `foo@file:/a@b/dir`).\n * \"@skaile/provider-fly@^0.1.0\" → { name: \"@skaile/provider-fly\", range: \"^0.1.0\" }\n * \"@skaile/connector-redis\" → { name: \"@skaile/connector-redis\", range: \"*\" }\n * \"lodash@^4\" → { name: \"lodash\", range: \"^4\" }\n */\nimport path from \"node:path\";\n\n/** A parsed plugin specifier: package name plus a semver range (`\"*\"` when omitted). */\nexport interface PluginSpec {\n name: string;\n range: string;\n}\n\n/**\n * Parse a single plugin specifier into `{ name, range }`.\n *\n * @param spec - An npm specifier, e.g. `\"@skaile/provider-fly@^0.1.0\"` or `\"lodash\"`.\n * @returns The package name and semver range (range defaults to `\"*\"`).\n * @throws Error when the specifier is empty.\n */\nexport function parseSpec(spec: string): PluginSpec {\n const trimmed = spec.trim();\n if (!trimmed) throw new Error(\"parseSpec: empty specifier\");\n\n // Find the version-separating `@` — the first one that is not the scope `@`\n // at index 0. A bare `@scope/name` has its only `@` at index 0 (no range).\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) {\n return { name: trimmed, range: \"*\" };\n }\n const name = trimmed.slice(0, at);\n const range = trimmed.slice(at + 1);\n return { name, range: range.length > 0 ? range : \"*\" };\n}\n\n/** Convenience: just the package name of a specifier. */\nexport function specName(spec: string): string {\n return parseSpec(spec).name;\n}\n\n/** A package name as the registry and `package.json` keys hold it (legacy uppercase included). */\nconst PACKAGE_NAME = /^(?:@[A-Za-z0-9][A-Za-z0-9._~-]*\\/)?[A-Za-z0-9][A-Za-z0-9._~-]*$/;\n\n/**\n * The refusal for a specifier that does not start with a package name, or `undefined` when it\n * does: `name`, `@scope/name`, or `name@<any range>` (`name@^1`, `name@npm:other@1`,\n * `name@github:user/repo`, `name@git+https://...`, `name@https://...tgz`, `name@file:/abs/dir`).\n * A range may hold a space (`name@>=0.1.0 <1`); an empty range (`name@`) is refused.\n * A bare path, a `file:` URL, a `github:` / `git+` / `https:` source or `user/repo` has no name:\n * the package manager would send it to the registry or key `package.json` by the URL, and fail\n * late (p1737). Such a source is installed under its package name, `<name>@<spec>`.\n */\nexport function npmSpecError(spec: string): string | undefined {\n const trimmed = spec.trim();\n if (trimmed !== \"\" && !/@file:$/i.test(trimmed)) {\n // Only the name is checked for white space (PACKAGE_NAME has none): an npm range may hold a\n // space (`>=0.1.0 <1`) and the package manager takes it as one argument.\n const at = trimmed.indexOf(\"@\", 1);\n const nameEnd = at > 0 ? at : trimmed.length;\n if (PACKAGE_NAME.test(trimmed.slice(0, nameEnd))) {\n if (at > 0 && trimmed.slice(at + 1).trim() === \"\") {\n return (\n `plugin spec '${trimmed}' has an empty version range after '@'. ` +\n `Write ${trimmed.slice(0, at)} for any version, or ${trimmed.slice(0, at)}@<range>, for example @1.2.0.`\n );\n }\n return undefined;\n }\n }\n return (\n `plugin spec '${spec}' is not an npm package name. Give an npm name with an optional version ` +\n \"range, for example @scope/name@1.2.0, or write <name>@<spec> for a git, URL or local source, \" +\n \"for example name@github:user/repo or name@file:/path/to/dir.\"\n );\n}\n\n/** The folder a `file:` range names, or `undefined` for any other spec or an absolute / URL target. */\nfunction relativeFileTarget(spec: string): { head: string; target: string } | undefined {\n const trimmed = spec.trim();\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) return undefined;\n const range = trimmed.slice(at + 1);\n if (!/^file:/i.test(range)) return undefined;\n const target = range.slice(\"file:\".length);\n if (\n target === \"\" ||\n target.startsWith(\"//\") ||\n path.isAbsolute(target) ||\n /^[A-Za-z]:[\\\\/]/.test(target)\n ) {\n return undefined;\n }\n return { head: trimmed.slice(0, at), target };\n}\n\n/**\n * The form of a spec to write into `skaile.yaml`. A relative `file:` range is typed relative to\n * `cwd`; `skaile.yaml` is committed and read on other machines, so it holds the folder relative\n * to the project instead (`name@file:./plugins/x`, `name@file:../x`), never a machine path\n * (p1737). Any other spec is returned as written.\n */\nexport function projectRelativeFileSpec(spec: string, cwd: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n const rel = path.relative(path.resolve(projectDir), path.resolve(cwd, parts.target));\n if (path.isAbsolute(rel)) return `${parts.head}@file:${rel}`;\n const posix = rel.split(path.sep).join(\"/\") || \".\";\n return `${parts.head}@file:${posix.startsWith(\"..\") || posix === \".\" ? posix : `./${posix}`}`;\n}\n\n/**\n * The form of a spec to hand to the package manager. It runs in `.skaile/plugins/`, so a\n * project-relative `file:` range is resolved to an absolute path against `projectDir` here, and\n * only here (p1737). Any other spec is returned as written.\n */\nexport function resolveFileSpec(spec: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n return `${parts.head}@file:${path.resolve(projectDir, parts.target)}`;\n}\n","/**\n * Runtime plugin loader: dynamic-import each reconciled plugin and let it\n * self-register into the `pluginRegistry`.\n *\n * Each plugin specifier resolves to an absolute path under the store's\n * `node_modules`; we import it via a `file://` URL so the import works inside\n * `bun --compile` binaries (which bundle only the literal-string switches, but\n * can still execute a `file://` import against the unpacked store on disk).\n * Failures are caught per-plugin so one broken plugin never aborts the rest.\n */\n\nimport { pathToFileURL } from \"node:url\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport { resolvePluginEntry } from \"./paths.js\";\nimport { parseSpec } from \"./spec.js\";\n\n/** Options for {@link loadPlugins}. */\nexport interface LoadOptions {\n log?: Logger;\n}\n\n/** Result of a load pass: which specs registered and which failed. */\nexport interface LoadResult {\n loaded: string[];\n failed: { spec: string; error: string; reason: string }[];\n}\n\n/** The self-registration entrypoint a plugin module is expected to export. */\ntype PluginModule = { register?: (registry: PluginRegistry) => void };\n\n/**\n * Load and register each plugin in `plugins` into `registry`.\n *\n * @param projectDir - Project root holding `.skaile/plugins/node_modules`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param registry - Registry to register into. Defaults to the process-wide `pluginRegistry`.\n * @param opts - Optional logger.\n * @returns Loaded specs + per-plugin failures (never throws).\n */\nexport async function loadPlugins(\n projectDir: string,\n plugins: string[],\n registry: PluginRegistry = pluginRegistry,\n opts: LoadOptions = {},\n): Promise<LoadResult> {\n const loaded: string[] = [];\n const failed: { spec: string; error: string; reason: string }[] = [];\n\n for (const spec of plugins) {\n try {\n const { name } = parseSpec(spec);\n const entry = resolvePluginEntry(projectDir, name);\n const mod = (await import(pathToFileURL(entry).href)) as PluginModule;\n if (typeof mod.register !== \"function\") {\n throw new Error(`plugin \"${name}\" does not export a register() function`);\n }\n mod.register(registry);\n loaded.push(spec);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n failed.push({ spec, error: `failed to load plugin \"${spec}\": ${message}`, reason: message });\n opts.log?.warn(`plugin load failed: ${spec}`, { error: message });\n }\n }\n\n return { loaded, failed };\n}\n","/**\n * Reconcile the project-local plugin store (`<projectDir>/.skaile/plugins/`).\n *\n * The reconciler is hash-skipped: it computes a SHA-256 over the sorted plugin\n * list plus the lock file's `plugins` slice and compares it to the stored\n * `.reconcile-hash`. On a match it returns with zero further I/O; otherwise it\n * regenerates the store's `package.json` and runs `bun install` against it.\n *\n * The install step is injectable (`InstallFn`) so tests stay hermetic — they\n * pass a fake installer that records calls and writes a stub `node_modules`.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPluginsLockSlice } from \"@skaile/workspaces/core\";\nimport { nodeModulesDir, pluginsDir, pluginsPkgJson, reconcileHashFile } from \"./paths.js\";\nimport { parseSpec, resolveFileSpec } from \"./spec.js\";\n\n/** How `InstallFn` may treat the store's lock: `frozen` forbids lock changes. */\nexport interface InstallOptions {\n /**\n * `false` when the spec list changed since the last `package.json`, so the\n * lock has to change too. Defaults to `true` (frozen when a lock exists).\n */\n frozen?: boolean;\n}\n\n/**\n * Installs the store's dependencies. Returns `ok: false` (never throws) on a\n * failed install so the reconciler can surface the captured `output`.\n */\nexport type InstallFn = (\n pluginsDir: string,\n opts?: InstallOptions,\n) => Promise<{ ok: boolean; output: string }>;\n\n/** Options for {@link reconcilePlugins}. */\nexport interface ReconcileOptions {\n /** Injectable installer. Defaults to a real `bun install` of the store. */\n runInstall?: InstallFn;\n /**\n * Lock slice to fold into the reconcile-hash. Defaults to\n * `readPluginsLockSlice(projectDir)` so a lock edit invalidates the hash.\n */\n lockSlice?: unknown;\n}\n\n/** Result of a reconcile pass. */\nexport interface ReconcileResult {\n changed: boolean;\n reason: \"no-plugins\" | \"up-to-date\" | \"reconciled\";\n}\n\n/** Run a command to completion, capturing stdout+stderr. `started: false` when it cannot spawn. */\nasync function runCapture(\n args: string[],\n cwd: string,\n): Promise<{ started: boolean; code: number; output: string }> {\n const { portableSpawn } = await import(\"@skaile/workspaces/core\");\n const proc = portableSpawn(args, { cwd });\n const chunks: string[] = [];\n const decoder = new TextDecoder();\n const pump = async (stream: ReadableStream<Uint8Array>) => {\n const reader = stream.getReader();\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n if (value) chunks.push(decoder.decode(value, { stream: true }));\n }\n };\n await Promise.all([pump(proc.stdout), pump(proc.stderr)]);\n const code = await proc.exited;\n // `portableSpawn` reports a spawn error (ENOENT) as exit -1 with no pid.\n return { started: proc.pid !== -1, code, output: chunks.join(\"\") };\n}\n\n/**\n * The default real installer: `bun install` inside the store directory, or\n * `npm install` when `bun` is not on PATH. Frozen only when a lock exists and\n * the spec list did not change (`opts.frozen !== false`): a changed list has to\n * rewrite the lock, which a frozen install refuses.\n */\nexport const defaultInstall: InstallFn = async (dir, opts = {}) => {\n const hasBunLock = existsSync(`${dir}/bun.lock`) || existsSync(`${dir}/bun.lockb`);\n const hasNpmLock = existsSync(`${dir}/package-lock.json`);\n const frozen = opts.frozen !== false;\n\n const bunArgs =\n frozen && (hasBunLock || hasNpmLock)\n ? [\"bun\", \"install\", \"--frozen-lockfile\"]\n : [\"bun\", \"install\"];\n const withBun = await runCapture(bunArgs, dir);\n if (withBun.started) return { ok: withBun.code === 0, output: withBun.output };\n\n const npmArgs =\n frozen && hasNpmLock\n ? [\"npm\", \"ci\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"]\n : [\"npm\", \"install\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"];\n const withNpm = await runCapture(npmArgs, dir);\n if (withNpm.started) return { ok: withNpm.code === 0, output: withNpm.output };\n return {\n ok: false,\n output:\n \"neither bun nor npm found on PATH; plugin install needs one of them (https://bun.sh or https://nodejs.org)\",\n };\n};\n\n/**\n * Generate the store's `package.json` from the plugin specs. Returns the\n * previous file content (`undefined` when there was none) and whether the\n * dependency set changed.\n */\nfunction writePackageJson(\n projectDir: string,\n plugins: string[],\n): { previous: string | undefined; depsChanged: boolean; removedDep: boolean } {\n const dependencies: Record<string, string> = {};\n for (const spec of plugins) {\n const { name, range } = parseSpec(resolveFileSpec(spec, projectDir));\n dependencies[name] = range;\n }\n const pkg = {\n name: \"skaile-project-plugins\",\n private: true,\n dependencies,\n };\n const file = pluginsPkgJson(projectDir);\n const previous = existsSync(file) ? readFileSync(file, \"utf8\") : undefined;\n let before: Record<string, string> | undefined;\n try {\n before = previous === undefined ? undefined : JSON.parse(previous).dependencies;\n } catch {\n before = undefined;\n }\n const sortedJson = (d: Record<string, string> | undefined) =>\n JSON.stringify(Object.entries(d ?? {}).sort(([a], [b]) => a.localeCompare(b)));\n const depsChanged = before === undefined || sortedJson(before) !== sortedJson(dependencies);\n // A plugin the list no longer names: the package manager prunes a registry package, but not a\n // `file:` one and not what a failed install left, so the caller rebuilds `node_modules`.\n const removedDep = Object.keys(before ?? {}).some((name) => !(name in dependencies));\n mkdirSync(pluginsDir(projectDir), { recursive: true });\n writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\\n`);\n return { previous, depsChanged, removedDep };\n}\n\n/** Whether `node_modules` holds a `package.json` for every declared plugin (by package name). */\nfunction allPluginsInstalled(projectDir: string, plugins: string[]): boolean {\n return plugins.every((spec) => {\n const { name } = parseSpec(resolveFileSpec(spec, projectDir));\n return existsSync(join(nodeModulesDir(projectDir), name, \"package.json\"));\n });\n}\n\n/**\n * Reconcile the plugin store for a project.\n *\n * @param projectDir - Project root containing `skaile.yaml` / `skaile.lock.yaml`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param opts - Optional injectable installer + lock slice override.\n * @returns Whether the store changed and why.\n */\nexport async function reconcilePlugins(\n projectDir: string,\n plugins: string[],\n opts: ReconcileOptions = {},\n): Promise<ReconcileResult> {\n if (plugins.length === 0) {\n return { changed: false, reason: \"no-plugins\" };\n }\n\n const lockSlice = opts.lockSlice ?? readPluginsLockSlice(projectDir);\n const wantHash = createHash(\"sha256\")\n .update(\n JSON.stringify({\n plugins: plugins.map((spec) => resolveFileSpec(spec, projectDir)).sort(),\n lock: lockSlice,\n }),\n )\n .digest(\"hex\");\n\n const hashFile = reconcileHashFile(projectDir);\n if (existsSync(hashFile)) {\n const have = readFileSync(hashFile, \"utf8\").trim();\n // The hash only says what was installed where it was written. A clone or a copied store comes\n // with the hash but without `node_modules`; trust the hash only while every declared package\n // is on disk.\n if (have === wantHash && allPluginsInstalled(projectDir, plugins)) {\n return { changed: false, reason: \"up-to-date\" };\n }\n }\n\n const { previous, depsChanged, removedDep } = writePackageJson(projectDir, plugins);\n if (removedDep) rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n\n const install = opts.runInstall ?? defaultInstall;\n const result = await install(pluginsDir(projectDir), { frozen: !depsChanged });\n if (!result.ok) {\n // A failed install must not leave the spec behind: the next reconcile\n // would compare against it and treat the store as already changed.\n if (previous === undefined) rmSync(pluginsPkgJson(projectDir), { force: true });\n else writeFileSync(pluginsPkgJson(projectDir), previous);\n throw new Error(`plugin install failed:\\n${result.output}`);\n }\n\n writeFileSync(hashFile, wantHash);\n return { changed: true, reason: \"reconciled\" };\n}\n\n/**\n * Put the store back to `previousPlugins` after `plugin install` failed past\n * the reconcile (the plugin installed but does not load). Best effort: a\n * failing reinstall is swallowed, the store is then rebuilt by the next\n * reconcile because the hash no longer matches the declared list.\n *\n * With no previous plugins every generated file of the store goes away\n * (`package.json`, hash, lock file and `node_modules`), so the store keeps\n * neither the rejected spec nor its installed package.\n */\nexport async function rollbackPluginStore(\n projectDir: string,\n previousPlugins: string[],\n opts: ReconcileOptions = {},\n): Promise<void> {\n if (previousPlugins.length === 0) {\n const dir = pluginsDir(projectDir);\n rmSync(pluginsPkgJson(projectDir), { force: true });\n rmSync(reconcileHashFile(projectDir), { force: true });\n rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n for (const lock of [\"bun.lock\", \"bun.lockb\", \"package-lock.json\"]) {\n rmSync(join(dir, lock), { force: true });\n }\n try {\n // The folder goes when nothing else of the user's is in it.\n rmdirSync(dir);\n } catch {\n // not empty, or already gone\n }\n return;\n }\n try {\n await reconcilePlugins(projectDir, previousPlugins, opts);\n } catch {\n // the next reconcile retries\n }\n}\n","/**\n * The project-local plugin store: reconcile (`<projectDir>/.skaile/plugins/`)\n * then load the reconciled plugins into the `pluginRegistry`.\n *\n * `ensurePluginsLoaded` is the single entrypoint commands wire in. It is a\n * guarded no-op when `plugins` is empty/undefined — zero overhead for the\n * common case where no project declares `plugins:` in `skaile.yaml`.\n */\n\nimport { resolve as resolvePath } from \"node:path\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport pc from \"picocolors\";\nimport { type LoadResult, loadPlugins } from \"./load.js\";\nimport { type ReconcileOptions, reconcilePlugins } from \"./reconcile.js\";\nimport { specName } from \"./spec.js\";\n\nexport type { LoadResult } from \"./load.js\";\nexport { loadPlugins } from \"./load.js\";\nexport type { ReconcileOptions } from \"./reconcile.js\";\nexport { reconcilePlugins, rollbackPluginStore } from \"./reconcile.js\";\nexport { npmSpecError, projectRelativeFileSpec, resolveFileSpec, specName } from \"./spec.js\";\n\n/** Options for {@link ensurePluginsLoaded}. */\nexport interface EnsurePluginsOptions extends ReconcileOptions {\n log?: Logger;\n}\n\n/**\n * Reconcile the plugin store then load each plugin into `registry`.\n *\n * No-op (returns immediately) when `plugins` is empty/undefined, so the common\n * no-plugins path costs nothing.\n *\n * @param projectDir - Project root.\n * @param plugins - The `skaile.yaml` `plugins:` list (may be undefined).\n * @param registry - Registry to register into. Defaults to `pluginRegistry`.\n * @param opts - Injectable installer / lock slice + optional logger.\n * @returns The load result, or an empty result when there are no plugins.\n */\nexport async function ensurePluginsLoaded(\n projectDir: string,\n plugins: string[] | undefined,\n registry: PluginRegistry = pluginRegistry,\n opts: EnsurePluginsOptions = {},\n): Promise<LoadResult> {\n if (!plugins || plugins.length === 0) {\n return { loaded: [], failed: [] };\n }\n await reconcilePlugins(projectDir, plugins, opts);\n return loadPlugins(projectDir, plugins, registry, { log: opts.log });\n}\n\n/**\n * The installer's output of a failed `plugin install` is a dump (bun's banner, resolver\n * progress, then the `error:` lines). A load warning keeps the first line and the cause of it\n * (p1113); `skaile plugin install <spec>` prints the whole output.\n *\n * bun: the last `error:` line. npm: its `code` line and the first detail line after it\n * (`E404: 404 Not Found - GET …`), never the trailing `A complete log of this run can be found\n * in: …` pointer (p1272).\n */\nexport function condensePluginFailure(reason: string): string {\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\");\n const [first, ...rest] = lines;\n if (!reason.startsWith(\"plugin install failed\") || first === undefined || rest.length === 0) {\n return reason;\n }\n const head = first.replace(/:$/, \"\");\n const npmPrefix = /^npm (ERR!|error)\\s*/i;\n const npmLines = rest\n .filter((l) => npmPrefix.test(l) && !/^npm \\S+\\s+A complete log of this run\\b/i.test(l))\n .map((l) => l.replace(npmPrefix, \"\"))\n .filter((l) => l !== \"\");\n const codeLine = npmLines.find((l) => /^code\\s+\\S+/i.test(l));\n if (codeLine) {\n const code = codeLine.replace(/^code\\s+/i, \"\");\n const detail = npmLines.find((l) => l !== codeLine && !/^code\\s/i.test(l));\n return `${head}: npm ${code}${detail ? `: ${detail}` : \"\"}`;\n }\n const causes = rest.filter(\n (l) => /^error\\b/i.test(l) || (npmPrefix.test(l) && !/A complete log of this run\\b/i.test(l)),\n );\n const cause =\n causes.at(-1) ?? rest.filter((l) => !/A complete log of this run\\b/i.test(l)).at(-1);\n return `${head}: ${cause ?? rest.at(-1)}`;\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\/]/g, \"\\\\$&\");\n}\n\n/**\n * Split the output of one failed install of the whole plugin store into one reason per plugin\n * (p1272): the package manager runs once for every spec, so its output names the plugins that\n * failed. A plugin gets the line that names it (also its URL-encoded form `@scope%2fname`); a\n * plugin the output never names says it was not installed and which plugin the install stopped\n * at. With one plugin, or when the output names none (no `bun` and no `npm`), every plugin keeps\n * the whole condensed reason.\n */\nexport function pluginFailureReasons(\n reason: string,\n specs: readonly string[],\n): Map<string, string> {\n const out = new Map<string, string>();\n const condensed = condensePluginFailure(reason);\n if (specs.length < 2 || !reason.startsWith(\"plugin install failed\")) return out;\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\" && !/A complete log of this run\\b/i.test(l));\n const names = specs.map((spec) => {\n try {\n return specName(spec);\n } catch {\n return spec;\n }\n });\n const mentions = (text: string, name: string): boolean => {\n const forms = [name, name.replace(\"/\", \"%2f\"), name.replace(\"/\", \"%2F\")];\n return forms.some((f) =>\n new RegExp(`(?<![\\\\w@.-])(?<!@[\\\\w.~-]+/)${escapeRegExp(f)}(?![\\\\w-]|\\\\.\\\\w)`).test(text),\n );\n };\n const cause = /\\berror\\b|\\bE[A-Z0-9]{3,}\\b|\\b404\\b|notarget|failed to resolve/i;\n const named: string[] = [];\n specs.forEach((spec, i) => {\n const name = names[i] as string;\n const line = mentions(condensed, name)\n ? condensed.replace(/^plugin install failed:\\s*/, \"\")\n : lines.filter((l) => mentions(l, name) && cause.test(l)).at(-1);\n if (line === undefined) return;\n named.push(name);\n out.set(spec, `plugin install failed: ${line.replace(/^(npm\\s+)?(ERR!|error:?)\\s*/i, \"\")}`);\n });\n if (named.length === 0) return new Map();\n specs.forEach((spec, i) => {\n if (!out.has(spec)) {\n out.set(\n spec,\n `plugin install failed: ${names[i]} was not installed, the install stopped at ${named.join(\", \")}`,\n );\n }\n });\n return out;\n}\n\n/** One `! plugin <name> failed to load: <reason>` line on stderr (stdout carries a run's answer). */\nfunction warnPluginFailed(spec: string, reason: string): void {\n let name = spec;\n try {\n name = specName(spec);\n } catch {\n /* a spec that does not parse is named as written */\n }\n process.stderr.write(\n ` ${pc.yellow(\"!\")} plugin ${name} failed to load: ${condensePluginFailure(reason)}\\n`,\n );\n}\n\n/**\n * Reconcile + load the `plugins:` of the project's `skaile.yaml` into the process registry, so a\n * plugin's harness is known to `run`, `repl` and `config set harness`. A plugin that fails to\n * reconcile or load is skipped (its harness stays unknown, the command goes on) and named in one\n * `! plugin <name> failed to load: <reason>` line on stderr. An unreadable config is not this\n * function's to report: the command reads it again and says so.\n */\nexport function loadDeclaredPlugins(projectDir: string): Promise<void> {\n // A plugin registers once per process: a second `register()` is a duplicate.\n const key = resolvePath(projectDir);\n let pending = declaredPluginLoads.get(key);\n if (!pending) {\n pending = loadDeclaredPluginsOnce(projectDir);\n declaredPluginLoads.set(key, pending);\n }\n return pending;\n}\n\nconst declaredPluginLoads = new Map<string, Promise<void>>();\n\nasync function loadDeclaredPluginsOnce(projectDir: string): Promise<void> {\n let plugins: string[] | undefined;\n try {\n const { resolveSkWorkspaceConfig } = await import(\"@skaile/workspaces/core\");\n plugins = resolveSkWorkspaceConfig(projectDir).plugins;\n } catch {\n return;\n }\n if (!plugins || plugins.length === 0) return;\n try {\n const result = await ensurePluginsLoaded(projectDir, plugins, pluginRegistry);\n for (const f of result.failed) warnPluginFailed(f.spec, f.reason);\n } catch (err) {\n // The store could not be reconciled: no plugin was loaded.\n const reason = err instanceof Error ? err.message : String(err);\n const reasons = pluginFailureReasons(reason, plugins);\n for (const spec of plugins) warnPluginFailed(spec, reasons.get(spec) ?? reason);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { err, okJson, ok } from './chunk-3MWQKQUB.js';
2
- import { fleetMountConnectingMessage, buildConnectorListPayload } from './chunk-MPRWVZXF.js';
2
+ import { fleetMountConnectingMessage, buildConnectorListPayload } from './chunk-SKG6G4HO.js';
3
3
  import { readFile } from 'fs/promises';
4
4
  import { join } from 'path';
5
5
 
@@ -120,5 +120,5 @@ async function connectorDescribe(manager, id) {
120
120
  }
121
121
 
122
122
  export { connectorDescribe, connectorExec, connectorList, connectorLoadSkill, connectorRead, connectorSearch, connectorWrite, mountList, mountRead, mountStatus, mountSync };
123
- //# sourceMappingURL=chunk-YGT3CGPD.js.map
124
- //# sourceMappingURL=chunk-YGT3CGPD.js.map
123
+ //# sourceMappingURL=chunk-2U67XYZM.js.map
124
+ //# sourceMappingURL=chunk-2U67XYZM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../workspace-plugin/src/tools/connectors.ts"],"names":[],"mappings":";;;;;AA4BA,SAAS,cAAc,OAAA,EAAiD;AACtE,EAAA,OAAO,OAAA,CACJ,gBAAe,CACf,MAAA,CAAO,CAAC,CAAA,KAA+B,OAAO,CAAA,CAAE,SAAA,KAAc,QAAQ,CAAA;AAC3E;AAaA,eAAe,YAAA,CACb,SACA,KAAA,EACoB;AAEpB,EAAA,IAAI,MAAM,MAAA,KAAW,YAAA;AACnB,IAAA,OAAO,EAAE,GAAG,KAAA,EAAO,QAAQ,2BAAA,CAA4B,KAAA,CAAM,EAAE,CAAA,EAAE;AAEnE,EAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,kBAAA,GAAqB,MAAM,EAAE,CAAA;AAC5D,EAAA,IAAI,CAAC,QAAA,IAAY,QAAA,CAAS,KAAA,KAAU,QAAQ,OAAO,KAAA;AACnD,EAAA,IAAI,QAAA,CAAS,KAAA,KAAU,MAAA,EAAQ,OA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OAAO,GAAA,CAAI,yCAAyC,CAAA;AAClE,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,QAAQ,UAAA,EAAW;AAClC,IAAA,MAAM,aAAa,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,EAAE,CAAA;AACjD,IAAA,IAAI,CAAC,UAAA,EAAY,OAAO,GAAA,CAAI,CAAA,mCAAA,EAAsC,EAAE,CAAA,CAAA,CAAG,CAAA;AACvE,IAAA,OAAO,OAAO,UAAU,CAAA;AAAA,EAC1B,SAAS,CAAA,EAAY;AACnB,IAAA,OAAO,IAAI,CAAA,YAAa,KAAA,GAAQ,EAAE,OAAA,GAAU,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,EACvD;AACF","file":"chunk-YGT3CGPD.js","sourcesContent":["// src/tools/connectors.ts\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport {\n buildConnectorListPayload,\n type ConnectorManager,\n fleetMountConnectingMessage,\n} from \"@skaile/workspaces/connectors\";\nimport type { ToolResult } from \"../types.js\";\nimport { err, ok, okJson } from \"../types.js\";\n\n// ── Mountable-connector helpers ──────────────────────────────────────────────\n//\n// The unified ConnectorManager owns mountable (filesystem-face) connectors too.\n// A connector is mountable when its `listConnectors()` summary carries a\n// `mountPath`. The `mount*` helpers below project that subset for the legacy\n// `mount_*` tool surface.\n\n/**\n * A connector summary that carries a projected filesystem path. Unlike the raw\n * `listConnectors()` summary, `mountPath` is non-optional here — `listMountable()`\n * runtime-filters to exactly those entries before narrowing to this type.\n */\ntype MountableConnector = ReturnType<ConnectorManager[\"listConnectors\"]>[number] & {\n mountPath: string;\n};\n\n/** Return the mountable (filesystem-face) connectors from a manager. */\nfunction listMountable(manager: ConnectorManager): MountableConnector[] {\n return manager\n .listConnectors()\n .filter((c): c is MountableConnector => typeof c.mountPath === \"string\");\n}\n\n/**\n * A mountable connector as reported to the agent, with an optional `reason`.\n *\n * A fleet-managed mount whose path is gone reports `status: \"error\"` plus a\n * `reason`, even though the connector handle still reads `connected`. One whose\n * probe timed out keeps its cached status and gains a `reason` saying it is\n * unverified: a slow cloud mount is not reported dead.\n */\ntype MountView = MountableConnector & { reason?: string };\n\n/** Overlay a live re-check on the cached connect-time status where one applies. */\nasync function withLiveness(\n manager: ConnectorManager,\n mount: MountableConnector,\n): Promise<MountView> {\n // Retried in the background; its path is not verified yet.\n if (mount.status === \"connecting\")\n return { ...mount, reason: fleetMountConnectingMessage(mount.id) };\n // Optional call: the tool tests' manager doubles omit the method.\n const liveness = await manager.checkMountLiveness?.(mount.id);\n if (!liveness || liveness.state === \"live\") return mount;\n if (liveness.state === \"dead\") return { ...mount, status: \"error\", reason: liveness.reason };\n return { ...mount, reason: liveness.reason };\n}\n\n/**\n * List all mountable (filesystem-face) connectors declared in `skaile.yaml`\n * with their current mount status.\n *\n * @param manager - Active `ConnectorManager` or `null` when not configured.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountList(manager: ConnectorManager | null): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n return okJson(await Promise.all(listMountable(manager).map((m) => withLiveness(manager, m))));\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Sync a mountable connector — pull the latest content from its remote source.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param mountId - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountSync(\n manager: ConnectorManager | null,\n mountId: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const result = await manager.sync(mountId);\n return okJson(result);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Get the current status and metadata for a single mountable connector.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param mountId - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountStatus(\n manager: ConnectorManager | null,\n mountId: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const mount = listMountable(manager).find((v) => v.id === mountId);\n if (!mount) return err(`Mount not found: \"${mountId}\"`);\n return okJson(await withLiveness(manager, mount));\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Read a file from within a mountable connector's projected directory by its\n * relative path.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param mountId - Connector ID declared in `skaile.yaml`.\n * @param filePath - Relative path within the projected mount directory.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountRead(\n manager: ConnectorManager | null,\n mountId: string,\n filePath: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const mount = listMountable(manager).find((v) => v.id === mountId);\n if (!mount) return err(`Mount not found: \"${mountId}\"`);\n if (mount.status === \"connecting\") return err(fleetMountConnectingMessage(mountId));\n const content = await readFile(join(mount.mountPath, filePath), \"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 * List all connectors registered with the `ConnectorManager`.\n *\n * Returns `{ connected, failed }` — `connected` from `manager.listConnectors()`,\n * `failed` from `manager.listFailedConnectors()`. A connector that threw during\n * `connect()` never enters the active map, so it is absent from the first list\n * entirely; without the second one an agent driven through MCP or OMP has no\n * way to learn that a mount it is about to write into is dead. Returns an error\n * result when no manager is configured (i.e. `skaile.yaml` has no `connectors`\n * section).\n *\n * @param manager - Active `ConnectorManager` or `null` when not configured.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorList(manager: ConnectorManager | null): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n // Same payload as the Claude SDK tool: per-mount health and a notice when one is not ok.\n return okJson(await buildConnectorListPayload(manager));\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Read content from a connector at the given path.\n *\n * Delegates to `manager.read(id, path)`. Returns an error result when the\n * path yields `null` (not found) or the manager is absent.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param path - Resource path within the connector (connector-specific format).\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorRead(\n manager: ConnectorManager | null,\n id: string,\n path: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const content = await manager.read(id, path);\n if (content === null) return err(`No content at path \"${path}\" in connector \"${id}\"`);\n return okJson(content);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Write string content to a connector at the given path.\n *\n * Delegates to `manager.write(id, path, { data: content })`.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param path - Destination path within the connector.\n * @param content - String payload to write.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorWrite(\n manager: ConnectorManager | null,\n id: string,\n path: string,\n content: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n await manager.write(id, path, { data: content });\n return ok(`Written to \"${path}\" in connector \"${id}\"`);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Search a connector's data using a query string.\n *\n * Delegates to `manager.search(id, query)` and returns the result set as JSON.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param query - Free-text or structured query (connector-specific format).\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorSearch(\n manager: ConnectorManager | null,\n id: string,\n query: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const results = await manager.search(id, query);\n return okJson(results);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Execute a named operation on a connector.\n *\n * Delegates to `manager.executeOp(id, operation, args)`. Operations and\n * their argument shapes are connector-specific; use {@link connectorDescribe}\n * to discover what operations a connector supports.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param operation - Operation name (from the connector's `RuntimeSkillDescriptor`).\n * @param args - Named arguments for the operation.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorExec(\n manager: ConnectorManager | null,\n id: string,\n operation: string,\n args: Record<string, unknown>,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const result = await manager.executeOp(id, operation, args);\n return ok(result);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Load the rendered skill body for a connector.\n *\n * Delegates to `manager.loadSkill(id)` and returns the skill content as\n * plain text. Useful when the agent needs the connector's operations and\n * usage instructions injected as prompt context.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorLoadSkill(\n manager: ConnectorManager | null,\n id: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const skill = manager.loadSkill(id);\n return ok(skill);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Describe a connector's capabilities via its `RuntimeSkillDescriptor`.\n *\n * Finds the matching skill descriptor from `manager.listSkills()` and returns\n * it as JSON. The descriptor includes the connector's operations, argument\n * shapes, and usage instructions.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorDescribe(\n manager: ConnectorManager | null,\n id: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const skills = manager.listSkills();\n const descriptor = skills.find((s) => s.id === id);\n if (!descriptor) return err(`No skill descriptor for connector \"${id}\"`);\n return okJson(descriptor);\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/connectors.ts"],"names":[],"mappings":";;;;;AA4BA,SAAS,cAAc,OAAA,EAAiD;AACtE,EAAA,OAAO,OAAA,CACJ,gBAAe,CACf,MAAA,CAAO,CAAC,CAAA,KAA+B,OAAO,CAAA,CAAE,SAAA,KAAc,QAAQ,CAAA;AAC3E;AAaA,eAAe,YAAA,CACb,SACA,KAAA,EACoB;AAEpB,EAAA,IAAI,MAAM,MAAA,KAAW,YAAA;AACnB,IAAA,OAAO,EAAE,GAAG,KAAA,EAAO,QAAQ,2BAAA,CAA4B,KAAA,CAAM,EAAE,CAAA,EAAE;AAEnE,EAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,kBAAA,GAAqB,MAAM,EAAE,CAAA;AAC5D,EAAA,IAAI,CAAC,QAAA,IAAY,QAAA,CAAS,KAAA,KAAU,QAAQ,OAAO,KAAA;AACnD,EAAA,IAAI,QAAA,CAAS,KAAA,KAAU,MAAA,EAAQ,OAAO,EAAE,GAAG,KAAA,EAAO,MAAA,EAAQ,OAAA,EAAS,MAAA,EAAQ,QAAA,CAAS,MAAA,EAAO;AAC3F,EAAA,OAAO,EAAE,GAAG,KAAA,EAAO,MAAA,EAAQ,SAAS,MAAA,EAAO;AAC7C;AAUA,eAAsB,UAAU,OAAA,EAAuD;AACrF,EAAA,IAAI,CAAC,OAAA,EAAS,OAAO,GAAA,CAAI,yCAAyC,CAAA;AAClE,EAAA,IAAI;AACF,IAAA,OAAO,MAAA,CAAO,MAAM,OAAA,CAAQ,GAAA,CAAI,cAAc,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,MAAM,YAAA,CAAa,OAAA,EAAS,CAAC,CA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U,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,EACvD;AACF","file":"chunk-2U67XYZM.js","sourcesContent":["// src/tools/connectors.ts\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport {\n buildConnectorListPayload,\n type ConnectorManager,\n fleetMountConnectingMessage,\n} from \"@skaile/workspaces/connectors\";\nimport type { ToolResult } from \"../types.js\";\nimport { err, ok, okJson } from \"../types.js\";\n\n// ── Mountable-connector helpers ──────────────────────────────────────────────\n//\n// The unified ConnectorManager owns mountable (filesystem-face) connectors too.\n// A connector is mountable when its `listConnectors()` summary carries a\n// `mountPath`. The `mount*` helpers below project that subset for the legacy\n// `mount_*` tool surface.\n\n/**\n * A connector summary that carries a projected filesystem path. Unlike the raw\n * `listConnectors()` summary, `mountPath` is non-optional here — `listMountable()`\n * runtime-filters to exactly those entries before narrowing to this type.\n */\ntype MountableConnector = ReturnType<ConnectorManager[\"listConnectors\"]>[number] & {\n mountPath: string;\n};\n\n/** Return the mountable (filesystem-face) connectors from a manager. */\nfunction listMountable(manager: ConnectorManager): MountableConnector[] {\n return manager\n .listConnectors()\n .filter((c): c is MountableConnector => typeof c.mountPath === \"string\");\n}\n\n/**\n * A mountable connector as reported to the agent, with an optional `reason`.\n *\n * A fleet-managed mount whose path is gone reports `status: \"error\"` plus a\n * `reason`, even though the connector handle still reads `connected`. One whose\n * probe timed out keeps its cached status and gains a `reason` saying it is\n * unverified: a slow cloud mount is not reported dead.\n */\ntype MountView = MountableConnector & { reason?: string };\n\n/** Overlay a live re-check on the cached connect-time status where one applies. */\nasync function withLiveness(\n manager: ConnectorManager,\n mount: MountableConnector,\n): Promise<MountView> {\n // Retried in the background; its path is not verified yet.\n if (mount.status === \"connecting\")\n return { ...mount, reason: fleetMountConnectingMessage(mount.id) };\n // Optional call: the tool tests' manager doubles omit the method.\n const liveness = await manager.checkMountLiveness?.(mount.id);\n if (!liveness || liveness.state === \"live\") return mount;\n if (liveness.state === \"dead\") return { ...mount, status: \"error\", reason: liveness.reason };\n return { ...mount, reason: liveness.reason };\n}\n\n/**\n * List all mountable (filesystem-face) connectors declared in `skaile.yaml`\n * with their current mount status.\n *\n * @param manager - Active `ConnectorManager` or `null` when not configured.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountList(manager: ConnectorManager | null): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n return okJson(await Promise.all(listMountable(manager).map((m) => withLiveness(manager, m))));\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Sync a mountable connector — pull the latest content from its remote source.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param mountId - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountSync(\n manager: ConnectorManager | null,\n mountId: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const result = await manager.sync(mountId);\n return okJson(result);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Get the current status and metadata for a single mountable connector.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param mountId - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountStatus(\n manager: ConnectorManager | null,\n mountId: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const mount = listMountable(manager).find((v) => v.id === mountId);\n if (!mount) return err(`Mount not found: \"${mountId}\"`);\n return okJson(await withLiveness(manager, mount));\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Read a file from within a mountable connector's projected directory by its\n * relative path.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param mountId - Connector ID declared in `skaile.yaml`.\n * @param filePath - Relative path within the projected mount directory.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function mountRead(\n manager: ConnectorManager | null,\n mountId: string,\n filePath: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const mount = listMountable(manager).find((v) => v.id === mountId);\n if (!mount) return err(`Mount not found: \"${mountId}\"`);\n if (mount.status === \"connecting\") return err(fleetMountConnectingMessage(mountId));\n const content = await readFile(join(mount.mountPath, filePath), \"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 * List all connectors registered with the `ConnectorManager`.\n *\n * Returns `{ connected, failed }` — `connected` from `manager.listConnectors()`,\n * `failed` from `manager.listFailedConnectors()`. A connector that threw during\n * `connect()` never enters the active map, so it is absent from the first list\n * entirely; without the second one an agent driven through MCP or OMP has no\n * way to learn that a mount it is about to write into is dead. Returns an error\n * result when no manager is configured (i.e. `skaile.yaml` has no `connectors`\n * section).\n *\n * @param manager - Active `ConnectorManager` or `null` when not configured.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorList(manager: ConnectorManager | null): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n // Same payload as the Claude SDK tool: per-mount health and a notice when one is not ok.\n return okJson(await buildConnectorListPayload(manager));\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Read content from a connector at the given path.\n *\n * Delegates to `manager.read(id, path)`. Returns an error result when the\n * path yields `null` (not found) or the manager is absent.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param path - Resource path within the connector (connector-specific format).\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorRead(\n manager: ConnectorManager | null,\n id: string,\n path: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const content = await manager.read(id, path);\n if (content === null) return err(`No content at path \"${path}\" in connector \"${id}\"`);\n return okJson(content);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Write string content to a connector at the given path.\n *\n * Delegates to `manager.write(id, path, { data: content })`.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param path - Destination path within the connector.\n * @param content - String payload to write.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorWrite(\n manager: ConnectorManager | null,\n id: string,\n path: string,\n content: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n await manager.write(id, path, { data: content });\n return ok(`Written to \"${path}\" in connector \"${id}\"`);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Search a connector's data using a query string.\n *\n * Delegates to `manager.search(id, query)` and returns the result set as JSON.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param query - Free-text or structured query (connector-specific format).\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorSearch(\n manager: ConnectorManager | null,\n id: string,\n query: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const results = await manager.search(id, query);\n return okJson(results);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Execute a named operation on a connector.\n *\n * Delegates to `manager.executeOp(id, operation, args)`. Operations and\n * their argument shapes are connector-specific; use {@link connectorDescribe}\n * to discover what operations a connector supports.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n * @param operation - Operation name (from the connector's `RuntimeSkillDescriptor`).\n * @param args - Named arguments for the operation.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorExec(\n manager: ConnectorManager | null,\n id: string,\n operation: string,\n args: Record<string, unknown>,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const result = await manager.executeOp(id, operation, args);\n return ok(result);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Load the rendered skill body for a connector.\n *\n * Delegates to `manager.loadSkill(id)` and returns the skill content as\n * plain text. Useful when the agent needs the connector's operations and\n * usage instructions injected as prompt context.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorLoadSkill(\n manager: ConnectorManager | null,\n id: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const skill = manager.loadSkill(id);\n return ok(skill);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Describe a connector's capabilities via its `RuntimeSkillDescriptor`.\n *\n * Finds the matching skill descriptor from `manager.listSkills()` and returns\n * it as JSON. The descriptor includes the connector's operations, argument\n * shapes, and usage instructions.\n *\n * @param manager - Active `ConnectorManager` or `null`.\n * @param id - Connector ID declared in `skaile.yaml`.\n *\n * @docLink packages/workspace-plugin/concepts#tool-delivery\n */\nexport async function connectorDescribe(\n manager: ConnectorManager | null,\n id: string,\n): Promise<ToolResult> {\n if (!manager) return err(\"No connectors configured in skaile.yaml\");\n try {\n const skills = manager.listSkills();\n const descriptor = skills.find((s) => s.id === id);\n if (!descriptor) return err(`No skill descriptor for connector \"${id}\"`);\n return okJson(descriptor);\n } catch (e: unknown) {\n return err(e instanceof Error ? e.message : String(e));\n }\n}\n"]}