@skaile/workspaces 4.36.0 → 4.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/app-sdk/index.js +1 -1
- package/dist/{asset-feeds-SJELMLNK.js → asset-feeds-UYIFZKKG.js} +16 -16
- package/dist/asset-feeds-UYIFZKKG.js.map +1 -0
- package/dist/asset-manager/catalog-deployer.js +9 -8
- package/dist/asset-manager/index.js +15 -14
- package/dist/asset-manager/installer.js +11 -10
- package/dist/asset-manager/renderers.js +2 -2
- package/dist/asset-manager/src/index.d.ts +77 -18
- package/dist/asset-manager/src/index.d.ts.map +1 -1
- package/dist/asset-manager/src/installer.d.ts +11 -1
- package/dist/asset-manager/src/installer.d.ts.map +1 -1
- package/dist/bridge/drivers/claude-sdk.js +14 -13
- package/dist/bridge/drivers/claude-sdk.js.map +1 -1
- package/dist/bridge/drivers/codex.js +11 -10
- package/dist/bridge/drivers/codex.js.map +1 -1
- package/dist/bridge/drivers/continue.js +12 -11
- package/dist/bridge/drivers/continue.js.map +1 -1
- package/dist/bridge/drivers/echo.js +3 -3
- package/dist/bridge/drivers/gemini.js +6 -6
- package/dist/bridge/drivers/goose.js +12 -11
- package/dist/bridge/drivers/goose.js.map +1 -1
- package/dist/bridge/drivers/omp.js +4 -4
- package/dist/bridge/drivers/opencode.js +12 -11
- package/dist/bridge/drivers/opencode.js.map +1 -1
- package/dist/bridge/drivers/qwen.js +6 -6
- package/dist/bridge/index.js +15 -14
- package/dist/{chunk-3CLUU45N.js → chunk-27DN4DZD.js} +8 -8
- package/dist/{chunk-3CLUU45N.js.map → chunk-27DN4DZD.js.map} +1 -1
- package/dist/{chunk-VOEBLPXO.js → chunk-2EL2PBRC.js} +3 -3
- package/dist/{chunk-VOEBLPXO.js.map → chunk-2EL2PBRC.js.map} +1 -1
- package/dist/{chunk-VRFKCF3R.js → chunk-36ML6SFP.js} +4 -4
- package/dist/{chunk-VRFKCF3R.js.map → chunk-36ML6SFP.js.map} +1 -1
- package/dist/{chunk-O63QZ6XX.js → chunk-4WKZEMBD.js} +4 -4
- package/dist/{chunk-O63QZ6XX.js.map → chunk-4WKZEMBD.js.map} +1 -1
- package/dist/{chunk-2D3C4AJP.js → chunk-5CYEWBPB.js} +11 -4
- package/dist/chunk-5CYEWBPB.js.map +1 -0
- package/dist/{chunk-SQ7IN7KR.js → chunk-5K2VT6E2.js} +3 -3
- package/dist/{chunk-SQ7IN7KR.js.map → chunk-5K2VT6E2.js.map} +1 -1
- package/dist/{chunk-NTASYPDN.js → chunk-5NYBY6ZE.js} +3 -3
- package/dist/{chunk-NTASYPDN.js.map → chunk-5NYBY6ZE.js.map} +1 -1
- package/dist/{chunk-FQE2NBUH.js → chunk-6EMF4UZI.js} +8 -8
- package/dist/{chunk-FQE2NBUH.js.map → chunk-6EMF4UZI.js.map} +1 -1
- package/dist/{chunk-MQU632EK.js → chunk-6KPQDP7P.js} +2 -2
- package/dist/{chunk-MQU632EK.js.map → chunk-6KPQDP7P.js.map} +1 -1
- package/dist/{chunk-LVRKJW53.js → chunk-6VRZ6M2L.js} +10 -3
- package/dist/chunk-6VRZ6M2L.js.map +1 -0
- package/dist/{chunk-5L55HNNA.js → chunk-7FZSABQV.js} +5 -5
- package/dist/{chunk-5L55HNNA.js.map → chunk-7FZSABQV.js.map} +1 -1
- package/dist/{chunk-FLGLODDF.js → chunk-7RC37XFW.js} +3 -3
- package/dist/{chunk-FLGLODDF.js.map → chunk-7RC37XFW.js.map} +1 -1
- package/dist/{chunk-3VUHHDZW.js → chunk-7UL2SQQH.js} +4 -4
- package/dist/{chunk-3VUHHDZW.js.map → chunk-7UL2SQQH.js.map} +1 -1
- package/dist/{chunk-GEEW6SY2.js → chunk-A5EDMBFG.js} +2 -2
- package/dist/{chunk-GEEW6SY2.js.map → chunk-A5EDMBFG.js.map} +1 -1
- package/dist/{chunk-QABZZROM.js → chunk-ARUJBGAH.js} +3 -3
- package/dist/{chunk-QABZZROM.js.map → chunk-ARUJBGAH.js.map} +1 -1
- package/dist/{chunk-TILISP6X.js → chunk-BQ3HXZNT.js} +2 -2
- package/dist/{chunk-TILISP6X.js.map → chunk-BQ3HXZNT.js.map} +1 -1
- package/dist/{chunk-NVNKPWL4.js → chunk-CACCIOQL.js} +12 -12
- package/dist/{chunk-NVNKPWL4.js.map → chunk-CACCIOQL.js.map} +1 -1
- package/dist/{chunk-5JAO4MXA.js → chunk-DOVURNRK.js} +3 -3
- package/dist/{chunk-5JAO4MXA.js.map → chunk-DOVURNRK.js.map} +1 -1
- package/dist/{chunk-P4VHQA4N.js → chunk-DSB6X25D.js} +3 -3
- package/dist/{chunk-P4VHQA4N.js.map → chunk-DSB6X25D.js.map} +1 -1
- package/dist/{chunk-ZWTCXL3H.js → chunk-DV47JNI4.js} +3 -3
- package/dist/{chunk-ZWTCXL3H.js.map → chunk-DV47JNI4.js.map} +1 -1
- package/dist/{chunk-Q7SIVPM2.js → chunk-EETXMMZS.js} +3 -3
- package/dist/{chunk-Q7SIVPM2.js.map → chunk-EETXMMZS.js.map} +1 -1
- package/dist/{chunk-OEBAXTQ4.js → chunk-EOKAFBJ7.js} +3 -3
- package/dist/{chunk-OEBAXTQ4.js.map → chunk-EOKAFBJ7.js.map} +1 -1
- package/dist/{chunk-6BEGKO2Q.js → chunk-HUNZYTOS.js} +4 -3
- package/dist/chunk-HUNZYTOS.js.map +1 -0
- package/dist/{chunk-YOIENZHA.js → chunk-HXG6IZSF.js} +6 -6
- package/dist/{chunk-YOIENZHA.js.map → chunk-HXG6IZSF.js.map} +1 -1
- package/dist/{chunk-L22WTIIC.js → chunk-ILAZDNIA.js} +3 -3
- package/dist/{chunk-L22WTIIC.js.map → chunk-ILAZDNIA.js.map} +1 -1
- package/dist/{chunk-FWZTKSYI.js → chunk-J5UF3OOS.js} +10 -10
- package/dist/{chunk-FWZTKSYI.js.map → chunk-J5UF3OOS.js.map} +1 -1
- package/dist/{chunk-QKXDRBLL.js → chunk-JEPSP6XK.js} +11 -80
- package/dist/chunk-JEPSP6XK.js.map +1 -0
- package/dist/{chunk-KIFJWSNC.js → chunk-KAJH3XPW.js} +7 -3
- package/dist/chunk-KAJH3XPW.js.map +1 -0
- package/dist/chunk-LOHQTTUV.js +29 -0
- package/dist/chunk-LOHQTTUV.js.map +1 -0
- package/dist/{chunk-MDBAEEY5.js → chunk-MQ42OYKH.js} +159 -7
- package/dist/chunk-MQ42OYKH.js.map +1 -0
- package/dist/{chunk-5JJ5KQUM.js → chunk-MS2JK4V7.js} +6 -6
- package/dist/{chunk-5JJ5KQUM.js.map → chunk-MS2JK4V7.js.map} +1 -1
- package/dist/{chunk-JRSLMZOT.js → chunk-OKGUDNDT.js} +37 -7
- package/dist/chunk-OKGUDNDT.js.map +1 -0
- package/dist/{chunk-DFZDL62S.js → chunk-OLMNDIAU.js} +14 -9
- package/dist/chunk-OLMNDIAU.js.map +1 -0
- package/dist/{chunk-3SUWLY3H.js → chunk-OQRB7JUS.js} +3 -3
- package/dist/{chunk-3SUWLY3H.js.map → chunk-OQRB7JUS.js.map} +1 -1
- package/dist/{chunk-TTITGVXV.js → chunk-PRCUGFXV.js} +3 -3
- package/dist/{chunk-TTITGVXV.js.map → chunk-PRCUGFXV.js.map} +1 -1
- package/dist/{chunk-MRS5YHPI.js → chunk-QBQITQAM.js} +3 -3
- package/dist/{chunk-MRS5YHPI.js.map → chunk-QBQITQAM.js.map} +1 -1
- package/dist/{chunk-PKGI5QG7.js → chunk-QWWDDU5Z.js} +274 -67
- package/dist/chunk-QWWDDU5Z.js.map +1 -0
- package/dist/{chunk-NKYNDLCB.js → chunk-R2U346ER.js} +3 -3
- package/dist/{chunk-NKYNDLCB.js.map → chunk-R2U346ER.js.map} +1 -1
- package/dist/{chunk-KVDXSEQH.js → chunk-R5ARWJGE.js} +104 -63
- package/dist/chunk-R5ARWJGE.js.map +1 -0
- package/dist/chunk-TLKM4M47.js +78 -0
- package/dist/chunk-TLKM4M47.js.map +1 -0
- package/dist/{chunk-NFECHLV6.js → chunk-TNWXGHLD.js} +3 -3
- package/dist/{chunk-NFECHLV6.js.map → chunk-TNWXGHLD.js.map} +1 -1
- package/dist/{chunk-H3KXUUYQ.js → chunk-VDBP6Y5M.js} +4 -4
- package/dist/{chunk-H3KXUUYQ.js.map → chunk-VDBP6Y5M.js.map} +1 -1
- package/dist/{chunk-XN7DAZB7.js → chunk-VJNTB4DN.js} +5 -5
- package/dist/chunk-VJNTB4DN.js.map +1 -0
- package/dist/{chunk-BSIHJZKN.js → chunk-XU7JET5Z.js} +107 -26
- package/dist/chunk-XU7JET5Z.js.map +1 -0
- package/dist/{chunk-LIS5KT2X.js → chunk-YCJ3PJNB.js} +5 -5
- package/dist/{chunk-LIS5KT2X.js.map → chunk-YCJ3PJNB.js.map} +1 -1
- package/dist/{chunk-VCLN2IUM.js → chunk-YCMZHL4T.js} +31 -27
- package/dist/chunk-YCMZHL4T.js.map +1 -0
- package/dist/{chunk-JS7DCCDA.js → chunk-YNUBJY3L.js} +4 -4
- package/dist/chunk-YNUBJY3L.js.map +1 -0
- package/dist/{chunk-S63H4HDH.js → chunk-YQEF36D5.js} +4 -4
- package/dist/{chunk-S63H4HDH.js.map → chunk-YQEF36D5.js.map} +1 -1
- package/dist/{chunk-FJYOQMXT.js → chunk-YV3YI3TA.js} +32 -16
- package/dist/chunk-YV3YI3TA.js.map +1 -0
- package/dist/cli/index.js +755 -533
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/asset-feeds.d.ts.map +1 -1
- package/dist/cli/src/commands/asset-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/cache.d.ts.map +1 -1
- package/dist/cli/src/commands/catalog.d.ts +28 -3
- package/dist/cli/src/commands/catalog.d.ts.map +1 -1
- package/dist/cli/src/commands/complete-resolvers.d.ts +1 -7
- package/dist/cli/src/commands/complete-resolvers.d.ts.map +1 -1
- package/dist/cli/src/commands/complete.d.ts.map +1 -1
- package/dist/cli/src/commands/diff.d.ts +3 -1
- package/dist/cli/src/commands/diff.d.ts.map +1 -1
- package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/library-index.d.ts +8 -0
- package/dist/cli/src/commands/library-index.d.ts.map +1 -1
- package/dist/cli/src/commands/library-publish.d.ts +7 -2
- package/dist/cli/src/commands/library-publish.d.ts.map +1 -1
- package/dist/cli/src/commands/manage.d.ts.map +1 -1
- package/dist/cli/src/commands/outdated.d.ts +12 -2
- package/dist/cli/src/commands/outdated.d.ts.map +1 -1
- package/dist/cli/src/commands/project.d.ts +2 -2
- package/dist/cli/src/commands/publish-core.d.ts +21 -0
- package/dist/cli/src/commands/publish-core.d.ts.map +1 -1
- package/dist/cli/src/commands/skailify-lib.d.ts +18 -1
- package/dist/cli/src/commands/skailify-lib.d.ts.map +1 -1
- package/dist/cli/src/commands/source-manifest-publish.d.ts.map +1 -1
- package/dist/cli/src/commands/store.d.ts.map +1 -1
- package/dist/cli/src/commands/update.d.ts.map +1 -1
- package/dist/cli/src/commands/validate.d.ts.map +1 -1
- package/dist/cli/src/paths.d.ts +1 -1
- package/dist/cli/src/paths.d.ts.map +1 -1
- package/dist/cli/src/store-auth.d.ts.map +1 -1
- package/dist/connectors/config.js +6 -5
- package/dist/connectors/index.js +19 -18
- package/dist/connectors-shared/index.js +2 -2
- package/dist/core/index.js +8 -7
- package/dist/core/manifest.js +2 -2
- package/dist/core/models.js +1 -1
- package/dist/core/publish-manifest.js +2 -2
- package/dist/core/ref.js +1 -1
- package/dist/core/runtime-assets.js +6 -5
- package/dist/core/src/asset-roots.d.ts +2 -12
- package/dist/core/src/asset-roots.d.ts.map +1 -1
- package/dist/core/src/cache-paths.d.ts +7 -3
- package/dist/core/src/cache-paths.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +3 -3
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/lock.d.ts +27 -4
- package/dist/core/src/lock.d.ts.map +1 -1
- package/dist/core/src/models.d.ts +26 -6
- package/dist/core/src/models.d.ts.map +1 -1
- package/dist/core/src/repo-manager.d.ts.map +1 -1
- package/dist/core/src/settings.d.ts +2 -1
- package/dist/core/src/settings.d.ts.map +1 -1
- package/dist/core/src/store.d.ts.map +1 -1
- package/dist/core/src/workspace-config.d.ts.map +1 -1
- package/dist/core/store.js +2 -1
- package/dist/core/workspace-config.js +5 -4
- package/dist/deploy/index.js +8 -7
- package/dist/deploy/index.js.map +1 -1
- package/dist/discovery/index.js +5 -5
- package/dist/discovery/src/domains.d.ts +6 -1
- package/dist/discovery/src/domains.d.ts.map +1 -1
- package/dist/discovery/src/index.d.ts +1 -1
- package/dist/discovery/src/index.d.ts.map +1 -1
- package/dist/{ensure-sources-SYZO2HNP.js → ensure-sources-VX63EKY7.js} +18 -17
- package/dist/ensure-sources-VX63EKY7.js.map +1 -0
- package/dist/factory-assets/connectors/box.js +19 -18
- package/dist/factory-assets/connectors/deploy.js +19 -18
- package/dist/factory-assets/connectors/devserver.js +19 -18
- package/dist/factory-assets/connectors/flow/adapter.js +19 -18
- package/dist/factory-assets/connectors/flow/engine.js +9 -8
- package/dist/factory-assets/connectors/flow/run-flow.js +21 -20
- package/dist/factory-assets/connectors/flow.js +19 -18
- package/dist/factory-assets/connectors/git.js +19 -18
- package/dist/factory-assets/connectors/gmail.js +19 -18
- package/dist/factory-assets/connectors/googledrive.js +19 -18
- package/dist/factory-assets/connectors/local.js +19 -18
- package/dist/factory-assets/connectors/mattermost.js +19 -18
- package/dist/factory-assets/connectors/memory.js +19 -18
- package/dist/factory-assets/connectors/minio.js +19 -18
- package/dist/factory-assets/connectors/postgres.js +19 -18
- package/dist/factory-assets/connectors/s3.js +19 -18
- package/dist/factory-assets/connectors/sharepoint.js +19 -18
- package/dist/factory-assets/connectors/sqlite.js +19 -18
- package/dist/factory-assets/connectors/static-server.js +19 -18
- package/dist/factory-assets/connectors/tunnel.js +19 -18
- package/dist/factory-assets/connectors/webdav.js +19 -18
- package/dist/factory-assets/connectors/xstate-store.js +19 -18
- package/dist/factory-assets/connectors/xstate.js +19 -18
- package/dist/flows-PX53XFV7.js +25 -0
- package/dist/{flows-6MDMBQUZ.js.map → flows-PX53XFV7.js.map} +1 -1
- package/dist/{helpers-IMUCDNME.js → helpers-DF55G2YC.js} +18 -17
- package/dist/{helpers-IMUCDNME.js.map → helpers-DF55G2YC.js.map} +1 -1
- package/dist/library/index.js +12 -11
- package/dist/library/install.js +2 -2
- package/dist/library/src/config.d.ts +11 -9
- package/dist/library/src/config.d.ts.map +1 -1
- package/dist/library/src/index.d.ts +2 -2
- package/dist/library/src/index.d.ts.map +1 -1
- package/dist/library/src/local/db.d.ts.map +1 -1
- package/dist/library/src/local/library-manager.d.ts +7 -0
- package/dist/library/src/local/library-manager.d.ts.map +1 -1
- package/dist/library/src/local/library.d.ts +5 -4
- package/dist/library/src/local/library.d.ts.map +1 -1
- package/dist/library/src/local/schema.d.ts +2 -0
- package/dist/library/src/local/schema.d.ts.map +1 -1
- package/dist/library/src/local/sidecar-paths.d.ts.map +1 -1
- package/dist/library/src/local/store-paths.d.ts.map +1 -1
- package/dist/library/src/remote/cache.d.ts.map +1 -1
- package/dist/library/src/sync/git-driver.d.ts +34 -0
- package/dist/library/src/sync/git-driver.d.ts.map +1 -1
- package/dist/{library-publish-XAIAHKRL.js → library-publish-2PNWJJOY.js} +95 -41
- package/dist/library-publish-2PNWJJOY.js.map +1 -0
- package/dist/open-library-SUVOMIWZ.js +38 -0
- package/dist/{open-library-6N3XZ2XL.js.map → open-library-SUVOMIWZ.js.map} +1 -1
- package/dist/paths-W4LDORQQ.js +21 -0
- package/dist/{paths-4MTICP3T.js.map → paths-W4LDORQQ.js.map} +1 -1
- package/dist/{plugin-store-GQ4WQZJ2.js → plugin-store-D45CREMJ.js} +10 -9
- package/dist/plugin-store-D45CREMJ.js.map +1 -0
- package/dist/project-RTLVOXUU.js +34 -0
- package/dist/{project-HESTMGPU.js.map → project-RTLVOXUU.js.map} +1 -1
- package/dist/resolver/index.js +9 -8
- package/dist/runner/index.js +28 -27
- package/dist/runner/src/composition/bootstrap.d.ts +1 -1
- package/dist/runner/src/composition/bootstrap.d.ts.map +1 -1
- package/dist/runner/src/prompt-turn-queue.d.ts +27 -4
- package/dist/runner/src/prompt-turn-queue.d.ts.map +1 -1
- package/dist/runner/src/runtime-session-emit.d.ts +2 -1
- package/dist/runner/src/runtime-session-emit.d.ts.map +1 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +15 -14
- package/dist/sdk/bridge.js +15 -14
- package/dist/sdk/core.js +8 -7
- package/dist/sdk/flow.js +9 -8
- package/dist/sdk/index.js +28 -27
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/resolver.js +9 -8
- package/dist/sdk/runner.js +28 -27
- package/dist/sdk/session.js +2 -2
- package/dist/sdk/store.js +1 -1
- package/dist/sdk/types.js +1 -1
- package/dist/secrets/index.js +18 -1
- package/dist/secrets/src/providers/local.d.ts.map +1 -1
- package/dist/session/index.js +2 -2
- package/dist/session/src/dispatcher.d.ts.map +1 -1
- package/dist/{setup-PQG5DH5Z.js → setup-ZA7VZL72.js} +25 -24
- package/dist/setup-ZA7VZL72.js.map +1 -0
- package/dist/skills-R3RPIPWP.js +25 -0
- package/dist/{skills-JHUY4DFE.js.map → skills-R3RPIPWP.js.map} +1 -1
- package/dist/{source-PNYNVVPM.js → source-Y5YQ7M53.js} +21 -20
- package/dist/{source-PNYNVVPM.js.map → source-Y5YQ7M53.js.map} +1 -1
- package/dist/{source-manifest-publish-6O6H4T2P.js → source-manifest-publish-RZIJNRIW.js} +24 -25
- package/dist/source-manifest-publish-RZIJNRIW.js.map +1 -0
- package/dist/store/index.js +1 -1
- package/dist/store/src/store.d.ts +9 -0
- package/dist/store/src/store.d.ts.map +1 -1
- package/dist/store/src/types.d.ts +17 -0
- package/dist/store/src/types.d.ts.map +1 -1
- package/dist/tui/index.js +28 -27
- package/dist/tui/index.js.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/manifests.js +1 -1
- package/dist/types/src/events.d.ts +28 -3
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/manifests/index.d.ts +1 -1
- package/dist/types/src/manifests/index.d.ts.map +1 -1
- package/dist/types/src/manifests/skill.d.ts +10 -0
- package/dist/types/src/manifests/skill.d.ts.map +1 -1
- package/dist/types/src/protocol.d.ts +2 -0
- package/dist/types/src/protocol.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +12 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/workspace-plugin/adapters/mcp.js +15 -14
- package/dist/workspace-plugin/adapters/omp.js +7 -7
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/asset-feeds-SJELMLNK.js.map +0 -1
- package/dist/chunk-2D3C4AJP.js.map +0 -1
- package/dist/chunk-422WJ2QC.js +0 -158
- package/dist/chunk-422WJ2QC.js.map +0 -1
- package/dist/chunk-6BEGKO2Q.js.map +0 -1
- package/dist/chunk-BSIHJZKN.js.map +0 -1
- package/dist/chunk-DFZDL62S.js.map +0 -1
- package/dist/chunk-FJYOQMXT.js.map +0 -1
- package/dist/chunk-JRSLMZOT.js.map +0 -1
- package/dist/chunk-JS7DCCDA.js.map +0 -1
- package/dist/chunk-KIFJWSNC.js.map +0 -1
- package/dist/chunk-KVDXSEQH.js.map +0 -1
- package/dist/chunk-LVRKJW53.js.map +0 -1
- package/dist/chunk-MDBAEEY5.js.map +0 -1
- package/dist/chunk-PKGI5QG7.js.map +0 -1
- package/dist/chunk-QKXDRBLL.js.map +0 -1
- package/dist/chunk-VCLN2IUM.js.map +0 -1
- package/dist/chunk-XN7DAZB7.js.map +0 -1
- package/dist/ensure-sources-SYZO2HNP.js.map +0 -1
- package/dist/flows-6MDMBQUZ.js +0 -24
- package/dist/library-publish-XAIAHKRL.js.map +0 -1
- package/dist/open-library-6N3XZ2XL.js +0 -37
- package/dist/paths-4MTICP3T.js +0 -20
- package/dist/plugin-store-GQ4WQZJ2.js.map +0 -1
- package/dist/project-HESTMGPU.js +0 -33
- package/dist/setup-PQG5DH5Z.js.map +0 -1
- package/dist/skills-JHUY4DFE.js +0 -24
- package/dist/source-manifest-publish-6O6H4T2P.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { globalSkaileDir } from './chunk-TLKM4M47.js';
|
|
1
2
|
import { DRIVER_TARGETS } from './chunk-EB4ZTESQ.js';
|
|
2
3
|
import { lstatSync } from 'fs';
|
|
3
4
|
import { homedir } from 'os';
|
|
4
|
-
import {
|
|
5
|
+
import { join, resolve } from 'path';
|
|
5
6
|
|
|
6
7
|
function deployedBase(kind, target, globalInstall, cwd) {
|
|
7
8
|
const targetMap = DRIVER_TARGETS[target];
|
|
@@ -10,6 +11,9 @@ function deployedBase(kind, target, globalInstall, cwd) {
|
|
|
10
11
|
const paths = targetMap[scope];
|
|
11
12
|
const destStr = paths[kind] ?? paths.skill ?? "";
|
|
12
13
|
if (globalInstall) {
|
|
14
|
+
if (destStr === "~/.skaile" || destStr.startsWith("~/.skaile/")) {
|
|
15
|
+
return join(globalSkaileDir(), destStr.slice("~/.skaile".length));
|
|
16
|
+
}
|
|
13
17
|
return destStr.replace(/^~/, homedir());
|
|
14
18
|
}
|
|
15
19
|
return resolve(cwd ?? process.cwd(), destStr);
|
|
@@ -27,5 +31,5 @@ function isDeployed(kind, name, target, globalInstall, cwd) {
|
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export { deployedBase, deployedDir, isDeployed };
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-KAJH3XPW.js.map
|
|
35
|
+
//# sourceMappingURL=chunk-KAJH3XPW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../core/src/store.ts"],"names":[],"mappings":";;;;;;AA6BO,SAAS,YAAA,CACd,IA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F","file":"chunk-KAJH3XPW.js","sourcesContent":["/**\n * Deploy-target helpers — resolve framework-specific install paths.\n *\n * This module contains only deploy path resolution. All catalog, repository,\n * and history I/O has moved to @skaile/asset-manager (project-local).\n */\n\nimport { lstatSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { globalSkaileDir } from \"./cache-paths.js\";\nimport type { DriverTarget } from \"./driver-targets.js\";\nimport { type AiComponent, DRIVER_TARGETS } from \"./driver-targets.js\";\n\n// ── Deploy-target helpers ─────────────────────────────────────────────────────\n\n/**\n * Resolve the base deploy directory for an asset kind in a given driver target + scope.\n * For local scope, the path is relative to `cwd` (defaults to `process.cwd()`).\n * For global scope, `~` is expanded to the home directory.\n *\n * @param kind - Asset component type (e.g. `\"skill\"`, `\"agent\"`)\n * @param target - Driver target identifier (e.g. `\"claude-code\"`, `\"omp\"`)\n * @param globalInstall - `true` for user-global install, `false` for project-local\n * @param cwd - Working directory for project-local installs (default: `process.cwd()`)\n * @returns Absolute path to the base deploy directory\n * @throws When `target` is not found in `DRIVER_TARGETS`\n * @docLink packages/core/concepts#deployed-base\n */\nexport function deployedBase(\n kind: AiComponent,\n target: DriverTarget,\n globalInstall: boolean,\n cwd?: string,\n): string {\n const targetMap = DRIVER_TARGETS[target];\n if (!targetMap) throw new Error(`Unknown deploy target: '${target}'`);\n const scope = globalInstall ? \"global\" : \"local\";\n const paths = targetMap[scope];\n const destStr = paths[kind] ?? paths.skill ?? \"\";\n if (globalInstall) {\n // `~/.skaile/...` is skaile's own per-user root, so it follows `$SKAILE_HOME`;\n // every other `~/...` is a driver's home dir (`~/.claude`, `~/.omp`, ...).\n if (destStr === \"~/.skaile\" || destStr.startsWith(\"~/.skaile/\")) {\n return join(globalSkaileDir(), destStr.slice(\"~/.skaile\".length));\n }\n return destStr.replace(/^~/, homedir());\n }\n return resolve(cwd ?? process.cwd(), destStr);\n}\n\n/**\n * Return the full deploy path for a named asset: `<deployedBase>/<name>`.\n *\n * @param kind - Asset component type\n * @param name - Asset name (becomes the directory/file name under the base)\n * @param target - Driver target identifier\n * @param globalInstall - `true` for user-global, `false` for project-local\n * @param cwd - Working directory for local installs\n * @returns Absolute path to the asset's deploy directory\n * @docLink packages/core/concepts#deployed-dir\n */\nexport function deployedDir(\n kind: AiComponent,\n name: string,\n target: DriverTarget,\n globalInstall: boolean,\n cwd?: string,\n): string {\n return join(deployedBase(kind, target, globalInstall, cwd), name);\n}\n\n/**\n * Check whether an asset is already deployed at its expected location.\n * Uses `lstatSync` so symlinks are treated as deployed.\n *\n * @param kind - Asset component type\n * @param name - Asset name\n * @param target - Driver target identifier\n * @param globalInstall - `true` for user-global, `false` for project-local\n * @param cwd - Working directory for local installs\n * @returns `true` if the deploy path exists, `false` otherwise\n * @docLink packages/core/concepts#is-deployed\n */\nexport function isDeployed(\n kind: AiComponent,\n name: string,\n target: DriverTarget,\n globalInstall: boolean,\n cwd?: string,\n): boolean {\n try {\n lstatSync(deployedDir(kind, name, target, globalInstall, cwd));\n return true;\n } catch {\n return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getStoreConfig, getStoreToken, storeFetch } from './chunk-MQ42OYKH.js';
|
|
2
|
+
|
|
3
|
+
// cli/src/store-publisher.ts
|
|
4
|
+
function makeHttpPublisherClient(config = getStoreConfig(), timeoutMs = 2e4) {
|
|
5
|
+
const call = async (path, opts) => {
|
|
6
|
+
const jwt = await getStoreToken();
|
|
7
|
+
return storeFetch({ ...config, jwt }, path, { timeoutMs, ...opts });
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
me: () => call("/api/v1/me"),
|
|
11
|
+
sourcesAdd: (body) => call("/api/v1/sources", { method: "POST", body }),
|
|
12
|
+
sourcesList: () => call("/api/v1/sources"),
|
|
13
|
+
sourceSync: (id) => call(`/api/v1/sources/${id}/sync`, { method: "POST", body: {} }),
|
|
14
|
+
jobGet: (jobId) => call(`/api/v1/jobs/${jobId}`),
|
|
15
|
+
sourceCandidates: (id) => call(`/api/v1/sources/${id}/candidates`),
|
|
16
|
+
assetPreview: (id) => call(`/api/v1/assets/${id}/preview`),
|
|
17
|
+
assetPublish: (id, body, dryRun) => call(`/api/v1/assets/${id}/publish`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
body,
|
|
20
|
+
...dryRun ? { params: { dryRun: "1" } } : {}
|
|
21
|
+
}),
|
|
22
|
+
assetUnpublish: (id) => call(`/api/v1/assets/${id}/unpublish`, { method: "POST", body: {} }),
|
|
23
|
+
namespaceAvailability: (ns) => call(`/api/v1/namespaces/${encodeURIComponent(ns)}/availability`)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { makeHttpPublisherClient };
|
|
28
|
+
//# sourceMappingURL=chunk-LOHQTTUV.js.map
|
|
29
|
+
//# sourceMappingURL=chunk-LOHQTTUV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../cli/src/store-publisher.ts"],"names":[],"mappings":";;;AA+FO,SAAS,uBAAA,CACd,MAAA,GAAsB,cAAA,EAAe,EACrC,YAAY,GAAA,EACK;AAGjB,EAAA,MAAM,IAAA,GAAO,OACX,IAAA,EACA,IAAA,KACe;AACf,IAAA,MAAM,GAAA,GAAM,MAAM,aAAA,EAAc;AAChC,IAAA,OAAO,UAAA,CAAc,EAAE,GAAG,MAAA,EAAQ,GAAA,EAAI,EAAG,IAAA,EAAM,EAAE,SAAA,EAAW,GAAG,IAAA,EAAM,CAAA;AAAA,EACvE,CAAA;AACA,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,MAAM,IAAA,CAAK,YAAY,CAAA;AAAA,IAC3B,UAAA,EAAY,CAAC,IAAA,KAAS,IAAA,CAAK,mBAAmB,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,CAAA;AAAA,IACtE,WAAA,EAAa,MAAM,IAAA,CAAK,iBAAiB,CAAA;AAAA,IACzC,UAAA,EAAY,CAAC,EAAA,KAAO,IAAA,CAAK,CAAA,gBAAA,EAAmB,EAAE,CAAA,KAAA,CAAA,EAAS,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,IACnF,QAAQ,CAAC,KAAA,KAAU,IAAA,CAAK,CAAA,aAAA,EAAgB,KAAK,CAAA,CAAE,CAAA;AAAA,IAC/C,kBAAkB,CAAC,EAAA,KAAO,IAAA,CAAK,CAAA,gBAAA,EAAmB,EAAE,CAAA,WAAA,CAAa,CAAA;AAAA,IACjE,cAAc,CAAC,EAAA,KAAO,IAAA,CAAK,CAAA,eAAA,EAAkB,EAAE,CAAA,QAAA,CAAU,CAAA;AAAA,IACzD,YAAA,EAAc,CAAC,EAAA,EAAI,IAAA,EAAM,WACvB,IAAA,CAAK,CAAA,eAAA,EAAkB,EAAE,CAAA,QAAA,CAAA,EAAY;AAAA,MACnC,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA;AAAA,MACA,GAAI,SAAS,EAAE,MAAA,EAAQ,EAAE,MAAA,EAAQ,GAAA,EAAI,EAAE,GAAI;AAAC,KAC7C,CAAA;AAAA,IACH,cAAA,EAAgB,CAAC,EAAA,KAAO,IAAA,CAAK,CAAA,eAAA,EAAkB,EAAE,CAAA,UAAA,CAAA,EAAc,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,IAC3F,qBAAA,EAAuB,CAAC,EAAA,KACtB,IAAA,CAAK,sBAAsB,kBAAA,CAAmB,EAAE,CAAC,CAAA,aAAA,CAAe;AAAA,GACpE;AACF","file":"chunk-LOHQTTUV.js","sourcesContent":["/**\n * Typed REST client for the AI Asset Store **publisher** surface — the\n * curator-publish flow (`skaile source manifest publish` / `yank`). Thin\n * wrappers over {@link storeFetch}; every method maps 1:1 to an `/api/v1/…`\n * endpoint. The {@link PublisherClient} interface is injectable so the\n * orchestration in `commands/source-manifest-publish.ts` can be unit-tested\n * against a fake without a live store.\n *\n * @docLink cli/dev-guide#store-publisher\n */\n\nimport { getStoreConfig, getStoreToken, type StoreConfig, storeFetch } from \"./store-client.ts\";\n\n/**\n * The publisher REST surface used by the curator-publish flow. Kept minimal —\n * only the endpoints `runPublish` / `runYank` actually call. Response shapes\n * are narrowed to the fields the orchestration reads (the server returns more).\n */\nexport interface PublisherClient {\n /**\n * Identity of the caller. `username` is the Keycloak login (personal-tier\n * namespace); `githubLogin` is the verified GitHub handle when connected —\n * the namespace to publish under when it differs from the login.\n */\n me(): Promise<{ username: string; githubLogin?: string | null }>;\n /** Register (or re-register) a source; returns the created/existing row id. */\n sourcesAdd(body: {\n url: string;\n ref: string;\n sidecarUrl?: string;\n sidecarRef?: string;\n /**\n * Target publisher namespace (the manifest's `publisher`). When it differs\n * from the caller's login username, the store resolves the CLAIMED Publisher\n * for it (the store must already have the claim). Omitted → the store\n * defaults to `@<username>` (personal).\n */\n namespace?: string;\n }): Promise<{ id: string }>;\n /** List sources — used to recover an id when `sourcesAdd` rejects a dup url. */\n sourcesList(): Promise<Array<{ id: string; url: string }>>;\n /** Kick off a source sync; returns the async job id to poll. */\n sourceSync(id: string): Promise<{ jobId: string }>;\n /** Poll a job's terminal status + per-item results. */\n jobGet(\n jobId: string,\n ): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }>;\n /** Discovered publishable candidates for a synced source. */\n sourceCandidates(id: string): Promise<\n Array<{\n id: string;\n name: string;\n version: string;\n kind: string;\n published: boolean;\n assetRoot: string;\n }>\n >;\n /** Per-asset preview — the discovered file set + resolved candidate metadata. */\n assetPreview(id: string): Promise<{\n discoveredFiles: string[];\n candidate: { name: string; version: string; kind: string; publisherNamespace: string };\n }>;\n /**\n * Publish one asset. `dryRun` returns the would-be `{ manifest }` without\n * launching a job; the normal path returns `{ jobId }`.\n */\n assetPublish(\n id: string,\n body: { ref: string; files: string[] },\n dryRun?: boolean,\n ): Promise<{ jobId?: string; manifest?: unknown }>;\n /** Retract a published asset. Response body is ignored. */\n assetUnpublish(id: string): Promise<unknown>;\n /**\n * Read-only \"can I publish under `@<ns>` right now, and if not, what's the\n * path?\" probe. Backs the `publish --dry-run` namespace status line; its\n * `message` is store-authored and meant to be surfaced verbatim.\n */\n namespaceAvailability(ns: string): Promise<{\n namespace: string;\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n claimMethod?: string;\n message: string;\n }>;\n}\n\n/**\n * Construct the real HTTP-backed {@link PublisherClient}. Every call carries a\n * longer timeout than the default store client because publish/sync trigger\n * server-side clone work.\n *\n * @param config - Store connection config; defaults to {@link getStoreConfig}.\n * @param timeoutMs - Per-request abort timeout (default 20s).\n */\nexport function makeHttpPublisherClient(\n config: StoreConfig = getStoreConfig(),\n timeoutMs = 20_000,\n): PublisherClient {\n // Acquire a fresh Keycloak token per call (device-flow session in\n // ~/.skaile/auth.json, refreshed on demand) rather than a static config.jwt.\n const call = async <T>(\n path: string,\n opts?: { method?: string; body?: unknown; params?: Record<string, string> },\n ): Promise<T> => {\n const jwt = await getStoreToken();\n return storeFetch<T>({ ...config, jwt }, path, { timeoutMs, ...opts });\n };\n return {\n me: () => call(\"/api/v1/me\"),\n sourcesAdd: (body) => call(\"/api/v1/sources\", { method: \"POST\", body }),\n sourcesList: () => call(\"/api/v1/sources\"),\n sourceSync: (id) => call(`/api/v1/sources/${id}/sync`, { method: \"POST\", body: {} }),\n jobGet: (jobId) => call(`/api/v1/jobs/${jobId}`),\n sourceCandidates: (id) => call(`/api/v1/sources/${id}/candidates`),\n assetPreview: (id) => call(`/api/v1/assets/${id}/preview`),\n assetPublish: (id, body, dryRun) =>\n call(`/api/v1/assets/${id}/publish`, {\n method: \"POST\",\n body,\n ...(dryRun ? { params: { dryRun: \"1\" } } : {}),\n }),\n assetUnpublish: (id) => call(`/api/v1/assets/${id}/unpublish`, { method: \"POST\", body: {} }),\n namespaceAvailability: (ns) =>\n call(`/api/v1/namespaces/${encodeURIComponent(ns)}/availability`),\n };\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S, logErr, logWarn, logOk, logInfo } from './chunk-ILAZDNIA.js';
|
|
2
|
+
import { globalSettingsPath, mapLegacyFields } from './chunk-YV3YI3TA.js';
|
|
3
|
+
import { globalSkaileDir } from './chunk-TLKM4M47.js';
|
|
2
4
|
import { rmSync, existsSync, readFileSync, mkdirSync, writeFileSync, chmodSync } from 'fs';
|
|
3
5
|
import { randomBytes, createHash } from 'crypto';
|
|
4
|
-
import { homedir } from 'os';
|
|
5
6
|
import { join, dirname } from 'path';
|
|
6
7
|
|
|
7
8
|
function makePkcePair() {
|
|
@@ -13,12 +14,11 @@ function trimTrailingSlash(url) {
|
|
|
13
14
|
return url.replace(/\/+$/, "");
|
|
14
15
|
}
|
|
15
16
|
function loadStoreAuthConfig() {
|
|
16
|
-
const home = process.env.SKAILE_HOME ?? join(homedir(), ".skaile");
|
|
17
17
|
return {
|
|
18
18
|
keycloakUrl: trimTrailingSlash(process.env.SKAILE_KEYCLOAK_URL ?? "https://auth.skaile.ai"),
|
|
19
19
|
realm: process.env.SKAILE_STORE_REALM ?? "skaile-store",
|
|
20
20
|
clientId: process.env.SKAILE_STORE_CLI_CLIENT ?? "skaile-store-cli",
|
|
21
|
-
authFile: process.env.SKAILE_AUTH_FILE ?? join(
|
|
21
|
+
authFile: process.env.SKAILE_AUTH_FILE ?? join(globalSkaileDir(), "auth.json")
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
function oidc(config) {
|
|
@@ -227,6 +227,158 @@ function isStoreAuthenticated() {
|
|
|
227
227
|
return hasStoredAuth(loadStoreAuthConfig());
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
// cli/src/commands/publish-core.ts
|
|
231
|
+
function formatNamespaceAvailability(a) {
|
|
232
|
+
switch (a.status) {
|
|
233
|
+
case "owned-by-you":
|
|
234
|
+
case "available":
|
|
235
|
+
return `${S.ok("\u2713")} ${a.message}`;
|
|
236
|
+
case "claimable-by-you":
|
|
237
|
+
return `${S.warn("!")} ${a.message}`;
|
|
238
|
+
default:
|
|
239
|
+
return `${S.err("\u2717")} ${a.message}`;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
async function preflightNamespace(client, namespace) {
|
|
243
|
+
let a;
|
|
244
|
+
try {
|
|
245
|
+
a = await client.namespaceAvailability(namespace);
|
|
246
|
+
} catch {
|
|
247
|
+
return { ok: true };
|
|
248
|
+
}
|
|
249
|
+
switch (a.status) {
|
|
250
|
+
case "owned-by-you":
|
|
251
|
+
case "available":
|
|
252
|
+
return { ok: true };
|
|
253
|
+
case "claimable-by-you":
|
|
254
|
+
return {
|
|
255
|
+
ok: false,
|
|
256
|
+
message: `@${namespace} isn't yours yet \u2014 claim it in the store first${a.claimMethod ? ` (${a.claimMethod})` : ""}, then re-run. ${a.message}`
|
|
257
|
+
};
|
|
258
|
+
default:
|
|
259
|
+
return { ok: false, message: `Cannot publish under @${namespace} \u2014 ${a.message}` };
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function matchCandidatesToManifest(candidates, manifest) {
|
|
263
|
+
const wanted = new Set((manifest.assets ?? []).map((a) => `${a.kind}:${a.name}`));
|
|
264
|
+
return candidates.filter((c) => wanted.has(`${c.kind}:${c.name}`));
|
|
265
|
+
}
|
|
266
|
+
function refFor(kind, publisher, name, version) {
|
|
267
|
+
const base = `${kind}:@${publisher}/${name}`;
|
|
268
|
+
return version ? `${base}#${version}` : base;
|
|
269
|
+
}
|
|
270
|
+
var UNSET_NAMESPACE = "<manifest publisher>";
|
|
271
|
+
function assetNamespace(asset, manifest) {
|
|
272
|
+
return asset.publisher ?? manifest.publisher;
|
|
273
|
+
}
|
|
274
|
+
function manifestNamespaces(manifest, assetName) {
|
|
275
|
+
const out = /* @__PURE__ */ new Set();
|
|
276
|
+
for (const a of manifest.assets ?? []) {
|
|
277
|
+
if (assetName && a.name !== assetName) continue;
|
|
278
|
+
const ns = assetNamespace(a, manifest);
|
|
279
|
+
if (ns) out.add(ns);
|
|
280
|
+
}
|
|
281
|
+
if (out.size === 0 && manifest.publisher) out.add(manifest.publisher);
|
|
282
|
+
return [...out];
|
|
283
|
+
}
|
|
284
|
+
function plannedRefs(manifest, assetName) {
|
|
285
|
+
return (manifest.assets ?? []).filter((a) => !assetName || a.name === assetName).map(
|
|
286
|
+
(a) => refFor(
|
|
287
|
+
a.kind,
|
|
288
|
+
assetNamespace(a, manifest) ?? UNSET_NAMESPACE,
|
|
289
|
+
a.name,
|
|
290
|
+
a.version ?? manifest.version
|
|
291
|
+
)
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
function bareName(ref) {
|
|
295
|
+
const afterKind = ref.includes(":") ? ref.slice(ref.indexOf(":") + 1) : ref;
|
|
296
|
+
const afterScope = afterKind.includes("/") ? afterKind.slice(afterKind.indexOf("/") + 1) : afterKind;
|
|
297
|
+
return afterScope.split("#")[0];
|
|
298
|
+
}
|
|
299
|
+
async function pollJob(client, jobId, intervalMs = 1500, timeoutMs = 6e4) {
|
|
300
|
+
const deadline = Date.now() + timeoutMs;
|
|
301
|
+
let job = await client.jobGet(jobId);
|
|
302
|
+
while (job.status === "running" && Date.now() < deadline) {
|
|
303
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
304
|
+
job = await client.jobGet(jobId);
|
|
305
|
+
}
|
|
306
|
+
return job;
|
|
307
|
+
}
|
|
308
|
+
function isDupSourceError(err) {
|
|
309
|
+
const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
|
|
310
|
+
return /\b409\b|conflict|duplicate|already exists|already registered|unique/.test(msg);
|
|
311
|
+
}
|
|
312
|
+
async function publishToStore(opts) {
|
|
313
|
+
const { sourceUrl, ref, sidecar, manifest, assetName, client: pub } = opts;
|
|
314
|
+
let sourceId;
|
|
315
|
+
try {
|
|
316
|
+
const added = await pub.sourcesAdd({
|
|
317
|
+
url: sourceUrl,
|
|
318
|
+
ref,
|
|
319
|
+
...sidecar ? { sidecarUrl: sidecar.url, sidecarRef: sidecar.ref } : {},
|
|
320
|
+
// Publish under the manifest's declared namespace; the store resolves a
|
|
321
|
+
// claimed Publisher when it differs from the caller's login, else defaults
|
|
322
|
+
// to `@<username>`. Omitted when the manifest carries no publisher.
|
|
323
|
+
...manifest.publisher ? { namespace: manifest.publisher } : {}
|
|
324
|
+
});
|
|
325
|
+
sourceId = added.id;
|
|
326
|
+
} catch (err) {
|
|
327
|
+
if (!isDupSourceError(err)) throw err;
|
|
328
|
+
const rows = await pub.sourcesList();
|
|
329
|
+
const found = rows.find((r) => r.url === sourceUrl);
|
|
330
|
+
if (!found) {
|
|
331
|
+
throw new Error(
|
|
332
|
+
`Source ${sourceUrl} looked already-registered but no owned row matched: ${err instanceof Error ? err.message : String(err)}`
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
sourceId = found.id;
|
|
336
|
+
}
|
|
337
|
+
const { jobId } = await pub.sourceSync(sourceId);
|
|
338
|
+
const job = await pollJob(pub, jobId);
|
|
339
|
+
if (job.status === "failed" || job.status === "cancelled") {
|
|
340
|
+
const failed = (job.items ?? []).filter((i) => i.status === "failed");
|
|
341
|
+
for (const i of failed) logErr(`sync: ${i.label}: ${i.error ?? "failed"}`);
|
|
342
|
+
logErr(`Source sync ${job.status}.`);
|
|
343
|
+
process.exit(1);
|
|
344
|
+
}
|
|
345
|
+
if (job.status === "running") {
|
|
346
|
+
logErr("Source sync timed out before completing \u2014 re-run `publish`, or check the store.");
|
|
347
|
+
process.exit(1);
|
|
348
|
+
}
|
|
349
|
+
let candidates = matchCandidatesToManifest(await pub.sourceCandidates(sourceId), manifest);
|
|
350
|
+
if (assetName) candidates = candidates.filter((c) => c.name === assetName);
|
|
351
|
+
if (candidates.length === 0) {
|
|
352
|
+
logWarn("No candidates discovered \u2014 check the manifest and the source ref.");
|
|
353
|
+
process.exit(1);
|
|
354
|
+
}
|
|
355
|
+
const published = [];
|
|
356
|
+
for (const c of candidates) {
|
|
357
|
+
try {
|
|
358
|
+
const preview = await pub.assetPreview(c.id);
|
|
359
|
+
const res = await pub.assetPublish(c.id, { ref, files: preview.discoveredFiles });
|
|
360
|
+
if (res.jobId) {
|
|
361
|
+
const pubJob = await pollJob(pub, res.jobId);
|
|
362
|
+
if (pubJob.status !== "succeeded") {
|
|
363
|
+
const errs = (pubJob.items ?? []).filter((i) => i.status === "failed").map((i) => i.error).filter(Boolean);
|
|
364
|
+
logWarn(
|
|
365
|
+
`Publish of ${c.kind}:${c.name} did not succeed (${pubJob.status})` + (errs.length ? `: ${errs.join("; ")}` : "")
|
|
366
|
+
);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
published.push(refFor(c.kind, preview.candidate.publisherNamespace, c.name, c.version));
|
|
371
|
+
} catch (err) {
|
|
372
|
+
logWarn(
|
|
373
|
+
`Failed to publish ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
logOk(`Published ${published.length} asset(s):`);
|
|
378
|
+
for (const r of published) logInfo(` ${r}`);
|
|
379
|
+
return { published };
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export { assetNamespace, bareName, deviceLogin, formatNamespaceAvailability, getStoreConfig, getStoreIdentity, getStoreToken, hasStoredAuth, isStoreAuthenticated, loadStoreAuthConfig, logout, manifestNamespaces, plannedRefs, preflightNamespace, publishToStore, refFor, storeFetch };
|
|
383
|
+
//# sourceMappingURL=chunk-MQ42OYKH.js.map
|
|
384
|
+
//# sourceMappingURL=chunk-MQ42OYKH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../cli/src/store-auth.ts","../cli/src/store-client.ts","../cli/src/commands/publish-core.ts"],"names":["readFileSync"],"mappings":";;;;;;;AAsBA,SAAS,YAAA,GAAwD;AAC/D,EAAA,MAAM,QAAA,GAAW,WAAA,CAAY,EAAE,CAAA,CAAE,SA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OAAO,CAAA;AACjB,UAAA,OAAA;AAAA,YACE,cAAc,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,kBAAA,EAAqB,MAAA,CAAO,MAAM,CAAA,CAAA,CAAA,IAC7D,KAAK,MAAA,GAAS,CAAA,EAAA,EAAK,KAAK,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,GAAK,EAAA;AAAA,WAC5C;AACA,UAAA;AAAA,QACF;AAAA,MACF;AACA,MAAA,SAAA,CAAU,IAAA,CAAK,MAAA,CAAO,CAAA,CAAE,IAAA,EAAM,OAAA,CAAQ,SAAA,CAAU,kBAAA,EAAoB,CAAA,CAAE,IAAA,EAAM,CAAA,CAAE,OAAO,CAAC,CAAA;AAAA,IACxF,SAAS,GAAA,EAAK;AACZ,MAAA,OAAA;AAAA,QACE,CAAA,kBAAA,EAAqB,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OAC5F;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,UAAA,EAAa,SAAA,CAAU,MAAM,CAAA,UAAA,CAAY,CAAA;AAC/C,EAAA,KAAA,MAAW,CAAA,IAAK,SAAA,EAAW,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC3C,EAAA,OAAO,EAAE,SAAA,EAAU;AACrB","file":"chunk-MQ42OYKH.js","sourcesContent":["/**\n * Keycloak Device Authorization Grant (RFC 8628) for the store CLI: a public\n * device-flow client (`skaile-store-cli`) issues a plain realm JWT the store's\n * `AuthGuard` accepts — a CLI can't use the storefront's confidential browser\n * client. Tokens cache at `~/.skaile/auth.json` (0600, shared with `store/cli`);\n * `getAccessToken` refreshes transparently. All targets are env-overridable.\n *\n * @docLink cli/dev-guide#store-auth\n */\nimport { createHash, randomBytes } from \"node:crypto\";\nimport { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { globalSkaileDir } from \"@skaile/workspaces/core\";\n\n/**\n * A PKCE (RFC 7636) `code_verifier` + its S256 `code_challenge`. Keycloak\n * enforces PKCE on the `skaile-store-cli` device flow (the device-authorization\n * request 400s with \"Missing parameter: code_challenge_method\" otherwise), so\n * every `deviceLogin` mints a fresh pair: the challenge goes on the device-auth\n * request, the verifier on the matching token poll. `base64url` (no padding)\n * per the spec.\n */\nfunction makePkcePair(): { verifier: string; challenge: string } {\n const verifier = randomBytes(32).toString(\"base64url\");\n const challenge = createHash(\"sha256\").update(verifier).digest(\"base64url\");\n return { verifier, challenge };\n}\n\n/** Resolved auth targets — every field has a prod default, all env-overridable. */\nexport interface StoreAuthConfig {\n keycloakUrl: string;\n realm: string;\n clientId: string;\n authFile: string;\n}\n\nfunction trimTrailingSlash(url: string): string {\n return url.replace(/\\/+$/, \"\");\n}\n\n/**\n * Load the auth config. Defaults target the production store\n * (`auth.skaile.ai`, realm `skaile-store`, public client `skaile-store-cli`);\n * override with `SKAILE_KEYCLOAK_URL` / `SKAILE_STORE_REALM` /\n * `SKAILE_STORE_CLI_CLIENT` / `SKAILE_AUTH_FILE` for dev or a preview deploy.\n */\nexport function loadStoreAuthConfig(): StoreAuthConfig {\n return {\n keycloakUrl: trimTrailingSlash(process.env.SKAILE_KEYCLOAK_URL ?? \"https://auth.skaile.ai\"),\n realm: process.env.SKAILE_STORE_REALM ?? \"skaile-store\",\n clientId: process.env.SKAILE_STORE_CLI_CLIENT ?? \"skaile-store-cli\",\n authFile: process.env.SKAILE_AUTH_FILE ?? join(globalSkaileDir(), \"auth.json\"),\n };\n}\n\n/** Keycloak OIDC endpoints derived from the realm base. */\nfunction oidc(config: StoreAuthConfig): { deviceAuth: string; token: string } {\n const base = `${config.keycloakUrl}/realms/${config.realm}/protocol/openid-connect`;\n return { deviceAuth: `${base}/auth/device`, token: `${base}/token` };\n}\n\nexport interface StoredAuth {\n access_token: string;\n refresh_token?: string;\n /** Epoch ms when the access token expires (with a safety margin already applied). */\n expires_at: number;\n}\n\ninterface TokenResponse {\n access_token: string;\n refresh_token?: string;\n expires_in?: number;\n error?: string;\n error_description?: string;\n}\n\ninterface DeviceAuthResponse {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete?: string;\n interval?: number;\n expires_in: number;\n}\n\n/** Refresh this many ms before real expiry so an in-flight call never 401s. */\nconst EXPIRY_MARGIN_MS = 30_000;\n\n/** Injectable seams so the poll loop is unit-testable without real time or network. */\nexport interface AuthDeps {\n fetchImpl?: typeof fetch;\n sleep?: (ms: number) => Promise<void>;\n /** Called once with the verification URL + user code (default: write to stderr). */\n onPrompt?: (url: string, userCode: string) => void;\n}\n\nfunction readAuth(config: StoreAuthConfig): StoredAuth | null {\n try {\n const parsed = JSON.parse(readFileSync(config.authFile, \"utf-8\"));\n // Reject a corrupt / hand-edited file rather than treat it as a session.\n if (parsed && typeof parsed.access_token === \"string\") return parsed as StoredAuth;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * The caller's store identity, decoded LOCALLY from the cached token's JWT\n * payload (no network, no signature check — this is an author-side hint, not an\n * authorization decision). Returns `null` when not signed in or the token is\n * unreadable. `githubLogin` is the verified GitHub handle (the preferred\n * publisher namespace); `username` is the Keycloak `preferred_username`.\n */\nexport function getStoreIdentity(\n config: StoreAuthConfig = loadStoreAuthConfig(),\n): { username?: string; githubLogin?: string } | null {\n const auth = readAuth(config);\n if (!auth) return null;\n try {\n const payload = auth.access_token.split(\".\")[1];\n const json = JSON.parse(Buffer.from(payload, \"base64url\").toString(\"utf-8\"));\n const username =\n typeof json.preferred_username === \"string\" ? json.preferred_username : undefined;\n const githubLogin = typeof json.github_login === \"string\" ? json.github_login : undefined;\n return username || githubLogin ? { username, githubLogin } : null;\n } catch {\n return null;\n }\n}\n\nfunction writeAuth(config: StoreAuthConfig, auth: StoredAuth): void {\n mkdirSync(dirname(config.authFile), { recursive: true });\n writeFileSync(config.authFile, JSON.stringify(auth, null, 2), { mode: 0o600 });\n chmodSync(config.authFile, 0o600);\n}\n\n/** Remove the cached session (sign out). */\nexport function logout(config: StoreAuthConfig): void {\n try {\n rmSync(config.authFile);\n } catch {\n // already absent — nothing to do\n }\n}\n\n/** True when a cached, well-formed session exists (validity/refresh resolved on use). */\nexport function hasStoredAuth(config: StoreAuthConfig): boolean {\n return readAuth(config) !== null;\n}\n\nfunction tokenToStored(token: TokenResponse): StoredAuth {\n return {\n access_token: token.access_token,\n refresh_token: token.refresh_token,\n expires_at: Date.now() + (token.expires_in ?? 300) * 1000 - EXPIRY_MARGIN_MS,\n };\n}\n\nconst defaultSleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));\n\nfunction defaultPrompt(url: string, userCode: string): void {\n process.stderr.write(\n `\\nTo sign in, open:\\n\\n ${url}\\n\\nand enter the code: ${userCode}\\n\\nWaiting for approval…\\n`,\n );\n}\n\n/**\n * Run the device flow to completion, persisting tokens on success. Prints the\n * verification URL + user code for the operator to approve in a browser.\n */\nexport async function deviceLogin(\n config: StoreAuthConfig,\n deps: AuthDeps = {},\n): Promise<StoredAuth> {\n const fetchImpl = deps.fetchImpl ?? fetch;\n const sleep = deps.sleep ?? defaultSleep;\n const onPrompt = deps.onPrompt ?? defaultPrompt;\n const endpoints = oidc(config);\n const pkce = makePkcePair();\n\n const deviceRes = await fetchImpl(endpoints.deviceAuth, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n client_id: config.clientId,\n scope: \"openid profile\",\n code_challenge: pkce.challenge,\n code_challenge_method: \"S256\",\n }),\n });\n if (!deviceRes.ok) {\n throw new Error(\n `Device authorization request failed (${deviceRes.status}): ${await deviceRes.text()}`,\n );\n }\n const device = (await deviceRes.json()) as DeviceAuthResponse;\n\n onPrompt(device.verification_uri_complete ?? device.verification_uri, device.user_code);\n\n const intervalMs = (device.interval ?? 5) * 1000;\n const deadline = Date.now() + device.expires_in * 1000;\n let waitMs = intervalMs;\n\n while (Date.now() < deadline) {\n await sleep(waitMs);\n const tokenRes = await fetchImpl(endpoints.token, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: device.device_code,\n client_id: config.clientId,\n code_verifier: pkce.verifier,\n }),\n });\n const token = (await tokenRes.json()) as TokenResponse;\n if (tokenRes.ok) {\n const stored = tokenToStored(token);\n writeAuth(config, stored);\n return stored;\n }\n // RFC 8628 §3.5 pending / slow-down handling.\n if (token.error === \"authorization_pending\") continue;\n if (token.error === \"slow_down\") {\n waitMs += 5_000;\n continue;\n }\n throw new Error(`Sign-in failed: ${token.error_description ?? token.error ?? \"unknown error\"}`);\n }\n throw new Error(\"Sign-in timed out before approval.\");\n}\n\n/** Exchange a refresh token for a fresh access token; persist on success. */\nasync function refresh(\n config: StoreAuthConfig,\n refreshToken: string,\n fetchImpl: typeof fetch,\n): Promise<StoredAuth> {\n const res = await fetchImpl(oidc(config).token, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n grant_type: \"refresh_token\",\n refresh_token: refreshToken,\n client_id: config.clientId,\n }),\n });\n const token = (await res.json()) as TokenResponse;\n if (!res.ok) {\n throw new Error(\n `Token refresh failed: ${token.error_description ?? token.error ?? res.status}`,\n );\n }\n const stored = tokenToStored(token);\n writeAuth(config, stored);\n return stored;\n}\n\n/**\n * Return a valid access token, refreshing if it is expired (or about to). Throws\n * a clear \"run `skaile store login`\" error when there is no usable session.\n */\nexport async function getAccessToken(\n config: StoreAuthConfig,\n deps: AuthDeps = {},\n): Promise<string> {\n const fetchImpl = deps.fetchImpl ?? fetch;\n const auth = readAuth(config);\n if (!auth) throw new Error(\"Not signed in. Run `skaile store login` first.\");\n if (Date.now() < auth.expires_at) return auth.access_token;\n if (!auth.refresh_token) throw new Error(\"Session expired. Run `skaile store login` again.\");\n try {\n return (await refresh(config, auth.refresh_token, fetchImpl)).access_token;\n } catch {\n throw new Error(\"Session expired and refresh failed. Run `skaile store login` again.\");\n }\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { globalSettingsPath, mapLegacyFields } from \"@skaile/workspaces/core\";\nimport { type AuthDeps, getAccessToken, hasStoredAuth, loadStoreAuthConfig } from \"./store-auth.ts\";\n\n/**\n * Connection configuration for the AI Asset Store API. `jwt` is normally left\n * null here and filled per-call by the caller from {@link getStoreToken} (the\n * device-flow session); it stays on the type for the `{ ...config, jwt }` spread.\n *\n * @docLink cli/dev-guide#store-client\n */\nexport interface StoreConfig {\n url: string;\n jwt: string | null;\n}\n\n/**\n * Read the store API base URL (settings `storeUrl` → `SKAILE_STORE_URL` →\n * default). Auth is not read here — it lives in the device-flow session; see\n * {@link getStoreToken}.\n *\n * @docLink cli/dev-guide#store-client\n */\nexport function getStoreConfig(): StoreConfig {\n const settingsPath = globalSettingsPath();\n let settings: Record<string, any> = {};\n if (existsSync(settingsPath)) {\n try {\n settings = mapLegacyFields(JSON.parse(readFileSync(settingsPath, \"utf-8\")));\n } catch {\n settings = {};\n }\n }\n return {\n url: settings.storeUrl ?? process.env.SKAILE_STORE_URL ?? \"https://api.skaile.store\",\n jwt: null,\n };\n}\n\n/**\n * Return a valid store access token (Keycloak device-flow session, refreshed if\n * needed). Throws a \"run `skaile store login`\" error when there is no session.\n * This is the auth source for every `/api/v1/*` publisher call.\n */\nexport function getStoreToken(deps?: AuthDeps): Promise<string> {\n return getAccessToken(loadStoreAuthConfig(), deps);\n}\n\n/**\n * Make an authenticated HTTP request to the store REST API.\n *\n * @param config - Store connection config (URL + auth token).\n * @param path - API path (e.g. `/api/assets`).\n * @param opts - Optional method, body, query params, extra headers, and\n * `timeoutMs` (default 1500). Publisher calls pass a longer timeout because\n * they trigger server-side clone/sync work.\n * @returns Parsed JSON response body.\n * @docLink cli/dev-guide#store-client\n */\nexport async function storeFetch<T = any>(\n config: StoreConfig,\n path: string,\n opts?: {\n method?: string;\n body?: unknown;\n params?: Record<string, string>;\n headers?: Record<string, string>;\n timeoutMs?: number;\n },\n): Promise<T> {\n let url = `${config.url}${path}`;\n if (opts?.params) {\n const sp = new URLSearchParams(opts.params);\n url += `?${sp}`;\n }\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...(opts?.headers ?? {}),\n };\n if (config.jwt) {\n headers.Authorization = `Bearer ${config.jwt}`;\n }\n\n const fetchOpts: RequestInit = {\n method: opts?.method ?? \"GET\",\n headers,\n };\n if (opts?.body) {\n fetchOpts.body = JSON.stringify(opts.body);\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), opts?.timeoutMs ?? 1_500);\n try {\n const res = await fetch(url, { ...fetchOpts, signal: controller.signal });\n if (!res.ok) {\n const body = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));\n // Prefer the store's human-readable `message` (e.g. \"Namespace '@x' is\n // reserved … Sign in with GitHub to claim it\") over the bare `error` code\n // (`UNPROCESSABLE_CONTENT`) — the message is the actionable part.\n const b = body as { message?: string; error?: string };\n throw new Error(b.message ?? b.error ?? `Store API error: ${res.status}`);\n }\n return res.json() as Promise<T>;\n } finally {\n clearTimeout(timeout);\n }\n}\n\n/**\n * Return `true` when a store session exists (a Keycloak device-flow token cached\n * at `~/.skaile/auth.json`). Validity/refresh is resolved on use via\n * {@link getStoreToken}.\n *\n * @docLink cli/dev-guide#store-client\n */\nexport function isStoreAuthenticated(): boolean {\n return hasStoredAuth(loadStoreAuthConfig());\n}\n","/**\n * Shared store-interaction core for the two publish front-ends — the curator\n * sidecar flow (`source manifest publish`) and the first-party library flow\n * (`library publish`). Both differ only in their git side-effects + how they\n * resolve the source repo; the store orchestration below (register → sync →\n * candidates → per-asset preview+publish) is identical.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * so the orchestration stays unit/integration-testable without a live store.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport type { SkPublishManifest } from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport type { PublisherClient } from \"../store-publisher.ts\";\n\n/**\n * One-line rendering of a namespace-availability probe for a `--dry-run` plan.\n * The `message` is store-authored (identical to what a real publish would echo)\n * — we only prepend a status glyph so the reader sees green/amber/red at a\n * glance without the CLI re-deriving any authorization logic.\n */\nexport function formatNamespaceAvailability(a: {\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n message: string;\n}): string {\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return `${S.ok(\"✓\")} ${a.message}`;\n case \"claimable-by-you\":\n return `${S.warn(\"!\")} ${a.message}`;\n default:\n return `${S.err(\"✗\")} ${a.message}`;\n }\n}\n\n/**\n * Preflight the target namespace against the store's availability probe BEFORE a\n * publish does any irreversible work (a public git push). Returns `{ ok: false }`\n * with a guided message for `reserved` (not yours) and `claimable-by-you` (must\n * claim first) — the two states a real publish would reject — so the caller can\n * abort with actionable guidance instead of a raw 422 after pushing bytes.\n *\n * The probe is advisory: any failure (offline, older store) returns `{ ok: true }`\n * so the store stays the authority and a valid publish is never blocked.\n */\nexport async function preflightNamespace(\n client: PublisherClient,\n namespace: string,\n): Promise<{ ok: boolean; message?: string }> {\n let a: Awaited<ReturnType<PublisherClient[\"namespaceAvailability\"]>>;\n try {\n a = await client.namespaceAvailability(namespace);\n } catch {\n return { ok: true };\n }\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return { ok: true };\n case \"claimable-by-you\":\n return {\n ok: false,\n message:\n `@${namespace} isn't yours yet — claim it in the store first` +\n `${a.claimMethod ? ` (${a.claimMethod})` : \"\"}, then re-run. ${a.message}`,\n };\n default: // reserved, or any unrecognized future status (fail safe → block)\n return { ok: false, message: `Cannot publish under @${namespace} — ${a.message}` };\n }\n}\n\n/** One candidate row shape the matcher operates on (kind + name are the key). */\ninterface CandidateLike {\n kind: string;\n name: string;\n}\n\n/**\n * Keep only candidates whose `(kind, name)` pair is declared in the manifest.\n * The backend may merge extra assets from the base repo into the candidate\n * list; a publish only touches what the manifest curated/declared.\n */\nexport function matchCandidatesToManifest<T extends CandidateLike>(\n candidates: T[],\n manifest: SkPublishManifest,\n): T[] {\n const wanted = new Set((manifest.assets ?? []).map((a) => `${a.kind}:${a.name}`));\n return candidates.filter((c) => wanted.has(`${c.kind}:${c.name}`));\n}\n\n/** A canonical ref string `kind:@publisher/name[#version]` for reporting. */\nexport function refFor(kind: string, publisher: string, name: string, version?: string): string {\n const base = `${kind}:@${publisher}/${name}`;\n return version ? `${base}#${version}` : base;\n}\n\n/** Placeholder namespace shown when neither the asset nor the manifest names a publisher. */\nconst UNSET_NAMESPACE = \"<manifest publisher>\";\n\n/**\n * The publisher namespace one manifest asset publishes under:\n * `assets[].publisher` first, else the manifest's top-level `publisher` —\n * the same priority discovery applies when it indexes the asset. `undefined`\n * when neither is declared.\n */\nexport function assetNamespace(\n asset: { publisher?: string },\n manifest: SkPublishManifest,\n): string | undefined {\n return asset.publisher ?? manifest.publisher;\n}\n\n/**\n * Every distinct namespace the manifest's assets (optionally narrowed to\n * `assetName`) publish under, in first-seen order. A manifest whose assets\n * carry no namespace at all falls back to its top-level `publisher` so an\n * empty inventory still reports the namespace it would claim.\n */\nexport function manifestNamespaces(manifest: SkPublishManifest, assetName?: string): string[] {\n const out = new Set<string>();\n for (const a of manifest.assets ?? []) {\n if (assetName && a.name !== assetName) continue;\n const ns = assetNamespace(a, manifest);\n if (ns) out.add(ns);\n }\n if (out.size === 0 && manifest.publisher) out.add(manifest.publisher);\n return [...out];\n}\n\n/**\n * The canonical refs a publish would produce, one per manifest asset (optionally\n * narrowed to `assetName`), each under its own `assets[].publisher ?? publisher`.\n */\nexport function plannedRefs(manifest: SkPublishManifest, assetName?: string): string[] {\n return (manifest.assets ?? [])\n .filter((a) => !assetName || a.name === assetName)\n .map((a) =>\n refFor(\n a.kind,\n assetNamespace(a, manifest) ?? UNSET_NAMESPACE,\n a.name,\n a.version ?? manifest.version,\n ),\n );\n}\n\n/** The bare asset name from a `kind:@publisher/name#version` ref or a plain name. */\nexport function bareName(ref: string): string {\n const afterKind = ref.includes(\":\") ? ref.slice(ref.indexOf(\":\") + 1) : ref;\n const afterScope = afterKind.includes(\"/\")\n ? afterKind.slice(afterKind.indexOf(\"/\") + 1)\n : afterKind;\n return afterScope.split(\"#\")[0];\n}\n\n/**\n * Poll a job until it leaves `running` or the deadline passes. Returns the last\n * observed state — the caller MUST treat a still-`running` result as a timeout\n * (not success), since it means the deadline was hit before the job finished.\n */\nexport async function pollJob(\n client: PublisherClient,\n jobId: string,\n intervalMs = 1_500,\n timeoutMs = 60_000,\n): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }> {\n const deadline = Date.now() + timeoutMs;\n let job = await client.jobGet(jobId);\n while (job.status === \"running\" && Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, intervalMs));\n job = await client.jobGet(jobId);\n }\n return job;\n}\n\n/**\n * True when a `sourcesAdd` rejection is a duplicate-URL conflict (the source is\n * already registered) — the only error the publish flow recovers from by looking\n * the existing row up. Every other failure (auth, 5xx, network) must propagate.\n */\nexport function isDupSourceError(err: unknown): boolean {\n const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();\n return /\\b409\\b|conflict|duplicate|already exists|already registered|unique/.test(msg);\n}\n\n/**\n * Register + sync the source, then publish its curated/declared candidates —\n * the store-side steps shared by both publish front-ends. Git side-effects (the\n * sidecar push, or the library commit+push) happen in the caller *before* this;\n * this function is purely store interaction.\n *\n * The sidecar front-end passes `sidecar` (so `sourcesAdd` carries the sidecar\n * pin); the library front-end omits it (the source repo IS the manifest host).\n * `assetName`, when set, narrows publication to the single candidate of that\n * name. Fatal store states (`sourcesAdd` non-dup failure) surface; sync failures\n * and empty candidate sets `process.exit(1)` with the same messages as before.\n */\nexport async function publishToStore(opts: {\n sourceUrl: string;\n ref: string;\n sidecar?: { url: string; ref: string };\n manifest: SkPublishManifest;\n assetName?: string;\n client: PublisherClient;\n}): Promise<{ published: string[] }> {\n const { sourceUrl, ref, sidecar, manifest, assetName, client: pub } = opts;\n\n let sourceId: string;\n try {\n const added = await pub.sourcesAdd({\n url: sourceUrl,\n ref,\n ...(sidecar ? { sidecarUrl: sidecar.url, sidecarRef: sidecar.ref } : {}),\n // Publish under the manifest's declared namespace; the store resolves a\n // claimed Publisher when it differs from the caller's login, else defaults\n // to `@<username>`. Omitted when the manifest carries no publisher.\n ...(manifest.publisher ? { namespace: manifest.publisher } : {}),\n });\n sourceId = added.id;\n } catch (err) {\n // Only a duplicate-url conflict is recoverable (source already registered);\n // auth/5xx/network failures must surface, not silently reuse a stale row.\n if (!isDupSourceError(err)) throw err;\n const rows = await pub.sourcesList();\n const found = rows.find((r) => r.url === sourceUrl);\n if (!found) {\n throw new Error(\n `Source ${sourceUrl} looked already-registered but no owned row matched: ` +\n `${err instanceof Error ? err.message : String(err)}`,\n );\n }\n sourceId = found.id;\n }\n\n const { jobId } = await pub.sourceSync(sourceId);\n const job = await pollJob(pub, jobId);\n if (job.status === \"failed\" || job.status === \"cancelled\") {\n const failed = (job.items ?? []).filter((i) => i.status === \"failed\");\n for (const i of failed) logErr(`sync: ${i.label}: ${i.error ?? \"failed\"}`);\n logErr(`Source sync ${job.status}.`);\n process.exit(1);\n }\n // A still-`running` job means the poll deadline was hit — do NOT proceed on an\n // unfinished sync (it would read incomplete candidates).\n if (job.status === \"running\") {\n logErr(\"Source sync timed out before completing — re-run `publish`, or check the store.\");\n process.exit(1);\n }\n\n let candidates = matchCandidatesToManifest(await pub.sourceCandidates(sourceId), manifest);\n if (assetName) candidates = candidates.filter((c) => c.name === assetName);\n if (candidates.length === 0) {\n logWarn(\"No candidates discovered — check the manifest and the source ref.\");\n process.exit(1);\n }\n\n const published: string[] = [];\n for (const c of candidates) {\n try {\n const preview = await pub.assetPreview(c.id);\n const res = await pub.assetPublish(c.id, { ref, files: preview.discoveredFiles });\n // Publish is async — wait for the job so we only report refs that actually\n // landed, not ones whose import is still in flight or about to fail.\n if (res.jobId) {\n const pubJob = await pollJob(pub, res.jobId);\n if (pubJob.status !== \"succeeded\") {\n const errs = (pubJob.items ?? [])\n .filter((i) => i.status === \"failed\")\n .map((i) => i.error)\n .filter(Boolean);\n logWarn(\n `Publish of ${c.kind}:${c.name} did not succeed (${pubJob.status})` +\n (errs.length ? `: ${errs.join(\"; \")}` : \"\"),\n );\n continue;\n }\n }\n published.push(refFor(c.kind, preview.candidate.publisherNamespace, c.name, c.version));\n } catch (err) {\n logWarn(\n `Failed to publish ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Published ${published.length} asset(s):`);\n for (const r of published) logInfo(` ${r}`);\n return { published };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { logErr } from './chunk-
|
|
2
|
-
import { flowKindProvider } from './chunk-
|
|
3
|
-
import { knowledgeKindProvider } from './chunk-
|
|
4
|
-
import { createDefaultRegistry } from './chunk-
|
|
1
|
+
import { logErr } from './chunk-ILAZDNIA.js';
|
|
2
|
+
import { flowKindProvider } from './chunk-7RC37XFW.js';
|
|
3
|
+
import { knowledgeKindProvider } from './chunk-XU7JET5Z.js';
|
|
4
|
+
import { createDefaultRegistry } from './chunk-OLMNDIAU.js';
|
|
5
5
|
|
|
6
6
|
// cli/src/open-registry.ts
|
|
7
7
|
function createFullRegistry() {
|
|
@@ -103,5 +103,5 @@ async function openLibraryManager() {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export { LocalCatalogDisabledError, createFullRegistry, openCatalogSource, openLibrary, openLibraryManager, resolveCatalogSource };
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-MS2JK4V7.js.map
|
|
107
|
+
//# s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A,EAAO,MAAM;AAAA,EAAC,CAAA,EAAE;AACnC;AASA,eAAsB,kBAAA,GAInB;AACD,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,oBAA4B,CAAA;AACpE,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,EAAY;AAClC,EAAA,MAAM,OAAA,GAAU,IAAI,cAAA,CAAe,OAAO,CAAA;AAC1C,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAC1D","file":"chunk-5JJ5KQUM.js","sourcesContent":["/**\n * open-registry.ts — shared helper to create a full AssetKindRegistry.\n *\n * Bootstraps the registry with all built-in providers (9 core + preset)\n * from @skaile/discovery, plus the extension kind providers (flow from\n * @skaile/workspaces/factory-assets/connectors/flow/engine, knowledge from @skaile/library).\n *\n * This is the single registration point for the CLI. All code paths\n * that need a registry (source sync, lib-status, etc.) should use this.\n */\n\nimport type { AssetKindRegistry } from \"@skaile/workspaces/discovery\";\nimport { createDefaultRegistry } from \"@skaile/workspaces/discovery\";\nimport { flowKindProvider } from \"@skaile/workspaces/factory-assets/connectors/flow/engine\";\nimport { knowledgeKindProvider } from \"@skaile/workspaces/library\";\n\n/**\n * Create a fully-configured AssetKindRegistry with all known providers.\n *\n * Registers:\n * - 9 core kinds (skill, agent, connector, mount, mcp-server, contract, prompt, persona, ruleset)\n * - preset (composition entity)\n * - flow (extension, from @skaile/workspaces/factory-assets/connectors/flow/engine)\n * - knowledge (extension, from @skaile/library)\n *\n * @returns An unfrozen registry (auto-freezes on first read)\n */\nexport function createFullRegistry(): AssetKindRegistry {\n const registry = createDefaultRegistry();\n registry.register(flowKindProvider);\n registry.register(knowledgeKindProvider);\n return registry;\n}\n","/**\n * open-library.ts — shared helpers to open the LocalIndex and the configured\n * Catalog source.\n *\n * Lazy-loads the `@skaile/workspaces/library` subpath and returns the\n * LocalIndex instance (backed by `@libsql/client`; runs on Node and Bun).\n * The catalog-source helper reads\n * `~/.skaile/config.yaml` (and project-level overlay if `projectDir` is given)\n * to decide between {@link RemoteCatalogSource} (default — points at\n * `https://skaile.store`) and a {@link LocalCatalogSource} bound to the most\n * recent local library registered via `skaile source add`.\n */\n\nimport { logErr } from \"./helpers.ts\";\nimport { createFullRegistry } from \"./open-registry.ts\";\n\n/** Thrown by {@link openCatalogSource} when `catalog.url` is the `local` sentinel. */\nexport class LocalCatalogDisabledError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LocalCatalogDisabledError\";\n }\n}\n\n/**\n * Open the LocalIndex with the full kind registry. Exits with code 1\n * if the library directory cannot be created.\n *\n * @returns A `LocalIndex` instance ready for use.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibrary() {\n try {\n const { LocalIndex } = await import(\"@skaile/workspaces/library\");\n return new LocalIndex({ kindRegistry: createFullRegistry() });\n } catch (err) {\n logErr(`Could not open LocalIndex: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Resolve the configured **remote** Catalog source for the CLI.\n *\n * Reads `~/.skaile/config.yaml` (plus the optional project-level overlay) and\n * returns a {@link RemoteCatalogSource} pointing at `catalog.url` (default:\n * `https://skaile.store`). The `cache_ttl: 0` config flag flips the source\n * into air-gapped mode: network reads are disabled, only `skaile update`\n * performs refreshes.\n *\n * **Local-mode rejection.** If the resolved config has `catalog.url: local`\n * this helper throws — callers wanting the dispatched local-or-remote source\n * must use {@link resolveCatalogSource}. Remote-only consumers like\n * `skaile update --catalog-only` rely on this strict behaviour.\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A configured {@link RemoteCatalogSource}.\n * @throws When `catalog.url` is the `local` sentinel.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<\n | import(\"@skaile/workspaces/library\").RemoteCatalogSource\n | import(\"@skaile/workspaces/library\").RestCatalogSource\n> {\n const { resolveConfig, RemoteCatalogSource, RestCatalogSource, isLocalCatalogUrl } = await import(\n \"@skaile/workspaces/library\"\n );\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n if (isLocalCatalogUrl(baseUrl)) {\n throw new LocalCatalogDisabledError(\n \"catalog.url is set to 'local' — remote catalog is disabled. \" +\n \"Use `skaile source add <path>` + `skaile source sync` for local sources, \" +\n \"or set `catalog.url: https://skaile.store` in ~/.skaile/config.yaml.\",\n );\n }\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n if (cfg.catalog.framing === \"rest\") {\n return new RestCatalogSource({ baseUrl, cacheTtlMs });\n }\n return new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n}\n\n/**\n * Resolved catalog source plus a close handle for releasing any underlying\n * resources (e.g. the `LocalIndex` SQLite connection in local mode).\n *\n * Callers MUST invoke `close()` when done — typically in a `finally` block.\n * For remote-mode sources `close()` is a no-op, but the contract is uniform\n * so consumers don't have to branch.\n *\n * @docLink cli/dev-guide#open-library\n */\nexport interface ResolvedCatalogSource {\n /** The {@link ICatalogSource} ready for use. */\n source: import(\"@skaile/workspaces/library\").ICatalogSource;\n /** Release any underlying resources (SQLite handle in local mode). */\n close(): void;\n}\n\n/**\n * Resolve the configured Catalog source — local or remote — based on\n * `~/.skaile/config.yaml`.\n *\n * Dispatch:\n * - `catalog.url: local` → opens {@link LocalIndex}, picks the most recently\n * registered local library whose `path` still exists on disk, and returns a\n * {@link LocalCatalogSource} bound to that library. Throws if no usable\n * local library is registered.\n * - any URL → returns {@link RemoteCatalogSource} (same as\n * {@link openCatalogSource}).\n *\n * The returned `close()` releases the underlying `LocalIndex` SQLite handle\n * in local mode (no-op in remote mode). Callers MUST invoke it — typically in\n * a `finally` block — to satisfy `library/CLAUDE.md` § \"Notes for Consumers\".\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A `ResolvedCatalogSource` carrying the source and a close handle.\n * @throws When `local` is configured but no usable local library is registered.\n * @docLink cli/dev-guide#open-library\n */\nexport async function resolveCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<ResolvedCatalogSource> {\n const {\n resolveConfig,\n RemoteCatalogSource,\n RestCatalogSource,\n LocalCatalogSource,\n isLocalCatalogUrl,\n } = await import(\"@skaile/workspaces/library\");\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n\n if (isLocalCatalogUrl(baseUrl)) {\n const fs = await import(\"node:fs\");\n const library = await openLibrary();\n try {\n const sources = await library.listSources();\n type LibraryRow = (typeof sources)[number];\n // Type-narrow: `path` is required for local libraries after the filter.\n const usable = sources\n .filter(\n (s): s is LibraryRow & { path: string } =>\n s.backend === \"local\" && typeof s.path === \"string\" && s.path.length > 0,\n )\n .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());\n\n if (usable.length === 0) {\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile source add <path>` first, then `skaile source sync`.\",\n );\n }\n\n // Prefer the most recently added library whose path still exists.\n const present = usable.find((s) => fs.existsSync(s.path));\n if (!present) {\n const head = usable[0];\n throw new Error(\n `catalog.url is set to 'local' but every registered local library has a missing path on disk. ` +\n `Most recent: ${head.path} (library ${head.id}). ` +\n `Re-register with \\`skaile source add <existing-path>\\` or run \\`skaile source list\\` to inspect.`,\n );\n }\n\n const source = new LocalCatalogSource(\n library,\n present.id,\n present.path,\n createFullRegistry(),\n );\n return { source, close: () => library.close() };\n } catch (err) {\n // Release the handle on any failure during dispatch — otherwise the\n // SQLite WAL state leaks for the lifetime of the process.\n library.close();\n throw err;\n }\n }\n\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n const source =\n cfg.catalog.framing === \"rest\"\n ? new RestCatalogSource({ baseUrl, cacheTtlMs })\n : new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n return { source, close: () => {} };\n}\n\n/**\n * Open the LibraryManager bound to the active LocalIndex.\n * Caller owns lifetime — must call `close()` (returned helper closes the\n * underlying LocalIndex).\n *\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibraryManager(): Promise<{\n manager: import(\"@skaile/workspaces/library\").LibraryManager;\n library: import(\"@skaile/workspaces/library\").LocalIndex;\n close: () => void;\n}> {\n const { LibraryManager } = await import(\"@skaile/workspaces/library\");\n const library = await openLibrary();\n const manager = new LibraryManager(library);\n return { manager, library, close: () => library.close() };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/open-registry.ts","../cli/src/open-library.ts"],"names":["source"],"mappings":";;;;;;AA2BO,SAAS,kBAAA,GAAwC;AACtD,EAAA,MAAM,WAAW,qBAAA,EAAsB;AACvC,EAAA,QAAA,CAAS,SAAS,gBAAgB,CAAA;AAClC,EAAA,QAAA,CAAS,SAAS,qBAAqB,CAAA;AACvC,EAAA,OAAO,QAAA;AACT;;;ACfO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EACnD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EACd;AACF;AASA,eAAsB,WAAA,GAAc;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,UAAA,EAAW,GAAI,MAAM,OAAO,oBAA4B,CAAA;AAChE,IAAA,OAAO,IAAI,UAAA,CAAW,EAAE,YAAA,EAAc,kBAAA,IAAsB,CAAA;AAAA,EAC9D,SAAS,GAAA,EAAK;AACZ,IAAA,MAAA,CAAO,CAAA,2BAAA,EAA8B,eAAe,KAAA,GAAQ,GAAA,CAAI,UAAU,MAAA,CAAO,GAAG,CAAC,CAAA,CAAE,CAAA;AACvF,IAAA,OAAA,CAAQ,KAAK,C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AA,OAAA,CAAQ,KAAA,EAAM;AACd,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,OAAA,CAAQ,SAAA,GAAY,GAAA;AAC3C,EAAA,MAAM,SACJ,GAAA,CAAI,OAAA,CAAQ,OAAA,KAAY,MAAA,GACpB,IAAI,iBAAA,CAAkB,EAAE,OAAA,EAAS,UAAA,EAAY,CAAA,GAC7C,IAAI,oBAAoB,EAAE,OAAA,EAAS,YAAY,CAAA;AACrD,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,MAAM;AAAA,EAAC,CAAA,EAAE;AACnC;AASA,eAAsB,kBAAA,GAInB;AACD,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,oBAA4B,CAAA;AACpE,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,EAAY;AAClC,EAAA,MAAM,OAAA,GAAU,IAAI,cAAA,CAAe,OAAO,CAAA;AAC1C,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAC1D","file":"chunk-MS2JK4V7.js","sourcesContent":["/**\n * open-registry.ts — shared helper to create a full AssetKindRegistry.\n *\n * Bootstraps the registry with all built-in providers (9 core + preset)\n * from @skaile/discovery, plus the extension kind providers (flow from\n * @skaile/workspaces/factory-assets/connectors/flow/engine, knowledge from @skaile/library).\n *\n * This is the single registration point for the CLI. All code paths\n * that need a registry (source sync, lib-status, etc.) should use this.\n */\n\nimport type { AssetKindRegistry } from \"@skaile/workspaces/discovery\";\nimport { createDefaultRegistry } from \"@skaile/workspaces/discovery\";\nimport { flowKindProvider } from \"@skaile/workspaces/factory-assets/connectors/flow/engine\";\nimport { knowledgeKindProvider } from \"@skaile/workspaces/library\";\n\n/**\n * Create a fully-configured AssetKindRegistry with all known providers.\n *\n * Registers:\n * - 9 core kinds (skill, agent, connector, mount, mcp-server, contract, prompt, persona, ruleset)\n * - preset (composition entity)\n * - flow (extension, from @skaile/workspaces/factory-assets/connectors/flow/engine)\n * - knowledge (extension, from @skaile/library)\n *\n * @returns An unfrozen registry (auto-freezes on first read)\n */\nexport function createFullRegistry(): AssetKindRegistry {\n const registry = createDefaultRegistry();\n registry.register(flowKindProvider);\n registry.register(knowledgeKindProvider);\n return registry;\n}\n","/**\n * open-library.ts — shared helpers to open the LocalIndex and the configured\n * Catalog source.\n *\n * Lazy-loads the `@skaile/workspaces/library` subpath and returns the\n * LocalIndex instance (backed by `@libsql/client`; runs on Node and Bun).\n * The catalog-source helper reads\n * `~/.skaile/config.yaml` (and project-level overlay if `projectDir` is given)\n * to decide between {@link RemoteCatalogSource} (default — points at\n * `https://skaile.store`) and a {@link LocalCatalogSource} bound to the most\n * recent local library registered via `skaile source add`.\n */\n\nimport { logErr } from \"./helpers.ts\";\nimport { createFullRegistry } from \"./open-registry.ts\";\n\n/** Thrown by {@link openCatalogSource} when `catalog.url` is the `local` sentinel. */\nexport class LocalCatalogDisabledError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LocalCatalogDisabledError\";\n }\n}\n\n/**\n * Open the LocalIndex with the full kind registry. Exits with code 1\n * if the library directory cannot be created.\n *\n * @returns A `LocalIndex` instance ready for use.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibrary() {\n try {\n const { LocalIndex } = await import(\"@skaile/workspaces/library\");\n return new LocalIndex({ kindRegistry: createFullRegistry() });\n } catch (err) {\n logErr(`Could not open LocalIndex: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Resolve the configured **remote** Catalog source for the CLI.\n *\n * Reads `~/.skaile/config.yaml` (plus the optional project-level overlay) and\n * returns a {@link RemoteCatalogSource} pointing at `catalog.url` (default:\n * `https://skaile.store`). The `cache_ttl: 0` config flag flips the source\n * into air-gapped mode: network reads are disabled, only `skaile update`\n * performs refreshes.\n *\n * **Local-mode rejection.** If the resolved config has `catalog.url: local`\n * this helper throws — callers wanting the dispatched local-or-remote source\n * must use {@link resolveCatalogSource}. Remote-only consumers like\n * `skaile update --catalog-only` rely on this strict behaviour.\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A configured {@link RemoteCatalogSource}.\n * @throws When `catalog.url` is the `local` sentinel.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<\n | import(\"@skaile/workspaces/library\").RemoteCatalogSource\n | import(\"@skaile/workspaces/library\").RestCatalogSource\n> {\n const { resolveConfig, RemoteCatalogSource, RestCatalogSource, isLocalCatalogUrl } = await import(\n \"@skaile/workspaces/library\"\n );\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n if (isLocalCatalogUrl(baseUrl)) {\n throw new LocalCatalogDisabledError(\n \"catalog.url is set to 'local' — remote catalog is disabled. \" +\n \"Use `skaile source add <path>` + `skaile source sync` for local sources, \" +\n \"or set `catalog.url: https://skaile.store` in ~/.skaile/config.yaml.\",\n );\n }\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n if (cfg.catalog.framing === \"rest\") {\n return new RestCatalogSource({ baseUrl, cacheTtlMs });\n }\n return new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n}\n\n/**\n * Resolved catalog source plus a close handle for releasing any underlying\n * resources (e.g. the `LocalIndex` SQLite connection in local mode).\n *\n * Callers MUST invoke `close()` when done — typically in a `finally` block.\n * For remote-mode sources `close()` is a no-op, but the contract is uniform\n * so consumers don't have to branch.\n *\n * @docLink cli/dev-guide#open-library\n */\nexport interface ResolvedCatalogSource {\n /** The {@link ICatalogSource} ready for use. */\n source: import(\"@skaile/workspaces/library\").ICatalogSource;\n /** Release any underlying resources (SQLite handle in local mode). */\n close(): void;\n}\n\n/**\n * Resolve the configured Catalog source — local or remote — based on\n * `~/.skaile/config.yaml`.\n *\n * Dispatch:\n * - `catalog.url: local` → opens {@link LocalIndex}, picks the most recently\n * registered local library whose `path` still exists on disk, and returns a\n * {@link LocalCatalogSource} bound to that library. Throws if no usable\n * local library is registered.\n * - any URL → returns {@link RemoteCatalogSource} (same as\n * {@link openCatalogSource}).\n *\n * The returned `close()` releases the underlying `LocalIndex` SQLite handle\n * in local mode (no-op in remote mode). Callers MUST invoke it — typically in\n * a `finally` block — to satisfy `library/CLAUDE.md` § \"Notes for Consumers\".\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A `ResolvedCatalogSource` carrying the source and a close handle.\n * @throws When `local` is configured but no usable local library is registered.\n * @docLink cli/dev-guide#open-library\n */\nexport async function resolveCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<ResolvedCatalogSource> {\n const {\n resolveConfig,\n RemoteCatalogSource,\n RestCatalogSource,\n LocalCatalogSource,\n isLocalCatalogUrl,\n } = await import(\"@skaile/workspaces/library\");\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n\n if (isLocalCatalogUrl(baseUrl)) {\n const fs = await import(\"node:fs\");\n const library = await openLibrary();\n try {\n const sources = await library.listSources();\n type LibraryRow = (typeof sources)[number];\n // Type-narrow: `path` is required for local libraries after the filter.\n const usable = sources\n .filter(\n (s): s is LibraryRow & { path: string } =>\n s.backend === \"local\" && typeof s.path === \"string\" && s.path.length > 0,\n )\n .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());\n\n if (usable.length === 0) {\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile source add <path>` first, then `skaile source sync`.\",\n );\n }\n\n // Prefer the most recently added library whose path still exists.\n const present = usable.find((s) => fs.existsSync(s.path));\n if (!present) {\n const head = usable[0];\n throw new Error(\n `catalog.url is set to 'local' but every registered local library has a missing path on disk. ` +\n `Most recent: ${head.path} (library ${head.id}). ` +\n `Re-register with \\`skaile source add <existing-path>\\` or run \\`skaile source list\\` to inspect.`,\n );\n }\n\n const source = new LocalCatalogSource(\n library,\n present.id,\n present.path,\n createFullRegistry(),\n );\n return { source, close: () => library.close() };\n } catch (err) {\n // Release the handle on any failure during dispatch — otherwise the\n // SQLite WAL state leaks for the lifetime of the process.\n library.close();\n throw err;\n }\n }\n\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n const source =\n cfg.catalog.framing === \"rest\"\n ? new RestCatalogSource({ baseUrl, cacheTtlMs })\n : new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n return { source, close: () => {} };\n}\n\n/**\n * Open the LibraryManager bound to the active LocalIndex.\n * Caller owns lifetime — must call `close()` (returned helper closes the\n * underlying LocalIndex).\n *\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibraryManager(): Promise<{\n manager: import(\"@skaile/workspaces/library\").LibraryManager;\n library: import(\"@skaile/workspaces/library\").LocalIndex;\n close: () => void;\n}> {\n const { LibraryManager } = await import(\"@skaile/workspaces/library\");\n const library = await openLibrary();\n const manager = new LibraryManager(library);\n return { manager, library, close: () => library.close() };\n}\n"]}
|
|
@@ -366,6 +366,8 @@ var AgentStore = class _AgentStore {
|
|
|
366
366
|
_unnamedEchoesOwed = 0;
|
|
367
367
|
_error = null;
|
|
368
368
|
_isAllLoaded;
|
|
369
|
+
/** Prompts a cancel dropped before they ran; new Set on every change. */
|
|
370
|
+
_notSentPromptIds = /* @__PURE__ */ new Set();
|
|
369
371
|
_seq;
|
|
370
372
|
_streamingFlushed = true;
|
|
371
373
|
/** Shared state per store namespace — new Map instance on every mutation. */
|
|
@@ -426,6 +428,18 @@ var AgentStore = class _AgentStore {
|
|
|
426
428
|
get isAllLoaded() {
|
|
427
429
|
return this._isAllLoaded;
|
|
428
430
|
}
|
|
431
|
+
/** `messageId`s of prompts a cancel dropped before they ran. */
|
|
432
|
+
get notSentPromptIds() {
|
|
433
|
+
return this._notSentPromptIds;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Whether `message` is a prompt a cancel dropped before it ran, so the UI
|
|
437
|
+
* shows it as "Not sent". Matches on the prompt payload's `messageId`.
|
|
438
|
+
*/
|
|
439
|
+
isPromptNotSent(message) {
|
|
440
|
+
const payload = message.payload;
|
|
441
|
+
return payload.type === "prompt" && typeof payload.messageId === "string" && this._notSentPromptIds.has(payload.messageId);
|
|
442
|
+
}
|
|
429
443
|
// -- Commands --------------------------------------------------------------
|
|
430
444
|
/**
|
|
431
445
|
* Send a user prompt to the agent and optimistically update local state.
|
|
@@ -442,8 +456,16 @@ var AgentStore = class _AgentStore {
|
|
|
442
456
|
this._streamingFlushed = false;
|
|
443
457
|
this._setOpenQuestions([]);
|
|
444
458
|
this._phase = "thinking";
|
|
445
|
-
|
|
446
|
-
|
|
459
|
+
const userId = this._options.userId;
|
|
460
|
+
if (userId) {
|
|
461
|
+
const id = crypto.randomUUID();
|
|
462
|
+
const command = { type: "prompt", prompt: text, messageId: id, senderId: userId };
|
|
463
|
+
this._appendMessage(command, "user", id);
|
|
464
|
+
this._options.send(command);
|
|
465
|
+
} else {
|
|
466
|
+
this._appendMessage({ type: "prompt", prompt: text }, "user");
|
|
467
|
+
this._options.send({ type: "prompt", prompt: text });
|
|
468
|
+
}
|
|
447
469
|
this._notify();
|
|
448
470
|
}
|
|
449
471
|
/**
|
|
@@ -498,7 +520,8 @@ var AgentStore = class _AgentStore {
|
|
|
498
520
|
this._streamingText = "";
|
|
499
521
|
this._streamingFlushed = true;
|
|
500
522
|
this._phase = "cancelling";
|
|
501
|
-
this._options.
|
|
523
|
+
const userId = this._options.userId;
|
|
524
|
+
this._options.send(userId ? { type: "cancel", senderId: userId } : { type: "cancel" });
|
|
502
525
|
this._notify();
|
|
503
526
|
}
|
|
504
527
|
/**
|
|
@@ -596,6 +619,7 @@ var AgentStore = class _AgentStore {
|
|
|
596
619
|
pendingQuestion: this._pendingQuestion,
|
|
597
620
|
error: this._error,
|
|
598
621
|
isAllLoaded: this._isAllLoaded,
|
|
622
|
+
notSentPromptIds: this._notSentPromptIds,
|
|
599
623
|
sharedState: this._sharedState,
|
|
600
624
|
capabilities: this._capabilities,
|
|
601
625
|
activeRenderInvocations: this._activeRenderInvocations,
|
|
@@ -772,6 +796,12 @@ var AgentStore = class _AgentStore {
|
|
|
772
796
|
this._incompatibleProtocol = null;
|
|
773
797
|
break;
|
|
774
798
|
}
|
|
799
|
+
case "queued_prompts_dropped": {
|
|
800
|
+
const fresh = event.messageIds.filter((id) => !this._notSentPromptIds.has(id));
|
|
801
|
+
if (fresh.length === 0) return;
|
|
802
|
+
this._notSentPromptIds = /* @__PURE__ */ new Set([...this._notSentPromptIds, ...fresh]);
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
775
805
|
case "incompatible_protocol":
|
|
776
806
|
this._incompatibleProtocol = event;
|
|
777
807
|
break;
|
|
@@ -798,12 +828,12 @@ var AgentStore = class _AgentStore {
|
|
|
798
828
|
this._streamingFlushed = true;
|
|
799
829
|
return true;
|
|
800
830
|
}
|
|
801
|
-
_appendMessage(payload, senderId) {
|
|
831
|
+
_appendMessage(payload, senderId, id = crypto.randomUUID()) {
|
|
802
832
|
this._seq++;
|
|
803
833
|
this._messages = [
|
|
804
834
|
...this._messages,
|
|
805
835
|
{
|
|
806
|
-
id
|
|
836
|
+
id,
|
|
807
837
|
seq: this._seq,
|
|
808
838
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
809
839
|
sessionId: this._options.sessionId,
|
|
@@ -821,5 +851,5 @@ var AgentStore = class _AgentStore {
|
|
|
821
851
|
};
|
|
822
852
|
|
|
823
853
|
export { AgentStore, ResourceClient, ResourceRequestError };
|
|
824
|
-
//# sourceMappingURL=chunk-
|
|
825
|
-
//# sourceMappingURL=chunk-
|
|
854
|
+
//# sourceMappingURL=chunk-OKGUDNDT.js.map
|
|
855
|
+
//# sourceMappingURL=chunk-OKGUDNDT.js.map
|