@skaile/workspaces 6.16.0 → 6.17.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 +18 -0
- package/dist/{agent-file-refresh-76NNFB4W.js → agent-file-refresh-RZWE25KN.js} +33 -33
- package/dist/{agent-file-refresh-76NNFB4W.js.map → agent-file-refresh-RZWE25KN.js.map} +1 -1
- package/dist/ai-sdk.js +4 -4
- package/dist/{asset-feeds-ON7FYHHF.js → asset-feeds-W4A2UFNX.js} +16 -16
- package/dist/{asset-feeds-ON7FYHHF.js.map → asset-feeds-W4A2UFNX.js.map} +1 -1
- package/dist/asset-manager/catalog-deployer.js +3 -3
- package/dist/asset-manager/history.js +3 -3
- package/dist/asset-manager/index.js +8 -8
- package/dist/asset-manager/installer.js +7 -7
- package/dist/asset-manager/renderers.js +4 -4
- package/dist/bridge/harnesses/claude-sdk.js +7 -7
- package/dist/bridge/harnesses/codex.js +7 -7
- package/dist/bridge/harnesses/continue.js +8 -8
- package/dist/bridge/harnesses/echo.js +3 -3
- package/dist/bridge/harnesses/gemini.js +6 -6
- package/dist/bridge/harnesses/goose.js +8 -8
- package/dist/bridge/harnesses/omp.js +5 -5
- package/dist/bridge/harnesses/opencode.js +9 -9
- package/dist/bridge/harnesses/qwen.js +6 -6
- package/dist/bridge/index.js +13 -13
- package/dist/{chunk-BTMSHGN3.js → chunk-2QNDAGYL.js} +4 -4
- package/dist/{chunk-BTMSHGN3.js.map → chunk-2QNDAGYL.js.map} +1 -1
- package/dist/{chunk-2ZDZJ7XQ.js → chunk-3O3HWR23.js} +3 -3
- package/dist/{chunk-2ZDZJ7XQ.js.map → chunk-3O3HWR23.js.map} +1 -1
- package/dist/{chunk-G5SUWZEU.js → chunk-3ZY6W7CL.js} +4 -3
- package/dist/chunk-3ZY6W7CL.js.map +1 -0
- package/dist/{chunk-2JUCWMIS.js → chunk-4BVE6JTM.js} +9 -9
- package/dist/{chunk-2JUCWMIS.js.map → chunk-4BVE6JTM.js.map} +1 -1
- package/dist/{chunk-Z23I2JA6.js → chunk-4CVRFWEY.js} +5 -5
- package/dist/{chunk-Z23I2JA6.js.map → chunk-4CVRFWEY.js.map} +1 -1
- package/dist/{chunk-PPSSDUN6.js → chunk-4YVQGPZ5.js} +3 -3
- package/dist/{chunk-PPSSDUN6.js.map → chunk-4YVQGPZ5.js.map} +1 -1
- package/dist/{chunk-ETGC2MEM.js → chunk-52HUF3DF.js} +3 -3
- package/dist/{chunk-ETGC2MEM.js.map → chunk-52HUF3DF.js.map} +1 -1
- package/dist/{chunk-Z7HLX4V2.js → chunk-57B4DG3Y.js} +4 -4
- package/dist/{chunk-Z7HLX4V2.js.map → chunk-57B4DG3Y.js.map} +1 -1
- package/dist/{chunk-WW22FS74.js → chunk-5L3UCHBK.js} +9 -9
- package/dist/{chunk-WW22FS74.js.map → chunk-5L3UCHBK.js.map} +1 -1
- package/dist/{chunk-72DYHOO2.js → chunk-6CTRJADR.js} +5 -5
- package/dist/{chunk-72DYHOO2.js.map → chunk-6CTRJADR.js.map} +1 -1
- package/dist/{chunk-3LAJJURV.js → chunk-6O7KIJUW.js} +5 -5
- package/dist/{chunk-3LAJJURV.js.map → chunk-6O7KIJUW.js.map} +1 -1
- package/dist/{chunk-EGKCKWWE.js → chunk-6PWQJMHM.js} +3 -3
- package/dist/{chunk-EGKCKWWE.js.map → chunk-6PWQJMHM.js.map} +1 -1
- package/dist/{chunk-7IW5E6LB.js → chunk-7D46CRUU.js} +12 -12
- package/dist/{chunk-7IW5E6LB.js.map → chunk-7D46CRUU.js.map} +1 -1
- package/dist/{chunk-IG4YQ7ER.js → chunk-7IKAKXMZ.js} +3 -3
- package/dist/{chunk-IG4YQ7ER.js.map → chunk-7IKAKXMZ.js.map} +1 -1
- package/dist/{chunk-4ZNKEDYH.js → chunk-AS4SKSXJ.js} +5 -5
- package/dist/{chunk-4ZNKEDYH.js.map → chunk-AS4SKSXJ.js.map} +1 -1
- package/dist/{chunk-6KV34G6A.js → chunk-AVB7NLO6.js} +6 -6
- package/dist/{chunk-6KV34G6A.js.map → chunk-AVB7NLO6.js.map} +1 -1
- package/dist/{chunk-MG6QD7GE.js → chunk-DG7OEBLI.js} +6 -6
- package/dist/{chunk-MG6QD7GE.js.map → chunk-DG7OEBLI.js.map} +1 -1
- package/dist/{chunk-4X5WXQV7.js → chunk-DTIR5W6G.js} +3 -3
- package/dist/{chunk-4X5WXQV7.js.map → chunk-DTIR5W6G.js.map} +1 -1
- package/dist/{chunk-PRB67LCK.js → chunk-E2VPBB7C.js} +11 -11
- package/dist/{chunk-PRB67LCK.js.map → chunk-E2VPBB7C.js.map} +1 -1
- package/dist/{chunk-NAQXDTF3.js → chunk-EFCRBVHL.js} +3 -3
- package/dist/{chunk-NAQXDTF3.js.map → chunk-EFCRBVHL.js.map} +1 -1
- package/dist/{chunk-ZII54C3E.js → chunk-F6EPGAES.js} +122 -50
- package/dist/chunk-F6EPGAES.js.map +1 -0
- package/dist/{chunk-VFEZUSB6.js → chunk-FURORBXE.js} +4 -4
- package/dist/{chunk-VFEZUSB6.js.map → chunk-FURORBXE.js.map} +1 -1
- package/dist/{chunk-BRAOB37W.js → chunk-GXW4B5SE.js} +51 -17
- package/dist/chunk-GXW4B5SE.js.map +1 -0
- package/dist/{chunk-SX54OQQT.js → chunk-HTQLI3OI.js} +4 -4
- package/dist/{chunk-SX54OQQT.js.map → chunk-HTQLI3OI.js.map} +1 -1
- package/dist/{chunk-TYK752MU.js → chunk-HZU5JW2F.js} +3 -3
- package/dist/{chunk-TYK752MU.js.map → chunk-HZU5JW2F.js.map} +1 -1
- package/dist/{chunk-NJ6UCY2B.js → chunk-I46MAK4H.js} +3 -3
- package/dist/{chunk-NJ6UCY2B.js.map → chunk-I46MAK4H.js.map} +1 -1
- package/dist/{chunk-PD42JZWI.js → chunk-K7IV5FY4.js} +2 -2
- package/dist/{chunk-PD42JZWI.js.map → chunk-K7IV5FY4.js.map} +1 -1
- package/dist/{chunk-2SSG5B24.js → chunk-KNOABDPY.js} +4 -4
- package/dist/{chunk-2SSG5B24.js.map → chunk-KNOABDPY.js.map} +1 -1
- package/dist/{chunk-P6FJDT35.js → chunk-LZ6C4YMX.js} +3 -3
- package/dist/{chunk-P6FJDT35.js.map → chunk-LZ6C4YMX.js.map} +1 -1
- package/dist/{chunk-TW5AP6IF.js → chunk-MZEZCRSO.js} +5 -5
- package/dist/{chunk-TW5AP6IF.js.map → chunk-MZEZCRSO.js.map} +1 -1
- package/dist/{chunk-3UYKT62L.js → chunk-N2XZSIJW.js} +244 -19
- package/dist/chunk-N2XZSIJW.js.map +1 -0
- package/dist/{chunk-65SOXO7I.js → chunk-NZAUPFIM.js} +11 -11
- package/dist/{chunk-65SOXO7I.js.map → chunk-NZAUPFIM.js.map} +1 -1
- package/dist/{chunk-OD4N5O7V.js → chunk-OLGQHP4R.js} +3 -3
- package/dist/{chunk-OD4N5O7V.js.map → chunk-OLGQHP4R.js.map} +1 -1
- package/dist/{chunk-RPRMD7XV.js → chunk-OMV4ROIO.js} +4 -4
- package/dist/{chunk-RPRMD7XV.js.map → chunk-OMV4ROIO.js.map} +1 -1
- package/dist/{chunk-H3PY5DFL.js → chunk-PC54LSZP.js} +3 -3
- package/dist/{chunk-H3PY5DFL.js.map → chunk-PC54LSZP.js.map} +1 -1
- package/dist/{chunk-U2WPJHRA.js → chunk-QZS7E3DY.js} +4 -4
- package/dist/{chunk-U2WPJHRA.js.map → chunk-QZS7E3DY.js.map} +1 -1
- package/dist/{chunk-S3UOZBGE.js → chunk-SOAQP4BI.js} +3 -3
- package/dist/{chunk-S3UOZBGE.js.map → chunk-SOAQP4BI.js.map} +1 -1
- package/dist/{chunk-FPG36VC4.js → chunk-UIAGUME5.js} +6 -6
- package/dist/{chunk-FPG36VC4.js.map → chunk-UIAGUME5.js.map} +1 -1
- package/dist/{chunk-NNJQQYHY.js → chunk-URN4G32O.js} +2 -2
- package/dist/{chunk-NNJQQYHY.js.map → chunk-URN4G32O.js.map} +1 -1
- package/dist/{chunk-CU5WY6HN.js → chunk-VAO3XYN3.js} +3 -3
- package/dist/{chunk-CU5WY6HN.js.map → chunk-VAO3XYN3.js.map} +1 -1
- package/dist/{chunk-QUIK7L3Z.js → chunk-WNT54WWX.js} +9 -9
- package/dist/{chunk-QUIK7L3Z.js.map → chunk-WNT54WWX.js.map} +1 -1
- package/dist/{chunk-T65N4CIZ.js → chunk-XHWBSC53.js} +4 -4
- package/dist/{chunk-T65N4CIZ.js.map → chunk-XHWBSC53.js.map} +1 -1
- package/dist/{chunk-KDRA6FYE.js → chunk-YKN5S7PO.js} +9 -9
- package/dist/{chunk-KDRA6FYE.js.map → chunk-YKN5S7PO.js.map} +1 -1
- package/dist/{chunk-TVRL3IPZ.js → chunk-ZEUBZV7L.js} +3 -3
- package/dist/{chunk-TVRL3IPZ.js.map → chunk-ZEUBZV7L.js.map} +1 -1
- package/dist/{chunk-U7P22GEB.js → chunk-ZHI3YMGQ.js} +4 -4
- package/dist/{chunk-U7P22GEB.js.map → chunk-ZHI3YMGQ.js.map} +1 -1
- package/dist/{chunk-6M44OQKH.js → chunk-ZKLXJV37.js} +9 -9
- package/dist/{chunk-6M44OQKH.js.map → chunk-ZKLXJV37.js.map} +1 -1
- package/dist/{claude-code-VL6UM7BZ.js → claude-code-K3QSXJ35.js} +4 -4
- package/dist/{claude-code-VL6UM7BZ.js.map → claude-code-K3QSXJ35.js.map} +1 -1
- package/dist/cli/index.js +115 -90
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/commands/plugin-registry-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/serve-preflight.d.ts +38 -0
- package/dist/cli/src/commands/serve-preflight.d.ts.map +1 -1
- package/dist/cli/src/commands/serve.d.ts +7 -6
- package/dist/cli/src/commands/serve.d.ts.map +1 -1
- package/dist/connectors/config.js +2 -2
- package/dist/connectors/index.js +16 -16
- package/dist/{connectors-7EPJRVLJ.js → connectors-SBV254SC.js} +19 -19
- package/dist/{connectors-7EPJRVLJ.js.map → connectors-SBV254SC.js.map} +1 -1
- package/dist/core/index.js +3 -3
- package/dist/core/runtime-assets.js +2 -2
- package/dist/core/src/model-endpoint-config.d.ts +12 -0
- package/dist/core/src/model-endpoint-config.d.ts.map +1 -0
- package/dist/core/src/workspace-config.d.ts +6 -0
- package/dist/core/src/workspace-config.d.ts.map +1 -1
- package/dist/core/workspace-config.js +1 -1
- package/dist/deploy/index.js +4 -4
- package/dist/{ensure-sources-CI3JQJST.js → ensure-sources-URRZB56T.js} +22 -22
- package/dist/{ensure-sources-CI3JQJST.js.map → ensure-sources-URRZB56T.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +16 -16
- package/dist/factory-assets/connectors/deploy.js +16 -16
- package/dist/factory-assets/connectors/devserver.js +16 -16
- package/dist/factory-assets/connectors/flow/adapter.js +16 -16
- package/dist/factory-assets/connectors/flow/contract/schema.d.ts +2 -2
- package/dist/factory-assets/connectors/flow/engine.js +4 -4
- package/dist/factory-assets/connectors/flow/run-flow.js +17 -17
- package/dist/factory-assets/connectors/flow.js +16 -16
- package/dist/factory-assets/connectors/git.js +16 -16
- package/dist/factory-assets/connectors/gmail.js +16 -16
- package/dist/factory-assets/connectors/googledrive.js +16 -16
- package/dist/factory-assets/connectors/local.js +16 -16
- package/dist/factory-assets/connectors/mattermost.js +16 -16
- package/dist/factory-assets/connectors/memory.js +16 -16
- package/dist/factory-assets/connectors/minio.js +16 -16
- package/dist/factory-assets/connectors/postgres.js +16 -16
- package/dist/factory-assets/connectors/s3.js +16 -16
- package/dist/factory-assets/connectors/sharepoint.js +16 -16
- package/dist/factory-assets/connectors/sqlite.js +16 -16
- package/dist/factory-assets/connectors/static-server.js +16 -16
- package/dist/factory-assets/connectors/tunnel.js +16 -16
- package/dist/factory-assets/connectors/webdav.js +16 -16
- package/dist/factory-assets/connectors/xstate-store.js +16 -16
- package/dist/factory-assets/connectors/xstate.js +16 -16
- package/dist/{flows-6XQAYQS4.js → flows-YGBWX46B.js} +6 -6
- package/dist/{flows-6XQAYQS4.js.map → flows-YGBWX46B.js.map} +1 -1
- package/dist/{helpers-26MR5QPO.js → helpers-5FFJORMD.js} +22 -22
- package/dist/{helpers-26MR5QPO.js.map → helpers-5FFJORMD.js.map} +1 -1
- package/dist/library/index.js +4 -4
- package/dist/{library-publish-F3AKF66O.js → library-publish-AW4525ZC.js} +39 -39
- package/dist/{library-publish-F3AKF66O.js.map → library-publish-AW4525ZC.js.map} +1 -1
- package/dist/model-endpoint/index.js +7 -7
- package/dist/model-endpoint/src/server.d.ts.map +1 -1
- package/dist/model-endpoint/src/transform.d.ts +49 -0
- package/dist/model-endpoint/src/transform.d.ts.map +1 -0
- package/dist/model-endpoint/src/types.d.ts +13 -0
- package/dist/model-endpoint/src/types.d.ts.map +1 -1
- package/dist/{open-library-FVV6GG4I.js → open-library-C254HCNL.js} +25 -25
- package/dist/{open-library-FVV6GG4I.js.map → open-library-C254HCNL.js.map} +1 -1
- package/dist/{open-registry-VX2BVMS5.js → open-registry-FI6EO2PN.js} +8 -8
- package/dist/{open-registry-VX2BVMS5.js.map → open-registry-FI6EO2PN.js.map} +1 -1
- package/dist/{paths-PIWSSUUG.js → paths-FYPFJ437.js} +6 -6
- package/dist/{paths-PIWSSUUG.js.map → paths-FYPFJ437.js.map} +1 -1
- package/dist/plugin-registry/index.js +1 -1
- package/dist/plugin-registry/src/context.d.ts +6 -0
- package/dist/plugin-registry/src/context.d.ts.map +1 -1
- package/dist/plugin-registry/src/index.d.ts +4 -3
- package/dist/plugin-registry/src/index.d.ts.map +1 -1
- package/dist/plugin-registry/src/internal.d.ts.map +1 -1
- package/dist/plugin-registry/src/model-transform.d.ts +15 -0
- package/dist/plugin-registry/src/model-transform.d.ts.map +1 -0
- package/dist/plugin-registry/src/registry.d.ts +5 -5
- package/dist/plugin-registry/src/registry.d.ts.map +1 -1
- package/dist/plugin-registry/src/targets.d.ts +17 -2
- package/dist/plugin-registry/src/targets.d.ts.map +1 -1
- package/dist/{plugin-store-MVTW6G7J.js → plugin-store-ITA3IADY.js} +7 -7
- package/dist/{plugin-store-MVTW6G7J.js.map → plugin-store-ITA3IADY.js.map} +1 -1
- package/dist/{project-GFQP4TW6.js → project-7XU7YX3Q.js} +35 -35
- package/dist/{project-GFQP4TW6.js.map → project-7XU7YX3Q.js.map} +1 -1
- package/dist/resolver/index.js +3 -3
- package/dist/runner/composition-content.js +5 -5
- package/dist/runner/index.js +26 -26
- package/dist/runner/src/external-mcp.d.ts +32 -7
- package/dist/runner/src/external-mcp.d.ts.map +1 -1
- package/dist/runner/src/model-endpoint-discovery.d.ts +18 -0
- package/dist/runner/src/model-endpoint-discovery.d.ts.map +1 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +8 -8
- package/dist/sdk/bridge.js +13 -13
- package/dist/sdk/core.js +3 -3
- package/dist/sdk/flow.js +4 -4
- package/dist/sdk/index.js +26 -26
- package/dist/sdk/resolver.js +3 -3
- package/dist/sdk/runner.js +26 -26
- package/dist/sdk/transport/ws/server.js +4 -4
- package/dist/sdk/transport/ws.js +4 -4
- package/dist/sdk/transport.js +4 -4
- package/dist/{serve-preflight-XJS5OZML.js → serve-preflight-A43HQQXD.js} +81 -25
- package/dist/serve-preflight-A43HQQXD.js.map +1 -0
- package/dist/{setup-BFEBJLYF.js → setup-WD7XTLDA.js} +23 -23
- package/dist/{setup-BFEBJLYF.js.map → setup-WD7XTLDA.js.map} +1 -1
- package/dist/{skills-OCG7B5CL.js → skills-XH6OG32W.js} +5 -5
- package/dist/{skills-OCG7B5CL.js.map → skills-XH6OG32W.js.map} +1 -1
- package/dist/{source-P6JPZYWP.js → source-25TTNBDK.js} +37 -37
- package/dist/{source-P6JPZYWP.js.map → source-25TTNBDK.js.map} +1 -1
- package/dist/{source-manifest-publish-XBFHEURV.js → source-manifest-publish-QJTPZQBN.js} +39 -39
- package/dist/{source-manifest-publish-XBFHEURV.js.map → source-manifest-publish-QJTPZQBN.js.map} +1 -1
- package/dist/transport/index.js +4 -4
- package/dist/transport/ws/server.js +4 -4
- package/dist/transport/ws.js +4 -4
- package/dist/tui/index.js +26 -26
- package/dist/workspace-plugin/adapters/mcp.js +19 -19
- package/dist/workspace-plugin/adapters/omp.js +14 -14
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3UYKT62L.js.map +0 -1
- package/dist/chunk-BRAOB37W.js.map +0 -1
- package/dist/chunk-G5SUWZEU.js.map +0 -1
- package/dist/chunk-ZII54C3E.js.map +0 -1
- package/dist/serve-preflight-XJS5OZML.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { mountList, mountSync, mountStatus, mountRead, connectorList, connectorRead, connectorWrite, connectorSearch, connectorExec, connectorLoadSkill, connectorDescribe } from './chunk-
|
|
2
|
-
import { flowList, flowShow, flowListSessions, flowGetSession, flowFindFlowForSession } from './chunk-
|
|
1
|
+
import { mountList, mountSync, mountStatus, mountRead, connectorList, connectorRead, connectorWrite, connectorSearch, connectorExec, connectorLoadSkill, connectorDescribe } from './chunk-ZEUBZV7L.js';
|
|
2
|
+
import { flowList, flowShow, flowListSessions, flowGetSession, flowFindFlowForSession } from './chunk-K7IV5FY4.js';
|
|
3
3
|
import { sessionList, sessionGet } from './chunk-WYZXSJBK.js';
|
|
4
4
|
import { skillList, skillShow, skillSearch, skillCheckRequirements, skillGetPreamble } from './chunk-SMFZ5YGN.js';
|
|
5
5
|
import { workspaceValidate, workspaceInfo, workspaceTestSecret, workspaceReload } from './chunk-KW37WNXY.js';
|
|
6
6
|
import { withActivityLabelDefs } from './chunk-JPV4WE5L.js';
|
|
7
|
-
import { loadHarnessSdk } from './chunk-
|
|
7
|
+
import { loadHarnessSdk } from './chunk-ZHI3YMGQ.js';
|
|
8
8
|
import { DEFAULT_HARNESS_ID } from './chunk-C5HFK34M.js';
|
|
9
9
|
import * as zNS from 'zod';
|
|
10
10
|
|
|
@@ -251,5 +251,5 @@ async function runMcpServerStdio(plugin) {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
export { buildWorkspaceMcpServer, buildWorkspaceMcpStdioServer, buildWorkspaceToolDefs, runMcpServerStdio };
|
|
254
|
-
//# sourceMappingURL=chunk-
|
|
255
|
-
//# sourceMappingURL=chunk-
|
|
254
|
+
//# sourceMappingURL=chunk-4CVRFWEY.js.map
|
|
255
|
+
//# sourceMappingURL=chunk-4CVRFWEY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../workspace-plugin/src/adapters/mcp.ts"],"names":["z"],"mappings":";;;;;;;;;;AA6CA,IAAM,OAAA,GAA4B,SAAkB,GAAA,CAAA,OAAA,IAAW,GAAA;AAiCxD,SAAS,uBAAuB,MAAA,EAA6C;AAClF,EAAA,MAAMA,EAAAA,GAAS,OAAA;AAEf,EAAA,MAAM,OAAA,GAAU,OAAO,OAAA,IAAW,kBAAA;AAClC,EAAA,MAAM,IAAI,MAAA,CAAO,UAAA;AAEjB,EAAA,OAAO;AAAA;AAAA,IAEL;AAAA,MACE,IAAA,EAAM,YAAA;AAAA,MACN,WAAA,EAAa,kEAAA;AAAA,MACb,aAAa,EAAC;AAAA,MACd,OAAA,EAAS,YAAY,SAAA,CAAU,MAAA,CAAO,gBAAgB;AAAA,KACxD;AAAA,IACA;AAAA,MACE,IAAA,EAAM,YAAA;AAAA,MACN,WAAA,EAAa,gEAAA;AAAA,MACb,WAAA,EAAa,EAAE,QAAA,EAAUA,EAAAA,CAAE,QAAO,CAAE,QAAA,CAAS,0BAA0B,CAAA,EAAE;AAAA,MACzE,OAAA,EAAS,OAAO,EAAE,QAAA,OAChB,SAAA,CAAU,MAAA,CAAO,kBAAkB,QAAQ;AAAA,KAC/C;AAAA,IACA;AAAA,MACE,IAAA,EAAM,cAAA;AAAA,MACN,WAAA,EAAa,sDAAA;AAAA,MACb,WAAA,EAAa,EAAE,QAAA,EAAUA,EAAAA,CAAE,QAAO,EAAE;AAAA,MACpC,OAAA,EAAS,OAAO,EA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F,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,MAAM,cAAA;AAAA,MACV,gCAAA;AAAA,MACA,MAAA,CAAO,UAAA;AAAA,MACP,MAAM,OAAO,gCAAgC;AAAA,KAC/C;AAAA,EACF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAI,kBAAA,CAAmB;AAAA,IAC5B,IAAA,EAAM,kBAAA;AAAA,IACN,KAAA,EAAO,qBAAA,CAAsB,sBAAA,CAAuB,MAAM,GAAG,OAAO;AAAA,GACrE,CAAA;AACH;AAgBA,eAAsB,6BAA6B,MAAA,EAAuC;AACxF,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,MAAM,OAAO,yCAAmD,CAAA;AACtF,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,CAAU,EAAE,MAAM,kBAAA,EAAoB,OAAA,EAAS,SAAS,CAAA;AAC3E,EAAA,KAAA,MAAW,GAAA,IAAO,sBAAA,CAAuB,MAAM,CAAA,EAAG;AAChD,IAAA,MAAA,CAAO,YAAA;AAAA,MACL,GAAA,CAAI,IAAA;AAAA,MACJ,EAAE,WAAA,EAAa,GAAA,CAAI,WAAA,EAAa,WAAA,EAAa,IAAI,WAAA,EAAY;AAAA,MAC7D,GAAA,CAAI;AAAA,KACN;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AAaA,eAAsB,kBAAkB,MAAA,EAAwC;AAC9E,EAAA,MAAM,MAAA,GAAS,MAAM,4BAAA,CAA6B,MAAM,CAAA;AACxD,EAAA,MAAM,EAAE,oBAAA,EAAqB,GAAI,MAAM,OACrC,2CACF,CAAA;AACA,EAAA,MAAM,MAAA,CAAO,OAAA,CAAQ,IAAI,oBAAA,EAAsB,CAAA;AACjD","file":"chunk-Z23I2JA6.js","sourcesContent":["// Static namespace import so bun --compile bundles zod into the binary.\n// Dynamic import(\"zod\") via a string variable evades bun's static analysis\n// and fails at runtime inside /$bunfs/. The unwrap (zNS.z ?? zNS.default\n// ?? zNS) handles both bun's native ESM and vitest's CJS-interop resolver,\n// which return the zod namespace at different keys.\nimport * as zNS from \"zod\";\nimport { loadHarnessSdk } from \"@skaile/workspaces/core\";\nimport { DEFAULT_HARNESS_ID } from \"@skaile/workspaces/core/framework\";\nimport { withActivityLabelDefs } from \"@skaile/workspaces/types\";\nimport type { WorkspacePlugin } from \"../plugin.js\";\nimport {\n connectorDescribe,\n connectorExec,\n connectorList,\n connectorLoadSkill,\n connectorRead,\n connectorSearch,\n connectorWrite,\n mountList,\n mountRead,\n mountStatus,\n mountSync,\n} from \"../tools/connectors.js\";\nimport {\n flowFindFlowForSession,\n flowGetSession,\n flowList,\n flowListSessions,\n flowShow,\n} from \"../tools/flows.js\";\nimport { sessionGet, sessionList } from \"../tools/sessions.js\";\nimport {\n skillCheckRequirements,\n skillGetPreamble,\n skillList,\n skillSearch,\n skillShow,\n} from \"../tools/skills.js\";\nimport {\n workspaceInfo,\n workspaceReload,\n workspaceTestSecret,\n workspaceValidate,\n} from \"../tools/validator.js\";\n\nconst zStatic: any = (zNS as any).z ?? (zNS as any).default ?? zNS;\n\n/**\n * One workspace plugin tool — name, description, a zod raw-shape input schema,\n * and an async handler returning a `ToolResult`.\n *\n * Carries **zero MCP/SDK dependency**: the same definitions feed both the\n * in-process Claude Agent SDK server ({@link buildWorkspaceMcpServer}) and the\n * raw stdio MCP server ({@link buildWorkspaceMcpStdioServer}).\n */\nexport interface WorkspaceToolDef {\n name: string;\n description: string;\n inputSchema: Record<string, unknown>;\n handler: (args: any) => Promise<unknown>;\n}\n\n/**\n * Build the 27 workspace plugin tool definitions.\n *\n * Tool groups:\n * - 4 mount tools (`mount_list`, `mount_sync`, `mount_status`, `mount_read`)\n * - 5 flow tools (`flow_list`, `flow_show`, `flow_list_sessions`, `flow_get_session`, `flow_find_flow_for_session`)\n * - 5 skill tools (`skill_list`, `skill_show`, `skill_search`, `skill_check_requirements`, `skill_get_preamble`)\n * - 2 session tools (`session_list`, `session_get`)\n * - 7 connector tools (`connector_list`, `connector_read`, `connector_write`, `connector_search`, `connector_exec`, `connector_load_skill`, `connector_describe`)\n * - 4 workspace tools (`workspace_validate`, `workspace_info`, `workspace_test_secret`, `workspace_reload`)\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n * @returns The 27 tool definitions, free of any MCP/SDK coupling.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport function buildWorkspaceToolDefs(plugin: WorkspacePlugin): WorkspaceToolDef[] {\n const z: any = zStatic;\n\n const harness = plugin.harness ?? DEFAULT_HARNESS_ID;\n const p = plugin.projectDir;\n\n return [\n // Mount tools\n {\n name: \"mount_list\",\n description: \"List all mounts declared in skaile.yaml with their mount status.\",\n inputSchema: {},\n handler: async () => mountList(plugin.connectorManager),\n },\n {\n name: \"mount_sync\",\n description: \"Sync a mount — pull latest from remote (git, S3, WebDAV).\",\n inputSchema: { mount_id: z.string().describe(\"Mount ID from mount_list\") },\n handler: async ({ mount_id }: { mount_id: string }) =>\n mountSync(plugin.connectorManager, mount_id),\n },\n {\n name: \"mount_status\",\n description: \"Get the mount status and last sync time for a mount.\",\n inputSchema: { mount_id: z.string() },\n handler: async ({ mount_id }: { mount_id: string }) =>\n mountStatus(plugin.connectorManager, mount_id),\n },\n {\n name: \"mount_read\",\n description: \"Read a file from a mounted mount by path.\",\n inputSchema: {\n mount_id: z.string(),\n path: z.string().describe(\"Relative path within the mount\"),\n },\n handler: async ({ mount_id, path }: { mount_id: string; path: string }) =>\n mountRead(plugin.connectorManager, mount_id, path),\n },\n // Flow tools\n {\n name: \"flow_list\",\n description: \"List all available flow definitions from ai-assets.\",\n inputSchema: {},\n handler: async () => flowList(p),\n },\n {\n name: \"flow_show\",\n description: \"Show full flow definition (nodes + edges) for a flow ID.\",\n inputSchema: { flow_id: z.string().describe(\"Flow ID from flow_list\") },\n handler: async ({ flow_id }: { flow_id: string }) => flowShow(p, flow_id),\n },\n {\n name: \"flow_list_sessions\",\n description: \"List past and active flow run sessions for this workspace.\",\n inputSchema: {},\n handler: async () => flowListSessions(p),\n },\n {\n name: \"flow_get_session\",\n description: \"Get harness metadata for a specific flow run session.\",\n inputSchema: { run_id: z.string().describe(\"Run ID from flow_list_sessions\") },\n handler: async ({ run_id }: { run_id: string }) => flowGetSession(p, run_id),\n },\n {\n name: \"flow_find_flow_for_session\",\n description: \"Resolve and return the flow definition used in a past session.\",\n inputSchema: { run_id: z.string() },\n handler: async ({ run_id }: { run_id: string }) => flowFindFlowForSession(p, run_id),\n },\n // Skill tools\n {\n name: \"skill_list\",\n description: \"List all skills in the ai-assets catalog.\",\n inputSchema: {},\n handler: async () => skillList(p),\n },\n {\n name: \"skill_show\",\n description: \"Show the full SKILL.md content for a skill ID.\",\n inputSchema: { skill_id: z.string().describe(\"Skill ID from skill_list\") },\n handler: async ({ skill_id }: { skill_id: string }) => skillShow(p, skill_id),\n },\n {\n name: \"skill_search\",\n description: \"Search skills by name, description, or keywords.\",\n inputSchema: { query: z.string() },\n handler: async ({ query }: { query: string }) => skillSearch(p, query),\n },\n {\n name: \"skill_check_requirements\",\n description: \"Validate that all skill prerequisites are met in the target directory.\",\n inputSchema: {\n skill_id: z.string(),\n target_dir: z\n .string()\n .optional()\n .describe(\"Directory to check against (default: projectDir)\"),\n },\n handler: async ({ skill_id, target_dir }: { skill_id: string; target_dir?: string }) =>\n skillCheckRequirements(p, skill_id, target_dir ?? p),\n },\n {\n name: \"skill_get_preamble\",\n description: \"Get the REQUIRES/INPUT/READS/WRITES DSL preamble for a skill.\",\n inputSchema: { skill_id: z.string() },\n handler: async ({ skill_id }: { skill_id: string }) => skillGetPreamble(p, skill_id),\n },\n // Session tools\n {\n name: \"session_list\",\n description: \"List all past agent run sessions for this workspace, sorted newest first.\",\n inputSchema: {},\n handler: async () => sessionList(p),\n },\n {\n name: \"session_get\",\n description: \"Get full metadata for a specific session by run ID.\",\n inputSchema: { run_id: z.string() },\n handler: async ({ run_id }: { run_id: string }) => sessionGet(p, run_id),\n },\n // Connector tools\n {\n name: \"connector_list\",\n description:\n \"List connectors declared in skaile.yaml as {connected, failed, notice?}. A host-managed mount in `connected` carries `health` {status: ok|stale|failed, errorClass, checkedAt}; if it is not ok, tell the user and do not write to it. `failed` holds connectors that did not connect this session, with the failure reason — their mount paths are dead directories, not synced workspaces.\",\n inputSchema: {},\n handler: async () => connectorList(plugin.connectorManager),\n },\n {\n name: \"connector_read\",\n description: \"Read content from a connector by path.\",\n inputSchema: {\n connector_id: z.string().describe(\"Connector ID from connector_list\"),\n path: z.string().describe(\"Path within the connector\"),\n },\n handler: async ({ connector_id, path }: { connector_id: string; path: string }) =>\n connectorRead(plugin.connectorManager, connector_id, path),\n },\n {\n name: \"connector_write\",\n description: \"Write content to a connector by path.\",\n inputSchema: {\n connector_id: z.string(),\n path: z.string(),\n content: z.string().describe(\"Content to write\"),\n },\n handler: async ({\n connector_id,\n path,\n content,\n }: {\n connector_id: string;\n path: string;\n content: string;\n }) => connectorWrite(plugin.connectorManager, connector_id, path, content),\n },\n {\n name: \"connector_search\",\n description: \"Search within a connector by query string.\",\n inputSchema: {\n connector_id: z.string(),\n query: z.string().describe(\"Search query\"),\n },\n handler: async ({ connector_id, query }: { connector_id: string; query: string }) =>\n connectorSearch(plugin.connectorManager, connector_id, query),\n },\n {\n name: \"connector_exec\",\n description: \"Execute a custom operation on a connector.\",\n inputSchema: {\n connector_id: z.string(),\n operation: z.string().describe(\"Operation name from connector_describe\"),\n args: z.record(z.string(), z.unknown()).describe(\"Operation arguments\"),\n },\n handler: async ({\n connector_id,\n operation,\n args,\n }: {\n connector_id: string;\n operation: string;\n args: Record<string, unknown>;\n }) => connectorExec(plugin.connectorManager, connector_id, operation, args),\n },\n {\n name: \"connector_load_skill\",\n description: \"Load the rendered skill body for a connector (operations + usage).\",\n inputSchema: {\n connector_id: z.string(),\n },\n handler: async ({ connector_id }: { connector_id: string }) =>\n connectorLoadSkill(plugin.connectorManager, connector_id),\n },\n {\n name: \"connector_describe\",\n description: \"Describe a connector's capabilities via its RuntimeSkillDescriptor.\",\n inputSchema: {\n connector_id: z.string(),\n },\n handler: async ({ connector_id }: { connector_id: string }) =>\n connectorDescribe(plugin.connectorManager, connector_id),\n },\n // Validator tools\n {\n name: \"workspace_validate\",\n description: \"Run a full health check: connectors, mounts, secrets, harness binary.\",\n inputSchema: {},\n handler: async () => workspaceValidate(plugin, harness),\n },\n {\n name: \"workspace_info\",\n description: \"Show workspace configuration: harness, model, provider, resource counts.\",\n inputSchema: {},\n handler: async () => workspaceInfo(plugin, harness, plugin.model),\n },\n {\n name: \"workspace_test_secret\",\n description: \"Test resolution of one secret reference (env:VAR, forge:key).\",\n inputSchema: { ref: z.string().describe(\"Secret ref e.g. env:ANTHROPIC_API_KEY\") },\n handler: async ({ ref }: { ref: string }) => workspaceTestSecret(ref),\n },\n {\n name: \"workspace_reload\",\n description: \"Re-read skaile.yaml and re-sync the plugin state.\",\n inputSchema: {},\n handler: async () => workspaceReload(plugin),\n },\n ];\n}\n\n/**\n * Build the **in-process** workspace MCP server via the Claude Agent SDK's\n * `createSdkMcpServer`. This shape is what the runner embeds into a Claude\n * Agent SDK `query()` call — the runner *is* the Claude Agent SDK host.\n *\n * Returns `null` when `@anthropic-ai/claude-agent-sdk` is not installed\n * (graceful degradation for non-Claude-Code environments).\n *\n * For the standalone `skaile mcp-server` stdio subprocess use\n * {@link buildWorkspaceMcpStdioServer} / {@link runMcpServerStdio} instead —\n * those carry no Claude Agent SDK dependency.\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n * @returns The SDK MCP server object or `null` if the SDK is unavailable.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport async function buildWorkspaceMcpServer(plugin: WorkspacePlugin): Promise<unknown | null> {\n let sdk: any;\n try {\n sdk = await loadHarnessSdk(\n \"@anthropic-ai/claude-agent-sdk\",\n plugin.projectDir,\n () => import(\"@anthropic-ai/claude-agent-sdk\"),\n );\n } catch {\n return null;\n }\n return sdk.createSdkMcpServer({\n name: \"skaile-workspace\",\n tools: withActivityLabelDefs(buildWorkspaceToolDefs(plugin), zStatic),\n });\n}\n\n/**\n * Build a **raw stdio** workspace MCP server on `@modelcontextprotocol/sdk` —\n * no Claude Agent SDK. This is the correct shape for the `skaile mcp-server`\n * stdio subprocess that MCP-client agents (Claude Code, Codex, …) spawn.\n * Runs on plain Node.\n *\n * The returned server is not yet connected — call `.connect(transport)` (or\n * use {@link runMcpServerStdio}).\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n * @returns A `McpServer` with all 27 workspace tools registered.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport async function buildWorkspaceMcpStdioServer(plugin: WorkspacePlugin): Promise<any> {\n const { McpServer } = await import(\"@modelcontextprotocol/sdk/server/mcp.js\" as string);\n const server = new McpServer({ name: \"skaile-workspace\", version: \"1.0.0\" });\n for (const def of buildWorkspaceToolDefs(plugin)) {\n server.registerTool(\n def.name,\n { description: def.description, inputSchema: def.inputSchema },\n def.handler,\n );\n }\n return server;\n}\n\n/**\n * Start the workspace MCP server over stdio transport.\n *\n * Builds the raw `@modelcontextprotocol/sdk` server via\n * {@link buildWorkspaceMcpStdioServer} and connects a `StdioServerTransport`.\n * No `@anthropic-ai/claude-agent-sdk` dependency anywhere on this path.\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport async function runMcpServerStdio(plugin: WorkspacePlugin): Promise<void> {\n const server = await buildWorkspaceMcpStdioServer(plugin);\n const { StdioServerTransport } = await import(\n \"@modelcontextprotocol/sdk/server/stdio.js\" as string\n );\n await server.connect(new StdioServerTransport());\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../workspace-plugin/src/adapters/mcp.ts"],"names":["z"],"mappings":";;;;;;;;;;AA6CA,IAAM,OAAA,GAA4B,SAAkB,GAAA,CAAA,OAAA,IAAW,GAAA;AAiCxD,SAAS,uBAAuB,MAAA,EAA6C;AACl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I,MAAM,OAAO,yCAAmD,CAAA;AACtF,EAAA,MAAM,MAAA,GAAS,IAAI,SAAA,CAAU,EAAE,MAAM,kBAAA,EAAoB,OAAA,EAAS,SAAS,CAAA;AAC3E,EAAA,KAAA,MAAW,GAAA,IAAO,sBAAA,CAAuB,MAAM,CAAA,EAAG;AAChD,IAAA,MAAA,CAAO,YAAA;AAAA,MACL,GAAA,CAAI,IAAA;AAAA,MACJ,EAAE,WAAA,EAAa,GAAA,CAAI,WAAA,EAAa,WAAA,EAAa,IAAI,WAAA,EAAY;AAAA,MAC7D,GAAA,CAAI;AAAA,KACN;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AAaA,eAAsB,kBAAkB,MAAA,EAAwC;AAC9E,EAAA,MAAM,MAAA,GAAS,MAAM,4BAAA,CAA6B,MAAM,CAAA;AACxD,EAAA,MAAM,EAAE,oBAAA,EAAqB,GAAI,MAAM,OACrC,2CACF,CAAA;AACA,EAAA,MAAM,MAAA,CAAO,OAAA,CAAQ,IAAI,oBAAA,EAAsB,CAAA;AACjD","file":"chunk-4CVRFWEY.js","sourcesContent":["// Static namespace import so bun --compile bundles zod into the binary.\n// Dynamic import(\"zod\") via a string variable evades bun's static analysis\n// and fails at runtime inside /$bunfs/. The unwrap (zNS.z ?? zNS.default\n// ?? zNS) handles both bun's native ESM and vitest's CJS-interop resolver,\n// which return the zod namespace at different keys.\nimport * as zNS from \"zod\";\nimport { loadHarnessSdk } from \"@skaile/workspaces/core\";\nimport { DEFAULT_HARNESS_ID } from \"@skaile/workspaces/core/framework\";\nimport { withActivityLabelDefs } from \"@skaile/workspaces/types\";\nimport type { WorkspacePlugin } from \"../plugin.js\";\nimport {\n connectorDescribe,\n connectorExec,\n connectorList,\n connectorLoadSkill,\n connectorRead,\n connectorSearch,\n connectorWrite,\n mountList,\n mountRead,\n mountStatus,\n mountSync,\n} from \"../tools/connectors.js\";\nimport {\n flowFindFlowForSession,\n flowGetSession,\n flowList,\n flowListSessions,\n flowShow,\n} from \"../tools/flows.js\";\nimport { sessionGet, sessionList } from \"../tools/sessions.js\";\nimport {\n skillCheckRequirements,\n skillGetPreamble,\n skillList,\n skillSearch,\n skillShow,\n} from \"../tools/skills.js\";\nimport {\n workspaceInfo,\n workspaceReload,\n workspaceTestSecret,\n workspaceValidate,\n} from \"../tools/validator.js\";\n\nconst zStatic: any = (zNS as any).z ?? (zNS as any).default ?? zNS;\n\n/**\n * One workspace plugin tool — name, description, a zod raw-shape input schema,\n * and an async handler returning a `ToolResult`.\n *\n * Carries **zero MCP/SDK dependency**: the same definitions feed both the\n * in-process Claude Agent SDK server ({@link buildWorkspaceMcpServer}) and the\n * raw stdio MCP server ({@link buildWorkspaceMcpStdioServer}).\n */\nexport interface WorkspaceToolDef {\n name: string;\n description: string;\n inputSchema: Record<string, unknown>;\n handler: (args: any) => Promise<unknown>;\n}\n\n/**\n * Build the 27 workspace plugin tool definitions.\n *\n * Tool groups:\n * - 4 mount tools (`mount_list`, `mount_sync`, `mount_status`, `mount_read`)\n * - 5 flow tools (`flow_list`, `flow_show`, `flow_list_sessions`, `flow_get_session`, `flow_find_flow_for_session`)\n * - 5 skill tools (`skill_list`, `skill_show`, `skill_search`, `skill_check_requirements`, `skill_get_preamble`)\n * - 2 session tools (`session_list`, `session_get`)\n * - 7 connector tools (`connector_list`, `connector_read`, `connector_write`, `connector_search`, `connector_exec`, `connector_load_skill`, `connector_describe`)\n * - 4 workspace tools (`workspace_validate`, `workspace_info`, `workspace_test_secret`, `workspace_reload`)\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n * @returns The 27 tool definitions, free of any MCP/SDK coupling.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport function buildWorkspaceToolDefs(plugin: WorkspacePlugin): WorkspaceToolDef[] {\n const z: any = zStatic;\n\n const harness = plugin.harness ?? DEFAULT_HARNESS_ID;\n const p = plugin.projectDir;\n\n return [\n // Mount tools\n {\n name: \"mount_list\",\n description: \"List all mounts declared in skaile.yaml with their mount status.\",\n inputSchema: {},\n handler: async () => mountList(plugin.connectorManager),\n },\n {\n name: \"mount_sync\",\n description: \"Sync a mount — pull latest from remote (git, S3, WebDAV).\",\n inputSchema: { mount_id: z.string().describe(\"Mount ID from mount_list\") },\n handler: async ({ mount_id }: { mount_id: string }) =>\n mountSync(plugin.connectorManager, mount_id),\n },\n {\n name: \"mount_status\",\n description: \"Get the mount status and last sync time for a mount.\",\n inputSchema: { mount_id: z.string() },\n handler: async ({ mount_id }: { mount_id: string }) =>\n mountStatus(plugin.connectorManager, mount_id),\n },\n {\n name: \"mount_read\",\n description: \"Read a file from a mounted mount by path.\",\n inputSchema: {\n mount_id: z.string(),\n path: z.string().describe(\"Relative path within the mount\"),\n },\n handler: async ({ mount_id, path }: { mount_id: string; path: string }) =>\n mountRead(plugin.connectorManager, mount_id, path),\n },\n // Flow tools\n {\n name: \"flow_list\",\n description: \"List all available flow definitions from ai-assets.\",\n inputSchema: {},\n handler: async () => flowList(p),\n },\n {\n name: \"flow_show\",\n description: \"Show full flow definition (nodes + edges) for a flow ID.\",\n inputSchema: { flow_id: z.string().describe(\"Flow ID from flow_list\") },\n handler: async ({ flow_id }: { flow_id: string }) => flowShow(p, flow_id),\n },\n {\n name: \"flow_list_sessions\",\n description: \"List past and active flow run sessions for this workspace.\",\n inputSchema: {},\n handler: async () => flowListSessions(p),\n },\n {\n name: \"flow_get_session\",\n description: \"Get harness metadata for a specific flow run session.\",\n inputSchema: { run_id: z.string().describe(\"Run ID from flow_list_sessions\") },\n handler: async ({ run_id }: { run_id: string }) => flowGetSession(p, run_id),\n },\n {\n name: \"flow_find_flow_for_session\",\n description: \"Resolve and return the flow definition used in a past session.\",\n inputSchema: { run_id: z.string() },\n handler: async ({ run_id }: { run_id: string }) => flowFindFlowForSession(p, run_id),\n },\n // Skill tools\n {\n name: \"skill_list\",\n description: \"List all skills in the ai-assets catalog.\",\n inputSchema: {},\n handler: async () => skillList(p),\n },\n {\n name: \"skill_show\",\n description: \"Show the full SKILL.md content for a skill ID.\",\n inputSchema: { skill_id: z.string().describe(\"Skill ID from skill_list\") },\n handler: async ({ skill_id }: { skill_id: string }) => skillShow(p, skill_id),\n },\n {\n name: \"skill_search\",\n description: \"Search skills by name, description, or keywords.\",\n inputSchema: { query: z.string() },\n handler: async ({ query }: { query: string }) => skillSearch(p, query),\n },\n {\n name: \"skill_check_requirements\",\n description: \"Validate that all skill prerequisites are met in the target directory.\",\n inputSchema: {\n skill_id: z.string(),\n target_dir: z\n .string()\n .optional()\n .describe(\"Directory to check against (default: projectDir)\"),\n },\n handler: async ({ skill_id, target_dir }: { skill_id: string; target_dir?: string }) =>\n skillCheckRequirements(p, skill_id, target_dir ?? p),\n },\n {\n name: \"skill_get_preamble\",\n description: \"Get the REQUIRES/INPUT/READS/WRITES DSL preamble for a skill.\",\n inputSchema: { skill_id: z.string() },\n handler: async ({ skill_id }: { skill_id: string }) => skillGetPreamble(p, skill_id),\n },\n // Session tools\n {\n name: \"session_list\",\n description: \"List all past agent run sessions for this workspace, sorted newest first.\",\n inputSchema: {},\n handler: async () => sessionList(p),\n },\n {\n name: \"session_get\",\n description: \"Get full metadata for a specific session by run ID.\",\n inputSchema: { run_id: z.string() },\n handler: async ({ run_id }: { run_id: string }) => sessionGet(p, run_id),\n },\n // Connector tools\n {\n name: \"connector_list\",\n description:\n \"List connectors declared in skaile.yaml as {connected, failed, notice?}. A host-managed mount in `connected` carries `health` {status: ok|stale|failed, errorClass, checkedAt}; if it is not ok, tell the user and do not write to it. `failed` holds connectors that did not connect this session, with the failure reason — their mount paths are dead directories, not synced workspaces.\",\n inputSchema: {},\n handler: async () => connectorList(plugin.connectorManager),\n },\n {\n name: \"connector_read\",\n description: \"Read content from a connector by path.\",\n inputSchema: {\n connector_id: z.string().describe(\"Connector ID from connector_list\"),\n path: z.string().describe(\"Path within the connector\"),\n },\n handler: async ({ connector_id, path }: { connector_id: string; path: string }) =>\n connectorRead(plugin.connectorManager, connector_id, path),\n },\n {\n name: \"connector_write\",\n description: \"Write content to a connector by path.\",\n inputSchema: {\n connector_id: z.string(),\n path: z.string(),\n content: z.string().describe(\"Content to write\"),\n },\n handler: async ({\n connector_id,\n path,\n content,\n }: {\n connector_id: string;\n path: string;\n content: string;\n }) => connectorWrite(plugin.connectorManager, connector_id, path, content),\n },\n {\n name: \"connector_search\",\n description: \"Search within a connector by query string.\",\n inputSchema: {\n connector_id: z.string(),\n query: z.string().describe(\"Search query\"),\n },\n handler: async ({ connector_id, query }: { connector_id: string; query: string }) =>\n connectorSearch(plugin.connectorManager, connector_id, query),\n },\n {\n name: \"connector_exec\",\n description: \"Execute a custom operation on a connector.\",\n inputSchema: {\n connector_id: z.string(),\n operation: z.string().describe(\"Operation name from connector_describe\"),\n args: z.record(z.string(), z.unknown()).describe(\"Operation arguments\"),\n },\n handler: async ({\n connector_id,\n operation,\n args,\n }: {\n connector_id: string;\n operation: string;\n args: Record<string, unknown>;\n }) => connectorExec(plugin.connectorManager, connector_id, operation, args),\n },\n {\n name: \"connector_load_skill\",\n description: \"Load the rendered skill body for a connector (operations + usage).\",\n inputSchema: {\n connector_id: z.string(),\n },\n handler: async ({ connector_id }: { connector_id: string }) =>\n connectorLoadSkill(plugin.connectorManager, connector_id),\n },\n {\n name: \"connector_describe\",\n description: \"Describe a connector's capabilities via its RuntimeSkillDescriptor.\",\n inputSchema: {\n connector_id: z.string(),\n },\n handler: async ({ connector_id }: { connector_id: string }) =>\n connectorDescribe(plugin.connectorManager, connector_id),\n },\n // Validator tools\n {\n name: \"workspace_validate\",\n description: \"Run a full health check: connectors, mounts, secrets, harness binary.\",\n inputSchema: {},\n handler: async () => workspaceValidate(plugin, harness),\n },\n {\n name: \"workspace_info\",\n description: \"Show workspace configuration: harness, model, provider, resource counts.\",\n inputSchema: {},\n handler: async () => workspaceInfo(plugin, harness, plugin.model),\n },\n {\n name: \"workspace_test_secret\",\n description: \"Test resolution of one secret reference (env:VAR, forge:key).\",\n inputSchema: { ref: z.string().describe(\"Secret ref e.g. env:ANTHROPIC_API_KEY\") },\n handler: async ({ ref }: { ref: string }) => workspaceTestSecret(ref),\n },\n {\n name: \"workspace_reload\",\n description: \"Re-read skaile.yaml and re-sync the plugin state.\",\n inputSchema: {},\n handler: async () => workspaceReload(plugin),\n },\n ];\n}\n\n/**\n * Build the **in-process** workspace MCP server via the Claude Agent SDK's\n * `createSdkMcpServer`. This shape is what the runner embeds into a Claude\n * Agent SDK `query()` call — the runner *is* the Claude Agent SDK host.\n *\n * Returns `null` when `@anthropic-ai/claude-agent-sdk` is not installed\n * (graceful degradation for non-Claude-Code environments).\n *\n * For the standalone `skaile mcp-server` stdio subprocess use\n * {@link buildWorkspaceMcpStdioServer} / {@link runMcpServerStdio} instead —\n * those carry no Claude Agent SDK dependency.\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n * @returns The SDK MCP server object or `null` if the SDK is unavailable.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport async function buildWorkspaceMcpServer(plugin: WorkspacePlugin): Promise<unknown | null> {\n let sdk: any;\n try {\n sdk = await loadHarnessSdk(\n \"@anthropic-ai/claude-agent-sdk\",\n plugin.projectDir,\n () => import(\"@anthropic-ai/claude-agent-sdk\"),\n );\n } catch {\n return null;\n }\n return sdk.createSdkMcpServer({\n name: \"skaile-workspace\",\n tools: withActivityLabelDefs(buildWorkspaceToolDefs(plugin), zStatic),\n });\n}\n\n/**\n * Build a **raw stdio** workspace MCP server on `@modelcontextprotocol/sdk` —\n * no Claude Agent SDK. This is the correct shape for the `skaile mcp-server`\n * stdio subprocess that MCP-client agents (Claude Code, Codex, …) spawn.\n * Runs on plain Node.\n *\n * The returned server is not yet connected — call `.connect(transport)` (or\n * use {@link runMcpServerStdio}).\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n * @returns A `McpServer` with all 27 workspace tools registered.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport async function buildWorkspaceMcpStdioServer(plugin: WorkspacePlugin): Promise<any> {\n const { McpServer } = await import(\"@modelcontextprotocol/sdk/server/mcp.js\" as string);\n const server = new McpServer({ name: \"skaile-workspace\", version: \"1.0.0\" });\n for (const def of buildWorkspaceToolDefs(plugin)) {\n server.registerTool(\n def.name,\n { description: def.description, inputSchema: def.inputSchema },\n def.handler,\n );\n }\n return server;\n}\n\n/**\n * Start the workspace MCP server over stdio transport.\n *\n * Builds the raw `@modelcontextprotocol/sdk` server via\n * {@link buildWorkspaceMcpStdioServer} and connects a `StdioServerTransport`.\n * No `@anthropic-ai/claude-agent-sdk` dependency anywhere on this path.\n *\n * @param plugin - A booted `WorkspacePlugin` instance.\n *\n * @docLink packages/workspace-plugin/concepts#adapters\n */\nexport async function runMcpServerStdio(plugin: WorkspacePlugin): Promise<void> {\n const server = await buildWorkspaceMcpStdioServer(plugin);\n const { StdioServerTransport } = await import(\n \"@modelcontextprotocol/sdk/server/stdio.js\" as string\n );\n await server.connect(new StdioServerTransport());\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { registryCredentialEnv, providerCredentialEnvName, BUILTIN_HARNESS_CATALOG } from './chunk-
|
|
1
|
+
import { registryCredentialEnv, providerCredentialEnvName, BUILTIN_HARNESS_CATALOG } from './chunk-SOAQP4BI.js';
|
|
2
2
|
import { getProviderPreset } from './chunk-6UP2EDFN.js';
|
|
3
3
|
import { mergeRegistries, resolveEntryBaseUrl, normalizeEntryBaseUrl, registryEntries, isEntryEnabled, parseModelRef } from './chunk-RXGPFAMN.js';
|
|
4
4
|
|
|
@@ -138,5 +138,5 @@ function continueRoleBinding(session) {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
export { bindSingleProviderEntry, continueRoleBinding, credentialsForEveryProvider, entryBaseUrl, entryModelIds, entrySurface, harnessModelSelector, harnessProviderName, isStockCatalogEndpoint, registryModelEntries, resolveEnvHarnessSession, resolveRegistryBinding, selectableEntries, versionedAnthropicBaseUrl };
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-4YVQGPZ5.js.map
|
|
142
|
+
//# sourceMappingURL=chunk-4YVQGPZ5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../bridge/src/provider-materialize/env-harnesses.ts"],"names":[],"mappings":";;;;;AAyEO,SAAS,wBAAA,CACd,MAAA,EACA,UAAA,GAAiD,OAAA,CAAQ,GAAA,EACtC;AACnB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,MAAA,CAAO,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AAAA,IAC/C,WAAW,EAAE,GAAG,UAAA,EAAY,GAAG,OAAO,GAAA,EAAI;AAAA,IAC1C,GAAI,OAAO,QAAA,GAAW,EAAE,UAAU,MAAA,CAAO,QAAA,KAAa,EAAC;AAAA,IACvD,GAAI,OAAO,KAAA,GAAQ,EAAE,OAAO,MAAA,CAAO,KAAA,KAAU;AAAC,GAChD;AACF;AA2BO,SAAS,aAAa,KAAA,EAA0D;AACrF,EAAA,IAAI,KAAA,CAAM,OAAA,EAAS,OAAO,KAAA,CAAM,OAAA;AAChC,EAAA,OAAO,MAAM,MAAA,GAAS,iBAAA,CAAkB,KAAA,CAAM,MAAM,GAAG,OAAA,GAAU,MAAA;AACnE;AAcO,SAAS,aAAa,KAAA,EAA+C;AAC1E,EAAA,MAAM,QAAA,GACJ,mBAAA,CAAoB,KAAK,CAAA,KACxB,KAAA,CAAM,SAAS,iBAAA,CAAkB,KAAA,CAAM,MAAM,CAAA,EAAG,QAAA,GAAW,MAAA,CAAA;AAC9D,EAAA,OAAO,qBAAA,CAAsB,QAAA,EAAU,YAAA,CAAa,KAAK,CAAC,CAAA;AAC5D;AASO,SAAS,yBAAA,CACd,SACA,OAAA,EACQ;AACR,EAAA,IAAI,OAAA,KAAY,sBAAsB,OAAO,OAAA;AAE7C,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,OAAO,CAAA;AA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2B,SAAA,EAAW,aAAa,OAAO,CAAA;AAC1D,EAAA,OAAO,OAAA;AACT;AAOO,SAAS,qBAAqB,OAAA,EAAmD;AACtF,EAAA,IAAI,CAAC,OAAA,CAAQ,eAAA,EAAiB,OAAO,MAAA;AACrC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,iBAAiB,CAAA,CAAA,EAAI,QAAQ,eAAe,CAAA,CAAA;AAChE;AAgCO,SAAS,oBAAoB,OAAA,EAA6D;AAC/F,EAAA,MAAM,OAAA,GAAU,uBAAuB,OAAO,CAAA;AAC9C,EAAA,IAAI,CAAC,SAAS,OAAO,MAAA;AACrB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA;AAAA,IACN,YAAY,OAAA,CAAQ,UAAA;AAAA,IACpB,UAAU,OAAA,CAAQ,iBAAA;AAAA,IAClB,GAAI,QAAQ,eAAA,GAAkB,EAAE,OAAO,OAAA,CAAQ,eAAA,KAAoB,EAAC;AAAA,IACpE,GAAI,OAAA,CAAQ,OAAA,GACR,EAAE,OAAA,EAAS,yBAAA,CAA0B,OAAA,CAAQ,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA,EAAE,GACvE,EAAC;AAAA,IACL,SAAA,EAAW,yBAAA,CAA0B,OAAA,CAAQ,UAAU;AAAA,GACzD;AACF","file":"chunk-PPSSDUN6.js","sourcesContent":["/**\n * Registry adapter for the **env-shaped CLI harnesses** — Gemini, Qwen, OpenCode,\n * Goose and Continue (§2.3).\n *\n * These harnesses take their endpoint from the environment rather than from a\n * config file, so the adapter's job is three things: resolve which registry\n * entry the session's model selector names, refuse at start when that entry\n * speaks a wire surface the harness cannot, and hand the harness the\n * provider-side model id it must put on the command line.\n *\n * Two pluralities meet here (`BUILTIN_HARNESS_CATALOG.providerPlurality`):\n *\n * - `single` — Gemini and Qwen address exactly one endpoint. The bound entry\n * supplies the credential *and* the base URL, and a surface mismatch is\n * fatal: a Gemini CLI pointed at an `openai-completions` endpoint cannot\n * work, and failing at start names the surface instead of leaving the user\n * with an opaque error mid-turn.\n * - `credentials-n` — OpenCode, Goose and Continue accept every enabled\n * entry's credential at once and select one active model. The credential\n * fan-out is `registryCredentialEnv`; the active model is this module's\n * `<provider>/<model>` binding.\n *\n * Writing the per-endpoint config files those three need for *custom*\n * endpoints (`opencode.json`, Goose `custom_providers/*.json`, Continue\n * `config.yaml`) is the file half, and is deliberately not here.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport {\n type AIProviderLlmEntry,\n type AIProviderSurface,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n mergeRegistries,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport type { ModelEntry } from \"../models.js\";\nimport { getProviderPreset } from \"../provider-catalog.js\";\nimport { BUILTIN_HARNESS_CATALOG } from \"../registry.js\";\nimport type { AgentConfig } from \"../types.js\";\nimport { providerCredentialEnvName, registryCredentialEnv } from \"./credential-env.js\";\n\n/**\n * Everything a CLI harness needs to know about this session's AI providers,\n * resolved once from its {@link AgentConfig}.\n */\nexport interface EnvHarnessSession {\n /** The merged registry this session may address. Empty when none was configured. */\n registry: MergedAIProviderRegistry;\n /**\n * Environment `credential.ref` lookups resolve against — the process\n * environment widened with `config.env`, which is where the session\n * boundary delivered every resolved `SKAILE_AIP_<ID>_KEY`.\n */\n lookupEnv: Record<string, string | undefined>;\n /** Model selector: `<providerId>/<modelId>`, a bare id, or `@role`. */\n modelRef?: string;\n /** Roles table an `@role` selector resolves through. */\n roles?: Record<string, string>;\n}\n\n/**\n * Resolve the session's providers once, from its {@link AgentConfig}.\n *\n * `config.env` is folded into `lookupEnv` rather than kept apart: it is part\n * of the session's environment, not an extra, and a credential or\n * `*_BASE_URL` delivered there must be visible exactly as the child will see\n * it.\n */\nexport function resolveEnvHarnessSession(\n config: AgentConfig,\n processEnv: Record<string, string | undefined> = process.env,\n): EnvHarnessSession {\n return {\n registry: config.registry ?? mergeRegistries([]),\n lookupEnv: { ...processEnv, ...config.env },\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n };\n}\n\n/** One resolved endpoint + model — everything a harness needs to spawn. */\nexport interface RegistryModelBinding {\n /** Registry id of the selected entry. */\n providerId: string;\n /** The selected entry itself. */\n entry: AIProviderLlmEntry;\n /** Logical model id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side model id — what goes on the wire / command line. */\n providerModelId?: string;\n /** Wire protocol, from the entry or its preset. */\n surface?: AIProviderSurface;\n /** Resolved endpoint, from the entry, its transport params, or its preset. */\n baseUrl?: string;\n /**\n * The provider name the *harness* knows this endpoint by — a catalog preset\n * id for a stock endpoint, the registry id for anything custom. See\n * {@link harnessProviderName}.\n */\n harnessProviderId: string;\n /** Non-fatal notes from `parseModelRef` (dangling role, disabled provider). */\n warnings: string[];\n}\n\n/** The entry's wire surface: its own, else its preset's. */\nexport function entrySurface(entry: AIProviderLlmEntry): AIProviderSurface | undefined {\n if (entry.surface) return entry.surface;\n return entry.preset ? getProviderPreset(entry.preset)?.surface : undefined;\n}\n\n/**\n * The entry's endpoint: its literal or transport-derived URL, else its\n * preset's literal, in the canonical spelling for its surface\n * (`normalizeEntryBaseUrl`: an `anthropic-messages` endpoint is its host root,\n * so `https://api.anthropic.com/v1` reads as `https://api.anthropic.com`).\n * Transport templates that still carry `{param}` placeholders never come\n * back — `resolveEntryBaseUrl` withholds those, and a preset's template is not\n * a URL.\n *\n * Every adapter reads the endpoint here and only re-spells it for a client\n * that wants something else ({@link versionedAnthropicBaseUrl}).\n */\nexport function entryBaseUrl(entry: AIProviderLlmEntry): string | undefined {\n const resolved =\n resolveEntryBaseUrl(entry) ??\n (entry.preset ? getProviderPreset(entry.preset)?.base_url : undefined);\n return normalizeEntryBaseUrl(resolved, entrySurface(entry));\n}\n\n/**\n * An `anthropic-messages` endpoint spelled for a client that appends only\n * `/messages` — `@ai-sdk/anthropic` (OpenCode) and Continue — rather than\n * `/v1/messages` like the Claude CLI, the Anthropic SDK and Goose. `baseUrl`\n * must already be canonical ({@link entryBaseUrl}); every other surface passes\n * through unchanged.\n */\nexport function versionedAnthropicBaseUrl(\n baseUrl: string,\n surface: AIProviderSurface | undefined,\n): string {\n if (surface !== \"anthropic-messages\") return baseUrl;\n // Append to the path, not the string: a query or fragment stays at the end.\n try {\n const url = new URL(baseUrl);\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/v1`;\n return url.toString();\n } catch {\n return `${baseUrl}/v1`;\n }\n}\n\n/**\n * True when a `credentials-n` harness already knows this endpoint under its\n * own catalog name — the entry names a preset and did not move it somewhere\n * else. Both sides are compared canonically, so `https://api.anthropic.com/v1`\n * is still the `anthropic` preset's endpoint.\n *\n * The one rule both halves of §2.3 read: it decides the name the env half\n * puts on the command line ({@link harnessProviderName}) *and* whether the\n * file half has to describe the endpoint at all. Reading it twice is what\n * keeps `-m <name>/<model>` and the generated provider file talking about the\n * same thing.\n */\nexport function isStockCatalogEndpoint(entry: AIProviderLlmEntry): boolean {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset) return false;\n return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));\n}\n\n/**\n * The provider name to give a `credentials-n` harness (`-m <name>/<model>`,\n * `GOOSE_PROVIDER`).\n *\n * A stock catalog endpoint is named by its preset, because that is the name\n * OpenCode's models.dev list and Goose's built-in provider table already use —\n * `prod-claude: {preset: anthropic}` is still Anthropic to them. An entry with\n * an endpoint of its own is named by its registry id: no built-in table knows\n * it, so the id is what its generated provider file is keyed by (the file half\n * of §2.3).\n */\nexport function harnessProviderName(providerId: string, entry: AIProviderLlmEntry): string {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset || !isStockCatalogEndpoint(entry)) return providerId;\n return preset.id;\n}\n\n/**\n * Enabled `llm`/`embed` entries, in registry order. Also the set the file\n * adapters render (`opencode-config.ts`, `goose-custom-providers.ts`,\n * `continue-config-yaml.ts`): the env half and the file half must agree on\n * which entries exist before they can agree on what to call them.\n */\nexport function selectableEntries(\n registry: MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * The provider-side model ids an entry declares, as `[logicalId, providerId]`\n * pairs in declaration order: every `model_map` entry, plus every\n * `capabilities` key the map does not rename.\n */\nexport function entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logicalIds = [\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}).filter((id) => !(id in (entry.model_map ?? {}))),\n ];\n return logicalIds.map((id) => [id, entry.model_map?.[id] ?? id]);\n}\n\nfunction describeBinding(\n providerId: string,\n entry: AIProviderLlmEntry,\n modelId: string | undefined,\n providerModelId: string | undefined,\n warnings: string[],\n): RegistryModelBinding {\n const surface = entrySurface(entry);\n const baseUrl = entryBaseUrl(entry);\n return {\n providerId,\n entry,\n ...(modelId === undefined ? {} : { modelId }),\n ...(providerModelId === undefined ? {} : { providerModelId }),\n ...(surface ? { surface } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n harnessProviderId: harnessProviderName(providerId, entry),\n warnings,\n };\n}\n\n/**\n * Resolve the session's endpoint + model.\n *\n * With no selector the first entry in registry order wins and the harness\n * keeps its own default model — exactly what an absent `model` meant before\n * the registry existed. Returns `undefined` when no entry can serve a model\n * (an empty, fully-disabled or voice-only registry).\n */\nexport function resolveRegistryBinding(\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const entries = selectableEntries(session.registry);\n if (entries.length === 0) return undefined;\n\n const selector = session.modelRef?.trim();\n if (!selector) {\n const [providerId, entry] = entries[0];\n return describeBinding(providerId, entry, undefined, undefined, []);\n }\n\n // A selector that is exactly an entry id names the endpoint and nothing\n // else: the harness keeps its own default model. `parseModelRef` would read\n // it as a bare *model* id and fall back to registry order.\n const named = entries.find(([id]) => id === selector);\n if (named) return describeBinding(named[0], named[1], undefined, undefined, []);\n\n const resolved = parseModelRef(selector, session.registry, session.roles);\n if (!resolved) return undefined;\n const match = entries.find(([id]) => id === resolved.providerId);\n if (!match) return undefined;\n return describeBinding(\n match[0],\n match[1],\n resolved.modelId,\n resolved.providerModelId,\n resolved.warnings,\n );\n}\n\n/**\n * Every credential a `credentials-n` harness may use: one variable per\n * enabled registry entry. OpenCode, Goose and Continue have always received\n * *all* of them, not just the selected endpoint's, because they route across\n * providers inside a single session.\n */\nexport function credentialsForEveryProvider(session: EnvHarnessSession): Record<string, string> {\n return registryCredentialEnv(session.registry, { env: session.lookupEnv });\n}\n\n/**\n * Throw when the bound entry speaks a wire surface this harness cannot.\n *\n * The message names the offending surface and lists the ones the harness does\n * speak (`BUILTIN_HARNESS_CATALOG[harnessId].surfaces`). An entry that declares\n * no surface and names no preset is not judged — there is nothing to compare.\n */\nexport function assertHarnessSpeaksSurface(\n harnessId: string,\n productName: string,\n binding: RegistryModelBinding,\n): void {\n const supported = BUILTIN_HARNESS_CATALOG[harnessId]?.surfaces;\n if (!supported || supported.length === 0) return;\n const surface = binding.surface;\n if (!surface || supported.includes(surface)) return;\n throw new Error(\n `${productName} cannot speak the '${surface}' surface of AI provider entry ` +\n `'${binding.providerId}'. ${productName} speaks: ${supported.join(\", \")}. ` +\n `Point this session's model at an entry with one of those surfaces, ` +\n `or run it on a harness that speaks '${surface}'.`,\n );\n}\n\n/**\n * The models a `credentials-n` harness can be pointed at, straight from the\n * registry: every enabled entry's mapped ids, namespaced the way the harness\n * takes them (`-m <provider>/<model>`).\n *\n * These harnesses have no model-list endpoint of their own — OpenCode reads\n * models.dev, Goose and Continue read their config — so the registry is the\n * only list that describes *this* session's reachable models, and it needs no\n * network call to produce.\n */\nexport function registryModelEntries(session: EnvHarnessSession): ModelEntry[] {\n const out: ModelEntry[] = [];\n const seen = new Set<string>();\n for (const [providerId, entry] of selectableEntries(session.registry)) {\n const harnessId = harnessProviderName(providerId, entry);\n const label = entry.label ?? providerId;\n for (const [logicalId, providerModelId] of entryModelIds(entry)) {\n const id = `${harnessId}/${providerModelId}`;\n if (seen.has(id)) continue;\n seen.add(id);\n out.push({ id, name: `${label} ${logicalId}` });\n }\n }\n return out;\n}\n\n/**\n * Resolve the binding and enforce the surface — what a `single`-plurality\n * harness does at start.\n *\n * The registry is authoritative: pointing the harness at an entry it cannot\n * speak throws rather than silently running somewhere else. `undefined` when\n * the session configured no endpoint at all, which leaves the harness on its\n * own native auth.\n */\nexport function bindSingleProviderEntry(\n harnessId: string,\n productName: string,\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n assertHarnessSpeaksSurface(harnessId, productName, binding);\n return binding;\n}\n\n/**\n * The `<provider>/<model>` selector a `credentials-n` harness takes on its\n * command line (`opencode -m`). `undefined` when no model was selected — the\n * harness then uses its own default rather than being handed a bare provider.\n */\nexport function harnessModelSelector(binding: RegistryModelBinding): string | undefined {\n if (!binding.providerModelId) return undefined;\n return `${binding.harnessProviderId}/${binding.providerModelId}`;\n}\n\n/**\n * Continue's model selection is a **role binding**, not a flag: `cn` has no\n * `--model` option (only `--config <slug>`), and its `config.yaml` binds each\n * model to roles (`chat`, `edit`, `apply`, …). This is the binding for the\n * role a headless `cn -p` turn runs as, and the shape its generated\n * `config.yaml` is rendered from.\n *\n * `apiKeyEnv` is a variable *name*: the secret travels in the child\n * environment, never in a rendered config.\n */\nexport interface ContinueRoleBinding {\n /** Continue role this model serves. A headless prompt is a `chat` turn. */\n role: \"chat\";\n /** Registry id of the entry. */\n providerId: string;\n /** Provider name Continue knows the endpoint by. */\n provider: string;\n /** Provider-side model id. */\n model?: string;\n /** Endpoint, when the entry states one, spelled the way Continue's `apiBase` wants it. */\n apiBase?: string;\n /** Env var holding the credential — the name, never the value. */\n apiKeyEnv: string;\n}\n\n/**\n * Map the session's chosen endpoint onto the Continue role a headless turn\n * runs as. `undefined` when the session configured no endpoint — `cn` then\n * runs against whatever its own `config.yaml` / Hub login provides.\n */\nexport function continueRoleBinding(session: EnvHarnessSession): ContinueRoleBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n return {\n role: \"chat\",\n providerId: binding.providerId,\n provider: binding.harnessProviderId,\n ...(binding.providerModelId ? { model: binding.providerModelId } : {}),\n ...(binding.baseUrl\n ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) }\n : {}),\n apiKeyEnv: providerCredentialEnvName(binding.providerId),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../bridge/src/provider-materialize/env-harnesses.ts"],"names":[],"mappings":";;;;;AAyEO,SAAS,wBAAA,CACd,MAAA,EACA,UAAA,GAAiD,OAAA,CAAQ,GAAA,EACtC;AACnB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,MAAA,CAAO,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AAAA,IAC/C,WAAW,EAAE,GAAG,UAAA,EAAY,GAAG,OAAO,GAAA,EAAI;AAAA,IAC1C,GAAI,OAAO,QAAA,GAAW,EAAE,UAAU,MAAA,CAAO,QAAA,KAAa,EAAC;AAAA,IACvD,GAAI,OAAO,KAAA,GAAQ,EAAE,OAAO,MAAA,CAAO,KAAA,KAAU;AAAC,GAChD;AACF;AA2BO,SAAS,aAAa,KAAA,EAA0D;AACrF,EAAA,IAAI,KAAA,CAAM,OAAA,EAAS,OAAO,KAAA,CAAM,OAAA;AAChC,EAAA,OAAO,MAAM,MAAA,GAAS,iBAAA,CAAkB,KAAA,CAAM,MAAM,GAAG,OAAA,GAAU,MAAA;AACnE;AAcO,SAAS,aAAa,KAAA,EAA+C;AAC1E,EAAA,MAAM,QAAA,GACJ,mBAAA,CAAoB,KAAK,CAAA,KACxB,KAAA,CAAM,SAAS,iBAAA,CAAkB,KAAA,CAAM,MAAM,C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M,GAAG,KAAK,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA,EAAI,CAAA;AAAA,IAChD;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAWO,SAAS,uBAAA,CACd,SAAA,EACA,WAAA,EACA,OAAA,EACkC;AAClC,EAAA,MAAM,OAAA,GAAU,uBAAuB,OAAO,CAAA;AAC9C,EAAA,IAAI,CAAC,SAAS,OAAO,MAAA;AACrB,EAAA,0BAAA,CAA2B,SAAA,EAAW,aAAa,OAAO,CAAA;AAC1D,EAAA,OAAO,OAAA;AACT;AAOO,SAAS,qBAAqB,OAAA,EAAmD;AACtF,EAAA,IAAI,CAAC,OAAA,CAAQ,eAAA,EAAiB,OAAO,MAAA;AACrC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,iBAAiB,CAAA,CAAA,EAAI,QAAQ,eAAe,CAAA,CAAA;AAChE;AAgCO,SAAS,oBAAoB,OAAA,EAA6D;AAC/F,EAAA,MAAM,OAAA,GAAU,uBAAuB,OAAO,CAAA;AAC9C,EAAA,IAAI,CAAC,SAAS,OAAO,MAAA;AACrB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA;AAAA,IACN,YAAY,OAAA,CAAQ,UAAA;AAAA,IACpB,UAAU,OAAA,CAAQ,iBAAA;AAAA,IAClB,GAAI,QAAQ,eAAA,GAAkB,EAAE,OAAO,OAAA,CAAQ,eAAA,KAAoB,EAAC;AAAA,IACpE,GAAI,OAAA,CAAQ,OAAA,GACR,EAAE,OAAA,EAAS,yBAAA,CAA0B,OAAA,CAAQ,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA,EAAE,GACvE,EAAC;AAAA,IACL,SAAA,EAAW,yBAAA,CAA0B,OAAA,CAAQ,UAAU;AAAA,GACzD;AACF","file":"chunk-4YVQGPZ5.js","sourcesContent":["/**\n * Registry adapter for the **env-shaped CLI harnesses** — Gemini, Qwen, OpenCode,\n * Goose and Continue (§2.3).\n *\n * These harnesses take their endpoint from the environment rather than from a\n * config file, so the adapter's job is three things: resolve which registry\n * entry the session's model selector names, refuse at start when that entry\n * speaks a wire surface the harness cannot, and hand the harness the\n * provider-side model id it must put on the command line.\n *\n * Two pluralities meet here (`BUILTIN_HARNESS_CATALOG.providerPlurality`):\n *\n * - `single` — Gemini and Qwen address exactly one endpoint. The bound entry\n * supplies the credential *and* the base URL, and a surface mismatch is\n * fatal: a Gemini CLI pointed at an `openai-completions` endpoint cannot\n * work, and failing at start names the surface instead of leaving the user\n * with an opaque error mid-turn.\n * - `credentials-n` — OpenCode, Goose and Continue accept every enabled\n * entry's credential at once and select one active model. The credential\n * fan-out is `registryCredentialEnv`; the active model is this module's\n * `<provider>/<model>` binding.\n *\n * Writing the per-endpoint config files those three need for *custom*\n * endpoints (`opencode.json`, Goose `custom_providers/*.json`, Continue\n * `config.yaml`) is the file half, and is deliberately not here.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport {\n type AIProviderLlmEntry,\n type AIProviderSurface,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n mergeRegistries,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport type { ModelEntry } from \"../models.js\";\nimport { getProviderPreset } from \"../provider-catalog.js\";\nimport { BUILTIN_HARNESS_CATALOG } from \"../registry.js\";\nimport type { AgentConfig } from \"../types.js\";\nimport { providerCredentialEnvName, registryCredentialEnv } from \"./credential-env.js\";\n\n/**\n * Everything a CLI harness needs to know about this session's AI providers,\n * resolved once from its {@link AgentConfig}.\n */\nexport interface EnvHarnessSession {\n /** The merged registry this session may address. Empty when none was configured. */\n registry: MergedAIProviderRegistry;\n /**\n * Environment `credential.ref` lookups resolve against — the process\n * environment widened with `config.env`, which is where the session\n * boundary delivered every resolved `SKAILE_AIP_<ID>_KEY`.\n */\n lookupEnv: Record<string, string | undefined>;\n /** Model selector: `<providerId>/<modelId>`, a bare id, or `@role`. */\n modelRef?: string;\n /** Roles table an `@role` selector resolves through. */\n roles?: Record<string, string>;\n}\n\n/**\n * Resolve the session's providers once, from its {@link AgentConfig}.\n *\n * `config.env` is folded into `lookupEnv` rather than kept apart: it is part\n * of the session's environment, not an extra, and a credential or\n * `*_BASE_URL` delivered there must be visible exactly as the child will see\n * it.\n */\nexport function resolveEnvHarnessSession(\n config: AgentConfig,\n processEnv: Record<string, string | undefined> = process.env,\n): EnvHarnessSession {\n return {\n registry: config.registry ?? mergeRegistries([]),\n lookupEnv: { ...processEnv, ...config.env },\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n };\n}\n\n/** One resolved endpoint + model — everything a harness needs to spawn. */\nexport interface RegistryModelBinding {\n /** Registry id of the selected entry. */\n providerId: string;\n /** The selected entry itself. */\n entry: AIProviderLlmEntry;\n /** Logical model id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side model id — what goes on the wire / command line. */\n providerModelId?: string;\n /** Wire protocol, from the entry or its preset. */\n surface?: AIProviderSurface;\n /** Resolved endpoint, from the entry, its transport params, or its preset. */\n baseUrl?: string;\n /**\n * The provider name the *harness* knows this endpoint by — a catalog preset\n * id for a stock endpoint, the registry id for anything custom. See\n * {@link harnessProviderName}.\n */\n harnessProviderId: string;\n /** Non-fatal notes from `parseModelRef` (dangling role, disabled provider). */\n warnings: string[];\n}\n\n/** The entry's wire surface: its own, else its preset's. */\nexport function entrySurface(entry: AIProviderLlmEntry): AIProviderSurface | undefined {\n if (entry.surface) return entry.surface;\n return entry.preset ? getProviderPreset(entry.preset)?.surface : undefined;\n}\n\n/**\n * The entry's endpoint: its literal or transport-derived URL, else its\n * preset's literal, in the canonical spelling for its surface\n * (`normalizeEntryBaseUrl`: an `anthropic-messages` endpoint is its host root,\n * so `https://api.anthropic.com/v1` reads as `https://api.anthropic.com`).\n * Transport templates that still carry `{param}` placeholders never come\n * back — `resolveEntryBaseUrl` withholds those, and a preset's template is not\n * a URL.\n *\n * Every adapter reads the endpoint here and only re-spells it for a client\n * that wants something else ({@link versionedAnthropicBaseUrl}).\n */\nexport function entryBaseUrl(entry: AIProviderLlmEntry): string | undefined {\n const resolved =\n resolveEntryBaseUrl(entry) ??\n (entry.preset ? getProviderPreset(entry.preset)?.base_url : undefined);\n return normalizeEntryBaseUrl(resolved, entrySurface(entry));\n}\n\n/**\n * An `anthropic-messages` endpoint spelled for a client that appends only\n * `/messages` — `@ai-sdk/anthropic` (OpenCode) and Continue — rather than\n * `/v1/messages` like the Claude CLI, the Anthropic SDK and Goose. `baseUrl`\n * must already be canonical ({@link entryBaseUrl}); every other surface passes\n * through unchanged.\n */\nexport function versionedAnthropicBaseUrl(\n baseUrl: string,\n surface: AIProviderSurface | undefined,\n): string {\n if (surface !== \"anthropic-messages\") return baseUrl;\n // Append to the path, not the string: a query or fragment stays at the end.\n try {\n const url = new URL(baseUrl);\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/v1`;\n return url.toString();\n } catch {\n return `${baseUrl}/v1`;\n }\n}\n\n/**\n * True when a `credentials-n` harness already knows this endpoint under its\n * own catalog name — the entry names a preset and did not move it somewhere\n * else. Both sides are compared canonically, so `https://api.anthropic.com/v1`\n * is still the `anthropic` preset's endpoint.\n *\n * The one rule both halves of §2.3 read: it decides the name the env half\n * puts on the command line ({@link harnessProviderName}) *and* whether the\n * file half has to describe the endpoint at all. Reading it twice is what\n * keeps `-m <name>/<model>` and the generated provider file talking about the\n * same thing.\n */\nexport function isStockCatalogEndpoint(entry: AIProviderLlmEntry): boolean {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset) return false;\n return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));\n}\n\n/**\n * The provider name to give a `credentials-n` harness (`-m <name>/<model>`,\n * `GOOSE_PROVIDER`).\n *\n * A stock catalog endpoint is named by its preset, because that is the name\n * OpenCode's models.dev list and Goose's built-in provider table already use —\n * `prod-claude: {preset: anthropic}` is still Anthropic to them. An entry with\n * an endpoint of its own is named by its registry id: no built-in table knows\n * it, so the id is what its generated provider file is keyed by (the file half\n * of §2.3).\n */\nexport function harnessProviderName(providerId: string, entry: AIProviderLlmEntry): string {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset || !isStockCatalogEndpoint(entry)) return providerId;\n return preset.id;\n}\n\n/**\n * Enabled `llm`/`embed` entries, in registry order. Also the set the file\n * adapters render (`opencode-config.ts`, `goose-custom-providers.ts`,\n * `continue-config-yaml.ts`): the env half and the file half must agree on\n * which entries exist before they can agree on what to call them.\n */\nexport function selectableEntries(\n registry: MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * The provider-side model ids an entry declares, as `[logicalId, providerId]`\n * pairs in declaration order: every `model_map` entry, plus every\n * `capabilities` key the map does not rename.\n */\nexport function entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logicalIds = [\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}).filter((id) => !(id in (entry.model_map ?? {}))),\n ];\n return logicalIds.map((id) => [id, entry.model_map?.[id] ?? id]);\n}\n\nfunction describeBinding(\n providerId: string,\n entry: AIProviderLlmEntry,\n modelId: string | undefined,\n providerModelId: string | undefined,\n warnings: string[],\n): RegistryModelBinding {\n const surface = entrySurface(entry);\n const baseUrl = entryBaseUrl(entry);\n return {\n providerId,\n entry,\n ...(modelId === undefined ? {} : { modelId }),\n ...(providerModelId === undefined ? {} : { providerModelId }),\n ...(surface ? { surface } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n harnessProviderId: harnessProviderName(providerId, entry),\n warnings,\n };\n}\n\n/**\n * Resolve the session's endpoint + model.\n *\n * With no selector the first entry in registry order wins and the harness\n * keeps its own default model — exactly what an absent `model` meant before\n * the registry existed. Returns `undefined` when no entry can serve a model\n * (an empty, fully-disabled or voice-only registry).\n */\nexport function resolveRegistryBinding(\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const entries = selectableEntries(session.registry);\n if (entries.length === 0) return undefined;\n\n const selector = session.modelRef?.trim();\n if (!selector) {\n const [providerId, entry] = entries[0];\n return describeBinding(providerId, entry, undefined, undefined, []);\n }\n\n // A selector that is exactly an entry id names the endpoint and nothing\n // else: the harness keeps its own default model. `parseModelRef` would read\n // it as a bare *model* id and fall back to registry order.\n const named = entries.find(([id]) => id === selector);\n if (named) return describeBinding(named[0], named[1], undefined, undefined, []);\n\n const resolved = parseModelRef(selector, session.registry, session.roles);\n if (!resolved) return undefined;\n const match = entries.find(([id]) => id === resolved.providerId);\n if (!match) return undefined;\n return describeBinding(\n match[0],\n match[1],\n resolved.modelId,\n resolved.providerModelId,\n resolved.warnings,\n );\n}\n\n/**\n * Every credential a `credentials-n` harness may use: one variable per\n * enabled registry entry. OpenCode, Goose and Continue have always received\n * *all* of them, not just the selected endpoint's, because they route across\n * providers inside a single session.\n */\nexport function credentialsForEveryProvider(session: EnvHarnessSession): Record<string, string> {\n return registryCredentialEnv(session.registry, { env: session.lookupEnv });\n}\n\n/**\n * Throw when the bound entry speaks a wire surface this harness cannot.\n *\n * The message names the offending surface and lists the ones the harness does\n * speak (`BUILTIN_HARNESS_CATALOG[harnessId].surfaces`). An entry that declares\n * no surface and names no preset is not judged — there is nothing to compare.\n */\nexport function assertHarnessSpeaksSurface(\n harnessId: string,\n productName: string,\n binding: RegistryModelBinding,\n): void {\n const supported = BUILTIN_HARNESS_CATALOG[harnessId]?.surfaces;\n if (!supported || supported.length === 0) return;\n const surface = binding.surface;\n if (!surface || supported.includes(surface)) return;\n throw new Error(\n `${productName} cannot speak the '${surface}' surface of AI provider entry ` +\n `'${binding.providerId}'. ${productName} speaks: ${supported.join(\", \")}. ` +\n `Point this session's model at an entry with one of those surfaces, ` +\n `or run it on a harness that speaks '${surface}'.`,\n );\n}\n\n/**\n * The models a `credentials-n` harness can be pointed at, straight from the\n * registry: every enabled entry's mapped ids, namespaced the way the harness\n * takes them (`-m <provider>/<model>`).\n *\n * These harnesses have no model-list endpoint of their own — OpenCode reads\n * models.dev, Goose and Continue read their config — so the registry is the\n * only list that describes *this* session's reachable models, and it needs no\n * network call to produce.\n */\nexport function registryModelEntries(session: EnvHarnessSession): ModelEntry[] {\n const out: ModelEntry[] = [];\n const seen = new Set<string>();\n for (const [providerId, entry] of selectableEntries(session.registry)) {\n const harnessId = harnessProviderName(providerId, entry);\n const label = entry.label ?? providerId;\n for (const [logicalId, providerModelId] of entryModelIds(entry)) {\n const id = `${harnessId}/${providerModelId}`;\n if (seen.has(id)) continue;\n seen.add(id);\n out.push({ id, name: `${label} ${logicalId}` });\n }\n }\n return out;\n}\n\n/**\n * Resolve the binding and enforce the surface — what a `single`-plurality\n * harness does at start.\n *\n * The registry is authoritative: pointing the harness at an entry it cannot\n * speak throws rather than silently running somewhere else. `undefined` when\n * the session configured no endpoint at all, which leaves the harness on its\n * own native auth.\n */\nexport function bindSingleProviderEntry(\n harnessId: string,\n productName: string,\n session: EnvHarnessSession,\n): RegistryModelBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n assertHarnessSpeaksSurface(harnessId, productName, binding);\n return binding;\n}\n\n/**\n * The `<provider>/<model>` selector a `credentials-n` harness takes on its\n * command line (`opencode -m`). `undefined` when no model was selected — the\n * harness then uses its own default rather than being handed a bare provider.\n */\nexport function harnessModelSelector(binding: RegistryModelBinding): string | undefined {\n if (!binding.providerModelId) return undefined;\n return `${binding.harnessProviderId}/${binding.providerModelId}`;\n}\n\n/**\n * Continue's model selection is a **role binding**, not a flag: `cn` has no\n * `--model` option (only `--config <slug>`), and its `config.yaml` binds each\n * model to roles (`chat`, `edit`, `apply`, …). This is the binding for the\n * role a headless `cn -p` turn runs as, and the shape its generated\n * `config.yaml` is rendered from.\n *\n * `apiKeyEnv` is a variable *name*: the secret travels in the child\n * environment, never in a rendered config.\n */\nexport interface ContinueRoleBinding {\n /** Continue role this model serves. A headless prompt is a `chat` turn. */\n role: \"chat\";\n /** Registry id of the entry. */\n providerId: string;\n /** Provider name Continue knows the endpoint by. */\n provider: string;\n /** Provider-side model id. */\n model?: string;\n /** Endpoint, when the entry states one, spelled the way Continue's `apiBase` wants it. */\n apiBase?: string;\n /** Env var holding the credential — the name, never the value. */\n apiKeyEnv: string;\n}\n\n/**\n * Map the session's chosen endpoint onto the Continue role a headless turn\n * runs as. `undefined` when the session configured no endpoint — `cn` then\n * runs against whatever its own `config.yaml` / Hub login provides.\n */\nexport function continueRoleBinding(session: EnvHarnessSession): ContinueRoleBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n return {\n role: \"chat\",\n providerId: binding.providerId,\n provider: binding.harnessProviderId,\n ...(binding.providerModelId ? { model: binding.providerModelId } : {}),\n ...(binding.baseUrl\n ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) }\n : {}),\n apiKeyEnv: providerCredentialEnvName(binding.providerId),\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveSkWorkspaceConfig, readLinks, getGlobalCacheDir, sourceCacheKey } from './chunk-
|
|
1
|
+
import { resolveSkWorkspaceConfig, readLinks, getGlobalCacheDir, sourceCacheKey } from './chunk-GXW4B5SE.js';
|
|
2
2
|
import { scanDirectory, tryWithFsDeadline } from './chunk-2MTRRK37.js';
|
|
3
3
|
import { existsSync, readFileSync } from 'fs';
|
|
4
4
|
import { lstat, stat } from 'fs/promises';
|
|
@@ -240,5 +240,5 @@ function findCatalogEntry(entries, query) {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
export { FACTORY_ASSETS_REPO_NAME, factoryAssetRoots, resolveFactoryAssetsRoot, resolveFactoryAssetsRootOrNull, resolvePackagedAssetsDir, resolveRuntimeAssets, resolveWorkspacesPackageRoot };
|
|
243
|
-
//# sourceMappingURL=chunk-
|
|
244
|
-
//# sourceMappingURL=chunk-
|
|
243
|
+
//# sourceMappingURL=chunk-52HUF3DF.js.map
|
|
244
|
+
//# sourceMappingURL=chunk-52HUF3DF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../core/src/runtime-assets.ts"],"names":["resolvePath","require"],"mappings":";;;;;;;;AAsDA,SAAS,sBACP,OAAA,EACmC;AACnC,EAAA,MAAM,aAAa,iBAAA,EAAkB;AACrC,EAAA,MAAM,MAAyC,EAAC;AAChD,EAAA,KAAA,MAAW,CAAA,IAAK,OAAA,IAAW,EAAC,EAAG;AAC7B,IAAA,MAAM,GAAA,GAAM,cAAA,CAAe,CAAA,CAAE,GAAG,CAAA;AAChC,IAAA,IAAI,GAAA,CAAI,GAAG,CAAA,EAAG;AACd,IAAA,GAAA,CAAI,GAAG,CAAA,GAAI;AAAA,MACT,IAAA,EAAM,IAAA,CAAK,UAAA,EAAY,GAAG,CAAA;AAAA,MAC1B,KAAK,CAAA,CAAE,GAAA;AAAA,MACP,QAAQ,CAAA,CAAE,GAAA;AAAA,MACV,GAAI,EAAE,SAAA,GAAY,EAAE,WAAW,CAAA,CAAE,SAAA,KAAc;AAAC,KAClD;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAqDO,IAAM,wBAAA,GAA2B;AAMxC,IAAM,iCAAA,GAAoC,yBAAA;AAkD1C,eAAsB,oBAAA,CACpB,UAAA,EACA,OAAA,GAAgC,EAAC,EACH;AAC9B,EAAA,MAAM,MAAA,GAA8B;AAAA,IAClC,gBAAgB,EAAC;AAAA,IACjB,cAAc,EAAC;AAAA,IACf,iBAAiB,EAAE,QAAA,EAAU,EAAC,EAAG,QAAA,EAAU,EAAC,EAAE;AAAA,IAC9C,UAAU,EAAC;AAAA,IACX,SAAS,YAAY;AACnB,MAAA,MAAM,QAAA,CAAS,UAAA,EAAY,MAAA,EAAQ,OAAO,CAAA;AAAA,IAC5C,CAAA;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Q,CAAC,KAAK,GAAA,EAAK;AAChE,IAAA,OACE,CAAA,oHAAA,CAAA;AAAA,EAGJ;AACA,EAAA,IAAI,KAAK,GAAA,EAAK;AACZ,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,IAAA,CAAK,GAAG,CAAA,8EAAA,CAAA;AAAA,EAC1C;AACA,EAAA,IAAI,KAAK,IAAA,EAAM;AACb,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,kBAAA,EAAqB,IAAA,CAAK,IAAI,CAAA,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,eAAe,IAAI,CAAA,2BAAA,CAAA;AAC5B;AAEA,SAAS,gBAAA,CACP,SACA,KAAA,EACiC;AACjC,EAAA,IAAI,MAAM,IAAA,EAAM;AACd,IAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAI,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,MAAM,IAAI,CAAA;AAC3D,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG,OAAO,QAAQ,CAAC,CAAA;AAE1C,EAAA,OAAO,MAAA;AACT","file":"chunk-ETGC2MEM.js","sourcesContent":["/**\n * Runtime asset resolution — read `skaile.yaml`, scan all declared repositories\n * (including the built-in `factory-assets/` directory as an implicit default),\n * and produce a unified view of connector catalog entries plus the implicit refs\n * that the `skaile.yaml` `connectors:` section adds to the dependency graph.\n *\n * This module is the single source of truth for \"which connectors does this\n * project see at runtime, and where do their implementations live on disk\".\n * Both the runner (serve, REPL, flow) and the platform's mid-session\n * `add_resource` flow consume `RuntimeAssetsResult.catalogEntries` and pass\n * it into `ConnectorManager` for catalog-based resolution.\n *\n * `factory-assets/` is the single first-party content tree (built-in connectors\n * + first-party skills + bundles) shipped inside the `@skaile/workspaces`\n * package — not a standalone package.\n *\n * It resolves to an **ordered list of roots** ({@link factoryAssetRoots}), not a\n * single dir. The bundled tree is always the baseline; an optional\n * `SKAILE_FACTORY_ASSETS_DIR` (legacy: `SKAILE_BASE_ASSETS_DIR`) is layered\n * **in front** as an additive override source — the agent container points it at\n * `/app/factory-assets/` (or a bind-mounted host dir) to ship updated skills /\n * flows / bundles / connector manifests without rebuilding the image. The two\n * roots resolve uniformly across every consumer (connector catalog scan, skill /\n * flow / completion discovery, the asset-manager factory source):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir, when set and existing (override layer).\n * 2. the bundled tree via {@link resolvePackagedAssetsDir} — the in-repo source\n * `packages/workspaces/factory-assets/` during dev, else the published\n * `dist/factory-assets/` after install (always-present baseline).\n *\n * Override semantics are **env-first**: on a name conflict the env root wins and\n * the bundled root fills the rest. Connector *code* still loads via the package's\n * static `exports` map, so the env root can override/add skills, flows, bundles,\n * and connector **manifests/metadata**, but cannot ship a new executable\n * connector — its `.js` is not on the package's import graph.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { lstat, stat } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { tryWithFsDeadline } from \"./fs-deadline.js\";\nimport { scanDirectory } from \"./manifest.js\";\nimport type { CatalogEntry } from \"./models.js\";\nimport { getGlobalCacheDir, readLinks, sourceCacheKey } from \"./repo-manager.js\";\nimport type { SourceDeclaration, SourceEntry } from \"./workspace-config.js\";\nimport { resolveSkWorkspaceConfig } from \"./workspace-config.js\";\n\n/**\n * Map declared `sources[]` to internal `SourceDeclaration`s keyed by the\n * collision-free {@link sourceCacheKey} (`<host>/<owner>/<repo>`), pointing at\n * the unified machine-cache clone path (`getGlobalCacheDir()/<key>/`). Keyed by\n * the same function every other cache writer/reader uses so the path resolves.\n */\nfunction sourcesToDeclarations(\n sources: SourceEntry[] | undefined,\n): Record<string, SourceDeclaration> {\n const sourcesDir = getGlobalCacheDir();\n const out: Record<string, SourceDeclaration> = {};\n for (const s of sources ?? []) {\n const key = sourceCacheKey(s.url);\n if (out[key]) continue;\n out[key] = {\n path: join(sourcesDir, key),\n url: s.url,\n branch: s.pin,\n ...(s.publisher ? { publisher: s.publisher } : {}),\n };\n }\n return out;\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Catalog entry filtered to mount/connector kinds. Same shape as `CatalogEntry`.\n * @docLink packages/core/concepts#runtime-catalog-entry\n */\nexport type RuntimeCatalogEntry = CatalogEntry;\n\n/**\n * Implicit catalog reference derived from a `connectors:` declaration in `skaile.yaml`.\n * Each connector driver becomes an implicit ref that must be resolved in the catalog.\n * @docLink packages/core/concepts#runtime-asset-ref\n */\nexport interface RuntimeAssetRef {\n kind: \"connector\";\n /** Driver name — matches `RuntimeCatalogEntry.name`. */\n name: string;\n /** Source declaration id from `skaile.yaml`. */\n declarationId: string;\n}\n\n/**\n * Aggregated npm packages required by all resolved mount/connector adapters.\n * Populated from `metadata.npm_deps` in each matched catalog entry.\n * @docLink packages/core/concepts#runtime-npm-deps\n */\nexport interface RuntimeNpmDeps {\n required: string[];\n optional: string[];\n}\n\n/**\n * Non-fatal warning emitted during `resolveRuntimeAssets` when a repo is unavailable\n * or a driver is not found in any catalog.\n * @docLink packages/core/concepts#runtime-asset-warning\n */\nexport interface RuntimeAssetWarning {\n /** Stable code for filtering / structured logging. */\n code: \"missing_driver\" | \"repo_unavailable\" | \"invalid_repo_decl\";\n message: string;\n /** Declaration id when applicable. */\n declarationId?: string;\n /** Driver / repository name when applicable. */\n name?: string;\n}\n\n/**\n * Repository name used for the implicit built-in `factory-assets` catalog entry\n * (the in-package connector tree).\n * @docLink packages/core/concepts#factory-assets-repo-name\n */\nexport const FACTORY_ASSETS_REPO_NAME = \"factory-assets\";\n\n/**\n * Repository name for the optional `SKAILE_FACTORY_ASSETS_DIR` override layer,\n * scanned ahead of (and overriding) the bundled {@link FACTORY_ASSETS_REPO_NAME}.\n */\nconst FACTORY_ASSETS_OVERRIDE_REPO_NAME = \"factory-assets:override\";\n\n/**\n * Result of `resolveRuntimeAssets`.\n * The same object is mutated in place by `refresh()`, allowing callers to hold\n * a stable reference and observe updates after a new repository is cloned or\n * a driver is installed mid-session.\n * @docLink packages/core/concepts#runtime-assets-result\n */\nexport interface RuntimeAssetsResult {\n catalogEntries: RuntimeCatalogEntry[];\n implicitRefs: RuntimeAssetRef[];\n requiredNpmDeps: RuntimeNpmDeps;\n warnings: RuntimeAssetWarning[];\n /** Re-scan repositories and re-derive implicit refs. Mutates in place. */\n refresh(): Promise<void>;\n /**\n * Catalog lookup. When `kind` is omitted and multiple entries share the\n * `name`, returns `undefined` (caller must disambiguate).\n */\n findEntry(query: { kind?: \"connector\"; name: string }): RuntimeCatalogEntry | undefined;\n}\n\n/** Options of {@link resolveRuntimeAssets}. */\nexport interface RuntimeAssetsOptions {\n /**\n * True when a connector driver is registered in the process (built-in or loaded plugin).\n * Core does not know the registry; the caller passes its lookup. Without it only the catalog\n * counts, so a driver a plugin registers is reported as `missing_driver`.\n */\n isDriverRegistered?: (driver: string) => boolean;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Resolve all runtime assets visible to a project by scanning declared repositories.\n *\n * Reads `skaile.yaml`, scans every declared repository (plus the implicit\n * built-in `factory-assets` repo), and derives implicit refs from `mounts:` /\n * `connectors:` declarations. Does not clone or install anything — purely a\n * read-only scan of what is already on disk. URL-only repositories that have\n * not been cloned yet are reported as `repo_unavailable` warnings.\n *\n * @param projectDir - Absolute path to the project workspace root\n * @param options - `isDriverRegistered`: a driver that no catalog entry lists but a plugin\n * registered is not reported as `missing_driver`\n * @returns `RuntimeAssetsResult` with catalog entries, implicit refs, npm deps, and warnings\n * @docLink packages/core/concepts#resolve-runtime-assets\n */\nexport async function resolveRuntimeAssets(\n projectDir: string,\n options: RuntimeAssetsOptions = {},\n): Promise<RuntimeAssetsResult> {\n const result: RuntimeAssetsResult = {\n catalogEntries: [],\n implicitRefs: [],\n requiredNpmDeps: { required: [], optional: [] },\n warnings: [],\n refresh: async () => {\n await populate(projectDir, result, options);\n },\n findEntry: (query) => findCatalogEntry(result.catalogEntries, query),\n };\n\n await populate(projectDir, result, options);\n return result;\n}\n\n/**\n * Resolve the ordered list of on-disk roots for the built-in `factory-assets`\n * tree (built-in connectors + first-party skills + bundles). This is the single\n * shared resolver every consumer goes through, so the env override and the\n * bundled baseline are honoured uniformly.\n *\n * Order (env-first = override-wins):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir (legacy: `SKAILE_BASE_ASSETS_DIR`),\n * when set and existing — an additive override layer.\n * 2. {@link resolvePackagedAssetsDir} — the bundled tree (in-repo source in dev,\n * `dist/factory-assets/` after install). Always-present baseline.\n *\n * Returns `[]` only when the package cannot be located at all. De-duplicated, so\n * pointing the env var at the bundled dir collapses to one root.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function factoryAssetRoots(): string[] {\n const roots: string[] = [];\n const envDir = process.env.SKAILE_FACTORY_ASSETS_DIR ?? process.env.SKAILE_BASE_ASSETS_DIR;\n // Deliberately still synchronous after #454: both candidates are\n // container-local (the image's `/app/factory-assets/`, or the installed\n // package tree resolved by `resolvePackagedAssetsDir`), never the FUSE\n // workspace mount. The mount-reachable probes on this module's scan path —\n // the project-relative `sources[].path` candidates in `resolveRepoDir` — are\n // async and deadline-bounded.\n if (envDir && existsSync(envDir)) roots.push(resolvePath(envDir));\n const bundled = resolvePackagedAssetsDir(\"factory-assets\");\n if (bundled) roots.push(bundled);\n return [...new Set(roots)];\n}\n\n/**\n * Resolve the primary on-disk root of the `factory-assets` tree — the first of\n * {@link factoryAssetRoots} (the env override when set, else the bundled tree).\n * Prefer {@link factoryAssetRoots} when you need to scan every layer; this\n * single-dir form is for callers that want one canonical path.\n *\n * @returns Absolute path to the highest-precedence `factory-assets` directory\n * @throws When no root can be located\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolveFactoryAssetsRoot(): string {\n const hit = resolveFactoryAssetsRootOrNull();\n if (hit) return hit;\n\n throw new Error(\n `Cannot resolve the factory-assets directory. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR to the on-disk path, ` +\n `ensure @skaile/workspaces is installed, ` +\n `or run from within the @skaile/workspaces package tree.`,\n );\n}\n\n/**\n * Non-throwing variant of {@link resolveFactoryAssetsRoot}: the same\n * env-then-packaged resolution tiers, returning `null` instead of throwing when\n * none locate the directory. Callers that treat a missing factory tree as a\n * soft \"not present\" (e.g. the asset-manager's implicit-source injection) MUST\n * use this so they honour the `SKAILE_FACTORY_ASSETS_DIR` container override\n * identically to the runtime path.\n */\nexport function resolveFactoryAssetsRootOrNull(): string | null {\n return factoryAssetRoots()[0] ?? null;\n}\n\n/**\n * Resolve the `@skaile/workspaces` package root — the directory containing its\n * `package.json`. Tries `require.resolve` first (works when installed as a\n * dependency *and* in-repo via the self-reference), then walks upward from this\n * module looking for a `package.json` whose `name` is `@skaile/workspaces`\n * (bounded to 8 levels). Returns `null` when neither locates it.\n *\n * The single source of truth for finding content shipped inside the package —\n * the unified `factory-assets/` tree (built-in connectors + first-party skills\n * + bundles) resolves through {@link resolvePackagedAssetsDir} on top of this.\n *\n * Memoized: the package location is immutable for the process lifetime, but\n * this sits on the CLI hot path (every `findSkills` / flow / completion call\n * funnels through here), so the `require.resolve` + upward `package.json` walk\n * runs once. `undefined` = not yet computed.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nlet workspacesPackageRootCache: string | null | undefined;\n\nexport function resolveWorkspacesPackageRoot(): string | null {\n if (workspacesPackageRootCache !== undefined) return workspacesPackageRootCache;\n workspacesPackageRootCache = computeWorkspacesPackageRoot();\n return workspacesPackageRootCache;\n}\n\nfunction computeWorkspacesPackageRoot(): string | null {\n try {\n const require = createRequire(import.meta.url);\n return dirname(require.resolve(\"@skaile/workspaces/package.json\"));\n } catch {\n // Fall through to the workspace walk.\n }\n let dir: string;\n try {\n dir = dirname(fileURLToPath(import.meta.url));\n } catch {\n return null;\n }\n for (let i = 0; i < 8; i++) {\n const pkgPath = join(dir, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as { name?: string };\n if (pkg.name === \"@skaile/workspaces\") return dir;\n } catch {\n // Ignore malformed package.json and keep walking.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Locate a content-asset directory inside the package. Prefers the in-repo\n * **source** dir `<pkgRoot>/<subdir>` when present — in a dev checkout it is the\n * full tree (e.g. `factory-assets/` keeps the connector `.ts` entry files that\n * `dist/` does not) — then the published `dist/<subdir>` copy (what\n * `files: [\"dist\"]` ships, the only one present after `npm i`). Returns `null`\n * when neither exists.\n *\n * `factory-assets/` resolves to the source tree in dev (code + skills + bundles)\n * and to `dist/factory-assets` post-install (compiled connectors + copied\n * manifests/skills/bundles).\n *\n * @param subdir - `\"factory-assets\"` | …\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolvePackagedAssetsDir(subdir: string): string | null {\n const root = resolveWorkspacesPackageRoot();\n if (!root) return null;\n for (const cand of [join(root, subdir), join(root, \"dist\", subdir)]) {\n if (existsSync(cand)) return cand;\n }\n return null;\n}\n\n// ─── Internals ────────────────────────────────────────────────────────────────\n\nconst CONNECTOR_SCAN_KINDS: ReadonlySet<string> = new Set([\"connector\"]);\n\nasync function populate(\n projectDir: string,\n target: RuntimeAssetsResult,\n options: RuntimeAssetsOptions,\n): Promise<void> {\n target.catalogEntries = [];\n target.implicitRefs = [];\n target.requiredNpmDeps = { required: [], optional: [] };\n target.warnings = [];\n\n const config = resolveSkWorkspaceConfig(projectDir);\n // Connector catalog scan runs over the project's declared sources[] (resolved\n // to their machine-cache clone paths) plus the implicit factory-assets repo.\n const repositories = buildEffectiveRepositories(sourcesToDeclarations(config.sources));\n const links = readLinks(projectDir);\n\n // Scan each repository for connector entries.\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = await resolveRepoDir(name, decl, projectDir, links);\n if (!repoDir) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: repoUnavailableMessage(name, decl),\n });\n continue;\n }\n try {\n // Both factory layers carry the same `factory-assets` provenance — the\n // override repo is an internal scan-order device, not a distinct source.\n const repoName = name === FACTORY_ASSETS_OVERRIDE_REPO_NAME ? FACTORY_ASSETS_REPO_NAME : name;\n // Only connector descriptors are consumed here, so only that kind is\n // \"known\": typed manifests of any other kind are irrelevant to this scan.\n const scanned = await scanDirectory(repoDir, repoName, {\n knownKinds: CONNECTOR_SCAN_KINDS,\n onDiagnostic: () => {},\n });\n const entries = scanned.filter((e) => e.kind === \"connector\");\n target.catalogEntries.push(...entries);\n } catch (err) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: `Failed to scan repository \"${name}\" at ${repoDir}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n });\n }\n }\n\n // De-duplicate by (kind, name), keeping the first occurrence. Scan order is\n // declared sources → env override → bundled baseline, so an env-supplied\n // connector manifest overrides the bundled one and the bundled one fills the\n // rest (the override layer can refresh built-in manifests in place).\n const seen = new Set<string>();\n target.catalogEntries = target.catalogEntries.filter((e) => {\n const key = `${e.kind}:${e.name}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n\n // Derive implicit refs from skaile.yaml connectors.\n for (const [index, c] of (config.connectors ?? []).entries()) {\n // No `driver` (a misspelt or old `adapter:` key): say so with the text `validate` prints,\n // not a warning about the driver `\"undefined\"` (p1739).\n if (typeof c.driver !== \"string\" || c.driver === \"\") {\n const legacy = (c as unknown as Record<string, unknown>).adapter;\n const label = typeof c.id === \"string\" && c.id !== \"\" ? `\"${c.id}\"` : `#${index + 1}`;\n target.warnings.push({\n code: \"missing_driver\",\n ...(typeof c.id === \"string\" && c.id !== \"\" ? { declarationId: c.id } : {}),\n message:\n legacy !== undefined\n ? `Connector ${label} sets \\`adapter: ${String(legacy)}\\`; the key is \\`driver\\`. Rename \\`adapter\\` to \\`driver\\`.`\n : `Connector ${label} has no \\`driver\\`; the runner cannot mount it. Add \\`driver: <name>\\`.`,\n });\n continue;\n }\n target.implicitRefs.push({ kind: \"connector\", name: c.driver, declarationId: c.id });\n }\n\n // Validate refs and aggregate npm deps.\n const requiredSet = new Set<string>();\n const optionalSet = new Set<string>();\n for (const ref of target.implicitRefs) {\n const entry = findCatalogEntry(target.catalogEntries, ref);\n // A plugin's connector has no catalog entry: the process registry knows it.\n if (!entry && options.isDriverRegistered?.(ref.name)) continue;\n if (!entry) {\n target.warnings.push({\n code: \"missing_driver\",\n declarationId: ref.declarationId,\n name: ref.name,\n message:\n `Unknown ${ref.kind} driver \"${ref.name}\" referenced by ${ref.kind} \"${ref.declarationId}\". ` +\n `Run \\`skaile ${ref.kind} catalog\\` to see available drivers, ` +\n `or declare a repository in skaile.yaml that provides this driver.`,\n });\n continue;\n }\n const npm = (entry.metadata?.npm_deps ?? {}) as { required?: string[]; optional?: string[] };\n for (const p of npm.required ?? []) requiredSet.add(p);\n for (const p of npm.optional ?? []) optionalSet.add(p);\n }\n target.requiredNpmDeps.required = [...requiredSet];\n target.requiredNpmDeps.optional = [...optionalSet];\n}\n\n/**\n * Build the effective `repositories` map: caller's declarations first, then the\n * implicit built-in `factory-assets` repos. Each {@link factoryAssetRoots} layer\n * becomes its own repo, the env override inserted **before** the bundled\n * baseline so its connector entries win on the first-match dedup downstream.\n * When the package cannot be located at all, a path-less sentinel under\n * {@link FACTORY_ASSETS_REPO_NAME} drives the `repo_unavailable` warning.\n */\nfunction buildEffectiveRepositories(\n declared: Record<string, SourceDeclaration> | undefined,\n): Record<string, SourceDeclaration> {\n const result: Record<string, SourceDeclaration> = { ...(declared ?? {}) };\n const roots = factoryAssetRoots();\n if (roots.length === 0) {\n // Surface as a warning during scan rather than throwing here — let the\n // caller decide whether factory-assets is required. resolveRepoDir() /\n // repoUnavailableMessage re-discover the failure and emit it.\n if (!result[FACTORY_ASSETS_REPO_NAME]) result[FACTORY_ASSETS_REPO_NAME] = { path: \"\" };\n return result;\n }\n // override-first when both layers exist, so the env root's entries are scanned\n // (and matched) ahead of the bundled baseline.\n const keys =\n roots.length > 1\n ? [FACTORY_ASSETS_OVERRIDE_REPO_NAME, FACTORY_ASSETS_REPO_NAME]\n : [FACTORY_ASSETS_REPO_NAME];\n roots.forEach((dir, i) => {\n const key = keys[i] ?? `${FACTORY_ASSETS_REPO_NAME}:${i}`;\n if (!result[key]) result[key] = { path: dir };\n });\n return result;\n}\n\n/**\n * Resolve a repository declaration to an on-disk directory. Order:\n * 1. Linked override (`.skaile/links.yaml`).\n * 2. Local `path` — relative to `projectDir`.\n * 3. Cloned URL repo at `.skaile/cache/sources/<name>/` (must already exist).\n *\n * Returns `null` when none of these resolve. Does not clone.\n *\n * **Async and deadline-bounded since #454.** Every candidate here is a\n * project-relative or operator-supplied path, so a `sources[].path` of\n * `workspace/my-assets` resolves onto the rclone FUSE mount — the same tree the\n * scan that follows walks. Probing it with `existsSync`/`lstatSync` would park\n * the `skaile serve` event loop *before* the (now async) scan ever ran, which\n * would leave the H2 fix meaningless on the very declaration that triggers it.\n * A probe that misses its deadline reads as \"unavailable\", which is what the\n * caller already does with an absent path — it becomes a `repo_unavailable`\n * warning rather than a stall.\n */\nasync function resolveRepoDir(\n name: string,\n decl: SourceDeclaration,\n projectDir: string,\n links: Record<string, string>,\n): Promise<string | null> {\n // 1. Linked override\n const linked = links[name];\n if (linked && (await pathExists(linked))) return linked;\n\n // 2. Local path\n if (decl.path) {\n const resolved = resolvePath(projectDir, decl.path);\n return (await pathExists(resolved)) ? resolved : null;\n }\n\n // 3. URL repo cloned to project's .skaile/cache/sources/<name> — the\n // project-local clone dir (often a symlink into the global cache, which\n // lives at getGlobalCacheDir()); NOT the global clone root itself.\n if (decl.url) {\n const projectDest = join(projectDir, \".skaile\", \"cache\", \"sources\", name);\n // One `lstat` answers both questions the pre-#454 `existsSync` + `lstatSync`\n // pair asked, and `lstat` (not `stat`) keeps the \"a symlink into the global\n // cache counts\" behaviour intact.\n const found = await tryWithFsDeadline(\n `lstat ${projectDest}`,\n async () => {\n await lstat(projectDest);\n return true;\n },\n false,\n );\n return found ? projectDest : null;\n }\n\n return null;\n}\n\n/** Deadline-bounded `existsSync` replacement — a wedged mount reads as absent. */\nfunction pathExists(path: string): Promise<boolean> {\n return tryWithFsDeadline(\n `stat ${path}`,\n async () => {\n await stat(path);\n return true;\n },\n false,\n );\n}\n\nfunction repoUnavailableMessage(name: string, decl: SourceDeclaration): string {\n if (name === FACTORY_ASSETS_REPO_NAME && !decl.path && !decl.url) {\n return (\n `Cannot resolve the built-in factory-assets. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR or ensure @skaile/workspaces is installed.`\n );\n }\n if (decl.url) {\n return `Repository \"${name}\" (${decl.url}) is not available. Register it as a Library Source via \\`skaile source add\\`.`;\n }\n if (decl.path) {\n return `Repository \"${name}\" path not found: ${decl.path}`;\n }\n return `Repository \"${name}\" has neither url nor path.`;\n}\n\nfunction findCatalogEntry(\n entries: RuntimeCatalogEntry[],\n query: { kind?: \"connector\"; name: string },\n): RuntimeCatalogEntry | undefined {\n if (query.kind) {\n return entries.find((e) => e.kind === query.kind && e.name === query.name);\n }\n const matches = entries.filter((e) => e.name === query.name);\n if (matches.length === 1) return matches[0];\n // 0 or >1 with no kind — caller must disambiguate.\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../core/src/runtime-assets.ts"],"names":["resolvePath","require"],"mappings":";;;;;;;;AAsDA,SAAS,sBACP,OAAA,EACmC;AACnC,EAAA,MAAM,aAAa,iBAAA,EAAkB;AACrC,EAAA,MAAM,MAAyC,EAAC;AAChD,EAAA,KAAA,MAAW,CAAA,IAAK,OAAA,IAAW,EAAC,EAAG;AAC7B,IAAA,MAAM,GAAA,GAAM,cAAA,CAAe,CA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A,EACiC;AACjC,EAAA,IAAI,MAAM,IAAA,EAAM;AACd,IAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAI,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,MAAM,IAAI,CAAA;AAC3D,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG,OAAO,QAAQ,CAAC,CAAA;AAE1C,EAAA,OAAO,MAAA;AACT","file":"chunk-52HUF3DF.js","sourcesContent":["/**\n * Runtime asset resolution — read `skaile.yaml`, scan all declared repositories\n * (including the built-in `factory-assets/` directory as an implicit default),\n * and produce a unified view of connector catalog entries plus the implicit refs\n * that the `skaile.yaml` `connectors:` section adds to the dependency graph.\n *\n * This module is the single source of truth for \"which connectors does this\n * project see at runtime, and where do their implementations live on disk\".\n * Both the runner (serve, REPL, flow) and the platform's mid-session\n * `add_resource` flow consume `RuntimeAssetsResult.catalogEntries` and pass\n * it into `ConnectorManager` for catalog-based resolution.\n *\n * `factory-assets/` is the single first-party content tree (built-in connectors\n * + first-party skills + bundles) shipped inside the `@skaile/workspaces`\n * package — not a standalone package.\n *\n * It resolves to an **ordered list of roots** ({@link factoryAssetRoots}), not a\n * single dir. The bundled tree is always the baseline; an optional\n * `SKAILE_FACTORY_ASSETS_DIR` (legacy: `SKAILE_BASE_ASSETS_DIR`) is layered\n * **in front** as an additive override source — the agent container points it at\n * `/app/factory-assets/` (or a bind-mounted host dir) to ship updated skills /\n * flows / bundles / connector manifests without rebuilding the image. The two\n * roots resolve uniformly across every consumer (connector catalog scan, skill /\n * flow / completion discovery, the asset-manager factory source):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir, when set and existing (override layer).\n * 2. the bundled tree via {@link resolvePackagedAssetsDir} — the in-repo source\n * `packages/workspaces/factory-assets/` during dev, else the published\n * `dist/factory-assets/` after install (always-present baseline).\n *\n * Override semantics are **env-first**: on a name conflict the env root wins and\n * the bundled root fills the rest. Connector *code* still loads via the package's\n * static `exports` map, so the env root can override/add skills, flows, bundles,\n * and connector **manifests/metadata**, but cannot ship a new executable\n * connector — its `.js` is not on the package's import graph.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { lstat, stat } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { tryWithFsDeadline } from \"./fs-deadline.js\";\nimport { scanDirectory } from \"./manifest.js\";\nimport type { CatalogEntry } from \"./models.js\";\nimport { getGlobalCacheDir, readLinks, sourceCacheKey } from \"./repo-manager.js\";\nimport type { SourceDeclaration, SourceEntry } from \"./workspace-config.js\";\nimport { resolveSkWorkspaceConfig } from \"./workspace-config.js\";\n\n/**\n * Map declared `sources[]` to internal `SourceDeclaration`s keyed by the\n * collision-free {@link sourceCacheKey} (`<host>/<owner>/<repo>`), pointing at\n * the unified machine-cache clone path (`getGlobalCacheDir()/<key>/`). Keyed by\n * the same function every other cache writer/reader uses so the path resolves.\n */\nfunction sourcesToDeclarations(\n sources: SourceEntry[] | undefined,\n): Record<string, SourceDeclaration> {\n const sourcesDir = getGlobalCacheDir();\n const out: Record<string, SourceDeclaration> = {};\n for (const s of sources ?? []) {\n const key = sourceCacheKey(s.url);\n if (out[key]) continue;\n out[key] = {\n path: join(sourcesDir, key),\n url: s.url,\n branch: s.pin,\n ...(s.publisher ? { publisher: s.publisher } : {}),\n };\n }\n return out;\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Catalog entry filtered to mount/connector kinds. Same shape as `CatalogEntry`.\n * @docLink packages/core/concepts#runtime-catalog-entry\n */\nexport type RuntimeCatalogEntry = CatalogEntry;\n\n/**\n * Implicit catalog reference derived from a `connectors:` declaration in `skaile.yaml`.\n * Each connector driver becomes an implicit ref that must be resolved in the catalog.\n * @docLink packages/core/concepts#runtime-asset-ref\n */\nexport interface RuntimeAssetRef {\n kind: \"connector\";\n /** Driver name — matches `RuntimeCatalogEntry.name`. */\n name: string;\n /** Source declaration id from `skaile.yaml`. */\n declarationId: string;\n}\n\n/**\n * Aggregated npm packages required by all resolved mount/connector adapters.\n * Populated from `metadata.npm_deps` in each matched catalog entry.\n * @docLink packages/core/concepts#runtime-npm-deps\n */\nexport interface RuntimeNpmDeps {\n required: string[];\n optional: string[];\n}\n\n/**\n * Non-fatal warning emitted during `resolveRuntimeAssets` when a repo is unavailable\n * or a driver is not found in any catalog.\n * @docLink packages/core/concepts#runtime-asset-warning\n */\nexport interface RuntimeAssetWarning {\n /** Stable code for filtering / structured logging. */\n code: \"missing_driver\" | \"repo_unavailable\" | \"invalid_repo_decl\";\n message: string;\n /** Declaration id when applicable. */\n declarationId?: string;\n /** Driver / repository name when applicable. */\n name?: string;\n}\n\n/**\n * Repository name used for the implicit built-in `factory-assets` catalog entry\n * (the in-package connector tree).\n * @docLink packages/core/concepts#factory-assets-repo-name\n */\nexport const FACTORY_ASSETS_REPO_NAME = \"factory-assets\";\n\n/**\n * Repository name for the optional `SKAILE_FACTORY_ASSETS_DIR` override layer,\n * scanned ahead of (and overriding) the bundled {@link FACTORY_ASSETS_REPO_NAME}.\n */\nconst FACTORY_ASSETS_OVERRIDE_REPO_NAME = \"factory-assets:override\";\n\n/**\n * Result of `resolveRuntimeAssets`.\n * The same object is mutated in place by `refresh()`, allowing callers to hold\n * a stable reference and observe updates after a new repository is cloned or\n * a driver is installed mid-session.\n * @docLink packages/core/concepts#runtime-assets-result\n */\nexport interface RuntimeAssetsResult {\n catalogEntries: RuntimeCatalogEntry[];\n implicitRefs: RuntimeAssetRef[];\n requiredNpmDeps: RuntimeNpmDeps;\n warnings: RuntimeAssetWarning[];\n /** Re-scan repositories and re-derive implicit refs. Mutates in place. */\n refresh(): Promise<void>;\n /**\n * Catalog lookup. When `kind` is omitted and multiple entries share the\n * `name`, returns `undefined` (caller must disambiguate).\n */\n findEntry(query: { kind?: \"connector\"; name: string }): RuntimeCatalogEntry | undefined;\n}\n\n/** Options of {@link resolveRuntimeAssets}. */\nexport interface RuntimeAssetsOptions {\n /**\n * True when a connector driver is registered in the process (built-in or loaded plugin).\n * Core does not know the registry; the caller passes its lookup. Without it only the catalog\n * counts, so a driver a plugin registers is reported as `missing_driver`.\n */\n isDriverRegistered?: (driver: string) => boolean;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Resolve all runtime assets visible to a project by scanning declared repositories.\n *\n * Reads `skaile.yaml`, scans every declared repository (plus the implicit\n * built-in `factory-assets` repo), and derives implicit refs from `mounts:` /\n * `connectors:` declarations. Does not clone or install anything — purely a\n * read-only scan of what is already on disk. URL-only repositories that have\n * not been cloned yet are reported as `repo_unavailable` warnings.\n *\n * @param projectDir - Absolute path to the project workspace root\n * @param options - `isDriverRegistered`: a driver that no catalog entry lists but a plugin\n * registered is not reported as `missing_driver`\n * @returns `RuntimeAssetsResult` with catalog entries, implicit refs, npm deps, and warnings\n * @docLink packages/core/concepts#resolve-runtime-assets\n */\nexport async function resolveRuntimeAssets(\n projectDir: string,\n options: RuntimeAssetsOptions = {},\n): Promise<RuntimeAssetsResult> {\n const result: RuntimeAssetsResult = {\n catalogEntries: [],\n implicitRefs: [],\n requiredNpmDeps: { required: [], optional: [] },\n warnings: [],\n refresh: async () => {\n await populate(projectDir, result, options);\n },\n findEntry: (query) => findCatalogEntry(result.catalogEntries, query),\n };\n\n await populate(projectDir, result, options);\n return result;\n}\n\n/**\n * Resolve the ordered list of on-disk roots for the built-in `factory-assets`\n * tree (built-in connectors + first-party skills + bundles). This is the single\n * shared resolver every consumer goes through, so the env override and the\n * bundled baseline are honoured uniformly.\n *\n * Order (env-first = override-wins):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir (legacy: `SKAILE_BASE_ASSETS_DIR`),\n * when set and existing — an additive override layer.\n * 2. {@link resolvePackagedAssetsDir} — the bundled tree (in-repo source in dev,\n * `dist/factory-assets/` after install). Always-present baseline.\n *\n * Returns `[]` only when the package cannot be located at all. De-duplicated, so\n * pointing the env var at the bundled dir collapses to one root.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function factoryAssetRoots(): string[] {\n const roots: string[] = [];\n const envDir = process.env.SKAILE_FACTORY_ASSETS_DIR ?? process.env.SKAILE_BASE_ASSETS_DIR;\n // Deliberately still synchronous after #454: both candidates are\n // container-local (the image's `/app/factory-assets/`, or the installed\n // package tree resolved by `resolvePackagedAssetsDir`), never the FUSE\n // workspace mount. The mount-reachable probes on this module's scan path —\n // the project-relative `sources[].path` candidates in `resolveRepoDir` — are\n // async and deadline-bounded.\n if (envDir && existsSync(envDir)) roots.push(resolvePath(envDir));\n const bundled = resolvePackagedAssetsDir(\"factory-assets\");\n if (bundled) roots.push(bundled);\n return [...new Set(roots)];\n}\n\n/**\n * Resolve the primary on-disk root of the `factory-assets` tree — the first of\n * {@link factoryAssetRoots} (the env override when set, else the bundled tree).\n * Prefer {@link factoryAssetRoots} when you need to scan every layer; this\n * single-dir form is for callers that want one canonical path.\n *\n * @returns Absolute path to the highest-precedence `factory-assets` directory\n * @throws When no root can be located\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolveFactoryAssetsRoot(): string {\n const hit = resolveFactoryAssetsRootOrNull();\n if (hit) return hit;\n\n throw new Error(\n `Cannot resolve the factory-assets directory. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR to the on-disk path, ` +\n `ensure @skaile/workspaces is installed, ` +\n `or run from within the @skaile/workspaces package tree.`,\n );\n}\n\n/**\n * Non-throwing variant of {@link resolveFactoryAssetsRoot}: the same\n * env-then-packaged resolution tiers, returning `null` instead of throwing when\n * none locate the directory. Callers that treat a missing factory tree as a\n * soft \"not present\" (e.g. the asset-manager's implicit-source injection) MUST\n * use this so they honour the `SKAILE_FACTORY_ASSETS_DIR` container override\n * identically to the runtime path.\n */\nexport function resolveFactoryAssetsRootOrNull(): string | null {\n return factoryAssetRoots()[0] ?? null;\n}\n\n/**\n * Resolve the `@skaile/workspaces` package root — the directory containing its\n * `package.json`. Tries `require.resolve` first (works when installed as a\n * dependency *and* in-repo via the self-reference), then walks upward from this\n * module looking for a `package.json` whose `name` is `@skaile/workspaces`\n * (bounded to 8 levels). Returns `null` when neither locates it.\n *\n * The single source of truth for finding content shipped inside the package —\n * the unified `factory-assets/` tree (built-in connectors + first-party skills\n * + bundles) resolves through {@link resolvePackagedAssetsDir} on top of this.\n *\n * Memoized: the package location is immutable for the process lifetime, but\n * this sits on the CLI hot path (every `findSkills` / flow / completion call\n * funnels through here), so the `require.resolve` + upward `package.json` walk\n * runs once. `undefined` = not yet computed.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nlet workspacesPackageRootCache: string | null | undefined;\n\nexport function resolveWorkspacesPackageRoot(): string | null {\n if (workspacesPackageRootCache !== undefined) return workspacesPackageRootCache;\n workspacesPackageRootCache = computeWorkspacesPackageRoot();\n return workspacesPackageRootCache;\n}\n\nfunction computeWorkspacesPackageRoot(): string | null {\n try {\n const require = createRequire(import.meta.url);\n return dirname(require.resolve(\"@skaile/workspaces/package.json\"));\n } catch {\n // Fall through to the workspace walk.\n }\n let dir: string;\n try {\n dir = dirname(fileURLToPath(import.meta.url));\n } catch {\n return null;\n }\n for (let i = 0; i < 8; i++) {\n const pkgPath = join(dir, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as { name?: string };\n if (pkg.name === \"@skaile/workspaces\") return dir;\n } catch {\n // Ignore malformed package.json and keep walking.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Locate a content-asset directory inside the package. Prefers the in-repo\n * **source** dir `<pkgRoot>/<subdir>` when present — in a dev checkout it is the\n * full tree (e.g. `factory-assets/` keeps the connector `.ts` entry files that\n * `dist/` does not) — then the published `dist/<subdir>` copy (what\n * `files: [\"dist\"]` ships, the only one present after `npm i`). Returns `null`\n * when neither exists.\n *\n * `factory-assets/` resolves to the source tree in dev (code + skills + bundles)\n * and to `dist/factory-assets` post-install (compiled connectors + copied\n * manifests/skills/bundles).\n *\n * @param subdir - `\"factory-assets\"` | …\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolvePackagedAssetsDir(subdir: string): string | null {\n const root = resolveWorkspacesPackageRoot();\n if (!root) return null;\n for (const cand of [join(root, subdir), join(root, \"dist\", subdir)]) {\n if (existsSync(cand)) return cand;\n }\n return null;\n}\n\n// ─── Internals ────────────────────────────────────────────────────────────────\n\nconst CONNECTOR_SCAN_KINDS: ReadonlySet<string> = new Set([\"connector\"]);\n\nasync function populate(\n projectDir: string,\n target: RuntimeAssetsResult,\n options: RuntimeAssetsOptions,\n): Promise<void> {\n target.catalogEntries = [];\n target.implicitRefs = [];\n target.requiredNpmDeps = { required: [], optional: [] };\n target.warnings = [];\n\n const config = resolveSkWorkspaceConfig(projectDir);\n // Connector catalog scan runs over the project's declared sources[] (resolved\n // to their machine-cache clone paths) plus the implicit factory-assets repo.\n const repositories = buildEffectiveRepositories(sourcesToDeclarations(config.sources));\n const links = readLinks(projectDir);\n\n // Scan each repository for connector entries.\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = await resolveRepoDir(name, decl, projectDir, links);\n if (!repoDir) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: repoUnavailableMessage(name, decl),\n });\n continue;\n }\n try {\n // Both factory layers carry the same `factory-assets` provenance — the\n // override repo is an internal scan-order device, not a distinct source.\n const repoName = name === FACTORY_ASSETS_OVERRIDE_REPO_NAME ? FACTORY_ASSETS_REPO_NAME : name;\n // Only connector descriptors are consumed here, so only that kind is\n // \"known\": typed manifests of any other kind are irrelevant to this scan.\n const scanned = await scanDirectory(repoDir, repoName, {\n knownKinds: CONNECTOR_SCAN_KINDS,\n onDiagnostic: () => {},\n });\n const entries = scanned.filter((e) => e.kind === \"connector\");\n target.catalogEntries.push(...entries);\n } catch (err) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: `Failed to scan repository \"${name}\" at ${repoDir}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n });\n }\n }\n\n // De-duplicate by (kind, name), keeping the first occurrence. Scan order is\n // declared sources → env override → bundled baseline, so an env-supplied\n // connector manifest overrides the bundled one and the bundled one fills the\n // rest (the override layer can refresh built-in manifests in place).\n const seen = new Set<string>();\n target.catalogEntries = target.catalogEntries.filter((e) => {\n const key = `${e.kind}:${e.name}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n\n // Derive implicit refs from skaile.yaml connectors.\n for (const [index, c] of (config.connectors ?? []).entries()) {\n // No `driver` (a misspelt or old `adapter:` key): say so with the text `validate` prints,\n // not a warning about the driver `\"undefined\"` (p1739).\n if (typeof c.driver !== \"string\" || c.driver === \"\") {\n const legacy = (c as unknown as Record<string, unknown>).adapter;\n const label = typeof c.id === \"string\" && c.id !== \"\" ? `\"${c.id}\"` : `#${index + 1}`;\n target.warnings.push({\n code: \"missing_driver\",\n ...(typeof c.id === \"string\" && c.id !== \"\" ? { declarationId: c.id } : {}),\n message:\n legacy !== undefined\n ? `Connector ${label} sets \\`adapter: ${String(legacy)}\\`; the key is \\`driver\\`. Rename \\`adapter\\` to \\`driver\\`.`\n : `Connector ${label} has no \\`driver\\`; the runner cannot mount it. Add \\`driver: <name>\\`.`,\n });\n continue;\n }\n target.implicitRefs.push({ kind: \"connector\", name: c.driver, declarationId: c.id });\n }\n\n // Validate refs and aggregate npm deps.\n const requiredSet = new Set<string>();\n const optionalSet = new Set<string>();\n for (const ref of target.implicitRefs) {\n const entry = findCatalogEntry(target.catalogEntries, ref);\n // A plugin's connector has no catalog entry: the process registry knows it.\n if (!entry && options.isDriverRegistered?.(ref.name)) continue;\n if (!entry) {\n target.warnings.push({\n code: \"missing_driver\",\n declarationId: ref.declarationId,\n name: ref.name,\n message:\n `Unknown ${ref.kind} driver \"${ref.name}\" referenced by ${ref.kind} \"${ref.declarationId}\". ` +\n `Run \\`skaile ${ref.kind} catalog\\` to see available drivers, ` +\n `or declare a repository in skaile.yaml that provides this driver.`,\n });\n continue;\n }\n const npm = (entry.metadata?.npm_deps ?? {}) as { required?: string[]; optional?: string[] };\n for (const p of npm.required ?? []) requiredSet.add(p);\n for (const p of npm.optional ?? []) optionalSet.add(p);\n }\n target.requiredNpmDeps.required = [...requiredSet];\n target.requiredNpmDeps.optional = [...optionalSet];\n}\n\n/**\n * Build the effective `repositories` map: caller's declarations first, then the\n * implicit built-in `factory-assets` repos. Each {@link factoryAssetRoots} layer\n * becomes its own repo, the env override inserted **before** the bundled\n * baseline so its connector entries win on the first-match dedup downstream.\n * When the package cannot be located at all, a path-less sentinel under\n * {@link FACTORY_ASSETS_REPO_NAME} drives the `repo_unavailable` warning.\n */\nfunction buildEffectiveRepositories(\n declared: Record<string, SourceDeclaration> | undefined,\n): Record<string, SourceDeclaration> {\n const result: Record<string, SourceDeclaration> = { ...(declared ?? {}) };\n const roots = factoryAssetRoots();\n if (roots.length === 0) {\n // Surface as a warning during scan rather than throwing here — let the\n // caller decide whether factory-assets is required. resolveRepoDir() /\n // repoUnavailableMessage re-discover the failure and emit it.\n if (!result[FACTORY_ASSETS_REPO_NAME]) result[FACTORY_ASSETS_REPO_NAME] = { path: \"\" };\n return result;\n }\n // override-first when both layers exist, so the env root's entries are scanned\n // (and matched) ahead of the bundled baseline.\n const keys =\n roots.length > 1\n ? [FACTORY_ASSETS_OVERRIDE_REPO_NAME, FACTORY_ASSETS_REPO_NAME]\n : [FACTORY_ASSETS_REPO_NAME];\n roots.forEach((dir, i) => {\n const key = keys[i] ?? `${FACTORY_ASSETS_REPO_NAME}:${i}`;\n if (!result[key]) result[key] = { path: dir };\n });\n return result;\n}\n\n/**\n * Resolve a repository declaration to an on-disk directory. Order:\n * 1. Linked override (`.skaile/links.yaml`).\n * 2. Local `path` — relative to `projectDir`.\n * 3. Cloned URL repo at `.skaile/cache/sources/<name>/` (must already exist).\n *\n * Returns `null` when none of these resolve. Does not clone.\n *\n * **Async and deadline-bounded since #454.** Every candidate here is a\n * project-relative or operator-supplied path, so a `sources[].path` of\n * `workspace/my-assets` resolves onto the rclone FUSE mount — the same tree the\n * scan that follows walks. Probing it with `existsSync`/`lstatSync` would park\n * the `skaile serve` event loop *before* the (now async) scan ever ran, which\n * would leave the H2 fix meaningless on the very declaration that triggers it.\n * A probe that misses its deadline reads as \"unavailable\", which is what the\n * caller already does with an absent path — it becomes a `repo_unavailable`\n * warning rather than a stall.\n */\nasync function resolveRepoDir(\n name: string,\n decl: SourceDeclaration,\n projectDir: string,\n links: Record<string, string>,\n): Promise<string | null> {\n // 1. Linked override\n const linked = links[name];\n if (linked && (await pathExists(linked))) return linked;\n\n // 2. Local path\n if (decl.path) {\n const resolved = resolvePath(projectDir, decl.path);\n return (await pathExists(resolved)) ? resolved : null;\n }\n\n // 3. URL repo cloned to project's .skaile/cache/sources/<name> — the\n // project-local clone dir (often a symlink into the global cache, which\n // lives at getGlobalCacheDir()); NOT the global clone root itself.\n if (decl.url) {\n const projectDest = join(projectDir, \".skaile\", \"cache\", \"sources\", name);\n // One `lstat` answers both questions the pre-#454 `existsSync` + `lstatSync`\n // pair asked, and `lstat` (not `stat`) keeps the \"a symlink into the global\n // cache counts\" behaviour intact.\n const found = await tryWithFsDeadline(\n `lstat ${projectDest}`,\n async () => {\n await lstat(projectDest);\n return true;\n },\n false,\n );\n return found ? projectDest : null;\n }\n\n return null;\n}\n\n/** Deadline-bounded `existsSync` replacement — a wedged mount reads as absent. */\nfunction pathExists(path: string): Promise<boolean> {\n return tryWithFsDeadline(\n `stat ${path}`,\n async () => {\n await stat(path);\n return true;\n },\n false,\n );\n}\n\nfunction repoUnavailableMessage(name: string, decl: SourceDeclaration): string {\n if (name === FACTORY_ASSETS_REPO_NAME && !decl.path && !decl.url) {\n return (\n `Cannot resolve the built-in factory-assets. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR or ensure @skaile/workspaces is installed.`\n );\n }\n if (decl.url) {\n return `Repository \"${name}\" (${decl.url}) is not available. Register it as a Library Source via \\`skaile source add\\`.`;\n }\n if (decl.path) {\n return `Repository \"${name}\" path not found: ${decl.path}`;\n }\n return `Repository \"${name}\" has neither url nor path.`;\n}\n\nfunction findCatalogEntry(\n entries: RuntimeCatalogEntry[],\n query: { kind?: \"connector\"; name: string },\n): RuntimeCatalogEntry | undefined {\n if (query.kind) {\n return entries.find((e) => e.kind === query.kind && e.name === query.name);\n }\n const matches = entries.filter((e) => e.name === query.name);\n if (matches.length === 1) return matches[0];\n // 0 or >1 with no kind — caller must disambiguate.\n return undefined;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getKindRegistry } from './chunk-
|
|
2
|
-
import { logErr } from './chunk-
|
|
1
|
+
import { getKindRegistry } from './chunk-QZS7E3DY.js';
|
|
2
|
+
import { logErr } from './chunk-5L3UCHBK.js';
|
|
3
3
|
import { userConfigPath } from './chunk-L5VSIPQD.js';
|
|
4
4
|
|
|
5
5
|
// cli/src/open-library.ts
|
|
@@ -90,5 +90,5 @@ async function openLibraryManager() {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export { LocalCatalogDisabledError, openCatalogSource, openLibrary, openLibraryManager, resolveCatalogSource };
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-57B4DG3Y.js.map
|
|
94
|
+
//# sourceMappingURL=chunk-57B4DG3Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/open-library.ts"],"names":["source"],"mappings":";;;;;AAkBO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EACnD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM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AU,IAAI,cAAA,CAAe,OAAO,CAAA;AAC1C,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAC1D","file":"chunk-Z7HLX4V2.js","sourcesContent":["/**\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 { userConfigPath } from \"@skaile/workspaces/core\";\nimport { logErr } from \"./helpers.ts\";\nimport { getKindRegistry } 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: getKindRegistry() });\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 library init <name> --path <dir>` for a local folder, \" +\n `or set \\`catalog.url: https://skaile.store\\` in ${userConfigPath()}.`,\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 libraryDirMissing,\n missingLibraryDirMessage,\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 // A registered library whose directory is gone has one wording everywhere.\n const gone = sources.filter(libraryDirMissing);\n if (usable.length === 0) {\n if (gone.length > 0) throw new Error(gone.map(missingLibraryDirMessage).join(\"\\n\"));\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile library init <name> --path <dir>` first (a git repo: `skaile source add <git-url>`).\",\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 throw new Error(gone.map(missingLibraryDirMessage).join(\"\\n\"));\n }\n\n const source = new LocalCatalogSource(library, present.id, present.path, getKindRegistry());\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-library.ts"],"names":["source"],"mappings":";;;;;AAkBO,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,eAAA,IAAmB,CAAA;AAAA,EAC3D,SAAS,GAAA,E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AAA,MAAM,IAAI,MAAM,IAAA,CAAK,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,MAC/D;AAEA,MAAA,MAAMA,OAAAA,GAAS,IAAI,kBAAA,CAAmB,OAAA,EAAS,QAAQ,EAAA,EAAI,OAAA,CAAQ,IAAA,EAAM,eAAA,EAAiB,CAAA;AAC1F,MAAA,OAAO,EAAE,MAAA,EAAAA,OAAAA,EAAQ,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAAA,IAChD,SAAS,GAAA,EAAK;AAGZ,MAAA,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-57B4DG3Y.js","sourcesContent":["/**\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 { userConfigPath } from \"@skaile/workspaces/core\";\nimport { logErr } from \"./helpers.ts\";\nimport { getKindRegistry } 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: getKindRegistry() });\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 library init <name> --path <dir>` for a local folder, \" +\n `or set \\`catalog.url: https://skaile.store\\` in ${userConfigPath()}.`,\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 libraryDirMissing,\n missingLibraryDirMessage,\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 // A registered library whose directory is gone has one wording everywhere.\n const gone = sources.filter(libraryDirMissing);\n if (usable.length === 0) {\n if (gone.length > 0) throw new Error(gone.map(missingLibraryDirMessage).join(\"\\n\"));\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile library init <name> --path <dir>` first (a git repo: `skaile source add <git-url>`).\",\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 throw new Error(gone.map(missingLibraryDirMessage).join(\"\\n\"));\n }\n\n const source = new LocalCatalogSource(library, present.id, present.path, getKindRegistry());\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,10 +1,10 @@
|
|
|
1
|
-
import { loadDeclaredPlugins } from './chunk-
|
|
2
|
-
import { preflight } from './chunk-
|
|
3
|
-
import { listHarnesses } from './chunk-
|
|
4
|
-
import { softDepName } from './chunk-
|
|
5
|
-
import { readLock, LockParseError } from './chunk-
|
|
6
|
-
import { resolveRuntimeAssets } from './chunk-
|
|
7
|
-
import { resolveAgentDefinitionDir, AgentRefResolutionError, normalizeAgentInstances, agentBlockKeyDiagnostics, agentInstanceDiagnostics, localConnectorMountDir, symlinkEscapeOfProject, isInsideProject, loadSkWorkspaceConfig, SKAILE_YAML_DEFAULT, resolveSkWorkspaceConfig } from './chunk-
|
|
1
|
+
import { loadDeclaredPlugins } from './chunk-XHWBSC53.js';
|
|
2
|
+
import { preflight } from './chunk-E2VPBB7C.js';
|
|
3
|
+
import { listHarnesses } from './chunk-SOAQP4BI.js';
|
|
4
|
+
import { softDepName } from './chunk-4BVE6JTM.js';
|
|
5
|
+
import { readLock, LockParseError } from './chunk-ZHI3YMGQ.js';
|
|
6
|
+
import { resolveRuntimeAssets } from './chunk-52HUF3DF.js';
|
|
7
|
+
import { resolveAgentDefinitionDir, AgentRefResolutionError, normalizeAgentInstances, agentBlockKeyDiagnostics, agentInstanceDiagnostics, localConnectorMountDir, symlinkEscapeOfProject, isInsideProject, loadSkWorkspaceConfig, SKAILE_YAML_DEFAULT, resolveSkWorkspaceConfig } from './chunk-GXW4B5SE.js';
|
|
8
8
|
import { SUPPORTED_HARNESSES } from './chunk-VTETQCR6.js';
|
|
9
9
|
import fs, { existsSync, readdirSync, readFileSync } from 'fs';
|
|
10
10
|
import { homedir } from 'os';
|
|
@@ -692,5 +692,5 @@ function warnFilesOnlyDelegates(projectDir, target) {
|
|
|
692
692
|
}
|
|
693
693
|
|
|
694
694
|
export { KIND_COL_WIDTH, S, TARGET_DEFAULT_HINT, agentDefinitionProblem, agentInstanceErrorLines, bareSoftDepName, canonicalHarnessId, checkAgentInstances, colorRef, connectorErrorLines, connectorMountPathChecks, deferredWarnings, driverAliasOption, fitWidth, foldDriverFlag, formatRelativeTime, formatSoftDepAddPreview, formatSoftDepHint, formatSoftDepRemovePreview, formatSoftDepSection, friendlyHarnessError, harnessErrorNotes, instanceRefProblem, isRecord, kindColor, kindColorPad, logErr, logInfo, logNoProject, logOk, logWarn, logWarnErr, noteExperimentalHarness, parseHarnessFilter, reportLegacyOmpCopies, reportProjectConfig, reportUnknownHarnesses, requireProjectConfig, setActiveCommand, unknownConnectorDriverErrors, unknownHarnessErrors, unknownHarnessTargetMessage, unknownKeyWarnings, warnFilesOnlyDelegates, warnPlaceholderBodies, warnProjectConfig, warnStaleHarnessCopies };
|
|
695
|
-
//# sourceMappingURL=chunk-
|
|
696
|
-
//# sourceMappingURL=chunk-
|
|
695
|
+
//# sourceMappingURL=chunk-5L3UCHBK.js.map
|
|
696
|
+
//# sourceMappingURL=chunk-5L3UCHBK.js.map
|