@skaile/workspaces 4.37.0 → 4.39.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 (321) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/app-sdk/index.js +1 -1
  3. package/dist/{asset-feeds-KTRFFJYM.js → asset-feeds-KXL45ALC.js} +16 -16
  4. package/dist/asset-feeds-KXL45ALC.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-252TK4RU.js} +8 -8
  29. package/dist/{chunk-SGMCSVTO.js.map → chunk-252TK4RU.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-YU433JEL.js → chunk-3C3ODIDE.js} +6 -6
  35. package/dist/{chunk-YU433JEL.js.map → chunk-3C3ODIDE.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-U4CNCL7Q.js → chunk-5LF27VUB.js} +12 -12
  41. package/dist/{chunk-U4CNCL7Q.js.map → chunk-5LF27VUB.js.map} +1 -1
  42. package/dist/{chunk-NTASYPDN.js → chunk-5NYBY6ZE.js} +3 -3
  43. package/dist/{chunk-NTASYPDN.js.map → chunk-5NYBY6ZE.js.map} +1 -1
  44. package/dist/{chunk-WTBXGJCD.js → chunk-5RWL4L3X.js} +10 -10
  45. package/dist/{chunk-WTBXGJCD.js.map → chunk-5RWL4L3X.js.map} +1 -1
  46. package/dist/{chunk-FLGLODDF.js → chunk-7RC37XFW.js} +3 -3
  47. package/dist/{chunk-FLGLODDF.js.map → chunk-7RC37XFW.js.map} +1 -1
  48. package/dist/{chunk-OPBGV4DX.js → chunk-7SAWDPUT.js} +3 -3
  49. package/dist/{chunk-OPBGV4DX.js.map → chunk-7SAWDPUT.js.map} +1 -1
  50. package/dist/{chunk-GEEW6SY2.js → chunk-A5EDMBFG.js} +2 -2
  51. package/dist/{chunk-GEEW6SY2.js.map → chunk-A5EDMBFG.js.map} +1 -1
  52. package/dist/{chunk-QABZZROM.js → chunk-ARUJBGAH.js} +3 -3
  53. package/dist/{chunk-QABZZROM.js.map → chunk-ARUJBGAH.js.map} +1 -1
  54. package/dist/{chunk-6BEGKO2Q.js → chunk-B4IAZTZZ.js} +4 -3
  55. package/dist/chunk-B4IAZTZZ.js.map +1 -0
  56. package/dist/{chunk-FZFCOQTI.js → chunk-BCUVRJXV.js} +3 -3
  57. package/dist/{chunk-FZFCOQTI.js.map → chunk-BCUVRJXV.js.map} +1 -1
  58. package/dist/{chunk-UTZEHXYT.js → chunk-C75VKXAM.js} +3 -3
  59. package/dist/{chunk-UTZEHXYT.js.map → chunk-C75VKXAM.js.map} +1 -1
  60. package/dist/{chunk-5JAO4MXA.js → chunk-DOVURNRK.js} +3 -3
  61. package/dist/{chunk-5JAO4MXA.js.map → chunk-DOVURNRK.js.map} +1 -1
  62. package/dist/{chunk-P4VHQA4N.js → chunk-DSB6X25D.js} +3 -3
  63. package/dist/{chunk-P4VHQA4N.js.map → chunk-DSB6X25D.js.map} +1 -1
  64. package/dist/{chunk-OEBAXTQ4.js → chunk-EOKAFBJ7.js} +3 -3
  65. package/dist/{chunk-OEBAXTQ4.js.map → chunk-EOKAFBJ7.js.map} +1 -1
  66. package/dist/{chunk-ENXE4BKS.js → chunk-FTPKMJFD.js} +2 -2
  67. package/dist/{chunk-ENXE4BKS.js.map → chunk-FTPKMJFD.js.map} +1 -1
  68. package/dist/{chunk-MDBAEEY5.js → chunk-H7N6RWNF.js} +159 -7
  69. package/dist/chunk-H7N6RWNF.js.map +1 -0
  70. package/dist/{chunk-V2OQ3BI6.js → chunk-IDEA6CYI.js} +6 -5
  71. package/dist/chunk-IDEA6CYI.js.map +1 -0
  72. package/dist/{chunk-QKXDRBLL.js → chunk-JEPSP6XK.js} +11 -80
  73. package/dist/chunk-JEPSP6XK.js.map +1 -0
  74. package/dist/{chunk-KIFJWSNC.js → chunk-KAJH3XPW.js} +7 -3
  75. package/dist/chunk-KAJH3XPW.js.map +1 -0
  76. package/dist/{chunk-2QYQOJ2F.js → chunk-KC3OF6B2.js} +3 -3
  77. package/dist/{chunk-2QYQOJ2F.js.map → chunk-KC3OF6B2.js.map} +1 -1
  78. package/dist/{chunk-5SGS5SN2.js → chunk-M7GPCWEV.js} +4 -4
  79. package/dist/{chunk-5SGS5SN2.js.map → chunk-M7GPCWEV.js.map} +1 -1
  80. package/dist/{chunk-L7R52OOV.js → chunk-NLKIW2VI.js} +3 -3
  81. package/dist/{chunk-L7R52OOV.js.map → chunk-NLKIW2VI.js.map} +1 -1
  82. package/dist/{chunk-DFZDL62S.js → chunk-OLMNDIAU.js} +14 -9
  83. package/dist/chunk-OLMNDIAU.js.map +1 -0
  84. package/dist/{chunk-3SUWLY3H.js → chunk-OQRB7JUS.js} +3 -3
  85. package/dist/{chunk-3SUWLY3H.js.map → chunk-OQRB7JUS.js.map} +1 -1
  86. package/dist/{chunk-USJWXEXS.js → chunk-P7BU6DAC.js} +235 -48
  87. package/dist/chunk-P7BU6DAC.js.map +1 -0
  88. package/dist/{chunk-MRS5YHPI.js → chunk-QBQITQAM.js} +3 -3
  89. package/dist/{chunk-MRS5YHPI.js.map → chunk-QBQITQAM.js.map} +1 -1
  90. package/dist/{chunk-KN5Y5BXK.js → chunk-QVLQGXT6.js} +5 -5
  91. package/dist/{chunk-KN5Y5BXK.js.map → chunk-QVLQGXT6.js.map} +1 -1
  92. package/dist/{chunk-RZXP5ZER.js → chunk-RDYI4MML.js} +3 -3
  93. package/dist/{chunk-RZXP5ZER.js.map → chunk-RDYI4MML.js.map} +1 -1
  94. package/dist/{chunk-SOFPA4S4.js → chunk-SM6EUQMY.js} +8 -8
  95. package/dist/{chunk-SOFPA4S4.js.map → chunk-SM6EUQMY.js.map} +1 -1
  96. package/dist/chunk-SSCPTAFJ.js +29 -0
  97. package/dist/chunk-SSCPTAFJ.js.map +1 -0
  98. package/dist/chunk-TLKM4M47.js +78 -0
  99. package/dist/chunk-TLKM4M47.js.map +1 -0
  100. package/dist/{chunk-NFECHLV6.js → chunk-TNWXGHLD.js} +3 -3
  101. package/dist/{chunk-NFECHLV6.js.map → chunk-TNWXGHLD.js.map} +1 -1
  102. package/dist/{chunk-R2SYODNK.js → chunk-TQ6XNACF.js} +274 -67
  103. package/dist/chunk-TQ6XNACF.js.map +1 -0
  104. package/dist/{chunk-WQULDAH2.js → chunk-TSVRKUGV.js} +2 -2
  105. package/dist/{chunk-WQULDAH2.js.map → chunk-TSVRKUGV.js.map} +1 -1
  106. package/dist/{chunk-H3KXUUYQ.js → chunk-VDBP6Y5M.js} +4 -4
  107. package/dist/{chunk-H3KXUUYQ.js.map → chunk-VDBP6Y5M.js.map} +1 -1
  108. package/dist/{chunk-XN7DAZB7.js → chunk-VJNTB4DN.js} +5 -5
  109. package/dist/chunk-VJNTB4DN.js.map +1 -0
  110. package/dist/{chunk-7YCPY6NC.js → chunk-VXPFSZDT.js} +6 -6
  111. package/dist/{chunk-7YCPY6NC.js.map → chunk-VXPFSZDT.js.map} +1 -1
  112. package/dist/{chunk-UFBURH6K.js → chunk-WCWFS36P.js} +4 -4
  113. package/dist/{chunk-UFBURH6K.js.map → chunk-WCWFS36P.js.map} +1 -1
  114. package/dist/{chunk-A5RRXBLI.js → chunk-X4DKUGV4.js} +5 -5
  115. package/dist/{chunk-A5RRXBLI.js.map → chunk-X4DKUGV4.js.map} +1 -1
  116. package/dist/{chunk-BSIHJZKN.js → chunk-XU7JET5Z.js} +107 -26
  117. package/dist/chunk-XU7JET5Z.js.map +1 -0
  118. package/dist/{chunk-VCLN2IUM.js → chunk-YCMZHL4T.js} +31 -27
  119. package/dist/chunk-YCMZHL4T.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-J5CDTQ36.js} +18 -17
  190. package/dist/ensure-sources-J5CDTQ36.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-EP6H3O3S.js} +18 -17
  217. package/dist/{helpers-IELIL4YR.js.map → helpers-EP6H3O3S.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-KKT73FJK.js} +95 -41
  237. package/dist/library-publish-KKT73FJK.js.map +1 -0
  238. package/dist/open-library-R62UBL6E.js +38 -0
  239. package/dist/{open-library-ULRYWTEA.js.map → open-library-R62UBL6E.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-GCW5DFAB.js +34 -0
  245. package/dist/{project-VKYNDEB6.js.map → project-GCW5DFAB.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/resource-handler.d.ts +32 -3
  251. package/dist/runner/src/resource-handler.d.ts.map +1 -1
  252. package/dist/runner/src/runtime-session-emit.d.ts +2 -1
  253. package/dist/runner/src/runtime-session-emit.d.ts.map +1 -1
  254. package/dist/runner/src/serve.d.ts.map +1 -1
  255. package/dist/sdk/asset-manager.js +15 -14
  256. package/dist/sdk/bridge.js +15 -14
  257. package/dist/sdk/core.js +8 -7
  258. package/dist/sdk/flow.js +9 -8
  259. package/dist/sdk/index.js +28 -27
  260. package/dist/sdk/index.js.map +1 -1
  261. package/dist/sdk/resolver.js +9 -8
  262. package/dist/sdk/runner.js +28 -27
  263. package/dist/sdk/session.js +2 -2
  264. package/dist/sdk/types.js +1 -1
  265. package/dist/secrets/index.js +2 -1
  266. package/dist/secrets/src/providers/local.d.ts.map +1 -1
  267. package/dist/session/index.js +2 -2
  268. package/dist/{setup-INJFK3VJ.js → setup-Q3LXY5AE.js} +25 -24
  269. package/dist/setup-Q3LXY5AE.js.map +1 -0
  270. package/dist/skills-R3RPIPWP.js +25 -0
  271. package/dist/{skills-JHUY4DFE.js.map → skills-R3RPIPWP.js.map} +1 -1
  272. package/dist/{source-IZXICUBU.js → source-CFQESKJU.js} +21 -20
  273. package/dist/{source-IZXICUBU.js.map → source-CFQESKJU.js.map} +1 -1
  274. package/dist/{source-manifest-publish-4JHOT4PA.js → source-manifest-publish-3TCBA2RV.js} +24 -25
  275. package/dist/source-manifest-publish-3TCBA2RV.js.map +1 -0
  276. package/dist/tui/index.js +28 -27
  277. package/dist/tui/index.js.map +1 -1
  278. package/dist/types/index.js +1 -1
  279. package/dist/types/manifests.js +1 -1
  280. package/dist/types/src/events.d.ts +73 -4
  281. package/dist/types/src/events.d.ts.map +1 -1
  282. package/dist/types/src/index.d.ts +2 -2
  283. package/dist/types/src/index.d.ts.map +1 -1
  284. package/dist/types/src/manifests/index.d.ts +1 -1
  285. package/dist/types/src/manifests/index.d.ts.map +1 -1
  286. package/dist/types/src/manifests/skill.d.ts +10 -0
  287. package/dist/types/src/manifests/skill.d.ts.map +1 -1
  288. package/dist/types/src/protocol.d.ts +3 -3
  289. package/dist/types/src/protocol.d.ts.map +1 -1
  290. package/dist/types/src/version.d.ts +27 -1
  291. package/dist/types/src/version.d.ts.map +1 -1
  292. package/dist/workspace-plugin/adapters/mcp.js +15 -14
  293. package/dist/workspace-plugin/adapters/omp.js +7 -7
  294. package/dist/workspace-plugin/index.js +1 -1
  295. package/package.json +1 -1
  296. package/dist/asset-feeds-KTRFFJYM.js.map +0 -1
  297. package/dist/chunk-2D3C4AJP.js.map +0 -1
  298. package/dist/chunk-6BEGKO2Q.js.map +0 -1
  299. package/dist/chunk-BSIHJZKN.js.map +0 -1
  300. package/dist/chunk-DFZDL62S.js.map +0 -1
  301. package/dist/chunk-FJYOQMXT.js.map +0 -1
  302. package/dist/chunk-KIFJWSNC.js.map +0 -1
  303. package/dist/chunk-MDBAEEY5.js.map +0 -1
  304. package/dist/chunk-MIRWAK5C.js +0 -158
  305. package/dist/chunk-MIRWAK5C.js.map +0 -1
  306. package/dist/chunk-QKXDRBLL.js.map +0 -1
  307. package/dist/chunk-R2SYODNK.js.map +0 -1
  308. package/dist/chunk-USJWXEXS.js.map +0 -1
  309. package/dist/chunk-V2OQ3BI6.js.map +0 -1
  310. package/dist/chunk-VCLN2IUM.js.map +0 -1
  311. package/dist/chunk-XN7DAZB7.js.map +0 -1
  312. package/dist/ensure-sources-IGU65O72.js.map +0 -1
  313. package/dist/flows-6MDMBQUZ.js +0 -24
  314. package/dist/library-publish-YKBYHZ43.js.map +0 -1
  315. package/dist/open-library-ULRYWTEA.js +0 -37
  316. package/dist/paths-4MTICP3T.js +0 -20
  317. package/dist/plugin-store-GQ4WQZJ2.js.map +0 -1
  318. package/dist/project-VKYNDEB6.js +0 -33
  319. package/dist/setup-INJFK3VJ.js.map +0 -1
  320. package/dist/skills-JHUY4DFE.js +0 -24
  321. package/dist/source-manifest-publish-4JHOT4PA.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../core/src/models.ts"],"names":[],"mappings":";;;AA4BO,IAAM,WAAA,GAAoC;AAAA,EAC/C,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;AAQO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AAwBO,SAAS,SAAS,CAAA,EAAuB;AAC9C,EAAA,MAAM,CAAA,GAAI,CAAA,CAAE,OAAA,CAAQ,GAAG,CAAA;AACvB,EAAA,IAAI,MAAM,EAAA,EAAI;AACZ,IAAA,MAAM,OAAO,CAAA,CAAE,KAAA,CAAM,CAAA,EAA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AE,IAAA,EAAM,GAAA,CAAI,IAAA,EAAM,IAAA,EAAM,IAAI,IAAA,EAAK;AAC1C;AAgKO,SAAS,kBAAkB,CAAA,EAAwC;AACxE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA,CAAO,CAAA,CAAE,IAAA,IAAQ,EAAE,CAAA;AAAA,IACzB,IAAA,EAAM,MAAA,CAAO,CAAA,CAAE,IAAA,IAAQ,OAAO,CAAA;AAAA,IAC9B,IAAA,EAAM,MAAA,CAAO,CAAA,CAAE,IAAA,IAAQ,EAAE,CAAA;AAAA,IACzB,MAAA,EAAQ,MAAA,CAAO,CAAA,CAAE,MAAA,IAAU,MAAM,CAAA;AAAA,IACjC,UAAU,CAAA,CAAE,QAAA,IAAY,OAAO,MAAA,CAAO,CAAA,CAAE,QAAQ,CAAA,GAAI;AAAA,GACtD;AACF;AAUO,SAAS,gBAAgB,CAAA,EAAwC;AACtE,EAAA,MAAM,CAAA,GAA6B;AAAA,IACjC,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,MAAM,CAAA,CAAE;AAAA,GACV;AACA,EAAA,IAAI,CAAA,CAAE,MAAA,KAAW,MAAA,EAAQ,CAAA,CAAE,SAAS,CAAA,CAAE,MAAA;AACtC,EAAA,IAAI,CAAA,CAAE,QAAA,IAAY,IAAA,EAAM,CAAA,CAAE,WAAW,CAAA,CAAE,QAAA;AACvC,EAAA,OAAO,CAAA;AACT","file":"chunk-GEEW6SY2.js","sourcesContent":["/**\n * Pure data models — no I/O, no side effects.\n */\n\nimport semver from \"semver\";\n\n/**\n * Discriminator for catalog entries and asset references.\n * Used in asset ref strings (e.g. `'skill:my-skill'`, `'agent:my-agent'`).\n * @docLink packages/core/concepts#asset-kind\n */\nexport type AssetKind =\n | \"skill\"\n | \"agent\"\n | \"prompt\"\n | \"bundle\"\n | \"flow\"\n | \"contract\"\n | \"mcp-server\"\n | \"persona\" // identity fragment — replaces SOUL.md in composition\n | \"ruleset\" // behavioral constraints — replaces RULES.md in composition\n | \"knowledge\" // knowledge bundle directory\n | \"connector\"; // connector descriptor (CONNECTOR.md)\n\n/**\n * All valid AssetKind values as a readonly array.\n * @docLink packages/core/concepts#asset-kinds\n */\nexport const ASSET_KINDS: readonly AssetKind[] = [\n \"skill\",\n \"agent\",\n \"prompt\",\n \"bundle\",\n \"flow\",\n \"contract\",\n \"mcp-server\",\n \"persona\",\n \"ruleset\",\n \"knowledge\",\n \"connector\",\n];\n/**\n * Asset kinds that represent individually installable assets (excludes \"bundle\").\n * Note: persona, ruleset, and knowledge are valid AssetKind values but are not\n * individually installable — they are resolved at session creation time via the\n * mixin-resolver, not through the install/deploy pipeline.\n * @docLink packages/core/concepts#individual-kinds\n */\nexport const INDIVIDUAL_KINDS = [\n \"skill\",\n \"agent\",\n \"prompt\",\n \"flow\",\n \"contract\",\n \"mcp-server\",\n] as const satisfies AssetKind[];\n\n// ── Dependency ────────────────────────────────────────────────────────────────\n\n/**\n * Declared dependency on another catalog asset.\n * @docLink packages/core/concepts#dependency\n */\nexport interface Dependency {\n /** Asset kind (e.g. \"skill\", \"agent\", \"contract\"). */\n kind: string;\n /** Asset name within that kind. */\n name: string;\n /** Canonical publisher namespace (when known). */\n publisher?: string;\n}\n\n/**\n * Parse a `\"kind:name\"` dependency string, or a bare `\"name\"` (defaults kind to `\"skill\"`).\n *\n * @param s - Dependency string, e.g. `\"skill:use-exa\"` or `\"use-exa\"`\n * @returns Parsed `{ kind, name }` dependency object\n * @docLink packages/core/concepts#parse-dep\n */\nexport function parseDep(s: string): Dependency {\n const i = s.indexOf(\":\");\n if (i !== -1) {\n const kind = s.slice(0, i).trim();\n const name = s.slice(i + 1).trim();\n return { kind, name };\n }\n return { kind: \"skill\", name: s.trim() };\n}\n\n/**\n * Serialize a Dependency back to its `\"kind:name\"` string form.\n *\n * @param d - Dependency to serialize\n * @returns String in `\"kind:name\"` format\n * @docLink packages/core/concepts#dep-to-str\n */\nexport function depToStr(d: Dependency): string {\n return `${d.kind}:${d.name}`;\n}\n\n// ── CatalogEntry ──────────────────────────────────────────────────────────────\n\n/**\n * A resolved catalog entry describing an installable asset.\n * Produced by manifest parsers and stored in the catalog YAML.\n * @docLink packages/core/concepts#catalog-entry\n */\nexport interface CatalogEntry {\n /** Unique asset name within its kind. */\n name: string;\n /** Asset kind discriminator. */\n kind: AssetKind;\n /** Short description of what this asset does. */\n description: string;\n /** Absolute path to manifest file */\n source: string;\n /** Canonical publisher namespace this asset belongs to (formerly `repository`). */\n publisher?: string;\n /**\n * `\"<org>/<repo>\"` coordinate the asset came from. Absent → the asset groups\n * directly under its publisher (local library with no git remote, or a\n * non-GitHub source). Replaces the former derived `domain` axis.\n */\n repo?: string;\n /**\n * Navigational domain slug (from a sidecar `DOMAIN.md`), or absent when no\n * domain claims this asset. Display-only — groups assets under their publisher\n * in the manage TUI; never part of identity or the install layout.\n */\n domainSlug?: string;\n /** Semantic version string (may be empty if not declared in the manifest). */\n version: string;\n /** Skills, agents, or other assets this entry depends on. */\n requires: Dependency[];\n /** Bundle dependencies — asset refs to install (bundles only). */\n dependencies: string[];\n /**\n * Kind-specific metadata extracted from the manifest frontmatter.\n * Used by MCP servers to carry default config (transport, command, args, env, url, headers)\n * so that `mcp:name` dependency refs resolve to a runnable declaration without\n * requiring verbose inline config in `skaile.yaml`.\n */\n metadata?: Record<string, unknown>;\n /** Curated facet, surfaced as a badge in the manage TUI (not a tree axis). */\n category?: string;\n /** Store-listing keywords (manifest `assets[].keywords`, else frontmatter). */\n keywords?: string[];\n /** Store-listing license (manifest `assets[].license`, else repo-level default). */\n license?: string;\n /** Store-listing homepage (manifest `assets[].homepage`, else repo-level default). */\n homepage?: string;\n}\n\n/**\n * How the members of a domain relate — drives display affordances only, never\n * install behaviour. Single canonical spelling shared with the store\n * (`DomainRelation` enum) and forge contract.\n */\nexport type DomainRelation = \"additions\" | \"alternatives\" | \"sequence\";\n\n/**\n * Display-only metadata for a navigational domain (from a sidecar `DOMAIN.md`,\n * surfaced by the store's `catalog.listDomains`). Keyed by {@link CatalogEntry.domainSlug}.\n * A domain groups assets under their publisher for co-discovery; it is never\n * part of asset identity and never bulk-installs.\n */\nexport interface CatalogDomain {\n /** Stable slug — the join key to {@link CatalogEntry.domainSlug}. */\n slug: string;\n /** Human-readable title (may change without breaking the slug join). */\n title: string;\n /** Free-text description from the `DOMAIN.md` body. */\n description?: string;\n /** How members relate — drives sort + per-asset glyph, not installs. */\n relation?: DomainRelation;\n /** Display order among a publisher's domains (ascending). */\n order?: number;\n /** `kind:name` ref of the recommended member (alternatives domains). */\n recommendedRef?: string;\n /** Sidecar provenance — `\"<org>/<repo>\"` the `DOMAIN.md` was authored in. */\n sidecarSource?: string;\n}\n\n/**\n * Construct a CatalogEntry from a raw deserialized record (e.g. from catalog.yaml).\n *\n * @param d - Raw object with loosely typed fields\n * @returns Normalized CatalogEntry\n * @docLink packages/core/concepts#entry-from-raw\n */\nexport function entryFromRaw(d: Record<string, unknown>): CatalogEntry {\n const rawDeps = d.dependencies;\n const deps = Array.isArray(rawDeps) ? (rawDeps as string[]).filter(Boolean) : [];\n const entry: CatalogEntry = {\n name: String(d.name ?? \"\"),\n kind: String(d.kind ?? \"skill\") as AssetKind,\n description: String(d.description ?? \"\"),\n source: String(d.source ?? \"\"),\n publisher: d.publisher != null ? String(d.publisher) : undefined,\n // Read `repo`, falling back to the legacy `domain` key so a stale\n // catalog.yaml cache written before this release still groups sanely.\n // The cache self-heals on next write (entryToRaw stops writing `domain`).\n repo: d.repo != null ? String(d.repo) : d.domain != null ? String(d.domain) : undefined,\n domainSlug: d.domainSlug != null ? String(d.domainSlug) : undefined,\n version: String(d.version ?? \"\"),\n requires: Array.isArray(d.requires)\n ? (d.requires as string[]).filter(Boolean).map(parseDep)\n : [],\n dependencies: deps,\n };\n if (d.metadata != null && typeof d.metadata === \"object\" && !Array.isArray(d.metadata)) {\n entry.metadata = d.metadata as Record<string, unknown>;\n }\n if (d.category != null) entry.category = String(d.category);\n if (Array.isArray(d.keywords)) {\n entry.keywords = (d.keywords as unknown[]).filter((k): k is string => typeof k === \"string\");\n }\n if (d.license != null) entry.license = String(d.license);\n if (d.homepage != null) entry.homepage = String(d.homepage);\n return entry;\n}\n\n/**\n * Serialize a CatalogEntry to a plain record suitable for YAML/JSON persistence.\n *\n * @param e - CatalogEntry to serialize\n * @returns Plain object with string-serialized requires and dependencies\n * @docLink packages/core/concepts#entry-to-raw\n */\nexport function entryToRaw(e: CatalogEntry): Record<string, unknown> {\n const raw: Record<string, unknown> = {\n name: e.name,\n kind: e.kind,\n description: e.description,\n source: e.source,\n publisher: e.publisher,\n repo: e.repo,\n version: e.version,\n ...(e.domainSlug != null ? { domainSlug: e.domainSlug } : {}),\n requires: e.requires.map(depToStr),\n dependencies: e.dependencies,\n };\n if (e.metadata) raw.metadata = e.metadata;\n if (e.category != null) raw.category = e.category;\n if (e.keywords && e.keywords.length > 0) raw.keywords = e.keywords;\n if (e.license != null) raw.license = e.license;\n if (e.homepage != null) raw.homepage = e.homepage;\n return raw;\n}\n\n// ── AssetRef ─────────────────────────────────────────────────────────────────\n\n/**\n * A parsed asset reference: `kind:@<publisher>/name[#pin]`.\n *\n * `publisher` is the canonical, GitHub-shaped publisher namespace (≤39 chars,\n * alphanumeric+hyphen). `pin` is a SemVer constraint, exact SHA, or absent.\n * Floating refs (`main`, `latest`, `HEAD`) are rejected at parse time.\n *\n * Produced by `parseAssetRef`; consumed by `resolveAsset` and `resolveAll`.\n * @docLink packages/core/concepts#asset-ref\n */\nexport interface AssetRef {\n kind: string;\n name: string;\n /** Canonical publisher namespace. Optional only for ambiguity-resolution\n * during migration; new manifests require it. */\n publisher?: string;\n /** SemVer constraint (^1.4.0, ~1.4, 1.x, exact 1.4.0), 40-char SHA, or undefined. */\n pin?: string;\n}\n\nconst SHA_RE = /^[0-9a-f]{40}$/i;\n\n// Scoped grammar: `kind:@publisher/name[#version]`. The publisher sub-pattern is\n// GitHub-shaped (1-39 chars, alphanumeric + single hyphens, no leading/trailing or\n// double hyphen); `@` is the scope sigil and `#` the version sigil. `name` is\n// intentionally permissive (`[^/#\\s]+` — only the structural separators are\n// forbidden); floating-ref rejection stays in `isValidPin`, so `#main`/`#latest`\n// match here and fail there with a clear message.\nconst SCOPED_REF_RE =\n /^(?:([a-z][a-z0-9-]*):)?@([A-Za-z0-9](?:[A-Za-z0-9]|-(?!-)){0,37}[A-Za-z0-9]|[A-Za-z0-9])\\/([^/#\\s]+)(?:#(.+))?$/;\n\n// Canonical asset-name grammar: lowercase kebab-case (npm-style, scope-free) —\n// `a-z` / `0-9` segments joined by single hyphens, no leading/trailing hyphen,\n// no uppercase, spaces, dots, or underscores. Names become directory names,\n// lock keys, and CLI args, so the constraint is intentionally narrow.\nconst ASSET_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n// Diagnostic-only matcher: a ref carrying a `kind:@publisher/` scope prefix,\n// capturing whatever follows (sans `#pin`) as the candidate name. Used solely\n// to tell \"missing publisher\" apart from \"malformed name\" when the strict\n// grammar above fails (e.g. a space in the name).\nconst SCOPE_PREFIX_RE = /^(?:[a-z][a-z0-9-]*:)?@[^/\\s]+\\/([^#]+?)(?:#.*)?$/;\n\n/** Human-readable statement of the canonical asset-name rule. */\nexport const ASSET_NAME_HINT =\n 'names must be lowercase kebab-case (a-z, 0-9, single hyphens; e.g. \"cli-concept\")';\n\n/**\n * True when `name` is a canonical asset name: lowercase kebab-case, scope-free.\n *\n * This is the single source of truth for asset-name validity — `parseAssetRef`\n * enforces it, and `skaile validate` reports violations across a repo tree.\n * @docLink packages/core/concepts#is-valid-asset-name\n */\nexport function isValidAssetName(name: string): boolean {\n return ASSET_NAME_RE.test(name);\n}\n\n/**\n * Coerce an arbitrary string into a canonical asset name (lowercase kebab-case).\n *\n * For **third-party sources we don't control**, an upstream asset may carry a\n * human-styled identity (`\"Complex App\"`, `\"CLI_Concept\"`). The canonical grammar\n * (`isValidAssetName`) rejects those, so the ingestion boundary slugifies them to\n * a valid identity rather than crashing: Unicode is folded to ASCII, the result is\n * lowercased, every run of non-`[a-z0-9]` becomes a single hyphen, and\n * leading/trailing hyphens are trimmed. The transform is idempotent and a no-op on\n * already-canonical names.\n *\n * This is intentionally **lossy** — the pretty original is not part of identity.\n * Callers that want to preserve it for display must stash it themselves (e.g. on\n * `CatalogEntry.metadata.displayName`). Authoring-time validation (`skaile validate`)\n * still uses `isValidAssetName` on raw frontmatter, so first-party typos surface there.\n *\n * @throws When `raw` contains no `[a-z0-9]` character (nothing to slugify).\n * @docLink packages/core/concepts#slugify-asset-name\n */\nexport function slugifyAssetName(raw: string): string {\n const slug = raw\n .normalize(\"NFKD\")\n .replace(/[\\u0300-\\u036f]/g, \"\") // strip combining accents\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n if (!slug) {\n throw new Error(`cannot derive a canonical asset name from \"${raw}\" — ${ASSET_NAME_HINT}.`);\n }\n return slug;\n}\n\n/** True when `pin` is a SemVer constraint, exact SemVer, or 40-char SHA. */\nfunction isValidPin(pin: string): boolean {\n if (SHA_RE.test(pin)) return true;\n if (semver.valid(pin)) return true;\n if (semver.validRange(pin)) return true;\n return false;\n}\n\n/** Throw the canonical non-canonical-pin error for a ref `s` carrying `pin`. */\nfunction rejectFloatingPin(s: string, pin: string): never {\n throw new Error(\n `non-canonical pin \"${pin}\" in \"${s}\" — pin must be a SemVer ` +\n \"constraint (1.4.0, ^1.4, ~1.4, 1.x), a 40-char SHA, or absent. \" +\n \"Floating refs (main/latest/HEAD) are not allowed.\",\n );\n}\n\n/** Throw the canonical malformed-name error for a ref `s` carrying `name`. */\nfunction rejectInvalidName(s: string, name: string): never {\n throw new Error(\n `invalid asset name \"${name}\" in ref \"${s}\" — ${ASSET_NAME_HINT}. ` +\n \"Run the `migrate-skaile-manifest` skill on legacy manifests.\",\n );\n}\n\n/**\n * Parse a canonical asset reference string into an `AssetRef` object.\n *\n * Grammar: `kind:@<publisher>/name[#version]`\n * \"skill:@skaile-ai/audit\" → { kind: \"skill\", name: \"audit\", publisher: \"skaile-ai\" }\n * \"skill:@skaile-ai/audit#^1.4.0\" → { …, pin: \"^1.4.0\" }\n * \"skill:@skaile-ai/audit#<40-sha>\" → { …, pin: \"<40-sha>\" }\n *\n * `@` is the scope sigil and `#` the version sigil. `<publisher>` is GitHub-shaped\n * (≤39 chars, alphanumeric+hyphen, no leading/trailing or double hyphen). `pin`\n * accepts a SemVer constraint (`^`, `~`, `x`, exact), a 40-char SHA, or is absent.\n * Floating refs (`main`/`latest`/`HEAD`/anything non-canonical) are parse-time errors.\n *\n * The shorthand `mcp:` is normalized to `mcp-server:`. `kind` defaults to `\"skill\"`.\n *\n * @param s - Asset reference string\n * @returns Parsed `AssetRef`\n * @throws When the ref matches no grammar, the publisher is malformed, or the pin\n * is a floating ref.\n * @docLink packages/core/concepts#parse-asset-ref\n */\nexport function parseAssetRef(s: string): AssetRef {\n const trimmed = s.trim();\n const m = SCOPED_REF_RE.exec(trimmed);\n if (m) {\n const kindRaw = m[1] ?? \"skill\";\n const kind = kindRaw === \"mcp\" ? \"mcp-server\" : kindRaw;\n const publisher = m[2];\n const name = m[3];\n const pin = m[4]?.trim() || undefined;\n if (!isValidAssetName(name)) rejectInvalidName(s, name);\n if (pin !== undefined && !isValidPin(pin)) rejectFloatingPin(s, pin);\n return { kind, name, publisher, pin };\n }\n\n // The strict grammar failed. If the ref nonetheless carries a `@publisher/`\n // scope and the fault is the name (e.g. an embedded space), surface a\n // name-specific error rather than the misleading \"publisher required\" — the\n // publisher is plainly present. A *valid* captured name means the publisher\n // itself is malformed, so fall through to the publisher error below.\n const scoped = SCOPE_PREFIX_RE.exec(trimmed);\n if (scoped) {\n const candidate = scoped[1].trim();\n if (!isValidAssetName(candidate)) rejectInvalidName(s, candidate);\n }\n\n throw new Error(\n `publisher required in asset ref \"${s}\" — use \\`kind:@<publisher>/name\\`. ` +\n \"Run the `migrate-skaile-manifest` skill on legacy manifests.\",\n );\n}\n\n/**\n * Serialize an AssetRef back to its canonical string form.\n *\n * Emits the scope form `kind:@publisher/name[#pin]` when `publisher` is present,\n * and the bare `kind:name[#pin]` form for transitive refs that inherit it.\n *\n * @param ref - AssetRef to serialize\n * @returns String in `\"kind:@publisher/name[#pin]\"` (or bare `\"kind:name[#pin]\"`) format\n * @docLink packages/core/concepts#asset-ref-to-str\n */\nexport function assetRefToStr(ref: AssetRef): string {\n const scope = ref.publisher ? `@${ref.publisher}/${ref.name}` : ref.name;\n return `${ref.kind}:${scope}${ref.pin ? `#${ref.pin}` : \"\"}`;\n}\n\n/**\n * Convert an AssetRef to a simple Dependency, dropping the repository and pin qualifiers.\n *\n * @param ref - Full asset reference (may include repository and pin)\n * @returns Dependency with only kind and name\n * @docLink packages/core/concepts#asset-ref-to-dep\n */\nexport function assetRefToDep(ref: AssetRef): Dependency {\n // Grammar-agnostic — drops publisher/pin, so the scope-sigil change doesn't touch it.\n return { kind: ref.kind, name: ref.name };\n}\n\n// ── Lock File ────────────────────────────────────────────────────────────────\n\n/** A path/sha256 pair recorded for one file inside a locked asset. */\nexport interface LockFileEntry {\n path: string;\n sha256: string;\n}\n\n/**\n * Per-asset entry in the lock file (v3 schema).\n * Keyed in `LockFile.assets` by canonical ref (`<kind>:@<publisher>/<name>#<version>`).\n * @docLink packages/core/api-reference#lock-entry\n */\nexport interface LockEntry {\n /** Composite sha256 over sorted `<path>:<sha256>\\n` rows. */\n sha256: string;\n /** Resolved upstream source + commit. */\n source: { url: string; commit: string };\n /** Files that constitute the asset. */\n files: LockFileEntry[];\n /** True when an `overrides[]` entry pinned this resolution. */\n override_applied: boolean;\n}\n\n/** Per-source-URL entry in `LockFile.sources`. */\nexport interface LockSourceEntry {\n url: string;\n commit: string;\n}\n\n/**\n * Full skaile.lock.yaml structure (v3 schema).\n * @docLink packages/core/api-reference#lock-file\n */\nexport interface LockFile {\n /** Lock file schema version. v3 is canonical. */\n schema_version: 3;\n /** ISO timestamp of when the lock was generated. */\n locked_at: string;\n /** Resolved assets keyed by canonical ref `<kind>:@<publisher>/<name>#<version>`. */\n assets: Record<string, LockEntry>;\n /** Every source URL that contributed at least one resolved asset. */\n sources: LockSourceEntry[];\n /**\n * Resolved plugin packages (from `skaile.yaml` `plugins:`), keyed by package\n * name. The plugin-store reconciler reads this slice into its reconcile-hash\n * so a lock change reinstalls even when the manifest list is unchanged.\n */\n plugins?: Record<string, LockPluginEntry>;\n}\n\n/** One pinned plugin package in the lock file's `plugins` slice. */\nexport interface LockPluginEntry {\n /** Resolved exact version (e.g. \"0.1.3\"). */\n version: string;\n /** Package integrity hash (e.g. \"sha512-...\"); may be empty until populated from bun's output. */\n integrity: string;\n}\n\n// ── AgentManifest ────────────────────────────────────────────────────────────\n\n/**\n * Agent package manifest — parsed from `agent.yaml` in an agent directory.\n * Defines the agent's identity, model preferences, capability requirements, and composition mixins.\n * @docLink packages/core/concepts#agent-manifest\n */\nexport interface AgentManifest {\n spec_version?: string;\n name?: string;\n version?: string;\n description?: string;\n model?: {\n preferred?: string;\n fallback?: string[];\n constraints?: { temperature?: number; max_tokens?: number };\n };\n tools?: {\n allowed?: string[];\n denied?: string[];\n };\n delegation?: { mode?: string };\n requires?: Array<{ name: string; source: string; version?: string; mount: string }>;\n tags?: string[];\n author?: string;\n metadata?: Record<string, unknown>;\n /**\n * @deprecated Use `persona`, `rules`, and `knowledge` mixin arrays instead.\n * This field is declared but was never resolved at runtime.\n */\n extends?: string;\n abilities?: string[];\n /**\n * Identity fragments to compose into the agent persona.\n * Each entry is a catalog ref (`persona:name@repo#pin`), a bare name\n * (defaults to kind \"persona\"), or a local path (`./my.persona.md`).\n * Resolved in order — concatenated with \\n\\n---\\n\\n separator.\n */\n persona?: string[];\n /**\n * Behavioral rule sets to compose into the agent's constraints.\n * Each entry is a catalog ref (`ruleset:name@repo#pin`), bare name,\n * or local path. All rules apply (union).\n */\n rules?: string[];\n /**\n * Knowledge bundles to compose into the agent's domain knowledge.\n * Each entry is a catalog ref (`knowledge:name@repo#pin`), bare name,\n * or local path to a knowledge directory. Loaded in declaration order.\n */\n knowledge?: string[];\n contracts?: string[];\n /**\n * v2 composition items. Each entry references an asset (skill, connector,\n * soul, ruleset, etc.) with binding semantics (discoverable, inline-live,\n * inline-snapshot). Resolved at session start via the composition module.\n */\n composes?: Array<{\n kind: string;\n ref: string;\n instance?: string;\n binding?: \"discoverable\" | \"inline-live\" | \"inline-snapshot\";\n }>;\n runtime?: {\n max_turns?: number;\n timeout?: number;\n [key: string]: unknown;\n };\n}\n\n// ── Repository ───────────────────────────────────────────────────────────────\n\ntype RepositoryKind = \"local\" | \"github\";\n\n/**\n * A registered asset repository (local path or cloned GitHub repo).\n * Stored in the catalog; consumed by `repo-manager` for cloning and scanning.\n * @docLink packages/core/concepts#repository\n */\nexport interface Repository {\n /** Logical repository name. */\n name: string;\n /** Storage kind: \"local\" for paths, \"github\" for remote URLs. */\n kind: RepositoryKind;\n /** Absolute path (local) or remote URL (github). */\n path: string;\n /** Active branch. */\n branch: string;\n /** Upstream fork URL (for fork-based workflows). */\n upstream?: string;\n}\n\n/**\n * Construct a `Repository` from a raw deserialized record.\n *\n * @param d - Raw object from YAML/JSON\n * @returns Normalized `Repository`\n * @docLink packages/core/concepts#repository-from-raw\n */\nexport function repositoryFromRaw(d: Record<string, unknown>): Repository {\n return {\n name: String(d.name ?? \"\"),\n kind: String(d.kind ?? \"local\") as RepositoryKind,\n path: String(d.path ?? \"\"),\n branch: String(d.branch ?? \"main\"),\n upstream: d.upstream != null ? String(d.upstream) : undefined,\n };\n}\n\n/**\n * Serialize a `Repository` to a plain record for YAML/JSON persistence.\n * Omits the `branch` field when it equals `\"main\"` to keep serialized output clean.\n *\n * @param r - Repository to serialize\n * @returns Plain object suitable for YAML/JSON\n * @docLink packages/core/concepts#repository-to-raw\n */\nexport function repositoryToRaw(r: Repository): Record<string, unknown> {\n const d: Record<string, unknown> = {\n name: r.name,\n kind: r.kind,\n path: r.path,\n };\n if (r.branch !== \"main\") d.branch = r.branch;\n if (r.upstream != null) d.upstream = r.upstream;\n return d;\n}\n"]}
1
+ {"version":3,"sources":["../core/src/models.ts"],"names":[],"mappings":";;;AA4BO,IAAM,WAAA,GAAoC;AAAA,EAC/C,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;AAQO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AAwBO,SAAS,SAAS,CAAA,EAAuB;AAC9C,EAAA,MAAM,CAAA,GAAI,CAAA,CAAE,OAAA,CAAQ,GAAG,CAAA;AACvB,EAAA,IAAI,MAAM,EAAA,EAAI;AACZ,IAAA,MAAM,OAAO,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,CAAC,EAAE,IAAA,EAAK;AAChC,IAAA,MAAM,OAAO,CAAA,CAAE,KAAA,CAAM,CAAA,GAAI,CAAC,EAAE,IAAA,EAAK;AACjC,IAAA,OAAO,EAAE,MAAM,IAAA,EAAK;AAAA,EACtB;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,CAAA,CAAE,MAAK,EAAE;AACzC;AASO,SAAS,SAAS,CAAA,EAAuB;AAC9C,EAAA,OAAO,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,EAAE,IAAI,CAAA,CAAA;AAC5B;AA4FO,SAAS,aAAa,CAAA,EAA0C;AACrE,EAAA,MAAM,UAAU,CAAA,CAAE,YAAA;AAClB,EAAA,MAAM,IAAA,GAAO,MAAM,OAAA,CAAQ,OAAO,IAAK,OAAA,CAAqB,MAAA,CAAO,OAAO,CAAA,GAAI,EAAC;AAC/E,EAAA,MAAM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AA,GAA6B;AAAA,IACjC,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,MAAM,CAAA,CAAE;AAAA,GACV;AACA,EAAA,IAAI,CAAA,CAAE,MAAA,KAAW,MAAA,EAAQ,CAAA,CAAE,SAAS,CAAA,CAAE,MAAA;AACtC,EAAA,IAAI,CAAA,CAAE,QAAA,IAAY,IAAA,EAAM,CAAA,CAAE,WAAW,CAAA,CAAE,QAAA;AACvC,EAAA,OAAO,CAAA;AACT","file":"chunk-A5EDMBFG.js","sourcesContent":["/**\n * Pure data models — no I/O, no side effects.\n */\n\nimport semver from \"semver\";\n\n/**\n * Discriminator for catalog entries and asset references.\n * Used in asset ref strings (e.g. `'skill:my-skill'`, `'agent:my-agent'`).\n * @docLink packages/core/concepts#asset-kind\n */\nexport type AssetKind =\n | \"skill\"\n | \"agent\"\n | \"prompt\"\n | \"bundle\"\n | \"flow\"\n | \"contract\"\n | \"mcp-server\"\n | \"persona\" // identity fragment — replaces SOUL.md in composition\n | \"ruleset\" // behavioral constraints — replaces RULES.md in composition\n | \"knowledge\" // knowledge bundle directory\n | \"connector\"; // connector descriptor (CONNECTOR.md)\n\n/**\n * All valid AssetKind values as a readonly array.\n * @docLink packages/core/concepts#asset-kinds\n */\nexport const ASSET_KINDS: readonly AssetKind[] = [\n \"skill\",\n \"agent\",\n \"prompt\",\n \"bundle\",\n \"flow\",\n \"contract\",\n \"mcp-server\",\n \"persona\",\n \"ruleset\",\n \"knowledge\",\n \"connector\",\n];\n/**\n * Asset kinds that represent individually installable assets (excludes \"bundle\").\n * Note: persona, ruleset, and knowledge are valid AssetKind values but are not\n * individually installable — they are resolved at session creation time via the\n * mixin-resolver, not through the install/deploy pipeline.\n * @docLink packages/core/concepts#individual-kinds\n */\nexport const INDIVIDUAL_KINDS = [\n \"skill\",\n \"agent\",\n \"prompt\",\n \"flow\",\n \"contract\",\n \"mcp-server\",\n] as const satisfies AssetKind[];\n\n// ── Dependency ────────────────────────────────────────────────────────────────\n\n/**\n * Declared dependency on another catalog asset.\n * @docLink packages/core/concepts#dependency\n */\nexport interface Dependency {\n /** Asset kind (e.g. \"skill\", \"agent\", \"contract\"). */\n kind: string;\n /** Asset name within that kind. */\n name: string;\n /** Canonical publisher namespace (when known). */\n publisher?: string;\n}\n\n/**\n * Parse a `\"kind:name\"` dependency string, or a bare `\"name\"` (defaults kind to `\"skill\"`).\n *\n * @param s - Dependency string, e.g. `\"skill:use-exa\"` or `\"use-exa\"`\n * @returns Parsed `{ kind, name }` dependency object\n * @docLink packages/core/concepts#parse-dep\n */\nexport function parseDep(s: string): Dependency {\n const i = s.indexOf(\":\");\n if (i !== -1) {\n const kind = s.slice(0, i).trim();\n const name = s.slice(i + 1).trim();\n return { kind, name };\n }\n return { kind: \"skill\", name: s.trim() };\n}\n\n/**\n * Serialize a Dependency back to its `\"kind:name\"` string form.\n *\n * @param d - Dependency to serialize\n * @returns String in `\"kind:name\"` format\n * @docLink packages/core/concepts#dep-to-str\n */\nexport function depToStr(d: Dependency): string {\n return `${d.kind}:${d.name}`;\n}\n\n// ── CatalogEntry ──────────────────────────────────────────────────────────────\n\n/**\n * A resolved catalog entry describing an installable asset.\n * Produced by manifest parsers and stored in the catalog YAML.\n * @docLink packages/core/concepts#catalog-entry\n */\nexport interface CatalogEntry {\n /** Unique asset name within its kind. */\n name: string;\n /** Asset kind discriminator. */\n kind: AssetKind;\n /** Short description of what this asset does. */\n description: string;\n /** Absolute path to manifest file */\n source: string;\n /** Canonical publisher namespace this asset belongs to (formerly `repository`). */\n publisher?: string;\n /**\n * `\"<org>/<repo>\"` coordinate the asset came from. Absent → the asset groups\n * directly under its publisher (local library with no git remote, or a\n * non-GitHub source). Replaces the former derived `domain` axis.\n */\n repo?: string;\n /**\n * Navigational domain slug (from a sidecar `DOMAIN.md`), or absent when no\n * domain claims this asset. Display-only — groups assets under their publisher\n * in the manage TUI; never part of identity or the install layout.\n */\n domainSlug?: string;\n /** Semantic version string (may be empty if not declared in the manifest). */\n version: string;\n /** Skills, agents, or other assets this entry depends on. */\n requires: Dependency[];\n /** Bundle dependencies — asset refs to install (bundles only). */\n dependencies: string[];\n /**\n * Kind-specific metadata extracted from the manifest frontmatter.\n * Used by MCP servers to carry default config (transport, command, args, env, url, headers)\n * so that `mcp:name` dependency refs resolve to a runnable declaration without\n * requiring verbose inline config in `skaile.yaml`.\n */\n metadata?: Record<string, unknown>;\n /** Curated facet, surfaced as a badge in the manage TUI (not a tree axis). */\n category?: string;\n /** Store-listing keywords (manifest `assets[].keywords`, else frontmatter). */\n keywords?: string[];\n /** Store-listing license (manifest `assets[].license`, else repo-level default). */\n license?: string;\n /** Store-listing homepage (manifest `assets[].homepage`, else repo-level default). */\n homepage?: string;\n}\n\n/**\n * How the members of a domain relate — drives display affordances only, never\n * install behaviour. Single canonical spelling shared with the store\n * (`DomainRelation` enum) and forge contract.\n */\nexport type DomainRelation = \"additions\" | \"alternatives\" | \"sequence\";\n\n/**\n * Display-only metadata for a navigational domain (from a sidecar `DOMAIN.md`,\n * surfaced by the store's `catalog.listDomains`). Keyed by {@link CatalogEntry.domainSlug}.\n * A domain groups assets under their publisher for co-discovery; it is never\n * part of asset identity and never bulk-installs.\n */\nexport interface CatalogDomain {\n /** Stable slug — the join key to {@link CatalogEntry.domainSlug}. */\n slug: string;\n /** Human-readable title (may change without breaking the slug join). */\n title: string;\n /** Free-text description from the `DOMAIN.md` body. */\n description?: string;\n /** How members relate — drives sort + per-asset glyph, not installs. */\n relation?: DomainRelation;\n /** Display order among a publisher's domains (ascending). */\n order?: number;\n /** `kind:name` ref of the recommended member (alternatives domains). */\n recommendedRef?: string;\n /** Sidecar provenance — `\"<org>/<repo>\"` the `DOMAIN.md` was authored in. */\n sidecarSource?: string;\n}\n\n/**\n * Construct a CatalogEntry from a raw deserialized record (e.g. from catalog.yaml).\n *\n * @param d - Raw object with loosely typed fields\n * @returns Normalized CatalogEntry\n * @docLink packages/core/concepts#entry-from-raw\n */\nexport function entryFromRaw(d: Record<string, unknown>): CatalogEntry {\n const rawDeps = d.dependencies;\n const deps = Array.isArray(rawDeps) ? (rawDeps as string[]).filter(Boolean) : [];\n const entry: CatalogEntry = {\n name: String(d.name ?? \"\"),\n kind: String(d.kind ?? \"skill\") as AssetKind,\n description: String(d.description ?? \"\"),\n source: String(d.source ?? \"\"),\n publisher: d.publisher != null ? String(d.publisher) : undefined,\n // Read `repo`, falling back to the legacy `domain` key so a stale\n // catalog.yaml cache written before this release still groups sanely.\n // The cache self-heals on next write (entryToRaw stops writing `domain`).\n repo: d.repo != null ? String(d.repo) : d.domain != null ? String(d.domain) : undefined,\n domainSlug: d.domainSlug != null ? String(d.domainSlug) : undefined,\n version: String(d.version ?? \"\"),\n requires: Array.isArray(d.requires)\n ? (d.requires as string[]).filter(Boolean).map(parseDep)\n : [],\n dependencies: deps,\n };\n if (d.metadata != null && typeof d.metadata === \"object\" && !Array.isArray(d.metadata)) {\n entry.metadata = d.metadata as Record<string, unknown>;\n }\n if (d.category != null) entry.category = String(d.category);\n if (Array.isArray(d.keywords)) {\n entry.keywords = (d.keywords as unknown[]).filter((k): k is string => typeof k === \"string\");\n }\n if (d.license != null) entry.license = String(d.license);\n if (d.homepage != null) entry.homepage = String(d.homepage);\n return entry;\n}\n\n/**\n * Serialize a CatalogEntry to a plain record suitable for YAML/JSON persistence.\n *\n * @param e - CatalogEntry to serialize\n * @returns Plain object with string-serialized requires and dependencies\n * @docLink packages/core/concepts#entry-to-raw\n */\nexport function entryToRaw(e: CatalogEntry): Record<string, unknown> {\n const raw: Record<string, unknown> = {\n name: e.name,\n kind: e.kind,\n description: e.description,\n source: e.source,\n publisher: e.publisher,\n repo: e.repo,\n version: e.version,\n ...(e.domainSlug != null ? { domainSlug: e.domainSlug } : {}),\n requires: e.requires.map(depToStr),\n dependencies: e.dependencies,\n };\n if (e.metadata) raw.metadata = e.metadata;\n if (e.category != null) raw.category = e.category;\n if (e.keywords && e.keywords.length > 0) raw.keywords = e.keywords;\n if (e.license != null) raw.license = e.license;\n if (e.homepage != null) raw.homepage = e.homepage;\n return raw;\n}\n\n// ── AssetRef ─────────────────────────────────────────────────────────────────\n\n/**\n * A parsed asset reference: `kind:@<publisher>/name[#pin]`.\n *\n * `publisher` is the canonical, GitHub-shaped publisher namespace (≤39 chars,\n * alphanumeric+hyphen). `pin` is a SemVer constraint, exact SHA, or absent.\n * Floating refs (`main`, `latest`, `HEAD`) are rejected at parse time.\n *\n * Produced by `parseAssetRef`; consumed by `resolveAsset` and `resolveAll`.\n * @docLink packages/core/concepts#asset-ref\n */\nexport interface AssetRef {\n kind: string;\n name: string;\n /** Canonical publisher namespace. Optional only for ambiguity-resolution\n * during migration; new manifests require it. */\n publisher?: string;\n /** SemVer constraint (^1.4.0, ~1.4, 1.x, exact 1.4.0), 40-char SHA, or undefined. */\n pin?: string;\n}\n\nconst SHA_RE = /^[0-9a-f]{40}$/i;\n\n// Scoped grammar: `kind:@publisher/name[#version]`. The publisher sub-pattern is\n// GitHub-shaped (1-39 chars, alphanumeric + single hyphens, no leading/trailing or\n// double hyphen); `@` is the scope sigil and `#` the version sigil. `name` is\n// intentionally permissive (`[^/#\\s]+` — only the structural separators are\n// forbidden); floating-ref rejection stays in `isValidPin`, so `#main`/`#latest`\n// match here and fail there with a clear message.\nconst SCOPED_REF_RE =\n /^(?:([a-z][a-z0-9-]*):)?@([A-Za-z0-9](?:[A-Za-z0-9]|-(?!-)){0,37}[A-Za-z0-9]|[A-Za-z0-9])\\/([^/#\\s]+)(?:#(.+))?$/;\n\n// Canonical asset-name grammar: lowercase kebab-case (npm-style, scope-free) —\n// `a-z` / `0-9` segments joined by single hyphens, no leading/trailing hyphen,\n// no uppercase, spaces, dots, or underscores. Names become directory names,\n// lock keys, and CLI args, so the constraint is intentionally narrow.\nconst ASSET_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n// Diagnostic-only matcher: a ref carrying a `kind:@publisher/` scope prefix,\n// capturing whatever follows (sans `#pin`) as the candidate name. Used solely\n// to tell \"missing publisher\" apart from \"malformed name\" when the strict\n// grammar above fails (e.g. a space in the name).\nconst SCOPE_PREFIX_RE = /^(?:[a-z][a-z0-9-]*:)?@[^/\\s]+\\/([^#]+?)(?:#.*)?$/;\n\n/** Human-readable statement of the canonical asset-name rule. */\nexport const ASSET_NAME_HINT =\n 'names must be lowercase kebab-case (a-z, 0-9, single hyphens; e.g. \"cli-concept\")';\n\n/**\n * True when `name` is a canonical asset name: lowercase kebab-case, scope-free.\n *\n * This is the single source of truth for asset-name validity — `parseAssetRef`\n * enforces it, and `skaile validate` reports violations across a repo tree.\n * @docLink packages/core/concepts#is-valid-asset-name\n */\nexport function isValidAssetName(name: string): boolean {\n return ASSET_NAME_RE.test(name);\n}\n\n/**\n * Coerce an arbitrary string into a canonical asset name (lowercase kebab-case).\n *\n * For **third-party sources we don't control**, an upstream asset may carry a\n * human-styled identity (`\"Complex App\"`, `\"CLI_Concept\"`). The canonical grammar\n * (`isValidAssetName`) rejects those, so the ingestion boundary slugifies them to\n * a valid identity rather than crashing: Unicode is folded to ASCII, the result is\n * lowercased, every run of non-`[a-z0-9]` becomes a single hyphen, and\n * leading/trailing hyphens are trimmed. The transform is idempotent and a no-op on\n * already-canonical names.\n *\n * This is intentionally **lossy** — the pretty original is not part of identity.\n * Callers that want to preserve it for display must stash it themselves (e.g. on\n * `CatalogEntry.metadata.displayName`). Authoring-time validation (`skaile validate`)\n * still uses `isValidAssetName` on raw frontmatter, so first-party typos surface there.\n *\n * @throws When `raw` contains no `[a-z0-9]` character (nothing to slugify).\n * @docLink packages/core/concepts#slugify-asset-name\n */\nexport function slugifyAssetName(raw: string): string {\n const slug = raw\n .normalize(\"NFKD\")\n .replace(/[\\u0300-\\u036f]/g, \"\") // strip combining accents\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n if (!slug) {\n throw new Error(`cannot derive a canonical asset name from \"${raw}\" — ${ASSET_NAME_HINT}.`);\n }\n return slug;\n}\n\n/** True when `pin` is a SemVer constraint, exact SemVer, or 40-char SHA. */\nfunction isValidPin(pin: string): boolean {\n if (SHA_RE.test(pin)) return true;\n if (semver.valid(pin)) return true;\n if (semver.validRange(pin)) return true;\n return false;\n}\n\n/** Throw the canonical non-canonical-pin error for a ref `s` carrying `pin`. */\nfunction rejectFloatingPin(s: string, pin: string): never {\n throw new Error(\n `non-canonical pin \"${pin}\" in \"${s}\" — pin must be a SemVer ` +\n \"constraint (1.4.0, ^1.4, ~1.4, 1.x), a 40-char SHA, or absent. \" +\n \"Floating refs (main/latest/HEAD) are not allowed.\",\n );\n}\n\n/** Throw the canonical malformed-name error for a ref `s` carrying `name`. */\nfunction rejectInvalidName(s: string, name: string): never {\n throw new Error(\n `invalid asset name \"${name}\" in ref \"${s}\" — ${ASSET_NAME_HINT}. ` +\n \"Run the `migrate-skaile-manifest` skill on legacy manifests.\",\n );\n}\n\n/**\n * Parse a canonical asset reference string into an `AssetRef` object.\n *\n * Grammar: `kind:@<publisher>/name[#version]`\n * \"skill:@skaile-ai/audit\" → { kind: \"skill\", name: \"audit\", publisher: \"skaile-ai\" }\n * \"skill:@skaile-ai/audit#^1.4.0\" → { …, pin: \"^1.4.0\" }\n * \"skill:@skaile-ai/audit#<40-sha>\" → { …, pin: \"<40-sha>\" }\n *\n * `@` is the scope sigil and `#` the version sigil. `<publisher>` is GitHub-shaped\n * (≤39 chars, alphanumeric+hyphen, no leading/trailing or double hyphen). `pin`\n * accepts a SemVer constraint (`^`, `~`, `x`, exact), a 40-char SHA, or is absent.\n * Floating refs (`main`/`latest`/`HEAD`/anything non-canonical) are parse-time errors.\n *\n * The shorthand `mcp:` is normalized to `mcp-server:`. `kind` defaults to `\"skill\"`.\n *\n * @param s - Asset reference string\n * @returns Parsed `AssetRef`\n * @throws When the ref matches no grammar, the publisher is malformed, or the pin\n * is a floating ref.\n * @docLink packages/core/concepts#parse-asset-ref\n */\nexport function parseAssetRef(s: string): AssetRef {\n const trimmed = s.trim();\n const m = SCOPED_REF_RE.exec(trimmed);\n if (m) {\n const kindRaw = m[1] ?? \"skill\";\n const kind = kindRaw === \"mcp\" ? \"mcp-server\" : kindRaw;\n const publisher = m[2];\n const name = m[3];\n const pin = m[4]?.trim() || undefined;\n if (!isValidAssetName(name)) rejectInvalidName(s, name);\n if (pin !== undefined && !isValidPin(pin)) rejectFloatingPin(s, pin);\n return { kind, name, publisher, pin };\n }\n\n // The strict grammar failed. If the ref nonetheless carries a `@publisher/`\n // scope and the fault is the name (e.g. an embedded space), surface a\n // name-specific error rather than the misleading \"publisher required\" — the\n // publisher is plainly present. A *valid* captured name means the publisher\n // itself is malformed, so fall through to the publisher error below.\n const scoped = SCOPE_PREFIX_RE.exec(trimmed);\n if (scoped) {\n const candidate = scoped[1].trim();\n if (!isValidAssetName(candidate)) rejectInvalidName(s, candidate);\n }\n\n throw new Error(\n `publisher required in asset ref \"${s}\" — use \\`kind:@<publisher>/name\\`. ` +\n \"Run the `migrate-skaile-manifest` skill on legacy manifests.\",\n );\n}\n\n/**\n * Serialize an AssetRef back to its canonical string form.\n *\n * Emits the scope form `kind:@publisher/name[#pin]` when `publisher` is present,\n * and the bare `kind:name[#pin]` form for transitive refs that inherit it.\n *\n * @param ref - AssetRef to serialize\n * @returns String in `\"kind:@publisher/name[#pin]\"` (or bare `\"kind:name[#pin]\"`) format\n * @docLink packages/core/concepts#asset-ref-to-str\n */\nexport function assetRefToStr(ref: AssetRef): string {\n const scope = ref.publisher ? `@${ref.publisher}/${ref.name}` : ref.name;\n return `${ref.kind}:${scope}${ref.pin ? `#${ref.pin}` : \"\"}`;\n}\n\n/**\n * Convert an AssetRef to a simple Dependency, dropping the repository and pin qualifiers.\n *\n * @param ref - Full asset reference (may include repository and pin)\n * @returns Dependency with only kind and name\n * @docLink packages/core/concepts#asset-ref-to-dep\n */\nexport function assetRefToDep(ref: AssetRef): Dependency {\n // Grammar-agnostic — drops publisher/pin, so the scope-sigil change doesn't touch it.\n return { kind: ref.kind, name: ref.name };\n}\n\n// ── Lock File ────────────────────────────────────────────────────────────────\n\n/** A path/sha256 pair recorded for one file inside a locked asset. */\nexport interface LockFileEntry {\n path: string;\n sha256: string;\n}\n\n/**\n * Library-origin marker on a {@link LockEntry}: the asset was resolved from a\n * registered library (a local authoring place) rather than a git source/store.\n */\nexport interface LockLibraryOrigin {\n /** Name of the library the asset was resolved from. */\n name: string;\n /** Library version of the asset at lock time. */\n version: string;\n /** Content hash recorded in the library index at lock time; absent when the library was never indexed. */\n sha256?: string;\n}\n\n/**\n * Per-asset entry in the lock file (v3 schema).\n * Keyed in `LockFile.assets` by canonical ref (`<kind>:@<publisher>/<name>#<version>`).\n * Source-origin entries carry `source` + `files`; library-origin entries carry\n * `library` instead (no `source`, empty `files`). Both fields are additive, so\n * lock files written before library origin existed still load unchanged.\n * @docLink packages/core/api-reference#lock-entry\n */\nexport interface LockEntry {\n /** Composite sha256 over sorted `<path>:<sha256>\\n` rows (library-origin: the library's hash, `\"\"` when unknown). */\n sha256: string;\n /** Resolved upstream source + commit. Absent for library-origin entries. */\n source?: { url: string; commit: string };\n /** Files that constitute the asset. Empty for library-origin entries. */\n files: LockFileEntry[];\n /** True when an `overrides[]` entry pinned this resolution. */\n override_applied: boolean;\n /** Set when the asset was resolved from a registered library. */\n library?: LockLibraryOrigin;\n}\n\n/** Per-source-URL entry in `LockFile.sources`. */\nexport interface LockSourceEntry {\n url: string;\n commit: string;\n}\n\n/**\n * Full skaile.lock.yaml structure (v3 schema).\n * @docLink packages/core/api-reference#lock-file\n */\nexport interface LockFile {\n /**\n * Lock file schema version: 3, or 4 when the lock holds a library-origin\n * entry (no `source`), so CLIs that predate library origin reject it cleanly.\n */\n schema_version: 3 | 4;\n /** ISO timestamp of when the lock was generated. */\n locked_at: string;\n /** Resolved assets keyed by canonical ref `<kind>:@<publisher>/<name>#<version>`. */\n assets: Record<string, LockEntry>;\n /** Every source URL that contributed at least one resolved asset. */\n sources: LockSourceEntry[];\n /**\n * Resolved plugin packages (from `skaile.yaml` `plugins:`), keyed by package\n * name. The plugin-store reconciler reads this slice into its reconcile-hash\n * so a lock change reinstalls even when the manifest list is unchanged.\n */\n plugins?: Record<string, LockPluginEntry>;\n}\n\n/** One pinned plugin package in the lock file's `plugins` slice. */\nexport interface LockPluginEntry {\n /** Resolved exact version (e.g. \"0.1.3\"). */\n version: string;\n /** Package integrity hash (e.g. \"sha512-...\"); may be empty until populated from bun's output. */\n integrity: string;\n}\n\n// ── AgentManifest ────────────────────────────────────────────────────────────\n\n/**\n * Agent package manifest — parsed from `agent.yaml` in an agent directory.\n * Defines the agent's identity, model preferences, capability requirements, and composition mixins.\n * @docLink packages/core/concepts#agent-manifest\n */\nexport interface AgentManifest {\n spec_version?: string;\n name?: string;\n version?: string;\n description?: string;\n model?: {\n preferred?: string;\n fallback?: string[];\n constraints?: { temperature?: number; max_tokens?: number };\n };\n tools?: {\n allowed?: string[];\n denied?: string[];\n };\n delegation?: { mode?: string };\n requires?: Array<{ name: string; source: string; version?: string; mount: string }>;\n tags?: string[];\n author?: string;\n metadata?: Record<string, unknown>;\n /**\n * @deprecated Use `persona`, `rules`, and `knowledge` mixin arrays instead.\n * This field is declared but was never resolved at runtime.\n */\n extends?: string;\n abilities?: string[];\n /**\n * Identity fragments to compose into the agent persona.\n * Each entry is a catalog ref (`persona:name@repo#pin`), a bare name\n * (defaults to kind \"persona\"), or a local path (`./my.persona.md`).\n * Resolved in order — concatenated with \\n\\n---\\n\\n separator.\n */\n persona?: string[];\n /**\n * Behavioral rule sets to compose into the agent's constraints.\n * Each entry is a catalog ref (`ruleset:name@repo#pin`), bare name,\n * or local path. All rules apply (union).\n */\n rules?: string[];\n /**\n * Knowledge bundles to compose into the agent's domain knowledge.\n * Each entry is a catalog ref (`knowledge:name@repo#pin`), bare name,\n * or local path to a knowledge directory. Loaded in declaration order.\n */\n knowledge?: string[];\n contracts?: string[];\n /**\n * v2 composition items. Each entry references an asset (skill, connector,\n * soul, ruleset, etc.) with binding semantics (discoverable, inline-live,\n * inline-snapshot). Resolved at session start via the composition module.\n */\n composes?: Array<{\n kind: string;\n ref: string;\n instance?: string;\n binding?: \"discoverable\" | \"inline-live\" | \"inline-snapshot\";\n }>;\n runtime?: {\n max_turns?: number;\n timeout?: number;\n [key: string]: unknown;\n };\n}\n\n// ── Repository ───────────────────────────────────────────────────────────────\n\ntype RepositoryKind = \"local\" | \"github\";\n\n/**\n * A registered asset repository (local path or cloned GitHub repo).\n * Stored in the catalog; consumed by `repo-manager` for cloning and scanning.\n * @docLink packages/core/concepts#repository\n */\nexport interface Repository {\n /** Logical repository name. */\n name: string;\n /** Storage kind: \"local\" for paths, \"github\" for remote URLs. */\n kind: RepositoryKind;\n /** Absolute path (local) or remote URL (github). */\n path: string;\n /** Active branch. */\n branch: string;\n /** Upstream fork URL (for fork-based workflows). */\n upstream?: string;\n}\n\n/**\n * Construct a `Repository` from a raw deserialized record.\n *\n * @param d - Raw object from YAML/JSON\n * @returns Normalized `Repository`\n * @docLink packages/core/concepts#repository-from-raw\n */\nexport function repositoryFromRaw(d: Record<string, unknown>): Repository {\n return {\n name: String(d.name ?? \"\"),\n kind: String(d.kind ?? \"local\") as RepositoryKind,\n path: String(d.path ?? \"\"),\n branch: String(d.branch ?? \"main\"),\n upstream: d.upstream != null ? String(d.upstream) : undefined,\n };\n}\n\n/**\n * Serialize a `Repository` to a plain record for YAML/JSON persistence.\n * Omits the `branch` field when it equals `\"main\"` to keep serialized output clean.\n *\n * @param r - Repository to serialize\n * @returns Plain object suitable for YAML/JSON\n * @docLink packages/core/concepts#repository-to-raw\n */\nexport function repositoryToRaw(r: Repository): Record<string, unknown> {\n const d: Record<string, unknown> = {\n name: r.name,\n kind: r.kind,\n path: r.path,\n };\n if (r.branch !== \"main\") d.branch = r.branch;\n if (r.upstream != null) d.upstream = r.upstream;\n return d;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { globalSkaileDir } from './chunk-QKXDRBLL.js';
1
+ import { globalSkaileDir } from './chunk-TLKM4M47.js';
2
2
  import { createHash } from 'crypto';
3
3
  import { mkdirSync, rmSync, writeFileSync, renameSync, existsSync, readdirSync } from 'fs';
4
4
  import { join } from 'path';
@@ -28,5 +28,5 @@ function removeSessionConfigFile(dir, filename) {
28
28
  }
29
29
 
30
30
  export { driverSessionConfigHome, pruneSessionConfigDir, removeSessionConfigFile, writeSessionConfigFile };
31
- //# sourceMappingURL=chunk-QABZZROM.js.map
32
- //# sourceMappingURL=chunk-QABZZROM.js.map
31
+ //# sourceMappingURL=chunk-ARUJBGAH.js.map
32
+ //# sourceMappingURL=chunk-ARUJBGAH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../bridge/src/provider-materialize/session-config-home.ts"],"names":[],"mappings":";;;;;AAmDO,SAAS,uBAAA,CAAwB,UAAkB,MAAA,EAAkC;AAC1F,EAAA,MAAM,GAAA,GACJ,MAAA,CAAO,SAAA,IAAa,yBAAA,CAA0B,IAAA,CAAK,OAAO,SAAS,CAAA,GAC/D,MAAA,CAAO,SAAA,GACP,UAAA,CAAW,QAAQ,EAChB,MAAA,CAAO,MAAA,CAAO,SAAA,IAAa,MAAA,CAAO,GAAG,CAAA,CACrC,OAAO,KAAK,CAAA,CACZ,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AACpB,EAAA,OAAO,IAAA,CAAK,eAAA,EAAgB,EAAG,QAAA,EAAU,GAAG,CAAA;AAC9C;AAQO,SAAS,sBAAA,CAAuB,GAAA,EAAa,QAAA,EAAkB,QAAA,EAA0B;AAC9F,EAAA,SAAA,CAAU,KAAK,EAAE,SAAA,EAAW,IAAA,EAAM,IAAA,EAAM,KAAO,CAAA;AAC/C,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,EAAK,QAAQ,CAAA;AAC/B,EAAA,MAAM,SAAA,GAAY,GAAG,IAAI,CAAA,IAAA,CAAA;AACzB,EAAA,MAAA,CAAO,SAAA,EAAW,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA;AACjC,EAAA,aAAA,CAAc,WAAW,QAAA,EAAU,EAAE,MAAM,GAAA,EAAO,IAAA,EAAM,MAAM,CAAA;AAC9D,EAAA,UAAA,CAAW,WAAW,IAAI,CAAA;AAC1B,EAAA,OAAO,IAAA;AACT;AASO,SAAS,qBAAA,CAAsB,KAAa,IAAA,EAAiC;AAClF,EAAA,IAAI,CAAC,UAAA,CAAW,GAAG,CAAA,EAAG;AACtB,EAAA,KAAA,MAAW,IAAA,IAAQ,WAAA,CAAY,GAAG,CAAA,EAAG;AACnC,IAAA,IAAI,CAAC,KAAK,QAAA,CAAS,OAAO,KAAK,IAAA,CAAK,GAAA,CAAI,IAAI,CAAA,EAAG;AAC/C,IAAA,MAAA,CAAO,KAAK,GAAA,EAAK,IAAI,GAAG,EAAE,KAAA,EAAO,MAAM,CAAA;AAAA,EACzC;AACF;AAGO,SAAS,uBAAA,CAAwB,KAAa,QAAA,EAAwB;AAC3E,EAAA,MAAA,CAAO,KAAK,GAAA,EAAK,QAAQ,GAAG,EAAE,KAAA,EAAO,MAAM,CAAA;AAC7C","file":"chunk-QABZZROM.js","sourcesContent":["/**\n * Session-private config homes for the **file-shaped CLI drivers** — OpenCode,\n * Goose and Continue (§2.3, file rows).\n *\n * An environment variable can say *which* endpoint a harness should use, but\n * it cannot describe one the harness has never heard of: a self-hosted\n * gateway, a LiteLLM proxy, an Ollama box. Each of these three harnesses learns\n * such an endpoint only from its own config file, and each resolves that file\n * out of a config home it takes from the environment:\n *\n * | driver | variable | file this adapter writes |\n * |------------|----------------------|--------------------------------------|\n * | `opencode` | `XDG_CONFIG_HOME` | `opencode/opencode.json` |\n * | `goose` | `GOOSE_PATH_ROOT` | `config/custom_providers/<id>.json` |\n * | `continue` | `CONTINUE_GLOBAL_DIR`| `config.yaml` |\n *\n * Pointing those variables at a directory this process owns is what keeps the\n * developer's real `~/.config/opencode`, goose config dir and `~/.continue`\n * out of the session: unread, and — the part that matters — unwritten. The\n * harnesses all persist state next to their config (sessions, logs, an index),\n * so a session that rendered into the ambient home would leave its debris in\n * it.\n *\n * The home is keyed by session id so a resumed turn finds the same directory,\n * and it lives under `$SKAILE_HOME` (default `~/.skaile`) rather than inside\n * `cwd`: the working tree is writable by the model, and a config home in there\n * would let a turn rewrite its own `base_url`. `$SKAILE_HOME` is also the test\n * seam.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readdirSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { globalSkaileDir } from \"@skaile/workspaces/core\";\n\n/** The `AgentConfig` fields a session home is derived from. */\nexport interface SessionHomeInput {\n cwd: string;\n sessionId?: string;\n}\n\n/**\n * `$SKAILE_HOME/<driverId>/<key>` — the directory this process owns on the\n * session's behalf.\n *\n * `key` is the session id when it is already a safe path segment, and a\n * digest of it (or of `cwd`, for a session that carries no id) otherwise, so\n * an id containing a separator can never escape the driver's subtree.\n */\nexport function driverSessionConfigHome(driverId: string, config: SessionHomeInput): string {\n const key =\n config.sessionId && /^[A-Za-z0-9._-]{1,128}$/.test(config.sessionId)\n ? config.sessionId\n : createHash(\"sha256\")\n .update(config.sessionId ?? config.cwd)\n .digest(\"hex\")\n .slice(0, 32);\n return join(globalSkaileDir(), driverId, key);\n}\n\n/**\n * Write `contents` to `path`, creating its directory.\n *\n * Atomic by rename: a harness reading a half-written config fails the whole\n * session, and these files are re-rendered before every turn.\n */\nexport function writeSessionConfigFile(dir: string, filename: string, contents: string): string {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n const path = join(dir, filename);\n const temporary = `${path}.new`;\n rmSync(temporary, { force: true });\n writeFileSync(temporary, contents, { mode: 0o600, flag: \"wx\" });\n renameSync(temporary, path);\n return path;\n}\n\n/**\n * Delete every `.json` file in `dir` that is not in `keep`.\n *\n * Goose loads *all* of `custom_providers/`, so a provider file left over from\n * an earlier render of the same session would keep answering for an endpoint\n * the registry no longer declares.\n */\nexport function pruneSessionConfigDir(dir: string, keep: ReadonlySet<string>): void {\n if (!existsSync(dir)) return;\n for (const name of readdirSync(dir)) {\n if (!name.endsWith(\".json\") || keep.has(name)) continue;\n rmSync(join(dir, name), { force: true });\n }\n}\n\n/** Remove a file an earlier render left behind. */\nexport function removeSessionConfigFile(dir: string, filename: string): void {\n rmSync(join(dir, filename), { force: true });\n}\n"]}
1
+ {"version":3,"sources":["../bridge/src/provider-materialize/session-config-home.ts"],"names":[],"mappings":";;;;;AAmDO,SAAS,uBAAA,CAAwB,UAAkB,MAAA,EAAkC;AAC1F,EAAA,MAAM,GAAA,GACJ,MAAA,CAAO,SAAA,IAAa,yBAAA,CAA0B,IAAA,CAAK,OAAO,SAAS,CAAA,GAC/D,MAAA,CAAO,SAAA,GACP,UAAA,CAAW,QAAQ,EAChB,MAAA,CAAO,MAAA,CAAO,SAAA,IAAa,MAAA,CAAO,GAAG,CAAA,CACrC,OAAO,KAAK,CAAA,CACZ,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AACpB,EAAA,OAAO,IAAA,CAAK,eAAA,EAAgB,EAAG,QAAA,EAAU,GAAG,CAAA;AAC9C;AAQO,SAAS,sBAAA,CAAuB,GAAA,EAAa,QAAA,EAAkB,QAAA,EAA0B;AAC9F,EAAA,SAAA,CAAU,KAAK,EAAE,SAAA,EAAW,IAAA,EAAM,IAAA,EAAM,KAAO,CAAA;AAC/C,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,EAAK,QAAQ,CAAA;AAC/B,EAAA,MAAM,SAAA,GAAY,GAAG,IAAI,CAAA,IAAA,CAAA;AACzB,EAAA,MAAA,CAAO,SAAA,EAAW,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA;AACjC,EAAA,aAAA,CAAc,WAAW,QAAA,EAAU,EAAE,MAAM,GAAA,EAAO,IAAA,EAAM,MAAM,CAAA;AAC9D,EAAA,UAAA,CAAW,WAAW,IAAI,CAAA;AAC1B,EAAA,OAAO,IAAA;AACT;AASO,SAAS,qBAAA,CAAsB,KAAa,IAAA,EAAiC;AAClF,EAAA,IAAI,CAAC,UAAA,CAAW,GAAG,CAAA,EAAG;AACtB,EAAA,KAAA,MAAW,IAAA,IAAQ,WAAA,CAAY,GAAG,CAAA,EAAG;AACnC,IAAA,IAAI,CAAC,KAAK,QAAA,CAAS,OAAO,KAAK,IAAA,CAAK,GAAA,CAAI,IAAI,CAAA,EAAG;AAC/C,IAAA,MAAA,CAAO,KAAK,GAAA,EAAK,IAAI,GAAG,EAAE,KAAA,EAAO,MAAM,CAAA;AAAA,EACzC;AACF;AAGO,SAAS,uBAAA,CAAwB,KAAa,QAAA,EAAwB;AAC3E,EAAA,MAAA,CAAO,KAAK,GAAA,EAAK,QAAQ,GAAG,EAAE,KAAA,EAAO,MAAM,CAAA;AAC7C","file":"chunk-ARUJBGAH.js","sourcesContent":["/**\n * Session-private config homes for the **file-shaped CLI drivers** — OpenCode,\n * Goose and Continue (§2.3, file rows).\n *\n * An environment variable can say *which* endpoint a harness should use, but\n * it cannot describe one the harness has never heard of: a self-hosted\n * gateway, a LiteLLM proxy, an Ollama box. Each of these three harnesses learns\n * such an endpoint only from its own config file, and each resolves that file\n * out of a config home it takes from the environment:\n *\n * | driver | variable | file this adapter writes |\n * |------------|----------------------|--------------------------------------|\n * | `opencode` | `XDG_CONFIG_HOME` | `opencode/opencode.json` |\n * | `goose` | `GOOSE_PATH_ROOT` | `config/custom_providers/<id>.json` |\n * | `continue` | `CONTINUE_GLOBAL_DIR`| `config.yaml` |\n *\n * Pointing those variables at a directory this process owns is what keeps the\n * developer's real `~/.config/opencode`, goose config dir and `~/.continue`\n * out of the session: unread, and — the part that matters — unwritten. The\n * harnesses all persist state next to their config (sessions, logs, an index),\n * so a session that rendered into the ambient home would leave its debris in\n * it.\n *\n * The home is keyed by session id so a resumed turn finds the same directory,\n * and it lives under `$SKAILE_HOME` (default `~/.skaile`) rather than inside\n * `cwd`: the working tree is writable by the model, and a config home in there\n * would let a turn rewrite its own `base_url`. `$SKAILE_HOME` is also the test\n * seam.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readdirSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { globalSkaileDir } from \"@skaile/workspaces/core\";\n\n/** The `AgentConfig` fields a session home is derived from. */\nexport interface SessionHomeInput {\n cwd: string;\n sessionId?: string;\n}\n\n/**\n * `$SKAILE_HOME/<driverId>/<key>` — the directory this process owns on the\n * session's behalf.\n *\n * `key` is the session id when it is already a safe path segment, and a\n * digest of it (or of `cwd`, for a session that carries no id) otherwise, so\n * an id containing a separator can never escape the driver's subtree.\n */\nexport function driverSessionConfigHome(driverId: string, config: SessionHomeInput): string {\n const key =\n config.sessionId && /^[A-Za-z0-9._-]{1,128}$/.test(config.sessionId)\n ? config.sessionId\n : createHash(\"sha256\")\n .update(config.sessionId ?? config.cwd)\n .digest(\"hex\")\n .slice(0, 32);\n return join(globalSkaileDir(), driverId, key);\n}\n\n/**\n * Write `contents` to `path`, creating its directory.\n *\n * Atomic by rename: a harness reading a half-written config fails the whole\n * session, and these files are re-rendered before every turn.\n */\nexport function writeSessionConfigFile(dir: string, filename: string, contents: string): string {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n const path = join(dir, filename);\n const temporary = `${path}.new`;\n rmSync(temporary, { force: true });\n writeFileSync(temporary, contents, { mode: 0o600, flag: \"wx\" });\n renameSync(temporary, path);\n return path;\n}\n\n/**\n * Delete every `.json` file in `dir` that is not in `keep`.\n *\n * Goose loads *all* of `custom_providers/`, so a provider file left over from\n * an earlier render of the same session would keep answering for an endpoint\n * the registry no longer declares.\n */\nexport function pruneSessionConfigDir(dir: string, keep: ReadonlySet<string>): void {\n if (!existsSync(dir)) return;\n for (const name of readdirSync(dir)) {\n if (!name.endsWith(\".json\") || keep.has(name)) continue;\n rmSync(join(dir, name), { force: true });\n }\n}\n\n/** Remove a file an earlier render left behind. */\nexport function removeSessionConfigFile(dir: string, filename: string): void {\n rmSync(join(dir, filename), { force: true });\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-B4IAZTZZ.js.map
536
+ //# sourceMappingURL=chunk-B4IAZTZZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../secrets/src/lifecycle.ts","../secrets/src/providers/env.ts","../secrets/src/providers/local.ts","../secrets/src/router.ts","../secrets/src/index.ts"],"names":["provider"],"mappings":";;;;;;;;AAuCO,IAAM,6BAAN,MAAiC;AAAA,EAC9B,MAAA;AAAA;AAAA;AAAA;AAAA,EAKR,WAAA,CAAY,QAAuB,OAAA,EAA8C;AAC/E,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,gBAAgB,aAAA,EAA+C;AAGnE,IAAA,IAAI;AACF,MAAA,MAAM,IAAA,CAAK,MAAA,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vNO,IAAM,OAAA,GAAU","file":"chunk-B4IAZTZZ.js","sourcesContent":["/**\n * CredentialLifecycleService — manages OAuth token refresh outside the SecretsRouter.\n *\n * Works with opaque token blobs stored via the {@link SecretsRouter}; providers remain\n * OAuth-unaware. Phase 1 ships non-OAuth paths (always returns `not_applicable`).\n * Full proactive OAuth refresh with expiry checking ships in Phase 3.4.\n *\n * @docLink packages/secrets/concepts#credential-lifecycle\n */\n\nimport type { SecretsRouter } from \"./router.js\";\n\n/**\n * Configuration for {@link CredentialLifecycleService}.\n *\n * Controls how aggressively the service proactively refreshes credentials before they expire.\n * The default lead time is 300 seconds (5 minutes).\n *\n * @docLink packages/secrets/concepts#credential-lifecycle\n */\nexport interface CredentialLifecycleConfig {\n /** How far before expiry to trigger a proactive refresh (seconds). */\n refreshLeadTimeSec: number;\n}\n\n/**\n * Result returned by {@link CredentialLifecycleService.refreshIfNeeded}.\n *\n * The `reason` discriminant indicates why a refresh did or did not occur.\n * An `error` string is present only when `reason` is `refresh_failed`.\n *\n * @docLink packages/secrets/concepts#credential-lifecycle\n */\nexport interface RefreshResult {\n refreshed: boolean;\n reason: \"not_applicable\" | \"still_valid\" | \"refreshed\" | \"refresh_failed\";\n error?: string;\n}\n\nexport class CredentialLifecycleService {\n private router: SecretsRouter;\n\n // `_config` is accepted for signature stability but not stored yet: Phase 1\n // ships no OAuth refresh, so there is nothing to configure. Phase 3.4 will\n // store and read `refreshLeadTimeSec` when proactive refresh lands.\n constructor(router: SecretsRouter, _config?: Partial<CredentialLifecycleConfig>) {\n this.router = router;\n }\n\n /**\n * Attempt to refresh a credential if needed.\n * Phase 1: always returns not_applicable (no OAuth support yet).\n */\n async refreshIfNeeded(credentialRef: string): Promise<RefreshResult> {\n // Phase 1: no OAuth refresh implemented.\n // The credential exists and is valid as-is (static secrets, env vars, etc.)\n try {\n await this.router.getMetadata(credentialRef);\n return { refreshed: false, reason: \"not_applicable\" };\n } catch {\n return { refreshed: false, reason: \"refresh_failed\", error: \"Credential not found\" };\n }\n }\n\n /**\n * Check if a credential is still valid (not expired).\n * Phase 1: always returns true for non-OAuth credentials.\n */\n async isValid(credentialRef: string): Promise<boolean> {\n try {\n await this.router.getSecret(credentialRef);\n return true;\n } catch {\n return false;\n }\n }\n}\n","/**\n * EnvSecretsProvider — read-only provider that resolves secrets from environment variables.\n *\n * Refs are expected to be plain env var names (e.g. `DATABASE_URL`). The provider is\n * always available with zero configuration and requires no encryption or keychain access.\n * `setSecret` and `deleteSecret` always throw `SecretAccessDeniedError` because\n * environment variables are managed externally to the running process.\n *\n * @docLink packages/secrets/concepts#env-secrets-provider\n */\n\nimport type {\n ISecretsProvider,\n ListFilter,\n ProviderCapabilities,\n SecretMetadata,\n SetSecretOptions,\n} from \"@skaile/workspaces/plugins\";\nimport { SecretAccessDeniedError, SecretNotFoundError } from \"@skaile/workspaces/plugins\";\n\n/**\n * Sentinel timestamp for env secrets, which have no real created/updated time.\n * The Unix epoch is unambiguously not \"now\", so consumers can recognise it as\n * \"unknown\" rather than treating it as a genuine recent timestamp.\n */\nconst ENV_UNKNOWN_TIMESTAMP = new Date(0);\n\nexport class EnvSecretsProvider implements ISecretsProvider {\n readonly id = \"env\";\n\n async getSecret(ref: string): Promise<Uint8Array> {\n const value = process.env[ref];\n if (value === undefined) {\n throw new SecretNotFoundError(ref);\n }\n return new TextEncoder().encode(value);\n }\n\n async setSecret(_ref: string, _value: Uint8Array, _opts?: SetSecretOptions): Promise<void> {\n throw new SecretAccessDeniedError(\"EnvSecretsProvider is read-only\");\n }\n\n async deleteSecret(_ref: string): Promise<void> {\n throw new SecretAccessDeniedError(\"EnvSecretsProvider is read-only\");\n }\n\n async listSecrets(filter?: ListFilter): Promise<string[]> {\n let keys = Object.keys(process.env);\n if (filter?.prefix) {\n keys = keys.filter((k) => k.startsWith(filter.prefix!));\n }\n if (filter?.limit) {\n keys = keys.slice(0, filter.limit);\n }\n return keys;\n }\n\n async testConnection(): Promise<{ ok: boolean; latencyMs?: number; error?: string }> {\n return { ok: true, latencyMs: 0 };\n }\n\n async getMetadata(ref: string): Promise<SecretMetadata> {\n const value = process.env[ref];\n if (value === undefined) {\n throw new SecretNotFoundError(ref);\n }\n // Env vars carry no creation/modification time. `SecretMetadata` requires\n // both fields, so use the Unix epoch as a documented \"unknown\" sentinel\n // rather than `new Date()`, which would falsely imply the secret was just\n // created/updated. The read-only scope summary already signals the source.\n return {\n ref,\n createdAt: ENV_UNKNOWN_TIMESTAMP,\n updatedAt: ENV_UNKNOWN_TIMESTAMP,\n scopeSummary: \"environment variable (read-only)\",\n };\n }\n\n getCapabilities(): ProviderCapabilities {\n return {\n supportsRotation: false,\n supportsExpiry: false,\n supportsBatch: false,\n scopeModel: \"flat\",\n };\n }\n}\n","/**\n * LocalSecretsProvider — AES-256-GCM encrypted file-blob storage at `~/.skaile/secrets/`.\n *\n * Each secret is stored as a separate `.enc` file named by the SHA-256 hash of the ref\n * (collision-free, filesystem-safe). A companion `.meta.json` stores the original ref,\n * timestamps, and optional user metadata. The master key is derived via PBKDF2-SHA-512\n * from one of three {@link KeyStrategy} sources: OS keychain (keytar), a passphrase from\n * `SKAILE_SECRETS_PASSPHRASE`, or a machine-derived passphrase as last resort.\n * Switching strategies re-encrypts all existing secrets with the new key.\n *\n * @docLink packages/secrets/concepts#local-secrets-provider\n */\n\nimport * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\n\n// The narrow module, not the `core` barrel: the barrel's chunks use `import.meta`,\n// which CommonJS-transpiling consumers (ts-jest) cannot load.\nimport { globalSkaileDir } from \"../../../core/src/cache-paths.js\";\nimport type {\n ISecretsProvider,\n ListFilter,\n ProviderCapabilities,\n SecretMetadata,\n SetSecretOptions,\n} from \"@skaile/workspaces/plugins\";\nimport {\n ProviderUnavailableError,\n SecretNotFoundError,\n SecretsError,\n} from \"@skaile/workspaces/plugins\";\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst ALGORITHM = \"aes-256-gcm\";\nconst IV_LENGTH = 12;\nconst AUTH_TAG_LENGTH = 16;\nconst SALT_LENGTH = 32;\nconst KEY_LENGTH = 32;\nconst PBKDF2_ITERATIONS = 100_000;\nconst PBKDF2_DIGEST = \"sha512\";\n\nconst KEYCHAIN_SERVICE = \"skaile-secrets\";\nconst KEYCHAIN_ACCOUNT = \"master-key\";\n\n/** Env var that provides the passphrase at runtime (never stored on disk). */\nconst PASSPHRASE_ENV = \"SKAILE_SECRETS_PASSPHRASE\";\n\n/**\n * Master key derivation strategy used by {@link LocalSecretsProvider}.\n *\n * - `keychain` — OS keychain (via keytar); most secure, requires keytar to be installed.\n * - `passphrase` — PBKDF2 from `SKAILE_SECRETS_PASSPHRASE` env var; portable across machines.\n * - `machine` — deterministic from hostname + username; least secure, last-resort fallback.\n *\n * The active strategy is persisted in `~/.skaile/secrets/.key-strategy`. Switching strategies\n * re-encrypts all existing secrets with the new key.\n *\n * @docLink packages/secrets/concepts#local-secrets-provider\n */\nexport type KeyStrategy = \"keychain\" | \"passphrase\" | \"machine\";\n\n// ---------------------------------------------------------------------------\n// Key derivation\n// ---------------------------------------------------------------------------\n\nfunction deriveMasterKey(passphrase: string, salt: Buffer): Buffer {\n return crypto.pbkdf2Sync(passphrase, salt, PBKDF2_ITERATIONS, KEY_LENGTH, PBKDF2_DIGEST);\n}\n\nfunction getMachinePassphrase(): string {\n // Deterministic but not secret -- last resort only.\n return `skaile:${os.hostname()}:${os.userInfo().username}`;\n}\n\n/** Hash a passphrase for verification (stored in .master). */\nfunction hashPassphrase(passphrase: string): string {\n return crypto.createHash(\"sha256\").update(passphrase).digest(\"hex\");\n}\n\n// ---------------------------------------------------------------------------\n// Filename hashing (injective: sha256 of ref)\n// ---------------------------------------------------------------------------\n\nfunction refToHash(ref: string): string {\n return crypto.createHash(\"sha256\").update(ref).digest(\"hex\").slice(0, 40);\n}\n\n// ---------------------------------------------------------------------------\n// Encryption / decryption\n// ---------------------------------------------------------------------------\n\nfunction encrypt(data: Uint8Array, key: Buffer): Buffer {\n const iv = crypto.randomBytes(IV_LENGTH);\n const cipher = crypto.createCipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });\n const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);\n const authTag = cipher.getAuthTag();\n // Format: [iv (12)] [authTag (16)] [ciphertext (...)]\n return Buffer.concat([iv, authTag, encrypted]);\n}\n\nfunction decrypt(blob: Buffer, key: Buffer): Buffer {\n const iv = blob.subarray(0, IV_LENGTH);\n const authTag = blob.subarray(IV_LENGTH, IV_LENGTH + AUTH_TAG_LENGTH);\n const ciphertext = blob.subarray(IV_LENGTH + AUTH_TAG_LENGTH);\n const decipher = crypto.createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });\n decipher.setAuthTag(authTag);\n return Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n}\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport class LocalSecretsProvider implements ISecretsProvider {\n readonly id = \"local\";\n private secretsDir: string;\n private masterKey: Buffer | null = null;\n private salt: Buffer | null = null;\n private strategy: KeyStrategy = \"machine\";\n\n constructor(secretsDir?: string) {\n this.secretsDir = secretsDir ?? path.join(globalSkaileDir(), \"secrets\");\n }\n\n // -- Initialization --------------------------------------------------------\n\n private ensureDir(): void {\n if (!fs.existsSync(this.secretsDir)) {\n fs.mkdirSync(this.secretsDir, { recursive: true, mode: 0o700 });\n }\n }\n\n private loadOrCreateSalt(): Buffer {\n const saltPath = path.join(this.secretsDir, \".salt\");\n if (fs.existsSync(saltPath)) {\n return fs.readFileSync(saltPath);\n }\n const salt = crypto.randomBytes(SALT_LENGTH);\n fs.writeFileSync(saltPath, salt, { mode: 0o600 });\n return salt;\n }\n\n private async ensureKey(): Promise<void> {\n if (this.masterKey) return;\n\n this.ensureDir();\n this.salt = this.loadOrCreateSalt();\n\n // Determine strategy\n const strategyPath = path.join(this.secretsDir, \".key-strategy\");\n if (fs.existsSync(strategyPath)) {\n this.strategy = fs.readFileSync(strategyPath, \"utf-8\").trim() as KeyStrategy;\n } else {\n // Auto-detect: try keychain, fall back to machine\n this.strategy = (await this.tryKeychainStrategy()) ? \"keychain\" : \"machine\";\n fs.writeFileSync(strategyPath, this.strategy, { mode: 0o600 });\n }\n\n // Derive key from strategy\n const passphrase = await this.getPassphraseForStrategy(this.strategy);\n this.masterKey = deriveMasterKey(passphrase, this.salt);\n }\n\n private async tryKeychainStrategy(): Promise<boolean> {\n try {\n // `keytar` is an optional OS-keychain native module the user installs\n // themselves; the `as string` specifier keeps it out of tsc resolution.\n const keytar = await import(\"keytar\" as string);\n let stored = await keytar.getPassword(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT);\n if (!stored) {\n stored = crypto.randomBytes(32).toString(\"base64\");\n await keytar.setPassword(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT, stored);\n }\n return true;\n } catch {\n return false;\n }\n }\n\n private async getPassphraseForStrategy(strategy: KeyStrategy): Promise<string> {\n switch (strategy) {\n case \"keychain\": {\n try {\n // `keytar` is an optional OS-keychain native module the user installs\n // themselves; the `as string` specifier keeps it out of tsc resolution.\n const keytar = await import(\"keytar\" as string);\n const stored = await keytar.getPassword(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT);\n if (stored) return stored;\n } catch {\n // Keychain failed; fall through to machine\n }\n return getMachinePassphrase();\n }\n case \"passphrase\": {\n const envPassphrase = process.env[PASSPHRASE_ENV];\n if (envPassphrase) {\n // Verify against stored hash if it exists\n const masterPath = path.join(this.secretsDir, \".master\");\n if (fs.existsSync(masterPath)) {\n const storedHash = fs.readFileSync(masterPath, \"utf-8\").trim();\n if (hashPassphrase(envPassphrase) !== storedHash) {\n throw new SecretsError(\n `Passphrase from ${PASSPHRASE_ENV} does not match stored hash. ` +\n \"Use skaile auth set-key-strategy passphrase to reset.\",\n \"PASSPHRASE_MISMATCH\",\n );\n }\n }\n return envPassphrase;\n }\n // No env var -- hard error. Silent fallback to machine would\n // produce a different key, causing AES-GCM auth-tag failures\n // on secrets encrypted with the real passphrase.\n throw new SecretsError(\n `Strategy is \"passphrase\" but ${PASSPHRASE_ENV} is not set. ` +\n `Export it before running: export ${PASSPHRASE_ENV}='...'`,\n \"PASSPHRASE_REQUIRED\",\n );\n }\n case \"machine\":\n return getMachinePassphrase();\n default:\n return getMachinePassphrase();\n }\n }\n\n // -- Strategy management ---------------------------------------------------\n\n /**\n * Set the key strategy explicitly. Called by `skaile auth set-key-strategy`.\n *\n * When existing secrets are present, they are re-encrypted with the new key\n * to prevent data loss from key mismatch.\n */\n async setKeyStrategy(strategy: KeyStrategy, passphrase?: string): Promise<void> {\n this.ensureDir();\n\n // --- 1. Validate new strategy prerequisites -------------------------\n\n const effectivePassphrase = passphrase ?? process.env[PASSPHRASE_ENV];\n\n if (strategy === \"passphrase\") {\n if (!effectivePassphrase) {\n throw new SecretsError(\n `Passphrase required. Pass it as an argument or set ${PASSPHRASE_ENV}.`,\n \"PASSPHRASE_REQUIRED\",\n );\n }\n }\n\n if (strategy === \"keychain\") {\n const success = await this.tryKeychainStrategy();\n if (!success) {\n throw new ProviderUnavailableError(\"local\", \"OS keychain not available\");\n }\n }\n\n // --- 2. Load the OLD key under the current strategy -----------------\n // ensureKey() reads the current strategy file and derives the key\n // that was used to encrypt existing secrets. This is critical for\n // cross-process scenarios where masterKey starts as null.\n\n const encFiles = this.listEncFiles();\n if (encFiles.length > 0) {\n await this.ensureKey();\n const oldKey = this.masterKey!;\n\n // Derive the new key\n const salt = this.salt!;\n const newPassphrase =\n strategy === \"passphrase\"\n ? effectivePassphrase!\n : strategy === \"keychain\"\n ? await this.getPassphraseForStrategy(\"keychain\")\n : getMachinePassphrase();\n const newKey = deriveMasterKey(newPassphrase, salt);\n\n // Re-encrypt each secret with the new key. A single failure must abort the\n // whole switch: committing the new strategy while a secret is still under\n // the old key orphans that secret (the registry advertises a key that no\n // longer decrypts it). Collect failures and throw before the commit below,\n // leaving `.key-strategy`/`.master` — and every secret — on the old key.\n const failed: string[] = [];\n for (const encFile of encFiles) {\n const filePath = path.join(this.secretsDir, encFile);\n const blob = fs.readFileSync(filePath);\n try {\n const plaintext = decrypt(blob, oldKey);\n const reEncrypted = encrypt(plaintext, newKey);\n fs.writeFileSync(filePath, reEncrypted, { mode: 0o600 });\n } catch {\n failed.push(encFile);\n }\n }\n if (failed.length > 0) {\n throw new Error(\n `[skaile/secrets] Key-strategy switch aborted: could not re-encrypt ` +\n `${failed.length} secret(s) (${failed.join(\", \")}). The previous strategy ` +\n \"is unchanged; resolve the failing secrets before retrying.\",\n );\n }\n }\n\n // --- 3. Commit the new strategy (last write -- failure above leaves\n // the old strategy intact) ------------------------------------\n\n if (strategy === \"passphrase\") {\n const masterPath = path.join(this.secretsDir, \".master\");\n fs.writeFileSync(masterPath, hashPassphrase(effectivePassphrase!), { mode: 0o600 });\n }\n\n const strategyPath = path.join(this.secretsDir, \".key-strategy\");\n fs.writeFileSync(strategyPath, strategy, { mode: 0o600 });\n this.masterKey = null;\n this.strategy = strategy;\n }\n\n getKeyStrategy(): KeyStrategy {\n const strategyPath = path.join(this.secretsDir, \".key-strategy\");\n if (fs.existsSync(strategyPath)) {\n return fs.readFileSync(strategyPath, \"utf-8\").trim() as KeyStrategy;\n }\n return \"machine\";\n }\n\n // -- File helpers ----------------------------------------------------------\n\n private encFilename(ref: string): string {\n return `${refToHash(ref)}.enc`;\n }\n\n private metaFilename(ref: string): string {\n return `${refToHash(ref)}.meta.json`;\n }\n\n private metaPath(ref: string): string {\n return path.join(this.secretsDir, this.metaFilename(ref));\n }\n\n private listEncFiles(): string[] {\n if (!fs.existsSync(this.secretsDir)) return [];\n return fs.readdirSync(this.secretsDir).filter((f) => f.endsWith(\".enc\"));\n }\n\n // -- ISecretsProvider implementation ----------------------------------------\n\n async getSecret(ref: string): Promise<Uint8Array> {\n await this.ensureKey();\n const filePath = path.join(this.secretsDir, this.encFilename(ref));\n if (!fs.existsSync(filePath)) {\n throw new SecretNotFoundError(ref);\n }\n const blob = fs.readFileSync(filePath);\n const decrypted = decrypt(blob, this.masterKey!);\n\n // Update lastAccessedAt\n const metaFile = this.metaPath(ref);\n if (fs.existsSync(metaFile)) {\n try {\n const meta = JSON.parse(fs.readFileSync(metaFile, \"utf-8\"));\n meta.lastAccessedAt = new Date().toISOString();\n fs.writeFileSync(metaFile, JSON.stringify(meta), { mode: 0o600 });\n } catch {\n // Non-fatal\n }\n }\n\n return new Uint8Array(decrypted);\n }\n\n async setSecret(ref: string, value: Uint8Array, opts?: SetSecretOptions): Promise<void> {\n await this.ensureKey();\n this.ensureDir();\n const filePath = path.join(this.secretsDir, this.encFilename(ref));\n const encrypted = encrypt(value, this.masterKey!);\n fs.writeFileSync(filePath, encrypted, { mode: 0o600 });\n\n // Write metadata (stores the original ref for reverse lookup)\n const now = new Date().toISOString();\n const metaFile = this.metaPath(ref);\n let existing: Record<string, unknown> = {};\n if (fs.existsSync(metaFile)) {\n try {\n existing = JSON.parse(fs.readFileSync(metaFile, \"utf-8\"));\n } catch {\n // Overwrite corrupt meta\n }\n }\n const meta = {\n ref,\n createdAt: existing.createdAt ?? now,\n updatedAt: now,\n lastAccessedAt: now,\n ...(opts?.metadata ? { userMeta: opts.metadata } : {}),\n ...(opts?.ttlSeconds\n ? { expiresAt: new Date(Date.now() + opts.ttlSeconds * 1000).toISOString() }\n : {}),\n };\n fs.writeFileSync(metaFile, JSON.stringify(meta, null, 2), { mode: 0o600 });\n }\n\n async deleteSecret(ref: string): Promise<void> {\n const filePath = path.join(this.secretsDir, this.encFilename(ref));\n const metaFile = this.metaPath(ref);\n if (!fs.existsSync(filePath)) {\n throw new SecretNotFoundError(ref);\n }\n fs.unlinkSync(filePath);\n if (fs.existsSync(metaFile)) {\n fs.unlinkSync(metaFile);\n }\n }\n\n async listSecrets(filter?: ListFilter): Promise<string[]> {\n this.ensureDir();\n // Read refs from meta files (the .enc filenames are hashes, not refs)\n const metaFiles = fs.readdirSync(this.secretsDir).filter((f) => f.endsWith(\".meta.json\"));\n let refs: string[] = [];\n for (const mf of metaFiles) {\n try {\n const meta = JSON.parse(fs.readFileSync(path.join(this.secretsDir, mf), \"utf-8\"));\n if (meta.ref) refs.push(meta.ref);\n } catch {\n // Skip corrupt meta files\n }\n }\n if (filter?.prefix) {\n refs = refs.filter((r) => r.startsWith(filter.prefix!));\n }\n if (filter?.limit) {\n refs = refs.slice(0, filter.limit);\n }\n return refs;\n }\n\n async testConnection(): Promise<{ ok: boolean; latencyMs?: number; error?: string }> {\n const start = Date.now();\n try {\n await this.ensureKey();\n // Write + read + delete a test secret\n const testRef = `__test_${crypto.randomBytes(4).toString(\"hex\")}`;\n const testValue = new TextEncoder().encode(\"test\");\n await this.setSecret(testRef, testValue);\n const read = await this.getSecret(testRef);\n await this.deleteSecret(testRef);\n if (new TextDecoder().decode(read) !== \"test\") {\n return { ok: false, error: \"Round-trip mismatch\" };\n }\n return { ok: true, latencyMs: Date.now() - start };\n } catch (e) {\n return {\n ok: false,\n latencyMs: Date.now() - start,\n error: e instanceof Error ? e.message : String(e),\n };\n }\n }\n\n async getMetadata(ref: string): Promise<SecretMetadata> {\n const metaFile = this.metaPath(ref);\n const filePath = path.join(this.secretsDir, this.encFilename(ref));\n if (!fs.existsSync(filePath)) {\n throw new SecretNotFoundError(ref);\n }\n if (fs.existsSync(metaFile)) {\n const raw = JSON.parse(fs.readFileSync(metaFile, \"utf-8\"));\n return {\n ref: raw.ref ?? ref,\n createdAt: new Date(raw.createdAt),\n updatedAt: new Date(raw.updatedAt),\n lastAccessedAt: raw.lastAccessedAt ? new Date(raw.lastAccessedAt) : undefined,\n owner: raw.owner,\n scopeSummary: \"local encrypted file\",\n };\n }\n // Fallback: derive from file stat\n const stat = fs.statSync(filePath);\n return {\n ref,\n createdAt: stat.birthtime,\n updatedAt: stat.mtime,\n scopeSummary: \"local encrypted file\",\n };\n }\n\n getCapabilities(): ProviderCapabilities {\n return {\n supportsRotation: false,\n supportsExpiry: false,\n supportsBatch: false,\n scopeModel: \"flat\",\n };\n }\n}\n","/**\n * SecretsRouter — audit chokepoint for all secret operations.\n *\n * Registers {@link ISecretsProvider} implementations by id, routes credential refs by\n * prefix or via routing config, and emits {@link CredentialAccessed} events for every\n * get, set, delete, list, and metadata operation. Routing rules are evaluated top-to-bottom;\n * the first matching prefix wins and falls back to the configured default provider.\n *\n * @docLink packages/secrets/concepts#secrets-router\n */\n\nimport type {\n ISecretsProvider,\n ListFilter,\n ProviderCapabilities,\n SecretMetadata,\n SetSecretOptions,\n} from \"@skaile/workspaces/plugins\";\nimport { ProviderUnavailableError } from \"@skaile/workspaces/plugins\";\n\n// ---------------------------------------------------------------------------\n// Audit event\n// ---------------------------------------------------------------------------\n\n/**\n * Audit event emitted by {@link SecretsRouter} after every secret operation.\n *\n * Delivered synchronously to all registered {@link AuditSink} functions. Errors thrown\n * by sinks are swallowed to ensure they never break the underlying secret operation.\n *\n * @docLink packages/secrets/concepts#secrets-router\n */\nexport interface CredentialAccessed {\n credential_ref: string;\n operation: \"get\" | \"set\" | \"delete\" | \"list\" | \"metadata\";\n provider_id: string;\n caller_session_id?: string;\n caller_tool_call?: string;\n timestamp: Date;\n}\n\n/**\n * Callback function that receives {@link CredentialAccessed} audit events from {@link SecretsRouter}.\n *\n * Register sinks via `SecretsRouter.addSink()`. Sinks run synchronously after each operation;\n * exceptions are caught and suppressed so they cannot interrupt credential resolution.\n *\n * @docLink packages/secrets/concepts#secrets-router\n */\nexport type AuditSink = (event: CredentialAccessed) => void;\n\n// ---------------------------------------------------------------------------\n// Routing config\n// ---------------------------------------------------------------------------\n\n/**\n * A single routing rule that maps a credential ref prefix to a provider.\n *\n * Rules in {@link SecretsRouterConfig.rules} are evaluated top-to-bottom;\n * the first rule whose `prefix` matches the start of the credential ref wins.\n *\n * @docLink packages/secrets/concepts#secrets-router\n */\nexport interface RoutingRule {\n /** Prefix match on credential_ref. First match wins. */\n prefix: string;\n /** Provider id to route to. */\n provider_id: string;\n}\n\n/**\n * Configuration object for {@link SecretsRouter}.\n *\n * Specifies the default provider id used when no routing rule matches, and an optional\n * ordered list of {@link RoutingRule} entries for prefix-based routing.\n *\n * @docLink packages/secrets/concepts#secrets-router\n */\nexport interface SecretsRouterConfig {\n /** Default provider id when no routing rule matches. */\n default_provider: string;\n /** Ordered routing rules. Evaluated top-to-bottom; first prefix match wins. */\n rules?: RoutingRule[];\n}\n\n// ---------------------------------------------------------------------------\n// Router\n// ---------------------------------------------------------------------------\n\nexport class SecretsRouter {\n private providers = new Map<string, ISecretsProvider>();\n private config: SecretsRouterConfig;\n private sinks: AuditSink[] = [];\n\n /** Caller context for audit events (set per-request by the runner). */\n callerSessionId?: string;\n callerToolCall?: string;\n\n constructor(config: SecretsRouterConfig) {\n this.config = config;\n }\n\n // -- Provider registration ------------------------------------------------\n\n register(provider: ISecretsProvider): void {\n this.providers.set(provider.id, provider);\n }\n\n unregister(id: string): void {\n this.providers.delete(id);\n }\n\n listProviders(): string[] {\n return [...this.providers.keys()];\n }\n\n // -- Audit sinks -----------------------------------------------------------\n\n addSink(sink: AuditSink): void {\n this.sinks.push(sink);\n }\n\n private emit(ref: string, operation: CredentialAccessed[\"operation\"], providerId: string): void {\n const event: CredentialAccessed = {\n credential_ref: ref,\n operation,\n provider_id: providerId,\n caller_session_id: this.callerSessionId,\n caller_tool_call: this.callerToolCall,\n timestamp: new Date(),\n };\n for (const sink of this.sinks) {\n try {\n sink(event);\n } catch {\n // Audit sink errors must not break the secret operation.\n }\n }\n }\n\n // -- Routing ---------------------------------------------------------------\n\n private resolve(ref: string): ISecretsProvider {\n // Check routing rules first\n if (this.config.rules) {\n for (const rule of this.config.rules) {\n if (ref.startsWith(rule.prefix)) {\n const provider = this.providers.get(rule.provider_id);\n if (provider) return provider;\n }\n }\n }\n\n // Fall back to default\n const provider = this.providers.get(this.config.default_provider);\n if (!provider) {\n throw new ProviderUnavailableError(\n this.config.default_provider,\n `No provider registered for default id \"${this.config.default_provider}\"`,\n );\n }\n return provider;\n }\n\n // -- Delegated operations --------------------------------------------------\n\n async getSecret(ref: string): Promise<Uint8Array> {\n const provider = this.resolve(ref);\n this.emit(ref, \"get\", provider.id);\n return provider.getSecret(ref);\n }\n\n async setSecret(ref: string, value: Uint8Array, opts?: SetSecretOptions): Promise<void> {\n const provider = this.resolve(ref);\n this.emit(ref, \"set\", provider.id);\n return provider.setSecret(ref, value, opts);\n }\n\n async deleteSecret(ref: string): Promise<void> {\n const provider = this.resolve(ref);\n this.emit(ref, \"delete\", provider.id);\n return provider.deleteSecret(ref);\n }\n\n async listSecrets(filter?: ListFilter): Promise<string[]> {\n // List aggregates from the default provider only (per-provider listing\n // would require iterating all providers; deferred to Phase 3 with\n // federated catalogs).\n const provider = this.providers.get(this.config.default_provider);\n if (!provider) return [];\n this.emit(\"*\", \"list\", provider.id);\n return provider.listSecrets(filter);\n }\n\n async getMetadata(ref: string): Promise<SecretMetadata> {\n const provider = this.resolve(ref);\n this.emit(ref, \"metadata\", provider.id);\n return provider.getMetadata(ref);\n }\n\n getCapabilities(providerId?: string): ProviderCapabilities | null {\n const id = providerId ?? this.config.default_provider;\n const provider = this.providers.get(id);\n return provider?.getCapabilities() ?? null;\n }\n\n async testConnection(\n providerId?: string,\n ): Promise<{ ok: boolean; latencyMs?: number; error?: string }> {\n const id = providerId ?? this.config.default_provider;\n const provider = this.providers.get(id);\n if (!provider) {\n return { ok: false, error: `Provider \"${id}\" not registered` };\n }\n return provider.testConnection();\n }\n}\n","/** Package version of `@skaile/secrets`. */\nexport const VERSION = \"0.0.0\";\n\n// Re-export interface + errors from plugins (convenience for consumers)\nexport type {\n ISecretsProvider,\n ListFilter,\n ProviderCapabilities,\n SecretMetadata,\n SetSecretOptions,\n} from \"@skaile/workspaces/plugins\";\nexport {\n ProviderUnavailableError,\n SecretAccessDeniedError,\n SecretExpiredError,\n SecretNotFoundError,\n SecretsError,\n} from \"@skaile/workspaces/plugins\";\nexport type { CredentialLifecycleConfig, RefreshResult } from \"./lifecycle.js\";\n// Lifecycle\nexport { CredentialLifecycleService } from \"./lifecycle.js\";\nexport { EnvSecretsProvider } from \"./providers/env.js\";\nexport type { KeyStrategy } from \"./providers/local.js\";\n// Built-in providers\nexport { LocalSecretsProvider } from \"./providers/local.js\";\nexport type { AuditSink, CredentialAccessed, RoutingRule, SecretsRouterConfig } from \"./router.js\";\n// Router\nexport { SecretsRouter } from \"./router.js\";\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-TSVRKUGV.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-BCUVRJXV.js.map
141
+ //# sourceMappingURL=chunk-BCUVRJXV.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,W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,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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C,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-BCUVRJXV.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,6 +1,6 @@
1
1
  import { classifyGenericErrorMessage, stripRunnerPrivateEnv } from './chunk-XBSQ4KMC.js';
2
2
  import { wrapAgentCommand, resolveAgentExec } from './chunk-YROR332M.js';
3
- import { AgentDriver } from './chunk-WQULDAH2.js';
3
+ import { AgentDriver } from './chunk-TSVRKUGV.js';
4
4
  import { spawn } from 'child_process';
5
5
  import { createInterface } from 'readline';
6
6
 
@@ -429,5 +429,5 @@ function extractCost(json) {
429
429
  }
430
430
 
431
431
  export { SubprocessCliDriver, extractCost, extractText, extractTokens };
432
- //# sourceMappingURL=chunk-UTZEHXYT.js.map
433
- //# sourceMappingURL=chunk-UTZEHXYT.js.map
432
+ //# sourceMappingURL=chunk-C75VKXAM.js.map
433
+ //# sourceMappingURL=chunk-C75VKXAM.js.map