@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
package/dist/chunk-VAKQQHWR.js
DELETED
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
byteLength,
|
|
4
|
-
truncateUtf8
|
|
5
|
-
} from "./chunk-6XLNIQDB.js";
|
|
6
|
-
import {
|
|
7
|
-
GUARDRAIL_DEFAULTS,
|
|
8
|
-
GUARDRAIL_ENV_VARS,
|
|
9
|
-
resolveGuardrail
|
|
10
|
-
} from "./chunk-4ZG3XFUR.js";
|
|
11
|
-
import {
|
|
12
|
-
clioStateDir
|
|
13
|
-
} from "./chunk-BNAZZHFG.js";
|
|
14
|
-
import {
|
|
15
|
-
init_esm_shims
|
|
16
|
-
} from "./chunk-3R73A4XB.js";
|
|
17
|
-
|
|
18
|
-
// src/tools/truncate.ts
|
|
19
|
-
init_esm_shims();
|
|
20
|
-
|
|
21
|
-
// src/engine/truncate.ts
|
|
22
|
-
init_esm_shims();
|
|
23
|
-
import {
|
|
24
|
-
formatSize,
|
|
25
|
-
GREP_MAX_LINE_LENGTH,
|
|
26
|
-
truncateHead,
|
|
27
|
-
truncateLine,
|
|
28
|
-
truncateTail
|
|
29
|
-
} from "@earendil-works/pi-agent-core";
|
|
30
|
-
|
|
31
|
-
// src/tools/truncate.ts
|
|
32
|
-
var DEFAULT_MAX_LINES = 2e3;
|
|
33
|
-
var DEFAULT_MAX_BYTES = 16 * 1024;
|
|
34
|
-
function splitLinesForCounting(content) {
|
|
35
|
-
if (content.length === 0) return [];
|
|
36
|
-
const lines = content.split("\n");
|
|
37
|
-
if (content.endsWith("\n")) lines.pop();
|
|
38
|
-
return lines;
|
|
39
|
-
}
|
|
40
|
-
function withClioDefaults(options) {
|
|
41
|
-
return {
|
|
42
|
-
maxLines: options.maxLines ?? DEFAULT_MAX_LINES,
|
|
43
|
-
maxBytes: options.maxBytes ?? DEFAULT_MAX_BYTES
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function truncateHead2(content, options = {}) {
|
|
47
|
-
return truncateHead(content, withClioDefaults(options));
|
|
48
|
-
}
|
|
49
|
-
function truncateTail2(content, options = {}) {
|
|
50
|
-
return truncateTail(content, withClioDefaults(options));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/tools/observation.ts
|
|
54
|
-
init_esm_shims();
|
|
55
|
-
|
|
56
|
-
// src/tools/result-shaping.ts
|
|
57
|
-
init_esm_shims();
|
|
58
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
59
|
-
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
60
|
-
var DEFAULT_TOOL_RESULT_MAX_BYTES = DEFAULT_MAX_BYTES + 2 * 1024;
|
|
61
|
-
var RESULT_TRUNCATION_MARKER = "\n[tool result truncated]";
|
|
62
|
-
var RESULT_OFFLOAD_MAX_BYTES = 10 * 1024 * 1024;
|
|
63
|
-
function mergeDetails(details, resultSize) {
|
|
64
|
-
return { ...details ?? {}, resultSize };
|
|
65
|
-
}
|
|
66
|
-
function maxBytesFor(spec) {
|
|
67
|
-
const configured = spec.metadata?.resultSizePolicy?.maxBytes;
|
|
68
|
-
return typeof configured === "number" && Number.isFinite(configured) && configured > 0 ? Math.floor(configured) : DEFAULT_TOOL_RESULT_MAX_BYTES;
|
|
69
|
-
}
|
|
70
|
-
function followUpHint(spec) {
|
|
71
|
-
return spec.metadata?.resultSizePolicy?.followUpHint ?? "Use a narrower query, offset/limit arguments, or a more specific tool call to inspect the omitted content.";
|
|
72
|
-
}
|
|
73
|
-
function detailsRecord(details, key) {
|
|
74
|
-
const candidate = details?.[key];
|
|
75
|
-
return candidate !== null && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : null;
|
|
76
|
-
}
|
|
77
|
-
function existingOffloadPath(details) {
|
|
78
|
-
const fromResultSize = detailsRecord(details, "resultSize")?.offloadPath;
|
|
79
|
-
if (typeof fromResultSize === "string" && fromResultSize.length > 0) return fromResultSize;
|
|
80
|
-
const fromObservation = detailsRecord(details, "observation")?.offloadPath;
|
|
81
|
-
return typeof fromObservation === "string" && fromObservation.length > 0 ? fromObservation : null;
|
|
82
|
-
}
|
|
83
|
-
function safePathSegment(value) {
|
|
84
|
-
const safe = value.trim().replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 128);
|
|
85
|
-
return safe.length > 0 ? safe : "unnamed";
|
|
86
|
-
}
|
|
87
|
-
function timestampSegment() {
|
|
88
|
-
return (/* @__PURE__ */ new Date()).toISOString().replace(/[^A-Za-z0-9._-]/g, "_");
|
|
89
|
-
}
|
|
90
|
-
function offloadBody(text, bytes, maxBytes) {
|
|
91
|
-
if (bytes <= maxBytes) return text;
|
|
92
|
-
const notice = `
|
|
93
|
-
[clio-coder scratch output truncated at ${maxBytes} bytes; original size ${bytes} bytes]`;
|
|
94
|
-
const prefixBudget = maxBytes - byteLength(notice);
|
|
95
|
-
return `${truncateUtf8(text, Math.max(0, prefixBudget), "")}${notice}`;
|
|
96
|
-
}
|
|
97
|
-
function writeToolOffload(text, context, maxBytes = RESULT_OFFLOAD_MAX_BYTES) {
|
|
98
|
-
try {
|
|
99
|
-
const bytes = byteLength(text);
|
|
100
|
-
const sessionId = safePathSegment(context?.sessionId ?? "no-session");
|
|
101
|
-
const callId = safePathSegment(context?.toolCallId ?? timestampSegment());
|
|
102
|
-
const dir = join(clioStateDir(), "scratch", sessionId);
|
|
103
|
-
const path = join(dir, `${callId}.txt`);
|
|
104
|
-
mkdirSync(dir, { recursive: true });
|
|
105
|
-
writeFileSync(path, offloadBody(text, bytes, maxBytes), "utf8");
|
|
106
|
-
return path;
|
|
107
|
-
} catch {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
var OFFLOAD_POINTER_NOTE = "overflow copy, read-only; not the workspace";
|
|
112
|
-
function offloadPointer(offloadPath) {
|
|
113
|
-
return `full: ${offloadPath} (${OFFLOAD_POINTER_NOTE})`;
|
|
114
|
-
}
|
|
115
|
-
function isSessionOffloadPath(filePath, sessionId) {
|
|
116
|
-
const dir = join(clioStateDir(), "scratch", safePathSegment(sessionId ?? "no-session"));
|
|
117
|
-
const rel = relative(dir, resolve(filePath));
|
|
118
|
-
return rel.length > 0 && !rel.startsWith("..") && !isAbsolute(rel);
|
|
119
|
-
}
|
|
120
|
-
function bracketedHint(spec, offloadPath) {
|
|
121
|
-
const hint = followUpHint(spec);
|
|
122
|
-
if (offloadPath === null) return hint;
|
|
123
|
-
return `${hint} ${offloadPointer(offloadPath)}; read it with offset and limit to inspect the rest.`;
|
|
124
|
-
}
|
|
125
|
-
function shapeJsonOverflow(spec, result, text, bytes, maxBytes, context) {
|
|
126
|
-
const observation = detailsRecord(result.details, "observation");
|
|
127
|
-
const offloadPath = writeToolOffload(text, context);
|
|
128
|
-
const next = typeof observation?.next === "string" && observation.next.length > 0 ? observation.next : followUpHint(spec);
|
|
129
|
-
const stub = JSON.stringify({
|
|
130
|
-
error: `result exceeded ${maxBytes} bytes`,
|
|
131
|
-
...offloadPath !== null ? { offloadPath, offloadPathNote: OFFLOAD_POINTER_NOTE } : {},
|
|
132
|
-
next
|
|
133
|
-
});
|
|
134
|
-
const resultSize = {
|
|
135
|
-
bytes,
|
|
136
|
-
shownBytes: byteLength(stub),
|
|
137
|
-
maxBytes,
|
|
138
|
-
truncated: true,
|
|
139
|
-
policy: spec.metadata?.resultSizePolicy?.kind ?? "truncate",
|
|
140
|
-
followUpHint: followUpHint(spec),
|
|
141
|
-
...offloadPath !== null ? { offloadPath } : {}
|
|
142
|
-
};
|
|
143
|
-
if (result.kind === "ok") {
|
|
144
|
-
return { ...result, output: stub, details: mergeDetails(result.details, resultSize) };
|
|
145
|
-
}
|
|
146
|
-
return { ...result, message: stub, details: mergeDetails(result.details, resultSize) };
|
|
147
|
-
}
|
|
148
|
-
function shapeToolResult(spec, result, context) {
|
|
149
|
-
if (existingOffloadPath(result.details) !== null) return result;
|
|
150
|
-
const maxBytes = maxBytesFor(spec);
|
|
151
|
-
const text = result.kind === "ok" ? result.output : result.message;
|
|
152
|
-
const bytes = byteLength(text);
|
|
153
|
-
if (bytes <= maxBytes) return result;
|
|
154
|
-
const observation = detailsRecord(result.details, "observation");
|
|
155
|
-
if (observation?.format === "json") return shapeJsonOverflow(spec, result, text, bytes, maxBytes, context);
|
|
156
|
-
const truncated = truncateUtf8(text, maxBytes, RESULT_TRUNCATION_MARKER);
|
|
157
|
-
const offloadPath = writeToolOffload(text, context);
|
|
158
|
-
const resultSize = {
|
|
159
|
-
bytes,
|
|
160
|
-
shownBytes: byteLength(truncated),
|
|
161
|
-
maxBytes,
|
|
162
|
-
truncated: true,
|
|
163
|
-
policy: spec.metadata?.resultSizePolicy?.kind ?? "truncate",
|
|
164
|
-
followUpHint: followUpHint(spec),
|
|
165
|
-
...offloadPath !== null ? { offloadPath } : {}
|
|
166
|
-
};
|
|
167
|
-
if (result.kind === "ok") {
|
|
168
|
-
return {
|
|
169
|
-
...result,
|
|
170
|
-
output: `${truncated}
|
|
171
|
-
|
|
172
|
-
[${bracketedHint(spec, offloadPath)}]`,
|
|
173
|
-
details: mergeDetails(result.details, resultSize)
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
...result,
|
|
178
|
-
message: `${truncated}
|
|
179
|
-
|
|
180
|
-
[${bracketedHint(spec, offloadPath)}]`,
|
|
181
|
-
details: mergeDetails(result.details, resultSize)
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// src/tools/observation.ts
|
|
186
|
-
var OBSERVATION_POLICY_SLACK_BYTES = 2 * 1024;
|
|
187
|
-
var OBSERVE_SELF_CAPS = {
|
|
188
|
-
grepContent: 16 * 1024,
|
|
189
|
-
grepFilesCount: 8 * 1024,
|
|
190
|
-
find: 8 * 1024,
|
|
191
|
-
ls: 8 * 1024,
|
|
192
|
-
codeNav: 16 * 1024,
|
|
193
|
-
contextDocs: 16 * 1024,
|
|
194
|
-
contextSkills: 50 * 1024,
|
|
195
|
-
contextWorkspace: 50 * 1024
|
|
196
|
-
};
|
|
197
|
-
var DEFAULT_OBSERVATION_TURN_BUDGET_BYTES = GUARDRAIL_DEFAULTS.observationTurnBudgetBytes;
|
|
198
|
-
var OBSERVATION_TURN_BUDGET_ENV = GUARDRAIL_ENV_VARS.observationTurnBudgetBytes;
|
|
199
|
-
var MIN_BUDGET_SLICE_BYTES = 1024;
|
|
200
|
-
var BUDGET_TRACK_LIMIT = 256;
|
|
201
|
-
var turnBudgets = /* @__PURE__ */ new Map();
|
|
202
|
-
var MAX_CONTINUATION_CHARS = 200;
|
|
203
|
-
function boundContinuation(next) {
|
|
204
|
-
if (next === void 0 || next.length <= MAX_CONTINUATION_CHARS) return next;
|
|
205
|
-
return `${Array.from(next).slice(0, MAX_CONTINUATION_CHARS).join("")}\u2026`;
|
|
206
|
-
}
|
|
207
|
-
function observationTurnBudgetLimit(env = process.env) {
|
|
208
|
-
return Math.max(MIN_BUDGET_SLICE_BYTES, resolveGuardrail("observationTurnBudgetBytes", env));
|
|
209
|
-
}
|
|
210
|
-
function budgetKey(options) {
|
|
211
|
-
const turnId = options?.turnId?.trim();
|
|
212
|
-
if (!turnId) return null;
|
|
213
|
-
const sessionId = options?.sessionId?.trim() || "no-session";
|
|
214
|
-
return `${sessionId}:${turnId}`;
|
|
215
|
-
}
|
|
216
|
-
function pruneBudgetMap() {
|
|
217
|
-
while (turnBudgets.size > BUDGET_TRACK_LIMIT) {
|
|
218
|
-
let oldestKey = null;
|
|
219
|
-
let oldestSeen = Number.POSITIVE_INFINITY;
|
|
220
|
-
for (const [key, state] of turnBudgets) {
|
|
221
|
-
if (state.lastSeenAt >= oldestSeen) continue;
|
|
222
|
-
oldestKey = key;
|
|
223
|
-
oldestSeen = state.lastSeenAt;
|
|
224
|
-
}
|
|
225
|
-
if (oldestKey === null) break;
|
|
226
|
-
turnBudgets.delete(oldestKey);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function reserveObservation(selfCapBytes, options) {
|
|
230
|
-
const key = budgetKey(options);
|
|
231
|
-
if (key === null) {
|
|
232
|
-
return {
|
|
233
|
-
key,
|
|
234
|
-
limitBytes: observationTurnBudgetLimit(),
|
|
235
|
-
usedBeforeBytes: 0,
|
|
236
|
-
selfCapBytes,
|
|
237
|
-
callCapBytes: selfCapBytes,
|
|
238
|
-
limited: false,
|
|
239
|
-
exhausted: false,
|
|
240
|
-
committed: false,
|
|
241
|
-
settled: false
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
const limitBytes = observationTurnBudgetLimit();
|
|
245
|
-
const state = turnBudgets.get(key) ?? { usedBytes: 0, lastSeenAt: Date.now() };
|
|
246
|
-
state.lastSeenAt = Date.now();
|
|
247
|
-
turnBudgets.set(key, state);
|
|
248
|
-
pruneBudgetMap();
|
|
249
|
-
const remaining = Math.max(0, limitBytes - state.usedBytes);
|
|
250
|
-
if (remaining < MIN_BUDGET_SLICE_BYTES) {
|
|
251
|
-
return {
|
|
252
|
-
key,
|
|
253
|
-
limitBytes,
|
|
254
|
-
usedBeforeBytes: state.usedBytes,
|
|
255
|
-
selfCapBytes,
|
|
256
|
-
callCapBytes: 0,
|
|
257
|
-
limited: true,
|
|
258
|
-
exhausted: true,
|
|
259
|
-
committed: false,
|
|
260
|
-
settled: false
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
const callCapBytes = Math.min(selfCapBytes, remaining);
|
|
264
|
-
return {
|
|
265
|
-
key,
|
|
266
|
-
limitBytes,
|
|
267
|
-
usedBeforeBytes: state.usedBytes,
|
|
268
|
-
selfCapBytes,
|
|
269
|
-
callCapBytes,
|
|
270
|
-
limited: callCapBytes < selfCapBytes,
|
|
271
|
-
exhausted: false,
|
|
272
|
-
committed: false,
|
|
273
|
-
settled: false
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function commitObservationReservation(reservation) {
|
|
277
|
-
if (reservation.key === null || reservation.committed || reservation.settled) return;
|
|
278
|
-
if (reservation.callCapBytes <= 0) return;
|
|
279
|
-
reservation.committed = true;
|
|
280
|
-
const state = turnBudgets.get(reservation.key) ?? {
|
|
281
|
-
usedBytes: reservation.usedBeforeBytes,
|
|
282
|
-
lastSeenAt: Date.now()
|
|
283
|
-
};
|
|
284
|
-
state.usedBytes += reservation.callCapBytes;
|
|
285
|
-
state.lastSeenAt = Date.now();
|
|
286
|
-
turnBudgets.set(reservation.key, state);
|
|
287
|
-
}
|
|
288
|
-
function releaseObservation(reservation) {
|
|
289
|
-
if (reservation.key === null || reservation.settled) return;
|
|
290
|
-
reservation.settled = true;
|
|
291
|
-
if (!reservation.committed) return;
|
|
292
|
-
const state = turnBudgets.get(reservation.key);
|
|
293
|
-
if (state === void 0) return;
|
|
294
|
-
state.usedBytes = Math.max(0, state.usedBytes - reservation.callCapBytes);
|
|
295
|
-
state.lastSeenAt = Date.now();
|
|
296
|
-
turnBudgets.set(reservation.key, state);
|
|
297
|
-
}
|
|
298
|
-
function recordSpentBytes(reservation, bytes) {
|
|
299
|
-
if (reservation.key === null || reservation.settled) return;
|
|
300
|
-
reservation.settled = true;
|
|
301
|
-
const committedBytes = reservation.committed ? reservation.callCapBytes : 0;
|
|
302
|
-
const state = turnBudgets.get(reservation.key) ?? {
|
|
303
|
-
usedBytes: reservation.usedBeforeBytes + committedBytes,
|
|
304
|
-
lastSeenAt: Date.now()
|
|
305
|
-
};
|
|
306
|
-
state.usedBytes = Math.max(0, state.usedBytes + bytes - committedBytes);
|
|
307
|
-
state.lastSeenAt = Date.now();
|
|
308
|
-
turnBudgets.set(reservation.key, state);
|
|
309
|
-
}
|
|
310
|
-
function budgetDetails(reservation) {
|
|
311
|
-
if (reservation.key === null) return null;
|
|
312
|
-
return {
|
|
313
|
-
limitBytes: reservation.limitBytes,
|
|
314
|
-
usedBeforeBytes: reservation.usedBeforeBytes,
|
|
315
|
-
exhausted: reservation.exhausted
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
function observationBudgetExhausted(input) {
|
|
319
|
-
const { tool, unit, reservation, subject, hint } = input;
|
|
320
|
-
const output = `[observation budget exhausted for this turn before ${tool} ${subject}: ${formatSize(
|
|
321
|
-
reservation.usedBeforeBytes
|
|
322
|
-
)} already returned of ${formatSize(reservation.limitBytes)}. ${hint}]`;
|
|
323
|
-
const shownBytes = byteLength(output);
|
|
324
|
-
recordSpentBytes(reservation, shownBytes);
|
|
325
|
-
const budget = budgetDetails(reservation);
|
|
326
|
-
const observation = {
|
|
327
|
-
tool,
|
|
328
|
-
unit,
|
|
329
|
-
shownCount: 0,
|
|
330
|
-
totalCount: null,
|
|
331
|
-
shownBytes,
|
|
332
|
-
// The notice message is the whole rendering here (the search never ran), so
|
|
333
|
-
// the full size is the message itself; keep totalBytes >= shownBytes.
|
|
334
|
-
totalBytes: shownBytes,
|
|
335
|
-
truncated: true,
|
|
336
|
-
format: "text",
|
|
337
|
-
...budget !== null ? { budget } : {}
|
|
338
|
-
};
|
|
339
|
-
return { kind: "ok", output, details: { observation } };
|
|
340
|
-
}
|
|
341
|
-
function noticeLine(input, bodyBytes, totalBytes, offloadPath, next) {
|
|
342
|
-
const totalSegment = input.totalCount === null ? `${input.shownCount}+` : String(input.totalCount);
|
|
343
|
-
const parts = [
|
|
344
|
-
`${input.tool}: ${input.shownCount}/${totalSegment} ${input.unit} shown (${formatSize(bodyBytes)} of ${formatSize(totalBytes)})`
|
|
345
|
-
];
|
|
346
|
-
if (offloadPath !== null) parts.push(offloadPointer(offloadPath));
|
|
347
|
-
if (next !== void 0 && next.length > 0) parts.push(`next: ${next}`);
|
|
348
|
-
return `[${parts.join(" | ")}]`;
|
|
349
|
-
}
|
|
350
|
-
function limitedBudgetNote(reservation) {
|
|
351
|
-
return `[Per-turn observation budget: ${formatSize(reservation.usedBeforeBytes)} already returned of ${formatSize(
|
|
352
|
-
reservation.limitBytes
|
|
353
|
-
)} before this call. Use narrower arguments or continue in a follow-up turn for more content.]`;
|
|
354
|
-
}
|
|
355
|
-
function jsonStubBudgetNote(reservation) {
|
|
356
|
-
return `per-turn observation budget nearly exhausted: ${formatSize(reservation.usedBeforeBytes)} of ${formatSize(reservation.limitBytes)} already returned this turn. Do not retry this call; answer from what you have gathered, or continue in a follow-up turn.`;
|
|
357
|
-
}
|
|
358
|
-
function finalizeObservation(input) {
|
|
359
|
-
const format = input.format ?? "text";
|
|
360
|
-
let output = input.output;
|
|
361
|
-
let truncated = input.truncated;
|
|
362
|
-
let shownCount = input.shownCount;
|
|
363
|
-
let offloadPath = null;
|
|
364
|
-
const bodyBytes = byteLength(output);
|
|
365
|
-
const totalBytes = input.totalBytes ?? byteLength(input.fullOutput ?? input.output);
|
|
366
|
-
const next = boundContinuation(input.next);
|
|
367
|
-
if (format === "json" && bodyBytes > input.reservation.callCapBytes) {
|
|
368
|
-
truncated = true;
|
|
369
|
-
shownCount = 0;
|
|
370
|
-
offloadPath = writeToolOffload(input.fullOutput ?? output, input.options);
|
|
371
|
-
const poolBound = input.reservation.limited;
|
|
372
|
-
output = JSON.stringify({
|
|
373
|
-
error: `result exceeded ${formatSize(input.reservation.callCapBytes)}`,
|
|
374
|
-
...poolBound ? { budget: jsonStubBudgetNote(input.reservation) } : {},
|
|
375
|
-
...offloadPath !== null ? { offloadPath } : {},
|
|
376
|
-
...!poolBound && next !== void 0 && next.length > 0 ? { next } : {}
|
|
377
|
-
});
|
|
378
|
-
} else if (truncated && input.fullOutput !== void 0) {
|
|
379
|
-
offloadPath = writeToolOffload(input.fullOutput, input.options);
|
|
380
|
-
}
|
|
381
|
-
if (format === "text") {
|
|
382
|
-
if (truncated && input.omitNotice !== true)
|
|
383
|
-
output += `
|
|
384
|
-
|
|
385
|
-
${noticeLine(input, bodyBytes, totalBytes, offloadPath, next)}`;
|
|
386
|
-
if (input.reservation.limited && !input.reservation.exhausted) {
|
|
387
|
-
output += `
|
|
388
|
-
|
|
389
|
-
${limitedBudgetNote(input.reservation)}`;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
const shownBytes = byteLength(output);
|
|
393
|
-
recordSpentBytes(input.reservation, shownBytes);
|
|
394
|
-
const budget = budgetDetails(input.reservation);
|
|
395
|
-
const observation = {
|
|
396
|
-
tool: input.tool,
|
|
397
|
-
unit: input.unit,
|
|
398
|
-
shownCount,
|
|
399
|
-
totalCount: input.totalCount,
|
|
400
|
-
shownBytes,
|
|
401
|
-
// shownBytes counts the appended notice/limited-budget lines; totalBytes
|
|
402
|
-
// measured only the pre-notice rendering (and equals it when a count-limited
|
|
403
|
-
// tool like ls offloads nothing). Floor the full-rendering size at the bytes
|
|
404
|
-
// actually returned so the envelope invariant totalBytes >= shownBytes holds.
|
|
405
|
-
totalBytes: Math.max(totalBytes, shownBytes),
|
|
406
|
-
truncated,
|
|
407
|
-
format,
|
|
408
|
-
...next !== void 0 && next.length > 0 ? { next } : {},
|
|
409
|
-
...offloadPath !== null ? { offloadPath } : {},
|
|
410
|
-
...budget !== null ? { budget } : {}
|
|
411
|
-
};
|
|
412
|
-
return { kind: "ok", output, details: { ...input.details ?? {}, observation } };
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
export {
|
|
416
|
-
formatSize,
|
|
417
|
-
GREP_MAX_LINE_LENGTH,
|
|
418
|
-
truncateLine,
|
|
419
|
-
DEFAULT_MAX_LINES,
|
|
420
|
-
splitLinesForCounting,
|
|
421
|
-
truncateHead2 as truncateHead,
|
|
422
|
-
truncateTail2 as truncateTail,
|
|
423
|
-
writeToolOffload,
|
|
424
|
-
isSessionOffloadPath,
|
|
425
|
-
shapeToolResult,
|
|
426
|
-
OBSERVATION_POLICY_SLACK_BYTES,
|
|
427
|
-
OBSERVE_SELF_CAPS,
|
|
428
|
-
reserveObservation,
|
|
429
|
-
commitObservationReservation,
|
|
430
|
-
releaseObservation,
|
|
431
|
-
observationBudgetExhausted,
|
|
432
|
-
finalizeObservation
|
|
433
|
-
};
|
|
434
|
-
//# sourceMappingURL=chunk-VAKQQHWR.js.map
|
package/dist/chunk-VPAYEGVX.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
gitCommitAttributionEnabled,
|
|
4
|
-
reportCommitAttributionDiagnostic,
|
|
5
|
-
withManagedGitCommitAttributionEnvironment
|
|
6
|
-
} from "./chunk-COU2UHX6.js";
|
|
7
|
-
import {
|
|
8
|
-
clampTimerDelayMs
|
|
9
|
-
} from "./chunk-FQ4SKYE4.js";
|
|
10
|
-
import {
|
|
11
|
-
AI_AGENT_NAME
|
|
12
|
-
} from "./chunk-6EJMN2Y3.js";
|
|
13
|
-
import {
|
|
14
|
-
init_esm_shims
|
|
15
|
-
} from "./chunk-3R73A4XB.js";
|
|
16
|
-
|
|
17
|
-
// src/core/safe-exec.ts
|
|
18
|
-
init_esm_shims();
|
|
19
|
-
import { spawn } from "node:child_process";
|
|
20
|
-
import path from "node:path";
|
|
21
|
-
import { performance } from "node:perf_hooks";
|
|
22
|
-
var SAFE_EXEC_DEFAULT_TIMEOUT_MS = 12e4;
|
|
23
|
-
var SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES = 6e5;
|
|
24
|
-
var ENV_ALLOWLIST = [
|
|
25
|
-
"PATH",
|
|
26
|
-
"HOME",
|
|
27
|
-
"USER",
|
|
28
|
-
"LOGNAME",
|
|
29
|
-
"LANG",
|
|
30
|
-
"LC_ALL",
|
|
31
|
-
"TMPDIR",
|
|
32
|
-
"TEMP",
|
|
33
|
-
"TMP",
|
|
34
|
-
"CI",
|
|
35
|
-
"NO_COLOR"
|
|
36
|
-
];
|
|
37
|
-
function buildSafeToolEnv(extra = {}) {
|
|
38
|
-
const env = {};
|
|
39
|
-
for (const key of ENV_ALLOWLIST) {
|
|
40
|
-
const value = process.env[key];
|
|
41
|
-
if (value !== void 0) env[key] = value;
|
|
42
|
-
}
|
|
43
|
-
for (const [key, value] of Object.entries(extra)) {
|
|
44
|
-
if (!/^[A-Z_][A-Z0-9_]*$/i.test(key)) continue;
|
|
45
|
-
env[key] = value;
|
|
46
|
-
}
|
|
47
|
-
env.AI_AGENT = AI_AGENT_NAME;
|
|
48
|
-
return env;
|
|
49
|
-
}
|
|
50
|
-
function resolveSafeCwd(cwd, workspaceRoot = process.cwd()) {
|
|
51
|
-
const root = path.resolve(workspaceRoot);
|
|
52
|
-
const resolved = cwd === void 0 ? root : path.isAbsolute(cwd) ? path.resolve(cwd) : path.resolve(root, cwd);
|
|
53
|
-
const rel = path.relative(root, resolved);
|
|
54
|
-
if (rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel)) return resolved;
|
|
55
|
-
throw new Error(`cwd escapes workspace root: ${resolved}`);
|
|
56
|
-
}
|
|
57
|
-
function runCommandVector(file, args, options = {}) {
|
|
58
|
-
return new Promise((resolve) => {
|
|
59
|
-
const startedAt = performance.now();
|
|
60
|
-
const cwd = resolveSafeCwd(options.cwd, options.workspaceRoot);
|
|
61
|
-
const timeoutMs = clampTimerDelayMs(options.timeoutMs ?? SAFE_EXEC_DEFAULT_TIMEOUT_MS);
|
|
62
|
-
const maxOutputBytes = options.maxOutputBytes ?? SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES;
|
|
63
|
-
const attribution = withManagedGitCommitAttributionEnvironment(buildSafeToolEnv(options.env), {
|
|
64
|
-
cwd,
|
|
65
|
-
enabled: gitCommitAttributionEnabled(process.env)
|
|
66
|
-
});
|
|
67
|
-
reportCommitAttributionDiagnostic(attribution.diagnostic);
|
|
68
|
-
let aborted = false;
|
|
69
|
-
let timedOut = false;
|
|
70
|
-
let outputCapped = false;
|
|
71
|
-
let outputBytes = 0;
|
|
72
|
-
let stdout = "";
|
|
73
|
-
let stderr = "";
|
|
74
|
-
let settled = false;
|
|
75
|
-
let killSent = false;
|
|
76
|
-
let timeoutId = null;
|
|
77
|
-
let killGraceTimer = null;
|
|
78
|
-
const child = spawn(file, [...args], {
|
|
79
|
-
cwd,
|
|
80
|
-
env: attribution.env,
|
|
81
|
-
detached: process.platform !== "win32",
|
|
82
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
83
|
-
});
|
|
84
|
-
const clearKillGraceTimer = () => {
|
|
85
|
-
if (killGraceTimer) clearTimeout(killGraceTimer);
|
|
86
|
-
killGraceTimer = null;
|
|
87
|
-
};
|
|
88
|
-
const sendSignal = (signalName) => {
|
|
89
|
-
const pid = child.pid;
|
|
90
|
-
if (pid && process.platform !== "win32") {
|
|
91
|
-
try {
|
|
92
|
-
process.kill(-pid, signalName);
|
|
93
|
-
return;
|
|
94
|
-
} catch {
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
child.kill(signalName);
|
|
98
|
-
};
|
|
99
|
-
const killChild = () => {
|
|
100
|
-
if (killSent) return;
|
|
101
|
-
killSent = true;
|
|
102
|
-
sendSignal("SIGTERM");
|
|
103
|
-
killGraceTimer = setTimeout(() => sendSignal("SIGKILL"), 3e3);
|
|
104
|
-
};
|
|
105
|
-
const onAbort = () => {
|
|
106
|
-
aborted = true;
|
|
107
|
-
killChild();
|
|
108
|
-
};
|
|
109
|
-
if (timeoutMs > 0) {
|
|
110
|
-
timeoutId = setTimeout(() => {
|
|
111
|
-
timedOut = true;
|
|
112
|
-
killChild();
|
|
113
|
-
}, timeoutMs);
|
|
114
|
-
}
|
|
115
|
-
if (options.signal?.aborted) onAbort();
|
|
116
|
-
else options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
117
|
-
const appendChunk = (target, chunk) => {
|
|
118
|
-
outputBytes += chunk.byteLength;
|
|
119
|
-
if (outputBytes > maxOutputBytes) {
|
|
120
|
-
outputCapped = true;
|
|
121
|
-
killChild();
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (target === "stdout") stdout += chunk.toString("utf8");
|
|
125
|
-
else stderr += chunk.toString("utf8");
|
|
126
|
-
};
|
|
127
|
-
child.stdout?.on("data", (chunk) => appendChunk("stdout", chunk));
|
|
128
|
-
child.stderr?.on("data", (chunk) => appendChunk("stderr", chunk));
|
|
129
|
-
child.on("error", (error) => {
|
|
130
|
-
if (settled) return;
|
|
131
|
-
settled = true;
|
|
132
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
133
|
-
clearKillGraceTimer();
|
|
134
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
135
|
-
resolve({
|
|
136
|
-
file,
|
|
137
|
-
args: [...args],
|
|
138
|
-
cwd,
|
|
139
|
-
stdout,
|
|
140
|
-
stderr: stderr.length > 0 ? stderr : error.message,
|
|
141
|
-
exitCode: null,
|
|
142
|
-
signal: null,
|
|
143
|
-
aborted,
|
|
144
|
-
timedOut,
|
|
145
|
-
outputCapped,
|
|
146
|
-
durationMs: Math.round(performance.now() - startedAt)
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
child.on("close", (code, signalName) => {
|
|
150
|
-
if (settled) return;
|
|
151
|
-
settled = true;
|
|
152
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
153
|
-
clearKillGraceTimer();
|
|
154
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
155
|
-
resolve({
|
|
156
|
-
file,
|
|
157
|
-
args: [...args],
|
|
158
|
-
cwd,
|
|
159
|
-
stdout,
|
|
160
|
-
stderr,
|
|
161
|
-
exitCode: code,
|
|
162
|
-
signal: signalName,
|
|
163
|
-
aborted,
|
|
164
|
-
timedOut,
|
|
165
|
-
outputCapped,
|
|
166
|
-
durationMs: Math.round(performance.now() - startedAt)
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
function combineSafeOutput(result) {
|
|
172
|
-
const { stdout, stderr } = result;
|
|
173
|
-
return stderr.length > 0 ? `${stdout}${stdout.endsWith("\n") || stdout.length === 0 ? "" : "\n"}${stderr}` : stdout;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export {
|
|
177
|
-
SAFE_EXEC_DEFAULT_TIMEOUT_MS,
|
|
178
|
-
SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES,
|
|
179
|
-
buildSafeToolEnv,
|
|
180
|
-
resolveSafeCwd,
|
|
181
|
-
runCommandVector,
|
|
182
|
-
combineSafeOutput
|
|
183
|
-
};
|
|
184
|
-
//# sourceMappingURL=chunk-VPAYEGVX.js.map
|
package/dist/chunk-XBXAASKX.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
durableAssistantTextFromEvent
|
|
4
|
-
} from "./chunk-SRDMMSEP.js";
|
|
5
|
-
import {
|
|
6
|
-
init_esm_shims
|
|
7
|
-
} from "./chunk-3R73A4XB.js";
|
|
8
|
-
|
|
9
|
-
// src/tools/dispatch-event-text.ts
|
|
10
|
-
init_esm_shims();
|
|
11
|
-
function assistantTextFromEvent(event) {
|
|
12
|
-
return durableAssistantTextFromEvent(event).trim();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
assistantTextFromEvent
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=chunk-XBXAASKX.js.map
|