@iowarp/clio-coder 0.3.0 → 0.3.2
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 +123 -2
- package/CONTRIBUTING.md +23 -23
- package/README.md +295 -627
- package/dist/acp-BIYHVZIM.js +128 -0
- package/dist/{agents-Q4MYPMUW.js → agents-YT6SSRIT.js} +52 -27
- package/dist/assets/codewiki.json +1 -0
- package/dist/assets/grammars/notices/@vscode__tree-sitter-wasm/LICENSE +21 -0
- package/dist/assets/grammars/notices/@vscode__tree-sitter-wasm/cgmanifest.json +16 -0
- package/dist/assets/grammars/notices/tree-sitter-wasms/LICENSE +24 -0
- package/dist/assets/grammars/tree-sitter-c-sharp.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-c.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-cpp.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-go.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-java.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-javascript.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-python.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-ruby.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-rust.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-tsx.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-typescript.wasm +0 -0
- package/dist/assets/grammars/tree-sitter.wasm +0 -0
- package/dist/{auth-O6HYIJ6J.js → auth-5TWEIYDN.js} +30 -15
- package/dist/chunk-2EHAIA3X.js +481 -0
- package/dist/{chunk-ME6DNWIU.js → chunk-2IR2NMPA.js} +12 -4
- package/dist/chunk-2SFS6XQE.js +122 -0
- package/dist/{chunk-KKKPTZLM.js → chunk-2STGEDFV.js} +8 -1
- package/dist/chunk-2VTFPG5O.js +48 -0
- package/dist/chunk-3I7MS7N2.js +40 -0
- package/dist/chunk-3R73A4XB.js +69 -0
- package/dist/{chunk-JPOWPFCU.js → chunk-3ZXDFGR5.js} +52 -23
- package/dist/chunk-4BJ5BYCE.js +61 -0
- package/dist/{chunk-26BZQOAD.js → chunk-4BPJXDWC.js} +161 -260
- package/dist/chunk-4KLWL3UC.js +18 -0
- package/dist/{chunk-5LDRNKX2.js → chunk-4VP4KH3K.js} +161 -262
- package/dist/chunk-4ZG3XFUR.js +77 -0
- package/dist/chunk-5B2AEOW5.js +5407 -0
- package/dist/chunk-5TSRNF4G.js +510 -0
- package/dist/{chunk-WD6AJM35.js → chunk-5UUP6MWO.js} +48 -69
- package/dist/{chunk-X3BR7HWV.js → chunk-5WIGXA4T.js} +7 -1
- package/dist/chunk-65DEGPJ6.js +52 -0
- package/dist/chunk-6EJMN2Y3.js +17 -0
- package/dist/chunk-6EJV5X2W.js +16405 -0
- package/dist/chunk-6N5PTWMY.js +136 -0
- package/dist/chunk-6XLNIQDB.js +27 -0
- package/dist/{chunk-XNISANGE.js → chunk-77VKQEHF.js} +171 -74
- package/dist/chunk-7CR24IG7.js +242 -0
- package/dist/{chunk-UWIJNAOB.js → chunk-7EYHLWU7.js} +907 -638
- package/dist/chunk-7MNJORFF.js +22 -0
- package/dist/{chunk-JWHCJDCI.js → chunk-A3CYT5EX.js} +257 -79
- package/dist/chunk-AGYYIBLL.js +1069 -0
- package/dist/chunk-AO4RKG4M.js +277 -0
- package/dist/chunk-APJ265NV.js +7410 -0
- package/dist/chunk-ARBGF5F7.js +174 -0
- package/dist/{chunk-TFSSEXL6.js → chunk-BMEMKKIT.js} +14 -4
- package/dist/{chunk-X3NE4WVW.js → chunk-BNAZZHFG.js} +7 -1
- package/dist/chunk-CBCAPZAA.js +229 -0
- package/dist/{chunk-QV47YRF4.js → chunk-CGKSTWHD.js} +7 -1
- package/dist/chunk-CMZWFGD2.js +352 -0
- package/dist/chunk-ECH6PKUQ.js +39 -0
- package/dist/{chunk-67MTHP2E.js → chunk-ED4KHGC3.js} +13 -5
- package/dist/chunk-EKMEHE4H.js +340 -0
- package/dist/{chunk-O4EJEDHO.js → chunk-EPVUXGXG.js} +50 -35
- package/dist/chunk-FCSXB6T2.js +338 -0
- package/dist/chunk-FJ3H4MN5.js +48 -0
- package/dist/chunk-FQ4SKYE4.js +29 -0
- package/dist/chunk-G2DE3C7R.js +644 -0
- package/dist/chunk-G4BMMOKF.js +182 -0
- package/dist/{chunk-7BHLZB3A.js → chunk-GGXXDWE4.js} +190 -1218
- package/dist/chunk-HC4CLZ2Y.js +68 -0
- package/dist/{chunk-E3NYWENM.js → chunk-HFSBBKSQ.js} +55 -61
- package/dist/chunk-HKIYEGME.js +30 -0
- package/dist/chunk-I4HZDVNP.js +73 -0
- package/dist/chunk-IGLFWIYI.js +161 -0
- package/dist/chunk-IHXBNWMM.js +137 -0
- package/dist/chunk-IKCO5N3L.js +162 -0
- package/dist/chunk-IR4CFBFN.js +56 -0
- package/dist/{chunk-DXQNI4PC.js → chunk-IWHMRKLL.js} +8 -1
- package/dist/{chunk-VOO7NYPP.js → chunk-J5HN4RYU.js} +27 -9
- package/dist/{chunk-4UQA7NCT.js → chunk-J5Q24KAG.js} +7 -2
- package/dist/{chunk-KBR4MZZR.js → chunk-JVCV3ICN.js} +7 -1
- package/dist/chunk-KJ5LWLOE.js +1077 -0
- package/dist/chunk-LBMZMYH2.js +285 -0
- package/dist/{chunk-3DANZDGR.js → chunk-LBNRH5WM.js} +100 -161
- package/dist/{chunk-TKHQ4DGZ.js → chunk-LZSJBIVT.js} +7358 -7414
- package/dist/{chunk-UGYAX5YI.js → chunk-M6SHUN7Q.js} +13 -8
- package/dist/chunk-MAW544W2.js +1882 -0
- package/dist/chunk-MBS4V7ZP.js +217 -0
- package/dist/{chunk-2J63S4SF.js → chunk-MFFY33HR.js} +167 -140
- package/dist/chunk-MNA4JGU4.js +255 -0
- package/dist/chunk-MQSRRFWA.js +3428 -0
- package/dist/{chunk-RQDWMVRB.js → chunk-MVVUPGPW.js} +138 -137
- package/dist/chunk-OAO4GE4M.js +619 -0
- package/dist/chunk-OHHN2SO4.js +5135 -0
- package/dist/chunk-OKGUZO2U.js +34 -0
- package/dist/{chunk-BBUH4VAA.js → chunk-OOJYHWRB.js} +60 -361
- package/dist/{chunk-D5YD55AR.js → chunk-OQ33BKR3.js} +12 -1
- package/dist/chunk-OQE5J4C6.js +73 -0
- package/dist/{chunk-AMFR5YA3.js → chunk-ORBHGJC5.js} +26 -12
- package/dist/chunk-POHLU5DW.js +1186 -0
- package/dist/chunk-QKMUKYO7.js +4961 -0
- package/dist/{chunk-7RBKDI66.js → chunk-QTYWRVRA.js} +104 -12
- package/dist/{chunk-5N2FG33Q.js → chunk-R346GLFC.js} +7 -1
- package/dist/chunk-SRF2PJNW.js +184 -0
- package/dist/chunk-SST6Z5JA.js +80 -0
- package/dist/{chunk-XV4ZJ6ZM.js → chunk-STBPMHSX.js} +473 -1194
- package/dist/{chunk-HBU5MTAM.js → chunk-SVNXH4L2.js} +7 -1
- package/dist/chunk-T6YILFSB.js +80 -0
- package/dist/chunk-TXOTCRLG.js +15 -0
- package/dist/chunk-TZTZS7QK.js +227 -0
- package/dist/chunk-UOV2BYIW.js +107 -0
- package/dist/{chunk-527KG6XR.js → chunk-V4RXGQ5Q.js} +72 -185
- package/dist/chunk-VAKQQHWR.js +434 -0
- package/dist/chunk-VG7TBQIY.js +128 -0
- package/dist/chunk-VJWL6YS5.js +244 -0
- package/dist/chunk-WEH5XRJQ.js +32 -0
- package/dist/{chunk-VPAWTYLY.js → chunk-WEPFGWHJ.js} +7 -1
- package/dist/chunk-WMSVI4G2.js +2095 -0
- package/dist/chunk-WVO7V2QY.js +797 -0
- package/dist/chunk-X4RCMKVQ.js +641 -0
- package/dist/chunk-X75S7HFS.js +374 -0
- package/dist/chunk-XN3L4EYL.js +46 -0
- package/dist/{chunk-HMYNFFY4.js → chunk-XPLRXC72.js} +7 -2
- package/dist/{chunk-PIDUD6M2.js → chunk-YCWGATWI.js} +12 -5
- package/dist/chunk-YHZX5GEU.js +193 -0
- package/dist/chunk-YXLYO42X.js +91 -0
- package/dist/{chunk-UHTSULZS.js → chunk-ZDOOVTXZ.js} +38 -73
- package/dist/chunk-ZI647VB5.js +37 -0
- package/dist/{chunk-CLJ5HLUD.js → chunk-ZWLZP4ZT.js} +25 -6
- package/dist/cli/index.js +70 -56
- package/dist/clio-4LY5K2AC.js +25 -0
- package/dist/code-nav-7AX6FYE6.js +600 -0
- package/dist/codewiki/build-worker.js +66 -0
- package/dist/compile-cache-CVJMMODC.js +18 -0
- package/dist/{components-JVHMUBEB.js → components-KELWS457.js} +31 -9
- package/dist/{config-ZFCDBMDC.js → config-GTLUW2PR.js} +104 -56
- package/dist/configure-R6A64DHX.js +42 -0
- package/dist/context-5VKGUVJJ.js +866 -0
- package/dist/{context-CDXTP2MP.js → context-JFZEJ7W5.js} +21 -13
- package/dist/{context-E3KIFVXI.js → context-RW5HC47S.js} +77 -36
- package/dist/{context-clear-3F4PLXOS.js → context-clear-6ZHBAZZT.js} +64 -30
- package/dist/{context-index-Q7YSYTR3.js → context-index-BZ4UYMTC.js} +36 -24
- package/dist/dispatch-runner-VKBRCWQC.js +1997 -0
- package/dist/{docs-YIETIWZI.js → docs-2C2LTVT2.js} +32 -13
- package/dist/doctor-KI767GSN.js +87 -0
- package/dist/{eval-B3KZZESM.js → eval-XSSNATB4.js} +93 -27
- package/dist/{evidence-V67CHM35.js → evidence-UA6AWDQQ.js} +55 -27
- package/dist/{evolve-YDZSUQYA.js → evolve-QNTFGV6Z.js} +59 -26
- package/dist/{extensions-SRG7XCAH.js → extensions-QVDOHDGJ.js} +23 -8
- package/dist/{fleet-CA2CRTVG.js → fleet-Q7UOMUSG.js} +173 -56
- package/dist/fleet-preflight-DDN536IT.js +26 -0
- package/dist/{init-2OZDJE2D.js → init-WBB65ZHQ.js} +79 -34
- package/dist/{memory-3PIQQAKX.js → memory-MD3O64RI.js} +57 -28
- package/dist/{models-DY35XI7Y.js → models-BZU34YWD.js} +49 -24
- package/dist/monitor-MEQA5C3I.js +661 -0
- package/dist/{chunk-PS4PFJQP.js → orchestrator-CGFKEP27.js} +22837 -18564
- package/dist/{paths-5OMXW7Z4.js → paths-UXLN5YYZ.js} +17 -6
- package/dist/preload-P6DGH2PZ.js +13 -0
- package/dist/{reset-PIFYNOS3.js → reset-L2FQEE3E.js} +25 -13
- package/dist/{run-3VSPP24F.js → run-IV4Q6RLN.js} +115 -63
- package/dist/{share-D36RQCXM.js → share-S5BZQC5I.js} +23 -10
- package/dist/{skills-F2MRLELY.js → skills-LQEKRDTN.js} +42 -15
- package/dist/{skills-eval-E2ZTW4PL.js → skills-eval-3DC4HEWS.js} +90 -45
- package/dist/steer-GGWFUJUD.js +77 -0
- package/dist/{targets-DZMEZAH4.js → targets-C4SSGQOB.js} +78 -60
- package/dist/terminal-lease-IT5JW2NR.js +395 -0
- package/dist/{trace-7NYCUI2J.js → trace-PNCASAXC.js} +48 -17
- package/dist/tree-sitter-HGKH6LG4.js +4673 -0
- package/dist/{uninstall-AD3JWHBB.js → uninstall-FZCQCDKC.js} +19 -8
- package/dist/{upgrade-WYYBKGDY.js → upgrade-7TT7SQ3G.js} +66 -24
- package/dist/{usage-ULIDAGFF.js → usage-GV4PKT3M.js} +71 -32
- package/dist/verify-G6V4D2G7.js +716 -0
- package/dist/version-KGEG7EPO.js +21 -0
- package/dist/web-fetch-2YHJ3KTG.js +638 -0
- package/dist/{wiki-generate-PKFIX6OB.js → wiki-generate-DQF6Z66B.js} +98 -48
- package/dist/worker/entry.js +297 -54
- package/dist/workspace-G4ZWUIPR.js +22 -0
- package/docs/README.md +29 -21
- package/docs/acp.md +191 -16
- package/docs/alcf-provider.md +1 -1
- package/docs/architecture.md +157 -7
- package/docs/artifact-placement.md +101 -0
- package/docs/artifact-versions.md +1 -1
- package/docs/built-in-agents.md +4 -2
- package/docs/capacity-and-scheduling.md +1 -1
- package/docs/commands-and-modes.md +224 -97
- package/docs/config-knobs-audit.md +1 -3
- package/docs/configuration-and-targets.md +236 -38
- package/docs/context-engine.md +34 -7
- package/docs/development-pipeline.md +102 -0
- package/docs/dispatch-architecture-rationale.md +1 -1
- package/docs/documentation-coverage.md +4 -4
- package/docs/documentation-guide.md +3 -3
- package/docs/environment-variables.md +15 -6
- package/docs/eval-runner.md +3 -3
- package/docs/evals-internal.md +2 -2
- package/docs/evidence-and-memory.md +10 -2
- package/docs/evolution.md +2 -2
- package/docs/exit-codes-and-output.md +15 -9
- package/docs/extensions-and-sharing.md +25 -18
- package/docs/fleet-demo-runbook.md +22 -23
- package/docs/fleet-dispatch.md +117 -16
- package/docs/git-commit-provenance.md +120 -0
- package/docs/glossary.md +107 -15
- package/docs/installation-and-lifecycle.md +75 -17
- package/docs/middleware-and-components.md +1 -1
- package/docs/model-catalog.md +46 -15
- package/docs/observability.md +8 -5
- package/docs/performance-methodology.md +491 -0
- package/docs/pi-boundary.md +72 -0
- package/docs/proactive-memory.md +14 -14
- package/docs/prompt-envelope-and-tools.md +25 -4
- package/docs/provider-adapter-cookbook.md +57 -4
- package/docs/release-cut-checklist.md +129 -111
- package/docs/safety-model.md +28 -8
- package/docs/scientific-validation.md +3 -3
- package/docs/session-lifecycle.md +55 -12
- package/docs/skills-marketplace.md +12 -8
- package/docs/time-conventions.md +101 -0
- package/docs/tool-usage.md +6 -5
- package/docs/trace-store.md +1 -1
- package/docs/troubleshooting.md +10 -7
- package/docs/tui-design.md +121 -28
- package/docs/worker-dispatch-mechanics.md +3 -3
- package/package.json +33 -36
- package/skills/README.md +5 -6
- package/skills/coding/ast-grep/SKILL.md +136 -0
- package/skills/coding/ast-grep/evals.md +56 -0
- package/skills/coding/ast-grep/references/rule_reference.md +297 -0
- package/skills/coding/coding-standards/SKILL.md +113 -0
- package/skills/coding/coding-standards/evals.md +34 -0
- package/skills/coding/prototype/SKILL.md +86 -0
- package/skills/coding/prototype/evals.md +42 -0
- package/skills/coding/prototype/references/LOGIC.md +67 -0
- package/skills/coding/prototype/references/UI.md +112 -0
- package/skills/coding/tdd/SKILL.md +101 -0
- package/skills/coding/tdd/evals.md +41 -0
- package/skills/coding/tdd/references/mocking.md +59 -0
- package/skills/coding/tdd/references/tests.md +77 -0
- package/skills/context/context-handoff/SKILL.md +126 -0
- package/skills/context/context-handoff/evals.md +57 -0
- package/skills/context/context-handoff/scripts/new-handoff.sh +26 -0
- package/skills/context/context-prime/SKILL.md +95 -0
- package/skills/context/context-prime/evals.md +54 -0
- package/skills/git/file-ticket/SKILL.md +107 -0
- package/skills/git/file-ticket/evals.md +54 -0
- package/skills/git/fix-issue/SKILL.md +106 -0
- package/skills/git/fix-issue/evals.md +71 -0
- package/skills/git/ship/SKILL.md +92 -0
- package/skills/git/ship/evals.md +72 -0
- package/skills/meta/clio-dev/SKILL.md +91 -0
- package/skills/meta/clio-dev/evals.md +45 -0
- package/skills/meta/clio-test/SKILL.md +130 -0
- package/skills/meta/clio-test/evals.md +43 -0
- package/skills/meta/clio-test/references/harness.md +97 -0
- package/skills/meta/clio-test/references/test-map.md +59 -0
- package/skills/meta/credentials/SKILL.md +125 -0
- package/skills/meta/credentials/evals.md +104 -0
- package/skills/meta/find-skills/SKILL.md +72 -0
- package/skills/meta/find-skills/evals.md +47 -0
- package/skills/meta/herdr/SKILL.md +127 -0
- package/skills/meta/herdr/evals.md +38 -0
- package/skills/meta/skill-craft/SKILL.md +102 -0
- package/skills/meta/skill-craft/evals.md +41 -0
- package/skills/planning/architecture/SKILL.md +129 -0
- package/skills/planning/architecture/evals.md +36 -0
- package/skills/planning/backlog/SKILL.md +90 -0
- package/skills/planning/backlog/evals.md +43 -0
- package/skills/planning/prd/SKILL.md +82 -0
- package/skills/planning/prd/evals.md +49 -0
- package/skills/planning/product-intent/SKILL.md +112 -0
- package/skills/planning/product-intent/evals.md +36 -0
- package/skills/planning/tech-spec/SKILL.md +115 -0
- package/skills/planning/tech-spec/evals.md +47 -0
- package/skills/registry.yaml +136 -0
- package/skills/research/arxiv-literature/SKILL.md +104 -0
- package/skills/research/arxiv-literature/evals.md +58 -0
- package/skills/research/experiment-protocol/SKILL.md +122 -0
- package/skills/research/experiment-protocol/evals.md +91 -0
- package/skills/research/scientific-debugging/SKILL.md +119 -0
- package/skills/research/scientific-debugging/evals.md +138 -0
- package/skills/research/scientific-modernization/SKILL.md +138 -0
- package/skills/research/scientific-modernization/evals.md +84 -0
- package/skills/skill-marketplace.json +12 -20
- package/skills/workflow/design-council/SKILL.md +139 -0
- package/skills/workflow/design-council/evals.md +97 -0
- package/skills/workflow/grill-me/SKILL.md +186 -0
- package/skills/workflow/grill-me/evals.md +78 -0
- package/skills/workflow/workflow-distiller/SKILL.md +136 -0
- package/skills/workflow/workflow-distiller/evals.md +107 -0
- package/src/cli/acp.ts +115 -0
- package/src/cli/agents.ts +60 -0
- package/src/cli/args.ts +280 -0
- package/src/cli/argv.ts +170 -0
- package/src/cli/ask.ts +34 -0
- package/src/cli/auth.ts +468 -0
- package/src/cli/bootstrap-generate.ts +498 -0
- package/src/cli/clio.ts +96 -0
- package/src/cli/components.ts +195 -0
- package/src/cli/config-inspect.ts +336 -0
- package/src/cli/config.ts +72 -0
- package/src/cli/configure-interop.ts +67 -0
- package/src/cli/configure-layout.ts +172 -0
- package/src/cli/configure.ts +1525 -0
- package/src/cli/context-clear.ts +76 -0
- package/src/cli/context-index.ts +100 -0
- package/src/cli/context.ts +321 -0
- package/src/cli/default-target.ts +55 -0
- package/src/cli/docs.ts +346 -0
- package/src/cli/doctor.ts +54 -0
- package/src/cli/eval.ts +315 -0
- package/src/cli/evidence.ts +225 -0
- package/src/cli/evolve.ts +219 -0
- package/src/cli/extensions.ts +214 -0
- package/src/cli/fleet.ts +868 -0
- package/src/cli/index.ts +338 -0
- package/src/cli/init.ts +219 -0
- package/src/cli/initial-message.ts +47 -0
- package/src/cli/internal-dispatch.ts +55 -0
- package/src/cli/memory.ts +182 -0
- package/src/cli/models.ts +257 -0
- package/src/cli/modes/json-stream.ts +121 -0
- package/src/cli/modes/jsonl.ts +9 -0
- package/src/cli/modes/print.ts +604 -0
- package/src/cli/oauth-manual-input.ts +72 -0
- package/src/cli/oauth-select.ts +36 -0
- package/src/cli/output-guard.ts +48 -0
- package/src/cli/paths.ts +44 -0
- package/src/cli/provider-target.ts +113 -0
- package/src/cli/removal.ts +72 -0
- package/src/cli/reset.ts +253 -0
- package/src/cli/run.ts +497 -0
- package/src/cli/share.ts +243 -0
- package/src/cli/shared.ts +60 -0
- package/src/cli/skills-eval.ts +1240 -0
- package/src/cli/skills.ts +485 -0
- package/src/cli/steer-channel.ts +86 -0
- package/src/cli/targets.ts +1154 -0
- package/src/cli/text-layout.ts +112 -0
- package/src/cli/trace.ts +322 -0
- package/src/cli/uninstall.ts +405 -0
- package/src/cli/upgrade.ts +286 -0
- package/src/cli/usage.ts +876 -0
- package/src/cli/validate-model.ts +28 -0
- package/src/cli/version.ts +7 -0
- package/src/cli/wiki-generate.ts +510 -0
- package/src/core/agent-environment.ts +7 -0
- package/src/core/artifact-paths.ts +43 -0
- package/src/core/bash-exec.ts +313 -0
- package/src/core/boot-trace.ts +42 -0
- package/src/core/bus-events.ts +744 -0
- package/src/core/bus-trace.ts +53 -0
- package/src/core/c-header-language.ts +265 -0
- package/src/core/clio-repo.ts +78 -0
- package/src/core/commit-attribution.ts +157 -0
- package/src/core/compile-cache.ts +159 -0
- package/src/core/config.ts +1722 -0
- package/src/core/context-floor.ts +33 -0
- package/src/core/defaults.ts +659 -0
- package/src/core/domain-loader.ts +177 -0
- package/src/core/event-bus.ts +94 -0
- package/src/core/file-references.ts +282 -0
- package/src/core/git-commit-attribution.ts +362 -0
- package/src/core/guardrails.ts +185 -0
- package/src/core/headless-permission.ts +21 -0
- package/src/core/incomplete-installation.ts +45 -0
- package/src/core/init.ts +223 -0
- package/src/core/json-payload.ts +58 -0
- package/src/core/package-root.ts +54 -0
- package/src/core/path-canonical.ts +37 -0
- package/src/core/process-identity.ts +41 -0
- package/src/core/recent-models.ts +91 -0
- package/src/core/residency-protection.ts +56 -0
- package/src/core/resolve-config-value.ts +88 -0
- package/src/core/response-schema.ts +279 -0
- package/src/core/run-overrides.ts +77 -0
- package/src/core/safe-exec.ts +205 -0
- package/src/core/safe-id.ts +37 -0
- package/src/core/safe-resource-write.ts +162 -0
- package/src/core/session-routing.ts +339 -0
- package/src/core/settings-layers.ts +354 -0
- package/src/core/shared-bus.ts +8 -0
- package/src/core/shell-quote.ts +26 -0
- package/src/core/skill-activation.ts +190 -0
- package/src/core/startup-timer.ts +37 -0
- package/src/core/state-file-lock.ts +219 -0
- package/src/core/termination.ts +275 -0
- package/src/core/timers.ts +38 -0
- package/src/core/tool-names.ts +65 -0
- package/src/core/verification-scripts.ts +13 -0
- package/src/core/workspace-files.ts +492 -0
- package/src/core/xdg.ts +177 -0
- package/src/domains/agents/builtins/architect.md +4 -4
- package/src/domains/agents/builtins/coder.md +3 -2
- package/src/domains/agents/builtins/debugger.md +1 -1
- package/src/domains/agents/builtins/documenter.md +1 -1
- package/src/domains/agents/builtins/git-master.md +3 -3
- package/src/domains/agents/builtins/provenance.md +1 -1
- package/src/domains/agents/builtins/researcher.md +1 -1
- package/src/domains/agents/builtins/scout.md +1 -1
- package/src/domains/agents/builtins/tester.md +1 -1
- package/src/domains/agents/builtins/verifier.md +1 -1
- package/src/domains/agents/builtins/wiki-writer.md +1 -1
- package/src/domains/agents/catalog.ts +172 -0
- package/src/domains/agents/contract.ts +16 -0
- package/src/domains/agents/extension.ts +110 -0
- package/src/domains/agents/fleet-commands.ts +154 -0
- package/src/domains/agents/fleet-contract.ts +797 -0
- package/src/domains/agents/frontmatter.ts +40 -0
- package/src/domains/agents/index.ts +102 -0
- package/src/domains/agents/manifest.ts +6 -0
- package/src/domains/agents/recipe-schema.ts +202 -0
- package/src/domains/agents/recipe.ts +125 -0
- package/src/domains/agents/registry.ts +111 -0
- package/src/domains/agents/result-contract.ts +1265 -0
- package/src/domains/agents/spec.ts +371 -0
- package/src/domains/agents/write-boundary.ts +109 -0
- package/src/domains/components/diff.ts +99 -0
- package/src/domains/components/hash.ts +21 -0
- package/src/domains/components/index.ts +3 -0
- package/src/domains/components/scan.ts +304 -0
- package/src/domains/components/snapshot.ts +108 -0
- package/src/domains/components/types.ts +82 -0
- package/src/domains/config/agent-namespace.ts +13 -0
- package/src/domains/config/classify.ts +106 -0
- package/src/domains/config/contract.ts +22 -0
- package/src/domains/config/extension.ts +142 -0
- package/src/domains/config/index.ts +23 -0
- package/src/domains/config/keybindings.ts +200 -0
- package/src/domains/config/manifest.ts +6 -0
- package/src/domains/config/watcher.ts +41 -0
- package/src/domains/context/adoption.ts +880 -0
- package/src/domains/context/bootstrap-prompt.ts +273 -0
- package/src/domains/context/bootstrap.ts +1502 -0
- package/src/domains/context/clear.ts +91 -0
- package/src/domains/context/clio-md.ts +429 -0
- package/src/domains/context/codewiki/artifact.ts +400 -0
- package/src/domains/context/codewiki/build-worker-protocol.ts +24 -0
- package/src/domains/context/codewiki/build-worker.ts +54 -0
- package/src/domains/context/codewiki/cmake.ts +356 -0
- package/src/domains/context/codewiki/cooperative.ts +46 -0
- package/src/domains/context/codewiki/coordinator.ts +182 -0
- package/src/domains/context/codewiki/digest.ts +135 -0
- package/src/domains/context/codewiki/grammar-assets.ts +33 -0
- package/src/domains/context/codewiki/indexer.ts +1529 -0
- package/src/domains/context/codewiki/paths.ts +67 -0
- package/src/domains/context/codewiki/schema.ts +80 -0
- package/src/domains/context/codewiki/tree-sitter.ts +771 -0
- package/src/domains/context/contract.ts +68 -0
- package/src/domains/context/excluded-dirs.ts +1 -0
- package/src/domains/context/extension.ts +358 -0
- package/src/domains/context/fingerprint.ts +198 -0
- package/src/domains/context/index.ts +154 -0
- package/src/domains/context/init-options.ts +69 -0
- package/src/domains/context/manifest.ts +6 -0
- package/src/domains/context/operator-profile.ts +157 -0
- package/src/domains/context/project-metadata.ts +529 -0
- package/src/domains/context/project-rules.ts +227 -0
- package/src/domains/context/prompt-context.ts +61 -0
- package/src/domains/context/refresh.ts +178 -0
- package/src/domains/context/runtime.ts +17 -0
- package/src/domains/context/sibling-files.ts +10 -0
- package/src/domains/context/state.ts +237 -0
- package/src/domains/context/wiki/assemble.ts +303 -0
- package/src/domains/context/wiki/frontmatter.ts +210 -0
- package/src/domains/context/wiki/generate.ts +595 -0
- package/src/domains/context/wiki/layout.ts +111 -0
- package/src/domains/context/wiki/meta.ts +221 -0
- package/src/domains/context/wiki/plan-store.ts +217 -0
- package/src/domains/context/wiki/plan.ts +250 -0
- package/src/domains/context/wiki/prompts.ts +283 -0
- package/src/domains/context/wiki/staleness.ts +198 -0
- package/src/domains/dispatch/active-route-planner.ts +168 -0
- package/src/domains/dispatch/admission-queue.ts +150 -0
- package/src/domains/dispatch/admission.ts +334 -0
- package/src/domains/dispatch/agent-candidates.ts +307 -0
- package/src/domains/dispatch/agent-ledger-hub.ts +71 -0
- package/src/domains/dispatch/agent-ledger-store.ts +257 -0
- package/src/domains/dispatch/agent-ledger.ts +212 -0
- package/src/domains/dispatch/agent-plan-adapter.ts +85 -0
- package/src/domains/dispatch/assignment-events.ts +132 -0
- package/src/domains/dispatch/assignment-reconcile.ts +76 -0
- package/src/domains/dispatch/assignment-store.ts +162 -0
- package/src/domains/dispatch/assignment.ts +278 -0
- package/src/domains/dispatch/backoff.ts +59 -0
- package/src/domains/dispatch/batch-store.ts +134 -0
- package/src/domains/dispatch/batch-tracker.ts +66 -0
- package/src/domains/dispatch/capability-match.ts +155 -0
- package/src/domains/dispatch/capacity-lease.ts +413 -0
- package/src/domains/dispatch/code-step-store.ts +52 -0
- package/src/domains/dispatch/code-step.ts +387 -0
- package/src/domains/dispatch/contract.ts +278 -0
- package/src/domains/dispatch/dedup.ts +133 -0
- package/src/domains/dispatch/event-pump.ts +251 -0
- package/src/domains/dispatch/execution-handoff.ts +29 -0
- package/src/domains/dispatch/execution-plan.ts +328 -0
- package/src/domains/dispatch/execution-role.ts +277 -0
- package/src/domains/dispatch/execution-scheduler.ts +583 -0
- package/src/domains/dispatch/extension.ts +6006 -0
- package/src/domains/dispatch/failure-classification.ts +147 -0
- package/src/domains/dispatch/fleet-commit-attribution.ts +56 -0
- package/src/domains/dispatch/fleet-plan.ts +225 -0
- package/src/domains/dispatch/fleet-preflight.ts +394 -0
- package/src/domains/dispatch/gate-decisions.ts +1040 -0
- package/src/domains/dispatch/gate-role-prompts.ts +58 -0
- package/src/domains/dispatch/heartbeat.ts +27 -0
- package/src/domains/dispatch/index.ts +137 -0
- package/src/domains/dispatch/joint-route-adapter.ts +114 -0
- package/src/domains/dispatch/joint-route-resolver.ts +283 -0
- package/src/domains/dispatch/manifest.ts +6 -0
- package/src/domains/dispatch/orphan-recovery.ts +266 -0
- package/src/domains/dispatch/outcome.ts +109 -0
- package/src/domains/dispatch/phase-timing.ts +47 -0
- package/src/domains/dispatch/placement.ts +202 -0
- package/src/domains/dispatch/receipt-findings.ts +255 -0
- package/src/domains/dispatch/receipt-integrity.ts +383 -0
- package/src/domains/dispatch/recovery-candidates.ts +74 -0
- package/src/domains/dispatch/reproducibility.ts +48 -0
- package/src/domains/dispatch/reservation-store.ts +501 -0
- package/src/domains/dispatch/route-approval.ts +177 -0
- package/src/domains/dispatch/route-candidates.ts +57 -0
- package/src/domains/dispatch/route-decision.ts +1079 -0
- package/src/domains/dispatch/route-facts.ts +187 -0
- package/src/domains/dispatch/route-history.ts +238 -0
- package/src/domains/dispatch/route-observer.ts +488 -0
- package/src/domains/dispatch/route-policy.ts +327 -0
- package/src/domains/dispatch/route-quality.ts +256 -0
- package/src/domains/dispatch/route-readiness.ts +120 -0
- package/src/domains/dispatch/routing-intent.ts +287 -0
- package/src/domains/dispatch/run-identity.ts +56 -0
- package/src/domains/dispatch/scout-transition.ts +130 -0
- package/src/domains/dispatch/state.ts +302 -0
- package/src/domains/dispatch/tool-stats.ts +132 -0
- package/src/domains/dispatch/transport.ts +210 -0
- package/src/domains/dispatch/types.ts +799 -0
- package/src/domains/dispatch/validation-grounding.ts +154 -0
- package/src/domains/dispatch/validation.ts +721 -0
- package/src/domains/dispatch/worker-protocol.ts +275 -0
- package/src/domains/dispatch/worker-spawn.ts +585 -0
- package/src/domains/dispatch/write-boundary-enforcer.ts +97 -0
- package/src/domains/dispatch/write-boundary.ts +426 -0
- package/src/domains/eval/artifacts/redact.ts +42 -0
- package/src/domains/eval/artifacts/store.ts +173 -0
- package/src/domains/eval/compare/compare.ts +33 -0
- package/src/domains/eval/compare/gates.ts +66 -0
- package/src/domains/eval/compare/thresholds.ts +92 -0
- package/src/domains/eval/harness-metrics.ts +62 -0
- package/src/domains/eval/index.ts +66 -0
- package/src/domains/eval/metrics/chaos-stream.ts +93 -0
- package/src/domains/eval/metrics/context.ts +34 -0
- package/src/domains/eval/metrics/coverage.ts +21 -0
- package/src/domains/eval/metrics/evidence.ts +182 -0
- package/src/domains/eval/metrics/fleet-loop-stream.ts +196 -0
- package/src/domains/eval/metrics/invariants.ts +736 -0
- package/src/domains/eval/metrics/latency.ts +4 -0
- package/src/domains/eval/metrics/token-stream.ts +139 -0
- package/src/domains/eval/metrics/tokens.ts +51 -0
- package/src/domains/eval/metrics/tool-calls.ts +7 -0
- package/src/domains/eval/proactive-memory.ts +279 -0
- package/src/domains/eval/provenance.ts +35 -0
- package/src/domains/eval/report.ts +234 -0
- package/src/domains/eval/reports/json.ts +5 -0
- package/src/domains/eval/reports/junit.ts +23 -0
- package/src/domains/eval/reports/markdown.ts +20 -0
- package/src/domains/eval/reports/swe-jsonl.ts +16 -0
- package/src/domains/eval/reports/text.ts +25 -0
- package/src/domains/eval/run-compare.ts +274 -0
- package/src/domains/eval/runner.ts +244 -0
- package/src/domains/eval/runners/clio-run.ts +148 -0
- package/src/domains/eval/runners/context-index.ts +56 -0
- package/src/domains/eval/runners/context-init.ts +203 -0
- package/src/domains/eval/runners/external-command.ts +350 -0
- package/src/domains/eval/runtime-paths.ts +171 -0
- package/src/domains/eval/schema/artifact.ts +75 -0
- package/src/domains/eval/schema/suite.ts +235 -0
- package/src/domains/eval/schema/validate.ts +339 -0
- package/src/domains/eval/store.ts +392 -0
- package/src/domains/eval/suites/load.ts +74 -0
- package/src/domains/eval/suites/matrix.ts +19 -0
- package/src/domains/eval/suites/resolve.ts +44 -0
- package/src/domains/eval/suites/run.ts +325 -0
- package/src/domains/eval/task-file.ts +186 -0
- package/src/domains/eval/types.ts +140 -0
- package/src/domains/eval/verifiers/command.ts +27 -0
- package/src/domains/eval/verifiers/file-exists.ts +6 -0
- package/src/domains/eval/verifiers/patch.ts +22 -0
- package/src/domains/eval/workspaces/git.ts +41 -0
- package/src/domains/eval/workspaces/local.ts +17 -0
- package/src/domains/eval/workspaces/temp-copy.ts +29 -0
- package/src/domains/evidence/build.ts +1754 -0
- package/src/domains/evidence/eval.ts +605 -0
- package/src/domains/evidence/failure-attribution.ts +54 -0
- package/src/domains/evidence/finish-contract-map.ts +42 -0
- package/src/domains/evidence/index.ts +55 -0
- package/src/domains/evidence/provenance.ts +200 -0
- package/src/domains/evidence/redact.ts +81 -0
- package/src/domains/evidence/store.ts +291 -0
- package/src/domains/evidence/types.ts +325 -0
- package/src/domains/evolution/SELF_EDIT_GATE.md +91 -0
- package/src/domains/evolution/index.ts +26 -0
- package/src/domains/evolution/manifest.ts +154 -0
- package/src/domains/evolution/validate.ts +304 -0
- package/src/domains/extensions/contract.ts +22 -0
- package/src/domains/extensions/discovery.ts +193 -0
- package/src/domains/extensions/extension.ts +46 -0
- package/src/domains/extensions/index.ts +34 -0
- package/src/domains/extensions/manager.ts +30 -0
- package/src/domains/extensions/manifest.ts +6 -0
- package/src/domains/extensions/resources.ts +38 -0
- package/src/domains/extensions/state.ts +224 -0
- package/src/domains/extensions/types.ts +83 -0
- package/src/domains/interop/consent.ts +185 -0
- package/src/domains/interop/contract.ts +29 -0
- package/src/domains/interop/detect.ts +173 -0
- package/src/domains/interop/extension.ts +59 -0
- package/src/domains/interop/index.ts +34 -0
- package/src/domains/interop/manifest.ts +6 -0
- package/src/domains/interop/registry.ts +139 -0
- package/src/domains/interop/state.ts +92 -0
- package/src/domains/interop/types.ts +109 -0
- package/src/domains/lifecycle/contract.ts +11 -0
- package/src/domains/lifecycle/doctor.ts +536 -0
- package/src/domains/lifecycle/extension.ts +23 -0
- package/src/domains/lifecycle/index.ts +21 -0
- package/src/domains/lifecycle/install-method.ts +51 -0
- package/src/domains/lifecycle/manifest.ts +6 -0
- package/src/domains/lifecycle/migrations/2026-08-18-lmstudio-runtime-id.ts +52 -0
- package/src/domains/lifecycle/migrations/index.ts +114 -0
- package/src/domains/lifecycle/state.ts +93 -0
- package/src/domains/lifecycle/upgrade-notice.ts +35 -0
- package/src/domains/lifecycle/version.ts +35 -0
- package/src/domains/memory/index.ts +128 -0
- package/src/domains/memory/operations.ts +143 -0
- package/src/domains/memory/prompt-section.ts +86 -0
- package/src/domains/memory/proposal.ts +180 -0
- package/src/domains/memory/store.ts +163 -0
- package/src/domains/memory/task-bank.ts +229 -0
- package/src/domains/memory/task-memory-handoff.ts +222 -0
- package/src/domains/memory/task-memory-policy.ts +602 -0
- package/src/domains/memory/task-memory-status.ts +58 -0
- package/src/domains/memory/task-memory-telemetry.ts +346 -0
- package/src/domains/memory/task-memory-trace.ts +89 -0
- package/src/domains/memory/types.ts +74 -0
- package/src/domains/memory/validate.ts +297 -0
- package/src/domains/middleware/budget.ts +216 -0
- package/src/domains/middleware/contract.ts +35 -0
- package/src/domains/middleware/dispatch-nudge.ts +469 -0
- package/src/domains/middleware/extension.ts +129 -0
- package/src/domains/middleware/hook-receipts.ts +70 -0
- package/src/domains/middleware/hooks-io.ts +186 -0
- package/src/domains/middleware/hooks.ts +432 -0
- package/src/domains/middleware/index.ts +154 -0
- package/src/domains/middleware/manifest.ts +6 -0
- package/src/domains/middleware/memory-intervention.ts +701 -0
- package/src/domains/middleware/rules.ts +42 -0
- package/src/domains/middleware/runtime.ts +333 -0
- package/src/domains/middleware/skills-reminder.ts +202 -0
- package/src/domains/middleware/snapshot.ts +71 -0
- package/src/domains/middleware/stalled-turn.ts +71 -0
- package/src/domains/middleware/task-board-reminder.ts +87 -0
- package/src/domains/middleware/task-nudge.ts +77 -0
- package/src/domains/middleware/tool-choice-control.ts +42 -0
- package/src/domains/middleware/types.ts +131 -0
- package/src/domains/middleware/validate.ts +329 -0
- package/src/domains/observability/accountability.ts +67 -0
- package/src/domains/observability/contract.ts +168 -0
- package/src/domains/observability/cost.ts +206 -0
- package/src/domains/observability/evidence-index.ts +123 -0
- package/src/domains/observability/extension.ts +281 -0
- package/src/domains/observability/index.ts +78 -0
- package/src/domains/observability/manifest.ts +10 -0
- package/src/domains/observability/metrics.ts +37 -0
- package/src/domains/observability/projection.ts +477 -0
- package/src/domains/observability/telemetry.ts +89 -0
- package/src/domains/observability/trace-store.ts +1454 -0
- package/src/domains/prompts/compiler.ts +614 -0
- package/src/domains/prompts/contract.ts +46 -0
- package/src/domains/prompts/extension.ts +336 -0
- package/src/domains/prompts/fragment-loader.ts +138 -0
- package/src/domains/prompts/fragments/identity/clio.md +5 -6
- package/src/domains/prompts/fragments/identity/docs-routing.md +10 -0
- package/src/domains/prompts/fragments/identity/self-awareness.md +19 -0
- package/src/domains/prompts/fragments/operating/contract.md +4 -41
- package/src/domains/prompts/fragments/operating/delegation.md +42 -0
- package/src/domains/prompts/fragments/operating/skills.md +26 -0
- package/src/domains/prompts/fragments/operating/worker.md +16 -0
- package/src/domains/prompts/fragments/safety/auto-edit.md +5 -5
- package/src/domains/prompts/fragments/safety/full-auto.md +3 -3
- package/src/domains/prompts/fragments/safety/read-only.md +4 -4
- package/src/domains/prompts/fragments/safety/suggest.md +2 -2
- package/src/domains/prompts/fragments/wiki/page.md +10 -0
- package/src/domains/prompts/fragments/wiki/plan.md +10 -0
- package/src/domains/prompts/hash.ts +73 -0
- package/src/domains/prompts/index.ts +32 -0
- package/src/domains/prompts/manifest.ts +8 -0
- package/src/domains/prompts/memory-intervention.ts +57 -0
- package/src/domains/prompts/preload.ts +82 -0
- package/src/domains/providers/auth/api-key.ts +47 -0
- package/src/domains/providers/auth/backend-file.ts +79 -0
- package/src/domains/providers/auth/backend-memory.ts +72 -0
- package/src/domains/providers/auth/boot-status.ts +65 -0
- package/src/domains/providers/auth/index.ts +37 -0
- package/src/domains/providers/auth/oauth.ts +37 -0
- package/src/domains/providers/auth/storage.ts +726 -0
- package/src/domains/providers/capabilities.ts +58 -0
- package/src/domains/providers/catalog.ts +162 -0
- package/src/domains/providers/contract.ts +162 -0
- package/src/domains/providers/credentials.ts +20 -0
- package/src/domains/providers/eligibility.ts +24 -0
- package/src/domains/providers/errors.ts +64 -0
- package/src/domains/providers/extension.ts +548 -0
- package/src/domains/providers/index.ts +142 -0
- package/src/domains/providers/knowledge-base-path.ts +102 -0
- package/src/domains/providers/manifest.ts +6 -0
- package/src/domains/providers/model-capabilities.ts +136 -0
- package/src/domains/providers/model-discovery.ts +144 -0
- package/src/domains/providers/model-family.ts +32 -0
- package/src/domains/providers/model-runtime-capabilities.ts +723 -0
- package/src/domains/providers/models/local-models/clio-local-coding-targets.yaml +120 -37
- package/src/domains/providers/plugins.ts +61 -0
- package/src/domains/providers/probe/fingerprint.ts +64 -0
- package/src/domains/providers/probe/http.ts +114 -0
- package/src/domains/providers/probe/reasoning.ts +111 -0
- package/src/domains/providers/registry.ts +187 -0
- package/src/domains/providers/resolver.ts +156 -0
- package/src/domains/providers/runtime-resolution.ts +720 -0
- package/src/domains/providers/runtimes/antigravity/antigravity-code.ts +90 -0
- package/src/domains/providers/runtimes/boot-manifest.ts +55 -0
- package/src/domains/providers/runtimes/builtins.ts +78 -0
- package/src/domains/providers/runtimes/claude/claude-code.ts +38 -0
- package/src/domains/providers/runtimes/claude/claude-sdk.ts +38 -0
- package/src/domains/providers/runtimes/claude/common.ts +55 -0
- package/src/domains/providers/runtimes/cloud/alcf.ts +171 -0
- package/src/domains/providers/runtimes/cloud/anthropic-max.ts +71 -0
- package/src/domains/providers/runtimes/cloud/anthropic.ts +43 -0
- package/src/domains/providers/runtimes/cloud/bedrock.ts +35 -0
- package/src/domains/providers/runtimes/cloud/deepseek.ts +50 -0
- package/src/domains/providers/runtimes/cloud/google.ts +41 -0
- package/src/domains/providers/runtimes/cloud/groq.ts +46 -0
- package/src/domains/providers/runtimes/cloud/mistral.ts +46 -0
- package/src/domains/providers/runtimes/cloud/openai-codex.ts +49 -0
- package/src/domains/providers/runtimes/cloud/openai.ts +46 -0
- package/src/domains/providers/runtimes/cloud/openrouter.ts +111 -0
- package/src/domains/providers/runtimes/common/lmstudio-http.ts +423 -0
- package/src/domains/providers/runtimes/common/local-synth.ts +164 -0
- package/src/domains/providers/runtimes/common/probe-helpers.ts +474 -0
- package/src/domains/providers/runtimes/local-native/lemonade-anthropic.ts +27 -0
- package/src/domains/providers/runtimes/local-native/lemonade-openai.ts +26 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-anthropic.ts +88 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-completion.ts +207 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-embed.ts +180 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-rerank.ts +126 -0
- package/src/domains/providers/runtimes/local-native/llamacpp.ts +98 -0
- package/src/domains/providers/runtimes/local-native/lmstudio.ts +241 -0
- package/src/domains/providers/runtimes/local-native/ollama-native.ts +117 -0
- package/src/domains/providers/runtimes/local-native/sglang.ts +26 -0
- package/src/domains/providers/runtimes/local-native/vllm.ts +27 -0
- package/src/domains/providers/runtimes/protocol/anthropic-compat.ts +104 -0
- package/src/domains/providers/runtimes/protocol/anthropic-messages.ts +28 -0
- package/src/domains/providers/runtimes/protocol/bedrock.ts +26 -0
- package/src/domains/providers/runtimes/protocol/google.ts +27 -0
- package/src/domains/providers/runtimes/protocol/openai-compat.ts +145 -0
- package/src/domains/providers/support.ts +241 -0
- package/src/domains/providers/thinking-control-policy.ts +85 -0
- package/src/domains/providers/types/capability-flags.ts +114 -0
- package/src/domains/providers/types/cost-provenance.ts +7 -0
- package/src/domains/providers/types/inference.ts +41 -0
- package/src/domains/providers/types/knowledge-base.ts +156 -0
- package/src/domains/providers/types/local-model-quirks.ts +216 -0
- package/src/domains/providers/types/runtime-descriptor.ts +181 -0
- package/src/domains/providers/types/target-descriptor.ts +60 -0
- package/src/domains/resources/collision.ts +92 -0
- package/src/domains/resources/common-loader.ts +140 -0
- package/src/domains/resources/contract.ts +24 -0
- package/src/domains/resources/extension.ts +59 -0
- package/src/domains/resources/index.ts +74 -0
- package/src/domains/resources/loader.ts +85 -0
- package/src/domains/resources/manifest.ts +6 -0
- package/src/domains/resources/prompts/loader.ts +246 -0
- package/src/domains/resources/prompts/substitute.ts +1 -0
- package/src/domains/resources/skills/content-hash.ts +107 -0
- package/src/domains/resources/skills/evals.ts +175 -0
- package/src/domains/resources/skills/install.ts +427 -0
- package/src/domains/resources/skills/loader.ts +985 -0
- package/src/domains/resources/skills/marketplace.ts +301 -0
- package/src/domains/resources/skills/provenance-pin.ts +115 -0
- package/src/domains/safety/action-classifier.ts +270 -0
- package/src/domains/safety/approval-axis.ts +23 -0
- package/src/domains/safety/audit.ts +493 -0
- package/src/domains/safety/autonomy.ts +174 -0
- package/src/domains/safety/call-target.ts +59 -0
- package/src/domains/safety/contract.ts +65 -0
- package/src/domains/safety/damage-control.ts +44 -0
- package/src/domains/safety/default-path-policy.ts +117 -0
- package/src/domains/safety/extension.ts +383 -0
- package/src/domains/safety/finish-contract-registration.ts +128 -0
- package/src/domains/safety/finish-contract.ts +554 -0
- package/src/domains/safety/index.ts +44 -0
- package/src/domains/safety/loop-detector.ts +143 -0
- package/src/domains/safety/manifest.ts +6 -0
- package/src/domains/safety/path-policy.ts +164 -0
- package/src/domains/safety/policy-engine.ts +994 -0
- package/src/domains/safety/project-policy.ts +391 -0
- package/src/domains/safety/protected-artifacts-registration.ts +189 -0
- package/src/domains/safety/protected-artifacts.ts +993 -0
- package/src/domains/safety/rejection-feedback.ts +102 -0
- package/src/domains/safety/rigor.ts +72 -0
- package/src/domains/safety/rule-compiler.ts +48 -0
- package/src/domains/safety/rule-pack-loader.ts +92 -0
- package/src/domains/safety/run-effects.ts +197 -0
- package/src/domains/safety/scope.ts +61 -0
- package/src/domains/scheduling/budget.ts +35 -0
- package/src/domains/scheduling/cluster.ts +175 -0
- package/src/domains/scheduling/contract.ts +30 -0
- package/src/domains/scheduling/extension.ts +91 -0
- package/src/domains/scheduling/index.ts +12 -0
- package/src/domains/scheduling/manifest.ts +6 -0
- package/src/domains/session/archive-readers.ts +208 -0
- package/src/domains/session/checkpoint.ts +38 -0
- package/src/domains/session/compaction/auto.ts +89 -0
- package/src/domains/session/compaction/branch-summary.ts +187 -0
- package/src/domains/session/compaction/compact.ts +493 -0
- package/src/domains/session/compaction/cut-point.ts +172 -0
- package/src/domains/session/compaction/defaults.ts +34 -0
- package/src/domains/session/compaction/mask-observations.ts +265 -0
- package/src/domains/session/compaction/session-entries.ts +18 -0
- package/src/domains/session/compaction/tokens.ts +148 -0
- package/src/domains/session/context-accounting.ts +583 -0
- package/src/domains/session/context-ledger.ts +362 -0
- package/src/domains/session/contract.ts +159 -0
- package/src/domains/session/cwd-fallback.ts +65 -0
- package/src/domains/session/decision-board.ts +190 -0
- package/src/domains/session/entries.ts +572 -0
- package/src/domains/session/extension.ts +403 -0
- package/src/domains/session/history.ts +172 -0
- package/src/domains/session/index.ts +84 -0
- package/src/domains/session/manager.ts +128 -0
- package/src/domains/session/manifest.ts +6 -0
- package/src/domains/session/migrations/index.ts +27 -0
- package/src/domains/session/prompt-manifest.ts +173 -0
- package/src/domains/session/protected-artifact-journal.ts +241 -0
- package/src/domains/session/protected-artifacts.ts +90 -0
- package/src/domains/session/retry.ts +230 -0
- package/src/domains/session/session-artifacts.ts +107 -0
- package/src/domains/session/task-board.ts +569 -0
- package/src/domains/session/tree/active-path.ts +137 -0
- package/src/domains/session/tree/fork.ts +159 -0
- package/src/domains/session/tree/manager.ts +128 -0
- package/src/domains/session/tree/navigator.ts +177 -0
- package/src/domains/session/tree/preview.ts +259 -0
- package/src/domains/session/usage.ts +148 -0
- package/src/domains/session/workspace/git-probe.ts +167 -0
- package/src/domains/session/workspace/index.ts +4 -0
- package/src/domains/session/workspace/project-type.ts +217 -0
- package/src/domains/session/workspace/snapshot.ts +74 -0
- package/src/domains/share/archive.ts +684 -0
- package/src/domains/share/contract.ts +9 -0
- package/src/domains/share/extension.ts +26 -0
- package/src/domains/share/index.ts +28 -0
- package/src/domains/share/manifest.ts +6 -0
- package/src/domains/user-tasks/store.ts +297 -0
- package/src/engine/acp/adapter.ts +397 -0
- package/src/engine/acp/errors.ts +128 -0
- package/src/engine/acp/event-mapper.ts +154 -0
- package/src/engine/acp/server.ts +2238 -0
- package/src/engine/acp/tool-mediator.ts +686 -0
- package/src/engine/acp/transport.ts +775 -0
- package/src/engine/acp/types.ts +196 -0
- package/src/engine/agent.ts +29 -0
- package/src/engine/ai.ts +207 -0
- package/src/engine/alcf-oauth.ts +205 -0
- package/src/engine/antigravity/subprocess-runtime.ts +205 -0
- package/src/engine/api-registry.ts +223 -0
- package/src/engine/apis/degraded-inference.ts +95 -0
- package/src/engine/apis/index.ts +16 -0
- package/src/engine/apis/llamacpp-residency.ts +292 -0
- package/src/engine/apis/lmstudio-residency.ts +76 -0
- package/src/engine/apis/lmstudio.ts +243 -0
- package/src/engine/apis/ollama-native.ts +528 -0
- package/src/engine/apis/openai-completions.ts +795 -0
- package/src/engine/apis/output-budget.ts +99 -0
- package/src/engine/apis/residency-lock.ts +29 -0
- package/src/engine/apis/residency.ts +776 -0
- package/src/engine/apis/resident-models.ts +42 -0
- package/src/engine/apis/sampling-overrides.ts +38 -0
- package/src/engine/apis/types.ts +16 -0
- package/src/engine/claude/sdk-runtime.ts +685 -0
- package/src/engine/claude/session-id.ts +5 -0
- package/src/engine/claude/subprocess-runtime.ts +316 -0
- package/src/engine/claude/tool-safety.ts +400 -0
- package/src/engine/env-api-keys.ts +98 -0
- package/src/engine/external-subprocess.ts +23 -0
- package/src/engine/gemma-channel-filter.ts +223 -0
- package/src/engine/harmony-response.ts +165 -0
- package/src/engine/instrumented-tui.ts +192 -0
- package/src/engine/loop-guard.ts +1127 -0
- package/src/engine/messages.ts +14 -0
- package/src/engine/models.ts +42 -0
- package/src/engine/oauth.ts +196 -0
- package/src/engine/pi-mono-names.ts +13 -0
- package/src/engine/prompt-templates.ts +1 -0
- package/src/engine/provider-payload.ts +272 -0
- package/src/engine/select-list.ts +53 -0
- package/src/engine/session.ts +834 -0
- package/src/engine/strip-tokenizer-sentinels.ts +125 -0
- package/src/engine/truncate.ts +9 -0
- package/src/engine/tui.ts +111 -0
- package/src/engine/types.ts +63 -0
- package/src/engine/worker-events.ts +100 -0
- package/src/engine/worker-runtime-capabilities.ts +5 -0
- package/src/engine/worker-runtime.ts +1022 -0
- package/src/engine/worker-tools.ts +208 -0
- package/src/entry/boot-options.ts +50 -0
- package/src/entry/orchestrator.ts +2011 -0
- package/src/interactive/application-controller.ts +433 -0
- package/src/interactive/bus-notices.ts +265 -0
- package/src/interactive/chat-loop-messages.ts +626 -0
- package/src/interactive/chat-loop-policy.ts +18 -0
- package/src/interactive/chat-loop.ts +1090 -0
- package/src/interactive/chat-panel.ts +1820 -0
- package/src/interactive/chat-renderer.ts +1228 -0
- package/src/interactive/clio-editor.ts +161 -0
- package/src/interactive/command-fallbacks.ts +23 -0
- package/src/interactive/command-output.ts +85 -0
- package/src/interactive/context-activity.ts +203 -0
- package/src/interactive/context-meter.ts +223 -0
- package/src/interactive/context-overlay.ts +246 -0
- package/src/interactive/cost-overlay.ts +279 -0
- package/src/interactive/dispatch-board.ts +1319 -0
- package/src/interactive/dispatch-steering.ts +86 -0
- package/src/interactive/editor-bash.ts +46 -0
- package/src/interactive/editor-steer.ts +51 -0
- package/src/interactive/editor-submit.ts +507 -0
- package/src/interactive/export-html/ansi-to-html.ts +161 -0
- package/src/interactive/export-html/index.ts +51 -0
- package/src/interactive/export-html/template.ts +45 -0
- package/src/interactive/export-html/tool-renderer.ts +54 -0
- package/src/interactive/external-editor.ts +67 -0
- package/src/interactive/follow-up-queue-panel.ts +75 -0
- package/src/interactive/footer/dashboard.ts +538 -0
- package/src/interactive/footer/notifications.ts +275 -0
- package/src/interactive/footer/widgets.ts +1264 -0
- package/src/interactive/footer-panel.ts +187 -0
- package/src/interactive/format-time.ts +97 -0
- package/src/interactive/index.ts +11 -0
- package/src/interactive/interactive-application.ts +939 -0
- package/src/interactive/interactive-event-projection.ts +385 -0
- package/src/interactive/interactive-input-runtime.ts +307 -0
- package/src/interactive/interactive-presentation.ts +584 -0
- package/src/interactive/interactive-shell.ts +388 -0
- package/src/interactive/interactive-slash-runtime.ts +554 -0
- package/src/interactive/interactive-subscriptions.ts +111 -0
- package/src/interactive/interactive-tickers.ts +183 -0
- package/src/interactive/keybinding-manager.ts +496 -0
- package/src/interactive/layout.ts +57 -0
- package/src/interactive/leader-key.ts +143 -0
- package/src/interactive/loop-guard-interrupt.ts +101 -0
- package/src/interactive/memory-overlay.ts +280 -0
- package/src/interactive/overlay-ask-user-lifecycle.ts +110 -0
- package/src/interactive/overlay-auth-lifecycle.ts +308 -0
- package/src/interactive/overlay-frame.ts +502 -0
- package/src/interactive/overlay-general-openers.ts +274 -0
- package/src/interactive/overlay-key-routing.ts +216 -0
- package/src/interactive/overlay-lifecycle.ts +426 -0
- package/src/interactive/overlay-model-selectors.ts +127 -0
- package/src/interactive/overlay-permission-lifecycle.ts +345 -0
- package/src/interactive/overlay-resource-openers.ts +112 -0
- package/src/interactive/overlay-session-lifecycle.ts +327 -0
- package/src/interactive/overlay-transitions.ts +57 -0
- package/src/interactive/overlays/agents.ts +69 -0
- package/src/interactive/overlays/ask-user.ts +921 -0
- package/src/interactive/overlays/auth-dialog.ts +221 -0
- package/src/interactive/overlays/context-reset.ts +108 -0
- package/src/interactive/overlays/cwd-fallback.ts +141 -0
- package/src/interactive/overlays/decisions.ts +300 -0
- package/src/interactive/overlays/extensions.ts +54 -0
- package/src/interactive/overlays/help-reference.ts +145 -0
- package/src/interactive/overlays/interop.ts +139 -0
- package/src/interactive/overlays/keybinding-detail.ts +90 -0
- package/src/interactive/overlays/list-overlay.ts +606 -0
- package/src/interactive/overlays/message-picker.ts +155 -0
- package/src/interactive/overlays/model-selector.ts +1109 -0
- package/src/interactive/overlays/prompts.ts +72 -0
- package/src/interactive/overlays/session-selector-search.ts +31 -0
- package/src/interactive/overlays/session-selector.ts +284 -0
- package/src/interactive/overlays/settings.ts +3451 -0
- package/src/interactive/overlays/skills-hub.ts +237 -0
- package/src/interactive/overlays/tree-selector.ts +422 -0
- package/src/interactive/permission-overlay.ts +170 -0
- package/src/interactive/render-trace.ts +534 -0
- package/src/interactive/renderers/branch-summary.ts +86 -0
- package/src/interactive/renderers/code-ink.ts +420 -0
- package/src/interactive/renderers/compaction-summary.ts +112 -0
- package/src/interactive/renderers/diff.ts +137 -0
- package/src/interactive/renderers/mermaid.ts +53 -0
- package/src/interactive/renderers/notice.ts +28 -0
- package/src/interactive/renderers/retry-status.ts +31 -0
- package/src/interactive/renderers/structured.ts +89 -0
- package/src/interactive/renderers/tool-execution.ts +1357 -0
- package/src/interactive/renderers/worker-entry.ts +280 -0
- package/src/interactive/session-last-turn.ts +186 -0
- package/src/interactive/session-switch-settlement.ts +10 -0
- package/src/interactive/session-transcript.ts +105 -0
- package/src/interactive/session-usage-reseed.ts +74 -0
- package/src/interactive/slash-autocomplete.ts +256 -0
- package/src/interactive/slash-commands.ts +1407 -0
- package/src/interactive/slash-spec.ts +424 -0
- package/src/interactive/status/controller.ts +260 -0
- package/src/interactive/status/index.ts +23 -0
- package/src/interactive/status/state-machine.ts +530 -0
- package/src/interactive/status/summary.ts +170 -0
- package/src/interactive/status/types.ts +121 -0
- package/src/interactive/status/verbs.ts +163 -0
- package/src/interactive/status/watchdog.ts +24 -0
- package/src/interactive/stdout-backpressure.ts +99 -0
- package/src/interactive/stream-pacer.ts +530 -0
- package/src/interactive/stream-pacing-policy.ts +66 -0
- package/src/interactive/tasks-overlay.ts +540 -0
- package/src/interactive/terminal-lease.ts +485 -0
- package/src/interactive/theme/components.ts +55 -0
- package/src/interactive/theme/glyphs.ts +70 -0
- package/src/interactive/theme/index.ts +15 -0
- package/src/interactive/theme/labels.ts +88 -0
- package/src/interactive/theme/rules.ts +138 -0
- package/src/interactive/theme/segments.ts +88 -0
- package/src/interactive/theme/tokens.ts +121 -0
- package/src/interactive/thinking-level-policy.ts +6 -0
- package/src/interactive/tool-prose-loop.ts +122 -0
- package/src/interactive/tool-prose-registration.ts +48 -0
- package/src/interactive/turn-context.ts +855 -0
- package/src/interactive/turn-middleware.ts +283 -0
- package/src/interactive/turn-persistence.ts +458 -0
- package/src/interactive/turn-queues.ts +181 -0
- package/src/interactive/turn-recovery.ts +323 -0
- package/src/interactive/turn-runtime.ts +869 -0
- package/src/interactive/turn-state.ts +133 -0
- package/src/interactive/view/artifacts.ts +1452 -0
- package/src/interactive/view/view-overlay.ts +735 -0
- package/src/interactive/welcome-dashboard.ts +537 -0
- package/src/interactive/worker-receipts.ts +143 -0
- package/src/interactive/worker-replay.ts +111 -0
- package/src/interactive/worker-share.ts +100 -0
- package/src/interactive/worker-stream.ts +446 -0
- package/src/interactive/workspace-facts.ts +141 -0
- package/src/tools/agent-tools.ts +402 -0
- package/src/tools/artifact.ts +103 -0
- package/src/tools/ask-user.ts +666 -0
- package/src/tools/bash.ts +204 -0
- package/src/tools/bootstrap.ts +77 -0
- package/src/tools/builtin-tool-catalog.ts +265 -0
- package/src/tools/codewiki/code-nav-surface.ts +29 -0
- package/src/tools/codewiki/code-nav.ts +549 -0
- package/src/tools/codewiki/shared.ts +118 -0
- package/src/tools/compete-worktrees.ts +898 -0
- package/src/tools/context/docs-engine.ts +630 -0
- package/src/tools/context/index.ts +514 -0
- package/src/tools/context/surface.ts +19 -0
- package/src/tools/core-bootstrap.ts +168 -0
- package/src/tools/credential-present.ts +151 -0
- package/src/tools/dispatch-admission.ts +533 -0
- package/src/tools/dispatch-arguments.ts +228 -0
- package/src/tools/dispatch-background.ts +54 -0
- package/src/tools/dispatch-event-text.ts +6 -0
- package/src/tools/dispatch-plan.ts +746 -0
- package/src/tools/dispatch-run-events.ts +238 -0
- package/src/tools/dispatch-runner.ts +2370 -0
- package/src/tools/dispatch-scout-admission.ts +295 -0
- package/src/tools/dispatch-scout.ts +461 -0
- package/src/tools/dispatch-types.ts +77 -0
- package/src/tools/dispatch.ts +244 -0
- package/src/tools/edit-diff.ts +534 -0
- package/src/tools/edit.ts +128 -0
- package/src/tools/executables.ts +22 -0
- package/src/tools/file-mutation-queue.ts +35 -0
- package/src/tools/find.ts +294 -0
- package/src/tools/grep.ts +495 -0
- package/src/tools/ignore-policy.ts +169 -0
- package/src/tools/lazy-tool.ts +60 -0
- package/src/tools/ledger.ts +206 -0
- package/src/tools/ls.ts +110 -0
- package/src/tools/monitor-surface.ts +36 -0
- package/src/tools/monitor.ts +767 -0
- package/src/tools/network-policy.ts +29 -0
- package/src/tools/observation.ts +421 -0
- package/src/tools/observers.ts +99 -0
- package/src/tools/path-utils.ts +79 -0
- package/src/tools/policy.ts +154 -0
- package/src/tools/profiles.ts +108 -0
- package/src/tools/read.ts +173 -0
- package/src/tools/registry.ts +1169 -0
- package/src/tools/result-shaping.ts +204 -0
- package/src/tools/safe-exec.ts +128 -0
- package/src/tools/spawn-hygiene.ts +182 -0
- package/src/tools/steer-surface.ts +17 -0
- package/src/tools/steer.ts +77 -0
- package/src/tools/tasks.ts +265 -0
- package/src/tools/truncate-utf8.ts +17 -0
- package/src/tools/truncate.ts +43 -0
- package/src/tools/verify/frontend.ts +687 -0
- package/src/tools/verify/index.ts +31 -0
- package/src/tools/verify/scripts.ts +108 -0
- package/src/tools/verify/surface.ts +46 -0
- package/src/tools/web-fetch-surface.ts +23 -0
- package/src/tools/web-fetch.ts +759 -0
- package/src/tools/worker-evidence.ts +215 -0
- package/src/tools/write.ts +57 -0
- package/src/utils/exif-orientation.ts +192 -0
- package/src/utils/git.ts +24 -0
- package/src/utils/image-resize.ts +148 -0
- package/src/utils/photon.ts +103 -0
- package/src/worker/control-lane.ts +22 -0
- package/src/worker/entry.ts +294 -0
- package/src/worker/event-projection.ts +56 -0
- package/src/worker/heartbeat.ts +24 -0
- package/src/worker/ledger-mirror.ts +95 -0
- package/src/worker/ndjson.ts +40 -0
- package/src/worker/protocol.ts +529 -0
- package/src/worker/resource-facts.ts +79 -0
- package/src/worker/runtime-registry.ts +12 -0
- package/src/worker/spec-contract.ts +675 -0
- package/src/worker/stdin-demux.ts +316 -0
- package/dist/acp-UMLFVA3F.js +0 -92
- package/dist/chunk-262G75JS.js +0 -35
- package/dist/chunk-6CWDTGUC.js +0 -20
- package/dist/chunk-BYEU76JP.js +0 -899
- package/dist/chunk-GNGDQYDU.js +0 -34688
- package/dist/chunk-GOTUR54M.js +0 -9
- package/dist/chunk-NI4DEJMC.js +0 -88
- package/dist/chunk-TPOCL34A.js +0 -2876
- package/dist/chunk-UU3R62TT.js +0 -128
- package/dist/clio-KIQ5SNDS.js +0 -53
- package/dist/configure-G4E3A2PG.js +0 -27
- package/dist/doctor-M5HJJZOL.js +0 -61
- package/dist/domains/agents/builtins/architect.md +0 -33
- package/dist/domains/agents/builtins/coder.md +0 -31
- package/dist/domains/agents/builtins/context-bootstrap.md +0 -38
- package/dist/domains/agents/builtins/debugger.md +0 -30
- package/dist/domains/agents/builtins/documenter.md +0 -31
- package/dist/domains/agents/builtins/git-master.md +0 -30
- package/dist/domains/agents/builtins/provenance.md +0 -30
- package/dist/domains/agents/builtins/researcher.md +0 -71
- package/dist/domains/agents/builtins/scout.md +0 -42
- package/dist/domains/agents/builtins/tester.md +0 -31
- package/dist/domains/agents/builtins/verifier.md +0 -30
- package/dist/domains/agents/builtins/wiki-writer.md +0 -41
- package/dist/fleet-preflight-CLIAX7YR.js +0 -21
- package/dist/preload-KZVHET2B.js +0 -11
- package/dist/version-ROZ6CZKH.js +0 -16
- package/docs/html/agents_blueprint.html +0 -936
- package/docs/html/alcf_blueprint.html +0 -324
- package/docs/html/architecture_blueprint.html +0 -850
- package/docs/html/commands_blueprint.html +0 -794
- package/docs/html/config_knobs_audit_blueprint.html +0 -178
- package/docs/html/configuration_blueprint.html +0 -1080
- package/docs/html/context_blueprint.html +0 -603
- package/docs/html/documentation_blueprint.html +0 -832
- package/docs/html/environment_blueprint.html +0 -404
- package/docs/html/eval_blueprint.html +0 -743
- package/docs/html/evals_internal_blueprint.html +0 -190
- package/docs/html/evolution_blueprint.html +0 -674
- package/docs/html/extensions_blueprint.html +0 -2065
- package/docs/html/fleet_dispatch_blueprint.html +0 -286
- package/docs/html/index.html +0 -919
- package/docs/html/lifecycle_blueprint.html +0 -723
- package/docs/html/memory_blueprint.html +0 -699
- package/docs/html/middleware_blueprint.html +0 -664
- package/docs/html/models_blueprint.html +0 -2366
- package/docs/html/observability_blueprint.html +0 -683
- package/docs/html/provider_adapter_blueprint.html +0 -245
- package/docs/html/safety_blueprint.html +0 -1386
- package/docs/html/shared.css +0 -571
- package/docs/html/shared.js +0 -143
- package/docs/html/skills_blueprint.html +0 -671
- package/docs/html/soak_blueprint.html +0 -182
- package/docs/html/tool_usage_blueprint.html +0 -350
- package/docs/html/tools_blueprint.html +0 -2249
- package/docs/html/trace_blueprint.html +0 -235
- package/docs/html/tui_design_blueprint.html +0 -314
- package/docs/html/validation_blueprint.html +0 -961
- package/docs/html/worker_dispatch_blueprint.html +0 -231
- package/skills/git/commit-crafting/SKILL.md +0 -79
- package/skills/git/commit-crafting/evals.md +0 -92
- package/skills/git/create-pr/SKILL.md +0 -116
- package/skills/git/create-pr/evals.md +0 -114
- package/skills/git/investigate-issue/SKILL.md +0 -139
- package/skills/git/investigate-issue/evals.md +0 -94
- package/skills/git/review-changes/SKILL.md +0 -103
- package/skills/git/review-changes/evals.md +0 -85
|
@@ -1,28 +1,75 @@
|
|
|
1
|
+
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
AGENT_AUTOMATION_AUTHORITIES,
|
|
3
|
-
|
|
4
|
+
artifactDefaultPath,
|
|
4
5
|
classify,
|
|
5
6
|
detectValidationCommand,
|
|
6
7
|
extractCommandDeleteTargets,
|
|
7
8
|
extractCommandWriteTargets,
|
|
8
9
|
inlineShellScript,
|
|
9
|
-
isVerificationScriptName,
|
|
10
10
|
tokenizeShellLike,
|
|
11
11
|
toolMutationPaths
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5UUP6MWO.js";
|
|
13
|
+
import {
|
|
14
|
+
isVerificationScriptName
|
|
15
|
+
} from "./chunk-7MNJORFF.js";
|
|
16
|
+
import {
|
|
17
|
+
canonicalizeExistingPath
|
|
18
|
+
} from "./chunk-ECH6PKUQ.js";
|
|
13
19
|
import {
|
|
14
20
|
ToolNames
|
|
15
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-CGKSTWHD.js";
|
|
22
|
+
import {
|
|
23
|
+
foreignAgentDirs
|
|
24
|
+
} from "./chunk-IHXBNWMM.js";
|
|
25
|
+
import {
|
|
26
|
+
require_dist
|
|
27
|
+
} from "./chunk-APJ265NV.js";
|
|
16
28
|
import {
|
|
17
29
|
clioConfigDir
|
|
18
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-BNAZZHFG.js";
|
|
19
31
|
import {
|
|
20
32
|
resolvePackageRoot
|
|
21
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-IWHMRKLL.js";
|
|
34
|
+
import {
|
|
35
|
+
__toESM,
|
|
36
|
+
init_esm_shims
|
|
37
|
+
} from "./chunk-3R73A4XB.js";
|
|
22
38
|
|
|
23
39
|
// src/domains/agents/result-contract.ts
|
|
40
|
+
init_esm_shims();
|
|
24
41
|
import { createHash } from "node:crypto";
|
|
25
42
|
import path from "node:path";
|
|
43
|
+
|
|
44
|
+
// src/core/json-payload.ts
|
|
45
|
+
init_esm_shims();
|
|
46
|
+
function jsonPayloadCandidates(text) {
|
|
47
|
+
const trimmed = text.trim();
|
|
48
|
+
const candidates = [trimmed];
|
|
49
|
+
const fenced = /```[A-Za-z0-9_-]*\s*\n?([\s\S]*?)```/.exec(trimmed)?.[1]?.trim();
|
|
50
|
+
if (fenced !== void 0 && fenced.length > 0) candidates.push(fenced);
|
|
51
|
+
const start = trimmed.indexOf("{");
|
|
52
|
+
const end = trimmed.lastIndexOf("}");
|
|
53
|
+
if (start >= 0 && end > start) candidates.push(trimmed.slice(start, end + 1));
|
|
54
|
+
return candidates;
|
|
55
|
+
}
|
|
56
|
+
function parseJsonObjectPayload(text) {
|
|
57
|
+
let parsedSomething = false;
|
|
58
|
+
for (const candidate of jsonPayloadCandidates(text)) {
|
|
59
|
+
let value;
|
|
60
|
+
try {
|
|
61
|
+
value = JSON.parse(candidate);
|
|
62
|
+
} catch {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
parsedSomething = true;
|
|
66
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) continue;
|
|
67
|
+
return { ok: true, value };
|
|
68
|
+
}
|
|
69
|
+
return { ok: false, reason: parsedSomething ? "not-object" : "not-json" };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/domains/agents/result-contract.ts
|
|
26
73
|
function canonical(value) {
|
|
27
74
|
if (value === null) return "null";
|
|
28
75
|
if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
@@ -66,15 +113,12 @@ function success(contract, quality, value, extra = {}) {
|
|
|
66
113
|
}
|
|
67
114
|
function parseJson(output) {
|
|
68
115
|
if (output === null || output.trim().length === 0) return { ok: false, reason: "missing final result" };
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} catch {
|
|
76
|
-
return { ok: false, reason: "result must be valid JSON" };
|
|
77
|
-
}
|
|
116
|
+
const parsed = parseJsonObjectPayload(output);
|
|
117
|
+
if (parsed.ok) return parsed;
|
|
118
|
+
return {
|
|
119
|
+
ok: false,
|
|
120
|
+
reason: parsed.reason === "not-object" ? "result must be a JSON object" : "result must be valid JSON"
|
|
121
|
+
};
|
|
78
122
|
}
|
|
79
123
|
function hasOnlyKeys(value, keys) {
|
|
80
124
|
const allowed = new Set(keys);
|
|
@@ -427,6 +471,14 @@ function pathIsPresent(filesystem, target) {
|
|
|
427
471
|
if (filesystem.pathExists === void 0) return true;
|
|
428
472
|
return filesystem.pathExists(target);
|
|
429
473
|
}
|
|
474
|
+
var MUTATION_VALIDATION_EXAMPLE = '{"name":"npm test","passed":true,"evidence":"exit 0"}';
|
|
475
|
+
function mutationValidationsReason(value) {
|
|
476
|
+
const empty = Array.isArray(value) && value.length === 0;
|
|
477
|
+
if (empty) {
|
|
478
|
+
return `Mutation result must carry typed validation results: validations was empty. Emit one entry per check this run actually made, each shaped like ${MUTATION_VALIDATION_EXAMPLE}. A run that only read files still names the read and cites what it saw.`;
|
|
479
|
+
}
|
|
480
|
+
return `Mutation result must carry typed validation results: every validations entry is shaped like ${MUTATION_VALIDATION_EXAMPLE}, with a string name, a boolean passed, a string evidence, and no other keys.`;
|
|
481
|
+
}
|
|
430
482
|
function validateMutation(contract, input) {
|
|
431
483
|
const parsed = parseJson(input.output);
|
|
432
484
|
if (!parsed.ok) return failure(contract, "unmeasured", parsed.reason);
|
|
@@ -437,8 +489,7 @@ function validateMutation(contract, input) {
|
|
|
437
489
|
const authorship = validateAuthorship(value);
|
|
438
490
|
if (authorship !== null) return failure(contract, "unmeasured", authorship);
|
|
439
491
|
const validations = parseChecks(value.validations);
|
|
440
|
-
if (validations === null)
|
|
441
|
-
return failure(contract, "unmeasured", "Mutation result must carry typed validation results");
|
|
492
|
+
if (validations === null) return failure(contract, "unmeasured", mutationValidationsReason(value.validations));
|
|
442
493
|
const reportedFailure = !validations.every((check) => check.passed);
|
|
443
494
|
const effects = input.observedRunEffects;
|
|
444
495
|
if (effects === void 0) return success(contract, reportedFailure ? "fail" : "pass", value);
|
|
@@ -616,6 +667,36 @@ function resultContractRepairMessage(input) {
|
|
|
616
667
|
}
|
|
617
668
|
return lines.join("\n");
|
|
618
669
|
}
|
|
670
|
+
var RESULT_CONTRACT_REPAIR_TOOL = "result_contract";
|
|
671
|
+
function resultContractRepairMessages(input, origin) {
|
|
672
|
+
const id = `clio-result-contract-repair-${input.attempt}`;
|
|
673
|
+
const timestamp = Date.now();
|
|
674
|
+
return [
|
|
675
|
+
{
|
|
676
|
+
role: "assistant",
|
|
677
|
+
content: [{ type: "toolCall", id, name: RESULT_CONTRACT_REPAIR_TOOL, arguments: {} }],
|
|
678
|
+
stopReason: "toolUse",
|
|
679
|
+
usage: {
|
|
680
|
+
input: 0,
|
|
681
|
+
output: 0,
|
|
682
|
+
cacheRead: 0,
|
|
683
|
+
cacheWrite: 0,
|
|
684
|
+
totalTokens: 0,
|
|
685
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
686
|
+
},
|
|
687
|
+
...origin,
|
|
688
|
+
timestamp
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
role: "toolResult",
|
|
692
|
+
toolCallId: id,
|
|
693
|
+
toolName: RESULT_CONTRACT_REPAIR_TOOL,
|
|
694
|
+
content: [{ type: "text", text: resultContractRepairMessage(input) }],
|
|
695
|
+
isError: true,
|
|
696
|
+
timestamp
|
|
697
|
+
}
|
|
698
|
+
];
|
|
699
|
+
}
|
|
619
700
|
function parseResultContract(value, sourcePath) {
|
|
620
701
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
621
702
|
throw new Error(`agent recipe: ${sourcePath}: resultContract must be an object`);
|
|
@@ -650,648 +731,384 @@ function parseResultContract(value, sourcePath) {
|
|
|
650
731
|
return { kind: record.kind };
|
|
651
732
|
}
|
|
652
733
|
|
|
653
|
-
// src/domains/
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
{
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
);
|
|
675
|
-
var RegistrySchema = Type.Object(
|
|
676
|
-
{
|
|
677
|
-
version: Type.Literal(1),
|
|
678
|
-
commands: Type.Record(Type.String({ minLength: 1 }), CommandSchema, { minProperties: 1 })
|
|
679
|
-
},
|
|
680
|
-
{ additionalProperties: false }
|
|
681
|
-
);
|
|
682
|
-
var COMMAND_ID_RE = /^[a-z0-9][a-z0-9._-]{0,63}$/u;
|
|
683
|
-
var ENV_NAME_RE = /^[A-Z_][A-Z0-9_]*$/u;
|
|
684
|
-
function fleetCommandsPath(cwd) {
|
|
685
|
-
return join(cwd, ".clio-coder", "fleets", "commands.yaml");
|
|
686
|
-
}
|
|
687
|
-
function firstSchemaError(value) {
|
|
688
|
-
if (Value.Check(RegistrySchema, value)) return null;
|
|
689
|
-
const first = [...Value.Errors(RegistrySchema, value)][0];
|
|
690
|
-
return first ? `${first.instancePath || "(root)"}: ${first.message}` : "command registry failed validation";
|
|
691
|
-
}
|
|
692
|
-
function checkCwd(id, value, sourcePath) {
|
|
693
|
-
if (isAbsolute(value)) {
|
|
694
|
-
throw new Error(`fleet commands ${sourcePath}: command '${id}' cwd must be workspace-relative`);
|
|
695
|
-
}
|
|
696
|
-
const normalized = normalize(value);
|
|
697
|
-
if (normalized === ".." || normalized.startsWith(`..${"/"}`) || normalized.split(/[\\/]/u).includes("..")) {
|
|
698
|
-
throw new Error(`fleet commands ${sourcePath}: command '${id}' cwd escapes the workspace`);
|
|
699
|
-
}
|
|
700
|
-
return normalized === "." ? "" : normalized;
|
|
701
|
-
}
|
|
702
|
-
function parseFleetCommands(raw, sourcePath) {
|
|
703
|
-
let parsed;
|
|
704
|
-
try {
|
|
705
|
-
parsed = yaml.parse(raw);
|
|
706
|
-
} catch (err) {
|
|
707
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
708
|
-
throw new Error(`fleet commands ${sourcePath}: invalid YAML (${reason})`);
|
|
709
|
-
}
|
|
710
|
-
const schemaError = firstSchemaError(parsed);
|
|
711
|
-
if (schemaError !== null) throw new Error(`fleet commands ${sourcePath}: ${schemaError}`);
|
|
712
|
-
const registry = parsed;
|
|
713
|
-
const commands = /* @__PURE__ */ new Map();
|
|
714
|
-
for (const [id, entry] of Object.entries(registry.commands)) {
|
|
715
|
-
if (!COMMAND_ID_RE.test(id)) {
|
|
716
|
-
throw new Error(`fleet commands ${sourcePath}: command id '${id}' must match ${COMMAND_ID_RE.source}`);
|
|
717
|
-
}
|
|
718
|
-
const executable = entry.argv[0] ?? "";
|
|
719
|
-
if (executable.trim().length === 0) {
|
|
720
|
-
throw new Error(`fleet commands ${sourcePath}: command '${id}' has an empty executable`);
|
|
721
|
-
}
|
|
722
|
-
for (const name of entry.env ?? []) {
|
|
723
|
-
if (!ENV_NAME_RE.test(name)) {
|
|
724
|
-
throw new Error(`fleet commands ${sourcePath}: command '${id}' env name '${name}' is not a variable name`);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
commands.set(id, {
|
|
728
|
-
id,
|
|
729
|
-
argv: [...entry.argv],
|
|
730
|
-
cwd: entry.cwd === void 0 ? "" : checkCwd(id, entry.cwd, sourcePath),
|
|
731
|
-
timeoutMs: entry.timeoutMs ?? FLEET_COMMAND_DEFAULT_TIMEOUT_MS,
|
|
732
|
-
env: [...entry.env ?? []],
|
|
733
|
-
description: entry.description ?? ""
|
|
734
|
-
});
|
|
734
|
+
// src/domains/safety/finish-contract.ts
|
|
735
|
+
init_esm_shims();
|
|
736
|
+
var FINISH_CONTRACT_ADVISORY_MESSAGE = "[Clio Coder] finish-contract advisory: you changed files this turn without recording validation evidence or an explicit limitation. Run a verification command or state what could not be verified.";
|
|
737
|
+
var DEFAULT_RECENT_ENTRY_LIMIT = 80;
|
|
738
|
+
var LIMITATION_PATTERNS = [
|
|
739
|
+
/\b(?:blocked by|blocker|blockers|unable to|not able to|could not|couldn't|cannot|can't)\b/i,
|
|
740
|
+
/\b(?:did not|didn't|have not|haven't|has not|hasn't|was not able|wasn't able)\b/i,
|
|
741
|
+
/\b(?:not complete|incomplete)\b/i,
|
|
742
|
+
/\b(?:not|un)(?:\s|-)?(?:validated|verified|tested)\b/i,
|
|
743
|
+
/^\s*Tests\s*:\s*(?:not run|not executed|not available|failed|blocked|skipped)\b/im,
|
|
744
|
+
/^\s*Known gaps?\s*:\s*(?!\s*(?:none|no\b|n\/a|not applicable)\b).+/im,
|
|
745
|
+
/\bremaining(?:\s+\w+){0,3}\s+(?:work|issue|issues|gap|gaps|blocker|blockers)\b/i
|
|
746
|
+
];
|
|
747
|
+
function assessFinishContract(input) {
|
|
748
|
+
const assistantText = input.assistantText.trim();
|
|
749
|
+
const sessionEntries = input.sessionEntries ?? [];
|
|
750
|
+
const assistantTurnId = input.assistantTurnId ?? null;
|
|
751
|
+
const window = recentEntries(sessionEntries, assistantTurnId, input.recentEntryLimit ?? DEFAULT_RECENT_ENTRY_LIMIT);
|
|
752
|
+
const mutatedPaths = mutatingReceipts(window);
|
|
753
|
+
if (mutatedPaths.length === 0) {
|
|
754
|
+
return { kind: "ok", reason: "no_mutation", evidence: [], mutatedPaths };
|
|
735
755
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
const path7 = fleetCommandsPath(cwd);
|
|
740
|
-
if (!existsSync(path7)) return null;
|
|
741
|
-
return parseFleetCommands(readFileSync(path7, "utf8"), path7);
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// src/domains/agents/fleet-contract.ts
|
|
745
|
-
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "node:fs";
|
|
746
|
-
import { basename, join as join2 } from "node:path";
|
|
747
|
-
import { Type as Type2 } from "typebox";
|
|
748
|
-
import { Value as Value2 } from "typebox/value";
|
|
749
|
-
|
|
750
|
-
// src/domains/agents/frontmatter.ts
|
|
751
|
-
import yaml2 from "yaml";
|
|
752
|
-
function parseFrontmatter(raw, sourcePath) {
|
|
753
|
-
const opening = raw.match(/^---\r?\n/);
|
|
754
|
-
if (!opening) {
|
|
755
|
-
throw new Error(`frontmatter: ${sourcePath}: missing YAML frontmatter opening delimiter`);
|
|
756
|
-
}
|
|
757
|
-
const closeRegex = /\r?\n---(?:\r?\n|$)/g;
|
|
758
|
-
closeRegex.lastIndex = opening[0].length;
|
|
759
|
-
const closing = closeRegex.exec(raw);
|
|
760
|
-
if (!closing) {
|
|
761
|
-
throw new Error(`frontmatter: ${sourcePath}: missing YAML frontmatter closing delimiter`);
|
|
762
|
-
}
|
|
763
|
-
const frontmatterText = raw.slice(opening[0].length, closing.index);
|
|
764
|
-
const body = raw.slice(closing.index + closing[0].length);
|
|
765
|
-
let parsed;
|
|
766
|
-
try {
|
|
767
|
-
parsed = yaml2.parse(frontmatterText);
|
|
768
|
-
} catch (err) {
|
|
769
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
770
|
-
throw new Error(`frontmatter: ${sourcePath}: invalid YAML frontmatter (${reason})`);
|
|
756
|
+
const evidence = collectValidationEvidence(window);
|
|
757
|
+
if (evidence.length > 0) {
|
|
758
|
+
return { kind: "ok", reason: "validation_evidence", evidence, mutatedPaths };
|
|
771
759
|
}
|
|
772
|
-
if (
|
|
773
|
-
|
|
760
|
+
if (hasExplicitLimitation(assistantText)) {
|
|
761
|
+
return { kind: "ok", reason: "explicit_limitation", evidence: [], mutatedPaths };
|
|
774
762
|
}
|
|
775
763
|
return {
|
|
776
|
-
|
|
777
|
-
|
|
764
|
+
kind: "engage",
|
|
765
|
+
reason: "unvalidated_mutation",
|
|
766
|
+
message: FINISH_CONTRACT_ADVISORY_MESSAGE,
|
|
767
|
+
evidence: [],
|
|
768
|
+
mutatedPaths
|
|
778
769
|
};
|
|
779
770
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
function normalizeWriteBoundaryEntry(entry) {
|
|
785
|
-
const raw = entry.trim();
|
|
786
|
-
if (raw.length === 0) throw new Error("write boundary: entry must be a non-empty path");
|
|
787
|
-
if (raw.includes("\\")) {
|
|
788
|
-
throw new Error(`write boundary: entry '${entry}' must use '/' separators`);
|
|
789
|
-
}
|
|
790
|
-
if (GLOB_CHARACTERS.test(raw)) {
|
|
791
|
-
throw new Error(`write boundary: entry '${entry}' looks like a glob, which v1 does not support`);
|
|
792
|
-
}
|
|
793
|
-
if (raw.startsWith("/") || /^[A-Za-z]:/u.test(raw)) {
|
|
794
|
-
throw new Error(`write boundary: entry '${entry}' must be repository-relative, not absolute`);
|
|
795
|
-
}
|
|
796
|
-
const subtree = raw.endsWith("/");
|
|
797
|
-
const segments = raw.split("/").filter((segment) => segment.length > 0);
|
|
798
|
-
if (segments.length === 0) {
|
|
799
|
-
throw new Error(`write boundary: entry '${entry}' must name a path inside the repository`);
|
|
800
|
-
}
|
|
801
|
-
for (const segment of segments) {
|
|
802
|
-
if (segment === "..") throw new Error(`write boundary: entry '${entry}' must not contain '..'`);
|
|
803
|
-
if (segment === ".") throw new Error(`write boundary: entry '${entry}' must not contain '.' segments`);
|
|
804
|
-
}
|
|
805
|
-
const joined = segments.join("/");
|
|
806
|
-
return subtree ? `${joined}/` : joined;
|
|
771
|
+
function hasExplicitLimitation(text) {
|
|
772
|
+
const normalized = text.trim();
|
|
773
|
+
if (normalized.length === 0) return false;
|
|
774
|
+
return LIMITATION_PATTERNS.some((pattern) => pattern.test(normalized));
|
|
807
775
|
}
|
|
808
|
-
function
|
|
809
|
-
|
|
810
|
-
|
|
776
|
+
function mutatingReceipts(recent) {
|
|
777
|
+
const mutationCalls = /* @__PURE__ */ new Map();
|
|
778
|
+
const paths = [];
|
|
779
|
+
const seen = /* @__PURE__ */ new Set();
|
|
780
|
+
for (const entry of recent) {
|
|
781
|
+
const bashMutation = bashExecutionMutationPaths(entry);
|
|
782
|
+
if (bashMutation !== null) {
|
|
783
|
+
for (const path5 of bashMutation) pushPath(paths, seen, path5);
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
const call = mutatingToolCall(entry);
|
|
787
|
+
if (call !== null) {
|
|
788
|
+
mutationCalls.set(call.toolCallId, call);
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
const resultId = successfulToolResultId(entry);
|
|
792
|
+
if (resultId !== null) {
|
|
793
|
+
const candidate = mutationCalls.get(resultId);
|
|
794
|
+
if (candidate !== void 0) {
|
|
795
|
+
for (const path5 of candidate.paths) pushPath(paths, seen, path5);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
811
798
|
}
|
|
812
|
-
|
|
813
|
-
return [...normalized].sort();
|
|
814
|
-
}
|
|
815
|
-
function toRepoRelativePosix(path7) {
|
|
816
|
-
return path7.split("\\").join("/");
|
|
817
|
-
}
|
|
818
|
-
function writeBoundaryCovers(boundary, path7) {
|
|
819
|
-
const candidate = toRepoRelativePosix(path7);
|
|
820
|
-
return boundary.some((entry) => entry.endsWith("/") ? candidate.startsWith(entry) : candidate === entry);
|
|
821
|
-
}
|
|
822
|
-
function describeWriteBoundary(boundary) {
|
|
823
|
-
return boundary.length === 0 ? "(nothing: readonly)" : boundary.join(", ");
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
// src/domains/agents/fleet-contract.ts
|
|
827
|
-
var FLEET_WRITE_BOUNDARY_VERSION = 4;
|
|
828
|
-
var FLEET_LOOP_MAX_ATTEMPTS = 5;
|
|
829
|
-
var FleetScopeSchema = Type2.Union([Type2.Literal("readonly"), Type2.Literal("workspace")]);
|
|
830
|
-
function writesSchema(version) {
|
|
831
|
-
return version >= FLEET_WRITE_BOUNDARY_VERSION ? { writes: Type2.Optional(Type2.Array(Type2.String({ minLength: 1 }), { maxItems: WRITE_BOUNDARY_MAX_ENTRIES })) } : {};
|
|
832
|
-
}
|
|
833
|
-
function agentStepSchema(version) {
|
|
834
|
-
return Type2.Object(
|
|
835
|
-
{
|
|
836
|
-
kind: Type2.Optional(Type2.Literal("agent")),
|
|
837
|
-
id: Type2.String({ minLength: 1 }),
|
|
838
|
-
agent: Type2.String({ minLength: 1 }),
|
|
839
|
-
scope: FleetScopeSchema,
|
|
840
|
-
dependencies: Type2.Array(Type2.String({ minLength: 1 })),
|
|
841
|
-
...writesSchema(version)
|
|
842
|
-
},
|
|
843
|
-
{ additionalProperties: false }
|
|
844
|
-
);
|
|
845
|
-
}
|
|
846
|
-
function codeStepSchema(version) {
|
|
847
|
-
return Type2.Object(
|
|
848
|
-
{
|
|
849
|
-
kind: Type2.Literal("code"),
|
|
850
|
-
id: Type2.String({ minLength: 1 }),
|
|
851
|
-
command: Type2.String({ minLength: 1 }),
|
|
852
|
-
scope: FleetScopeSchema,
|
|
853
|
-
dependencies: Type2.Array(Type2.String({ minLength: 1 })),
|
|
854
|
-
...version >= 3 ? { commitFrom: Type2.Optional(Type2.Array(Type2.String({ minLength: 1 }), { minItems: 1 })) } : {},
|
|
855
|
-
...writesSchema(version)
|
|
856
|
-
},
|
|
857
|
-
{ additionalProperties: false }
|
|
858
|
-
);
|
|
859
|
-
}
|
|
860
|
-
function loopStepSchema(version) {
|
|
861
|
-
return Type2.Object(
|
|
862
|
-
{
|
|
863
|
-
kind: Type2.Literal("loop"),
|
|
864
|
-
id: Type2.String({ minLength: 1 }),
|
|
865
|
-
// Required and finite: this is the whole point of the construct.
|
|
866
|
-
maxAttempts: Type2.Integer({ minimum: 1, maximum: FLEET_LOOP_MAX_ATTEMPTS }),
|
|
867
|
-
dependencies: Type2.Array(Type2.String({ minLength: 1 })),
|
|
868
|
-
check: Type2.Union([
|
|
869
|
-
Type2.Object(
|
|
870
|
-
{
|
|
871
|
-
kind: Type2.Literal("code"),
|
|
872
|
-
command: Type2.String({ minLength: 1 }),
|
|
873
|
-
scope: FleetScopeSchema,
|
|
874
|
-
...writesSchema(version)
|
|
875
|
-
},
|
|
876
|
-
{ additionalProperties: false }
|
|
877
|
-
),
|
|
878
|
-
Type2.Object(
|
|
879
|
-
{
|
|
880
|
-
kind: Type2.Literal("agent"),
|
|
881
|
-
agent: Type2.String({ minLength: 1 }),
|
|
882
|
-
scope: FleetScopeSchema,
|
|
883
|
-
...writesSchema(version)
|
|
884
|
-
},
|
|
885
|
-
{ additionalProperties: false }
|
|
886
|
-
)
|
|
887
|
-
]),
|
|
888
|
-
repair: Type2.Object(
|
|
889
|
-
{
|
|
890
|
-
kind: Type2.Optional(Type2.Literal("agent")),
|
|
891
|
-
agent: Type2.String({ minLength: 1 }),
|
|
892
|
-
scope: FleetScopeSchema,
|
|
893
|
-
...writesSchema(version)
|
|
894
|
-
},
|
|
895
|
-
{ additionalProperties: false }
|
|
896
|
-
)
|
|
897
|
-
},
|
|
898
|
-
{ additionalProperties: false }
|
|
899
|
-
);
|
|
900
|
-
}
|
|
901
|
-
function stepSchema(version) {
|
|
902
|
-
if (version === 1) return agentStepSchema(1);
|
|
903
|
-
if (version === 2) return Type2.Union([agentStepSchema(2), codeStepSchema(2)]);
|
|
904
|
-
return Type2.Union([agentStepSchema(version), codeStepSchema(version), loopStepSchema(version)]);
|
|
905
|
-
}
|
|
906
|
-
function frontmatterSchema(version) {
|
|
907
|
-
return Type2.Object(
|
|
908
|
-
{
|
|
909
|
-
version: Type2.Literal(version),
|
|
910
|
-
name: Type2.String({ minLength: 1 }),
|
|
911
|
-
description: Type2.Optional(Type2.String()),
|
|
912
|
-
steps: Type2.Array(stepSchema(version), { minItems: 1 }),
|
|
913
|
-
maxWorkers: Type2.Integer({ minimum: 1 }),
|
|
914
|
-
budgetUsd: Type2.Optional(Type2.Number()),
|
|
915
|
-
onFailure: Type2.Union([Type2.Literal("stop"), Type2.Literal("continue")])
|
|
916
|
-
},
|
|
917
|
-
{ additionalProperties: false }
|
|
918
|
-
);
|
|
799
|
+
return paths;
|
|
919
800
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
};
|
|
926
|
-
function contractVersion(frontmatter) {
|
|
927
|
-
const value = frontmatter.version;
|
|
928
|
-
return value === 1 || value === 2 || value === 3 || value === 4 ? value : null;
|
|
929
|
-
}
|
|
930
|
-
function firstSchemaError2(frontmatter, version) {
|
|
931
|
-
const schema = SCHEMAS[version];
|
|
932
|
-
if (Value2.Check(schema, frontmatter)) return null;
|
|
933
|
-
const first = [...Value2.Errors(schema, frontmatter)][0];
|
|
934
|
-
return first ? `${first.instancePath || "(root)"}: ${first.message}` : "front matter failed validation";
|
|
935
|
-
}
|
|
936
|
-
function fleetsDir(cwd) {
|
|
937
|
-
return join2(cwd, ".clio-coder", "fleets");
|
|
938
|
-
}
|
|
939
|
-
function normalizedWrites(writes) {
|
|
940
|
-
return writes === void 0 ? {} : { writes: normalizeWriteBoundary(writes) };
|
|
941
|
-
}
|
|
942
|
-
function normalizeStep(step) {
|
|
943
|
-
if (step.kind === "loop") {
|
|
944
|
-
const check = step.check;
|
|
945
|
-
const repair = step.repair;
|
|
946
|
-
return {
|
|
947
|
-
kind: "loop",
|
|
948
|
-
id: step.id,
|
|
949
|
-
maxAttempts: step.maxAttempts ?? 0,
|
|
950
|
-
dependencies: [...step.dependencies],
|
|
951
|
-
check: check.kind === "code" ? { kind: "code", command: check.command ?? "", scope: check.scope, ...normalizedWrites(check.writes) } : { kind: "agent", agent: check.agent ?? "", scope: check.scope, ...normalizedWrites(check.writes) },
|
|
952
|
-
repair: { kind: "agent", agent: repair.agent, scope: repair.scope, ...normalizedWrites(repair.writes) }
|
|
953
|
-
};
|
|
954
|
-
}
|
|
955
|
-
if (step.kind === "code") {
|
|
956
|
-
return {
|
|
957
|
-
kind: "code",
|
|
958
|
-
id: step.id,
|
|
959
|
-
command: step.command ?? "",
|
|
960
|
-
scope: step.scope,
|
|
961
|
-
dependencies: [...step.dependencies],
|
|
962
|
-
...step.commitFrom !== void 0 ? { commitFrom: [...step.commitFrom] } : {},
|
|
963
|
-
...normalizedWrites(step.writes)
|
|
964
|
-
};
|
|
801
|
+
function mutationPathsForTool(toolName, args) {
|
|
802
|
+
if (toolName === ToolNames.Bash) {
|
|
803
|
+
const command = typeof args?.command === "string" ? args.command : null;
|
|
804
|
+
if (command === null) return [];
|
|
805
|
+
return [...extractCommandWriteTargets(command), ...extractCommandDeleteTargets(command)];
|
|
965
806
|
}
|
|
966
|
-
return
|
|
967
|
-
kind: "agent",
|
|
968
|
-
id: step.id,
|
|
969
|
-
agent: step.agent ?? "",
|
|
970
|
-
scope: step.scope,
|
|
971
|
-
dependencies: [...step.dependencies],
|
|
972
|
-
...normalizedWrites(step.writes)
|
|
973
|
-
};
|
|
807
|
+
return toolMutationPaths(toolName, args);
|
|
974
808
|
}
|
|
975
|
-
function
|
|
976
|
-
|
|
809
|
+
function mutatingToolCall(entry) {
|
|
810
|
+
const record = asRecord(entry);
|
|
811
|
+
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
812
|
+
const payload = asRecord(record.payload);
|
|
813
|
+
if (payload === null) return null;
|
|
814
|
+
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
815
|
+
if (toolName === null) return null;
|
|
816
|
+
const args = asRecord(payload.args ?? payload.arguments ?? payload.input) ?? void 0;
|
|
817
|
+
const paths = mutationPathsForTool(toolName, args);
|
|
818
|
+
if (paths.length === 0) return null;
|
|
819
|
+
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
820
|
+
if (toolCallId === null) return null;
|
|
821
|
+
return { toolCallId, paths };
|
|
977
822
|
}
|
|
978
|
-
function
|
|
979
|
-
|
|
823
|
+
function bashExecutionMutationPaths(entry) {
|
|
824
|
+
const record = asRecord(entry);
|
|
825
|
+
if (record?.kind !== "bashExecution") return null;
|
|
826
|
+
if (typeof record.command !== "string") return null;
|
|
827
|
+
if (record.cancelled === true || record.exitCode !== 0) return null;
|
|
828
|
+
return [...extractCommandWriteTargets(record.command), ...extractCommandDeleteTargets(record.command)];
|
|
980
829
|
}
|
|
981
|
-
function
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
if (declared.has(step.id)) throw new Error(`fleet contract ${contract.path}: duplicate step id '${step.id}'`);
|
|
997
|
-
declared.add(step.id);
|
|
998
|
-
}
|
|
999
|
-
const owners = /* @__PURE__ */ new Map();
|
|
1000
|
-
for (const step of contract.steps) {
|
|
1001
|
-
if (step.kind !== "loop") continue;
|
|
1002
|
-
for (const [generated, owner] of occupiedIds({ steps: [step] })) {
|
|
1003
|
-
if (generated === step.id) continue;
|
|
1004
|
-
if (declared.has(generated)) {
|
|
1005
|
-
throw new Error(
|
|
1006
|
-
`fleet contract ${contract.path}: step id '${generated}' collides with an id loop '${owner}' generates`
|
|
1007
|
-
);
|
|
1008
|
-
}
|
|
1009
|
-
owners.set(generated, owner);
|
|
830
|
+
function pushPath(paths, seen, path5) {
|
|
831
|
+
if (path5.length === 0 || seen.has(path5)) return;
|
|
832
|
+
seen.add(path5);
|
|
833
|
+
paths.push(path5);
|
|
834
|
+
}
|
|
835
|
+
function collectValidationEvidence(recent) {
|
|
836
|
+
const evidence = [];
|
|
837
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
838
|
+
const dispatchCalls = /* @__PURE__ */ new Map();
|
|
839
|
+
const seen = /* @__PURE__ */ new Set();
|
|
840
|
+
for (const entry of recent) {
|
|
841
|
+
const protectedArtifact = protectedArtifactEvidence(entry);
|
|
842
|
+
if (protectedArtifact !== null) {
|
|
843
|
+
pushEvidence(evidence, seen, protectedArtifact);
|
|
844
|
+
continue;
|
|
1010
845
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
if (!declared.has(dependency)) {
|
|
1016
|
-
throw new Error(`fleet contract ${contract.path}: step '${step.id}' has unknown dependency '${dependency}'`);
|
|
1017
|
-
}
|
|
846
|
+
const call = bashValidationCall(entry);
|
|
847
|
+
if (call !== null) {
|
|
848
|
+
toolCalls.set(call.toolCallId, call);
|
|
849
|
+
continue;
|
|
1018
850
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
const ready = contract.steps.filter(
|
|
1024
|
-
(step) => remaining.has(step.id) && step.dependencies.every((dependency) => settled.has(dependency))
|
|
1025
|
-
);
|
|
1026
|
-
if (ready.length === 0) {
|
|
1027
|
-
throw new Error(`fleet contract ${contract.path}: dependency cycle among steps ${[...remaining].sort().join(", ")}`);
|
|
851
|
+
const typedValidationCall = validationToolCall(entry);
|
|
852
|
+
if (typedValidationCall !== null) {
|
|
853
|
+
toolCalls.set(typedValidationCall.toolCallId, typedValidationCall);
|
|
854
|
+
continue;
|
|
1028
855
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
856
|
+
const dispatchCall = dispatchEvidenceCall(entry);
|
|
857
|
+
if (dispatchCall !== null) {
|
|
858
|
+
dispatchCalls.set(dispatchCall.toolCallId, dispatchCall);
|
|
859
|
+
continue;
|
|
1032
860
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
throw new Error(`fleet contract ${contract.path}: commit step '${step.id}' names unknown source '${source}'`);
|
|
1041
|
-
}
|
|
1042
|
-
if (target.kind === "code") {
|
|
1043
|
-
throw new Error(
|
|
1044
|
-
`fleet contract ${contract.path}: commit step '${step.id}' source '${source}' is a code step and authors no commit message`
|
|
1045
|
-
);
|
|
861
|
+
const resultId = successfulToolResultId(entry);
|
|
862
|
+
if (resultId !== null) {
|
|
863
|
+
const dispatchCandidate = dispatchCalls.get(resultId);
|
|
864
|
+
const dispatchReceipt = dispatchReceiptEvidence(entry, dispatchCandidate);
|
|
865
|
+
if (dispatchReceipt !== null) {
|
|
866
|
+
pushEvidence(evidence, seen, dispatchReceipt);
|
|
867
|
+
continue;
|
|
1046
868
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
);
|
|
869
|
+
const candidate = toolCalls.get(resultId);
|
|
870
|
+
if (candidate !== void 0) {
|
|
871
|
+
pushEvidence(evidence, seen, validationEvidence(candidate));
|
|
1051
872
|
}
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
function fleetStepWriteBoundary(version, scope, writes) {
|
|
1056
|
-
if (version < FLEET_WRITE_BOUNDARY_VERSION) return void 0;
|
|
1057
|
-
return scope === "readonly" ? [] : [...writes ?? []];
|
|
1058
|
-
}
|
|
1059
|
-
function fleetStepBoundaries(contract) {
|
|
1060
|
-
const boundaries = [];
|
|
1061
|
-
const add = (id, scope, writes) => {
|
|
1062
|
-
boundaries.push({ id, scope, writes: fleetStepWriteBoundary(contract.version, scope, writes) });
|
|
1063
|
-
};
|
|
1064
|
-
for (const step of contract.steps) {
|
|
1065
|
-
if (step.kind === "loop") {
|
|
1066
|
-
add(`${step.id}.check`, step.check.scope, step.check.writes);
|
|
1067
|
-
add(`${step.id}.repair`, step.repair.scope, step.repair.writes);
|
|
1068
873
|
continue;
|
|
1069
874
|
}
|
|
1070
|
-
|
|
875
|
+
const bashExecution = bashExecutionEvidence(entry);
|
|
876
|
+
if (bashExecution !== null) pushEvidence(evidence, seen, bashExecution);
|
|
1071
877
|
}
|
|
1072
|
-
return
|
|
878
|
+
return evidence;
|
|
1073
879
|
}
|
|
1074
|
-
function
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
for (const step of contract.steps) {
|
|
1084
|
-
const declared = step.kind === "loop" ? [
|
|
1085
|
-
{ id: `${step.id}.check`, scope: step.check.scope, writes: step.check.writes },
|
|
1086
|
-
{ id: `${step.id}.repair`, scope: step.repair.scope, writes: step.repair.writes }
|
|
1087
|
-
] : [{ id: step.id, scope: step.scope, writes: step.writes }];
|
|
1088
|
-
for (const position of declared) {
|
|
1089
|
-
if (position.scope === "readonly" && position.writes !== void 0) {
|
|
1090
|
-
throw new Error(
|
|
1091
|
-
`fleet contract ${contract.path}: step '${position.id}' is 'readonly', which is the empty allowlist; remove its 'writes' or give it scope 'workspace'`
|
|
1092
|
-
);
|
|
1093
|
-
}
|
|
880
|
+
function recentEntries(entries, assistantTurnId, recentEntryLimit) {
|
|
881
|
+
const boundedLimit = Number.isFinite(recentEntryLimit) && recentEntryLimit > 0 ? Math.floor(recentEntryLimit) : DEFAULT_RECENT_ENTRY_LIMIT;
|
|
882
|
+
const assistantIndex = assistantTurnId === null ? -1 : entries.findIndex((entry) => turnIdOf(entry) === assistantTurnId);
|
|
883
|
+
const endExclusive = assistantIndex >= 0 ? assistantIndex : entries.length;
|
|
884
|
+
let startInclusive = Math.max(0, endExclusive - boundedLimit);
|
|
885
|
+
for (let index = endExclusive - 1; index >= startInclusive; index -= 1) {
|
|
886
|
+
if (isUserMessageEntry(entries[index])) {
|
|
887
|
+
startInclusive = index + 1;
|
|
888
|
+
break;
|
|
1094
889
|
}
|
|
1095
890
|
}
|
|
891
|
+
return entries.slice(startInclusive, endExclusive);
|
|
1096
892
|
}
|
|
1097
|
-
function
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
return closure;
|
|
1115
|
-
}
|
|
1116
|
-
function parseFleetContract(raw, sourcePath) {
|
|
1117
|
-
const { frontmatter, body } = parseFrontmatter(raw, sourcePath);
|
|
1118
|
-
const version = contractVersion(frontmatter);
|
|
1119
|
-
if (version === null) {
|
|
1120
|
-
throw new Error(
|
|
1121
|
-
`fleet contract ${sourcePath}: version must be 1 (agent steps), 2 (agent and code steps), 3 (adds bounded loops and commit steps), or 4 (adds enforced write boundaries)`
|
|
1122
|
-
);
|
|
1123
|
-
}
|
|
1124
|
-
if (version < FLEET_WRITE_BOUNDARY_VERSION) assertNoWritesBefore(frontmatter, sourcePath, version);
|
|
1125
|
-
const schemaError = firstSchemaError2(frontmatter, version);
|
|
1126
|
-
if (schemaError !== null) {
|
|
1127
|
-
throw new Error(`fleet contract ${sourcePath}: ${schemaError}`);
|
|
1128
|
-
}
|
|
1129
|
-
const fm = frontmatter;
|
|
1130
|
-
if (fm.budgetUsd !== void 0 && !(fm.budgetUsd > 0)) {
|
|
1131
|
-
throw new Error(`fleet contract ${sourcePath}: budgetUsd must be a positive number`);
|
|
1132
|
-
}
|
|
1133
|
-
const trimmedBody = body.trim();
|
|
1134
|
-
if (trimmedBody.length === 0) {
|
|
1135
|
-
throw new Error(`fleet contract ${sourcePath}: prompt body is empty`);
|
|
1136
|
-
}
|
|
1137
|
-
const contract = {
|
|
1138
|
-
version,
|
|
1139
|
-
name: fm.name,
|
|
1140
|
-
description: fm.description ?? "",
|
|
1141
|
-
steps: fm.steps.map(normalizeStep),
|
|
1142
|
-
maxWorkers: fm.maxWorkers,
|
|
1143
|
-
budgetUsd: fm.budgetUsd ?? null,
|
|
1144
|
-
onFailure: fm.onFailure,
|
|
1145
|
-
body: trimmedBody,
|
|
1146
|
-
path: sourcePath
|
|
893
|
+
function bashValidationCall(entry) {
|
|
894
|
+
const record = asRecord(entry);
|
|
895
|
+
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
896
|
+
const payload = asRecord(record.payload);
|
|
897
|
+
if (payload === null) return null;
|
|
898
|
+
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
899
|
+
if (toolName !== "bash") return null;
|
|
900
|
+
const args = asRecord(payload.args ?? payload.arguments ?? payload.input);
|
|
901
|
+
const command = typeof args?.command === "string" ? args.command : null;
|
|
902
|
+
if (command === null) return null;
|
|
903
|
+
const detected = detectValidationCommand(command);
|
|
904
|
+
if (detected.kind !== "validation") return null;
|
|
905
|
+
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
906
|
+
if (toolCallId === null) return null;
|
|
907
|
+
const candidate = {
|
|
908
|
+
toolCallId,
|
|
909
|
+
command: detected.matched
|
|
1147
910
|
};
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
return
|
|
1151
|
-
}
|
|
1152
|
-
function assertNoWritesBefore(frontmatter, sourcePath, version) {
|
|
1153
|
-
const steps = Array.isArray(frontmatter.steps) ? frontmatter.steps : [];
|
|
1154
|
-
const declaresWrites = (value) => typeof value === "object" && value !== null && "writes" in value;
|
|
1155
|
-
for (const step of steps) {
|
|
1156
|
-
const raw = step;
|
|
1157
|
-
if (declaresWrites(raw) || declaresWrites(raw.check) || declaresWrites(raw.repair)) {
|
|
1158
|
-
throw new Error(
|
|
1159
|
-
`fleet contract ${sourcePath}: 'writes' requires contract version ${FLEET_WRITE_BOUNDARY_VERSION}; this contract declares version ${version}, where the declaration would not be enforced`
|
|
1160
|
-
);
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
function fleetCodeSteps(contract) {
|
|
1165
|
-
const steps = [];
|
|
1166
|
-
for (const step of contract.steps) {
|
|
1167
|
-
if (step.kind === "code") steps.push({ id: step.id, command: step.command });
|
|
1168
|
-
else if (step.kind === "loop" && step.check.kind === "code") {
|
|
1169
|
-
steps.push({ id: fleetLoopCheckStepId(step.id, 1), command: step.check.command });
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
return steps;
|
|
911
|
+
const turnId = turnIdOf(entry);
|
|
912
|
+
if (turnId !== null) candidate.turnId = turnId;
|
|
913
|
+
return candidate;
|
|
1173
914
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
const
|
|
1190
|
-
if (
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
);
|
|
915
|
+
function dispatchEvidenceCall(entry) {
|
|
916
|
+
const record = asRecord(entry);
|
|
917
|
+
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
918
|
+
const payload = asRecord(record.payload);
|
|
919
|
+
if (payload === null) return null;
|
|
920
|
+
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
921
|
+
if (toolName !== "dispatch") return null;
|
|
922
|
+
const args = asRecord(payload.args ?? payload.arguments ?? payload.input);
|
|
923
|
+
const { agentId, task } = dispatchCallDescriptor(args);
|
|
924
|
+
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
925
|
+
if (toolCallId === null) return null;
|
|
926
|
+
const candidate = {
|
|
927
|
+
toolCallId,
|
|
928
|
+
command: `agent=${agentId}${task.length > 0 ? ` task=${task}` : ""}`
|
|
929
|
+
};
|
|
930
|
+
const turnId = turnIdOf(entry);
|
|
931
|
+
if (turnId !== null) candidate.turnId = turnId;
|
|
932
|
+
return candidate;
|
|
933
|
+
}
|
|
934
|
+
function dispatchCallDescriptor(args) {
|
|
935
|
+
const defaultAgent = stringFromFirst(args ?? {}, ["agent", "agent_id", "agentId"]);
|
|
936
|
+
const tasks = Array.isArray(args?.tasks) ? args.tasks : null;
|
|
937
|
+
if (tasks !== null && tasks.length > 0) {
|
|
938
|
+
const first = tasks[0];
|
|
939
|
+
if (typeof first === "string") {
|
|
940
|
+
return { agentId: defaultAgent ?? "coder", task: first.trim() };
|
|
1200
941
|
}
|
|
942
|
+
const firstRecord = asRecord(first);
|
|
943
|
+
const itemAgent = firstRecord === null ? null : stringFromFirst(firstRecord, ["agent", "agent_id", "agentId"]);
|
|
944
|
+
const itemTask = typeof firstRecord?.task === "string" ? firstRecord.task.trim() : "";
|
|
945
|
+
return { agentId: itemAgent ?? defaultAgent ?? "coder", task: itemTask };
|
|
1201
946
|
}
|
|
947
|
+
const singleTask = typeof args?.task === "string" ? args.task.trim() : "";
|
|
948
|
+
return { agentId: defaultAgent ?? "coder", task: singleTask };
|
|
1202
949
|
}
|
|
1203
|
-
function
|
|
1204
|
-
|
|
950
|
+
function validationToolCall(entry) {
|
|
951
|
+
const record = asRecord(entry);
|
|
952
|
+
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
953
|
+
const payload = asRecord(record.payload);
|
|
954
|
+
if (payload === null) return null;
|
|
955
|
+
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
956
|
+
if (toolName === null) return null;
|
|
957
|
+
const summary = typedValidationSummary(toolName, payload);
|
|
958
|
+
if (summary === null) return null;
|
|
959
|
+
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
960
|
+
if (toolCallId === null) return null;
|
|
961
|
+
const candidate = {
|
|
962
|
+
toolCallId,
|
|
963
|
+
command: summary
|
|
964
|
+
};
|
|
965
|
+
const turnId = turnIdOf(entry);
|
|
966
|
+
if (turnId !== null) candidate.turnId = turnId;
|
|
967
|
+
return candidate;
|
|
1205
968
|
}
|
|
1206
|
-
function
|
|
1207
|
-
const
|
|
1208
|
-
if (
|
|
1209
|
-
|
|
1210
|
-
|
|
969
|
+
function typedValidationSummary(toolName, payload) {
|
|
970
|
+
const args = asRecord(payload.args ?? payload.arguments ?? payload.input);
|
|
971
|
+
if (toolName === "verify") {
|
|
972
|
+
const check = typeof args?.check === "string" ? args.check.trim() : "";
|
|
973
|
+
if (check === "frontend") {
|
|
974
|
+
const path5 = typeof args?.path === "string" && args.path.trim().length > 0 ? args.path.trim() : "artifact";
|
|
975
|
+
return `verify frontend ${path5}`;
|
|
976
|
+
}
|
|
977
|
+
if (!isVerificationScriptName(check)) return null;
|
|
978
|
+
return `npm run ${check}`;
|
|
979
|
+
}
|
|
1211
980
|
return null;
|
|
1212
981
|
}
|
|
1213
|
-
function
|
|
1214
|
-
const
|
|
1215
|
-
if (
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
982
|
+
function successfulToolResultId(entry) {
|
|
983
|
+
const record = asRecord(entry);
|
|
984
|
+
if (record?.kind !== "message" || record.role !== "tool_result") return null;
|
|
985
|
+
const payload = asRecord(record.payload);
|
|
986
|
+
if (payload === null) return null;
|
|
987
|
+
if (payload.isError === true || payload.error === true) return null;
|
|
988
|
+
const result = asRecord(payload.result);
|
|
989
|
+
const details = asRecord(result?.details);
|
|
990
|
+
if (details?.kind === "error") return null;
|
|
991
|
+
return stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]);
|
|
1221
992
|
}
|
|
1222
|
-
function
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
993
|
+
function dispatchReceiptEvidence(entry, candidate) {
|
|
994
|
+
const record = asRecord(entry);
|
|
995
|
+
if (record?.kind !== "message" || record.role !== "tool_result") return null;
|
|
996
|
+
const payload = asRecord(record.payload);
|
|
997
|
+
if (payload === null) return null;
|
|
998
|
+
const toolName = stringFromFirst(payload, ["toolName", "name", "tool"]);
|
|
999
|
+
if (toolName !== null && toolName !== "dispatch") return null;
|
|
1000
|
+
const result = asRecord(payload.result);
|
|
1001
|
+
const details = asRecord(result?.details);
|
|
1002
|
+
if (details === null) return null;
|
|
1003
|
+
const summary = passedDispatchReceiptSummary(details, candidate);
|
|
1004
|
+
if (summary === null) return null;
|
|
1005
|
+
const evidence = {
|
|
1006
|
+
kind: "dispatch_receipt",
|
|
1007
|
+
summary
|
|
1008
|
+
};
|
|
1009
|
+
const turnId = candidate?.turnId ?? turnIdOf(entry);
|
|
1010
|
+
if (turnId !== null && turnId !== void 0) evidence.turnId = turnId;
|
|
1011
|
+
return evidence;
|
|
1229
1012
|
}
|
|
1230
|
-
function
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1013
|
+
function passedDispatchReceiptSummary(details, candidate) {
|
|
1014
|
+
if (Array.isArray(details.runs)) {
|
|
1015
|
+
const runs = details.runs.map(asRecord);
|
|
1016
|
+
if (runs.length === 0 || runs.some((run) => run === null || run.exitCode !== 0)) return null;
|
|
1017
|
+
if (typeof details.failedCount === "number" && details.failedCount !== 0) return null;
|
|
1018
|
+
const first = runs[0];
|
|
1019
|
+
const runId = typeof first?.runId === "string" && first.runId.length > 0 ? first.runId : "unknown";
|
|
1020
|
+
const agentId = dispatchReceiptAgentId(typeof first?.agentId === "string" ? first.agentId : void 0, candidate);
|
|
1021
|
+
const extra = runs.length > 1 ? ` (+${runs.length - 1} more)` : "";
|
|
1022
|
+
return `dispatch receipt passed: run ${runId} agent ${agentId}${extra}`;
|
|
1237
1023
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
];
|
|
1243
|
-
for (const { dir, source } of sources) {
|
|
1244
|
-
for (const file of listDirectory(dir)) {
|
|
1245
|
-
const path7 = join2(dir, file);
|
|
1246
|
-
const name = basename(file, ".md");
|
|
1247
|
-
try {
|
|
1248
|
-
const contract = parseFleetContract(readFileSync2(path7, "utf8"), path7);
|
|
1249
|
-
if (registryError !== null && fleetCodeSteps(contract).length > 0) throw new Error(registryError);
|
|
1250
|
-
validateFleetCommands(contract, registry);
|
|
1251
|
-
listings.set(name, { name, path: path7, source, contract, error: null, needsCommands: null });
|
|
1252
|
-
} catch (err) {
|
|
1253
|
-
listings.set(name, {
|
|
1254
|
-
name,
|
|
1255
|
-
path: path7,
|
|
1256
|
-
source,
|
|
1257
|
-
contract: null,
|
|
1258
|
-
error: err instanceof Error ? err.message : String(err),
|
|
1259
|
-
// A registry this repo never wrote is unfinished setup. A registry
|
|
1260
|
-
// that exists and does not parse, or one missing an id the contract
|
|
1261
|
-
// names, is a real error and stays one.
|
|
1262
|
-
needsCommands: err instanceof FleetCommandRegistryMissingError ? err.commands : null
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1024
|
+
if (details.exitCode === 0) {
|
|
1025
|
+
const runId = typeof details.runId === "string" && details.runId.length > 0 ? details.runId : "unknown";
|
|
1026
|
+
const agentId = dispatchReceiptAgentId(typeof details.agentId === "string" ? details.agentId : void 0, candidate);
|
|
1027
|
+
return `dispatch receipt passed: run ${runId} agent ${agentId}`;
|
|
1266
1028
|
}
|
|
1267
|
-
return
|
|
1029
|
+
return null;
|
|
1268
1030
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
if (
|
|
1281
|
-
|
|
1031
|
+
function dispatchReceiptAgentId(receiptAgentId, candidate) {
|
|
1032
|
+
if (receiptAgentId !== void 0 && receiptAgentId.length > 0) return receiptAgentId;
|
|
1033
|
+
return candidate?.command.match(/^agent=([^\s]+)/)?.[1] ?? "unknown";
|
|
1034
|
+
}
|
|
1035
|
+
function bashExecutionEvidence(entry) {
|
|
1036
|
+
const record = asRecord(entry);
|
|
1037
|
+
if (record?.kind !== "bashExecution") return null;
|
|
1038
|
+
if (typeof record.command !== "string") return null;
|
|
1039
|
+
if (record.cancelled === true) return null;
|
|
1040
|
+
if (record.exitCode !== 0) return null;
|
|
1041
|
+
const detected = detectValidationCommand(record.command);
|
|
1042
|
+
if (detected.kind !== "validation") return null;
|
|
1043
|
+
const evidence = {
|
|
1044
|
+
kind: "validation_command",
|
|
1045
|
+
summary: `validation command passed: ${detected.matched}`
|
|
1046
|
+
};
|
|
1047
|
+
const turnId = turnIdOf(entry);
|
|
1048
|
+
if (turnId !== null) evidence.turnId = turnId;
|
|
1049
|
+
return evidence;
|
|
1050
|
+
}
|
|
1051
|
+
function protectedArtifactEvidence(entry) {
|
|
1052
|
+
const record = asRecord(entry);
|
|
1053
|
+
if (record?.kind !== "protectedArtifact" || record.action !== "protect") return null;
|
|
1054
|
+
const artifact = asRecord(record.artifact);
|
|
1055
|
+
const path5 = typeof artifact?.path === "string" && artifact.path.trim().length > 0 ? artifact.path.trim() : null;
|
|
1056
|
+
if (path5 === null) return null;
|
|
1057
|
+
const evidence = {
|
|
1058
|
+
kind: "protected_artifact",
|
|
1059
|
+
summary: `protected artifact recorded: ${path5}`
|
|
1060
|
+
};
|
|
1061
|
+
const turnId = turnIdOf(entry);
|
|
1062
|
+
if (turnId !== null) evidence.turnId = turnId;
|
|
1063
|
+
return evidence;
|
|
1064
|
+
}
|
|
1065
|
+
function validationEvidence(candidate) {
|
|
1066
|
+
const evidence = {
|
|
1067
|
+
kind: "validation_command",
|
|
1068
|
+
summary: `validation command passed: ${candidate.command}`
|
|
1069
|
+
};
|
|
1070
|
+
if (candidate.turnId !== void 0) evidence.turnId = candidate.turnId;
|
|
1071
|
+
return evidence;
|
|
1072
|
+
}
|
|
1073
|
+
function pushEvidence(evidence, seen, item) {
|
|
1074
|
+
const key = `${item.kind}\0${item.summary}\0${item.turnId ?? ""}`;
|
|
1075
|
+
if (seen.has(key)) return;
|
|
1076
|
+
seen.add(key);
|
|
1077
|
+
evidence.push(item);
|
|
1078
|
+
}
|
|
1079
|
+
function isUserMessageEntry(entry) {
|
|
1080
|
+
const record = asRecord(entry);
|
|
1081
|
+
if (record?.kind !== "message" || record.role !== "user") return false;
|
|
1082
|
+
const payload = asRecord(record.payload);
|
|
1083
|
+
return payload?.synthetic !== true;
|
|
1084
|
+
}
|
|
1085
|
+
function turnIdOf(entry) {
|
|
1086
|
+
const record = asRecord(entry);
|
|
1087
|
+
return typeof record?.turnId === "string" ? record.turnId : null;
|
|
1088
|
+
}
|
|
1089
|
+
function stringFromFirst(record, keys) {
|
|
1090
|
+
for (const key of keys) {
|
|
1091
|
+
const value = record[key];
|
|
1092
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
1282
1093
|
}
|
|
1283
|
-
return
|
|
1094
|
+
return null;
|
|
1095
|
+
}
|
|
1096
|
+
function asRecord(value) {
|
|
1097
|
+
return value !== null && typeof value === "object" ? value : null;
|
|
1284
1098
|
}
|
|
1285
1099
|
|
|
1286
1100
|
// src/domains/safety/autonomy.ts
|
|
1101
|
+
init_esm_shims();
|
|
1287
1102
|
var AUTONOMY_LEVELS = ["read-only", "suggest", "auto-edit", "full-auto"];
|
|
1288
1103
|
var DEFAULT_AUTONOMY_LEVEL = "auto-edit";
|
|
1289
1104
|
function isAutonomyLevel(value) {
|
|
1290
1105
|
return typeof value === "string" && AUTONOMY_LEVELS.includes(value);
|
|
1291
1106
|
}
|
|
1107
|
+
var DEFAULT_AUTONOMY_EXPOSURE = "local";
|
|
1292
1108
|
function mapAutonomy(level, actionClass, options = {}) {
|
|
1293
|
-
if (actionClass === "read") return "allow";
|
|
1294
1109
|
if (actionClass === "git_destructive") return "deny";
|
|
1110
|
+
if ((level === "auto-edit" || level === "suggest") && options.exposure === "outward") return "ask";
|
|
1111
|
+
if (actionClass === "read") return "allow";
|
|
1295
1112
|
if (level === "read-only") return "deny";
|
|
1296
1113
|
if (level === "suggest") return "ask";
|
|
1297
1114
|
switch (actionClass) {
|
|
@@ -1317,7 +1134,17 @@ function autonomyDenyRejection(level, tool, actionClass) {
|
|
|
1317
1134
|
hints: ["Propose the exact edit or command as text.", "The operator can change the level in /settings."]
|
|
1318
1135
|
};
|
|
1319
1136
|
}
|
|
1320
|
-
function autonomyAskRejection(level, tool, actionClass) {
|
|
1137
|
+
function autonomyAskRejection(level, tool, actionClass, exposure = DEFAULT_AUTONOMY_EXPOSURE) {
|
|
1138
|
+
if (exposure === "outward") {
|
|
1139
|
+
return {
|
|
1140
|
+
short: `${tool} needs approval: outward-facing gate at autonomy ${level}`,
|
|
1141
|
+
detail: `The call declared exposure=outward, so answering it publishes or sends something outside the workspace. Autonomy ${level} auto-answers local gates and parks outward-facing ones for the operator.`,
|
|
1142
|
+
hints: [
|
|
1143
|
+
"Approving resumes only this call.",
|
|
1144
|
+
"Autonomy full-auto answers outward gates too; the safety net still applies there."
|
|
1145
|
+
]
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1321
1148
|
return {
|
|
1322
1149
|
short: `${tool} needs approval (${actionClass}) at autonomy ${level}`,
|
|
1323
1150
|
detail: `Autonomy ${level} routes ${actionClass} actions through operator approval. The call is parked until the operator approves it once or cancels it.`,
|
|
@@ -1336,105 +1163,11 @@ function autonomyAskRejection(level, tool, actionClass) {
|
|
|
1336
1163
|
};
|
|
1337
1164
|
}
|
|
1338
1165
|
|
|
1339
|
-
// src/domains/safety/loop-detector.ts
|
|
1340
|
-
var DEFAULT_WINDOW_MS = 3e4;
|
|
1341
|
-
var DEFAULT_MAX_REPEATS = 3;
|
|
1342
|
-
var DEFAULT_KEEP_LAST_ATTEMPTS = 4;
|
|
1343
|
-
function createLoopState(opts) {
|
|
1344
|
-
const windowMs = opts?.windowMs ?? DEFAULT_WINDOW_MS;
|
|
1345
|
-
const maxRepeats = opts?.maxRepeats ?? DEFAULT_MAX_REPEATS;
|
|
1346
|
-
const keepLastAttempts = opts?.keepLastAttempts ?? DEFAULT_KEEP_LAST_ATTEMPTS;
|
|
1347
|
-
return { recent: [], windowMs, maxRepeats, keepLastAttempts };
|
|
1348
|
-
}
|
|
1349
|
-
function hashToolCall(tool, args) {
|
|
1350
|
-
let argPart;
|
|
1351
|
-
try {
|
|
1352
|
-
argPart = canonicalSerialize(args ?? {}, /* @__PURE__ */ new WeakSet());
|
|
1353
|
-
} catch {
|
|
1354
|
-
argPart = "<unrepresentable>";
|
|
1355
|
-
}
|
|
1356
|
-
return `${tool}${argPart}`;
|
|
1357
|
-
}
|
|
1358
|
-
function canonicalSerialize(value, seen) {
|
|
1359
|
-
if (value === null) return "null";
|
|
1360
|
-
if (typeof value === "number") {
|
|
1361
|
-
if (!Number.isFinite(value)) {
|
|
1362
|
-
throw new Error(`canonicalSerialize: non-finite number ${String(value)} is not representable`);
|
|
1363
|
-
}
|
|
1364
|
-
return JSON.stringify(value);
|
|
1365
|
-
}
|
|
1366
|
-
if (typeof value === "string" || typeof value === "boolean") {
|
|
1367
|
-
return JSON.stringify(value);
|
|
1368
|
-
}
|
|
1369
|
-
if (typeof value === "bigint") {
|
|
1370
|
-
throw new Error("canonicalSerialize: bigint is not representable");
|
|
1371
|
-
}
|
|
1372
|
-
if (typeof value === "symbol" || typeof value === "function" || value === void 0) {
|
|
1373
|
-
throw new Error(`canonicalSerialize: ${typeof value} is not representable`);
|
|
1374
|
-
}
|
|
1375
|
-
if (Array.isArray(value)) {
|
|
1376
|
-
if (seen.has(value)) throw new Error("canonicalSerialize: circular reference is not representable");
|
|
1377
|
-
seen.add(value);
|
|
1378
|
-
try {
|
|
1379
|
-
const parts = [];
|
|
1380
|
-
for (let i = 0; i < value.length; i++) {
|
|
1381
|
-
if (!(i in value) || value[i] === void 0) {
|
|
1382
|
-
parts.push("null");
|
|
1383
|
-
continue;
|
|
1384
|
-
}
|
|
1385
|
-
parts.push(canonicalSerialize(value[i], seen));
|
|
1386
|
-
}
|
|
1387
|
-
return `[${parts.join(",")}]`;
|
|
1388
|
-
} finally {
|
|
1389
|
-
seen.delete(value);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
if (typeof value === "object") {
|
|
1393
|
-
if (value instanceof Date) {
|
|
1394
|
-
const jsonValue = value.toJSON();
|
|
1395
|
-
return jsonValue === null ? "null" : JSON.stringify(jsonValue);
|
|
1396
|
-
}
|
|
1397
|
-
if (seen.has(value)) throw new Error("canonicalSerialize: circular reference is not representable");
|
|
1398
|
-
seen.add(value);
|
|
1399
|
-
const obj = value;
|
|
1400
|
-
try {
|
|
1401
|
-
const keys = Object.keys(obj).sort();
|
|
1402
|
-
const parts = [];
|
|
1403
|
-
for (const key of keys) {
|
|
1404
|
-
const child = obj[key];
|
|
1405
|
-
if (child === void 0) continue;
|
|
1406
|
-
parts.push(`${JSON.stringify(key)}:${canonicalSerialize(child, seen)}`);
|
|
1407
|
-
}
|
|
1408
|
-
return `{${parts.join(",")}}`;
|
|
1409
|
-
} finally {
|
|
1410
|
-
seen.delete(value);
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
throw new Error(`canonicalSerialize: unsupported value of type ${typeof value}`);
|
|
1414
|
-
}
|
|
1415
|
-
function observe(state, key, now) {
|
|
1416
|
-
const cutoff = now - state.windowMs;
|
|
1417
|
-
const keepLast = state.keepLastAttempts ?? DEFAULT_KEEP_LAST_ATTEMPTS;
|
|
1418
|
-
const appended = [...state.recent, { key, at: now }];
|
|
1419
|
-
const floorStart = Math.max(0, appended.length - keepLast);
|
|
1420
|
-
const next = appended.filter((entry, index) => index >= floorStart || entry.at >= cutoff);
|
|
1421
|
-
let count = 0;
|
|
1422
|
-
for (const entry of next) {
|
|
1423
|
-
if (entry.key === key) count += 1;
|
|
1424
|
-
}
|
|
1425
|
-
const looping = count >= state.maxRepeats;
|
|
1426
|
-
const newState = {
|
|
1427
|
-
recent: next,
|
|
1428
|
-
windowMs: state.windowMs,
|
|
1429
|
-
maxRepeats: state.maxRepeats
|
|
1430
|
-
};
|
|
1431
|
-
return [newState, { looping, key, count }];
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
1166
|
// src/domains/safety/path-policy.ts
|
|
1167
|
+
init_esm_shims();
|
|
1435
1168
|
import { homedir } from "node:os";
|
|
1436
1169
|
import path2 from "node:path";
|
|
1437
|
-
var ORDERED_KINDS = ["zeroAccessPaths", "readOnlyPaths", "noDeletePaths"];
|
|
1170
|
+
var ORDERED_KINDS = ["zeroAccessPaths", "readOnlyPaths", "noWritePaths", "noDeletePaths"];
|
|
1438
1171
|
function isSameOrDescendant(candidatePath, policyPath) {
|
|
1439
1172
|
const candidate = path2.resolve(candidatePath);
|
|
1440
1173
|
const policy = path2.resolve(policyPath);
|
|
@@ -1453,7 +1186,7 @@ function normalizePolicyEntry(rawPath, root) {
|
|
|
1453
1186
|
}
|
|
1454
1187
|
function blocksOperation(kind, operation) {
|
|
1455
1188
|
if (kind === "zeroAccessPaths") return true;
|
|
1456
|
-
if (kind === "readOnlyPaths") return operation === "write" || operation === "delete";
|
|
1189
|
+
if (kind === "readOnlyPaths" || kind === "noWritePaths") return operation === "write" || operation === "delete";
|
|
1457
1190
|
return operation === "delete";
|
|
1458
1191
|
}
|
|
1459
1192
|
function compilePathPolicy(input, root = process.cwd()) {
|
|
@@ -1534,10 +1267,12 @@ function normalizeSeparators(value) {
|
|
|
1534
1267
|
}
|
|
1535
1268
|
|
|
1536
1269
|
// src/domains/safety/policy-engine.ts
|
|
1270
|
+
init_esm_shims();
|
|
1537
1271
|
import { createHash as createHash3 } from "node:crypto";
|
|
1538
1272
|
import path4 from "node:path";
|
|
1539
1273
|
|
|
1540
1274
|
// src/domains/safety/default-path-policy.ts
|
|
1275
|
+
init_esm_shims();
|
|
1541
1276
|
var DEFAULT_DAMAGE_CONTROL_PATH_POLICY = {
|
|
1542
1277
|
zeroAccessPaths: [
|
|
1543
1278
|
".env",
|
|
@@ -1619,6 +1354,10 @@ var DEFAULT_DAMAGE_CONTROL_PATH_POLICY = {
|
|
|
1619
1354
|
"venv/",
|
|
1620
1355
|
"target/"
|
|
1621
1356
|
],
|
|
1357
|
+
// Another agent's own configuration. Clio reads these roots for skills,
|
|
1358
|
+
// prompts, and rule prose and has no reason to author them, so the guard is
|
|
1359
|
+
// on writes and not only on deletes.
|
|
1360
|
+
noWritePaths: [...foreignAgentDirs()],
|
|
1622
1361
|
noDeletePaths: [
|
|
1623
1362
|
"~/.claude/",
|
|
1624
1363
|
"CLAUDE.md",
|
|
@@ -1636,15 +1375,17 @@ function mergePathPolicyInputs(base, override) {
|
|
|
1636
1375
|
return {
|
|
1637
1376
|
zeroAccessPaths: [...base.zeroAccessPaths ?? [], ...override.zeroAccessPaths ?? []],
|
|
1638
1377
|
readOnlyPaths: [...base.readOnlyPaths ?? [], ...override.readOnlyPaths ?? []],
|
|
1378
|
+
noWritePaths: [...base.noWritePaths ?? [], ...override.noWritePaths ?? []],
|
|
1639
1379
|
noDeletePaths: [...base.noDeletePaths ?? [], ...override.noDeletePaths ?? []]
|
|
1640
1380
|
};
|
|
1641
1381
|
}
|
|
1642
1382
|
|
|
1643
1383
|
// src/domains/safety/project-policy.ts
|
|
1384
|
+
init_esm_shims();
|
|
1385
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
1644
1386
|
import { createHash as createHash2 } from "node:crypto";
|
|
1645
|
-
import { existsSync
|
|
1387
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
1646
1388
|
import path3 from "node:path";
|
|
1647
|
-
import { parse as parseYaml } from "yaml";
|
|
1648
1389
|
var POLICY_RELATIVE_PATH = path3.join(".clio-coder", "safety.yaml");
|
|
1649
1390
|
var ACTION_CLASSES = /* @__PURE__ */ new Set([
|
|
1650
1391
|
"read",
|
|
@@ -1655,7 +1396,7 @@ var ACTION_CLASSES = /* @__PURE__ */ new Set([
|
|
|
1655
1396
|
"git_destructive",
|
|
1656
1397
|
"unknown"
|
|
1657
1398
|
]);
|
|
1658
|
-
var PATH_POLICY_KEYS = ["zeroAccessPaths", "readOnlyPaths", "noDeletePaths"];
|
|
1399
|
+
var PATH_POLICY_KEYS = ["zeroAccessPaths", "readOnlyPaths", "noWritePaths", "noDeletePaths"];
|
|
1659
1400
|
var ROOT_KEYS = /* @__PURE__ */ new Set(["version", "commands", "tasks", "disableDefaultPathPolicy", ...PATH_POLICY_KEYS]);
|
|
1660
1401
|
var COMMAND_KEYS = /* @__PURE__ */ new Set([
|
|
1661
1402
|
"id",
|
|
@@ -1677,7 +1418,7 @@ function projectSafetyPolicyPath(cwd = process.cwd()) {
|
|
|
1677
1418
|
let cursor = path3.resolve(cwd);
|
|
1678
1419
|
while (true) {
|
|
1679
1420
|
const candidate = path3.join(cursor, POLICY_RELATIVE_PATH);
|
|
1680
|
-
if (
|
|
1421
|
+
if (existsSync(candidate)) return candidate;
|
|
1681
1422
|
const parent = path3.dirname(cursor);
|
|
1682
1423
|
if (parent === cursor) return null;
|
|
1683
1424
|
cursor = parent;
|
|
@@ -1698,7 +1439,7 @@ function loadProjectSafetyPolicy(cwd = process.cwd()) {
|
|
|
1698
1439
|
}
|
|
1699
1440
|
let raw;
|
|
1700
1441
|
try {
|
|
1701
|
-
raw =
|
|
1442
|
+
raw = readFileSync(policyPath, "utf8");
|
|
1702
1443
|
} catch (err) {
|
|
1703
1444
|
return {
|
|
1704
1445
|
path: policyPath,
|
|
@@ -1712,7 +1453,7 @@ function loadProjectSafetyPolicy(cwd = process.cwd()) {
|
|
|
1712
1453
|
}
|
|
1713
1454
|
const hash = sha256(raw);
|
|
1714
1455
|
try {
|
|
1715
|
-
const parsed =
|
|
1456
|
+
const parsed = (0, import_yaml.parse)(raw);
|
|
1716
1457
|
return validateProjectSafetyPolicy(parsed, policyPath, hash);
|
|
1717
1458
|
} catch (err) {
|
|
1718
1459
|
return {
|
|
@@ -1948,6 +1689,7 @@ function sha256(raw) {
|
|
|
1948
1689
|
}
|
|
1949
1690
|
|
|
1950
1691
|
// src/domains/safety/rejection-feedback.ts
|
|
1692
|
+
init_esm_shims();
|
|
1951
1693
|
var HARD_BLOCK_CLASSES = ["git_destructive"];
|
|
1952
1694
|
function buildShort(ctx) {
|
|
1953
1695
|
const postureSuffix = ctx.posture ? ` in ${ctx.posture}` : "";
|
|
@@ -2008,11 +1750,13 @@ function formatModelRejection(reason, rejection) {
|
|
|
2008
1750
|
}
|
|
2009
1751
|
|
|
2010
1752
|
// src/domains/safety/rule-pack-loader.ts
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
import {
|
|
1753
|
+
init_esm_shims();
|
|
1754
|
+
var import_yaml2 = __toESM(require_dist(), 1);
|
|
1755
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
1756
|
+
import { join } from "node:path";
|
|
2014
1757
|
|
|
2015
1758
|
// src/domains/safety/rule-compiler.ts
|
|
1759
|
+
init_esm_shims();
|
|
2016
1760
|
function asString(value, ruleId, field) {
|
|
2017
1761
|
if (typeof value !== "string" || value.length === 0) {
|
|
2018
1762
|
throw new Error(`damage-control rule '${ruleId}': expected string for ${field}`);
|
|
@@ -2062,8 +1806,8 @@ function emptyRuleset(version) {
|
|
|
2062
1806
|
return { version, rules: [] };
|
|
2063
1807
|
}
|
|
2064
1808
|
function loadRulePacks(yamlPath) {
|
|
2065
|
-
const raw =
|
|
2066
|
-
const parsed =
|
|
1809
|
+
const raw = readFileSync2(yamlPath, "utf8");
|
|
1810
|
+
const parsed = (0, import_yaml2.parse)(raw);
|
|
2067
1811
|
if (!parsed || typeof parsed !== "object") {
|
|
2068
1812
|
throw new Error(`damage-control rules at ${yamlPath}: expected mapping at document root`);
|
|
2069
1813
|
}
|
|
@@ -2094,7 +1838,7 @@ function loadRulePacks(yamlPath) {
|
|
|
2094
1838
|
return out;
|
|
2095
1839
|
}
|
|
2096
1840
|
function loadDefaultRulePacks() {
|
|
2097
|
-
return loadRulePacks(
|
|
1841
|
+
return loadRulePacks(join(resolvePackageRoot(), "damage-control-rules.yaml"));
|
|
2098
1842
|
}
|
|
2099
1843
|
var cachedPacks = null;
|
|
2100
1844
|
function getCachedDefaultRulePacks() {
|
|
@@ -2132,10 +1876,7 @@ function writeRootTargetPath(call) {
|
|
|
2132
1876
|
if (!WRITE_ROOT_TOOLS.has(call.tool)) return null;
|
|
2133
1877
|
const target = pathArg(call.args);
|
|
2134
1878
|
if (target !== null) return target;
|
|
2135
|
-
if (call.tool === ToolNames.Artifact)
|
|
2136
|
-
const kind = call.args?.kind;
|
|
2137
|
-
return kind === "review" ? "REVIEW.md" : kind === "report" ? "REPORT.md" : "PLAN.md";
|
|
2138
|
-
}
|
|
1879
|
+
if (call.tool === ToolNames.Artifact) return artifactDefaultPath(call.args?.kind);
|
|
2139
1880
|
return null;
|
|
2140
1881
|
}
|
|
2141
1882
|
function isWriteConfinementEscape(call, actionClass) {
|
|
@@ -2374,10 +2115,8 @@ function pathPolicyTargets(call) {
|
|
|
2374
2115
|
const target = pathArg(args);
|
|
2375
2116
|
return target === null ? [] : [{ operation: "write", path: target }];
|
|
2376
2117
|
}
|
|
2377
|
-
case ToolNames.Artifact:
|
|
2378
|
-
|
|
2379
|
-
return [{ operation: "write", path: pathArg(args) ?? fallback }];
|
|
2380
|
-
}
|
|
2118
|
+
case ToolNames.Artifact:
|
|
2119
|
+
return [{ operation: "write", path: pathArg(args) ?? artifactDefaultPath(args?.kind) }];
|
|
2381
2120
|
case ToolNames.CredentialPresent:
|
|
2382
2121
|
return [];
|
|
2383
2122
|
case ToolNames.Bash: {
|
|
@@ -2689,446 +2428,8 @@ function packPayload(rules) {
|
|
|
2689
2428
|
}));
|
|
2690
2429
|
}
|
|
2691
2430
|
|
|
2692
|
-
// src/domains/safety/scope.ts
|
|
2693
|
-
import path5 from "node:path";
|
|
2694
|
-
function normalizeRoot(root) {
|
|
2695
|
-
return path5.resolve(root);
|
|
2696
|
-
}
|
|
2697
|
-
function isUnder(child, parent) {
|
|
2698
|
-
const c = normalizeRoot(child);
|
|
2699
|
-
const p = normalizeRoot(parent);
|
|
2700
|
-
if (c === p) return true;
|
|
2701
|
-
const rel = path5.relative(p, c);
|
|
2702
|
-
return rel !== "" && !rel.startsWith("..") && !path5.isAbsolute(rel);
|
|
2703
|
-
}
|
|
2704
|
-
function isSubset(worker, orchestrator) {
|
|
2705
|
-
for (const action of worker.allowedActions) {
|
|
2706
|
-
if (!orchestrator.allowedActions.has(action)) return false;
|
|
2707
|
-
}
|
|
2708
|
-
for (const root of worker.allowedWriteRoots) {
|
|
2709
|
-
const covered = orchestrator.allowedWriteRoots.some((outer) => isUnder(root, outer));
|
|
2710
|
-
if (!covered) return false;
|
|
2711
|
-
}
|
|
2712
|
-
if (worker.allowNetwork && !orchestrator.allowNetwork) return false;
|
|
2713
|
-
if (worker.allowDispatch && !orchestrator.allowDispatch) return false;
|
|
2714
|
-
return true;
|
|
2715
|
-
}
|
|
2716
|
-
var READONLY_SCOPE = {
|
|
2717
|
-
allowedActions: /* @__PURE__ */ new Set(["read"]),
|
|
2718
|
-
allowedWriteRoots: [],
|
|
2719
|
-
allowNetwork: true,
|
|
2720
|
-
allowDispatch: false
|
|
2721
|
-
};
|
|
2722
|
-
var WORKSPACE_SCOPE = {
|
|
2723
|
-
allowedActions: /* @__PURE__ */ new Set(["read", "write", "execute", "dispatch"]),
|
|
2724
|
-
allowedWriteRoots: [process.cwd()],
|
|
2725
|
-
allowNetwork: true,
|
|
2726
|
-
allowDispatch: true
|
|
2727
|
-
};
|
|
2728
|
-
var CONFIRMED_SCOPE = {
|
|
2729
|
-
allowedActions: /* @__PURE__ */ new Set(["read", "write", "execute", "dispatch", "system_modify"]),
|
|
2730
|
-
allowedWriteRoots: [process.cwd()],
|
|
2731
|
-
allowNetwork: true,
|
|
2732
|
-
allowDispatch: true
|
|
2733
|
-
};
|
|
2734
|
-
|
|
2735
|
-
// src/domains/safety/finish-contract.ts
|
|
2736
|
-
var FINISH_CONTRACT_ADVISORY_MESSAGE = "[Clio Coder] finish-contract advisory: you changed files this turn without recording validation evidence or an explicit limitation. Run a verification command or state what could not be verified.";
|
|
2737
|
-
var DEFAULT_RECENT_ENTRY_LIMIT = 80;
|
|
2738
|
-
var LIMITATION_PATTERNS = [
|
|
2739
|
-
/\b(?:blocked by|blocker|blockers|unable to|not able to|could not|couldn't|cannot|can't)\b/i,
|
|
2740
|
-
/\b(?:did not|didn't|have not|haven't|has not|hasn't|was not able|wasn't able)\b/i,
|
|
2741
|
-
/\b(?:not complete|incomplete)\b/i,
|
|
2742
|
-
/\b(?:not|un)(?:\s|-)?(?:validated|verified|tested)\b/i,
|
|
2743
|
-
/^\s*Tests\s*:\s*(?:not run|not executed|not available|failed|blocked|skipped)\b/im,
|
|
2744
|
-
/^\s*Known gaps?\s*:\s*(?!\s*(?:none|no\b|n\/a|not applicable)\b).+/im,
|
|
2745
|
-
/\bremaining(?:\s+\w+){0,3}\s+(?:work|issue|issues|gap|gaps|blocker|blockers)\b/i
|
|
2746
|
-
];
|
|
2747
|
-
function assessFinishContract(input) {
|
|
2748
|
-
const assistantText = input.assistantText.trim();
|
|
2749
|
-
const sessionEntries = input.sessionEntries ?? [];
|
|
2750
|
-
const assistantTurnId = input.assistantTurnId ?? null;
|
|
2751
|
-
const window = recentEntries(sessionEntries, assistantTurnId, input.recentEntryLimit ?? DEFAULT_RECENT_ENTRY_LIMIT);
|
|
2752
|
-
const mutatedPaths = mutatingReceipts(window);
|
|
2753
|
-
if (mutatedPaths.length === 0) {
|
|
2754
|
-
return { kind: "ok", reason: "no_mutation", evidence: [], mutatedPaths };
|
|
2755
|
-
}
|
|
2756
|
-
const evidence = collectValidationEvidence(window);
|
|
2757
|
-
if (evidence.length > 0) {
|
|
2758
|
-
return { kind: "ok", reason: "validation_evidence", evidence, mutatedPaths };
|
|
2759
|
-
}
|
|
2760
|
-
if (hasExplicitLimitation(assistantText)) {
|
|
2761
|
-
return { kind: "ok", reason: "explicit_limitation", evidence: [], mutatedPaths };
|
|
2762
|
-
}
|
|
2763
|
-
return {
|
|
2764
|
-
kind: "engage",
|
|
2765
|
-
reason: "unvalidated_mutation",
|
|
2766
|
-
message: FINISH_CONTRACT_ADVISORY_MESSAGE,
|
|
2767
|
-
evidence: [],
|
|
2768
|
-
mutatedPaths
|
|
2769
|
-
};
|
|
2770
|
-
}
|
|
2771
|
-
function hasExplicitLimitation(text) {
|
|
2772
|
-
const normalized = text.trim();
|
|
2773
|
-
if (normalized.length === 0) return false;
|
|
2774
|
-
return LIMITATION_PATTERNS.some((pattern) => pattern.test(normalized));
|
|
2775
|
-
}
|
|
2776
|
-
function mutatingReceipts(recent) {
|
|
2777
|
-
const mutationCalls = /* @__PURE__ */ new Map();
|
|
2778
|
-
const paths = [];
|
|
2779
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2780
|
-
for (const entry of recent) {
|
|
2781
|
-
const bashMutation = bashExecutionMutationPaths(entry);
|
|
2782
|
-
if (bashMutation !== null) {
|
|
2783
|
-
for (const path7 of bashMutation) pushPath(paths, seen, path7);
|
|
2784
|
-
continue;
|
|
2785
|
-
}
|
|
2786
|
-
const call = mutatingToolCall(entry);
|
|
2787
|
-
if (call !== null) {
|
|
2788
|
-
mutationCalls.set(call.toolCallId, call);
|
|
2789
|
-
continue;
|
|
2790
|
-
}
|
|
2791
|
-
const resultId = successfulToolResultId(entry);
|
|
2792
|
-
if (resultId !== null) {
|
|
2793
|
-
const candidate = mutationCalls.get(resultId);
|
|
2794
|
-
if (candidate !== void 0) {
|
|
2795
|
-
for (const path7 of candidate.paths) pushPath(paths, seen, path7);
|
|
2796
|
-
}
|
|
2797
|
-
}
|
|
2798
|
-
}
|
|
2799
|
-
return paths;
|
|
2800
|
-
}
|
|
2801
|
-
function mutationPathsForTool(toolName, args) {
|
|
2802
|
-
if (toolName === ToolNames.Bash) {
|
|
2803
|
-
const command = typeof args?.command === "string" ? args.command : null;
|
|
2804
|
-
if (command === null) return [];
|
|
2805
|
-
return [...extractCommandWriteTargets(command), ...extractCommandDeleteTargets(command)];
|
|
2806
|
-
}
|
|
2807
|
-
return toolMutationPaths(toolName, args);
|
|
2808
|
-
}
|
|
2809
|
-
function mutatingToolCall(entry) {
|
|
2810
|
-
const record = asRecord(entry);
|
|
2811
|
-
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
2812
|
-
const payload = asRecord(record.payload);
|
|
2813
|
-
if (payload === null) return null;
|
|
2814
|
-
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
2815
|
-
if (toolName === null) return null;
|
|
2816
|
-
const args = asRecord(payload.args ?? payload.arguments ?? payload.input) ?? void 0;
|
|
2817
|
-
const paths = mutationPathsForTool(toolName, args);
|
|
2818
|
-
if (paths.length === 0) return null;
|
|
2819
|
-
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
2820
|
-
if (toolCallId === null) return null;
|
|
2821
|
-
return { toolCallId, paths };
|
|
2822
|
-
}
|
|
2823
|
-
function bashExecutionMutationPaths(entry) {
|
|
2824
|
-
const record = asRecord(entry);
|
|
2825
|
-
if (record?.kind !== "bashExecution") return null;
|
|
2826
|
-
if (typeof record.command !== "string") return null;
|
|
2827
|
-
if (record.cancelled === true || record.exitCode !== 0) return null;
|
|
2828
|
-
return [...extractCommandWriteTargets(record.command), ...extractCommandDeleteTargets(record.command)];
|
|
2829
|
-
}
|
|
2830
|
-
function pushPath(paths, seen, path7) {
|
|
2831
|
-
if (path7.length === 0 || seen.has(path7)) return;
|
|
2832
|
-
seen.add(path7);
|
|
2833
|
-
paths.push(path7);
|
|
2834
|
-
}
|
|
2835
|
-
function collectValidationEvidence(recent) {
|
|
2836
|
-
const evidence = [];
|
|
2837
|
-
const toolCalls = /* @__PURE__ */ new Map();
|
|
2838
|
-
const dispatchCalls = /* @__PURE__ */ new Map();
|
|
2839
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2840
|
-
for (const entry of recent) {
|
|
2841
|
-
const protectedArtifact = protectedArtifactEvidence(entry);
|
|
2842
|
-
if (protectedArtifact !== null) {
|
|
2843
|
-
pushEvidence(evidence, seen, protectedArtifact);
|
|
2844
|
-
continue;
|
|
2845
|
-
}
|
|
2846
|
-
const call = bashValidationCall(entry);
|
|
2847
|
-
if (call !== null) {
|
|
2848
|
-
toolCalls.set(call.toolCallId, call);
|
|
2849
|
-
continue;
|
|
2850
|
-
}
|
|
2851
|
-
const typedValidationCall = validationToolCall(entry);
|
|
2852
|
-
if (typedValidationCall !== null) {
|
|
2853
|
-
toolCalls.set(typedValidationCall.toolCallId, typedValidationCall);
|
|
2854
|
-
continue;
|
|
2855
|
-
}
|
|
2856
|
-
const dispatchCall = dispatchEvidenceCall(entry);
|
|
2857
|
-
if (dispatchCall !== null) {
|
|
2858
|
-
dispatchCalls.set(dispatchCall.toolCallId, dispatchCall);
|
|
2859
|
-
continue;
|
|
2860
|
-
}
|
|
2861
|
-
const resultId = successfulToolResultId(entry);
|
|
2862
|
-
if (resultId !== null) {
|
|
2863
|
-
const dispatchCandidate = dispatchCalls.get(resultId);
|
|
2864
|
-
const dispatchReceipt = dispatchReceiptEvidence(entry, dispatchCandidate);
|
|
2865
|
-
if (dispatchReceipt !== null) {
|
|
2866
|
-
pushEvidence(evidence, seen, dispatchReceipt);
|
|
2867
|
-
continue;
|
|
2868
|
-
}
|
|
2869
|
-
const candidate = toolCalls.get(resultId);
|
|
2870
|
-
if (candidate !== void 0) {
|
|
2871
|
-
pushEvidence(evidence, seen, validationEvidence(candidate));
|
|
2872
|
-
}
|
|
2873
|
-
continue;
|
|
2874
|
-
}
|
|
2875
|
-
const bashExecution = bashExecutionEvidence(entry);
|
|
2876
|
-
if (bashExecution !== null) pushEvidence(evidence, seen, bashExecution);
|
|
2877
|
-
}
|
|
2878
|
-
return evidence;
|
|
2879
|
-
}
|
|
2880
|
-
function recentEntries(entries, assistantTurnId, recentEntryLimit) {
|
|
2881
|
-
const boundedLimit = Number.isFinite(recentEntryLimit) && recentEntryLimit > 0 ? Math.floor(recentEntryLimit) : DEFAULT_RECENT_ENTRY_LIMIT;
|
|
2882
|
-
const assistantIndex = assistantTurnId === null ? -1 : entries.findIndex((entry) => turnIdOf(entry) === assistantTurnId);
|
|
2883
|
-
const endExclusive = assistantIndex >= 0 ? assistantIndex : entries.length;
|
|
2884
|
-
let startInclusive = Math.max(0, endExclusive - boundedLimit);
|
|
2885
|
-
for (let index = endExclusive - 1; index >= startInclusive; index -= 1) {
|
|
2886
|
-
if (isUserMessageEntry(entries[index])) {
|
|
2887
|
-
startInclusive = index + 1;
|
|
2888
|
-
break;
|
|
2889
|
-
}
|
|
2890
|
-
}
|
|
2891
|
-
return entries.slice(startInclusive, endExclusive);
|
|
2892
|
-
}
|
|
2893
|
-
function bashValidationCall(entry) {
|
|
2894
|
-
const record = asRecord(entry);
|
|
2895
|
-
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
2896
|
-
const payload = asRecord(record.payload);
|
|
2897
|
-
if (payload === null) return null;
|
|
2898
|
-
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
2899
|
-
if (toolName !== "bash") return null;
|
|
2900
|
-
const args = asRecord(payload.args ?? payload.arguments ?? payload.input);
|
|
2901
|
-
const command = typeof args?.command === "string" ? args.command : null;
|
|
2902
|
-
if (command === null) return null;
|
|
2903
|
-
const detected = detectValidationCommand(command);
|
|
2904
|
-
if (detected.kind !== "validation") return null;
|
|
2905
|
-
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
2906
|
-
if (toolCallId === null) return null;
|
|
2907
|
-
const candidate = {
|
|
2908
|
-
toolCallId,
|
|
2909
|
-
command: detected.matched
|
|
2910
|
-
};
|
|
2911
|
-
const turnId = turnIdOf(entry);
|
|
2912
|
-
if (turnId !== null) candidate.turnId = turnId;
|
|
2913
|
-
return candidate;
|
|
2914
|
-
}
|
|
2915
|
-
function dispatchEvidenceCall(entry) {
|
|
2916
|
-
const record = asRecord(entry);
|
|
2917
|
-
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
2918
|
-
const payload = asRecord(record.payload);
|
|
2919
|
-
if (payload === null) return null;
|
|
2920
|
-
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
2921
|
-
if (toolName !== "dispatch") return null;
|
|
2922
|
-
const args = asRecord(payload.args ?? payload.arguments ?? payload.input);
|
|
2923
|
-
const { agentId, task } = dispatchCallDescriptor(args);
|
|
2924
|
-
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
2925
|
-
if (toolCallId === null) return null;
|
|
2926
|
-
const candidate = {
|
|
2927
|
-
toolCallId,
|
|
2928
|
-
command: `agent=${agentId}${task.length > 0 ? ` task=${task}` : ""}`
|
|
2929
|
-
};
|
|
2930
|
-
const turnId = turnIdOf(entry);
|
|
2931
|
-
if (turnId !== null) candidate.turnId = turnId;
|
|
2932
|
-
return candidate;
|
|
2933
|
-
}
|
|
2934
|
-
function dispatchCallDescriptor(args) {
|
|
2935
|
-
const defaultAgent = stringFromFirst(args ?? {}, ["agent", "agent_id", "agentId"]);
|
|
2936
|
-
const tasks = Array.isArray(args?.tasks) ? args.tasks : null;
|
|
2937
|
-
if (tasks !== null && tasks.length > 0) {
|
|
2938
|
-
const first = tasks[0];
|
|
2939
|
-
if (typeof first === "string") {
|
|
2940
|
-
return { agentId: defaultAgent ?? "coder", task: first.trim() };
|
|
2941
|
-
}
|
|
2942
|
-
const firstRecord = asRecord(first);
|
|
2943
|
-
const itemAgent = firstRecord === null ? null : stringFromFirst(firstRecord, ["agent", "agent_id", "agentId"]);
|
|
2944
|
-
const itemTask = typeof firstRecord?.task === "string" ? firstRecord.task.trim() : "";
|
|
2945
|
-
return { agentId: itemAgent ?? defaultAgent ?? "coder", task: itemTask };
|
|
2946
|
-
}
|
|
2947
|
-
const singleTask = typeof args?.task === "string" ? args.task.trim() : "";
|
|
2948
|
-
return { agentId: defaultAgent ?? "coder", task: singleTask };
|
|
2949
|
-
}
|
|
2950
|
-
function validationToolCall(entry) {
|
|
2951
|
-
const record = asRecord(entry);
|
|
2952
|
-
if (record?.kind !== "message" || record.role !== "tool_call") return null;
|
|
2953
|
-
const payload = asRecord(record.payload);
|
|
2954
|
-
if (payload === null) return null;
|
|
2955
|
-
const toolName = stringFromFirst(payload, ["name", "toolName", "tool"]);
|
|
2956
|
-
if (toolName === null) return null;
|
|
2957
|
-
const summary = typedValidationSummary(toolName, payload);
|
|
2958
|
-
if (summary === null) return null;
|
|
2959
|
-
const toolCallId = stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]) ?? turnIdOf(entry);
|
|
2960
|
-
if (toolCallId === null) return null;
|
|
2961
|
-
const candidate = {
|
|
2962
|
-
toolCallId,
|
|
2963
|
-
command: summary
|
|
2964
|
-
};
|
|
2965
|
-
const turnId = turnIdOf(entry);
|
|
2966
|
-
if (turnId !== null) candidate.turnId = turnId;
|
|
2967
|
-
return candidate;
|
|
2968
|
-
}
|
|
2969
|
-
function typedValidationSummary(toolName, payload) {
|
|
2970
|
-
const args = asRecord(payload.args ?? payload.arguments ?? payload.input);
|
|
2971
|
-
if (toolName === "verify") {
|
|
2972
|
-
const check = typeof args?.check === "string" ? args.check.trim() : "";
|
|
2973
|
-
if (check === "frontend") {
|
|
2974
|
-
const path7 = typeof args?.path === "string" && args.path.trim().length > 0 ? args.path.trim() : "artifact";
|
|
2975
|
-
return `verify frontend ${path7}`;
|
|
2976
|
-
}
|
|
2977
|
-
if (!isVerificationScriptName(check)) return null;
|
|
2978
|
-
return `npm run ${check}`;
|
|
2979
|
-
}
|
|
2980
|
-
return null;
|
|
2981
|
-
}
|
|
2982
|
-
function successfulToolResultId(entry) {
|
|
2983
|
-
const record = asRecord(entry);
|
|
2984
|
-
if (record?.kind !== "message" || record.role !== "tool_result") return null;
|
|
2985
|
-
const payload = asRecord(record.payload);
|
|
2986
|
-
if (payload === null) return null;
|
|
2987
|
-
if (payload.isError === true || payload.error === true) return null;
|
|
2988
|
-
const result = asRecord(payload.result);
|
|
2989
|
-
const details = asRecord(result?.details);
|
|
2990
|
-
if (details?.kind === "error") return null;
|
|
2991
|
-
return stringFromFirst(payload, ["toolCallId", "tool_call_id", "id"]);
|
|
2992
|
-
}
|
|
2993
|
-
function dispatchReceiptEvidence(entry, candidate) {
|
|
2994
|
-
const record = asRecord(entry);
|
|
2995
|
-
if (record?.kind !== "message" || record.role !== "tool_result") return null;
|
|
2996
|
-
const payload = asRecord(record.payload);
|
|
2997
|
-
if (payload === null) return null;
|
|
2998
|
-
const toolName = stringFromFirst(payload, ["toolName", "name", "tool"]);
|
|
2999
|
-
if (toolName !== null && toolName !== "dispatch") return null;
|
|
3000
|
-
const result = asRecord(payload.result);
|
|
3001
|
-
const details = asRecord(result?.details);
|
|
3002
|
-
if (details === null) return null;
|
|
3003
|
-
const summary = passedDispatchReceiptSummary(details, candidate);
|
|
3004
|
-
if (summary === null) return null;
|
|
3005
|
-
const evidence = {
|
|
3006
|
-
kind: "dispatch_receipt",
|
|
3007
|
-
summary
|
|
3008
|
-
};
|
|
3009
|
-
const turnId = candidate?.turnId ?? turnIdOf(entry);
|
|
3010
|
-
if (turnId !== null && turnId !== void 0) evidence.turnId = turnId;
|
|
3011
|
-
return evidence;
|
|
3012
|
-
}
|
|
3013
|
-
function passedDispatchReceiptSummary(details, candidate) {
|
|
3014
|
-
if (Array.isArray(details.runs)) {
|
|
3015
|
-
const runs = details.runs.map(asRecord);
|
|
3016
|
-
if (runs.length === 0 || runs.some((run) => run === null || run.exitCode !== 0)) return null;
|
|
3017
|
-
if (typeof details.failedCount === "number" && details.failedCount !== 0) return null;
|
|
3018
|
-
const first = runs[0];
|
|
3019
|
-
const runId = typeof first?.runId === "string" && first.runId.length > 0 ? first.runId : "unknown";
|
|
3020
|
-
const agentId = dispatchReceiptAgentId(typeof first?.agentId === "string" ? first.agentId : void 0, candidate);
|
|
3021
|
-
const extra = runs.length > 1 ? ` (+${runs.length - 1} more)` : "";
|
|
3022
|
-
return `dispatch receipt passed: run ${runId} agent ${agentId}${extra}`;
|
|
3023
|
-
}
|
|
3024
|
-
if (details.exitCode === 0) {
|
|
3025
|
-
const runId = typeof details.runId === "string" && details.runId.length > 0 ? details.runId : "unknown";
|
|
3026
|
-
const agentId = dispatchReceiptAgentId(typeof details.agentId === "string" ? details.agentId : void 0, candidate);
|
|
3027
|
-
return `dispatch receipt passed: run ${runId} agent ${agentId}`;
|
|
3028
|
-
}
|
|
3029
|
-
return null;
|
|
3030
|
-
}
|
|
3031
|
-
function dispatchReceiptAgentId(receiptAgentId, candidate) {
|
|
3032
|
-
if (receiptAgentId !== void 0 && receiptAgentId.length > 0) return receiptAgentId;
|
|
3033
|
-
return candidate?.command.match(/^agent=([^\s]+)/)?.[1] ?? "unknown";
|
|
3034
|
-
}
|
|
3035
|
-
function bashExecutionEvidence(entry) {
|
|
3036
|
-
const record = asRecord(entry);
|
|
3037
|
-
if (record?.kind !== "bashExecution") return null;
|
|
3038
|
-
if (typeof record.command !== "string") return null;
|
|
3039
|
-
if (record.cancelled === true) return null;
|
|
3040
|
-
if (record.exitCode !== 0) return null;
|
|
3041
|
-
const detected = detectValidationCommand(record.command);
|
|
3042
|
-
if (detected.kind !== "validation") return null;
|
|
3043
|
-
const evidence = {
|
|
3044
|
-
kind: "validation_command",
|
|
3045
|
-
summary: `validation command passed: ${detected.matched}`
|
|
3046
|
-
};
|
|
3047
|
-
const turnId = turnIdOf(entry);
|
|
3048
|
-
if (turnId !== null) evidence.turnId = turnId;
|
|
3049
|
-
return evidence;
|
|
3050
|
-
}
|
|
3051
|
-
function protectedArtifactEvidence(entry) {
|
|
3052
|
-
const record = asRecord(entry);
|
|
3053
|
-
if (record?.kind !== "protectedArtifact" || record.action !== "protect") return null;
|
|
3054
|
-
const artifact = asRecord(record.artifact);
|
|
3055
|
-
const path7 = typeof artifact?.path === "string" && artifact.path.trim().length > 0 ? artifact.path.trim() : null;
|
|
3056
|
-
if (path7 === null) return null;
|
|
3057
|
-
const evidence = {
|
|
3058
|
-
kind: "protected_artifact",
|
|
3059
|
-
summary: `protected artifact recorded: ${path7}`
|
|
3060
|
-
};
|
|
3061
|
-
const turnId = turnIdOf(entry);
|
|
3062
|
-
if (turnId !== null) evidence.turnId = turnId;
|
|
3063
|
-
return evidence;
|
|
3064
|
-
}
|
|
3065
|
-
function validationEvidence(candidate) {
|
|
3066
|
-
const evidence = {
|
|
3067
|
-
kind: "validation_command",
|
|
3068
|
-
summary: `validation command passed: ${candidate.command}`
|
|
3069
|
-
};
|
|
3070
|
-
if (candidate.turnId !== void 0) evidence.turnId = candidate.turnId;
|
|
3071
|
-
return evidence;
|
|
3072
|
-
}
|
|
3073
|
-
function pushEvidence(evidence, seen, item) {
|
|
3074
|
-
const key = `${item.kind}\0${item.summary}\0${item.turnId ?? ""}`;
|
|
3075
|
-
if (seen.has(key)) return;
|
|
3076
|
-
seen.add(key);
|
|
3077
|
-
evidence.push(item);
|
|
3078
|
-
}
|
|
3079
|
-
function isUserMessageEntry(entry) {
|
|
3080
|
-
const record = asRecord(entry);
|
|
3081
|
-
if (record?.kind !== "message" || record.role !== "user") return false;
|
|
3082
|
-
const payload = asRecord(record.payload);
|
|
3083
|
-
return payload?.synthetic !== true;
|
|
3084
|
-
}
|
|
3085
|
-
function turnIdOf(entry) {
|
|
3086
|
-
const record = asRecord(entry);
|
|
3087
|
-
return typeof record?.turnId === "string" ? record.turnId : null;
|
|
3088
|
-
}
|
|
3089
|
-
function stringFromFirst(record, keys) {
|
|
3090
|
-
for (const key of keys) {
|
|
3091
|
-
const value = record[key];
|
|
3092
|
-
if (typeof value === "string" && value.length > 0) return value;
|
|
3093
|
-
}
|
|
3094
|
-
return null;
|
|
3095
|
-
}
|
|
3096
|
-
function asRecord(value) {
|
|
3097
|
-
return value !== null && typeof value === "object" ? value : null;
|
|
3098
|
-
}
|
|
3099
|
-
|
|
3100
|
-
// src/domains/safety/rigor.ts
|
|
3101
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
3102
|
-
import path6 from "node:path";
|
|
3103
|
-
var VALIDATION_CONTRACT_FILES = [
|
|
3104
|
-
path6.join(".clio-coder", "validation.yaml"),
|
|
3105
|
-
path6.join(".clio-coder", "validation.yml"),
|
|
3106
|
-
"validation.yaml",
|
|
3107
|
-
"validation.yml",
|
|
3108
|
-
"VALIDATION.md"
|
|
3109
|
-
];
|
|
3110
|
-
function resolveRigor(options) {
|
|
3111
|
-
if (options.override === "high" || options.override === "normal") return options.override;
|
|
3112
|
-
const cwd = options.cwd ?? process.cwd();
|
|
3113
|
-
return hasValidationContract(cwd) ? "high" : "normal";
|
|
3114
|
-
}
|
|
3115
|
-
function parseRigorOverride(value) {
|
|
3116
|
-
if (typeof value !== "string") return null;
|
|
3117
|
-
const normalized = value.trim().toLowerCase();
|
|
3118
|
-
if (normalized === "high") return "high";
|
|
3119
|
-
if (normalized === "normal") return "normal";
|
|
3120
|
-
return null;
|
|
3121
|
-
}
|
|
3122
|
-
function hasValidationContract(cwd) {
|
|
3123
|
-
try {
|
|
3124
|
-
return VALIDATION_CONTRACT_FILES.some((relative) => existsSync4(path6.join(cwd, relative)));
|
|
3125
|
-
} catch {
|
|
3126
|
-
return false;
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
|
|
3130
2431
|
export {
|
|
3131
|
-
|
|
2432
|
+
parseJsonObjectPayload,
|
|
3132
2433
|
resultContractSourceId,
|
|
3133
2434
|
parseVerifierResult,
|
|
3134
2435
|
resultContractAuthorship,
|
|
@@ -3136,42 +2437,20 @@ export {
|
|
|
3136
2437
|
validateResultContract,
|
|
3137
2438
|
validateRecipeResult,
|
|
3138
2439
|
RESULT_CONTRACT_REPAIR_LIMIT,
|
|
3139
|
-
|
|
2440
|
+
resultContractRepairMessages,
|
|
3140
2441
|
parseResultContract,
|
|
3141
|
-
FLEET_COMMAND_BASE_ENV,
|
|
3142
|
-
loadFleetCommands,
|
|
3143
|
-
normalizeWriteBoundary,
|
|
3144
|
-
writeBoundaryCovers,
|
|
3145
|
-
describeWriteBoundary,
|
|
3146
|
-
fleetLoopCheckStepId,
|
|
3147
|
-
fleetLoopRepairStepId,
|
|
3148
|
-
fleetStepWriteBoundary,
|
|
3149
|
-
FLEET_COMMANDS_REPO_PATH,
|
|
3150
|
-
FLEET_COMMANDS_REMEDY,
|
|
3151
|
-
FleetCommandRegistryMissingError,
|
|
3152
|
-
loadFleetContract,
|
|
3153
|
-
listFleetContracts,
|
|
3154
|
-
renderFleetPrompt,
|
|
3155
2442
|
AUTONOMY_LEVELS,
|
|
3156
2443
|
DEFAULT_AUTONOMY_LEVEL,
|
|
3157
2444
|
isAutonomyLevel,
|
|
2445
|
+
DEFAULT_AUTONOMY_EXPOSURE,
|
|
3158
2446
|
mapAutonomy,
|
|
3159
2447
|
autonomyDenyRejection,
|
|
3160
2448
|
autonomyAskRejection,
|
|
3161
|
-
createLoopState,
|
|
3162
|
-
hashToolCall,
|
|
3163
|
-
observe,
|
|
3164
|
-
formatModelRejection,
|
|
3165
|
-
WRITE_ROOT_REFUSED_TOOLS,
|
|
3166
|
-
createSafetyPolicyEngine,
|
|
3167
|
-
isSubset,
|
|
3168
|
-
READONLY_SCOPE,
|
|
3169
|
-
WORKSPACE_SCOPE,
|
|
3170
|
-
CONFIRMED_SCOPE,
|
|
3171
2449
|
DEFAULT_RECENT_ENTRY_LIMIT,
|
|
3172
2450
|
assessFinishContract,
|
|
3173
2451
|
typedValidationSummary,
|
|
3174
|
-
|
|
3175
|
-
|
|
2452
|
+
formatModelRejection,
|
|
2453
|
+
WRITE_ROOT_REFUSED_TOOLS,
|
|
2454
|
+
createSafetyPolicyEngine
|
|
3176
2455
|
};
|
|
3177
|
-
//# sourceMappingURL=chunk-
|
|
2456
|
+
//# sourceMappingURL=chunk-STBPMHSX.js.map
|