@skaile/workspaces 6.5.0 → 6.6.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 +8 -0
- package/dist/ai-sdk.js +9 -9
- package/dist/{asset-feeds-4I6Z4OI3.js → asset-feeds-WQ6YQPHV.js} +20 -20
- package/dist/{asset-feeds-4I6Z4OI3.js.map → asset-feeds-WQ6YQPHV.js.map} +1 -1
- package/dist/asset-manager/catalog-deployer.js +7 -7
- package/dist/asset-manager/index.js +12 -12
- package/dist/asset-manager/installer.js +8 -8
- package/dist/asset-manager/renderers.js +7 -7
- package/dist/bridge/harnesses/claude-sdk.js +10 -10
- package/dist/bridge/harnesses/codex.js +11 -11
- package/dist/bridge/harnesses/continue.js +10 -10
- package/dist/bridge/harnesses/echo.js +3 -3
- package/dist/bridge/harnesses/gemini.js +7 -7
- package/dist/bridge/harnesses/goose.js +10 -10
- package/dist/bridge/harnesses/omp.js +5 -5
- package/dist/bridge/harnesses/opencode.js +10 -10
- package/dist/bridge/harnesses/qwen.js +7 -7
- package/dist/bridge/index.js +15 -15
- package/dist/{chunk-J5JWLKLB.js → chunk-2TLPC6TQ.js} +11 -11
- package/dist/{chunk-J5JWLKLB.js.map → chunk-2TLPC6TQ.js.map} +1 -1
- package/dist/{chunk-2IAWVUW3.js → chunk-4BFEPZ6J.js} +4 -4
- package/dist/{chunk-2IAWVUW3.js.map → chunk-4BFEPZ6J.js.map} +1 -1
- package/dist/{chunk-KUADKMNX.js → chunk-4J7JQX4G.js} +4 -4
- package/dist/{chunk-KUADKMNX.js.map → chunk-4J7JQX4G.js.map} +1 -1
- package/dist/{chunk-USVUS4DJ.js → chunk-5ETYBC2X.js} +7 -7
- package/dist/{chunk-USVUS4DJ.js.map → chunk-5ETYBC2X.js.map} +1 -1
- package/dist/{chunk-X44XKBZX.js → chunk-5XHQBCB5.js} +3 -3
- package/dist/{chunk-X44XKBZX.js.map → chunk-5XHQBCB5.js.map} +1 -1
- package/dist/{chunk-OLHHN3NO.js → chunk-65UAC3ZR.js} +3 -3
- package/dist/{chunk-OLHHN3NO.js.map → chunk-65UAC3ZR.js.map} +1 -1
- package/dist/{chunk-7H4GTP7V.js → chunk-6A6HE5LW.js} +3 -3
- package/dist/{chunk-7H4GTP7V.js.map → chunk-6A6HE5LW.js.map} +1 -1
- package/dist/{chunk-UMLCKKIA.js → chunk-6ARPZHOV.js} +6 -6
- package/dist/{chunk-UMLCKKIA.js.map → chunk-6ARPZHOV.js.map} +1 -1
- package/dist/{chunk-K4DHYTUM.js → chunk-6RHWTZPT.js} +3 -3
- package/dist/{chunk-K4DHYTUM.js.map → chunk-6RHWTZPT.js.map} +1 -1
- package/dist/{chunk-IWKKTCXY.js → chunk-6SXSVKQY.js} +7 -5
- package/dist/chunk-6SXSVKQY.js.map +1 -0
- package/dist/{chunk-OBZ5WQ32.js → chunk-7I5PNB2G.js} +3 -3
- package/dist/{chunk-OBZ5WQ32.js.map → chunk-7I5PNB2G.js.map} +1 -1
- package/dist/{chunk-SRTWKZP2.js → chunk-7PVGND4J.js} +8 -8
- package/dist/{chunk-SRTWKZP2.js.map → chunk-7PVGND4J.js.map} +1 -1
- package/dist/{chunk-TROEC2Z2.js → chunk-7SJHSGUV.js} +16 -16
- package/dist/{chunk-TROEC2Z2.js.map → chunk-7SJHSGUV.js.map} +1 -1
- package/dist/{chunk-TNQLDEM6.js → chunk-AQNW2FET.js} +230 -35
- package/dist/chunk-AQNW2FET.js.map +1 -0
- package/dist/{chunk-6EKQENAP.js → chunk-B6N653ZG.js} +6 -6
- package/dist/{chunk-6EKQENAP.js.map → chunk-B6N653ZG.js.map} +1 -1
- package/dist/{chunk-NSIOBKDX.js → chunk-BSMW3PX2.js} +2 -2
- package/dist/{chunk-NSIOBKDX.js.map → chunk-BSMW3PX2.js.map} +1 -1
- package/dist/{chunk-HTGTNN2B.js → chunk-CMXDFTA2.js} +3 -3
- package/dist/{chunk-HTGTNN2B.js.map → chunk-CMXDFTA2.js.map} +1 -1
- package/dist/{chunk-2HS357RA.js → chunk-DI6J2PJB.js} +7 -7
- package/dist/{chunk-2HS357RA.js.map → chunk-DI6J2PJB.js.map} +1 -1
- package/dist/{chunk-T7HGEMNB.js → chunk-DS6UUCFG.js} +3 -3
- package/dist/{chunk-T7HGEMNB.js.map → chunk-DS6UUCFG.js.map} +1 -1
- package/dist/{chunk-23SG4JRV.js → chunk-E2EC6SAX.js} +3 -3
- package/dist/{chunk-23SG4JRV.js.map → chunk-E2EC6SAX.js.map} +1 -1
- package/dist/{chunk-ETF6Q3R3.js → chunk-EPXZQIC6.js} +3 -3
- package/dist/{chunk-ETF6Q3R3.js.map → chunk-EPXZQIC6.js.map} +1 -1
- package/dist/{chunk-SZTHSPRC.js → chunk-F4CZQD3T.js} +3 -3
- package/dist/{chunk-SZTHSPRC.js.map → chunk-F4CZQD3T.js.map} +1 -1
- package/dist/{chunk-AVFRFGM2.js → chunk-GNUA7XT2.js} +3 -2
- package/dist/chunk-GNUA7XT2.js.map +1 -0
- package/dist/{chunk-6Y3SC7O4.js → chunk-GTAHU4N4.js} +4 -4
- package/dist/{chunk-6Y3SC7O4.js.map → chunk-GTAHU4N4.js.map} +1 -1
- package/dist/{chunk-3KSLUVKB.js → chunk-GTGWRKMJ.js} +6 -6
- package/dist/{chunk-3KSLUVKB.js.map → chunk-GTGWRKMJ.js.map} +1 -1
- package/dist/{chunk-YRC2EFOU.js → chunk-HGZN6JLP.js} +4 -4
- package/dist/{chunk-YRC2EFOU.js.map → chunk-HGZN6JLP.js.map} +1 -1
- package/dist/{chunk-KYNCY3F3.js → chunk-HQAPUPBE.js} +3 -3
- package/dist/{chunk-KYNCY3F3.js.map → chunk-HQAPUPBE.js.map} +1 -1
- package/dist/{chunk-HPA3RP5E.js → chunk-I5IF3JCG.js} +3 -3
- package/dist/{chunk-HPA3RP5E.js.map → chunk-I5IF3JCG.js.map} +1 -1
- package/dist/{chunk-7EMS2GZO.js → chunk-J262X4JU.js} +12 -12
- package/dist/{chunk-7EMS2GZO.js.map → chunk-J262X4JU.js.map} +1 -1
- package/dist/{chunk-22ZX33H6.js → chunk-J4WKNJHO.js} +4 -4
- package/dist/{chunk-22ZX33H6.js.map → chunk-J4WKNJHO.js.map} +1 -1
- package/dist/{chunk-G4NCSYWR.js → chunk-JIQUF3X2.js} +4 -4
- package/dist/{chunk-G4NCSYWR.js.map → chunk-JIQUF3X2.js.map} +1 -1
- package/dist/{chunk-IS3NIZBX.js → chunk-JRVQV7WC.js} +11 -11
- package/dist/{chunk-IS3NIZBX.js.map → chunk-JRVQV7WC.js.map} +1 -1
- package/dist/{chunk-UZET67SO.js → chunk-LBJ4M5J2.js} +4 -4
- package/dist/{chunk-UZET67SO.js.map → chunk-LBJ4M5J2.js.map} +1 -1
- package/dist/{chunk-TGUMN5G7.js → chunk-MMOWIRHP.js} +8 -8
- package/dist/{chunk-TGUMN5G7.js.map → chunk-MMOWIRHP.js.map} +1 -1
- package/dist/{chunk-EO7KGX6P.js → chunk-MXI3XWV6.js} +4 -4
- package/dist/{chunk-EO7KGX6P.js.map → chunk-MXI3XWV6.js.map} +1 -1
- package/dist/{chunk-LE6QS4PG.js → chunk-N2PBAXAA.js} +3 -3
- package/dist/{chunk-LE6QS4PG.js.map → chunk-N2PBAXAA.js.map} +1 -1
- package/dist/{chunk-YBEJCQE5.js → chunk-O7QZI6MQ.js} +3 -3
- package/dist/{chunk-YBEJCQE5.js.map → chunk-O7QZI6MQ.js.map} +1 -1
- package/dist/{chunk-ZUU2PLA3.js → chunk-OY22B7E2.js} +3 -3
- package/dist/{chunk-ZUU2PLA3.js.map → chunk-OY22B7E2.js.map} +1 -1
- package/dist/{chunk-W5KCAWGN.js → chunk-PTJTOPE5.js} +3 -3
- package/dist/{chunk-W5KCAWGN.js.map → chunk-PTJTOPE5.js.map} +1 -1
- package/dist/{chunk-WFLQMAR5.js → chunk-RAU5QPI6.js} +5 -5
- package/dist/{chunk-WFLQMAR5.js.map → chunk-RAU5QPI6.js.map} +1 -1
- package/dist/{chunk-AFTZNR2W.js → chunk-RHCEX2EV.js} +3 -3
- package/dist/{chunk-AFTZNR2W.js.map → chunk-RHCEX2EV.js.map} +1 -1
- package/dist/{chunk-Z2X7UZEZ.js → chunk-SCRYXAHH.js} +6 -6
- package/dist/{chunk-Z2X7UZEZ.js.map → chunk-SCRYXAHH.js.map} +1 -1
- package/dist/{chunk-DKXNKFKP.js → chunk-SGI5MRKP.js} +75 -3
- package/dist/chunk-SGI5MRKP.js.map +1 -0
- package/dist/{chunk-KA2GLAPS.js → chunk-SHTXMERQ.js} +7 -7
- package/dist/{chunk-KA2GLAPS.js.map → chunk-SHTXMERQ.js.map} +1 -1
- package/dist/{chunk-SN663FCA.js → chunk-SZKCE7EC.js} +5 -5
- package/dist/{chunk-SN663FCA.js.map → chunk-SZKCE7EC.js.map} +1 -1
- package/dist/{chunk-S7DVT2BV.js → chunk-TCH5UDKT.js} +4 -4
- package/dist/{chunk-S7DVT2BV.js.map → chunk-TCH5UDKT.js.map} +1 -1
- package/dist/{chunk-THX5EE3K.js → chunk-TUFNY6OD.js} +3 -3
- package/dist/{chunk-THX5EE3K.js.map → chunk-TUFNY6OD.js.map} +1 -1
- package/dist/{chunk-EN5REMWV.js → chunk-U3UDOX6I.js} +4 -4
- package/dist/{chunk-EN5REMWV.js.map → chunk-U3UDOX6I.js.map} +1 -1
- package/dist/{chunk-3DA74PLW.js → chunk-USSP43U3.js} +3 -3
- package/dist/{chunk-3DA74PLW.js.map → chunk-USSP43U3.js.map} +1 -1
- package/dist/{chunk-U6KRTCNA.js → chunk-VJRL6ZK6.js} +3 -3
- package/dist/{chunk-U6KRTCNA.js.map → chunk-VJRL6ZK6.js.map} +1 -1
- package/dist/{chunk-B4BLJUYN.js → chunk-VXYZ5M7Z.js} +24 -18
- package/dist/{chunk-B4BLJUYN.js.map → chunk-VXYZ5M7Z.js.map} +1 -1
- package/dist/{chunk-E6UWI3TP.js → chunk-WW5NAU6N.js} +3 -3
- package/dist/{chunk-E6UWI3TP.js.map → chunk-WW5NAU6N.js.map} +1 -1
- package/dist/{chunk-J6YPKMMY.js → chunk-XD3RYAMR.js} +6 -6
- package/dist/{chunk-J6YPKMMY.js.map → chunk-XD3RYAMR.js.map} +1 -1
- package/dist/{chunk-DNXPXJ3X.js → chunk-XYCYGN3Q.js} +14 -14
- package/dist/{chunk-DNXPXJ3X.js.map → chunk-XYCYGN3Q.js.map} +1 -1
- package/dist/{chunk-B436SG5P.js → chunk-YN6N3RBM.js} +7 -7
- package/dist/{chunk-B436SG5P.js.map → chunk-YN6N3RBM.js.map} +1 -1
- package/dist/{chunk-TDPQOR3C.js → chunk-Z4FERR4U.js} +2 -2
- package/dist/{chunk-TDPQOR3C.js.map → chunk-Z4FERR4U.js.map} +1 -1
- package/dist/{claude-code-JY6CYEG7.js → claude-code-LZH7Y4Y5.js} +5 -5
- package/dist/{claude-code-JY6CYEG7.js.map → claude-code-LZH7Y4Y5.js.map} +1 -1
- package/dist/cli/index.js +91 -91
- package/dist/connectors/config.js +4 -4
- package/dist/connectors/index.js +18 -18
- package/dist/connectors/src/connector-manager.d.ts.map +1 -1
- package/dist/connectors/src/mount-ledger.d.ts.map +1 -1
- package/dist/{connectors-VLFOQNS6.js → connectors-HU5MHSUJ.js} +21 -21
- package/dist/{connectors-VLFOQNS6.js.map → connectors-HU5MHSUJ.js.map} +1 -1
- package/dist/core/index.js +6 -6
- package/dist/core/logging.js +1 -1
- package/dist/core/manifest.js +1 -1
- package/dist/core/publish-manifest.js +2 -2
- package/dist/core/runtime-assets.js +4 -4
- package/dist/core/src/logging/index.d.ts +1 -0
- package/dist/core/src/logging/index.d.ts.map +1 -1
- package/dist/core/src/logging/log-safe-text.d.ts +20 -0
- package/dist/core/src/logging/log-safe-text.d.ts.map +1 -0
- package/dist/core/src/manifest.d.ts.map +1 -1
- 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 +3 -3
- package/dist/deploy/index.js +6 -6
- package/dist/discovery/index.js +3 -3
- package/dist/{ensure-sources-6O54DUQB.js → ensure-sources-CAMWJTMR.js} +24 -24
- package/dist/{ensure-sources-6O54DUQB.js.map → ensure-sources-CAMWJTMR.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +18 -18
- package/dist/factory-assets/connectors/deploy.js +18 -18
- package/dist/factory-assets/connectors/devserver.js +18 -18
- package/dist/factory-assets/connectors/flow/adapter.js +18 -18
- package/dist/factory-assets/connectors/flow/engine.js +7 -7
- package/dist/factory-assets/connectors/flow/run-flow.js +20 -20
- package/dist/factory-assets/connectors/flow.js +18 -18
- package/dist/factory-assets/connectors/git.js +18 -18
- package/dist/factory-assets/connectors/gmail.js +18 -18
- package/dist/factory-assets/connectors/googledrive.js +18 -18
- package/dist/factory-assets/connectors/local.js +18 -18
- package/dist/factory-assets/connectors/mattermost.js +18 -18
- package/dist/factory-assets/connectors/memory.js +18 -18
- package/dist/factory-assets/connectors/minio.js +18 -18
- package/dist/factory-assets/connectors/postgres.js +18 -18
- package/dist/factory-assets/connectors/s3.js +18 -18
- package/dist/factory-assets/connectors/sharepoint.js +18 -18
- package/dist/factory-assets/connectors/sqlite.js +18 -18
- package/dist/factory-assets/connectors/static-server.js +18 -18
- package/dist/factory-assets/connectors/tunnel.js +18 -18
- package/dist/factory-assets/connectors/webdav.js +18 -18
- package/dist/factory-assets/connectors/xstate-store.js +18 -18
- package/dist/factory-assets/connectors/xstate.js +18 -18
- package/dist/{flows-CIUPK7SB.js → flows-GVOVQGQW.js} +11 -11
- package/dist/{flows-CIUPK7SB.js.map → flows-GVOVQGQW.js.map} +1 -1
- package/dist/{helpers-YHDQHQEQ.js → helpers-WMCCODAV.js} +24 -24
- package/dist/{helpers-YHDQHQEQ.js.map → helpers-WMCCODAV.js.map} +1 -1
- package/dist/library/index.js +9 -9
- package/dist/library/install.js +3 -3
- package/dist/{library-publish-MUGUST43.js → library-publish-UQQMHTND.js} +49 -49
- package/dist/{library-publish-MUGUST43.js.map → library-publish-UQQMHTND.js.map} +1 -1
- package/dist/model-endpoint/index.js +9 -9
- package/dist/{open-library-BVQCB37E.js → open-library-OJ4HT2X4.js} +27 -27
- package/dist/{open-library-BVQCB37E.js.map → open-library-OJ4HT2X4.js.map} +1 -1
- package/dist/{open-registry-JCSIAKEC.js → open-registry-LWGIOJDK.js} +13 -13
- package/dist/{open-registry-JCSIAKEC.js.map → open-registry-LWGIOJDK.js.map} +1 -1
- package/dist/{paths-XLKCAFRZ.js → paths-FR2752HV.js} +9 -9
- package/dist/{paths-XLKCAFRZ.js.map → paths-FR2752HV.js.map} +1 -1
- package/dist/{plugin-store-NGRUTCJI.js → plugin-store-IALJUBN2.js} +9 -9
- package/dist/{plugin-store-NGRUTCJI.js.map → plugin-store-IALJUBN2.js.map} +1 -1
- package/dist/{project-BGYMLAS6.js → project-UQFCYHYS.js} +45 -45
- package/dist/{project-BGYMLAS6.js.map → project-UQFCYHYS.js.map} +1 -1
- package/dist/resolver/index.js +7 -7
- package/dist/runner/index.js +34 -34
- package/dist/runner/src/external-mcp.d.ts +22 -0
- package/dist/runner/src/external-mcp.d.ts.map +1 -1
- package/dist/runner/src/mcp-tools-snapshot.d.ts +13 -0
- package/dist/runner/src/mcp-tools-snapshot.d.ts.map +1 -0
- package/dist/runner/src/resources.d.ts +14 -0
- package/dist/runner/src/resources.d.ts.map +1 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +12 -12
- package/dist/sdk/bridge.js +15 -15
- package/dist/sdk/core.js +6 -6
- package/dist/sdk/flow.js +7 -7
- package/dist/sdk/index.js +34 -34
- package/dist/sdk/resolver.js +7 -7
- package/dist/sdk/runner.js +34 -34
- package/dist/sdk/transport/ws/server.js +7 -7
- package/dist/sdk/transport/ws.js +7 -7
- package/dist/sdk/transport.js +7 -7
- package/dist/{serve-preflight-GQY5DZX6.js → serve-preflight-TYEKHC32.js} +27 -27
- package/dist/{serve-preflight-GQY5DZX6.js.map → serve-preflight-TYEKHC32.js.map} +1 -1
- package/dist/{setup-2NWSKSCO.js → setup-4JV2IMCB.js} +25 -25
- package/dist/{setup-2NWSKSCO.js.map → setup-4JV2IMCB.js.map} +1 -1
- package/dist/{skills-PXZOL2FZ.js → skills-6QTKFMLW.js} +12 -12
- package/dist/{skills-PXZOL2FZ.js.map → skills-6QTKFMLW.js.map} +1 -1
- package/dist/{source-XA3L4H6I.js → source-XYMMJVKR.js} +44 -44
- package/dist/{source-XA3L4H6I.js.map → source-XYMMJVKR.js.map} +1 -1
- package/dist/{source-manifest-publish-QEGMTS33.js → source-manifest-publish-SZFGGKB4.js} +46 -46
- package/dist/{source-manifest-publish-QEGMTS33.js.map → source-manifest-publish-SZFGGKB4.js.map} +1 -1
- package/dist/transport/index.js +7 -7
- package/dist/transport/ws/server.js +7 -7
- package/dist/transport/ws.js +7 -7
- package/dist/tui/index.js +34 -34
- package/dist/workspace-plugin/adapters/mcp.js +25 -25
- package/dist/workspace-plugin/adapters/omp.js +14 -14
- package/dist/workspace-plugin/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-AVFRFGM2.js.map +0 -1
- package/dist/chunk-DKXNKFKP.js.map +0 -1
- package/dist/chunk-IWKKTCXY.js.map +0 -1
- package/dist/chunk-TNQLDEM6.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { entrySurface } from './chunk-
|
|
2
|
-
import { unresolvedProviderCredentials, entryCredentialValue, providerCredentialEnvName } from './chunk-
|
|
1
|
+
import { entrySurface } from './chunk-F4CZQD3T.js';
|
|
2
|
+
import { unresolvedProviderCredentials, entryCredentialValue, providerCredentialEnvName } from './chunk-BSMW3PX2.js';
|
|
3
3
|
import { AI_PROVIDER_SURFACES, registryEntries, isEntryEnabled, parseModelRef, normalizeEntryBaseUrl, resolveEntryBaseUrl } from './chunk-RXGPFAMN.js';
|
|
4
4
|
import { createHash } from 'crypto';
|
|
5
5
|
import fs from 'fs/promises';
|
|
@@ -501,5 +501,5 @@ async function materializeOmpIdentityDir(config) {
|
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
export { isCredentialOmissionWarning, materializeOmpIdentityDir, materializeOmpProviders, ompRegistryModelRefusal, registryModelEntries };
|
|
504
|
-
//# sourceMappingURL=chunk-
|
|
505
|
-
//# sourceMappingURL=chunk-
|
|
504
|
+
//# sourceMappingURL=chunk-TCH5UDKT.js.map
|
|
505
|
+
//# sourceMappingURL=chunk-TCH5UDKT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../bridge/src/harnesses/omp-models-yml.ts"],"names":[],"mappings":";;;;;;;;;;AA6EO,IAAM,cAAA,GAAoC,CAAC,GAAG,oBAAA,EAAsB,mBAAmB,CAAA;AAO9F,IAAM,mBAAA,GAAyC;AAAA,EAC7C,QAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,oBAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA;AAyBO,IAAM,mBAAA,GAAsB,YAAA;AAG5B,IAAM,mBAAA,GAAsB,YAAA;AAOnC,IAAM,qBAAA,GAA8C;AAAA,EAClD,YAAA,EAAc,IAAA;AAAA,EACd,aAAA,EAAe,IAAA;AAAA,EACf,aAAA,EAAe,IAAA;AAAA,EACf,YAAA,EAAc,IAAA;AAAA,EACd,aAAA,EAAe,IAAA;AAAA,EACf,iBAAA,EAAmB,IAAA;AAAA,EACnB,kBAAA,EAAoB,IAAA;AAAA,EACpB,eAAA,EAAiB;AACnB,CAAA;AAOA,IAAM,mBAAA,GAA4C;AAAA,EAChD,UAAA,EAAY,IAAA;AAAA,EACZ,cAAA,EAAgB,IAAA;AAAA,EAChB,cAAA,EAAgB,IAAA;AAAA,EAChB,WAAA,EAAa,IAAA;AAAA,EACb,eAAA,EAAiB,IAAA;AAAA,EACjB,eAAA,EAAiB,IAAA;AAAA,EACjB,uBAAA,EAAyB,IAAA;AAAA,EACzB,2BAAA,EAA6B,IAAA;AA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ter: an AI provider registry serialized into omp's own\n * configuration files, inside a session-private agent directory.\n *\n * omp already implements the target schema — `~/.omp/agent/models.yml` is a\n * `providers:` map with `baseUrl`, `api`, `apiKey`, `headers`, `authHeader`,\n * `auth`, `discovery` and `models[]` (`omp://models.md`) — so this module is a\n * *serializer*, not a translator. Our `surface` enum is omp's `api` enum\n * verbatim (§1.2); {@link OMP_API_VALUES} encodes that assertion so a future\n * surface that omp does not know is reported instead of silently written into\n * a file omp will then reject wholesale.\n *\n * Two files are produced:\n *\n * - `models.yml` — one entry per enabled `llm`/`embed` registry entry. `apiKey`\n * holds the **name** of the per-entry environment variable\n * (`SKAILE_AIP_<ID>_KEY`, {@link providerCredentialEnvName}), never a value:\n * omp resolves a `models.yml` `apiKey` as an env-var name first and only\n * falls back to treating it as a literal token. The values travel in the\n * child environment.\n * - `config.yml` — omp's settings file, carrying `modelRoles` rendered from the\n * `skaile.yaml` `roles` table. `models.yml`'s root accepts only `providers:`;\n * unknown root keys fail its schema, so roles cannot live there.\n *\n * `PI_CODING_AGENT_DIR` relocates omp's whole agent base — `config.yml`,\n * `models.yml` **and** the auth store `agent.db` (`omp://settings.md`). Pointing\n * it at a session-private directory is what makes N providers per session\n * possible without ever writing the user's `~/.omp/agent`. The cost is that a\n * standalone developer session would also lose the OAuth logins stored in that\n * auth store, so {@link materializeOmpAgentDir} seeds the session directory\n * with symlinks to everything in the user's agent directory *except* the two\n * files this module owns. Verified against omp 18.2.6: a ChatGPT/Codex OAuth\n * account stored in `~/.omp/agent/agent.db` still resolves (`omp token\n * openai-codex`) from a relocated directory that only symlinks `agent.db*`.\n * Under the platform the user directory does not exist, the seed is a no-op,\n * and the session starts empty — which is the correct behaviour there.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3 (omp row), §5, §9\n * @see omp://models.md, omp://settings.md\n */\n\nimport { createHash } from \"node:crypto\";\nimport type { Stats } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport net from \"node:net\";\nimport path from \"node:path\";\nimport {\n type AIProviderLlmEntry,\n type AIProviderRegistry,\n AI_PROVIDER_SURFACES,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport { parse, stringify } from \"yaml\";\nimport type { ModelEntry } from \"../models.js\";\nimport {\n entryCredentialValue,\n providerCredentialEnvName,\n type RegistryCredentialEnvOptions,\n unresolvedProviderCredentials,\n} from \"../provider-materialize/credential-env.js\";\nimport { entrySurface } from \"../provider-materialize/env-harnesses.js\";\nimport type { AgentConfig, OmpHarnessOptions } from \"../types.js\";\n\n/**\n * omp's allowed provider/model `api` values (`omp://models.md`, \"Allowed\n * provider/model `api` values\").\n *\n * Every {@link AI_PROVIDER_SURFACES} member is in this list — that equality is\n * the premise the whole adapter rests on (§1.2). `google-gemini-cli` is omp's\n * one extra value, which the registry has no surface for.\n */\nexport const OMP_API_VALUES: readonly string[] = [...AI_PROVIDER_SURFACES, \"google-gemini-cli\"];\n\n/**\n * `discovery.type` values omp accepts. The registry's own enum is wider on one\n * side (`anthropic-models-list`, `google-models-list`, `none`) and narrower on\n * the other, so a discovery block is emitted only when omp can act on it.\n */\nconst OMP_DISCOVERY_TYPES: readonly string[] = [\n \"ollama\",\n \"llama.cpp\",\n \"lm-studio\",\n \"openai-models-list\",\n \"proxy\",\n \"litellm\",\n];\n\n/** One `providers.<id>` block of `models.yml`. */\ninterface OmpProviderBlock {\n baseUrl?: string;\n api?: string;\n /** The *name* of the env var holding the credential — never a value. */\n apiKey?: string;\n auth?: \"apiKey\" | \"none\" | \"oauth\";\n authHeader?: boolean;\n headers?: Record<string, string>;\n discovery?: { type: string };\n models?: OmpModelBlock[];\n}\n\n/** One entry of a provider's `models[]`. */\ninterface OmpModelBlock {\n id: string;\n name?: string;\n input?: string[];\n contextWindow?: number;\n supportsTools?: boolean;\n}\n\n/** The two files this module owns inside the agent directory. */\nexport const OMP_MODELS_FILENAME = \"models.yml\";\n\n/** omp's settings file; `modelRoles` lives here, not in `models.yml`. */\nexport const OMP_CONFIG_FILENAME = \"config.yml\";\n\n/**\n * Names {@link materializeOmpAgentDir} never links in from the user's agent\n * directory: the two files it writes itself, their alternate spellings, and\n * the legacy `settings.json` omp would migrate into `config.yml`.\n */\nconst OWNED_AGENT_DIR_FILES: Record<string, true> = {\n \"models.yml\": true,\n \"models.yaml\": true,\n \"models.json\": true,\n \"config.yml\": true,\n \"config.yaml\": true,\n \"config.yml.lock\": true,\n \"config.yaml.lock\": true,\n \"settings.json\": true,\n};\n\n/**\n * omp's own runtime state inside its home. An agent directory that an older release used as\n * omp's home still holds these; they are never agent files, so the identity link skips them\n * and the user's own login (`agent.db`) linked in from their agent directory stays in place.\n */\nconst OMP_RUNTIME_ENTRIES: Record<string, true> = {\n \"agent.db\": true,\n \"agent.db-shm\": true,\n \"agent.db-wal\": true,\n \"models.db\": true,\n \"models.db-shm\": true,\n \"models.db-wal\": true,\n \"skill-descriptions.db\": true,\n \"skill-descriptions.db-shm\": true,\n \"skill-descriptions.db-wal\": true,\n \"custom-session-files\": true,\n intercom: true,\n sessions: true,\n};\n\n/**\n * The only entries of the user's own omp agent directory a session's private home links in:\n * omp's credential store, so the login the developer already has keeps working. Sessions,\n * history, `mcp.json`, extensions and blobs stay out: a run must not write into the user's\n * session store or load their MCP servers and extensions. `config.yml` is copied, not linked.\n */\nconst OMP_LOGIN_FILES = [\"agent.db\", \"agent.db-shm\", \"agent.db-wal\"] as const;\n\n/** Options for {@link renderOmpRegistry}. */\nexport interface RenderOmpRegistryOptions extends RegistryCredentialEnvOptions {\n /** `skaile.yaml` `roles`: role name → model selector. Rendered as `modelRoles`. */\n roles?: Record<string, string>;\n /**\n * The session's own selector. When `roles` names no `default`, the resolved\n * model becomes `modelRoles.default` so `@default` (and omp's `*` alias)\n * resolve to the entry the session actually runs on.\n */\n modelRef?: string;\n /**\n * Settings to render underneath `modelRoles` — the user's own `config.yml`\n * when a standalone session seeds one. `modelRoles` is replaced wholesale,\n * not deep-merged: a seeded role pointing at a provider this session does\n * not define would otherwise survive as a dangling selector.\n */\n baseSettings?: Record<string, unknown>;\n}\n\n/** What {@link renderOmpRegistry} produced. */\nexport interface OmpRegistryRender {\n /** `models.yml` contents. */\n modelsYml: string;\n /** `config.yml` contents. */\n configYml: string;\n /**\n * `SKAILE_AIP_<ID>_KEY` → secret, for the child environment. The only place\n * a credential value appears; both rendered files hold names alone.\n */\n credentialEnv: Record<string, string>;\n /** Entry ids written to `models.yml`, in registry order. */\n providerIds: string[];\n /** `modelRoles` as written, role name → `<providerId>/<providerModelId>`. */\n modelRoles: Record<string, string>;\n /** Entries and roles that could not be rendered, and why. */\n warnings: string[];\n}\n\n/** The provider-side model ids an entry declares, keyed by logical id. */\nfunction entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logical = new Set<string>([\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}),\n ]);\n const seen = new Set<string>();\n const out: Array<[string, string]> = [];\n for (const id of logical) {\n const providerSide = entry.model_map?.[id] ?? id;\n if (seen.has(providerSide)) continue;\n seen.add(providerSide);\n out.push([id, providerSide]);\n }\n return out;\n}\n\n/**\n * Serialize one entry into an omp provider block, or report why it cannot be.\n *\n * omp requires `baseUrl` on any provider that declares `models[]`, and\n * provider-level `api` whenever `discovery` is set (except `discovery.type:\n * proxy`, where the wire is auto-detected per model). A file that violates its\n * schema is rejected *wholesale* — the registry keeps operating on built-in\n * models and the error only surfaces through `ModelRegistry.getError()` — so an\n * entry that cannot satisfy those rules is dropped here, loudly, rather than\n * taking every other provider down with it.\n */\nfunction renderProvider(\n id: string,\n entry: AIProviderLlmEntry,\n warnings: string[],\n): OmpProviderBlock | undefined {\n // The Anthropic SDK inside omp appends `/v1/messages`: a stored `…/v1` must\n // not reach the file as written. Not `entryBaseUrl`: omp gets no preset\n // literal, so an entry without an endpoint of its own is reported below.\n const baseUrl = normalizeEntryBaseUrl(resolveEntryBaseUrl(entry), entrySurface(entry));\n if (!baseUrl) {\n warnings.push(\n `provider '${id}' has no resolvable base_url (missing transport params?) — omitted from models.yml`,\n );\n return undefined;\n }\n\n // Only the entry's own surface becomes `api`; an inherited one stays omp's\n // to infer, as before. The preset's surface above only picks the URL rule.\n const surface = entry.surface;\n if (surface && !OMP_API_VALUES.includes(surface)) {\n warnings.push(\n `provider '${id}' has surface '${surface}', which omp's api enum does not accept`,\n );\n return undefined;\n }\n\n const block: OmpProviderBlock = { baseUrl };\n if (surface) block.api = surface;\n\n const kind = entry.credential?.kind ?? \"none\";\n if (kind === \"none\") {\n block.auth = \"none\";\n } else if (kind === \"sigv4\" || kind === \"google_adc\" || kind === \"azure_entra\") {\n // Ambient signing chains: the AWS/Google/Azure SDK inside omp signs the\n // request from its own environment. There is no token to hand over, and\n // omp must not treat the provider as unavailable for the lack of one.\n block.auth = \"none\";\n } else {\n block.apiKey = providerCredentialEnvName(id);\n // `bearer` is the only kind that needs the header injected; the Anthropic\n // and Azure surfaces place an `api_key_header` credential themselves.\n if (kind === \"bearer\" || kind === \"oauth\") block.authHeader = true;\n }\n\n const headers = { ...entry.headers };\n if (entry.query_params && Object.keys(entry.query_params).length > 0) {\n if (surface === \"bedrock-converse-stream\") {\n // omp keeps a query string on a Bedrock `baseUrl` and appends it to the\n // final URL (and to SigV4's canonical request) — the documented carrier\n // for gateways that authenticate by query parameter.\n const search = new URLSearchParams(entry.query_params).toString();\n block.baseUrl = `${baseUrl}${baseUrl.includes(\"?\") ? \"&\" : \"?\"}${search}`;\n } else {\n warnings.push(\n `provider '${id}' declares query_params, which omp's models.yml has no slot for on surface ` +\n `'${surface ?? \"unset\"}' — they were dropped`,\n );\n }\n }\n if (Object.keys(headers).length > 0) block.headers = headers;\n\n const discoveryType = entry.discovery?.type;\n if (discoveryType) {\n if (!OMP_DISCOVERY_TYPES.includes(discoveryType)) {\n warnings.push(\n `provider '${id}' declares discovery '${discoveryType}', which omp does not implement — ` +\n `models come from model_map only`,\n );\n } else if (!surface && discoveryType !== \"proxy\") {\n warnings.push(\n `provider '${id}' declares discovery '${discoveryType}' but no surface — omp requires ` +\n `provider-level api for every discovery type but 'proxy'`,\n );\n } else {\n block.discovery = { type: discoveryType };\n }\n }\n\n const models: OmpModelBlock[] = [];\n for (const [logical, providerSide] of entryModelIds(entry)) {\n const model: OmpModelBlock = { id: providerSide };\n if (logical !== providerSide) model.name = logical;\n const caps = entry.capabilities?.[logical];\n if (caps?.context_window !== undefined) model.contextWindow = caps.context_window;\n if (caps?.images !== undefined) model.input = caps.images ? [\"text\", \"image\"] : [\"text\"];\n if (caps?.tools !== undefined) model.supportsTools = caps.tools;\n models.push(model);\n }\n if (models.length > 0) {\n if (!surface) {\n warnings.push(\n `provider '${id}' declares models but no surface — omp requires api at provider or model level`,\n );\n return undefined;\n }\n block.models = models;\n } else if (!block.discovery) {\n warnings.push(\n `provider '${id}' declares neither model_map/capabilities nor a discovery omp implements — ` +\n `it will only override an omp built-in provider of the same id`,\n );\n }\n\n return block;\n}\n\n/**\n * Resolve the `roles` table into omp `modelRoles` selectors.\n *\n * Roles do not chain, so each value is resolved as a plain selector rather than\n * through `@role` expansion. A trailing omp thinking suffix (`:high`) survives\n * untouched: it is not part of any `model_map` key, so it falls through\n * `parseModelRef`'s literal path and is re-emitted on the provider-side id.\n */\nfunction renderModelRoles(\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n roles: Record<string, string> | undefined,\n modelRef: string | undefined,\n warnings: string[],\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [role, selector] of Object.entries(roles ?? {})) {\n const trimmed = selector.trim();\n if (!trimmed) continue;\n const ref = parseModelRef(trimmed, registry);\n if (!ref?.providerModelId) {\n warnings.push(\n `role '${role}' ('${selector}') resolves to no model in this registry — dropped`,\n );\n continue;\n }\n out[role] = `${ref.providerId}/${ref.providerModelId}`;\n }\n if (out.default === undefined && modelRef) {\n const ref = parseModelRef(modelRef, registry, roles);\n if (ref?.providerModelId) out.default = `${ref.providerId}/${ref.providerModelId}`;\n }\n return out;\n}\n\n/**\n * The warning for an entry left out of `models.yml` because its credential does not resolve.\n * `skaile run` and `skaile repl` print the same fact as one `! provider ... is not used` line\n * (runner `credential-notice.ts`), so the harness keeps this warning off the console.\n */\nfunction credentialOmissionWarning(id: string, reason: string): string {\n return `provider '${id}' omitted from models.yml: ${reason}`;\n}\n\n/** True for a warning built by {@link credentialOmissionWarning}. */\nexport function isCredentialOmissionWarning(warning: string): boolean {\n return /^provider '[^']+' omitted from models\\.yml: /.test(warning);\n}\n\n/**\n * Serialize a registry into the two omp files plus the credential environment\n * that carries their secrets.\n *\n * Only enabled `llm`/`embed` entries are rendered: `stt`/`tts` entries have no\n * wire surface and omp has no slot for them. The credential environment is\n * scoped to the same set — the omp child has no use for a Deepgram key, and a\n * secret that reaches a process which cannot spend it is pure exposure.\n *\n * An entry whose credential does not resolve here still gets its\n * `SKAILE_AIP_<ID>_KEY` name written into `models.yml`: a `platform:` ref is\n * resolved by the session boundary, which materializes the value into\n * `AgentConfig.env` under that same programme-standard name.\n */\nexport function renderOmpRegistry(\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n options: RenderOmpRegistryOptions = {},\n): OmpRegistryRender {\n const warnings: string[] = [];\n const providers: Record<string, OmpProviderBlock> = {};\n const providerIds: string[] = [];\n const credentialEnv: Record<string, string> = {};\n\n // An entry whose credential cannot be resolved here is not handed to omp: it\n // would send an empty key (`invalid x-api-key`) and shadow omp's own login for\n // the same provider.\n const unresolved = new Map(\n unresolvedProviderCredentials(registry, options).map((u) => [u.providerId, u.reason]),\n );\n for (const [id, entry] of registryEntries(registry)) {\n if (entry.kind !== \"llm\" && entry.kind !== \"embed\") continue;\n if (!isEntryEnabled(entry)) continue;\n const reason = unresolved.get(id);\n if (reason) {\n warnings.push(credentialOmissionWarning(id, reason));\n continue;\n }\n const block = renderProvider(id, entry as AIProviderLlmEntry, warnings);\n if (!block) continue;\n providers[id] = block;\n providerIds.push(id);\n // Only the canonical name, never a vendor-conventional alias: every\n // endpoint omp may address is named in models.yml with its own variable,\n // and a stray `ANTHROPIC_API_KEY` would silently make omp's *built-in*\n // Anthropic provider look authenticated with some gateway entry's key.\n const secret = entryCredentialValue(id, entry, options);\n if (secret) credentialEnv[providerCredentialEnvName(id)] = secret;\n }\n\n const modelRoles = renderModelRoles(registry, options.roles, options.modelRef, warnings);\n\n const settings: Record<string, unknown> = { ...options.baseSettings };\n if (Object.keys(modelRoles).length > 0) settings.modelRoles = modelRoles;\n\n return {\n modelsYml: stringify({ providers }),\n configYml: stringify(settings),\n credentialEnv,\n providerIds,\n modelRoles,\n warnings,\n };\n}\n\n/**\n * The models a registry makes selectable, as the harness-neutral catalog entry.\n *\n * ids are `<providerId>/<providerModelId>` — the exact selector omp's `--model`\n * and `modelRoles` take, and unambiguous when two entries serve the same model\n * id, which is the normal case once a session carries N providers.\n */\nexport function registryModelEntries(\n registry: AIProviderRegistry | MergedAIProviderRegistry | undefined,\n): ModelEntry[] {\n if (!registry) return [];\n const out: ModelEntry[] = [];\n for (const [id, entry] of registryEntries(registry)) {\n if (entry.kind !== \"llm\" && entry.kind !== \"embed\") continue;\n if (!isEntryEnabled(entry)) continue;\n const label = entry.label ?? id;\n for (const [logical, providerSide] of entryModelIds(entry as AIProviderLlmEntry)) {\n out.push({ id: `${id}/${providerSide}`, name: `${label} ${logical}` });\n }\n }\n return out;\n}\n\n/**\n * Why omp cannot serve `<providerId>/<model>` from this registry, or `undefined` when it can (or\n * when this check cannot tell). omp knows only the models a registry entry declares\n * (`model_map`, `capabilities`) or its `discovery` lists: for a provider id omp has no login for\n * and an entry that declares neither, `omp --model fake/fake-1` exits with `Model \"fake/fake-1\"\n * not found` on the first prompt (p1334). `nativeProviders` are the ids omp ships a login for;\n * their entry only overrides the built-in provider, so the model may still be omp's own.\n */\nexport function ompRegistryModelRefusal(\n registry: AIProviderRegistry | MergedAIProviderRegistry | undefined,\n selector: string,\n nativeProviders: ReadonlySet<string>,\n): string | undefined {\n if (!registry) return undefined;\n const slash = selector.indexOf(\"/\");\n if (slash <= 0) return undefined;\n const head = selector.slice(0, slash);\n // A trailing omp thinking suffix (`:high`) is not part of the model id.\n const model = selector.slice(slash + 1).replace(/:(off|minimal|low|medium|high|xhigh)$/i, \"\");\n if (!model || nativeProviders.has(head)) return undefined;\n const found = registryEntries(registry).find(([id]) => id === head);\n if (!found) return undefined;\n const [, entry] = found;\n if ((entry.kind !== \"llm\" && entry.kind !== \"embed\") || !isEntryEnabled(entry)) return undefined;\n const llm = entry as AIProviderLlmEntry;\n if (llm.discovery?.type && OMP_DISCOVERY_TYPES.includes(llm.discovery.type)) return undefined;\n const known = entryModelIds(llm).flatMap(([logical, providerSide]) => [logical, providerSide]);\n if (known.includes(model)) return undefined;\n return known.length === 0\n ? `omp cannot serve model '${selector}': registry entry '${head}' declares no models (add model_map or capabilities to it in providers.yml), and omp has no login for '${head}'. Pick a model omp lists.`\n : `omp cannot serve model '${selector}': registry entry '${head}' declares ${known.join(\", \")}, not '${model}'. Pick one of those, or add '${model}' to the entry's model_map.`;\n}\n\n/** Options for {@link materializeOmpAgentDir}. */\nexport interface MaterializeOmpAgentDirOptions extends RenderOmpRegistryOptions {\n /**\n * The user's own omp agent directory to seed from — its auth store\n * (`agent.db`) is linked in so a standalone session keeps the login the\n * developer already has, and its `config.yml` is read as base settings.\n * Sessions, history, `mcp.json` and extensions are not linked. Absent (the\n * platform case) seeds nothing. A missing directory is not an error: it is the platform case.\n */\n seedFrom?: string;\n /**\n * GitAgent identity directory (`AgentConfig.agentDir`) whose contents omp\n * reads out of the same base: `agent.yaml`, `SOUL.md`, `RULES.md`,\n * `knowledge/`. Linked in after the seed, so identity wins a name clash.\n */\n identityDir?: string;\n}\n\n/** What {@link materializeOmpAgentDir} wrote. */\nexport interface OmpAgentDirMaterialization extends OmpRegistryRender {\n /** The directory `PI_CODING_AGENT_DIR` must point at. */\n agentDir: string;\n /** The directory is the harness's temporary home: remove it when the run ends. */\n ephemeral?: boolean;\n /** Names linked in from {@link MaterializeOmpAgentDirOptions.seedFrom}. */\n seeded: string[];\n /** Names linked in from {@link MaterializeOmpAgentDirOptions.identityDir}. */\n identity: string[];\n}\n\n/** Inputs {@link planOmpAgentDir} derives the session directory layout from. */\nexport interface OmpAgentDirPlanInput {\n /** Session working directory. Distinguishes two default-named sessions. */\n cwd: string;\n /** Session id — the directory key, so concurrent sessions never collide. */\n sessionId?: string;\n /** `AgentConfig.harnessOptions.omp`. */\n options?: OmpHarnessOptions;\n /** Home the default seed source resolves against. Defaults to `os.homedir()`. */\n homeDir?: string;\n /** Root the private directory is created under. Defaults to `os.tmpdir()`. */\n tmpDir?: string;\n}\n\n/** Where a session's omp agent directory lives, and what it inherits. */\nexport interface OmpAgentDirPlan {\n /** Session-private directory `PI_CODING_AGENT_DIR` points at. */\n agentDir: string;\n /** User agent directory whose login is linked in, when there is one to inherit. */\n seedFrom?: string;\n /**\n * The directory is the harness's own temporary home, to be removed when the run ends. False\n * when the session named its own `harnessOptions.omp.agentHome`, which belongs to the user.\n */\n ephemeral: boolean;\n}\n\n/**\n * Decide the session-private agent directory and whether it inherits the\n * developer's omp state.\n *\n * The directory is deliberately **outside `cwd`**. It holds omp's credential\n * store — a symlink to the developer's `agent.db` on a standalone machine —\n * and `cwd` is the one tree the agent has write access to by design; managed\n * codex draws the same line and rejects a private directory nested in the\n * workspace (`codex/instance-state.ts`). Sessions are keyed by id, falling\n * back to a digest of the workspace path. The temporary directory is `<key>-<random>`, created per\n * call, so no two runs share one (and one run's cleanup never removes another's).\n *\n * Seeding keys on the user directory *existing*, which is exactly the\n * platform/standalone distinction the plan draws: a platform container has no\n * `~/.omp/agent`, so the session correctly starts empty; a developer machine\n * has one, so the session keeps the logins already stored there.\n * `harnessOptions.omp.seedUserAgentDir: false` forces the empty case anyway.\n */\nexport async function planOmpAgentDir(input: OmpAgentDirPlanInput): Promise<OmpAgentDirPlan> {\n const options = input.options;\n const key =\n input.sessionId?.trim() ||\n createHash(\"sha256\").update(path.resolve(input.cwd)).digest(\"hex\").slice(0, 16);\n const ephemeral = options?.agentHome === undefined;\n // The temporary home is unique per spawn: callers key sessions loosely (`skaile chat` passes\n // none, `serve` without --session-id uses one shared id, sub-prompt harnesses share a hash), and\n // the harness deletes its home when its run ends, which must never reach a sibling's home.\n let agentDir = options?.agentHome ?? \"\";\n if (ephemeral) {\n const root = path.join(input.tmpDir ?? os.tmpdir(), \"skaile-omp-agent\");\n await fs.mkdir(root, { recursive: true });\n await sweepStaleOmpHomes(root);\n agentDir = await fs.mkdtemp(path.join(root, `${key.replace(/[^A-Za-z0-9._-]/g, \"_\")}-`));\n await fs.writeFile(path.join(agentDir, OWNER_FILE), String(process.pid));\n }\n if (options?.seedUserAgentDir === false) return { agentDir, ephemeral };\n\n const seedFrom =\n options?.userAgentDir ?? path.join(input.homeDir ?? os.homedir(), \".omp\", \"agent\");\n if (path.resolve(seedFrom) === path.resolve(agentDir)) return { agentDir, ephemeral };\n try {\n if (!(await fs.stat(seedFrom)).isDirectory()) return { agentDir, ephemeral };\n } catch {\n return { agentDir, ephemeral };\n }\n return { agentDir, seedFrom, ephemeral };\n}\n\n/** Names the process that created a temporary home; the sweep keeps a home whose owner lives. */\nconst OWNER_FILE = \".skaile-owner-pid\";\n/** A temporary home older than this whose owner is gone is removed at the next start. */\nconst STALE_HOME_MS = 24 * 60 * 60 * 1000;\n\n/**\n * The names skaile gave a temporary home: `<key>-<six random characters>` (`mkdtemp`), and\n * `<key>-<12 hex>` from releases before 5.16 (p1151).\n */\nconst SKAILE_HOME_NAME = /^[A-Za-z0-9._-]+-(?:[A-Za-z0-9]{6}|[0-9a-f]{12})$/;\n\nfunction processAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (err) {\n return (err as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\n/**\n * Whether nothing listens on the unix socket `file`: a connect is refused (the process that\n * bound it is gone) or finds no socket. A socket somebody still serves, or one that does not\n * answer within a second, counts as in use.\n */\nfunction socketIsDead(file: string): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n const conn = net.connect(file);\n const done = (dead: boolean) => {\n conn.destroy();\n resolve(dead);\n };\n conn.setTimeout(1000, () => done(false));\n conn.once(\"connect\", () => done(false));\n conn.once(\"error\", (err: NodeJS.ErrnoException) =>\n done(err.code === \"ECONNREFUSED\" || err.code === \"ENOENT\"),\n );\n });\n}\n\n/**\n * Remove temporary homes older than a day whose creating process is gone: a run that was killed\n * never reached the harness's own cleanup, and every one leaves symlinks and databases behind\n * (p811). A home of a live process is kept whatever its age. A unix socket of that age that\n * nobody listens on is removed too (omp binds one beside the homes and a killed run leaves it,\n * p1316). Best effort: a failure is ignored.\n */\nasync function sweepStaleOmpHomes(root: string, now = Date.now()): Promise<void> {\n let names: string[];\n try {\n names = await fs.readdir(root);\n } catch {\n return;\n }\n await Promise.all(\n names.map(async (name) => {\n const home = path.join(root, name);\n try {\n const stat = await fs.lstat(home);\n if (now - stat.mtimeMs < STALE_HOME_MS) return;\n if (stat.isSocket()) {\n if (await socketIsDead(home)) await fs.rm(home, { force: true });\n return;\n }\n if (!stat.isDirectory()) return;\n const owner = Number.parseInt(\n await fs.readFile(path.join(home, OWNER_FILE), \"utf8\").catch(() => \"\"),\n 10,\n );\n if (Number.isInteger(owner) && processAlive(owner)) return;\n // A home with no owner file is one an older version made: remove it only when its\n // name has the `<key>-<six random characters>` shape `mkdtemp` gives (never a folder\n // somebody else put in this directory).\n if (!Number.isInteger(owner) && !SKAILE_HOME_NAME.test(name)) return;\n await fs.rm(home, { recursive: true, force: true });\n } catch {\n /* another process may be sweeping the same home */\n }\n }),\n );\n}\n\n/**\n * Run the steps that fill a planned home; when one throws, remove a temporary home before\n * rethrowing. The harness only learns the home (and deletes it at cleanup) once these steps\n * return, so a failure here would otherwise leave a new directory per spawn behind.\n */\nasync function removeHomeOnThrow<T>(plan: OmpAgentDirPlan, fill: () => Promise<T>): Promise<T> {\n try {\n return await fill();\n } catch (err) {\n if (plan.ephemeral) await fs.rm(plan.agentDir, { recursive: true, force: true });\n throw err;\n }\n}\n\n/** Remove a path whatever it is, without following a symlink into its target. */\nasync function removeEntry(target: string): Promise<void> {\n let stat: Stats;\n try {\n stat = await fs.lstat(target);\n } catch {\n return;\n }\n if (stat.isSymbolicLink() || stat.isFile()) {\n await fs.unlink(target);\n return;\n }\n await fs.rm(target, { recursive: true, force: true });\n}\n\n/** Symlink every entry of `sourceDir` into `dir`, skipping the owned names. */\nasync function linkInto(\n dir: string,\n sourceDir: string,\n skip: Record<string, true>,\n): Promise<string[]> {\n let names: string[];\n try {\n names = await fs.readdir(sourceDir);\n } catch {\n return [];\n }\n const linked: string[] = [];\n for (const name of names) {\n if (skip[name]) continue;\n const target = path.join(dir, name);\n await removeEntry(target);\n await fs.symlink(path.join(sourceDir, name), target);\n linked.push(name);\n }\n return linked;\n}\n\n/**\n * Remove the symlinks into the user's agent directory that an older release (or a home the\n * session named itself) left in `dir`: only the login files may point there (p811).\n */\nasync function dropStaleSeedLinks(dir: string, sourceDir: string): Promise<void> {\n let names: string[];\n try {\n names = await fs.readdir(dir);\n } catch {\n return;\n }\n const root = path.resolve(sourceDir);\n for (const name of names) {\n if ((OMP_LOGIN_FILES as readonly string[]).includes(name)) continue;\n const entry = path.join(dir, name);\n try {\n if (!(await fs.lstat(entry)).isSymbolicLink()) continue;\n const to = path.resolve(dir, await fs.readlink(entry));\n if (to === root || to.startsWith(root + path.sep)) await fs.unlink(entry);\n } catch {\n // Gone or unreadable: nothing to drop.\n }\n }\n}\n\n/** Symlink the login files (see {@link OMP_LOGIN_FILES}) of the user's agent directory into `dir`. */\nasync function linkLoginFiles(dir: string, sourceDir: string): Promise<string[]> {\n await dropStaleSeedLinks(dir, sourceDir);\n const linked: string[] = [];\n for (const name of OMP_LOGIN_FILES) {\n const from = path.join(sourceDir, name);\n try {\n if (!(await fs.stat(from)).isFile()) continue;\n } catch {\n continue;\n }\n const target = path.join(dir, name);\n await removeEntry(target);\n await fs.symlink(from, target);\n linked.push(name);\n }\n return linked;\n}\n\n/** Read a seeded `config.yml` as the base settings, or `{}` when unusable. */\nasync function readSeededSettings(seedFrom: string): Promise<Record<string, unknown>> {\n for (const name of [\"config.yml\", \"config.yaml\"]) {\n let raw: string;\n try {\n raw = await fs.readFile(path.join(seedFrom, name), \"utf-8\");\n } catch {\n continue;\n }\n const parsed = parse(raw) as unknown;\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed as Record<string, unknown>;\n }\n }\n return {};\n}\n\n/**\n * The model selector of the user's own omp default (`modelRoles.default` in their `config.yml`)\n * when it can only be served by their own `models.yml`, else `undefined` (p1172).\n *\n * The session-private home never copies the user's `models.yml`: it holds their credentials.\n * A default such as `anthropic/claude-opus-5-5` that their `models.yml` defines (a gateway, a\n * local server) then names a provider the private home does not have, and omp quietly picks\n * another model. A default on a built-in omp provider keeps working there (its login is linked\n * in), and a provider the registry renders is there too, so neither is reported.\n */\nasync function ownDefaultNeedingOwnModels(\n seedFrom: string,\n rendered: readonly string[],\n): Promise<string | undefined> {\n const selector = (await readSeededSettings(seedFrom)).modelRoles;\n const own =\n selector && typeof selector === \"object\" && !Array.isArray(selector)\n ? (selector as Record<string, unknown>).default\n : undefined;\n if (typeof own !== \"string\" || !own.includes(\"/\")) return undefined;\n const providerId = own.slice(0, own.indexOf(\"/\"));\n if (rendered.includes(providerId)) return undefined;\n let raw: string;\n try {\n raw = await fs.readFile(path.join(seedFrom, OMP_MODELS_FILENAME), \"utf-8\");\n } catch {\n return undefined;\n }\n const providers = (parse(raw) as { providers?: unknown } | null)?.providers;\n if (!providers || typeof providers !== \"object\" || Array.isArray(providers)) return undefined;\n return providerId in providers ? own : undefined;\n}\n\n/**\n * Build the session-private agent directory and write omp's two files into it.\n *\n * The user's `~/.omp/agent/models.yml` and `config.yml` are never opened for\n * writing: `config.yml` is *copied* into the session (so a token refresh or a\n * settings write inside the session cannot reach back through a symlink),\n * `models.yml` is not seeded at all, and everything else — `agent.db*` above\n * all — is symlinked so the session shares the developer's logins and caches.\n */\nexport async function materializeOmpAgentDir(\n agentDir: string,\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n options: MaterializeOmpAgentDirOptions = {},\n): Promise<OmpAgentDirMaterialization> {\n await fs.mkdir(agentDir, { recursive: true });\n\n const seeded = options.seedFrom ? await linkLoginFiles(agentDir, options.seedFrom) : [];\n const identity = options.identityDir\n ? await linkInto(agentDir, options.identityDir, OWNED_AGENT_DIR_FILES)\n : [];\n\n const baseSettings =\n options.baseSettings ??\n (options.seedFrom ? await readSeededSettings(options.seedFrom) : undefined);\n\n const render = renderOmpRegistry(registry, { ...options, baseSettings });\n\n await fs.writeFile(path.join(agentDir, OMP_MODELS_FILENAME), render.modelsYml, \"utf-8\");\n await fs.writeFile(path.join(agentDir, OMP_CONFIG_FILENAME), render.configYml, \"utf-8\");\n\n return { ...render, agentDir, seeded, identity };\n}\n\n/** What the omp harness gets back from {@link materializeOmpProviders}. */\nexport interface OmpProviderMaterialization extends OmpAgentDirMaterialization {\n /**\n * The `--model` argument for this session: `<providerId>/<providerModelId>`,\n * the one selector form omp treats as unambiguous when several providers\n * carry the same model id. Absent when the session named no model.\n */\n modelArg?: string;\n}\n\n/**\n * The whole omp adapter for one session: decide the private agent directory,\n * inherit the developer's omp state where there is any, write `models.yml` and\n * `config.yml`, and report the credential environment and `--model` selector\n * the child needs.\n *\n * Returns `undefined` when the session carries no registry with a selectable\n * entry — the harness then behaves exactly as it did before the registry\n * existed, which is what keeps this an expand-and-contract change.\n *\n * Also returns `undefined` when the session names no model (no `--model`, no\n * `default` role) and the user's own omp default is served by the user's own\n * `models.yml`, which a private home does not carry (p1172): the registry would\n * only swap that default for whatever model omp finds first.\n *\n * Also returns `undefined` when no entry can be handed to omp (every\n * credential unresolved) or when the entry the session's model selects was\n * left out: a session-private agent directory would then start omp without the\n * user's own settings, and a model that only the user's own omp login can\n * serve would fail with `No API key found` although native omp answers. The\n * harness then starts omp on the user's agent directory, so \"omp falls back to\n * its own login\" is true.\n *\n * `env:` references resolve against the runner's environment *overlaid with*\n * `config.env`, so a credential the session boundary already resolved (a\n * `platform:` secret it turned into an env var, for instance) is found here\n * under the name the registry entry points at.\n */\nexport async function materializeOmpProviders(\n config: AgentConfig,\n): Promise<OmpProviderMaterialization | undefined> {\n const registry = config.registry;\n if (!registry) return undefined;\n const selectable = registryEntries(registry).some(\n ([, entry]) => (entry.kind === \"llm\" || entry.kind === \"embed\") && isEntryEnabled(entry),\n );\n if (!selectable) return undefined;\n\n const env = { ...process.env, ...config.env };\n const selected = config.modelRef\n ? parseModelRef(config.modelRef, registry, config.roles)\n : undefined;\n const usable = renderOmpRegistry(registry, {\n env,\n ...(config.roles ? { roles: config.roles } : {}),\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n }).providerIds;\n if (usable.length === 0) return undefined;\n if (selected && !usable.includes(selected.providerId)) return undefined;\n\n const plan = await planOmpAgentDir({\n cwd: config.cwd,\n ...(config.sessionId ? { sessionId: config.sessionId } : {}),\n ...(config.harnessOptions?.omp ? { options: config.harnessOptions.omp } : {}),\n });\n\n if (!selected && !config.model && plan.seedFrom) {\n const named = renderOmpRegistry(registry, {\n env,\n ...(config.roles ? { roles: config.roles } : {}),\n }).modelRoles;\n if (named.default === undefined && (await ownDefaultNeedingOwnModels(plan.seedFrom, usable))) {\n if (plan.ephemeral) await fs.rm(plan.agentDir, { recursive: true, force: true });\n return undefined;\n }\n }\n\n const rendered = await removeHomeOnThrow(plan, () =>\n materializeOmpAgentDir(plan.agentDir, registry, {\n env,\n ...(plan.seedFrom ? { seedFrom: plan.seedFrom } : {}),\n ...(config.agentDir ? { identityDir: config.agentDir } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n }),\n );\n\n return {\n ...rendered,\n ephemeral: plan.ephemeral,\n ...(selected?.providerModelId\n ? { modelArg: `${selected.providerId}/${selected.providerModelId}` }\n : {}),\n };\n}\n\n/** What {@link materializeOmpIdentityDir} wrote. */\nexport interface OmpIdentityDirMaterialization {\n /** The directory `PI_CODING_AGENT_DIR` must point at. */\n agentDir: string;\n /** The directory is the harness's temporary home: remove it when the run ends. */\n ephemeral: boolean;\n /** Names linked in from the user's own omp agent directory. */\n seeded: string[];\n /** Names linked in from `AgentConfig.agentDir`. */\n identity: string[];\n}\n\n/**\n * The omp home of a session that has an agent directory but no provider registry.\n *\n * omp keeps its runtime state (`agent.db`, `models.db`, `skill-descriptions.db`, session\n * scratch, `intercom/`) in `PI_CODING_AGENT_DIR`. Pointing that at the agent directory itself\n * put those files beside `SOUL.md` in a pinned, shared source (`.skaile/cache/agents/<name>/`)\n * and made omp name a path inside the cache when it lacks a credential. So the home is a\n * private directory outside `cwd` (see {@link planOmpAgentDir}): the developer's own omp state\n * is linked in (their login keeps working), their `config.yml` / `models.yml` are copied (a\n * settings write cannot reach back), and the agent directory's entries are linked in last,\n * so the agent files stay where they are and omp can still read them.\n *\n * Returns `undefined` when the session has no `agentDir`.\n */\nexport async function materializeOmpIdentityDir(\n config: AgentConfig,\n): Promise<OmpIdentityDirMaterialization | undefined> {\n const identityDir = config.agentDir;\n if (!identityDir) return undefined;\n // Keyed by the agent and the workspace too: two role children of one session, each with\n // its own agent directory, must not link their entries into one home.\n const agentKey = createHash(\"sha256\")\n .update(`${path.resolve(identityDir)}\\0${path.resolve(config.cwd)}`)\n .digest(\"hex\")\n .slice(0, 12);\n const plan = await planOmpAgentDir({\n cwd: config.cwd,\n sessionId: `${config.sessionId?.trim() || \"agent\"}-${agentKey}`,\n ...(config.harnessOptions?.omp ? { options: config.harnessOptions.omp } : {}),\n });\n return removeHomeOnThrow(plan, async () => {\n await fs.mkdir(plan.agentDir, { recursive: true });\n const seeded = plan.seedFrom ? await linkLoginFiles(plan.agentDir, plan.seedFrom) : [];\n if (plan.seedFrom) {\n for (const name of Object.keys(OWNED_AGENT_DIR_FILES)) {\n const from = path.join(plan.seedFrom, name);\n try {\n if (!(await fs.stat(from)).isFile()) continue;\n } catch {\n continue;\n }\n const to = path.join(plan.agentDir, name);\n await removeEntry(to);\n await fs.copyFile(from, to);\n }\n }\n const identity = await linkInto(plan.agentDir, identityDir, {\n ...OWNED_AGENT_DIR_FILES,\n ...OMP_RUNTIME_ENTRIES,\n });\n return { agentDir: plan.agentDir, ephemeral: plan.ephemeral, seeded, identity };\n });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../bridge/src/harnesses/omp-models-yml.ts"],"names":[],"mappings":";;;;;;;;;;AA6EO,IAAM,cAAA,GAAoC,CAAC,GAAG,oBAAA,EAAsB,mBAAmB,CAAA;AAO9F,IAAM,mBAAA,GAAyC;AAAA,EAC7C,QAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,oBAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA;AAyBO,IAAM,mBAAA,GAAsB,YAAA;AAG5B,IAAM,mBAAA,GAAsB,YAAA;AAOnC,IAAM,qBAAA,GAA8C;AAAA,EAClD,YAAA,EAAc,IAAA;AAAA,EACd,aAAA,EAAe,IAAA;AAAA,EACf,aAAA,EAAe,IAAA;AAAA,EACf,YAAA,EAAc,IAAA;AAAA,EACd,aAAA,EAAe,IAAA;AAAA,EACf,iBAAA,EAAmB,IAAA;AAAA,EACnB,kBAAA,EAAoB,IAAA;AAAA,EACpB,eAAA,EAAiB;AACnB,CAAA;AAOA,IAAM,mBAAA,GAA4C;AAAA,EAChD,UAAA,EAAY,IAAA;AAAA,EACZ,cAAA,EAAgB,IAAA;AAAA,EAChB,cAAA,EAAgB,IAAA;AAAA,EAChB,WAAA,EAAa,IAAA;AAAA,EACb,eAAA,EAAiB,IAAA;AAAA,EACjB,eAAA,EAAiB,IAAA;AAAA,EACjB,uBAAA,EAAyB,IAAA;AAAA,EACzB,2BAAA,EAA6B,IAAA;AAAA,EAC7B,2BAAA,EAA6B,IAAA;AAAA,EAC7B,sBAAA,EAAwB,IAA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Ae,GAAA,EAAI,GAAI;AAAC,GAC5E,CAAA;AACD,EAAA,OAAO,iBAAA,CAAkB,MAAM,YAAY;AACzC,IAAA,MAAM,GAAG,KAAA,CAAM,IAAA,CAAK,UAAU,EAAE,SAAA,EAAW,MAAM,CAAA;AACjD,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,QAAA,GAAW,MAAM,cAAA,CAAe,KAAK,QAAA,EAAU,IAAA,CAAK,QAAQ,CAAA,GAAI,EAAC;AACrF,IAAA,IAAI,KAAK,QAAA,EAAU;AACjB,MAAA,KAAA,MAAW,IAAA,IAAQ,MAAA,CAAO,IAAA,CAAK,qBAAqB,CAAA,EAAG;AACrD,QAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,UAAU,IAAI,CAAA;AAC1C,QAAA,IAAI;AACF,UAAA,IAAI,EAAE,MAAM,EAAA,CAAG,KAAK,IAAI,CAAA,EAAG,QAAO,EAAG;AAAA,QACvC,CAAA,CAAA,MAAQ;AACN,UAAA;AAAA,QACF;AACA,QAAA,MAAM,EAAA,GAAK,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,UAAU,IAAI,CAAA;AACxC,QAAA,MAAM,YAAY,EAAE,CAAA;AACpB,QAAA,MAAM,EAAA,CAAG,QAAA,CAAS,IAAA,EAAM,EAAE,CAAA;AAAA,MAC5B;AAAA,IACF;AACA,IAAA,MAAM,QAAA,GAAW,MAAM,QAAA,CAAS,IAAA,CAAK,UAAU,WAAA,EAAa;AAAA,MAC1D,GAAG,qBAAA;AAAA,MACH,GAAG;AAAA,KACJ,CAAA;AACD,IAAA,OAAO,EAAE,UAAU,IAAA,CAAK,QAAA,EAAU,WAAW,IAAA,CAAK,SAAA,EAAW,QAAQ,QAAA,EAAS;AAAA,EAChF,CAAC,CAAA;AACH","file":"chunk-TCH5UDKT.js","sourcesContent":["/**\n * The omp adapter: an AI provider registry serialized into omp's own\n * configuration files, inside a session-private agent directory.\n *\n * omp already implements the target schema — `~/.omp/agent/models.yml` is a\n * `providers:` map with `baseUrl`, `api`, `apiKey`, `headers`, `authHeader`,\n * `auth`, `discovery` and `models[]` (`omp://models.md`) — so this module is a\n * *serializer*, not a translator. Our `surface` enum is omp's `api` enum\n * verbatim (§1.2); {@link OMP_API_VALUES} encodes that assertion so a future\n * surface that omp does not know is reported instead of silently written into\n * a file omp will then reject wholesale.\n *\n * Two files are produced:\n *\n * - `models.yml` — one entry per enabled `llm`/`embed` registry entry. `apiKey`\n * holds the **name** of the per-entry environment variable\n * (`SKAILE_AIP_<ID>_KEY`, {@link providerCredentialEnvName}), never a value:\n * omp resolves a `models.yml` `apiKey` as an env-var name first and only\n * falls back to treating it as a literal token. The values travel in the\n * child environment.\n * - `config.yml` — omp's settings file, carrying `modelRoles` rendered from the\n * `skaile.yaml` `roles` table. `models.yml`'s root accepts only `providers:`;\n * unknown root keys fail its schema, so roles cannot live there.\n *\n * `PI_CODING_AGENT_DIR` relocates omp's whole agent base — `config.yml`,\n * `models.yml` **and** the auth store `agent.db` (`omp://settings.md`). Pointing\n * it at a session-private directory is what makes N providers per session\n * possible without ever writing the user's `~/.omp/agent`. The cost is that a\n * standalone developer session would also lose the OAuth logins stored in that\n * auth store, so {@link materializeOmpAgentDir} seeds the session directory\n * with symlinks to everything in the user's agent directory *except* the two\n * files this module owns. Verified against omp 18.2.6: a ChatGPT/Codex OAuth\n * account stored in `~/.omp/agent/agent.db` still resolves (`omp token\n * openai-codex`) from a relocated directory that only symlinks `agent.db*`.\n * Under the platform the user directory does not exist, the seed is a no-op,\n * and the session starts empty — which is the correct behaviour there.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3 (omp row), §5, §9\n * @see omp://models.md, omp://settings.md\n */\n\nimport { createHash } from \"node:crypto\";\nimport type { Stats } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport net from \"node:net\";\nimport path from \"node:path\";\nimport {\n type AIProviderLlmEntry,\n type AIProviderRegistry,\n AI_PROVIDER_SURFACES,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport { parse, stringify } from \"yaml\";\nimport type { ModelEntry } from \"../models.js\";\nimport {\n entryCredentialValue,\n providerCredentialEnvName,\n type RegistryCredentialEnvOptions,\n unresolvedProviderCredentials,\n} from \"../provider-materialize/credential-env.js\";\nimport { entrySurface } from \"../provider-materialize/env-harnesses.js\";\nimport type { AgentConfig, OmpHarnessOptions } from \"../types.js\";\n\n/**\n * omp's allowed provider/model `api` values (`omp://models.md`, \"Allowed\n * provider/model `api` values\").\n *\n * Every {@link AI_PROVIDER_SURFACES} member is in this list — that equality is\n * the premise the whole adapter rests on (§1.2). `google-gemini-cli` is omp's\n * one extra value, which the registry has no surface for.\n */\nexport const OMP_API_VALUES: readonly string[] = [...AI_PROVIDER_SURFACES, \"google-gemini-cli\"];\n\n/**\n * `discovery.type` values omp accepts. The registry's own enum is wider on one\n * side (`anthropic-models-list`, `google-models-list`, `none`) and narrower on\n * the other, so a discovery block is emitted only when omp can act on it.\n */\nconst OMP_DISCOVERY_TYPES: readonly string[] = [\n \"ollama\",\n \"llama.cpp\",\n \"lm-studio\",\n \"openai-models-list\",\n \"proxy\",\n \"litellm\",\n];\n\n/** One `providers.<id>` block of `models.yml`. */\ninterface OmpProviderBlock {\n baseUrl?: string;\n api?: string;\n /** The *name* of the env var holding the credential — never a value. */\n apiKey?: string;\n auth?: \"apiKey\" | \"none\" | \"oauth\";\n authHeader?: boolean;\n headers?: Record<string, string>;\n discovery?: { type: string };\n models?: OmpModelBlock[];\n}\n\n/** One entry of a provider's `models[]`. */\ninterface OmpModelBlock {\n id: string;\n name?: string;\n input?: string[];\n contextWindow?: number;\n supportsTools?: boolean;\n}\n\n/** The two files this module owns inside the agent directory. */\nexport const OMP_MODELS_FILENAME = \"models.yml\";\n\n/** omp's settings file; `modelRoles` lives here, not in `models.yml`. */\nexport const OMP_CONFIG_FILENAME = \"config.yml\";\n\n/**\n * Names {@link materializeOmpAgentDir} never links in from the user's agent\n * directory: the two files it writes itself, their alternate spellings, and\n * the legacy `settings.json` omp would migrate into `config.yml`.\n */\nconst OWNED_AGENT_DIR_FILES: Record<string, true> = {\n \"models.yml\": true,\n \"models.yaml\": true,\n \"models.json\": true,\n \"config.yml\": true,\n \"config.yaml\": true,\n \"config.yml.lock\": true,\n \"config.yaml.lock\": true,\n \"settings.json\": true,\n};\n\n/**\n * omp's own runtime state inside its home. An agent directory that an older release used as\n * omp's home still holds these; they are never agent files, so the identity link skips them\n * and the user's own login (`agent.db`) linked in from their agent directory stays in place.\n */\nconst OMP_RUNTIME_ENTRIES: Record<string, true> = {\n \"agent.db\": true,\n \"agent.db-shm\": true,\n \"agent.db-wal\": true,\n \"models.db\": true,\n \"models.db-shm\": true,\n \"models.db-wal\": true,\n \"skill-descriptions.db\": true,\n \"skill-descriptions.db-shm\": true,\n \"skill-descriptions.db-wal\": true,\n \"custom-session-files\": true,\n intercom: true,\n sessions: true,\n};\n\n/**\n * The only entries of the user's own omp agent directory a session's private home links in:\n * omp's credential store, so the login the developer already has keeps working. Sessions,\n * history, `mcp.json`, extensions and blobs stay out: a run must not write into the user's\n * session store or load their MCP servers and extensions. `config.yml` is copied, not linked.\n */\nconst OMP_LOGIN_FILES = [\"agent.db\", \"agent.db-shm\", \"agent.db-wal\"] as const;\n\n/** Options for {@link renderOmpRegistry}. */\nexport interface RenderOmpRegistryOptions extends RegistryCredentialEnvOptions {\n /** `skaile.yaml` `roles`: role name → model selector. Rendered as `modelRoles`. */\n roles?: Record<string, string>;\n /**\n * The session's own selector. When `roles` names no `default`, the resolved\n * model becomes `modelRoles.default` so `@default` (and omp's `*` alias)\n * resolve to the entry the session actually runs on.\n */\n modelRef?: string;\n /**\n * Settings to render underneath `modelRoles` — the user's own `config.yml`\n * when a standalone session seeds one. `modelRoles` is replaced wholesale,\n * not deep-merged: a seeded role pointing at a provider this session does\n * not define would otherwise survive as a dangling selector.\n */\n baseSettings?: Record<string, unknown>;\n}\n\n/** What {@link renderOmpRegistry} produced. */\nexport interface OmpRegistryRender {\n /** `models.yml` contents. */\n modelsYml: string;\n /** `config.yml` contents. */\n configYml: string;\n /**\n * `SKAILE_AIP_<ID>_KEY` → secret, for the child environment. The only place\n * a credential value appears; both rendered files hold names alone.\n */\n credentialEnv: Record<string, string>;\n /** Entry ids written to `models.yml`, in registry order. */\n providerIds: string[];\n /** `modelRoles` as written, role name → `<providerId>/<providerModelId>`. */\n modelRoles: Record<string, string>;\n /** Entries and roles that could not be rendered, and why. */\n warnings: string[];\n}\n\n/** The provider-side model ids an entry declares, keyed by logical id. */\nfunction entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logical = new Set<string>([\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}),\n ]);\n const seen = new Set<string>();\n const out: Array<[string, string]> = [];\n for (const id of logical) {\n const providerSide = entry.model_map?.[id] ?? id;\n if (seen.has(providerSide)) continue;\n seen.add(providerSide);\n out.push([id, providerSide]);\n }\n return out;\n}\n\n/**\n * Serialize one entry into an omp provider block, or report why it cannot be.\n *\n * omp requires `baseUrl` on any provider that declares `models[]`, and\n * provider-level `api` whenever `discovery` is set (except `discovery.type:\n * proxy`, where the wire is auto-detected per model). A file that violates its\n * schema is rejected *wholesale* — the registry keeps operating on built-in\n * models and the error only surfaces through `ModelRegistry.getError()` — so an\n * entry that cannot satisfy those rules is dropped here, loudly, rather than\n * taking every other provider down with it.\n */\nfunction renderProvider(\n id: string,\n entry: AIProviderLlmEntry,\n warnings: string[],\n): OmpProviderBlock | undefined {\n // The Anthropic SDK inside omp appends `/v1/messages`: a stored `…/v1` must\n // not reach the file as written. Not `entryBaseUrl`: omp gets no preset\n // literal, so an entry without an endpoint of its own is reported below.\n const baseUrl = normalizeEntryBaseUrl(resolveEntryBaseUrl(entry), entrySurface(entry));\n if (!baseUrl) {\n warnings.push(\n `provider '${id}' has no resolvable base_url (missing transport params?) — omitted from models.yml`,\n );\n return undefined;\n }\n\n // Only the entry's own surface becomes `api`; an inherited one stays omp's\n // to infer, as before. The preset's surface above only picks the URL rule.\n const surface = entry.surface;\n if (surface && !OMP_API_VALUES.includes(surface)) {\n warnings.push(\n `provider '${id}' has surface '${surface}', which omp's api enum does not accept`,\n );\n return undefined;\n }\n\n const block: OmpProviderBlock = { baseUrl };\n if (surface) block.api = surface;\n\n const kind = entry.credential?.kind ?? \"none\";\n if (kind === \"none\") {\n block.auth = \"none\";\n } else if (kind === \"sigv4\" || kind === \"google_adc\" || kind === \"azure_entra\") {\n // Ambient signing chains: the AWS/Google/Azure SDK inside omp signs the\n // request from its own environment. There is no token to hand over, and\n // omp must not treat the provider as unavailable for the lack of one.\n block.auth = \"none\";\n } else {\n block.apiKey = providerCredentialEnvName(id);\n // `bearer` is the only kind that needs the header injected; the Anthropic\n // and Azure surfaces place an `api_key_header` credential themselves.\n if (kind === \"bearer\" || kind === \"oauth\") block.authHeader = true;\n }\n\n const headers = { ...entry.headers };\n if (entry.query_params && Object.keys(entry.query_params).length > 0) {\n if (surface === \"bedrock-converse-stream\") {\n // omp keeps a query string on a Bedrock `baseUrl` and appends it to the\n // final URL (and to SigV4's canonical request) — the documented carrier\n // for gateways that authenticate by query parameter.\n const search = new URLSearchParams(entry.query_params).toString();\n block.baseUrl = `${baseUrl}${baseUrl.includes(\"?\") ? \"&\" : \"?\"}${search}`;\n } else {\n warnings.push(\n `provider '${id}' declares query_params, which omp's models.yml has no slot for on surface ` +\n `'${surface ?? \"unset\"}' — they were dropped`,\n );\n }\n }\n if (Object.keys(headers).length > 0) block.headers = headers;\n\n const discoveryType = entry.discovery?.type;\n if (discoveryType) {\n if (!OMP_DISCOVERY_TYPES.includes(discoveryType)) {\n warnings.push(\n `provider '${id}' declares discovery '${discoveryType}', which omp does not implement — ` +\n `models come from model_map only`,\n );\n } else if (!surface && discoveryType !== \"proxy\") {\n warnings.push(\n `provider '${id}' declares discovery '${discoveryType}' but no surface — omp requires ` +\n `provider-level api for every discovery type but 'proxy'`,\n );\n } else {\n block.discovery = { type: discoveryType };\n }\n }\n\n const models: OmpModelBlock[] = [];\n for (const [logical, providerSide] of entryModelIds(entry)) {\n const model: OmpModelBlock = { id: providerSide };\n if (logical !== providerSide) model.name = logical;\n const caps = entry.capabilities?.[logical];\n if (caps?.context_window !== undefined) model.contextWindow = caps.context_window;\n if (caps?.images !== undefined) model.input = caps.images ? [\"text\", \"image\"] : [\"text\"];\n if (caps?.tools !== undefined) model.supportsTools = caps.tools;\n models.push(model);\n }\n if (models.length > 0) {\n if (!surface) {\n warnings.push(\n `provider '${id}' declares models but no surface — omp requires api at provider or model level`,\n );\n return undefined;\n }\n block.models = models;\n } else if (!block.discovery) {\n warnings.push(\n `provider '${id}' declares neither model_map/capabilities nor a discovery omp implements — ` +\n `it will only override an omp built-in provider of the same id`,\n );\n }\n\n return block;\n}\n\n/**\n * Resolve the `roles` table into omp `modelRoles` selectors.\n *\n * Roles do not chain, so each value is resolved as a plain selector rather than\n * through `@role` expansion. A trailing omp thinking suffix (`:high`) survives\n * untouched: it is not part of any `model_map` key, so it falls through\n * `parseModelRef`'s literal path and is re-emitted on the provider-side id.\n */\nfunction renderModelRoles(\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n roles: Record<string, string> | undefined,\n modelRef: string | undefined,\n warnings: string[],\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [role, selector] of Object.entries(roles ?? {})) {\n const trimmed = selector.trim();\n if (!trimmed) continue;\n const ref = parseModelRef(trimmed, registry);\n if (!ref?.providerModelId) {\n warnings.push(\n `role '${role}' ('${selector}') resolves to no model in this registry — dropped`,\n );\n continue;\n }\n out[role] = `${ref.providerId}/${ref.providerModelId}`;\n }\n if (out.default === undefined && modelRef) {\n const ref = parseModelRef(modelRef, registry, roles);\n if (ref?.providerModelId) out.default = `${ref.providerId}/${ref.providerModelId}`;\n }\n return out;\n}\n\n/**\n * The warning for an entry left out of `models.yml` because its credential does not resolve.\n * `skaile run` and `skaile repl` print the same fact as one `! provider ... is not used` line\n * (runner `credential-notice.ts`), so the harness keeps this warning off the console.\n */\nfunction credentialOmissionWarning(id: string, reason: string): string {\n return `provider '${id}' omitted from models.yml: ${reason}`;\n}\n\n/** True for a warning built by {@link credentialOmissionWarning}. */\nexport function isCredentialOmissionWarning(warning: string): boolean {\n return /^provider '[^']+' omitted from models\\.yml: /.test(warning);\n}\n\n/**\n * Serialize a registry into the two omp files plus the credential environment\n * that carries their secrets.\n *\n * Only enabled `llm`/`embed` entries are rendered: `stt`/`tts` entries have no\n * wire surface and omp has no slot for them. The credential environment is\n * scoped to the same set — the omp child has no use for a Deepgram key, and a\n * secret that reaches a process which cannot spend it is pure exposure.\n *\n * An entry whose credential does not resolve here still gets its\n * `SKAILE_AIP_<ID>_KEY` name written into `models.yml`: a `platform:` ref is\n * resolved by the session boundary, which materializes the value into\n * `AgentConfig.env` under that same programme-standard name.\n */\nexport function renderOmpRegistry(\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n options: RenderOmpRegistryOptions = {},\n): OmpRegistryRender {\n const warnings: string[] = [];\n const providers: Record<string, OmpProviderBlock> = {};\n const providerIds: string[] = [];\n const credentialEnv: Record<string, string> = {};\n\n // An entry whose credential cannot be resolved here is not handed to omp: it\n // would send an empty key (`invalid x-api-key`) and shadow omp's own login for\n // the same provider.\n const unresolved = new Map(\n unresolvedProviderCredentials(registry, options).map((u) => [u.providerId, u.reason]),\n );\n for (const [id, entry] of registryEntries(registry)) {\n if (entry.kind !== \"llm\" && entry.kind !== \"embed\") continue;\n if (!isEntryEnabled(entry)) continue;\n const reason = unresolved.get(id);\n if (reason) {\n warnings.push(credentialOmissionWarning(id, reason));\n continue;\n }\n const block = renderProvider(id, entry as AIProviderLlmEntry, warnings);\n if (!block) continue;\n providers[id] = block;\n providerIds.push(id);\n // Only the canonical name, never a vendor-conventional alias: every\n // endpoint omp may address is named in models.yml with its own variable,\n // and a stray `ANTHROPIC_API_KEY` would silently make omp's *built-in*\n // Anthropic provider look authenticated with some gateway entry's key.\n const secret = entryCredentialValue(id, entry, options);\n if (secret) credentialEnv[providerCredentialEnvName(id)] = secret;\n }\n\n const modelRoles = renderModelRoles(registry, options.roles, options.modelRef, warnings);\n\n const settings: Record<string, unknown> = { ...options.baseSettings };\n if (Object.keys(modelRoles).length > 0) settings.modelRoles = modelRoles;\n\n return {\n modelsYml: stringify({ providers }),\n configYml: stringify(settings),\n credentialEnv,\n providerIds,\n modelRoles,\n warnings,\n };\n}\n\n/**\n * The models a registry makes selectable, as the harness-neutral catalog entry.\n *\n * ids are `<providerId>/<providerModelId>` — the exact selector omp's `--model`\n * and `modelRoles` take, and unambiguous when two entries serve the same model\n * id, which is the normal case once a session carries N providers.\n */\nexport function registryModelEntries(\n registry: AIProviderRegistry | MergedAIProviderRegistry | undefined,\n): ModelEntry[] {\n if (!registry) return [];\n const out: ModelEntry[] = [];\n for (const [id, entry] of registryEntries(registry)) {\n if (entry.kind !== \"llm\" && entry.kind !== \"embed\") continue;\n if (!isEntryEnabled(entry)) continue;\n const label = entry.label ?? id;\n for (const [logical, providerSide] of entryModelIds(entry as AIProviderLlmEntry)) {\n out.push({ id: `${id}/${providerSide}`, name: `${label} ${logical}` });\n }\n }\n return out;\n}\n\n/**\n * Why omp cannot serve `<providerId>/<model>` from this registry, or `undefined` when it can (or\n * when this check cannot tell). omp knows only the models a registry entry declares\n * (`model_map`, `capabilities`) or its `discovery` lists: for a provider id omp has no login for\n * and an entry that declares neither, `omp --model fake/fake-1` exits with `Model \"fake/fake-1\"\n * not found` on the first prompt (p1334). `nativeProviders` are the ids omp ships a login for;\n * their entry only overrides the built-in provider, so the model may still be omp's own.\n */\nexport function ompRegistryModelRefusal(\n registry: AIProviderRegistry | MergedAIProviderRegistry | undefined,\n selector: string,\n nativeProviders: ReadonlySet<string>,\n): string | undefined {\n if (!registry) return undefined;\n const slash = selector.indexOf(\"/\");\n if (slash <= 0) return undefined;\n const head = selector.slice(0, slash);\n // A trailing omp thinking suffix (`:high`) is not part of the model id.\n const model = selector.slice(slash + 1).replace(/:(off|minimal|low|medium|high|xhigh)$/i, \"\");\n if (!model || nativeProviders.has(head)) return undefined;\n const found = registryEntries(registry).find(([id]) => id === head);\n if (!found) return undefined;\n const [, entry] = found;\n if ((entry.kind !== \"llm\" && entry.kind !== \"embed\") || !isEntryEnabled(entry)) return undefined;\n const llm = entry as AIProviderLlmEntry;\n if (llm.discovery?.type && OMP_DISCOVERY_TYPES.includes(llm.discovery.type)) return undefined;\n const known = entryModelIds(llm).flatMap(([logical, providerSide]) => [logical, providerSide]);\n if (known.includes(model)) return undefined;\n return known.length === 0\n ? `omp cannot serve model '${selector}': registry entry '${head}' declares no models (add model_map or capabilities to it in providers.yml), and omp has no login for '${head}'. Pick a model omp lists.`\n : `omp cannot serve model '${selector}': registry entry '${head}' declares ${known.join(\", \")}, not '${model}'. Pick one of those, or add '${model}' to the entry's model_map.`;\n}\n\n/** Options for {@link materializeOmpAgentDir}. */\nexport interface MaterializeOmpAgentDirOptions extends RenderOmpRegistryOptions {\n /**\n * The user's own omp agent directory to seed from — its auth store\n * (`agent.db`) is linked in so a standalone session keeps the login the\n * developer already has, and its `config.yml` is read as base settings.\n * Sessions, history, `mcp.json` and extensions are not linked. Absent (the\n * platform case) seeds nothing. A missing directory is not an error: it is the platform case.\n */\n seedFrom?: string;\n /**\n * GitAgent identity directory (`AgentConfig.agentDir`) whose contents omp\n * reads out of the same base: `agent.yaml`, `SOUL.md`, `RULES.md`,\n * `knowledge/`. Linked in after the seed, so identity wins a name clash.\n */\n identityDir?: string;\n}\n\n/** What {@link materializeOmpAgentDir} wrote. */\nexport interface OmpAgentDirMaterialization extends OmpRegistryRender {\n /** The directory `PI_CODING_AGENT_DIR` must point at. */\n agentDir: string;\n /** The directory is the harness's temporary home: remove it when the run ends. */\n ephemeral?: boolean;\n /** Names linked in from {@link MaterializeOmpAgentDirOptions.seedFrom}. */\n seeded: string[];\n /** Names linked in from {@link MaterializeOmpAgentDirOptions.identityDir}. */\n identity: string[];\n}\n\n/** Inputs {@link planOmpAgentDir} derives the session directory layout from. */\nexport interface OmpAgentDirPlanInput {\n /** Session working directory. Distinguishes two default-named sessions. */\n cwd: string;\n /** Session id — the directory key, so concurrent sessions never collide. */\n sessionId?: string;\n /** `AgentConfig.harnessOptions.omp`. */\n options?: OmpHarnessOptions;\n /** Home the default seed source resolves against. Defaults to `os.homedir()`. */\n homeDir?: string;\n /** Root the private directory is created under. Defaults to `os.tmpdir()`. */\n tmpDir?: string;\n}\n\n/** Where a session's omp agent directory lives, and what it inherits. */\nexport interface OmpAgentDirPlan {\n /** Session-private directory `PI_CODING_AGENT_DIR` points at. */\n agentDir: string;\n /** User agent directory whose login is linked in, when there is one to inherit. */\n seedFrom?: string;\n /**\n * The directory is the harness's own temporary home, to be removed when the run ends. False\n * when the session named its own `harnessOptions.omp.agentHome`, which belongs to the user.\n */\n ephemeral: boolean;\n}\n\n/**\n * Decide the session-private agent directory and whether it inherits the\n * developer's omp state.\n *\n * The directory is deliberately **outside `cwd`**. It holds omp's credential\n * store — a symlink to the developer's `agent.db` on a standalone machine —\n * and `cwd` is the one tree the agent has write access to by design; managed\n * codex draws the same line and rejects a private directory nested in the\n * workspace (`codex/instance-state.ts`). Sessions are keyed by id, falling\n * back to a digest of the workspace path. The temporary directory is `<key>-<random>`, created per\n * call, so no two runs share one (and one run's cleanup never removes another's).\n *\n * Seeding keys on the user directory *existing*, which is exactly the\n * platform/standalone distinction the plan draws: a platform container has no\n * `~/.omp/agent`, so the session correctly starts empty; a developer machine\n * has one, so the session keeps the logins already stored there.\n * `harnessOptions.omp.seedUserAgentDir: false` forces the empty case anyway.\n */\nexport async function planOmpAgentDir(input: OmpAgentDirPlanInput): Promise<OmpAgentDirPlan> {\n const options = input.options;\n const key =\n input.sessionId?.trim() ||\n createHash(\"sha256\").update(path.resolve(input.cwd)).digest(\"hex\").slice(0, 16);\n const ephemeral = options?.agentHome === undefined;\n // The temporary home is unique per spawn: callers key sessions loosely (`skaile chat` passes\n // none, `serve` without --session-id uses one shared id, sub-prompt harnesses share a hash), and\n // the harness deletes its home when its run ends, which must never reach a sibling's home.\n let agentDir = options?.agentHome ?? \"\";\n if (ephemeral) {\n const root = path.join(input.tmpDir ?? os.tmpdir(), \"skaile-omp-agent\");\n await fs.mkdir(root, { recursive: true });\n await sweepStaleOmpHomes(root);\n agentDir = await fs.mkdtemp(path.join(root, `${key.replace(/[^A-Za-z0-9._-]/g, \"_\")}-`));\n await fs.writeFile(path.join(agentDir, OWNER_FILE), String(process.pid));\n }\n if (options?.seedUserAgentDir === false) return { agentDir, ephemeral };\n\n const seedFrom =\n options?.userAgentDir ?? path.join(input.homeDir ?? os.homedir(), \".omp\", \"agent\");\n if (path.resolve(seedFrom) === path.resolve(agentDir)) return { agentDir, ephemeral };\n try {\n if (!(await fs.stat(seedFrom)).isDirectory()) return { agentDir, ephemeral };\n } catch {\n return { agentDir, ephemeral };\n }\n return { agentDir, seedFrom, ephemeral };\n}\n\n/** Names the process that created a temporary home; the sweep keeps a home whose owner lives. */\nconst OWNER_FILE = \".skaile-owner-pid\";\n/** A temporary home older than this whose owner is gone is removed at the next start. */\nconst STALE_HOME_MS = 24 * 60 * 60 * 1000;\n\n/**\n * The names skaile gave a temporary home: `<key>-<six random characters>` (`mkdtemp`), and\n * `<key>-<12 hex>` from releases before 5.16 (p1151).\n */\nconst SKAILE_HOME_NAME = /^[A-Za-z0-9._-]+-(?:[A-Za-z0-9]{6}|[0-9a-f]{12})$/;\n\nfunction processAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (err) {\n return (err as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\n/**\n * Whether nothing listens on the unix socket `file`: a connect is refused (the process that\n * bound it is gone) or finds no socket. A socket somebody still serves, or one that does not\n * answer within a second, counts as in use.\n */\nfunction socketIsDead(file: string): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n const conn = net.connect(file);\n const done = (dead: boolean) => {\n conn.destroy();\n resolve(dead);\n };\n conn.setTimeout(1000, () => done(false));\n conn.once(\"connect\", () => done(false));\n conn.once(\"error\", (err: NodeJS.ErrnoException) =>\n done(err.code === \"ECONNREFUSED\" || err.code === \"ENOENT\"),\n );\n });\n}\n\n/**\n * Remove temporary homes older than a day whose creating process is gone: a run that was killed\n * never reached the harness's own cleanup, and every one leaves symlinks and databases behind\n * (p811). A home of a live process is kept whatever its age. A unix socket of that age that\n * nobody listens on is removed too (omp binds one beside the homes and a killed run leaves it,\n * p1316). Best effort: a failure is ignored.\n */\nasync function sweepStaleOmpHomes(root: string, now = Date.now()): Promise<void> {\n let names: string[];\n try {\n names = await fs.readdir(root);\n } catch {\n return;\n }\n await Promise.all(\n names.map(async (name) => {\n const home = path.join(root, name);\n try {\n const stat = await fs.lstat(home);\n if (now - stat.mtimeMs < STALE_HOME_MS) return;\n if (stat.isSocket()) {\n if (await socketIsDead(home)) await fs.rm(home, { force: true });\n return;\n }\n if (!stat.isDirectory()) return;\n const owner = Number.parseInt(\n await fs.readFile(path.join(home, OWNER_FILE), \"utf8\").catch(() => \"\"),\n 10,\n );\n if (Number.isInteger(owner) && processAlive(owner)) return;\n // A home with no owner file is one an older version made: remove it only when its\n // name has the `<key>-<six random characters>` shape `mkdtemp` gives (never a folder\n // somebody else put in this directory).\n if (!Number.isInteger(owner) && !SKAILE_HOME_NAME.test(name)) return;\n await fs.rm(home, { recursive: true, force: true });\n } catch {\n /* another process may be sweeping the same home */\n }\n }),\n );\n}\n\n/**\n * Run the steps that fill a planned home; when one throws, remove a temporary home before\n * rethrowing. The harness only learns the home (and deletes it at cleanup) once these steps\n * return, so a failure here would otherwise leave a new directory per spawn behind.\n */\nasync function removeHomeOnThrow<T>(plan: OmpAgentDirPlan, fill: () => Promise<T>): Promise<T> {\n try {\n return await fill();\n } catch (err) {\n if (plan.ephemeral) await fs.rm(plan.agentDir, { recursive: true, force: true });\n throw err;\n }\n}\n\n/** Remove a path whatever it is, without following a symlink into its target. */\nasync function removeEntry(target: string): Promise<void> {\n let stat: Stats;\n try {\n stat = await fs.lstat(target);\n } catch {\n return;\n }\n if (stat.isSymbolicLink() || stat.isFile()) {\n await fs.unlink(target);\n return;\n }\n await fs.rm(target, { recursive: true, force: true });\n}\n\n/** Symlink every entry of `sourceDir` into `dir`, skipping the owned names. */\nasync function linkInto(\n dir: string,\n sourceDir: string,\n skip: Record<string, true>,\n): Promise<string[]> {\n let names: string[];\n try {\n names = await fs.readdir(sourceDir);\n } catch {\n return [];\n }\n const linked: string[] = [];\n for (const name of names) {\n if (skip[name]) continue;\n const target = path.join(dir, name);\n await removeEntry(target);\n await fs.symlink(path.join(sourceDir, name), target);\n linked.push(name);\n }\n return linked;\n}\n\n/**\n * Remove the symlinks into the user's agent directory that an older release (or a home the\n * session named itself) left in `dir`: only the login files may point there (p811).\n */\nasync function dropStaleSeedLinks(dir: string, sourceDir: string): Promise<void> {\n let names: string[];\n try {\n names = await fs.readdir(dir);\n } catch {\n return;\n }\n const root = path.resolve(sourceDir);\n for (const name of names) {\n if ((OMP_LOGIN_FILES as readonly string[]).includes(name)) continue;\n const entry = path.join(dir, name);\n try {\n if (!(await fs.lstat(entry)).isSymbolicLink()) continue;\n const to = path.resolve(dir, await fs.readlink(entry));\n if (to === root || to.startsWith(root + path.sep)) await fs.unlink(entry);\n } catch {\n // Gone or unreadable: nothing to drop.\n }\n }\n}\n\n/** Symlink the login files (see {@link OMP_LOGIN_FILES}) of the user's agent directory into `dir`. */\nasync function linkLoginFiles(dir: string, sourceDir: string): Promise<string[]> {\n await dropStaleSeedLinks(dir, sourceDir);\n const linked: string[] = [];\n for (const name of OMP_LOGIN_FILES) {\n const from = path.join(sourceDir, name);\n try {\n if (!(await fs.stat(from)).isFile()) continue;\n } catch {\n continue;\n }\n const target = path.join(dir, name);\n await removeEntry(target);\n await fs.symlink(from, target);\n linked.push(name);\n }\n return linked;\n}\n\n/** Read a seeded `config.yml` as the base settings, or `{}` when unusable. */\nasync function readSeededSettings(seedFrom: string): Promise<Record<string, unknown>> {\n for (const name of [\"config.yml\", \"config.yaml\"]) {\n let raw: string;\n try {\n raw = await fs.readFile(path.join(seedFrom, name), \"utf-8\");\n } catch {\n continue;\n }\n const parsed = parse(raw) as unknown;\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed as Record<string, unknown>;\n }\n }\n return {};\n}\n\n/**\n * The model selector of the user's own omp default (`modelRoles.default` in their `config.yml`)\n * when it can only be served by their own `models.yml`, else `undefined` (p1172).\n *\n * The session-private home never copies the user's `models.yml`: it holds their credentials.\n * A default such as `anthropic/claude-opus-5-5` that their `models.yml` defines (a gateway, a\n * local server) then names a provider the private home does not have, and omp quietly picks\n * another model. A default on a built-in omp provider keeps working there (its login is linked\n * in), and a provider the registry renders is there too, so neither is reported.\n */\nasync function ownDefaultNeedingOwnModels(\n seedFrom: string,\n rendered: readonly string[],\n): Promise<string | undefined> {\n const selector = (await readSeededSettings(seedFrom)).modelRoles;\n const own =\n selector && typeof selector === \"object\" && !Array.isArray(selector)\n ? (selector as Record<string, unknown>).default\n : undefined;\n if (typeof own !== \"string\" || !own.includes(\"/\")) return undefined;\n const providerId = own.slice(0, own.indexOf(\"/\"));\n if (rendered.includes(providerId)) return undefined;\n let raw: string;\n try {\n raw = await fs.readFile(path.join(seedFrom, OMP_MODELS_FILENAME), \"utf-8\");\n } catch {\n return undefined;\n }\n const providers = (parse(raw) as { providers?: unknown } | null)?.providers;\n if (!providers || typeof providers !== \"object\" || Array.isArray(providers)) return undefined;\n return providerId in providers ? own : undefined;\n}\n\n/**\n * Build the session-private agent directory and write omp's two files into it.\n *\n * The user's `~/.omp/agent/models.yml` and `config.yml` are never opened for\n * writing: `config.yml` is *copied* into the session (so a token refresh or a\n * settings write inside the session cannot reach back through a symlink),\n * `models.yml` is not seeded at all, and everything else — `agent.db*` above\n * all — is symlinked so the session shares the developer's logins and caches.\n */\nexport async function materializeOmpAgentDir(\n agentDir: string,\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n options: MaterializeOmpAgentDirOptions = {},\n): Promise<OmpAgentDirMaterialization> {\n await fs.mkdir(agentDir, { recursive: true });\n\n const seeded = options.seedFrom ? await linkLoginFiles(agentDir, options.seedFrom) : [];\n const identity = options.identityDir\n ? await linkInto(agentDir, options.identityDir, OWNED_AGENT_DIR_FILES)\n : [];\n\n const baseSettings =\n options.baseSettings ??\n (options.seedFrom ? await readSeededSettings(options.seedFrom) : undefined);\n\n const render = renderOmpRegistry(registry, { ...options, baseSettings });\n\n await fs.writeFile(path.join(agentDir, OMP_MODELS_FILENAME), render.modelsYml, \"utf-8\");\n await fs.writeFile(path.join(agentDir, OMP_CONFIG_FILENAME), render.configYml, \"utf-8\");\n\n return { ...render, agentDir, seeded, identity };\n}\n\n/** What the omp harness gets back from {@link materializeOmpProviders}. */\nexport interface OmpProviderMaterialization extends OmpAgentDirMaterialization {\n /**\n * The `--model` argument for this session: `<providerId>/<providerModelId>`,\n * the one selector form omp treats as unambiguous when several providers\n * carry the same model id. Absent when the session named no model.\n */\n modelArg?: string;\n}\n\n/**\n * The whole omp adapter for one session: decide the private agent directory,\n * inherit the developer's omp state where there is any, write `models.yml` and\n * `config.yml`, and report the credential environment and `--model` selector\n * the child needs.\n *\n * Returns `undefined` when the session carries no registry with a selectable\n * entry — the harness then behaves exactly as it did before the registry\n * existed, which is what keeps this an expand-and-contract change.\n *\n * Also returns `undefined` when the session names no model (no `--model`, no\n * `default` role) and the user's own omp default is served by the user's own\n * `models.yml`, which a private home does not carry (p1172): the registry would\n * only swap that default for whatever model omp finds first.\n *\n * Also returns `undefined` when no entry can be handed to omp (every\n * credential unresolved) or when the entry the session's model selects was\n * left out: a session-private agent directory would then start omp without the\n * user's own settings, and a model that only the user's own omp login can\n * serve would fail with `No API key found` although native omp answers. The\n * harness then starts omp on the user's agent directory, so \"omp falls back to\n * its own login\" is true.\n *\n * `env:` references resolve against the runner's environment *overlaid with*\n * `config.env`, so a credential the session boundary already resolved (a\n * `platform:` secret it turned into an env var, for instance) is found here\n * under the name the registry entry points at.\n */\nexport async function materializeOmpProviders(\n config: AgentConfig,\n): Promise<OmpProviderMaterialization | undefined> {\n const registry = config.registry;\n if (!registry) return undefined;\n const selectable = registryEntries(registry).some(\n ([, entry]) => (entry.kind === \"llm\" || entry.kind === \"embed\") && isEntryEnabled(entry),\n );\n if (!selectable) return undefined;\n\n const env = { ...process.env, ...config.env };\n const selected = config.modelRef\n ? parseModelRef(config.modelRef, registry, config.roles)\n : undefined;\n const usable = renderOmpRegistry(registry, {\n env,\n ...(config.roles ? { roles: config.roles } : {}),\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n }).providerIds;\n if (usable.length === 0) return undefined;\n if (selected && !usable.includes(selected.providerId)) return undefined;\n\n const plan = await planOmpAgentDir({\n cwd: config.cwd,\n ...(config.sessionId ? { sessionId: config.sessionId } : {}),\n ...(config.harnessOptions?.omp ? { options: config.harnessOptions.omp } : {}),\n });\n\n if (!selected && !config.model && plan.seedFrom) {\n const named = renderOmpRegistry(registry, {\n env,\n ...(config.roles ? { roles: config.roles } : {}),\n }).modelRoles;\n if (named.default === undefined && (await ownDefaultNeedingOwnModels(plan.seedFrom, usable))) {\n if (plan.ephemeral) await fs.rm(plan.agentDir, { recursive: true, force: true });\n return undefined;\n }\n }\n\n const rendered = await removeHomeOnThrow(plan, () =>\n materializeOmpAgentDir(plan.agentDir, registry, {\n env,\n ...(plan.seedFrom ? { seedFrom: plan.seedFrom } : {}),\n ...(config.agentDir ? { identityDir: config.agentDir } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n }),\n );\n\n return {\n ...rendered,\n ephemeral: plan.ephemeral,\n ...(selected?.providerModelId\n ? { modelArg: `${selected.providerId}/${selected.providerModelId}` }\n : {}),\n };\n}\n\n/** What {@link materializeOmpIdentityDir} wrote. */\nexport interface OmpIdentityDirMaterialization {\n /** The directory `PI_CODING_AGENT_DIR` must point at. */\n agentDir: string;\n /** The directory is the harness's temporary home: remove it when the run ends. */\n ephemeral: boolean;\n /** Names linked in from the user's own omp agent directory. */\n seeded: string[];\n /** Names linked in from `AgentConfig.agentDir`. */\n identity: string[];\n}\n\n/**\n * The omp home of a session that has an agent directory but no provider registry.\n *\n * omp keeps its runtime state (`agent.db`, `models.db`, `skill-descriptions.db`, session\n * scratch, `intercom/`) in `PI_CODING_AGENT_DIR`. Pointing that at the agent directory itself\n * put those files beside `SOUL.md` in a pinned, shared source (`.skaile/cache/agents/<name>/`)\n * and made omp name a path inside the cache when it lacks a credential. So the home is a\n * private directory outside `cwd` (see {@link planOmpAgentDir}): the developer's own omp state\n * is linked in (their login keeps working), their `config.yml` / `models.yml` are copied (a\n * settings write cannot reach back), and the agent directory's entries are linked in last,\n * so the agent files stay where they are and omp can still read them.\n *\n * Returns `undefined` when the session has no `agentDir`.\n */\nexport async function materializeOmpIdentityDir(\n config: AgentConfig,\n): Promise<OmpIdentityDirMaterialization | undefined> {\n const identityDir = config.agentDir;\n if (!identityDir) return undefined;\n // Keyed by the agent and the workspace too: two role children of one session, each with\n // its own agent directory, must not link their entries into one home.\n const agentKey = createHash(\"sha256\")\n .update(`${path.resolve(identityDir)}\\0${path.resolve(config.cwd)}`)\n .digest(\"hex\")\n .slice(0, 12);\n const plan = await planOmpAgentDir({\n cwd: config.cwd,\n sessionId: `${config.sessionId?.trim() || \"agent\"}-${agentKey}`,\n ...(config.harnessOptions?.omp ? { options: config.harnessOptions.omp } : {}),\n });\n return removeHomeOnThrow(plan, async () => {\n await fs.mkdir(plan.agentDir, { recursive: true });\n const seeded = plan.seedFrom ? await linkLoginFiles(plan.agentDir, plan.seedFrom) : [];\n if (plan.seedFrom) {\n for (const name of Object.keys(OWNED_AGENT_DIR_FILES)) {\n const from = path.join(plan.seedFrom, name);\n try {\n if (!(await fs.stat(from)).isFile()) continue;\n } catch {\n continue;\n }\n const to = path.join(plan.agentDir, name);\n await removeEntry(to);\n await fs.copyFile(from, to);\n }\n }\n const identity = await linkInto(plan.agentDir, identityDir, {\n ...OWNED_AGENT_DIR_FILES,\n ...OMP_RUNTIME_ENTRIES,\n });\n return { agentDir: plan.agentDir, ephemeral: plan.ephemeral, seeded, identity };\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pluginRegistry } from './chunk-G5SUWZEU.js';
|
|
2
|
-
import { readPluginsLockSlice } from './chunk-
|
|
2
|
+
import { readPluginsLockSlice } from './chunk-6ARPZHOV.js';
|
|
3
3
|
import path, { join, resolve } from 'path';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
5
|
import { pathToFileURL } from 'url';
|
|
@@ -356,5 +356,5 @@ async function loadDeclaredPluginsOnce(projectDir) {
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
export { condensePluginFailure, ensurePluginsLoaded, loadDeclaredPlugins, loadPlugins, npmSpecError, pluginFailureReasons, projectRelativeFileSpec, reconcilePlugins, resolveFileSpec, rollbackPluginStore, specName };
|
|
359
|
-
//# sourceMappingURL=chunk-
|
|
360
|
-
//# sourceMappingURL=chunk-
|
|
359
|
+
//# sourceMappingURL=chunk-TUFNY6OD.js.map
|
|
360
|
+
//# sourceMappingURL=chunk-TUFNY6OD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/plugin-store/paths.ts","../cli/src/plugin-store/spec.ts","../cli/src/plugin-store/load.ts","../cli/src/plugin-store/reconcile.ts","../cli/src/plugin-store/index.ts"],"names":["existsSync","readFileSync","join","resolvePath"],"mappings":";;;;;;;;AAWO,SAAS,WAAW,UAAA,EAA4B;AACrD,EAAA,OAAO,IAAA,CAAK,UAAA,EAAY,SAAA,EAAW,SAAS,CAAA;AAC9C;AAGO,SAAS,eAAe,UAAA,EAA4B;AACzD,EAAA,OAAO,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,EAAG,cAAc,CAAA;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AAA;AAAA,EACF;AACA,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG;AACtC,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,MAAM,mBAAA,CAAoB,UAAA,EAAY,SAAS,cAAc,CAAA;AAC5E,IAAA,KAAA,MAAW,KAAK,MAAA,CAAO,MAAA,mBAAyB,CAAA,CAAE,IAAA,EAAM,EAAE,MAAM,CAAA;AAAA,EAClE,SAAS,GAAA,EAAK;AAEZ,IAAA,MAAM,SAAS,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,OAAO,GAAG,CAAA;AAC9D,IAAA,MAAM,OAAA,GAAU,oBAAA,CAAqB,MAAA,EAAQ,OAAO,CAAA;AACpD,IAAA,KAAA,MAAW,IAAA,IAAQ,SAAS,gBAAA,CAAiB,IAAA,EAAM,QAAQ,GAAA,CAAI,IAAI,KAAK,MAAM,CAAA;AAAA,EAChF;AACF","file":"chunk-THX5EE3K.js","sourcesContent":["/**\n * Pure path helpers for the project-local plugin store.\n *\n * The store is a self-contained npm workspace owned by the CLI under\n * `<projectDir>/.skaile/plugins/`. Only `resolvePluginEntry` reads the filesystem.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\n/** `<projectDir>/.skaile/plugins` — the store root. */\nexport function pluginsDir(projectDir: string): string {\n return join(projectDir, \".skaile\", \"plugins\");\n}\n\n/** `<store>/package.json` — generated, never user-edited. */\nexport function pluginsPkgJson(projectDir: string): string {\n return join(pluginsDir(projectDir), \"package.json\");\n}\n\n/** `<store>/node_modules` — where reconciled plugin packages land. */\nexport function nodeModulesDir(projectDir: string): string {\n return join(pluginsDir(projectDir), \"node_modules\");\n}\n\n/** `<store>/.reconcile-hash` — SHA of plugins-list + lock slice; skip reinstall when unchanged. */\nexport function reconcileHashFile(projectDir: string): string {\n return join(pluginsDir(projectDir), \".reconcile-hash\");\n}\n\n/** Pick the file an `exports` target points at, preferring the ESM-friendly conditions. */\nfunction exportsTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n if (Array.isArray(target)) {\n for (const t of target) {\n const hit = exportsTarget(t);\n if (hit) return hit;\n }\n return undefined;\n }\n if (target && typeof target === \"object\") {\n const map = target as Record<string, unknown>;\n for (const cond of [\"import\", \"node\", \"default\", \"require\"]) {\n if (cond in map) {\n const hit = exportsTarget(map[cond]);\n if (hit) return hit;\n }\n }\n }\n return undefined;\n}\n\n/**\n * Absolute path to a plugin package's entry file under the store's\n * `node_modules`, resolved from its `package.json` (`exports[\".\"]`, then\n * `module`, then `main`, then `index.js`). Node's ESM loader rejects directory\n * imports, so the entry must be a file; `import()` of the result works inside\n * compiled binaries via `pathToFileURL`.\n *\n * @throws When the package is not installed or declares no resolvable entry.\n */\nexport function resolvePluginEntry(projectDir: string, pkgName: string): string {\n const pkgDir = join(nodeModulesDir(projectDir), pkgName);\n const pkgJsonPath = join(pkgDir, \"package.json\");\n if (!existsSync(pkgJsonPath)) {\n throw new Error(`package \"${pkgName}\" is not installed in ${nodeModulesDir(projectDir)}`);\n }\n const pkg = JSON.parse(readFileSync(pkgJsonPath, \"utf8\")) as {\n exports?: unknown;\n module?: string;\n main?: string;\n };\n let rel: string | undefined;\n if (pkg.exports !== undefined) {\n const root =\n typeof pkg.exports === \"object\" && pkg.exports !== null && !Array.isArray(pkg.exports)\n ? ((pkg.exports as Record<string, unknown>)[\".\"] ?? pkg.exports)\n : pkg.exports;\n rel = exportsTarget(root);\n }\n rel ??= pkg.module ?? pkg.main ?? \"index.js\";\n const entry = resolve(pkgDir, rel);\n if (!existsSync(entry)) {\n throw new Error(`package \"${pkgName}\" entry ${rel} does not exist`);\n }\n return entry;\n}\n","/**\n * Parse npm package specifiers from the `plugins:` list into name + range.\n *\n * The leading `@` of a scope is NOT a separator: the first `@` at a non-zero\n * index splits the package name (which never holds an `@`) from its range, so a\n * range may hold one itself (`foo@npm:bar@1.0.0`, `foo@file:/a@b/dir`).\n * \"@skaile/provider-fly@^0.1.0\" → { name: \"@skaile/provider-fly\", range: \"^0.1.0\" }\n * \"@skaile/connector-redis\" → { name: \"@skaile/connector-redis\", range: \"*\" }\n * \"lodash@^4\" → { name: \"lodash\", range: \"^4\" }\n */\nimport path from \"node:path\";\n\n/** A parsed plugin specifier: package name plus a semver range (`\"*\"` when omitted). */\nexport interface PluginSpec {\n name: string;\n range: string;\n}\n\n/**\n * Parse a single plugin specifier into `{ name, range }`.\n *\n * @param spec - An npm specifier, e.g. `\"@skaile/provider-fly@^0.1.0\"` or `\"lodash\"`.\n * @returns The package name and semver range (range defaults to `\"*\"`).\n * @throws Error when the specifier is empty.\n */\nexport function parseSpec(spec: string): PluginSpec {\n const trimmed = spec.trim();\n if (!trimmed) throw new Error(\"parseSpec: empty specifier\");\n\n // Find the version-separating `@` — the first one that is not the scope `@`\n // at index 0. A bare `@scope/name` has its only `@` at index 0 (no range).\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) {\n return { name: trimmed, range: \"*\" };\n }\n const name = trimmed.slice(0, at);\n const range = trimmed.slice(at + 1);\n return { name, range: range.length > 0 ? range : \"*\" };\n}\n\n/** Convenience: just the package name of a specifier. */\nexport function specName(spec: string): string {\n return parseSpec(spec).name;\n}\n\n/** A package name as the registry and `package.json` keys hold it (legacy uppercase included). */\nconst PACKAGE_NAME = /^(?:@[A-Za-z0-9][A-Za-z0-9._~-]*\\/)?[A-Za-z0-9][A-Za-z0-9._~-]*$/;\n\n/**\n * The refusal for a specifier that does not start with a package name, or `undefined` when it\n * does: `name`, `@scope/name`, or `name@<any range>` (`name@^1`, `name@npm:other@1`,\n * `name@github:user/repo`, `name@git+https://...`, `name@https://...tgz`, `name@file:/abs/dir`).\n * A range may hold a space (`name@>=0.1.0 <1`); an empty range (`name@`) is refused.\n * A bare path, a `file:` URL, a `github:` / `git+` / `https:` source or `user/repo` has no name:\n * the package manager would send it to the registry or key `package.json` by the URL, and fail\n * late (p1737). Such a source is installed under its package name, `<name>@<spec>`.\n */\nexport function npmSpecError(spec: string): string | undefined {\n const trimmed = spec.trim();\n if (trimmed !== \"\" && !/@file:$/i.test(trimmed)) {\n // Only the name is checked for white space (PACKAGE_NAME has none): an npm range may hold a\n // space (`>=0.1.0 <1`) and the package manager takes it as one argument.\n const at = trimmed.indexOf(\"@\", 1);\n const nameEnd = at > 0 ? at : trimmed.length;\n if (PACKAGE_NAME.test(trimmed.slice(0, nameEnd))) {\n if (at > 0 && trimmed.slice(at + 1).trim() === \"\") {\n return (\n `plugin spec '${trimmed}' has an empty version range after '@'. ` +\n `Write ${trimmed.slice(0, at)} for any version, or ${trimmed.slice(0, at)}@<range>, for example @1.2.0.`\n );\n }\n return undefined;\n }\n }\n return (\n `plugin spec '${spec}' is not an npm package name. Give an npm name with an optional version ` +\n \"range, for example @scope/name@1.2.0, or write <name>@<spec> for a git, URL or local source, \" +\n \"for example name@github:user/repo or name@file:/path/to/dir.\"\n );\n}\n\n/** The folder a `file:` range names, or `undefined` for any other spec or an absolute / URL target. */\nfunction relativeFileTarget(spec: string): { head: string; target: string } | undefined {\n const trimmed = spec.trim();\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) return undefined;\n const range = trimmed.slice(at + 1);\n if (!/^file:/i.test(range)) return undefined;\n const target = range.slice(\"file:\".length);\n if (\n target === \"\" ||\n target.startsWith(\"//\") ||\n path.isAbsolute(target) ||\n /^[A-Za-z]:[\\\\/]/.test(target)\n ) {\n return undefined;\n }\n return { head: trimmed.slice(0, at), target };\n}\n\n/**\n * The form of a spec to write into `skaile.yaml`. A relative `file:` range is typed relative to\n * `cwd`; `skaile.yaml` is committed and read on other machines, so it holds the folder relative\n * to the project instead (`name@file:./plugins/x`, `name@file:../x`), never a machine path\n * (p1737). Any other spec is returned as written.\n */\nexport function projectRelativeFileSpec(spec: string, cwd: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n const rel = path.relative(path.resolve(projectDir), path.resolve(cwd, parts.target));\n if (path.isAbsolute(rel)) return `${parts.head}@file:${rel}`;\n const posix = rel.split(path.sep).join(\"/\") || \".\";\n return `${parts.head}@file:${posix.startsWith(\"..\") || posix === \".\" ? posix : `./${posix}`}`;\n}\n\n/**\n * The form of a spec to hand to the package manager. It runs in `.skaile/plugins/`, so a\n * project-relative `file:` range is resolved to an absolute path against `projectDir` here, and\n * only here (p1737). Any other spec is returned as written.\n */\nexport function resolveFileSpec(spec: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n return `${parts.head}@file:${path.resolve(projectDir, parts.target)}`;\n}\n","/**\n * Runtime plugin loader: dynamic-import each reconciled plugin and let it\n * self-register into the `pluginRegistry`.\n *\n * Each plugin specifier resolves to an absolute path under the store's\n * `node_modules`; we import it via a `file://` URL so the import works inside\n * `bun --compile` binaries (which bundle only the literal-string switches, but\n * can still execute a `file://` import against the unpacked store on disk).\n * Failures are caught per-plugin so one broken plugin never aborts the rest.\n */\n\nimport { pathToFileURL } from \"node:url\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport { resolvePluginEntry } from \"./paths.js\";\nimport { parseSpec } from \"./spec.js\";\n\n/** Options for {@link loadPlugins}. */\nexport interface LoadOptions {\n log?: Logger;\n}\n\n/** Result of a load pass: which specs registered and which failed. */\nexport interface LoadResult {\n loaded: string[];\n failed: { spec: string; error: string; reason: string }[];\n}\n\n/** The self-registration entrypoint a plugin module is expected to export. */\ntype PluginModule = { register?: (registry: PluginRegistry) => void };\n\n/**\n * Load and register each plugin in `plugins` into `registry`.\n *\n * @param projectDir - Project root holding `.skaile/plugins/node_modules`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param registry - Registry to register into. Defaults to the process-wide `pluginRegistry`.\n * @param opts - Optional logger.\n * @returns Loaded specs + per-plugin failures (never throws).\n */\nexport async function loadPlugins(\n projectDir: string,\n plugins: string[],\n registry: PluginRegistry = pluginRegistry,\n opts: LoadOptions = {},\n): Promise<LoadResult> {\n const loaded: string[] = [];\n const failed: { spec: string; error: string; reason: string }[] = [];\n\n for (const spec of plugins) {\n try {\n const { name } = parseSpec(spec);\n const entry = resolvePluginEntry(projectDir, name);\n const mod = (await import(pathToFileURL(entry).href)) as PluginModule;\n if (typeof mod.register !== \"function\") {\n throw new Error(`plugin \"${name}\" does not export a register() function`);\n }\n mod.register(registry);\n loaded.push(spec);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n failed.push({ spec, error: `failed to load plugin \"${spec}\": ${message}`, reason: message });\n opts.log?.warn(`plugin load failed: ${spec}`, { error: message });\n }\n }\n\n return { loaded, failed };\n}\n","/**\n * Reconcile the project-local plugin store (`<projectDir>/.skaile/plugins/`).\n *\n * The reconciler is hash-skipped: it computes a SHA-256 over the sorted plugin\n * list plus the lock file's `plugins` slice and compares it to the stored\n * `.reconcile-hash`. On a match it returns with zero further I/O; otherwise it\n * regenerates the store's `package.json` and runs `bun install` against it.\n *\n * The install step is injectable (`InstallFn`) so tests stay hermetic — they\n * pass a fake installer that records calls and writes a stub `node_modules`.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPluginsLockSlice } from \"@skaile/workspaces/core\";\nimport { nodeModulesDir, pluginsDir, pluginsPkgJson, reconcileHashFile } from \"./paths.js\";\nimport { parseSpec, resolveFileSpec } from \"./spec.js\";\n\n/** How `InstallFn` may treat the store's lock: `frozen` forbids lock changes. */\nexport interface InstallOptions {\n /**\n * `false` when the spec list changed since the last `package.json`, so the\n * lock has to change too. Defaults to `true` (frozen when a lock exists).\n */\n frozen?: boolean;\n}\n\n/**\n * Installs the store's dependencies. Returns `ok: false` (never throws) on a\n * failed install so the reconciler can surface the captured `output`.\n */\nexport type InstallFn = (\n pluginsDir: string,\n opts?: InstallOptions,\n) => Promise<{ ok: boolean; output: string }>;\n\n/** Options for {@link reconcilePlugins}. */\nexport interface ReconcileOptions {\n /** Injectable installer. Defaults to a real `bun install` of the store. */\n runInstall?: InstallFn;\n /**\n * Lock slice to fold into the reconcile-hash. Defaults to\n * `readPluginsLockSlice(projectDir)` so a lock edit invalidates the hash.\n */\n lockSlice?: unknown;\n}\n\n/** Result of a reconcile pass. */\nexport interface ReconcileResult {\n changed: boolean;\n reason: \"no-plugins\" | \"up-to-date\" | \"reconciled\";\n}\n\n/** Run a command to completion, capturing stdout+stderr. `started: false` when it cannot spawn. */\nasync function runCapture(\n args: string[],\n cwd: string,\n): Promise<{ started: boolean; code: number; output: string }> {\n const { portableSpawn } = await import(\"@skaile/workspaces/core\");\n const proc = portableSpawn(args, { cwd });\n const chunks: string[] = [];\n const decoder = new TextDecoder();\n const pump = async (stream: ReadableStream<Uint8Array>) => {\n const reader = stream.getReader();\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n if (value) chunks.push(decoder.decode(value, { stream: true }));\n }\n };\n await Promise.all([pump(proc.stdout), pump(proc.stderr)]);\n const code = await proc.exited;\n // `portableSpawn` reports a spawn error (ENOENT) as exit -1 with no pid.\n return { started: proc.pid !== -1, code, output: chunks.join(\"\") };\n}\n\n/**\n * The default real installer: `bun install` inside the store directory, or\n * `npm install` when `bun` is not on PATH. Frozen only when a lock exists and\n * the spec list did not change (`opts.frozen !== false`): a changed list has to\n * rewrite the lock, which a frozen install refuses.\n */\nexport const defaultInstall: InstallFn = async (dir, opts = {}) => {\n const hasBunLock = existsSync(`${dir}/bun.lock`) || existsSync(`${dir}/bun.lockb`);\n const hasNpmLock = existsSync(`${dir}/package-lock.json`);\n const frozen = opts.frozen !== false;\n\n const bunArgs =\n frozen && (hasBunLock || hasNpmLock)\n ? [\"bun\", \"install\", \"--frozen-lockfile\"]\n : [\"bun\", \"install\"];\n const withBun = await runCapture(bunArgs, dir);\n if (withBun.started) return { ok: withBun.code === 0, output: withBun.output };\n\n const npmArgs =\n frozen && hasNpmLock\n ? [\"npm\", \"ci\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"]\n : [\"npm\", \"install\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"];\n const withNpm = await runCapture(npmArgs, dir);\n if (withNpm.started) return { ok: withNpm.code === 0, output: withNpm.output };\n return {\n ok: false,\n output:\n \"neither bun nor npm found on PATH; plugin install needs one of them (https://bun.sh or https://nodejs.org)\",\n };\n};\n\n/**\n * Generate the store's `package.json` from the plugin specs. Returns the\n * previous file content (`undefined` when there was none) and whether the\n * dependency set changed.\n */\nfunction writePackageJson(\n projectDir: string,\n plugins: string[],\n): { previous: string | undefined; depsChanged: boolean; removedDep: boolean } {\n const dependencies: Record<string, string> = {};\n for (const spec of plugins) {\n const { name, range } = parseSpec(resolveFileSpec(spec, projectDir));\n dependencies[name] = range;\n }\n const pkg = {\n name: \"skaile-project-plugins\",\n private: true,\n dependencies,\n };\n const file = pluginsPkgJson(projectDir);\n const previous = existsSync(file) ? readFileSync(file, \"utf8\") : undefined;\n let before: Record<string, string> | undefined;\n try {\n before = previous === undefined ? undefined : JSON.parse(previous).dependencies;\n } catch {\n before = undefined;\n }\n const sortedJson = (d: Record<string, string> | undefined) =>\n JSON.stringify(Object.entries(d ?? {}).sort(([a], [b]) => a.localeCompare(b)));\n const depsChanged = before === undefined || sortedJson(before) !== sortedJson(dependencies);\n // A plugin the list no longer names: the package manager prunes a registry package, but not a\n // `file:` one and not what a failed install left, so the caller rebuilds `node_modules`.\n const removedDep = Object.keys(before ?? {}).some((name) => !(name in dependencies));\n mkdirSync(pluginsDir(projectDir), { recursive: true });\n writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\\n`);\n return { previous, depsChanged, removedDep };\n}\n\n/**\n * Reconcile the plugin store for a project.\n *\n * @param projectDir - Project root containing `skaile.yaml` / `skaile.lock.yaml`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param opts - Optional injectable installer + lock slice override.\n * @returns Whether the store changed and why.\n */\nexport async function reconcilePlugins(\n projectDir: string,\n plugins: string[],\n opts: ReconcileOptions = {},\n): Promise<ReconcileResult> {\n if (plugins.length === 0) {\n return { changed: false, reason: \"no-plugins\" };\n }\n\n const lockSlice = opts.lockSlice ?? readPluginsLockSlice(projectDir);\n const wantHash = createHash(\"sha256\")\n .update(\n JSON.stringify({\n plugins: plugins.map((spec) => resolveFileSpec(spec, projectDir)).sort(),\n lock: lockSlice,\n }),\n )\n .digest(\"hex\");\n\n const hashFile = reconcileHashFile(projectDir);\n if (existsSync(hashFile)) {\n const have = readFileSync(hashFile, \"utf8\").trim();\n if (have === wantHash) {\n return { changed: false, reason: \"up-to-date\" };\n }\n }\n\n const { previous, depsChanged, removedDep } = writePackageJson(projectDir, plugins);\n if (removedDep) rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n\n const install = opts.runInstall ?? defaultInstall;\n const result = await install(pluginsDir(projectDir), { frozen: !depsChanged });\n if (!result.ok) {\n // A failed install must not leave the spec behind: the next reconcile\n // would compare against it and treat the store as already changed.\n if (previous === undefined) rmSync(pluginsPkgJson(projectDir), { force: true });\n else writeFileSync(pluginsPkgJson(projectDir), previous);\n throw new Error(`plugin install failed:\\n${result.output}`);\n }\n\n writeFileSync(hashFile, wantHash);\n return { changed: true, reason: \"reconciled\" };\n}\n\n/**\n * Put the store back to `previousPlugins` after `plugin install` failed past\n * the reconcile (the plugin installed but does not load). Best effort: a\n * failing reinstall is swallowed, the store is then rebuilt by the next\n * reconcile because the hash no longer matches the declared list.\n *\n * With no previous plugins every generated file of the store goes away\n * (`package.json`, hash, lock file and `node_modules`), so the store keeps\n * neither the rejected spec nor its installed package.\n */\nexport async function rollbackPluginStore(\n projectDir: string,\n previousPlugins: string[],\n opts: ReconcileOptions = {},\n): Promise<void> {\n if (previousPlugins.length === 0) {\n const dir = pluginsDir(projectDir);\n rmSync(pluginsPkgJson(projectDir), { force: true });\n rmSync(reconcileHashFile(projectDir), { force: true });\n rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n for (const lock of [\"bun.lock\", \"bun.lockb\", \"package-lock.json\"]) {\n rmSync(join(dir, lock), { force: true });\n }\n try {\n // The folder goes when nothing else of the user's is in it.\n rmdirSync(dir);\n } catch {\n // not empty, or already gone\n }\n return;\n }\n try {\n await reconcilePlugins(projectDir, previousPlugins, opts);\n } catch {\n // the next reconcile retries\n }\n}\n","/**\n * The project-local plugin store: reconcile (`<projectDir>/.skaile/plugins/`)\n * then load the reconciled plugins into the `pluginRegistry`.\n *\n * `ensurePluginsLoaded` is the single entrypoint commands wire in. It is a\n * guarded no-op when `plugins` is empty/undefined — zero overhead for the\n * common case where no project declares `plugins:` in `skaile.yaml`.\n */\n\nimport { resolve as resolvePath } from \"node:path\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport pc from \"picocolors\";\nimport { type LoadResult, loadPlugins } from \"./load.js\";\nimport { type ReconcileOptions, reconcilePlugins } from \"./reconcile.js\";\nimport { specName } from \"./spec.js\";\n\nexport type { LoadResult } from \"./load.js\";\nexport { loadPlugins } from \"./load.js\";\nexport type { ReconcileOptions } from \"./reconcile.js\";\nexport { reconcilePlugins, rollbackPluginStore } from \"./reconcile.js\";\nexport { npmSpecError, projectRelativeFileSpec, resolveFileSpec, specName } from \"./spec.js\";\n\n/** Options for {@link ensurePluginsLoaded}. */\nexport interface EnsurePluginsOptions extends ReconcileOptions {\n log?: Logger;\n}\n\n/**\n * Reconcile the plugin store then load each plugin into `registry`.\n *\n * No-op (returns immediately) when `plugins` is empty/undefined, so the common\n * no-plugins path costs nothing.\n *\n * @param projectDir - Project root.\n * @param plugins - The `skaile.yaml` `plugins:` list (may be undefined).\n * @param registry - Registry to register into. Defaults to `pluginRegistry`.\n * @param opts - Injectable installer / lock slice + optional logger.\n * @returns The load result, or an empty result when there are no plugins.\n */\nexport async function ensurePluginsLoaded(\n projectDir: string,\n plugins: string[] | undefined,\n registry: PluginRegistry = pluginRegistry,\n opts: EnsurePluginsOptions = {},\n): Promise<LoadResult> {\n if (!plugins || plugins.length === 0) {\n return { loaded: [], failed: [] };\n }\n await reconcilePlugins(projectDir, plugins, opts);\n return loadPlugins(projectDir, plugins, registry, { log: opts.log });\n}\n\n/**\n * The installer's output of a failed `plugin install` is a dump (bun's banner, resolver\n * progress, then the `error:` lines). A load warning keeps the first line and the cause of it\n * (p1113); `skaile plugin install <spec>` prints the whole output.\n *\n * bun: the last `error:` line. npm: its `code` line and the first detail line after it\n * (`E404: 404 Not Found - GET …`), never the trailing `A complete log of this run can be found\n * in: …` pointer (p1272).\n */\nexport function condensePluginFailure(reason: string): string {\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\");\n const [first, ...rest] = lines;\n if (!reason.startsWith(\"plugin install failed\") || first === undefined || rest.length === 0) {\n return reason;\n }\n const head = first.replace(/:$/, \"\");\n const npmPrefix = /^npm (ERR!|error)\\s*/i;\n const npmLines = rest\n .filter((l) => npmPrefix.test(l) && !/^npm \\S+\\s+A complete log of this run\\b/i.test(l))\n .map((l) => l.replace(npmPrefix, \"\"))\n .filter((l) => l !== \"\");\n const codeLine = npmLines.find((l) => /^code\\s+\\S+/i.test(l));\n if (codeLine) {\n const code = codeLine.replace(/^code\\s+/i, \"\");\n const detail = npmLines.find((l) => l !== codeLine && !/^code\\s/i.test(l));\n return `${head}: npm ${code}${detail ? `: ${detail}` : \"\"}`;\n }\n const causes = rest.filter(\n (l) => /^error\\b/i.test(l) || (npmPrefix.test(l) && !/A complete log of this run\\b/i.test(l)),\n );\n const cause =\n causes.at(-1) ?? rest.filter((l) => !/A complete log of this run\\b/i.test(l)).at(-1);\n return `${head}: ${cause ?? rest.at(-1)}`;\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\/]/g, \"\\\\$&\");\n}\n\n/**\n * Split the output of one failed install of the whole plugin store into one reason per plugin\n * (p1272): the package manager runs once for every spec, so its output names the plugins that\n * failed. A plugin gets the line that names it (also its URL-encoded form `@scope%2fname`); a\n * plugin the output never names says it was not installed and which plugin the install stopped\n * at. With one plugin, or when the output names none (no `bun` and no `npm`), every plugin keeps\n * the whole condensed reason.\n */\nexport function pluginFailureReasons(\n reason: string,\n specs: readonly string[],\n): Map<string, string> {\n const out = new Map<string, string>();\n const condensed = condensePluginFailure(reason);\n if (specs.length < 2 || !reason.startsWith(\"plugin install failed\")) return out;\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\" && !/A complete log of this run\\b/i.test(l));\n const names = specs.map((spec) => {\n try {\n return specName(spec);\n } catch {\n return spec;\n }\n });\n const mentions = (text: string, name: string): boolean => {\n const forms = [name, name.replace(\"/\", \"%2f\"), name.replace(\"/\", \"%2F\")];\n return forms.some((f) =>\n new RegExp(`(?<![\\\\w@.-])(?<!@[\\\\w.~-]+/)${escapeRegExp(f)}(?![\\\\w-]|\\\\.\\\\w)`).test(text),\n );\n };\n const cause = /\\berror\\b|\\bE[A-Z0-9]{3,}\\b|\\b404\\b|notarget|failed to resolve/i;\n const named: string[] = [];\n specs.forEach((spec, i) => {\n const name = names[i] as string;\n const line = mentions(condensed, name)\n ? condensed.replace(/^plugin install failed:\\s*/, \"\")\n : lines.filter((l) => mentions(l, name) && cause.test(l)).at(-1);\n if (line === undefined) return;\n named.push(name);\n out.set(spec, `plugin install failed: ${line.replace(/^(npm\\s+)?(ERR!|error:?)\\s*/i, \"\")}`);\n });\n if (named.length === 0) return new Map();\n specs.forEach((spec, i) => {\n if (!out.has(spec)) {\n out.set(\n spec,\n `plugin install failed: ${names[i]} was not installed, the install stopped at ${named.join(\", \")}`,\n );\n }\n });\n return out;\n}\n\n/** One `! plugin <name> failed to load: <reason>` line on stderr (stdout carries a run's answer). */\nfunction warnPluginFailed(spec: string, reason: string): void {\n let name = spec;\n try {\n name = specName(spec);\n } catch {\n /* a spec that does not parse is named as written */\n }\n process.stderr.write(\n ` ${pc.yellow(\"!\")} plugin ${name} failed to load: ${condensePluginFailure(reason)}\\n`,\n );\n}\n\n/**\n * Reconcile + load the `plugins:` of the project's `skaile.yaml` into the process registry, so a\n * plugin's harness is known to `run`, `repl` and `config set harness`. A plugin that fails to\n * reconcile or load is skipped (its harness stays unknown, the command goes on) and named in one\n * `! plugin <name> failed to load: <reason>` line on stderr. An unreadable config is not this\n * function's to report: the command reads it again and says so.\n */\nexport function loadDeclaredPlugins(projectDir: string): Promise<void> {\n // A plugin registers once per process: a second `register()` is a duplicate.\n const key = resolvePath(projectDir);\n let pending = declaredPluginLoads.get(key);\n if (!pending) {\n pending = loadDeclaredPluginsOnce(projectDir);\n declaredPluginLoads.set(key, pending);\n }\n return pending;\n}\n\nconst declaredPluginLoads = new Map<string, Promise<void>>();\n\nasync function loadDeclaredPluginsOnce(projectDir: string): Promise<void> {\n let plugins: string[] | undefined;\n try {\n const { resolveSkWorkspaceConfig } = await import(\"@skaile/workspaces/core\");\n plugins = resolveSkWorkspaceConfig(projectDir).plugins;\n } catch {\n return;\n }\n if (!plugins || plugins.length === 0) return;\n try {\n const result = await ensurePluginsLoaded(projectDir, plugins, pluginRegistry);\n for (const f of result.failed) warnPluginFailed(f.spec, f.reason);\n } catch (err) {\n // The store could not be reconciled: no plugin was loaded.\n const reason = err instanceof Error ? err.message : String(err);\n const reasons = pluginFailureReasons(reason, plugins);\n for (const spec of plugins) warnPluginFailed(spec, reasons.get(spec) ?? reason);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/plugin-store/paths.ts","../cli/src/plugin-store/spec.ts","../cli/src/plugin-store/load.ts","../cli/src/plugin-store/reconcile.ts","../cli/src/plugin-store/index.ts"],"names":["existsSync","readFileSync","join","resolvePath"],"mappings":";;;;;;;;AAWO,SAAS,WAAW,UAAA,EAA4B;AACrD,EAAA,OAAO,IAAA,CAAK,UAAA,EAAY,SAAA,EAAW,SAAS,CAAA;AAC9C;AAGO,SAAS,e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A,OAAA,GAAU,wBAAA,CAAyB,UAAU,CAAA,CAAE,OAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA;AAAA,EACF;AACA,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG;AACtC,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,MAAM,mBAAA,CAAoB,UAAA,EAAY,SAAS,cAAc,CAAA;AAC5E,IAAA,KAAA,MAAW,KAAK,MAAA,CAAO,MAAA,mBAAyB,CAAA,CAAE,IAAA,EAAM,EAAE,MAAM,CAAA;AAAA,EAClE,SAAS,GAAA,EAAK;AAEZ,IAAA,MAAM,SAAS,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,OAAO,GAAG,CAAA;AAC9D,IAAA,MAAM,OAAA,GAAU,oBAAA,CAAqB,MAAA,EAAQ,OAAO,CAAA;AACpD,IAAA,KAAA,MAAW,IAAA,IAAQ,SAAS,gBAAA,CAAiB,IAAA,EAAM,QAAQ,GAAA,CAAI,IAAI,KAAK,MAAM,CAAA;AAAA,EAChF;AACF","file":"chunk-TUFNY6OD.js","sourcesContent":["/**\n * Pure path helpers for the project-local plugin store.\n *\n * The store is a self-contained npm workspace owned by the CLI under\n * `<projectDir>/.skaile/plugins/`. Only `resolvePluginEntry` reads the filesystem.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\n/** `<projectDir>/.skaile/plugins` — the store root. */\nexport function pluginsDir(projectDir: string): string {\n return join(projectDir, \".skaile\", \"plugins\");\n}\n\n/** `<store>/package.json` — generated, never user-edited. */\nexport function pluginsPkgJson(projectDir: string): string {\n return join(pluginsDir(projectDir), \"package.json\");\n}\n\n/** `<store>/node_modules` — where reconciled plugin packages land. */\nexport function nodeModulesDir(projectDir: string): string {\n return join(pluginsDir(projectDir), \"node_modules\");\n}\n\n/** `<store>/.reconcile-hash` — SHA of plugins-list + lock slice; skip reinstall when unchanged. */\nexport function reconcileHashFile(projectDir: string): string {\n return join(pluginsDir(projectDir), \".reconcile-hash\");\n}\n\n/** Pick the file an `exports` target points at, preferring the ESM-friendly conditions. */\nfunction exportsTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n if (Array.isArray(target)) {\n for (const t of target) {\n const hit = exportsTarget(t);\n if (hit) return hit;\n }\n return undefined;\n }\n if (target && typeof target === \"object\") {\n const map = target as Record<string, unknown>;\n for (const cond of [\"import\", \"node\", \"default\", \"require\"]) {\n if (cond in map) {\n const hit = exportsTarget(map[cond]);\n if (hit) return hit;\n }\n }\n }\n return undefined;\n}\n\n/**\n * Absolute path to a plugin package's entry file under the store's\n * `node_modules`, resolved from its `package.json` (`exports[\".\"]`, then\n * `module`, then `main`, then `index.js`). Node's ESM loader rejects directory\n * imports, so the entry must be a file; `import()` of the result works inside\n * compiled binaries via `pathToFileURL`.\n *\n * @throws When the package is not installed or declares no resolvable entry.\n */\nexport function resolvePluginEntry(projectDir: string, pkgName: string): string {\n const pkgDir = join(nodeModulesDir(projectDir), pkgName);\n const pkgJsonPath = join(pkgDir, \"package.json\");\n if (!existsSync(pkgJsonPath)) {\n throw new Error(`package \"${pkgName}\" is not installed in ${nodeModulesDir(projectDir)}`);\n }\n const pkg = JSON.parse(readFileSync(pkgJsonPath, \"utf8\")) as {\n exports?: unknown;\n module?: string;\n main?: string;\n };\n let rel: string | undefined;\n if (pkg.exports !== undefined) {\n const root =\n typeof pkg.exports === \"object\" && pkg.exports !== null && !Array.isArray(pkg.exports)\n ? ((pkg.exports as Record<string, unknown>)[\".\"] ?? pkg.exports)\n : pkg.exports;\n rel = exportsTarget(root);\n }\n rel ??= pkg.module ?? pkg.main ?? \"index.js\";\n const entry = resolve(pkgDir, rel);\n if (!existsSync(entry)) {\n throw new Error(`package \"${pkgName}\" entry ${rel} does not exist`);\n }\n return entry;\n}\n","/**\n * Parse npm package specifiers from the `plugins:` list into name + range.\n *\n * The leading `@` of a scope is NOT a separator: the first `@` at a non-zero\n * index splits the package name (which never holds an `@`) from its range, so a\n * range may hold one itself (`foo@npm:bar@1.0.0`, `foo@file:/a@b/dir`).\n * \"@skaile/provider-fly@^0.1.0\" → { name: \"@skaile/provider-fly\", range: \"^0.1.0\" }\n * \"@skaile/connector-redis\" → { name: \"@skaile/connector-redis\", range: \"*\" }\n * \"lodash@^4\" → { name: \"lodash\", range: \"^4\" }\n */\nimport path from \"node:path\";\n\n/** A parsed plugin specifier: package name plus a semver range (`\"*\"` when omitted). */\nexport interface PluginSpec {\n name: string;\n range: string;\n}\n\n/**\n * Parse a single plugin specifier into `{ name, range }`.\n *\n * @param spec - An npm specifier, e.g. `\"@skaile/provider-fly@^0.1.0\"` or `\"lodash\"`.\n * @returns The package name and semver range (range defaults to `\"*\"`).\n * @throws Error when the specifier is empty.\n */\nexport function parseSpec(spec: string): PluginSpec {\n const trimmed = spec.trim();\n if (!trimmed) throw new Error(\"parseSpec: empty specifier\");\n\n // Find the version-separating `@` — the first one that is not the scope `@`\n // at index 0. A bare `@scope/name` has its only `@` at index 0 (no range).\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) {\n return { name: trimmed, range: \"*\" };\n }\n const name = trimmed.slice(0, at);\n const range = trimmed.slice(at + 1);\n return { name, range: range.length > 0 ? range : \"*\" };\n}\n\n/** Convenience: just the package name of a specifier. */\nexport function specName(spec: string): string {\n return parseSpec(spec).name;\n}\n\n/** A package name as the registry and `package.json` keys hold it (legacy uppercase included). */\nconst PACKAGE_NAME = /^(?:@[A-Za-z0-9][A-Za-z0-9._~-]*\\/)?[A-Za-z0-9][A-Za-z0-9._~-]*$/;\n\n/**\n * The refusal for a specifier that does not start with a package name, or `undefined` when it\n * does: `name`, `@scope/name`, or `name@<any range>` (`name@^1`, `name@npm:other@1`,\n * `name@github:user/repo`, `name@git+https://...`, `name@https://...tgz`, `name@file:/abs/dir`).\n * A range may hold a space (`name@>=0.1.0 <1`); an empty range (`name@`) is refused.\n * A bare path, a `file:` URL, a `github:` / `git+` / `https:` source or `user/repo` has no name:\n * the package manager would send it to the registry or key `package.json` by the URL, and fail\n * late (p1737). Such a source is installed under its package name, `<name>@<spec>`.\n */\nexport function npmSpecError(spec: string): string | undefined {\n const trimmed = spec.trim();\n if (trimmed !== \"\" && !/@file:$/i.test(trimmed)) {\n // Only the name is checked for white space (PACKAGE_NAME has none): an npm range may hold a\n // space (`>=0.1.0 <1`) and the package manager takes it as one argument.\n const at = trimmed.indexOf(\"@\", 1);\n const nameEnd = at > 0 ? at : trimmed.length;\n if (PACKAGE_NAME.test(trimmed.slice(0, nameEnd))) {\n if (at > 0 && trimmed.slice(at + 1).trim() === \"\") {\n return (\n `plugin spec '${trimmed}' has an empty version range after '@'. ` +\n `Write ${trimmed.slice(0, at)} for any version, or ${trimmed.slice(0, at)}@<range>, for example @1.2.0.`\n );\n }\n return undefined;\n }\n }\n return (\n `plugin spec '${spec}' is not an npm package name. Give an npm name with an optional version ` +\n \"range, for example @scope/name@1.2.0, or write <name>@<spec> for a git, URL or local source, \" +\n \"for example name@github:user/repo or name@file:/path/to/dir.\"\n );\n}\n\n/** The folder a `file:` range names, or `undefined` for any other spec or an absolute / URL target. */\nfunction relativeFileTarget(spec: string): { head: string; target: string } | undefined {\n const trimmed = spec.trim();\n const at = trimmed.indexOf(\"@\", 1);\n if (at <= 0) return undefined;\n const range = trimmed.slice(at + 1);\n if (!/^file:/i.test(range)) return undefined;\n const target = range.slice(\"file:\".length);\n if (\n target === \"\" ||\n target.startsWith(\"//\") ||\n path.isAbsolute(target) ||\n /^[A-Za-z]:[\\\\/]/.test(target)\n ) {\n return undefined;\n }\n return { head: trimmed.slice(0, at), target };\n}\n\n/**\n * The form of a spec to write into `skaile.yaml`. A relative `file:` range is typed relative to\n * `cwd`; `skaile.yaml` is committed and read on other machines, so it holds the folder relative\n * to the project instead (`name@file:./plugins/x`, `name@file:../x`), never a machine path\n * (p1737). Any other spec is returned as written.\n */\nexport function projectRelativeFileSpec(spec: string, cwd: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n const rel = path.relative(path.resolve(projectDir), path.resolve(cwd, parts.target));\n if (path.isAbsolute(rel)) return `${parts.head}@file:${rel}`;\n const posix = rel.split(path.sep).join(\"/\") || \".\";\n return `${parts.head}@file:${posix.startsWith(\"..\") || posix === \".\" ? posix : `./${posix}`}`;\n}\n\n/**\n * The form of a spec to hand to the package manager. It runs in `.skaile/plugins/`, so a\n * project-relative `file:` range is resolved to an absolute path against `projectDir` here, and\n * only here (p1737). Any other spec is returned as written.\n */\nexport function resolveFileSpec(spec: string, projectDir: string): string {\n const parts = relativeFileTarget(spec);\n if (!parts) return spec;\n return `${parts.head}@file:${path.resolve(projectDir, parts.target)}`;\n}\n","/**\n * Runtime plugin loader: dynamic-import each reconciled plugin and let it\n * self-register into the `pluginRegistry`.\n *\n * Each plugin specifier resolves to an absolute path under the store's\n * `node_modules`; we import it via a `file://` URL so the import works inside\n * `bun --compile` binaries (which bundle only the literal-string switches, but\n * can still execute a `file://` import against the unpacked store on disk).\n * Failures are caught per-plugin so one broken plugin never aborts the rest.\n */\n\nimport { pathToFileURL } from \"node:url\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport { resolvePluginEntry } from \"./paths.js\";\nimport { parseSpec } from \"./spec.js\";\n\n/** Options for {@link loadPlugins}. */\nexport interface LoadOptions {\n log?: Logger;\n}\n\n/** Result of a load pass: which specs registered and which failed. */\nexport interface LoadResult {\n loaded: string[];\n failed: { spec: string; error: string; reason: string }[];\n}\n\n/** The self-registration entrypoint a plugin module is expected to export. */\ntype PluginModule = { register?: (registry: PluginRegistry) => void };\n\n/**\n * Load and register each plugin in `plugins` into `registry`.\n *\n * @param projectDir - Project root holding `.skaile/plugins/node_modules`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param registry - Registry to register into. Defaults to the process-wide `pluginRegistry`.\n * @param opts - Optional logger.\n * @returns Loaded specs + per-plugin failures (never throws).\n */\nexport async function loadPlugins(\n projectDir: string,\n plugins: string[],\n registry: PluginRegistry = pluginRegistry,\n opts: LoadOptions = {},\n): Promise<LoadResult> {\n const loaded: string[] = [];\n const failed: { spec: string; error: string; reason: string }[] = [];\n\n for (const spec of plugins) {\n try {\n const { name } = parseSpec(spec);\n const entry = resolvePluginEntry(projectDir, name);\n const mod = (await import(pathToFileURL(entry).href)) as PluginModule;\n if (typeof mod.register !== \"function\") {\n throw new Error(`plugin \"${name}\" does not export a register() function`);\n }\n mod.register(registry);\n loaded.push(spec);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n failed.push({ spec, error: `failed to load plugin \"${spec}\": ${message}`, reason: message });\n opts.log?.warn(`plugin load failed: ${spec}`, { error: message });\n }\n }\n\n return { loaded, failed };\n}\n","/**\n * Reconcile the project-local plugin store (`<projectDir>/.skaile/plugins/`).\n *\n * The reconciler is hash-skipped: it computes a SHA-256 over the sorted plugin\n * list plus the lock file's `plugins` slice and compares it to the stored\n * `.reconcile-hash`. On a match it returns with zero further I/O; otherwise it\n * regenerates the store's `package.json` and runs `bun install` against it.\n *\n * The install step is injectable (`InstallFn`) so tests stay hermetic — they\n * pass a fake installer that records calls and writes a stub `node_modules`.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPluginsLockSlice } from \"@skaile/workspaces/core\";\nimport { nodeModulesDir, pluginsDir, pluginsPkgJson, reconcileHashFile } from \"./paths.js\";\nimport { parseSpec, resolveFileSpec } from \"./spec.js\";\n\n/** How `InstallFn` may treat the store's lock: `frozen` forbids lock changes. */\nexport interface InstallOptions {\n /**\n * `false` when the spec list changed since the last `package.json`, so the\n * lock has to change too. Defaults to `true` (frozen when a lock exists).\n */\n frozen?: boolean;\n}\n\n/**\n * Installs the store's dependencies. Returns `ok: false` (never throws) on a\n * failed install so the reconciler can surface the captured `output`.\n */\nexport type InstallFn = (\n pluginsDir: string,\n opts?: InstallOptions,\n) => Promise<{ ok: boolean; output: string }>;\n\n/** Options for {@link reconcilePlugins}. */\nexport interface ReconcileOptions {\n /** Injectable installer. Defaults to a real `bun install` of the store. */\n runInstall?: InstallFn;\n /**\n * Lock slice to fold into the reconcile-hash. Defaults to\n * `readPluginsLockSlice(projectDir)` so a lock edit invalidates the hash.\n */\n lockSlice?: unknown;\n}\n\n/** Result of a reconcile pass. */\nexport interface ReconcileResult {\n changed: boolean;\n reason: \"no-plugins\" | \"up-to-date\" | \"reconciled\";\n}\n\n/** Run a command to completion, capturing stdout+stderr. `started: false` when it cannot spawn. */\nasync function runCapture(\n args: string[],\n cwd: string,\n): Promise<{ started: boolean; code: number; output: string }> {\n const { portableSpawn } = await import(\"@skaile/workspaces/core\");\n const proc = portableSpawn(args, { cwd });\n const chunks: string[] = [];\n const decoder = new TextDecoder();\n const pump = async (stream: ReadableStream<Uint8Array>) => {\n const reader = stream.getReader();\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n if (value) chunks.push(decoder.decode(value, { stream: true }));\n }\n };\n await Promise.all([pump(proc.stdout), pump(proc.stderr)]);\n const code = await proc.exited;\n // `portableSpawn` reports a spawn error (ENOENT) as exit -1 with no pid.\n return { started: proc.pid !== -1, code, output: chunks.join(\"\") };\n}\n\n/**\n * The default real installer: `bun install` inside the store directory, or\n * `npm install` when `bun` is not on PATH. Frozen only when a lock exists and\n * the spec list did not change (`opts.frozen !== false`): a changed list has to\n * rewrite the lock, which a frozen install refuses.\n */\nexport const defaultInstall: InstallFn = async (dir, opts = {}) => {\n const hasBunLock = existsSync(`${dir}/bun.lock`) || existsSync(`${dir}/bun.lockb`);\n const hasNpmLock = existsSync(`${dir}/package-lock.json`);\n const frozen = opts.frozen !== false;\n\n const bunArgs =\n frozen && (hasBunLock || hasNpmLock)\n ? [\"bun\", \"install\", \"--frozen-lockfile\"]\n : [\"bun\", \"install\"];\n const withBun = await runCapture(bunArgs, dir);\n if (withBun.started) return { ok: withBun.code === 0, output: withBun.output };\n\n const npmArgs =\n frozen && hasNpmLock\n ? [\"npm\", \"ci\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"]\n : [\"npm\", \"install\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\"];\n const withNpm = await runCapture(npmArgs, dir);\n if (withNpm.started) return { ok: withNpm.code === 0, output: withNpm.output };\n return {\n ok: false,\n output:\n \"neither bun nor npm found on PATH; plugin install needs one of them (https://bun.sh or https://nodejs.org)\",\n };\n};\n\n/**\n * Generate the store's `package.json` from the plugin specs. Returns the\n * previous file content (`undefined` when there was none) and whether the\n * dependency set changed.\n */\nfunction writePackageJson(\n projectDir: string,\n plugins: string[],\n): { previous: string | undefined; depsChanged: boolean; removedDep: boolean } {\n const dependencies: Record<string, string> = {};\n for (const spec of plugins) {\n const { name, range } = parseSpec(resolveFileSpec(spec, projectDir));\n dependencies[name] = range;\n }\n const pkg = {\n name: \"skaile-project-plugins\",\n private: true,\n dependencies,\n };\n const file = pluginsPkgJson(projectDir);\n const previous = existsSync(file) ? readFileSync(file, \"utf8\") : undefined;\n let before: Record<string, string> | undefined;\n try {\n before = previous === undefined ? undefined : JSON.parse(previous).dependencies;\n } catch {\n before = undefined;\n }\n const sortedJson = (d: Record<string, string> | undefined) =>\n JSON.stringify(Object.entries(d ?? {}).sort(([a], [b]) => a.localeCompare(b)));\n const depsChanged = before === undefined || sortedJson(before) !== sortedJson(dependencies);\n // A plugin the list no longer names: the package manager prunes a registry package, but not a\n // `file:` one and not what a failed install left, so the caller rebuilds `node_modules`.\n const removedDep = Object.keys(before ?? {}).some((name) => !(name in dependencies));\n mkdirSync(pluginsDir(projectDir), { recursive: true });\n writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\\n`);\n return { previous, depsChanged, removedDep };\n}\n\n/**\n * Reconcile the plugin store for a project.\n *\n * @param projectDir - Project root containing `skaile.yaml` / `skaile.lock.yaml`.\n * @param plugins - The `skaile.yaml` `plugins:` list (npm specifiers).\n * @param opts - Optional injectable installer + lock slice override.\n * @returns Whether the store changed and why.\n */\nexport async function reconcilePlugins(\n projectDir: string,\n plugins: string[],\n opts: ReconcileOptions = {},\n): Promise<ReconcileResult> {\n if (plugins.length === 0) {\n return { changed: false, reason: \"no-plugins\" };\n }\n\n const lockSlice = opts.lockSlice ?? readPluginsLockSlice(projectDir);\n const wantHash = createHash(\"sha256\")\n .update(\n JSON.stringify({\n plugins: plugins.map((spec) => resolveFileSpec(spec, projectDir)).sort(),\n lock: lockSlice,\n }),\n )\n .digest(\"hex\");\n\n const hashFile = reconcileHashFile(projectDir);\n if (existsSync(hashFile)) {\n const have = readFileSync(hashFile, \"utf8\").trim();\n if (have === wantHash) {\n return { changed: false, reason: \"up-to-date\" };\n }\n }\n\n const { previous, depsChanged, removedDep } = writePackageJson(projectDir, plugins);\n if (removedDep) rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n\n const install = opts.runInstall ?? defaultInstall;\n const result = await install(pluginsDir(projectDir), { frozen: !depsChanged });\n if (!result.ok) {\n // A failed install must not leave the spec behind: the next reconcile\n // would compare against it and treat the store as already changed.\n if (previous === undefined) rmSync(pluginsPkgJson(projectDir), { force: true });\n else writeFileSync(pluginsPkgJson(projectDir), previous);\n throw new Error(`plugin install failed:\\n${result.output}`);\n }\n\n writeFileSync(hashFile, wantHash);\n return { changed: true, reason: \"reconciled\" };\n}\n\n/**\n * Put the store back to `previousPlugins` after `plugin install` failed past\n * the reconcile (the plugin installed but does not load). Best effort: a\n * failing reinstall is swallowed, the store is then rebuilt by the next\n * reconcile because the hash no longer matches the declared list.\n *\n * With no previous plugins every generated file of the store goes away\n * (`package.json`, hash, lock file and `node_modules`), so the store keeps\n * neither the rejected spec nor its installed package.\n */\nexport async function rollbackPluginStore(\n projectDir: string,\n previousPlugins: string[],\n opts: ReconcileOptions = {},\n): Promise<void> {\n if (previousPlugins.length === 0) {\n const dir = pluginsDir(projectDir);\n rmSync(pluginsPkgJson(projectDir), { force: true });\n rmSync(reconcileHashFile(projectDir), { force: true });\n rmSync(nodeModulesDir(projectDir), { recursive: true, force: true });\n for (const lock of [\"bun.lock\", \"bun.lockb\", \"package-lock.json\"]) {\n rmSync(join(dir, lock), { force: true });\n }\n try {\n // The folder goes when nothing else of the user's is in it.\n rmdirSync(dir);\n } catch {\n // not empty, or already gone\n }\n return;\n }\n try {\n await reconcilePlugins(projectDir, previousPlugins, opts);\n } catch {\n // the next reconcile retries\n }\n}\n","/**\n * The project-local plugin store: reconcile (`<projectDir>/.skaile/plugins/`)\n * then load the reconciled plugins into the `pluginRegistry`.\n *\n * `ensurePluginsLoaded` is the single entrypoint commands wire in. It is a\n * guarded no-op when `plugins` is empty/undefined — zero overhead for the\n * common case where no project declares `plugins:` in `skaile.yaml`.\n */\n\nimport { resolve as resolvePath } from \"node:path\";\nimport { type PluginRegistry, pluginRegistry } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport pc from \"picocolors\";\nimport { type LoadResult, loadPlugins } from \"./load.js\";\nimport { type ReconcileOptions, reconcilePlugins } from \"./reconcile.js\";\nimport { specName } from \"./spec.js\";\n\nexport type { LoadResult } from \"./load.js\";\nexport { loadPlugins } from \"./load.js\";\nexport type { ReconcileOptions } from \"./reconcile.js\";\nexport { reconcilePlugins, rollbackPluginStore } from \"./reconcile.js\";\nexport { npmSpecError, projectRelativeFileSpec, resolveFileSpec, specName } from \"./spec.js\";\n\n/** Options for {@link ensurePluginsLoaded}. */\nexport interface EnsurePluginsOptions extends ReconcileOptions {\n log?: Logger;\n}\n\n/**\n * Reconcile the plugin store then load each plugin into `registry`.\n *\n * No-op (returns immediately) when `plugins` is empty/undefined, so the common\n * no-plugins path costs nothing.\n *\n * @param projectDir - Project root.\n * @param plugins - The `skaile.yaml` `plugins:` list (may be undefined).\n * @param registry - Registry to register into. Defaults to `pluginRegistry`.\n * @param opts - Injectable installer / lock slice + optional logger.\n * @returns The load result, or an empty result when there are no plugins.\n */\nexport async function ensurePluginsLoaded(\n projectDir: string,\n plugins: string[] | undefined,\n registry: PluginRegistry = pluginRegistry,\n opts: EnsurePluginsOptions = {},\n): Promise<LoadResult> {\n if (!plugins || plugins.length === 0) {\n return { loaded: [], failed: [] };\n }\n await reconcilePlugins(projectDir, plugins, opts);\n return loadPlugins(projectDir, plugins, registry, { log: opts.log });\n}\n\n/**\n * The installer's output of a failed `plugin install` is a dump (bun's banner, resolver\n * progress, then the `error:` lines). A load warning keeps the first line and the cause of it\n * (p1113); `skaile plugin install <spec>` prints the whole output.\n *\n * bun: the last `error:` line. npm: its `code` line and the first detail line after it\n * (`E404: 404 Not Found - GET …`), never the trailing `A complete log of this run can be found\n * in: …` pointer (p1272).\n */\nexport function condensePluginFailure(reason: string): string {\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\");\n const [first, ...rest] = lines;\n if (!reason.startsWith(\"plugin install failed\") || first === undefined || rest.length === 0) {\n return reason;\n }\n const head = first.replace(/:$/, \"\");\n const npmPrefix = /^npm (ERR!|error)\\s*/i;\n const npmLines = rest\n .filter((l) => npmPrefix.test(l) && !/^npm \\S+\\s+A complete log of this run\\b/i.test(l))\n .map((l) => l.replace(npmPrefix, \"\"))\n .filter((l) => l !== \"\");\n const codeLine = npmLines.find((l) => /^code\\s+\\S+/i.test(l));\n if (codeLine) {\n const code = codeLine.replace(/^code\\s+/i, \"\");\n const detail = npmLines.find((l) => l !== codeLine && !/^code\\s/i.test(l));\n return `${head}: npm ${code}${detail ? `: ${detail}` : \"\"}`;\n }\n const causes = rest.filter(\n (l) => /^error\\b/i.test(l) || (npmPrefix.test(l) && !/A complete log of this run\\b/i.test(l)),\n );\n const cause =\n causes.at(-1) ?? rest.filter((l) => !/A complete log of this run\\b/i.test(l)).at(-1);\n return `${head}: ${cause ?? rest.at(-1)}`;\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\/]/g, \"\\\\$&\");\n}\n\n/**\n * Split the output of one failed install of the whole plugin store into one reason per plugin\n * (p1272): the package manager runs once for every spec, so its output names the plugins that\n * failed. A plugin gets the line that names it (also its URL-encoded form `@scope%2fname`); a\n * plugin the output never names says it was not installed and which plugin the install stopped\n * at. With one plugin, or when the output names none (no `bun` and no `npm`), every plugin keeps\n * the whole condensed reason.\n */\nexport function pluginFailureReasons(\n reason: string,\n specs: readonly string[],\n): Map<string, string> {\n const out = new Map<string, string>();\n const condensed = condensePluginFailure(reason);\n if (specs.length < 2 || !reason.startsWith(\"plugin install failed\")) return out;\n const lines = reason\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l !== \"\" && !/A complete log of this run\\b/i.test(l));\n const names = specs.map((spec) => {\n try {\n return specName(spec);\n } catch {\n return spec;\n }\n });\n const mentions = (text: string, name: string): boolean => {\n const forms = [name, name.replace(\"/\", \"%2f\"), name.replace(\"/\", \"%2F\")];\n return forms.some((f) =>\n new RegExp(`(?<![\\\\w@.-])(?<!@[\\\\w.~-]+/)${escapeRegExp(f)}(?![\\\\w-]|\\\\.\\\\w)`).test(text),\n );\n };\n const cause = /\\berror\\b|\\bE[A-Z0-9]{3,}\\b|\\b404\\b|notarget|failed to resolve/i;\n const named: string[] = [];\n specs.forEach((spec, i) => {\n const name = names[i] as string;\n const line = mentions(condensed, name)\n ? condensed.replace(/^plugin install failed:\\s*/, \"\")\n : lines.filter((l) => mentions(l, name) && cause.test(l)).at(-1);\n if (line === undefined) return;\n named.push(name);\n out.set(spec, `plugin install failed: ${line.replace(/^(npm\\s+)?(ERR!|error:?)\\s*/i, \"\")}`);\n });\n if (named.length === 0) return new Map();\n specs.forEach((spec, i) => {\n if (!out.has(spec)) {\n out.set(\n spec,\n `plugin install failed: ${names[i]} was not installed, the install stopped at ${named.join(\", \")}`,\n );\n }\n });\n return out;\n}\n\n/** One `! plugin <name> failed to load: <reason>` line on stderr (stdout carries a run's answer). */\nfunction warnPluginFailed(spec: string, reason: string): void {\n let name = spec;\n try {\n name = specName(spec);\n } catch {\n /* a spec that does not parse is named as written */\n }\n process.stderr.write(\n ` ${pc.yellow(\"!\")} plugin ${name} failed to load: ${condensePluginFailure(reason)}\\n`,\n );\n}\n\n/**\n * Reconcile + load the `plugins:` of the project's `skaile.yaml` into the process registry, so a\n * plugin's harness is known to `run`, `repl` and `config set harness`. A plugin that fails to\n * reconcile or load is skipped (its harness stays unknown, the command goes on) and named in one\n * `! plugin <name> failed to load: <reason>` line on stderr. An unreadable config is not this\n * function's to report: the command reads it again and says so.\n */\nexport function loadDeclaredPlugins(projectDir: string): Promise<void> {\n // A plugin registers once per process: a second `register()` is a duplicate.\n const key = resolvePath(projectDir);\n let pending = declaredPluginLoads.get(key);\n if (!pending) {\n pending = loadDeclaredPluginsOnce(projectDir);\n declaredPluginLoads.set(key, pending);\n }\n return pending;\n}\n\nconst declaredPluginLoads = new Map<string, Promise<void>>();\n\nasync function loadDeclaredPluginsOnce(projectDir: string): Promise<void> {\n let plugins: string[] | undefined;\n try {\n const { resolveSkWorkspaceConfig } = await import(\"@skaile/workspaces/core\");\n plugins = resolveSkWorkspaceConfig(projectDir).plugins;\n } catch {\n return;\n }\n if (!plugins || plugins.length === 0) return;\n try {\n const result = await ensurePluginsLoaded(projectDir, plugins, pluginRegistry);\n for (const f of result.failed) warnPluginFailed(f.spec, f.reason);\n } catch (err) {\n // The store could not be reconciled: no plugin was loaded.\n const reason = err instanceof Error ? err.message : String(err);\n const reasons = pluginFailureReasons(reason, plugins);\n for (const spec of plugins) warnPluginFailed(spec, reasons.get(spec) ?? reason);\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveAgentExec } from './chunk-7DN6JKP2.js';
|
|
2
|
-
import { BUILTIN_HARNESS_CATALOG } from './chunk-
|
|
3
|
-
import { tryWithFsDeadline, fsDeadlineMs, withFsDeadline } from './chunk-
|
|
2
|
+
import { BUILTIN_HARNESS_CATALOG } from './chunk-BSMW3PX2.js';
|
|
3
|
+
import { tryWithFsDeadline, fsDeadlineMs, withFsDeadline } from './chunk-GNUA7XT2.js';
|
|
4
4
|
import { entryTransport, normalizeAnthropicBaseUrl, resolveEntryBaseUrl, registryEntries, parseModelRef } from './chunk-RXGPFAMN.js';
|
|
5
5
|
import { createWriteStream, createReadStream } from 'fs';
|
|
6
6
|
import { unlink, rename, readdir, stat } from 'fs/promises';
|
|
@@ -569,5 +569,5 @@ function sessionSurfaceNotice(registry, modelRef) {
|
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
export { ANTHROPIC_DEFAULT_BASE_URL, APPROVE_ONCE, DENY, agentTranscriptStore, approvalCardOf, buildClaudeEndpointEnv, claudeEndpointMode, localTranscriptStore, probeResumeTranscript, resolveClaudeConfigDir, scrubPoisonedTranscript, sessionSurfaceNotice, transcriptStoreForRuntime, unsupportedSurfaceNotice };
|
|
572
|
-
//# sourceMappingURL=chunk-
|
|
573
|
-
//# sourceMappingURL=chunk-
|
|
572
|
+
//# sourceMappingURL=chunk-U3UDOX6I.js.map
|
|
573
|
+
//# sourceMappingURL=chunk-U3UDOX6I.js.map
|