@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
|
@@ -2,7 +2,7 @@ import { createRequire as __clioCreateRequire } from "node:module"; const requir
|
|
|
2
2
|
import {
|
|
3
3
|
readStateInfo,
|
|
4
4
|
runDoctor
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KHSFENX2.js";
|
|
6
6
|
import {
|
|
7
7
|
getVersionInfo
|
|
8
8
|
} from "./chunk-XPLRXC72.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
readSettings,
|
|
11
11
|
settingsPath,
|
|
12
12
|
updateSettings
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-AD2SYQYC.js";
|
|
14
14
|
import {
|
|
15
15
|
authStoragePath,
|
|
16
16
|
openAuthStorage
|
|
@@ -158,4 +158,4 @@ export {
|
|
|
158
158
|
describeUpgradeNotice,
|
|
159
159
|
LifecycleDomainModule
|
|
160
160
|
};
|
|
161
|
-
//# sourceMappingURL=chunk-
|
|
161
|
+
//# sourceMappingURL=chunk-6XXKFVSN.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ACTIVE_ROUTING_ROLES,
|
|
6
6
|
DEFAULT_SETTINGS,
|
|
7
7
|
THINKING_LEVELS
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4OC57DA6.js";
|
|
9
9
|
import {
|
|
10
10
|
MAX_TIMER_DELAY_MS
|
|
11
11
|
} from "./chunk-FQ4SKYE4.js";
|
|
@@ -783,6 +783,7 @@ var TOP_LEVEL_KEYS = [
|
|
|
783
783
|
"delegation",
|
|
784
784
|
"keybindings",
|
|
785
785
|
"compaction",
|
|
786
|
+
"context",
|
|
786
787
|
"retry",
|
|
787
788
|
"guardrails"
|
|
788
789
|
];
|
|
@@ -1182,6 +1183,58 @@ function validateSettings(raw) {
|
|
|
1182
1183
|
}
|
|
1183
1184
|
}
|
|
1184
1185
|
}
|
|
1186
|
+
if ("context" in raw) {
|
|
1187
|
+
if (!isPlainObject(raw.context)) {
|
|
1188
|
+
issues.add("context", `expected a map, got ${describe(raw.context)}`);
|
|
1189
|
+
} else {
|
|
1190
|
+
issues.unknownKeys("context", raw.context, ["workingSet"]);
|
|
1191
|
+
if ("workingSet" in raw.context) {
|
|
1192
|
+
if (!isPlainObject(raw.context.workingSet)) {
|
|
1193
|
+
issues.add("context.workingSet", `expected a map, got ${describe(raw.context.workingSet)}`);
|
|
1194
|
+
} else {
|
|
1195
|
+
const workingSet = raw.context.workingSet;
|
|
1196
|
+
issues.unknownKeys("context.workingSet", workingSet, [
|
|
1197
|
+
"enabled",
|
|
1198
|
+
"policy",
|
|
1199
|
+
"target",
|
|
1200
|
+
"protectLastTurns",
|
|
1201
|
+
"minEvictableTokens"
|
|
1202
|
+
]);
|
|
1203
|
+
if ("enabled" in workingSet) {
|
|
1204
|
+
const v = expectBoolean(issues, "context.workingSet.enabled", workingSet.enabled);
|
|
1205
|
+
if (v !== void 0) settings.context.workingSet.enabled = v;
|
|
1206
|
+
}
|
|
1207
|
+
if ("policy" in workingSet) {
|
|
1208
|
+
const v = expectEnum(issues, "context.workingSet.policy", workingSet.policy, [
|
|
1209
|
+
"age-horizon",
|
|
1210
|
+
"structural-v1"
|
|
1211
|
+
]);
|
|
1212
|
+
if (v !== void 0) settings.context.workingSet.policy = v;
|
|
1213
|
+
}
|
|
1214
|
+
if ("target" in workingSet) {
|
|
1215
|
+
const v = expectNumber(issues, "context.workingSet.target", workingSet.target);
|
|
1216
|
+
if (v !== void 0 && (v <= 0 || v >= 1)) {
|
|
1217
|
+
issues.add("context.workingSet.target", `expected a number > 0 and < 1, got ${v}`);
|
|
1218
|
+
} else if (v !== void 0) {
|
|
1219
|
+
settings.context.workingSet.target = v;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
if ("protectLastTurns" in workingSet) {
|
|
1223
|
+
const v = expectInteger(issues, "context.workingSet.protectLastTurns", workingSet.protectLastTurns, {
|
|
1224
|
+
min: 1
|
|
1225
|
+
});
|
|
1226
|
+
if (v !== void 0) settings.context.workingSet.protectLastTurns = v;
|
|
1227
|
+
}
|
|
1228
|
+
if ("minEvictableTokens" in workingSet) {
|
|
1229
|
+
const v = expectInteger(issues, "context.workingSet.minEvictableTokens", workingSet.minEvictableTokens, {
|
|
1230
|
+
min: 0
|
|
1231
|
+
});
|
|
1232
|
+
if (v !== void 0) settings.context.workingSet.minEvictableTokens = v;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1185
1238
|
if ("retry" in raw) {
|
|
1186
1239
|
if (!isPlainObject(raw.retry)) {
|
|
1187
1240
|
issues.add("retry", `expected a map, got ${describe(raw.retry)}`);
|
|
@@ -1390,4 +1443,4 @@ export {
|
|
|
1390
1443
|
removeFleetProfileFromSettings,
|
|
1391
1444
|
bindAgentProfileInSettings
|
|
1392
1445
|
};
|
|
1393
|
-
//# sourceMappingURL=chunk-
|
|
1446
|
+
//# sourceMappingURL=chunk-AD2SYQYC.js.map
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
artifactDefaultPath,
|
|
4
|
+
extractCommandCdTargets,
|
|
5
|
+
extractCommandWriteTargets
|
|
6
|
+
} from "./chunk-MV3K5QF2.js";
|
|
7
|
+
import {
|
|
8
|
+
canonicalizeExistingPath
|
|
9
|
+
} from "./chunk-ECH6PKUQ.js";
|
|
10
|
+
import {
|
|
11
|
+
ToolNames,
|
|
12
|
+
isBuiltinToolName
|
|
13
|
+
} from "./chunk-CGKSTWHD.js";
|
|
14
|
+
import {
|
|
15
|
+
init_esm_shims
|
|
16
|
+
} from "./chunk-3R73A4XB.js";
|
|
17
|
+
|
|
18
|
+
// src/domains/agents/spec.ts
|
|
19
|
+
init_esm_shims();
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
|
|
22
|
+
// src/domains/safety/action-classifier.ts
|
|
23
|
+
init_esm_shims();
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
var GIT_DESTRUCTIVE_PATTERNS = [
|
|
26
|
+
{ name: "git-push-force-long", re: /\bgit\s+push\s+--force\b/i },
|
|
27
|
+
{ name: "git-push-force-short", re: /\bgit\s+push\s+-f\b/i },
|
|
28
|
+
{ name: "git-reset-hard", re: /\bgit\s+reset\s+--hard\b/i },
|
|
29
|
+
{ name: "git-clean-fd", re: /\bgit\s+clean\s+-fd?\b/i },
|
|
30
|
+
{ name: "git-checkout-dot", re: /\bgit\s+checkout\s+--\s+\./i },
|
|
31
|
+
{ name: "git-branch-D", re: /\bgit\s+branch\s+-D\b/i },
|
|
32
|
+
{ name: "git-restore-source", re: /\bgit\s+restore\s+--source\b/i }
|
|
33
|
+
];
|
|
34
|
+
var SYSTEM_MODIFY_PATTERNS = [
|
|
35
|
+
{ name: "sudo-or-doas", re: /\b(sudo|doas)\b/i },
|
|
36
|
+
// allow rm -rf /tmp/... and /var/tmp/... but flag everything else rooted at /
|
|
37
|
+
{ name: "rm-rf-root", re: /\brm\s+-rf?\s+\/(?!(tmp|var\/tmp)(?:\/|\s|$))/i },
|
|
38
|
+
{ name: "apt-install", re: /\bapt(-get)?\s+(install|remove|purge)/i },
|
|
39
|
+
{ name: "brew-install", re: /\bbrew\s+(install|uninstall|reinstall)/i },
|
|
40
|
+
{ name: "npm-install-global", re: /\bnpm\s+install\s+-g\b/i },
|
|
41
|
+
{ name: "pip-install", re: /\bpip\s+install\b/i },
|
|
42
|
+
{ name: "systemctl", re: /\bsystemctl\s+/i },
|
|
43
|
+
{ name: "chmod-root", re: /\bchmod\s+[0-7]{3,4}\s+\//i },
|
|
44
|
+
{ name: "chown", re: /\bchown\s+/i }
|
|
45
|
+
];
|
|
46
|
+
var SYSTEM_WRITE_ROOT_PREFIXES = ["/etc", "/usr", "/var", "/bin", "/sbin", "/run"];
|
|
47
|
+
var SYSTEM_WRITE_EXEMPT_PREFIXES = ["/var/tmp", "/var/folders"];
|
|
48
|
+
function isUnderPrefix(abs, prefix) {
|
|
49
|
+
return abs === prefix || abs.startsWith(`${prefix}/`);
|
|
50
|
+
}
|
|
51
|
+
function baseClassify(tool) {
|
|
52
|
+
switch (tool) {
|
|
53
|
+
case ToolNames.Read:
|
|
54
|
+
case ToolNames.Grep:
|
|
55
|
+
case ToolNames.Find:
|
|
56
|
+
case ToolNames.Ls:
|
|
57
|
+
case ToolNames.WebFetch:
|
|
58
|
+
case ToolNames.Git:
|
|
59
|
+
case ToolNames.CodeNav:
|
|
60
|
+
case ToolNames.Context:
|
|
61
|
+
case ToolNames.Monitor:
|
|
62
|
+
case ToolNames.AskUser:
|
|
63
|
+
case ToolNames.CredentialPresent:
|
|
64
|
+
// tasks pick mutates only Clio-owned session-ledger and project-local
|
|
65
|
+
// .clio-coder runtime state, never source-workspace files. By intentional
|
|
66
|
+
// policy it stays read class and ungated; the tool itself still requires
|
|
67
|
+
// a durable operator task id before it can mutate either store.
|
|
68
|
+
case ToolNames.Tasks:
|
|
69
|
+
// ledger posts a typed contribution to a coordination board and reads a
|
|
70
|
+
// local mirror. Neither touches the workspace, so it is never gated
|
|
71
|
+
// behind a confirmation.
|
|
72
|
+
case ToolNames.Ledger:
|
|
73
|
+
return "read";
|
|
74
|
+
case ToolNames.Write:
|
|
75
|
+
case ToolNames.Edit:
|
|
76
|
+
case ToolNames.Artifact:
|
|
77
|
+
return "write";
|
|
78
|
+
case ToolNames.Bash:
|
|
79
|
+
case ToolNames.Verify:
|
|
80
|
+
return "execute";
|
|
81
|
+
case ToolNames.Dispatch:
|
|
82
|
+
case ToolNames.Steer:
|
|
83
|
+
return "dispatch";
|
|
84
|
+
default:
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function scanStringOf(args) {
|
|
89
|
+
if (!args) return "";
|
|
90
|
+
const parts = [];
|
|
91
|
+
for (const value of Object.values(args)) {
|
|
92
|
+
if (value == null) continue;
|
|
93
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
94
|
+
parts.push(String(value));
|
|
95
|
+
} else {
|
|
96
|
+
try {
|
|
97
|
+
parts.push(JSON.stringify(value));
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return parts.join(" ");
|
|
103
|
+
}
|
|
104
|
+
function matchFirst(patterns, haystack) {
|
|
105
|
+
for (const p of patterns) {
|
|
106
|
+
if (p.re.test(haystack)) return p;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function resolveCandidate(p, baseCwd) {
|
|
111
|
+
if (p.startsWith("~")) return p;
|
|
112
|
+
const base = canonicalizeExistingPath(path.resolve(baseCwd ?? process.cwd()));
|
|
113
|
+
const resolved = path.isAbsolute(p) ? path.resolve(p) : path.resolve(base, p);
|
|
114
|
+
return canonicalizeExistingPath(resolved);
|
|
115
|
+
}
|
|
116
|
+
function isInsideCwd(abs) {
|
|
117
|
+
const cwd = canonicalizeExistingPath(path.resolve(process.cwd()));
|
|
118
|
+
const candidate = canonicalizeExistingPath(abs);
|
|
119
|
+
const rel = path.relative(cwd, candidate);
|
|
120
|
+
return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
121
|
+
}
|
|
122
|
+
function writePathClass(pathArg, baseCwd) {
|
|
123
|
+
if (pathArg.startsWith("~")) {
|
|
124
|
+
return { cls: "system_modify", reason: `write-path-home-escape: ${pathArg}` };
|
|
125
|
+
}
|
|
126
|
+
const abs = resolveCandidate(pathArg, baseCwd);
|
|
127
|
+
const exempt = SYSTEM_WRITE_EXEMPT_PREFIXES.some((prefix) => isUnderPrefix(abs, prefix));
|
|
128
|
+
if (!exempt) {
|
|
129
|
+
for (const prefix of SYSTEM_WRITE_ROOT_PREFIXES) {
|
|
130
|
+
if (isUnderPrefix(abs, prefix)) {
|
|
131
|
+
return { cls: "system_modify", reason: `write-path-system-root: ${prefix}` };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!isInsideCwd(abs)) {
|
|
136
|
+
return { cls: "system_modify", reason: `write-path-outside-cwd: ${abs}` };
|
|
137
|
+
}
|
|
138
|
+
return { cls: "write" };
|
|
139
|
+
}
|
|
140
|
+
function extractWritePath(tool, args) {
|
|
141
|
+
const candidate = args?.path ?? args?.file_path ?? args?.filePath;
|
|
142
|
+
if (typeof candidate === "string" && candidate.length > 0) return candidate;
|
|
143
|
+
return tool === ToolNames.Artifact ? artifactDefaultPath(args?.kind) : null;
|
|
144
|
+
}
|
|
145
|
+
function classify(call) {
|
|
146
|
+
const base = baseClassify(call.tool);
|
|
147
|
+
if (base === null) {
|
|
148
|
+
return { actionClass: "unknown", reasons: [`unknown tool: ${call.tool}`] };
|
|
149
|
+
}
|
|
150
|
+
const reasons = [];
|
|
151
|
+
if (call.tool === ToolNames.Bash) {
|
|
152
|
+
const scan = scanStringOf(call.args);
|
|
153
|
+
const gitHit = matchFirst(GIT_DESTRUCTIVE_PATTERNS, scan);
|
|
154
|
+
if (gitHit) {
|
|
155
|
+
return { actionClass: "git_destructive", reasons: [`pattern:${gitHit.name}`] };
|
|
156
|
+
}
|
|
157
|
+
const sysHit = matchFirst(SYSTEM_MODIFY_PATTERNS, scan);
|
|
158
|
+
if (sysHit) {
|
|
159
|
+
return { actionClass: "system_modify", reasons: [`pattern:${sysHit.name}`] };
|
|
160
|
+
}
|
|
161
|
+
const command = typeof call.args?.command === "string" ? call.args.command : null;
|
|
162
|
+
const argCwd = typeof call.args?.cwd === "string" && call.args.cwd.length > 0 ? call.args.cwd : void 0;
|
|
163
|
+
if (command !== null) {
|
|
164
|
+
const targetReasons = [];
|
|
165
|
+
for (const target of extractCommandWriteTargets(command)) {
|
|
166
|
+
const decision = writePathClass(target, argCwd);
|
|
167
|
+
if (decision.cls === "system_modify") {
|
|
168
|
+
targetReasons.push(decision.reason ?? `bash-write-target: ${target}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
for (const target of extractCommandCdTargets(command)) {
|
|
172
|
+
if (target.startsWith("~")) {
|
|
173
|
+
targetReasons.push(`bash-cd-home-escape: ${target}`);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const abs = resolveCandidate(target, argCwd);
|
|
177
|
+
if (!isInsideCwd(abs)) {
|
|
178
|
+
targetReasons.push(`bash-cd-outside-workspace: ${abs}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (targetReasons.length > 0) {
|
|
182
|
+
return { actionClass: "system_modify", reasons: targetReasons };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return { actionClass: "execute", reasons };
|
|
186
|
+
}
|
|
187
|
+
if (base === "write") {
|
|
188
|
+
const pathArg = extractWritePath(call.tool, call.args);
|
|
189
|
+
if (pathArg) {
|
|
190
|
+
const decision = writePathClass(pathArg);
|
|
191
|
+
if (decision.cls === "system_modify") {
|
|
192
|
+
return { actionClass: "system_modify", reasons: decision.reason ? [decision.reason] : [] };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { actionClass: "write", reasons };
|
|
196
|
+
}
|
|
197
|
+
return { actionClass: base, reasons };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/domains/agents/spec.ts
|
|
201
|
+
var AGENT_AUTOMATION_AUTHORITIES = ["read-only", "verification", "artifact-write", "workspace-edit"];
|
|
202
|
+
var AGENT_PRODUCTS = ["orientation"];
|
|
203
|
+
var AGENT_CATEGORIES = [
|
|
204
|
+
"explore",
|
|
205
|
+
"plan",
|
|
206
|
+
"research",
|
|
207
|
+
"implement",
|
|
208
|
+
"quality",
|
|
209
|
+
"science",
|
|
210
|
+
"evolution",
|
|
211
|
+
"operations",
|
|
212
|
+
"internal"
|
|
213
|
+
];
|
|
214
|
+
var AGENT_CAPABILITY_CLASSES = [
|
|
215
|
+
"read-only",
|
|
216
|
+
"artifact-write",
|
|
217
|
+
"workspace-edit",
|
|
218
|
+
"verification",
|
|
219
|
+
"orchestration",
|
|
220
|
+
"internal"
|
|
221
|
+
];
|
|
222
|
+
var AGENT_LATENCY_CLASSES = ["fast", "balanced", "deep"];
|
|
223
|
+
var AGENT_AUDIENCES = ["base", "shadow", "custom", "internal"];
|
|
224
|
+
var AGENT_PROJECT_CONTEXT_TIERS = ["none", "bounded"];
|
|
225
|
+
function includes(values, value) {
|
|
226
|
+
return typeof value === "string" && values.includes(value);
|
|
227
|
+
}
|
|
228
|
+
function isAgentCategory(value) {
|
|
229
|
+
return includes(AGENT_CATEGORIES, value);
|
|
230
|
+
}
|
|
231
|
+
function isAgentCapabilityClass(value) {
|
|
232
|
+
return includes(AGENT_CAPABILITY_CLASSES, value);
|
|
233
|
+
}
|
|
234
|
+
function isAgentLatencyClass(value) {
|
|
235
|
+
return includes(AGENT_LATENCY_CLASSES, value);
|
|
236
|
+
}
|
|
237
|
+
function isAgentAudience(value) {
|
|
238
|
+
return includes(AGENT_AUDIENCES, value);
|
|
239
|
+
}
|
|
240
|
+
function isAgentProjectContextTier(value) {
|
|
241
|
+
return includes(AGENT_PROJECT_CONTEXT_TIERS, value);
|
|
242
|
+
}
|
|
243
|
+
function isAgentProduct(value) {
|
|
244
|
+
return includes(AGENT_PRODUCTS, value);
|
|
245
|
+
}
|
|
246
|
+
function actionClassesForTools(tools) {
|
|
247
|
+
const actions = /* @__PURE__ */ new Set();
|
|
248
|
+
for (const tool of tools) actions.add(classify({ tool }).actionClass);
|
|
249
|
+
return actions;
|
|
250
|
+
}
|
|
251
|
+
function normalizeTools(recipe) {
|
|
252
|
+
const seen = /* @__PURE__ */ new Set();
|
|
253
|
+
const tools = [];
|
|
254
|
+
for (const tool of recipe.tools) {
|
|
255
|
+
if (typeof tool !== "string" || tool.trim().length === 0) {
|
|
256
|
+
throw new Error(`agent recipe '${recipe.id}' declares an invalid tool name`);
|
|
257
|
+
}
|
|
258
|
+
if (seen.has(tool)) continue;
|
|
259
|
+
seen.add(tool);
|
|
260
|
+
tools.push(isBuiltinToolName(tool) ? tool : tool);
|
|
261
|
+
}
|
|
262
|
+
return tools;
|
|
263
|
+
}
|
|
264
|
+
function asToolName(tool) {
|
|
265
|
+
return isBuiltinToolName(tool) ? tool : tool;
|
|
266
|
+
}
|
|
267
|
+
function normalizeToolRequirements(recipe, tools) {
|
|
268
|
+
if (!recipe.toolRequirements) {
|
|
269
|
+
throw new Error(`agent recipe '${recipe.id}' must declare tools.required and tools.optional`);
|
|
270
|
+
}
|
|
271
|
+
const declared = new Set(tools);
|
|
272
|
+
const required = recipe.toolRequirements.required.map((requirement, index) => {
|
|
273
|
+
if (typeof requirement === "string") return asToolName(requirement);
|
|
274
|
+
if (!Array.isArray(requirement.anyOf) || requirement.anyOf.length === 0) {
|
|
275
|
+
throw new Error(`agent recipe '${recipe.id}' tools.required[${index}].anyOf must be non-empty`);
|
|
276
|
+
}
|
|
277
|
+
return { anyOf: requirement.anyOf.map(asToolName) };
|
|
278
|
+
});
|
|
279
|
+
const optional = recipe.toolRequirements.optional.map(asToolName);
|
|
280
|
+
const mentioned = required.flatMap(
|
|
281
|
+
(requirement) => typeof requirement === "string" ? [requirement] : requirement.anyOf
|
|
282
|
+
);
|
|
283
|
+
for (const tool of [...mentioned, ...optional]) {
|
|
284
|
+
if (!declared.has(tool)) throw new Error(`agent recipe '${recipe.id}' requirement '${tool}' is not declared`);
|
|
285
|
+
}
|
|
286
|
+
if ((/* @__PURE__ */ new Set([...mentioned, ...optional])).size !== mentioned.length + optional.length) {
|
|
287
|
+
throw new Error(`agent recipe '${recipe.id}' contains duplicate tool requirements`);
|
|
288
|
+
}
|
|
289
|
+
if ((/* @__PURE__ */ new Set([...mentioned, ...optional])).size !== tools.length) {
|
|
290
|
+
throw new Error(`agent recipe '${recipe.id}' has declared tools without required/optional semantics`);
|
|
291
|
+
}
|
|
292
|
+
return { required, optional };
|
|
293
|
+
}
|
|
294
|
+
function resolveAgentToolCompatibility(spec, effectiveTools, options) {
|
|
295
|
+
const available = new Set(effectiveTools);
|
|
296
|
+
const missingRequired = [];
|
|
297
|
+
for (const requirement of spec.toolRequirements.required) {
|
|
298
|
+
if (typeof requirement === "string") {
|
|
299
|
+
if (!available.has(requirement)) missingRequired.push(requirement);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (!requirement.anyOf.some((tool) => available.has(tool))) {
|
|
303
|
+
missingRequired.push(`anyOf(${requirement.anyOf.join("|")})`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (available.has(ToolNames.Dispatch) && !options.mediatesDispatch) {
|
|
307
|
+
missingRequired.push("dispatch(runtime mediation unavailable)");
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
compatible: missingRequired.length === 0,
|
|
311
|
+
missingRequired,
|
|
312
|
+
lostOptional: spec.toolRequirements.optional.filter((tool) => !available.has(tool))
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function normalizeAgentSpec(recipe) {
|
|
316
|
+
const tools = normalizeTools(recipe);
|
|
317
|
+
const toolRequirements = normalizeToolRequirements(recipe, tools);
|
|
318
|
+
return {
|
|
319
|
+
version: recipe.version,
|
|
320
|
+
id: recipe.id,
|
|
321
|
+
name: recipe.name,
|
|
322
|
+
description: recipe.description,
|
|
323
|
+
source: recipe.source,
|
|
324
|
+
filepath: recipe.filepath,
|
|
325
|
+
tools,
|
|
326
|
+
toolRequirements,
|
|
327
|
+
category: recipe.category,
|
|
328
|
+
capabilityClass: recipe.capabilityClass,
|
|
329
|
+
latencyClass: recipe.latencyClass,
|
|
330
|
+
projectContextTier: recipe.projectContextTier,
|
|
331
|
+
audience: recipe.audience,
|
|
332
|
+
tags: recipe.tags,
|
|
333
|
+
skills: recipe.skills,
|
|
334
|
+
resultContract: recipe.resultContract,
|
|
335
|
+
...recipe.product !== void 0 ? { product: recipe.product } : {},
|
|
336
|
+
budget: recipe.budget,
|
|
337
|
+
body: recipe.body
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function agentSpecFingerprint(spec) {
|
|
341
|
+
const requirement = (entry) => typeof entry === "string" ? entry : `anyOf(${[...entry.anyOf].sort().join("|")})`;
|
|
342
|
+
const payload = JSON.stringify({
|
|
343
|
+
id: spec.id,
|
|
344
|
+
tools: [...spec.tools].sort(),
|
|
345
|
+
required: spec.toolRequirements.required.map(requirement).sort(),
|
|
346
|
+
optional: [...spec.toolRequirements.optional].sort(),
|
|
347
|
+
capabilityClass: spec.capabilityClass,
|
|
348
|
+
latencyClass: spec.latencyClass,
|
|
349
|
+
projectContextTier: spec.projectContextTier,
|
|
350
|
+
audience: spec.audience,
|
|
351
|
+
skills: [...spec.skills].sort(),
|
|
352
|
+
resultContract: spec.resultContract,
|
|
353
|
+
budget: spec.budget,
|
|
354
|
+
body: createHash("sha256").update(spec.body, "utf8").digest("hex")
|
|
355
|
+
});
|
|
356
|
+
return createHash("sha256").update(payload, "utf8").digest("hex");
|
|
357
|
+
}
|
|
358
|
+
function isUserVisibleAgent(spec) {
|
|
359
|
+
return spec.audience === "base" || spec.audience === "custom";
|
|
360
|
+
}
|
|
361
|
+
function isShadowAgent(spec) {
|
|
362
|
+
return spec.audience === "shadow" || spec.audience === "internal";
|
|
363
|
+
}
|
|
364
|
+
function agentSpecPolicyErrors(spec) {
|
|
365
|
+
const errors = [];
|
|
366
|
+
const actions = actionClassesForTools(spec.tools);
|
|
367
|
+
const requiredGroups = spec.toolRequirements.required.map(
|
|
368
|
+
(requirement) => typeof requirement === "string" ? [requirement] : requirement.anyOf
|
|
369
|
+
);
|
|
370
|
+
const requiresTool = (tool) => requiredGroups.some((group) => group.length > 0 && group.every((candidate) => candidate === tool));
|
|
371
|
+
const requiresMutation = requiredGroups.some(
|
|
372
|
+
(group) => group.length > 0 && group.every((tool) => tool === ToolNames.Write || tool === ToolNames.Edit)
|
|
373
|
+
);
|
|
374
|
+
if (spec.capabilityClass === "workspace-edit" && (!requiresTool(ToolNames.Read) || !requiresMutation)) {
|
|
375
|
+
errors.push(`workspace-edit agent '${spec.id}' must require read and write|edit`);
|
|
376
|
+
}
|
|
377
|
+
if (spec.capabilityClass === "verification" && !requiresTool(ToolNames.Verify)) {
|
|
378
|
+
errors.push(`verification agent '${spec.id}' must require verify`);
|
|
379
|
+
}
|
|
380
|
+
if (spec.capabilityClass === "artifact-write" && !requiresTool(ToolNames.Artifact)) {
|
|
381
|
+
errors.push(`artifact-write agent '${spec.id}' must require artifact`);
|
|
382
|
+
}
|
|
383
|
+
if (spec.skills.length > 0 && !requiresTool(ToolNames.Context)) {
|
|
384
|
+
errors.push(`agent '${spec.id}' must require context for bound skills`);
|
|
385
|
+
}
|
|
386
|
+
if (spec.capabilityClass === "orchestration" && spec.tools.includes(ToolNames.Dispatch) && !requiresTool(ToolNames.Dispatch)) {
|
|
387
|
+
errors.push(`orchestration agent '${spec.id}' must require dispatch when it is declared`);
|
|
388
|
+
}
|
|
389
|
+
const toolList = spec.tools.join(", ");
|
|
390
|
+
if (spec.capabilityClass === "read-only") {
|
|
391
|
+
for (const action of actions) {
|
|
392
|
+
if (action !== "read") errors.push(`read-only agent '${spec.id}' requests ${action} tools (${toolList})`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (spec.capabilityClass === "artifact-write") {
|
|
396
|
+
for (const tool of spec.tools) {
|
|
397
|
+
const action = classify({ tool }).actionClass;
|
|
398
|
+
if (action === "execute" || action === "dispatch" || action === "system_modify" || action === "git_destructive") {
|
|
399
|
+
errors.push(`artifact-write agent '${spec.id}' requests ${action} tool '${tool}'`);
|
|
400
|
+
}
|
|
401
|
+
if (action === "write" && tool !== ToolNames.Artifact) {
|
|
402
|
+
errors.push(`artifact-write agent '${spec.id}' can only write terminal artifacts; got '${tool}'`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (spec.capabilityClass === "verification") {
|
|
407
|
+
for (const tool of spec.tools) {
|
|
408
|
+
const action = classify({ tool }).actionClass;
|
|
409
|
+
if (action === "write" || action === "dispatch" || action === "system_modify" || action === "git_destructive") {
|
|
410
|
+
errors.push(`verification agent '${spec.id}' must not request ${action} tool '${tool}'`);
|
|
411
|
+
}
|
|
412
|
+
if (tool === ToolNames.Bash)
|
|
413
|
+
errors.push(`verification agent '${spec.id}' must use typed validation tools, not bash`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (spec.capabilityClass !== "orchestration" && spec.tools.includes(ToolNames.Dispatch)) {
|
|
417
|
+
errors.push(`agent '${spec.id}' exposes dispatch without orchestration capability`);
|
|
418
|
+
}
|
|
419
|
+
if (spec.tools.includes(ToolNames.AskUser)) {
|
|
420
|
+
errors.push(`agent '${spec.id}' exposes ask_user, which is only available to the orchestrator`);
|
|
421
|
+
}
|
|
422
|
+
if (spec.skills.length > 0 && !spec.tools.includes(ToolNames.Context)) {
|
|
423
|
+
errors.push(`agent '${spec.id}' declares skills but does not expose context`);
|
|
424
|
+
}
|
|
425
|
+
return errors;
|
|
426
|
+
}
|
|
427
|
+
function assertAgentSpecPolicy(spec) {
|
|
428
|
+
const errors = agentSpecPolicyErrors(spec);
|
|
429
|
+
if (errors.length > 0) throw new Error(`agent policy violation:
|
|
430
|
+
${errors.map((error) => `- ${error}`).join("\n")}`);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export {
|
|
434
|
+
classify,
|
|
435
|
+
AGENT_AUTOMATION_AUTHORITIES,
|
|
436
|
+
isAgentCategory,
|
|
437
|
+
isAgentCapabilityClass,
|
|
438
|
+
isAgentLatencyClass,
|
|
439
|
+
isAgentAudience,
|
|
440
|
+
isAgentProjectContextTier,
|
|
441
|
+
isAgentProduct,
|
|
442
|
+
resolveAgentToolCompatibility,
|
|
443
|
+
normalizeAgentSpec,
|
|
444
|
+
agentSpecFingerprint,
|
|
445
|
+
isUserVisibleAgent,
|
|
446
|
+
isShadowAgent,
|
|
447
|
+
assertAgentSpecPolicy
|
|
448
|
+
};
|
|
449
|
+
//# sourceMappingURL=chunk-AOCYTWAV.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
init_esm_shims
|
|
4
|
+
} from "./chunk-3R73A4XB.js";
|
|
5
|
+
|
|
6
|
+
// src/engine/strip-tokenizer-sentinels.ts
|
|
7
|
+
init_esm_shims();
|
|
8
|
+
var KNOWN_SENTINELS = [
|
|
9
|
+
"<|endoftext|>",
|
|
10
|
+
"<|im_start|>",
|
|
11
|
+
"<|im_end|>",
|
|
12
|
+
"<|eot_id|>",
|
|
13
|
+
"<|end_of_turn|>",
|
|
14
|
+
"<|fim_prefix|>",
|
|
15
|
+
"<|fim_middle|>",
|
|
16
|
+
"<|fim_suffix|>",
|
|
17
|
+
"<|file_separator|>",
|
|
18
|
+
"<s>",
|
|
19
|
+
"</s>"
|
|
20
|
+
];
|
|
21
|
+
var SENTINEL_RE = new RegExp(KNOWN_SENTINELS.map((s) => s.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&")).join("|"), "g");
|
|
22
|
+
var MAX_SENTINEL_LEN = KNOWN_SENTINELS.reduce((max, s) => s.length > max ? s.length : max, 0);
|
|
23
|
+
function stripTokenizerSentinels(text) {
|
|
24
|
+
if (text.length === 0) return text;
|
|
25
|
+
return text.replace(SENTINEL_RE, "");
|
|
26
|
+
}
|
|
27
|
+
function isSentinelPrefix(tail) {
|
|
28
|
+
if (tail.length === 0) return false;
|
|
29
|
+
for (const sentinel of KNOWN_SENTINELS) {
|
|
30
|
+
if (sentinel.length > tail.length && sentinel.startsWith(tail)) return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
function createSentinelStripper() {
|
|
35
|
+
let buffer = "";
|
|
36
|
+
return {
|
|
37
|
+
push(chunk) {
|
|
38
|
+
if (chunk.length === 0) return "";
|
|
39
|
+
buffer += chunk;
|
|
40
|
+
const stripped = buffer.replace(SENTINEL_RE, "");
|
|
41
|
+
const holdMax = Math.min(stripped.length, MAX_SENTINEL_LEN - 1);
|
|
42
|
+
let hold = 0;
|
|
43
|
+
for (let take = holdMax; take > 0; take--) {
|
|
44
|
+
const tail = stripped.slice(stripped.length - take);
|
|
45
|
+
if (isSentinelPrefix(tail)) {
|
|
46
|
+
hold = take;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const safe = hold === 0 ? stripped : stripped.slice(0, stripped.length - hold);
|
|
51
|
+
buffer = hold === 0 ? "" : stripped.slice(stripped.length - hold);
|
|
52
|
+
return safe;
|
|
53
|
+
},
|
|
54
|
+
flush() {
|
|
55
|
+
if (buffer.length === 0) return "";
|
|
56
|
+
const remainder = buffer.replace(SENTINEL_RE, "");
|
|
57
|
+
buffer = "";
|
|
58
|
+
return remainder;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
stripTokenizerSentinels,
|
|
65
|
+
createSentinelStripper
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=chunk-CFGTUFWB.js.map
|