@iowarp/clio-coder 0.3.9 → 0.4.1
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 +92 -0
- package/NOTICE +33 -0
- package/README.md +121 -16
- package/dist/{acp-7LOELQFP.js → acp-ZILU3AUO.js} +19 -18
- package/dist/{agents-FIBG2SHA.js → agents-HYWGBGQR.js} +53 -39
- package/dist/assets/codewiki.json +1 -1
- package/dist/{auth-OI4LIH2I.js → auth-N3QT7CBO.js} +24 -21
- package/dist/{builtins-AD25UL3C.js → builtins-UJLMOVOV.js} +6 -6
- package/dist/{chunk-I4HZDVNP.js → chunk-2LEAKD4C.js} +2 -3
- package/dist/{chunk-465CC7FK.js → chunk-2NM363SV.js} +60 -64
- package/dist/{chunk-4H6ULJ3H.js → chunk-2VG7KLYV.js} +1046 -1370
- package/dist/{chunk-SST6Z5JA.js → chunk-336NSSKI.js} +1 -1
- package/dist/{chunk-NZU6YDNV.js → chunk-3I5NY75V.js} +5 -5
- package/dist/{chunk-47CMYGET.js → chunk-3QSOM6PA.js} +2 -2
- package/dist/chunk-42FMPA75.js +101 -0
- package/dist/{chunk-HAY4ZE2P.js → chunk-5PSMVOLM.js} +2 -2
- package/dist/{chunk-IHKBWSXF.js → chunk-5QIAJV2D.js} +3 -3
- package/dist/chunk-5YHDIDBP.js +97 -0
- package/dist/chunk-6CCS4G3W.js +1529 -0
- package/dist/{chunk-2JDWVJND.js → chunk-6DWBAZ5U.js} +2 -2
- package/dist/{chunk-BVDVID7E.js → chunk-6FN3E6KX.js} +6 -6
- package/dist/{chunk-DG4M6ZUE.js → chunk-6HMJX2VU.js} +59 -59
- package/dist/{chunk-3MRC2YSQ.js → chunk-6I5ILFOF.js} +3 -2
- package/dist/chunk-6NJQITNH.js +1412 -0
- package/dist/chunk-6VC4OV3Z.js +365 -0
- package/dist/{chunk-LU7P4LHA.js → chunk-72GZI5EV.js} +2 -2
- package/dist/{chunk-5T7RBWN2.js → chunk-74YWRRU5.js} +9 -8
- package/dist/{chunk-VPTUJU4P.js → chunk-7EPLI7VL.js} +2 -2
- package/dist/{chunk-CA42X6KT.js → chunk-7OBGU7UB.js} +7 -7
- package/dist/{chunk-56KB5IJP.js → chunk-7PWAODYW.js} +3 -3
- package/dist/chunk-7RY5VZPH.js +573 -0
- package/dist/{chunk-OEDBCISO.js → chunk-ABLSQ6JX.js} +3 -3
- package/dist/{chunk-5HFBWUMU.js → chunk-AFKWHWXF.js} +13 -23
- package/dist/{chunk-FWDFM5ZU.js → chunk-AK5XEFVZ.js} +3 -3
- package/dist/{chunk-WXCJ7VME.js → chunk-AKB4GYDL.js} +7 -7
- package/dist/chunk-AP73CFDC.js +308 -0
- package/dist/{chunk-4LJX2PUC.js → chunk-BBTJOK6Y.js} +5 -5
- package/dist/{chunk-QQ7EKM72.js → chunk-BDPT6GTK.js} +13 -61
- package/dist/chunk-BJGUKIG4.js +302 -0
- package/dist/chunk-BMS5RKQY.js +27 -0
- package/dist/{chunk-TD7UE2L5.js → chunk-BTGG6BG2.js} +81 -40
- package/dist/chunk-BTK3SSSK.js +67 -0
- package/dist/{chunk-M6L6IDJG.js → chunk-BWH6N36D.js} +1 -1
- package/dist/chunk-BWW4HLO4.js +301 -0
- package/dist/{chunk-BNAZZHFG.js → chunk-BYP5D4HI.js} +1 -1
- package/dist/{chunk-HJB5IUKP.js → chunk-C537JADH.js} +18 -18
- package/dist/{chunk-774ILSRL.js → chunk-CDNVLKUX.js} +5 -4
- package/dist/{chunk-HPCTNZM2.js → chunk-CTJ4RNAA.js} +4 -4
- package/dist/{chunk-AEYBF3TB.js → chunk-CWVRRIEI.js} +2 -2
- package/dist/chunk-D4CJV46V.js +462 -0
- package/dist/chunk-D7E7WCDF.js +27 -0
- package/dist/{chunk-5PVQ4SRS.js → chunk-E67WX76H.js} +10 -126
- package/dist/{chunk-FQ4SKYE4.js → chunk-EBY63B7G.js} +2 -5
- package/dist/chunk-EIMVLWB3.js +1842 -0
- package/dist/{chunk-AMKHQW3C.js → chunk-FEFIFZTL.js} +3 -3
- package/dist/{chunk-RAPCMZL4.js → chunk-FSP7CMNU.js} +9 -1
- package/dist/{chunk-3DUR4WUA.js → chunk-FYUN5KZ3.js} +25 -25
- package/dist/{chunk-MV3K5QF2.js → chunk-GCSMB2KY.js} +2 -2
- package/dist/chunk-GIZNH63R.js +40 -0
- package/dist/chunk-GPPB3JBE.js +688 -0
- package/dist/{chunk-B5XRQOLB.js → chunk-GVQJ5CCZ.js} +17 -11
- package/dist/chunk-HHV2GANA.js +88 -0
- package/dist/chunk-HJWWJ6IL.js +184 -0
- package/dist/{chunk-RKRLDWD3.js → chunk-HLW2MRKE.js} +1 -1
- package/dist/chunk-HRQMFLJP.js +75 -0
- package/dist/{chunk-AD7Y7STJ.js → chunk-HUAS7ITX.js} +107 -97
- package/dist/{chunk-O6I4CIEU.js → chunk-I66EAJFY.js} +6 -6
- package/dist/{chunk-S4COXYBG.js → chunk-IG7BCQBA.js} +129 -106
- package/dist/{chunk-N3PBVRTZ.js → chunk-IXJT6DCX.js} +9 -7
- package/dist/chunk-J4HBWF6Y.js +2635 -0
- package/dist/chunk-J5LZHVIT.js +284 -0
- package/dist/{chunk-GAYUJ7LE.js → chunk-JA5QWE4Z.js} +544 -227
- package/dist/{chunk-B5CSFE7B.js → chunk-JIEGK6UF.js} +6 -174
- package/dist/{chunk-VKBMFOYV.js → chunk-JZWT5J3Y.js} +23 -27
- package/dist/chunk-K6BF4U2H.js +1785 -0
- package/dist/{chunk-CGKSTWHD.js → chunk-K6BSR66V.js} +2 -1
- package/dist/{chunk-YSEHGPCT.js → chunk-MA3H6DM5.js} +6 -6
- package/dist/{chunk-EBOC7MT3.js → chunk-MOPSG2X7.js} +9 -9
- package/dist/{chunk-KV2AOLDF.js → chunk-MQXIVJ35.js} +18 -29
- package/dist/{chunk-P3JGPQFL.js → chunk-N5UK64DP.js} +4 -4
- package/dist/chunk-NDDGJUXD.js +81 -0
- package/dist/chunk-NEKRRTYW.js +56 -0
- package/dist/{chunk-4ZG3XFUR.js → chunk-NLFAQR7Z.js} +12 -1
- package/dist/{chunk-VO2LKSTM.js → chunk-O42A54GG.js} +2 -2
- package/dist/{chunk-T3Z6VAAF.js → chunk-OJTRZGR3.js} +53 -92
- package/dist/{chunk-5DQRIYDZ.js → chunk-PBP4B7XR.js} +3 -3
- package/dist/{chunk-NQ6UCCOD.js → chunk-PJJ6MY27.js} +8 -8
- package/dist/chunk-PMZCIOCJ.js +25 -0
- package/dist/{chunk-ZGVHUX3M.js → chunk-PMZVFWSR.js} +2 -2
- package/dist/{chunk-7C6RYZGQ.js → chunk-PVAMAVBB.js} +5 -4
- package/dist/chunk-QDC3K2U3.js +262 -0
- package/dist/{chunk-JEQQR47K.js → chunk-QKIFBZKT.js} +173 -14
- package/dist/{chunk-R7LNVMCS.js → chunk-QMXC4JB7.js} +70 -78
- package/dist/chunk-QSNYB6ZV.js +195 -0
- package/dist/chunk-QTFGO774.js +644 -0
- package/dist/{chunk-ODFEOB4F.js → chunk-R23Z6K6I.js} +27 -9
- package/dist/{chunk-3UUY7R3Z.js → chunk-R32CLGZ6.js} +14 -14
- package/dist/chunk-R346GLFC.js +31 -0
- package/dist/chunk-RKSR6VSF.js +132 -0
- package/dist/{chunk-N5XKWMDW.js → chunk-SCYB3HA4.js} +73 -27
- package/dist/{chunk-PZ4I4JE2.js → chunk-SINK3QR6.js} +135 -125
- package/dist/{chunk-5QKCQQ3E.js → chunk-SUW5DORT.js} +2 -2
- package/dist/chunk-T56WDKA5.js +183 -0
- package/dist/{chunk-ECUO3KDP.js → chunk-TD3PGPQA.js} +87 -26
- package/dist/{chunk-HKO36JWF.js → chunk-THYWACCR.js} +31 -3
- package/dist/{chunk-LXPJXFM5.js → chunk-TVH4ONAM.js} +18 -12
- package/dist/chunk-TVHHYFHE.js +255 -0
- package/dist/chunk-U2WB7TZS.js +271 -0
- package/dist/{chunk-NNNWO6F2.js → chunk-UAPGZHYC.js} +237 -33
- package/dist/{chunk-MIX5N5AC.js → chunk-UEDMSP56.js} +415 -160
- package/dist/{chunk-WIE7ZOSW.js → chunk-UXN6JT4W.js} +3 -3
- package/dist/{chunk-CMZWFGD2.js → chunk-VAVR4IJY.js} +19 -15
- package/dist/{chunk-MV2VUEJC.js → chunk-VEGN6WIQ.js} +2 -2
- package/dist/chunk-VKFQTNDV.js +66 -0
- package/dist/{chunk-FALJGAWU.js → chunk-VKRH2TCS.js} +2 -2
- package/dist/{chunk-A2NJGIB3.js → chunk-VN3SHNBN.js} +2 -2
- package/dist/{chunk-XK56QHLX.js → chunk-VPKWYKEY.js} +19 -5
- package/dist/{chunk-UOSL25KY.js → chunk-VXMFAE2W.js} +1 -1
- package/dist/{chunk-EQ63NRB7.js → chunk-WNP7O5WZ.js} +3 -3
- package/dist/chunk-WR6U3OVP.js +45 -0
- package/dist/{chunk-TEO2TLVN.js → chunk-XKA2ICR3.js} +1051 -1196
- package/dist/{chunk-3V5AYSEQ.js → chunk-Y45G3AXC.js} +72 -65
- package/dist/{chunk-J5Q24KAG.js → chunk-Y4CAGMM6.js} +2 -2
- package/dist/chunk-YAKGTXEV.js +17 -0
- package/dist/{chunk-ZI647VB5.js → chunk-YPI3QQCF.js} +2 -2
- package/dist/{chunk-YW7UVM5V.js → chunk-ZAZB4JMW.js} +55 -11
- package/dist/{chunk-HCBCAYZU.js → chunk-ZJLUDYFY.js} +11 -11
- package/dist/{chunk-HKIYEGME.js → chunk-ZTJUVLTU.js} +2 -2
- package/dist/{chunk-IFBNV6H6.js → chunk-ZW55JB7N.js} +3 -3
- package/dist/cli/index.js +48 -37
- package/dist/clio-IT3G3VQH.js +25 -0
- package/dist/{code-nav-LMW275PA.js → code-nav-RK6S7F6E.js} +8 -8
- package/dist/codewiki/build-worker.js +1 -1
- package/dist/{compile-cache-CVJMMODC.js → compile-cache-OQAVB7Y5.js} +3 -5
- package/dist/{components-ZFA3SAER.js → components-UBWCQSRW.js} +6 -6
- package/dist/{config-RXS5T3JT.js → config-3QZRWZJF.js} +73 -61
- package/dist/configure-FL7Y3KJF.js +54 -0
- package/dist/{context-MVOORGMF.js → context-5HE7ODYK.js} +61 -49
- package/dist/{context-I3BTOTCS.js → context-KYQFRVDC.js} +11 -11
- package/dist/{context-PALKKQYL.js → context-XNHL75JV.js} +43 -28
- package/dist/{context-clear-N2WOYZ2K.js → context-clear-N545L53A.js} +60 -48
- package/dist/{context-working-set-MIEVECVZ.js → context-working-set-QHKXSV2F.js} +15 -13
- package/dist/{dispatch-runner-VVA4SRRH.js → dispatch-runner-RGIE5PCT.js} +109 -72
- package/dist/{docs-7LQ23DLM.js → docs-5NAF6AU7.js} +7 -13
- package/dist/doctor-ZGPEGHIP.js +772 -0
- package/dist/{eval-IJ5VEZDJ.js → eval-GXLL44RD.js} +106 -86
- package/dist/eval-inventory-HBWSWQOK.js +315 -0
- package/dist/{evidence-L5APPXNV.js → evidence-HWLBRH3Q.js} +209 -51
- package/dist/{evolve-RGNKFJ52.js → evolve-FTZBMNVW.js} +57 -45
- package/dist/{extensions-7WYWUX5A.js → extensions-VHRBEID7.js} +7 -7
- package/dist/{fleet-6CNVBZZP.js → fleet-CKZHJWZJ.js} +215 -114
- package/dist/{fleet-commands-L2SXSYEI.js → fleet-commands-EXDXBMV6.js} +13 -12
- package/dist/fleet-decisions-OTHB6KRL.js +157 -0
- package/dist/{fleet-graph-2J3OOIPO.js → fleet-graph-YTEZUCUT.js} +20 -17
- package/dist/fleet-inspect-SS6YMDCK.js +445 -0
- package/dist/{fleet-preflight-CZRJ4JP5.js → fleet-preflight-PBY4VYOM.js} +6 -9
- package/dist/{fleet-validate-C5RI6DP7.js → fleet-validate-KMEM5L3S.js} +25 -20
- package/dist/fleet-verify-QD5M7E7Q.js +178 -0
- package/dist/fleet-view-WAMJYNDT.js +94 -0
- package/dist/{init-VBN2ACVA.js → init-5XQRBOFV.js} +79 -66
- package/dist/install-NKNG7KD4.js +13 -0
- package/dist/interop-34TVO25M.js +116 -0
- package/dist/{library-JHGUMLY2.js → library-3QY6KF57.js} +25 -21
- package/dist/{memory-K4OQIYWG.js → memory-L4UTIIIW.js} +59 -47
- package/dist/{models-2NCZUWDD.js → models-ZVX3QOWE.js} +47 -37
- package/dist/{monitor-MMVTJABD.js → monitor-CEKVSYTS.js} +67 -57
- package/dist/{orchestrator-ZKBPCHW6.js → orchestrator-77BAP6BC.js} +7633 -7699
- package/dist/panes-7STHOAUJ.js +103 -0
- package/dist/panes-SHAUIRXY.js +60 -0
- package/dist/{paths-DBXMZMDU.js → paths-L7LGY6RN.js} +6 -6
- package/dist/{reset-DD5JGOY3.js → reset-EOLM7GVE.js} +15 -14
- package/dist/resources-74GKTLSF.js +115 -0
- package/dist/{run-QEGNX7FL.js → run-HBAUJNNZ.js} +139 -98
- package/dist/{share-JKD3BQMW.js → share-G3APVLVP.js} +25 -21
- package/dist/{skills-LMQIKDOZ.js → skills-35HHUKCR.js} +37 -27
- package/dist/{skills-eval-I7X2774U.js → skills-eval-QN4HSHDC.js} +80 -73
- package/dist/skills-inventory-J357J34F.js +129 -0
- package/dist/slash-commands-JZZCQA32.js +79 -0
- package/dist/{steer-CF5TDANS.js → steer-XAVHJM22.js} +4 -4
- package/dist/{support-I7LOJLIF.js → support-U7QOWY26.js} +7 -7
- package/dist/{targets-RUSR6B5Z.js → targets-DSM6CY3M.js} +67 -59
- package/dist/{terminal-lease-QYVORFR4.js → terminal-lease-JOPFUVEM.js} +15 -10
- package/dist/tools-MKNWVPBH.js +29 -0
- package/dist/{trace-ODOQIVIW.js → trace-ECQ7TIYZ.js} +194 -7
- package/dist/tui-primitives-K5PASC3O.js +17 -0
- package/dist/{uninstall-ZJF5H5ZN.js → uninstall-N34PCTGJ.js} +6 -8
- package/dist/{upgrade-XANW3FXB.js → upgrade-H7TOM7YL.js} +37 -62
- package/dist/{usage-4H7ZRXQT.js → usage-X52N3IDJ.js} +70 -59
- package/dist/{verifiers-UZXNBZEB.js → verifiers-EJTVVSMA.js} +174 -14
- package/dist/{verify-BVKWTNDL.js → verify-YJL6XET2.js} +12 -11
- package/dist/{web-fetch-2YHJ3KTG.js → web-fetch-MPIFL3LL.js} +3 -4
- package/dist/{wiki-generate-MY7WV2QI.js → wiki-generate-4NDZTQ4B.js} +86 -75
- package/dist/with-panes-OBOBFIIR.js +818 -0
- package/dist/worker/entry.js +131 -91
- package/docs/README.md +3 -2
- package/docs/acp.md +25 -4
- package/docs/alcf-provider.md +1 -1
- package/docs/architecture.md +2 -2
- package/docs/artifact-versions.md +4 -1
- package/docs/built-in-agents.md +40 -32
- package/docs/capacity-and-scheduling.md +43 -5
- package/docs/commands-and-modes.md +39 -4
- package/docs/config-knobs-audit.md +3 -0
- package/docs/configuration-and-targets.md +138 -167
- package/docs/context-engine.md +1 -1
- package/docs/development-pipeline.md +19 -0
- package/docs/dispatch-typed-intent.md +385 -0
- package/docs/documentation-coverage.md +2 -2
- package/docs/documentation-guide.md +1 -1
- package/docs/environment-variables.md +3 -1
- package/docs/eval-runner.md +1 -1
- package/docs/evals-internal.md +1 -1
- package/docs/evidence-and-memory.md +2 -2
- package/docs/evolution.md +1 -1
- package/docs/exit-codes-and-output.md +3 -1
- package/docs/extensions-and-sharing.md +25 -1
- package/docs/fleet-demo-runbook.md +6 -3
- package/docs/fleet-dispatch.md +30 -7
- package/docs/installation-and-lifecycle.md +16 -3
- package/docs/middleware-and-components.md +1 -1
- package/docs/model-catalog.md +10 -1
- package/docs/observability.md +3 -3
- package/docs/proactive-memory.md +1 -1
- package/docs/prompt-envelope-and-tools.md +1 -1
- package/docs/provider-adapter-cookbook.md +1 -1
- package/docs/release-cut-checklist.md +164 -177
- package/docs/safety-model.md +2 -2
- package/docs/scientific-validation.md +3 -3
- package/docs/session-lifecycle.md +1 -1
- package/docs/skills-marketplace.md +1 -1
- package/docs/tool-usage.md +18 -8
- package/docs/trace-store.md +16 -11
- package/docs/troubleshooting.md +2 -2
- package/docs/tui-design.md +1 -1
- package/docs/worker-dispatch-mechanics.md +1 -1
- package/evals/README.md +5 -0
- package/evals/behavioral-corpus-grader.mjs +103 -0
- package/evals/behavioral-machinery-baseline.json +2276 -0
- package/evals/behavioral-machinery-driver.ts +250 -0
- package/evals/behavioral-machinery-support.ts +253 -0
- package/evals/behavioral-machinery.yaml +614 -0
- package/evals/behavioral-model-negative-control.yaml +68 -0
- package/evals/behavioral-model.yaml +216 -0
- package/evals/fixtures/behavioral-facts.txt +3 -0
- package/evals/fixtures/behavioral-main.ts +7 -0
- package/evals/fixtures/decoy/note.txt +2 -0
- package/evals/fixtures/private/credentials.txt +1 -0
- package/evals/tracked-metrics-baseline.yaml +229 -0
- package/evals/tracked-metrics-grader.mjs +129 -0
- package/package.json +8 -16
- package/skills/README.md +6 -6
- package/skills/coding/ast-grep/SKILL.md +8 -2
- package/skills/coding/coding-standards/SKILL.md +8 -2
- package/skills/coding/prototype/SKILL.md +8 -2
- package/skills/coding/tdd/SKILL.md +8 -2
- package/skills/context/context-handoff/SKILL.md +12 -3
- package/skills/context/context-handoff/evals.md +3 -3
- package/skills/context/context-prime/SKILL.md +8 -2
- package/skills/context/context-prime/evals.md +2 -2
- package/skills/git/file-ticket/SKILL.md +9 -4
- package/skills/git/file-ticket/evals.md +2 -2
- package/skills/git/fix-issue/SKILL.md +12 -5
- package/skills/git/fix-issue/evals.md +4 -4
- package/skills/git/resolve-merge-conflicts/SKILL.md +8 -2
- package/skills/git/resolve-merge-conflicts/evals.md +2 -2
- package/skills/git/ship/SKILL.md +9 -3
- package/skills/git/ship/evals.md +4 -4
- package/skills/git/worktree-create/SKILL.md +7 -2
- package/skills/git/worktree-create/evals.md +6 -6
- package/skills/git/worktree-merge/SKILL.md +7 -2
- package/skills/git/worktree-merge/evals.md +6 -6
- package/skills/meta/{clio-dev → clio-coder-dev}/SKILL.md +14 -8
- package/skills/meta/{clio-dev → clio-coder-dev}/evals.md +3 -3
- package/skills/meta/{clio-test → clio-coder-test}/SKILL.md +11 -5
- package/skills/meta/{clio-test → clio-coder-test}/evals.md +1 -1
- package/skills/meta/credentials/SKILL.md +9 -2
- package/skills/meta/find-skills/SKILL.md +8 -2
- package/skills/meta/herdr/SKILL.md +8 -2
- package/skills/meta/skill-craft/SKILL.md +21 -4
- package/skills/planning/architecture/SKILL.md +9 -3
- package/skills/planning/backlog/SKILL.md +8 -2
- package/skills/planning/prd/SKILL.md +8 -2
- package/skills/planning/product-intent/SKILL.md +8 -2
- package/skills/planning/tech-spec/SKILL.md +9 -3
- package/skills/registry.yaml +66 -66
- package/skills/research/arxiv-literature/SKILL.md +8 -2
- package/skills/research/experiment-protocol/SKILL.md +9 -2
- package/skills/research/scientific-debugging/SKILL.md +9 -2
- package/skills/research/scientific-debugging/evals.md +2 -2
- package/skills/research/scientific-modernization/SKILL.md +9 -2
- package/skills/skill-marketplace.json +257 -38
- package/skills/workflow/cut-it/SKILL.md +10 -2
- package/skills/workflow/design-council/SKILL.md +11 -2
- package/skills/workflow/grill-me/SKILL.md +8 -2
- package/skills/workflow/workflow-distiller/SKILL.md +8 -2
- package/src/cli/acp.ts +8 -4
- package/src/cli/argv.ts +25 -0
- package/src/cli/auth.ts +2 -2
- package/src/cli/bootstrap-generate.ts +5 -5
- package/src/cli/clio.ts +6 -1
- package/src/cli/config-inspect.ts +3 -3
- package/src/cli/configure-interop.ts +1 -1
- package/src/cli/configure.ts +50 -48
- package/src/cli/default-target.ts +1 -1
- package/src/cli/docs.ts +6 -6
- package/src/cli/doctor-naming.ts +323 -0
- package/src/cli/doctor-panes.ts +156 -0
- package/src/cli/doctor-toolchain.ts +78 -0
- package/src/cli/doctor.ts +34 -1
- package/src/cli/eval-inventory.ts +436 -0
- package/src/cli/eval.ts +13 -0
- package/src/cli/evidence-detail.ts +88 -0
- package/src/cli/evidence-inventory.ts +183 -0
- package/src/cli/evidence.ts +30 -5
- package/src/cli/fleet-decisions.ts +69 -0
- package/src/cli/fleet-inspect.ts +334 -0
- package/src/cli/fleet-preflight.ts +1 -1
- package/src/cli/fleet-verify.ts +133 -0
- package/src/cli/fleet-view.ts +827 -0
- package/src/cli/fleet.ts +154 -40
- package/src/cli/index.ts +14 -2
- package/src/cli/interop-inspect.ts +128 -0
- package/src/cli/interop.ts +34 -0
- package/src/cli/models.ts +3 -3
- package/src/cli/modes/print.ts +1 -1
- package/src/cli/panes.ts +35 -0
- package/src/cli/reset.ts +6 -3
- package/src/cli/run.ts +67 -13
- package/src/cli/share.ts +1 -1
- package/src/cli/skills-eval.ts +11 -11
- package/src/cli/skills-inventory.ts +185 -0
- package/src/cli/skills.ts +16 -13
- package/src/cli/targets.ts +23 -24
- package/src/cli/tools.ts +321 -0
- package/src/cli/trace-inspect.ts +252 -0
- package/src/cli/trace.ts +64 -2
- package/src/cli/uninstall.ts +2 -2
- package/src/cli/upgrade.ts +29 -34
- package/src/cli/usage.ts +2 -2
- package/src/cli/validate-model.ts +1 -1
- package/src/cli/verifiers-inspect.ts +347 -0
- package/src/cli/verifiers.ts +9 -0
- package/src/cli/wiki-generate.ts +5 -5
- package/src/core/bash-exec.ts +1 -1
- package/src/core/boot-trace.ts +3 -3
- package/src/core/bus-events.ts +4 -0
- package/src/core/bus-trace.ts +2 -2
- package/src/core/compile-cache.ts +1 -1
- package/src/core/config.ts +1070 -845
- package/src/core/defaults.ts +342 -463
- package/src/core/domain-loader.ts +6 -4
- package/src/core/event-bus.ts +1 -1
- package/src/core/file-references.ts +78 -88
- package/src/core/git-commit-attribution.ts +3 -9
- package/src/core/guardrails.ts +24 -4
- package/src/core/naming-compat.ts +45 -0
- package/src/core/naming-events.ts +62 -0
- package/src/core/recent-models.ts +1 -7
- package/src/core/residency-protection.ts +4 -8
- package/src/core/resolve-config-value.ts +1 -1
- package/src/core/response-model-id.ts +0 -14
- package/src/core/response-schema.ts +44 -4
- package/src/core/session-routing.ts +84 -74
- package/src/core/skill-activation.ts +18 -0
- package/src/core/termination.ts +4 -4
- package/src/core/theme-token-hex.ts +43 -0
- package/src/core/timers.ts +2 -12
- package/src/core/tool-names.ts +2 -1
- package/src/core/xdg.ts +1 -1
- package/src/domains/agents/catalog.ts +2 -12
- package/src/domains/agents/extension.ts +3 -3
- package/src/domains/agents/fleets/build-review.md +0 -3
- package/src/domains/agents/fleets/build-test.md +0 -3
- package/src/domains/agents/registry.ts +7 -7
- package/src/domains/agents/result-contract-filesystem.ts +32 -0
- package/src/domains/agents/result-contract.ts +165 -36
- package/src/domains/agents/spec.ts +0 -11
- package/src/domains/config/classify.ts +37 -46
- package/src/domains/config/extension.ts +5 -5
- package/src/domains/config/keybindings.ts +48 -47
- package/src/domains/config/watcher.ts +1 -1
- package/src/domains/context/codewiki/indexer.ts +1 -1
- package/src/domains/context/extension.ts +3 -3
- package/src/domains/context/prompt-context.ts +1 -1
- package/src/domains/context/wiki/assemble.ts +2 -2
- package/src/domains/context/working-set/replay/metrics.ts +0 -4
- package/src/domains/context/working-set/replay/report.ts +1 -1
- package/src/domains/context/working-set/replay/synthetic.ts +2 -2
- package/src/domains/dispatch/active-route-planner.ts +2 -2
- package/src/domains/dispatch/admission-error.ts +9 -0
- package/src/domains/dispatch/admission.ts +22 -21
- package/src/domains/dispatch/agent-candidates.ts +1 -1
- package/src/domains/dispatch/agent-ledger-store.ts +1 -1
- package/src/domains/dispatch/agent-ledger.ts +1 -1
- package/src/domains/dispatch/assignment.ts +5 -5
- package/src/domains/dispatch/capacity-lease.ts +23 -6
- package/src/domains/dispatch/code-step.ts +1 -1
- package/src/domains/dispatch/contract.ts +2 -2
- package/src/domains/dispatch/council-topology.ts +398 -0
- package/src/domains/dispatch/extension.ts +287 -111
- package/src/domains/dispatch/fleet-node-prompt.ts +62 -0
- package/src/domains/dispatch/fleet-plan.ts +7 -2
- package/src/domains/dispatch/fleet-preflight.ts +8 -17
- package/src/domains/dispatch/fleet-run.ts +59 -3
- package/src/domains/dispatch/gate-decisions.ts +36 -15
- package/src/domains/dispatch/gate-role-prompts.ts +9 -0
- package/src/domains/dispatch/gate-topology.ts +289 -0
- package/src/domains/dispatch/index.ts +19 -0
- package/src/domains/dispatch/intent-compatibility.ts +330 -0
- package/src/domains/dispatch/intent.ts +85 -1
- package/src/domains/dispatch/joint-route-resolver.ts +1 -1
- package/src/domains/dispatch/path-scope.ts +0 -61
- package/src/domains/dispatch/placement.ts +2 -2
- package/src/domains/dispatch/receipt-findings.ts +1 -1
- package/src/domains/dispatch/receipt-integrity.ts +20 -8
- package/src/domains/dispatch/reservation-store.ts +24 -27
- package/src/domains/dispatch/route-decision.ts +1 -1
- package/src/domains/dispatch/route-history.ts +1 -1
- package/src/domains/dispatch/route-policy.ts +1 -1
- package/src/domains/dispatch/route-readiness.ts +0 -28
- package/src/domains/dispatch/run-event-journal-bridge.ts +149 -0
- package/src/domains/dispatch/run-event-journal.ts +599 -0
- package/src/domains/dispatch/state.ts +45 -1
- package/src/domains/dispatch/tool-stats.ts +1 -1
- package/src/domains/dispatch/transport.ts +2 -19
- package/src/domains/dispatch/types.ts +16 -3
- package/src/domains/dispatch/validation.ts +33 -8
- package/src/domains/dispatch/worker-protocol.ts +2 -2
- package/src/domains/eval/artifacts/store.ts +5 -4
- package/src/domains/eval/compare/compare.ts +3 -16
- package/src/domains/eval/compare/thresholds.ts +0 -8
- package/src/domains/eval/execution-provenance.ts +1 -1
- package/src/domains/eval/inventory.ts +113 -0
- package/src/domains/eval/metrics/token-stream.ts +0 -7
- package/src/domains/eval/report.ts +1 -1
- package/src/domains/eval/runner.ts +1 -1
- package/src/domains/eval/runners/clio-run.ts +7 -6
- package/src/domains/eval/runners/external-command.ts +4 -3
- package/src/domains/eval/schema/artifact.ts +1 -1
- package/src/domains/eval/schema/behavioral-metrics.ts +3 -2
- package/src/domains/eval/schema/behavioral.ts +7 -6
- package/src/domains/eval/schema/execution-envelope.ts +4 -2
- package/src/domains/eval/schema/naming.ts +10 -0
- package/src/domains/eval/schema/serving.ts +31 -0
- package/src/domains/eval/schema/suite.ts +2 -2
- package/src/domains/eval/schema/validate.ts +9 -5
- package/src/domains/eval/schema/verdict.ts +4 -2
- package/src/domains/eval/store.ts +12 -2
- package/src/domains/eval/suites/run.ts +12 -6
- package/src/domains/eval/types.ts +1 -1
- package/src/domains/eval/workspaces/git.ts +1 -1
- package/src/domains/eval/workspaces/temp-copy.ts +1 -1
- package/src/domains/evidence/build.ts +13 -5
- package/src/domains/evidence/store.ts +6 -0
- package/src/domains/interop/consent.ts +7 -7
- package/src/domains/interop/extension.ts +1 -1
- package/src/domains/lifecycle/doctor.ts +27 -21
- package/src/domains/lifecycle/migrations/2026-09-01-clio-coder-naming.ts +155 -0
- package/src/domains/lifecycle/migrations/2026-09-01-retire-panes-knobs.ts +59 -0
- package/src/domains/lifecycle/migrations/2026-09-01-settings-v2.ts +338 -0
- package/src/domains/lifecycle/migrations/index.ts +20 -1
- package/src/domains/lifecycle/naming-history.ts +153 -0
- package/src/domains/lifecycle/naming-mutable-state.ts +104 -0
- package/src/domains/lifecycle/naming-resources.ts +261 -0
- package/src/domains/lifecycle/naming-tool-markers.ts +139 -0
- package/src/domains/lifecycle/naming-yazi.ts +81 -0
- package/src/domains/lifecycle/upgrade-notice.ts +1 -1
- package/src/domains/memory/index.ts +0 -1
- package/src/domains/memory/task-memory-handoff.ts +6 -3
- package/src/domains/memory/task-memory-policy.ts +6 -10
- package/src/domains/memory/task-memory-telemetry.ts +1 -0
- package/src/domains/middleware/index.ts +7 -0
- package/src/domains/middleware/marketplace-offer.ts +339 -0
- package/src/domains/middleware/memory-intervention.ts +33 -21
- package/src/domains/middleware/runtime.ts +2 -2
- package/src/domains/mux/contract.ts +566 -0
- package/src/domains/mux/detect.ts +182 -0
- package/src/domains/mux/dock-controller.ts +365 -0
- package/src/domains/mux/extension.ts +53 -0
- package/src/domains/mux/index.ts +116 -0
- package/src/domains/mux/manifest.ts +6 -0
- package/src/domains/mux/operations.ts +192 -0
- package/src/domains/mux/pane-registry.ts +90 -0
- package/src/domains/mux/protocol.ts +62 -0
- package/src/domains/mux/socket-client.ts +964 -0
- package/src/domains/mux/types.ts +265 -0
- package/src/domains/mux/viewer-command.ts +59 -0
- package/src/domains/mux/yazi/assets/init.lua +2 -0
- package/src/domains/mux/yazi/assets/plugins/git.yazi/LICENSE +21 -0
- package/src/domains/mux/yazi/assets/plugins/git.yazi/README.md +78 -0
- package/src/domains/mux/yazi/assets/plugins/git.yazi/main.lua +255 -0
- package/src/domains/mux/yazi/assets/plugins/git.yazi/types.lua +12 -0
- package/src/domains/mux/yazi/assets/yazi.toml +17 -0
- package/src/domains/mux/yazi/event-stream.ts +182 -0
- package/src/domains/mux/yazi/profile.ts +299 -0
- package/src/domains/mux/yazi/session.ts +251 -0
- package/src/domains/mux/yazi/theme.ts +30 -0
- package/src/domains/observability/cost.ts +21 -0
- package/src/domains/observability/extension.ts +1 -1
- package/src/domains/observability/index.ts +2 -0
- package/src/domains/observability/out-of-turn-usage.ts +2 -2
- package/src/domains/observability/projection.ts +1 -1
- package/src/domains/observability/trace-store.ts +63 -11
- package/src/domains/prompts/compiler.ts +2 -2
- package/src/domains/prompts/extension.ts +3 -3
- package/src/domains/prompts/fragments/identity/clio-worker.md +1 -1
- package/src/domains/prompts/fragments/operating/skills.md +25 -18
- package/src/domains/providers/endpoint-capacity.ts +154 -22
- package/src/domains/providers/endpoint-slots-store.ts +189 -0
- package/src/domains/providers/extension.ts +25 -8
- package/src/domains/providers/index.ts +22 -0
- package/src/domains/providers/knowledge-base-path.ts +1 -1
- package/src/domains/providers/model-runtime-capabilities.ts +46 -2
- package/src/domains/providers/models/cloud-models/alcf.yaml +1 -1
- package/src/domains/providers/models/local-models/{clio-local-coding-targets.yaml → clio-coder-local-coding-targets.yaml} +4 -4
- package/src/domains/providers/plugins.ts +1 -1
- package/src/domains/providers/resolver.ts +1 -1
- package/src/domains/providers/runtimes/boot-manifest.ts +1 -0
- package/src/domains/providers/runtimes/builtins.ts +2 -0
- package/src/domains/providers/runtimes/cloud/alcf.ts +4 -4
- package/src/domains/providers/runtimes/common/lmstudio-http.ts +1 -5
- package/src/domains/providers/runtimes/common/local-synth.ts +3 -3
- package/src/domains/providers/runtimes/common/probe-helpers.ts +2 -2
- package/src/domains/providers/runtimes/local-native/llamacpp-completion.ts +1 -1
- package/src/domains/providers/runtimes/local-native/lmstudio.ts +2 -9
- package/src/domains/providers/runtimes/protocol/litellm.ts +285 -0
- package/src/domains/providers/support.ts +1 -0
- package/src/domains/providers/target-model-cache.ts +124 -0
- package/src/domains/providers/types/knowledge-base.ts +13 -0
- package/src/domains/providers/types/local-model-quirks.ts +2 -2
- package/src/domains/providers/types/target-descriptor.ts +3 -3
- package/src/domains/resources/extension.ts +1 -1
- package/src/domains/resources/index.ts +3 -0
- package/src/domains/resources/library.ts +6 -6
- package/src/domains/resources/prompts/loader.ts +1 -1
- package/src/domains/resources/skills/content-hash.ts +7 -6
- package/src/domains/resources/skills/evals.ts +1 -1
- package/src/domains/resources/skills/install.ts +36 -12
- package/src/domains/resources/skills/loader.ts +72 -13
- package/src/domains/resources/skills/marketplace.ts +21 -2
- package/src/domains/resources/skills/promotion.ts +214 -0
- package/src/domains/safety/action-classifier.ts +6 -0
- package/src/domains/safety/audit.ts +2 -2
- package/src/domains/safety/finish-contract.ts +2 -1
- package/src/domains/safety/run-effects.ts +1 -1
- package/src/domains/scheduling/extension.ts +4 -4
- package/src/domains/session/archive-readers.ts +9 -1
- package/src/domains/session/compaction/branch-summary.ts +4 -0
- package/src/domains/session/compaction/compact.ts +1 -1
- package/src/domains/session/compaction/tokens.ts +4 -0
- package/src/domains/session/context-accounting.ts +1 -1
- package/src/domains/session/decision-board.ts +1 -1
- package/src/domains/session/extension.ts +1 -1
- package/src/domains/session/handoff.ts +2 -2
- package/src/domains/session/prompt-manifest.ts +0 -5
- package/src/domains/session/protected-artifact-journal.ts +12 -6
- package/src/domains/session/retry.ts +1 -1
- package/src/domains/share/archive.ts +85 -36
- package/src/domains/toolchain/archive.ts +175 -0
- package/src/domains/toolchain/contract.ts +28 -0
- package/src/domains/toolchain/extension.ts +47 -0
- package/src/domains/toolchain/index.ts +39 -0
- package/src/domains/toolchain/install.ts +327 -0
- package/src/domains/toolchain/manifest.ts +8 -0
- package/src/domains/toolchain/paths.ts +34 -0
- package/src/domains/toolchain/registry.ts +265 -0
- package/src/domains/toolchain/remove.ts +218 -0
- package/src/domains/toolchain/resolve.ts +182 -0
- package/src/domains/toolchain/types.ts +113 -0
- package/src/domains/toolchain/version.ts +88 -0
- package/src/engine/acp/adapter.ts +3 -3
- package/src/engine/acp/event-mapper.ts +3 -3
- package/src/engine/acp/server.ts +440 -96
- package/src/engine/acp/tool-mediator.ts +2 -2
- package/src/engine/acp/types.ts +20 -2
- package/src/engine/alcf-oauth.ts +5 -5
- package/src/engine/antigravity/subprocess-runtime.ts +2 -2
- package/src/engine/api-registry.ts +1 -1
- package/src/engine/apis/llamacpp-residency.ts +1 -19
- package/src/engine/apis/lmstudio.ts +1 -6
- package/src/engine/apis/ollama-native.ts +3 -3
- package/src/engine/apis/openai-completions.ts +2 -2
- package/src/engine/apis/residency.ts +3 -9
- package/src/engine/claude/sdk-module.ts +87 -0
- package/src/engine/claude/sdk-runtime.ts +25 -17
- package/src/engine/claude/subprocess-runtime.ts +1 -1
- package/src/engine/claude/tool-safety.ts +4 -4
- package/src/engine/loop-guard.ts +0 -5
- package/src/engine/session.ts +14 -7
- package/src/engine/tui-primitives.ts +21 -0
- package/src/engine/tui.ts +1 -0
- package/src/engine/worker-events.ts +6 -6
- package/src/engine/worker-runtime.ts +16 -26
- package/src/entry/boot-options.ts +2 -0
- package/src/entry/orchestrator.ts +207 -90
- package/src/entry/panes-activation.ts +31 -0
- package/src/entry/with-panes.ts +20 -0
- package/src/interactive/application-controller.ts +21 -21
- package/src/interactive/bus-notices.ts +2 -2
- package/src/interactive/chat-loop.ts +8 -8
- package/src/interactive/chat-panel.ts +1 -1
- package/src/interactive/clio-editor.ts +105 -1
- package/src/interactive/context-activity.ts +8 -6
- package/src/interactive/context-meter.ts +3 -6
- package/src/interactive/context-overlay.ts +2 -1
- package/src/interactive/cost-overlay.ts +3 -1
- package/src/interactive/council-grid.ts +3 -5
- package/src/interactive/council.ts +11 -0
- package/src/interactive/dispatch-board.ts +56 -49
- package/src/interactive/editor-bash.ts +21 -0
- package/src/interactive/editor-steer.ts +9 -4
- package/src/interactive/editor-submit.ts +24 -18
- package/src/interactive/external-editor.ts +1 -1
- package/src/interactive/file-reference-completion.ts +360 -0
- package/src/interactive/footer/dashboard.ts +15 -17
- package/src/interactive/footer/notifications.ts +14 -8
- package/src/interactive/footer/widgets.ts +2 -44
- package/src/interactive/interactive-application.ts +229 -62
- package/src/interactive/interactive-event-projection.ts +1 -1
- package/src/interactive/interactive-input-runtime.ts +9 -2
- package/src/interactive/interactive-presentation.ts +21 -16
- package/src/interactive/interactive-shell.ts +2 -2
- package/src/interactive/interactive-slash-runtime.ts +99 -23
- package/src/interactive/interactive-subscriptions.ts +1 -1
- package/src/interactive/interactive-tickers.ts +1 -1
- package/src/interactive/keybinding-manager.ts +4 -4
- package/src/interactive/layout.ts +1 -1
- package/src/interactive/memory-overlay.ts +3 -2
- package/src/interactive/modal-marker.ts +151 -0
- package/src/interactive/mutation-preview.ts +1 -1
- package/src/interactive/mux-bridge.ts +214 -0
- package/src/interactive/overlay-frame.ts +62 -14
- package/src/interactive/overlay-general-openers.ts +7 -2
- package/src/interactive/overlay-key-routing.ts +21 -10
- package/src/interactive/overlay-lifecycle.ts +20 -4
- package/src/interactive/overlay-model-selectors.ts +43 -6
- package/src/interactive/overlay-permission-lifecycle.ts +90 -22
- package/src/interactive/overlay-transitions.ts +18 -4
- package/src/interactive/overlays/agents.ts +3 -2
- package/src/interactive/overlays/ask-user.ts +161 -41
- package/src/interactive/overlays/auth-dialog.ts +1 -0
- package/src/interactive/overlays/context-reset.ts +29 -4
- package/src/interactive/overlays/cwd-fallback.ts +29 -4
- package/src/interactive/overlays/decisions.ts +15 -13
- package/src/interactive/overlays/extensions.ts +1 -0
- package/src/interactive/overlays/fleet-run-approval.ts +4 -3
- package/src/interactive/overlays/handoff-review.ts +3 -2
- package/src/interactive/overlays/help-reference.ts +2 -0
- package/src/interactive/overlays/interop.ts +2 -1
- package/src/interactive/overlays/library-install-confirm.ts +2 -1
- package/src/interactive/overlays/library-tabs.ts +28 -0
- package/src/interactive/overlays/list-overlay.ts +10 -1
- package/src/interactive/overlays/message-picker.ts +2 -1
- package/src/interactive/overlays/model-scope.ts +86 -0
- package/src/interactive/overlays/model-selector.ts +40 -31
- package/src/interactive/overlays/prompts.ts +11 -4
- package/src/interactive/overlays/session-selector.ts +3 -2
- package/src/interactive/overlays/settings-sections.ts +30 -0
- package/src/interactive/overlays/settings.ts +849 -268
- package/src/interactive/overlays/side-question.ts +3 -2
- package/src/interactive/overlays/skills-hub.ts +11 -19
- package/src/interactive/overlays/tree-selector.ts +3 -2
- package/src/interactive/pane-policy.ts +46 -0
- package/src/interactive/panes-runtime.ts +318 -0
- package/src/interactive/permission-overlay.ts +2 -2
- package/src/interactive/renderers/compaction-summary.ts +29 -0
- package/src/interactive/renderers/retry-status.ts +12 -4
- package/src/interactive/renderers/tool-execution.ts +4 -4
- package/src/interactive/renderers/worker-entry.ts +122 -14
- package/src/interactive/session-transcript.ts +3 -3
- package/src/interactive/slash-autocomplete.ts +454 -165
- package/src/interactive/slash-commands.ts +521 -189
- package/src/interactive/slash-spec.ts +160 -17
- package/src/interactive/status/controller.ts +2 -2
- package/src/interactive/stream-pacing-policy.ts +1 -1
- package/src/interactive/tasks-overlay.ts +21 -13
- package/src/interactive/terminal-lease.ts +6 -7
- package/src/interactive/theme/tokens.ts +3 -14
- package/src/interactive/turn-context.ts +58 -13
- package/src/interactive/turn-persistence.ts +2 -2
- package/src/interactive/turn-prewarm.ts +2 -2
- package/src/interactive/turn-runtime.ts +8 -8
- package/src/interactive/turn-state.ts +1 -1
- package/src/interactive/view/artifacts.ts +120 -9
- package/src/interactive/view/view-overlay.ts +14 -10
- package/src/interactive/watch-pane.ts +180 -0
- package/src/interactive/welcome-dashboard.ts +15 -15
- package/src/interactive/worker-progress.ts +11 -5
- package/src/interactive/worker-receipts.ts +20 -2
- package/src/interactive/worker-stream.ts +6 -4
- package/src/interactive/yazi-bridge.ts +451 -0
- package/src/tools/ask-user.ts +3 -3
- package/src/tools/bash.ts +1 -1
- package/src/tools/bootstrap.ts +26 -2
- package/src/tools/builtin-tool-catalog.ts +16 -1
- package/src/tools/compete-worktrees.ts +108 -17
- package/src/tools/context/index.ts +15 -1
- package/src/tools/core-bootstrap.ts +2 -1
- package/src/tools/dispatch-admission.ts +18 -5
- package/src/tools/dispatch-arguments.ts +21 -21
- package/src/tools/dispatch-plan.ts +0 -11
- package/src/tools/dispatch-run-events.ts +145 -28
- package/src/tools/dispatch-runner.ts +40 -13
- package/src/tools/dispatch-types.ts +15 -3
- package/src/tools/dispatch.ts +2 -2
- package/src/tools/executables.ts +17 -14
- package/src/tools/find.ts +1 -6
- package/src/tools/monitor.ts +4 -4
- package/src/tools/observation.ts +54 -4
- package/src/tools/observers.ts +0 -33
- package/src/tools/panes-surface.ts +38 -0
- package/src/tools/panes.ts +112 -0
- package/src/tools/policy.ts +10 -1
- package/src/tools/presentation.ts +1 -0
- package/src/tools/task-worktree.ts +28 -7
- package/src/tools/verify/authoring.ts +3 -6
- package/src/tools/verify/frontend.ts +1 -1
- package/src/tools/web-fetch.ts +1 -1
- package/src/worker/entry.ts +4 -3
- package/src/worker/protocol.ts +16 -14
- package/src/worker/spec-contract.ts +2 -2
- package/src/worker/stdin-demux.ts +2 -2
- package/dist/chunk-D73KXYPF.js +0 -37
- package/dist/chunk-MLOK6ZOS.js +0 -2888
- package/dist/chunk-PNY46YEY.js +0 -1581
- package/dist/chunk-XDOQXGFO.js +0 -515
- package/dist/chunk-YKOFT37S.js +0 -279
- package/dist/clio-LT5V7SSZ.js +0 -26
- package/dist/configure-2WYWSCSD.js +0 -49
- package/dist/doctor-TWBWFK5V.js +0 -165
- package/src/engine/apis/degraded-inference.ts +0 -95
- /package/skills/meta/{clio-test → clio-coder-test}/references/harness.md +0 -0
- /package/skills/meta/{clio-test → clio-coder-test}/references/test-map.md +0 -0
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
decideReviewGate,
|
|
4
|
+
materializePendingGateDecision,
|
|
5
|
+
readGateDecisionArtifacts,
|
|
6
|
+
readGateDecisionArtifactsForRunIds,
|
|
7
|
+
stagePendingGateDecision,
|
|
8
|
+
verifyGateDecisionArtifact
|
|
9
|
+
} from "./chunk-GPPB3JBE.js";
|
|
2
10
|
import {
|
|
3
11
|
RUN_RECEIPT_INTEGRITY_ALGORITHM,
|
|
4
12
|
RUN_RECEIPT_INTEGRITY_VERSION,
|
|
@@ -10,24 +18,20 @@ import {
|
|
|
10
18
|
inspectRunReceiptTrustStatus,
|
|
11
19
|
isReceiptIntegrity,
|
|
12
20
|
isTrustStatusIdentifier,
|
|
13
|
-
loadEvalArtifact,
|
|
14
21
|
normalizeTrustStatus,
|
|
15
|
-
parseEvalArtifactV4,
|
|
16
|
-
redactArtifactForStorage,
|
|
17
22
|
retiredIntegrityVersionOf,
|
|
18
23
|
sha256,
|
|
19
|
-
sumEvalHarnessMetrics,
|
|
20
24
|
trustVerdict,
|
|
21
25
|
verifyReceiptIntegrity,
|
|
22
26
|
withReceiptIntegrity
|
|
23
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-6NJQITNH.js";
|
|
24
28
|
import {
|
|
25
29
|
protectedArtifactFromSessionEntry,
|
|
26
30
|
protectedArtifactStateFromSessionEntries,
|
|
27
31
|
readAuditRows,
|
|
28
32
|
readSessionEntriesForId,
|
|
29
33
|
responseModelIdObservationFromRecord
|
|
30
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-TVH4ONAM.js";
|
|
31
35
|
import {
|
|
32
36
|
applyTaskWorktree,
|
|
33
37
|
captureWorkspaceSnapshot,
|
|
@@ -35,19 +39,32 @@ import {
|
|
|
35
39
|
createTaskWorktree,
|
|
36
40
|
createWriteBoundaryEnforcer,
|
|
37
41
|
gitCheckoutRoot
|
|
38
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-TD3PGPQA.js";
|
|
39
43
|
import {
|
|
40
44
|
executionPlanAncestors,
|
|
41
45
|
spliceExecutionPlan
|
|
42
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-THYWACCR.js";
|
|
43
47
|
import {
|
|
44
48
|
parseRigorOverride,
|
|
45
49
|
resolveRigor
|
|
46
50
|
} from "./chunk-RVG5JXAL.js";
|
|
47
51
|
import {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
loadEvalArtifact,
|
|
53
|
+
parseEvalArtifactV4,
|
|
54
|
+
redactArtifactForStorage,
|
|
55
|
+
sumEvalHarnessMetrics
|
|
56
|
+
} from "./chunk-6CCS4G3W.js";
|
|
57
|
+
import {
|
|
58
|
+
defaultRunEventJournal,
|
|
59
|
+
removeRunEventJournals
|
|
60
|
+
} from "./chunk-6VC4OV3Z.js";
|
|
61
|
+
import {
|
|
62
|
+
AdmissionCanceledError,
|
|
63
|
+
EVENT_TEE_LIMIT,
|
|
64
|
+
createWorkerOutputCapture,
|
|
65
|
+
durableAssistantTextFromEvent,
|
|
66
|
+
startDispatchEventPump
|
|
67
|
+
} from "./chunk-T56WDKA5.js";
|
|
51
68
|
import {
|
|
52
69
|
LOCAL_NODE_ID,
|
|
53
70
|
computeSettingsFingerprint,
|
|
@@ -58,9 +75,14 @@ import {
|
|
|
58
75
|
receiptAttestationFields,
|
|
59
76
|
routeFactVerdict,
|
|
60
77
|
spawnNativeWorker
|
|
61
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-AFKWHWXF.js";
|
|
79
|
+
import {
|
|
80
|
+
FLEET_COMMAND_BASE_ENV,
|
|
81
|
+
normalizeWriteBoundary
|
|
82
|
+
} from "./chunk-CTJ4RNAA.js";
|
|
62
83
|
import {
|
|
63
84
|
AGENT_LEDGER_PROMPT_MAX_CHARS,
|
|
85
|
+
COUNCIL_MIN_MEMBERS,
|
|
64
86
|
RETRYABLE_OUTCOMES,
|
|
65
87
|
UnsupportedResponseSchemaError,
|
|
66
88
|
WORKER_EXIT_PERMISSION_REQUIRED,
|
|
@@ -70,24 +92,23 @@ import {
|
|
|
70
92
|
agentRoleReadinessReport,
|
|
71
93
|
agentRouteCandidates,
|
|
72
94
|
antigravitySubprocessConfigForAutonomy,
|
|
73
|
-
applyToolProfile,
|
|
74
95
|
approvedRouteCandidates,
|
|
75
96
|
assertApprovedAssignmentRoute,
|
|
76
97
|
assertApprovedRecoveryCapability,
|
|
77
|
-
assertToolProfileEnforceable,
|
|
78
98
|
claimConflicts,
|
|
79
99
|
classifyAgentTask,
|
|
80
100
|
claudeSubprocessPermissionConfigForAutonomy,
|
|
81
101
|
competeStanceLiner,
|
|
82
102
|
createRunEffectsRecorder,
|
|
103
|
+
declaredScopeIntent,
|
|
83
104
|
declaredScopeReplacementDiagnostic,
|
|
84
105
|
declaredScopeReplacementNotice,
|
|
85
|
-
describeCallAction,
|
|
86
106
|
isBoundedGateRolePrompt,
|
|
87
107
|
isClaudeCanonicalTool,
|
|
88
108
|
isResponseSchemaRejection,
|
|
89
109
|
isRunOutcomeCode,
|
|
90
110
|
networkToolsDisabled,
|
|
111
|
+
nodeResultContractFilesystem,
|
|
91
112
|
projectExecutionHandoffs,
|
|
92
113
|
renderAgentLedger,
|
|
93
114
|
resolveDispatchPathScope,
|
|
@@ -98,7 +119,7 @@ import {
|
|
|
98
119
|
serializeWorkerRuntimeDescriptor,
|
|
99
120
|
toolPromptHintsForNames,
|
|
100
121
|
validateJobSpec
|
|
101
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-2VG7KLYV.js";
|
|
102
123
|
import {
|
|
103
124
|
decideRoute,
|
|
104
125
|
defaultRoutingIntent,
|
|
@@ -116,7 +137,20 @@ import {
|
|
|
116
137
|
routingIntentRejection,
|
|
117
138
|
sameRouteIdentity,
|
|
118
139
|
toRouteCandidate
|
|
119
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-7EPLI7VL.js";
|
|
141
|
+
import {
|
|
142
|
+
assessFinishContract
|
|
143
|
+
} from "./chunk-PVAMAVBB.js";
|
|
144
|
+
import {
|
|
145
|
+
WRITE_ROOT_REFUSED_TOOLS
|
|
146
|
+
} from "./chunk-IXJT6DCX.js";
|
|
147
|
+
import {
|
|
148
|
+
describeCallAction
|
|
149
|
+
} from "./chunk-TVHHYFHE.js";
|
|
150
|
+
import {
|
|
151
|
+
applyToolProfile,
|
|
152
|
+
assertToolProfileEnforceable
|
|
153
|
+
} from "./chunk-42FMPA75.js";
|
|
120
154
|
import {
|
|
121
155
|
appliesRecipeResultContract,
|
|
122
156
|
gateRouteCorrelation,
|
|
@@ -126,14 +160,30 @@ import {
|
|
|
126
160
|
withAttemptRole
|
|
127
161
|
} from "./chunk-H7IXIC72.js";
|
|
128
162
|
import {
|
|
129
|
-
|
|
130
|
-
} from "./chunk-
|
|
163
|
+
compareCodepoints
|
|
164
|
+
} from "./chunk-VN3SHNBN.js";
|
|
131
165
|
import {
|
|
132
|
-
|
|
133
|
-
|
|
166
|
+
DEFAULT_AUTONOMY_LEVEL,
|
|
167
|
+
autonomyDenyRejection,
|
|
168
|
+
isSkillActivation,
|
|
169
|
+
mapAutonomy
|
|
170
|
+
} from "./chunk-FSP7CMNU.js";
|
|
134
171
|
import {
|
|
135
|
-
|
|
136
|
-
|
|
172
|
+
createRedactionTally,
|
|
173
|
+
redactSecretsDeep,
|
|
174
|
+
redactSecretsText
|
|
175
|
+
} from "./chunk-4BJ5BYCE.js";
|
|
176
|
+
import {
|
|
177
|
+
truncateUtf8
|
|
178
|
+
} from "./chunk-6XLNIQDB.js";
|
|
179
|
+
import {
|
|
180
|
+
canonicalJson,
|
|
181
|
+
endpointIdentityHash,
|
|
182
|
+
parseAgentLedgerBody
|
|
183
|
+
} from "./chunk-VAVR4IJY.js";
|
|
184
|
+
import {
|
|
185
|
+
pathBoundaryCovers
|
|
186
|
+
} from "./chunk-HHV2GANA.js";
|
|
137
187
|
import {
|
|
138
188
|
agentSpecFingerprint,
|
|
139
189
|
assertAgentSpecPolicy,
|
|
@@ -141,78 +191,65 @@ import {
|
|
|
141
191
|
isUserVisibleAgent,
|
|
142
192
|
normalizeAgentSpec,
|
|
143
193
|
parseJsonObjectPayload,
|
|
144
|
-
parseVerifierResult,
|
|
145
|
-
pathBoundaryCovers,
|
|
146
194
|
resolveAgentToolCompatibility,
|
|
147
195
|
resultContractAuthorship,
|
|
148
196
|
validateRecipeResult
|
|
149
|
-
} from "./chunk-
|
|
197
|
+
} from "./chunk-IG7BCQBA.js";
|
|
150
198
|
import {
|
|
151
199
|
detectValidationCommand
|
|
152
|
-
} from "./chunk-
|
|
153
|
-
import {
|
|
154
|
-
DEFAULT_AUTONOMY_LEVEL,
|
|
155
|
-
autonomyDenyRejection,
|
|
156
|
-
isSkillActivation,
|
|
157
|
-
mapAutonomy
|
|
158
|
-
} from "./chunk-RAPCMZL4.js";
|
|
200
|
+
} from "./chunk-GCSMB2KY.js";
|
|
159
201
|
import {
|
|
160
202
|
isProjectVerifierCheckId,
|
|
161
203
|
isVerificationScriptName
|
|
162
204
|
} from "./chunk-UL3WSD3F.js";
|
|
163
|
-
import {
|
|
164
|
-
createRedactionTally,
|
|
165
|
-
redactSecretsDeep,
|
|
166
|
-
redactSecretsText
|
|
167
|
-
} from "./chunk-4BJ5BYCE.js";
|
|
168
205
|
import {
|
|
169
206
|
canonicalizeExistingPath
|
|
170
207
|
} from "./chunk-ECH6PKUQ.js";
|
|
171
|
-
import {
|
|
172
|
-
canonicalJson,
|
|
173
|
-
endpointIdentityHash,
|
|
174
|
-
parseAgentLedgerBody
|
|
175
|
-
} from "./chunk-CMZWFGD2.js";
|
|
176
|
-
import {
|
|
177
|
-
truncateUtf8
|
|
178
|
-
} from "./chunk-6XLNIQDB.js";
|
|
179
208
|
import {
|
|
180
209
|
ToolNames,
|
|
181
210
|
isBuiltinToolName
|
|
182
|
-
} from "./chunk-
|
|
211
|
+
} from "./chunk-K6BSR66V.js";
|
|
183
212
|
import {
|
|
184
213
|
canonicalizeWireModelId,
|
|
185
|
-
|
|
214
|
+
endpointCapacityFor,
|
|
186
215
|
endpointCapacityForStatus,
|
|
187
216
|
endpointLabel,
|
|
188
217
|
firstRuntimeResolutionError,
|
|
189
218
|
foregroundStreamUsage,
|
|
190
219
|
isDispatchEligibleRuntime,
|
|
220
|
+
normalizeCostProvenance,
|
|
221
|
+
resolveEndpointCapacities,
|
|
191
222
|
resolveModelCapabilities,
|
|
192
223
|
resolveRuntimeTarget,
|
|
193
224
|
runtimeResolutionWarnings,
|
|
194
225
|
runtimeTargetSnapshot
|
|
195
|
-
} from "./chunk-
|
|
226
|
+
} from "./chunk-UEDMSP56.js";
|
|
196
227
|
import {
|
|
197
228
|
ceilChars
|
|
198
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-CWVRRIEI.js";
|
|
230
|
+
import {
|
|
231
|
+
atomicWrite
|
|
232
|
+
} from "./chunk-MQXIVJ35.js";
|
|
233
|
+
import {
|
|
234
|
+
assertSafeId
|
|
235
|
+
} from "./chunk-R346GLFC.js";
|
|
236
|
+
import {
|
|
237
|
+
BusChannels
|
|
238
|
+
} from "./chunk-HLW2MRKE.js";
|
|
239
|
+
import {
|
|
240
|
+
normalizeClioCoderEventRecord,
|
|
241
|
+
normalizeClioCoderEventType
|
|
242
|
+
} from "./chunk-BTK3SSSK.js";
|
|
199
243
|
import {
|
|
200
244
|
attributeCommitMessage,
|
|
201
245
|
gitCommitAttributionEnabled,
|
|
202
246
|
reportCommitAttributionDiagnostic,
|
|
203
247
|
withManagedGitCommitAttributionEnvironment
|
|
204
|
-
} from "./chunk-
|
|
248
|
+
} from "./chunk-JIEGK6UF.js";
|
|
205
249
|
import {
|
|
206
250
|
MAX_TIMER_DELAY_MS,
|
|
207
251
|
rawDurationMs
|
|
208
|
-
} from "./chunk-
|
|
209
|
-
import {
|
|
210
|
-
BusChannels
|
|
211
|
-
} from "./chunk-RKRLDWD3.js";
|
|
212
|
-
import {
|
|
213
|
-
assertSafeId,
|
|
214
|
-
atomicWrite
|
|
215
|
-
} from "./chunk-KV2AOLDF.js";
|
|
252
|
+
} from "./chunk-EBY63B7G.js";
|
|
216
253
|
import {
|
|
217
254
|
AI_AGENT_NAME
|
|
218
255
|
} from "./chunk-6EJMN2Y3.js";
|
|
@@ -226,14 +263,14 @@ import {
|
|
|
226
263
|
DEFAULT_DELEGATION_TURN_TIMEOUT_MS,
|
|
227
264
|
DEFAULT_SETTINGS,
|
|
228
265
|
THINKING_LEVELS
|
|
229
|
-
} from "./chunk-
|
|
266
|
+
} from "./chunk-BWW4HLO4.js";
|
|
230
267
|
import {
|
|
231
268
|
GUARDRAIL_DEFAULTS,
|
|
232
269
|
resolveGuardrail
|
|
233
|
-
} from "./chunk-
|
|
270
|
+
} from "./chunk-NLFAQR7Z.js";
|
|
234
271
|
import {
|
|
235
272
|
targetRequiresAuth
|
|
236
|
-
} from "./chunk-
|
|
273
|
+
} from "./chunk-WNP7O5WZ.js";
|
|
237
274
|
import {
|
|
238
275
|
FILE_LOCK_ACQUIRE_TIMEOUT_MS,
|
|
239
276
|
withStateFileLock,
|
|
@@ -248,10 +285,10 @@ import {
|
|
|
248
285
|
clioDataDir,
|
|
249
286
|
clioStateDir,
|
|
250
287
|
stateRootRemoved
|
|
251
|
-
} from "./chunk-
|
|
288
|
+
} from "./chunk-BYP5D4HI.js";
|
|
252
289
|
import {
|
|
253
290
|
resolveEffectivePricing
|
|
254
|
-
} from "./chunk-
|
|
291
|
+
} from "./chunk-O42A54GG.js";
|
|
255
292
|
import {
|
|
256
293
|
init_esm_shims
|
|
257
294
|
} from "./chunk-3R73A4XB.js";
|
|
@@ -265,10 +302,10 @@ function protectedResidencyModels(settings) {
|
|
|
265
302
|
if (!trimmed || byId.has(trimmed)) return;
|
|
266
303
|
byId.set(trimmed, role);
|
|
267
304
|
};
|
|
268
|
-
add(settings.
|
|
269
|
-
add(settings.
|
|
270
|
-
add(settings.
|
|
271
|
-
for (const profile of Object.values(settings.
|
|
305
|
+
add(settings.chat.model, "chat");
|
|
306
|
+
add(settings.context.memory.model, "memory");
|
|
307
|
+
add(settings.fleet.default.model, "worker");
|
|
308
|
+
for (const profile of Object.values(settings.fleet.profiles ?? {})) add(profile.model, "worker");
|
|
272
309
|
for (const target of settings.targets) add(target.defaultModel, "target-default");
|
|
273
310
|
return [...byId].map(([modelId, role]) => ({ modelId, role }));
|
|
274
311
|
}
|
|
@@ -409,8 +446,8 @@ var StdioJsonRpcTransport = class {
|
|
|
409
446
|
constructor(command, args, options = {}) {
|
|
410
447
|
this.terminationGraceMs = boundedMilliseconds(options.terminationGraceMs, 500);
|
|
411
448
|
this.terminationWaitMs = boundedMilliseconds(options.terminationWaitMs, 2e3);
|
|
412
|
-
this.childClosePromise = new Promise((
|
|
413
|
-
this.resolveChildClose =
|
|
449
|
+
this.childClosePromise = new Promise((resolve4) => {
|
|
450
|
+
this.resolveChildClose = resolve4;
|
|
414
451
|
});
|
|
415
452
|
const childEnvironment = options.env ? { ...process.env, ...options.env } : process.env;
|
|
416
453
|
const attribution = withManagedGitCommitAttributionEnvironment(childEnvironment, {
|
|
@@ -467,10 +504,10 @@ var StdioJsonRpcTransport = class {
|
|
|
467
504
|
const requestTimeoutMs = validateRequestTimeout(method, timeoutMs);
|
|
468
505
|
const id = this.nextId++;
|
|
469
506
|
const message = { jsonrpc: "2.0", id, method, params };
|
|
470
|
-
const promise = new Promise((
|
|
507
|
+
const promise = new Promise((resolve4, reject) => {
|
|
471
508
|
const pending = {
|
|
472
509
|
method,
|
|
473
|
-
resolve: (value) =>
|
|
510
|
+
resolve: (value) => resolve4(value),
|
|
474
511
|
reject
|
|
475
512
|
};
|
|
476
513
|
if (requestTimeoutMs !== void 0) {
|
|
@@ -657,9 +694,9 @@ var StdioJsonRpcTransport = class {
|
|
|
657
694
|
if (remaining <= 0) return this.terminationObserved();
|
|
658
695
|
const interval = Math.min(10, remaining);
|
|
659
696
|
if (this.childHandlesClosed) {
|
|
660
|
-
await new Promise((
|
|
697
|
+
await new Promise((resolve4) => setTimeout(resolve4, interval));
|
|
661
698
|
} else {
|
|
662
|
-
await Promise.race([this.childClosePromise, new Promise((
|
|
699
|
+
await Promise.race([this.childClosePromise, new Promise((resolve4) => setTimeout(resolve4, interval))]);
|
|
663
700
|
}
|
|
664
701
|
}
|
|
665
702
|
return true;
|
|
@@ -724,10 +761,10 @@ var StreamJsonRpcPeerTransport = class {
|
|
|
724
761
|
const requestTimeoutMs = validateRequestTimeout(method, timeoutMs);
|
|
725
762
|
const id = this.nextId++;
|
|
726
763
|
const message = { jsonrpc: "2.0", id, method, params };
|
|
727
|
-
const promise = new Promise((
|
|
764
|
+
const promise = new Promise((resolve4, reject) => {
|
|
728
765
|
const pending = {
|
|
729
766
|
method,
|
|
730
|
-
resolve: (value) =>
|
|
767
|
+
resolve: (value) => resolve4(value),
|
|
731
768
|
reject
|
|
732
769
|
};
|
|
733
770
|
if (requestTimeoutMs !== void 0) {
|
|
@@ -891,162 +928,6 @@ function createStdioServerTransport(options = {}) {
|
|
|
891
928
|
return new StreamJsonRpcPeerTransport(options);
|
|
892
929
|
}
|
|
893
930
|
|
|
894
|
-
// src/domains/dispatch/event-pump.ts
|
|
895
|
-
init_esm_shims();
|
|
896
|
-
var EVENT_TEE_LIMIT = 1024;
|
|
897
|
-
function startDispatchEventPump(source, fold, options = {}) {
|
|
898
|
-
const limit = options.limit ?? EVENT_TEE_LIMIT;
|
|
899
|
-
const pending = [...options.prelude ?? []];
|
|
900
|
-
const waiters = [];
|
|
901
|
-
let finished = false;
|
|
902
|
-
let abandoned = false;
|
|
903
|
-
let dropped = 0;
|
|
904
|
-
const push = (value) => {
|
|
905
|
-
if (abandoned) return;
|
|
906
|
-
const waiter = waiters.shift();
|
|
907
|
-
if (waiter) {
|
|
908
|
-
waiter({ value, done: false });
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
911
|
-
pending.push(value);
|
|
912
|
-
while (pending.length > limit) {
|
|
913
|
-
pending.shift();
|
|
914
|
-
dropped += 1;
|
|
915
|
-
}
|
|
916
|
-
};
|
|
917
|
-
const end = () => {
|
|
918
|
-
finished = true;
|
|
919
|
-
while (waiters.length > 0) {
|
|
920
|
-
waiters.shift()?.({ value: void 0, done: true });
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
const notify = (event) => {
|
|
924
|
-
try {
|
|
925
|
-
options.onEvent?.(event);
|
|
926
|
-
} catch (error) {
|
|
927
|
-
options.onError?.(error);
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
const done = (async () => {
|
|
931
|
-
try {
|
|
932
|
-
for (const event of options.prelude ?? []) notify(event);
|
|
933
|
-
for await (const event of source) {
|
|
934
|
-
try {
|
|
935
|
-
fold(event);
|
|
936
|
-
} catch (error) {
|
|
937
|
-
options.onError?.(error);
|
|
938
|
-
}
|
|
939
|
-
notify(event);
|
|
940
|
-
push(event);
|
|
941
|
-
}
|
|
942
|
-
} catch (error) {
|
|
943
|
-
options.onError?.(error);
|
|
944
|
-
} finally {
|
|
945
|
-
end();
|
|
946
|
-
}
|
|
947
|
-
})();
|
|
948
|
-
const events = {
|
|
949
|
-
next() {
|
|
950
|
-
if (pending.length > 0) {
|
|
951
|
-
return Promise.resolve({ value: pending.shift(), done: false });
|
|
952
|
-
}
|
|
953
|
-
if (finished || abandoned) return Promise.resolve({ value: void 0, done: true });
|
|
954
|
-
return new Promise((resolve5) => {
|
|
955
|
-
waiters.push(resolve5);
|
|
956
|
-
});
|
|
957
|
-
},
|
|
958
|
-
return() {
|
|
959
|
-
abandoned = true;
|
|
960
|
-
pending.length = 0;
|
|
961
|
-
while (waiters.length > 0) {
|
|
962
|
-
waiters.shift()?.({ value: void 0, done: true });
|
|
963
|
-
}
|
|
964
|
-
return Promise.resolve({ value: void 0, done: true });
|
|
965
|
-
},
|
|
966
|
-
[Symbol.asyncIterator]() {
|
|
967
|
-
return this;
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
return { events, done, droppedEvents: () => dropped };
|
|
971
|
-
}
|
|
972
|
-
var WORKER_OUTPUT_MAX_BYTES = 8192;
|
|
973
|
-
var WORKER_OUTPUT_TRUNCATION_MARKER = "\n[worker output truncated]";
|
|
974
|
-
function isRecord2(value) {
|
|
975
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
976
|
-
}
|
|
977
|
-
function assistantTextFromContent(content) {
|
|
978
|
-
if (typeof content === "string") return content;
|
|
979
|
-
if (!Array.isArray(content)) return "";
|
|
980
|
-
return content.map((block) => {
|
|
981
|
-
if (typeof block === "string") return block;
|
|
982
|
-
if (!isRecord2(block)) return "";
|
|
983
|
-
return typeof block.text === "string" ? block.text : "";
|
|
984
|
-
}).join("");
|
|
985
|
-
}
|
|
986
|
-
function isDurableAssistantMessage(message) {
|
|
987
|
-
const stopReason = message.stopReason;
|
|
988
|
-
if (stopReason === "toolUse" || stopReason === "error" || stopReason === "aborted" || stopReason === "cancelled") {
|
|
989
|
-
return false;
|
|
990
|
-
}
|
|
991
|
-
if (!Array.isArray(message.content)) return true;
|
|
992
|
-
return !message.content.some((block) => isRecord2(block) && block.type === "toolCall");
|
|
993
|
-
}
|
|
994
|
-
function durableAssistantTextFromEvent(event) {
|
|
995
|
-
if (!isRecord2(event) || event.type !== "message_end" || !isRecord2(event.message)) return "";
|
|
996
|
-
if (event.message.role !== "assistant" || !isDurableAssistantMessage(event.message)) return "";
|
|
997
|
-
return assistantTextFromContent(event.message.content);
|
|
998
|
-
}
|
|
999
|
-
function boundedOutput(state, text) {
|
|
1000
|
-
const bytes = Buffer.byteLength(text, "utf8");
|
|
1001
|
-
const bounded = truncateUtf8(text, WORKER_OUTPUT_MAX_BYTES, WORKER_OUTPUT_TRUNCATION_MARKER);
|
|
1002
|
-
return { state, text: bounded, bytes, truncated: bounded !== text };
|
|
1003
|
-
}
|
|
1004
|
-
function createWorkerOutputCapture() {
|
|
1005
|
-
let finalText = null;
|
|
1006
|
-
let partialText = "";
|
|
1007
|
-
let partialBytes = 0;
|
|
1008
|
-
let partialStored = 0;
|
|
1009
|
-
return {
|
|
1010
|
-
observe(event) {
|
|
1011
|
-
if (!isRecord2(event)) return;
|
|
1012
|
-
if (event.type === "message_end") {
|
|
1013
|
-
const message = isRecord2(event.message) ? event.message : null;
|
|
1014
|
-
partialText = "";
|
|
1015
|
-
partialBytes = 0;
|
|
1016
|
-
partialStored = 0;
|
|
1017
|
-
if (message === null || message.role !== "assistant") return;
|
|
1018
|
-
if (!isDurableAssistantMessage(message)) return;
|
|
1019
|
-
const text = assistantTextFromContent(message.content).trim();
|
|
1020
|
-
if (text.length > 0) finalText = text;
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1023
|
-
if (event.type !== "message_update") return;
|
|
1024
|
-
const assistantEvent = isRecord2(event.assistantMessageEvent) ? event.assistantMessageEvent : null;
|
|
1025
|
-
if (assistantEvent === null || assistantEvent.type !== "text_delta") return;
|
|
1026
|
-
const delta = assistantEvent.delta;
|
|
1027
|
-
if (typeof delta !== "string" || delta.length === 0) return;
|
|
1028
|
-
partialBytes += Buffer.byteLength(delta, "utf8");
|
|
1029
|
-
if (partialStored < WORKER_OUTPUT_MAX_BYTES) {
|
|
1030
|
-
partialText += delta;
|
|
1031
|
-
partialStored += Buffer.byteLength(delta, "utf8");
|
|
1032
|
-
}
|
|
1033
|
-
},
|
|
1034
|
-
snapshot() {
|
|
1035
|
-
if (partialBytes > 0 && partialText.trim().length > 0) {
|
|
1036
|
-
const bounded = truncateUtf8(partialText.trim(), WORKER_OUTPUT_MAX_BYTES, WORKER_OUTPUT_TRUNCATION_MARKER);
|
|
1037
|
-
return {
|
|
1038
|
-
state: "partial",
|
|
1039
|
-
text: bounded,
|
|
1040
|
-
bytes: partialBytes,
|
|
1041
|
-
truncated: bounded !== partialText.trim() || partialBytes > partialStored
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
if (finalText !== null) return boundedOutput("final", finalText);
|
|
1045
|
-
return void 0;
|
|
1046
|
-
}
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
931
|
// src/domains/dispatch/capacity-lease.ts
|
|
1051
932
|
init_esm_shims();
|
|
1052
933
|
import { randomBytes } from "node:crypto";
|
|
@@ -1186,6 +1067,11 @@ function describeEndpointCapacityHolders(holders) {
|
|
|
1186
1067
|
const total = holders.leases + holders.reservations + holders.foregroundStreams;
|
|
1187
1068
|
return `${named} ${total === 1 ? "holds" : "hold"} ${total === 1 ? "the slot" : "the slots"}`;
|
|
1188
1069
|
}
|
|
1070
|
+
function endpointCapacityRemedy(input) {
|
|
1071
|
+
const ways = "set this target's maxConcurrentRequests to the slot count the server was started with, collect in-flight runs, or point workers at a second server";
|
|
1072
|
+
if (input?.rosterFloor === void 0) return `reduce the same-wave worker count, ${ways}`;
|
|
1073
|
+
return `a council runs its whole roster in one wave and cannot go below ${input.rosterFloor} members, so ${ways}`;
|
|
1074
|
+
}
|
|
1189
1075
|
function assertCapacity(file, nodeId, endpointKey, limits) {
|
|
1190
1076
|
const held2 = heldReservationUsage(file.reservations);
|
|
1191
1077
|
const globalUsed = file.leases.length + held2.global;
|
|
@@ -1214,7 +1100,7 @@ function assertCapacity(file, nodeId, endpointKey, limits) {
|
|
|
1214
1100
|
const used = holders.leases + holders.reservations + holders.foregroundStreams;
|
|
1215
1101
|
if (used >= endpointLimit)
|
|
1216
1102
|
throw new Error(
|
|
1217
|
-
`dispatch: admission denied: endpoint '${endpointLabel(endpointKey)}' capacity reached (${used}/${endpointLimit} slots): ${describeEndpointCapacityHolders(holders)};
|
|
1103
|
+
`dispatch: admission denied: endpoint '${endpointLabel(endpointKey)}' capacity reached (${used}/${endpointLimit} slots): ${describeEndpointCapacityHolders(holders)}; ${endpointCapacityRemedy()}`
|
|
1218
1104
|
);
|
|
1219
1105
|
}
|
|
1220
1106
|
}
|
|
@@ -1509,7 +1395,7 @@ function agentLedgerContribution(id, runId) {
|
|
|
1509
1395
|
if (record === null) return null;
|
|
1510
1396
|
const contribution = contributionFor(record, runId);
|
|
1511
1397
|
const mine = record.entries.filter((entry) => entry.runId === runId).sort((left, right) => left.sequence - right.sequence);
|
|
1512
|
-
const digest = createHash("sha256").update(`clio.agentLedger:${canonicalJson(mine)}`, "utf8").digest("hex");
|
|
1398
|
+
const digest = createHash("sha256").update(`clio-coder.agentLedger:${canonicalJson(mine)}`, "utf8").digest("hex");
|
|
1513
1399
|
return { posted: contribution.posted, refused: contribution.refused, digest };
|
|
1514
1400
|
}
|
|
1515
1401
|
|
|
@@ -1548,7 +1434,7 @@ function renderDispatchReviewerTask(originalTask, builderRunId, cycle, intent) {
|
|
|
1548
1434
|
|
|
1549
1435
|
// src/domains/dispatch/receipt-findings.ts
|
|
1550
1436
|
init_esm_shims();
|
|
1551
|
-
import { createHash as
|
|
1437
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
1552
1438
|
|
|
1553
1439
|
// src/domains/evidence/index.ts
|
|
1554
1440
|
init_esm_shims();
|
|
@@ -1556,15 +1442,15 @@ init_esm_shims();
|
|
|
1556
1442
|
// src/domains/evidence/build.ts
|
|
1557
1443
|
init_esm_shims();
|
|
1558
1444
|
import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
1559
|
-
import { join as
|
|
1445
|
+
import { join as join16 } from "node:path";
|
|
1560
1446
|
|
|
1561
1447
|
// src/domains/dispatch/index.ts
|
|
1562
1448
|
init_esm_shims();
|
|
1563
1449
|
|
|
1564
1450
|
// src/domains/dispatch/extension.ts
|
|
1565
1451
|
init_esm_shims();
|
|
1566
|
-
import { createHash as
|
|
1567
|
-
import {
|
|
1452
|
+
import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
|
|
1453
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync11 } from "node:fs";
|
|
1568
1454
|
import { isAbsolute as isAbsolute2, relative, resolve as resolvePath, sep } from "node:path";
|
|
1569
1455
|
import { performance as performance5 } from "node:perf_hooks";
|
|
1570
1456
|
|
|
@@ -1575,20 +1461,20 @@ import { performance as performance4 } from "node:perf_hooks";
|
|
|
1575
1461
|
// src/engine/acp/event-mapper.ts
|
|
1576
1462
|
init_esm_shims();
|
|
1577
1463
|
import { performance as performance2 } from "node:perf_hooks";
|
|
1578
|
-
function
|
|
1464
|
+
function isRecord2(value) {
|
|
1579
1465
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1580
1466
|
}
|
|
1581
1467
|
function textFromContent(value) {
|
|
1582
1468
|
if (typeof value === "string") return value;
|
|
1583
|
-
if (!
|
|
1469
|
+
if (!isRecord2(value)) return "";
|
|
1584
1470
|
if (value.type === "text" && typeof value.text === "string") return value.text;
|
|
1585
|
-
if (
|
|
1471
|
+
if (isRecord2(value.content)) return textFromContent(value.content);
|
|
1586
1472
|
return "";
|
|
1587
1473
|
}
|
|
1588
1474
|
function toolContentText(value) {
|
|
1589
1475
|
if (typeof value === "string") return value;
|
|
1590
1476
|
if (Array.isArray(value)) return value.map(toolContentText).filter(Boolean).join("\n");
|
|
1591
|
-
if (!
|
|
1477
|
+
if (!isRecord2(value)) return "";
|
|
1592
1478
|
const direct = textFromContent(value);
|
|
1593
1479
|
if (direct.length > 0) return direct;
|
|
1594
1480
|
return "";
|
|
@@ -1611,8 +1497,8 @@ var AcpEventMapper = class {
|
|
|
1611
1497
|
/** Tool-call id to its `performance.now()` start mark; spans only, never an instant. */
|
|
1612
1498
|
toolStarts = /* @__PURE__ */ new Map();
|
|
1613
1499
|
mapUpdate(params) {
|
|
1614
|
-
const record =
|
|
1615
|
-
const update =
|
|
1500
|
+
const record = isRecord2(params) ? params : {};
|
|
1501
|
+
const update = isRecord2(record.update) ? record.update : {};
|
|
1616
1502
|
const kind = typeof update.sessionUpdate === "string" ? update.sessionUpdate : "";
|
|
1617
1503
|
if (kind === "agent_message_chunk" || kind === "user_message_chunk") {
|
|
1618
1504
|
const text = textFromContent(update.content);
|
|
@@ -1639,7 +1525,7 @@ var AcpEventMapper = class {
|
|
|
1639
1525
|
return this.mapToolUpdate(update);
|
|
1640
1526
|
}
|
|
1641
1527
|
if (kind === "plan") {
|
|
1642
|
-
return [{ type: "
|
|
1528
|
+
return [{ type: "clio_coder_plan_update", payload: update }];
|
|
1643
1529
|
}
|
|
1644
1530
|
return [];
|
|
1645
1531
|
}
|
|
@@ -1673,7 +1559,7 @@ var AcpEventMapper = class {
|
|
|
1673
1559
|
this.toolStarts.set(toolCallId, performance2.now());
|
|
1674
1560
|
const action = describeCallAction(update.kind ?? title, update.rawInput);
|
|
1675
1561
|
out.push({
|
|
1676
|
-
type: "
|
|
1562
|
+
type: "clio_coder_tool_start",
|
|
1677
1563
|
payload: {
|
|
1678
1564
|
tool: update.kind ?? title,
|
|
1679
1565
|
toolCallId,
|
|
@@ -1702,7 +1588,7 @@ var AcpEventMapper = class {
|
|
|
1702
1588
|
isError
|
|
1703
1589
|
});
|
|
1704
1590
|
out.push({
|
|
1705
|
-
type: "
|
|
1591
|
+
type: "clio_coder_tool_finish",
|
|
1706
1592
|
payload: {
|
|
1707
1593
|
tool: update.kind ?? title,
|
|
1708
1594
|
toolCallId,
|
|
@@ -1779,7 +1665,7 @@ var MOVE_DESTINATION_PATH_KEYS = [
|
|
|
1779
1665
|
"new_path",
|
|
1780
1666
|
"target"
|
|
1781
1667
|
];
|
|
1782
|
-
function
|
|
1668
|
+
function isRecord3(value) {
|
|
1783
1669
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1784
1670
|
}
|
|
1785
1671
|
function stringField(record, ...keys) {
|
|
@@ -1913,7 +1799,7 @@ function extractLocationPaths(locations, cwd) {
|
|
|
1913
1799
|
const paths = [];
|
|
1914
1800
|
const errors = [];
|
|
1915
1801
|
for (const value of locations) {
|
|
1916
|
-
if (!
|
|
1802
|
+
if (!isRecord3(value)) {
|
|
1917
1803
|
errors.push("locations contains a non-object entry");
|
|
1918
1804
|
continue;
|
|
1919
1805
|
}
|
|
@@ -1928,11 +1814,11 @@ function extractLocationPaths(locations, cwd) {
|
|
|
1928
1814
|
return { paths, provided: true, errors };
|
|
1929
1815
|
}
|
|
1930
1816
|
function mutationTargets(toolCall, kind, cwd) {
|
|
1931
|
-
const rawInput =
|
|
1817
|
+
const rawInput = isRecord3(toolCall?.rawInput) ? toolCall.rawInput : {};
|
|
1932
1818
|
const raw = extractRawMutationPaths(rawInput, kind, cwd);
|
|
1933
1819
|
const locations = extractLocationPaths(toolCall?.locations, cwd);
|
|
1934
1820
|
const errors = [...raw.errors, ...locations.errors];
|
|
1935
|
-
if (toolCall?.rawInput !== void 0 && !
|
|
1821
|
+
if (toolCall?.rawInput !== void 0 && !isRecord3(toolCall.rawInput)) {
|
|
1936
1822
|
errors.push("rawInput must be an object");
|
|
1937
1823
|
}
|
|
1938
1824
|
if (raw.provided && locations.provided && !samePathSet(raw.paths, locations.paths)) {
|
|
@@ -2002,11 +1888,11 @@ function mapMutationToolCall(toolCall, kind, displayTool, cwd, metadataError) {
|
|
|
2002
1888
|
};
|
|
2003
1889
|
}
|
|
2004
1890
|
function mapPathBearingToolCall(toolCall, tool, displayTool, cwd, targetRequired) {
|
|
2005
|
-
const rawInput =
|
|
1891
|
+
const rawInput = isRecord3(toolCall?.rawInput) ? toolCall.rawInput : {};
|
|
2006
1892
|
const raw = extractPathFields(rawInput, SINGLE_MUTATION_PATH_KEYS, MULTI_MUTATION_PATH_KEYS, cwd, "rawInput");
|
|
2007
1893
|
const locations = extractLocationPaths(toolCall?.locations, cwd);
|
|
2008
1894
|
const errors = [...raw.errors, ...locations.errors];
|
|
2009
|
-
if (toolCall?.rawInput !== void 0 && !
|
|
1895
|
+
if (toolCall?.rawInput !== void 0 && !isRecord3(toolCall.rawInput)) errors.push("rawInput must be an object");
|
|
2010
1896
|
if (raw.provided && locations.provided && !samePathSet(raw.paths, locations.paths)) {
|
|
2011
1897
|
errors.push("rawInput and locations contain conflicting path targets");
|
|
2012
1898
|
}
|
|
@@ -2027,7 +1913,7 @@ function mapPathBearingToolCall(toolCall, tool, displayTool, cwd, targetRequired
|
|
|
2027
1913
|
}
|
|
2028
1914
|
function mapToolCall(toolCall, cwd) {
|
|
2029
1915
|
const kind = typeof toolCall?.kind === "string" ? toolCall.kind.toLowerCase() : "";
|
|
2030
|
-
const rawInput =
|
|
1916
|
+
const rawInput = isRecord3(toolCall?.rawInput) ? toolCall.rawInput : {};
|
|
2031
1917
|
const rawTool = stringField(rawInput, "tool", "toolName", "tool_name", "name");
|
|
2032
1918
|
const title = typeof toolCall?.title === "string" ? toolCall.title : void 0;
|
|
2033
1919
|
const displayTool = rawTool ?? kind ?? title ?? "unknown";
|
|
@@ -2131,15 +2017,15 @@ var AcpToolMediator = class {
|
|
|
2131
2017
|
async handle(params) {
|
|
2132
2018
|
const startedAt = performance3.now();
|
|
2133
2019
|
this.requested += 1;
|
|
2134
|
-
const parsed =
|
|
2020
|
+
const parsed = isRecord3(params) ? params : {};
|
|
2135
2021
|
const options = Array.isArray(parsed.options) ? parsed.options : [];
|
|
2136
|
-
const toolCall =
|
|
2022
|
+
const toolCall = isRecord3(parsed.toolCall) ? parsed.toolCall : void 0;
|
|
2137
2023
|
const mapped = mapToolCall(toolCall, this.input.cwd);
|
|
2138
2024
|
let decision = "denied";
|
|
2139
2025
|
let reason;
|
|
2140
2026
|
let safetyDecision;
|
|
2141
2027
|
if (mapped.validationError !== void 0) {
|
|
2142
|
-
if (this.input.toolGovernance === "clio-policy") {
|
|
2028
|
+
if (this.input.toolGovernance === "clio-coder-policy") {
|
|
2143
2029
|
const invalidSafetyDecisions = mapped.evaluations.map(
|
|
2144
2030
|
(evaluation) => this.input.safety.evaluate({ tool: evaluation.tool, args: evaluation.args })
|
|
2145
2031
|
);
|
|
@@ -2236,6 +2122,7 @@ var AcpToolMediator = class {
|
|
|
2236
2122
|
init_esm_shims();
|
|
2237
2123
|
var ACP_USAGE_META_KEY = "clio-coder/usage";
|
|
2238
2124
|
var ACP_SESSION_META_KEY = "clio-coder/session";
|
|
2125
|
+
var ACP_AGENT_META_KEY = "clio-coder/agent";
|
|
2239
2126
|
var ACP_MAX_STRING_BYTES = 4096;
|
|
2240
2127
|
var ACP_MAX_RAW_RECORD_BYTES = 32768;
|
|
2241
2128
|
var ACP_MAX_CHUNK_BYTES = 16384;
|
|
@@ -2254,7 +2141,7 @@ var AsyncEventQueue = class {
|
|
|
2254
2141
|
const value = this.values.shift();
|
|
2255
2142
|
if (value !== void 0) return Promise.resolve({ done: false, value });
|
|
2256
2143
|
if (this.done) return Promise.resolve({ done: true, value: void 0 });
|
|
2257
|
-
return new Promise((
|
|
2144
|
+
return new Promise((resolve4) => this.waiters.push(resolve4));
|
|
2258
2145
|
}
|
|
2259
2146
|
push(value) {
|
|
2260
2147
|
if (this.done) return;
|
|
@@ -2274,22 +2161,22 @@ var AsyncEventQueue = class {
|
|
|
2274
2161
|
}
|
|
2275
2162
|
}
|
|
2276
2163
|
};
|
|
2277
|
-
function
|
|
2164
|
+
function isRecord4(value) {
|
|
2278
2165
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2279
2166
|
}
|
|
2280
2167
|
function sessionIdFrom(value) {
|
|
2281
2168
|
if (typeof value === "string" && value.length > 0) return value;
|
|
2282
|
-
if (!
|
|
2169
|
+
if (!isRecord4(value)) return null;
|
|
2283
2170
|
const sessionId = value.sessionId ?? value.id;
|
|
2284
2171
|
return typeof sessionId === "string" && sessionId.length > 0 ? sessionId : null;
|
|
2285
2172
|
}
|
|
2286
2173
|
function supportsSessionClose(init) {
|
|
2287
2174
|
const caps = init?.agentCapabilities;
|
|
2288
|
-
if (!
|
|
2289
|
-
const meta =
|
|
2290
|
-
if (
|
|
2175
|
+
if (!isRecord4(caps)) return false;
|
|
2176
|
+
const meta = isRecord4(caps._meta) ? caps._meta[ACP_SESSION_META_KEY] : void 0;
|
|
2177
|
+
if (isRecord4(meta) && meta.close === true) return true;
|
|
2291
2178
|
const sessionCaps = caps.sessionCapabilities;
|
|
2292
|
-
return
|
|
2179
|
+
return isRecord4(sessionCaps) && isRecord4(sessionCaps.close);
|
|
2293
2180
|
}
|
|
2294
2181
|
function flattenPrompt(input) {
|
|
2295
2182
|
const parts = [
|
|
@@ -2313,7 +2200,7 @@ function finite(value) {
|
|
|
2313
2200
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
2314
2201
|
}
|
|
2315
2202
|
function mergeUsage(into, raw) {
|
|
2316
|
-
if (!
|
|
2203
|
+
if (!isRecord4(raw)) return;
|
|
2317
2204
|
into.inputTokens += finite(raw.input) + finite(raw.inputTokens) + finite(raw.input_tokens);
|
|
2318
2205
|
into.outputTokens += finite(raw.output) + finite(raw.outputTokens) + finite(raw.output_tokens);
|
|
2319
2206
|
into.cacheReadTokens += finite(raw.cacheRead) + finite(raw.cacheReadTokens) + finite(raw.cache_read_tokens);
|
|
@@ -2381,10 +2268,10 @@ function startAcpDelegationRun(input) {
|
|
|
2381
2268
|
const mediator = new AcpToolMediator({
|
|
2382
2269
|
safety: input.safety,
|
|
2383
2270
|
cwd: input.cwd,
|
|
2384
|
-
toolGovernance: input.agent.toolGovernance ?? "clio-policy",
|
|
2271
|
+
toolGovernance: input.agent.toolGovernance ?? "clio-coder-policy",
|
|
2385
2272
|
...input.autonomy !== void 0 ? { autonomy: input.autonomy } : {},
|
|
2386
2273
|
onPermissionResolved: (event) => emit({
|
|
2387
|
-
type: "
|
|
2274
|
+
type: "clio_coder_permission_resolved",
|
|
2388
2275
|
payload: event
|
|
2389
2276
|
})
|
|
2390
2277
|
});
|
|
@@ -2459,7 +2346,7 @@ function startAcpDelegationRun(input) {
|
|
|
2459
2346
|
},
|
|
2460
2347
|
turnTimeoutMs
|
|
2461
2348
|
);
|
|
2462
|
-
const metaUsage =
|
|
2349
|
+
const metaUsage = isRecord4(promptResponse?._meta) ? promptResponse._meta[ACP_USAGE_META_KEY] : void 0;
|
|
2463
2350
|
if (metaUsage !== void 0) {
|
|
2464
2351
|
mergeUsage(usage, metaUsage);
|
|
2465
2352
|
} else {
|
|
@@ -2891,7 +2778,7 @@ function compileWorker(table, inputs) {
|
|
|
2891
2778
|
if (inputs.hasBoundSkills && !inputs.hasCanonicalContext) {
|
|
2892
2779
|
throw new Error("prompts/compiler: bound skills require canonical context in the final attached tool surface");
|
|
2893
2780
|
}
|
|
2894
|
-
const identity = lookupFragment(table, "identity.clio-worker", "worker identity");
|
|
2781
|
+
const identity = lookupFragment(table, "identity.clio-coder-worker", "worker identity");
|
|
2895
2782
|
const operatingContract = lookupFragment(table, "operating.contract", "operating contract");
|
|
2896
2783
|
const workerContract = lookupFragment(table, "operating.worker", "worker contract");
|
|
2897
2784
|
const safety = lookupFragment(table, `safety.${inputs.autonomy}`, "safety");
|
|
@@ -2977,8 +2864,8 @@ function createAssignmentEventStream(options = {}) {
|
|
|
2977
2864
|
return Promise.resolve({ value: pending.shift(), done: false });
|
|
2978
2865
|
}
|
|
2979
2866
|
if (finished || abandoned) return Promise.resolve({ value: void 0, done: true });
|
|
2980
|
-
return new Promise((
|
|
2981
|
-
waiters.push(
|
|
2867
|
+
return new Promise((resolve4) => {
|
|
2868
|
+
waiters.push(resolve4);
|
|
2982
2869
|
});
|
|
2983
2870
|
},
|
|
2984
2871
|
return() {
|
|
@@ -3023,7 +2910,7 @@ function asAssignmentId(rootRunId) {
|
|
|
3023
2910
|
function activeRoutingEnabled(input) {
|
|
3024
2911
|
if (input.posture === "manual" || input.failover !== "approved") return false;
|
|
3025
2912
|
if (input.capabilityClass !== "read-only" && input.capabilityClass !== "verification") return false;
|
|
3026
|
-
return input.settings.
|
|
2913
|
+
return input.settings.roles.includes(input.role) && input.settings.postures.includes(input.posture);
|
|
3027
2914
|
}
|
|
3028
2915
|
function applyActiveRouteSelection(req, decision) {
|
|
3029
2916
|
if (decision.mode !== "active") throw new Error("dispatch: cannot apply a non-active route decision");
|
|
@@ -3082,10 +2969,10 @@ var AssignmentRegistry = class {
|
|
|
3082
2969
|
const id = asAssignmentId(rootRunId);
|
|
3083
2970
|
const existing = this.#assignments.get(id);
|
|
3084
2971
|
if (existing) return this.#snapshot(existing);
|
|
3085
|
-
let
|
|
2972
|
+
let resolve4;
|
|
3086
2973
|
let reject;
|
|
3087
2974
|
const terminal = new Promise((resolvePromise, rejectPromise) => {
|
|
3088
|
-
|
|
2975
|
+
resolve4 = resolvePromise;
|
|
3089
2976
|
reject = rejectPromise;
|
|
3090
2977
|
});
|
|
3091
2978
|
const assignment = {
|
|
@@ -3100,7 +2987,7 @@ var AssignmentRegistry = class {
|
|
|
3100
2987
|
outcomeDetail: null,
|
|
3101
2988
|
terminal,
|
|
3102
2989
|
stream: createAssignmentEventStream(this.#onStreamError !== void 0 ? { onError: this.#onStreamError } : {}),
|
|
3103
|
-
resolve:
|
|
2990
|
+
resolve: resolve4,
|
|
3104
2991
|
reject
|
|
3105
2992
|
};
|
|
3106
2993
|
this.#assignments.set(id, assignment);
|
|
@@ -3223,7 +3110,7 @@ function routeValidationProjection(request, allowUnenvelopedApproval = false) {
|
|
|
3223
3110
|
function enabled(input) {
|
|
3224
3111
|
const posture = input.request.routingIntent?.posture ?? "balanced";
|
|
3225
3112
|
if (input.request.agentSelection?.mode === "auto") {
|
|
3226
|
-
return input.settings !== void 0 && posture !== "manual" && input.failover === "approved" && input.settings.
|
|
3113
|
+
return input.settings !== void 0 && posture !== "manual" && input.failover === "approved" && input.settings.postures.includes(posture) && input.settings.agentRoles.length > 0;
|
|
3227
3114
|
}
|
|
3228
3115
|
return input.settings !== void 0 && input.capabilityClass !== null && activeRoutingEnabled({
|
|
3229
3116
|
settings: input.settings,
|
|
@@ -3340,10 +3227,10 @@ function createAdmissionQueue(options) {
|
|
|
3340
3227
|
const effectiveDeadline = Math.min(request.deadlineAt, request.queuedAt + options.finiteCeilingMs);
|
|
3341
3228
|
if (!Number.isFinite(effectiveDeadline))
|
|
3342
3229
|
return Promise.reject(new Error("dispatch: queued request requires a finite deadline"));
|
|
3343
|
-
return new Promise((
|
|
3230
|
+
return new Promise((resolve4, reject) => {
|
|
3344
3231
|
const bounded = { ...request, deadlineAt: effectiveDeadline };
|
|
3345
3232
|
const timer = setTimeout(() => remove(request.requestId, "timed_out"), Math.max(0, effectiveDeadline - now()));
|
|
3346
|
-
entries.set(request.requestId, { request: bounded, resolve:
|
|
3233
|
+
entries.set(request.requestId, { request: bounded, resolve: resolve4, reject, timer });
|
|
3347
3234
|
});
|
|
3348
3235
|
},
|
|
3349
3236
|
cancel(requestId) {
|
|
@@ -3407,7 +3294,8 @@ import { randomBytes as randomBytes2 } from "node:crypto";
|
|
|
3407
3294
|
var MAX_RESERVATION_RECORDS = 500;
|
|
3408
3295
|
var DEFAULT_RESERVATION_TTL_MS = 15 * 6e4;
|
|
3409
3296
|
function endpointCapacityDenial(input) {
|
|
3410
|
-
|
|
3297
|
+
const remedy = endpointCapacityRemedy(input.topology === "council" ? { rosterFloor: COUNCIL_MIN_MEMBERS } : void 0);
|
|
3298
|
+
return `dispatch: admission denied: endpoint '${endpointLabel(input.endpointKey)}' capacity exceeded (${input.used + input.requested}/${input.limit} slots): ${describeEndpointCapacityHolders(input)}; ${remedy}`;
|
|
3411
3299
|
}
|
|
3412
3300
|
function copyRecord(record) {
|
|
3413
3301
|
return { ...record, members: record.members.map((member) => ({ ...member })) };
|
|
@@ -3415,7 +3303,7 @@ function copyRecord(record) {
|
|
|
3415
3303
|
function validRecord(value) {
|
|
3416
3304
|
if (typeof value !== "object" || value === null) return false;
|
|
3417
3305
|
const record = value;
|
|
3418
|
-
return typeof record.ownerId === "string" && typeof record.ownerPid === "number" && Number.isInteger(record.ownerPid) && record.ownerPid > 0 && (record.topology === "parallel" || record.topology === "detached" || record.topology === "sequential" || record.topology === "pipeline" || record.topology === "review" || record.topology === "compete") && (record.status === "active" || record.status === "released" || record.status === "rolled_back" || record.status === "expired") && typeof record.createdAt === "string" && typeof record.expiresAt === "string" && (record.settledAt === null || typeof record.settledAt === "string") && Array.isArray(record.members) && record.members.every(
|
|
3306
|
+
return typeof record.ownerId === "string" && typeof record.ownerPid === "number" && Number.isInteger(record.ownerPid) && record.ownerPid > 0 && (record.topology === "parallel" || record.topology === "detached" || record.topology === "sequential" || record.topology === "pipeline" || record.topology === "review" || record.topology === "compete" || record.topology === "council") && (record.status === "active" || record.status === "released" || record.status === "rolled_back" || record.status === "expired") && typeof record.createdAt === "string" && typeof record.expiresAt === "string" && (record.settledAt === null || typeof record.settledAt === "string") && Array.isArray(record.members) && record.members.every(
|
|
3419
3307
|
(member) => typeof member.memberId === "string" && Number.isInteger(member.wave) && typeof member.nodeId === "string" && (member.endpointKey === void 0 || typeof member.endpointKey === "string") && typeof member.costUpperBoundUsd === "number" && Number.isFinite(member.costUpperBoundUsd) && member.costUpperBoundUsd >= 0 && (member.status === "held" || member.status === "consumed" || member.status === "released") && (member.consumedAt === null || typeof member.consumedAt === "string") && (member.releasedAt === null || typeof member.releasedAt === "string")
|
|
3420
3308
|
);
|
|
3421
3309
|
}
|
|
@@ -3469,7 +3357,7 @@ function outstandingTasks(record) {
|
|
|
3469
3357
|
function outstandingBudget(record) {
|
|
3470
3358
|
return record.members.filter((member) => member.status === "held" || member.status === "consumed").reduce((sum, member) => sum + member.costUpperBoundUsd, 0);
|
|
3471
3359
|
}
|
|
3472
|
-
function allocateReservation(tasks, existing, capacity) {
|
|
3360
|
+
function allocateReservation(tasks, existing, capacity, topology) {
|
|
3473
3361
|
if (tasks.length === 0) return { ok: false, reason: "reservation requires at least one task" };
|
|
3474
3362
|
const duplicate = tasks.find((task, index) => tasks.slice(0, index).some((entry) => entry.memberId === task.memberId));
|
|
3475
3363
|
if (duplicate) return { ok: false, reason: `duplicate reservation member '${duplicate.memberId}'` };
|
|
@@ -3507,7 +3395,8 @@ function allocateReservation(tasks, existing, capacity) {
|
|
|
3507
3395
|
requested: slots,
|
|
3508
3396
|
leases: endpoint.leases ?? endpoint.active - (endpoint.foregroundStreams ?? 0),
|
|
3509
3397
|
reservations: heldSlots,
|
|
3510
|
-
foregroundStreams: endpoint.foregroundStreams ?? 0
|
|
3398
|
+
foregroundStreams: endpoint.foregroundStreams ?? 0,
|
|
3399
|
+
...topology === void 0 ? {} : { topology }
|
|
3511
3400
|
})
|
|
3512
3401
|
};
|
|
3513
3402
|
}
|
|
@@ -3535,7 +3424,7 @@ function createDispatchReservation(input) {
|
|
|
3535
3424
|
`dispatch: reservation denied: capacity is draining (requested by pid ${drain.requestedByPid} at ${drain.requestedAt})`
|
|
3536
3425
|
);
|
|
3537
3426
|
}
|
|
3538
|
-
const planned = allocateReservation(input.tasks, records, input.capacity);
|
|
3427
|
+
const planned = allocateReservation(input.tasks, records, input.capacity, input.topology);
|
|
3539
3428
|
if (!planned.ok) {
|
|
3540
3429
|
replaceReservations(state, records);
|
|
3541
3430
|
writeCapacityStateUnsafe(state);
|
|
@@ -3802,7 +3691,12 @@ function describeAdmissionFailure(input) {
|
|
|
3802
3691
|
if (endpointLimit !== void 0 && endpointActive >= endpointLimit) {
|
|
3803
3692
|
const holders = input.usage.endpointHolders?.[input.endpointKey];
|
|
3804
3693
|
const occupancy = holders === void 0 ? "the supplied capacity snapshot does not attribute the occupied slots" : describeEndpointCapacityHolders(holders);
|
|
3805
|
-
|
|
3694
|
+
const queued2 = input.queueDepth > 0 ? `, ${input.queueDepth} more queued` : "";
|
|
3695
|
+
return [
|
|
3696
|
+
`dispatch: admission timed out after ${Math.round(input.waitedMs)}ms waiting for an endpoint slot`,
|
|
3697
|
+
` on '${endpointLabel(input.endpointKey)}' (${endpointActive}/${endpointLimit} slots${queued2}): ${occupancy}.`,
|
|
3698
|
+
" Wait for the running request to settle or dispatch this work again."
|
|
3699
|
+
].join("");
|
|
3806
3700
|
}
|
|
3807
3701
|
}
|
|
3808
3702
|
const nodeLimit = input.limits.nodes[input.nodeId];
|
|
@@ -3846,10 +3740,6 @@ function createCapacityAdmissionController(options) {
|
|
|
3846
3740
|
admittedLease = request.value();
|
|
3847
3741
|
return true;
|
|
3848
3742
|
} catch (error) {
|
|
3849
|
-
if (error instanceof Error && /endpoint '.*' capacity reached/u.test(error.message)) {
|
|
3850
|
-
queue.fail(request.requestId, error);
|
|
3851
|
-
return false;
|
|
3852
|
-
}
|
|
3853
3743
|
if (error instanceof Error && /capacity reached/.test(error.message)) return false;
|
|
3854
3744
|
queue.fail(request.requestId, error instanceof Error ? error : new Error(String(error)));
|
|
3855
3745
|
return false;
|
|
@@ -3914,18 +3804,18 @@ function createCapacityAdmissionController(options) {
|
|
|
3914
3804
|
pumpNow();
|
|
3915
3805
|
const outcome = await outcomePromise;
|
|
3916
3806
|
if (outcome.state !== "admitted") {
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
);
|
|
3807
|
+
const detail = describeAdmissionFailure({
|
|
3808
|
+
state: outcome.state,
|
|
3809
|
+
nodeId: input.nodeId,
|
|
3810
|
+
...input.endpointKey !== void 0 ? { endpointKey: input.endpointKey } : {},
|
|
3811
|
+
waitedMs: now() - queuedAt,
|
|
3812
|
+
overdueAtQueueMs: queuedAt - input.deadlineAt,
|
|
3813
|
+
queueDepth: queue.size(),
|
|
3814
|
+
limits: options.limits(),
|
|
3815
|
+
usage: options.usage?.() ?? capacityLeaseUsage({ nowMs: now() })
|
|
3816
|
+
});
|
|
3817
|
+
if (outcome.state === "canceled") throw new AdmissionCanceledError(detail);
|
|
3818
|
+
throw new Error(detail);
|
|
3929
3819
|
}
|
|
3930
3820
|
const lease = acquired.get(input.assignmentId);
|
|
3931
3821
|
if (!lease) throw new Error("dispatch: admitted request has no capacity lease");
|
|
@@ -5577,9 +5467,9 @@ function completedReroutes(reroutes, toNode) {
|
|
|
5577
5467
|
}
|
|
5578
5468
|
function requestedNodeId(req, settings) {
|
|
5579
5469
|
if (req.node !== void 0 && req.node.trim().length > 0) return req.node.trim();
|
|
5580
|
-
const workers = settings?.
|
|
5470
|
+
const workers = settings?.fleet;
|
|
5581
5471
|
if (!workers) return null;
|
|
5582
|
-
const profileName = req.workerProfile ?? workers.
|
|
5472
|
+
const profileName = req.workerProfile ?? workers.agentProfiles?.[req.agentId];
|
|
5583
5473
|
if (!profileName) return null;
|
|
5584
5474
|
const pin = workers.profiles?.[profileName]?.node;
|
|
5585
5475
|
return pin !== void 0 && pin.trim().length > 0 ? pin.trim() : null;
|
|
@@ -5738,696 +5628,45 @@ function collectReproducibilityMetadata(cwd, safety) {
|
|
|
5738
5628
|
dirty: dirtyEntries === null ? null : dirtyEntries > 0,
|
|
5739
5629
|
dirtyEntries,
|
|
5740
5630
|
statusHash: status === null ? null : sha2564(status)
|
|
5741
|
-
},
|
|
5742
|
-
safetyPolicy: {
|
|
5743
|
-
version: safety?.version ?? 1,
|
|
5744
|
-
rulePackHash: safety?.rulePackHash ?? null,
|
|
5745
|
-
rulePackVersion: safety?.rulePackVersion ?? null,
|
|
5746
|
-
projectPolicyPath: safety?.projectPolicyPath ?? null,
|
|
5747
|
-
projectPolicyHash: safety?.projectPolicyHash ?? null,
|
|
5748
|
-
projectPolicyValid: safety?.projectPolicyValid ?? null
|
|
5749
|
-
}
|
|
5750
|
-
};
|
|
5751
|
-
}
|
|
5752
|
-
function git(cwd, args) {
|
|
5753
|
-
const result = spawnSync("git", [...args], {
|
|
5754
|
-
cwd,
|
|
5755
|
-
encoding: "utf8",
|
|
5756
|
-
timeout: 1e3,
|
|
5757
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
5758
|
-
});
|
|
5759
|
-
if (result.status !== 0 || typeof result.stdout !== "string") return null;
|
|
5760
|
-
const trimmed = result.stdout.trim();
|
|
5761
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
5762
|
-
}
|
|
5763
|
-
function sha2564(input) {
|
|
5764
|
-
return createHash5("sha256").update(input, "utf8").digest("hex");
|
|
5765
|
-
}
|
|
5766
|
-
|
|
5767
|
-
// src/domains/dispatch/route-observer.ts
|
|
5768
|
-
init_esm_shims();
|
|
5769
|
-
import { appendFileSync, existsSync as existsSync10, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync10, renameSync as renameSync4, statSync } from "node:fs";
|
|
5770
|
-
import { join as join12 } from "node:path";
|
|
5771
|
-
|
|
5772
|
-
// src/domains/dispatch/gate-decisions.ts
|
|
5773
|
-
init_esm_shims();
|
|
5774
|
-
import { createHash as createHash6, randomBytes as randomBytes4 } from "node:crypto";
|
|
5775
|
-
import { closeSync, existsSync as existsSync8, fsyncSync, mkdirSync as mkdirSync4, openSync, readdirSync as readdirSync2, readFileSync as readFileSync8, rmSync } from "node:fs";
|
|
5776
|
-
import { dirname as dirname3, join as join10, resolve as resolve4 } from "node:path";
|
|
5777
|
-
function parseReviewGateResult(output) {
|
|
5778
|
-
const result = parseVerifierResult(output);
|
|
5779
|
-
return result === null ? { ok: false, reason: "reviewer did not return a valid verifier report" } : { ok: true, result };
|
|
5780
|
-
}
|
|
5781
|
-
function decideReviewGate(input) {
|
|
5782
|
-
const base = {
|
|
5783
|
-
group: input.group,
|
|
5784
|
-
topology: "review",
|
|
5785
|
-
cycle: input.cycle,
|
|
5786
|
-
subjects: input.subjects,
|
|
5787
|
-
decider: input.decider,
|
|
5788
|
-
correlation: input.correlation
|
|
5789
|
-
};
|
|
5790
|
-
const parsed = parseReviewGateResult(input.output);
|
|
5791
|
-
if (!parsed.ok) {
|
|
5792
|
-
return {
|
|
5793
|
-
draft: { ...base, outcome: "exhausted", detail: parsed.reason },
|
|
5794
|
-
verdict: null,
|
|
5795
|
-
findings: null,
|
|
5796
|
-
needsDecision: `review gate produced no structured verdict in cycle ${input.cycle}: ${parsed.reason}`
|
|
5797
|
-
};
|
|
5798
|
-
}
|
|
5799
|
-
if (parsed.result.verdict === "pass" || input.terminalCycle) {
|
|
5800
|
-
return {
|
|
5801
|
-
draft: { ...base, outcome: parsed.result.verdict },
|
|
5802
|
-
verdict: parsed.result.verdict,
|
|
5803
|
-
findings: null,
|
|
5804
|
-
needsDecision: null
|
|
5805
|
-
};
|
|
5806
|
-
}
|
|
5807
|
-
const failed = parsed.result.checks.filter((check) => !check.passed);
|
|
5808
|
-
return {
|
|
5809
|
-
draft: { ...base, outcome: "revise", detail: `reviewer reported ${failed.length} failed check(s)` },
|
|
5810
|
-
verdict: null,
|
|
5811
|
-
findings: JSON.stringify({ verdict: "fail", checks: failed }),
|
|
5812
|
-
needsDecision: null
|
|
5813
|
-
};
|
|
5814
|
-
}
|
|
5815
|
-
function parseGateChecks(value) {
|
|
5816
|
-
if (!Array.isArray(value) || value.length === 0) return null;
|
|
5817
|
-
const checks = [];
|
|
5818
|
-
for (const entry of value) {
|
|
5819
|
-
if (!isRecord6(entry)) return null;
|
|
5820
|
-
const keys = Object.keys(entry);
|
|
5821
|
-
if (keys.some((key) => key !== "name" && key !== "passed" && key !== "evidence") || typeof entry.name !== "string" || entry.name.trim().length === 0 || typeof entry.passed !== "boolean" || typeof entry.evidence !== "string" || entry.evidence.trim().length === 0) {
|
|
5822
|
-
return null;
|
|
5823
|
-
}
|
|
5824
|
-
checks.push({ name: entry.name, passed: entry.passed, evidence: entry.evidence });
|
|
5825
|
-
}
|
|
5826
|
-
return checks;
|
|
5827
|
-
}
|
|
5828
|
-
function parseCompeteGateResult(output, candidateCount) {
|
|
5829
|
-
const parsed = parseJsonObjectPayload(output);
|
|
5830
|
-
if (!parsed.ok) {
|
|
5831
|
-
return {
|
|
5832
|
-
ok: false,
|
|
5833
|
-
reason: parsed.reason === "not-object" ? "judge result must be a JSON object" : "judge result must be valid JSON"
|
|
5834
|
-
};
|
|
5835
|
-
}
|
|
5836
|
-
const value = parsed.value;
|
|
5837
|
-
if (Object.keys(value).some((key) => key !== "winner" && key !== "checks")) {
|
|
5838
|
-
return { ok: false, reason: "judge result has unknown fields" };
|
|
5839
|
-
}
|
|
5840
|
-
const winner = value.winner;
|
|
5841
|
-
if (typeof winner !== "number" || !Number.isSafeInteger(winner) || winner < 1 || winner > candidateCount) {
|
|
5842
|
-
return { ok: false, reason: `judge winner must be an integer 1..${candidateCount}` };
|
|
5843
|
-
}
|
|
5844
|
-
const checks = parseGateChecks(value.checks);
|
|
5845
|
-
if (checks === null) return { ok: false, reason: "judge result must carry typed checks with evidence" };
|
|
5846
|
-
return { ok: true, result: { winner, checks } };
|
|
5847
|
-
}
|
|
5848
|
-
function decisionsDirectory(stateDir = clioStateDir()) {
|
|
5849
|
-
return join10(stateDir, "gate-decisions");
|
|
5850
|
-
}
|
|
5851
|
-
function pendingDecisionsDirectory(stateDir = clioStateDir()) {
|
|
5852
|
-
return join10(decisionsDirectory(stateDir), "pending");
|
|
5853
|
-
}
|
|
5854
|
-
function isRecord6(value) {
|
|
5855
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5856
|
-
}
|
|
5857
|
-
function isSubjectRef(value) {
|
|
5858
|
-
if (!isRecord6(value) || typeof value.runId !== "string" || value.runId.trim().length === 0) return false;
|
|
5859
|
-
return typeof value.digest === "string" && /^[0-9a-f]{64}$/.test(value.digest);
|
|
5860
|
-
}
|
|
5861
|
-
function isSafeDecisionId(value) {
|
|
5862
|
-
return typeof value === "string" && value.length > 0 && value.length <= 256 && /^[A-Za-z0-9._-]+$/.test(value);
|
|
5863
|
-
}
|
|
5864
|
-
function isCorrelation(value) {
|
|
5865
|
-
if (!isRecord6(value)) return false;
|
|
5866
|
-
const fields = ["agent", "target", "modelFamily", "runtime", "node", "independent"];
|
|
5867
|
-
if (Object.keys(value).some((key) => !fields.includes(key))) return false;
|
|
5868
|
-
if (!fields.every((field) => typeof value[field] === "boolean")) return false;
|
|
5869
|
-
return value.independent === (!value.agent && !value.modelFamily);
|
|
5870
|
-
}
|
|
5871
|
-
function semanticError(value) {
|
|
5872
|
-
if (!isRecord6(value)) return "gate decision is not an object";
|
|
5873
|
-
if (value.version !== 2) return "unsupported gate decision version";
|
|
5874
|
-
if (!isSafeDecisionId(value.id)) return "gate decision id invalid";
|
|
5875
|
-
if (typeof value.group !== "string" || value.group.length === 0) return "gate decision group invalid";
|
|
5876
|
-
if (value.topology !== "review" && value.topology !== "compete") return "gate decision topology invalid";
|
|
5877
|
-
if (typeof value.cycle !== "number" || !Number.isInteger(value.cycle) || value.cycle < 1) {
|
|
5878
|
-
return "gate decision cycle invalid";
|
|
5879
|
-
}
|
|
5880
|
-
const reviewOutcome = value.outcome === "pass" || value.outcome === "fail" || value.outcome === "revise" || value.outcome === "exhausted";
|
|
5881
|
-
const competeOutcome = value.outcome === "winner" || value.outcome === "no-winner" || value.outcome === "operator-confirmed" || value.outcome === "full-auto-applied";
|
|
5882
|
-
if (value.topology === "review" && !reviewOutcome || value.topology === "compete" && !competeOutcome) {
|
|
5883
|
-
return "gate decision outcome is incompatible with topology";
|
|
5884
|
-
}
|
|
5885
|
-
if (!Array.isArray(value.subjects) || value.subjects.length === 0 || !value.subjects.every(isSubjectRef)) {
|
|
5886
|
-
return "gate decision subjects invalid";
|
|
5887
|
-
}
|
|
5888
|
-
if (value.decider !== void 0 && !isSubjectRef(value.decider)) return "gate decision decider invalid";
|
|
5889
|
-
if (value.decider === void 0) {
|
|
5890
|
-
if (value.correlation !== void 0) return "gate decision correlation requires a decider";
|
|
5891
|
-
} else if (!isCorrelation(value.correlation)) {
|
|
5892
|
-
return "gate decision correlation invalid";
|
|
5893
|
-
}
|
|
5894
|
-
if (typeof value.createdAt !== "string" || !Number.isFinite(Date.parse(value.createdAt))) {
|
|
5895
|
-
return "gate decision timestamp invalid";
|
|
5896
|
-
}
|
|
5897
|
-
const needsWinner = value.outcome === "winner" || value.outcome === "operator-confirmed" || value.outcome === "full-auto-applied";
|
|
5898
|
-
if (needsWinner) {
|
|
5899
|
-
if (!isRecord6(value.winner) || typeof value.winner.index !== "number" || !Number.isInteger(value.winner.index) || value.winner.index < 1 || !isSubjectRef(value.winner.subject) || typeof value.winner.branch !== "string" || value.winner.branch !== `clio/compete/${value.group}/${value.winner.index}`) {
|
|
5900
|
-
return "gate decision winner invalid";
|
|
5901
|
-
}
|
|
5902
|
-
const winnerSubject = value.winner.subject;
|
|
5903
|
-
if (!value.subjects.some((subject) => subject.runId === winnerSubject.runId)) {
|
|
5904
|
-
return "gate decision winner is not a subject";
|
|
5905
|
-
}
|
|
5906
|
-
} else if (value.winner !== void 0) {
|
|
5907
|
-
return "gate decision winner is not valid for this outcome";
|
|
5908
|
-
}
|
|
5909
|
-
const needsConfirmation = value.outcome === "operator-confirmed" || value.outcome === "full-auto-applied";
|
|
5910
|
-
if (needsConfirmation) {
|
|
5911
|
-
if (!isRecord6(value.confirmation) || typeof value.confirmation.id !== "string" || value.confirmation.id.length === 0 || typeof value.confirmation.digest !== "string" || !/^[0-9a-f]{64}$/.test(value.confirmation.digest)) {
|
|
5912
|
-
return "gate decision confirmation invalid";
|
|
5913
|
-
}
|
|
5914
|
-
} else if (value.confirmation !== void 0) {
|
|
5915
|
-
return "gate decision confirmation is not valid for this outcome";
|
|
5916
|
-
}
|
|
5917
|
-
if (value.detail !== void 0 && typeof value.detail !== "string") return "gate decision detail invalid";
|
|
5918
|
-
if (!isRecord6(value.integrity) || value.integrity.algorithm !== "sha256" || typeof value.integrity.digest !== "string") {
|
|
5919
|
-
return "gate decision integrity invalid";
|
|
5920
|
-
}
|
|
5921
|
-
return null;
|
|
5922
|
-
}
|
|
5923
|
-
function safeGroup(group) {
|
|
5924
|
-
const safe = group.replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 128);
|
|
5925
|
-
return safe.length > 0 ? safe : "gate";
|
|
5926
|
-
}
|
|
5927
|
-
function newDecisionId(group) {
|
|
5928
|
-
return `${safeGroup(group)}-${Date.now().toString(36)}-${randomBytes4(6).toString("hex")}`;
|
|
5929
|
-
}
|
|
5930
|
-
function decisionArtifactPath(id, stateDir = clioStateDir()) {
|
|
5931
|
-
return join10(decisionsDirectory(stateDir), `${id}.json`);
|
|
5932
|
-
}
|
|
5933
|
-
function pendingDecisionPath(id, stateDir = clioStateDir()) {
|
|
5934
|
-
return join10(pendingDecisionsDirectory(stateDir), `${id}.json`);
|
|
5935
|
-
}
|
|
5936
|
-
function decisionPayload(decision) {
|
|
5937
|
-
return {
|
|
5938
|
-
contract: "clio.gateDecision.integrity",
|
|
5939
|
-
version: decision.version,
|
|
5940
|
-
id: decision.id,
|
|
5941
|
-
group: decision.group,
|
|
5942
|
-
topology: decision.topology,
|
|
5943
|
-
cycle: decision.cycle,
|
|
5944
|
-
outcome: decision.outcome,
|
|
5945
|
-
subjects: decision.subjects.map((subject) => ({ runId: subject.runId, digest: subject.digest })),
|
|
5946
|
-
...decision.decider !== void 0 ? { decider: { runId: decision.decider.runId, digest: decision.decider.digest } } : {},
|
|
5947
|
-
...decision.correlation !== void 0 ? { correlation: { ...decision.correlation } } : {},
|
|
5948
|
-
...decision.winner !== void 0 ? {
|
|
5949
|
-
winner: {
|
|
5950
|
-
index: decision.winner.index,
|
|
5951
|
-
subject: {
|
|
5952
|
-
runId: decision.winner.subject.runId,
|
|
5953
|
-
digest: decision.winner.subject.digest
|
|
5954
|
-
},
|
|
5955
|
-
branch: decision.winner.branch
|
|
5956
|
-
}
|
|
5957
|
-
} : {},
|
|
5958
|
-
...decision.confirmation !== void 0 ? { confirmation: { id: decision.confirmation.id, digest: decision.confirmation.digest } } : {},
|
|
5959
|
-
...decision.detail !== void 0 ? { detail: decision.detail } : {},
|
|
5960
|
-
createdAt: decision.createdAt
|
|
5961
|
-
};
|
|
5962
|
-
}
|
|
5963
|
-
function decisionDigest(decision) {
|
|
5964
|
-
return createHash6("sha256").update(JSON.stringify(decisionPayload(decision)), "utf8").digest("hex");
|
|
5965
|
-
}
|
|
5966
|
-
function artifactWithoutIntegrity(artifact) {
|
|
5967
|
-
const result = {
|
|
5968
|
-
version: artifact.version,
|
|
5969
|
-
id: artifact.id,
|
|
5970
|
-
group: artifact.group,
|
|
5971
|
-
topology: artifact.topology,
|
|
5972
|
-
cycle: artifact.cycle,
|
|
5973
|
-
outcome: artifact.outcome,
|
|
5974
|
-
subjects: artifact.subjects.map((subject) => ({ ...subject })),
|
|
5975
|
-
createdAt: artifact.createdAt
|
|
5976
|
-
};
|
|
5977
|
-
if (artifact.decider !== void 0) result.decider = { ...artifact.decider };
|
|
5978
|
-
if (artifact.correlation !== void 0) result.correlation = { ...artifact.correlation };
|
|
5979
|
-
if (artifact.winner !== void 0) {
|
|
5980
|
-
result.winner = {
|
|
5981
|
-
index: artifact.winner.index,
|
|
5982
|
-
subject: { ...artifact.winner.subject },
|
|
5983
|
-
branch: artifact.winner.branch
|
|
5984
|
-
};
|
|
5985
|
-
}
|
|
5986
|
-
if (artifact.confirmation !== void 0) result.confirmation = { ...artifact.confirmation };
|
|
5987
|
-
if (artifact.detail !== void 0) result.detail = artifact.detail;
|
|
5988
|
-
return result;
|
|
5989
|
-
}
|
|
5990
|
-
function verifyGateDecisionArtifact(artifact) {
|
|
5991
|
-
const invalid = semanticError(artifact);
|
|
5992
|
-
if (invalid !== null) return { ok: false, reason: invalid };
|
|
5993
|
-
if (!/^[0-9a-f]{64}$/.test(artifact.integrity.digest)) return { ok: false, reason: "gate decision integrity invalid" };
|
|
5994
|
-
return decisionDigest(artifactWithoutIntegrity(artifact)) === artifact.integrity.digest ? { ok: true } : { ok: false, reason: "gate decision integrity mismatch" };
|
|
5995
|
-
}
|
|
5996
|
-
function buildGateDecisionArtifact(draft, id = newDecisionId(draft.group), createdAt = draft.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()) {
|
|
5997
|
-
if (draft.group.trim().length === 0) throw new Error("gate decision group is required");
|
|
5998
|
-
if (!Number.isInteger(draft.cycle) || draft.cycle < 1)
|
|
5999
|
-
throw new Error("gate decision cycle must be a positive integer");
|
|
6000
|
-
if (draft.subjects.length === 0) throw new Error("gate decision requires at least one subject receipt");
|
|
6001
|
-
const withoutIntegrity = {
|
|
6002
|
-
version: 2,
|
|
6003
|
-
id,
|
|
6004
|
-
group: draft.group,
|
|
6005
|
-
topology: draft.topology,
|
|
6006
|
-
cycle: draft.cycle,
|
|
6007
|
-
outcome: draft.outcome,
|
|
6008
|
-
subjects: draft.subjects.map((subject) => ({ ...subject })),
|
|
6009
|
-
createdAt
|
|
6010
|
-
};
|
|
6011
|
-
if (draft.decider !== void 0) withoutIntegrity.decider = { ...draft.decider };
|
|
6012
|
-
if (draft.correlation !== void 0) withoutIntegrity.correlation = { ...draft.correlation };
|
|
6013
|
-
if (draft.winner !== void 0) {
|
|
6014
|
-
withoutIntegrity.winner = {
|
|
6015
|
-
index: draft.winner.index,
|
|
6016
|
-
subject: { ...draft.winner.subject },
|
|
6017
|
-
branch: draft.winner.branch
|
|
6018
|
-
};
|
|
6019
|
-
}
|
|
6020
|
-
if (draft.confirmation !== void 0) withoutIntegrity.confirmation = { ...draft.confirmation };
|
|
6021
|
-
if (draft.detail !== void 0) withoutIntegrity.detail = draft.detail;
|
|
6022
|
-
const artifact = {
|
|
6023
|
-
...withoutIntegrity,
|
|
6024
|
-
integrity: { algorithm: "sha256", digest: decisionDigest(withoutIntegrity) }
|
|
6025
|
-
};
|
|
6026
|
-
const verification = verifyGateDecisionArtifact(artifact);
|
|
6027
|
-
if (!verification.ok) throw new Error(verification.reason);
|
|
6028
|
-
return artifact;
|
|
6029
|
-
}
|
|
6030
|
-
function readVerifiedArtifact(path2) {
|
|
6031
|
-
let value;
|
|
6032
|
-
try {
|
|
6033
|
-
value = JSON.parse(readFileSync8(path2, "utf8"));
|
|
6034
|
-
} catch (error) {
|
|
6035
|
-
throw new Error(
|
|
6036
|
-
`gate decision artifact is unreadable at ${path2}: ${error instanceof Error ? error.message : String(error)}`
|
|
6037
|
-
);
|
|
6038
|
-
}
|
|
6039
|
-
const artifact = value;
|
|
6040
|
-
const verification = verifyGateDecisionArtifact(artifact);
|
|
6041
|
-
if (!verification.ok) throw new Error(`gate decision artifact is invalid at ${path2}: ${verification.reason}`);
|
|
6042
|
-
return artifact;
|
|
6043
|
-
}
|
|
6044
|
-
function persistGateDecisionArtifact(artifact, stateDir, allowIdenticalExisting) {
|
|
6045
|
-
const verification = verifyGateDecisionArtifact(artifact);
|
|
6046
|
-
if (!verification.ok) throw new Error(verification.reason);
|
|
6047
|
-
const directory = decisionsDirectory(stateDir);
|
|
6048
|
-
mkdirSync4(directory, { recursive: true });
|
|
6049
|
-
const path2 = decisionArtifactPath(artifact.id, stateDir);
|
|
6050
|
-
if (existsSync8(path2)) {
|
|
6051
|
-
const existing = readVerifiedArtifact(path2);
|
|
6052
|
-
if (allowIdenticalExisting && existing.id === artifact.id && existing.integrity.digest === artifact.integrity.digest) {
|
|
6053
|
-
return { artifact: existing, path: path2 };
|
|
6054
|
-
}
|
|
6055
|
-
throw new Error(`gate decision artifact collision: ${artifact.id}`);
|
|
6056
|
-
}
|
|
6057
|
-
atomicWrite(path2, JSON.stringify(artifact, null, 2));
|
|
6058
|
-
return { artifact, path: path2 };
|
|
6059
|
-
}
|
|
6060
|
-
function cloneGateDecisionArtifact(artifact) {
|
|
6061
|
-
return {
|
|
6062
|
-
...artifactWithoutIntegrity(artifact),
|
|
6063
|
-
integrity: { ...artifact.integrity }
|
|
6064
|
-
};
|
|
6065
|
-
}
|
|
6066
|
-
function pendingRecordPayload(record) {
|
|
6067
|
-
if (record.kind === "output") {
|
|
6068
|
-
return {
|
|
6069
|
-
contract: "clio.gateDecision.pending",
|
|
6070
|
-
version: record.version,
|
|
6071
|
-
kind: record.kind,
|
|
6072
|
-
id: record.id,
|
|
6073
|
-
group: record.group,
|
|
6074
|
-
topology: record.topology,
|
|
6075
|
-
cycle: record.cycle,
|
|
6076
|
-
subjects: record.subjects.map((subject) => ({ runId: subject.runId, digest: subject.digest })),
|
|
6077
|
-
deciderRunId: record.deciderRunId,
|
|
6078
|
-
finalOutput: record.finalOutput,
|
|
6079
|
-
...record.terminalCycle !== void 0 ? { terminalCycle: record.terminalCycle } : {},
|
|
6080
|
-
...record.resourceRoot !== void 0 ? { resourceRoot: record.resourceRoot } : {},
|
|
6081
|
-
createdAt: record.createdAt
|
|
6082
|
-
};
|
|
6083
|
-
}
|
|
6084
|
-
const decisionWithoutIntegrity = artifactWithoutIntegrity(record.decision);
|
|
6085
|
-
return {
|
|
6086
|
-
contract: "clio.gateDecision.pending",
|
|
6087
|
-
version: record.version,
|
|
6088
|
-
kind: record.kind,
|
|
6089
|
-
id: record.id,
|
|
6090
|
-
decision: {
|
|
6091
|
-
...decisionPayload(decisionWithoutIntegrity),
|
|
6092
|
-
integrity: { ...record.decision.integrity }
|
|
6093
|
-
},
|
|
6094
|
-
...record.finalOutput !== void 0 ? { finalOutput: record.finalOutput } : {},
|
|
6095
|
-
...record.resourceRoot !== void 0 ? { resourceRoot: record.resourceRoot } : {},
|
|
6096
|
-
createdAt: record.createdAt
|
|
6097
|
-
};
|
|
6098
|
-
}
|
|
6099
|
-
function pendingRecordDigest(record) {
|
|
6100
|
-
return createHash6("sha256").update(JSON.stringify(pendingRecordPayload(record)), "utf8").digest("hex");
|
|
6101
|
-
}
|
|
6102
|
-
function pendingRecordWithoutIntegrity(record) {
|
|
6103
|
-
if (record.kind === "output") {
|
|
6104
|
-
return {
|
|
6105
|
-
version: record.version,
|
|
6106
|
-
kind: record.kind,
|
|
6107
|
-
id: record.id,
|
|
6108
|
-
group: record.group,
|
|
6109
|
-
topology: record.topology,
|
|
6110
|
-
cycle: record.cycle,
|
|
6111
|
-
subjects: record.subjects.map((subject) => ({ ...subject })),
|
|
6112
|
-
deciderRunId: record.deciderRunId,
|
|
6113
|
-
finalOutput: record.finalOutput,
|
|
6114
|
-
...record.terminalCycle !== void 0 ? { terminalCycle: record.terminalCycle } : {},
|
|
6115
|
-
...record.resourceRoot !== void 0 ? { resourceRoot: record.resourceRoot } : {},
|
|
6116
|
-
createdAt: record.createdAt
|
|
6117
|
-
};
|
|
6118
|
-
}
|
|
6119
|
-
return {
|
|
6120
|
-
version: record.version,
|
|
6121
|
-
kind: record.kind,
|
|
6122
|
-
id: record.id,
|
|
6123
|
-
decision: cloneGateDecisionArtifact(record.decision),
|
|
6124
|
-
...record.finalOutput !== void 0 ? { finalOutput: record.finalOutput } : {},
|
|
6125
|
-
...record.resourceRoot !== void 0 ? { resourceRoot: record.resourceRoot } : {},
|
|
6126
|
-
createdAt: record.createdAt
|
|
6127
|
-
};
|
|
6128
|
-
}
|
|
6129
|
-
function pendingSemanticError(value) {
|
|
6130
|
-
if (!isRecord6(value)) return "pending gate decision is not an object";
|
|
6131
|
-
if (value.version !== 1) return "unsupported pending gate decision version";
|
|
6132
|
-
if (!isSafeDecisionId(value.id)) return "pending gate decision id invalid";
|
|
6133
|
-
if (typeof value.createdAt !== "string" || !Number.isFinite(Date.parse(value.createdAt))) {
|
|
6134
|
-
return "pending gate decision timestamp invalid";
|
|
6135
|
-
}
|
|
6136
|
-
if (!isRecord6(value.integrity) || value.integrity.algorithm !== "sha256" || typeof value.integrity.digest !== "string" || !/^[0-9a-f]{64}$/.test(value.integrity.digest)) {
|
|
6137
|
-
return "pending gate decision integrity invalid";
|
|
6138
|
-
}
|
|
6139
|
-
if (value.kind === "output") {
|
|
6140
|
-
if (typeof value.group !== "string" || value.group.trim().length === 0) {
|
|
6141
|
-
return "pending gate output group invalid";
|
|
6142
|
-
}
|
|
6143
|
-
if (value.topology !== "review" && value.topology !== "compete") {
|
|
6144
|
-
return "pending gate output topology invalid";
|
|
6145
|
-
}
|
|
6146
|
-
if (typeof value.cycle !== "number" || !Number.isInteger(value.cycle) || value.cycle < 1) {
|
|
6147
|
-
return "pending gate output cycle invalid";
|
|
6148
|
-
}
|
|
6149
|
-
if (!Array.isArray(value.subjects) || value.subjects.length === 0 || !value.subjects.every(isSubjectRef)) {
|
|
6150
|
-
return "pending gate output subjects invalid";
|
|
6151
|
-
}
|
|
6152
|
-
if (typeof value.deciderRunId !== "string" || value.deciderRunId.trim().length === 0) {
|
|
6153
|
-
return "pending gate output decider run id invalid";
|
|
6154
|
-
}
|
|
6155
|
-
if (typeof value.finalOutput !== "string") return "pending gate output text invalid";
|
|
6156
|
-
if (value.terminalCycle !== void 0 && typeof value.terminalCycle !== "boolean") {
|
|
6157
|
-
return "pending gate output terminal-cycle marker invalid";
|
|
6158
|
-
}
|
|
6159
|
-
if (value.resourceRoot !== void 0 && (typeof value.resourceRoot !== "string" || value.resourceRoot.length === 0)) {
|
|
6160
|
-
return "pending gate output resource root invalid";
|
|
6161
|
-
}
|
|
6162
|
-
return null;
|
|
6163
|
-
}
|
|
6164
|
-
if (value.kind !== "decision") return "pending gate decision kind invalid";
|
|
6165
|
-
if (!isRecord6(value.decision)) return "pending gate decision artifact invalid";
|
|
6166
|
-
const verification = verifyGateDecisionArtifact(value.decision);
|
|
6167
|
-
if (!verification.ok) return `pending gate decision artifact invalid: ${verification.reason}`;
|
|
6168
|
-
if (value.decision.id !== value.id) return "pending gate decision artifact id mismatch";
|
|
6169
|
-
if (value.decision.createdAt !== value.createdAt) return "pending gate decision artifact timestamp mismatch";
|
|
6170
|
-
if (value.finalOutput !== void 0 && typeof value.finalOutput !== "string") {
|
|
6171
|
-
return "pending gate decision output invalid";
|
|
6172
|
-
}
|
|
6173
|
-
if (value.resourceRoot !== void 0 && (typeof value.resourceRoot !== "string" || value.resourceRoot.length === 0)) {
|
|
6174
|
-
return "pending gate decision resource root invalid";
|
|
6175
|
-
}
|
|
6176
|
-
return null;
|
|
6177
|
-
}
|
|
6178
|
-
function verifyPendingGateDecisionRecord(record) {
|
|
6179
|
-
const invalid = pendingSemanticError(record);
|
|
6180
|
-
if (invalid !== null) return { ok: false, reason: invalid };
|
|
6181
|
-
return pendingRecordDigest(pendingRecordWithoutIntegrity(record)) === record.integrity.digest ? { ok: true } : { ok: false, reason: "pending gate decision integrity mismatch" };
|
|
6182
|
-
}
|
|
6183
|
-
function clonePendingGateDecisionRecord(record) {
|
|
6184
|
-
const without = pendingRecordWithoutIntegrity(record);
|
|
6185
|
-
return {
|
|
6186
|
-
...without,
|
|
6187
|
-
integrity: { ...record.integrity }
|
|
6188
|
-
};
|
|
6189
|
-
}
|
|
6190
|
-
function parsePendingGateDecisionRecord(value) {
|
|
6191
|
-
const invalid = pendingSemanticError(value);
|
|
6192
|
-
if (invalid !== null) throw new Error(invalid);
|
|
6193
|
-
const record = clonePendingGateDecisionRecord(value);
|
|
6194
|
-
const verification = verifyPendingGateDecisionRecord(record);
|
|
6195
|
-
if (!verification.ok) throw new Error(verification.reason);
|
|
6196
|
-
return record;
|
|
6197
|
-
}
|
|
6198
|
-
function assertPendingHandlePath(handle) {
|
|
6199
|
-
const expected = pendingDecisionPath(handle.record.id, handle.stateDir);
|
|
6200
|
-
if (resolve4(handle.path) !== resolve4(expected)) {
|
|
6201
|
-
throw new Error(`pending gate decision path does not match id ${handle.record.id}`);
|
|
6202
|
-
}
|
|
6203
|
-
}
|
|
6204
|
-
function pendingHandle(record, stateDir) {
|
|
6205
|
-
return {
|
|
6206
|
-
record: clonePendingGateDecisionRecord(record),
|
|
6207
|
-
path: pendingDecisionPath(record.id, stateDir),
|
|
6208
|
-
stateDir
|
|
6209
|
-
};
|
|
6210
|
-
}
|
|
6211
|
-
function persistPendingGateDecision(record, stateDir, allowReplace) {
|
|
6212
|
-
const verification = verifyPendingGateDecisionRecord(record);
|
|
6213
|
-
if (!verification.ok) throw new Error(verification.reason);
|
|
6214
|
-
const path2 = pendingDecisionPath(record.id, stateDir);
|
|
6215
|
-
mkdirSync4(dirname3(path2), { recursive: true });
|
|
6216
|
-
if (!allowReplace && existsSync8(path2)) throw new Error(`pending gate decision collision: ${record.id}`);
|
|
6217
|
-
atomicWrite(path2, JSON.stringify(record, null, 2));
|
|
6218
|
-
return pendingHandle(record, stateDir);
|
|
6219
|
-
}
|
|
6220
|
-
function loadPendingGateDecision(handle) {
|
|
6221
|
-
assertPendingHandlePath(handle);
|
|
6222
|
-
if (!existsSync8(handle.path)) return null;
|
|
6223
|
-
const record = parsePendingGateDecisionRecord(JSON.parse(readFileSync8(handle.path, "utf8")));
|
|
6224
|
-
if (record.id !== handle.record.id) throw new Error("pending gate decision changed identity on disk");
|
|
6225
|
-
return pendingHandle(record, handle.stateDir);
|
|
6226
|
-
}
|
|
6227
|
-
function fsyncDirectoryBestEffort(path2) {
|
|
6228
|
-
let fd = null;
|
|
6229
|
-
try {
|
|
6230
|
-
fd = openSync(path2, "r");
|
|
6231
|
-
fsyncSync(fd);
|
|
6232
|
-
} catch {
|
|
6233
|
-
} finally {
|
|
6234
|
-
if (fd !== null) closeSync(fd);
|
|
6235
|
-
}
|
|
6236
|
-
}
|
|
6237
|
-
function clearPendingGateDecision(handle) {
|
|
6238
|
-
assertPendingHandlePath(handle);
|
|
6239
|
-
rmSync(handle.path, { force: true });
|
|
6240
|
-
fsyncDirectoryBestEffort(dirname3(handle.path));
|
|
6241
|
-
}
|
|
6242
|
-
function sameSubjectRefs(left, right) {
|
|
6243
|
-
return left.length === right.length && left.every((subject, index) => {
|
|
6244
|
-
const other = right[index];
|
|
6245
|
-
return other !== void 0 && subject.runId === other.runId && subject.digest === other.digest;
|
|
6246
|
-
});
|
|
6247
|
-
}
|
|
6248
|
-
function stagePendingGateOutput(draft, stateDir = clioStateDir()) {
|
|
6249
|
-
const id = newDecisionId(draft.group);
|
|
6250
|
-
const withoutIntegrity = {
|
|
6251
|
-
version: 1,
|
|
6252
|
-
kind: "output",
|
|
6253
|
-
id,
|
|
6254
|
-
group: draft.group,
|
|
6255
|
-
topology: draft.topology,
|
|
6256
|
-
cycle: draft.cycle,
|
|
6257
|
-
subjects: draft.subjects.map((subject) => ({ ...subject })),
|
|
6258
|
-
deciderRunId: draft.deciderRunId,
|
|
6259
|
-
finalOutput: draft.finalOutput,
|
|
6260
|
-
...draft.terminalCycle !== void 0 ? { terminalCycle: draft.terminalCycle } : {},
|
|
6261
|
-
...draft.resourceRoot !== void 0 ? { resourceRoot: draft.resourceRoot } : {},
|
|
6262
|
-
createdAt: draft.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6263
|
-
};
|
|
6264
|
-
const record = {
|
|
6265
|
-
...withoutIntegrity,
|
|
6266
|
-
integrity: { algorithm: "sha256", digest: pendingRecordDigest(withoutIntegrity) }
|
|
6267
|
-
};
|
|
6268
|
-
if (existsSync8(decisionArtifactPath(id, stateDir))) throw new Error(`gate decision artifact collision: ${id}`);
|
|
6269
|
-
return persistPendingGateDecision(record, stateDir, false);
|
|
6270
|
-
}
|
|
6271
|
-
function stagePendingGateDecision(draft, options = {}) {
|
|
6272
|
-
const stateDir = options.stateDir ?? clioStateDir();
|
|
6273
|
-
const id = newDecisionId(draft.group);
|
|
6274
|
-
const createdAt = draft.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
6275
|
-
const decision = buildGateDecisionArtifact(draft, id, createdAt);
|
|
6276
|
-
const withoutIntegrity = {
|
|
6277
|
-
version: 1,
|
|
6278
|
-
kind: "decision",
|
|
6279
|
-
id,
|
|
6280
|
-
decision,
|
|
6281
|
-
...options.finalOutput !== void 0 ? { finalOutput: options.finalOutput } : {},
|
|
6282
|
-
...options.resourceRoot !== void 0 ? { resourceRoot: options.resourceRoot } : {},
|
|
6283
|
-
createdAt
|
|
6284
|
-
};
|
|
6285
|
-
const record = {
|
|
6286
|
-
...withoutIntegrity,
|
|
6287
|
-
integrity: { algorithm: "sha256", digest: pendingRecordDigest(withoutIntegrity) }
|
|
6288
|
-
};
|
|
6289
|
-
if (existsSync8(decisionArtifactPath(id, stateDir))) throw new Error(`gate decision artifact collision: ${id}`);
|
|
6290
|
-
return persistPendingGateDecision(record, stateDir, false);
|
|
6291
|
-
}
|
|
6292
|
-
function resolvePendingGateDecision(handle, draft) {
|
|
6293
|
-
const loaded = loadPendingGateDecision(handle);
|
|
6294
|
-
if (loaded === null) throw new Error(`pending gate decision is missing: ${handle.record.id}`);
|
|
6295
|
-
if (loaded.record.kind === "decision") {
|
|
6296
|
-
const expected = buildGateDecisionArtifact(draft, loaded.record.id, loaded.record.createdAt);
|
|
6297
|
-
if (expected.integrity.digest !== loaded.record.decision.integrity.digest) {
|
|
6298
|
-
throw new Error("pending gate decision was already resolved to a different artifact");
|
|
6299
|
-
}
|
|
6300
|
-
return loaded;
|
|
6301
|
-
}
|
|
6302
|
-
const pending = loaded.record;
|
|
6303
|
-
if (draft.group !== pending.group || draft.topology !== pending.topology || draft.cycle !== pending.cycle || !sameSubjectRefs(draft.subjects, pending.subjects)) {
|
|
6304
|
-
throw new Error("resolved gate decision does not match staged output context");
|
|
6305
|
-
}
|
|
6306
|
-
if (draft.decider === void 0 || draft.decider.runId !== pending.deciderRunId) {
|
|
6307
|
-
throw new Error("resolved gate decision does not match staged decider run");
|
|
6308
|
-
}
|
|
6309
|
-
if (draft.createdAt !== void 0 && draft.createdAt !== pending.createdAt) {
|
|
6310
|
-
throw new Error("resolved gate decision cannot change the staged timestamp");
|
|
6311
|
-
}
|
|
6312
|
-
const decision = buildGateDecisionArtifact(draft, pending.id, pending.createdAt);
|
|
6313
|
-
const withoutIntegrity = {
|
|
6314
|
-
version: 1,
|
|
6315
|
-
kind: "decision",
|
|
6316
|
-
id: pending.id,
|
|
6317
|
-
decision,
|
|
6318
|
-
finalOutput: pending.finalOutput,
|
|
6319
|
-
...pending.resourceRoot !== void 0 ? { resourceRoot: pending.resourceRoot } : {},
|
|
6320
|
-
createdAt: pending.createdAt
|
|
6321
|
-
};
|
|
6322
|
-
const resolvedRecord = {
|
|
6323
|
-
...withoutIntegrity,
|
|
6324
|
-
integrity: { algorithm: "sha256", digest: pendingRecordDigest(withoutIntegrity) }
|
|
6325
|
-
};
|
|
6326
|
-
return persistPendingGateDecision(resolvedRecord, loaded.stateDir, true);
|
|
6327
|
-
}
|
|
6328
|
-
function materializePendingGateDecision(handle) {
|
|
6329
|
-
const loaded = loadPendingGateDecision(handle);
|
|
6330
|
-
if (loaded === null) {
|
|
6331
|
-
if (handle.record.kind !== "decision") {
|
|
6332
|
-
throw new Error(`pending gate output is missing before resolution: ${handle.record.id}`);
|
|
6333
|
-
}
|
|
6334
|
-
const path2 = decisionArtifactPath(handle.record.decision.id, handle.stateDir);
|
|
6335
|
-
if (!existsSync8(path2)) throw new Error(`pending gate decision and artifact are both missing: ${handle.record.id}`);
|
|
6336
|
-
const artifact = readVerifiedArtifact(path2);
|
|
6337
|
-
if (artifact.integrity.digest !== handle.record.decision.integrity.digest) {
|
|
6338
|
-
throw new Error(`gate decision artifact conflicts with completed pending record: ${handle.record.id}`);
|
|
6339
|
-
}
|
|
6340
|
-
return { artifact, path: path2 };
|
|
6341
|
-
}
|
|
6342
|
-
if (loaded.record.kind !== "decision") {
|
|
6343
|
-
throw new Error(`pending gate output requires receipt resolution: ${loaded.record.id}`);
|
|
6344
|
-
}
|
|
6345
|
-
const written = persistGateDecisionArtifact(loaded.record.decision, loaded.stateDir, true);
|
|
6346
|
-
const persisted = readVerifiedArtifact(written.path);
|
|
6347
|
-
if (persisted.integrity.digest !== loaded.record.decision.integrity.digest) {
|
|
6348
|
-
throw new Error(`materialized gate decision does not match pending record: ${loaded.record.id}`);
|
|
6349
|
-
}
|
|
6350
|
-
clearPendingGateDecision(loaded);
|
|
6351
|
-
return { artifact: persisted, path: written.path };
|
|
6352
|
-
}
|
|
6353
|
-
function finalizePendingGateDecision(handle, draft) {
|
|
6354
|
-
return materializePendingGateDecision(resolvePendingGateDecision(handle, draft));
|
|
6355
|
-
}
|
|
6356
|
-
function readPendingGateDecisions(stateDir = clioStateDir()) {
|
|
6357
|
-
const directory = pendingDecisionsDirectory(stateDir);
|
|
6358
|
-
if (!existsSync8(directory)) return { records: [], errors: [] };
|
|
6359
|
-
const records = [];
|
|
6360
|
-
const errors = [];
|
|
6361
|
-
for (const name of readdirSync2(directory).filter((entry) => entry.endsWith(".json")).sort()) {
|
|
6362
|
-
const path2 = join10(directory, name);
|
|
6363
|
-
try {
|
|
6364
|
-
const record = parsePendingGateDecisionRecord(JSON.parse(readFileSync8(path2, "utf8")));
|
|
6365
|
-
if (name !== `${record.id}.json`) throw new Error("pending gate decision filename does not match its id");
|
|
6366
|
-
records.push({ record, path: path2, stateDir });
|
|
6367
|
-
} catch (error) {
|
|
6368
|
-
errors.push({ path: path2, message: error instanceof Error ? error.message : String(error) });
|
|
6369
|
-
}
|
|
6370
|
-
}
|
|
6371
|
-
return { records, errors };
|
|
6372
|
-
}
|
|
6373
|
-
function preflightPendingGateDecisionMaterialization(handles) {
|
|
6374
|
-
for (const handle of handles) {
|
|
6375
|
-
if (handle.record.kind !== "decision") continue;
|
|
6376
|
-
const path2 = decisionArtifactPath(handle.record.decision.id, handle.stateDir);
|
|
6377
|
-
if (!existsSync8(path2)) continue;
|
|
6378
|
-
const existing = readVerifiedArtifact(path2);
|
|
6379
|
-
if (existing.integrity.digest !== handle.record.decision.integrity.digest) {
|
|
6380
|
-
throw new Error(`gate decision artifact conflicts with pending record: ${handle.record.id}`);
|
|
6381
|
-
}
|
|
6382
|
-
}
|
|
6383
|
-
}
|
|
6384
|
-
function preparePendingGateDecisionRecovery(stateDir = clioStateDir()) {
|
|
6385
|
-
const pending = readPendingGateDecisions(stateDir);
|
|
6386
|
-
if (pending.errors.length > 0) {
|
|
6387
|
-
throw new Error(
|
|
6388
|
-
`pending gate decision journal is untrustworthy: ${pending.errors.map((entry) => `${entry.path}: ${entry.message}`).join("; ")}`
|
|
6389
|
-
);
|
|
6390
|
-
}
|
|
6391
|
-
const ready = pending.records.filter((handle) => handle.record.kind === "decision");
|
|
6392
|
-
preflightPendingGateDecisionMaterialization(ready);
|
|
6393
|
-
return {
|
|
6394
|
-
ready,
|
|
6395
|
-
unresolved: pending.records.filter((handle) => handle.record.kind === "output")
|
|
6396
|
-
};
|
|
6397
|
-
}
|
|
6398
|
-
function readGateDecisionArtifacts(group, stateDir = clioStateDir()) {
|
|
6399
|
-
const directory = decisionsDirectory(stateDir);
|
|
6400
|
-
if (!existsSync8(directory)) return [];
|
|
6401
|
-
const out = [];
|
|
6402
|
-
for (const name of readdirSync2(directory).filter((entry) => entry.endsWith(".json")).sort()) {
|
|
6403
|
-
const path2 = join10(directory, name);
|
|
6404
|
-
try {
|
|
6405
|
-
const artifact = JSON.parse(readFileSync8(path2, "utf8"));
|
|
6406
|
-
if (group !== void 0 && artifact.group !== group) continue;
|
|
6407
|
-
if (!verifyGateDecisionArtifact(artifact).ok) continue;
|
|
6408
|
-
out.push({ artifact, path: path2 });
|
|
6409
|
-
} catch {
|
|
5631
|
+
},
|
|
5632
|
+
safetyPolicy: {
|
|
5633
|
+
version: safety?.version ?? 1,
|
|
5634
|
+
rulePackHash: safety?.rulePackHash ?? null,
|
|
5635
|
+
rulePackVersion: safety?.rulePackVersion ?? null,
|
|
5636
|
+
projectPolicyPath: safety?.projectPolicyPath ?? null,
|
|
5637
|
+
projectPolicyHash: safety?.projectPolicyHash ?? null,
|
|
5638
|
+
projectPolicyValid: safety?.projectPolicyValid ?? null
|
|
6410
5639
|
}
|
|
6411
|
-
}
|
|
6412
|
-
return out;
|
|
5640
|
+
};
|
|
6413
5641
|
}
|
|
6414
|
-
function
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
5642
|
+
function git(cwd, args) {
|
|
5643
|
+
const result = spawnSync("git", [...args], {
|
|
5644
|
+
cwd,
|
|
5645
|
+
encoding: "utf8",
|
|
5646
|
+
timeout: 1e3,
|
|
5647
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
6420
5648
|
});
|
|
5649
|
+
if (result.status !== 0 || typeof result.stdout !== "string") return null;
|
|
5650
|
+
const trimmed = result.stdout.trim();
|
|
5651
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
5652
|
+
}
|
|
5653
|
+
function sha2564(input) {
|
|
5654
|
+
return createHash5("sha256").update(input, "utf8").digest("hex");
|
|
6421
5655
|
}
|
|
6422
5656
|
|
|
6423
|
-
// src/domains/dispatch/route-
|
|
5657
|
+
// src/domains/dispatch/route-observer.ts
|
|
6424
5658
|
init_esm_shims();
|
|
6425
|
-
import { existsSync as existsSync9, readFileSync as readFileSync9, renameSync as
|
|
5659
|
+
import { appendFileSync, existsSync as existsSync9, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync9, renameSync as renameSync4, statSync } from "node:fs";
|
|
6426
5660
|
import { join as join11 } from "node:path";
|
|
5661
|
+
|
|
5662
|
+
// src/domains/dispatch/route-history.ts
|
|
5663
|
+
init_esm_shims();
|
|
5664
|
+
import { existsSync as existsSync8, readFileSync as readFileSync8, renameSync as renameSync3 } from "node:fs";
|
|
5665
|
+
import { join as join10 } from "node:path";
|
|
6427
5666
|
var ROUTE_HISTORY_VERSION = 3;
|
|
6428
5667
|
var DEFAULT_MAX_RECORDS = 4096;
|
|
6429
5668
|
function historyPath(stateDir) {
|
|
6430
|
-
return
|
|
5669
|
+
return join10(stateDir, "route-history.json");
|
|
6431
5670
|
}
|
|
6432
5671
|
function clone2(record) {
|
|
6433
5672
|
return structuredClone(record);
|
|
@@ -6436,7 +5675,7 @@ function compareRecords(left, right) {
|
|
|
6436
5675
|
return left.settledAt.localeCompare(right.settledAt) || left.receiptDigest.localeCompare(right.receiptDigest);
|
|
6437
5676
|
}
|
|
6438
5677
|
function validateRecord(value) {
|
|
6439
|
-
if (!
|
|
5678
|
+
if (!isRecord5(value) || value.version !== ROUTE_HISTORY_VERSION)
|
|
6440
5679
|
throw new Error("route history record has unsupported version");
|
|
6441
5680
|
if (!isDigest(value.receiptDigest)) throw new Error("route history receipt digest invalid");
|
|
6442
5681
|
if (typeof value.assignmentId !== "string" || value.assignmentId.length === 0)
|
|
@@ -6480,8 +5719,8 @@ function validateRecord(value) {
|
|
|
6480
5719
|
};
|
|
6481
5720
|
}
|
|
6482
5721
|
function readHistory(path2) {
|
|
6483
|
-
if (!
|
|
6484
|
-
const raw =
|
|
5722
|
+
if (!existsSync8(path2)) return [];
|
|
5723
|
+
const raw = readFileSync8(path2, "utf8").trim();
|
|
6485
5724
|
if (raw.length === 0) return [];
|
|
6486
5725
|
let parsed;
|
|
6487
5726
|
try {
|
|
@@ -6489,7 +5728,7 @@ function readHistory(path2) {
|
|
|
6489
5728
|
} catch (error) {
|
|
6490
5729
|
throw new Error(`route history unreadable: ${error instanceof Error ? error.message : String(error)}`);
|
|
6491
5730
|
}
|
|
6492
|
-
if (!
|
|
5731
|
+
if (!isRecord5(parsed) || !Array.isArray(parsed.records)) throw new Error("route history has unsupported format");
|
|
6493
5732
|
if (parsed.version !== ROUTE_HISTORY_VERSION) {
|
|
6494
5733
|
retireHistory(path2, parsed.version);
|
|
6495
5734
|
return [];
|
|
@@ -6501,7 +5740,7 @@ function retireHistory(path2, version) {
|
|
|
6501
5740
|
const retired = `${path2}.v${String(version)}.${stamp}.retired`;
|
|
6502
5741
|
renameSync3(path2, retired);
|
|
6503
5742
|
process.stderr.write(
|
|
6504
|
-
`[clio:dispatch] route history v${String(version)} is retired; starting empty at v${ROUTE_HISTORY_VERSION}. Prior observations: ${retired}
|
|
5743
|
+
`[clio-coder:dispatch] route history v${String(version)} is retired; starting empty at v${ROUTE_HISTORY_VERSION}. Prior observations: ${retired}
|
|
6505
5744
|
`
|
|
6506
5745
|
);
|
|
6507
5746
|
}
|
|
@@ -6549,14 +5788,14 @@ function createRouteHistoryStore(options = {}) {
|
|
|
6549
5788
|
}
|
|
6550
5789
|
};
|
|
6551
5790
|
}
|
|
6552
|
-
function
|
|
5791
|
+
function isRecord5(value) {
|
|
6553
5792
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6554
5793
|
}
|
|
6555
5794
|
function isDigest(value) {
|
|
6556
5795
|
return typeof value === "string" && /^[0-9a-f]{64}$/u.test(value);
|
|
6557
5796
|
}
|
|
6558
5797
|
function isRouteCandidate(value) {
|
|
6559
|
-
if (!
|
|
5798
|
+
if (!isRecord5(value)) return false;
|
|
6560
5799
|
if (!isExecutionRole(value.executionRole)) return false;
|
|
6561
5800
|
return [
|
|
6562
5801
|
value.agentId,
|
|
@@ -6572,7 +5811,7 @@ function isRouteCandidate(value) {
|
|
|
6572
5811
|
].every((field) => typeof field === "string");
|
|
6573
5812
|
}
|
|
6574
5813
|
function isPhaseTiming(value) {
|
|
6575
|
-
if (!
|
|
5814
|
+
if (!isRecord5(value)) return false;
|
|
6576
5815
|
return [
|
|
6577
5816
|
"requestToDecisionMs",
|
|
6578
5817
|
"decisionMs",
|
|
@@ -6588,7 +5827,7 @@ function isPhaseTiming(value) {
|
|
|
6588
5827
|
|
|
6589
5828
|
// src/domains/dispatch/route-quality.ts
|
|
6590
5829
|
init_esm_shims();
|
|
6591
|
-
import { createHash as
|
|
5830
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
6592
5831
|
function compareStrings(left, right) {
|
|
6593
5832
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
6594
5833
|
}
|
|
@@ -6703,7 +5942,7 @@ function reduceRouteQuality(input) {
|
|
|
6703
5942
|
return { label, checks, correlatedGates, sourceDigests: [...sourceDigests].sort(compareStrings) };
|
|
6704
5943
|
}
|
|
6705
5944
|
function routeQualityEvalDigest(artifact) {
|
|
6706
|
-
return
|
|
5945
|
+
return createHash6("sha256").update(canonicalJson2(artifact), "utf8").digest("hex");
|
|
6707
5946
|
}
|
|
6708
5947
|
function canonicalJson2(value) {
|
|
6709
5948
|
if (value === null) return "null";
|
|
@@ -6776,28 +6015,28 @@ function createRouteLearner(capacity = LEARNER_CAPACITY) {
|
|
|
6776
6015
|
}
|
|
6777
6016
|
var OBSERVATION_LOG_MAX_BYTES = 1024 * 1024;
|
|
6778
6017
|
function durableQualitySources(stateDir) {
|
|
6779
|
-
const runsPath2 =
|
|
6780
|
-
if (!
|
|
6018
|
+
const runsPath2 = join11(stateDir, "runs.json");
|
|
6019
|
+
if (!existsSync9(runsPath2)) return { receipts: [], gates: [], evals: [] };
|
|
6781
6020
|
try {
|
|
6782
|
-
const parsed = JSON.parse(
|
|
6021
|
+
const parsed = JSON.parse(readFileSync9(runsPath2, "utf8"));
|
|
6783
6022
|
if (!Array.isArray(parsed)) return { receipts: [], gates: [], evals: [] };
|
|
6784
6023
|
const receipts = [];
|
|
6785
6024
|
for (const envelope of parsed) {
|
|
6786
6025
|
if (typeof envelope !== "object" || envelope === null || Array.isArray(envelope)) continue;
|
|
6787
6026
|
const run = envelope;
|
|
6788
|
-
const path2 = run.receiptPath ??
|
|
6789
|
-
if (!
|
|
6790
|
-
const receipt = JSON.parse(
|
|
6027
|
+
const path2 = run.receiptPath ?? join11(stateDir, "receipts", `${run.id}.json`);
|
|
6028
|
+
if (!existsSync9(path2)) continue;
|
|
6029
|
+
const receipt = JSON.parse(readFileSync9(path2, "utf8"));
|
|
6791
6030
|
if (typeof receipt === "object" && receipt !== null && !Array.isArray(receipt)) {
|
|
6792
6031
|
receipts.push({ receipt, envelope: run });
|
|
6793
6032
|
}
|
|
6794
6033
|
}
|
|
6795
6034
|
const evals = [];
|
|
6796
|
-
const evalDirectory =
|
|
6797
|
-
if (
|
|
6798
|
-
for (const name of
|
|
6035
|
+
const evalDirectory = join11(clioDataDir(), "evals");
|
|
6036
|
+
if (existsSync9(evalDirectory)) {
|
|
6037
|
+
for (const name of readdirSync2(evalDirectory).filter((entry) => entry.endsWith(".json")).sort()) {
|
|
6799
6038
|
try {
|
|
6800
|
-
const artifact = parseEvalArtifactV4(JSON.parse(
|
|
6039
|
+
const artifact = parseEvalArtifactV4(JSON.parse(readFileSync9(join11(evalDirectory, name), "utf8")), name);
|
|
6801
6040
|
evals.push({ artifact, digest: routeQualityEvalDigest(artifact) });
|
|
6802
6041
|
} catch {
|
|
6803
6042
|
}
|
|
@@ -6809,8 +6048,8 @@ function durableQualitySources(stateDir) {
|
|
|
6809
6048
|
}
|
|
6810
6049
|
}
|
|
6811
6050
|
function appendObservationLine(dir, record) {
|
|
6812
|
-
|
|
6813
|
-
const path2 =
|
|
6051
|
+
mkdirSync4(dir, { recursive: true });
|
|
6052
|
+
const path2 = join11(dir, "observations.jsonl");
|
|
6814
6053
|
try {
|
|
6815
6054
|
if (statSync(path2).size > OBSERVATION_LOG_MAX_BYTES) {
|
|
6816
6055
|
renameSync4(path2, `${path2}.1`);
|
|
@@ -6842,7 +6081,7 @@ function createRouteObserver(options) {
|
|
|
6842
6081
|
const PENDING_LIMIT = 512;
|
|
6843
6082
|
let totalObservations = 0;
|
|
6844
6083
|
let sequence = 0;
|
|
6845
|
-
const logDir = () => options.logDir ??
|
|
6084
|
+
const logDir = () => options.logDir ?? join11(clioStateDir(), "route-decisions");
|
|
6846
6085
|
const reconcileHistory = () => {
|
|
6847
6086
|
const sources = durableQualitySources(options.stateDir ?? clioStateDir());
|
|
6848
6087
|
if (sources.receipts.length === 0) return;
|
|
@@ -7013,6 +6252,327 @@ function createRouteObserver(options) {
|
|
|
7013
6252
|
};
|
|
7014
6253
|
}
|
|
7015
6254
|
|
|
6255
|
+
// src/domains/dispatch/run-event-journal-bridge.ts
|
|
6256
|
+
init_esm_shims();
|
|
6257
|
+
|
|
6258
|
+
// src/tools/dispatch-run-events.ts
|
|
6259
|
+
init_esm_shims();
|
|
6260
|
+
|
|
6261
|
+
// src/tools/dispatch-event-text.ts
|
|
6262
|
+
init_esm_shims();
|
|
6263
|
+
function assistantTextFromEvent(event) {
|
|
6264
|
+
return durableAssistantTextFromEvent(event).trim();
|
|
6265
|
+
}
|
|
6266
|
+
function receiptResponseModelIdObservationLabel(receipt) {
|
|
6267
|
+
const responses = receipt.upstreamResponses ?? [];
|
|
6268
|
+
if (responses.length === 0) return null;
|
|
6269
|
+
const labels = responses.map((response) => {
|
|
6270
|
+
const observation = responseModelIdObservationFromRecord(
|
|
6271
|
+
response,
|
|
6272
|
+
"legacy-difference-only"
|
|
6273
|
+
);
|
|
6274
|
+
if (observation.state === "reported") return `reported:${observation.reportedModelId}`;
|
|
6275
|
+
if (observation.state === "not-reported") return "not-reported";
|
|
6276
|
+
if (observation.state === "not-observed") return "not-observed";
|
|
6277
|
+
return `legacy-difference-only:${observation.differingModelId ?? "none"}`;
|
|
6278
|
+
});
|
|
6279
|
+
return `response_model_id_observation=${labels.join(",")}`;
|
|
6280
|
+
}
|
|
6281
|
+
|
|
6282
|
+
// src/tools/dispatch-run-events.ts
|
|
6283
|
+
var RUN_TAIL_ENTRY_LIMIT = 100;
|
|
6284
|
+
var RUN_TAIL_RUN_LIMIT = 64;
|
|
6285
|
+
var RUN_TAIL_TEXT_LIMIT = 600;
|
|
6286
|
+
function isRecord6(value) {
|
|
6287
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6288
|
+
}
|
|
6289
|
+
function eventDetail(event) {
|
|
6290
|
+
const normalized = isRecord6(event) ? normalizeClioCoderEventRecord(event) : event;
|
|
6291
|
+
const text = assistantTextFromEvent(normalized);
|
|
6292
|
+
if (text.length > 0) return truncateUtf8(text, RUN_TAIL_TEXT_LIMIT, "...");
|
|
6293
|
+
if (!isRecord6(normalized)) return void 0;
|
|
6294
|
+
if (normalized.type === "clio_coder_tool_finish" && isRecord6(normalized.payload)) {
|
|
6295
|
+
const tool = typeof normalized.payload.tool === "string" ? normalized.payload.tool : "tool";
|
|
6296
|
+
const outcome = typeof normalized.payload.outcome === "string" ? normalized.payload.outcome : "";
|
|
6297
|
+
return `${tool} ${outcome}`.trim();
|
|
6298
|
+
}
|
|
6299
|
+
if (normalized.type === "attempt_start") {
|
|
6300
|
+
const attempt = typeof normalized.attempt === "number" ? normalized.attempt : "?";
|
|
6301
|
+
const runId = typeof normalized.runId === "string" ? normalized.runId : "?";
|
|
6302
|
+
const reason = typeof normalized.reason === "string" ? normalized.reason : "retry";
|
|
6303
|
+
return truncateUtf8(`attempt ${attempt} -> ${runId}: ${reason}`, RUN_TAIL_TEXT_LIMIT, "...");
|
|
6304
|
+
}
|
|
6305
|
+
return void 0;
|
|
6306
|
+
}
|
|
6307
|
+
function runTailEntryFromEvent(event, at = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
6308
|
+
const type = isRecord6(event) && typeof event.type === "string" ? normalizeClioCoderEventType(event.type) : "unknown";
|
|
6309
|
+
if (type === "heartbeat" || type === "message_update") return null;
|
|
6310
|
+
const entry = { at, type };
|
|
6311
|
+
const detail = eventDetail(event);
|
|
6312
|
+
if (detail !== void 0) entry.detail = detail;
|
|
6313
|
+
return entry;
|
|
6314
|
+
}
|
|
6315
|
+
var REGISTRY_FAILURE_OUTCOME = "failed";
|
|
6316
|
+
var REGISTRY_UNKNOWN_OUTCOME = "unknown";
|
|
6317
|
+
function errorText(error) {
|
|
6318
|
+
return error instanceof Error ? error.message : String(error);
|
|
6319
|
+
}
|
|
6320
|
+
function createDispatchRunEventRegistry(options = {}) {
|
|
6321
|
+
const runTails = /* @__PURE__ */ new Map();
|
|
6322
|
+
const activeRuns = /* @__PURE__ */ new Set();
|
|
6323
|
+
const activeBatches = /* @__PURE__ */ new Set();
|
|
6324
|
+
const journal = options.journal === void 0 ? defaultRunEventJournal() : options.journal;
|
|
6325
|
+
const journalSeal = (logicalRunId, receipt) => {
|
|
6326
|
+
if (journal === null || !isRecord6(receipt)) return;
|
|
6327
|
+
const digest = receipt.integrity?.digest;
|
|
6328
|
+
const outcome = typeof receipt.outcome === "string" ? receipt.outcome : REGISTRY_UNKNOWN_OUTCOME;
|
|
6329
|
+
journal.receipt(logicalRunId, {
|
|
6330
|
+
outcome,
|
|
6331
|
+
exitCode: typeof receipt.exitCode === "number" ? receipt.exitCode : null,
|
|
6332
|
+
...typeof digest === "string" ? { digest } : {},
|
|
6333
|
+
...receipt.runId !== logicalRunId ? { attemptRunId: receipt.runId } : {}
|
|
6334
|
+
});
|
|
6335
|
+
journal.terminal(logicalRunId, outcome, receipt.outcomeDetail ?? void 0);
|
|
6336
|
+
};
|
|
6337
|
+
const sealBatchJournals = (assignmentIds, receipts) => {
|
|
6338
|
+
if (journal === null || !Array.isArray(receipts)) return;
|
|
6339
|
+
if (assignmentIds.length === receipts.length) {
|
|
6340
|
+
for (const [index, runId] of assignmentIds.entries()) {
|
|
6341
|
+
const receipt = receipts[index];
|
|
6342
|
+
if (receipt !== void 0) journalSeal(runId, receipt);
|
|
6343
|
+
}
|
|
6344
|
+
return;
|
|
6345
|
+
}
|
|
6346
|
+
for (const receipt of receipts) {
|
|
6347
|
+
if (receipt != null && typeof receipt.runId === "string") journalSeal(receipt.runId, receipt);
|
|
6348
|
+
}
|
|
6349
|
+
};
|
|
6350
|
+
const pruneRunTails = () => {
|
|
6351
|
+
while (runTails.size > RUN_TAIL_RUN_LIMIT) {
|
|
6352
|
+
let oldestKey = null;
|
|
6353
|
+
let oldestSeen = Number.POSITIVE_INFINITY;
|
|
6354
|
+
for (const [key, state] of runTails) {
|
|
6355
|
+
if (activeRuns.has(key) || state.lastSeenAt >= oldestSeen) continue;
|
|
6356
|
+
oldestKey = key;
|
|
6357
|
+
oldestSeen = state.lastSeenAt;
|
|
6358
|
+
}
|
|
6359
|
+
if (oldestKey === null) break;
|
|
6360
|
+
runTails.delete(oldestKey);
|
|
6361
|
+
}
|
|
6362
|
+
};
|
|
6363
|
+
const recordRunEvent = (runId, agentId, event) => {
|
|
6364
|
+
const entry = runTailEntryFromEvent(event);
|
|
6365
|
+
if (entry === null) return;
|
|
6366
|
+
const state = runTails.get(runId) ?? { agentId, entries: [], lastSeenAt: Date.now() };
|
|
6367
|
+
state.lastSeenAt = Date.now();
|
|
6368
|
+
state.entries.push(entry);
|
|
6369
|
+
if (state.entries.length > RUN_TAIL_ENTRY_LIMIT) {
|
|
6370
|
+
state.entries.splice(0, state.entries.length - RUN_TAIL_ENTRY_LIMIT);
|
|
6371
|
+
}
|
|
6372
|
+
runTails.set(runId, state);
|
|
6373
|
+
pruneRunTails();
|
|
6374
|
+
journal?.append(runId, entry);
|
|
6375
|
+
};
|
|
6376
|
+
const drainSingle = async (runId, agentId, events, bus) => {
|
|
6377
|
+
const summary = {
|
|
6378
|
+
count: 0,
|
|
6379
|
+
types: [],
|
|
6380
|
+
lastAssistantText: "",
|
|
6381
|
+
terminalAttemptRunId: runId
|
|
6382
|
+
};
|
|
6383
|
+
for await (const event of events) {
|
|
6384
|
+
summary.count += 1;
|
|
6385
|
+
const type = isRecord6(event) && typeof event.type === "string" ? event.type : "unknown";
|
|
6386
|
+
summary.types.push(type);
|
|
6387
|
+
if (type === "attempt_start") summary.lastAssistantText = "";
|
|
6388
|
+
const text = durableAssistantTextFromEvent(event);
|
|
6389
|
+
if (text.trim().length > 0) summary.lastAssistantText = text;
|
|
6390
|
+
recordRunEvent(runId, agentId, event);
|
|
6391
|
+
if (type !== "heartbeat") bus?.emit(BusChannels.DispatchProgress, { runId, agentId, event });
|
|
6392
|
+
}
|
|
6393
|
+
return summary;
|
|
6394
|
+
};
|
|
6395
|
+
const drainBatch = async (batchId, events, bus) => {
|
|
6396
|
+
const summaries = /* @__PURE__ */ new Map();
|
|
6397
|
+
for await (const event of events) {
|
|
6398
|
+
if (!isRecord6(event) || event.type !== "batch_run_event") continue;
|
|
6399
|
+
const runId = typeof event.runId === "string" ? event.runId : batchId;
|
|
6400
|
+
const agentId = typeof event.agentId === "string" ? event.agentId : "batch";
|
|
6401
|
+
const inner = event.event;
|
|
6402
|
+
const summary = summaries.get(runId) ?? {
|
|
6403
|
+
count: 0,
|
|
6404
|
+
types: [],
|
|
6405
|
+
lastAssistantText: "",
|
|
6406
|
+
terminalAttemptRunId: runId
|
|
6407
|
+
};
|
|
6408
|
+
summary.count += 1;
|
|
6409
|
+
const type = isRecord6(inner) && typeof inner.type === "string" ? inner.type : "unknown";
|
|
6410
|
+
summary.types.push(type);
|
|
6411
|
+
const text = durableAssistantTextFromEvent(inner);
|
|
6412
|
+
if (text.trim().length > 0) summary.lastAssistantText = text;
|
|
6413
|
+
summaries.set(runId, summary);
|
|
6414
|
+
recordRunEvent(runId, agentId, inner);
|
|
6415
|
+
if (type !== "heartbeat") bus?.emit(BusChannels.DispatchProgress, { runId, agentId, event: inner });
|
|
6416
|
+
}
|
|
6417
|
+
return summaries;
|
|
6418
|
+
};
|
|
6419
|
+
return {
|
|
6420
|
+
registerSingle(handle, agentId, bus) {
|
|
6421
|
+
if (activeRuns.has(handle.runId)) {
|
|
6422
|
+
throw new Error(`dispatch event registry: run '${handle.runId}' is already registered`);
|
|
6423
|
+
}
|
|
6424
|
+
activeRuns.add(handle.runId);
|
|
6425
|
+
journal?.open(handle.runId, agentId);
|
|
6426
|
+
const summaryPromise = drainSingle(handle.runId, agentId, handle.events, bus);
|
|
6427
|
+
const completion = Promise.allSettled([summaryPromise, handle.finalPromise]).then(
|
|
6428
|
+
([summaryResult, receiptResult]) => {
|
|
6429
|
+
if (summaryResult.status === "rejected") throw summaryResult.reason;
|
|
6430
|
+
if (receiptResult.status === "rejected") throw receiptResult.reason;
|
|
6431
|
+
return { receipt: receiptResult.value, summary: summaryResult.value };
|
|
6432
|
+
}
|
|
6433
|
+
);
|
|
6434
|
+
const releaseSingle = () => {
|
|
6435
|
+
activeRuns.delete(handle.runId);
|
|
6436
|
+
pruneRunTails();
|
|
6437
|
+
};
|
|
6438
|
+
void completion.then(
|
|
6439
|
+
({ receipt }) => {
|
|
6440
|
+
journalSeal(handle.runId, receipt);
|
|
6441
|
+
releaseSingle();
|
|
6442
|
+
},
|
|
6443
|
+
(error) => {
|
|
6444
|
+
journal?.terminal(handle.runId, REGISTRY_FAILURE_OUTCOME, errorText(error));
|
|
6445
|
+
releaseSingle();
|
|
6446
|
+
}
|
|
6447
|
+
);
|
|
6448
|
+
return { runId: handle.runId, completion };
|
|
6449
|
+
},
|
|
6450
|
+
registerBatch(handle, agentIds, bus) {
|
|
6451
|
+
if (activeBatches.has(handle.batchId)) {
|
|
6452
|
+
throw new Error(`dispatch event registry: batch '${handle.batchId}' is already registered`);
|
|
6453
|
+
}
|
|
6454
|
+
const duplicateRunId = handle.assignmentIds.find(
|
|
6455
|
+
(runId, index) => handle.assignmentIds.slice(0, index).includes(runId)
|
|
6456
|
+
);
|
|
6457
|
+
if (duplicateRunId !== void 0) {
|
|
6458
|
+
throw new Error(`dispatch event registry: batch '${handle.batchId}' repeats run '${duplicateRunId}'`);
|
|
6459
|
+
}
|
|
6460
|
+
const activeRunId = handle.assignmentIds.find((runId) => activeRuns.has(runId));
|
|
6461
|
+
if (activeRunId !== void 0) {
|
|
6462
|
+
throw new Error(`dispatch event registry: run '${activeRunId}' is already registered`);
|
|
6463
|
+
}
|
|
6464
|
+
activeBatches.add(handle.batchId);
|
|
6465
|
+
for (const runId of handle.assignmentIds) activeRuns.add(runId);
|
|
6466
|
+
for (const [index, runId] of handle.assignmentIds.entries()) {
|
|
6467
|
+
journal?.open(runId, agentIds[index] ?? "unknown");
|
|
6468
|
+
}
|
|
6469
|
+
const completion = Promise.allSettled([drainBatch(handle.batchId, handle.events, bus), handle.finalPromise]).then(
|
|
6470
|
+
([summariesResult, receiptsResult]) => {
|
|
6471
|
+
if (summariesResult.status === "rejected") throw summariesResult.reason;
|
|
6472
|
+
if (receiptsResult.status === "rejected") throw receiptsResult.reason;
|
|
6473
|
+
return { receipts: receiptsResult.value, summaries: summariesResult.value };
|
|
6474
|
+
}
|
|
6475
|
+
);
|
|
6476
|
+
const releaseBatch = () => {
|
|
6477
|
+
activeBatches.delete(handle.batchId);
|
|
6478
|
+
for (const runId of handle.assignmentIds) activeRuns.delete(runId);
|
|
6479
|
+
pruneRunTails();
|
|
6480
|
+
};
|
|
6481
|
+
void completion.then(
|
|
6482
|
+
({ receipts }) => {
|
|
6483
|
+
sealBatchJournals(handle.assignmentIds, receipts);
|
|
6484
|
+
releaseBatch();
|
|
6485
|
+
},
|
|
6486
|
+
(error) => {
|
|
6487
|
+
const detail = errorText(error);
|
|
6488
|
+
for (const runId of handle.assignmentIds) {
|
|
6489
|
+
journal?.terminal(runId, REGISTRY_FAILURE_OUTCOME, detail);
|
|
6490
|
+
}
|
|
6491
|
+
releaseBatch();
|
|
6492
|
+
}
|
|
6493
|
+
);
|
|
6494
|
+
for (const [index, runId] of handle.assignmentIds.entries()) {
|
|
6495
|
+
if (!runTails.has(runId)) {
|
|
6496
|
+
runTails.set(runId, {
|
|
6497
|
+
agentId: agentIds[index] ?? "unknown",
|
|
6498
|
+
entries: [],
|
|
6499
|
+
lastSeenAt: Date.now()
|
|
6500
|
+
});
|
|
6501
|
+
}
|
|
6502
|
+
}
|
|
6503
|
+
return { batchId: handle.batchId, assignmentIds: handle.assignmentIds, completion };
|
|
6504
|
+
},
|
|
6505
|
+
recordEvent: recordRunEvent,
|
|
6506
|
+
eventTail(runId) {
|
|
6507
|
+
const state = runTails.get(runId);
|
|
6508
|
+
return state === void 0 ? null : { agentId: state.agentId, entries: [...state.entries] };
|
|
6509
|
+
}
|
|
6510
|
+
};
|
|
6511
|
+
}
|
|
6512
|
+
|
|
6513
|
+
// src/domains/dispatch/run-event-journal-bridge.ts
|
|
6514
|
+
var OPENED_RUN_LIMIT = 512;
|
|
6515
|
+
function isRecord7(value) {
|
|
6516
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6517
|
+
}
|
|
6518
|
+
function runIdentity(payload) {
|
|
6519
|
+
if (!isRecord7(payload)) return null;
|
|
6520
|
+
if (typeof payload.runId !== "string" || payload.runId.length === 0) return null;
|
|
6521
|
+
return { runId: payload.runId, agentId: typeof payload.agentId === "string" ? payload.agentId : "unknown" };
|
|
6522
|
+
}
|
|
6523
|
+
function attachRunEventJournalBridge(bus, options = {}) {
|
|
6524
|
+
const journal = options.journal ?? defaultRunEventJournal();
|
|
6525
|
+
const opened = /* @__PURE__ */ new Set();
|
|
6526
|
+
const ensureOpen = (runId, agentId) => {
|
|
6527
|
+
if (opened.has(runId)) return;
|
|
6528
|
+
opened.add(runId);
|
|
6529
|
+
while (opened.size > OPENED_RUN_LIMIT) {
|
|
6530
|
+
const oldest = opened.values().next();
|
|
6531
|
+
if (oldest.done === true) break;
|
|
6532
|
+
opened.delete(oldest.value);
|
|
6533
|
+
}
|
|
6534
|
+
journal.open(runId, agentId);
|
|
6535
|
+
};
|
|
6536
|
+
const seal = (outcome, detail, payload) => {
|
|
6537
|
+
const identity = runIdentity(payload);
|
|
6538
|
+
if (identity === null) return;
|
|
6539
|
+
ensureOpen(identity.runId, identity.agentId);
|
|
6540
|
+
const exitCode = isRecord7(payload) && typeof payload.exitCode === "number" ? payload.exitCode : null;
|
|
6541
|
+
journal.receipt(identity.runId, { outcome, exitCode });
|
|
6542
|
+
journal.terminal(identity.runId, outcome, detail ?? void 0);
|
|
6543
|
+
opened.delete(identity.runId);
|
|
6544
|
+
};
|
|
6545
|
+
const unsubscribes = [
|
|
6546
|
+
bus.on(BusChannels.DispatchProgress, (payload) => {
|
|
6547
|
+
const identity = runIdentity(payload);
|
|
6548
|
+
if (identity === null) return;
|
|
6549
|
+
const entry = runTailEntryFromEvent(payload.event);
|
|
6550
|
+
if (entry === null) return;
|
|
6551
|
+
ensureOpen(identity.runId, identity.agentId);
|
|
6552
|
+
const message = isRecord7(payload.event) && typeof payload.event.message === "string" ? payload.event.message : void 0;
|
|
6553
|
+
journal.append(
|
|
6554
|
+
identity.runId,
|
|
6555
|
+
entry.detail === void 0 && message !== void 0 ? { ...entry, detail: message } : entry
|
|
6556
|
+
);
|
|
6557
|
+
}),
|
|
6558
|
+
bus.on(BusChannels.DispatchCompleted, (payload) => {
|
|
6559
|
+
seal(payload.outcome, payload.outcomeDetail, payload);
|
|
6560
|
+
}),
|
|
6561
|
+
bus.on(BusChannels.DispatchFailed, (payload) => {
|
|
6562
|
+
seal(payload.outcome, payload.outcomeDetail, payload);
|
|
6563
|
+
})
|
|
6564
|
+
];
|
|
6565
|
+
let stopped = false;
|
|
6566
|
+
return {
|
|
6567
|
+
stop() {
|
|
6568
|
+
if (stopped) return;
|
|
6569
|
+
stopped = true;
|
|
6570
|
+
for (const unsubscribe of unsubscribes) unsubscribe();
|
|
6571
|
+
opened.clear();
|
|
6572
|
+
}
|
|
6573
|
+
};
|
|
6574
|
+
}
|
|
6575
|
+
|
|
7016
6576
|
// src/domains/dispatch/run-identity.ts
|
|
7017
6577
|
init_esm_shims();
|
|
7018
6578
|
import { hostname as hostname3, userInfo } from "node:os";
|
|
@@ -7062,27 +6622,27 @@ function detectRunIdentity(env = process.env) {
|
|
|
7062
6622
|
|
|
7063
6623
|
// src/domains/dispatch/state.ts
|
|
7064
6624
|
init_esm_shims();
|
|
7065
|
-
import { randomBytes as
|
|
7066
|
-
import { existsSync as
|
|
7067
|
-
import { join as
|
|
6625
|
+
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
6626
|
+
import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync10 } from "node:fs";
|
|
6627
|
+
import { join as join12 } from "node:path";
|
|
7068
6628
|
function newRunId() {
|
|
7069
|
-
const n = BigInt(`0x${
|
|
6629
|
+
const n = BigInt(`0x${randomBytes4(8).toString("hex")}`);
|
|
7070
6630
|
const raw = n.toString(36);
|
|
7071
6631
|
if (raw.length >= 12) return raw.slice(0, 12);
|
|
7072
6632
|
return raw.padStart(12, "0");
|
|
7073
6633
|
}
|
|
7074
6634
|
function runsPath() {
|
|
7075
|
-
return
|
|
6635
|
+
return join12(clioStateDir(), "runs.json");
|
|
7076
6636
|
}
|
|
7077
6637
|
function receiptPathFor(runId) {
|
|
7078
|
-
return
|
|
6638
|
+
return join12(clioStateDir(), "receipts", `${runId}.json`);
|
|
7079
6639
|
}
|
|
7080
6640
|
function fleetRunPath(runId) {
|
|
7081
|
-
return
|
|
6641
|
+
return join12(clioStateDir(), "fleet-runs", `${runId}.json`);
|
|
7082
6642
|
}
|
|
7083
6643
|
function readFleetRun(runId) {
|
|
7084
6644
|
try {
|
|
7085
|
-
const parsed = JSON.parse(
|
|
6645
|
+
const parsed = JSON.parse(readFileSync10(fleetRunPath(runId), "utf8"));
|
|
7086
6646
|
return parsed.version === 1 && parsed.id === runId ? structuredClone(parsed) : null;
|
|
7087
6647
|
} catch {
|
|
7088
6648
|
return null;
|
|
@@ -7092,10 +6652,27 @@ async function writeFleetRun(record) {
|
|
|
7092
6652
|
await atomicWrite(fleetRunPath(record.id), `${JSON.stringify(record, null, 2)}
|
|
7093
6653
|
`);
|
|
7094
6654
|
}
|
|
6655
|
+
var MAX_FLEET_RUN_SCAN = 64;
|
|
6656
|
+
function listFleetRuns(limit = MAX_FLEET_RUN_SCAN) {
|
|
6657
|
+
let entries;
|
|
6658
|
+
try {
|
|
6659
|
+
entries = readdirSync3(join12(clioStateDir(), "fleet-runs"));
|
|
6660
|
+
} catch {
|
|
6661
|
+
return [];
|
|
6662
|
+
}
|
|
6663
|
+
const records = [];
|
|
6664
|
+
for (const name of entries.slice(0, MAX_FLEET_RUN_SCAN)) {
|
|
6665
|
+
if (!name.endsWith(".json")) continue;
|
|
6666
|
+
const record = readFleetRun(name.slice(0, -".json".length));
|
|
6667
|
+
if (record !== null) records.push(record);
|
|
6668
|
+
}
|
|
6669
|
+
records.sort((a, b) => (Date.parse(b.startedAt) || 0) - (Date.parse(a.startedAt) || 0));
|
|
6670
|
+
return records.slice(0, Math.max(0, limit));
|
|
6671
|
+
}
|
|
7095
6672
|
function readRuns() {
|
|
7096
6673
|
const path2 = runsPath();
|
|
7097
|
-
if (!
|
|
7098
|
-
const raw =
|
|
6674
|
+
if (!existsSync10(path2)) return [];
|
|
6675
|
+
const raw = readFileSync10(path2, "utf8").trim();
|
|
7099
6676
|
if (raw.length === 0) return [];
|
|
7100
6677
|
const parsed = JSON.parse(raw);
|
|
7101
6678
|
if (!Array.isArray(parsed)) return [];
|
|
@@ -7253,6 +6830,10 @@ function openLedger(opts) {
|
|
|
7253
6830
|
const capped = capRuns(merged, maxRuns);
|
|
7254
6831
|
runs = capped;
|
|
7255
6832
|
atomicWrite(target, JSON.stringify(capped, null, 2));
|
|
6833
|
+
if (merged.length > capped.length) {
|
|
6834
|
+
const kept = new Set(capped.map((run) => run.id));
|
|
6835
|
+
removeRunEventJournals(merged.filter((run) => !kept.has(run.id)).map((run) => run.id));
|
|
6836
|
+
}
|
|
7256
6837
|
dirty.clear();
|
|
7257
6838
|
});
|
|
7258
6839
|
},
|
|
@@ -7410,7 +6991,7 @@ function calculateUsageCostUsd(meter, pricing) {
|
|
|
7410
6991
|
return (meter.inputTokens * pricing.input + meter.outputTokens * pricing.output + meter.cacheReadTokens * pricing.cacheRead + meter.cacheWriteTokens * pricing.cacheWrite) / 1e6;
|
|
7411
6992
|
}
|
|
7412
6993
|
function admissionMaxOutputTokens(settings) {
|
|
7413
|
-
return settings?.
|
|
6994
|
+
return settings?.chat.maxOutputTokens ?? DEFAULT_SETTINGS.chat.maxOutputTokens;
|
|
7414
6995
|
}
|
|
7415
6996
|
function conservativeRouteAdmissionEstimateUsd(pricing, maxOutputTokens) {
|
|
7416
6997
|
if (pricing.provenance === "known_free") return 0;
|
|
@@ -7421,7 +7002,7 @@ function requestOriginFor(req) {
|
|
|
7421
7002
|
return req.requestOrigin ?? "agent";
|
|
7422
7003
|
}
|
|
7423
7004
|
function sha2565(input) {
|
|
7424
|
-
return
|
|
7005
|
+
return createHash7("sha256").update(input, "utf8").digest("hex");
|
|
7425
7006
|
}
|
|
7426
7007
|
function promptHash(systemPrompt) {
|
|
7427
7008
|
return systemPrompt.length > 0 ? sha2565(systemPrompt) : null;
|
|
@@ -7442,7 +7023,7 @@ function eventContainsFirstModelToken(event) {
|
|
|
7442
7023
|
return assistantEvent?.type === "text_delta" || assistantEvent?.type === "thinking_delta" || assistantEvent?.type === "toolcall_start" || assistantEvent?.type === "toolcall_delta";
|
|
7443
7024
|
}
|
|
7444
7025
|
function eventStartsTool(event) {
|
|
7445
|
-
return event.type === "tool_execution_start" || event.type === "
|
|
7026
|
+
return event.type === "tool_execution_start" || event.type === "clio_coder_tool_start";
|
|
7446
7027
|
}
|
|
7447
7028
|
function finitePositive(value) {
|
|
7448
7029
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
@@ -7563,8 +7144,8 @@ var DISPATCH_DRAIN_GRACE_MS = 2e3;
|
|
|
7563
7144
|
var RUN_WRITE_TARGET_HISTORY = 512;
|
|
7564
7145
|
async function awaitEventDrain(drained, graceMs = DISPATCH_DRAIN_GRACE_MS) {
|
|
7565
7146
|
let timer;
|
|
7566
|
-
const grace = new Promise((
|
|
7567
|
-
timer = setTimeout(() =>
|
|
7147
|
+
const grace = new Promise((resolve4) => {
|
|
7148
|
+
timer = setTimeout(() => resolve4(false), graceMs);
|
|
7568
7149
|
});
|
|
7569
7150
|
try {
|
|
7570
7151
|
return await Promise.race([drained.then(() => true), grace]);
|
|
@@ -7575,7 +7156,7 @@ async function awaitEventDrain(drained, graceMs = DISPATCH_DRAIN_GRACE_MS) {
|
|
|
7575
7156
|
function reportDispatchDiagnostic(scope, error) {
|
|
7576
7157
|
const message = error instanceof Error ? error.message : String(error);
|
|
7577
7158
|
try {
|
|
7578
|
-
process.stderr.write(`[clio:dispatch] ${scope}: ${message}
|
|
7159
|
+
process.stderr.write(`[clio-coder:dispatch] ${scope}: ${message}
|
|
7579
7160
|
`);
|
|
7580
7161
|
} catch {
|
|
7581
7162
|
}
|
|
@@ -7996,7 +7577,7 @@ function assertPostRuntimeToolCompatibility(agentId, spec, effectiveTools, targe
|
|
|
7996
7577
|
function workerToolCallHardCap(settings) {
|
|
7997
7578
|
const rawEnvCap = process.env.CLIO_CODER_WORKER_TOOL_CALL_CAP?.trim();
|
|
7998
7579
|
const parsedEnvCap = rawEnvCap && /^[1-9]\d*$/.test(rawEnvCap) ? Number(rawEnvCap) : Number.NaN;
|
|
7999
|
-
return Number.isSafeInteger(parsedEnvCap) ? parsedEnvCap : settings?.
|
|
7580
|
+
return Number.isSafeInteger(parsedEnvCap) ? parsedEnvCap : settings?.fleet.limits.toolCallsPerRun ?? GUARDRAIL_DEFAULTS.workerToolCallCap;
|
|
8000
7581
|
}
|
|
8001
7582
|
function resolveEffectiveWorkerBudget(input) {
|
|
8002
7583
|
const hardCap = workerToolCallHardCap(input.settings);
|
|
@@ -8094,13 +7675,13 @@ function acpRuntimeLimitations() {
|
|
|
8094
7675
|
];
|
|
8095
7676
|
}
|
|
8096
7677
|
function readWorkerTargets(settings) {
|
|
8097
|
-
const workerDefault = settings?.
|
|
8098
|
-
target: settings.
|
|
8099
|
-
model: settings.
|
|
8100
|
-
thinkingLevel: settings.
|
|
7678
|
+
const workerDefault = settings?.fleet?.default ? {
|
|
7679
|
+
target: settings.fleet.default.target ?? null,
|
|
7680
|
+
model: settings.fleet.default.model ?? null,
|
|
7681
|
+
thinkingLevel: settings.fleet.default.thinkingLevel ?? "off"
|
|
8101
7682
|
} : null;
|
|
8102
7683
|
const workerProfiles = {};
|
|
8103
|
-
for (const [name, profile] of Object.entries(settings?.
|
|
7684
|
+
for (const [name, profile] of Object.entries(settings?.fleet?.profiles ?? {})) {
|
|
8104
7685
|
workerProfiles[name] = {
|
|
8105
7686
|
target: profile.target ?? null,
|
|
8106
7687
|
model: profile.model ?? null,
|
|
@@ -8108,7 +7689,7 @@ function readWorkerTargets(settings) {
|
|
|
8108
7689
|
};
|
|
8109
7690
|
}
|
|
8110
7691
|
const agentBindings = {};
|
|
8111
|
-
for (const [agentId, profileName] of Object.entries(settings?.
|
|
7692
|
+
for (const [agentId, profileName] of Object.entries(settings?.fleet?.agentProfiles ?? {})) {
|
|
8112
7693
|
const id = agentId.trim();
|
|
8113
7694
|
const profile = profileName.trim();
|
|
8114
7695
|
if (id.length > 0 && profile.length > 0) agentBindings[id] = profile;
|
|
@@ -8245,12 +7826,12 @@ function buildDispatchWorkerSpec(input, config) {
|
|
|
8245
7826
|
if (input.req.trustProjectCompatRoots !== void 0) {
|
|
8246
7827
|
spec.trustProjectCompatRoots = input.req.trustProjectCompatRoots;
|
|
8247
7828
|
} else if (settings) {
|
|
8248
|
-
spec.trustProjectCompatRoots = settings.
|
|
7829
|
+
spec.trustProjectCompatRoots = settings.integrations.projectResources.trustProjectImports === true;
|
|
8249
7830
|
}
|
|
8250
|
-
spec.gitCommitAttribution = settings?.
|
|
8251
|
-
spec.onPermission = settings?.
|
|
7831
|
+
spec.gitCommitAttribution = settings?.integrations.git.commitAttribution ?? true;
|
|
7832
|
+
spec.onPermission = settings?.fleet.permissions.mode ?? "deny";
|
|
8252
7833
|
if (spec.onPermission === "escalate") {
|
|
8253
|
-
const escalation = settings?.
|
|
7834
|
+
const escalation = settings?.fleet.permissions.escalation;
|
|
8254
7835
|
if (escalation) spec.escalation = { timeoutMs: escalation.timeoutMs, fallback: escalation.fallback };
|
|
8255
7836
|
}
|
|
8256
7837
|
assertRuntimeCanHonorWorkerPermissionMode(input.target.runtime, spec.onPermission);
|
|
@@ -8638,7 +8219,7 @@ function createDispatchBundle(context, options) {
|
|
|
8638
8219
|
const heartbeatIntervalMs = options?.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS;
|
|
8639
8220
|
const getResilienceCooldownMs = () => {
|
|
8640
8221
|
if (options?.resilienceCooldownMs !== void 0) return options.resilienceCooldownMs;
|
|
8641
|
-
const settingsVal = getEffectiveSettings()?.
|
|
8222
|
+
const settingsVal = getEffectiveSettings()?.fleet?.retry.routeCooldownMs;
|
|
8642
8223
|
if (settingsVal !== void 0 && settingsVal >= 0) return settingsVal;
|
|
8643
8224
|
return DEFAULT_RESILIENCE_COOLDOWN_MS;
|
|
8644
8225
|
};
|
|
@@ -8648,6 +8229,7 @@ function createDispatchBundle(context, options) {
|
|
|
8648
8229
|
let ledger = null;
|
|
8649
8230
|
let heartbeatTimer = null;
|
|
8650
8231
|
const active = /* @__PURE__ */ new Map();
|
|
8232
|
+
const pendingCapacity = /* @__PURE__ */ new Map();
|
|
8651
8233
|
const targetCooldowns = /* @__PURE__ */ new Map();
|
|
8652
8234
|
const ownedReservations = /* @__PURE__ */ new Set();
|
|
8653
8235
|
const runWriteAttributions = /* @__PURE__ */ new Map();
|
|
@@ -8675,18 +8257,23 @@ function createDispatchBundle(context, options) {
|
|
|
8675
8257
|
onError: (error) => reportDispatchDiagnostic("read capacity lease usage", error)
|
|
8676
8258
|
})
|
|
8677
8259
|
);
|
|
8260
|
+
function configuredEndpointCapacities() {
|
|
8261
|
+
return resolveEndpointCapacities({
|
|
8262
|
+
statuses: providers.list(),
|
|
8263
|
+
targets: getEffectiveSettings()?.targets ?? [],
|
|
8264
|
+
runtimeFor: (runtimeId) => providers.getRuntime(runtimeId)
|
|
8265
|
+
});
|
|
8266
|
+
}
|
|
8678
8267
|
function configuredEndpointLimits() {
|
|
8679
|
-
return Object.fromEntries(
|
|
8680
|
-
Object.entries(endpointCapacitiesForStatuses(providers.list())).map(([key, value]) => [key, value.limit])
|
|
8681
|
-
);
|
|
8268
|
+
return Object.fromEntries(Object.entries(configuredEndpointCapacities()).map(([key, value]) => [key, value.limit]));
|
|
8682
8269
|
}
|
|
8683
8270
|
function endpointCapacityForTarget(targetId) {
|
|
8684
8271
|
const status = providers.list().find((entry) => entry.target.id === targetId);
|
|
8685
|
-
|
|
8686
|
-
|
|
8272
|
+
const target = status?.target ?? providers.getTarget(targetId);
|
|
8273
|
+
if (target === null || target === void 0) return null;
|
|
8274
|
+
const endpoint = status === void 0 ? endpointCapacityFor({ target, runtime: providers.getRuntime(target.runtime) }) : endpointCapacityForStatus(status);
|
|
8687
8275
|
if (endpoint === null) return null;
|
|
8688
|
-
|
|
8689
|
-
return configured ?? endpoint;
|
|
8276
|
+
return configuredEndpointCapacities()[endpoint.key] ?? endpoint;
|
|
8690
8277
|
}
|
|
8691
8278
|
function reservationCapacitySnapshot(settings) {
|
|
8692
8279
|
const preflight = scheduling.preflight();
|
|
@@ -8760,13 +8347,27 @@ function createDispatchBundle(context, options) {
|
|
|
8760
8347
|
}
|
|
8761
8348
|
}
|
|
8762
8349
|
function configuredGlobalCapacity(settings) {
|
|
8763
|
-
const configured = settings?.
|
|
8350
|
+
const configured = settings?.fleet.concurrency;
|
|
8764
8351
|
return scheduling.maxWorkers?.() ?? (configured === "auto" || configured === void 0 ? 4 : Math.max(1, configured));
|
|
8765
8352
|
}
|
|
8353
|
+
function publishCapacityQueued(identity, timing, node) {
|
|
8354
|
+
pendingCapacity.set(identity.runId, { identity, timing, node });
|
|
8355
|
+
context.bus.emit(BusChannels.DispatchEnqueued, identity);
|
|
8356
|
+
}
|
|
8357
|
+
function publishCapacityAdmissionFailure(identity, error) {
|
|
8358
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
8359
|
+
const outcome = error instanceof AdmissionCanceledError ? "canceled" : /admission timed out/u.test(detail) ? "timed_out" : "denied_by_policy";
|
|
8360
|
+
context.bus.emit(BusChannels.DispatchFailed, {
|
|
8361
|
+
...identity,
|
|
8362
|
+
outcome,
|
|
8363
|
+
outcomeDetail: detail,
|
|
8364
|
+
reason: outcome
|
|
8365
|
+
});
|
|
8366
|
+
}
|
|
8766
8367
|
async function admitAssignmentCapacity(req, nodeId, timing, endpoint) {
|
|
8767
8368
|
const queuedAt = now();
|
|
8768
8369
|
timing.queuedAt = new Date(queuedAt).toISOString();
|
|
8769
|
-
const assignmentId = req.lineage?.rootRunId ?? `pending-${queuedAt.toString(36)}-${
|
|
8370
|
+
const assignmentId = req.lineage?.rootRunId ?? req.runIdHint ?? `pending-${queuedAt.toString(36)}-${randomBytes5(6).toString("hex")}`;
|
|
8770
8371
|
const requestedAt = Date.parse(timing.requestedAt ?? timing.queuedAt);
|
|
8771
8372
|
const deadlineAt = req.assignmentDeadlineAt ?? requestedAt + (req.routingIntent?.deadlineMs ?? 6e4);
|
|
8772
8373
|
if (req.lineage === void 0) await registerAssignment(assignmentId);
|
|
@@ -8822,7 +8423,7 @@ function createDispatchBundle(context, options) {
|
|
|
8822
8423
|
const finalizedTotals = { inputTokens: 0, outputTokens: 0, totalTokens: 0, costUsd: 0, runtimeSeconds: 0 };
|
|
8823
8424
|
const finalizedCosts = [];
|
|
8824
8425
|
function workersMaxRetries(settings = getEffectiveSettings()) {
|
|
8825
|
-
const value = settings?.
|
|
8426
|
+
const value = settings?.fleet?.retry.maxRetries;
|
|
8826
8427
|
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : 2;
|
|
8827
8428
|
}
|
|
8828
8429
|
function failoverModeFor(req) {
|
|
@@ -9010,6 +8611,7 @@ function createDispatchBundle(context, options) {
|
|
|
9010
8611
|
depth: run.lineage.depth
|
|
9011
8612
|
}
|
|
9012
8613
|
};
|
|
8614
|
+
delete retryReq.runIdHint;
|
|
9013
8615
|
const reasonKey = retryReasonKey(run.lineage.rootRunId, attempt);
|
|
9014
8616
|
retryReasons.set(reasonKey, reason);
|
|
9015
8617
|
try {
|
|
@@ -9356,10 +8958,10 @@ function createDispatchBundle(context, options) {
|
|
|
9356
8958
|
providers
|
|
9357
8959
|
);
|
|
9358
8960
|
enforceCapabilityGate(target.target.id, target.modelCapabilities, req.requiredCapabilities);
|
|
9359
|
-
assertRuntimeCanHonorWorkerPermissionMode(target.runtime, settings?.
|
|
8961
|
+
assertRuntimeCanHonorWorkerPermissionMode(target.runtime, settings?.fleet.permissions.mode ?? "deny");
|
|
9360
8962
|
assertWorkerBudgetEnforceable(target.runtime, spec.budget !== null || req.budget !== void 0);
|
|
9361
8963
|
const cwd = req.cwd ?? process.cwd();
|
|
9362
|
-
const sessionAutonomy = settings?.autonomy ?? "auto-edit";
|
|
8964
|
+
const sessionAutonomy = settings?.safety.autonomy ?? "auto-edit";
|
|
9363
8965
|
const effectiveAutonomy = clampWorkerAutonomy(sessionAutonomy, req.autonomy);
|
|
9364
8966
|
const effectiveTools = withLedgerToolNarrowing(
|
|
9365
8967
|
effectiveToolNames(admission.allowedTools, target, pathScope.writeBoundaries.length > 0, deniedToolNames(req)),
|
|
@@ -9378,7 +8980,7 @@ function createDispatchBundle(context, options) {
|
|
|
9378
8980
|
toolPromptHints: toolPromptHintsForNames(effectiveTools),
|
|
9379
8981
|
hasCanonicalContext: effectiveTools.includes(ToolNames.Context),
|
|
9380
8982
|
hasBoundSkills: effectiveTools.includes(ToolNames.Context) && recipe.skills !== void 0 && recipe.skills.length > 0 && req.noSkills !== true,
|
|
9381
|
-
onPermission: settings?.
|
|
8983
|
+
onPermission: settings?.fleet.permissions.mode ?? "deny",
|
|
9382
8984
|
persona: {
|
|
9383
8985
|
id: `persona.${recipe.id}`,
|
|
9384
8986
|
relPath: recipe.filepath,
|
|
@@ -9403,7 +9005,7 @@ function createDispatchBundle(context, options) {
|
|
|
9403
9005
|
capabilityClass: spec.capabilityClass,
|
|
9404
9006
|
projectContextTier: tier,
|
|
9405
9007
|
autonomy: effectiveAutonomy,
|
|
9406
|
-
onPermission: settings?.
|
|
9008
|
+
onPermission: settings?.fleet.permissions.mode ?? "deny",
|
|
9407
9009
|
project,
|
|
9408
9010
|
workspace: readWorkspaceRootFacts(cwd)
|
|
9409
9011
|
});
|
|
@@ -9416,7 +9018,7 @@ function createDispatchBundle(context, options) {
|
|
|
9416
9018
|
const personaOverride = personaOverrideFor(req, staticCompositionHash);
|
|
9417
9019
|
const currentToolSignature = toolSignature(effectiveTools);
|
|
9418
9020
|
const auth = targetRequiresAuth(target.target, target.runtime) ? await providers.auth.resolveForTarget(target.target, target.runtime) : null;
|
|
9419
|
-
const apiKey = auth?.apiKey ?? (auth === null ? "clio-local-target" : void 0);
|
|
9021
|
+
const apiKey = auth?.apiKey ?? (auth === null ? "clio-coder-local-target" : void 0);
|
|
9420
9022
|
const runtimeKind = target.runtime.kind;
|
|
9421
9023
|
const limitations = runtimeLimitations(runtimeKind, target.runtime.id);
|
|
9422
9024
|
return {
|
|
@@ -9467,16 +9069,16 @@ function createDispatchBundle(context, options) {
|
|
|
9467
9069
|
}
|
|
9468
9070
|
}
|
|
9469
9071
|
if (!settings) throw new Error("dispatch: effective settings required for ACP delegation");
|
|
9470
|
-
const configured = settings.
|
|
9072
|
+
const configured = settings.integrations.externalAgents.entries.find((entry) => entry.id === agentId);
|
|
9471
9073
|
if (!configured) throw new Error(`dispatch: ACP delegation agent '${agentId}' not configured`);
|
|
9472
|
-
const toolGovernance = configured.toolGovernance ?? "clio-policy";
|
|
9074
|
+
const toolGovernance = configured.toolGovernance ?? "clio-coder-policy";
|
|
9473
9075
|
if (options?.autonomyOverride === true && toolGovernance === "agent-managed") {
|
|
9474
9076
|
throw new Error(
|
|
9475
|
-
`dispatch: ACP delegation agent '${agentId}' uses toolGovernance='agent-managed', which cannot enforce an explicit one-run autonomy override; choose clio-policy or deny-all governance, or omit --autonomy`
|
|
9077
|
+
`dispatch: ACP delegation agent '${agentId}' uses toolGovernance='agent-managed', which cannot enforce an explicit one-run autonomy override; choose clio-coder-policy or deny-all governance, or omit --autonomy`
|
|
9476
9078
|
);
|
|
9477
9079
|
}
|
|
9478
9080
|
const admission = resolveDelegationAdmissionStage(req, safety);
|
|
9479
|
-
const sessionAutonomy = settings.autonomy ?? "auto-edit";
|
|
9081
|
+
const sessionAutonomy = settings.safety.autonomy ?? "auto-edit";
|
|
9480
9082
|
const autonomy = clampWorkerAutonomy(sessionAutonomy, req.autonomy);
|
|
9481
9083
|
if (toolGovernance === "agent-managed" && autonomy !== sessionAutonomy) {
|
|
9482
9084
|
throw new Error(
|
|
@@ -9536,7 +9138,26 @@ function createDispatchBundle(context, options) {
|
|
|
9536
9138
|
const wireModelId = lifecycle.agentConfig.id;
|
|
9537
9139
|
assertTargetNotCoolingDown(req, targetId, runtimeId, wireModelId);
|
|
9538
9140
|
assertBudgetAdmitsRoute(req, { rates: null, provenance: "unknown" }, settings);
|
|
9539
|
-
const
|
|
9141
|
+
const queuedIdentity = req.lineage === void 0 && req.runIdHint !== void 0 ? {
|
|
9142
|
+
runId: req.runIdHint,
|
|
9143
|
+
agentId: req.agentId,
|
|
9144
|
+
task: req.task,
|
|
9145
|
+
requestOrigin: lifecycle.requestOrigin,
|
|
9146
|
+
targetId,
|
|
9147
|
+
wireModelId,
|
|
9148
|
+
runtimeId,
|
|
9149
|
+
runtimeKind: "acp-delegation"
|
|
9150
|
+
} : null;
|
|
9151
|
+
if (queuedIdentity !== null) publishCapacityQueued(queuedIdentity, timing, null);
|
|
9152
|
+
let capacityLease;
|
|
9153
|
+
try {
|
|
9154
|
+
capacityLease = await admitAssignmentCapacity(req, "local", timing, null);
|
|
9155
|
+
} catch (error) {
|
|
9156
|
+
if (queuedIdentity !== null) publishCapacityAdmissionFailure(queuedIdentity, error);
|
|
9157
|
+
throw error;
|
|
9158
|
+
} finally {
|
|
9159
|
+
if (queuedIdentity !== null) pendingCapacity.delete(queuedIdentity.runId);
|
|
9160
|
+
}
|
|
9540
9161
|
const leaseSlot = createLeaseSlotGuard(capacityAdmission, capacityLease.leaseId, req.lineage !== void 0);
|
|
9541
9162
|
const ledgerRef = (() => {
|
|
9542
9163
|
try {
|
|
@@ -9601,12 +9222,12 @@ function createDispatchBundle(context, options) {
|
|
|
9601
9222
|
if (eventContainsFirstModelToken(event)) markObservedPhase("firstModelTokenAt");
|
|
9602
9223
|
if (eventStartsTool(event)) markObservedPhase("firstToolAt");
|
|
9603
9224
|
}
|
|
9604
|
-
if (event.type === "
|
|
9225
|
+
if (event.type === "clio_coder_tool_start" && event.payload && typeof event.payload.tool === "string") {
|
|
9605
9226
|
recordToolStart(inFlightTools, event.payload);
|
|
9606
9227
|
}
|
|
9607
|
-
if (event.type === "
|
|
9228
|
+
if (event.type === "clio_coder_run_outcome" && !reportedSpoofedOutcome) {
|
|
9608
9229
|
reportedSpoofedOutcome = true;
|
|
9609
|
-
reportDispatchDiagnostic("ACP outcome event", new Error("ignored untrusted
|
|
9230
|
+
reportDispatchDiagnostic("ACP outcome event", new Error("ignored untrusted clio_coder_run_outcome assertion"));
|
|
9610
9231
|
}
|
|
9611
9232
|
if (isRecord8(event)) {
|
|
9612
9233
|
const finishEntry = appendDispatchFinishContractEntry(finishContractEntries, event);
|
|
@@ -9637,7 +9258,7 @@ function createDispatchBundle(context, options) {
|
|
|
9637
9258
|
if (message !== null) failureMessage = message;
|
|
9638
9259
|
}
|
|
9639
9260
|
}
|
|
9640
|
-
if (event.type === "
|
|
9261
|
+
if (event.type === "clio_coder_permission_resolved" && event.payload && typeof event.payload.tool === "string") {
|
|
9641
9262
|
const requestId = typeof event.payload.requestId === "string" ? event.payload.requestId : `delegation-permission-${Date.now()}`;
|
|
9642
9263
|
const origin = runIdForPermissionAudit !== null ? `delegation:${runIdForPermissionAudit}` : "delegation:unknown";
|
|
9643
9264
|
const actionClass = typeof event.payload.actionClass === "string" ? event.payload.actionClass : "unknown";
|
|
@@ -9661,7 +9282,7 @@ function createDispatchBundle(context, options) {
|
|
|
9661
9282
|
...runIdForPermissionAudit !== null ? { requestedBy: runIdForPermissionAudit } : {}
|
|
9662
9283
|
});
|
|
9663
9284
|
}
|
|
9664
|
-
if (event.type === "
|
|
9285
|
+
if (event.type === "clio_coder_tool_finish" && event.payload && typeof event.payload.tool === "string") {
|
|
9665
9286
|
recordToolCompletion(inFlightTools, event.payload);
|
|
9666
9287
|
recordToolFinish(toolStats, event.payload);
|
|
9667
9288
|
if (event.payload.decision === "allowed") safetyDecisionCounts.allowed += 1;
|
|
@@ -9705,8 +9326,10 @@ function createDispatchBundle(context, options) {
|
|
|
9705
9326
|
runIdForPermissionAudit = envelope.id;
|
|
9706
9327
|
lineage = lineageFor(req, envelope.id);
|
|
9707
9328
|
if (req.lineage === void 0) {
|
|
9708
|
-
|
|
9709
|
-
|
|
9329
|
+
if (capacityLease.assignmentId !== lineage.rootRunId) {
|
|
9330
|
+
capacityAdmission.rename(capacityLease.leaseId, lineage.rootRunId);
|
|
9331
|
+
await renameStoredAssignment(capacityLease.assignmentId, lineage.rootRunId);
|
|
9332
|
+
}
|
|
9710
9333
|
leaseSlot.transferToAssignment();
|
|
9711
9334
|
}
|
|
9712
9335
|
identity = detectRunIdentity();
|
|
@@ -9730,16 +9353,18 @@ function createDispatchBundle(context, options) {
|
|
|
9730
9353
|
runtimeKind: "acp-delegation"
|
|
9731
9354
|
});
|
|
9732
9355
|
await ledgerRef.persist();
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9356
|
+
if (req.lineage !== void 0) {
|
|
9357
|
+
context.bus.emit(BusChannels.DispatchEnqueued, {
|
|
9358
|
+
runId: envelope.id,
|
|
9359
|
+
agentId: req.agentId,
|
|
9360
|
+
task: req.task,
|
|
9361
|
+
requestOrigin: lifecycle.requestOrigin,
|
|
9362
|
+
targetId,
|
|
9363
|
+
wireModelId,
|
|
9364
|
+
runtimeId,
|
|
9365
|
+
runtimeKind: "acp-delegation"
|
|
9366
|
+
});
|
|
9367
|
+
}
|
|
9743
9368
|
context.bus.emit(BusChannels.DispatchStarted, {
|
|
9744
9369
|
runId: envelope.id,
|
|
9745
9370
|
agentId: req.agentId,
|
|
@@ -9835,7 +9460,7 @@ function createDispatchBundle(context, options) {
|
|
|
9835
9460
|
const finalFailureMessage = result.failureMessage ?? failureMessage;
|
|
9836
9461
|
const finalToolStats = snapshotToolStats(toolStats);
|
|
9837
9462
|
const unfinished = snapshotUnfinishedTools(inFlightTools);
|
|
9838
|
-
const toolGovernance = lifecycle.agentConfig.toolGovernance ?? "clio-policy";
|
|
9463
|
+
const toolGovernance = lifecycle.agentConfig.toolGovernance ?? "clio-coder-policy";
|
|
9839
9464
|
return {
|
|
9840
9465
|
runId: envelope.id,
|
|
9841
9466
|
agentId: req.agentId,
|
|
@@ -9885,7 +9510,7 @@ function createDispatchBundle(context, options) {
|
|
|
9885
9510
|
dynamicHash: lifecycle.dynamicHash,
|
|
9886
9511
|
promptSignature: lifecycle.promptSignature,
|
|
9887
9512
|
toolSignature: lifecycle.toolSignature,
|
|
9888
|
-
|
|
9513
|
+
clioCoderVersion: readClioVersion(),
|
|
9889
9514
|
piMonoVersion: readPiMonoVersion(),
|
|
9890
9515
|
platform: process.platform,
|
|
9891
9516
|
nodeVersion: process.version,
|
|
@@ -9899,7 +9524,7 @@ function createDispatchBundle(context, options) {
|
|
|
9899
9524
|
quality: createRunReceiptQuality({ runtimeEnforceable: false, enforcementPassed: null, resultContract: null }),
|
|
9900
9525
|
autonomyEnforcement: autonomyEnforcementForAcpDelegation(
|
|
9901
9526
|
lifecycle.autonomy,
|
|
9902
|
-
lifecycle.agentConfig.toolGovernance ?? "clio-policy",
|
|
9527
|
+
lifecycle.agentConfig.toolGovernance ?? "clio-coder-policy",
|
|
9903
9528
|
lifecycle.sessionAutonomy,
|
|
9904
9529
|
req.autonomy
|
|
9905
9530
|
),
|
|
@@ -9929,7 +9554,7 @@ function createDispatchBundle(context, options) {
|
|
|
9929
9554
|
toolCallsRequested: result.delegation.toolCallsRequested,
|
|
9930
9555
|
toolCallsApproved: result.delegation.toolCallsApproved,
|
|
9931
9556
|
toolCallsDenied: result.delegation.toolCallsDenied,
|
|
9932
|
-
toolGovernance: lifecycle.agentConfig.toolGovernance ?? "clio-policy",
|
|
9557
|
+
toolGovernance: lifecycle.agentConfig.toolGovernance ?? "clio-coder-policy",
|
|
9933
9558
|
toolCallLog: acp.toolCallLog()
|
|
9934
9559
|
},
|
|
9935
9560
|
sessionId: result.delegation.acpSessionId
|
|
@@ -10136,7 +9761,7 @@ function createDispatchBundle(context, options) {
|
|
|
10136
9761
|
const requestedAt = new Date(now()).toISOString();
|
|
10137
9762
|
const timing = { requestedAt, decisionStartedAt: requestedAt };
|
|
10138
9763
|
const settings = getEffectiveSettings();
|
|
10139
|
-
const isAcpAgent = settings?.
|
|
9764
|
+
const isAcpAgent = settings?.integrations.externalAgents?.entries?.some((entry) => entry.id === req.agentId) ?? false;
|
|
10140
9765
|
if (isAcpAgent && !req.delegationAgentId) {
|
|
10141
9766
|
req.delegationAgentId = req.agentId;
|
|
10142
9767
|
}
|
|
@@ -10146,12 +9771,13 @@ function createDispatchBundle(context, options) {
|
|
|
10146
9771
|
throw new Error(`dispatch: invalid spec: ${validated.errors.join("; ")}`);
|
|
10147
9772
|
}
|
|
10148
9773
|
req = validation.restore(validated.spec);
|
|
9774
|
+
if (req.lineage === void 0 && req.runIdHint === void 0) req = { ...req, runIdHint: newRunId() };
|
|
10149
9775
|
let activeRouteObservation = null;
|
|
10150
9776
|
if (req.delegationAgentId === void 0) {
|
|
10151
9777
|
const recipe = agents.get(req.agentId);
|
|
10152
9778
|
const activation = consumeActiveRouteApproval({
|
|
10153
9779
|
request: req,
|
|
10154
|
-
settings: settings?.
|
|
9780
|
+
settings: settings?.fleet.adaptiveRouting,
|
|
10155
9781
|
capabilityClass: recipe === null ? null : normalizeAgentSpec(recipe).capabilityClass,
|
|
10156
9782
|
failover: failoverModeFor(req),
|
|
10157
9783
|
requestedAt,
|
|
@@ -10264,7 +9890,34 @@ function createDispatchBundle(context, options) {
|
|
|
10264
9890
|
},
|
|
10265
9891
|
shadow: () => observeShadowRoute(req, placed, settings)
|
|
10266
9892
|
});
|
|
10267
|
-
const
|
|
9893
|
+
const queuedIdentity = req.lineage === void 0 && req.runIdHint !== void 0 ? {
|
|
9894
|
+
runId: req.runIdHint,
|
|
9895
|
+
agentId: req.agentId,
|
|
9896
|
+
task: req.task,
|
|
9897
|
+
agentAudience: lifecycle.agentAudience,
|
|
9898
|
+
requestOrigin: lifecycle.requestOrigin,
|
|
9899
|
+
targetId: lifecycle.target.target.id,
|
|
9900
|
+
wireModelId: lifecycle.target.wireModelId,
|
|
9901
|
+
runtimeId: lifecycle.target.runtime.id,
|
|
9902
|
+
runtimeKind: lifecycle.runtimeKind,
|
|
9903
|
+
budget: lifecycle.budgetEnvelope,
|
|
9904
|
+
...endpoint !== null ? { endpoint: { key: endpoint.key, label: endpoint.label, limit: endpoint.limit } } : {},
|
|
9905
|
+
...placement !== null ? { node: placement.node.id } : {},
|
|
9906
|
+
...req.gate !== void 0 ? { gate: { role: req.gate.role, cycle: req.gate.cycle } } : {},
|
|
9907
|
+
...req.council !== void 0 ? { council: req.council } : {},
|
|
9908
|
+
...req.reroutes !== void 0 && req.reroutes.length > 0 ? { rerouteCount: req.reroutes.length } : {},
|
|
9909
|
+
...lifecycle.target.modelCapabilities !== void 0 && lifecycle.target.modelCapabilities !== null && lifecycle.target.modelCapabilities.contextWindow > 0 ? { contextWindow: lifecycle.target.modelCapabilities.contextWindow } : {}
|
|
9910
|
+
} : null;
|
|
9911
|
+
if (queuedIdentity !== null) publishCapacityQueued(queuedIdentity, timing, placement?.node ?? null);
|
|
9912
|
+
let capacityLease;
|
|
9913
|
+
try {
|
|
9914
|
+
capacityLease = await admitAssignmentCapacity(req, placement?.node.id ?? "local", timing, endpoint);
|
|
9915
|
+
} catch (error) {
|
|
9916
|
+
if (queuedIdentity !== null) publishCapacityAdmissionFailure(queuedIdentity, error);
|
|
9917
|
+
throw error;
|
|
9918
|
+
} finally {
|
|
9919
|
+
if (queuedIdentity !== null) pendingCapacity.delete(queuedIdentity.runId);
|
|
9920
|
+
}
|
|
10268
9921
|
const leaseSlot = createLeaseSlotGuard(capacityAdmission, capacityLease.leaseId, req.lineage !== void 0);
|
|
10269
9922
|
const ledgerRef = (() => {
|
|
10270
9923
|
try {
|
|
@@ -10381,7 +10034,7 @@ function createDispatchBundle(context, options) {
|
|
|
10381
10034
|
context.bus.emit(BusChannels.DispatchProgress, {
|
|
10382
10035
|
runId,
|
|
10383
10036
|
agentId: req.agentId,
|
|
10384
|
-
event: { type: "
|
|
10037
|
+
event: { type: "clio_coder_write_record_downgraded", payload: downgrade }
|
|
10385
10038
|
});
|
|
10386
10039
|
}
|
|
10387
10040
|
});
|
|
@@ -10412,11 +10065,11 @@ function createDispatchBundle(context, options) {
|
|
|
10412
10065
|
if (eventContainsFirstModelToken(event)) markObservedPhase("firstModelTokenAt");
|
|
10413
10066
|
if (eventStartsTool(event)) markObservedPhase("firstToolAt");
|
|
10414
10067
|
}
|
|
10415
|
-
if (event.type === "
|
|
10068
|
+
if (event.type === "clio_coder_tool_start" && event.payload && typeof event.payload.tool === "string") {
|
|
10416
10069
|
recordToolStart(inFlightTools, event.payload);
|
|
10417
10070
|
}
|
|
10418
|
-
if (event.type === "
|
|
10419
|
-
if (event.type === "
|
|
10071
|
+
if (event.type === "clio_coder_steer_received") acknowledgeSteer(event.payload?.sequence);
|
|
10072
|
+
if (event.type === "clio_coder_run_outcome" && isRunOutcomeCode(event.payload?.outcomeCode) && event.payload.outcomeCode !== "worker_final_output_missing" && event.payload.outcomeCode !== "host_verification_rejected") {
|
|
10420
10073
|
if (acceptsOutcomeCodeEvents) {
|
|
10421
10074
|
trustedOutcomeCodes.add(event.payload.outcomeCode);
|
|
10422
10075
|
} else if (!reportedUntrustedOutcome) {
|
|
@@ -10435,7 +10088,7 @@ function createDispatchBundle(context, options) {
|
|
|
10435
10088
|
}
|
|
10436
10089
|
recordWorkerRunEffect(runEffects, event);
|
|
10437
10090
|
}
|
|
10438
|
-
if (event.type === "
|
|
10091
|
+
if (event.type === "clio_coder_permission_escalated" && event.payload && typeof event.payload.requestId === "string") {
|
|
10439
10092
|
escalationCounts.requested += 1;
|
|
10440
10093
|
const ctx = isRecord8(event.payload.decision) ? event.payload.decision : null;
|
|
10441
10094
|
const classification = ctx !== null && isRecord8(ctx.classification) ? ctx.classification : null;
|
|
@@ -10462,6 +10115,7 @@ function createDispatchBundle(context, options) {
|
|
|
10462
10115
|
...ruleId !== null ? { ruleId } : {},
|
|
10463
10116
|
...policySource !== null ? { policySource } : {},
|
|
10464
10117
|
...typeof event.payload.timeoutMs === "number" ? { timeoutMs: event.payload.timeoutMs } : {},
|
|
10118
|
+
fallback: spec.escalation?.fallback ?? "deny",
|
|
10465
10119
|
escalation: true
|
|
10466
10120
|
});
|
|
10467
10121
|
}
|
|
@@ -10487,7 +10141,7 @@ function createDispatchBundle(context, options) {
|
|
|
10487
10141
|
if (message !== null) failureMessage = message;
|
|
10488
10142
|
}
|
|
10489
10143
|
}
|
|
10490
|
-
if (event.type === "
|
|
10144
|
+
if (event.type === "clio_coder_permission_resolved" && event.payload && typeof event.payload.tool === "string") {
|
|
10491
10145
|
const source = event.payload.source;
|
|
10492
10146
|
const granted = (source === "operator" || source === "remembered") && event.payload.decision === "approved";
|
|
10493
10147
|
const decidedBy = source === "operator" ? "operator" : source === "remembered" ? "operator:remembered" : source === "timeout" ? "timeout" : "policy:no-operator";
|
|
@@ -10519,10 +10173,11 @@ function createDispatchBundle(context, options) {
|
|
|
10519
10173
|
decidedBy,
|
|
10520
10174
|
actionClass,
|
|
10521
10175
|
reason,
|
|
10176
|
+
...source === "timeout" ? { fallback: spec.escalation?.fallback ?? "deny" } : {},
|
|
10522
10177
|
...runIdForPermissionAudit !== null ? { requestedBy: runIdForPermissionAudit } : {}
|
|
10523
10178
|
});
|
|
10524
10179
|
}
|
|
10525
|
-
if (event.type === "
|
|
10180
|
+
if (event.type === "clio_coder_tool_finish" && event.payload && typeof event.payload.tool === "string") {
|
|
10526
10181
|
recordToolCompletion(inFlightTools, event.payload);
|
|
10527
10182
|
recordToolFinish(toolStats, event.payload);
|
|
10528
10183
|
if (isSkillActivation(event.payload.skillActivation)) {
|
|
@@ -10571,8 +10226,10 @@ function createDispatchBundle(context, options) {
|
|
|
10571
10226
|
runIdForPermissionAudit = envelope.id;
|
|
10572
10227
|
lineage = lineageFor(req, envelope.id);
|
|
10573
10228
|
if (req.lineage === void 0) {
|
|
10574
|
-
|
|
10575
|
-
|
|
10229
|
+
if (capacityLease.assignmentId !== lineage.rootRunId) {
|
|
10230
|
+
capacityAdmission.rename(capacityLease.leaseId, lineage.rootRunId);
|
|
10231
|
+
await renameStoredAssignment(capacityLease.assignmentId, lineage.rootRunId);
|
|
10232
|
+
}
|
|
10576
10233
|
leaseSlot.transferToAssignment();
|
|
10577
10234
|
}
|
|
10578
10235
|
if (agentLedgerId !== null) {
|
|
@@ -10621,18 +10278,20 @@ function createDispatchBundle(context, options) {
|
|
|
10621
10278
|
...req.reroutes !== void 0 && req.reroutes.length > 0 ? { rerouteCount: req.reroutes.length } : {},
|
|
10622
10279
|
...lifecycle.target.modelCapabilities !== void 0 && lifecycle.target.modelCapabilities !== null && lifecycle.target.modelCapabilities.contextWindow > 0 ? { contextWindow: lifecycle.target.modelCapabilities.contextWindow } : {}
|
|
10623
10280
|
};
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10281
|
+
if (req.lineage !== void 0) {
|
|
10282
|
+
context.bus.emit(BusChannels.DispatchEnqueued, {
|
|
10283
|
+
runId: envelope.id,
|
|
10284
|
+
agentId: req.agentId,
|
|
10285
|
+
task: req.task,
|
|
10286
|
+
agentAudience: lifecycle.agentAudience,
|
|
10287
|
+
requestOrigin: lifecycle.requestOrigin,
|
|
10288
|
+
targetId: lifecycle.target.target.id,
|
|
10289
|
+
wireModelId: lifecycle.target.wireModelId,
|
|
10290
|
+
runtimeId: lifecycle.target.runtime.id,
|
|
10291
|
+
runtimeKind: lifecycle.runtimeKind,
|
|
10292
|
+
...fleetIdentity
|
|
10293
|
+
});
|
|
10294
|
+
}
|
|
10636
10295
|
context.bus.emit(BusChannels.DispatchStarted, {
|
|
10637
10296
|
runId: envelope.id,
|
|
10638
10297
|
agentId: req.agentId,
|
|
@@ -10737,10 +10396,10 @@ function createDispatchBundle(context, options) {
|
|
|
10737
10396
|
const fleetGate = (() => {
|
|
10738
10397
|
if (req.fleetGateReceipt === void 0) return null;
|
|
10739
10398
|
try {
|
|
10740
|
-
const content =
|
|
10741
|
-
return { path: req.fleetGateReceipt.path, pathHash:
|
|
10399
|
+
const content = readFileSync11(resolvePath(lifecycle.cwd, req.fleetGateReceipt.path));
|
|
10400
|
+
return { path: req.fleetGateReceipt.path, pathHash: createHash7("sha256").update(content).digest("hex") };
|
|
10742
10401
|
} catch {
|
|
10743
|
-
return { path: req.fleetGateReceipt.path, pathHash:
|
|
10402
|
+
return { path: req.fleetGateReceipt.path, pathHash: createHash7("sha256").update("").digest("hex") };
|
|
10744
10403
|
}
|
|
10745
10404
|
})();
|
|
10746
10405
|
const ledgerContribution = (() => {
|
|
@@ -10817,7 +10476,7 @@ function createDispatchBundle(context, options) {
|
|
|
10817
10476
|
dynamicHash: lifecycle.dynamicHash,
|
|
10818
10477
|
promptSignature: lifecycle.promptSignature,
|
|
10819
10478
|
toolSignature: lifecycle.toolSignature,
|
|
10820
|
-
|
|
10479
|
+
clioCoderVersion: readClioVersion(),
|
|
10821
10480
|
piMonoVersion: readPiMonoVersion(),
|
|
10822
10481
|
platform: process.platform,
|
|
10823
10482
|
nodeVersion: process.version,
|
|
@@ -10839,7 +10498,7 @@ function createDispatchBundle(context, options) {
|
|
|
10839
10498
|
...skillActivations.length > 0 ? { skillActivations: [...skillActivations] } : {},
|
|
10840
10499
|
autonomyEnforcement: autonomyEnforcementForWorkerSpec(
|
|
10841
10500
|
spec,
|
|
10842
|
-
lifecycle.settings?.autonomy ?? "auto-edit",
|
|
10501
|
+
lifecycle.settings?.safety.autonomy ?? "auto-edit",
|
|
10843
10502
|
req.autonomy
|
|
10844
10503
|
),
|
|
10845
10504
|
safety: {
|
|
@@ -10995,18 +10654,7 @@ function createDispatchBundle(context, options) {
|
|
|
10995
10654
|
cwd: lifecycle.cwd,
|
|
10996
10655
|
networkAllowed: lifecycle.admission.allowedTools.includes(ToolNames.WebFetch),
|
|
10997
10656
|
observedRunEffects,
|
|
10998
|
-
filesystem:
|
|
10999
|
-
readFile(filePath) {
|
|
11000
|
-
try {
|
|
11001
|
-
return readFileSync12(filePath, "utf8");
|
|
11002
|
-
} catch {
|
|
11003
|
-
return null;
|
|
11004
|
-
}
|
|
11005
|
-
},
|
|
11006
|
-
pathExists(filePath) {
|
|
11007
|
-
return existsSync12(filePath);
|
|
11008
|
-
}
|
|
11009
|
-
}
|
|
10657
|
+
filesystem: nodeResultContractFilesystem()
|
|
11010
10658
|
});
|
|
11011
10659
|
const resultValidation = resultContract?.applicable === true ? resultContract.validation : null;
|
|
11012
10660
|
if (finalOutcome === "succeeded" && resultValidation?.conformance === "fail") {
|
|
@@ -11277,7 +10925,7 @@ function createDispatchBundle(context, options) {
|
|
|
11277
10925
|
return { runId: handle.runId, events: assignment.events, finalPromise: terminal };
|
|
11278
10926
|
}
|
|
11279
10927
|
function previewFixed(req, settings = getEffectiveSettings()) {
|
|
11280
|
-
const isAcpAgent = settings?.
|
|
10928
|
+
const isAcpAgent = settings?.integrations.externalAgents?.entries?.some((entry) => entry.id === req.agentId) ?? false;
|
|
11281
10929
|
if (isAcpAgent && !req.delegationAgentId) req = { ...req, delegationAgentId: req.agentId };
|
|
11282
10930
|
const validation = routeValidationProjection(req, true);
|
|
11283
10931
|
const validated = validateJobSpec(validation.jobSpec);
|
|
@@ -11350,7 +10998,7 @@ function createDispatchBundle(context, options) {
|
|
|
11350
10998
|
req
|
|
11351
10999
|
);
|
|
11352
11000
|
assertPostRuntimeToolCompatibility(req.agentId, agentSpec, effectiveTools, target);
|
|
11353
|
-
assertRuntimeCanHonorWorkerPermissionMode(target.runtime, settings?.
|
|
11001
|
+
assertRuntimeCanHonorWorkerPermissionMode(target.runtime, settings?.fleet.permissions.mode ?? "deny");
|
|
11354
11002
|
assertWorkerBudgetEnforceable(target.runtime, agentSpec.budget !== null || req.budget !== void 0);
|
|
11355
11003
|
assertResponseSchemaEnforceable(target.runtime, target.modelCapabilities, req.responseSchema, effectiveTools.length);
|
|
11356
11004
|
assertWriteRootsEnforceable(target.runtime, pathScope.writeBoundaries);
|
|
@@ -11405,7 +11053,7 @@ function createDispatchBundle(context, options) {
|
|
|
11405
11053
|
specs,
|
|
11406
11054
|
request: req,
|
|
11407
11055
|
mode,
|
|
11408
|
-
activeAgentRoles: settings?.
|
|
11056
|
+
activeAgentRoles: settings?.fleet.adaptiveRouting.agentRoles ?? [],
|
|
11409
11057
|
...agentIntent === void 0 ? {} : { intentOverride: agentIntent }
|
|
11410
11058
|
});
|
|
11411
11059
|
const settingsFingerprint = computeSettingsFingerprint(settings ?? null);
|
|
@@ -11490,7 +11138,7 @@ function createDispatchBundle(context, options) {
|
|
|
11490
11138
|
const recipe = agents.get(req.agentId);
|
|
11491
11139
|
return planActiveRoute({
|
|
11492
11140
|
request: req,
|
|
11493
|
-
settings: settings?.
|
|
11141
|
+
settings: settings?.fleet.adaptiveRouting,
|
|
11494
11142
|
capabilityClass: recipe === null ? null : normalizeAgentSpec(recipe).capabilityClass,
|
|
11495
11143
|
failover: failoverModeFor(req),
|
|
11496
11144
|
fixed,
|
|
@@ -11655,7 +11303,7 @@ function createDispatchBundle(context, options) {
|
|
|
11655
11303
|
costProvenance: "unknown",
|
|
11656
11304
|
compiledPromptHash: null,
|
|
11657
11305
|
staticCompositionHash: null,
|
|
11658
|
-
|
|
11306
|
+
clioCoderVersion: readClioVersion(),
|
|
11659
11307
|
piMonoVersion: readPiMonoVersion(),
|
|
11660
11308
|
platform: process.platform,
|
|
11661
11309
|
nodeVersion: process.version,
|
|
@@ -11715,8 +11363,10 @@ function createDispatchBundle(context, options) {
|
|
|
11715
11363
|
});
|
|
11716
11364
|
return receipt;
|
|
11717
11365
|
}
|
|
11366
|
+
let journalBridge = null;
|
|
11718
11367
|
const extension = {
|
|
11719
11368
|
async start() {
|
|
11369
|
+
if (options?.journalRunEvents === true) journalBridge = attachRunEventJournalBridge(context.bus);
|
|
11720
11370
|
cleanupDispatchReservations({ startup: true, nowMs: now() });
|
|
11721
11371
|
ledger = openLedger();
|
|
11722
11372
|
try {
|
|
@@ -11768,6 +11418,8 @@ function createDispatchBundle(context, options) {
|
|
|
11768
11418
|
for (const ownerId of ownedReservations) rollbackDispatchReservation(ownerId, now());
|
|
11769
11419
|
ownedReservations.clear();
|
|
11770
11420
|
await Promise.allSettled([...assignmentWrites]);
|
|
11421
|
+
journalBridge?.stop();
|
|
11422
|
+
journalBridge = null;
|
|
11771
11423
|
}
|
|
11772
11424
|
};
|
|
11773
11425
|
function emitRunAborted(run, source) {
|
|
@@ -11788,6 +11440,26 @@ function createDispatchBundle(context, options) {
|
|
|
11788
11440
|
const running = [];
|
|
11789
11441
|
const totals = { ...finalizedTotals };
|
|
11790
11442
|
const costAmounts = [...finalizedCosts];
|
|
11443
|
+
for (const pending of pendingCapacity.values()) {
|
|
11444
|
+
const startedAt = pending.timing.queuedAt ?? pending.timing.requestedAt ?? new Date(tickNow).toISOString();
|
|
11445
|
+
running.push({
|
|
11446
|
+
runId: pending.identity.runId,
|
|
11447
|
+
agentId: pending.identity.agentId,
|
|
11448
|
+
...pending.identity.task !== void 0 ? { task: pending.identity.task } : {},
|
|
11449
|
+
...pending.identity.budget !== void 0 ? { budget: pending.identity.budget } : {},
|
|
11450
|
+
runtimeKind: pending.identity.runtimeKind,
|
|
11451
|
+
outcomePhase: "queued",
|
|
11452
|
+
heartbeat: "n/a",
|
|
11453
|
+
lineage: { parentRunId: null, rootRunId: pending.identity.runId, attempt: 0, depth: 0 },
|
|
11454
|
+
startedAt,
|
|
11455
|
+
elapsedMs: 0,
|
|
11456
|
+
timing: deriveRunPhaseDurations(pending.timing, startedAt, new Date(tickNow).toISOString()),
|
|
11457
|
+
tokens: { input: 0, output: 0, total: 0 },
|
|
11458
|
+
costUsd: 0,
|
|
11459
|
+
costProvenance: "unknown",
|
|
11460
|
+
node: pending.node === null ? null : { ...pending.node }
|
|
11461
|
+
});
|
|
11462
|
+
}
|
|
11791
11463
|
for (const run of active.values()) {
|
|
11792
11464
|
let heartbeat = "n/a";
|
|
11793
11465
|
if (run.heartbeatAt && Number.isFinite(heartbeatMonotonicAt(run.heartbeatAt))) {
|
|
@@ -11952,6 +11624,17 @@ function createDispatchBundle(context, options) {
|
|
|
11952
11624
|
},
|
|
11953
11625
|
abort(runId, reason) {
|
|
11954
11626
|
const rootRunId = assignmentRootFor(runId);
|
|
11627
|
+
const queued = pendingCapacity.get(rootRunId);
|
|
11628
|
+
if (queued !== void 0 && capacityAdmission.cancel(rootRunId)) {
|
|
11629
|
+
persistAssignment(cancelStoredAssignment(rootRunId), `${rootRunId}:cancel-queued`);
|
|
11630
|
+
context.bus.emit(BusChannels.RunAborted, {
|
|
11631
|
+
source: "dispatch_abort",
|
|
11632
|
+
runId: rootRunId,
|
|
11633
|
+
startedAt: null,
|
|
11634
|
+
elapsedMs: null,
|
|
11635
|
+
reason: reason?.detail ?? "operator abort while waiting for an endpoint slot"
|
|
11636
|
+
});
|
|
11637
|
+
}
|
|
11955
11638
|
const assignment = assignments.get(rootRunId);
|
|
11956
11639
|
if (assignment?.status === "running") {
|
|
11957
11640
|
assignments.cancel(assignment.id);
|
|
@@ -12052,12 +11735,12 @@ var DispatchManifest = {
|
|
|
12052
11735
|
|
|
12053
11736
|
// src/domains/dispatch/code-step-store.ts
|
|
12054
11737
|
init_esm_shims();
|
|
12055
|
-
import { join as
|
|
11738
|
+
import { join as join13 } from "node:path";
|
|
12056
11739
|
function codeStepDir(rootId) {
|
|
12057
|
-
return
|
|
11740
|
+
return join13(clioStateDir(), "code-steps", rootId);
|
|
12058
11741
|
}
|
|
12059
11742
|
function codeStepRecordPath(rootId, runId) {
|
|
12060
|
-
return
|
|
11743
|
+
return join13(codeStepDir(rootId), `${runId}.json`);
|
|
12061
11744
|
}
|
|
12062
11745
|
async function writeCodeStepRecord(rootId, record) {
|
|
12063
11746
|
const path2 = codeStepRecordPath(rootId, record.runId);
|
|
@@ -12068,7 +11751,7 @@ async function writeCodeStepRecord(rootId, record) {
|
|
|
12068
11751
|
|
|
12069
11752
|
// src/domains/dispatch/delegation-plan.ts
|
|
12070
11753
|
init_esm_shims();
|
|
12071
|
-
import { createHash as
|
|
11754
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
12072
11755
|
var DELEGATION_PROPOSAL_BRIEFING_MAX_BYTES = 12e3;
|
|
12073
11756
|
function buildDelegationProposalBriefing(proposals) {
|
|
12074
11757
|
const value = proposals.map((proposal) => `PROPOSAL ${proposal.agent}
|
|
@@ -12176,7 +11859,7 @@ function validateDelegationPlan(input) {
|
|
|
12176
11859
|
}
|
|
12177
11860
|
}
|
|
12178
11861
|
const plan = { tasks };
|
|
12179
|
-
return { ok: true, plan, hash:
|
|
11862
|
+
return { ok: true, plan, hash: createHash8("sha256").update(JSON.stringify(plan)).digest("hex") };
|
|
12180
11863
|
}
|
|
12181
11864
|
|
|
12182
11865
|
// src/domains/dispatch/execution-scheduler.ts
|
|
@@ -12604,9 +12287,125 @@ function gateFailureLines(output) {
|
|
|
12604
12287
|
|
|
12605
12288
|
// src/domains/dispatch/fleet-run.ts
|
|
12606
12289
|
init_esm_shims();
|
|
12607
|
-
import { createHash as
|
|
12608
|
-
import { readFileSync as
|
|
12609
|
-
import { join as
|
|
12290
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
12291
|
+
import { readFileSync as readFileSync12 } from "node:fs";
|
|
12292
|
+
import { join as join14 } from "node:path";
|
|
12293
|
+
|
|
12294
|
+
// src/domains/observability/cost.ts
|
|
12295
|
+
init_esm_shims();
|
|
12296
|
+
function emptyCostAggregate() {
|
|
12297
|
+
return { knownUsd: 0, hasEstimated: false, hasUnknown: false, allKnownFree: false, calls: 0 };
|
|
12298
|
+
}
|
|
12299
|
+
function costWasMeasured(cost) {
|
|
12300
|
+
return cost !== null && cost !== void 0 && cost.calls > 0;
|
|
12301
|
+
}
|
|
12302
|
+
function accumulateCostAmount(aggregate, amount, first) {
|
|
12303
|
+
return {
|
|
12304
|
+
knownUsd: aggregate.knownUsd + (amount.provenance === "unknown" ? 0 : amount.usd),
|
|
12305
|
+
hasEstimated: aggregate.hasEstimated || amount.provenance === "estimated",
|
|
12306
|
+
hasUnknown: aggregate.hasUnknown || amount.provenance === "unknown",
|
|
12307
|
+
allKnownFree: amount.provenance === "known_free" && (first || aggregate.allKnownFree),
|
|
12308
|
+
calls: aggregate.calls + 1
|
|
12309
|
+
};
|
|
12310
|
+
}
|
|
12311
|
+
function aggregateCostAmounts(amounts) {
|
|
12312
|
+
return amounts.reduce(
|
|
12313
|
+
(aggregate, amount, index) => accumulateCostAmount(aggregate, amount, index === 0),
|
|
12314
|
+
emptyCostAggregate()
|
|
12315
|
+
);
|
|
12316
|
+
}
|
|
12317
|
+
function formatUsdAmount(value) {
|
|
12318
|
+
if (!Number.isFinite(value) || value <= 0) return "$0.00";
|
|
12319
|
+
return value < 0.01 ? `$${value.toFixed(4)}` : `$${value.toFixed(2)}`;
|
|
12320
|
+
}
|
|
12321
|
+
function formatCostAggregate(cost) {
|
|
12322
|
+
if (!costWasMeasured(cost)) return null;
|
|
12323
|
+
if (cost.allKnownFree) return "$0.00 local";
|
|
12324
|
+
if (cost.hasUnknown) return cost.knownUsd > 0 ? `${formatUsdAmount(cost.knownUsd)} +?` : null;
|
|
12325
|
+
if (cost.hasEstimated) return `~${formatUsdAmount(cost.knownUsd)} est`;
|
|
12326
|
+
return formatUsdAmount(cost.knownUsd);
|
|
12327
|
+
}
|
|
12328
|
+
var COST_NOT_MEASURED = "not measured";
|
|
12329
|
+
function costAggregateForAmount(usd, provenance) {
|
|
12330
|
+
return aggregateCostAmounts([{ usd, provenance: normalizeCostProvenance(provenance) }]);
|
|
12331
|
+
}
|
|
12332
|
+
function renderCostAggregate(cost) {
|
|
12333
|
+
return formatCostAggregate(cost) ?? COST_NOT_MEASURED;
|
|
12334
|
+
}
|
|
12335
|
+
function renderCostAmount(usd, provenance) {
|
|
12336
|
+
return renderCostAggregate(costAggregateForAmount(usd, provenance));
|
|
12337
|
+
}
|
|
12338
|
+
function emptyBreakdown() {
|
|
12339
|
+
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, reasoningTokens: 0, totalTokens: 0 };
|
|
12340
|
+
}
|
|
12341
|
+
function createCostTracker() {
|
|
12342
|
+
const log = [];
|
|
12343
|
+
let total = 0;
|
|
12344
|
+
const totals = emptyBreakdown();
|
|
12345
|
+
return {
|
|
12346
|
+
accumulate(providerId, attributedModelId, tokens, usd, breakdown, costProvenance, modelIdFacts, label) {
|
|
12347
|
+
const resolvedUsd = usd ?? 0;
|
|
12348
|
+
const provenance = normalizeCostProvenance(costProvenance);
|
|
12349
|
+
const input = breakdown?.input ?? 0;
|
|
12350
|
+
const output = breakdown?.output ?? 0;
|
|
12351
|
+
const cacheRead = breakdown?.cacheRead ?? 0;
|
|
12352
|
+
const cacheWrite = breakdown?.cacheWrite ?? 0;
|
|
12353
|
+
const reasoningTokens = breakdown?.reasoningTokens ?? 0;
|
|
12354
|
+
const apiCalls = breakdown?.apiCalls;
|
|
12355
|
+
log.push({
|
|
12356
|
+
providerId,
|
|
12357
|
+
attributedModelId,
|
|
12358
|
+
requestedModelIds: [...modelIdFacts?.requestedModelIds ?? [attributedModelId]],
|
|
12359
|
+
responseModelIdObservationCounts: modelIdFacts ? { ...modelIdFacts.responseModelIdObservationCounts } : {
|
|
12360
|
+
reportedCalls: 0,
|
|
12361
|
+
notReportedCalls: 0,
|
|
12362
|
+
notObservedCalls: apiCalls ?? 1,
|
|
12363
|
+
legacyDifferenceOnlyCalls: 0
|
|
12364
|
+
},
|
|
12365
|
+
tokens,
|
|
12366
|
+
usd: resolvedUsd,
|
|
12367
|
+
provenance,
|
|
12368
|
+
input,
|
|
12369
|
+
output,
|
|
12370
|
+
cacheRead,
|
|
12371
|
+
cacheWrite,
|
|
12372
|
+
reasoningTokens,
|
|
12373
|
+
...apiCalls !== void 0 ? { apiCalls } : {},
|
|
12374
|
+
...label !== void 0 ? { label } : {}
|
|
12375
|
+
});
|
|
12376
|
+
total += resolvedUsd;
|
|
12377
|
+
totals.input += input;
|
|
12378
|
+
totals.output += output;
|
|
12379
|
+
totals.cacheRead += cacheRead;
|
|
12380
|
+
totals.cacheWrite += cacheWrite;
|
|
12381
|
+
totals.reasoningTokens += reasoningTokens;
|
|
12382
|
+
totals.totalTokens += tokens;
|
|
12383
|
+
return resolvedUsd;
|
|
12384
|
+
},
|
|
12385
|
+
sessionTotal() {
|
|
12386
|
+
return total;
|
|
12387
|
+
},
|
|
12388
|
+
sessionCost() {
|
|
12389
|
+
return aggregateCostAmounts(log.map((entry) => ({ usd: entry.usd, provenance: entry.provenance })));
|
|
12390
|
+
},
|
|
12391
|
+
sessionTokens() {
|
|
12392
|
+
return { ...totals };
|
|
12393
|
+
},
|
|
12394
|
+
entries() {
|
|
12395
|
+
return log;
|
|
12396
|
+
},
|
|
12397
|
+
reset() {
|
|
12398
|
+
log.length = 0;
|
|
12399
|
+
total = 0;
|
|
12400
|
+
totals.input = 0;
|
|
12401
|
+
totals.output = 0;
|
|
12402
|
+
totals.cacheRead = 0;
|
|
12403
|
+
totals.cacheWrite = 0;
|
|
12404
|
+
totals.reasoningTokens = 0;
|
|
12405
|
+
totals.totalTokens = 0;
|
|
12406
|
+
}
|
|
12407
|
+
};
|
|
12408
|
+
}
|
|
12610
12409
|
|
|
12611
12410
|
// src/domains/dispatch/fleet-commit-attribution.ts
|
|
12612
12411
|
init_esm_shims();
|
|
@@ -12698,6 +12497,11 @@ function fleetGateCorrelation(subject, decider) {
|
|
|
12698
12497
|
);
|
|
12699
12498
|
return { agent, target, modelFamily: modelFamily2, runtime, node, independent };
|
|
12700
12499
|
}
|
|
12500
|
+
function fleetStepIntent(writes) {
|
|
12501
|
+
if (writes === void 0 || writes.length === 0) return null;
|
|
12502
|
+
const built = declaredScopeIntent({ relevantPaths: writes });
|
|
12503
|
+
return built.ok ? built.intent : null;
|
|
12504
|
+
}
|
|
12701
12505
|
function fleetPlanWaveIndex(plan, stepId) {
|
|
12702
12506
|
return plan.waves.findIndex((wave) => wave.includes(stepId));
|
|
12703
12507
|
}
|
|
@@ -12769,7 +12573,7 @@ async function executeFleetRun(input) {
|
|
|
12769
12573
|
for (const [stepId, replayedResult] of replayed) {
|
|
12770
12574
|
try {
|
|
12771
12575
|
const receipt = JSON.parse(
|
|
12772
|
-
|
|
12576
|
+
readFileSync12(join14(clioStateDir(), "receipts", `${replayedResult.terminalRunId}.json`), "utf8")
|
|
12773
12577
|
);
|
|
12774
12578
|
receiptsByStep.set(stepId, receipt);
|
|
12775
12579
|
} catch {
|
|
@@ -12790,6 +12594,9 @@ async function executeFleetRun(input) {
|
|
|
12790
12594
|
succeeded: true,
|
|
12791
12595
|
terminalRunId: replayedResult.terminalRunId,
|
|
12792
12596
|
costUsd: receiptsByStep.get(stepId)?.costUsd ?? 0,
|
|
12597
|
+
// A replay whose receipt no longer exists on disk has no cost claim at
|
|
12598
|
+
// all, which is `unknown` rather than a zero the projection invented.
|
|
12599
|
+
costProvenance: receiptsByStep.get(stepId)?.costProvenance ?? "unknown",
|
|
12793
12600
|
result: replayedResult
|
|
12794
12601
|
});
|
|
12795
12602
|
await fileStepAttempt(replayedResult.terminalRunId);
|
|
@@ -12859,11 +12666,13 @@ async function executeFleetRun(input) {
|
|
|
12859
12666
|
if (step.planParentId !== void 0 && parentReceipt === void 0) {
|
|
12860
12667
|
throw new Error(`fleet dynamic step '${step.id}' has no terminal plan-step receipt`);
|
|
12861
12668
|
}
|
|
12669
|
+
const stepIntent = fleetStepIntent(step.writes);
|
|
12862
12670
|
const request = {
|
|
12863
12671
|
agentId: step.agentId,
|
|
12864
12672
|
executionRole: step.executionRole,
|
|
12865
12673
|
task: step.task,
|
|
12866
12674
|
cwd: workspaceRoot,
|
|
12675
|
+
...stepIntent === null ? {} : { intent: stepIntent },
|
|
12867
12676
|
predecessorHandoffs: handoffs,
|
|
12868
12677
|
requestOrigin: "user",
|
|
12869
12678
|
lineage: {
|
|
@@ -12951,11 +12760,11 @@ async function executeFleetRun(input) {
|
|
|
12951
12760
|
if (step.gate !== void 0 && succeeded) {
|
|
12952
12761
|
let gateBytes = "";
|
|
12953
12762
|
try {
|
|
12954
|
-
gateBytes =
|
|
12763
|
+
gateBytes = readFileSync12(join14(workspaceRoot, step.gate.path), "utf8");
|
|
12955
12764
|
} catch {
|
|
12956
12765
|
gateBytes = "";
|
|
12957
12766
|
}
|
|
12958
|
-
gatePathHash =
|
|
12767
|
+
gatePathHash = createHash9("sha256").update(gateBytes).digest("hex");
|
|
12959
12768
|
const command = input.commands?.commands.get(step.gate.commandId);
|
|
12960
12769
|
if (gateBytes.length === 0 || command === void 0) {
|
|
12961
12770
|
stepSucceeded = false;
|
|
@@ -13007,11 +12816,12 @@ async function executeFleetRun(input) {
|
|
|
13007
12816
|
succeeded: stepSucceeded,
|
|
13008
12817
|
terminalRunId: receipt.runId,
|
|
13009
12818
|
costUsd: receipt.costUsd,
|
|
12819
|
+
costProvenance: receipt.costProvenance,
|
|
13010
12820
|
receipt,
|
|
13011
12821
|
...failureReason !== void 0 ? { failureReason } : {}
|
|
13012
12822
|
});
|
|
13013
12823
|
notice(
|
|
13014
|
-
`step ${step.id} ${step.agentId}: ${stepSucceeded ? "succeeded" : "failed"}${failureReason !== void 0 ? ` reason=${failureReason}` : ""} assignment=${handle.runId} terminal-run=${receipt.runId} cost
|
|
12824
|
+
`step ${step.id} ${step.agentId}: ${stepSucceeded ? "succeeded" : "failed"}${failureReason !== void 0 ? ` reason=${failureReason}` : ""} assignment=${handle.runId} terminal-run=${receipt.runId} cost=${renderCostAmount(receipt.costUsd, receipt.costProvenance)}`
|
|
13015
12825
|
);
|
|
13016
12826
|
return {
|
|
13017
12827
|
stepId: step.id,
|
|
@@ -13070,6 +12880,8 @@ async function executeFleetRun(input) {
|
|
|
13070
12880
|
succeeded: outcome.report.passed,
|
|
13071
12881
|
terminalRunId: outcome.record.runId,
|
|
13072
12882
|
costUsd: 0,
|
|
12883
|
+
// No model ran, so nothing needed pricing. This zero was observed.
|
|
12884
|
+
costProvenance: "known_free",
|
|
13073
12885
|
codeStep: outcome.record,
|
|
13074
12886
|
recordPath
|
|
13075
12887
|
});
|
|
@@ -13192,7 +13004,9 @@ async function executeFleetRun(input) {
|
|
|
13192
13004
|
planHash: input.plan.hash,
|
|
13193
13005
|
result,
|
|
13194
13006
|
receipts,
|
|
13195
|
-
|
|
13007
|
+
totalCost: aggregateCostAmounts(
|
|
13008
|
+
receipts.map((receipt) => ({ usd: receipt.costUsd, provenance: receipt.costProvenance }))
|
|
13009
|
+
),
|
|
13196
13010
|
requiredStepCount: required.length,
|
|
13197
13011
|
succeededStepCount,
|
|
13198
13012
|
resolvedLoopCount: result.loops.length - failedLoops.length,
|
|
@@ -13420,6 +13234,37 @@ init_esm_shims();
|
|
|
13420
13234
|
// src/domains/evidence/types.ts
|
|
13421
13235
|
init_esm_shims();
|
|
13422
13236
|
var EVIDENCE_VERSION = 1;
|
|
13237
|
+
var EVIDENCE_TAGS = [
|
|
13238
|
+
"audit-linked",
|
|
13239
|
+
"audit-missing",
|
|
13240
|
+
"best-effort-link",
|
|
13241
|
+
"timeout",
|
|
13242
|
+
"context-overflow",
|
|
13243
|
+
"provider-transient",
|
|
13244
|
+
"missing-dependency",
|
|
13245
|
+
"wrong-runtime",
|
|
13246
|
+
"proxy-validation",
|
|
13247
|
+
"no-validation",
|
|
13248
|
+
"destructive-cleanup",
|
|
13249
|
+
"blocked-tool",
|
|
13250
|
+
"escalation",
|
|
13251
|
+
"external-bypass",
|
|
13252
|
+
"external-approximation",
|
|
13253
|
+
"independent-review",
|
|
13254
|
+
"context-provenance",
|
|
13255
|
+
"completion-evidence",
|
|
13256
|
+
"receipt-integrity",
|
|
13257
|
+
"receipt-retired",
|
|
13258
|
+
"protected-artifact",
|
|
13259
|
+
"tool-loop",
|
|
13260
|
+
"test-failure",
|
|
13261
|
+
"build-failure",
|
|
13262
|
+
"cwd-missing",
|
|
13263
|
+
"session-linked",
|
|
13264
|
+
"session-missing",
|
|
13265
|
+
"auth-failure",
|
|
13266
|
+
"unknown"
|
|
13267
|
+
];
|
|
13423
13268
|
var FAILURE_CAUSE_TAG_ORDER = [
|
|
13424
13269
|
"timeout",
|
|
13425
13270
|
"auth-failure",
|
|
@@ -13484,7 +13329,7 @@ function latestGateDecisionForRun(decisions, runId) {
|
|
|
13484
13329
|
// src/domains/evidence/store.ts
|
|
13485
13330
|
init_esm_shims();
|
|
13486
13331
|
import { readdir, readFile } from "node:fs/promises";
|
|
13487
|
-
import { join as
|
|
13332
|
+
import { join as join15 } from "node:path";
|
|
13488
13333
|
var EVIDENCE_FILES = [
|
|
13489
13334
|
"overview.json",
|
|
13490
13335
|
"transcript.md",
|
|
@@ -13500,11 +13345,11 @@ var EVIDENCE_FILES = [
|
|
|
13500
13345
|
"findings.md"
|
|
13501
13346
|
];
|
|
13502
13347
|
function evidenceRoot(dataDir) {
|
|
13503
|
-
return
|
|
13348
|
+
return join15(dataDir, "evidence");
|
|
13504
13349
|
}
|
|
13505
13350
|
function evidenceDirectory(dataDir, evidenceId) {
|
|
13506
13351
|
assertSafeId(evidenceId, "evidence");
|
|
13507
|
-
return
|
|
13352
|
+
return join15(evidenceRoot(dataDir), evidenceId);
|
|
13508
13353
|
}
|
|
13509
13354
|
var EvidenceNotFoundError = class extends Error {
|
|
13510
13355
|
constructor(evidenceId) {
|
|
@@ -13520,7 +13365,7 @@ function isMissingFile(error) {
|
|
|
13520
13365
|
async function loadEvidenceOverview(dataDir, evidenceId) {
|
|
13521
13366
|
let raw;
|
|
13522
13367
|
try {
|
|
13523
|
-
raw = await readFile(
|
|
13368
|
+
raw = await readFile(join15(evidenceDirectory(dataDir, evidenceId), "overview.json"), "utf8");
|
|
13524
13369
|
} catch (error) {
|
|
13525
13370
|
if (isMissingFile(error)) throw new EvidenceNotFoundError(evidenceId);
|
|
13526
13371
|
throw error;
|
|
@@ -13532,7 +13377,7 @@ async function inspectEvidence(dataDir, evidenceId) {
|
|
|
13532
13377
|
const overview = await loadEvidenceOverview(dataDir, evidenceId);
|
|
13533
13378
|
let findingsRaw;
|
|
13534
13379
|
try {
|
|
13535
|
-
findingsRaw = await readFile(
|
|
13380
|
+
findingsRaw = await readFile(join15(evidenceDirectory(dataDir, evidenceId), "findings.json"), "utf8");
|
|
13536
13381
|
} catch (error) {
|
|
13537
13382
|
if (isMissingFile(error)) throw new Error(`evidence artifact ${evidenceId} is missing findings.json`);
|
|
13538
13383
|
throw error;
|
|
@@ -13544,7 +13389,7 @@ async function inspectEvidence(dataDir, evidenceId) {
|
|
|
13544
13389
|
async function loadEvidenceTrustStatus(dataDir, evidenceId) {
|
|
13545
13390
|
let raw;
|
|
13546
13391
|
try {
|
|
13547
|
-
raw = await readFile(
|
|
13392
|
+
raw = await readFile(join15(evidenceDirectory(dataDir, evidenceId), "trust-status.json"), "utf8");
|
|
13548
13393
|
} catch (error) {
|
|
13549
13394
|
if (isMissingFile(error)) {
|
|
13550
13395
|
return { version: 1, evidenceId, projection: "historical_format", runs: [] };
|
|
@@ -13577,7 +13422,7 @@ async function loadEvidenceTrustStatus(dataDir, evidenceId) {
|
|
|
13577
13422
|
async function loadEvidenceRunProvenance(dataDir, evidenceId) {
|
|
13578
13423
|
let raw;
|
|
13579
13424
|
try {
|
|
13580
|
-
raw = await readFile(
|
|
13425
|
+
raw = await readFile(join15(evidenceDirectory(dataDir, evidenceId), "receipt.json"), "utf8");
|
|
13581
13426
|
} catch (error) {
|
|
13582
13427
|
const err = error;
|
|
13583
13428
|
if (err.code === "ENOENT") return [];
|
|
@@ -13631,6 +13476,7 @@ function parseOverview(value, source) {
|
|
|
13631
13476
|
const totals = readTotals(value.totals, `${source}.totals`);
|
|
13632
13477
|
const tags = readStringArray(value, source, "tags");
|
|
13633
13478
|
const files = readStringArray(value, source, "files");
|
|
13479
|
+
const redactionCount = typeof value.redactionCount === "number" && Number.isFinite(value.redactionCount) ? value.redactionCount : void 0;
|
|
13634
13480
|
return {
|
|
13635
13481
|
version: 1,
|
|
13636
13482
|
evidenceId,
|
|
@@ -13649,7 +13495,8 @@ function parseOverview(value, source) {
|
|
|
13649
13495
|
modelIds,
|
|
13650
13496
|
totals,
|
|
13651
13497
|
tags,
|
|
13652
|
-
files
|
|
13498
|
+
files,
|
|
13499
|
+
...redactionCount === void 0 ? {} : { redactionCount }
|
|
13653
13500
|
};
|
|
13654
13501
|
}
|
|
13655
13502
|
function parseFindingsFile(value, source) {
|
|
@@ -13749,6 +13596,7 @@ var MAX_TASK_CHARS = 500;
|
|
|
13749
13596
|
var TRANSCRIPT_TEXT_MAX_CHARS = 500;
|
|
13750
13597
|
var TOOL_PREVIEW_MAX_CHARS = 240;
|
|
13751
13598
|
var TASK_LEDGER_ROW_LIMIT = 200;
|
|
13599
|
+
var MODEL_PRIVATE_MARKER = "[not sent to model]";
|
|
13752
13600
|
async function buildEvidence(options) {
|
|
13753
13601
|
if (options.runId !== void 0 && options.sessionId !== void 0) {
|
|
13754
13602
|
throw new Error("build evidence accepts either runId or sessionId, not both");
|
|
@@ -14149,22 +13997,22 @@ function finding(index, severity, tag, runId, message) {
|
|
|
14149
13997
|
}
|
|
14150
13998
|
async function writeEvidenceFiles(directory, overview, runSources, findings, sessionLinks, auditLinks, toolEventRows, gateDecisions, trustStatus, protectedArtifacts, transcript) {
|
|
14151
13999
|
await mkdir(directory, { recursive: true });
|
|
14152
|
-
await writeJson(
|
|
14000
|
+
await writeJson(join16(directory, "overview.json"), overview);
|
|
14153
14001
|
await writeFile(
|
|
14154
|
-
|
|
14002
|
+
join16(directory, "transcript.md"),
|
|
14155
14003
|
transcript ?? renderTranscript(overview, runSources, sessionLinks, trustStatus),
|
|
14156
14004
|
"utf8"
|
|
14157
14005
|
);
|
|
14158
|
-
await writeJsonl(
|
|
14159
|
-
await writeJsonl(
|
|
14160
|
-
await writeJsonl(
|
|
14161
|
-
await writeJsonl(
|
|
14162
|
-
await writeJson(
|
|
14163
|
-
await writeJson(
|
|
14164
|
-
await writeJson(
|
|
14165
|
-
await writeJson(
|
|
14166
|
-
await writeJson(
|
|
14167
|
-
await writeFile(
|
|
14006
|
+
await writeJsonl(join16(directory, "trace.raw.jsonl"), rawTraceRows(runSources));
|
|
14007
|
+
await writeJsonl(join16(directory, "trace.cleaned.jsonl"), cleanedTraceRows(runSources, findings, toolEventRows));
|
|
14008
|
+
await writeJsonl(join16(directory, "tool-events.jsonl"), toolEventRows);
|
|
14009
|
+
await writeJsonl(join16(directory, "audit-linked.jsonl"), auditLinks.rows);
|
|
14010
|
+
await writeJson(join16(directory, "receipt.json"), receiptsFile(runSources));
|
|
14011
|
+
await writeJson(join16(directory, "gate-decisions.json"), gateDecisions);
|
|
14012
|
+
await writeJson(join16(directory, "trust-status.json"), trustStatus);
|
|
14013
|
+
await writeJson(join16(directory, "protected-artifacts.json"), protectedArtifacts);
|
|
14014
|
+
await writeJson(join16(directory, "findings.json"), findingsFile(overview.evidenceId, [...findings]));
|
|
14015
|
+
await writeFile(join16(directory, "findings.md"), renderEvidenceFindingsMarkdown(findings, trustStatus), "utf8");
|
|
14168
14016
|
}
|
|
14169
14017
|
function rawTraceRows(runSources) {
|
|
14170
14018
|
const rows = [];
|
|
@@ -14347,6 +14195,7 @@ function sessionToolEvents(entries) {
|
|
|
14347
14195
|
for (const linked of entries) {
|
|
14348
14196
|
const entry = linked.entry;
|
|
14349
14197
|
if (entry.kind === "bashExecution") {
|
|
14198
|
+
const contextMarker = entry.excludeFromContext === true ? `${MODEL_PRIVATE_MARKER} ` : "";
|
|
14350
14199
|
events.push({
|
|
14351
14200
|
source: "session-entry",
|
|
14352
14201
|
runId: linked.link.runId,
|
|
@@ -14361,8 +14210,8 @@ function sessionToolEvents(entries) {
|
|
|
14361
14210
|
timestamp: entry.timestamp,
|
|
14362
14211
|
linkKind: "session-bash-execution",
|
|
14363
14212
|
confidence: "exact",
|
|
14364
|
-
argsPreview: truncateText(entry.command
|
|
14365
|
-
resultPreview: truncateText(entry.output
|
|
14213
|
+
argsPreview: truncateText(`${contextMarker}${entry.command}`, TOOL_PREVIEW_MAX_CHARS),
|
|
14214
|
+
resultPreview: truncateText(`${contextMarker}${entry.output}`, TOOL_PREVIEW_MAX_CHARS)
|
|
14366
14215
|
});
|
|
14367
14216
|
continue;
|
|
14368
14217
|
}
|
|
@@ -14716,9 +14565,10 @@ function renderSessionTranscriptEntry(linked) {
|
|
|
14716
14565
|
}
|
|
14717
14566
|
if (entry.kind === "bashExecution") {
|
|
14718
14567
|
const status = entry.cancelled ? "cancelled" : entry.exitCode === null ? "exit=?" : `exit=${entry.exitCode}`;
|
|
14568
|
+
const contextMarker = entry.excludeFromContext === true ? ` ${MODEL_PRIVATE_MARKER}` : "";
|
|
14719
14569
|
return [
|
|
14720
|
-
`${prefix} bash ${status}: $ ${truncateText(entry.command, TRANSCRIPT_TEXT_MAX_CHARS)}`,
|
|
14721
|
-
` output: ${previewUnknown(entry.output)}`
|
|
14570
|
+
`${prefix} bash ${status}${contextMarker}: $ ${truncateText(entry.command, TRANSCRIPT_TEXT_MAX_CHARS)}`,
|
|
14571
|
+
` output${contextMarker}: ${previewUnknown(entry.output)}`
|
|
14722
14572
|
];
|
|
14723
14573
|
}
|
|
14724
14574
|
if (entry.kind === "branchSummary")
|
|
@@ -14842,7 +14692,7 @@ function axisFindings(offset, source, status) {
|
|
|
14842
14692
|
return out;
|
|
14843
14693
|
}
|
|
14844
14694
|
async function readRunLedger(stateDir) {
|
|
14845
|
-
const target =
|
|
14695
|
+
const target = join16(stateDir, "runs.json");
|
|
14846
14696
|
let raw;
|
|
14847
14697
|
try {
|
|
14848
14698
|
raw = await readFile2(target, "utf8");
|
|
@@ -14863,7 +14713,7 @@ function selectRunEnvelopes(ledger, source) {
|
|
|
14863
14713
|
});
|
|
14864
14714
|
}
|
|
14865
14715
|
async function readReceipt(stateDir, envelope) {
|
|
14866
|
-
const receiptPath = envelope.receiptPath ??
|
|
14716
|
+
const receiptPath = envelope.receiptPath ?? join16(stateDir, "receipts", `${envelope.id}.json`);
|
|
14867
14717
|
let raw;
|
|
14868
14718
|
try {
|
|
14869
14719
|
raw = await readFile2(receiptPath, "utf8");
|
|
@@ -14948,7 +14798,7 @@ function parseRunReceipt(value, source) {
|
|
|
14948
14798
|
costUsd: readNumber2(value, source, "costUsd"),
|
|
14949
14799
|
compiledPromptHash: readNullableString2(value, source, "compiledPromptHash"),
|
|
14950
14800
|
staticCompositionHash: readNullableString2(value, source, "staticCompositionHash"),
|
|
14951
|
-
|
|
14801
|
+
clioCoderVersion: readReceiptVersion(value, source),
|
|
14952
14802
|
piMonoVersion: readString2(value, source, "piMonoVersion"),
|
|
14953
14803
|
platform: readString2(value, source, "platform"),
|
|
14954
14804
|
nodeVersion: readString2(value, source, "nodeVersion"),
|
|
@@ -14962,6 +14812,10 @@ function parseRunReceipt(value, source) {
|
|
|
14962
14812
|
}
|
|
14963
14813
|
};
|
|
14964
14814
|
}
|
|
14815
|
+
function readReceiptVersion(value, source) {
|
|
14816
|
+
if (typeof value.clioCoderVersion === "string") return value.clioCoderVersion;
|
|
14817
|
+
return readString2(value, source, "clioVersion");
|
|
14818
|
+
}
|
|
14965
14819
|
function readToolStats(record, source, field) {
|
|
14966
14820
|
const value = record[field];
|
|
14967
14821
|
if (!Array.isArray(value)) throw new Error(`${source}.${field}: expected array`);
|
|
@@ -15152,7 +15006,7 @@ function sanitizeEvidenceId(value) {
|
|
|
15152
15006
|
// src/domains/evidence/eval.ts
|
|
15153
15007
|
init_esm_shims();
|
|
15154
15008
|
import { mkdir as mkdir2, readdir as readdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
15155
|
-
import { join as
|
|
15009
|
+
import { join as join17 } from "node:path";
|
|
15156
15010
|
|
|
15157
15011
|
// src/domains/eval/index.ts
|
|
15158
15012
|
init_esm_shims();
|
|
@@ -15353,19 +15207,19 @@ async function writeEvalEvidenceFiles(directory, artifact, overview, findings, t
|
|
|
15353
15207
|
};
|
|
15354
15208
|
const redactedArtifact = redactArtifactForStorage(artifact);
|
|
15355
15209
|
await mkdir2(directory, { recursive: true });
|
|
15356
|
-
await writeJson2(
|
|
15357
|
-
await writeFile2(
|
|
15358
|
-
await writeJsonl2(
|
|
15359
|
-
await writeJsonl2(
|
|
15360
|
-
await writeJsonl2(
|
|
15361
|
-
await writeJsonl2(
|
|
15362
|
-
await writeJson2(
|
|
15363
|
-
await writeJson2(
|
|
15364
|
-
await writeJson2(
|
|
15365
|
-
await writeJson2(
|
|
15366
|
-
await writeJson2(
|
|
15367
|
-
await writeJson2(
|
|
15368
|
-
await writeFile2(
|
|
15210
|
+
await writeJson2(join17(directory, "overview.json"), overview);
|
|
15211
|
+
await writeFile2(join17(directory, "transcript.md"), renderEvalTranscript(redactedArtifact, overview), "utf8");
|
|
15212
|
+
await writeJsonl2(join17(directory, "trace.raw.jsonl"), rawEvalTraceRows(redactedArtifact));
|
|
15213
|
+
await writeJsonl2(join17(directory, "trace.cleaned.jsonl"), cleanedEvalTraceRows(redactedArtifact, findings));
|
|
15214
|
+
await writeJsonl2(join17(directory, "tool-events.jsonl"), redactArtifactForStorage(toolEventRows));
|
|
15215
|
+
await writeJsonl2(join17(directory, "audit-linked.jsonl"), linkedRuns.auditRows);
|
|
15216
|
+
await writeJson2(join17(directory, "receipt.json"), receiptsFile2);
|
|
15217
|
+
await writeJson2(join17(directory, "gate-decisions.json"), gateDecisions);
|
|
15218
|
+
await writeJson2(join17(directory, "trust-status.json"), trustStatus);
|
|
15219
|
+
await writeJson2(join17(directory, "protected-artifacts.json"), emptyProtected);
|
|
15220
|
+
await writeJson2(join17(directory, "eval-result.json"), redactedArtifact);
|
|
15221
|
+
await writeJson2(join17(directory, "findings.json"), findingsFile(overview.evidenceId, [...findings]));
|
|
15222
|
+
await writeFile2(join17(directory, "findings.md"), renderEvidenceFindingsMarkdown(findings, trustStatus), "utf8");
|
|
15369
15223
|
}
|
|
15370
15224
|
function rawEvalTraceRows(artifact) {
|
|
15371
15225
|
return artifact.results.map((result) => ({
|
|
@@ -15506,7 +15360,7 @@ async function linkEvalRuns(stateDir, artifact) {
|
|
|
15506
15360
|
}
|
|
15507
15361
|
async function readRunLedger2(stateDir) {
|
|
15508
15362
|
try {
|
|
15509
|
-
const raw = await readFile3(
|
|
15363
|
+
const raw = await readFile3(join17(stateDir, "runs.json"), "utf8");
|
|
15510
15364
|
const parsed = JSON.parse(raw);
|
|
15511
15365
|
return Array.isArray(parsed) ? parsed.filter(isRecord12) : [];
|
|
15512
15366
|
} catch {
|
|
@@ -15517,7 +15371,7 @@ function evalRunMatches(artifact, envelope) {
|
|
|
15517
15371
|
return artifact.results.some((result) => result.runId === envelope.id);
|
|
15518
15372
|
}
|
|
15519
15373
|
async function readReceiptForRun(stateDir, envelope) {
|
|
15520
|
-
const path2 = envelope.receiptPath ??
|
|
15374
|
+
const path2 = envelope.receiptPath ?? join17(stateDir, "receipts", `${envelope.id}.json`);
|
|
15521
15375
|
try {
|
|
15522
15376
|
const parsed = JSON.parse(await readFile3(path2, "utf8"));
|
|
15523
15377
|
return isRecord12(parsed) ? parsed : null;
|
|
@@ -15546,7 +15400,7 @@ async function countSessionEntries(stateDir, sessionIds) {
|
|
|
15546
15400
|
return count;
|
|
15547
15401
|
}
|
|
15548
15402
|
async function findSessionLedgerPath(stateDir, sessionId) {
|
|
15549
|
-
const root =
|
|
15403
|
+
const root = join17(stateDir, "sessions");
|
|
15550
15404
|
let cwdHashes;
|
|
15551
15405
|
try {
|
|
15552
15406
|
cwdHashes = await readdir2(root);
|
|
@@ -15554,7 +15408,7 @@ async function findSessionLedgerPath(stateDir, sessionId) {
|
|
|
15554
15408
|
return null;
|
|
15555
15409
|
}
|
|
15556
15410
|
for (const cwdHash of cwdHashes) {
|
|
15557
|
-
const path2 =
|
|
15411
|
+
const path2 = join17(root, cwdHash, sessionId, "current.jsonl");
|
|
15558
15412
|
try {
|
|
15559
15413
|
await readFile3(path2, "utf8");
|
|
15560
15414
|
return path2;
|
|
@@ -15564,7 +15418,7 @@ async function findSessionLedgerPath(stateDir, sessionId) {
|
|
|
15564
15418
|
return null;
|
|
15565
15419
|
}
|
|
15566
15420
|
async function linkedEvalAuditRows(stateDir, runIds, artifact) {
|
|
15567
|
-
const root =
|
|
15421
|
+
const root = join17(stateDir, "audit");
|
|
15568
15422
|
let files;
|
|
15569
15423
|
try {
|
|
15570
15424
|
files = await readdir2(root);
|
|
@@ -15573,7 +15427,7 @@ async function linkedEvalAuditRows(stateDir, runIds, artifact) {
|
|
|
15573
15427
|
}
|
|
15574
15428
|
const rows = [];
|
|
15575
15429
|
for (const file of files.filter((name) => name.endsWith(".jsonl")).sort(compareCodepoints)) {
|
|
15576
|
-
const raw = await readFile3(
|
|
15430
|
+
const raw = await readFile3(join17(root, file), "utf8").catch(() => "");
|
|
15577
15431
|
const lines = raw.split("\n");
|
|
15578
15432
|
for (let index = 0; index < lines.length; index += 1) {
|
|
15579
15433
|
const line = lines[index];
|
|
@@ -15684,12 +15538,12 @@ function canonicalJson3(value) {
|
|
|
15684
15538
|
throw new Error(`response schema digest cannot represent ${typeof value}`);
|
|
15685
15539
|
}
|
|
15686
15540
|
function canonicalResponseSchemaDigest(schema) {
|
|
15687
|
-
return
|
|
15541
|
+
return createHash10("sha256").update(canonicalJson3(schema), "utf8").digest("hex");
|
|
15688
15542
|
}
|
|
15689
15543
|
function typedValidationFactsFromToolStats(toolStats) {
|
|
15690
15544
|
return toolStats.filter((stat) => stat.tool === "verify" && stat.count > 0).map((stat) => ({
|
|
15691
15545
|
sourceId: "tool:verify",
|
|
15692
|
-
validatorDigest:
|
|
15546
|
+
validatorDigest: createHash10("sha256").update(canonicalJson3(stat), "utf8").digest("hex"),
|
|
15693
15547
|
passed: stat.ok === stat.count && stat.errors === 0 && stat.blocked === 0
|
|
15694
15548
|
}));
|
|
15695
15549
|
}
|
|
@@ -15812,14 +15666,13 @@ export {
|
|
|
15812
15666
|
createStdioServerTransport,
|
|
15813
15667
|
ACP_USAGE_META_KEY,
|
|
15814
15668
|
ACP_SESSION_META_KEY,
|
|
15669
|
+
ACP_AGENT_META_KEY,
|
|
15815
15670
|
ACP_MAX_STRING_BYTES,
|
|
15816
15671
|
ACP_MAX_RAW_RECORD_BYTES,
|
|
15817
15672
|
ACP_MAX_CHUNK_BYTES,
|
|
15818
15673
|
ACP_MAX_TOOL_CALL_ID_BYTES,
|
|
15819
15674
|
compile,
|
|
15820
15675
|
compileWorker,
|
|
15821
|
-
WORKER_OUTPUT_MAX_BYTES,
|
|
15822
|
-
durableAssistantTextFromEvent,
|
|
15823
15676
|
setCapacityDraining,
|
|
15824
15677
|
capacityDrain,
|
|
15825
15678
|
capacityLeaseUsage,
|
|
@@ -15829,20 +15682,20 @@ export {
|
|
|
15829
15682
|
renderDispatchReviewerTask,
|
|
15830
15683
|
createRunReceiptQuality,
|
|
15831
15684
|
UNVERIFIABLE_RECEIPT_VERIFICATION,
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
stagePendingGateDecision,
|
|
15836
|
-
resolvePendingGateDecision,
|
|
15837
|
-
materializePendingGateDecision,
|
|
15838
|
-
finalizePendingGateDecision,
|
|
15839
|
-
readPendingGateDecisions,
|
|
15840
|
-
preflightPendingGateDecisionMaterialization,
|
|
15841
|
-
preparePendingGateDecisionRecovery,
|
|
15842
|
-
readGateDecisionArtifacts,
|
|
15685
|
+
assistantTextFromEvent,
|
|
15686
|
+
receiptResponseModelIdObservationLabel,
|
|
15687
|
+
createDispatchRunEventRegistry,
|
|
15843
15688
|
readFleetRun,
|
|
15689
|
+
listFleetRuns,
|
|
15844
15690
|
openLedger,
|
|
15845
15691
|
executePlan,
|
|
15692
|
+
aggregateCostAmounts,
|
|
15693
|
+
formatCostAggregate,
|
|
15694
|
+
COST_NOT_MEASURED,
|
|
15695
|
+
costAggregateForAmount,
|
|
15696
|
+
renderCostAggregate,
|
|
15697
|
+
renderCostAmount,
|
|
15698
|
+
createCostTracker,
|
|
15846
15699
|
planFleetResume,
|
|
15847
15700
|
executeFleetRun,
|
|
15848
15701
|
DispatchDomainModule,
|
|
@@ -15850,14 +15703,16 @@ export {
|
|
|
15850
15703
|
extractRunProvenance,
|
|
15851
15704
|
provenanceTranscriptLines,
|
|
15852
15705
|
provenanceCompactSuffix,
|
|
15706
|
+
EVIDENCE_TAGS,
|
|
15853
15707
|
FAILURE_CAUSE_TAGS,
|
|
15854
15708
|
evidenceDirectory,
|
|
15855
15709
|
EvidenceNotFoundError,
|
|
15856
15710
|
inspectEvidence,
|
|
15711
|
+
loadEvidenceTrustStatus,
|
|
15857
15712
|
loadEvidenceRunProvenance,
|
|
15858
15713
|
listEvidenceOverviews,
|
|
15859
15714
|
buildEvidence,
|
|
15860
15715
|
summarizeEvalResults,
|
|
15861
15716
|
buildEvalEvidence
|
|
15862
15717
|
};
|
|
15863
|
-
//# sourceMappingURL=chunk-
|
|
15718
|
+
//# sourceMappingURL=chunk-XKA2ICR3.js.map
|