@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
|
@@ -7,24 +7,31 @@ import {
|
|
|
7
7
|
TASK_MEMORY_POLICY_DEFAULT_TIMEOUT_MS,
|
|
8
8
|
runTaskMemoryPolicy,
|
|
9
9
|
taskMemoryBankDelta
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WHGPSPT5.js";
|
|
11
|
+
import {
|
|
12
|
+
isTerminalRunEnvelope
|
|
13
|
+
} from "./chunk-XXQNGV4M.js";
|
|
11
14
|
import {
|
|
12
|
-
isTerminalRunEnvelope,
|
|
13
15
|
taskBoardCounts
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-43AOLP7E.js";
|
|
17
|
+
import {
|
|
18
|
+
SKILL_SUGGESTION_ANCHOR,
|
|
19
|
+
SKILL_SUGGESTION_PREFIX
|
|
20
|
+
} from "./chunk-GOXNB3AO.js";
|
|
15
21
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
legacyToolResultDigest,
|
|
23
|
+
sanitizeToolResultDigest
|
|
24
|
+
} from "./chunk-ODFEOB4F.js";
|
|
18
25
|
import {
|
|
19
26
|
ToolNames
|
|
20
27
|
} from "./chunk-CGKSTWHD.js";
|
|
21
|
-
import {
|
|
22
|
-
ceilChars
|
|
23
|
-
} from "./chunk-LZSJBIVT.js";
|
|
24
28
|
import {
|
|
25
29
|
reportCommitAttributionDiagnostic,
|
|
26
30
|
withManagedGitCommitAttributionEnvironment
|
|
27
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-VEZEGCGW.js";
|
|
32
|
+
import {
|
|
33
|
+
ceilChars
|
|
34
|
+
} from "./chunk-GEYXPTRF.js";
|
|
28
35
|
import {
|
|
29
36
|
require_dist
|
|
30
37
|
} from "./chunk-APJ265NV.js";
|
|
@@ -61,6 +68,10 @@ function metadataNumber(input, key) {
|
|
|
61
68
|
const value = input.metadata?.[key];
|
|
62
69
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
63
70
|
}
|
|
71
|
+
function metadataString(input, key) {
|
|
72
|
+
const value = input.metadata?.[key];
|
|
73
|
+
return typeof value === "string" ? value : null;
|
|
74
|
+
}
|
|
64
75
|
function isMiddlewareHook(value) {
|
|
65
76
|
return MIDDLEWARE_HOOKS.includes(value);
|
|
66
77
|
}
|
|
@@ -187,8 +198,93 @@ init_esm_shims();
|
|
|
187
198
|
init_esm_shims();
|
|
188
199
|
var STALLED_TURN_REGISTRATION_ID = "nudge.stalled-turn";
|
|
189
200
|
var STALLED_TURN_REQUEST_CONTINUATION_MESSAGE = "You ended your turn after announcing an action without executing it: no tools were called. Continue now and perform the announced action, or state plainly that you are finished and waiting for the user.";
|
|
201
|
+
var SKILL_SUGGESTION_WAIT_CONTINUATION_MESSAGE = "You ended your turn on a skill suggestion without doing the task. The suggestion line has already made the offer and only the operator loads a skill, so nothing is needed from them before you proceed. Continue the task now without the skill.";
|
|
190
202
|
var INTENT_PATTERN = /\b(let me|i['’]ll|i will|i am going to|i['’]m going to|now i|next i|let's|let us)\b/i;
|
|
203
|
+
var CONCRETE_ACTION_STEMS = [
|
|
204
|
+
"add",
|
|
205
|
+
"analyse",
|
|
206
|
+
"analyze",
|
|
207
|
+
"apply",
|
|
208
|
+
"audit",
|
|
209
|
+
"build",
|
|
210
|
+
"change",
|
|
211
|
+
"check",
|
|
212
|
+
"compare",
|
|
213
|
+
"compile",
|
|
214
|
+
"create",
|
|
215
|
+
"debug",
|
|
216
|
+
"delete",
|
|
217
|
+
"edit",
|
|
218
|
+
"execute",
|
|
219
|
+
"explore",
|
|
220
|
+
"find",
|
|
221
|
+
"fix",
|
|
222
|
+
"format",
|
|
223
|
+
"grep",
|
|
224
|
+
"implement",
|
|
225
|
+
"inspect",
|
|
226
|
+
"install",
|
|
227
|
+
"investigate",
|
|
228
|
+
"list",
|
|
229
|
+
"load",
|
|
230
|
+
"look",
|
|
231
|
+
"modify",
|
|
232
|
+
"open",
|
|
233
|
+
"patch",
|
|
234
|
+
"query",
|
|
235
|
+
"read",
|
|
236
|
+
"refactor",
|
|
237
|
+
"remove",
|
|
238
|
+
"rename",
|
|
239
|
+
"replace",
|
|
240
|
+
"review",
|
|
241
|
+
"run",
|
|
242
|
+
"scan",
|
|
243
|
+
"search",
|
|
244
|
+
"test",
|
|
245
|
+
"trace",
|
|
246
|
+
"update",
|
|
247
|
+
"validate",
|
|
248
|
+
"verify",
|
|
249
|
+
"write"
|
|
250
|
+
];
|
|
251
|
+
var DOUBLED_CONSONANT_STEMS = /* @__PURE__ */ new Set(["debug", "format", "run", "scan"]);
|
|
252
|
+
function concreteActionForms(stem) {
|
|
253
|
+
const forms = /* @__PURE__ */ new Set([stem, `${stem}s`, `${stem}ed`, `${stem}ing`]);
|
|
254
|
+
if (/(?:ch|sh|s|x|z)$/.test(stem)) forms.add(`${stem}es`);
|
|
255
|
+
if (stem.endsWith("e")) {
|
|
256
|
+
forms.add(`${stem}d`);
|
|
257
|
+
forms.add(`${stem.slice(0, -1)}ing`);
|
|
258
|
+
}
|
|
259
|
+
if (stem.endsWith("y")) {
|
|
260
|
+
forms.add(`${stem.slice(0, -1)}ies`);
|
|
261
|
+
forms.add(`${stem.slice(0, -1)}ied`);
|
|
262
|
+
}
|
|
263
|
+
if (DOUBLED_CONSONANT_STEMS.has(stem)) {
|
|
264
|
+
const doubled = `${stem}${stem.slice(-1)}`;
|
|
265
|
+
forms.add(`${doubled}ed`);
|
|
266
|
+
forms.add(`${doubled}ing`);
|
|
267
|
+
}
|
|
268
|
+
return [...forms];
|
|
269
|
+
}
|
|
270
|
+
var CONCRETE_ACTION_PATTERN = new RegExp(
|
|
271
|
+
`\\b(?:${CONCRETE_ACTION_STEMS.flatMap(concreteActionForms).join("|")})\\b`,
|
|
272
|
+
"giu"
|
|
273
|
+
);
|
|
274
|
+
var NAMED_PATH_EXTENSIONS = "c|cc|cfg|cjs|cmake|conf|cpp|cs|css|csv|env|go|h|hpp|html|ini|java|jl|js|json|jsx|lock|log|lua|md|mjs|nc|php|py|rb|rs|rst|sh|sql|toml|ts|tsx|txt|yaml|yml";
|
|
275
|
+
var NAMED_PATH_PATTERN = new RegExp(
|
|
276
|
+
`(?:^|[\\s\`"'(\\[])(?:[\\w@.\\-/]*[\\w@\\-]\\.(?:${NAMED_PATH_EXTENSIONS})\\b|(?:\\.{1,2}|~)\\/[\\w@.\\-/]+)`,
|
|
277
|
+
"iu"
|
|
278
|
+
);
|
|
279
|
+
var NAMED_COMMAND_PATTERN = /\b(?:npm|npx|pnpm|yarn|bun|git|cargo|rustc|cmake|ctest|ninja|meson|bazel|gradle|mvn|pytest|pip|python3?|node|deno|tsc|biome|eslint|prettier|jest|vitest|ruff|mypy|docker|kubectl|mpirun|srun|sbatch|gcc|clang)\s+[-\w./]/iu;
|
|
280
|
+
var ACTION_OBJECT_CONNECTOR_PATTERN = /^(?:at|for|in|into|on|through|to)\s+/i;
|
|
281
|
+
var ACTION_OBJECT_DETERMINER_PATTERN = /^(?:a|an|my|our|that|the|their|these|this|those|your)\s+/i;
|
|
282
|
+
var ACTION_OBJECT_PATTERN = /^(?!(?:again|everyone|later|next|now|soon|then|you)\b)[`"'./~]*[\p{L}\p{N}_-]/iu;
|
|
283
|
+
var CONDITIONAL_LEAD_IN_PATTERN = /\b(?:if|once|unless|until|when|whenever)\b/i;
|
|
284
|
+
var CONDITIONAL_INVITATION_PATTERN = /\b(?:ask|give|point|say|send|share|tell)\b[\s\S]*\b(?:and|then)\s*$/i;
|
|
285
|
+
var CONDITIONAL_OFFER_SUFFIX_PATTERN = /\b(?:if\s+(?:needed|necessary|requested)\b|if\b[^.!?]*\byou\b|when(?:ever)?\s+you\b)/i;
|
|
191
286
|
var LET_ME_KNOW_PATTERN = /\blet me know\b/i;
|
|
287
|
+
var DEFERRAL_LEAD_PATTERN = /^\s*(?:just\s+|simply\s+|now\s+)?(?:wait|hold\s+off|hold|stand\s+by|pause|defer)\b/i;
|
|
192
288
|
var COMPLETION_PATTERN = /^\s*(?:all\s+done|done|complete|completed|all\s+set)\b|^\s*(?:here(?:'s| is)\s+)?(?:a\s+)?summary\b|^\s*summary\s*:?$/i;
|
|
193
289
|
var STALLED_TURN_RULE_DEFINITION = {
|
|
194
290
|
rule: {
|
|
@@ -202,6 +298,24 @@ var STALLED_TURN_RULE_DEFINITION = {
|
|
|
202
298
|
effects: [{ kind: "request_continuation", message: STALLED_TURN_REQUEST_CONTINUATION_MESSAGE }],
|
|
203
299
|
predicate: shouldRequestStalledTurnContinuation
|
|
204
300
|
};
|
|
301
|
+
var SKILL_WAIT_PATTERN = /\/skill\b|\bskills?\b|\bskip\b/i;
|
|
302
|
+
function isSkillSuggestionWait(input) {
|
|
303
|
+
if (input.hook !== "turn_end") return false;
|
|
304
|
+
if (!isNormalStopReason(input.metadata?.stopReason)) return false;
|
|
305
|
+
const text = input.text ?? "";
|
|
306
|
+
if (!text.includes(SKILL_SUGGESTION_PREFIX)) return false;
|
|
307
|
+
const toolNames = metadataString(input, "turnToolNames");
|
|
308
|
+
if (toolNames === null) {
|
|
309
|
+
if ((metadataNumber(input, "turnToolCalls") ?? 0) !== 0) return false;
|
|
310
|
+
} else if (toolNames.split(",").filter((name) => name.length > 0).some((name) => name !== ToolNames.Context)) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
const lastLine = lastNonEmptyLine(text);
|
|
314
|
+
if (lastLine === null) return false;
|
|
315
|
+
const finalSentence = lastSentence(lastLine);
|
|
316
|
+
if (finalSentence.length === 0) return false;
|
|
317
|
+
return SKILL_WAIT_PATTERN.test(finalSentence) || isQuestion(finalSentence) || LET_ME_KNOW_PATTERN.test(finalSentence);
|
|
318
|
+
}
|
|
205
319
|
function shouldRequestStalledTurnContinuation(input) {
|
|
206
320
|
if (input.hook !== "turn_end") return false;
|
|
207
321
|
if (input.metadata?.turnToolCalls !== 0) return false;
|
|
@@ -213,7 +327,34 @@ function shouldRequestStalledTurnContinuation(input) {
|
|
|
213
327
|
if (isQuestion(finalSentence)) return false;
|
|
214
328
|
if (LET_ME_KNOW_PATTERN.test(finalSentence)) return false;
|
|
215
329
|
if (COMPLETION_PATTERN.test(lastLine) || COMPLETION_PATTERN.test(finalSentence)) return false;
|
|
216
|
-
return
|
|
330
|
+
return announcesConcreteAction(finalSentence);
|
|
331
|
+
}
|
|
332
|
+
function announcesConcreteAction(sentence) {
|
|
333
|
+
const intent = INTENT_PATTERN.exec(sentence);
|
|
334
|
+
if (intent) {
|
|
335
|
+
const leadIn = sentence.slice(0, intent.index);
|
|
336
|
+
if (CONDITIONAL_LEAD_IN_PATTERN.test(leadIn) || CONDITIONAL_INVITATION_PATTERN.test(leadIn) || CONDITIONAL_OFFER_SUFFIX_PATTERN.test(sentence)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
const clause = sentence.slice(intent.index + intent[0].length);
|
|
340
|
+
if (DEFERRAL_LEAD_PATTERN.test(clause)) return false;
|
|
341
|
+
if (hasActionWithObject(clause)) return true;
|
|
342
|
+
if (CONDITIONAL_LEAD_IN_PATTERN.test(clause)) return false;
|
|
343
|
+
return namesToolTarget(clause);
|
|
344
|
+
}
|
|
345
|
+
return sentence.endsWith(":") && hasActionWithObject(sentence);
|
|
346
|
+
}
|
|
347
|
+
function namesToolTarget(clause) {
|
|
348
|
+
return NAMED_PATH_PATTERN.test(clause) || NAMED_COMMAND_PATTERN.test(clause);
|
|
349
|
+
}
|
|
350
|
+
function hasActionWithObject(clause) {
|
|
351
|
+
for (const action of clause.matchAll(CONCRETE_ACTION_PATTERN)) {
|
|
352
|
+
const remainder = clause.slice((action.index ?? 0) + action[0].length).trimStart();
|
|
353
|
+
const withoutConnector = remainder.replace(ACTION_OBJECT_CONNECTOR_PATTERN, "");
|
|
354
|
+
const object = withoutConnector.replace(ACTION_OBJECT_DETERMINER_PATTERN, "");
|
|
355
|
+
if (ACTION_OBJECT_PATTERN.test(object)) return true;
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
217
358
|
}
|
|
218
359
|
function isNormalStopReason(value) {
|
|
219
360
|
if (value === void 0 || value === null) return true;
|
|
@@ -229,10 +370,16 @@ function lastNonEmptyLine(text) {
|
|
|
229
370
|
}
|
|
230
371
|
return null;
|
|
231
372
|
}
|
|
373
|
+
var SENTENCE_TERMINATOR_PATTERN = /[.!?]+["'’)\]]*(?=\s|$)/gu;
|
|
232
374
|
function lastSentence(line) {
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
375
|
+
const trimmed = line.trimEnd();
|
|
376
|
+
let start = 0;
|
|
377
|
+
for (const terminator of trimmed.matchAll(SENTENCE_TERMINATOR_PATTERN)) {
|
|
378
|
+
const end = (terminator.index ?? 0) + terminator[0].length;
|
|
379
|
+
if (end >= trimmed.length) break;
|
|
380
|
+
start = end;
|
|
381
|
+
}
|
|
382
|
+
return trimmed.slice(start).replace(/^[\s"'([{-]+/, "").trim();
|
|
236
383
|
}
|
|
237
384
|
function isQuestion(sentence) {
|
|
238
385
|
return /[?]["')\]]*$/.test(sentence.trim());
|
|
@@ -432,6 +579,12 @@ function cloneHookInput(input) {
|
|
|
432
579
|
if (input.metadata !== void 0) cloned.metadata = { ...input.metadata };
|
|
433
580
|
if (input.toolArgs !== void 0) cloned.toolArgs = { ...input.toolArgs };
|
|
434
581
|
if (input.toolResultDetails !== void 0) cloned.toolResultDetails = { ...input.toolResultDetails };
|
|
582
|
+
if (input.toolResultDigest !== void 0) {
|
|
583
|
+
cloned.toolResultDigest = {
|
|
584
|
+
text: input.toolResultDigest.text,
|
|
585
|
+
provenance: { ...input.toolResultDigest.provenance }
|
|
586
|
+
};
|
|
587
|
+
}
|
|
435
588
|
if (input.text !== void 0) cloned.text = input.text.slice(0, MIDDLEWARE_HOOK_TEXT_MAX_CHARS);
|
|
436
589
|
return cloned;
|
|
437
590
|
}
|
|
@@ -1232,7 +1385,6 @@ var MEMORY_INTERVENTION_DEFAULT_WINDOW_STEPS = 8;
|
|
|
1232
1385
|
var MEMORY_INTERVENTION_DEFAULT_MAX_TOKENS = 400;
|
|
1233
1386
|
var MEMORY_INTERVENTION_DEFAULT_EVERY_N_TOOLS = 10;
|
|
1234
1387
|
var MEMORY_INTERVENTION_ACTIVITY_LIMIT = 20;
|
|
1235
|
-
var RESULT_DIGEST_MAX_CHARS = 240;
|
|
1236
1388
|
var CALL_DESCRIPTION_MAX_CHARS = 180;
|
|
1237
1389
|
var NO_EFFECTS = [];
|
|
1238
1390
|
function createMemoryInterventionRegistration(deps) {
|
|
@@ -1242,7 +1394,7 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1242
1394
|
let toolStep = 0;
|
|
1243
1395
|
let lastTurnEndStep = 0;
|
|
1244
1396
|
let reactivateAfterCompaction = false;
|
|
1245
|
-
let
|
|
1397
|
+
let lastInjectedOperationFingerprint = null;
|
|
1246
1398
|
let currentTask = "(current task unavailable)";
|
|
1247
1399
|
let toolsSinceMemoryStep = 0;
|
|
1248
1400
|
let consecutiveErrors = 0;
|
|
@@ -1291,6 +1443,7 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1291
1443
|
return effects;
|
|
1292
1444
|
}
|
|
1293
1445
|
case "on_compaction":
|
|
1446
|
+
if (input.metadata?.stage === "working_set_recall") return NO_EFFECTS;
|
|
1294
1447
|
reactivateAfterCompaction = true;
|
|
1295
1448
|
return NO_EFFECTS;
|
|
1296
1449
|
case "turn_start": {
|
|
@@ -1510,12 +1663,12 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1510
1663
|
function observeBeforeTool(input) {
|
|
1511
1664
|
const prepared = prepareToolStep(input);
|
|
1512
1665
|
if (prepared === null) return;
|
|
1513
|
-
setBounded(pending, pendingKey(input, prepared.
|
|
1666
|
+
setBounded(pending, pendingKey(input, prepared.operationFingerprint), prepared, settings().windowSteps);
|
|
1514
1667
|
}
|
|
1515
1668
|
function observeAfterTool(input) {
|
|
1516
1669
|
const fallback = prepareToolStep(input);
|
|
1517
1670
|
if (fallback === null) return NO_EFFECTS;
|
|
1518
|
-
const key = pendingKey(input, fallback.
|
|
1671
|
+
const key = pendingKey(input, fallback.operationFingerprint);
|
|
1519
1672
|
const prepared = pending.get(key) ?? fallback;
|
|
1520
1673
|
pending.delete(key);
|
|
1521
1674
|
const outcome = input.metadata?.resultKind === "error" ? "error" : "ok";
|
|
@@ -1529,11 +1682,13 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1529
1682
|
} else {
|
|
1530
1683
|
consecutiveErrors = 0;
|
|
1531
1684
|
}
|
|
1685
|
+
const digest = resultDigest(input, outcome);
|
|
1532
1686
|
const step = {
|
|
1533
1687
|
...prepared,
|
|
1534
1688
|
step: toolStep,
|
|
1535
1689
|
outcome,
|
|
1536
|
-
resultDigest:
|
|
1690
|
+
resultDigest: digest.text,
|
|
1691
|
+
resultDigestProvenance: digest.provenance
|
|
1537
1692
|
};
|
|
1538
1693
|
trajectory.push(step);
|
|
1539
1694
|
if (trajectory.length > live.windowSteps) trajectory.splice(0, trajectory.length - live.windowSteps);
|
|
@@ -1542,19 +1697,19 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1542
1697
|
return annotateRepeatedFailure(step);
|
|
1543
1698
|
}
|
|
1544
1699
|
function annotateRepeatedFailure(step) {
|
|
1545
|
-
if (annotatedThisTurn.has(step.
|
|
1700
|
+
if (annotatedThisTurn.has(step.operationFingerprint)) return NO_EFFECTS;
|
|
1546
1701
|
const occurrences = trajectory.filter(
|
|
1547
|
-
(candidate) => candidate.outcome === "error" && candidate.
|
|
1702
|
+
(candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint
|
|
1548
1703
|
).length;
|
|
1549
|
-
const failure = failures.get(step.
|
|
1704
|
+
const failure = failures.get(step.operationFingerprint);
|
|
1550
1705
|
if (occurrences < 2 || failure === void 0) return NO_EFFECTS;
|
|
1551
1706
|
const message = boundedReminder(
|
|
1552
1707
|
`Memory: [${failure.entryId}] you already tried ${failure.callDescription} at step ${failure.firstStep} and it failed with ${failure.errorDigest}. Change the approach rather than repeating it.`,
|
|
1553
1708
|
settings().maxTokens
|
|
1554
1709
|
);
|
|
1555
1710
|
if (message.length === 0) return NO_EFFECTS;
|
|
1556
|
-
annotatedThisTurn.add(step.
|
|
1557
|
-
|
|
1711
|
+
annotatedThisTurn.add(step.operationFingerprint);
|
|
1712
|
+
lastInjectedOperationFingerprint = step.operationFingerprint;
|
|
1558
1713
|
lastDecision = "injected";
|
|
1559
1714
|
rulesInjectedSincePromptedStep = true;
|
|
1560
1715
|
annotatedSinceTurnEnd = true;
|
|
@@ -1563,7 +1718,7 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1563
1718
|
return [{ kind: "annotate_tool_result", message, severity: "warn" }];
|
|
1564
1719
|
}
|
|
1565
1720
|
function rememberFailure(step) {
|
|
1566
|
-
const previous = failures.get(step.
|
|
1721
|
+
const previous = failures.get(step.operationFingerprint);
|
|
1567
1722
|
const attempts = (previous?.attempts ?? 0) + 1;
|
|
1568
1723
|
const firstStep = previous?.firstStep ?? step.step;
|
|
1569
1724
|
const content = proceduralContent(step.callDescription, attempts, firstStep, step.resultDigest);
|
|
@@ -1579,7 +1734,7 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1579
1734
|
}
|
|
1580
1735
|
setBounded(
|
|
1581
1736
|
failures,
|
|
1582
|
-
step.
|
|
1737
|
+
step.operationFingerprint,
|
|
1583
1738
|
{
|
|
1584
1739
|
entryId,
|
|
1585
1740
|
attempts,
|
|
@@ -1594,20 +1749,20 @@ function createMemoryInterventionRegistration(deps) {
|
|
|
1594
1749
|
try {
|
|
1595
1750
|
for (let index = trajectory.length - 1; index >= 0; index -= 1) {
|
|
1596
1751
|
const step = trajectory[index];
|
|
1597
|
-
if (step === void 0 || step.outcome !== "error" || step.step <= lastTurnEndStep || step.
|
|
1752
|
+
if (step === void 0 || step.outcome !== "error" || step.step <= lastTurnEndStep || step.operationFingerprint === lastInjectedOperationFingerprint) {
|
|
1598
1753
|
continue;
|
|
1599
1754
|
}
|
|
1600
1755
|
const occurrences = trajectory.filter(
|
|
1601
|
-
(candidate) => candidate.outcome === "error" && candidate.
|
|
1756
|
+
(candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint
|
|
1602
1757
|
).length;
|
|
1603
|
-
const failure = failures.get(step.
|
|
1758
|
+
const failure = failures.get(step.operationFingerprint);
|
|
1604
1759
|
if (occurrences < 2 || failure === void 0) continue;
|
|
1605
1760
|
const message = boundedReminder(
|
|
1606
1761
|
`Memory: [${failure.entryId}] you already tried ${failure.callDescription} at step ${failure.firstStep} and it failed with ${failure.errorDigest}.`,
|
|
1607
1762
|
settings().maxTokens
|
|
1608
1763
|
);
|
|
1609
1764
|
if (message.length === 0) return NO_EFFECTS;
|
|
1610
|
-
|
|
1765
|
+
lastInjectedOperationFingerprint = step.operationFingerprint;
|
|
1611
1766
|
lastInjectedMessage = message;
|
|
1612
1767
|
lastDecision = "injected";
|
|
1613
1768
|
rulesInjectedSincePromptedStep = true;
|
|
@@ -1649,29 +1804,33 @@ function prepareToolStep(input) {
|
|
|
1649
1804
|
const canonical = hashToolCall(toolName, input.toolArgs ?? {});
|
|
1650
1805
|
return {
|
|
1651
1806
|
toolName,
|
|
1652
|
-
|
|
1807
|
+
operationFingerprint: createHash2("sha256").update(canonical).digest("hex").slice(0, 16),
|
|
1653
1808
|
callDescription: shortText(canonical, CALL_DESCRIPTION_MAX_CHARS)
|
|
1654
1809
|
};
|
|
1655
1810
|
}
|
|
1656
|
-
function pendingKey(input,
|
|
1657
|
-
return input.toolCallId ?? `anonymous:${
|
|
1811
|
+
function pendingKey(input, operationFingerprint) {
|
|
1812
|
+
return input.toolCallId ?? `anonymous:${operationFingerprint}`;
|
|
1658
1813
|
}
|
|
1659
1814
|
function resultDigest(input, outcome) {
|
|
1815
|
+
if (input.toolResultDigest !== void 0) return sanitizeToolResultDigest(input.toolResultDigest);
|
|
1660
1816
|
if (outcome === "error") {
|
|
1661
1817
|
const metadataMessage = input.metadata?.errorMessage;
|
|
1662
1818
|
if (typeof metadataMessage === "string" && metadataMessage.trim().length > 0) {
|
|
1663
|
-
return
|
|
1819
|
+
return legacyToolResultDigest(diagnosticLine(metadataMessage), { outcome });
|
|
1664
1820
|
}
|
|
1665
1821
|
for (const key of ["error", "message"]) {
|
|
1666
1822
|
const value = input.toolResultDetails?.[key];
|
|
1667
1823
|
if (typeof value === "string" && value.trim().length > 0) {
|
|
1668
|
-
return
|
|
1824
|
+
return legacyToolResultDigest(diagnosticLine(value), { outcome });
|
|
1669
1825
|
}
|
|
1670
1826
|
}
|
|
1671
|
-
return "
|
|
1827
|
+
return legacyToolResultDigest("", { outcome });
|
|
1672
1828
|
}
|
|
1673
1829
|
const resultFingerprint = input.metadata?.resultFingerprint;
|
|
1674
|
-
return
|
|
1830
|
+
return legacyToolResultDigest(
|
|
1831
|
+
typeof resultFingerprint === "string" ? `ok result ${resultFingerprint.slice(0, 16)}` : "ok",
|
|
1832
|
+
{ outcome }
|
|
1833
|
+
);
|
|
1675
1834
|
}
|
|
1676
1835
|
var DIAGNOSTIC_HINT = /\b(error|failed|failure|cannot|unable|expected|refused|denied|missing|not found|timed out|timeout|fatal)\b/iu;
|
|
1677
1836
|
function diagnosticLine(value) {
|
|
@@ -1713,7 +1872,7 @@ init_esm_shims();
|
|
|
1713
1872
|
var SKILLS_REMINDER_REGISTRATION_ID = "observer.skills-reminder";
|
|
1714
1873
|
function skillsReminderMessage(installed, installable = 0) {
|
|
1715
1874
|
const counts = installable > 0 ? `${installed} installed, ${installable} installable from the marketplace` : `${installed} installed`;
|
|
1716
|
-
return `[Skills] ${counts}. Start this task by listing them with context(scope="skills") and checking for a match; if one matches, open your reply with the line \`${SKILL_SUGGESTION_ANCHOR}\` (a comma-separated sequence, in order, when several compose) and
|
|
1875
|
+
return `[Skills] ${counts}. Start this task by listing them with context(scope="skills") and checking for a match; if one matches, open your reply with the line \`${SKILL_SUGGESTION_ANCHOR}\` (a comma-separated sequence, in order, when several compose) and then continue the task in the same turn without the skill. Only the operator loads a skill, and a marketplace skill is offered for install when the operator runs it. If none match, do not mention skills and continue with the task.`;
|
|
1717
1876
|
}
|
|
1718
1877
|
var NO_EFFECTS2 = [];
|
|
1719
1878
|
var GREETING_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -1767,9 +1926,12 @@ function createSkillsReminderRegistration(deps) {
|
|
|
1767
1926
|
let observedAnyTurn = false;
|
|
1768
1927
|
return {
|
|
1769
1928
|
id: SKILLS_REMINDER_REGISTRATION_ID,
|
|
1770
|
-
description: "once per session, on the first substantive turn, teaches the skill-suggestion reply protocol",
|
|
1771
|
-
hooks: ["turn_start"],
|
|
1929
|
+
description: "once per session, on the first substantive turn, teaches the skill-suggestion reply protocol; keeps a turn going that stopped on the suggestion",
|
|
1930
|
+
hooks: ["turn_start", "turn_end"],
|
|
1772
1931
|
evaluate(input) {
|
|
1932
|
+
if (input.hook === "turn_end") {
|
|
1933
|
+
return isSkillSuggestionWait(input) ? [{ kind: "request_continuation", message: SKILL_SUGGESTION_WAIT_CONTINUATION_MESSAGE }] : NO_EFFECTS2;
|
|
1934
|
+
}
|
|
1773
1935
|
const sessionId = input.sessionId ?? null;
|
|
1774
1936
|
if (lastSeenSessionId === void 0) {
|
|
1775
1937
|
lastSeenSessionId = sessionId;
|
|
@@ -2092,4 +2254,4 @@ export {
|
|
|
2092
2254
|
createMiddlewareToolChoiceControl,
|
|
2093
2255
|
MiddlewareDomainModule
|
|
2094
2256
|
};
|
|
2095
|
-
//# sourceMappingURL=chunk-
|
|
2257
|
+
//# sourceMappingURL=chunk-ZXF4XRKW.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
EMPTY_WORKING_SET_VIEW,
|
|
4
|
+
callPathsByToolCallId,
|
|
5
|
+
offloadPathOf,
|
|
6
|
+
parseRefKey,
|
|
7
|
+
primaryPathOf,
|
|
8
|
+
refKey,
|
|
9
|
+
toolResultPayload,
|
|
10
|
+
toolResultText
|
|
11
|
+
} from "./chunk-TZSKNMZG.js";
|
|
12
|
+
import {
|
|
13
|
+
filterEntriesToActivePath
|
|
14
|
+
} from "./chunk-W6GROXXM.js";
|
|
15
|
+
import {
|
|
16
|
+
ceilChars
|
|
17
|
+
} from "./chunk-GEYXPTRF.js";
|
|
18
|
+
import {
|
|
19
|
+
init_esm_shims
|
|
20
|
+
} from "./chunk-3R73A4XB.js";
|
|
21
|
+
|
|
22
|
+
// src/domains/context/working-set/recall.ts
|
|
23
|
+
init_esm_shims();
|
|
24
|
+
function isThinkingEntry(entry) {
|
|
25
|
+
return entry.kind === "message" && entry.role === "assistant";
|
|
26
|
+
}
|
|
27
|
+
function isToolResultEntry(entry) {
|
|
28
|
+
return entry.kind === "message" && entry.role === "tool_result";
|
|
29
|
+
}
|
|
30
|
+
function resolveRecall(entries, view, ref, activeLeafTurnId) {
|
|
31
|
+
const parsed = parseRefKey(ref);
|
|
32
|
+
if (parsed === null) return { ok: false, error: { kind: "invalid_ref", ref } };
|
|
33
|
+
const key = refKey(parsed);
|
|
34
|
+
const active = filterEntriesToActivePath(entries, activeLeafTurnId);
|
|
35
|
+
const entry = active.find((candidate) => candidate.turnId === key);
|
|
36
|
+
if (entry === void 0) {
|
|
37
|
+
return { ok: false, error: { kind: "not_on_active_path", ref: key } };
|
|
38
|
+
}
|
|
39
|
+
if (isThinkingEntry(entry) || !view.evicted.has(key) || !isToolResultEntry(entry)) {
|
|
40
|
+
return { ok: false, error: { kind: "not_evicted", ref: key } };
|
|
41
|
+
}
|
|
42
|
+
const payload = toolResultPayload(entry.payload);
|
|
43
|
+
const body = toolResultText(payload.result);
|
|
44
|
+
const offloadPath = offloadPathOf(payload);
|
|
45
|
+
return {
|
|
46
|
+
ok: true,
|
|
47
|
+
result: {
|
|
48
|
+
ref: parsed,
|
|
49
|
+
entry,
|
|
50
|
+
body,
|
|
51
|
+
tokens: ceilChars(body.length),
|
|
52
|
+
...offloadPath !== void 0 ? { offloadPath } : {}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function recallParentTurnId(entries, activeLeafTurnId) {
|
|
57
|
+
const active = filterEntriesToActivePath(entries, activeLeafTurnId);
|
|
58
|
+
for (let i = active.length - 1; i >= 0; i -= 1) {
|
|
59
|
+
const candidate = active[i];
|
|
60
|
+
if (candidate?.kind === "message") return candidate.turnId;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function buildRecallFields(result, meta) {
|
|
65
|
+
return {
|
|
66
|
+
kind: "contextRecall",
|
|
67
|
+
ref: { entry: result.ref.entry },
|
|
68
|
+
trigger: meta.trigger,
|
|
69
|
+
tokensReadmitted: result.tokens,
|
|
70
|
+
...meta.toolCallId !== void 0 ? { toolCallId: meta.toolCallId } : {}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
var MAX_LISTED_REFS = 8;
|
|
74
|
+
function recallableRefListing(entries, view) {
|
|
75
|
+
const byTurnId = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const entry of entries) byTurnId.set(entry.turnId, entry);
|
|
77
|
+
const callPaths = callPathsByToolCallId(entries);
|
|
78
|
+
const refs = [];
|
|
79
|
+
for (const key of view.evicted.keys()) {
|
|
80
|
+
const entry = byTurnId.get(key);
|
|
81
|
+
if (entry === void 0 || !isToolResultEntry(entry)) continue;
|
|
82
|
+
const payload = toolResultPayload(entry.payload);
|
|
83
|
+
const toolCallId = typeof payload.obj.toolCallId === "string" ? payload.obj.toolCallId : void 0;
|
|
84
|
+
const path = primaryPathOf(payload) ?? (toolCallId === void 0 ? void 0 : callPaths.get(toolCallId));
|
|
85
|
+
refs.push(`${key} (${payload.toolName}${path === void 0 ? "" : ` ${path}`})`);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
refs: refs.slice(0, MAX_LISTED_REFS),
|
|
89
|
+
remaining: Math.max(0, refs.length - MAX_LISTED_REFS)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function recallableRefMessage(entries, view) {
|
|
93
|
+
const listing = recallableRefListing(entries, view);
|
|
94
|
+
if (listing.refs.length === 0) return "No recallable refs on the active path.";
|
|
95
|
+
const more = listing.remaining > 0 ? `, and ${listing.remaining} more` : "";
|
|
96
|
+
return `Recallable refs on the active path: ${listing.refs.join(", ")}${more}.`;
|
|
97
|
+
}
|
|
98
|
+
function recallErrorMessage(error, entries = [], view = EMPTY_WORKING_SET_VIEW) {
|
|
99
|
+
const listing = ` ${recallableRefMessage(entries, view)}`;
|
|
100
|
+
switch (error.kind) {
|
|
101
|
+
case "invalid_ref":
|
|
102
|
+
return `recall ref must be a single turnId without whitespace; got '${error.ref}'.`;
|
|
103
|
+
case "not_on_active_path":
|
|
104
|
+
return `ref ${error.ref} is not on the active path of this session (unknown or on an abandoned branch).${listing}`;
|
|
105
|
+
case "not_evicted": {
|
|
106
|
+
const entry = entries.find((candidate) => candidate.turnId === error.ref);
|
|
107
|
+
if (entry !== void 0 && isThinkingEntry(entry)) {
|
|
108
|
+
return `ref ${error.ref} is an assistant turn; thinking is not recallable.${listing}`;
|
|
109
|
+
}
|
|
110
|
+
return `ref ${error.ref} is not evicted; its content is already in context.${listing}`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
resolveRecall,
|
|
117
|
+
recallParentTurnId,
|
|
118
|
+
buildRecallFields,
|
|
119
|
+
recallableRefListing,
|
|
120
|
+
recallErrorMessage
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=chunk-ZZMN5OM4.js.map
|