@iowarp/clio-coder 0.3.3 → 0.3.6
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 +74 -0
- package/CONTRIBUTING.md +7 -7
- package/README.md +3 -3
- package/dist/{acp-P2AQILE2.js → acp-2BEHC4DL.js} +9 -8
- package/dist/{agents-72W3BI7I.js → agents-LNNFTM53.js} +29 -24
- package/dist/assets/codewiki.json +1 -1
- package/dist/{auth-5TWEIYDN.js → auth-KXXFI2VS.js} +14 -10
- package/dist/{chunk-GGXXDWE4.js → chunk-22NAGB7X.js} +2 -2
- package/dist/{chunk-YCWGATWI.js → chunk-24I7BN55.js} +2 -2
- package/dist/{chunk-EKMEHE4H.js → chunk-33YXPOE3.js} +2 -3
- package/dist/chunk-3BPUFZDL.js +37 -0
- package/dist/chunk-43AOLP7E.js +375 -0
- package/dist/{chunk-ZDOOVTXZ.js → chunk-4OC57DA6.js} +27 -4
- package/dist/{chunk-6SGHMWE3.js → chunk-5JGRAMKL.js} +5 -5
- package/dist/{chunk-V6RTAOC2.js → chunk-6US73PDB.js} +572 -51
- package/dist/{chunk-5UFT4SUX.js → chunk-6XXKFVSN.js} +3 -3
- package/dist/{chunk-A3CYT5EX.js → chunk-AD2SYQYC.js} +55 -2
- package/dist/chunk-AOCYTWAV.js +449 -0
- package/dist/chunk-CFGTUFWB.js +67 -0
- package/dist/chunk-CJUB2JJ2.js +1478 -0
- package/dist/{chunk-FNTMWMX5.js → chunk-CKXWIANG.js} +14 -12
- package/dist/{chunk-PIWWS5BL.js → chunk-CYQKWTG3.js} +63 -78
- package/dist/{chunk-LZSJBIVT.js → chunk-DJVECN66.js} +271 -762
- package/dist/{chunk-CBCAPZAA.js → chunk-E25LMLRW.js} +2 -2
- package/dist/{chunk-ZWMF7253.js → chunk-E2ER4LJF.js} +304 -9
- package/dist/{chunk-STBPMHSX.js → chunk-EKY57CSP.js} +51 -84
- package/dist/{chunk-DUYJ5IO6.js → chunk-EYPA3EGJ.js} +12 -4
- package/dist/{chunk-M6SHUN7Q.js → chunk-FO5ZOVUY.js} +2 -2
- package/dist/chunk-FYYLNIL5.js +313 -0
- package/dist/{chunk-OQ33BKR3.js → chunk-G7MUEIGA.js} +3 -60
- package/dist/chunk-GEYXPTRF.js +613 -0
- package/dist/chunk-GOXNB3AO.js +261 -0
- package/dist/{chunk-G4BMMOKF.js → chunk-HVDIIIQW.js} +2 -2
- package/dist/chunk-HWUFFB6L.js +83 -0
- package/dist/{chunk-4XUGQOHA.js → chunk-K7T3E2SR.js} +15 -8
- package/dist/chunk-K7VKOLQQ.js +15 -0
- package/dist/{chunk-UFIIWP2H.js → chunk-KHSFENX2.js} +8 -8
- package/dist/{chunk-BMEMKKIT.js → chunk-KOHPCX4K.js} +2 -2
- package/dist/chunk-LCGCVYZ4.js +57 -0
- package/dist/chunk-LL4KHSZI.js +22 -0
- package/dist/{chunk-PAJK6MAQ.js → chunk-LYF7OHWH.js} +42 -15
- package/dist/{chunk-POHLU5DW.js → chunk-M6L6IDJG.js} +3 -3
- package/dist/{chunk-5UUP6MWO.js → chunk-MV3K5QF2.js} +5 -436
- package/dist/{chunk-X4RCMKVQ.js → chunk-NDINPTJ4.js} +2 -2
- package/dist/{chunk-TZK7PACC.js → chunk-NILBFAPG.js} +14 -8
- package/dist/chunk-ODFEOB4F.js +1082 -0
- package/dist/{chunk-AGYYIBLL.js → chunk-OH3TOQTB.js} +6 -2
- package/dist/chunk-OZNBF4L3.js +23 -0
- package/dist/{chunk-DSELYM6W.js → chunk-PBTHKCPN.js} +30 -10
- package/dist/{verify-375KUB3Y.js → chunk-PCZJO5TI.js} +127 -42
- package/dist/{chunk-ED4KHGC3.js → chunk-PPAMZ32Z.js} +9 -2
- package/dist/{chunk-SRDMMSEP.js → chunk-QM3F2GKX.js} +1063 -1645
- package/dist/{chunk-X6IAEBZR.js → chunk-QNQHSOLF.js} +7 -7
- package/dist/{chunk-OC7FIQPC.js → chunk-R46L2BIR.js} +10 -7
- package/dist/{chunk-2TLUCQVG.js → chunk-RD5U66HV.js} +3 -3
- package/dist/{chunk-6N5PTWMY.js → chunk-RY3LY4J5.js} +50 -13
- package/dist/{chunk-OKGUZO2U.js → chunk-SPULKLCF.js} +4 -3
- package/dist/{chunk-OOJYHWRB.js → chunk-TSHXZTOQ.js} +6 -5
- package/dist/chunk-TZSKNMZG.js +434 -0
- package/dist/{chunk-7MNJORFF.js → chunk-UL3WSD3F.js} +6 -1
- package/dist/{chunk-VJWL6YS5.js → chunk-UUVG37B4.js} +2 -2
- package/dist/{chunk-COU2UHX6.js → chunk-VEZEGCGW.js} +170 -2
- package/dist/chunk-W6GROXXM.js +69 -0
- package/dist/{chunk-OAO4GE4M.js → chunk-WHGPSPT5.js} +2 -2
- package/dist/chunk-WHJYKASB.js +677 -0
- package/dist/{chunk-ORBHGJC5.js → chunk-WR67VIZY.js} +3 -3
- package/dist/{chunk-YHZX5GEU.js → chunk-XAKHZX5N.js} +2 -2
- package/dist/{chunk-TZTZS7QK.js → chunk-XE2VEJHX.js} +5 -3
- package/dist/{chunk-LM5TQCJZ.js → chunk-XF5N4U5A.js} +8 -7
- package/dist/{chunk-LWLEKMDQ.js → chunk-XXQNGV4M.js} +1073 -552
- package/dist/{chunk-KZWTDYJF.js → chunk-XYDYPRZI.js} +7 -7
- package/dist/chunk-ZGVHUX3M.js +66 -0
- package/dist/{chunk-LW6DSM3M.js → chunk-ZRGEBJ4T.js} +1192 -1119
- package/dist/{chunk-2DJ2KNFG.js → chunk-ZXF4XRKW.js} +202 -40
- package/dist/chunk-ZZMN5OM4.js +122 -0
- package/dist/cli/index.js +34 -30
- package/dist/{clio-JOU4FXVA.js → clio-M2KGYUFZ.js} +7 -6
- package/dist/{code-nav-7AX6FYE6.js → code-nav-GQNL7XA6.js} +8 -6
- package/dist/codewiki/build-worker.js +4 -4
- package/dist/{components-KELWS457.js → components-5TTYYX6G.js} +3 -3
- package/dist/{config-XCDVKR23.js → config-XUUYQIWO.js} +47 -35
- package/dist/{configure-4GAP54ZW.js → configure-IHJ7YOMV.js} +18 -15
- package/dist/{context-77FM5DV5.js → context-74JLXAWD.js} +18 -10
- package/dist/{context-4UOGGLQ5.js → context-75MIWW3U.js} +41 -29
- package/dist/{context-5VKGUVJJ.js → context-ZQ7SIFJV.js} +85 -9
- package/dist/{context-clear-XXJRLCJJ.js → context-clear-GYKWNUML.js} +41 -29
- package/dist/{context-index-BZ4UYMTC.js → context-index-SSR5ECNE.js} +3 -3
- package/dist/context-working-set-UX5KEP4J.js +1553 -0
- package/dist/{dispatch-runner-QPRDDBDX.js → dispatch-runner-GIJBHNFL.js} +47 -32
- package/dist/{docs-2C2LTVT2.js → docs-6FZSCG5B.js} +3 -3
- package/dist/{doctor-HR46URBJ.js → doctor-SVJ5BZCW.js} +12 -12
- package/dist/{eval-XSSNATB4.js → eval-CG6LLBLD.js} +54 -238
- package/dist/{evidence-6HG2PY2B.js → evidence-ZYFIEN42.js} +57 -28
- package/dist/{evolve-K7YU3NCY.js → evolve-QGEXEMDW.js} +36 -25
- package/dist/{extensions-QVDOHDGJ.js → extensions-ADGNCJJD.js} +3 -3
- package/dist/{fleet-VY3HHKN6.js → fleet-S5R4ZOQY.js} +73 -44
- package/dist/{fleet-preflight-DDN536IT.js → fleet-preflight-BHSNPBMH.js} +3 -3
- package/dist/{init-JYGXI3FK.js → init-5DRU55YR.js} +49 -37
- package/dist/memory-7YKKR6UC.js +467 -0
- package/dist/{models-I5QWSEOM.js → models-ZPOLRU2C.js} +24 -21
- package/dist/{monitor-GE4ID3IA.js → monitor-US5F5YGZ.js} +73 -46
- package/dist/{orchestrator-EM5MC3HM.js → orchestrator-E2AL4T5N.js} +1624 -1007
- package/dist/{paths-UXLN5YYZ.js → paths-E7KYAQWE.js} +3 -3
- package/dist/{reset-L2FQEE3E.js → reset-KZ652EK6.js} +6 -5
- package/dist/{run-ZU3QMZPZ.js → run-SRNBKDWD.js} +76 -54
- package/dist/{share-S5BZQC5I.js → share-CGZE33UP.js} +7 -6
- package/dist/{skills-X5VXCRNQ.js → skills-S2X4DLY5.js} +4 -4
- package/dist/{skills-eval-WKIHWTHR.js → skills-eval-W2GGIC4R.js} +40 -29
- package/dist/{targets-SNCPI2NR.js → targets-54SWINWB.js} +28 -23
- package/dist/{terminal-lease-BNAHVHBS.js → terminal-lease-SAIF2OGY.js} +6 -4
- package/dist/{uninstall-FZCQCDKC.js → uninstall-BVLWXKBT.js} +3 -3
- package/dist/{upgrade-JQHHPQ4K.js → upgrade-JKAR27XC.js} +20 -19
- package/dist/{usage-OR4O5SMZ.js → usage-MSAWCLX4.js} +79 -36
- package/dist/verifiers-NCBTHHN2.js +1220 -0
- package/dist/verify-X5HDROLA.js +25 -0
- package/dist/{wiki-generate-UEXP2ARI.js → wiki-generate-GUSOQ6ZP.js} +50 -37
- package/dist/worker/entry.js +90 -70
- package/dist/{workspace-G4ZWUIPR.js → workspace-ZJ6BFM3Q.js} +4 -4
- package/docs/README.md +8 -7
- package/docs/acp.md +1 -1
- package/docs/alcf-provider.md +1 -1
- package/docs/architecture.md +2 -2
- package/docs/artifact-placement.md +1 -2
- package/docs/artifact-versions.md +1 -1
- package/docs/built-in-agents.md +1 -1
- package/docs/capacity-and-scheduling.md +1 -1
- package/docs/commands-and-modes.md +60 -26
- package/docs/config-knobs-audit.md +1 -2
- package/docs/configuration-and-targets.md +26 -1
- package/docs/context-engine.md +67 -13
- package/docs/context-working-set.md +194 -0
- package/docs/development-pipeline.md +1 -1
- package/docs/documentation-coverage.md +6 -6
- package/docs/documentation-guide.md +7 -6
- package/docs/environment-variables.md +2 -1
- package/docs/eval-runner.md +1 -1
- package/docs/evals-internal.md +4 -32
- package/docs/evidence-and-memory.md +139 -7
- package/docs/evolution.md +1 -1
- package/docs/exit-codes-and-output.md +1 -1
- package/docs/extensions-and-sharing.md +2 -2
- package/docs/fleet-dispatch.md +49 -8
- package/docs/glossary.md +21 -1
- package/docs/installation-and-lifecycle.md +2 -2
- package/docs/middleware-and-components.md +19 -2
- package/docs/model-catalog.md +7 -9
- package/docs/observability.md +4 -4
- package/docs/proactive-memory.md +26 -16
- package/docs/prompt-envelope-and-tools.md +7 -5
- package/docs/provider-adapter-cookbook.md +1 -1
- package/docs/release-cut-checklist.md +43 -40
- package/docs/safety-model.md +49 -8
- package/docs/scientific-validation.md +21 -3
- package/docs/session-lifecycle.md +3 -3
- package/docs/skills-marketplace.md +1 -1
- package/docs/tool-usage.md +79 -12
- package/docs/trace-store.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/tui-design.md +38 -4
- package/docs/worker-dispatch-mechanics.md +11 -1
- package/package.json +13 -13
- package/skills/meta/clio-test/SKILL.md +20 -17
- package/skills/meta/clio-test/evals.md +3 -3
- package/skills/meta/clio-test/references/harness.md +35 -6
- package/skills/meta/clio-test/references/test-map.md +20 -10
- package/skills/registry.yaml +2 -2
- package/skills/skill-marketplace.json +1 -1
- package/src/cli/agents.ts +2 -3
- package/src/cli/argv.ts +14 -1
- package/src/cli/context-working-set.ts +513 -0
- package/src/cli/context.ts +8 -0
- package/src/cli/evidence.ts +20 -2
- package/src/cli/fleet.ts +15 -0
- package/src/cli/index.ts +5 -1
- package/src/cli/memory.ts +272 -10
- package/src/cli/modes/json-stream.ts +2 -2
- package/src/cli/modes/print.ts +12 -1
- package/src/cli/run.ts +22 -2
- package/src/cli/targets.ts +12 -3
- package/src/cli/usage.ts +55 -7
- package/src/cli/verifiers.ts +325 -0
- package/src/core/bash-exec.ts +39 -14
- package/src/core/bus-events.ts +22 -4
- package/src/core/config.ts +54 -0
- package/src/core/defaults.ts +50 -3
- package/src/core/response-model-id.ts +134 -0
- package/src/core/toml.ts +62 -0
- package/src/core/verification-scripts.ts +6 -0
- package/src/core/workspace-files.ts +0 -1
- package/src/domains/agents/builtins/architect.md +1 -1
- package/src/domains/agents/builtins/verifier.md +3 -0
- package/src/domains/agents/catalog.ts +5 -4
- package/src/domains/agents/recipe.ts +54 -14
- package/src/domains/agents/result-contract.ts +7 -4
- package/src/domains/config/classify.ts +1 -0
- package/src/domains/context/bootstrap.ts +36 -27
- package/src/domains/context/project-metadata.ts +19 -63
- package/src/domains/context/prompt-context.ts +8 -0
- package/src/domains/context/working-set/contract.ts +161 -0
- package/src/domains/context/working-set/defaults.ts +28 -0
- package/src/domains/context/working-set/engine.ts +203 -0
- package/src/domains/context/working-set/fold.ts +62 -0
- package/src/domains/context/working-set/horizon.ts +38 -0
- package/src/domains/context/working-set/marker.ts +103 -0
- package/src/domains/context/working-set/path-index.ts +436 -0
- package/src/domains/context/working-set/payload.ts +152 -0
- package/src/domains/context/working-set/policies/age-horizon.ts +55 -0
- package/src/domains/context/working-set/policies/index.ts +20 -0
- package/src/domains/context/working-set/policies/structural.ts +160 -0
- package/src/domains/context/working-set/project.ts +132 -0
- package/src/domains/context/working-set/protect.ts +109 -0
- package/src/domains/context/working-set/recall.ts +177 -0
- package/src/domains/context/working-set/replay/controls.ts +112 -0
- package/src/domains/context/working-set/replay/load-clio.ts +199 -0
- package/src/domains/context/working-set/replay/metrics.ts +185 -0
- package/src/domains/context/working-set/replay/reference-graph.ts +79 -0
- package/src/domains/context/working-set/replay/report.ts +139 -0
- package/src/domains/context/working-set/replay/runner.ts +325 -0
- package/src/domains/context/working-set/replay/synthetic.ts +422 -0
- package/src/domains/context/working-set/replay/trace.ts +21 -0
- package/src/domains/context/working-set/visible.ts +54 -0
- package/src/domains/dispatch/budget-envelope.ts +396 -0
- package/src/domains/dispatch/contract.ts +2 -0
- package/src/domains/dispatch/extension.ts +81 -27
- package/src/domains/dispatch/orphan-recovery.ts +1 -0
- package/src/domains/dispatch/receipt-integrity.ts +4 -0
- package/src/domains/dispatch/state.ts +1 -0
- package/src/domains/dispatch/types.ts +10 -3
- package/src/domains/dispatch/validation.ts +14 -0
- package/src/domains/dispatch/worker-spawn.ts +14 -3
- package/src/domains/eval/metrics/evidence.ts +0 -116
- package/src/domains/eval/metrics/invariants.ts +1 -1
- package/src/domains/eval/runners/clio-run.ts +1 -10
- package/src/domains/eval/runners/external-command.ts +2 -29
- package/src/domains/eval/schema/suite.ts +0 -7
- package/src/domains/eval/suites/run.ts +1 -7
- package/src/domains/evidence/build.ts +112 -45
- package/src/domains/evidence/eval.ts +24 -7
- package/src/domains/evidence/index.ts +53 -0
- package/src/domains/evidence/ordering.ts +12 -0
- package/src/domains/evidence/run-trust.ts +221 -0
- package/src/domains/evidence/store.ts +46 -6
- package/src/domains/evidence/trust-status.ts +854 -0
- package/src/domains/evidence/types.ts +26 -0
- package/src/domains/memory/index.ts +22 -0
- package/src/domains/memory/operations.ts +58 -1
- package/src/domains/memory/promotion.ts +281 -0
- package/src/domains/memory/prompt-section.ts +25 -5
- package/src/domains/memory/proposal.ts +51 -7
- package/src/domains/memory/task-bank.ts +3 -2
- package/src/domains/memory/task-memory-handoff.ts +181 -24
- package/src/domains/memory/task-memory-policy.ts +3 -1
- package/src/domains/memory/types.ts +37 -0
- package/src/domains/memory/validate.ts +178 -0
- package/src/domains/middleware/memory-intervention.ts +38 -25
- package/src/domains/middleware/runtime.ts +6 -0
- package/src/domains/middleware/skills-reminder.ts +19 -4
- package/src/domains/middleware/stalled-turn.ts +208 -5
- package/src/domains/middleware/types.ts +10 -0
- package/src/domains/observability/contract.ts +6 -1
- package/src/domains/observability/cost.ts +20 -4
- package/src/domains/observability/extension.ts +2 -2
- package/src/domains/providers/index.ts +3 -0
- package/src/domains/providers/model-discovery.ts +9 -0
- package/src/domains/providers/runtime-resolution.ts +38 -1
- package/src/domains/providers/runtimes/common/probe-helpers.ts +97 -16
- package/src/domains/providers/types/context-window-slots.ts +18 -0
- package/src/domains/providers/types/runtime-descriptor.ts +3 -1
- package/src/domains/safety/autonomy.ts +1 -1
- package/src/domains/safety/call-target.ts +211 -14
- package/src/domains/safety/decision-presentation.ts +268 -0
- package/src/domains/safety/default-path-policy.ts +8 -0
- package/src/domains/safety/finish-contract.ts +4 -3
- package/src/domains/safety/policy-engine.ts +48 -6
- package/src/domains/safety/redaction.ts +73 -0
- package/src/domains/session/compaction/compact.ts +23 -1
- package/src/domains/session/compaction/cut-point.ts +2 -0
- package/src/domains/session/compaction/tokens.ts +16 -1
- package/src/domains/session/context-ledger.ts +12 -1
- package/src/domains/session/decision-board.ts +4 -0
- package/src/domains/session/entries.ts +110 -1
- package/src/domains/session/history.ts +68 -19
- package/src/domains/session/manager.ts +9 -2
- package/src/domains/session/migrations/index.ts +22 -3
- package/src/domains/session/usage.ts +24 -7
- package/src/engine/acp/event-mapper.ts +7 -0
- package/src/engine/acp/server.ts +32 -2
- package/src/engine/agent.ts +18 -1
- package/src/engine/apis/lmstudio.ts +25 -4
- package/src/engine/apis/openai-completions.ts +147 -22
- package/src/engine/claude/sdk-runtime.ts +8 -2
- package/src/engine/claude/tool-safety.ts +13 -0
- package/src/engine/loop-guard.ts +27 -3
- package/src/engine/session.ts +9 -3
- package/src/engine/worker-events.ts +4 -3
- package/src/engine/worker-runtime.ts +59 -54
- package/src/entry/orchestrator.ts +34 -5
- package/src/interactive/chat-loop-messages.ts +40 -6
- package/src/interactive/chat-loop.ts +13 -0
- package/src/interactive/chat-panel.ts +17 -1
- package/src/interactive/chat-renderer.ts +49 -24
- package/src/interactive/clio-editor.ts +44 -7
- package/src/interactive/context-meter.ts +10 -0
- package/src/interactive/context-overlay.ts +120 -7
- package/src/interactive/context-recall-command.ts +110 -0
- package/src/interactive/cost-overlay.ts +39 -8
- package/src/interactive/dispatch-board.ts +212 -35
- package/src/interactive/footer/widgets.ts +13 -0
- package/src/interactive/interactive-application.ts +6 -1
- package/src/interactive/interactive-input-runtime.ts +11 -1
- package/src/interactive/interactive-presentation.ts +11 -1
- package/src/interactive/interactive-slash-runtime.ts +37 -1
- package/src/interactive/memory-overlay.ts +89 -4
- package/src/interactive/model-session-replay.ts +21 -0
- package/src/interactive/overlay-ask-user-lifecycle.ts +1 -1
- package/src/interactive/overlay-frame.ts +5 -2
- package/src/interactive/overlay-general-openers.ts +46 -1
- package/src/interactive/overlay-key-routing.ts +41 -1
- package/src/interactive/overlay-lifecycle.ts +11 -4
- package/src/interactive/overlay-permission-lifecycle.ts +23 -8
- package/src/interactive/overlay-session-lifecycle.ts +8 -4
- package/src/interactive/overlay-transitions.ts +11 -0
- package/src/interactive/overlays/ask-user.ts +74 -30
- package/src/interactive/overlays/decisions.ts +3 -1
- package/src/interactive/permission-hint.ts +35 -0
- package/src/interactive/permission-overlay.ts +95 -45
- package/src/interactive/renderers/tool-execution.ts +37 -51
- package/src/interactive/session-last-turn.ts +8 -1
- package/src/interactive/session-transcript.ts +2 -2
- package/src/interactive/session-usage-reseed.ts +36 -10
- package/src/interactive/slash-commands.ts +31 -4
- package/src/interactive/status/summary.ts +5 -0
- package/src/interactive/status/types.ts +5 -0
- package/src/interactive/terminal-lease.ts +1 -0
- package/src/interactive/turn-context.ts +333 -110
- package/src/interactive/turn-middleware.ts +7 -6
- package/src/interactive/turn-runtime.ts +37 -8
- package/src/interactive/turn-state.ts +3 -0
- package/src/interactive/worker-progress.ts +440 -0
- package/src/interactive/worker-stream.ts +51 -110
- package/src/tools/agent-tools.ts +39 -7
- package/src/tools/ask-user.ts +21 -1
- package/src/tools/bash.ts +144 -82
- package/src/tools/builtin-tool-catalog.ts +11 -5
- package/src/tools/context/index.ts +107 -5
- package/src/tools/context/surface.ts +3 -2
- package/src/tools/core-bootstrap.ts +21 -0
- package/src/tools/dispatch-arguments.ts +8 -0
- package/src/tools/dispatch-event-text.ts +19 -0
- package/src/tools/dispatch-runner.ts +9 -7
- package/src/tools/dispatch.ts +24 -1
- package/src/tools/monitor.ts +43 -20
- package/src/tools/registry.ts +72 -10
- package/src/tools/result-disposition.ts +706 -0
- package/src/tools/result-shaping.ts +321 -20
- package/src/tools/safe-exec.ts +2 -0
- package/src/tools/verify/authoring.ts +1120 -0
- package/src/tools/verify/catalog.ts +346 -0
- package/src/tools/verify/index.ts +13 -3
- package/src/tools/verify/scripts.ts +135 -37
- package/src/tools/verify/surface.ts +9 -5
- package/src/tools/worker-evidence.ts +54 -12
- package/src/worker/spec-contract.ts +43 -3
- package/dist/chunk-J7CWMCQD.js +0 -255
- package/dist/chunk-T6YILFSB.js +0 -80
- package/dist/chunk-VAKQQHWR.js +0 -434
- package/dist/chunk-VPAYEGVX.js +0 -184
- package/dist/chunk-XBXAASKX.js +0 -18
- package/dist/memory-WFZMGYHX.js +0 -236
- package/src/domains/eval/metrics/chaos-stream.ts +0 -93
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
filterEntriesToActivePath
|
|
4
|
+
} from "./chunk-W6GROXXM.js";
|
|
5
|
+
import {
|
|
6
|
+
init_esm_shims
|
|
7
|
+
} from "./chunk-3R73A4XB.js";
|
|
8
|
+
|
|
9
|
+
// src/domains/context/working-set/fold.ts
|
|
10
|
+
init_esm_shims();
|
|
11
|
+
function refKey(ref) {
|
|
12
|
+
return ref.entry;
|
|
13
|
+
}
|
|
14
|
+
function parseRefKey(key) {
|
|
15
|
+
const trimmed = key.trim();
|
|
16
|
+
if (trimmed.length === 0 || /\s/.test(trimmed)) return null;
|
|
17
|
+
return { entry: trimmed };
|
|
18
|
+
}
|
|
19
|
+
function foldWorkingSet(entries, activeLeafTurnId) {
|
|
20
|
+
const active = filterEntriesToActivePath(entries, activeLeafTurnId);
|
|
21
|
+
const evicted = /* @__PURE__ */ new Map();
|
|
22
|
+
let evictionEvents = 0;
|
|
23
|
+
let itemsEvicted = 0;
|
|
24
|
+
let recalls = 0;
|
|
25
|
+
let lastPolicyId = null;
|
|
26
|
+
let lastEvictionTurnId = null;
|
|
27
|
+
for (const entry of active) {
|
|
28
|
+
if (entry.kind === "contextEviction") {
|
|
29
|
+
evictionEvents += 1;
|
|
30
|
+
lastPolicyId = entry.policyId;
|
|
31
|
+
lastEvictionTurnId = entry.turnId;
|
|
32
|
+
for (const item of entry.evicted) {
|
|
33
|
+
itemsEvicted += 1;
|
|
34
|
+
evicted.set(refKey(item.ref), {
|
|
35
|
+
reason: item.reason,
|
|
36
|
+
marker: item.marker,
|
|
37
|
+
...item.by === void 0 ? {} : { by: item.by },
|
|
38
|
+
tokensFreed: item.tokensFreed,
|
|
39
|
+
evictedAtTurnId: entry.turnId,
|
|
40
|
+
policyId: entry.policyId
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (entry.kind === "contextRecall") recalls += 1;
|
|
46
|
+
}
|
|
47
|
+
return { evicted, evictionEvents, itemsEvicted, recalls, lastPolicyId, lastEvictionTurnId };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/domains/context/working-set/path-index.ts
|
|
51
|
+
init_esm_shims();
|
|
52
|
+
import { basename, isAbsolute, join, normalize, resolve } from "node:path";
|
|
53
|
+
|
|
54
|
+
// src/domains/context/working-set/horizon.ts
|
|
55
|
+
init_esm_shims();
|
|
56
|
+
function isTurnStart(entry) {
|
|
57
|
+
if (entry.kind === "bashExecution" || entry.kind === "branchSummary") return true;
|
|
58
|
+
return entry.kind === "message" && entry.role === "user";
|
|
59
|
+
}
|
|
60
|
+
function protectionCutoffIndex(entries, protectLastTurns) {
|
|
61
|
+
const horizon = Math.max(1, Math.floor(protectLastTurns));
|
|
62
|
+
let seen = 0;
|
|
63
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
64
|
+
const entry = entries[i];
|
|
65
|
+
if (!entry || !isTurnStart(entry)) continue;
|
|
66
|
+
seen += 1;
|
|
67
|
+
if (seen >= horizon) return i;
|
|
68
|
+
}
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/domains/context/working-set/payload.ts
|
|
73
|
+
init_esm_shims();
|
|
74
|
+
function isRecord(value) {
|
|
75
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
76
|
+
}
|
|
77
|
+
function toolResultPayload(payload) {
|
|
78
|
+
const obj = isRecord(payload) ? payload : { result: payload };
|
|
79
|
+
const result = obj.result ?? obj.output ?? obj.out ?? obj.content ?? payload;
|
|
80
|
+
const toolName = typeof obj.toolName === "string" && obj.toolName || typeof obj.name === "string" && obj.name || typeof obj.tool === "string" && obj.tool || "tool";
|
|
81
|
+
return { obj, result, toolName };
|
|
82
|
+
}
|
|
83
|
+
function textFromContent(content) {
|
|
84
|
+
if (!Array.isArray(content)) return "";
|
|
85
|
+
const parts = [];
|
|
86
|
+
for (const block of content) {
|
|
87
|
+
if (!isRecord(block)) continue;
|
|
88
|
+
if (block.type === "text" && typeof block.text === "string") parts.push(block.text);
|
|
89
|
+
}
|
|
90
|
+
return parts.join("");
|
|
91
|
+
}
|
|
92
|
+
function stringifyBody(value) {
|
|
93
|
+
if (value === void 0 || value === null) return "";
|
|
94
|
+
if (typeof value === "string") return value;
|
|
95
|
+
try {
|
|
96
|
+
return JSON.stringify(value) ?? "";
|
|
97
|
+
} catch {
|
|
98
|
+
return String(value);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function toolResultText(result) {
|
|
102
|
+
if (typeof result === "string") return result;
|
|
103
|
+
if (!isRecord(result)) return stringifyBody(result);
|
|
104
|
+
const contentText = textFromContent(result.content);
|
|
105
|
+
if (contentText.length > 0) return contentText;
|
|
106
|
+
if (typeof result.text === "string") return result.text;
|
|
107
|
+
if (typeof result.output === "string") return result.output;
|
|
108
|
+
if (typeof result.message === "string") return result.message;
|
|
109
|
+
return stringifyBody(result);
|
|
110
|
+
}
|
|
111
|
+
function toolResultBodyTokens(payload) {
|
|
112
|
+
return Math.ceil(toolResultText(toolResultPayload(payload).result).length / 4);
|
|
113
|
+
}
|
|
114
|
+
function nestedRecord(parent, key) {
|
|
115
|
+
if (parent === null) return null;
|
|
116
|
+
const value = parent[key];
|
|
117
|
+
return isRecord(value) ? value : null;
|
|
118
|
+
}
|
|
119
|
+
function stringField(record, key) {
|
|
120
|
+
if (record === null) return void 0;
|
|
121
|
+
const value = record[key];
|
|
122
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
123
|
+
}
|
|
124
|
+
function offloadPathOf(payload) {
|
|
125
|
+
const details = nestedRecord(isRecord(payload.result) ? payload.result : null, "details");
|
|
126
|
+
return stringField(nestedRecord(details, "resultDisposition"), "offloadPath") ?? stringField(nestedRecord(details, "observation"), "offloadPath") ?? stringField(nestedRecord(details, "resultSize"), "offloadPath") ?? stringField(nestedRecord(payload.obj, "resultSummary"), "offloadPath");
|
|
127
|
+
}
|
|
128
|
+
function primaryPathOf(payload) {
|
|
129
|
+
const details = nestedRecord(isRecord(payload.result) ? payload.result : null, "details");
|
|
130
|
+
const paths = details?.paths;
|
|
131
|
+
if (!Array.isArray(paths) || paths.length !== 1) return void 0;
|
|
132
|
+
const first = paths[0];
|
|
133
|
+
return typeof first === "string" && first.length > 0 ? first : void 0;
|
|
134
|
+
}
|
|
135
|
+
function isThinkingBlock(block) {
|
|
136
|
+
return isRecord(block) && block.type === "thinking";
|
|
137
|
+
}
|
|
138
|
+
function hasThinking(payload) {
|
|
139
|
+
const obj = isRecord(payload) ? payload : null;
|
|
140
|
+
if (obj === null) return false;
|
|
141
|
+
if (Array.isArray(obj.content) && obj.content.some(isThinkingBlock)) return true;
|
|
142
|
+
return typeof obj.thinking === "string" && obj.thinking.length > 0;
|
|
143
|
+
}
|
|
144
|
+
function withoutThinkingBlocks(content) {
|
|
145
|
+
if (!Array.isArray(content)) return void 0;
|
|
146
|
+
return content.filter((block) => !isThinkingBlock(block));
|
|
147
|
+
}
|
|
148
|
+
function hasLegacyCompactionMarker(payload) {
|
|
149
|
+
if (!isRecord(payload)) return false;
|
|
150
|
+
if (isRecord(payload.contextCompaction)) return true;
|
|
151
|
+
if (isRecord(nestedRecord(payload, "resultSummary")?.contextCompaction)) return true;
|
|
152
|
+
const result = payload.result ?? payload.output ?? payload.out;
|
|
153
|
+
return isRecord(nestedRecord(isRecord(result) ? result : null, "details")?.contextCompaction);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/domains/context/working-set/path-index.ts
|
|
157
|
+
function rangeEnd(range) {
|
|
158
|
+
return range.limit === null ? Number.POSITIVE_INFINITY : range.offset + range.limit;
|
|
159
|
+
}
|
|
160
|
+
function isFullRead(range) {
|
|
161
|
+
return range !== null && range.offset === 0 && range.limit === null;
|
|
162
|
+
}
|
|
163
|
+
function covers(later, earlier) {
|
|
164
|
+
if (isFullRead(later)) return true;
|
|
165
|
+
if (later === null || earlier === null) return false;
|
|
166
|
+
return later.offset <= earlier.offset && rangeEnd(later) >= rangeEnd(earlier);
|
|
167
|
+
}
|
|
168
|
+
var LISTING_COMMANDS = /* @__PURE__ */ new Set(["ls", "find", "tree", "fd", "rg", "grep"]);
|
|
169
|
+
var MATCH_LINE_COMMANDS = /* @__PURE__ */ new Set(["rg", "grep"]);
|
|
170
|
+
var TOOL_OPS = /* @__PURE__ */ new Map([
|
|
171
|
+
["read", "read"],
|
|
172
|
+
["grep", "grep"],
|
|
173
|
+
["find", "find"],
|
|
174
|
+
["ls", "ls"],
|
|
175
|
+
["code_nav", "code_nav"],
|
|
176
|
+
["write", "write"],
|
|
177
|
+
["edit", "edit"],
|
|
178
|
+
["artifact", "write"],
|
|
179
|
+
["bash", "bash"],
|
|
180
|
+
["git", "bash"],
|
|
181
|
+
["verify", "bash"]
|
|
182
|
+
]);
|
|
183
|
+
var CODE_NAV_PATH_MODES = /* @__PURE__ */ new Set(["path", "outline", "deps", "dependents"]);
|
|
184
|
+
var LISTING_OPS = /* @__PURE__ */ new Set(["grep", "find", "ls", "bash"]);
|
|
185
|
+
function canonicalize(value, cwd) {
|
|
186
|
+
const trimmed = value.trim();
|
|
187
|
+
if (trimmed.length === 0) return "";
|
|
188
|
+
if (isAbsolute(trimmed)) return normalize(trimmed);
|
|
189
|
+
return cwd === null ? normalize(trimmed) : resolve(cwd, trimmed);
|
|
190
|
+
}
|
|
191
|
+
function usableCwd(options) {
|
|
192
|
+
const cwd = options?.cwd;
|
|
193
|
+
if (typeof cwd !== "string" || cwd.trim().length === 0 || !isAbsolute(cwd)) return null;
|
|
194
|
+
return normalize(cwd);
|
|
195
|
+
}
|
|
196
|
+
function stableStringify(value) {
|
|
197
|
+
if (value === null) return "null";
|
|
198
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
199
|
+
if (isRecord(value)) {
|
|
200
|
+
const keys = Object.keys(value).sort();
|
|
201
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
|
|
202
|
+
}
|
|
203
|
+
if (value === void 0) return "null";
|
|
204
|
+
return JSON.stringify(value) ?? "null";
|
|
205
|
+
}
|
|
206
|
+
function callFacts(toolName, args) {
|
|
207
|
+
return { toolName, args, argsKey: args === void 0 ? "" : stableStringify(args) };
|
|
208
|
+
}
|
|
209
|
+
function stringField2(record, ...keys) {
|
|
210
|
+
if (record === null) return null;
|
|
211
|
+
for (const key of keys) {
|
|
212
|
+
const value = record[key];
|
|
213
|
+
if (typeof value === "string" && value.trim().length > 0) return value.trim();
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
function payloadRecord(payload) {
|
|
218
|
+
return isRecord(payload) ? payload : null;
|
|
219
|
+
}
|
|
220
|
+
function collectToolCalls(entries) {
|
|
221
|
+
const calls = /* @__PURE__ */ new Map();
|
|
222
|
+
for (const entry of entries) {
|
|
223
|
+
if (entry.kind !== "message") continue;
|
|
224
|
+
const obj = payloadRecord(entry.payload);
|
|
225
|
+
if (entry.role === "tool_call" && obj !== null) {
|
|
226
|
+
const id = stringField2(obj, "toolCallId", "tool_call_id", "id") ?? entry.turnId;
|
|
227
|
+
const name = stringField2(obj, "name", "toolName", "tool") ?? "tool";
|
|
228
|
+
calls.set(id, callFacts(name, obj.args ?? obj.arguments ?? obj.input));
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (entry.role !== "assistant" || obj === null || !Array.isArray(obj.content)) continue;
|
|
232
|
+
for (const block of obj.content) {
|
|
233
|
+
if (!isRecord(block) || block.type !== "toolCall") continue;
|
|
234
|
+
const id = stringField2(block, "id", "toolCallId") ?? entry.turnId;
|
|
235
|
+
const name = stringField2(block, "name", "toolName") ?? "tool";
|
|
236
|
+
calls.set(id, callFacts(name, block.arguments ?? block.args ?? block.input));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return calls;
|
|
240
|
+
}
|
|
241
|
+
function callPathsByToolCallId(entries) {
|
|
242
|
+
const paths = /* @__PURE__ */ new Map();
|
|
243
|
+
for (const [id, call] of collectToolCalls(entries)) {
|
|
244
|
+
const named = stringField2(isRecord(call.args) ? call.args : null, "path", "file_path", "filePath");
|
|
245
|
+
if (named !== null) paths.set(id, named);
|
|
246
|
+
}
|
|
247
|
+
return paths;
|
|
248
|
+
}
|
|
249
|
+
function observedPath(op, args, cwd) {
|
|
250
|
+
if (op === "bash") {
|
|
251
|
+
const explicit = stringField2(args, "cwd");
|
|
252
|
+
return explicit === null ? "" : canonicalize(explicit, cwd);
|
|
253
|
+
}
|
|
254
|
+
if (op === "code_nav") {
|
|
255
|
+
const mode = stringField2(args, "mode");
|
|
256
|
+
if (mode === null || !CODE_NAV_PATH_MODES.has(mode)) return "";
|
|
257
|
+
const query = stringField2(args, "query");
|
|
258
|
+
return query === null ? "" : canonicalize(query, cwd);
|
|
259
|
+
}
|
|
260
|
+
const named = stringField2(args, "path", "file_path", "filePath");
|
|
261
|
+
if (named !== null) return canonicalize(named, cwd);
|
|
262
|
+
if (op === "grep" || op === "find" || op === "ls") return cwd ?? ".";
|
|
263
|
+
return "";
|
|
264
|
+
}
|
|
265
|
+
function readRange(args) {
|
|
266
|
+
if (args === null) return { offset: 0, limit: null };
|
|
267
|
+
const tail = args.tail;
|
|
268
|
+
if (typeof tail === "number" && Number.isFinite(tail) && tail > 0) return null;
|
|
269
|
+
const rawOffset = args.offset;
|
|
270
|
+
const rawLimit = args.limit;
|
|
271
|
+
const offset = typeof rawOffset === "number" && Number.isFinite(rawOffset) && rawOffset > 1 ? Math.floor(rawOffset) - 1 : 0;
|
|
272
|
+
const limit = typeof rawLimit === "number" && Number.isFinite(rawLimit) && rawLimit > 0 ? Math.floor(rawLimit) : null;
|
|
273
|
+
return { offset, limit };
|
|
274
|
+
}
|
|
275
|
+
function looksLikeConcreteFilePath(line) {
|
|
276
|
+
const text = line.trim();
|
|
277
|
+
if (text.length === 0) return false;
|
|
278
|
+
if (text.startsWith("[")) return false;
|
|
279
|
+
if (text.endsWith("/")) return false;
|
|
280
|
+
return !/\s/.test(text);
|
|
281
|
+
}
|
|
282
|
+
function pathFromMatchLine(line) {
|
|
283
|
+
const match = /^([^\s:]+):\d+[:-]/.exec(line.trim());
|
|
284
|
+
return match?.[1] ?? null;
|
|
285
|
+
}
|
|
286
|
+
function surfacedPaths(op, args, text, root, cwd) {
|
|
287
|
+
const lines = text.split("\n");
|
|
288
|
+
const matchLines = op === "grep" || op === "bash" && isMatchLineCommand(args);
|
|
289
|
+
const out = [];
|
|
290
|
+
const seen = /* @__PURE__ */ new Set();
|
|
291
|
+
for (const line of lines) {
|
|
292
|
+
const raw = matchLines ? pathFromMatchLine(line) ?? candidateWholeLine(line) : candidateWholeLine(line);
|
|
293
|
+
if (raw === null) continue;
|
|
294
|
+
const resolved = resolveSurfaced(raw, root, cwd);
|
|
295
|
+
if (resolved.length === 0 || seen.has(resolved)) continue;
|
|
296
|
+
seen.add(resolved);
|
|
297
|
+
out.push(resolved);
|
|
298
|
+
}
|
|
299
|
+
return out;
|
|
300
|
+
}
|
|
301
|
+
function candidateWholeLine(line) {
|
|
302
|
+
return looksLikeConcreteFilePath(line) ? line.trim() : null;
|
|
303
|
+
}
|
|
304
|
+
function isMatchLineCommand(args) {
|
|
305
|
+
const verb = commandVerb(args);
|
|
306
|
+
return verb !== null && MATCH_LINE_COMMANDS.has(verb);
|
|
307
|
+
}
|
|
308
|
+
function commandVerb(args) {
|
|
309
|
+
const command = stringField2(args, "command");
|
|
310
|
+
if (command === null) return null;
|
|
311
|
+
const first = command.trimStart().split(/\s+/)[0];
|
|
312
|
+
return first === void 0 || first.length === 0 ? null : basename(first);
|
|
313
|
+
}
|
|
314
|
+
function resolveSurfaced(value, root, cwd) {
|
|
315
|
+
if (isAbsolute(value)) return normalize(value);
|
|
316
|
+
if (root.length === 0) return canonicalize(value, cwd);
|
|
317
|
+
if (basename(root) === value) return canonicalize(root, cwd);
|
|
318
|
+
return canonicalize(join(root, value), cwd);
|
|
319
|
+
}
|
|
320
|
+
function shouldParseSurfaced(op, args, isError) {
|
|
321
|
+
if (isError || !LISTING_OPS.has(op)) return false;
|
|
322
|
+
if (op !== "bash") return true;
|
|
323
|
+
const verb = commandVerb(args);
|
|
324
|
+
return verb !== null && LISTING_COMMANDS.has(verb);
|
|
325
|
+
}
|
|
326
|
+
function fileEntryOp(operation) {
|
|
327
|
+
if (operation === "read") return "read";
|
|
328
|
+
if (operation === "edit") return "edit";
|
|
329
|
+
return "write";
|
|
330
|
+
}
|
|
331
|
+
function toolResultObservation(entry, context) {
|
|
332
|
+
const obj = payloadRecord(entry.payload);
|
|
333
|
+
const toolCallId = stringField2(obj, "toolCallId", "tool_call_id", "id");
|
|
334
|
+
const call = toolCallId === null ? void 0 : context.calls.get(toolCallId);
|
|
335
|
+
const toolName = stringField2(obj, "toolName", "name", "tool") ?? call?.toolName ?? "tool";
|
|
336
|
+
const op = TOOL_OPS.get(toolName);
|
|
337
|
+
if (op === void 0) return null;
|
|
338
|
+
const args = call !== void 0 && isRecord(call.args) ? call.args : null;
|
|
339
|
+
const isError = obj?.isError === true || obj?.error === true;
|
|
340
|
+
const isBlocked = obj?.outcome === "blocked" || typeof obj?.blockReason === "string";
|
|
341
|
+
const path = observedPath(op, args, context.cwd);
|
|
342
|
+
const surfaced = shouldParseSurfaced(op, args, isError) ? surfacedPaths(op, args, toolResultText(obj?.result ?? entry.payload), path, context.cwd) : [];
|
|
343
|
+
return {
|
|
344
|
+
ref: { entry: entry.turnId },
|
|
345
|
+
toolCallId,
|
|
346
|
+
toolName,
|
|
347
|
+
op,
|
|
348
|
+
path,
|
|
349
|
+
range: op === "read" ? readRange(args) : null,
|
|
350
|
+
surfaced,
|
|
351
|
+
isError,
|
|
352
|
+
isBlocked,
|
|
353
|
+
turnIndex: context.turnIndex,
|
|
354
|
+
entryIndex: context.entryIndex,
|
|
355
|
+
argsKey: call?.argsKey ?? ""
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function buildPathIndex(entries, options) {
|
|
359
|
+
const cwd = usableCwd(options);
|
|
360
|
+
const calls = collectToolCalls(entries);
|
|
361
|
+
const observations = [];
|
|
362
|
+
const byRef = /* @__PURE__ */ new Map();
|
|
363
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
364
|
+
const turnIndexOf = /* @__PURE__ */ new Map();
|
|
365
|
+
let turnIndex = 0;
|
|
366
|
+
for (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {
|
|
367
|
+
const entry = entries[entryIndex];
|
|
368
|
+
if (entry === void 0) continue;
|
|
369
|
+
turnIndexOf.set(entry.turnId, turnIndex);
|
|
370
|
+
let observation = null;
|
|
371
|
+
if (entry.kind === "fileEntry") {
|
|
372
|
+
observation = {
|
|
373
|
+
ref: { entry: entry.turnId },
|
|
374
|
+
toolCallId: null,
|
|
375
|
+
toolName: "fileEntry",
|
|
376
|
+
op: fileEntryOp(entry.operation),
|
|
377
|
+
path: canonicalize(entry.path, cwd),
|
|
378
|
+
range: null,
|
|
379
|
+
surfaced: [],
|
|
380
|
+
isError: false,
|
|
381
|
+
isBlocked: false,
|
|
382
|
+
turnIndex,
|
|
383
|
+
entryIndex,
|
|
384
|
+
argsKey: ""
|
|
385
|
+
};
|
|
386
|
+
} else if (entry.kind === "message" && entry.role === "tool_result") {
|
|
387
|
+
observation = toolResultObservation(entry, { entryIndex, turnIndex, cwd, calls });
|
|
388
|
+
}
|
|
389
|
+
if (observation !== null) {
|
|
390
|
+
observations.push(observation);
|
|
391
|
+
byRef.set(observation.ref.entry, observation);
|
|
392
|
+
if (observation.path.length > 0) {
|
|
393
|
+
const bucket = byPath.get(observation.path);
|
|
394
|
+
if (bucket === void 0) byPath.set(observation.path, [observation]);
|
|
395
|
+
else bucket.push(observation);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (isTurnStart(entry)) turnIndex += 1;
|
|
399
|
+
}
|
|
400
|
+
return { observations, byRef, byPath, turnIndexOf, turnCount: turnIndex };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/domains/context/working-set/contract.ts
|
|
404
|
+
init_esm_shims();
|
|
405
|
+
var EMPTY_WORKING_SET_VIEW = Object.freeze({
|
|
406
|
+
evicted: /* @__PURE__ */ new Map(),
|
|
407
|
+
evictionEvents: 0,
|
|
408
|
+
itemsEvicted: 0,
|
|
409
|
+
recalls: 0,
|
|
410
|
+
lastPolicyId: null,
|
|
411
|
+
lastEvictionTurnId: null
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
export {
|
|
415
|
+
refKey,
|
|
416
|
+
parseRefKey,
|
|
417
|
+
foldWorkingSet,
|
|
418
|
+
EMPTY_WORKING_SET_VIEW,
|
|
419
|
+
isTurnStart,
|
|
420
|
+
protectionCutoffIndex,
|
|
421
|
+
isRecord,
|
|
422
|
+
toolResultPayload,
|
|
423
|
+
toolResultText,
|
|
424
|
+
toolResultBodyTokens,
|
|
425
|
+
offloadPathOf,
|
|
426
|
+
primaryPathOf,
|
|
427
|
+
hasThinking,
|
|
428
|
+
withoutThinkingBlocks,
|
|
429
|
+
hasLegacyCompactionMarker,
|
|
430
|
+
covers,
|
|
431
|
+
callPathsByToolCallId,
|
|
432
|
+
buildPathIndex
|
|
433
|
+
};
|
|
434
|
+
//# sourceMappingURL=chunk-TZSKNMZG.js.map
|
|
@@ -7,9 +7,13 @@ import {
|
|
|
7
7
|
init_esm_shims();
|
|
8
8
|
var VERIFICATION_SCRIPT_FAMILY_HINT = "test*/lint*/build*/typecheck*/check*/format*/ci*";
|
|
9
9
|
var VERIFICATION_SCRIPT_PATTERN = /^(?:test|lint|build|typecheck|check|format|ci)(?:[:.-].*)?$/;
|
|
10
|
+
var PROJECT_VERIFIER_CHECK_ID_PATTERN = /^[a-z0-9][a-z0-9._:-]*$/;
|
|
10
11
|
function isVerificationScriptName(name) {
|
|
11
12
|
return VERIFICATION_SCRIPT_PATTERN.test(name);
|
|
12
13
|
}
|
|
14
|
+
function isProjectVerifierCheckId(name) {
|
|
15
|
+
return PROJECT_VERIFIER_CHECK_ID_PATTERN.test(name);
|
|
16
|
+
}
|
|
13
17
|
function declaredVerificationScripts(scripts) {
|
|
14
18
|
return Object.keys(scripts).filter((name) => isVerificationScriptName(name)).sort((a, b) => a.localeCompare(b));
|
|
15
19
|
}
|
|
@@ -17,6 +21,7 @@ function declaredVerificationScripts(scripts) {
|
|
|
17
21
|
export {
|
|
18
22
|
VERIFICATION_SCRIPT_FAMILY_HINT,
|
|
19
23
|
isVerificationScriptName,
|
|
24
|
+
isProjectVerifierCheckId,
|
|
20
25
|
declaredVerificationScripts
|
|
21
26
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-UL3WSD3F.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
WORKSPACE_EXCLUDED_DIRS,
|
|
8
8
|
enumerateWorkspaceFiles,
|
|
9
9
|
enumerateWorkspaceFilesAsync
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-33YXPOE3.js";
|
|
11
11
|
import {
|
|
12
12
|
init_esm_shims
|
|
13
13
|
} from "./chunk-3R73A4XB.js";
|
|
@@ -241,4 +241,4 @@ export {
|
|
|
241
241
|
computeFingerprintCached,
|
|
242
242
|
isStale
|
|
243
243
|
};
|
|
244
|
-
//# sourceMappingURL=chunk-
|
|
244
|
+
//# sourceMappingURL=chunk-UUVG37B4.js.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
clampTimerDelayMs
|
|
4
|
+
} from "./chunk-FQ4SKYE4.js";
|
|
2
5
|
import {
|
|
3
6
|
clioStateDir
|
|
4
7
|
} from "./chunk-BNAZZHFG.js";
|
|
@@ -390,11 +393,176 @@ function withManagedGitCommitAttributionEnvironment(source, options = {}) {
|
|
|
390
393
|
return { env, diagnostic: null };
|
|
391
394
|
}
|
|
392
395
|
|
|
396
|
+
// src/core/safe-exec.ts
|
|
397
|
+
init_esm_shims();
|
|
398
|
+
import { spawn } from "node:child_process";
|
|
399
|
+
import path from "node:path";
|
|
400
|
+
import { performance } from "node:perf_hooks";
|
|
401
|
+
var SAFE_EXEC_DEFAULT_TIMEOUT_MS = 12e4;
|
|
402
|
+
var SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES = 6e5;
|
|
403
|
+
var ENV_ALLOWLIST = [
|
|
404
|
+
"PATH",
|
|
405
|
+
"HOME",
|
|
406
|
+
"USER",
|
|
407
|
+
"LOGNAME",
|
|
408
|
+
"LANG",
|
|
409
|
+
"LC_ALL",
|
|
410
|
+
"TMPDIR",
|
|
411
|
+
"TEMP",
|
|
412
|
+
"TMP",
|
|
413
|
+
"CI",
|
|
414
|
+
"NO_COLOR"
|
|
415
|
+
];
|
|
416
|
+
function buildSafeToolEnv(extra = {}) {
|
|
417
|
+
const env = {};
|
|
418
|
+
for (const key of ENV_ALLOWLIST) {
|
|
419
|
+
const value = process.env[key];
|
|
420
|
+
if (value !== void 0) env[key] = value;
|
|
421
|
+
}
|
|
422
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
423
|
+
if (!/^[A-Z_][A-Z0-9_]*$/i.test(key)) continue;
|
|
424
|
+
env[key] = value;
|
|
425
|
+
}
|
|
426
|
+
env.AI_AGENT = AI_AGENT_NAME;
|
|
427
|
+
return env;
|
|
428
|
+
}
|
|
429
|
+
function resolveSafeCwd(cwd, workspaceRoot = process.cwd()) {
|
|
430
|
+
const root = path.resolve(workspaceRoot);
|
|
431
|
+
const resolved = cwd === void 0 ? root : path.isAbsolute(cwd) ? path.resolve(cwd) : path.resolve(root, cwd);
|
|
432
|
+
const rel = path.relative(root, resolved);
|
|
433
|
+
if (rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel)) return resolved;
|
|
434
|
+
throw new Error(`cwd escapes workspace root: ${resolved}`);
|
|
435
|
+
}
|
|
436
|
+
function runCommandVector(file, args, options = {}) {
|
|
437
|
+
return new Promise((resolve2) => {
|
|
438
|
+
const startedAt = performance.now();
|
|
439
|
+
const cwd = resolveSafeCwd(options.cwd, options.workspaceRoot);
|
|
440
|
+
const timeoutMs = clampTimerDelayMs(options.timeoutMs ?? SAFE_EXEC_DEFAULT_TIMEOUT_MS);
|
|
441
|
+
const maxOutputBytes = options.maxOutputBytes ?? SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES;
|
|
442
|
+
const attribution = withManagedGitCommitAttributionEnvironment(buildSafeToolEnv(options.env), {
|
|
443
|
+
cwd,
|
|
444
|
+
enabled: gitCommitAttributionEnabled(process.env)
|
|
445
|
+
});
|
|
446
|
+
reportCommitAttributionDiagnostic(attribution.diagnostic);
|
|
447
|
+
let aborted = false;
|
|
448
|
+
let timedOut = false;
|
|
449
|
+
let outputCapped = false;
|
|
450
|
+
let outputBytes = 0;
|
|
451
|
+
let stdout = "";
|
|
452
|
+
let stderr = "";
|
|
453
|
+
let settled = false;
|
|
454
|
+
let killSent = false;
|
|
455
|
+
let timeoutId = null;
|
|
456
|
+
let killGraceTimer = null;
|
|
457
|
+
const child = spawn(file, [...args], {
|
|
458
|
+
cwd,
|
|
459
|
+
env: attribution.env,
|
|
460
|
+
detached: process.platform !== "win32",
|
|
461
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
462
|
+
});
|
|
463
|
+
const clearKillGraceTimer = () => {
|
|
464
|
+
if (killGraceTimer) clearTimeout(killGraceTimer);
|
|
465
|
+
killGraceTimer = null;
|
|
466
|
+
};
|
|
467
|
+
const sendSignal = (signalName) => {
|
|
468
|
+
const pid = child.pid;
|
|
469
|
+
if (pid && process.platform !== "win32") {
|
|
470
|
+
try {
|
|
471
|
+
process.kill(-pid, signalName);
|
|
472
|
+
return;
|
|
473
|
+
} catch {
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
child.kill(signalName);
|
|
477
|
+
};
|
|
478
|
+
const killChild = () => {
|
|
479
|
+
if (killSent) return;
|
|
480
|
+
killSent = true;
|
|
481
|
+
sendSignal("SIGTERM");
|
|
482
|
+
killGraceTimer = setTimeout(() => sendSignal("SIGKILL"), 3e3);
|
|
483
|
+
};
|
|
484
|
+
const onAbort = () => {
|
|
485
|
+
aborted = true;
|
|
486
|
+
killChild();
|
|
487
|
+
};
|
|
488
|
+
if (timeoutMs > 0) {
|
|
489
|
+
timeoutId = setTimeout(() => {
|
|
490
|
+
timedOut = true;
|
|
491
|
+
killChild();
|
|
492
|
+
}, timeoutMs);
|
|
493
|
+
}
|
|
494
|
+
if (options.signal?.aborted) onAbort();
|
|
495
|
+
else options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
496
|
+
const appendChunk = (target, chunk) => {
|
|
497
|
+
outputBytes += chunk.byteLength;
|
|
498
|
+
if (outputBytes > maxOutputBytes) {
|
|
499
|
+
outputCapped = true;
|
|
500
|
+
killChild();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (target === "stdout") stdout += chunk.toString("utf8");
|
|
504
|
+
else stderr += chunk.toString("utf8");
|
|
505
|
+
};
|
|
506
|
+
child.stdout?.on("data", (chunk) => appendChunk("stdout", chunk));
|
|
507
|
+
child.stderr?.on("data", (chunk) => appendChunk("stderr", chunk));
|
|
508
|
+
child.on("error", (error) => {
|
|
509
|
+
if (settled) return;
|
|
510
|
+
settled = true;
|
|
511
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
512
|
+
clearKillGraceTimer();
|
|
513
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
514
|
+
resolve2({
|
|
515
|
+
file,
|
|
516
|
+
args: [...args],
|
|
517
|
+
cwd,
|
|
518
|
+
stdout,
|
|
519
|
+
stderr: stderr.length > 0 ? stderr : error.message,
|
|
520
|
+
exitCode: null,
|
|
521
|
+
signal: null,
|
|
522
|
+
aborted,
|
|
523
|
+
timedOut,
|
|
524
|
+
outputCapped,
|
|
525
|
+
durationMs: Math.round(performance.now() - startedAt)
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
child.on("close", (code, signalName) => {
|
|
529
|
+
if (settled) return;
|
|
530
|
+
settled = true;
|
|
531
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
532
|
+
clearKillGraceTimer();
|
|
533
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
534
|
+
resolve2({
|
|
535
|
+
file,
|
|
536
|
+
args: [...args],
|
|
537
|
+
cwd,
|
|
538
|
+
stdout,
|
|
539
|
+
stderr,
|
|
540
|
+
exitCode: code,
|
|
541
|
+
signal: signalName,
|
|
542
|
+
aborted,
|
|
543
|
+
timedOut,
|
|
544
|
+
outputCapped,
|
|
545
|
+
durationMs: Math.round(performance.now() - startedAt)
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function combineSafeOutput(result) {
|
|
551
|
+
const { stdout, stderr } = result;
|
|
552
|
+
return stderr.length > 0 ? `${stdout}${stdout.endsWith("\n") || stdout.length === 0 ? "" : "\n"}${stderr}` : stdout;
|
|
553
|
+
}
|
|
554
|
+
|
|
393
555
|
export {
|
|
394
556
|
attributeCommitMessage,
|
|
395
557
|
reportCommitAttributionDiagnostic,
|
|
396
558
|
setGitCommitAttributionEnabled,
|
|
397
559
|
gitCommitAttributionEnabled,
|
|
398
|
-
withManagedGitCommitAttributionEnvironment
|
|
560
|
+
withManagedGitCommitAttributionEnvironment,
|
|
561
|
+
SAFE_EXEC_DEFAULT_TIMEOUT_MS,
|
|
562
|
+
SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES,
|
|
563
|
+
buildSafeToolEnv,
|
|
564
|
+
resolveSafeCwd,
|
|
565
|
+
runCommandVector,
|
|
566
|
+
combineSafeOutput
|
|
399
567
|
};
|
|
400
|
-
//# sourceMappingURL=chunk-
|
|
568
|
+
//# sourceMappingURL=chunk-VEZEGCGW.js.map
|