@skaile/workspaces 4.37.0 → 4.38.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 (313) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/app-sdk/index.js +1 -1
  3. package/dist/{asset-feeds-KTRFFJYM.js → asset-feeds-UYIFZKKG.js} +16 -16
  4. package/dist/asset-feeds-UYIFZKKG.js.map +1 -0
  5. package/dist/asset-manager/catalog-deployer.js +9 -8
  6. package/dist/asset-manager/index.js +15 -14
  7. package/dist/asset-manager/installer.js +11 -10
  8. package/dist/asset-manager/renderers.js +2 -2
  9. package/dist/asset-manager/src/index.d.ts +77 -18
  10. package/dist/asset-manager/src/index.d.ts.map +1 -1
  11. package/dist/asset-manager/src/installer.d.ts +11 -1
  12. package/dist/asset-manager/src/installer.d.ts.map +1 -1
  13. package/dist/bridge/drivers/claude-sdk.js +14 -13
  14. package/dist/bridge/drivers/claude-sdk.js.map +1 -1
  15. package/dist/bridge/drivers/codex.js +11 -10
  16. package/dist/bridge/drivers/codex.js.map +1 -1
  17. package/dist/bridge/drivers/continue.js +12 -11
  18. package/dist/bridge/drivers/continue.js.map +1 -1
  19. package/dist/bridge/drivers/echo.js +3 -3
  20. package/dist/bridge/drivers/gemini.js +6 -6
  21. package/dist/bridge/drivers/goose.js +12 -11
  22. package/dist/bridge/drivers/goose.js.map +1 -1
  23. package/dist/bridge/drivers/omp.js +4 -4
  24. package/dist/bridge/drivers/opencode.js +12 -11
  25. package/dist/bridge/drivers/opencode.js.map +1 -1
  26. package/dist/bridge/drivers/qwen.js +6 -6
  27. package/dist/bridge/index.js +15 -14
  28. package/dist/{chunk-SGMCSVTO.js → chunk-27DN4DZD.js} +8 -8
  29. package/dist/{chunk-SGMCSVTO.js.map → chunk-27DN4DZD.js.map} +1 -1
  30. package/dist/{chunk-VOEBLPXO.js → chunk-2EL2PBRC.js} +3 -3
  31. package/dist/{chunk-VOEBLPXO.js.map → chunk-2EL2PBRC.js.map} +1 -1
  32. package/dist/{chunk-VRFKCF3R.js → chunk-36ML6SFP.js} +4 -4
  33. package/dist/{chunk-VRFKCF3R.js.map → chunk-36ML6SFP.js.map} +1 -1
  34. package/dist/{chunk-UFBURH6K.js → chunk-4WKZEMBD.js} +4 -4
  35. package/dist/{chunk-UFBURH6K.js.map → chunk-4WKZEMBD.js.map} +1 -1
  36. package/dist/{chunk-2D3C4AJP.js → chunk-5CYEWBPB.js} +11 -4
  37. package/dist/chunk-5CYEWBPB.js.map +1 -0
  38. package/dist/{chunk-SQ7IN7KR.js → chunk-5K2VT6E2.js} +3 -3
  39. package/dist/{chunk-SQ7IN7KR.js.map → chunk-5K2VT6E2.js.map} +1 -1
  40. package/dist/{chunk-NTASYPDN.js → chunk-5NYBY6ZE.js} +3 -3
  41. package/dist/{chunk-NTASYPDN.js.map → chunk-5NYBY6ZE.js.map} +1 -1
  42. package/dist/{chunk-SOFPA4S4.js → chunk-6EMF4UZI.js} +8 -8
  43. package/dist/{chunk-SOFPA4S4.js.map → chunk-6EMF4UZI.js.map} +1 -1
  44. package/dist/{chunk-WQULDAH2.js → chunk-6KPQDP7P.js} +2 -2
  45. package/dist/{chunk-WQULDAH2.js.map → chunk-6KPQDP7P.js.map} +1 -1
  46. package/dist/{chunk-OPBGV4DX.js → chunk-6VRZ6M2L.js} +3 -3
  47. package/dist/{chunk-OPBGV4DX.js.map → chunk-6VRZ6M2L.js.map} +1 -1
  48. package/dist/{chunk-KN5Y5BXK.js → chunk-7FZSABQV.js} +5 -5
  49. package/dist/{chunk-KN5Y5BXK.js.map → chunk-7FZSABQV.js.map} +1 -1
  50. package/dist/{chunk-FLGLODDF.js → chunk-7RC37XFW.js} +3 -3
  51. package/dist/{chunk-FLGLODDF.js.map → chunk-7RC37XFW.js.map} +1 -1
  52. package/dist/{chunk-5SGS5SN2.js → chunk-7UL2SQQH.js} +4 -4
  53. package/dist/{chunk-5SGS5SN2.js.map → chunk-7UL2SQQH.js.map} +1 -1
  54. package/dist/{chunk-GEEW6SY2.js → chunk-A5EDMBFG.js} +2 -2
  55. package/dist/{chunk-GEEW6SY2.js.map → chunk-A5EDMBFG.js.map} +1 -1
  56. package/dist/{chunk-QABZZROM.js → chunk-ARUJBGAH.js} +3 -3
  57. package/dist/{chunk-QABZZROM.js.map → chunk-ARUJBGAH.js.map} +1 -1
  58. package/dist/{chunk-ENXE4BKS.js → chunk-BQ3HXZNT.js} +2 -2
  59. package/dist/{chunk-ENXE4BKS.js.map → chunk-BQ3HXZNT.js.map} +1 -1
  60. package/dist/{chunk-U4CNCL7Q.js → chunk-CACCIOQL.js} +12 -12
  61. package/dist/{chunk-U4CNCL7Q.js.map → chunk-CACCIOQL.js.map} +1 -1
  62. package/dist/{chunk-5JAO4MXA.js → chunk-DOVURNRK.js} +3 -3
  63. package/dist/{chunk-5JAO4MXA.js.map → chunk-DOVURNRK.js.map} +1 -1
  64. package/dist/{chunk-P4VHQA4N.js → chunk-DSB6X25D.js} +3 -3
  65. package/dist/{chunk-P4VHQA4N.js.map → chunk-DSB6X25D.js.map} +1 -1
  66. package/dist/{chunk-2QYQOJ2F.js → chunk-DV47JNI4.js} +3 -3
  67. package/dist/{chunk-2QYQOJ2F.js.map → chunk-DV47JNI4.js.map} +1 -1
  68. package/dist/{chunk-FZFCOQTI.js → chunk-EETXMMZS.js} +3 -3
  69. package/dist/{chunk-FZFCOQTI.js.map → chunk-EETXMMZS.js.map} +1 -1
  70. package/dist/{chunk-OEBAXTQ4.js → chunk-EOKAFBJ7.js} +3 -3
  71. package/dist/{chunk-OEBAXTQ4.js.map → chunk-EOKAFBJ7.js.map} +1 -1
  72. package/dist/{chunk-6BEGKO2Q.js → chunk-HUNZYTOS.js} +4 -3
  73. package/dist/chunk-HUNZYTOS.js.map +1 -0
  74. package/dist/{chunk-7YCPY6NC.js → chunk-HXG6IZSF.js} +6 -6
  75. package/dist/{chunk-7YCPY6NC.js.map → chunk-HXG6IZSF.js.map} +1 -1
  76. package/dist/{chunk-L7R52OOV.js → chunk-ILAZDNIA.js} +3 -3
  77. package/dist/{chunk-L7R52OOV.js.map → chunk-ILAZDNIA.js.map} +1 -1
  78. package/dist/{chunk-WTBXGJCD.js → chunk-J5UF3OOS.js} +10 -10
  79. package/dist/{chunk-WTBXGJCD.js.map → chunk-J5UF3OOS.js.map} +1 -1
  80. package/dist/{chunk-QKXDRBLL.js → chunk-JEPSP6XK.js} +11 -80
  81. package/dist/chunk-JEPSP6XK.js.map +1 -0
  82. package/dist/{chunk-KIFJWSNC.js → chunk-KAJH3XPW.js} +7 -3
  83. package/dist/chunk-KAJH3XPW.js.map +1 -0
  84. package/dist/chunk-LOHQTTUV.js +29 -0
  85. package/dist/chunk-LOHQTTUV.js.map +1 -0
  86. package/dist/{chunk-MDBAEEY5.js → chunk-MQ42OYKH.js} +159 -7
  87. package/dist/chunk-MQ42OYKH.js.map +1 -0
  88. package/dist/{chunk-YU433JEL.js → chunk-MS2JK4V7.js} +6 -6
  89. package/dist/{chunk-YU433JEL.js.map → chunk-MS2JK4V7.js.map} +1 -1
  90. package/dist/{chunk-DFZDL62S.js → chunk-OLMNDIAU.js} +14 -9
  91. package/dist/chunk-OLMNDIAU.js.map +1 -0
  92. package/dist/{chunk-3SUWLY3H.js → chunk-OQRB7JUS.js} +3 -3
  93. package/dist/{chunk-3SUWLY3H.js.map → chunk-OQRB7JUS.js.map} +1 -1
  94. package/dist/{chunk-RZXP5ZER.js → chunk-PRCUGFXV.js} +3 -3
  95. package/dist/{chunk-RZXP5ZER.js.map → chunk-PRCUGFXV.js.map} +1 -1
  96. package/dist/{chunk-MRS5YHPI.js → chunk-QBQITQAM.js} +3 -3
  97. package/dist/{chunk-MRS5YHPI.js.map → chunk-QBQITQAM.js.map} +1 -1
  98. package/dist/{chunk-R2SYODNK.js → chunk-QWWDDU5Z.js} +274 -67
  99. package/dist/chunk-QWWDDU5Z.js.map +1 -0
  100. package/dist/{chunk-UTZEHXYT.js → chunk-R2U346ER.js} +3 -3
  101. package/dist/{chunk-UTZEHXYT.js.map → chunk-R2U346ER.js.map} +1 -1
  102. package/dist/{chunk-USJWXEXS.js → chunk-R5ARWJGE.js} +46 -41
  103. package/dist/chunk-R5ARWJGE.js.map +1 -0
  104. package/dist/chunk-TLKM4M47.js +78 -0
  105. package/dist/chunk-TLKM4M47.js.map +1 -0
  106. package/dist/{chunk-NFECHLV6.js → chunk-TNWXGHLD.js} +3 -3
  107. package/dist/{chunk-NFECHLV6.js.map → chunk-TNWXGHLD.js.map} +1 -1
  108. package/dist/{chunk-H3KXUUYQ.js → chunk-VDBP6Y5M.js} +4 -4
  109. package/dist/{chunk-H3KXUUYQ.js.map → chunk-VDBP6Y5M.js.map} +1 -1
  110. package/dist/{chunk-XN7DAZB7.js → chunk-VJNTB4DN.js} +5 -5
  111. package/dist/chunk-VJNTB4DN.js.map +1 -0
  112. package/dist/{chunk-BSIHJZKN.js → chunk-XU7JET5Z.js} +107 -26
  113. package/dist/chunk-XU7JET5Z.js.map +1 -0
  114. package/dist/{chunk-A5RRXBLI.js → chunk-YCJ3PJNB.js} +5 -5
  115. package/dist/{chunk-A5RRXBLI.js.map → chunk-YCJ3PJNB.js.map} +1 -1
  116. package/dist/{chunk-VCLN2IUM.js → chunk-YCMZHL4T.js} +31 -27
  117. package/dist/chunk-YCMZHL4T.js.map +1 -0
  118. package/dist/{chunk-V2OQ3BI6.js → chunk-YNUBJY3L.js} +2 -2
  119. package/dist/chunk-YNUBJY3L.js.map +1 -0
  120. package/dist/{chunk-S63H4HDH.js → chunk-YQEF36D5.js} +4 -4
  121. package/dist/{chunk-S63H4HDH.js.map → chunk-YQEF36D5.js.map} +1 -1
  122. package/dist/{chunk-FJYOQMXT.js → chunk-YV3YI3TA.js} +32 -16
  123. package/dist/chunk-YV3YI3TA.js.map +1 -0
  124. package/dist/cli/index.js +755 -533
  125. package/dist/cli/index.js.map +1 -1
  126. package/dist/cli/src/asset-feeds.d.ts.map +1 -1
  127. package/dist/cli/src/commands/asset-cmd.d.ts.map +1 -1
  128. package/dist/cli/src/commands/cache.d.ts.map +1 -1
  129. package/dist/cli/src/commands/catalog.d.ts +28 -3
  130. package/dist/cli/src/commands/catalog.d.ts.map +1 -1
  131. package/dist/cli/src/commands/complete-resolvers.d.ts +1 -7
  132. package/dist/cli/src/commands/complete-resolvers.d.ts.map +1 -1
  133. package/dist/cli/src/commands/complete.d.ts.map +1 -1
  134. package/dist/cli/src/commands/diff.d.ts +3 -1
  135. package/dist/cli/src/commands/diff.d.ts.map +1 -1
  136. package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
  137. package/dist/cli/src/commands/library-index.d.ts +8 -0
  138. package/dist/cli/src/commands/library-index.d.ts.map +1 -1
  139. package/dist/cli/src/commands/library-publish.d.ts +7 -2
  140. package/dist/cli/src/commands/library-publish.d.ts.map +1 -1
  141. package/dist/cli/src/commands/manage.d.ts.map +1 -1
  142. package/dist/cli/src/commands/outdated.d.ts +12 -2
  143. package/dist/cli/src/commands/outdated.d.ts.map +1 -1
  144. package/dist/cli/src/commands/project.d.ts +2 -2
  145. package/dist/cli/src/commands/publish-core.d.ts +21 -0
  146. package/dist/cli/src/commands/publish-core.d.ts.map +1 -1
  147. package/dist/cli/src/commands/skailify-lib.d.ts +18 -1
  148. package/dist/cli/src/commands/skailify-lib.d.ts.map +1 -1
  149. package/dist/cli/src/commands/source-manifest-publish.d.ts.map +1 -1
  150. package/dist/cli/src/commands/store.d.ts.map +1 -1
  151. package/dist/cli/src/commands/update.d.ts.map +1 -1
  152. package/dist/cli/src/commands/validate.d.ts.map +1 -1
  153. package/dist/cli/src/paths.d.ts +1 -1
  154. package/dist/cli/src/paths.d.ts.map +1 -1
  155. package/dist/cli/src/store-auth.d.ts.map +1 -1
  156. package/dist/connectors/config.js +6 -5
  157. package/dist/connectors/index.js +19 -18
  158. package/dist/connectors-shared/index.js +2 -2
  159. package/dist/core/index.js +8 -7
  160. package/dist/core/manifest.js +2 -2
  161. package/dist/core/models.js +1 -1
  162. package/dist/core/publish-manifest.js +2 -2
  163. package/dist/core/ref.js +1 -1
  164. package/dist/core/runtime-assets.js +6 -5
  165. package/dist/core/src/asset-roots.d.ts +2 -12
  166. package/dist/core/src/asset-roots.d.ts.map +1 -1
  167. package/dist/core/src/cache-paths.d.ts +7 -3
  168. package/dist/core/src/cache-paths.d.ts.map +1 -1
  169. package/dist/core/src/index.d.ts +3 -3
  170. package/dist/core/src/index.d.ts.map +1 -1
  171. package/dist/core/src/lock.d.ts +27 -4
  172. package/dist/core/src/lock.d.ts.map +1 -1
  173. package/dist/core/src/models.d.ts +26 -6
  174. package/dist/core/src/models.d.ts.map +1 -1
  175. package/dist/core/src/repo-manager.d.ts.map +1 -1
  176. package/dist/core/src/settings.d.ts +2 -1
  177. package/dist/core/src/settings.d.ts.map +1 -1
  178. package/dist/core/src/store.d.ts.map +1 -1
  179. package/dist/core/src/workspace-config.d.ts.map +1 -1
  180. package/dist/core/store.js +2 -1
  181. package/dist/core/workspace-config.js +5 -4
  182. package/dist/deploy/index.js +8 -7
  183. package/dist/deploy/index.js.map +1 -1
  184. package/dist/discovery/index.js +5 -5
  185. package/dist/discovery/src/domains.d.ts +6 -1
  186. package/dist/discovery/src/domains.d.ts.map +1 -1
  187. package/dist/discovery/src/index.d.ts +1 -1
  188. package/dist/discovery/src/index.d.ts.map +1 -1
  189. package/dist/{ensure-sources-IGU65O72.js → ensure-sources-VX63EKY7.js} +18 -17
  190. package/dist/ensure-sources-VX63EKY7.js.map +1 -0
  191. package/dist/factory-assets/connectors/box.js +19 -18
  192. package/dist/factory-assets/connectors/deploy.js +19 -18
  193. package/dist/factory-assets/connectors/devserver.js +19 -18
  194. package/dist/factory-assets/connectors/flow/adapter.js +19 -18
  195. package/dist/factory-assets/connectors/flow/engine.js +9 -8
  196. package/dist/factory-assets/connectors/flow/run-flow.js +21 -20
  197. package/dist/factory-assets/connectors/flow.js +19 -18
  198. package/dist/factory-assets/connectors/git.js +19 -18
  199. package/dist/factory-assets/connectors/gmail.js +19 -18
  200. package/dist/factory-assets/connectors/googledrive.js +19 -18
  201. package/dist/factory-assets/connectors/local.js +19 -18
  202. package/dist/factory-assets/connectors/mattermost.js +19 -18
  203. package/dist/factory-assets/connectors/memory.js +19 -18
  204. package/dist/factory-assets/connectors/minio.js +19 -18
  205. package/dist/factory-assets/connectors/postgres.js +19 -18
  206. package/dist/factory-assets/connectors/s3.js +19 -18
  207. package/dist/factory-assets/connectors/sharepoint.js +19 -18
  208. package/dist/factory-assets/connectors/sqlite.js +19 -18
  209. package/dist/factory-assets/connectors/static-server.js +19 -18
  210. package/dist/factory-assets/connectors/tunnel.js +19 -18
  211. package/dist/factory-assets/connectors/webdav.js +19 -18
  212. package/dist/factory-assets/connectors/xstate-store.js +19 -18
  213. package/dist/factory-assets/connectors/xstate.js +19 -18
  214. package/dist/flows-PX53XFV7.js +25 -0
  215. package/dist/{flows-6MDMBQUZ.js.map → flows-PX53XFV7.js.map} +1 -1
  216. package/dist/{helpers-IELIL4YR.js → helpers-DF55G2YC.js} +18 -17
  217. package/dist/{helpers-IELIL4YR.js.map → helpers-DF55G2YC.js.map} +1 -1
  218. package/dist/library/index.js +12 -11
  219. package/dist/library/install.js +2 -2
  220. package/dist/library/src/config.d.ts +11 -9
  221. package/dist/library/src/config.d.ts.map +1 -1
  222. package/dist/library/src/index.d.ts +2 -2
  223. package/dist/library/src/index.d.ts.map +1 -1
  224. package/dist/library/src/local/db.d.ts.map +1 -1
  225. package/dist/library/src/local/library-manager.d.ts +7 -0
  226. package/dist/library/src/local/library-manager.d.ts.map +1 -1
  227. package/dist/library/src/local/library.d.ts +5 -4
  228. package/dist/library/src/local/library.d.ts.map +1 -1
  229. package/dist/library/src/local/schema.d.ts +2 -0
  230. package/dist/library/src/local/schema.d.ts.map +1 -1
  231. package/dist/library/src/local/sidecar-paths.d.ts.map +1 -1
  232. package/dist/library/src/local/store-paths.d.ts.map +1 -1
  233. package/dist/library/src/remote/cache.d.ts.map +1 -1
  234. package/dist/library/src/sync/git-driver.d.ts +34 -0
  235. package/dist/library/src/sync/git-driver.d.ts.map +1 -1
  236. package/dist/{library-publish-YKBYHZ43.js → library-publish-2PNWJJOY.js} +95 -41
  237. package/dist/library-publish-2PNWJJOY.js.map +1 -0
  238. package/dist/open-library-SUVOMIWZ.js +38 -0
  239. package/dist/{open-library-ULRYWTEA.js.map → open-library-SUVOMIWZ.js.map} +1 -1
  240. package/dist/paths-W4LDORQQ.js +21 -0
  241. package/dist/{paths-4MTICP3T.js.map → paths-W4LDORQQ.js.map} +1 -1
  242. package/dist/{plugin-store-GQ4WQZJ2.js → plugin-store-D45CREMJ.js} +10 -9
  243. package/dist/plugin-store-D45CREMJ.js.map +1 -0
  244. package/dist/project-RTLVOXUU.js +34 -0
  245. package/dist/{project-VKYNDEB6.js.map → project-RTLVOXUU.js.map} +1 -1
  246. package/dist/resolver/index.js +9 -8
  247. package/dist/runner/index.js +28 -27
  248. package/dist/runner/src/composition/bootstrap.d.ts +1 -1
  249. package/dist/runner/src/composition/bootstrap.d.ts.map +1 -1
  250. package/dist/runner/src/runtime-session-emit.d.ts +2 -1
  251. package/dist/runner/src/runtime-session-emit.d.ts.map +1 -1
  252. package/dist/runner/src/serve.d.ts.map +1 -1
  253. package/dist/sdk/asset-manager.js +15 -14
  254. package/dist/sdk/bridge.js +15 -14
  255. package/dist/sdk/core.js +8 -7
  256. package/dist/sdk/flow.js +9 -8
  257. package/dist/sdk/index.js +28 -27
  258. package/dist/sdk/index.js.map +1 -1
  259. package/dist/sdk/resolver.js +9 -8
  260. package/dist/sdk/runner.js +28 -27
  261. package/dist/sdk/session.js +2 -2
  262. package/dist/sdk/types.js +1 -1
  263. package/dist/secrets/index.js +18 -1
  264. package/dist/secrets/src/providers/local.d.ts.map +1 -1
  265. package/dist/session/index.js +2 -2
  266. package/dist/{setup-INJFK3VJ.js → setup-ZA7VZL72.js} +25 -24
  267. package/dist/setup-ZA7VZL72.js.map +1 -0
  268. package/dist/skills-R3RPIPWP.js +25 -0
  269. package/dist/{skills-JHUY4DFE.js.map → skills-R3RPIPWP.js.map} +1 -1
  270. package/dist/{source-IZXICUBU.js → source-Y5YQ7M53.js} +21 -20
  271. package/dist/{source-IZXICUBU.js.map → source-Y5YQ7M53.js.map} +1 -1
  272. package/dist/{source-manifest-publish-4JHOT4PA.js → source-manifest-publish-RZIJNRIW.js} +24 -25
  273. package/dist/source-manifest-publish-RZIJNRIW.js.map +1 -0
  274. package/dist/tui/index.js +28 -27
  275. package/dist/tui/index.js.map +1 -1
  276. package/dist/types/index.js +1 -1
  277. package/dist/types/manifests.js +1 -1
  278. package/dist/types/src/events.d.ts +4 -2
  279. package/dist/types/src/events.d.ts.map +1 -1
  280. package/dist/types/src/manifests/index.d.ts +1 -1
  281. package/dist/types/src/manifests/index.d.ts.map +1 -1
  282. package/dist/types/src/manifests/skill.d.ts +10 -0
  283. package/dist/types/src/manifests/skill.d.ts.map +1 -1
  284. package/dist/workspace-plugin/adapters/mcp.js +15 -14
  285. package/dist/workspace-plugin/adapters/omp.js +7 -7
  286. package/dist/workspace-plugin/index.js +1 -1
  287. package/package.json +1 -1
  288. package/dist/asset-feeds-KTRFFJYM.js.map +0 -1
  289. package/dist/chunk-2D3C4AJP.js.map +0 -1
  290. package/dist/chunk-6BEGKO2Q.js.map +0 -1
  291. package/dist/chunk-BSIHJZKN.js.map +0 -1
  292. package/dist/chunk-DFZDL62S.js.map +0 -1
  293. package/dist/chunk-FJYOQMXT.js.map +0 -1
  294. package/dist/chunk-KIFJWSNC.js.map +0 -1
  295. package/dist/chunk-MDBAEEY5.js.map +0 -1
  296. package/dist/chunk-MIRWAK5C.js +0 -158
  297. package/dist/chunk-MIRWAK5C.js.map +0 -1
  298. package/dist/chunk-QKXDRBLL.js.map +0 -1
  299. package/dist/chunk-R2SYODNK.js.map +0 -1
  300. package/dist/chunk-USJWXEXS.js.map +0 -1
  301. package/dist/chunk-V2OQ3BI6.js.map +0 -1
  302. package/dist/chunk-VCLN2IUM.js.map +0 -1
  303. package/dist/chunk-XN7DAZB7.js.map +0 -1
  304. package/dist/ensure-sources-IGU65O72.js.map +0 -1
  305. package/dist/flows-6MDMBQUZ.js +0 -24
  306. package/dist/library-publish-YKBYHZ43.js.map +0 -1
  307. package/dist/open-library-ULRYWTEA.js +0 -37
  308. package/dist/paths-4MTICP3T.js +0 -20
  309. package/dist/plugin-store-GQ4WQZJ2.js.map +0 -1
  310. package/dist/project-VKYNDEB6.js +0 -33
  311. package/dist/setup-INJFK3VJ.js.map +0 -1
  312. package/dist/skills-JHUY4DFE.js +0 -24
  313. package/dist/source-manifest-publish-4JHOT4PA.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { tryWithFsDeadline, withFsDeadline, fsDeadlineMs } from './chunk-SQ7IN7KR.js';
1
+ import { tryWithFsDeadline, withFsDeadline, fsDeadlineMs } from './chunk-5K2VT6E2.js';
2
2
  import { createLogger } from './chunk-BOFL7GIF.js';
3
3
  import { stat, mkdir, cp, writeFile, rm } from 'fs/promises';
4
4
  import { resolve, sep, join } from 'path';
@@ -155,5 +155,5 @@ function resolveFlowSkills(flow, allEntries) {
155
155
  }
156
156
 
157
157
  export { WORKSPACE_MOUNT_ENV_VAR, deployAll, deployCatalogEntry, findAiAssetsRoot, isUnderWorkspaceMount, resolveFlowSkills, undeployCatalogEntry, workspaceMountDirs };
158
- //# sourceMappingURL=chunk-5JAO4MXA.js.map
159
- //# sourceMappingURL=chunk-5JAO4MXA.js.map
158
+ //# sourceMappingURL=chunk-DOVURNRK.js.map
159
+ //# sourceMappingURL=chunk-DOVURNRK.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../asset-manager/src/catalog-deployer.ts"],"names":[],"mappings":";;;;;AA2GA,IAAM,uBAAA,GAA0B,CAAA;AAGhC,IAAM,qBAAA,GAAwB,CAAA;AAE9B,IAAI,cAAA;AAEJ,SAAS,GAAA,GAAuC;AAC9C,EAAA,cAAA,KAAmB,aAAa,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,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AU,QAAA,EAAU,OAAA,EAAQ;AACvC","file":"chunk-5JAO4MXA.js","sourcesContent":["/**\n * Platform-triggered asset deployment.\n *\n * Takes catalog entries (with source_path relative to ai-assets/) and deploys\n * them to a session's .claude/skills/ directory. Handles skill context injection\n * and catalog priority-based name resolution.\n */\n\nimport { cp, mkdir, rm, stat, writeFile } from \"node:fs/promises\";\nimport { join, resolve, sep } from \"node:path\";\nimport { fsDeadlineMs, tryWithFsDeadline, withFsDeadline } from \"@skaile/workspaces/core\";\nimport { createLogger } from \"@skaile/workspaces/core/logging\";\n\n// ---------------------------------------------------------------------------\n// Types (formerly in catalog-compiler.ts, inlined after tear-out in Task 1.5)\n// ---------------------------------------------------------------------------\n\n/**\n * A single user-facing input parameter declared in a SKILL.md.\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface InputSpec {\n /** Input parameter key used in skill invocation. */\n key: string;\n /** Whether the input must be provided before running the skill. */\n required?: boolean;\n /** Question string shown to the user when collecting this input. */\n prompt?: string;\n /** Short display label for UI forms. */\n label?: string;\n /** Input data type hint (e.g. `\"string\"`, `\"number\"`, `\"file\"`). */\n type?: string;\n /** Additional guidance text shown alongside the input field. */\n hint?: string;\n}\n\n/**\n * A compiled catalog entry (skill or flow).\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface CatalogEntryCompiled {\n /** Unique ID in `domain/name` form (e.g. `skaileup-conceptualization/cf_overview`). */\n id: string;\n /** Asset kind. */\n kind: \"skill\" | \"flow\";\n /** Human-readable asset name. */\n name: string;\n /** One-line description. */\n description: string;\n /** Semantic version string. */\n version: string;\n /** Maturity stage. */\n stage: \"alpha\" | \"beta\" | \"stable\";\n /** Searchable keywords. */\n keywords: string[];\n /** User-facing input specifications. */\n inputs: InputSpec[];\n /** Domain directory name. */\n source_domain: string;\n /** Asset path relative to assetsRoot. */\n source_path: string;\n /** Optional icon identifier. */\n icon?: string;\n /** Flow-only: required skill names. */\n required_skills?: string[];\n /** Flow-only: optional skill names. */\n optional_skills?: string[];\n}\n\n/**\n * Options controlling how platform-triggered skill deployment is performed.\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface DeployFromCatalogOptions {\n /** Root directory of ai-assets (where `source_path` in catalog entries is relative to). */\n assetsRoot: string;\n /** Target directory for deployed skills (e.g. `/workspace/.claude/skills/`). */\n skillsDir: string;\n /** Optional context markdown appended to the deployed skill directory as `CONTEXT.md`. */\n context?: string;\n}\n\n/**\n * Result of a platform-triggered batch skill deployment.\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface DeployResult {\n /** IDs of catalog entries successfully deployed. */\n deployed: string[];\n /** IDs of catalog entries skipped (non-skill kinds). */\n skipped: string[];\n /** Error messages for entries that could not be deployed. */\n errors: string[];\n}\n\n// ---------------------------------------------------------------------------\n// Workspace-mount awareness\n// ---------------------------------------------------------------------------\n\n/**\n * Multiplier applied to the base filesystem deadline for whole-tree operations\n * (recursive copy / remove), which legitimately outlast a single `stat`.\n */\nconst TREE_OP_DEADLINE_FACTOR = 4;\n\n/** Default number of parent levels {@link findAiAssetsRoot} inspects. */\nconst AI_ASSETS_WALK_LEVELS = 6;\n\nlet deployerLogger: ReturnType<typeof createLogger> | undefined;\n\nfunction log(): ReturnType<typeof createLogger> {\n deployerLogger ??= createLogger({ kind: \"runner\", subkind: \"catalog-deployer\" });\n return deployerLogger;\n}\n\n/**\n * Where the agent container binds its rclone FUSE mount. Nothing under this\n * path is a safe place to read an asset tree from: the mount is remote\n * (SharePoint / OneDrive / WebDAV) and can wedge indefinitely.\n */\nconst DEFAULT_WORKSPACE_MOUNT_DIR = \"/skaile/workspace\";\n\n/**\n * Env override for the workspace-mount path(s), comma-separated.\n *\n * Set it when the runner binds the mount somewhere other than\n * {@link DEFAULT_WORKSPACE_MOUNT_DIR}; set it to the empty string to disable\n * the guard entirely (single-machine dev, where nothing is a network mount).\n */\nexport const WORKSPACE_MOUNT_ENV_VAR = \"SKAILE_WORKSPACE_MOUNT_DIR\";\n\n/**\n * Resolve the directories treated as network mounts.\n *\n * Read per call rather than cached: the runner mutates `process.env` while\n * wiring a session, so a module-load snapshot would pin a pre-configuration\n * value.\n *\n * @returns Absolute mount paths; empty when the guard is disabled.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport function workspaceMountDirs(): string[] {\n const raw = process.env[WORKSPACE_MOUNT_ENV_VAR];\n if (raw === undefined) return [DEFAULT_WORKSPACE_MOUNT_DIR];\n return raw\n .split(\",\")\n .map((segment) => segment.trim())\n .filter((segment) => segment.length > 0)\n .map((segment) => resolve(segment));\n}\n\n/**\n * Is `candidate` at, or inside, one of the known workspace mount paths?\n *\n * Pure path arithmetic — deliberately no filesystem access, because the whole\n * point is to decide *before* touching a path that might be unresponsive.\n *\n * @param candidate - Path to test.\n * @param mountDirs - Mount roots; defaults to {@link workspaceMountDirs}.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport function isUnderWorkspaceMount(\n candidate: string,\n mountDirs: string[] = workspaceMountDirs(),\n): boolean {\n const target = resolve(candidate);\n return mountDirs.some((dir) => {\n const root = resolve(dir);\n return target === root || target.startsWith(root + sep);\n });\n}\n\n/**\n * Walk upward from `startDir` looking for an `ai-assets/` directory.\n *\n * Two properties matter beyond \"find the folder\":\n *\n * 1. **Never synchronous.** The walk probes up to six directories; any one of\n * them can be on a FUSE mount, and the former `existsSync` chain blocked the\n * event loop on the first unresponsive probe. Each probe is now awaited and\n * deadline-bounded, so a wedged mount costs one skipped candidate.\n * 2. **Never resolves onto a mount.** A hit under the workspace mount is\n * skipped with a warning rather than returned: accepting it would wire every\n * later skill deploy — a recursive copy — to a remote filesystem. The walk\n * continues upward, so a legitimate `ai-assets/` in a parent still wins.\n *\n * Only a **directory** counts. An `ai-assets` file would otherwise be returned\n * as a root and every later `join(root, source_path)` would fail with ENOTDIR.\n *\n * @param startDir - Directory to start from (typically the project dir).\n * @param opts - `levels` caps the upward walk; `mountDirs` overrides the mount\n * roots (defaults to {@link workspaceMountDirs}).\n * @returns Absolute path to the `ai-assets/` directory, or `null` if none is\n * reachable within `levels`.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function findAiAssetsRoot(\n startDir: string,\n opts?: { levels?: number; mountDirs?: string[] },\n): Promise<string | null> {\n const mountDirs = opts?.mountDirs ?? workspaceMountDirs();\n const levels = opts?.levels ?? AI_ASSETS_WALK_LEVELS;\n let dir = resolve(startDir);\n // Every level of a `/skaile/workspace/...` start dir is under the mount, so\n // an unconditional warn would fire once per level for one lookup. Collect and\n // report once — the operator needs the fact, not six copies of it.\n const refused: string[] = [];\n\n for (let i = 0; i < levels; i++) {\n const candidate = join(dir, \"ai-assets\");\n if (isUnderWorkspaceMount(candidate, mountDirs)) {\n refused.push(candidate);\n } else {\n const isDir = await tryWithFsDeadline(\n `stat ${candidate}`,\n async () => (await stat(candidate)).isDirectory(),\n false,\n );\n if (isDir) {\n if (refused.length > 0) warnRefused(refused, mountDirs);\n return candidate;\n }\n }\n const parent = resolve(dir, \"..\");\n if (parent === dir) break; // filesystem root — nothing further up\n dir = parent;\n }\n if (refused.length > 0) warnRefused(refused, mountDirs);\n return null;\n}\n\n/** Single warning for every `ai-assets` candidate skipped for sitting on a mount. */\nfunction warnRefused(refused: string[], mountDirs: string[]): void {\n log().warn(\n \"findAiAssetsRoot refused candidates under a workspace mount — deploying skills from a network mount can stall the session\",\n { refused, mountDirs },\n );\n}\n\n/**\n * Deploy a single catalog entry to the session skills directory.\n *\n * Copies the entire skill source directory into `skillsDir/<entry.name>/`.\n * If `context` is provided, a separate `CONTEXT.md` is written alongside\n * `SKILL.md` so the source file is never modified.\n *\n * Only `skill` entries are deployable; other kinds return an error.\n *\n * **Async by necessity.** This runs from the `session_init` command handler\n * with the WebSocket live, and both `assetsRoot` and `skillsDir` can sit on a\n * network mount. The former `cpSync`/`rmSync` pair parked the event loop for\n * the whole copy; every call is now awaited and deadline-bounded, so an\n * unresponsive mount fails one deployment instead of the session.\n *\n * @param entry - Compiled catalog entry to deploy.\n * @param options - Deployment target and optional context.\n * @returns `{ success: true }` on success, `{ success: false, error }` on failure.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function deployCatalogEntry(\n entry: CatalogEntryCompiled,\n options: DeployFromCatalogOptions,\n): Promise<{ success: boolean; error?: string }> {\n const { assetsRoot, skillsDir, context } = options;\n\n if (entry.kind !== \"skill\") {\n return { success: false, error: `Cannot deploy ${entry.kind} directly — only skills` };\n }\n\n const sourcePath = join(assetsRoot, entry.source_path);\n const skillMdPath = join(sourcePath, \"SKILL.md\");\n\n const hasSkillMd = await tryWithFsDeadline(\n `stat ${skillMdPath}`,\n async () => {\n await stat(skillMdPath);\n return true;\n },\n false,\n );\n if (!hasSkillMd) {\n return { success: false, error: `SKILL.md not found at ${skillMdPath}` };\n }\n\n const destDir = join(skillsDir, entry.name);\n\n try {\n await withFsDeadline(`mkdir ${destDir}`, () => mkdir(destDir, { recursive: true }));\n\n // Copy the entire skill directory\n await withFsDeadline(\n `cp ${sourcePath} -> ${destDir}`,\n () => cp(sourcePath, destDir, { recursive: true }),\n fsDeadlineMs() * TREE_OP_DEADLINE_FACTOR,\n );\n\n // Write context to a separate CONTEXT.md — never modify the original SKILL.md.\n // The agent discovers both files in the skill directory.\n const contextPath = join(destDir, \"CONTEXT.md\");\n if (context) {\n await withFsDeadline(`write ${contextPath}`, () =>\n writeFile(contextPath, `# Additional Context\\n\\n${context}\\n`, \"utf8\"),\n );\n } else {\n // `force: true` makes this a single call: a stale CONTEXT.md is removed,\n // an absent one is a no-op. The former existsSync probe only added a\n // second trip to the same possibly-wedged mount.\n await withFsDeadline(`rm ${contextPath}`, () => rm(contextPath, { force: true }));\n }\n } catch (err) {\n return { success: false, error: err instanceof Error ? err.message : String(err) };\n }\n\n return { success: true };\n}\n\n/**\n * Remove a deployed skill directory from the session skills directory.\n *\n * @param name - Skill name (directory basename under `skillsDir`).\n * @param skillsDir - Absolute path to the session skills directory.\n * @returns `true` if the skill was found and removed; `false` if it was not\n * deployed, or if the directory could not be reached within the deadline.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function undeployCatalogEntry(name: string, skillsDir: string): Promise<boolean> {\n const destDir = join(skillsDir, name);\n const exists = await tryWithFsDeadline(\n `stat ${destDir}`,\n async () => {\n await stat(destDir);\n return true;\n },\n false,\n );\n if (!exists) return false;\n await withFsDeadline(\n `rm -r ${destDir}`,\n () => rm(destDir, { recursive: true, force: true }),\n fsDeadlineMs() * TREE_OP_DEADLINE_FACTOR,\n );\n return true;\n}\n\n/**\n * Deploy multiple catalog entries in a single batch operation.\n *\n * Non-skill entries (flows, agents, etc.) are automatically skipped and\n * recorded in `result.skipped`. Deployment failures are collected in\n * `result.errors` without aborting the rest of the batch.\n *\n * @param entries - Compiled catalog entries to deploy.\n * @param options - Deployment target and optional context.\n * @returns Aggregated {@link DeployResult} with deployed, skipped, and error lists.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function deployAll(\n entries: CatalogEntryCompiled[],\n options: DeployFromCatalogOptions,\n): Promise<DeployResult> {\n const result: DeployResult = { deployed: [], skipped: [], errors: [] };\n\n for (const entry of entries) {\n if (entry.kind !== \"skill\") {\n result.skipped.push(entry.id);\n continue;\n }\n\n // Serial on purpose: concurrent recursive copies onto one mount multiply\n // the queue depth on the exact resource that is already the bottleneck.\n const r = await deployCatalogEntry(entry, options);\n if (r.success) {\n result.deployed.push(entry.id);\n } else {\n result.errors.push(`${entry.id}: ${r.error}`);\n }\n }\n\n return result;\n}\n\n/**\n * Resolve a flow's skill dependencies from the full catalog entry list.\n *\n * Partitions `flow.required_skills` and `flow.optional_skills` into resolved\n * entries and a list of names that could not be found. Missing optional skills\n * are silently ignored (they do not appear in `missing`).\n *\n * @param flow - Compiled flow entry whose skill dependencies should be resolved.\n * @param allEntries - Full set of compiled catalog entries to search.\n * @returns Object containing resolved `required` entries, resolved `optional` entries,\n * and `missing` skill names that were listed as required but not found.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport function resolveFlowSkills(\n flow: CatalogEntryCompiled,\n allEntries: CatalogEntryCompiled[],\n): { required: CatalogEntryCompiled[]; optional: CatalogEntryCompiled[]; missing: string[] } {\n const skillsByName = new Map<string, CatalogEntryCompiled>();\n for (const e of allEntries) {\n if (e.kind === \"skill\") skillsByName.set(e.name, e);\n }\n\n const required: CatalogEntryCompiled[] = [];\n const optional: CatalogEntryCompiled[] = [];\n const missing: string[] = [];\n\n for (const name of flow.required_skills ?? []) {\n const entry = skillsByName.get(name);\n if (entry) required.push(entry);\n else missing.push(name);\n }\n\n for (const name of flow.optional_skills ?? []) {\n const entry = skillsByName.get(name);\n if (entry) optional.push(entry);\n // Optional skills don't count as missing\n }\n\n return { required, optional, missing };\n}\n"]}
1
+ {"version":3,"sources":["../asset-manager/src/catalog-deployer.ts"],"names":[],"mappings":";;;;;AA2GA,IAAM,uBAAA,GAA0B,CAAA;AAGhC,IAAM,qBAAA,GAAwB,CAAA;AAE9B,IAAI,cAAA;AAEJ,SAAS,GAAA,GAAuC;AAC9C,EAAA,cAAA,KAAmB,aAAa,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,oBAAoB,CAAA;AAC/E,EAAA,OAAO,cAAA;AACT;AAOA,IAAM,2BAAA,GAA8B,mBAAA;AAS7B,IAAM,uBAAA,GAA0B;AAYhC,SAAS,kBAAA,GAA+B;AAC7C,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,uBAAuB,CAAA;AAC/C,EAAA,IAAI,GAAA,KAAQ,MAAA,EAAW,OAAO,CAAC,2BAA2B,CAAA;AAC1D,EAAA,OAAO,GAAA,CACJ,MAAM,GAAG,CAAA,CACT,IAAI,CAAC,OAAA,KAAY,OAAA,CAAQ,IAAA,EAAM,CAAA,CAC/B,OAAO,CAAC,OAAA,KAAY,OAAA,CAAQ,MAAA,GAAS,CAAC,CAAA,CACtC,IAAI,CAAC,OAAA,KAAY,OAAA,CAAQ,OAAO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A,EAAY;AAC1B,IAAA,IAAI,EAAE,IAAA,KAAS,OAAA,eAAsB,GAAA,CAAI,CAAA,CAAE,MAAM,CAAC,CAAA;AAAA,EACpD;AAEA,EAAA,MAAM,WAAmC,EAAC;AAC1C,EAAA,MAAM,WAAmC,EAAC;AAC1C,EAAA,MAAM,UAAoB,EAAC;AAE3B,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,eAAA,IAAmB,EAAC,EAAG;AAC7C,IAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,GAAA,CAAI,IAAI,CAAA;AACnC,IAAA,IAAI,KAAA,EAAO,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA;AAAA,SACzB,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,EACxB;AAEA,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,eAAA,IAAmB,EAAC,EAAG;AAC7C,IAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,GAAA,CAAI,IAAI,CAAA;AACnC,IAAA,IAAI,KAAA,EAAO,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA;AAAA,EAEhC;AAEA,EAAA,OAAO,EAAE,QAAA,EAAU,QAAA,EAAU,OAAA,EAAQ;AACvC","file":"chunk-DOVURNRK.js","sourcesContent":["/**\n * Platform-triggered asset deployment.\n *\n * Takes catalog entries (with source_path relative to ai-assets/) and deploys\n * them to a session's .claude/skills/ directory. Handles skill context injection\n * and catalog priority-based name resolution.\n */\n\nimport { cp, mkdir, rm, stat, writeFile } from \"node:fs/promises\";\nimport { join, resolve, sep } from \"node:path\";\nimport { fsDeadlineMs, tryWithFsDeadline, withFsDeadline } from \"@skaile/workspaces/core\";\nimport { createLogger } from \"@skaile/workspaces/core/logging\";\n\n// ---------------------------------------------------------------------------\n// Types (formerly in catalog-compiler.ts, inlined after tear-out in Task 1.5)\n// ---------------------------------------------------------------------------\n\n/**\n * A single user-facing input parameter declared in a SKILL.md.\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface InputSpec {\n /** Input parameter key used in skill invocation. */\n key: string;\n /** Whether the input must be provided before running the skill. */\n required?: boolean;\n /** Question string shown to the user when collecting this input. */\n prompt?: string;\n /** Short display label for UI forms. */\n label?: string;\n /** Input data type hint (e.g. `\"string\"`, `\"number\"`, `\"file\"`). */\n type?: string;\n /** Additional guidance text shown alongside the input field. */\n hint?: string;\n}\n\n/**\n * A compiled catalog entry (skill or flow).\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface CatalogEntryCompiled {\n /** Unique ID in `domain/name` form (e.g. `skaileup-conceptualization/cf_overview`). */\n id: string;\n /** Asset kind. */\n kind: \"skill\" | \"flow\";\n /** Human-readable asset name. */\n name: string;\n /** One-line description. */\n description: string;\n /** Semantic version string. */\n version: string;\n /** Maturity stage. */\n stage: \"alpha\" | \"beta\" | \"stable\";\n /** Searchable keywords. */\n keywords: string[];\n /** User-facing input specifications. */\n inputs: InputSpec[];\n /** Domain directory name. */\n source_domain: string;\n /** Asset path relative to assetsRoot. */\n source_path: string;\n /** Optional icon identifier. */\n icon?: string;\n /** Flow-only: required skill names. */\n required_skills?: string[];\n /** Flow-only: optional skill names. */\n optional_skills?: string[];\n}\n\n/**\n * Options controlling how platform-triggered skill deployment is performed.\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface DeployFromCatalogOptions {\n /** Root directory of ai-assets (where `source_path` in catalog entries is relative to). */\n assetsRoot: string;\n /** Target directory for deployed skills (e.g. `/workspace/.claude/skills/`). */\n skillsDir: string;\n /** Optional context markdown appended to the deployed skill directory as `CONTEXT.md`. */\n context?: string;\n}\n\n/**\n * Result of a platform-triggered batch skill deployment.\n *\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport interface DeployResult {\n /** IDs of catalog entries successfully deployed. */\n deployed: string[];\n /** IDs of catalog entries skipped (non-skill kinds). */\n skipped: string[];\n /** Error messages for entries that could not be deployed. */\n errors: string[];\n}\n\n// ---------------------------------------------------------------------------\n// Workspace-mount awareness\n// ---------------------------------------------------------------------------\n\n/**\n * Multiplier applied to the base filesystem deadline for whole-tree operations\n * (recursive copy / remove), which legitimately outlast a single `stat`.\n */\nconst TREE_OP_DEADLINE_FACTOR = 4;\n\n/** Default number of parent levels {@link findAiAssetsRoot} inspects. */\nconst AI_ASSETS_WALK_LEVELS = 6;\n\nlet deployerLogger: ReturnType<typeof createLogger> | undefined;\n\nfunction log(): ReturnType<typeof createLogger> {\n deployerLogger ??= createLogger({ kind: \"runner\", subkind: \"catalog-deployer\" });\n return deployerLogger;\n}\n\n/**\n * Where the agent container binds its rclone FUSE mount. Nothing under this\n * path is a safe place to read an asset tree from: the mount is remote\n * (SharePoint / OneDrive / WebDAV) and can wedge indefinitely.\n */\nconst DEFAULT_WORKSPACE_MOUNT_DIR = \"/skaile/workspace\";\n\n/**\n * Env override for the workspace-mount path(s), comma-separated.\n *\n * Set it when the runner binds the mount somewhere other than\n * {@link DEFAULT_WORKSPACE_MOUNT_DIR}; set it to the empty string to disable\n * the guard entirely (single-machine dev, where nothing is a network mount).\n */\nexport const WORKSPACE_MOUNT_ENV_VAR = \"SKAILE_WORKSPACE_MOUNT_DIR\";\n\n/**\n * Resolve the directories treated as network mounts.\n *\n * Read per call rather than cached: the runner mutates `process.env` while\n * wiring a session, so a module-load snapshot would pin a pre-configuration\n * value.\n *\n * @returns Absolute mount paths; empty when the guard is disabled.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport function workspaceMountDirs(): string[] {\n const raw = process.env[WORKSPACE_MOUNT_ENV_VAR];\n if (raw === undefined) return [DEFAULT_WORKSPACE_MOUNT_DIR];\n return raw\n .split(\",\")\n .map((segment) => segment.trim())\n .filter((segment) => segment.length > 0)\n .map((segment) => resolve(segment));\n}\n\n/**\n * Is `candidate` at, or inside, one of the known workspace mount paths?\n *\n * Pure path arithmetic — deliberately no filesystem access, because the whole\n * point is to decide *before* touching a path that might be unresponsive.\n *\n * @param candidate - Path to test.\n * @param mountDirs - Mount roots; defaults to {@link workspaceMountDirs}.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport function isUnderWorkspaceMount(\n candidate: string,\n mountDirs: string[] = workspaceMountDirs(),\n): boolean {\n const target = resolve(candidate);\n return mountDirs.some((dir) => {\n const root = resolve(dir);\n return target === root || target.startsWith(root + sep);\n });\n}\n\n/**\n * Walk upward from `startDir` looking for an `ai-assets/` directory.\n *\n * Two properties matter beyond \"find the folder\":\n *\n * 1. **Never synchronous.** The walk probes up to six directories; any one of\n * them can be on a FUSE mount, and the former `existsSync` chain blocked the\n * event loop on the first unresponsive probe. Each probe is now awaited and\n * deadline-bounded, so a wedged mount costs one skipped candidate.\n * 2. **Never resolves onto a mount.** A hit under the workspace mount is\n * skipped with a warning rather than returned: accepting it would wire every\n * later skill deploy — a recursive copy — to a remote filesystem. The walk\n * continues upward, so a legitimate `ai-assets/` in a parent still wins.\n *\n * Only a **directory** counts. An `ai-assets` file would otherwise be returned\n * as a root and every later `join(root, source_path)` would fail with ENOTDIR.\n *\n * @param startDir - Directory to start from (typically the project dir).\n * @param opts - `levels` caps the upward walk; `mountDirs` overrides the mount\n * roots (defaults to {@link workspaceMountDirs}).\n * @returns Absolute path to the `ai-assets/` directory, or `null` if none is\n * reachable within `levels`.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function findAiAssetsRoot(\n startDir: string,\n opts?: { levels?: number; mountDirs?: string[] },\n): Promise<string | null> {\n const mountDirs = opts?.mountDirs ?? workspaceMountDirs();\n const levels = opts?.levels ?? AI_ASSETS_WALK_LEVELS;\n let dir = resolve(startDir);\n // Every level of a `/skaile/workspace/...` start dir is under the mount, so\n // an unconditional warn would fire once per level for one lookup. Collect and\n // report once — the operator needs the fact, not six copies of it.\n const refused: string[] = [];\n\n for (let i = 0; i < levels; i++) {\n const candidate = join(dir, \"ai-assets\");\n if (isUnderWorkspaceMount(candidate, mountDirs)) {\n refused.push(candidate);\n } else {\n const isDir = await tryWithFsDeadline(\n `stat ${candidate}`,\n async () => (await stat(candidate)).isDirectory(),\n false,\n );\n if (isDir) {\n if (refused.length > 0) warnRefused(refused, mountDirs);\n return candidate;\n }\n }\n const parent = resolve(dir, \"..\");\n if (parent === dir) break; // filesystem root — nothing further up\n dir = parent;\n }\n if (refused.length > 0) warnRefused(refused, mountDirs);\n return null;\n}\n\n/** Single warning for every `ai-assets` candidate skipped for sitting on a mount. */\nfunction warnRefused(refused: string[], mountDirs: string[]): void {\n log().warn(\n \"findAiAssetsRoot refused candidates under a workspace mount — deploying skills from a network mount can stall the session\",\n { refused, mountDirs },\n );\n}\n\n/**\n * Deploy a single catalog entry to the session skills directory.\n *\n * Copies the entire skill source directory into `skillsDir/<entry.name>/`.\n * If `context` is provided, a separate `CONTEXT.md` is written alongside\n * `SKILL.md` so the source file is never modified.\n *\n * Only `skill` entries are deployable; other kinds return an error.\n *\n * **Async by necessity.** This runs from the `session_init` command handler\n * with the WebSocket live, and both `assetsRoot` and `skillsDir` can sit on a\n * network mount. The former `cpSync`/`rmSync` pair parked the event loop for\n * the whole copy; every call is now awaited and deadline-bounded, so an\n * unresponsive mount fails one deployment instead of the session.\n *\n * @param entry - Compiled catalog entry to deploy.\n * @param options - Deployment target and optional context.\n * @returns `{ success: true }` on success, `{ success: false, error }` on failure.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function deployCatalogEntry(\n entry: CatalogEntryCompiled,\n options: DeployFromCatalogOptions,\n): Promise<{ success: boolean; error?: string }> {\n const { assetsRoot, skillsDir, context } = options;\n\n if (entry.kind !== \"skill\") {\n return { success: false, error: `Cannot deploy ${entry.kind} directly — only skills` };\n }\n\n const sourcePath = join(assetsRoot, entry.source_path);\n const skillMdPath = join(sourcePath, \"SKILL.md\");\n\n const hasSkillMd = await tryWithFsDeadline(\n `stat ${skillMdPath}`,\n async () => {\n await stat(skillMdPath);\n return true;\n },\n false,\n );\n if (!hasSkillMd) {\n return { success: false, error: `SKILL.md not found at ${skillMdPath}` };\n }\n\n const destDir = join(skillsDir, entry.name);\n\n try {\n await withFsDeadline(`mkdir ${destDir}`, () => mkdir(destDir, { recursive: true }));\n\n // Copy the entire skill directory\n await withFsDeadline(\n `cp ${sourcePath} -> ${destDir}`,\n () => cp(sourcePath, destDir, { recursive: true }),\n fsDeadlineMs() * TREE_OP_DEADLINE_FACTOR,\n );\n\n // Write context to a separate CONTEXT.md — never modify the original SKILL.md.\n // The agent discovers both files in the skill directory.\n const contextPath = join(destDir, \"CONTEXT.md\");\n if (context) {\n await withFsDeadline(`write ${contextPath}`, () =>\n writeFile(contextPath, `# Additional Context\\n\\n${context}\\n`, \"utf8\"),\n );\n } else {\n // `force: true` makes this a single call: a stale CONTEXT.md is removed,\n // an absent one is a no-op. The former existsSync probe only added a\n // second trip to the same possibly-wedged mount.\n await withFsDeadline(`rm ${contextPath}`, () => rm(contextPath, { force: true }));\n }\n } catch (err) {\n return { success: false, error: err instanceof Error ? err.message : String(err) };\n }\n\n return { success: true };\n}\n\n/**\n * Remove a deployed skill directory from the session skills directory.\n *\n * @param name - Skill name (directory basename under `skillsDir`).\n * @param skillsDir - Absolute path to the session skills directory.\n * @returns `true` if the skill was found and removed; `false` if it was not\n * deployed, or if the directory could not be reached within the deadline.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function undeployCatalogEntry(name: string, skillsDir: string): Promise<boolean> {\n const destDir = join(skillsDir, name);\n const exists = await tryWithFsDeadline(\n `stat ${destDir}`,\n async () => {\n await stat(destDir);\n return true;\n },\n false,\n );\n if (!exists) return false;\n await withFsDeadline(\n `rm -r ${destDir}`,\n () => rm(destDir, { recursive: true, force: true }),\n fsDeadlineMs() * TREE_OP_DEADLINE_FACTOR,\n );\n return true;\n}\n\n/**\n * Deploy multiple catalog entries in a single batch operation.\n *\n * Non-skill entries (flows, agents, etc.) are automatically skipped and\n * recorded in `result.skipped`. Deployment failures are collected in\n * `result.errors` without aborting the rest of the batch.\n *\n * @param entries - Compiled catalog entries to deploy.\n * @param options - Deployment target and optional context.\n * @returns Aggregated {@link DeployResult} with deployed, skipped, and error lists.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport async function deployAll(\n entries: CatalogEntryCompiled[],\n options: DeployFromCatalogOptions,\n): Promise<DeployResult> {\n const result: DeployResult = { deployed: [], skipped: [], errors: [] };\n\n for (const entry of entries) {\n if (entry.kind !== \"skill\") {\n result.skipped.push(entry.id);\n continue;\n }\n\n // Serial on purpose: concurrent recursive copies onto one mount multiply\n // the queue depth on the exact resource that is already the bottleneck.\n const r = await deployCatalogEntry(entry, options);\n if (r.success) {\n result.deployed.push(entry.id);\n } else {\n result.errors.push(`${entry.id}: ${r.error}`);\n }\n }\n\n return result;\n}\n\n/**\n * Resolve a flow's skill dependencies from the full catalog entry list.\n *\n * Partitions `flow.required_skills` and `flow.optional_skills` into resolved\n * entries and a list of names that could not be found. Missing optional skills\n * are silently ignored (they do not appear in `missing`).\n *\n * @param flow - Compiled flow entry whose skill dependencies should be resolved.\n * @param allEntries - Full set of compiled catalog entries to search.\n * @returns Object containing resolved `required` entries, resolved `optional` entries,\n * and `missing` skill names that were listed as required but not found.\n * @docLink packages/asset-manager/concepts#catalog-deployer\n */\nexport function resolveFlowSkills(\n flow: CatalogEntryCompiled,\n allEntries: CatalogEntryCompiled[],\n): { required: CatalogEntryCompiled[]; optional: CatalogEntryCompiled[]; missing: string[] } {\n const skillsByName = new Map<string, CatalogEntryCompiled>();\n for (const e of allEntries) {\n if (e.kind === \"skill\") skillsByName.set(e.name, e);\n }\n\n const required: CatalogEntryCompiled[] = [];\n const optional: CatalogEntryCompiled[] = [];\n const missing: string[] = [];\n\n for (const name of flow.required_skills ?? []) {\n const entry = skillsByName.get(name);\n if (entry) required.push(entry);\n else missing.push(name);\n }\n\n for (const name of flow.optional_skills ?? []) {\n const entry = skillsByName.get(name);\n if (entry) optional.push(entry);\n // Optional skills don't count as missing\n }\n\n return { required, optional, missing };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { parseAssetRef } from './chunk-GEEW6SY2.js';
1
+ import { parseAssetRef } from './chunk-A5EDMBFG.js';
2
2
  import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
3
3
  import { join, resolve } from 'path';
4
4
  import { stringify, parse } from 'yaml';
@@ -241,5 +241,5 @@ function saveSkPublishManifest(dir, manifest) {
241
241
  }
242
242
 
243
243
  export { SKAILE_MANIFEST_FILENAME, decodeSkaileManifest, encodeSkaileManifest, loadSkPublishManifest, saveSkPublishManifest };
244
- //# sourceMappingURL=chunk-P4VHQA4N.js.map
245
- //# sourceMappingURL=chunk-P4VHQA4N.js.map
244
+ //# sourceMappingURL=chunk-DSB6X25D.js.map
245
+ //# sourceMappingURL=chunk-DSB6X25D.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../core/src/publish-manifest.ts"],"names":[],"mappings":";;;;;AAmJO,IAAM,wBAAA,GAA2B;AAIxC,SAAS,YAAY,GAAA,EAA0C;AAC7D,EAAA,IAAI,CAAC,OAAO,OAAO,GAAA,KAAQ,YAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA,EAAG,OAAO,MAAA;AAClE,EAAA,MAAM,CAAA,GAAI,GAAA;AACV,EAAA,IAAI,OAAO,EAAE,GAAA,KAAQ,QAAA,IAAY,EAAE,GAAA,CAAI,MAAA,KAAW,GAAG,OAAO,MAAA;AAC5D,EAAA,MAAM,GAAA,GAAsB,EAAE,GAAA,EAAK,CAAA,CAAE,GAAA,EAAI;AACzC,EAAA,IAAI,OAAO,CAAA,CAAE,MAAA,KAAW,QAAA,IAAY,CAAA,CAAE,OAAO,MAAA,GAAS,CAAA,EAAG,GAAA,CAAI,MAAA,GAAS,CAAA,CAAE,MAAA;AACxE,EAAA,OAAO,GAAA;AACT;AAEA,SAAS,gBAAgB,GAAA,EAA8C;AACrE,EAAA,IAAI,CAAC,OAAO,OAAO,GAAA,KAAQ,YAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA,EAAG,OAAO,MA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AAC,CAAA;AACtD,EAAA,OAAO,QAAA;AACT","file":"chunk-P4VHQA4N.js","sourcesContent":["/**\n * Publish manifest — `skaile.manifest.yaml`\n *\n * What a repo PUBLISHES: the `publisher` / `version` / `assets[]` that used to\n * live in the publication half of `skaile.yaml`, plus a per-asset dependency\n * graph, store-listing metadata, and an optional curator `source:` pointer.\n *\n * ── Two files, two codecs ──────────────────────────────────────────────────\n *\n * skaile.yaml → SkWorkspaceConfig (workspace + consumption)\n * skaile.manifest.yaml → SkPublishManifest (publication) ← this module\n *\n * A repo can have either file, both, or neither: a pure workspace has only\n * `skaile.yaml`; a pure asset repo (e.g. `ai-assets`) has only\n * `skaile.manifest.yaml`; a repo that is both has both.\n *\n * ── One format, three roles ────────────────────────────────────────────────\n *\n * First-party `source:` absent → bytes live in this repo (`root`/`files`).\n * Curator/sidecar `source:` present → bytes come from the referenced upstream,\n * verified by `sha256`.\n *\n * `decodeSkaileManifest` mirrors `decodeSkaileYaml`: total (never throws),\n * returns {@link Diagnostic}s. Dep-ref strings are validated with `parseAssetRef`.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parse, stringify } from \"yaml\";\nimport { parseAssetRef } from \"./models.js\";\nimport type { Diagnostic } from \"./workspace-config.js\";\n\n// ── Types ───────────────────────────────────────────────────────────────────\n\n/** One file inside a curated asset, pinned to an exact upstream blob hash. */\nexport interface ManifestFileEntry {\n path: string;\n /** 64-hex sha256 of the upstream blob. */\n sha256: string;\n}\n\n/**\n * One entry in a manifest's `assets:` list. Either `root:` (recursive walk) or\n * `files:` (explicit list, supports globs for first-party; the granular\n * `{path, sha256}` form for curated upstream verification) declares which paths\n * constitute the asset. `version:` overrides the manifest-level version.\n *\n * @docLink packages/core/publish-manifest#asset-entry\n */\nexport interface AssetEntry {\n kind: string;\n name: string;\n root?: string;\n /**\n * Explicit file listing. First-party manifests use bare `string[]` (globs,\n * fast-glob). Curated entries may use the granular `{path, sha256}` form so\n * the resolver fetches + verifies exact upstream blobs without a full clone.\n */\n files?: string[] | ManifestFileEntry[];\n version?: string;\n /** Per-asset publisher override (e.g. for curator/mirror repos). */\n publisher?: string;\n\n /**\n * Canonical dep refs (`kind:@<publisher>/name[#version]`) — same grammar as\n * `SkWorkspaceConfig.dependencies`. Authoritative for this asset's resolved\n * deps. (Was `requires` in `.skaile-source.yaml`.)\n */\n dependencies?: string[];\n\n /**\n * Author-pinned composite sha256 over the asset's `files`/`root` (same\n * deterministic algorithm as the walker + discovery). Optional locally;\n * REQUIRED on store publish. (Was `.skaile-source.yaml` `assets[].sha256`.)\n */\n sha256?: string;\n\n /**\n * Curator override: this single asset's bytes come from a different upstream\n * than the manifest-level `source`. Absent → inherit manifest `source` (or\n * first-party when that is also absent).\n */\n source?: ManifestSource;\n\n // ── Store-listing metadata (all optional; fall back to content frontmatter) ──\n description?: string;\n keywords?: string[];\n category?: string;\n license?: string;\n homepage?: string;\n}\n\n/**\n * Upstream the bytes come from when a manifest curates a repo it does not own.\n * Absent → first-party (bytes live in the manifest's own repo).\n *\n * @docLink packages/core/publish-manifest#manifest-source\n */\nexport interface ManifestSource {\n url: string;\n /** 40-char commit the curated bytes are pinned to. */\n commit?: string;\n}\n\n/**\n * Signing/attribution recorded when a manifest is published on behalf of others.\n *\n * @docLink packages/core/publish-manifest#manifest-provenance\n */\nexport interface ManifestProvenance {\n curator: string;\n signed_by?: string;\n}\n\n/**\n * Parsed `skaile.manifest.yaml` — what a repo publishes.\n *\n * @docLink packages/core/publish-manifest#sk-publish-manifest\n */\nexport interface SkPublishManifest {\n publisher?: string;\n version?: string;\n /** Repo-level store defaults inherited by assets unless overridden per-entry. */\n license?: string;\n homepage?: string;\n /**\n * Repo-relative path prefixes holding dev-only assets — excluded from\n * discovery/publish unless `--dev`. (Was `.skaile-source.yaml` `dev_paths`.)\n */\n dev_paths?: string[];\n /**\n * Curator mode: the single upstream all assets in this file come from. A\n * per-asset `source` overrides it. Absent → first-party (own repo).\n */\n source?: ManifestSource;\n /** Present when this manifest is curated/published on behalf of another author. */\n provenance?: ManifestProvenance;\n assets?: AssetEntry[];\n}\n\n/** Result of {@link decodeSkaileManifest}: the manifest plus any notes. */\nexport interface ManifestDecodeResult {\n manifest: SkPublishManifest;\n diagnostics: Diagnostic[];\n}\n\n/** The single fixed filename for a publish manifest. */\nexport const SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n// ── Decode ──────────────────────────────────────────────────────────────────\n\nfunction parseSource(raw: unknown): ManifestSource | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const s = raw as Record<string, unknown>;\n if (typeof s.url !== \"string\" || s.url.length === 0) return undefined;\n const out: ManifestSource = { url: s.url };\n if (typeof s.commit === \"string\" && s.commit.length > 0) out.commit = s.commit;\n return out;\n}\n\nfunction parseProvenance(raw: unknown): ManifestProvenance | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n if (typeof p.curator !== \"string\" || p.curator.length === 0) return undefined;\n const out: ManifestProvenance = { curator: p.curator };\n if (typeof p.signed_by === \"string\" && p.signed_by.length > 0) out.signed_by = p.signed_by;\n return out;\n}\n\n/** Parse `files:` as either `string[]` (globs) or `{path, sha256}[]` (granular). */\nfunction parseFiles(raw: unknown): string[] | ManifestFileEntry[] | undefined {\n if (!Array.isArray(raw)) return undefined;\n const strings: string[] = [];\n const granular: ManifestFileEntry[] = [];\n for (const item of raw) {\n if (typeof item === \"string\") {\n strings.push(item);\n } else if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const f = item as Record<string, unknown>;\n if (typeof f.path === \"string\" && typeof f.sha256 === \"string\") {\n granular.push({ path: f.path, sha256: f.sha256 });\n }\n }\n }\n // A manifest uses one form per entry; if both somehow appear, granular wins\n // (it is the verifiable form). Empty → undefined.\n if (granular.length > 0) return granular;\n if (strings.length > 0) return strings;\n return undefined;\n}\n\n/** Parse the YAML root, returning either the mapping or an error diagnostic. */\nfunction parseManifestRoot(\n text: string,\n): { ok: true; raw: Record<string, unknown> } | { ok: false; diagnostic: Diagnostic } {\n let parsed: unknown;\n try {\n parsed = parse(text) ?? {};\n } catch (err) {\n return {\n ok: false,\n diagnostic: {\n code: \"yaml_syntax\",\n severity: \"error\",\n message: `Invalid YAML: ${err instanceof Error ? err.message : String(err)}`,\n },\n };\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {\n ok: false,\n diagnostic: {\n code: \"non_object_root\",\n severity: \"error\",\n message: \"skaile.manifest.yaml must be a mapping at the top level.\",\n },\n };\n }\n return { ok: true, raw: parsed as Record<string, unknown> };\n}\n\n/**\n * Strip a SINGLE leading `@` from a publisher and, when one was removed, push a\n * `warning` diagnostic. The `@` is the scope sigil the ref formatter adds — an\n * authored `@acme` would otherwise index as `@@acme` and be un-addable. Bare\n * names are returned untouched.\n */\nfunction normalizePublisher(value: string, path: string, diagnostics: Diagnostic[]): string {\n if (!value.startsWith(\"@\")) return value;\n const stripped = value.slice(1);\n diagnostics.push({\n code: \"publisher_leading_sigil\",\n severity: \"warning\",\n message: `publisher \"${value}\": leading \"@\" is the scope sigil and is added automatically — use bare \"${stripped}\"`,\n path,\n });\n return stripped;\n}\n\n/** Decode the manifest-level scalar/array/object fields onto `manifest`. */\nfunction decodeManifestFields(\n raw: Record<string, unknown>,\n manifest: SkPublishManifest,\n diagnostics: Diagnostic[],\n): void {\n if (typeof raw.publisher === \"string\" && raw.publisher.length > 0) {\n manifest.publisher = normalizePublisher(raw.publisher, \"publisher\", diagnostics);\n }\n if (typeof raw.version === \"string\" && raw.version.length > 0) {\n manifest.version = raw.version;\n }\n if (typeof raw.license === \"string\" && raw.license.length > 0) {\n manifest.license = raw.license;\n }\n if (typeof raw.homepage === \"string\" && raw.homepage.length > 0) {\n manifest.homepage = raw.homepage;\n }\n if (Array.isArray(raw.dev_paths)) {\n const paths = raw.dev_paths.filter((p): p is string => typeof p === \"string\" && p.length > 0);\n if (paths.length > 0) manifest.dev_paths = paths;\n }\n const source = parseSource(raw.source);\n if (source) manifest.source = source;\n const provenance = parseProvenance(raw.provenance);\n if (provenance) manifest.provenance = provenance;\n}\n\n/**\n * Validate an asset's `dependencies` via `parseAssetRef`, pushing a `warning`\n * for each malformed ref. Returns the kept (valid) refs.\n */\nfunction decodeAssetDependencies(\n raw: unknown,\n kind: string,\n name: string,\n diagnostics: Diagnostic[],\n): string[] {\n const deps: string[] = [];\n if (!Array.isArray(raw)) return deps;\n for (const dep of raw) {\n if (typeof dep !== \"string\") continue;\n try {\n parseAssetRef(dep);\n deps.push(dep);\n } catch (err) {\n diagnostics.push({\n code: \"malformed_dependency\",\n severity: \"warning\",\n message: `assets[${kind}:${name}].dependencies: ${\n err instanceof Error ? err.message : String(err)\n }`,\n path: `assets.${kind}:${name}.dependencies`,\n });\n }\n }\n return deps;\n}\n\n/**\n * Decode one `assets[]` item into an {@link AssetEntry}, or `undefined` when the\n * item is not a mapping or lacks both `kind` and `name`. Pushes dependency\n * warnings to `diagnostics`.\n */\nfunction decodeAssetEntry(item: unknown, diagnostics: Diagnostic[]): AssetEntry | undefined {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const a = item as Record<string, unknown>;\n const kind = typeof a.kind === \"string\" ? a.kind : \"\";\n const name = typeof a.name === \"string\" ? a.name : \"\";\n if (!kind || !name) return undefined;\n const entry: AssetEntry = { kind, name };\n if (typeof a.root === \"string\") entry.root = a.root;\n const files = parseFiles(a.files);\n if (files) entry.files = files;\n if (typeof a.version === \"string\") entry.version = a.version;\n if (typeof a.publisher === \"string\")\n entry.publisher = normalizePublisher(\n a.publisher,\n `assets.${kind}:${name}.publisher`,\n diagnostics,\n );\n if (typeof a.sha256 === \"string\") entry.sha256 = a.sha256;\n const assetSource = parseSource(a.source);\n if (assetSource) entry.source = assetSource;\n\n const deps = decodeAssetDependencies(a.dependencies, kind, name, diagnostics);\n if (deps.length > 0) entry.dependencies = deps;\n\n if (typeof a.description === \"string\") entry.description = a.description;\n if (Array.isArray(a.keywords)) {\n const kw = a.keywords.filter((k): k is string => typeof k === \"string\");\n if (kw.length > 0) entry.keywords = kw;\n }\n if (typeof a.category === \"string\") entry.category = a.category;\n if (typeof a.license === \"string\") entry.license = a.license;\n if (typeof a.homepage === \"string\") entry.homepage = a.homepage;\n\n return entry;\n}\n\n/** Decode the `assets[]` list onto `manifest`, collecting dependency warnings. */\nfunction decodeManifestAssets(\n raw: Record<string, unknown>,\n manifest: SkPublishManifest,\n diagnostics: Diagnostic[],\n): void {\n if (!Array.isArray(raw.assets)) return;\n const entries: AssetEntry[] = [];\n for (const item of raw.assets) {\n const entry = decodeAssetEntry(item, diagnostics);\n if (entry) entries.push(entry);\n }\n if (entries.length > 0) manifest.assets = entries;\n}\n\n/**\n * Decode `skaile.manifest.yaml` text into a {@link SkPublishManifest} plus\n * {@link Diagnostic}s. Total — never throws: a YAML syntax error or non-object\n * root is reported as an `error`-severity diagnostic with an empty manifest.\n * Malformed `assets[].dependencies` refs are reported as `warning`s (validated\n * via `parseAssetRef`) rather than silently dropped.\n *\n * Pair with {@link encodeSkaileManifest} for round-tripping.\n * @docLink packages/core/publish-manifest#decode-skaile-manifest\n */\nexport function decodeSkaileManifest(text: string): ManifestDecodeResult {\n const root = parseManifestRoot(text);\n if (!root.ok) {\n return { manifest: {}, diagnostics: [root.diagnostic] };\n }\n\n const manifest: SkPublishManifest = {};\n const diagnostics: Diagnostic[] = [];\n decodeManifestFields(root.raw, manifest, diagnostics);\n decodeManifestAssets(root.raw, manifest, diagnostics);\n\n return { manifest, diagnostics };\n}\n\n// ── Encode ──────────────────────────────────────────────────────────────────\n\n/** Fixed top-level key order for {@link encodeSkaileManifest}. */\nconst MANIFEST_KEY_ORDER: (keyof SkPublishManifest)[] = [\n \"publisher\",\n \"version\",\n \"license\",\n \"homepage\",\n \"dev_paths\",\n \"source\",\n \"provenance\",\n \"assets\",\n];\n\n/** Fixed per-asset key order for {@link encodeSkaileManifest}. */\nconst ASSET_KEY_ORDER: (keyof AssetEntry)[] = [\n \"kind\",\n \"name\",\n \"source\",\n \"root\",\n \"files\",\n \"version\",\n \"publisher\",\n \"sha256\",\n \"dependencies\",\n \"description\",\n \"keywords\",\n \"category\",\n \"license\",\n \"homepage\",\n];\n\nfunction orderedAsset(a: AssetEntry): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key of ASSET_KEY_ORDER) {\n const value = a[key];\n if (value !== undefined) out[key] = value;\n }\n return out;\n}\n\n/**\n * Encode a {@link SkPublishManifest} to canonical `skaile.manifest.yaml` text:\n * deterministic key order, only defined fields, `lineWidth: 120` (mirrors\n * `encodeSkaileYaml`).\n * @docLink packages/core/publish-manifest#encode-skaile-manifest\n */\nexport function encodeSkaileManifest(manifest: SkPublishManifest): string {\n const out: Record<string, unknown> = {};\n for (const key of MANIFEST_KEY_ORDER) {\n const value = manifest[key];\n if (value === undefined) continue;\n if (key === \"assets\" && Array.isArray(value)) {\n out.assets = (value as AssetEntry[]).map(orderedAsset);\n } else {\n out[key] = value;\n }\n }\n return stringify(out, { lineWidth: 120 });\n}\n\n// ── File I/O ──────────────────────────────────────────────────────────────────\n\n/**\n * Load and decode `<dir>/skaile.manifest.yaml`. Returns `null` when the file is\n * absent or unparseable (mirrors `loadSkWorkspaceConfig`'s tolerant contract).\n * @docLink packages/core/publish-manifest#load-sk-publish-manifest\n */\nexport function loadSkPublishManifest(dir: string): SkPublishManifest | null {\n const filePath = join(resolve(dir), SKAILE_MANIFEST_FILENAME);\n if (!existsSync(filePath)) return null;\n let raw: string;\n try {\n raw = readFileSync(filePath, \"utf-8\");\n } catch {\n return null;\n }\n const { manifest, diagnostics } = decodeSkaileManifest(raw);\n if (diagnostics.some((d) => d.code === \"yaml_syntax\" || d.code === \"non_object_root\")) {\n return null;\n }\n return manifest;\n}\n\n/**\n * Encode and write a manifest to `<dir>/skaile.manifest.yaml`, creating the\n * directory if needed. Returns the absolute path written.\n * @docLink packages/core/publish-manifest#save-sk-publish-manifest\n */\nexport function saveSkPublishManifest(dir: string, manifest: SkPublishManifest): string {\n const resolvedDir = resolve(dir);\n const filePath = join(resolvedDir, SKAILE_MANIFEST_FILENAME);\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n writeFileSync(filePath, encodeSkaileManifest(manifest));\n return filePath;\n}\n"]}
1
+ {"version":3,"sources":["../core/src/publish-manifest.ts"],"names":[],"mappings":";;;;;AAmJO,IAAM,wBAAA,GAA2B;AAIxC,SAAS,YAAY,GAAA,EAA0C;AAC7D,EAAA,IAAI,CAAC,OAAO,OAAO,GAAA,KAAQ,YAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA,EAAG,OAAO,MAAA;AAClE,EAAA,MAAM,CAAA,GAAI,GAAA;AACV,EAAA,IAAI,OAAO,EAAE,GAAA,KAAQ,QAAA,IAAY,EAAE,GAAA,CAAI,MAAA,KAAW,GAAG,OAAO,MAAA;AAC5D,EAAA,MAAM,GAAA,GAAsB,EAAE,GAAA,EAAK,CAAA,CAAE,GAAA,EAAI;AACzC,EAAA,IAAI,OAAO,CAAA,CAAE,MAAA,KAAW,QAAA,IAAY,CAAA,CAAE,OAAO,MAAA,GAAS,CAAA,EAAG,GAAA,CAAI,MAAA,GAAS,CAAA,CAAE,MAAA;AACxE,EAAA,OAAO,GAAA;AACT;AAEA,SAAS,gBAAgB,GAAA,EAA8C;AACrE,EAAA,IAAI,CAAC,OAAO,OAAO,GAAA,KAAQ,YAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA,EAAG,OAAO,MAAA;AAClE,EAAA,MAAM,CAAA,GAAI,GAAA;AACV,EAAA,IAAI,OAAO,EAAE,OAAA,KAAY,QAAA,IAAY,EAAE,OAAA,CAAQ,MAAA,KAAW,GAAG,OAAO,MAAA;AACpE,EAAA,MAAM,GAAA,GAA0B,EAAE,OAAA,EAAS,CAAA,CAAE,OAAA,EAAQ;AACrD,EAAA,IAAI,OAAO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AA;AAC1C;AASO,SAAS,sBAAsB,GAAA,EAAuC;AAC3E,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,OAAA,CAAQ,GAAG,GAAG,wBAAwB,CAAA;AAC5D,EAAA,IAAI,CAAC,UAAA,CAAW,QAAQ,CAAA,EAAG,OAAO,IAAA;AAClC,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,YAAA,CAAa,UAAU,OAAO,CAAA;AAAA,EACtC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,EAAE,QAAA,EAAU,WAAA,EAAY,GAAI,qBAAqB,GAAG,CAAA;AAC1D,EAAA,IAAI,WAAA,CAAY,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,aAAA,IAAiB,CAAA,CAAE,IAAA,KAAS,iBAAiB,CAAA,EAAG;AACrF,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,QAAA;AACT;AAOO,SAAS,qBAAA,CAAsB,KAAa,QAAA,EAAqC;AACtF,EAAA,MAAM,WAAA,GAAc,QAAQ,GAAG,CAAA;AAC/B,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,WAAA,EAAa,wBAAwB,CAAA;AAC3D,EAAA,IAAI,CAAC,UAAA,CAAW,WAAW,CAAA,EAAG;AAC5B,IAAA,SAAA,CAAU,WAAA,EAAa,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAAA,EAC5C;AACA,EAAA,aAAA,CAAc,QAAA,EAAU,oBAAA,CAAqB,QAAQ,CAAC,CAAA;AACtD,EAAA,OAAO,QAAA;AACT","file":"chunk-DSB6X25D.js","sourcesContent":["/**\n * Publish manifest — `skaile.manifest.yaml`\n *\n * What a repo PUBLISHES: the `publisher` / `version` / `assets[]` that used to\n * live in the publication half of `skaile.yaml`, plus a per-asset dependency\n * graph, store-listing metadata, and an optional curator `source:` pointer.\n *\n * ── Two files, two codecs ──────────────────────────────────────────────────\n *\n * skaile.yaml → SkWorkspaceConfig (workspace + consumption)\n * skaile.manifest.yaml → SkPublishManifest (publication) ← this module\n *\n * A repo can have either file, both, or neither: a pure workspace has only\n * `skaile.yaml`; a pure asset repo (e.g. `ai-assets`) has only\n * `skaile.manifest.yaml`; a repo that is both has both.\n *\n * ── One format, three roles ────────────────────────────────────────────────\n *\n * First-party `source:` absent → bytes live in this repo (`root`/`files`).\n * Curator/sidecar `source:` present → bytes come from the referenced upstream,\n * verified by `sha256`.\n *\n * `decodeSkaileManifest` mirrors `decodeSkaileYaml`: total (never throws),\n * returns {@link Diagnostic}s. Dep-ref strings are validated with `parseAssetRef`.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parse, stringify } from \"yaml\";\nimport { parseAssetRef } from \"./models.js\";\nimport type { Diagnostic } from \"./workspace-config.js\";\n\n// ── Types ───────────────────────────────────────────────────────────────────\n\n/** One file inside a curated asset, pinned to an exact upstream blob hash. */\nexport interface ManifestFileEntry {\n path: string;\n /** 64-hex sha256 of the upstream blob. */\n sha256: string;\n}\n\n/**\n * One entry in a manifest's `assets:` list. Either `root:` (recursive walk) or\n * `files:` (explicit list, supports globs for first-party; the granular\n * `{path, sha256}` form for curated upstream verification) declares which paths\n * constitute the asset. `version:` overrides the manifest-level version.\n *\n * @docLink packages/core/publish-manifest#asset-entry\n */\nexport interface AssetEntry {\n kind: string;\n name: string;\n root?: string;\n /**\n * Explicit file listing. First-party manifests use bare `string[]` (globs,\n * fast-glob). Curated entries may use the granular `{path, sha256}` form so\n * the resolver fetches + verifies exact upstream blobs without a full clone.\n */\n files?: string[] | ManifestFileEntry[];\n version?: string;\n /** Per-asset publisher override (e.g. for curator/mirror repos). */\n publisher?: string;\n\n /**\n * Canonical dep refs (`kind:@<publisher>/name[#version]`) — same grammar as\n * `SkWorkspaceConfig.dependencies`. Authoritative for this asset's resolved\n * deps. (Was `requires` in `.skaile-source.yaml`.)\n */\n dependencies?: string[];\n\n /**\n * Author-pinned composite sha256 over the asset's `files`/`root` (same\n * deterministic algorithm as the walker + discovery). Optional locally;\n * REQUIRED on store publish. (Was `.skaile-source.yaml` `assets[].sha256`.)\n */\n sha256?: string;\n\n /**\n * Curator override: this single asset's bytes come from a different upstream\n * than the manifest-level `source`. Absent → inherit manifest `source` (or\n * first-party when that is also absent).\n */\n source?: ManifestSource;\n\n // ── Store-listing metadata (all optional; fall back to content frontmatter) ──\n description?: string;\n keywords?: string[];\n category?: string;\n license?: string;\n homepage?: string;\n}\n\n/**\n * Upstream the bytes come from when a manifest curates a repo it does not own.\n * Absent → first-party (bytes live in the manifest's own repo).\n *\n * @docLink packages/core/publish-manifest#manifest-source\n */\nexport interface ManifestSource {\n url: string;\n /** 40-char commit the curated bytes are pinned to. */\n commit?: string;\n}\n\n/**\n * Signing/attribution recorded when a manifest is published on behalf of others.\n *\n * @docLink packages/core/publish-manifest#manifest-provenance\n */\nexport interface ManifestProvenance {\n curator: string;\n signed_by?: string;\n}\n\n/**\n * Parsed `skaile.manifest.yaml` — what a repo publishes.\n *\n * @docLink packages/core/publish-manifest#sk-publish-manifest\n */\nexport interface SkPublishManifest {\n publisher?: string;\n version?: string;\n /** Repo-level store defaults inherited by assets unless overridden per-entry. */\n license?: string;\n homepage?: string;\n /**\n * Repo-relative path prefixes holding dev-only assets — excluded from\n * discovery/publish unless `--dev`. (Was `.skaile-source.yaml` `dev_paths`.)\n */\n dev_paths?: string[];\n /**\n * Curator mode: the single upstream all assets in this file come from. A\n * per-asset `source` overrides it. Absent → first-party (own repo).\n */\n source?: ManifestSource;\n /** Present when this manifest is curated/published on behalf of another author. */\n provenance?: ManifestProvenance;\n assets?: AssetEntry[];\n}\n\n/** Result of {@link decodeSkaileManifest}: the manifest plus any notes. */\nexport interface ManifestDecodeResult {\n manifest: SkPublishManifest;\n diagnostics: Diagnostic[];\n}\n\n/** The single fixed filename for a publish manifest. */\nexport const SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n// ── Decode ──────────────────────────────────────────────────────────────────\n\nfunction parseSource(raw: unknown): ManifestSource | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const s = raw as Record<string, unknown>;\n if (typeof s.url !== \"string\" || s.url.length === 0) return undefined;\n const out: ManifestSource = { url: s.url };\n if (typeof s.commit === \"string\" && s.commit.length > 0) out.commit = s.commit;\n return out;\n}\n\nfunction parseProvenance(raw: unknown): ManifestProvenance | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n if (typeof p.curator !== \"string\" || p.curator.length === 0) return undefined;\n const out: ManifestProvenance = { curator: p.curator };\n if (typeof p.signed_by === \"string\" && p.signed_by.length > 0) out.signed_by = p.signed_by;\n return out;\n}\n\n/** Parse `files:` as either `string[]` (globs) or `{path, sha256}[]` (granular). */\nfunction parseFiles(raw: unknown): string[] | ManifestFileEntry[] | undefined {\n if (!Array.isArray(raw)) return undefined;\n const strings: string[] = [];\n const granular: ManifestFileEntry[] = [];\n for (const item of raw) {\n if (typeof item === \"string\") {\n strings.push(item);\n } else if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const f = item as Record<string, unknown>;\n if (typeof f.path === \"string\" && typeof f.sha256 === \"string\") {\n granular.push({ path: f.path, sha256: f.sha256 });\n }\n }\n }\n // A manifest uses one form per entry; if both somehow appear, granular wins\n // (it is the verifiable form). Empty → undefined.\n if (granular.length > 0) return granular;\n if (strings.length > 0) return strings;\n return undefined;\n}\n\n/** Parse the YAML root, returning either the mapping or an error diagnostic. */\nfunction parseManifestRoot(\n text: string,\n): { ok: true; raw: Record<string, unknown> } | { ok: false; diagnostic: Diagnostic } {\n let parsed: unknown;\n try {\n parsed = parse(text) ?? {};\n } catch (err) {\n return {\n ok: false,\n diagnostic: {\n code: \"yaml_syntax\",\n severity: \"error\",\n message: `Invalid YAML: ${err instanceof Error ? err.message : String(err)}`,\n },\n };\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {\n ok: false,\n diagnostic: {\n code: \"non_object_root\",\n severity: \"error\",\n message: \"skaile.manifest.yaml must be a mapping at the top level.\",\n },\n };\n }\n return { ok: true, raw: parsed as Record<string, unknown> };\n}\n\n/**\n * Strip a SINGLE leading `@` from a publisher and, when one was removed, push a\n * `warning` diagnostic. The `@` is the scope sigil the ref formatter adds — an\n * authored `@acme` would otherwise index as `@@acme` and be un-addable. Bare\n * names are returned untouched.\n */\nfunction normalizePublisher(value: string, path: string, diagnostics: Diagnostic[]): string {\n if (!value.startsWith(\"@\")) return value;\n const stripped = value.slice(1);\n diagnostics.push({\n code: \"publisher_leading_sigil\",\n severity: \"warning\",\n message: `publisher \"${value}\": leading \"@\" is the scope sigil and is added automatically — use bare \"${stripped}\"`,\n path,\n });\n return stripped;\n}\n\n/** Decode the manifest-level scalar/array/object fields onto `manifest`. */\nfunction decodeManifestFields(\n raw: Record<string, unknown>,\n manifest: SkPublishManifest,\n diagnostics: Diagnostic[],\n): void {\n if (typeof raw.publisher === \"string\" && raw.publisher.length > 0) {\n manifest.publisher = normalizePublisher(raw.publisher, \"publisher\", diagnostics);\n }\n if (typeof raw.version === \"string\" && raw.version.length > 0) {\n manifest.version = raw.version;\n }\n if (typeof raw.license === \"string\" && raw.license.length > 0) {\n manifest.license = raw.license;\n }\n if (typeof raw.homepage === \"string\" && raw.homepage.length > 0) {\n manifest.homepage = raw.homepage;\n }\n if (Array.isArray(raw.dev_paths)) {\n const paths = raw.dev_paths.filter((p): p is string => typeof p === \"string\" && p.length > 0);\n if (paths.length > 0) manifest.dev_paths = paths;\n }\n const source = parseSource(raw.source);\n if (source) manifest.source = source;\n const provenance = parseProvenance(raw.provenance);\n if (provenance) manifest.provenance = provenance;\n}\n\n/**\n * Validate an asset's `dependencies` via `parseAssetRef`, pushing a `warning`\n * for each malformed ref. Returns the kept (valid) refs.\n */\nfunction decodeAssetDependencies(\n raw: unknown,\n kind: string,\n name: string,\n diagnostics: Diagnostic[],\n): string[] {\n const deps: string[] = [];\n if (!Array.isArray(raw)) return deps;\n for (const dep of raw) {\n if (typeof dep !== \"string\") continue;\n try {\n parseAssetRef(dep);\n deps.push(dep);\n } catch (err) {\n diagnostics.push({\n code: \"malformed_dependency\",\n severity: \"warning\",\n message: `assets[${kind}:${name}].dependencies: ${\n err instanceof Error ? err.message : String(err)\n }`,\n path: `assets.${kind}:${name}.dependencies`,\n });\n }\n }\n return deps;\n}\n\n/**\n * Decode one `assets[]` item into an {@link AssetEntry}, or `undefined` when the\n * item is not a mapping or lacks both `kind` and `name`. Pushes dependency\n * warnings to `diagnostics`.\n */\nfunction decodeAssetEntry(item: unknown, diagnostics: Diagnostic[]): AssetEntry | undefined {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const a = item as Record<string, unknown>;\n const kind = typeof a.kind === \"string\" ? a.kind : \"\";\n const name = typeof a.name === \"string\" ? a.name : \"\";\n if (!kind || !name) return undefined;\n const entry: AssetEntry = { kind, name };\n if (typeof a.root === \"string\") entry.root = a.root;\n const files = parseFiles(a.files);\n if (files) entry.files = files;\n if (typeof a.version === \"string\") entry.version = a.version;\n if (typeof a.publisher === \"string\")\n entry.publisher = normalizePublisher(\n a.publisher,\n `assets.${kind}:${name}.publisher`,\n diagnostics,\n );\n if (typeof a.sha256 === \"string\") entry.sha256 = a.sha256;\n const assetSource = parseSource(a.source);\n if (assetSource) entry.source = assetSource;\n\n const deps = decodeAssetDependencies(a.dependencies, kind, name, diagnostics);\n if (deps.length > 0) entry.dependencies = deps;\n\n if (typeof a.description === \"string\") entry.description = a.description;\n if (Array.isArray(a.keywords)) {\n const kw = a.keywords.filter((k): k is string => typeof k === \"string\");\n if (kw.length > 0) entry.keywords = kw;\n }\n if (typeof a.category === \"string\") entry.category = a.category;\n if (typeof a.license === \"string\") entry.license = a.license;\n if (typeof a.homepage === \"string\") entry.homepage = a.homepage;\n\n return entry;\n}\n\n/** Decode the `assets[]` list onto `manifest`, collecting dependency warnings. */\nfunction decodeManifestAssets(\n raw: Record<string, unknown>,\n manifest: SkPublishManifest,\n diagnostics: Diagnostic[],\n): void {\n if (!Array.isArray(raw.assets)) return;\n const entries: AssetEntry[] = [];\n for (const item of raw.assets) {\n const entry = decodeAssetEntry(item, diagnostics);\n if (entry) entries.push(entry);\n }\n if (entries.length > 0) manifest.assets = entries;\n}\n\n/**\n * Decode `skaile.manifest.yaml` text into a {@link SkPublishManifest} plus\n * {@link Diagnostic}s. Total — never throws: a YAML syntax error or non-object\n * root is reported as an `error`-severity diagnostic with an empty manifest.\n * Malformed `assets[].dependencies` refs are reported as `warning`s (validated\n * via `parseAssetRef`) rather than silently dropped.\n *\n * Pair with {@link encodeSkaileManifest} for round-tripping.\n * @docLink packages/core/publish-manifest#decode-skaile-manifest\n */\nexport function decodeSkaileManifest(text: string): ManifestDecodeResult {\n const root = parseManifestRoot(text);\n if (!root.ok) {\n return { manifest: {}, diagnostics: [root.diagnostic] };\n }\n\n const manifest: SkPublishManifest = {};\n const diagnostics: Diagnostic[] = [];\n decodeManifestFields(root.raw, manifest, diagnostics);\n decodeManifestAssets(root.raw, manifest, diagnostics);\n\n return { manifest, diagnostics };\n}\n\n// ── Encode ──────────────────────────────────────────────────────────────────\n\n/** Fixed top-level key order for {@link encodeSkaileManifest}. */\nconst MANIFEST_KEY_ORDER: (keyof SkPublishManifest)[] = [\n \"publisher\",\n \"version\",\n \"license\",\n \"homepage\",\n \"dev_paths\",\n \"source\",\n \"provenance\",\n \"assets\",\n];\n\n/** Fixed per-asset key order for {@link encodeSkaileManifest}. */\nconst ASSET_KEY_ORDER: (keyof AssetEntry)[] = [\n \"kind\",\n \"name\",\n \"source\",\n \"root\",\n \"files\",\n \"version\",\n \"publisher\",\n \"sha256\",\n \"dependencies\",\n \"description\",\n \"keywords\",\n \"category\",\n \"license\",\n \"homepage\",\n];\n\nfunction orderedAsset(a: AssetEntry): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key of ASSET_KEY_ORDER) {\n const value = a[key];\n if (value !== undefined) out[key] = value;\n }\n return out;\n}\n\n/**\n * Encode a {@link SkPublishManifest} to canonical `skaile.manifest.yaml` text:\n * deterministic key order, only defined fields, `lineWidth: 120` (mirrors\n * `encodeSkaileYaml`).\n * @docLink packages/core/publish-manifest#encode-skaile-manifest\n */\nexport function encodeSkaileManifest(manifest: SkPublishManifest): string {\n const out: Record<string, unknown> = {};\n for (const key of MANIFEST_KEY_ORDER) {\n const value = manifest[key];\n if (value === undefined) continue;\n if (key === \"assets\" && Array.isArray(value)) {\n out.assets = (value as AssetEntry[]).map(orderedAsset);\n } else {\n out[key] = value;\n }\n }\n return stringify(out, { lineWidth: 120 });\n}\n\n// ── File I/O ──────────────────────────────────────────────────────────────────\n\n/**\n * Load and decode `<dir>/skaile.manifest.yaml`. Returns `null` when the file is\n * absent or unparseable (mirrors `loadSkWorkspaceConfig`'s tolerant contract).\n * @docLink packages/core/publish-manifest#load-sk-publish-manifest\n */\nexport function loadSkPublishManifest(dir: string): SkPublishManifest | null {\n const filePath = join(resolve(dir), SKAILE_MANIFEST_FILENAME);\n if (!existsSync(filePath)) return null;\n let raw: string;\n try {\n raw = readFileSync(filePath, \"utf-8\");\n } catch {\n return null;\n }\n const { manifest, diagnostics } = decodeSkaileManifest(raw);\n if (diagnostics.some((d) => d.code === \"yaml_syntax\" || d.code === \"non_object_root\")) {\n return null;\n }\n return manifest;\n}\n\n/**\n * Encode and write a manifest to `<dir>/skaile.manifest.yaml`, creating the\n * directory if needed. Returns the absolute path written.\n * @docLink packages/core/publish-manifest#save-sk-publish-manifest\n */\nexport function saveSkPublishManifest(dir: string, manifest: SkPublishManifest): string {\n const resolvedDir = resolve(dir);\n const filePath = join(resolvedDir, SKAILE_MANIFEST_FILENAME);\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n writeFileSync(filePath, encodeSkaileManifest(manifest));\n return filePath;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { CONNECTOR_ERROR_KINDS } from './chunk-V2OQ3BI6.js';
1
+ import { CONNECTOR_ERROR_KINDS } from './chunk-YNUBJY3L.js';
2
2
 
3
3
  // connectors/src/connect-error-kind.ts
4
4
  var CONNECT_ERROR_KIND_PROPERTY = "skaileConnectErrorKind";
@@ -28,5 +28,5 @@ var ClassifiedConnectError = class extends Error {
28
28
  };
29
29
 
30
30
  export { CONNECT_ERROR_KIND_PROPERTY, ClassifiedConnectError, declaredConnectErrorKind, withConnectErrorKind };
31
- //# sourceMappingURL=chunk-2QYQOJ2F.js.map
32
- //# sourceMappingURL=chunk-2QYQOJ2F.js.map
31
+ //# sourceMappingURL=chunk-DV47JNI4.js.map
32
+ //# sourceMappingURL=chunk-DV47JNI4.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../connectors/src/connect-error-kind.ts"],"names":[],"mappings":";;;AAuBO,IAAM,2BAAA,GAA8B;AAYpC,SAAS,yBAAyB,GAAA,EAA8C;AACrF,EAAA,IAAI,QAAQ,IAAA,IAAQ,OAAO,QAAQ,QAAA,IAAY,EAAE,+BAA+B,GAAA,CAAA,EAAM;AACpF,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,MAAM,KAAA,GAAS,IAAgC,2BAA2B,CAAA;AAC1E,EAAA,OAAQ,qBAAA,CAA6C,QAAA,CAAS,KAAK,CAAA,GAC9D,KAAA,GACD,MAAA;AACN;AAOO,SAAS,oBAAA,CAAwB,KAAQ,IAAA,EAA6B;AAC3E,EAAA,IAAI,QAAQ,IAAA,IAAQ,OAAO,QAAQ,QAAA,IAAY,EAAE,+BAA+B,GAAA,CAAA,EAAM;AACpF,IAAA,IAAI;AACF,MAAC,GAAA,CAAgC,2BAA2B,CAAA,GAAI,IAAA;AAAA,IAClE,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAMO,IAAM,sBAAA,GAAN,cAAqC,KAAA,CAAM;AAAA,EAChD,CAAU,2BAA2B;AAAA,EACrC,WAAA,CAAY,SAAiB,IAAA,EAA0B;AACrD,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,wBAAA;AACZ,IAAA,IAAA,CAAK,2BAA2B,CAAA,GAAI,IAAA;AAAA,EACtC;AACF","file":"chunk-2QYQOJ2F.js","sourcesContent":["/**\n * The driver-side contract for classifying a connect failure: how a thrower\n * says which {@link ConnectorErrorKind} its error is. Read by the manager's\n * `classifyConnectError` (`classify-connect-error.ts`) into the `errorKind`\n * field of `connector_status` error events.\n *\n * Depends on nothing but `types`, so the `connectors-shared` subpath can\n * re-export it to out-of-tree drivers.\n *\n * @docLink packages/connectors/concepts#connector-manager\n */\n\nimport { CONNECTOR_ERROR_KINDS, type ConnectorErrorKind } from \"@skaile/workspaces/types\";\n\n/**\n * The property a thrown error carries its kind on.\n *\n * Namespaced because it is read off any thrown object: a bare `errorKind` is\n * a name a library's own error may already use, and a value that happened to\n * read `\"config\"` would silently misroute the failure. A plain string key\n * rather than a symbol, so a driver with no import from this package can still\n * set it: `throw Object.assign(new Error(msg), { skaileConnectErrorKind: \"config\" })`.\n */\nexport const CONNECT_ERROR_KIND_PROPERTY = \"skaileConnectErrorKind\";\n\n/**\n * The shape of an error that declares its kind. For classes that must spell the\n * key out instead of computing it (see the git driver's `TokenMediatorError`):\n * `implements` keeps the literal tied to {@link CONNECT_ERROR_KIND_PROPERTY}.\n */\nexport type DeclaresConnectErrorKind = {\n readonly [CONNECT_ERROR_KIND_PROPERTY]: ConnectorErrorKind;\n};\n\n/** The kind `err` declares for itself, or `undefined` when it declares none (or an unknown one). */\nexport function declaredConnectErrorKind(err: unknown): ConnectorErrorKind | undefined {\n if (err === null || typeof err !== \"object\" || !(CONNECT_ERROR_KIND_PROPERTY in err)) {\n return undefined;\n }\n const value = (err as Record<string, unknown>)[CONNECT_ERROR_KIND_PROPERTY];\n return (CONNECTOR_ERROR_KINDS as readonly unknown[]).includes(value)\n ? (value as ConnectorErrorKind)\n : undefined;\n}\n\n/**\n * Stamp `kind` onto `err` unless it already declares one, and return it for\n * rethrowing. For throw sites that know what a failure means but throw an\n * error they did not construct (a failed `git` child, say).\n */\nexport function withConnectErrorKind<T>(err: T, kind: ConnectorErrorKind): T {\n if (err !== null && typeof err === \"object\" && !(CONNECT_ERROR_KIND_PROPERTY in err)) {\n try {\n (err as Record<string, unknown>)[CONNECT_ERROR_KIND_PROPERTY] = kind;\n } catch {\n // Frozen or sealed: unclassified beats replacing the real error with a TypeError.\n }\n }\n return err;\n}\n\n/**\n * An `Error` carrying an explicit {@link ConnectorErrorKind}, for throw sites\n * that build their own error.\n */\nexport class ClassifiedConnectError extends Error {\n readonly [CONNECT_ERROR_KIND_PROPERTY]: ConnectorErrorKind;\n constructor(message: string, kind: ConnectorErrorKind) {\n super(message);\n this.name = \"ClassifiedConnectError\";\n this[CONNECT_ERROR_KIND_PROPERTY] = kind;\n }\n}\n"]}
1
+ {"version":3,"sources":["../connectors/src/connect-error-kind.ts"],"names":[],"mappings":";;;AAuBO,IAAM,2BAAA,GAA8B;AAYpC,SAAS,yBAAyB,GAAA,EAA8C;AACrF,EAAA,IAAI,QAAQ,IAAA,IAAQ,OAAO,QAAQ,QAAA,IAAY,EAAE,+BAA+B,GAAA,CAAA,EAAM;AACpF,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,MAAM,KAAA,GAAS,IAAgC,2BAA2B,CAAA;AAC1E,EAAA,OAAQ,qBAAA,CAA6C,QAAA,CAAS,KAAK,CAAA,GAC9D,KAAA,GACD,MAAA;AACN;AAOO,SAAS,oBAAA,CAAwB,KAAQ,IAAA,EAA6B;AAC3E,EAAA,IAAI,QAAQ,IAAA,IAAQ,OAAO,QAAQ,QAAA,IAAY,EAAE,+BAA+B,GAAA,CAAA,EAAM;AACpF,IAAA,IAAI;AACF,MAAC,GAAA,CAAgC,2BAA2B,CAAA,GAAI,IAAA;AAAA,IAClE,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAMO,IAAM,sBAAA,GAAN,cAAqC,KAAA,CAAM;AAAA,EAChD,CAAU,2BAA2B;AAAA,EACrC,WAAA,CAAY,SAAiB,IAAA,EAA0B;AACrD,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,wBAAA;AACZ,IAAA,IAAA,CAAK,2BAA2B,CAAA,GAAI,IAAA;AAAA,EACtC;AACF","file":"chunk-DV47JNI4.js","sourcesContent":["/**\n * The driver-side contract for classifying a connect failure: how a thrower\n * says which {@link ConnectorErrorKind} its error is. Read by the manager's\n * `classifyConnectError` (`classify-connect-error.ts`) into the `errorKind`\n * field of `connector_status` error events.\n *\n * Depends on nothing but `types`, so the `connectors-shared` subpath can\n * re-export it to out-of-tree drivers.\n *\n * @docLink packages/connectors/concepts#connector-manager\n */\n\nimport { CONNECTOR_ERROR_KINDS, type ConnectorErrorKind } from \"@skaile/workspaces/types\";\n\n/**\n * The property a thrown error carries its kind on.\n *\n * Namespaced because it is read off any thrown object: a bare `errorKind` is\n * a name a library's own error may already use, and a value that happened to\n * read `\"config\"` would silently misroute the failure. A plain string key\n * rather than a symbol, so a driver with no import from this package can still\n * set it: `throw Object.assign(new Error(msg), { skaileConnectErrorKind: \"config\" })`.\n */\nexport const CONNECT_ERROR_KIND_PROPERTY = \"skaileConnectErrorKind\";\n\n/**\n * The shape of an error that declares its kind. For classes that must spell the\n * key out instead of computing it (see the git driver's `TokenMediatorError`):\n * `implements` keeps the literal tied to {@link CONNECT_ERROR_KIND_PROPERTY}.\n */\nexport type DeclaresConnectErrorKind = {\n readonly [CONNECT_ERROR_KIND_PROPERTY]: ConnectorErrorKind;\n};\n\n/** The kind `err` declares for itself, or `undefined` when it declares none (or an unknown one). */\nexport function declaredConnectErrorKind(err: unknown): ConnectorErrorKind | undefined {\n if (err === null || typeof err !== \"object\" || !(CONNECT_ERROR_KIND_PROPERTY in err)) {\n return undefined;\n }\n const value = (err as Record<string, unknown>)[CONNECT_ERROR_KIND_PROPERTY];\n return (CONNECTOR_ERROR_KINDS as readonly unknown[]).includes(value)\n ? (value as ConnectorErrorKind)\n : undefined;\n}\n\n/**\n * Stamp `kind` onto `err` unless it already declares one, and return it for\n * rethrowing. For throw sites that know what a failure means but throw an\n * error they did not construct (a failed `git` child, say).\n */\nexport function withConnectErrorKind<T>(err: T, kind: ConnectorErrorKind): T {\n if (err !== null && typeof err === \"object\" && !(CONNECT_ERROR_KIND_PROPERTY in err)) {\n try {\n (err as Record<string, unknown>)[CONNECT_ERROR_KIND_PROPERTY] = kind;\n } catch {\n // Frozen or sealed: unclassified beats replacing the real error with a TypeError.\n }\n }\n return err;\n}\n\n/**\n * An `Error` carrying an explicit {@link ConnectorErrorKind}, for throw sites\n * that build their own error.\n */\nexport class ClassifiedConnectError extends Error {\n readonly [CONNECT_ERROR_KIND_PROPERTY]: ConnectorErrorKind;\n constructor(message: string, kind: ConnectorErrorKind) {\n super(message);\n this.name = \"ClassifiedConnectError\";\n this[CONNECT_ERROR_KIND_PROPERTY] = kind;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { getProviderPreset, registryCredentialEnv, providerCredentialEnvName, BUILTIN_DRIVER_CATALOG } from './chunk-WQULDAH2.js';
1
+ import { getProviderPreset, registryCredentialEnv, providerCredentialEnvName, BUILTIN_DRIVER_CATALOG } from './chunk-6KPQDP7P.js';
2
2
  import { mergeRegistries, resolveEntryBaseUrl, normalizeEntryBaseUrl, registryEntries, isEntryEnabled, parseModelRef } from './chunk-MJHSLODD.js';
3
3
 
4
4
  // bridge/src/provider-materialize/env-drivers.ts
@@ -137,5 +137,5 @@ function continueRoleBinding(session) {
137
137
  }
138
138
 
139
139
  export { bindSingleProviderEntry, continueRoleBinding, credentialsForEveryProvider, entryBaseUrl, entryModelIds, entrySurface, harnessModelSelector, harnessProviderName, isStockCatalogEndpoint, registryModelEntries, resolveEnvDriverSession, resolveRegistryBinding, selectableEntries, versionedAnthropicBaseUrl };
140
- //# sourceMappingURL=chunk-FZFCOQTI.js.map
141
- //# sourceMappingURL=chunk-FZFCOQTI.js.map
140
+ //# sourceMappingURL=chunk-EETXMMZS.js.map
141
+ //# sourceMappingURL=chunk-EETXMMZS.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../bridge/src/provider-materialize/env-drivers.ts"],"names":[],"mappings":";;;;AAyEO,SAAS,uBAAA,CACd,MAAA,EACA,UAAA,GAAiD,OAAA,CAAQ,GAAA,EACvC;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,MAAA,CAAO,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AAAA,IAC/C,WAAW,EAAE,GAAG,UAAA,EAAY,GAAG,OAAO,GAAA,EAAI;AAAA,IAC1C,GAAI,OAAO,QAAA,GAAW,EAAE,UAAU,MAAA,CAAO,QAAA,KAAa,EAAC;AAAA,IACvD,GAAI,OAAO,KAAA,GAAQ,EAAE,OAAO,MAAA,CAAO,KAAA,KAAU;AAAC,GAChD;AACF;AA2BO,SAAS,aAAa,KAAA,EAA0D;AACrF,EAAA,IAAI,KAAA,CAAM,OAAA,EAAS,OAAO,KAAA,CAAM,OAAA;AAChC,EAAA,OAAO,MAAM,MAAA,GAAS,iBAAA,CAAkB,KAAA,CAAM,MAAM,GAAG,OAAA,GAAU,MAAA;AACnE;AAcO,SAAS,aAAa,KAAA,EAA+C;AAC1E,EAAA,MAAM,QAAA,GACJ,mBAAA,CAAoB,KAAK,CAAA,KACxB,KAAA,CAAM,SAAS,iBAAA,CAAkB,KAAA,CAAM,MAAM,CAAA,EAAG,QAAA,GAAW,MAAA,CAAA;AAC9D,EAAA,OAAO,qBAAA,CAAsB,QAAA,EAAU,YAAA,CAAa,KAAK,CAAC,CAAA;AAC5D;AASO,SAAS,yBAAA,CACd,SACA,OAAA,EACQ;AACR,EAAA,IAAI,OAAA,KAAY,sBAAsB,OAAO,OAAA;AAE7C,EAAA,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A;AAC9C,EAAA,IAAI,CAAC,SAAS,OAAO,MAAA;AACrB,EAAA,yBAAA,CAA0B,QAAA,EAAU,aAAa,OAAO,CAAA;AACxD,EAAA,OAAO,OAAA;AACT;AAOO,SAAS,qBAAqB,OAAA,EAAmD;AACtF,EAAA,IAAI,CAAC,OAAA,CAAQ,eAAA,EAAiB,OAAO,MAAA;AACrC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,iBAAiB,CAAA,CAAA,EAAI,QAAQ,eAAe,CAAA,CAAA;AAChE;AAgCO,SAAS,oBAAoB,OAAA,EAA4D;AAC9F,EAAA,MAAM,OAAA,GAAU,uBAAuB,OAAO,CAAA;AAC9C,EAAA,IAAI,CAAC,SAAS,OAAO,MAAA;AACrB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA;AAAA,IACN,YAAY,OAAA,CAAQ,UAAA;AAAA,IACpB,UAAU,OAAA,CAAQ,iBAAA;AAAA,IAClB,GAAI,QAAQ,eAAA,GAAkB,EAAE,OAAO,OAAA,CAAQ,eAAA,KAAoB,EAAC;AAAA,IACpE,GAAI,OAAA,CAAQ,OAAA,GACR,EAAE,OAAA,EAAS,yBAAA,CAA0B,OAAA,CAAQ,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA,EAAE,GACvE,EAAC;AAAA,IACL,SAAA,EAAW,yBAAA,CAA0B,OAAA,CAAQ,UAAU;AAAA,GACzD;AACF","file":"chunk-FZFCOQTI.js","sourcesContent":["/**\n * Registry adapter for the **env-shaped CLI drivers** — Gemini, Qwen, OpenCode,\n * Goose and Continue (§2.3).\n *\n * These harnesses take their endpoint from the environment rather than from a\n * config file, so the adapter's job is three things: resolve which registry\n * entry the session's model selector names, refuse at start when that entry\n * speaks a wire surface the harness cannot, and hand the driver the\n * provider-side model id it must put on the command line.\n *\n * Two pluralities meet here (`BUILTIN_DRIVER_CATALOG.providerPlurality`):\n *\n * - `single` — Gemini and Qwen address exactly one endpoint. The bound entry\n * supplies the credential *and* the base URL, and a surface mismatch is\n * fatal: a Gemini CLI pointed at an `openai-completions` endpoint cannot\n * work, and failing at start names the surface instead of leaving the user\n * with an opaque error mid-turn.\n * - `credentials-n` — OpenCode, Goose and Continue accept every enabled\n * entry's credential at once and select one active model. The credential\n * fan-out is `registryCredentialEnv`; the active model is this module's\n * `<provider>/<model>` binding.\n *\n * Writing the per-endpoint config files those three need for *custom*\n * endpoints (`opencode.json`, Goose `custom_providers/*.json`, Continue\n * `config.yaml`) is the file half, and is deliberately not here.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport {\n type AIProviderLlmEntry,\n type AIProviderSurface,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n mergeRegistries,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport type { ModelEntry } from \"../models.js\";\nimport { getProviderPreset } from \"../provider-catalog.js\";\nimport { BUILTIN_DRIVER_CATALOG } from \"../registry.js\";\nimport type { AgentConfig } from \"../types.js\";\nimport { providerCredentialEnvName, registryCredentialEnv } from \"./credential-env.js\";\n\n/**\n * Everything a CLI driver needs to know about this session's AI providers,\n * resolved once from its {@link AgentConfig}.\n */\nexport interface EnvDriverSession {\n /** The merged registry this session may address. Empty when none was configured. */\n registry: MergedAIProviderRegistry;\n /**\n * Environment `credential.ref` lookups resolve against — the process\n * environment widened with `config.env`, which is where the session\n * boundary delivered every resolved `SKAILE_AIP_<ID>_KEY`.\n */\n lookupEnv: Record<string, string | undefined>;\n /** Model selector: `<providerId>/<modelId>`, a bare id, or `@role`. */\n modelRef?: string;\n /** Roles table an `@role` selector resolves through. */\n roles?: Record<string, string>;\n}\n\n/**\n * Resolve the session's providers once, from its {@link AgentConfig}.\n *\n * `config.env` is folded into `lookupEnv` rather than kept apart: it is part\n * of the session's environment, not an extra, and a credential or\n * `*_BASE_URL` delivered there must be visible exactly as the child will see\n * it.\n */\nexport function resolveEnvDriverSession(\n config: AgentConfig,\n processEnv: Record<string, string | undefined> = process.env,\n): EnvDriverSession {\n return {\n registry: config.registry ?? mergeRegistries([]),\n lookupEnv: { ...processEnv, ...config.env },\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n };\n}\n\n/** One resolved endpoint + model — everything a driver needs to spawn. */\nexport interface RegistryModelBinding {\n /** Registry id of the selected entry. */\n providerId: string;\n /** The selected entry itself. */\n entry: AIProviderLlmEntry;\n /** Logical model id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side model id — what goes on the wire / command line. */\n providerModelId?: string;\n /** Wire protocol, from the entry or its preset. */\n surface?: AIProviderSurface;\n /** Resolved endpoint, from the entry, its transport params, or its preset. */\n baseUrl?: string;\n /**\n * The provider name the *harness* knows this endpoint by — a catalog preset\n * id for a stock endpoint, the registry id for anything custom. See\n * {@link harnessProviderName}.\n */\n harnessProviderId: string;\n /** Non-fatal notes from `parseModelRef` (dangling role, disabled provider). */\n warnings: string[];\n}\n\n/** The entry's wire surface: its own, else its preset's. */\nexport function entrySurface(entry: AIProviderLlmEntry): AIProviderSurface | undefined {\n if (entry.surface) return entry.surface;\n return entry.preset ? getProviderPreset(entry.preset)?.surface : undefined;\n}\n\n/**\n * The entry's endpoint: its literal or transport-derived URL, else its\n * preset's literal, in the canonical spelling for its surface\n * (`normalizeEntryBaseUrl`: an `anthropic-messages` endpoint is its host root,\n * so `https://api.anthropic.com/v1` reads as `https://api.anthropic.com`).\n * Transport templates that still carry `{param}` placeholders never come\n * back — `resolveEntryBaseUrl` withholds those, and a preset's template is not\n * a URL.\n *\n * Every adapter reads the endpoint here and only re-spells it for a client\n * that wants something else ({@link versionedAnthropicBaseUrl}).\n */\nexport function entryBaseUrl(entry: AIProviderLlmEntry): string | undefined {\n const resolved =\n resolveEntryBaseUrl(entry) ??\n (entry.preset ? getProviderPreset(entry.preset)?.base_url : undefined);\n return normalizeEntryBaseUrl(resolved, entrySurface(entry));\n}\n\n/**\n * An `anthropic-messages` endpoint spelled for a client that appends only\n * `/messages` — `@ai-sdk/anthropic` (OpenCode) and Continue — rather than\n * `/v1/messages` like the Claude CLI, the Anthropic SDK and Goose. `baseUrl`\n * must already be canonical ({@link entryBaseUrl}); every other surface passes\n * through unchanged.\n */\nexport function versionedAnthropicBaseUrl(\n baseUrl: string,\n surface: AIProviderSurface | undefined,\n): string {\n if (surface !== \"anthropic-messages\") return baseUrl;\n // Append to the path, not the string: a query or fragment stays at the end.\n try {\n const url = new URL(baseUrl);\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/v1`;\n return url.toString();\n } catch {\n return `${baseUrl}/v1`;\n }\n}\n\n/**\n * True when a `credentials-n` harness already knows this endpoint under its\n * own catalog name — the entry names a preset and did not move it somewhere\n * else. Both sides are compared canonically, so `https://api.anthropic.com/v1`\n * is still the `anthropic` preset's endpoint.\n *\n * The one rule both halves of §2.3 read: it decides the name the env half\n * puts on the command line ({@link harnessProviderName}) *and* whether the\n * file half has to describe the endpoint at all. Reading it twice is what\n * keeps `-m <name>/<model>` and the generated provider file talking about the\n * same thing.\n */\nexport function isStockCatalogEndpoint(entry: AIProviderLlmEntry): boolean {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset) return false;\n return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));\n}\n\n/**\n * The provider name to give a `credentials-n` harness (`-m <name>/<model>`,\n * `GOOSE_PROVIDER`).\n *\n * A stock catalog endpoint is named by its preset, because that is the name\n * OpenCode's models.dev list and Goose's built-in provider table already use —\n * `prod-claude: {preset: anthropic}` is still Anthropic to them. An entry with\n * an endpoint of its own is named by its registry id: no built-in table knows\n * it, so the id is what its generated provider file is keyed by (the file half\n * of §2.3).\n */\nexport function harnessProviderName(providerId: string, entry: AIProviderLlmEntry): string {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset || !isStockCatalogEndpoint(entry)) return providerId;\n return preset.id;\n}\n\n/**\n * Enabled `llm`/`embed` entries, in registry order. Also the set the file\n * adapters render (`opencode-config.ts`, `goose-custom-providers.ts`,\n * `continue-config-yaml.ts`): the env half and the file half must agree on\n * which entries exist before they can agree on what to call them.\n */\nexport function selectableEntries(\n registry: MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * The provider-side model ids an entry declares, as `[logicalId, providerId]`\n * pairs in declaration order: every `model_map` entry, plus every\n * `capabilities` key the map does not rename.\n */\nexport function entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logicalIds = [\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}).filter((id) => !(id in (entry.model_map ?? {}))),\n ];\n return logicalIds.map((id) => [id, entry.model_map?.[id] ?? id]);\n}\n\nfunction describeBinding(\n providerId: string,\n entry: AIProviderLlmEntry,\n modelId: string | undefined,\n providerModelId: string | undefined,\n warnings: string[],\n): RegistryModelBinding {\n const surface = entrySurface(entry);\n const baseUrl = entryBaseUrl(entry);\n return {\n providerId,\n entry,\n ...(modelId === undefined ? {} : { modelId }),\n ...(providerModelId === undefined ? {} : { providerModelId }),\n ...(surface ? { surface } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n harnessProviderId: harnessProviderName(providerId, entry),\n warnings,\n };\n}\n\n/**\n * Resolve the session's endpoint + model.\n *\n * With no selector the first entry in registry order wins and the harness\n * keeps its own default model — exactly what an absent `model` meant before\n * the registry existed. Returns `undefined` when no entry can serve a model\n * (an empty, fully-disabled or voice-only registry).\n */\nexport function resolveRegistryBinding(\n session: EnvDriverSession,\n): RegistryModelBinding | undefined {\n const entries = selectableEntries(session.registry);\n if (entries.length === 0) return undefined;\n\n const selector = session.modelRef?.trim();\n if (!selector) {\n const [providerId, entry] = entries[0];\n return describeBinding(providerId, entry, undefined, undefined, []);\n }\n\n // A selector that is exactly an entry id names the endpoint and nothing\n // else: the harness keeps its own default model. `parseModelRef` would read\n // it as a bare *model* id and fall back to registry order.\n const named = entries.find(([id]) => id === selector);\n if (named) return describeBinding(named[0], named[1], undefined, undefined, []);\n\n const resolved = parseModelRef(selector, session.registry, session.roles);\n if (!resolved) return undefined;\n const match = entries.find(([id]) => id === resolved.providerId);\n if (!match) return undefined;\n return describeBinding(\n match[0],\n match[1],\n resolved.modelId,\n resolved.providerModelId,\n resolved.warnings,\n );\n}\n\n/**\n * Every credential a `credentials-n` harness may use: one variable per\n * enabled registry entry. OpenCode, Goose and Continue have always received\n * *all* of them, not just the selected endpoint's, because they route across\n * providers inside a single session.\n */\nexport function credentialsForEveryProvider(session: EnvDriverSession): Record<string, string> {\n return registryCredentialEnv(session.registry, { env: session.lookupEnv });\n}\n\n/**\n * Throw when the bound entry speaks a wire surface this driver cannot.\n *\n * The message names the offending surface and lists the ones the harness does\n * speak (`BUILTIN_DRIVER_CATALOG[driverId].surfaces`). An entry that declares\n * no surface and names no preset is not judged — there is nothing to compare.\n */\nexport function assertDriverSpeaksSurface(\n driverId: string,\n productName: string,\n binding: RegistryModelBinding,\n): void {\n const supported = BUILTIN_DRIVER_CATALOG[driverId]?.surfaces;\n if (!supported || supported.length === 0) return;\n const surface = binding.surface;\n if (!surface || supported.includes(surface)) return;\n throw new Error(\n `${productName} cannot speak the '${surface}' surface of AI provider entry ` +\n `'${binding.providerId}'. ${productName} speaks: ${supported.join(\", \")}. ` +\n `Point this session's model at an entry with one of those surfaces, ` +\n `or run it on a driver that speaks '${surface}'.`,\n );\n}\n\n/**\n * The models a `credentials-n` harness can be pointed at, straight from the\n * registry: every enabled entry's mapped ids, namespaced the way the harness\n * takes them (`-m <provider>/<model>`).\n *\n * These harnesses have no model-list endpoint of their own — OpenCode reads\n * models.dev, Goose and Continue read their config — so the registry is the\n * only list that describes *this* session's reachable models, and it needs no\n * network call to produce.\n */\nexport function registryModelEntries(session: EnvDriverSession): ModelEntry[] {\n const out: ModelEntry[] = [];\n const seen = new Set<string>();\n for (const [providerId, entry] of selectableEntries(session.registry)) {\n const harnessId = harnessProviderName(providerId, entry);\n const label = entry.label ?? providerId;\n for (const [logicalId, providerModelId] of entryModelIds(entry)) {\n const id = `${harnessId}/${providerModelId}`;\n if (seen.has(id)) continue;\n seen.add(id);\n out.push({ id, name: `${label} ${logicalId}` });\n }\n }\n return out;\n}\n\n/**\n * Resolve the binding and enforce the surface — what a `single`-plurality\n * driver does at start.\n *\n * The registry is authoritative: pointing the driver at an entry it cannot\n * speak throws rather than silently running somewhere else. `undefined` when\n * the session configured no endpoint at all, which leaves the driver on its\n * own native auth.\n */\nexport function bindSingleProviderEntry(\n driverId: string,\n productName: string,\n session: EnvDriverSession,\n): RegistryModelBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n assertDriverSpeaksSurface(driverId, productName, binding);\n return binding;\n}\n\n/**\n * The `<provider>/<model>` selector a `credentials-n` harness takes on its\n * command line (`opencode -m`). `undefined` when no model was selected — the\n * harness then uses its own default rather than being handed a bare provider.\n */\nexport function harnessModelSelector(binding: RegistryModelBinding): string | undefined {\n if (!binding.providerModelId) return undefined;\n return `${binding.harnessProviderId}/${binding.providerModelId}`;\n}\n\n/**\n * Continue's model selection is a **role binding**, not a flag: `cn` has no\n * `--model` option (only `--config <slug>`), and its `config.yaml` binds each\n * model to roles (`chat`, `edit`, `apply`, …). This is the binding for the\n * role a headless `cn -p` turn runs as, and the shape its generated\n * `config.yaml` is rendered from.\n *\n * `apiKeyEnv` is a variable *name*: the secret travels in the child\n * environment, never in a rendered config.\n */\nexport interface ContinueRoleBinding {\n /** Continue role this model serves. A headless prompt is a `chat` turn. */\n role: \"chat\";\n /** Registry id of the entry. */\n providerId: string;\n /** Provider name Continue knows the endpoint by. */\n provider: string;\n /** Provider-side model id. */\n model?: string;\n /** Endpoint, when the entry states one, spelled the way Continue's `apiBase` wants it. */\n apiBase?: string;\n /** Env var holding the credential — the name, never the value. */\n apiKeyEnv: string;\n}\n\n/**\n * Map the session's chosen endpoint onto the Continue role a headless turn\n * runs as. `undefined` when the session configured no endpoint — `cn` then\n * runs against whatever its own `config.yaml` / Hub login provides.\n */\nexport function continueRoleBinding(session: EnvDriverSession): ContinueRoleBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n return {\n role: \"chat\",\n providerId: binding.providerId,\n provider: binding.harnessProviderId,\n ...(binding.providerModelId ? { model: binding.providerModelId } : {}),\n ...(binding.baseUrl\n ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) }\n : {}),\n apiKeyEnv: providerCredentialEnvName(binding.providerId),\n };\n}\n"]}
1
+ {"version":3,"sources":["../bridge/src/provider-materialize/env-drivers.ts"],"names":[],"mappings":";;;;AAyEO,SAAS,uBAAA,CACd,MAAA,EACA,UAAA,GAAiD,OAAA,CAAQ,GAAA,EACvC;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,MAAA,CAAO,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AAAA,IAC/C,WAAW,EAAE,GAAG,UAAA,EAAY,GAAG,OAAO,GAAA,EAAI;AAAA,IAC1C,GAAI,OAAO,QAAA,GAAW,EAAE,UAAU,MAAA,CAAO,QAAA,KAAa,EAAC;AAAA,IACvD,GAAI,OAAO,KAAA,GAAQ,EAAE,OAAO,MAAA,CAAO,KAAA,KAAU;AAAC,GAChD;AACF;AA2BO,SAAS,aAAa,KAAA,EAA0D;AACrF,EAAA,IAAI,KAAA,CAAM,OAAA,EAAS,OAAO,KAAA,CAAM,OAAA;AAChC,EAAA,OAAO,MAAM,MAAA,GAAS,iBAAA,CAAkB,KAAA,CAAM,MAAM,GAAG,OAAA,GAAU,MAAA;AACnE;AAcO,SAAS,aAAa,KAAA,EAA+C;AAC1E,EAAA,MAAM,QAAA,GACJ,mBAAA,CAAoB,KAAK,CAAA,KACxB,KAAA,CAAM,S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(§2.3).\n *\n * These harnesses take their endpoint from the environment rather than from a\n * config file, so the adapter's job is three things: resolve which registry\n * entry the session's model selector names, refuse at start when that entry\n * speaks a wire surface the harness cannot, and hand the driver the\n * provider-side model id it must put on the command line.\n *\n * Two pluralities meet here (`BUILTIN_DRIVER_CATALOG.providerPlurality`):\n *\n * - `single` — Gemini and Qwen address exactly one endpoint. The bound entry\n * supplies the credential *and* the base URL, and a surface mismatch is\n * fatal: a Gemini CLI pointed at an `openai-completions` endpoint cannot\n * work, and failing at start names the surface instead of leaving the user\n * with an opaque error mid-turn.\n * - `credentials-n` — OpenCode, Goose and Continue accept every enabled\n * entry's credential at once and select one active model. The credential\n * fan-out is `registryCredentialEnv`; the active model is this module's\n * `<provider>/<model>` binding.\n *\n * Writing the per-endpoint config files those three need for *custom*\n * endpoints (`opencode.json`, Goose `custom_providers/*.json`, Continue\n * `config.yaml`) is the file half, and is deliberately not here.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport {\n type AIProviderLlmEntry,\n type AIProviderSurface,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n mergeRegistries,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport type { ModelEntry } from \"../models.js\";\nimport { getProviderPreset } from \"../provider-catalog.js\";\nimport { BUILTIN_DRIVER_CATALOG } from \"../registry.js\";\nimport type { AgentConfig } from \"../types.js\";\nimport { providerCredentialEnvName, registryCredentialEnv } from \"./credential-env.js\";\n\n/**\n * Everything a CLI driver needs to know about this session's AI providers,\n * resolved once from its {@link AgentConfig}.\n */\nexport interface EnvDriverSession {\n /** The merged registry this session may address. Empty when none was configured. */\n registry: MergedAIProviderRegistry;\n /**\n * Environment `credential.ref` lookups resolve against — the process\n * environment widened with `config.env`, which is where the session\n * boundary delivered every resolved `SKAILE_AIP_<ID>_KEY`.\n */\n lookupEnv: Record<string, string | undefined>;\n /** Model selector: `<providerId>/<modelId>`, a bare id, or `@role`. */\n modelRef?: string;\n /** Roles table an `@role` selector resolves through. */\n roles?: Record<string, string>;\n}\n\n/**\n * Resolve the session's providers once, from its {@link AgentConfig}.\n *\n * `config.env` is folded into `lookupEnv` rather than kept apart: it is part\n * of the session's environment, not an extra, and a credential or\n * `*_BASE_URL` delivered there must be visible exactly as the child will see\n * it.\n */\nexport function resolveEnvDriverSession(\n config: AgentConfig,\n processEnv: Record<string, string | undefined> = process.env,\n): EnvDriverSession {\n return {\n registry: config.registry ?? mergeRegistries([]),\n lookupEnv: { ...processEnv, ...config.env },\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n };\n}\n\n/** One resolved endpoint + model — everything a driver needs to spawn. */\nexport interface RegistryModelBinding {\n /** Registry id of the selected entry. */\n providerId: string;\n /** The selected entry itself. */\n entry: AIProviderLlmEntry;\n /** Logical model id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side model id — what goes on the wire / command line. */\n providerModelId?: string;\n /** Wire protocol, from the entry or its preset. */\n surface?: AIProviderSurface;\n /** Resolved endpoint, from the entry, its transport params, or its preset. */\n baseUrl?: string;\n /**\n * The provider name the *harness* knows this endpoint by — a catalog preset\n * id for a stock endpoint, the registry id for anything custom. See\n * {@link harnessProviderName}.\n */\n harnessProviderId: string;\n /** Non-fatal notes from `parseModelRef` (dangling role, disabled provider). */\n warnings: string[];\n}\n\n/** The entry's wire surface: its own, else its preset's. */\nexport function entrySurface(entry: AIProviderLlmEntry): AIProviderSurface | undefined {\n if (entry.surface) return entry.surface;\n return entry.preset ? getProviderPreset(entry.preset)?.surface : undefined;\n}\n\n/**\n * The entry's endpoint: its literal or transport-derived URL, else its\n * preset's literal, in the canonical spelling for its surface\n * (`normalizeEntryBaseUrl`: an `anthropic-messages` endpoint is its host root,\n * so `https://api.anthropic.com/v1` reads as `https://api.anthropic.com`).\n * Transport templates that still carry `{param}` placeholders never come\n * back — `resolveEntryBaseUrl` withholds those, and a preset's template is not\n * a URL.\n *\n * Every adapter reads the endpoint here and only re-spells it for a client\n * that wants something else ({@link versionedAnthropicBaseUrl}).\n */\nexport function entryBaseUrl(entry: AIProviderLlmEntry): string | undefined {\n const resolved =\n resolveEntryBaseUrl(entry) ??\n (entry.preset ? getProviderPreset(entry.preset)?.base_url : undefined);\n return normalizeEntryBaseUrl(resolved, entrySurface(entry));\n}\n\n/**\n * An `anthropic-messages` endpoint spelled for a client that appends only\n * `/messages` — `@ai-sdk/anthropic` (OpenCode) and Continue — rather than\n * `/v1/messages` like the Claude CLI, the Anthropic SDK and Goose. `baseUrl`\n * must already be canonical ({@link entryBaseUrl}); every other surface passes\n * through unchanged.\n */\nexport function versionedAnthropicBaseUrl(\n baseUrl: string,\n surface: AIProviderSurface | undefined,\n): string {\n if (surface !== \"anthropic-messages\") return baseUrl;\n // Append to the path, not the string: a query or fragment stays at the end.\n try {\n const url = new URL(baseUrl);\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/v1`;\n return url.toString();\n } catch {\n return `${baseUrl}/v1`;\n }\n}\n\n/**\n * True when a `credentials-n` harness already knows this endpoint under its\n * own catalog name — the entry names a preset and did not move it somewhere\n * else. Both sides are compared canonically, so `https://api.anthropic.com/v1`\n * is still the `anthropic` preset's endpoint.\n *\n * The one rule both halves of §2.3 read: it decides the name the env half\n * puts on the command line ({@link harnessProviderName}) *and* whether the\n * file half has to describe the endpoint at all. Reading it twice is what\n * keeps `-m <name>/<model>` and the generated provider file talking about the\n * same thing.\n */\nexport function isStockCatalogEndpoint(entry: AIProviderLlmEntry): boolean {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset) return false;\n return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));\n}\n\n/**\n * The provider name to give a `credentials-n` harness (`-m <name>/<model>`,\n * `GOOSE_PROVIDER`).\n *\n * A stock catalog endpoint is named by its preset, because that is the name\n * OpenCode's models.dev list and Goose's built-in provider table already use —\n * `prod-claude: {preset: anthropic}` is still Anthropic to them. An entry with\n * an endpoint of its own is named by its registry id: no built-in table knows\n * it, so the id is what its generated provider file is keyed by (the file half\n * of §2.3).\n */\nexport function harnessProviderName(providerId: string, entry: AIProviderLlmEntry): string {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset || !isStockCatalogEndpoint(entry)) return providerId;\n return preset.id;\n}\n\n/**\n * Enabled `llm`/`embed` entries, in registry order. Also the set the file\n * adapters render (`opencode-config.ts`, `goose-custom-providers.ts`,\n * `continue-config-yaml.ts`): the env half and the file half must agree on\n * which entries exist before they can agree on what to call them.\n */\nexport function selectableEntries(\n registry: MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * The provider-side model ids an entry declares, as `[logicalId, providerId]`\n * pairs in declaration order: every `model_map` entry, plus every\n * `capabilities` key the map does not rename.\n */\nexport function entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logicalIds = [\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}).filter((id) => !(id in (entry.model_map ?? {}))),\n ];\n return logicalIds.map((id) => [id, entry.model_map?.[id] ?? id]);\n}\n\nfunction describeBinding(\n providerId: string,\n entry: AIProviderLlmEntry,\n modelId: string | undefined,\n providerModelId: string | undefined,\n warnings: string[],\n): RegistryModelBinding {\n const surface = entrySurface(entry);\n const baseUrl = entryBaseUrl(entry);\n return {\n providerId,\n entry,\n ...(modelId === undefined ? {} : { modelId }),\n ...(providerModelId === undefined ? {} : { providerModelId }),\n ...(surface ? { surface } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n harnessProviderId: harnessProviderName(providerId, entry),\n warnings,\n };\n}\n\n/**\n * Resolve the session's endpoint + model.\n *\n * With no selector the first entry in registry order wins and the harness\n * keeps its own default model — exactly what an absent `model` meant before\n * the registry existed. Returns `undefined` when no entry can serve a model\n * (an empty, fully-disabled or voice-only registry).\n */\nexport function resolveRegistryBinding(\n session: EnvDriverSession,\n): RegistryModelBinding | undefined {\n const entries = selectableEntries(session.registry);\n if (entries.length === 0) return undefined;\n\n const selector = session.modelRef?.trim();\n if (!selector) {\n const [providerId, entry] = entries[0];\n return describeBinding(providerId, entry, undefined, undefined, []);\n }\n\n // A selector that is exactly an entry id names the endpoint and nothing\n // else: the harness keeps its own default model. `parseModelRef` would read\n // it as a bare *model* id and fall back to registry order.\n const named = entries.find(([id]) => id === selector);\n if (named) return describeBinding(named[0], named[1], undefined, undefined, []);\n\n const resolved = parseModelRef(selector, session.registry, session.roles);\n if (!resolved) return undefined;\n const match = entries.find(([id]) => id === resolved.providerId);\n if (!match) return undefined;\n return describeBinding(\n match[0],\n match[1],\n resolved.modelId,\n resolved.providerModelId,\n resolved.warnings,\n );\n}\n\n/**\n * Every credential a `credentials-n` harness may use: one variable per\n * enabled registry entry. OpenCode, Goose and Continue have always received\n * *all* of them, not just the selected endpoint's, because they route across\n * providers inside a single session.\n */\nexport function credentialsForEveryProvider(session: EnvDriverSession): Record<string, string> {\n return registryCredentialEnv(session.registry, { env: session.lookupEnv });\n}\n\n/**\n * Throw when the bound entry speaks a wire surface this driver cannot.\n *\n * The message names the offending surface and lists the ones the harness does\n * speak (`BUILTIN_DRIVER_CATALOG[driverId].surfaces`). An entry that declares\n * no surface and names no preset is not judged — there is nothing to compare.\n */\nexport function assertDriverSpeaksSurface(\n driverId: string,\n productName: string,\n binding: RegistryModelBinding,\n): void {\n const supported = BUILTIN_DRIVER_CATALOG[driverId]?.surfaces;\n if (!supported || supported.length === 0) return;\n const surface = binding.surface;\n if (!surface || supported.includes(surface)) return;\n throw new Error(\n `${productName} cannot speak the '${surface}' surface of AI provider entry ` +\n `'${binding.providerId}'. ${productName} speaks: ${supported.join(\", \")}. ` +\n `Point this session's model at an entry with one of those surfaces, ` +\n `or run it on a driver that speaks '${surface}'.`,\n );\n}\n\n/**\n * The models a `credentials-n` harness can be pointed at, straight from the\n * registry: every enabled entry's mapped ids, namespaced the way the harness\n * takes them (`-m <provider>/<model>`).\n *\n * These harnesses have no model-list endpoint of their own — OpenCode reads\n * models.dev, Goose and Continue read their config — so the registry is the\n * only list that describes *this* session's reachable models, and it needs no\n * network call to produce.\n */\nexport function registryModelEntries(session: EnvDriverSession): ModelEntry[] {\n const out: ModelEntry[] = [];\n const seen = new Set<string>();\n for (const [providerId, entry] of selectableEntries(session.registry)) {\n const harnessId = harnessProviderName(providerId, entry);\n const label = entry.label ?? providerId;\n for (const [logicalId, providerModelId] of entryModelIds(entry)) {\n const id = `${harnessId}/${providerModelId}`;\n if (seen.has(id)) continue;\n seen.add(id);\n out.push({ id, name: `${label} ${logicalId}` });\n }\n }\n return out;\n}\n\n/**\n * Resolve the binding and enforce the surface — what a `single`-plurality\n * driver does at start.\n *\n * The registry is authoritative: pointing the driver at an entry it cannot\n * speak throws rather than silently running somewhere else. `undefined` when\n * the session configured no endpoint at all, which leaves the driver on its\n * own native auth.\n */\nexport function bindSingleProviderEntry(\n driverId: string,\n productName: string,\n session: EnvDriverSession,\n): RegistryModelBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n assertDriverSpeaksSurface(driverId, productName, binding);\n return binding;\n}\n\n/**\n * The `<provider>/<model>` selector a `credentials-n` harness takes on its\n * command line (`opencode -m`). `undefined` when no model was selected — the\n * harness then uses its own default rather than being handed a bare provider.\n */\nexport function harnessModelSelector(binding: RegistryModelBinding): string | undefined {\n if (!binding.providerModelId) return undefined;\n return `${binding.harnessProviderId}/${binding.providerModelId}`;\n}\n\n/**\n * Continue's model selection is a **role binding**, not a flag: `cn` has no\n * `--model` option (only `--config <slug>`), and its `config.yaml` binds each\n * model to roles (`chat`, `edit`, `apply`, …). This is the binding for the\n * role a headless `cn -p` turn runs as, and the shape its generated\n * `config.yaml` is rendered from.\n *\n * `apiKeyEnv` is a variable *name*: the secret travels in the child\n * environment, never in a rendered config.\n */\nexport interface ContinueRoleBinding {\n /** Continue role this model serves. A headless prompt is a `chat` turn. */\n role: \"chat\";\n /** Registry id of the entry. */\n providerId: string;\n /** Provider name Continue knows the endpoint by. */\n provider: string;\n /** Provider-side model id. */\n model?: string;\n /** Endpoint, when the entry states one, spelled the way Continue's `apiBase` wants it. */\n apiBase?: string;\n /** Env var holding the credential — the name, never the value. */\n apiKeyEnv: string;\n}\n\n/**\n * Map the session's chosen endpoint onto the Continue role a headless turn\n * runs as. `undefined` when the session configured no endpoint — `cn` then\n * runs against whatever its own `config.yaml` / Hub login provides.\n */\nexport function continueRoleBinding(session: EnvDriverSession): ContinueRoleBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n return {\n role: \"chat\",\n providerId: binding.providerId,\n provider: binding.harnessProviderId,\n ...(binding.providerModelId ? { model: binding.providerModelId } : {}),\n ...(binding.baseUrl\n ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) }\n : {}),\n apiKeyEnv: providerCredentialEnvName(binding.providerId),\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { findAiAssetsRoot } from './chunk-5JAO4MXA.js';
1
+ import { findAiAssetsRoot } from './chunk-DOVURNRK.js';
2
2
 
3
3
  // workspace-plugin/src/utils/ai-assets.ts
4
4
  function findAiAssetsRoot2(startDir) {
@@ -6,5 +6,5 @@ function findAiAssetsRoot2(startDir) {
6
6
  }
7
7
 
8
8
  export { findAiAssetsRoot2 as findAiAssetsRoot };
9
- //# sourceMappingURL=chunk-OEBAXTQ4.js.map
10
- //# sourceMappingURL=chunk-OEBAXTQ4.js.map
9
+ //# sourceMappingURL=chunk-EOKAFBJ7.js.map
10
+ //# sourceMappingURL=chunk-EOKAFBJ7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../workspace-plugin/src/utils/ai-assets.ts"],"names":["findAiAssetsRoot"],"mappings":";;;AA+BO,SAASA,kBAAiB,QAAA,EAA0C;AACzE,EAAA,OAAO,iBAAuB,QAAQ,CAAA;AACxC","file":"chunk-OEBAXTQ4.js","sourcesContent":["// utils/ai-assets.ts\n// Shared utility for locating the ai-assets root directory.\n//\n// This is NOT a startup path (an earlier comment here claimed it was). Every\n// caller is an agent-invokable tool in `tools/flows.ts` / `tools/skills.ts`, so\n// the walk runs on a request path inside the long-lived `skaile serve` process,\n// once per tool invocation. With `projectDir = /skaile` the upward walk passes\n// directly beside the rclone FUSE workspace mount, so a synchronous `statSync`\n// here parks the whole event loop when that mount wedges — the failure mode\n// behind the 2026-08-07 outages. See issue #454.\nimport { findAiAssetsRoot as findAiAssetsRootShared } from \"@skaile/workspaces/asset-manager/catalog-deployer\";\n\n/**\n * Walk up from `startDir` looking for an `ai-assets/` directory.\n *\n * Delegates to the shared implementation in `asset-manager/catalog-deployer`,\n * which is async, deadline-bounded, level-capped, and refuses a candidate that\n * resolves at or under a workspace mount (continuing upward so a legitimate\n * parent still wins).\n *\n * @param startDir - Absolute path to begin the upward search from (typically\n * the skaile `projectDir`).\n * Note the upward walk is now level-capped rather than running to the\n * filesystem root. Six levels covers every real layout and stops an\n * unbounded climb across mount boundaries.\n *\n * @returns Absolute path to the first usable `ai-assets/` directory found, or\n * `null` if no match exists within the cap.\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport function findAiAssetsRoot(startDir: string): Promise<string | null> {\n return findAiAssetsRootShared(startDir);\n}\n"]}
1
+ {"version":3,"sources":["../workspace-plugin/src/utils/ai-assets.ts"],"names":["findAiAssetsRoot"],"mappings":";;;AA+BO,SAASA,kBAAiB,QAAA,EAA0C;AACzE,EAAA,OAAO,iBAAuB,QAAQ,CAAA;AACxC","file":"chunk-EOKAFBJ7.js","sourcesContent":["// utils/ai-assets.ts\n// Shared utility for locating the ai-assets root directory.\n//\n// This is NOT a startup path (an earlier comment here claimed it was). Every\n// caller is an agent-invokable tool in `tools/flows.ts` / `tools/skills.ts`, so\n// the walk runs on a request path inside the long-lived `skaile serve` process,\n// once per tool invocation. With `projectDir = /skaile` the upward walk passes\n// directly beside the rclone FUSE workspace mount, so a synchronous `statSync`\n// here parks the whole event loop when that mount wedges — the failure mode\n// behind the 2026-08-07 outages. See issue #454.\nimport { findAiAssetsRoot as findAiAssetsRootShared } from \"@skaile/workspaces/asset-manager/catalog-deployer\";\n\n/**\n * Walk up from `startDir` looking for an `ai-assets/` directory.\n *\n * Delegates to the shared implementation in `asset-manager/catalog-deployer`,\n * which is async, deadline-bounded, level-capped, and refuses a candidate that\n * resolves at or under a workspace mount (continuing upward so a legitimate\n * parent still wins).\n *\n * @param startDir - Absolute path to begin the upward search from (typically\n * the skaile `projectDir`).\n * Note the upward walk is now level-capped rather than running to the\n * filesystem root. Six levels covers every real layout and stops an\n * unbounded climb across mount boundaries.\n *\n * @returns Absolute path to the first usable `ai-assets/` directory found, or\n * `null` if no match exists within the cap.\n *\n * @docLink packages/workspace-plugin/concepts#workspaceplugin-lifecycle\n */\nexport function findAiAssetsRoot(startDir: string): Promise<string | null> {\n return findAiAssetsRootShared(startDir);\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { SecretNotFoundError, SecretAccessDeniedError, SecretsError, ProviderUnavailableError } from './chunk-JXT46QFC.js';
2
+ import { globalSkaileDir } from './chunk-TLKM4M47.js';
2
3
  import * as crypto from 'crypto';
3
4
  import * as fs from 'fs';
4
5
  import * as os from 'os';
@@ -134,7 +135,7 @@ var LocalSecretsProvider = class {
134
135
  salt = null;
135
136
  strategy = "machine";
136
137
  constructor(secretsDir) {
137
- this.secretsDir = secretsDir ?? path.join(os.homedir(), ".skaile", "secrets");
138
+ this.secretsDir = secretsDir ?? path.join(globalSkaileDir(), "secrets");
138
139
  }
139
140
  // -- Initialization --------------------------------------------------------
140
141
  ensureDir() {
@@ -531,5 +532,5 @@ var SecretsRouter = class {
531
532
  var VERSION = "0.0.0";
532
533
 
533
534
  export { CredentialLifecycleService, EnvSecretsProvider, LocalSecretsProvider, SecretsRouter, VERSION };
534
- //# sourceMappingURL=chunk-6BEGKO2Q.js.map
535
- //# sourceMappingURL=chunk-6BEGKO2Q.js.map
535
+ //# sourceMappingURL=chunk-HUNZYTOS.js.map
536
+ //# sourceMappingURL=chunk-HUNZYTOS.js.map