@skaile/workspaces 6.6.0 → 6.7.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 +28 -0
- package/dist/ai-sdk.js +10 -17
- package/dist/ai-sdk.js.map +1 -1
- package/dist/app-sdk/index.js +1 -1
- package/dist/{asset-feeds-WQ6YQPHV.js → asset-feeds-4A7PJ4OB.js} +18 -18
- package/dist/{asset-feeds-WQ6YQPHV.js.map → asset-feeds-4A7PJ4OB.js.map} +1 -1
- package/dist/asset-manager/catalog-deployer.js +4 -4
- package/dist/asset-manager/index.js +10 -10
- package/dist/asset-manager/installer.js +6 -6
- package/dist/asset-manager/renderers.js +5 -5
- package/dist/asset-manager/src/index.d.ts +89 -15
- package/dist/asset-manager/src/index.d.ts.map +1 -1
- package/dist/asset-manager/src/install-agent.d.ts +22 -1
- package/dist/asset-manager/src/install-agent.d.ts.map +1 -1
- package/dist/asset-manager/src/install-instances.d.ts +30 -1
- package/dist/asset-manager/src/install-instances.d.ts.map +1 -1
- package/dist/asset-manager/src/installer.d.ts +12 -0
- package/dist/asset-manager/src/installer.d.ts.map +1 -1
- package/dist/asset-manager/src/renderers.d.ts.map +1 -1
- package/dist/bridge/harnesses/claude-sdk.js +21 -15
- package/dist/bridge/harnesses/claude-sdk.js.map +1 -1
- package/dist/bridge/harnesses/codex.js +9 -8
- package/dist/bridge/harnesses/codex.js.map +1 -1
- package/dist/bridge/harnesses/continue.js +11 -9
- package/dist/bridge/harnesses/continue.js.map +1 -1
- package/dist/bridge/harnesses/echo.js +5 -4
- package/dist/bridge/harnesses/echo.js.map +1 -1
- package/dist/bridge/harnesses/gemini.js +8 -6
- package/dist/bridge/harnesses/goose.js +11 -9
- package/dist/bridge/harnesses/goose.js.map +1 -1
- package/dist/bridge/harnesses/omp.js +9 -7
- package/dist/bridge/harnesses/omp.js.map +1 -1
- package/dist/bridge/harnesses/opencode.js +11 -9
- package/dist/bridge/harnesses/opencode.js.map +1 -1
- package/dist/bridge/harnesses/qwen.js +9 -7
- package/dist/bridge/harnesses/qwen.js.map +1 -1
- package/dist/bridge/index.js +17 -15
- package/dist/bridge/src/ai-sdk.d.ts.map +1 -1
- package/dist/bridge/src/claude-sdk-surface.d.ts +2 -1
- package/dist/bridge/src/claude-sdk-surface.d.ts.map +1 -1
- package/dist/bridge/src/harness-binaries.d.ts +21 -0
- package/dist/bridge/src/harness-binaries.d.ts.map +1 -0
- package/dist/bridge/src/harness-model-check.d.ts +22 -6
- package/dist/bridge/src/harness-model-check.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/claude-sdk.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/continue.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/gemini.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/goose.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/omp-models-yml.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/omp.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/opencode.d.ts.map +1 -1
- package/dist/bridge/src/harnesses/qwen.d.ts.map +1 -1
- package/dist/bridge/src/index.d.ts +2 -1
- package/dist/bridge/src/index.d.ts.map +1 -1
- package/dist/{chunk-LBJ4M5J2.js → chunk-237BMOZW.js} +4 -4
- package/dist/{chunk-LBJ4M5J2.js.map → chunk-237BMOZW.js.map} +1 -1
- package/dist/{chunk-2TLPC6TQ.js → chunk-37AYPPOO.js} +41 -19
- package/dist/chunk-37AYPPOO.js.map +1 -0
- package/dist/{chunk-GTGWRKMJ.js → chunk-37X4A6VZ.js} +6 -6
- package/dist/{chunk-GTGWRKMJ.js.map → chunk-37X4A6VZ.js.map} +1 -1
- package/dist/{chunk-MXI3XWV6.js → chunk-3HSLJAMJ.js} +4 -4
- package/dist/{chunk-MXI3XWV6.js.map → chunk-3HSLJAMJ.js.map} +1 -1
- package/dist/{chunk-RHCEX2EV.js → chunk-3W6XZQ2Y.js} +3 -3
- package/dist/{chunk-RHCEX2EV.js.map → chunk-3W6XZQ2Y.js.map} +1 -1
- package/dist/{chunk-F4CZQD3T.js → chunk-4C2E5QUP.js} +4 -3
- package/dist/chunk-4C2E5QUP.js.map +1 -0
- package/dist/{chunk-DS6UUCFG.js → chunk-4CD2R4MJ.js} +5 -4
- package/dist/chunk-4CD2R4MJ.js.map +1 -0
- package/dist/{chunk-AQNW2FET.js → chunk-6RPS7JEH.js} +92 -39
- package/dist/chunk-6RPS7JEH.js.map +1 -0
- package/dist/{chunk-BSMW3PX2.js → chunk-6UP2EDFN.js} +4 -313
- package/dist/chunk-6UP2EDFN.js.map +1 -0
- package/dist/{chunk-4J7JQX4G.js → chunk-72TLO2AG.js} +4 -4
- package/dist/{chunk-4J7JQX4G.js.map → chunk-72TLO2AG.js.map} +1 -1
- package/dist/{chunk-I5IF3JCG.js → chunk-AO57IFME.js} +3 -3
- package/dist/{chunk-I5IF3JCG.js.map → chunk-AO57IFME.js.map} +1 -1
- package/dist/{chunk-G5SYFFMD.js → chunk-ASBZOTEO.js} +2 -2
- package/dist/{chunk-G5SYFFMD.js.map → chunk-ASBZOTEO.js.map} +1 -1
- package/dist/{chunk-O7QZI6MQ.js → chunk-BB5EJLKZ.js} +2 -2
- package/dist/{chunk-O7QZI6MQ.js.map → chunk-BB5EJLKZ.js.map} +1 -1
- package/dist/{chunk-N2PBAXAA.js → chunk-BKLDBUQA.js} +3 -3
- package/dist/{chunk-N2PBAXAA.js.map → chunk-BKLDBUQA.js.map} +1 -1
- package/dist/{chunk-XD3RYAMR.js → chunk-CTRTFMCX.js} +6 -6
- package/dist/{chunk-XD3RYAMR.js.map → chunk-CTRTFMCX.js.map} +1 -1
- package/dist/{chunk-EPXZQIC6.js → chunk-DFP476EU.js} +8 -4
- package/dist/chunk-DFP476EU.js.map +1 -0
- package/dist/{chunk-MMOWIRHP.js → chunk-G44FFUMA.js} +12 -10
- package/dist/chunk-G44FFUMA.js.map +1 -0
- package/dist/{chunk-JIQUF3X2.js → chunk-G7NMF5WQ.js} +3 -3
- package/dist/{chunk-JIQUF3X2.js.map → chunk-G7NMF5WQ.js.map} +1 -1
- package/dist/{chunk-SHTXMERQ.js → chunk-GAIMSCZ7.js} +10 -8
- package/dist/chunk-GAIMSCZ7.js.map +1 -0
- package/dist/{chunk-6A6HE5LW.js → chunk-HLAEYFUN.js} +3 -3
- package/dist/{chunk-6A6HE5LW.js.map → chunk-HLAEYFUN.js.map} +1 -1
- package/dist/{chunk-YN6N3RBM.js → chunk-HMVAGPYR.js} +47 -11
- package/dist/chunk-HMVAGPYR.js.map +1 -0
- package/dist/{chunk-U3UDOX6I.js → chunk-HPXONAI2.js} +6 -4
- package/dist/chunk-HPXONAI2.js.map +1 -0
- package/dist/{chunk-5ETYBC2X.js → chunk-IRK3LNG3.js} +6 -6
- package/dist/{chunk-5ETYBC2X.js.map → chunk-IRK3LNG3.js.map} +1 -1
- package/dist/{chunk-J262X4JU.js → chunk-J7VEQORJ.js} +69 -16
- package/dist/chunk-J7VEQORJ.js.map +1 -0
- package/dist/{chunk-DI6J2PJB.js → chunk-KO3VSZQP.js} +47 -18
- package/dist/chunk-KO3VSZQP.js.map +1 -0
- package/dist/{chunk-KSH5CFQS.js → chunk-KORDNXKA.js} +3 -3
- package/dist/{chunk-KSH5CFQS.js.map → chunk-KORDNXKA.js.map} +1 -1
- package/dist/{chunk-SCRYXAHH.js → chunk-L3JQJ6D5.js} +6 -6
- package/dist/{chunk-SCRYXAHH.js.map → chunk-L3JQJ6D5.js.map} +1 -1
- package/dist/{chunk-7I5PNB2G.js → chunk-L7QOZG5V.js} +3 -3
- package/dist/{chunk-7I5PNB2G.js.map → chunk-L7QOZG5V.js.map} +1 -1
- package/dist/{chunk-VXYZ5M7Z.js → chunk-LX4TTTRR.js} +64 -27
- package/dist/chunk-LX4TTTRR.js.map +1 -0
- package/dist/{chunk-KSUT5KAE.js → chunk-LZPJOF7Y.js} +3 -3
- package/dist/{chunk-KSUT5KAE.js.map → chunk-LZPJOF7Y.js.map} +1 -1
- package/dist/{chunk-65UAC3ZR.js → chunk-N6ZGB5ES.js} +4 -3
- package/dist/chunk-N6ZGB5ES.js.map +1 -0
- package/dist/{chunk-2M3VLKT2.js → chunk-NURTGAWM.js} +3 -3
- package/dist/{chunk-2M3VLKT2.js.map → chunk-NURTGAWM.js.map} +1 -1
- package/dist/{chunk-J4WKNJHO.js → chunk-O5Y7VMVQ.js} +15 -14
- package/dist/chunk-O5Y7VMVQ.js.map +1 -0
- package/dist/{chunk-6SXSVKQY.js → chunk-O7ADRMCR.js} +63 -14
- package/dist/chunk-O7ADRMCR.js.map +1 -0
- package/dist/{chunk-7PVGND4J.js → chunk-OGTQUEAO.js} +21 -14
- package/dist/chunk-OGTQUEAO.js.map +1 -0
- package/dist/{chunk-VJRL6ZK6.js → chunk-OSABUEWA.js} +3 -3
- package/dist/{chunk-VJRL6ZK6.js.map → chunk-OSABUEWA.js.map} +1 -1
- package/dist/{chunk-WW5NAU6N.js → chunk-PLLZSKOO.js} +3 -3
- package/dist/{chunk-WW5NAU6N.js.map → chunk-PLLZSKOO.js.map} +1 -1
- package/dist/{chunk-7SJHSGUV.js → chunk-Q2NYTMT6.js} +16 -15
- package/dist/chunk-Q2NYTMT6.js.map +1 -0
- package/dist/{chunk-E2EC6SAX.js → chunk-QC5BYUED.js} +51 -15
- package/dist/chunk-QC5BYUED.js.map +1 -0
- package/dist/{chunk-RAU5QPI6.js → chunk-QCR5AE5E.js} +5 -5
- package/dist/{chunk-RAU5QPI6.js.map → chunk-QCR5AE5E.js.map} +1 -1
- package/dist/{chunk-TUFNY6OD.js → chunk-QW5B3TEO.js} +10 -4
- package/dist/chunk-QW5B3TEO.js.map +1 -0
- package/dist/{chunk-Z4FERR4U.js → chunk-RAHAZ7LP.js} +2 -2
- package/dist/{chunk-Z4FERR4U.js.map → chunk-RAHAZ7LP.js.map} +1 -1
- package/dist/{chunk-OY22B7E2.js → chunk-SBNUXJ6E.js} +3 -3
- package/dist/{chunk-OY22B7E2.js.map → chunk-SBNUXJ6E.js.map} +1 -1
- package/dist/{chunk-6ARPZHOV.js → chunk-TMJBEGS4.js} +35 -6
- package/dist/chunk-TMJBEGS4.js.map +1 -0
- package/dist/{chunk-6RHWTZPT.js → chunk-TXX3OUYI.js} +3 -3
- package/dist/{chunk-6RHWTZPT.js.map → chunk-TXX3OUYI.js.map} +1 -1
- package/dist/{chunk-SZKCE7EC.js → chunk-U52FYGK5.js} +5 -5
- package/dist/{chunk-SZKCE7EC.js.map → chunk-U52FYGK5.js.map} +1 -1
- package/dist/{chunk-TCH5UDKT.js → chunk-UCB7FK25.js} +10 -8
- package/dist/chunk-UCB7FK25.js.map +1 -0
- package/dist/{chunk-5XHQBCB5.js → chunk-WFK4MUBL.js} +21 -7
- package/dist/chunk-WFK4MUBL.js.map +1 -0
- package/dist/{chunk-HGZN6JLP.js → chunk-WIYVR24B.js} +4 -4
- package/dist/{chunk-HGZN6JLP.js.map → chunk-WIYVR24B.js.map} +1 -1
- package/dist/{chunk-B6N653ZG.js → chunk-WKENHNDM.js} +6 -6
- package/dist/{chunk-B6N653ZG.js.map → chunk-WKENHNDM.js.map} +1 -1
- package/dist/chunk-WWSRIT3J.js +59 -0
- package/dist/chunk-WWSRIT3J.js.map +1 -0
- package/dist/chunk-XON6ODIC.js +315 -0
- package/dist/chunk-XON6ODIC.js.map +1 -0
- package/dist/{chunk-4BFEPZ6J.js → chunk-ZBA4P5TD.js} +3 -3
- package/dist/{chunk-4BFEPZ6J.js.map → chunk-ZBA4P5TD.js.map} +1 -1
- package/dist/{chunk-JRVQV7WC.js → chunk-ZDTDS62B.js} +595 -126
- package/dist/chunk-ZDTDS62B.js.map +1 -0
- package/dist/{chunk-XYCYGN3Q.js → chunk-ZM4SDVUV.js} +79 -20
- package/dist/chunk-ZM4SDVUV.js.map +1 -0
- package/dist/{claude-code-LZH7Y4Y5.js → claude-code-BLFRZU2X.js} +4 -4
- package/dist/{claude-code-LZH7Y4Y5.js.map → claude-code-BLFRZU2X.js.map} +1 -1
- package/dist/cli/index.js +474 -198
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/agent-pins.d.ts +9 -3
- package/dist/cli/src/agent-pins.d.ts.map +1 -1
- package/dist/cli/src/commands/asset-cmd.d.ts +1 -1
- package/dist/cli/src/commands/asset-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/cache.d.ts.map +1 -1
- package/dist/cli/src/commands/catalog.d.ts +2 -0
- package/dist/cli/src/commands/catalog.d.ts.map +1 -1
- package/dist/cli/src/commands/config.d.ts.map +1 -1
- package/dist/cli/src/commands/harness-preflight.d.ts +38 -0
- package/dist/cli/src/commands/harness-preflight.d.ts.map +1 -0
- package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/library-index.d.ts +16 -0
- package/dist/cli/src/commands/library-index.d.ts.map +1 -1
- package/dist/cli/src/commands/migrate-assets.d.ts +5 -0
- package/dist/cli/src/commands/migrate-assets.d.ts.map +1 -1
- package/dist/cli/src/commands/migrate-harness.d.ts +15 -7
- package/dist/cli/src/commands/migrate-harness.d.ts.map +1 -1
- package/dist/cli/src/commands/migrate.d.ts.map +1 -1
- package/dist/cli/src/commands/outdated.d.ts.map +1 -1
- package/dist/cli/src/commands/plugin-registry-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/project.d.ts +14 -0
- package/dist/cli/src/commands/project.d.ts.map +1 -1
- package/dist/cli/src/commands/run.d.ts.map +1 -1
- package/dist/cli/src/commands/serve-preflight.d.ts +6 -5
- package/dist/cli/src/commands/serve-preflight.d.ts.map +1 -1
- package/dist/cli/src/commands/serve.d.ts.map +1 -1
- package/dist/cli/src/commands/session.d.ts.map +1 -1
- package/dist/cli/src/commands/source.d.ts +11 -0
- package/dist/cli/src/commands/source.d.ts.map +1 -1
- package/dist/cli/src/commands/update.d.ts.map +1 -1
- package/dist/cli/src/commands/validate-instances.d.ts +6 -0
- package/dist/cli/src/commands/validate-instances.d.ts.map +1 -1
- package/dist/cli/src/commands/validate.d.ts.map +1 -1
- package/dist/cli/src/commands/why.d.ts.map +1 -1
- package/dist/cli/src/plugin-store/reconcile.d.ts.map +1 -1
- package/dist/cli/src/session-hint.d.ts +7 -0
- package/dist/cli/src/session-hint.d.ts.map +1 -0
- package/dist/connectors/config.js +3 -3
- package/dist/connectors/index.js +21 -19
- package/dist/connectors/src/managed-gitconfig.d.ts +6 -4
- package/dist/connectors/src/managed-gitconfig.d.ts.map +1 -1
- package/dist/{connectors-HU5MHSUJ.js → connectors-OJJU4LSN.js} +24 -22
- package/dist/{connectors-HU5MHSUJ.js.map → connectors-OJJU4LSN.js.map} +1 -1
- package/dist/connectors-shared/index.js +2 -2
- package/dist/core/index.js +4 -4
- package/dist/core/publish-manifest.js +1 -1
- package/dist/core/runtime-assets.js +3 -3
- package/dist/core/src/agent-instances.d.ts +11 -0
- package/dist/core/src/agent-instances.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +3 -2
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/publish-manifest.d.ts +20 -6
- package/dist/core/src/publish-manifest.d.ts.map +1 -1
- package/dist/core/src/repo-manager.d.ts +9 -0
- package/dist/core/src/repo-manager.d.ts.map +1 -1
- package/dist/core/src/run-state-ignore.d.ts +17 -0
- package/dist/core/src/run-state-ignore.d.ts.map +1 -0
- package/dist/core/src/workspace-config.d.ts.map +1 -1
- package/dist/core/workspace-config.js +2 -2
- package/dist/deploy/index.js +4 -4
- package/dist/discovery/index.js +2 -2
- package/dist/discovery/src/builtin-providers.d.ts.map +1 -1
- package/dist/discovery/src/discover-manifest.d.ts.map +1 -1
- package/dist/discovery/src/tree-entries.d.ts.map +1 -1
- package/dist/{ensure-sources-CAMWJTMR.js → ensure-sources-F6VQDCWY.js} +26 -24
- package/dist/ensure-sources-F6VQDCWY.js.map +1 -0
- package/dist/factory-assets/connectors/box.js +21 -19
- package/dist/factory-assets/connectors/deploy.js +21 -19
- package/dist/factory-assets/connectors/devserver.js +21 -19
- package/dist/factory-assets/connectors/flow/adapter.js +21 -19
- package/dist/factory-assets/connectors/flow/engine/router-settlement.d.ts +2 -0
- package/dist/factory-assets/connectors/flow/engine/router-settlement.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine.js +5 -5
- package/dist/factory-assets/connectors/flow/run-flow.js +22 -20
- package/dist/factory-assets/connectors/flow.js +21 -19
- package/dist/factory-assets/connectors/git/CONNECTOR.md +4 -1
- package/dist/factory-assets/connectors/git/exec.d.ts.map +1 -1
- package/dist/factory-assets/connectors/git.js +21 -19
- package/dist/factory-assets/connectors/gmail.js +21 -19
- package/dist/factory-assets/connectors/googledrive.js +21 -19
- package/dist/factory-assets/connectors/local.js +21 -19
- package/dist/factory-assets/connectors/mattermost.js +21 -19
- package/dist/factory-assets/connectors/memory.js +21 -19
- package/dist/factory-assets/connectors/minio.js +21 -19
- package/dist/factory-assets/connectors/postgres.js +21 -19
- package/dist/factory-assets/connectors/s3.js +21 -19
- package/dist/factory-assets/connectors/sharepoint.js +21 -19
- package/dist/factory-assets/connectors/sqlite.js +21 -19
- package/dist/factory-assets/connectors/static-server.js +21 -19
- package/dist/factory-assets/connectors/tunnel.js +21 -19
- package/dist/factory-assets/connectors/webdav.js +21 -19
- package/dist/factory-assets/connectors/xstate-store.js +21 -19
- package/dist/factory-assets/connectors/xstate.js +21 -19
- package/dist/factory-assets/skills/authoring-skaile-assets/SKILL.md +14 -1
- package/dist/{flows-GVOVQGQW.js → flows-I6ODIPZZ.js} +7 -7
- package/dist/{flows-GVOVQGQW.js.map → flows-I6ODIPZZ.js.map} +1 -1
- package/dist/{helpers-WMCCODAV.js → helpers-PJNUTZXZ.js} +26 -24
- package/dist/{helpers-WMCCODAV.js.map → helpers-PJNUTZXZ.js.map} +1 -1
- package/dist/library/index.js +7 -7
- package/dist/library/install.js +2 -2
- package/dist/library/src/manifest-writer.d.ts +5 -0
- package/dist/library/src/manifest-writer.d.ts.map +1 -1
- package/dist/{library-publish-UQQMHTND.js → library-publish-FNNDWVBO.js} +47 -45
- package/dist/library-publish-FNNDWVBO.js.map +1 -0
- package/dist/model-endpoint/index.js +8 -7
- package/dist/{open-library-OJ4HT2X4.js → open-library-R5EZROFN.js} +29 -27
- package/dist/{open-library-OJ4HT2X4.js.map → open-library-R5EZROFN.js.map} +1 -1
- package/dist/{open-registry-LWGIOJDK.js → open-registry-RZW2AFD6.js} +11 -11
- package/dist/{open-registry-LWGIOJDK.js.map → open-registry-RZW2AFD6.js.map} +1 -1
- package/dist/{paths-FR2752HV.js → paths-RPK5PNZQ.js} +7 -7
- package/dist/{paths-FR2752HV.js.map → paths-RPK5PNZQ.js.map} +1 -1
- package/dist/{plugin-store-IALJUBN2.js → plugin-store-OJTERUEZ.js} +7 -7
- package/dist/{plugin-store-IALJUBN2.js.map → plugin-store-OJTERUEZ.js.map} +1 -1
- package/dist/{project-UQFCYHYS.js → project-S2FT3LLR.js} +43 -41
- package/dist/{project-UQFCYHYS.js.map → project-S2FT3LLR.js.map} +1 -1
- package/dist/resolver/index.js +4 -4
- package/dist/runner/index.js +32 -30
- package/dist/runner/src/capability-roundtrip.d.ts +6 -6
- package/dist/runner/src/capability-roundtrip.d.ts.map +1 -1
- package/dist/runner/src/composition/run-snapshot.d.ts +7 -1
- package/dist/runner/src/composition/run-snapshot.d.ts.map +1 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +10 -10
- package/dist/sdk/bridge.js +17 -15
- package/dist/sdk/core.js +4 -4
- package/dist/sdk/flow.js +5 -5
- package/dist/sdk/index.js +32 -30
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/resolver.js +4 -4
- package/dist/sdk/runner.js +32 -30
- package/dist/sdk/session.js +2 -2
- package/dist/sdk/transport/ws/server.js +5 -5
- package/dist/sdk/transport/ws.js +5 -5
- package/dist/sdk/transport.js +5 -5
- package/dist/sdk/types.js +1 -1
- package/dist/serve-preflight-AADSOUO2.js +58 -0
- package/dist/{serve-preflight-TYEKHC32.js.map → serve-preflight-AADSOUO2.js.map} +1 -1
- package/dist/session/index.js +2 -2
- package/dist/{setup-4JV2IMCB.js → setup-HOAJHUFQ.js} +27 -25
- package/dist/setup-HOAJHUFQ.js.map +1 -0
- package/dist/{skills-6QTKFMLW.js → skills-KHHW3RZ3.js} +6 -6
- package/dist/{skills-6QTKFMLW.js.map → skills-KHHW3RZ3.js.map} +1 -1
- package/dist/source-FOELFCY6.js +88 -0
- package/dist/{source-XYMMJVKR.js.map → source-FOELFCY6.js.map} +1 -1
- package/dist/{source-manifest-publish-SZFGGKB4.js → source-manifest-publish-Q7P5AEVU.js} +44 -42
- package/dist/source-manifest-publish-Q7P5AEVU.js.map +1 -0
- package/dist/transport/index.js +5 -5
- package/dist/transport/ws/server.js +5 -5
- package/dist/transport/ws.js +5 -5
- package/dist/tui/index.js +56 -37
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/src/repl.d.ts +10 -0
- package/dist/tui/src/repl.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/src/version.d.ts +4 -4
- package/dist/workspace-plugin/adapters/mcp.js +24 -22
- package/dist/workspace-plugin/adapters/omp.js +14 -14
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2TLPC6TQ.js.map +0 -1
- package/dist/chunk-5XHQBCB5.js.map +0 -1
- package/dist/chunk-65UAC3ZR.js.map +0 -1
- package/dist/chunk-6ARPZHOV.js.map +0 -1
- package/dist/chunk-6SXSVKQY.js.map +0 -1
- package/dist/chunk-7PVGND4J.js.map +0 -1
- package/dist/chunk-7SJHSGUV.js.map +0 -1
- package/dist/chunk-AQNW2FET.js.map +0 -1
- package/dist/chunk-BSMW3PX2.js.map +0 -1
- package/dist/chunk-DI6J2PJB.js.map +0 -1
- package/dist/chunk-DS6UUCFG.js.map +0 -1
- package/dist/chunk-E2EC6SAX.js.map +0 -1
- package/dist/chunk-EPXZQIC6.js.map +0 -1
- package/dist/chunk-F4CZQD3T.js.map +0 -1
- package/dist/chunk-J262X4JU.js.map +0 -1
- package/dist/chunk-J4WKNJHO.js.map +0 -1
- package/dist/chunk-JRVQV7WC.js.map +0 -1
- package/dist/chunk-MMOWIRHP.js.map +0 -1
- package/dist/chunk-SHTXMERQ.js.map +0 -1
- package/dist/chunk-TCH5UDKT.js.map +0 -1
- package/dist/chunk-TUFNY6OD.js.map +0 -1
- package/dist/chunk-U3UDOX6I.js.map +0 -1
- package/dist/chunk-VXYZ5M7Z.js.map +0 -1
- package/dist/chunk-XYCYGN3Q.js.map +0 -1
- package/dist/chunk-YN6N3RBM.js.map +0 -1
- package/dist/ensure-sources-CAMWJTMR.js.map +0 -1
- package/dist/library-publish-UQQMHTND.js.map +0 -1
- package/dist/serve-preflight-TYEKHC32.js +0 -56
- package/dist/setup-4JV2IMCB.js.map +0 -1
- package/dist/source-XYMMJVKR.js +0 -86
- package/dist/source-manifest-publish-SZFGGKB4.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../bridge/src/harness-model-check.ts","../bridge/src/normalizer.ts","../bridge/src/runtime.ts","../bridge/src/validation.ts"],"names":["path"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,SAAS,gBAAgB,SAAA,EAAoD;AAC3E,EAAA,IAAI,cAAc,OAAA,EAAS,2BAAW,GAAA,CAAI,CAAC,QAAQ,CAAC,CAAA;AACpD,EAAA,IAAI,cAAc,YAAA,EAAc,2BAAW,GAAA,CAAI,CAAC,WAAW,CAAC,CAAA;AAC5D,EAAA,IAAI,SAAA,KAAc,OAAO,OAAO,IAAI,IAAI,MAAA,CAAO,IAAA,CAAK,mBAAmB,CAAC,CAAA;AACxE,EAAA,OAAO,MAAA;AACT;AAQA,SAAS,UAAA,GAAoE;AAC3E,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,mBAAA,IAAuB,IAAA,CAAK,KAAK,EAAA,CAAG,OAAA,EAAQ,EAAG,MAAA,EAAQ,OAAO,CAAA;AACtF,EAAA,MAAM,SAAA,uBA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,KAAA,CAAM,GAAA,EAAK;AAAA,MAChC,MAAA,EAAQ,KAAA;AAAA,MACR,OAAA;AAAA,MACA,QAAQ,UAAA,CAAW;AAAA,KACpB,CAAA;AAED,IAAA,YAAA,CAAa,OAAO,CAAA;AAEpB,IAAA,IAAI,QAAA,CAAS,EAAA,EAAI,OAAO,EAAE,IAAI,IAAA,EAAK;AAEnC,IAAA,MAAM,SAAS,QAAA,CAAS,MAAA;AACxB,IAAA,IAAI,MAAA,KAAW,GAAA,IAAO,MAAA,KAAW,GAAA,EAAK;AACpC,MAAA,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAO,yCAAA,EAA0C;AAAA,IACvE;AACA,IAAA,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAO,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAA,EAAG;AAAA,EAC3D,SAAS,GAAA,EAAU;AACjB,IAAA,IAAI,GAAA,CAAI,SAAS,YAAA,EAAc,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,OAAO,wBAAA,EAAyB;AACnF,IAAA,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAO,GAAA,CAAI,WAAW,eAAA,EAAgB;AAAA,EAC5D;AACF","file":"chunk-HMVAGPYR.js","sourcesContent":["/**\n * Pre-flight model check: would the harness refuse the selected model before it starts a turn?\n *\n * `skaile run --dry-run` uses it so a setup check learns about a refusal that a real run would\n * print. The codex harness refuses a selection up front when it cannot address the AI provider\n * surface; codex, omp and the Claude SDK refuse a provider nothing serves\n * ({@link checkModelProvider}); every other harness answers `undefined`.\n */\nimport { execFile } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport {\n type AIProviderRegistry,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n parseModelRef,\n registryEntries,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport { openSqlite } from \"@skaile/workspaces/core/logging\";\nimport { parse } from \"yaml\";\nimport { buildCodexConfigDocument } from \"./codex/config-toml.js\";\nimport { ompRegistryModelRefusal, registryModelEntries } from \"./harnesses/omp-models-yml.js\";\nimport { sessionSurfaceNotice } from \"./claude-sdk-surface.js\";\nimport { bindSingleProviderEntry } from \"./provider-materialize/env-harnesses.js\";\nimport { AI_PROVIDER_PRESETS } from \"./provider-catalog.js\";\nimport { BUILTIN_HARNESS_CATALOG } from \"./registry.js\";\n\n/** What {@link checkHarnessModel} reads. */\nexport interface HarnessModelCheckInput {\n registry?: AIProviderRegistry | MergedAIProviderRegistry;\n /** The model selector: `<providerId>/<modelId>`, a bare id or `@role`. */\n model?: string;\n roles?: Record<string, string>;\n}\n\n/**\n * Providers a harness reaches with its own login, without a registry entry: codex talks to\n * OpenAI, the Claude SDK to Anthropic, omp to every vendor it ships a login for. A harness not\n * listed here (a plugin's, `echo`) is not checked.\n */\nfunction nativeProviders(harnessId: string): ReadonlySet<string> | undefined {\n if (harnessId === \"codex\") return new Set([\"openai\"]);\n if (harnessId === \"claude-sdk\") return new Set([\"anthropic\"]);\n if (harnessId === \"omp\") return new Set(Object.keys(AI_PROVIDER_PRESETS));\n return undefined;\n}\n\n/**\n * What omp can serve on the user's own agent directory (`PI_CODING_AGENT_DIR`, else\n * `~/.omp/agent`): the provider ids their `models.yml` defines, and whether they have a login\n * (a usable credential in `agent.db`), which may carry built-in providers this list cannot name\n * (p1111). The file alone is no login: omp creates an empty `agent.db` on its first start (p1470).\n */\nfunction ompOwnHome(): { providers: ReadonlySet<string>; hasLogin: boolean } {\n const dir = process.env.PI_CODING_AGENT_DIR || path.join(os.homedir(), \".omp\", \"agent\");\n const providers = new Set<string>();\n try {\n const doc = parse(readFileSync(path.join(dir, \"models.yml\"), \"utf-8\")) as {\n providers?: unknown;\n } | null;\n const block = doc?.providers;\n if (block && typeof block === \"object\" && !Array.isArray(block)) {\n for (const id of Object.keys(block)) providers.add(id);\n }\n } catch {\n // no models.yml, or one omp itself will reject\n }\n return { providers, hasLogin: ompHasCredential(path.join(dir, \"agent.db\")) };\n}\n\n/**\n * True when omp's auth store holds a credential that is not disabled. A missing, unreadable or\n * schema-less file holds none. Reads the `auth_credentials` table and its `disabled_cause`\n * column as omp 18.12.6 writes them (checked against that version); a different layout reads\n * as \"no login\", which is the safe side. Read-only: the check never creates or changes the file.\n */\nfunction ompHasCredential(authDb: string): boolean {\n if (!existsSync(authDb)) return false;\n try {\n const db = openSqlite(authDb, { readonly: true });\n try {\n return (\n db\n .prepare(\"SELECT 1 AS found FROM auth_credentials WHERE disabled_cause IS NULL LIMIT 1\")\n .get<{ found: number }>() != null\n );\n } finally {\n db.close();\n }\n } catch {\n return false;\n }\n}\n\n/**\n * `<provider>/<model>` whose provider nothing can serve: not a registry entry and not a\n * provider the harness has its own login for. Without this the id goes to the harness's default\n * provider verbatim and fails there with a message that blames the login.\n *\n * The rule differs per harness (p1111). omp and the Claude SDK route through a registry entry,\n * so while any enabled registry entry is left they take an unknown head as a vendor-scoped\n * model id (`meta-llama/Llama-3.3-70B`). codex talks to OpenAI only and cannot, so it refuses\n * a head that is neither a registered provider nor `openai`, whatever else is registered.\n */\nexport function checkModelProvider(\n harnessId: string,\n input: HarnessModelCheckInput,\n): string | undefined {\n const native = nativeProviders(harnessId);\n let selector = input.model?.trim() ?? \"\";\n if (selector.startsWith(\"@\")) selector = input.roles?.[selector.slice(1)]?.trim() ?? \"\";\n const slash = selector.indexOf(\"/\");\n if (!native || slash <= 0 || selector.startsWith(\"@\")) return undefined;\n const head = selector.slice(0, slash);\n if (native.has(head)) return undefined;\n const entries = input.registry ? registryEntries(input.registry) : [];\n if (entries.some(([id]) => id === head)) return undefined;\n const servesVendorIds =\n harnessId !== \"codex\" &&\n entries.some(\n ([, entry]) => (entry.kind === \"llm\" || entry.kind === \"embed\") && isEntryEnabled(entry),\n );\n if (servesVendorIds) return undefined;\n if (harnessId === \"omp\") {\n // With no registry entry omp runs on the user's own agent directory: their `models.yml`\n // providers and the logins omp ships are served there.\n const own = ompOwnHome();\n if (own.providers.has(head) || own.hasLogin) return undefined;\n }\n return `provider '${head}' is not configured: run skaile providers list`;\n}\n\n/**\n * The surface problem of the entry the selected model routes to, for the harnesses that route\n * the model through one registry entry and cannot speak every surface: the Claude Agent SDK\n * (`sessionSurfaceNotice`), and Gemini CLI and Qwen Code (the check they run at start,\n * `bindSingleProviderEntry`). `undefined` for the others and for an entry they speak. `skaile run`\n * and `run --dry-run` print it; `config set model` and `serve` do not judge it.\n */\nexport function checkModelSurface(\n harnessId: string,\n input: HarnessModelCheckInput,\n): string | undefined {\n const registry = input.registry;\n if (!registry) return undefined;\n let selector = input.model?.trim() ?? \"\";\n if (selector.startsWith(\"@\")) selector = input.roles?.[selector.slice(1)]?.trim() ?? \"\";\n if (harnessId === \"claude-sdk\")\n return selector ? sessionSurfaceNotice(registry, selector) : undefined;\n if (harnessId !== \"gemini\" && harnessId !== \"qwen\") return undefined;\n const merged: MergedAIProviderRegistry = Array.isArray(\n (registry as MergedAIProviderRegistry).order,\n )\n ? (registry as MergedAIProviderRegistry)\n : {\n version: 1,\n providers: registry as AIProviderRegistry,\n order: Object.keys(registry),\n origin: {},\n locked: [],\n };\n try {\n bindSingleProviderEntry(harnessId, BUILTIN_HARNESS_CATALOG[harnessId]?.name ?? harnessId, {\n registry: merged,\n lookupEnv: process.env,\n ...(selector ? { modelRef: selector } : {}),\n });\n } catch (err) {\n return err instanceof Error ? err.message : String(err);\n }\n return undefined;\n}\n\n/**\n * The refusal message the harness prints for this model, or `undefined` when it takes it.\n * The text matches the one the harness throws at start. The provider surface the Claude SDK,\n * Gemini CLI and Qwen Code cannot speak is {@link checkModelSurface}, which `run` adds.\n */\nexport function checkHarnessModel(\n harnessId: string,\n input: HarnessModelCheckInput,\n): string | undefined {\n const unknownProvider = checkModelProvider(harnessId, input);\n if (unknownProvider) return unknownProvider;\n if (harnessId === \"omp\") {\n let selector = input.model?.trim() ?? \"\";\n if (selector.startsWith(\"@\")) selector = input.roles?.[selector.slice(1)]?.trim() ?? \"\";\n return ompRegistryModelRefusal(input.registry, selector, nativeProviders(\"omp\") ?? new Set());\n }\n if (harnessId !== \"codex\") return undefined;\n const build = buildCodexConfigDocument({\n registry: input.registry,\n ...(input.model ? { modelRef: input.model, model: input.model } : {}),\n ...(input.roles ? { roles: input.roles } : {}),\n });\n if (!build.unaddressable) return undefined;\n const { id, reason } = build.unaddressable;\n return `AI provider '${id}' cannot be used with the codex harness: ${reason}. Pick a model of another provider.`;\n}\n\n/**\n * The refusal `skaile serve --harness omp --model <x>` prints before it is ready, or `undefined`\n * when omp can take the model (p1334). Stricter than {@link checkHarnessModel}, which `run --dry-run`\n * shares: a server answers its first prompt long after start, so a model omp reports as \"not\n * found\" must fail at start.\n *\n * It judges exactly what the harness sends. `materializeOmpProviders` resolves the selector with\n * `parseModelRef` and passes `--model <entry>/<model>` to omp: an `<entry>/<model>` selector goes\n * to that entry, and so does a bare id an entry maps; omp then refuses a model that entry does\n * not declare. An id no entry names or maps (`anthropic/claude-sonnet-4-5`,\n * `meta-llama/Llama-3.3-70B`, `nosuch/foo`) goes on exactly as typed: the registry\n * cannot judge it, so this check answers `undefined` for it, and {@link isUnlistedModel} tells\n * the caller to ask omp itself ({@link checkOmpListedModel}). The refusal names the selector the\n * user typed, never the rewritten one alone.\n */\nexport function checkOmpServeModel(input: HarnessModelCheckInput): string | undefined {\n const registry = input.registry;\n let selector = input.model?.trim() ?? \"\";\n if (selector.startsWith(\"@\")) selector = input.roles?.[selector.slice(1)]?.trim() ?? \"\";\n if (!registry || !selector) return undefined;\n const ref = parseModelRef(selector, registry, input.roles);\n if (!ref?.providerModelId || ref.fallback) return undefined;\n const sent = `${ref.providerId}/${ref.providerModelId}`;\n const refusal = ompRegistryModelRefusal(registry, sent, nativeProviders(\"omp\") ?? new Set());\n if (!refusal) return undefined;\n if (sent === selector) return refusal;\n const detail = refusal.slice(refusal.indexOf(\"': \") + 3);\n return `omp cannot serve model '${selector}': it is sent to omp as '${sent}'; ${detail}`;\n}\n\n/**\n * True when `model` is an id the registry does not list: no entry is named by its head, none maps\n * it, and it is not an `@role`. Such an id goes to the harness as typed, so only the\n * harness itself can say whether it takes it. False with no registry entry to judge against.\n */\nexport function isUnlistedModel(input: HarnessModelCheckInput): boolean {\n let selector = input.model?.trim() ?? \"\";\n if (selector.startsWith(\"@\")) selector = input.roles?.[selector.slice(1)]?.trim() ?? \"\";\n if (!input.registry || !selector) return false;\n return parseModelRef(selector, input.registry, input.roles)?.fallback === true;\n}\n\n/** Thinking levels omp takes as a `:<level>` suffix of a model selector. */\nconst OMP_THINKING_SUFFIX = /:(off|minimal|low|medium|high|xhigh)$/i;\n\n/** Run `omp <args> --json` and return the `models` of its answer, or `undefined` for no answer. */\nfunction ompModels(args: string[], timeoutMs: number): Promise<unknown[] | undefined> {\n const bin = process.env.OMP_BRIDGE_BIN || \"omp\";\n const pre = process.env.OMP_BRIDGE_PREARGS\n ? process.env.OMP_BRIDGE_PREARGS.split(/\\s+/).filter(Boolean)\n : [];\n return new Promise((resolve) => {\n execFile(\n bin,\n [...pre, ...args, \"--json\"],\n { timeout: timeoutMs, maxBuffer: 64 * 1024 * 1024, env: process.env },\n (error, out) => {\n if (error) return resolve(undefined);\n try {\n const parsed: unknown = JSON.parse(out);\n const models = Array.isArray(parsed)\n ? parsed\n : parsed && typeof parsed === \"object\" && \"models\" in parsed\n ? parsed.models\n : undefined;\n resolve(Array.isArray(models) ? models : undefined);\n } catch {\n resolve(undefined);\n }\n },\n );\n });\n}\n\n/**\n * The refusal `skaile serve --harness omp --model <x>` prints before it is ready when no registry\n * entry is involved and omp runs on the user's own agent directory, or `undefined` when omp may\n * take the model (p1334). The registry check ({@link checkOmpServeModel}) cannot judge that\n * case: omp's catalog (built-in vendors, `models.yml`, logins) lives in omp.\n *\n * Asks omp itself. `omp models find` is a substring search, but `omp --model` also takes forms it\n * does not match (`anthropic/sonnet-4-5`, `openrouter/~anthropic/claude-sonnet-latest:high`), so\n * a selector is refused only when omp cannot know it: a `:<thinking level>` suffix is dropped, a\n * non-empty `find` answer passes, and an empty one passes too when the selector's `<provider>/`\n * head is a provider omp lists models for. A bare id that matches nothing, or a provider omp does\n * not list, is refused. Anything else (omp missing, a timeout, output that is not the expected\n * JSON) is no verdict, and the harness reports its own failure at start. Honours the\n * `OMP_BRIDGE_BIN` / `OMP_BRIDGE_PREARGS` test seam the harness uses.\n *\n * @param selector - The model as typed (`<provider>/<model>` or a bare id); `@role` is not judged.\n * @param timeoutMs - Total time to wait for omp across both calls (default 20 s).\n */\nexport async function checkOmpListedModel(\n selector: string,\n timeoutMs = 20_000,\n): Promise<string | undefined> {\n const wanted = selector.trim();\n if (!wanted || wanted.startsWith(\"@\")) return undefined;\n const deadline = Date.now() + timeoutMs;\n const query = wanted.replace(OMP_THINKING_SUFFIX, \"\");\n const found = await ompModels([\"models\", \"find\", query], timeoutMs);\n if (!found || found.length > 0) return undefined;\n const refusal = `omp cannot serve model '${wanted}': omp lists no model that matches it. Run \\`omp models\\` to see what it can serve.`;\n const slash = query.indexOf(\"/\");\n if (slash <= 0) return refusal;\n // The budget covers both calls: with no time left there is no verdict.\n const left = deadline - Date.now();\n if (left <= 0) return undefined;\n const all = await ompModels([\"models\"], left);\n if (!all) return undefined;\n const provider = query.slice(0, slash).toLowerCase();\n const known = all.some(\n (m) =>\n typeof m === \"object\" &&\n m !== null &&\n \"provider\" in m &&\n typeof m.provider === \"string\" &&\n m.provider.toLowerCase() === provider,\n );\n return known ? undefined : refusal;\n}\n","/**\n * EventNormalizer — converts bridge-level AgentEvent (raw harness events) to\n * skaile-agent-types AgentEvent (normalized, human-readable events).\n *\n * Stateful: tracks active subagents and dev-server detection across a session.\n * Call reset() between sessions.\n */\n\nimport {\n type AgentEvent as NormalizedEvent,\n type NativeApprovalDescription,\n stripActivityLabel,\n TOOL_ACTIVITY_LABEL_MAX_CHARS,\n TOOL_ACTIVITY_LABEL_PARAM,\n} from \"@skaile/workspaces/types\";\nimport { classifyClaudeSdkError } from \"./error-classifier.js\";\nimport type { AgentMessage, AgentEvent as BridgeEvent, ContentBlock } from \"./types.js\";\n\n/**\n * The optional usage keys a `result` event carries, in the shape both\n * `finished` and a result-sourced `error` emit them. Absent keys stay absent.\n */\nfunction resultUsageFields(\n event: Pick<\n Extract<BridgeEvent, { type: \"result\" | \"error\" }>,\n \"tokens\" | \"modelUsage\" | \"contextTokens\" | \"contextWindow\"\n >,\n) {\n return {\n ...(event.tokens ? { tokens: event.tokens } : {}),\n ...(event.modelUsage ? { modelUsage: event.modelUsage } : {}),\n ...(typeof event.contextTokens === \"number\" ? { contextTokens: event.contextTokens } : {}),\n ...(typeof event.contextWindow === \"number\" ? { contextWindow: event.contextWindow } : {}),\n };\n}\n\n/**\n * The tool a harness uses to park a turn on a human answer. Both branches that\n * recognise it must use this constant: `message_start` turns it into a\n * `question`, and `tool_call` must then stay silent about it.\n */\nconst QUESTION_TOOL = \"AskUserQuestion\";\n\nconst MAX_ANNOUNCED_TOOL_USES = 64;\n\n/**\n * Bridge `tool_call` inputs are loosely typed: Codex MCP arguments may arrive\n * as a JSON string, and the echo harness passes a bare path.\n */\nfunction toolInputRecord(input: unknown): Record<string, unknown> {\n let value = input;\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value);\n } catch {\n return { input };\n }\n }\n if (typeof value === \"object\" && value !== null && !Array.isArray(value)) {\n return value as Record<string, unknown>;\n }\n return value === undefined ? {} : { input };\n}\n\n/**\n * Converts raw bridge-level {@link BridgeEvent} payloads into normalized\n * `@skaile/workspaces/types` `AgentEvent` payloads consumed by the runner and transport.\n *\n * Stateful: tracks active subagents and dev-server detection across a session.\n * Call {@link EventNormalizer.reset} between sessions to clear accumulated state.\n *\n * @docLink packages/bridge/api-reference#normalizer\n */\nexport class EventNormalizer {\n private activeSubagents = new Map<string, string>();\n private devServerStartingEmitted = false;\n /** Dev-server URLs already announced as ready: each server once, a second one too. */\n private announcedDevServers = new Set<string>();\n /** True when message_update deltas have been emitted for the current message. */\n private hasStreamedText = false;\n /**\n * True once a `_thinkingDelta` run has been reported as `status: thinking`;\n * cleared by the next text delta or assistant message, so a run reports once.\n */\n private thinkingAnnounced = false;\n /**\n * tool_use blocks `message_start` already reported, awaiting the harness's\n * matching bridge `tool_call` — which must then not report the call again.\n */\n private announcedToolUses: Array<{ id?: string; name: string }> = [];\n\n /**\n * Convert a single bridge event into zero or more normalized events.\n * One bridge event can produce multiple normalized events (e.g., a message_start\n * with text + tool_use blocks produces both text and tool_call events).\n */\n normalize(event: BridgeEvent): NormalizedEvent[] {\n switch (event.type) {\n case \"message_start\":\n return this.handleMessageStart(event.message);\n\n case \"message_update\":\n return this.handleMessageUpdate(event);\n\n case \"message_end\":\n return [];\n\n case \"message_retract\":\n // The replay streams its reply afresh, so its deltas (or, failing\n // those, its message_start text) must count as a new message.\n this.hasStreamedText = false;\n return event.text ? [{ type: \"text_retract\", content: event.text }] : [];\n\n case \"turn_end\":\n return this.handleTurnEnd(event.toolResults);\n\n case \"result\":\n return this.handleResult(event);\n\n case \"error\":\n this.announcedToolUses = [];\n return [\n {\n type: \"error\",\n message: event.error,\n fatal: event.fatal ?? true,\n category: event.detail?.category,\n ...(event.detail?.hint ? { hint: event.detail.hint } : {}),\n ...resultUsageFields(event),\n ...(event.retrying === true\n ? { retrying: true, ...(event.retryReason ? { retryReason: event.retryReason } : {}) }\n : {}),\n ...(event.selfStarted === true ? { selfStarted: true as const } : {}),\n },\n ];\n\n case \"background_task_started\":\n return [{ type: \"background_task_started\", taskId: event.taskId }];\n\n case \"self_turn_started\":\n return [{ type: \"self_turn_started\", taskIds: [...event.taskIds] }];\n\n case \"tool_call\": {\n // The question tool parks the turn on the user's answer, so reporting\n // work here would undo the idle its `question` event just set, and\n // nothing follows to correct it while the user reads the prompt.\n const toolName = event.name ?? event.tool?.name;\n if (toolName === QUESTION_TOOL) return [];\n // A harness that also sent the call as a `message_start` tool_use block\n // (Claude) was already reported there; the rest only ever send this.\n if (!toolName || this.consumeAnnouncedToolUse(toolName, event.toolCallId)) {\n return [{ type: \"status\", phase: \"working\" }];\n }\n return this.handleToolUse(\n {\n type: \"tool_use\",\n id: typeof event.toolCallId === \"string\" ? event.toolCallId : undefined,\n name: toolName,\n input: toolInputRecord(event.input),\n },\n typeof event.parentToolUseId === \"string\" ? event.parentToolUseId : undefined,\n );\n }\n\n case \"tool_execution_end\":\n return [];\n\n case \"agent_end\":\n this.announcedToolUses = [];\n return [{ type: \"status\", phase: \"idle\" }];\n\n case \"commands_available\":\n // Pass through to transport — the gateway caches this event\n return [event as unknown as NormalizedEvent];\n\n case \"session_info\":\n // Pass through to transport — the forge layer stores the OMP session ID\n return [event as unknown as NormalizedEvent];\n\n case \"ui_render\":\n case \"ui_render_update\":\n case \"ui_clear\":\n // Pass through verbatim — harnesses that implement the Agent UI Protocol emit these directly\n return [event as unknown as NormalizedEvent];\n\n default:\n return [];\n }\n }\n\n /** Clear all stateful tracking between sessions. */\n reset(): void {\n this.activeSubagents.clear();\n this.devServerStartingEmitted = false;\n this.announcedDevServers.clear();\n this.hasStreamedText = false;\n this.thinkingAnnounced = false;\n this.announcedToolUses = [];\n }\n\n private consumeAnnouncedToolUse(name: string, id: unknown): boolean {\n const callId = typeof id === \"string\" ? id : undefined;\n const index = this.announcedToolUses.findIndex(\n (entry) => entry.name === name && (!callId || !entry.id || entry.id === callId),\n );\n if (index === -1) return false;\n this.announcedToolUses.splice(index, 1);\n return true;\n }\n\n // ---------------------------------------------------------------------------\n // message_start → text, tool_call, question, subagent\n // ---------------------------------------------------------------------------\n\n private handleMessageStart(message: AgentMessage): NormalizedEvent[] {\n // Only process assistant messages. Harnesses (e.g. omp) may echo the user's\n // message as a message_start with role:\"user\" before streaming the response.\n // Emitting a text event for that echo would prepend the user's input to the\n // assistant bubble on the frontend.\n if (message.role !== \"assistant\") return [];\n\n // A subagent's message is not the main reply: its text belongs to the\n // subagent's own result, and it must not reset the main stream's state.\n const parentToolUseId = message.parentToolUseId;\n const events: NormalizedEvent[] = [];\n const blocks = this.getContentBlocks(message);\n\n for (const block of blocks) {\n if (block.type === \"text\" && block.text) {\n if (parentToolUseId) continue;\n // Skip full text if we already streamed it via message_update deltas\n if (!this.hasStreamedText) {\n events.push({ type: \"text\", content: block.text });\n }\n } else if (block.type === \"tool_use\" && block.name) {\n if (block.name !== QUESTION_TOOL) {\n this.announcedToolUses.push({ id: block.id, name: block.name });\n // Bounded in case a harness never echoes a block as a tool_call.\n if (this.announcedToolUses.length > MAX_ANNOUNCED_TOOL_USES) {\n this.announcedToolUses.shift();\n }\n }\n events.push(...this.handleToolUse(block, parentToolUseId));\n }\n }\n\n if (!parentToolUseId) this.hasStreamedText = false;\n if (!parentToolUseId) this.thinkingAnnounced = false;\n return events;\n }\n\n private handleToolUse(block: ContentBlock, parentToolUseId?: string): NormalizedEvent[] {\n const name = block.name!;\n const input = (block.input ?? {}) as Record<string, unknown>;\n\n if (name === QUESTION_TOOL) {\n return this.handleAskUserQuestion(input);\n }\n if (name === \"Agent\") {\n return this.handleAgentToolUse(block, input);\n }\n return this.handleGenericToolUse(name, input, parentToolUseId);\n }\n\n private handleAskUserQuestion(input: Record<string, unknown>): NormalizedEvent[] {\n const events: NormalizedEvent[] = [];\n const candidate = input.approval as Partial<NativeApprovalDescription> | undefined;\n const approval =\n candidate &&\n [\"command\", \"file\", \"permissions\", \"mcp\"].includes(candidate.kind ?? \"\") &&\n Array.isArray(candidate.details) &&\n candidate.details.length > 0 &&\n candidate.details.length <= 64 &&\n candidate.details.every((detail) => typeof detail === \"string\" && detail.length <= 8192) &&\n candidate.details.reduce((total, detail) => total + detail.length, 0) <= 65536\n ? (candidate as NativeApprovalDescription)\n : undefined;\n if (Object.hasOwn(input, \"approval\") && !approval) return [];\n // Claude SDK sends { questions: [{ question, header, options: [{ label, description }] }] }\n // Legacy/simple format sends { question: string, options?: string[] }\n const questions = input.questions;\n if (Array.isArray(questions)) {\n for (const q of questions) {\n const qObj = q as Record<string, unknown>;\n const question = String(qObj.question ?? \"\");\n const rawOpts = qObj.options;\n const options = Array.isArray(rawOpts)\n ? rawOpts.map((o: any) => (typeof o === \"string\" ? o : String(o.label ?? o)))\n : undefined;\n events.push({\n type: \"question\",\n question,\n options,\n ...(typeof input.requestId === \"string\" ? { requestId: input.requestId } : {}),\n ...(approval ? { approval } : {}),\n });\n }\n } else {\n const question = String(input.question ?? input.text ?? \"\");\n const rawOptions = input.options;\n const options = Array.isArray(rawOptions) ? rawOptions.map(String) : undefined;\n events.push({\n type: \"question\",\n question,\n options,\n ...(typeof input.requestId === \"string\" ? { requestId: input.requestId } : {}),\n ...(approval ? { approval } : {}),\n });\n }\n return events;\n }\n\n private handleAgentToolUse(\n block: ContentBlock,\n input: Record<string, unknown>,\n ): NormalizedEvent[] {\n const agentName = String(input.subagent_type ?? input.description ?? \"unknown\");\n const description = String(input.description ?? input.prompt ?? \"\").slice(0, 200);\n if (block.id) {\n this.activeSubagents.set(block.id, agentName);\n }\n return [\n { type: \"subagent\", name: agentName, status: \"started\", description },\n { type: \"status\", phase: \"working\" },\n ];\n }\n\n private handleGenericToolUse(\n name: string,\n input: Record<string, unknown>,\n parentToolUseId?: string,\n ): NormalizedEvent[] {\n const events: NormalizedEvent[] = [];\n const label = labelToolCall(name, input);\n events.push({\n type: \"tool_call\",\n tool: name,\n input,\n // Summarize without the label: it would eat the default branch's\n // 100-char argument budget and push the real args out.\n summary: summarizeToolCall(name, stripActivityLabel(input)),\n ...(label ? { label } : {}),\n ...(parentToolUseId ? { parentToolUseId } : {}),\n });\n events.push({ type: \"status\", phase: \"working\" });\n\n if (name === \"Bash\" && typeof input.command === \"string\") {\n const devEvent = this.detectDevServerStarting(input.command);\n if (devEvent) events.push(devEvent);\n }\n\n return events;\n }\n\n // ---------------------------------------------------------------------------\n // message_update → streaming text\n // ---------------------------------------------------------------------------\n\n private handleMessageUpdate(event: BridgeEvent): NormalizedEvent[] {\n // Bridge deltas carry no subagent tag: a harness must drop a subagent's\n // partials itself (claude-sdk does in handleStreamEvent), or they read as main text.\n const delta = (event as any)._textDelta as string | undefined;\n if (delta) {\n this.hasStreamedText = true;\n this.thinkingAnnounced = false;\n return [{ type: \"text\", content: delta }];\n }\n // The protocol has no thinking-content event, so reasoning surfaces as the\n // existing `thinking` phase, once per run. The text is never forwarded as\n // `text`; a harness keeps it out of `_textDelta`.\n const thinking: unknown = \"_thinkingDelta\" in event ? event._thinkingDelta : undefined;\n if (typeof thinking === \"string\" && thinking && !this.thinkingAnnounced) {\n this.thinkingAnnounced = true;\n return [{ type: \"status\", phase: \"thinking\" }];\n }\n return [];\n }\n\n // ---------------------------------------------------------------------------\n // turn_end → tool_result, subagent finished, file_changed, dev_server\n // ---------------------------------------------------------------------------\n\n private handleTurnEnd(toolResults?: AgentMessage[]): NormalizedEvent[] {\n if (!toolResults?.length) return [];\n\n const events: NormalizedEvent[] = [];\n\n for (const result of toolResults) {\n const toolName = result.toolName ?? \"unknown\";\n const outputData = result.data ?? result.content;\n const output = typeof outputData === \"string\" ? outputData : JSON.stringify(outputData);\n\n // Check if this is a subagent result\n if (toolName === \"Agent\" || this.isSubagentResult(result)) {\n events.push(...this.handleSubagentResult(result, output));\n } else {\n events.push(...this.handleToolResult(toolName, outputData, output, result.parentToolUseId));\n }\n }\n\n return events;\n }\n\n private handleSubagentResult(result: AgentMessage, output: string): NormalizedEvent[] {\n const events: NormalizedEvent[] = [];\n const agentName = this.resolveSubagentName(result);\n const description = output.slice(0, 200);\n events.push({ type: \"subagent\", name: agentName, status: \"finished\", description });\n\n if (agentName === \"dev-server\") events.push(...this.detectDevServerReady(output));\n return events;\n }\n\n private handleToolResult(\n toolName: string,\n outputData: unknown,\n output: string,\n parentToolUseId?: string,\n ): NormalizedEvent[] {\n const events: NormalizedEvent[] = [];\n events.push({\n type: \"tool_result\",\n tool: toolName,\n output: outputData,\n summary: summarizeToolResult(toolName, outputData),\n ...(parentToolUseId ? { parentToolUseId } : {}),\n });\n\n // Detect file changes from Write/Edit results\n const fileEvents = detectFileChanges(toolName, outputData);\n if (fileEvents.length > 0) events.push(...fileEvents);\n\n // Detect dev servers from Bash output\n if (toolName === \"Bash\") events.push(...this.detectDevServerReady(output));\n return events;\n }\n\n private isSubagentResult(result: AgentMessage): boolean {\n // Check if the tool result's id maps to a tracked subagent\n if (result.toolName && this.activeSubagents.has(result.toolName)) return true;\n return false;\n }\n\n private resolveSubagentName(result: AgentMessage): string {\n // toolName on bridge AgentMessage is resolved from toolIdToName in the harness\n const name = result.toolName ? this.activeSubagents.get(result.toolName) : undefined;\n if (name) {\n this.activeSubagents.delete(result.toolName!);\n return name;\n }\n return result.toolName ?? \"unknown\";\n }\n\n // ---------------------------------------------------------------------------\n // result → finished or error\n // ---------------------------------------------------------------------------\n\n private handleResult(event: BridgeEvent & { type: \"result\" }): NormalizedEvent[] {\n const usage = resultUsageFields(event);\n if (event.subtype === \"success\") {\n return [\n {\n type: \"finished\",\n summary: event.summary ?? \"Task completed\",\n costUsd: event.costUsd ?? 0,\n ...usage,\n ...(event.selfStarted === true ? { selfStarted: true as const } : {}),\n },\n ];\n }\n\n const errors = event.errors ?? [];\n // Run the same classifier the claude-sdk harness uses on its `error`\n // event so the result-error path also surfaces a category and hint\n // (harnesses other than claude-sdk emit `result` without a paired\n // `error`, so this is the only place they get classified).\n const detail = classifyClaudeSdkError({ errors, subtype: event.subtype });\n // The turn billed even though it failed: carry its usage so a ledger\n // that only writes on `finished` can write here too. Unlike the finished\n // branch, no `costUsd: 0` fallback — an absent figure stays absent.\n return [\n {\n type: \"error\",\n message: `Agent stopped: ${event.subtype}${errors.length ? ` — ${errors.join(\"; \")}` : \"\"}`,\n fatal: event.subtype === \"error_during_execution\",\n category: detail.category,\n ...(detail.hint ? { hint: detail.hint } : {}),\n ...(typeof event.costUsd === \"number\" ? { costUsd: event.costUsd } : {}),\n ...usage,\n ...(event.selfStarted === true ? { selfStarted: true as const } : {}),\n },\n ];\n }\n\n // ---------------------------------------------------------------------------\n // Dev server detection\n // ---------------------------------------------------------------------------\n\n private detectDevServerStarting(command: string): NormalizedEvent | null {\n if (this.devServerStartingEmitted) return null;\n const cmd = command.toLowerCase();\n const isFrontendStart =\n (cmd.includes(\"pnpm run dev\") || cmd.includes(\"pnpm dev\") || cmd.includes(\"vite\")) &&\n (cmd.includes(\"frontend\") || cmd.includes(\"dev:preview\"));\n if (isFrontendStart) {\n this.devServerStartingEmitted = true;\n return { type: \"dev_server\", url: \"http://localhost:3000\", status: \"starting\" };\n }\n return null;\n }\n\n /** One `ready` event per URL in `text` not announced before in this session. */\n private detectDevServerReady(text: string): NormalizedEvent[] {\n const events: NormalizedEvent[] = [];\n for (const url of devServerReadyUrls(text)) {\n if (this.announcedDevServers.has(url)) continue;\n this.announcedDevServers.add(url);\n events.push({ type: \"dev_server\", url, status: \"ready\" });\n }\n return events;\n }\n\n // ---------------------------------------------------------------------------\n // Helpers\n // ---------------------------------------------------------------------------\n\n private getContentBlocks(message: AgentMessage): ContentBlock[] {\n if (Array.isArray(message.content)) return message.content;\n if (typeof message.content === \"string\" && message.content) {\n return [{ type: \"text\", text: message.content }];\n }\n return [];\n }\n}\n\nconst ESC = String.fromCharCode(27);\nconst BEL = String.fromCharCode(7);\n/**\n * CSI (`ESC [ … m`, cursor moves) and OSC (`ESC ] … BEL`, hyperlinks) escape sequences, plus\n * CSI written as the text `\\u001b[` / `\\x1b[`: a non-string tool result reaches the detector\n * JSON-encoded, which spells ESC out.\n */\nconst ANSI_ESCAPE = new RegExp(\n `(?:${ESC}|\\\\\\\\u001b|\\\\\\\\x1b)\\\\[[0-?]*[ -/]*[@-~]|${ESC}\\\\][^${BEL}${ESC}]*(?:${BEL}|${ESC}\\\\\\\\)`,\n \"g\",\n);\n\n/** A dev server's `Local:` line on a loopback host (Vite, Nuxt, Storybook, Next). */\nconst LOCAL_URL = /Local:\\s+(https?):\\/\\/(?:localhost|127\\.0\\.0\\.1|\\[::1\\]|0\\.0\\.0\\.0):(\\d+)\\/?/g;\nconst EXPLICIT_URL = /DEVSERVER_READY:(https?:\\/\\/[^\\s\"\\\\]+)/g;\n\n/**\n * The URLs a dev server's ready output announces, without duplicates; empty\n * when there are none. One output can hold several servers\n * (`concurrently \"vite\" \"storybook dev\"`, a combined log). Explicit\n * `DEVSERVER_READY:<url>` lines come first (a bare trailing `/` after the\n * port dropped, so it matches the `Local:` form), then every `Local:` line, after\n * stripping ANSI colours, on any loopback host, announced as `localhost` (what\n * a browser opens; `0.0.0.0` is not one). `FRONTEND_READY` →\n * `http://localhost:3000` only when neither is present. A `Network:` line (LAN\n * address) never matches.\n */\nfunction devServerReadyUrls(text: string): string[] {\n const explicit = [...text.matchAll(EXPLICIT_URL)].map((m) =>\n m[1]!.replace(/^(https?:\\/\\/[^/]+)\\/$/, \"$1\"),\n );\n const local = [...text.replace(ANSI_ESCAPE, \"\").matchAll(LOCAL_URL)].map(\n (m) => `${m[1]}://localhost:${m[2]}`,\n );\n const urls = [...new Set([...explicit, ...local])];\n if (urls.length > 0) return urls;\n return text.includes(\"FRONTEND_READY\") ? [\"http://localhost:3000\"] : [];\n}\n\n// ---------------------------------------------------------------------------\n// Pure helper functions (exported for reuse)\n// ---------------------------------------------------------------------------\n\n/**\n * Produce a human-readable one-line summary of a tool call for the activity log.\n *\n * Returns a string like `$ git status` for Bash, `Read src/index.ts` for Read, etc.\n * Falls back to `ToolName({...input...})` for unrecognised tools.\n *\n * @param tool - Tool name (e.g. `\"Bash\"`, `\"Write\"`, `\"Grep\"`).\n * @param input - Tool input record passed to the call.\n * @returns A short display string suitable for the activity feed.\n * @docLink packages/bridge/api-reference#normalizer\n */\nexport function summarizeToolCall(tool: string, input: Record<string, unknown>): string {\n // A harness that sent a bare value instead of named args has it under `input`.\n const arg = (key: string) => String(input[key] ?? input.input);\n switch (tool) {\n case \"Bash\":\n return `$ ${String(input.command ?? input.input ?? \"\").slice(0, 200)}`;\n case \"Write\":\n return `Create ${arg(\"file_path\")}`;\n case \"Edit\":\n return `Edit ${arg(\"file_path\")}`;\n case \"Read\":\n return `Read ${arg(\"file_path\")}`;\n case \"Glob\":\n return `Find ${arg(\"pattern\")}`;\n case \"Grep\":\n return `Search for ${arg(\"pattern\")}`;\n case \"ApplyPatch\": {\n // Paths only: stringifying the input would serialize every full diff.\n const changes = Array.isArray(input.changes) ? input.changes : [];\n const paths = changes\n .map((change) => (change as { path?: unknown } | null)?.path)\n .filter((path): path is string => typeof path === \"string\");\n return `Edit ${paths.join(\", \").slice(0, 200) || \"files\"}`;\n }\n default:\n return `${tool}(${JSON.stringify(input).slice(0, 100)})`;\n }\n}\n\n/**\n * Produce the plain-language label shown to non-technical users while a tool\n * call runs: the agent's own `activity_label`, Bash's `description`, else a\n * derived phrase for Claude Code built-ins. `undefined` for any other tool —\n * the UI then falls back to a generic \"working\" line rather than raw input.\n *\n * @param tool - Tool name as the model called it.\n * @param input - Tool input record, still carrying `activity_label`.\n * @returns A trimmed label capped at `TOOL_ACTIVITY_LABEL_MAX_CHARS`, or `undefined`.\n * @docLink packages/bridge/api-reference#normalizer\n */\nexport function labelToolCall(tool: string, input: Record<string, unknown>): string | undefined {\n const authored =\n nonEmpty(input[TOOL_ACTIVITY_LABEL_PARAM]) ??\n (tool === \"Bash\" ? nonEmpty(input.description) : undefined);\n const label = authored ?? builtinToolLabel(tool, input);\n if (!label) return undefined;\n return label.length > TOOL_ACTIVITY_LABEL_MAX_CHARS\n ? `${label.slice(0, TOOL_ACTIVITY_LABEL_MAX_CHARS - 1).trimEnd()}…`\n : label;\n}\n\nfunction nonEmpty(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.replace(/\\s+/g, \" \").trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction builtinToolLabel(tool: string, input: Record<string, unknown>): string | undefined {\n switch (tool) {\n case \"Read\":\n return withTarget(\"Reading\", baseName(input.file_path));\n case \"Edit\":\n case \"MultiEdit\":\n case \"NotebookEdit\":\n return withTarget(\"Editing\", baseName(input.file_path ?? input.notebook_path));\n case \"Write\":\n return withTarget(\"Creating\", baseName(input.file_path));\n case \"Grep\":\n case \"Glob\":\n return \"Searching files\";\n case \"WebSearch\":\n return \"Searching the web\";\n case \"WebFetch\":\n return withTarget(\"Fetching\", hostOf(input.url), \"a web page\");\n case \"TodoWrite\":\n return \"Updating the task list\";\n case \"ApplyPatch\":\n return \"Editing files\";\n default:\n return undefined;\n }\n}\n\nfunction withTarget(verb: string, target: string | undefined, fallback = \"a file\"): string {\n return `${verb} ${target ?? fallback}`;\n}\n\nfunction baseName(value: unknown): string | undefined {\n if (typeof value !== \"string\" || value.length === 0) return undefined;\n return value.split(/[\\\\/]/).filter(Boolean).pop();\n}\n\nfunction hostOf(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n try {\n return new URL(value).host || undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Extract plain text from an Anthropic content-block array (e.g. tool results returned by Claude SDK). */\nfunction extractContentBlockText(blocks: unknown[]): string | null {\n const textBlocks = blocks.filter(\n (b): b is { type: \"text\"; text: string } =>\n typeof b === \"object\" &&\n b !== null &&\n (b as Record<string, unknown>).type === \"text\" &&\n typeof (b as Record<string, unknown>).text === \"string\",\n );\n if (textBlocks.length === 0) return null;\n return textBlocks.map((b) => b.text).join(\"\\n\");\n}\n\n/**\n * Produce a human-readable one-line summary of a tool result for the activity log.\n *\n * Handles Bash stdout/stderr, Write/Edit file paths, ApplyPatch change counts, and\n * Anthropic content-block arrays. Falls back to `JSON.stringify` for unknown shapes.\n *\n * @param tool - Tool name.\n * @param result - Raw tool result payload.\n * @returns A short display string, truncated to 200 characters.\n * @docLink packages/bridge/api-reference#normalizer\n */\nexport function summarizeToolResult(tool: string, result: unknown): string {\n // Handle Anthropic content-block arrays: [{ type: \"text\", text: \"...\" }, ...]\n if (Array.isArray(result)) {\n const text = extractContentBlockText(result);\n return (text ?? JSON.stringify(result)).slice(0, 200);\n }\n if (typeof result !== \"object\" || !result) {\n return String(result).slice(0, 200);\n }\n const r = result as Record<string, unknown>;\n switch (tool) {\n case \"Bash\": {\n const stderr = String(r.stderr ?? \"\").trim();\n if (stderr) return `stderr: ${stderr.slice(0, 200)}`;\n return (\n String(r.stdout ?? \"\")\n .trim()\n .slice(0, 200) || \"(no output)\"\n );\n }\n case \"Write\":\n return `${String(r.type)}: ${String(r.filePath)}`;\n case \"Edit\":\n return `Edited ${String(r.filePath)}`;\n case \"ApplyPatch\":\n return `${Array.isArray(r.changes) ? r.changes.length : 0} file changes`;\n default:\n return JSON.stringify(result).slice(0, 200);\n }\n}\n\n/**\n * Detect file-change events from a tool result, returning zero or more `file_changed` events.\n *\n * Handles `Write` (single create/edit), `Edit` (single edit), and `ApplyPatch` (multi-file\n * patch with per-change `kind` classification). Returns an empty array for all other tools.\n *\n * @param toolName - Name of the tool that produced the result.\n * @param result - Raw tool result payload.\n * @returns Array of `file_changed` normalized events.\n * @docLink packages/bridge/api-reference#normalizer\n */\nexport function detectFileChanges(toolName: string, result: unknown): NormalizedEvent[] {\n if (typeof result !== \"object\" || !result) return [];\n const r = result as Record<string, unknown>;\n\n if (toolName === \"Write\" && r.filePath) {\n return [\n {\n type: \"file_changed\",\n path: String(r.filePath),\n action: r.type === \"create\" ? \"create\" : \"edit\",\n },\n ];\n }\n if (toolName === \"Edit\" && r.filePath) {\n return [{ type: \"file_changed\", path: String(r.filePath), action: \"edit\" }];\n }\n if (toolName === \"ApplyPatch\" && Array.isArray(r.changes)) {\n return r.changes\n .filter(\n (change): change is { path: string; kind: \"add\" | \"delete\" | \"update\" } =>\n typeof change === \"object\" &&\n change !== null &&\n typeof (change as Record<string, unknown>).path === \"string\" &&\n typeof (change as Record<string, unknown>).kind === \"string\",\n )\n .map((change) => ({\n type: \"file_changed\" as const,\n path: change.path,\n action: change.kind === \"add\" ? \"create\" : change.kind === \"delete\" ? \"delete\" : \"edit\",\n }));\n }\n\n return [];\n}\n\n/**\n * Backward-compatible single-event helper; returns the first `file_changed` event or `null`.\n *\n * Prefer {@link detectFileChanges} for multi-file patches (e.g. `ApplyPatch`).\n *\n * @param toolName - Name of the tool that produced the result.\n * @param result - Raw tool result payload.\n * @returns First detected `file_changed` event, or `null`.\n * @docLink packages/bridge/api-reference#normalizer\n */\nexport function detectFileChange(toolName: string, result: unknown): NormalizedEvent | null {\n return detectFileChanges(toolName, result)[0] ?? null;\n}\n","/**\n * BridgeRuntime — implements IAgentRuntime from @skaile/workspaces/types by wrapping\n * an AgentHarness + EventNormalizer. This is the primary integration point for\n * consumers that want normalized events from any harness.\n */\n\nimport type {\n AgentEvent,\n AgentPromptInput,\n AgentReconfigureOptions,\n AgentRuntimeConfig,\n IAgentRuntime,\n} from \"@skaile/workspaces/types\";\n\nimport { EventNormalizer } from \"./normalizer.js\";\nimport { toMergedRegistry } from \"./provider-registry-derive.js\";\nimport { createHarness } from \"./registry.js\";\nimport type { AgentConfig, AgentHarness } from \"./types.js\";\n\n/**\n * Implements `IAgentRuntime` from `@skaile/workspaces/types` by wrapping an {@link AgentHarness}\n * and an {@link EventNormalizer}.\n *\n * This is the primary integration point for consumers that want normalized `AgentEvent`\n * payloads from any harness without managing the harness lifecycle directly. Create via\n * {@link createRuntime} to avoid coupling to `BridgeRuntime` directly.\n *\n * @docLink packages/bridge/api-reference#runtime\n */\nexport class BridgeRuntime implements IAgentRuntime {\n private harness: AgentHarness | null = null;\n private normalizer = new EventNormalizer();\n private handlers = new Set<(event: AgentEvent) => void>();\n private boundEventHandler: ((event: any) => void) | null = null;\n private harnessId: string;\n\n constructor(harnessId: string = \"claude-sdk\") {\n this.harnessId = harnessId;\n }\n\n async start(config: AgentRuntimeConfig): Promise<void> {\n // Dispose previous harness if any\n if (this.harness) {\n await this.dispose();\n }\n\n this.normalizer.reset();\n\n const bridgeConfig: AgentConfig = {\n cwd: config.cwd,\n model: config.model,\n systemPrompt: config.systemPrompt,\n env: config.env,\n agentDir: config.agentDir,\n sessionId: config.sessionId,\n resumeSessionId: config.resumeSessionId,\n maxTurns: config.maxTurns,\n ...(config.registry ? { registry: toMergedRegistry(config.registry, \"runtime\") } : {}),\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n };\n\n this.harness = await createHarness(this.harnessId, bridgeConfig);\n\n // Wire bridge events through normalizer to handlers\n this.boundEventHandler = (bridgeEvent: any) => {\n const normalized = this.normalizer.normalize(bridgeEvent);\n for (const event of normalized) {\n for (const handler of this.handlers) {\n handler(event);\n }\n }\n };\n this.harness.on(\"agent-event\", this.boundEventHandler);\n\n await this.harness.start();\n }\n\n async configure(_config: AgentReconfigureOptions): Promise<void> {\n // Runtime reconfiguration for BridgeRuntime is a no-op for now.\n // Future: reconnect connectors, reload ai-assets, update subagents.\n }\n\n async prompt(message: string): Promise<void> {\n if (!this.harness) throw new Error(\"Runtime not started — call start() first\");\n await this.harness.prompt(message);\n }\n\n async promptInput(input: AgentPromptInput): Promise<void> {\n if (!this.harness) throw new Error(\"Runtime not started — call start() first\");\n await this.harness.promptInput(input);\n }\n\n async reply(answer: string, question?: string, requestId?: string): Promise<void> {\n if (!this.harness) throw new Error(\"Runtime not started — call start() first\");\n // Mirror serve.ts handleReply: an answer must resume the paused turn. Falling through to\n // prompt() would deny the question as superseded and drop the structured answer.\n if (\n this.harness?.hasPendingQuestion() &&\n this.harness.answerQuestion(answer, question, requestId)\n )\n return;\n if (this.harness?.acceptsReplyAsPrompt) await this.prompt(answer);\n }\n\n async abort(): Promise<void> {\n if (this.harness) {\n await this.harness.abort();\n }\n }\n\n async dispose(): Promise<void> {\n if (this.harness) {\n if (this.boundEventHandler) {\n this.harness.off(\"agent-event\", this.boundEventHandler);\n this.boundEventHandler = null;\n }\n this.harness.kill();\n this.harness = null;\n }\n this.normalizer.reset();\n }\n\n onEvent(handler: (event: AgentEvent) => void): void {\n this.handlers.add(handler);\n }\n\n offEvent(handler: (event: AgentEvent) => void): void {\n this.handlers.delete(handler);\n }\n\n get isRunning(): boolean {\n return this.harness?.isRunning ?? false;\n }\n}\n\n/**\n * Factory function to create a {@link BridgeRuntime} with the specified harness.\n *\n * @param harnessId - Registered harness id (default: `\"claude-sdk\"`).\n * @returns A new `IAgentRuntime` wrapping the selected harness with event normalization.\n * @docLink packages/bridge/api-reference#runtime\n */\nexport function createRuntime(harnessId: string = \"claude-sdk\"): IAgentRuntime {\n return new BridgeRuntime(harnessId);\n}\n","/** Provider API key validation — hits each provider's models endpoint to verify the key works. */\n\nimport {\n buildCredentialHeaders,\n expandPreset,\n getProviderPreset,\n resolvePresetBaseUrl,\n resolveProbeUrl,\n} from \"./provider-catalog.js\";\n\n/**\n * Result of an API key validation check performed by {@link validateApiKey}.\n *\n * @docLink packages/bridge/api-reference#validation\n */\nexport interface ValidationResult {\n /** `true` when the API key was accepted by the provider's models endpoint. */\n ok: boolean;\n /** Human-readable error description when `ok` is `false`. */\n error?: string;\n}\n\n/**\n * Validate an API key by sending a lightweight GET request to the provider's models endpoint.\n *\n * Returns `{ ok: true }` when the provider accepts the key (HTTP 2xx). Returns\n * `{ ok: false, error }` on 401/403 (invalid key), other HTTP errors, network failures,\n * or unsupported providers. Requests time out after 8 seconds.\n *\n * @param provider - Catalog preset id (e.g. `\"anthropic\"`, `\"openai\"`, `\"google\"`).\n * @param key - API key to validate.\n * @param options - Optional base-URL / environment overrides; defaults to the\n * provider's own API, or its `base_url_env` value when one is set.\n * @returns Validation result with optional error description.\n * @docLink packages/bridge/api-reference#validation\n */\nexport async function validateApiKey(\n provider: string,\n key: string,\n options: { baseUrl?: string; env?: Record<string, string | undefined> } = {},\n): Promise<ValidationResult> {\n const preset = getProviderPreset(provider);\n if (!preset) return { ok: false, error: `Unknown provider: ${provider}` };\n\n // Validate against the same endpoint discovery/dispatch use: behind a gateway\n // the key is the gateway's, and the provider's public API would reject it.\n const baseUrl = resolvePresetBaseUrl(preset, {\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n env: options.env ?? process.env,\n });\n const entry = expandPreset(preset, baseUrl ? { baseUrl } : {});\n const url = resolveProbeUrl(entry);\n if (!url) return { ok: false, error: `Provider ${provider} exposes no models endpoint` };\n // Static non-secret headers (Anthropic's `anthropic-version`) plus the\n // credential carrier the preset's `auth_header` names.\n const headers = { ...entry.headers, ...buildCredentialHeaders(entry, key) };\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 8000);\n\n const response = await fetch(url, {\n method: \"GET\",\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeout);\n\n if (response.ok) return { ok: true };\n\n const status = response.status;\n if (status === 401 || status === 403) {\n return { ok: false, error: \"Invalid API key (authentication failed)\" };\n }\n return { ok: false, error: `API returned HTTP ${status}` };\n } catch (err: any) {\n if (err.name === \"AbortError\") return { ok: false, error: \"Request timed out (8s)\" };\n return { ok: false, error: err.message ?? \"Network error\" };\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveAgentExec } from './chunk-7DN6JKP2.js';
|
|
2
|
-
import { BUILTIN_HARNESS_CATALOG } from './chunk-
|
|
2
|
+
import { BUILTIN_HARNESS_CATALOG } from './chunk-XON6ODIC.js';
|
|
3
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';
|
|
@@ -563,11 +563,13 @@ function sessionSurfaceNotice(registry, modelRef) {
|
|
|
563
563
|
const named = modelRef?.trim();
|
|
564
564
|
if (!named) return void 0;
|
|
565
565
|
const entries = registryEntries(registry);
|
|
566
|
-
const
|
|
566
|
+
const parsed = entries.some(([id]) => id === named) ? void 0 : parseModelRef(named, registry);
|
|
567
|
+
if (parsed?.fallback) return void 0;
|
|
568
|
+
const providerId = entries.some(([id]) => id === named) ? named : parsed?.providerId;
|
|
567
569
|
const entry = entries.find(([id]) => id === providerId)?.[1];
|
|
568
570
|
return providerId && entry ? unsupportedSurfaceNotice(providerId, entry) : void 0;
|
|
569
571
|
}
|
|
570
572
|
|
|
571
573
|
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-
|
|
574
|
+
//# sourceMappingURL=chunk-HPXONAI2.js.map
|
|
575
|
+
//# sourceMappingURL=chunk-HPXONAI2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../bridge/src/approval-card.ts","../bridge/src/cloud.ts","../bridge/src/harnesses/scrub-transcript.ts","../bridge/src/harnesses/resume-probe.ts","../bridge/src/agent-transcript.ts","../bridge/src/claude-sdk-surface.ts"],"names":["join"],"mappings":";;;;;;;;;;;;AAUO,IAAM,YAAA,GAAe;AAErB,IAAM,IAAA,GAAO;AAab,SAAS,eAAe,KAAA,EAA6C;AAC1E,EAAA,IAAI,KAAA,CAAM,IAAA,KAAS,eAAA,IAAmB,CAAC,KAAA,CAAM,QAAQ,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG,OAAO,MAAA;AACpF,EAAA,KAAA,MAAW,KAAA,IAAS,KAAA,CAAM,OAAA,CAAQ,OAAA,EAAS;AACzC,IAAA,IAAI,KAAA,CAAM,IAAA,KAAS,UAAA,IAAc,KAAA,CAAM,SAAS,iBAAA,EAAmB;AACnE,IAAA,MAAM,QAAQ,KAAA,CAAM,KAAA;AACpB,IAAA,MAAM,WAAW,KAAA,EAAO,QAAA;AACxB,IAAA,MAAM,YAAY,KAAA,EAAO,SAAA;AACzB,IAAA,MAAM,QAAQ,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,GAAK,SAAA,CAAU,CAAC,CAAA,GAA+B,MAAA;AACpF,IAAA,IACE,CAAC,YACD,OAAO,KAAA,EAAO,aAAa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AAQ,CAAA;AAGxC,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,EAAE,CAAA,KAAM,EAAA,KAAO,KAAK,CAAA,GAAI,MAAA,GAAY,aAAA,CAAc,OAAO,QAAQ,CAAA;AAC/F,EAAA,IAAI,MAAA,EAAQ,UAAU,OAAO,MAAA;AAC7B,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,EAAE,CAAA,KAAM,EAAA,KAAO,KAAK,CAAA,GAAI,KAAA,GAAQ,MAAA,EAAQ,UAAA;AAC1E,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,EAAE,CAAA,KAAM,EAAA,KAAO,UAAU,CAAA,GAAI,CAAC,CAAA;AAC3D,EAAA,OAAO,UAAA,IAAc,KAAA,GAAQ,wBAAA,CAAyB,UAAA,EAAY,KAAK,CAAA,GAAI,MAAA;AAC7E","file":"chunk-HPXONAI2.js","sourcesContent":["/**\n * The tool-approval card a harness raises for `permissionMode: \"interactive\"`: a `message_start`\n * carrying an `AskUserQuestion` tool call whose input has an `approval` description. The\n * normalizer turns it into a `question` event with `approval`; a host that reads the harness's\n * events directly (the REPL, a single-shot run) recognises it with {@link approvalCardOf} and\n * answers with {@link APPROVE_ONCE} or {@link DENY} through `harness.answerQuestion`.\n */\nimport type { AgentEvent } from \"./types.js\";\n\n/** The one positive answer of an approval card. */\nexport const APPROVE_ONCE = \"Approve once\";\n/** The negative answer of an approval card. */\nexport const DENY = \"Deny\";\n\n/** What a host needs to ask and answer one approval card. */\nexport interface ApprovalCard {\n /** The question text; the key `answerQuestion` takes. */\n question: string;\n requestId?: string;\n kind: \"command\" | \"file\" | \"permissions\" | \"mcp\";\n /** Bounded plain text of what the tool call is about to do. */\n details: string[];\n}\n\n/** The approval card an event carries, else `undefined`. */\nexport function approvalCardOf(event: AgentEvent): ApprovalCard | undefined {\n if (event.type !== \"message_start\" || !Array.isArray(event.message.content)) return undefined;\n for (const block of event.message.content) {\n if (block.type !== \"tool_use\" || block.name !== \"AskUserQuestion\") continue;\n const input = block.input as Record<string, unknown> | undefined;\n const approval = input?.approval as { kind?: unknown; details?: unknown } | undefined;\n const questions = input?.questions;\n const first = Array.isArray(questions) ? (questions[0] as { question?: unknown }) : undefined;\n if (\n !approval ||\n typeof first?.question !== \"string\" ||\n !Array.isArray(approval.details) ||\n !approval.details.every((d) => typeof d === \"string\")\n ) {\n continue;\n }\n return {\n question: first.question,\n ...(typeof input?.requestId === \"string\" ? { requestId: input.requestId } : {}),\n kind: approval.kind as ApprovalCard[\"kind\"],\n details: approval.details as string[],\n };\n }\n return undefined;\n}\n","/**\n * AI endpoint transport for the `claude-sdk` harness — the Claude Agent SDK's\n * child-process environment.\n *\n * {@link buildClaudeEndpointEnv} takes an **AI provider registry entry** and\n * is what the harness calls, on every transport. It is plan §2.3's\n * `buildEndpointEnv` for the claude-sdk row (named for the harness because the\n * vars it emits — `CLAUDE_CODE_USE_*`, `ANTHROPIC_*` — are the Claude Agent\n * SDK's own contract, not a portable one).\n *\n * A registry entry says what the deleted `cloud` axis said — Amazon Bedrock,\n * Google Vertex AI, Azure AI Foundry, a generic gateway — with `surface` +\n * `transport` + `base_url` + `credential`, and says it for the direct\n * endpoint too, which the `cloud` axis could not address at all.\n *\n * Cross-repo contract: env key names and semantics here are load-bearing —\n * the platform resolves credential bundles against the same key set.\n */\n\nimport {\n type AIProviderEntry,\n type AIProviderLlmEntry,\n entryTransport,\n normalizeAnthropicBaseUrl,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\n\n/**\n * Env vars scrubbed from the inherited environment before an endpoint env is\n * assembled. Ambient first-party credentials or a stale `CLAUDE_CODE_USE_*`\n * flag must never leak into a session whose entry points elsewhere (the\n * ambient carriers are restored explicitly when the entry has none of its\n * own).\n *\n * Deliberately NOT exhaustive: ambient transport-specific vars (AWS_*,\n * GOOGLE_*, ANTHROPIC_VERTEX_PROJECT_ID, ANTHROPIC_FOUNDRY_*) survive so a\n * standalone CLI inherits its own signing chain; the SDK ignores vars whose\n * transport flag is unset.\n */\nconst SCRUBBED_ENV_KEYS = [\"ANTHROPIC_API_KEY\", \"ANTHROPIC_AUTH_TOKEN\", \"ANTHROPIC_BASE_URL\"];\n\n/**\n * The Anthropic first-party endpoint. An entry that resolves to exactly this\n * host needs no `ANTHROPIC_BASE_URL`: the SDK already points there, and an\n * explicit value would make every default session look like a third-party\n * redirect to Claude Code's own telemetry and auth heuristics.\n */\nexport const ANTHROPIC_DEFAULT_BASE_URL = \"https://api.anthropic.com\";\n\n/**\n * Headers the SDK owns and an entry must not restate through\n * `ANTHROPIC_CUSTOM_HEADERS`: the protocol version it was built against, and\n * the two credential carriers (which are `credential.ref`'s job — a literal\n * secret in `headers` is a validation error anyway).\n */\nconst SDK_OWNED_HEADERS: Record<string, true> = {\n \"anthropic-version\": true,\n authorization: true,\n \"x-api-key\": true,\n};\n\n/**\n * Which of the Claude Agent SDK's four native transports an entry addresses.\n *\n * The SDK has no `transport` field: it switches on a `CLAUDE_CODE_USE_*` flag.\n * Bedrock and Vertex are their own wire surfaces, so they are recognized by\n * `surface` as well as by `transport` — a legacy-derived entry that had no\n * region (and therefore no `params`, and therefore no `transport`) is still a\n * Bedrock session, exactly as it was before the registry existed.\n */\nexport type ClaudeEndpointMode = \"anthropic\" | \"bedrock\" | \"vertex\" | \"foundry\";\n\n/** Classify a registry entry into its {@link ClaudeEndpointMode}. */\nexport function claudeEndpointMode(entry: AIProviderEntry): ClaudeEndpointMode {\n const surface = (entry as AIProviderLlmEntry).surface;\n const transport = entryTransport(entry);\n if (surface === \"bedrock-converse-stream\" || transport === \"bedrock\") return \"bedrock\";\n if (surface === \"google-vertex\" || transport === \"vertex\") return \"vertex\";\n if (transport === \"foundry\") return \"foundry\";\n return \"anthropic\";\n}\n\n/** Arguments for {@link buildClaudeEndpointEnv}. */\nexport interface ClaudeEndpointEnvInput {\n /** The selected registry entry — the whole endpoint definition. */\n entry: AIProviderEntry;\n /**\n * The entry's credential, already resolved from its `credential.ref`\n * (`resolveEntryCredential`). Absent for `kind: none`, for an ambient\n * `sigv4` / `google_adc` / `azure_entra` chain, for `oauth` (whose blob the\n * runner writes to the Claude credentials file, never to the env), and for a\n * reference that did not resolve.\n */\n credential?: string;\n /**\n * The harness's base environment — `process.env` with `undefined` dropped.\n * The endpoint vars are layered **on top** of it, never instead of it, so\n * `PATH`, `HOME` and `SKAILE_SESSION_ID` reach the child.\n */\n baseEnv: Record<string, string>;\n /** `AgentConfig.env` plus any credential material the session carried. */\n configEnv?: Record<string, string>;\n}\n\n/**\n * Assemble the Claude Agent SDK child env for one registry entry (plan §2.3).\n *\n * Pure (no external state read, no input mutated). Starts from `baseEnv`\n * merged with `configEnv`, scrubs the inherited Anthropic credential/routing\n * vars and every `CLAUDE_CODE_USE_*` flag, then writes exactly what the entry\n * describes: at most one transport flag, the endpoint, and the credential in\n * the carrier its `kind` names.\n *\n * Credential kinds (§1.4): `api_key_header` → `ANTHROPIC_API_KEY` (the SDK\n * sends it as `x-api-key`); `bearer` → `ANTHROPIC_AUTH_TOKEN` (sent as\n * `Authorization: Bearer`); `sigv4` / `google_adc` / `azure_entra` emit\n * nothing and let the AWS/Google/Azure chain sign — which is why the scrub\n * deliberately spares ambient `AWS_*` / `GOOGLE_*` values; `oauth` and `none`\n * emit nothing, and the pre-scrub ambient carriers are restored so an OAuth or\n * shell-configured session keeps the auth it had.\n *\n * Never returns `undefined` or empty values; absent settings are omitted.\n */\nexport function buildClaudeEndpointEnv(args: ClaudeEndpointEnvInput): Record<string, string> {\n const { entry, credential, baseEnv, configEnv } = args;\n const env: Record<string, string> = { ...baseEnv, ...(configEnv ?? {}) };\n\n // Captured before the scrub — an entry with no credential material of its\n // own falls back to these, the way the gateway branch always has.\n const ambient = { authToken: env.ANTHROPIC_AUTH_TOKEN, apiKey: env.ANTHROPIC_API_KEY };\n\n for (const key of Object.keys(env)) {\n if (SCRUBBED_ENV_KEYS.includes(key) || key.startsWith(\"CLAUDE_CODE_USE_\")) {\n delete env[key];\n }\n }\n\n const set = (key: string, value: string | undefined) => {\n // Falsy check is deliberate: an empty-string credential/setting is never\n // valid env — dropping it beats shipping a key the SDK treats as set.\n if (value) env[key] = value;\n };\n\n const kind = entry.credential?.kind ?? \"none\";\n const params = (entry as AIProviderLlmEntry).params as Record<string, string> | undefined;\n\n // Static headers ride as ANTHROPIC_CUSTOM_HEADERS (`Name: Value` per line),\n // the only channel the SDK offers. An entry with none leaves an ambient\n // value alone.\n const headers = Object.entries(entry.headers ?? {}).filter(\n ([name]) => !SDK_OWNED_HEADERS[name.toLowerCase()],\n );\n if (headers.length > 0) {\n env.ANTHROPIC_CUSTOM_HEADERS = headers.map(([name, value]) => `${name}: ${value}`).join(\"\\n\");\n }\n\n switch (claudeEndpointMode(entry)) {\n case \"bedrock\": {\n env.CLAUDE_CODE_USE_BEDROCK = \"1\";\n // The AWS credential bundle itself is `configEnv` material (AWS_*), and\n // ambient AWS_* survived the scrub, so a standalone CLI keeps its own.\n set(\"AWS_REGION\", params?.region);\n break;\n }\n case \"vertex\": {\n env.CLAUDE_CODE_USE_VERTEX = \"1\";\n // GOOGLE_APPLICATION_CREDENTIALS is a path the runner materialized; it\n // arrives through `configEnv` or ambient, never from `credential`.\n set(\"ANTHROPIC_VERTEX_PROJECT_ID\", params?.project);\n set(\"CLOUD_ML_REGION\", params?.location);\n break;\n }\n case \"foundry\": {\n env.CLAUDE_CODE_USE_FOUNDRY = \"1\";\n // §1.3: an explicit `base_url` wins over the resource-derived endpoint,\n // and the SDK has a separate var for each form.\n if (entry.base_url) set(\"ANTHROPIC_FOUNDRY_BASE_URL\", entry.base_url);\n else set(\"ANTHROPIC_FOUNDRY_RESOURCE\", params?.resource);\n set(\"ANTHROPIC_FOUNDRY_API_KEY\", credential);\n break;\n }\n case \"anthropic\": {\n const baseUrl = normalizeAnthropicBaseUrl(resolveEntryBaseUrl(entry));\n if (baseUrl && baseUrl.toLowerCase() !== ANTHROPIC_DEFAULT_BASE_URL) {\n env.ANTHROPIC_BASE_URL = baseUrl;\n }\n if (kind === \"bearer\") set(\"ANTHROPIC_AUTH_TOKEN\", credential);\n else if (kind === \"api_key_header\") set(\"ANTHROPIC_API_KEY\", credential);\n if (!credential) {\n // `oauth` / `none` / an unresolved ref: the ambient carriers are the\n // only auth this session has, and the scrub just removed them.\n if (ambient.authToken) env.ANTHROPIC_AUTH_TOKEN = ambient.authToken;\n else set(\"ANTHROPIC_API_KEY\", ambient.apiKey);\n }\n break;\n }\n }\n\n return env;\n}\n","/**\n * Poisoned-transcript repair for the Claude Agent SDK harness.\n *\n * The Anthropic Messages API can permanently reject a conversation once its\n * persisted history contains a malformed content block. Because the bad block\n * lives in the SDK's on-disk JSONL transcript, every replayed turn fails with\n * the same `400 invalid_request_error` and the session is bricked with no\n * in-band recovery.\n *\n * This module repairs the transcript in place, covering three known poison\n * classes:\n *\n * 1. **Image `media_type` mismatch / omission.** An image block whose declared\n * `media_type` does not match — or is missing for — the actual bytes:\n * `... The image was specified using the image/png media type, but the\n * image appears to be a image/jpeg image`. Produced by the Claude Code\n * `Read` tool's format fallback (anthropics/claude-code#55338, #30124,\n * #33179). Repaired by sniffing the base64 magic bytes and correcting\n * `media_type`.\n * 2. **Oversized image.** An image whose decoded payload exceeds the API's\n * 5 MB per-image limit (anthropics/claude-code#34566). Replaced with a\n * text stub — the byte budget cannot be recovered any other way.\n * 3. **`cache_control` on an empty text block.** A text block carrying a\n * `cache_control` marker with empty/whitespace `text`\n * (anthropics/claude-code#59626). The `cache_control` field is stripped.\n *\n * Genuinely unidentifiable image blocks are also replaced with a text stub.\n *\n * Recovering by content scan (rather than parsing the API's `messages.N`\n * index) is deliberate: the index addresses the assembled API request, not a\n * JSONL line, and reproducing the SDK's message-assembly is fragile. A full\n * scan is index-free and repairs every poisoned block in one pass.\n *\n * **Async and line-streaming since #454.** A Claude Code transcript is routinely\n * multi-megabyte (base64 images inline in `tool_result` blocks), and this runs on\n * a failed turn *and before every resume* — inside the single-threaded `skaile\n * serve` loop. The previous `readFileSync` + `writeFileSync` + `renameSync` held\n * the loop for the whole file and materialised it twice over as one string. Both\n * passes now stream line by line off a `createReadStream`, so the loop is yielded\n * between lines and peak memory is one JSONL line rather than the whole file, and\n * every I/O phase is deadline-bounded.\n *\n * Streaming was chosen over a worker thread: the work is I/O-bound rather than\n * CPU-bound (per-line `JSON.parse` on a yielded loop is not what stalls a turn),\n * and a worker would add a structured-clone of the same multi-MB payload plus a\n * thread lifecycle to a path that must never block a turn.\n *\n * @module\n */\n\nimport { createReadStream, createWriteStream } from \"node:fs\";\nimport { readdir, rename, stat, unlink } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { fsDeadlineMs, tryWithFsDeadline, withFsDeadline } from \"@skaile/workspaces/core\";\n\n/**\n * Minimal logger shape accepted by {@link scrubPoisonedTranscript}. Compatible\n * with the bridge `Logger`, but narrowed so the helper stays unit-testable\n * without a real logger instance.\n *\n * @category Transcript repair\n */\nexport interface ScrubLogger {\n info(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n}\n\n/**\n * Options for {@link scrubPoisonedTranscript}.\n *\n * @category Transcript repair\n */\nexport interface ScrubTranscriptOptions {\n /**\n * Claude Code config directory — the parent of `projects/`. Resolve from\n * `CLAUDE_CONFIG_DIR`, falling back to `~/.claude`.\n */\n configDir: string;\n /** SDK session id whose transcript JSONL should be repaired. */\n sessionId: string;\n /** Optional logger for diagnostics. */\n log?: ScrubLogger;\n /**\n * Where the transcript is read and written. Defaults to this process's own\n * filesystem access ({@link localTranscriptStore}); with the agent uid split\n * the transcript belongs to the agent uid and must be reached through it.\n */\n store?: TranscriptStore;\n}\n\n/**\n * Filesystem access to Claude Code transcripts. The CLI creates them 0600 in\n * 0700 dirs, so when it runs as a different uid than the runner, only that uid\n * can locate, read or rewrite them (see `agent-transcript.ts`).\n *\n * @category Transcript repair\n */\nexport interface TranscriptStore {\n /** Path of `<sessionId>.jsonl` under `<configDir>/projects/`, or `null` when absent. */\n locate(configDir: string, sessionId: string, timeoutMs?: number): Promise<string | null>;\n /** The file's contents as UTF-8 chunks. */\n read(filePath: string): AsyncIterable<string>;\n /** Atomically replace the file with `chunks` via a `.scrub-tmp` sibling. */\n replace(filePath: string, chunks: AsyncIterable<string>): Promise<void>;\n /** Remove the sibling a failed or abandoned {@link replace} left (best effort). */\n discardTemp(filePath: string): Promise<void>;\n}\n\n/**\n * Outcome of a {@link scrubPoisonedTranscript} pass.\n *\n * @category Transcript repair\n */\nexport interface ScrubTranscriptResult {\n /** The located JSONL transcript path, or `null` when not found. */\n filePath: string | null;\n /** Image blocks whose `media_type` was corrected (or filled in) to match the bytes. */\n corrected: number;\n /**\n * Image blocks replaced with a text stub — either unidentifiable bytes or a\n * payload over the API's 5 MB per-image limit.\n */\n stubbed: number;\n /** Empty text blocks from which a rejected `cache_control` marker was stripped. */\n cacheStripped: number;\n /**\n * `true` when the transcript was located, contained at least one poisoned\n * block, and was rewritten. `false` means nothing needed repair (or the\n * file was not found) — the caller should not retry the resume.\n */\n changed: boolean;\n /**\n * The last valid `cost-state` entry of this session, read during the same\n * pass. The CLI restores its run totals from it on `--resume`, so it is the\n * baseline of the resumed spawn's first `total_cost_usd` and `modelUsage`.\n * `null` when the transcript holds none (the CLI then starts from zero) or\n * could not be read.\n */\n costState: TranscriptCostState | null;\n}\n\n/**\n * The run totals the Claude Code CLI saves into a transcript as a\n * `{\"type\":\"cost-state\"}` entry and restores on `--resume`.\n *\n * @category Transcript repair\n */\nexport interface TranscriptCostState {\n /** The CLI's run-cumulative `total_cost_usd` at the time of the save. */\n totalCostUSD: number;\n /** The CLI's run-cumulative per-model usage, keyed by model id, in SDK field names. */\n modelUsage: Record<string, Record<string, number>>;\n}\n\n/** Text inserted in place of an image block whose format cannot be identified. */\nconst STUB_TEXT = \"[image removed: unprocessable image data]\";\n\n/** Text inserted in place of an image block that exceeds the API size limit. */\nconst STUB_TEXT_OVERSIZED = \"[image removed: image too large]\";\n\n/**\n * The Anthropic Messages API rejects any single image whose decoded payload\n * exceeds 5 MB. An image at or under this is left alone; a larger one is\n * stubbed (its byte budget cannot be recovered).\n */\nconst MAX_IMAGE_BYTES = 5 * 1024 * 1024;\n\n/**\n * Identify an image's media type from the leading bytes of its base64 payload.\n *\n * Recognises the four formats the Anthropic API accepts. Returns `null` when\n * the magic bytes match no known format — the caller treats that as a\n * genuinely corrupt block and stubs it.\n *\n * @param base64 - Base64-encoded image data (only the prefix is inspected).\n * @returns An `image/*` media type, or `null` when unrecognised.\n * @category Transcript repair\n */\nexport function sniffImageMediaType(base64: string): string | null {\n let buf: Buffer;\n try {\n // 32 base64 chars decode to 24 bytes — enough for the WebP check at 12.\n buf = Buffer.from(base64.slice(0, 32), \"base64\");\n } catch {\n return null;\n }\n if (buf.length < 4) {\n return null;\n }\n // JPEG — SOI marker `FF D8`. Third byte varies (and may be corrupt), so a\n // two-byte check is intentional: it still matches malformed JPEGs, which is\n // exactly the poison case the API flags as \"appears to be image/jpeg\".\n if (buf[0] === 0xff && buf[1] === 0xd8) {\n return \"image/jpeg\";\n }\n // PNG — `89 50 4E 47`.\n if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47) {\n return \"image/png\";\n }\n // GIF — `47 49 46 38` (\"GIF8\").\n if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x38) {\n return \"image/gif\";\n }\n // WebP — `RIFF` at 0..3 and `WEBP` at 8..11.\n if (\n buf.length >= 12 &&\n buf[0] === 0x52 &&\n buf[1] === 0x49 &&\n buf[2] === 0x46 &&\n buf[3] === 0x46 &&\n buf[8] === 0x57 &&\n buf[9] === 0x45 &&\n buf[10] === 0x42 &&\n buf[11] === 0x50\n ) {\n return \"image/webp\";\n }\n return null;\n}\n\n/** A base64 image source on a content block (shape is SDK-defined). */\ninterface Base64ImageSource {\n type?: string;\n media_type?: string;\n data?: string;\n}\n\n/** Loosely-typed content block from a transcript message. */\ninterface ContentBlockLike {\n type?: string;\n source?: Base64ImageSource;\n content?: unknown;\n [k: string]: unknown;\n}\n\n/** Mutable counters threaded through one scrub pass. */\ninterface ScrubCounters {\n corrected: number;\n stubbed: number;\n cacheStripped: number;\n}\n\n/** Total repairs recorded in a counter set — used to detect per-line changes. */\nfunction totalChanges(c: ScrubCounters): number {\n return c.corrected + c.stubbed + c.cacheStripped;\n}\n\n/**\n * Repair a single content block. Returns the (possibly replaced) block.\n *\n * - A `tool_result` block recurses into its `content` array.\n * - A text block carrying a `cache_control` marker whose `text` is empty or\n * whitespace has the marker stripped (the API rejects `cache_control` on\n * empty text blocks).\n * - An image block whose decoded payload exceeds the API's 5 MB limit is\n * replaced with a text stub.\n * - An image block whose bytes match no known format is replaced with a text\n * stub (an image cannot simply be dropped — a `tool_result` must keep at\n * least one content entry, and a bare `image` block is replaced 1:1).\n * - An image block whose declared `media_type` mismatches (or is missing for)\n * the sniffed type is corrected in place.\n * - Every other block is returned untouched.\n */\nfunction scrubBlock(block: ContentBlockLike, counters: ScrubCounters): ContentBlockLike {\n if (block.type === \"tool_result\" && Array.isArray(block.content)) {\n return {\n ...block,\n content: (block.content as ContentBlockLike[]).map((inner) => scrubBlock(inner, counters)),\n };\n }\n\n // A `cache_control` marker on a text block whose text is empty or whitespace\n // is rejected by the API (\"cache_control cannot be set for empty text\n // blocks\"). Strip the marker — the empty block itself is harmless.\n if (block.type === \"text\" && block.cache_control != null) {\n const text = typeof block.text === \"string\" ? block.text : \"\";\n if (text.trim() === \"\") {\n counters.cacheStripped++;\n const clone = { ...block };\n delete clone.cache_control;\n return clone;\n }\n }\n\n if (\n block.type === \"image\" &&\n block.source?.type === \"base64\" &&\n typeof block.source.data === \"string\"\n ) {\n const data = block.source.data;\n // The API rejects any image whose decoded payload exceeds 5 MB. The byte\n // budget cannot be salvaged, so the whole block becomes a text stub.\n // base64 encodes 3 bytes per 4 chars, so decoded length ≈ len * 3 / 4.\n if (Math.floor((data.length * 3) / 4) > MAX_IMAGE_BYTES) {\n counters.stubbed++;\n return { type: \"text\", text: STUB_TEXT_OVERSIZED };\n }\n const sniffed = sniffImageMediaType(data);\n if (sniffed === null) {\n counters.stubbed++;\n return { type: \"text\", text: STUB_TEXT };\n }\n if (sniffed !== block.source.media_type) {\n counters.corrected++;\n return { ...block, source: { ...block.source, media_type: sniffed } };\n }\n }\n\n return block;\n}\n\n/**\n * Locate the JSONL transcript for `sessionId` under `<configDir>/projects/`.\n *\n * Claude Code encodes the project directory into the `projects/` subfolder\n * name; rather than reproduce that encoding, this scans every subfolder for\n * `<sessionId>.jsonl` (the session id is a UUID — globally unique).\n *\n * Async and deadline-bounded since #454. The `existsSync(projectsDir)` probe is\n * gone: `readdir` already fails on a missing directory, so the probe was a\n * second stat on the same path for no information.\n *\n * `timeoutMs` defaults to {@link fsDeadlineMs} so callers that only need the\n * path (the resume probe) can omit it.\n *\n * @category Transcript repair\n */\nexport async function locateTranscriptPath(\n configDir: string,\n sessionId: string,\n timeoutMs: number = fsDeadlineMs(),\n): Promise<string | null> {\n const projectsDir = join(configDir, \"projects\");\n const entries = await tryWithFsDeadline(\n `readdir ${projectsDir}`,\n () => readdir(projectsDir),\n null,\n timeoutMs,\n );\n if (!entries) return null;\n for (const entry of entries) {\n const candidate = join(projectsDir, entry, `${sessionId}.jsonl`);\n const found = await tryWithFsDeadline(\n `stat ${candidate}`,\n async () => (await stat(candidate)).isFile(),\n false,\n timeoutMs,\n );\n if (found) return candidate;\n }\n return null;\n}\n\n/**\n * Yield a file's contents line by line, reproducing `readFileSync(...).split(\"\\n\")`\n * exactly — including the final (possibly empty) segment, so a trailing newline\n * survives a rewrite byte for byte.\n *\n * Splits on `\\n` alone, so a line out of a CRLF transcript arrives with its\n * `\\r` still attached. That carrier byte is part of the line here, and\n * {@link repairLine} re-attaches it to a line it rewrites — the file keeps the\n * terminator style it arrived with. Deliberately not `node:readline`:\n * `crlfDelay` strips the `\\r` outright (rewriting a CRLF transcript to LF) and\n * the interface swallows the trailing-newline distinction, either of which\n * would make the \"clean transcript is left byte-for-byte untouched\" guarantee\n * false. Only one line is held in memory at a time, so a multi-MB transcript\n * never materialises as a single string.\n */\nasync function* streamLines(chunks: AsyncIterable<string>): AsyncGenerator<string> {\n let pending = \"\";\n for await (const chunk of chunks) {\n pending += chunk;\n let idx = pending.indexOf(\"\\n\");\n while (idx !== -1) {\n yield pending.slice(0, idx);\n pending = pending.slice(idx + 1);\n idx = pending.indexOf(\"\\n\");\n }\n }\n yield pending;\n}\n\n/**\n * The runner's own filesystem access: the default {@link TranscriptStore}.\n *\n * @category Transcript repair\n */\nexport const localTranscriptStore: TranscriptStore = {\n locate: (configDir, sessionId, timeoutMs) =>\n locateTranscriptPath(configDir, sessionId, timeoutMs),\n async *read(filePath) {\n const stream = createReadStream(filePath, { encoding: \"utf8\" });\n try {\n for await (const chunk of stream) yield chunk as string;\n } finally {\n stream.destroy();\n }\n },\n async replace(filePath, chunks) {\n const tmpPath = `${filePath}.scrub-tmp`;\n await pipeline(chunks, createWriteStream(tmpPath, { encoding: \"utf8\" }));\n await rename(tmpPath, filePath);\n },\n async discardTemp(filePath) {\n const tmpPath = `${filePath}.scrub-tmp`;\n await tryWithFsDeadline(`unlink ${tmpPath}`, () => unlink(tmpPath), undefined, fsDeadlineMs());\n },\n};\n\n/**\n * Per-model counters the CLI's `cost-state` schema requires (checked against\n * `@anthropic-ai/claude-agent-sdk` 0.3.289; `thinkingTokens` is optional there).\n */\nconst COST_STATE_MODEL_FIELDS = [\n \"inputTokens\",\n \"outputTokens\",\n \"cacheReadInputTokens\",\n \"cacheCreationInputTokens\",\n \"webSearchRequests\",\n \"costUSD\",\n] as const;\n\nfunction isCount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0;\n}\n\n/**\n * Read a `cost-state` entry of `sessionId` off one JSONL line, or `null` when\n * the line is anything else. Mirrors the CLI, which skips an entry that fails\n * its schema and keeps the last valid one, so an entry with a bad total or a\n * per-model counter that is not a non-negative number is not a restorable\n * state. Leading NUL bytes (a torn append) are stripped, as the CLI does.\n */\nfunction readCostState(line: string, sessionId: string): TranscriptCostState | null {\n if (!line.includes('\"cost-state\"')) return null;\n let entry: { type?: unknown; sessionId?: unknown; totalCostUSD?: unknown; modelUsage?: unknown };\n try {\n entry = JSON.parse(line.replace(/^\\0+/, \"\"));\n } catch {\n return null;\n }\n if (entry.type !== \"cost-state\" || entry.sessionId !== sessionId) return null;\n const total = entry.totalCostUSD;\n if (!isCount(total)) return null;\n const usage = entry.modelUsage;\n if (!usage || typeof usage !== \"object\" || Array.isArray(usage)) return null;\n for (const model of Object.values(usage)) {\n if (!model || typeof model !== \"object\") return null;\n const counters = model as Record<string, unknown>;\n if (!COST_STATE_MODEL_FIELDS.every((field) => isCount(counters[field]))) return null;\n }\n return {\n totalCostUSD: total,\n modelUsage: usage as Record<string, Record<string, number>>,\n };\n}\n\n/**\n * Repair one JSONL line, returning the (possibly rewritten) line and mutating\n * `counters`. A non-JSON, blank, or content-less line is returned untouched.\n *\n * The reader splits on `\\n` only, so a line from a CRLF transcript still carries\n * its trailing `\\r`. An untouched line is returned verbatim and keeps it; a\n * rewritten one is rebuilt by `JSON.stringify`, which would drop it — leaving a\n * repaired CRLF transcript with mixed line endings. So the terminator is split\n * off before the parse and re-appended to the rewritten line.\n */\nfunction repairLine(line: string, counters: ScrubCounters): string {\n if (line.trim() === \"\") return line;\n const eol = line.endsWith(\"\\r\") ? \"\\r\" : \"\";\n const body = eol === \"\" ? line : line.slice(0, -1);\n let entry: { message?: { content?: unknown } };\n try {\n entry = JSON.parse(body);\n } catch {\n return line; // Not JSON — leave untouched.\n }\n const content = entry.message?.content;\n if (!Array.isArray(content)) return line;\n const before = totalChanges(counters);\n const scrubbed = (content as ContentBlockLike[]).map((block) => scrubBlock(block, counters));\n if (totalChanges(counters) === before) return line; // Nothing changed on this line.\n return `${JSON.stringify({ ...entry, message: { ...entry.message, content: scrubbed } })}${eol}`;\n}\n\n/**\n * Scan a Claude Code SDK transcript for image content blocks whose declared\n * `media_type` does not match the actual bytes, repair them, and atomically\n * rewrite the file.\n *\n * Safe to call after a turn has failed: the SDK query is dead at that point,\n * and the next resume re-reads the transcript from disk.\n *\n * **Async since #454.** Two streaming passes rather than one whole-file read:\n * pass 1 counts repairs without writing anything, and pass 2 runs only when\n * pass 1 found something. The common case — the preventive scrub of a clean\n * transcript before every resume — is therefore one streaming read and zero\n * writes, and a clean transcript is still left byte-for-byte untouched.\n *\n * @param opts - Config directory, session id, and an optional logger.\n * @returns A {@link ScrubTranscriptResult}. When `changed` is `true` the\n * caller may retry the resume with the same session id.\n * @category Transcript repair\n */\nexport async function scrubPoisonedTranscript(\n opts: ScrubTranscriptOptions,\n): Promise<ScrubTranscriptResult> {\n const { configDir, sessionId, log } = opts;\n const store = opts.store ?? localTranscriptStore;\n const timeoutMs = fsDeadlineMs();\n const result: ScrubTranscriptResult = {\n filePath: null,\n corrected: 0,\n stubbed: 0,\n cacheStripped: 0,\n changed: false,\n costState: null,\n };\n\n let filePath: string | null;\n try {\n filePath = await store.locate(configDir, sessionId, timeoutMs);\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to locate transcript\", {\n configDir,\n sessionId,\n error: err instanceof Error ? err.message : String(err),\n });\n return result;\n }\n if (!filePath) {\n log?.warn(\"scrub-transcript: no transcript found\", { configDir, sessionId });\n return result;\n }\n result.filePath = filePath;\n\n // ── Pass 1: detect. Streams the transcript, counting repairs, writing nothing.\n const counters: ScrubCounters = { corrected: 0, stubbed: 0, cacheStripped: 0 };\n let costState: TranscriptCostState | null = null;\n try {\n await withFsDeadline(\n `scan transcript ${filePath}`,\n async () => {\n for await (const line of streamLines(store.read(filePath))) {\n repairLine(line, counters);\n costState = readCostState(line, sessionId) ?? costState;\n }\n },\n timeoutMs,\n );\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to read transcript\", {\n filePath,\n error: err instanceof Error ? err.message : String(err),\n });\n return result;\n }\n\n result.corrected = counters.corrected;\n result.stubbed = counters.stubbed;\n result.cacheStripped = counters.cacheStripped;\n result.costState = costState;\n\n if (totalChanges(counters) === 0) {\n return result;\n }\n\n // ── Pass 2: rewrite. Atomic: stream a sibling temp file, then rename over the\n // original. Line separators are re-emitted exactly as pass 1 split them, so a\n // trailing newline and any blank lines survive verbatim.\n const source = filePath;\n try {\n await withFsDeadline(\n `rewrite transcript ${source}`,\n async () => {\n const discard: ScrubCounters = { corrected: 0, stubbed: 0, cacheStripped: 0 };\n await store.replace(\n source,\n (async function* () {\n let first = true;\n for await (const line of streamLines(store.read(source))) {\n yield first ? repairLine(line, discard) : `\\n${repairLine(line, discard)}`;\n first = false;\n }\n })(),\n );\n },\n timeoutMs,\n );\n } catch (err) {\n log?.warn(\"scrub-transcript: failed to rewrite transcript\", {\n filePath,\n error: err instanceof Error ? err.message : String(err),\n });\n // Never leave a half-written `.scrub-tmp` in the SDK's projects dir, also\n // when the deadline abandoned the replace mid-write.\n await store.discardTemp(source).catch(() => {});\n return result;\n }\n\n result.changed = true;\n log?.info(\"scrub-transcript: repaired poisoned transcript\", {\n filePath,\n corrected: result.corrected,\n stubbed: result.stubbed,\n cacheStripped: result.cacheStripped,\n });\n return result;\n}\n","/**\n * Pre-first-turn resume probe for the Claude Agent SDK harness.\n *\n * A tier-1 native resume only hands its session id to the SDK inside the first\n * real turn, so the `jsonl_lost` outcome (\"No conversation found\") is invisible\n * until a turn is consumed. The runner shares the container filesystem with the\n * SDK, so a cheap `stat` of the on-disk JSONL transcript is an authoritative,\n * side-effect-free signal of whether the resume will find its history — no\n * probe query, no spurious model turn.\n *\n * @module\n */\n\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { withFsDeadline } from \"@skaile/workspaces/core\";\nimport { locateTranscriptPath } from \"./scrub-transcript.js\";\n\n/**\n * Overall wall-clock budget for the probe. Deliberately a small fraction of the\n * platform's `session_init_ack` timeout (`DEFAULT_INIT_ACK_TIMEOUT_MS`, 15s):\n * the probe runs synchronously on the pre-ack path, so a wedged\n * `CLAUDE_CONFIG_DIR` mount must never push the ack past its deadline.\n */\nconst RESUME_PROBE_TIMEOUT_MS = 2_000;\n\n/**\n * Outcome of {@link probeResumeTranscript}: whether the SDK transcript for a\n * requested tier-1 resume exists on disk.\n *\n * @category Resume probe\n */\nexport type ResumeProbeOutcome = \"transcript_found\" | \"jsonl_lost\";\n\n/**\n * Resolve the Claude Code config directory — the parent of `projects/` — from\n * an explicit env map, the process environment, or the `~/.claude` default.\n *\n * The runner's probe and the claude-sdk harness share this one resolver, so they\n * agree as long as they see the same `CLAUDE_CONFIG_DIR`. Today they do:\n * `CLAUDE_CONFIG_DIR` is container-scoped and neither side threads a per-session\n * override through `config.env`, so both fall through to `process.env`. If a\n * future change ever set the harness's `config.env.CLAUDE_CONFIG_DIR` to a\n * divergent path, the reactive `resume_failed { jsonl_lost }` turn remains the\n * safety net.\n *\n * @category Resume probe\n */\nexport function resolveClaudeConfigDir(env?: Record<string, string | undefined>): string {\n return env?.CLAUDE_CONFIG_DIR || process.env.CLAUDE_CONFIG_DIR || join(homedir(), \".claude\");\n}\n\n/**\n * Probe whether the SDK JSONL transcript for `sessionId` exists on disk.\n *\n * Non-null locator result → `transcript_found`; null → `jsonl_lost`;\n * `undefined` → outcome unknown (the probe exceeded its budget or errored). The\n * caller leaves the ack field ABSENT on `undefined` so the reactive\n * `resume_failed { jsonl_lost }` turn stays the safety net — a timed-out probe\n * must never masquerade as a genuine `jsonl_lost` and force a needless downgrade.\n *\n * `opts.timeoutMs` overrides {@link RESUME_PROBE_TIMEOUT_MS}; `opts.locate`\n * overrides the transcript locator (used by tests / alternate stores).\n *\n * @category Resume probe\n */\nexport async function probeResumeTranscript(\n sessionId: string,\n opts?: {\n env?: Record<string, string | undefined>;\n timeoutMs?: number;\n locate?: (configDir: string, sessionId: string) => Promise<string | null>;\n },\n): Promise<ResumeProbeOutcome | undefined> {\n const configDir = resolveClaudeConfigDir(opts?.env);\n const timeoutMs = opts?.timeoutMs ?? RESUME_PROBE_TIMEOUT_MS;\n const locate = opts?.locate ?? locateTranscriptPath;\n try {\n // Bound the whole probe on wall-clock and THROW on expiry: the inner per-op\n // deadline swallows a timeout into a null path (a false `jsonl_lost`), so a\n // wedged mount must yield \"unknown\" here rather than a spurious downgrade.\n const filePath = await withFsDeadline(\n `resume-probe ${sessionId}`,\n () => locate(configDir, sessionId),\n timeoutMs,\n );\n return filePath ? \"transcript_found\" : \"jsonl_lost\";\n } catch {\n return undefined;\n }\n}\n","import { type ChildProcess, spawn } from \"node:child_process\";\nimport { join } from \"node:path\";\nimport { fsDeadlineMs, withFsDeadline } from \"@skaile/workspaces/core\";\nimport { resolveAgentExec } from \"./agent-exec.js\";\nimport { localTranscriptStore, type TranscriptStore } from \"./harnesses/scrub-transcript.js\";\n\n/**\n * Transcripts reached through the agent launch shim.\n *\n * With the uid split on, the Claude CLI runs as the agent uid and creates its\n * transcripts 0600 in 0700 dirs, so the runner can no longer list, read or\n * rewrite them itself. This store runs plain tools (`find`, `cat`, `sh`, `mv`)\n * as the agent uid through the shim instead. The child gets only `PATH` and\n * `LC_ALL`, never the runner's environment, and runs in `/` because the\n * runner's own cwd may not be enterable by the agent uid.\n */\nexport function agentTranscriptStore(shim: string): TranscriptStore {\n // A replace the scrub's deadline abandoned keeps running; discardTemp stops\n // it before removing its temp file.\n const inFlight = new Map<string, ChildProcess>();\n // Paths whose rewrite discardTemp gave up on: their rename must never run.\n const cancelled = new Set<string>();\n const track = (filePath: string, child: ChildProcess) => {\n inFlight.set(filePath, child);\n child.once(\"close\", () => {\n if (inFlight.get(filePath) === child) inFlight.delete(filePath);\n });\n };\n return {\n async locate(configDir, sessionId, timeoutMs = 10_000) {\n // A session id is a UUID; anything glob- or path-shaped is not ours.\n if (!/^[A-Za-z0-9._-]+$/.test(sessionId)) return null;\n const projectsDir = join(configDir, \"projects\");\n // Markers on stdout, not exit codes, carry the answer: a shim or launcher\n // failure has exit codes of its own and must never read as \"not found\".\n const { stdout } = await collect(\n runAsAgent(shim, [\n \"sh\",\n \"-c\",\n '[ -d \"$1\" ] || { echo \"@@no-projects\"; exit 0; }; ' +\n 'find \"$1\" -mindepth 2 -maxdepth 2 -type f -name \"$2\" -print -quit; echo \"@@find:$?\"',\n \"sh\",\n projectsDir,\n `${sessionId}.jsonl`,\n ]),\n timeoutMs,\n );\n const lines = stdout.split(\"\\n\").map((l) => l.trim());\n // A missing projects/ is the same \"not found\" as a failed readdir locally.\n if (lines.includes(\"@@no-projects\")) return null;\n const status = lines.find((l) => l.startsWith(\"@@find:\"));\n if (status === undefined)\n throw new Error(\"locating a transcript as the agent uid failed (no answer from the shim)\");\n // A path find printed counts even if it later hit an unreadable sibling.\n const found = lines.find((l) => l.startsWith(\"/\"));\n if (found) return found;\n if (status !== \"@@find:0\")\n throw new Error(`locating a transcript as the agent uid failed (${status.slice(2)})`);\n return null;\n },\n\n async *read(filePath) {\n const child = runAsAgent(shim, [\"cat\", \"--\", filePath]);\n const exited = exitOf(child);\n exited.catch(() => {}); // awaited below; this only stops an unhandled rejection\n const stderr = drain(child);\n child.stdout?.setEncoding(\"utf8\");\n for await (const chunk of child.stdout as AsyncIterable<string>) yield chunk;\n const code = await exited;\n if (code !== 0)\n throw new Error(`reading ${filePath} as the agent uid failed: ${await stderr}`);\n },\n\n async replace(filePath, chunks) {\n const child = runAsAgent(shim, [\n \"sh\",\n \"-c\",\n // 0600 like the CLI's own files. Only writes the temp file: the rename\n // is a separate step below, run only after the input was fully sent,\n // so a killed or starved writer can never commit a partial transcript.\n 'umask 077; cat > \"$1.scrub-tmp\"',\n \"sh\",\n filePath,\n ]);\n cancelled.delete(filePath);\n track(filePath, child);\n const exited = exitOf(child);\n exited.catch(() => {}); // awaited below; this only stops an unhandled rejection\n const stderr = drain(child);\n const stdin = child.stdin;\n if (!stdin) throw new Error(\"agent shim has no stdin\");\n // A child that dies early surfaces through its exit code, not an EPIPE crash.\n stdin.on(\"error\", () => {});\n const gone = exited.then(\n () => undefined,\n () => undefined,\n );\n // Stop pulling input as soon as the child is gone (killed by discardTemp,\n // or failed), instead of waiting on a producer that may never resume.\n const input = chunks[Symbol.asyncIterator]();\n let drained = false;\n try {\n for (;;) {\n const next = await Promise.race([\n input.next(),\n gone.then(() => ({ dead: true as const })),\n ]);\n if (\"dead\" in next || stdin.destroyed) break;\n if (next.done) {\n drained = true;\n break;\n }\n if (!stdin.write(next.value)) {\n await Promise.race([new Promise((resolve) => stdin.once(\"drain\", resolve)), gone]);\n }\n }\n } finally {\n stdin.end();\n // Close the producer too, so the reader feeding it (a `cat` through\n // the shim) is torn down rather than left blocked on a full pipe.\n if (!drained) void input.return?.()?.catch(() => {});\n }\n const code = await exited;\n if (code !== 0 || !drained)\n throw new Error(`rewriting ${filePath} as the agent uid failed: ${await stderr}`);\n if (cancelled.has(filePath)) throw new Error(`rewrite of ${filePath} was abandoned`);\n const mover = runAsAgent(shim, [\"mv\", \"-f\", \"--\", `${filePath}.scrub-tmp`, filePath]);\n track(filePath, mover);\n const moved = await collect(mover, 10_000);\n if (moved.code !== 0) throw new Error(`renaming the rewritten ${filePath} failed`);\n },\n\n async discardTemp(filePath) {\n // Before anything else, so a writer that is just finishing never renames.\n cancelled.add(filePath);\n const pending = inFlight.get(filePath);\n if (pending && pending.exitCode === null && pending.signalCode === null) {\n // The writer cannot commit (the rename is a separate step), so this only\n // stops it; bounded, since a writer stuck on a hung mount may never die.\n const closed = new Promise((resolve) => pending.once(\"close\", resolve));\n pending.kill(\"SIGKILL\");\n await withFsDeadline(`stop the rewrite of ${filePath}`, () => closed, fsDeadlineMs());\n }\n await collect(runAsAgent(shim, [\"rm\", \"-f\", \"--\", `${filePath}.scrub-tmp`]), 10_000);\n },\n };\n}\n\n/**\n * The transcript store for this runner: through the agent shim when\n * `SKAILE_AGENT_EXEC` is set, the runner's own filesystem otherwise.\n */\nexport function transcriptStoreForRuntime(\n env: Record<string, string | undefined> = process.env,\n): TranscriptStore {\n const shim = resolveAgentExec(env);\n return shim ? agentTranscriptStore(shim) : localTranscriptStore;\n}\n\nfunction runAsAgent(shim: string, argv: string[]): ChildProcess {\n return spawn(shim, [\"--\", ...argv], {\n cwd: \"/\",\n env: { PATH: process.env.PATH ?? \"/usr/bin:/bin\", LC_ALL: \"C\" },\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n}\n\nfunction exitOf(child: ChildProcess): Promise<number> {\n return new Promise((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"close\", (code) => resolve(code ?? 1));\n });\n}\n\n/** Keep the last 1 KiB of stderr for the error message, and keep the pipe drained. */\nfunction drain(child: ChildProcess): Promise<string> {\n return new Promise((resolve) => {\n let tail = \"\";\n child.stderr?.setEncoding(\"utf8\");\n child.stderr?.on(\"data\", (c: string) => {\n tail = (tail + c).slice(-1024);\n });\n child.stderr?.once(\"close\", () => resolve(tail.trim()));\n });\n}\n\nasync function collect(\n child: ChildProcess,\n timeoutMs: number,\n): Promise<{ code: number; stdout: string }> {\n let stdout = \"\";\n child.stdout?.setEncoding(\"utf8\");\n child.stdout?.on(\"data\", (c: string) => {\n stdout += c;\n });\n void drain(child);\n child.stdin?.end();\n let timer: NodeJS.Timeout | undefined;\n try {\n const code = await Promise.race([\n exitOf(child),\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n child.kill(\"SIGKILL\");\n reject(new Error(`agent shim did not answer within ${timeoutMs} ms`));\n }, timeoutMs);\n }),\n ]);\n return { code, stdout };\n } finally {\n clearTimeout(timer);\n }\n}\n","import {\n type AIProviderEntry,\n type AIProviderRegistry,\n type MergedAIProviderRegistry,\n parseModelRef,\n registryEntries,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport { BUILTIN_HARNESS_CATALOG } from \"./registry.js\";\n\n/**\n * The line for a selected provider entry whose surface the Claude Agent SDK cannot speak, or\n * `undefined` when there is none. `skaile run` and `skaile repl` print it as one `!` line (runner\n * `credential-notice.ts`), so the harness logs the same text at `info`, which reaches the log\n * database but not the terminal (p1475).\n *\n * @param providerId - The entry the run selected.\n * @param entry - That registry entry.\n */\nexport function unsupportedSurfaceNotice(\n providerId: string,\n entry: AIProviderEntry,\n): string | undefined {\n const supported = BUILTIN_HARNESS_CATALOG[\"claude-sdk\"].surfaces;\n const surface = \"surface\" in entry ? entry.surface : undefined;\n if (!surface || !supported || supported.includes(surface)) return undefined;\n return `provider '${providerId}' uses the '${surface}' surface, which the Claude Agent SDK cannot speak (it speaks: ${supported.join(\", \")})`;\n}\n\n/**\n * {@link unsupportedSurfaceNotice} for a session: the entry its model selector names (an entry id,\n * or the head of `<providerId>/<modelId>`). `undefined` with no selector, an id no entry lists\n * (it selects no provider), or an entry it speaks.\n */\nexport function sessionSurfaceNotice(\n registry: AIProviderRegistry | MergedAIProviderRegistry,\n modelRef: string | undefined,\n): string | undefined {\n const named = modelRef?.trim();\n if (!named) return undefined;\n const entries = registryEntries(registry);\n // An id no entry lists (`sonnet`, `claude-sonnet-4-5`) selects no provider: the harness takes\n // it as typed on the endpoint it would use with no selector.\n const parsed = entries.some(([id]) => id === named) ? undefined : parseModelRef(named, registry);\n if (parsed?.fallback) return undefined;\n const providerId = entries.some(([id]) => id === named) ? named : parsed?.providerId;\n const entry = entries.find(([id]) => id === providerId)?.[1];\n return providerId && entry ? unsupportedSurfaceNotice(providerId, entry) : undefined;\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { initTelemetry } from './chunk-4R6DROGN.js';
|
|
2
2
|
import { parseSkillFrontmatter, validateFlowVersions } from './chunk-PTJTOPE5.js';
|
|
3
|
-
import { FlowAdapter, SessionNodeExecutor, SessionSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn } from './chunk-
|
|
4
|
-
import { loadFlow, flowLookupRoots, findFlowFileInRoots, FLOW_FILE_EXTENSIONS } from './chunk-
|
|
3
|
+
import { FlowAdapter, SessionNodeExecutor, SessionSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn } from './chunk-LX4TTTRR.js';
|
|
4
|
+
import { loadFlow, flowLookupRoots, findFlowFileInRoots, FLOW_FILE_EXTENSIONS } from './chunk-WFK4MUBL.js';
|
|
5
5
|
import { renderStimulusPrompt } from './chunk-WD3L5QSU.js';
|
|
6
6
|
import { flowSkillVersionPins } from './chunk-7RGTAEG6.js';
|
|
7
|
-
import { resolveSettings } from './chunk-
|
|
7
|
+
import { resolveSettings } from './chunk-TMJBEGS4.js';
|
|
8
8
|
import { DEFAULT_HARNESS_ID } from './chunk-C5HFK34M.js';
|
|
9
9
|
import { findKindDirs } from './chunk-MWXYN6NY.js';
|
|
10
|
-
import { resolveAgentDir, resolveSkWorkspaceConfig } from './chunk-
|
|
10
|
+
import { resolveAgentDir, resolveSkWorkspaceConfig } from './chunk-O7ADRMCR.js';
|
|
11
11
|
import { isValidAssetName } from './chunk-V5KG6CCV.js';
|
|
12
12
|
import { createLogger } from './chunk-BOFL7GIF.js';
|
|
13
13
|
import fs from 'fs';
|
|
@@ -537,5 +537,5 @@ function walkForSkill(dir, skillId) {
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
export { awaitAgentEnd, resolveFlowPath, resumeFlow, runFlow };
|
|
540
|
-
//# sourceMappingURL=chunk-
|
|
541
|
-
//# sourceMappingURL=chunk-
|
|
540
|
+
//# sourceMappingURL=chunk-IRK3LNG3.js.map
|
|
541
|
+
//# sourceMappingURL=chunk-IRK3LNG3.js.map
|