muonroi-cli 1.3.4 → 1.4.1
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/LICENSE +21 -21
- package/README.md +122 -122
- package/dist/packages/agent-harness-core/src/predicate.d.ts +2 -2
- package/dist/packages/agent-harness-core/src/protocol.d.ts +8 -0
- package/dist/src/__test-helpers__/catalog-fixtures.d.ts +22 -0
- package/dist/src/__test-helpers__/catalog-fixtures.js +55 -0
- package/dist/src/agent-harness/index.js +1 -1
- package/dist/src/agent-harness/mock-model.d.ts +5 -0
- package/dist/src/agent-harness/mock-model.js +68 -23
- package/dist/src/agent-harness/test-spawn.d.ts +7 -1
- package/dist/src/agent-harness/test-spawn.js +19 -4
- package/dist/src/chat/__tests__/broadcast-bus.test.js +2 -2
- package/dist/src/chat/__tests__/client.test.js +1 -1
- package/dist/src/chat/broadcast-bus.js +2 -2
- package/dist/src/chat/chat-keychain.js +11 -2
- package/dist/src/chat/providers/discord/client.d.ts +1 -1
- package/dist/src/chat/providers/discord/client.js +1 -1
- package/dist/src/cli/config/screen-council.js +1 -1
- package/dist/src/cli/config/screen-models.js +2 -2
- package/dist/src/cli/config/screen-providers.js +2 -2
- package/dist/src/cli/config/tui.js +1 -1
- package/dist/src/cli/cost-forensics.d.ts +31 -0
- package/dist/src/cli/cost-forensics.js +58 -12
- package/dist/src/cli/cost-forensics.test.js +125 -2
- package/dist/src/cli/keys.d.ts +5 -1
- package/dist/src/cli/keys.js +48 -20
- package/dist/src/cli/keys.test.js +1 -1
- package/dist/src/cli/reporter-cmd.d.ts +15 -0
- package/dist/src/cli/reporter-cmd.js +120 -0
- package/dist/src/cli/usage-report.d.ts +38 -1
- package/dist/src/cli/usage-report.js +133 -0
- package/dist/src/council/__tests__/audit-replay.test.js +1 -1
- package/dist/src/council/__tests__/clarifier-max-rounds.test.js +5 -5
- package/dist/src/council/__tests__/clarifier-ready-gate.test.js +233 -0
- package/dist/src/council/__tests__/debate-planner-structured.test.js +2 -2
- package/dist/src/council/__tests__/decisions-lock.test.d.ts +6 -0
- package/dist/src/council/__tests__/decisions-lock.test.js +336 -0
- package/dist/src/council/__tests__/tool-trace.test.js +2 -2
- package/dist/src/council/clarifier.d.ts +19 -2
- package/dist/src/council/clarifier.js +84 -6
- package/dist/src/council/context.js +3 -3
- package/dist/src/council/debate-planner.d.ts +1 -1
- package/dist/src/council/debate-planner.js +40 -7
- package/dist/src/council/debate.js +1 -1
- package/dist/src/council/decisions-lock.d.ts +76 -0
- package/dist/src/council/decisions-lock.js +239 -0
- package/dist/src/council/index.d.ts +5 -0
- package/dist/src/council/index.js +50 -18
- package/dist/src/council/leader.d.ts +1 -1
- package/dist/src/council/leader.js +14 -1
- package/dist/src/council/llm.js +33 -61
- package/dist/src/council/phase-events.d.ts +5 -0
- package/dist/src/council/phase-events.js +1 -0
- package/dist/src/council/planner.js +1 -1
- package/dist/src/council/prompts.d.ts +24 -0
- package/dist/src/council/prompts.js +112 -22
- package/dist/src/council/types.d.ts +18 -0
- package/dist/src/ee/__tests__/export-transcripts.test.d.ts +11 -0
- package/dist/src/ee/__tests__/export-transcripts.test.js +200 -0
- package/dist/src/ee/__tests__/recall-format.test.d.ts +10 -0
- package/dist/src/ee/__tests__/recall-format.test.js +57 -0
- package/dist/src/ee/__tests__/recall-ledger.test.d.ts +1 -0
- package/dist/src/ee/__tests__/recall-ledger.test.js +45 -0
- package/dist/src/ee/auth.test.js +2 -2
- package/dist/src/ee/client.js +59 -0
- package/dist/src/ee/client.test.js +30 -0
- package/dist/src/ee/council-bridge.js +3 -3
- package/dist/src/ee/export-transcripts.d.ts +26 -0
- package/dist/src/ee/export-transcripts.js +115 -0
- package/dist/src/ee/intercept.d.ts +9 -0
- package/dist/src/ee/intercept.js +19 -0
- package/dist/src/ee/offline-queue.test.js +3 -3
- package/dist/src/ee/phase-tracker.js +1 -1
- package/dist/src/ee/recall-ledger.d.ts +32 -0
- package/dist/src/ee/recall-ledger.js +52 -0
- package/dist/src/ee/recall-mirror.test.d.ts +1 -0
- package/dist/src/ee/recall-mirror.test.js +65 -0
- package/dist/src/ee/scope.js +1 -1
- package/dist/src/ee/scope.test.js +1 -1
- package/dist/src/ee/search.d.ts +99 -0
- package/dist/src/ee/search.js +220 -0
- package/dist/src/ee/session-trajectory.js +1 -1
- package/dist/src/ee/session-trajectory.test.js +1 -1
- package/dist/src/ee/transcript-emit.d.ts +51 -0
- package/dist/src/ee/transcript-emit.js +140 -0
- package/dist/src/ee/types.d.ts +37 -1
- package/dist/src/flow/__tests__/migration.test.js +1 -1
- package/dist/src/flow/__tests__/run-manager-product.test.js +1 -1
- package/dist/src/flow/__tests__/run-manager.test.js +1 -1
- package/dist/src/flow/__tests__/scaffold-checkpoint.test.js +2 -2
- package/dist/src/flow/__tests__/scaffold.test.js +1 -1
- package/dist/src/flow/__tests__/warning-persist.test.js +1 -1
- package/dist/src/generated/version.d.ts +1 -1
- package/dist/src/generated/version.js +1 -1
- package/dist/src/gsd/__tests__/directives.test.js +35 -0
- package/dist/src/gsd/__tests__/types.test.js +14 -1
- package/dist/src/gsd/directives.d.ts +10 -0
- package/dist/src/gsd/directives.js +38 -2
- package/dist/src/gsd/gray-areas.js +1 -1
- package/dist/src/gsd/types.d.ts +1 -1
- package/dist/src/gsd/types.js +20 -6
- package/dist/src/headless/__tests__/council-answers.test.js +26 -1
- package/dist/src/headless/council-answers.d.ts +17 -2
- package/dist/src/headless/council-answers.js +21 -0
- package/dist/src/hooks/index.js +74 -49
- package/dist/src/index.js +180 -16
- package/dist/src/lsp/builtins.js +44 -0
- package/dist/src/lsp/builtins.test.js +22 -1
- package/dist/src/lsp/manager.js +40 -9
- package/dist/src/lsp/manager.test.js +23 -1
- package/dist/src/lsp/npm-cache.js +2 -1
- package/dist/src/lsp/npm-cache.test.js +1 -1
- package/dist/src/lsp/smoke.test.js +1 -1
- package/dist/src/lsp/types.d.ts +3 -1
- package/dist/src/maintain/__tests__/codebase-intel.test.d.ts +5 -0
- package/dist/src/maintain/__tests__/codebase-intel.test.js +237 -0
- package/dist/src/maintain/__tests__/gh-create-pr.test.d.ts +11 -0
- package/dist/src/maintain/__tests__/gh-create-pr.test.js +156 -0
- package/dist/src/maintain/__tests__/pr-builder.test.d.ts +10 -0
- package/dist/src/maintain/__tests__/pr-builder.test.js +225 -0
- package/dist/src/maintain/__tests__/repo-map.test.d.ts +5 -0
- package/dist/src/maintain/__tests__/repo-map.test.js +90 -0
- package/dist/src/maintain/__tests__/task-runner.test.d.ts +11 -0
- package/dist/src/maintain/__tests__/task-runner.test.js +281 -0
- package/dist/src/maintain/codebase-intel.d.ts +22 -0
- package/dist/src/maintain/codebase-intel.js +548 -0
- package/dist/src/maintain/gh-create-pr.d.ts +24 -0
- package/dist/src/maintain/gh-create-pr.js +111 -0
- package/dist/src/maintain/index.d.ts +12 -0
- package/dist/src/maintain/index.js +10 -0
- package/dist/src/maintain/pr-builder.d.ts +35 -0
- package/dist/src/maintain/pr-builder.js +305 -0
- package/dist/src/maintain/repo-map.d.ts +25 -0
- package/dist/src/maintain/repo-map.js +189 -0
- package/dist/src/maintain/task-runner.d.ts +45 -0
- package/dist/src/maintain/task-runner.js +401 -0
- package/dist/src/maintain/types.d.ts +45 -0
- package/dist/src/maintain/types.js +7 -0
- package/dist/src/mcp/__tests__/auto-setup.test.js +1 -1
- package/dist/src/mcp/__tests__/cap-tool-result.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/cap-tool-result.test.js +58 -0
- package/dist/src/mcp/__tests__/ee-tools.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/ee-tools.test.js +198 -0
- package/dist/src/mcp/__tests__/forensics-tools.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/forensics-tools.test.js +53 -0
- package/dist/src/mcp/__tests__/harness-driver-action-tools.spec.js +3 -1
- package/dist/src/mcp/__tests__/harness-driver-async-tools.spec.js +3 -1
- package/dist/src/mcp/__tests__/lsp-tools.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/lsp-tools.test.js +56 -0
- package/dist/src/mcp/__tests__/runtime-output-cap.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/runtime-output-cap.test.js +42 -0
- package/dist/src/mcp/__tests__/self-verify-jobs.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/self-verify-jobs.test.js +92 -0
- package/dist/src/mcp/__tests__/smart-filter.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/smart-filter.test.js +121 -0
- package/dist/src/mcp/__tests__/tools-server.smoke.test.d.ts +1 -0
- package/dist/src/mcp/__tests__/tools-server.smoke.test.js +42 -0
- package/dist/src/mcp/cap-tool-result.d.ts +1 -0
- package/dist/src/mcp/cap-tool-result.js +35 -0
- package/dist/src/mcp/ee-tools.d.ts +36 -0
- package/dist/src/mcp/ee-tools.js +159 -0
- package/dist/src/mcp/forensics-tools.d.ts +13 -0
- package/dist/src/mcp/forensics-tools.js +52 -0
- package/dist/src/mcp/lsp-tools.d.ts +16 -0
- package/dist/src/mcp/lsp-tools.js +65 -0
- package/dist/src/mcp/mcp-keychain.js +11 -2
- package/dist/src/mcp/oauth-callback.js +2 -2
- package/dist/src/mcp/opentui-spawn.js +1 -1
- package/dist/src/mcp/parse-headers.test.js +14 -14
- package/dist/src/mcp/runtime.js +11 -0
- package/dist/src/mcp/self-verify-jobs.d.ts +55 -0
- package/dist/src/mcp/self-verify-jobs.js +86 -0
- package/dist/src/mcp/smart-filter.d.ts +48 -0
- package/dist/src/mcp/smart-filter.js +115 -0
- package/dist/src/mcp/smoke.test.js +44 -44
- package/dist/src/mcp/tools-server.d.ts +14 -0
- package/dist/src/mcp/tools-server.js +147 -0
- package/dist/src/models/catalog-client.d.ts +22 -0
- package/dist/src/models/catalog-client.js +95 -9
- package/dist/src/models/catalog-gemini.test.d.ts +1 -0
- package/dist/src/models/catalog-gemini.test.js +46 -0
- package/dist/src/models/catalog-url.test.d.ts +1 -0
- package/dist/src/models/catalog-url.test.js +26 -0
- package/dist/src/models/catalog-validation.test.d.ts +1 -0
- package/dist/src/models/catalog-validation.test.js +63 -0
- package/dist/src/models/catalog.json +349 -177
- package/dist/src/models/classify-tier.d.ts +1 -1
- package/dist/src/models/classify-tier.js +1 -1
- package/dist/src/models/registry.d.ts +2 -0
- package/dist/src/models/registry.js +9 -0
- package/dist/src/ops/__tests__/doctor-ee-health.test.js +1 -1
- package/dist/src/ops/doctor.js +7 -7
- package/dist/src/orchestrator/__tests__/agent-base-url-switch.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/agent-base-url-switch.test.js +77 -0
- package/dist/src/orchestrator/__tests__/batch-turn-runner.test.js +10 -3
- package/dist/src/orchestrator/__tests__/cross-turn-dedup.test.js +38 -16
- package/dist/src/orchestrator/__tests__/error-forensics.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/error-forensics.test.js +93 -0
- package/dist/src/orchestrator/__tests__/flow-resume.test.js +1 -1
- package/dist/src/orchestrator/__tests__/humanize-api-error.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/humanize-api-error.test.js +68 -0
- package/dist/src/orchestrator/__tests__/message-processor.test.js +6 -1
- package/dist/src/orchestrator/__tests__/read-path-budget.test.js +62 -4
- package/dist/src/orchestrator/__tests__/retry-classifier.test.js +10 -0
- package/dist/src/orchestrator/__tests__/stream-runner.test.js +77 -4
- package/dist/src/orchestrator/__tests__/sub-agent-model-tier.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/sub-agent-model-tier.test.js +45 -0
- package/dist/src/orchestrator/__tests__/usage-shape-threading.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/usage-shape-threading.test.js +98 -0
- package/dist/src/orchestrator/agent.test.js +33 -18
- package/dist/src/orchestrator/batch-turn-runner.d.ts +1 -1
- package/dist/src/orchestrator/batch-turn-runner.js +3 -2
- package/dist/src/orchestrator/compaction.js +99 -87
- package/dist/src/orchestrator/compaction.test.js +17 -0
- package/dist/src/orchestrator/council-manager.d.ts +1 -1
- package/dist/src/orchestrator/council-manager.js +3 -10
- package/dist/src/orchestrator/cross-turn-dedup.js +21 -1
- package/dist/src/orchestrator/delegations.js +7 -1
- package/dist/src/orchestrator/delegations.test.js +1 -1
- package/dist/src/orchestrator/error-utils.d.ts +27 -1
- package/dist/src/orchestrator/error-utils.js +63 -1
- package/dist/src/orchestrator/grounding-check.d.ts +50 -0
- package/dist/src/orchestrator/grounding-check.js +123 -0
- package/dist/src/orchestrator/grounding-check.test.d.ts +1 -0
- package/dist/src/orchestrator/grounding-check.test.js +94 -0
- package/dist/src/orchestrator/interrupted-turn.d.ts +19 -0
- package/dist/src/orchestrator/interrupted-turn.js +28 -0
- package/dist/src/orchestrator/interrupted-turn.test.d.ts +1 -0
- package/dist/src/orchestrator/interrupted-turn.test.js +34 -0
- package/dist/src/orchestrator/message-processor.d.ts +11 -10
- package/dist/src/orchestrator/message-processor.js +1367 -93
- package/dist/src/orchestrator/orchestrator.d.ts +7 -3
- package/dist/src/orchestrator/orchestrator.js +158 -43
- package/dist/src/orchestrator/pending-calls.test.js +1 -1
- package/dist/src/orchestrator/prompts.d.ts +1 -1
- package/dist/src/orchestrator/prompts.js +237 -154
- package/dist/src/orchestrator/read-path-budget.d.ts +22 -2
- package/dist/src/orchestrator/read-path-budget.js +96 -18
- package/dist/src/orchestrator/reasoning.js +43 -1
- package/dist/src/orchestrator/reasoning.test.js +75 -0
- package/dist/src/orchestrator/repair-tool-call.d.ts +32 -0
- package/dist/src/orchestrator/repair-tool-call.js +50 -0
- package/dist/src/orchestrator/repetition-detector.d.ts +58 -0
- package/dist/src/orchestrator/repetition-detector.js +126 -0
- package/dist/src/orchestrator/repetition-detector.test.d.ts +1 -0
- package/dist/src/orchestrator/repetition-detector.test.js +103 -0
- package/dist/src/orchestrator/retry-classifier.js +8 -0
- package/dist/src/orchestrator/sandbox.test.js +3 -1
- package/dist/src/orchestrator/scope-ceiling.d.ts +86 -0
- package/dist/src/orchestrator/scope-ceiling.js +161 -0
- package/dist/src/orchestrator/scope-ceiling.test.d.ts +13 -0
- package/dist/src/orchestrator/scope-ceiling.test.js +181 -0
- package/dist/src/orchestrator/scope-reminder.d.ts +102 -0
- package/dist/src/orchestrator/scope-reminder.js +221 -0
- package/dist/src/orchestrator/scope-reminder.test.d.ts +15 -0
- package/dist/src/orchestrator/scope-reminder.test.js +204 -0
- package/dist/src/orchestrator/stall-rescue.d.ts +67 -0
- package/dist/src/orchestrator/stall-rescue.js +72 -0
- package/dist/src/orchestrator/stall-rescue.test.d.ts +1 -0
- package/dist/src/orchestrator/stall-rescue.test.js +88 -0
- package/dist/src/orchestrator/stall-watchdog.d.ts +34 -0
- package/dist/src/orchestrator/stall-watchdog.js +72 -0
- package/dist/src/orchestrator/stall-watchdog.test.d.ts +1 -0
- package/dist/src/orchestrator/stall-watchdog.test.js +73 -0
- package/dist/src/orchestrator/stream-runner.d.ts +18 -2
- package/dist/src/orchestrator/stream-runner.js +248 -77
- package/dist/src/orchestrator/sub-agent-cap.js +21 -1
- package/dist/src/orchestrator/sub-agent-cap.test.js +41 -3
- package/dist/src/orchestrator/sub-agent-model-tier.d.ts +13 -0
- package/dist/src/orchestrator/sub-agent-model-tier.js +45 -0
- package/dist/src/orchestrator/subagent-compactor.d.ts +49 -0
- package/dist/src/orchestrator/subagent-compactor.js +184 -11
- package/dist/src/orchestrator/subagent-compactor.spec.js +187 -2
- package/dist/src/orchestrator/text-tool-call-detector.d.ts +61 -0
- package/dist/src/orchestrator/text-tool-call-detector.js +163 -0
- package/dist/src/orchestrator/text-tool-call-detector.test.d.ts +1 -0
- package/dist/src/orchestrator/text-tool-call-detector.test.js +89 -0
- package/dist/src/orchestrator/tool-args-hash.d.ts +51 -0
- package/dist/src/orchestrator/tool-args-hash.js +219 -0
- package/dist/src/orchestrator/tool-args-hash.test.d.ts +1 -0
- package/dist/src/orchestrator/tool-args-hash.test.js +105 -0
- package/dist/src/orchestrator/tool-args-repair.d.ts +93 -0
- package/dist/src/orchestrator/tool-args-repair.js +219 -0
- package/dist/src/orchestrator/tool-args-repair.test.d.ts +1 -0
- package/dist/src/orchestrator/tool-args-repair.test.js +136 -0
- package/dist/src/orchestrator/tool-loop-cap.d.ts +66 -0
- package/dist/src/orchestrator/tool-loop-cap.js +138 -0
- package/dist/src/orchestrator/tool-loop-cap.test.d.ts +1 -0
- package/dist/src/orchestrator/tool-loop-cap.test.js +176 -0
- package/dist/src/orchestrator/tool-repetition-detector.d.ts +64 -0
- package/dist/src/orchestrator/tool-repetition-detector.js +0 -0
- package/dist/src/orchestrator/tool-repetition-detector.test.d.ts +1 -0
- package/dist/src/orchestrator/tool-repetition-detector.test.js +101 -0
- package/dist/src/orchestrator/turn-runner-deps.d.ts +3 -1
- package/dist/src/pil/__tests__/clarity-gate.test.d.ts +1 -0
- package/dist/src/pil/__tests__/clarity-gate.test.js +228 -0
- package/dist/src/pil/__tests__/config.test.js +44 -1
- package/dist/src/pil/__tests__/discovery-cache.test.d.ts +1 -0
- package/dist/src/pil/__tests__/discovery-cache.test.js +38 -0
- package/dist/src/pil/__tests__/discovery-types.test.d.ts +1 -0
- package/dist/src/pil/__tests__/discovery-types.test.js +54 -0
- package/dist/src/pil/__tests__/discovery.test.d.ts +1 -0
- package/dist/src/pil/__tests__/discovery.test.js +101 -0
- package/dist/src/pil/__tests__/layer1-intent-trace.test.js +5 -3
- package/dist/src/pil/__tests__/layer1-intent.test.js +25 -7
- package/dist/src/pil/__tests__/layer15-context-scan.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer15-context-scan.test.js +64 -0
- package/dist/src/pil/__tests__/layer16-clarity.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer16-clarity.test.js +153 -0
- package/dist/src/pil/__tests__/layer17-feasibility.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer17-feasibility.test.js +36 -0
- package/dist/src/pil/__tests__/layer18-acceptance.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer18-acceptance.test.js +95 -0
- package/dist/src/pil/__tests__/layer3-ee-injection.test.js +4 -1
- package/dist/src/pil/__tests__/layer3-injected-chunk.test.js +3 -3
- package/dist/src/pil/__tests__/layer6-output.test.js +69 -9
- package/dist/src/pil/__tests__/llm-classify.test.d.ts +1 -0
- package/dist/src/pil/__tests__/llm-classify.test.js +113 -0
- package/dist/src/pil/__tests__/native-capabilities-workbook.test.d.ts +1 -0
- package/dist/src/pil/__tests__/native-capabilities-workbook.test.js +40 -0
- package/dist/src/pil/__tests__/pipeline.test.js +3 -2
- package/dist/src/pil/__tests__/renderer-coverage.test.js +1 -1
- package/dist/src/pil/__tests__/response-tools.test.js +49 -1
- package/dist/src/pil/__tests__/scoreComplexity.test.js +2 -2
- package/dist/src/pil/agent-operating-contract.d.ts +51 -0
- package/dist/src/pil/agent-operating-contract.js +66 -0
- package/dist/src/pil/agent-operating-contract.test.d.ts +1 -0
- package/dist/src/pil/agent-operating-contract.test.js +75 -0
- package/dist/src/pil/budget-log.js +1 -1
- package/dist/src/pil/cheap-model-playbook.d.ts +80 -0
- package/dist/src/pil/cheap-model-playbook.js +147 -0
- package/dist/src/pil/cheap-model-playbook.test.d.ts +1 -0
- package/dist/src/pil/cheap-model-playbook.test.js +160 -0
- package/dist/src/pil/cheap-model-workbooks.d.ts +55 -0
- package/dist/src/pil/cheap-model-workbooks.js +102 -0
- package/dist/src/pil/cheap-model-workbooks.test.d.ts +1 -0
- package/dist/src/pil/cheap-model-workbooks.test.js +129 -0
- package/dist/src/pil/clarity-gate.d.ts +22 -0
- package/dist/src/pil/clarity-gate.js +162 -0
- package/dist/src/pil/config.d.ts +3 -0
- package/dist/src/pil/config.js +11 -0
- package/dist/src/pil/discovery-cache.d.ts +4 -0
- package/dist/src/pil/discovery-cache.js +18 -0
- package/dist/src/pil/discovery-types.d.ts +94 -0
- package/dist/src/pil/discovery-types.js +2 -0
- package/dist/src/pil/discovery.d.ts +18 -0
- package/dist/src/pil/discovery.js +341 -0
- package/dist/src/pil/index.d.ts +3 -1
- package/dist/src/pil/index.js +2 -1
- package/dist/src/pil/layer1-intent.d.ts +37 -1
- package/dist/src/pil/layer1-intent.js +675 -39
- package/dist/src/pil/layer1-intent.test.js +333 -1
- package/dist/src/pil/layer15-context-scan.d.ts +9 -0
- package/dist/src/pil/layer15-context-scan.js +164 -0
- package/dist/src/pil/layer16-clarity.d.ts +19 -0
- package/dist/src/pil/layer16-clarity.js +394 -0
- package/dist/src/pil/layer16-clarity.test.d.ts +1 -0
- package/dist/src/pil/layer16-clarity.test.js +31 -0
- package/dist/src/pil/layer17-feasibility.d.ts +4 -0
- package/dist/src/pil/layer17-feasibility.js +30 -0
- package/dist/src/pil/layer18-acceptance.d.ts +4 -0
- package/dist/src/pil/layer18-acceptance.js +84 -0
- package/dist/src/pil/layer1_5-complexity-size.d.ts +23 -0
- package/dist/src/pil/layer1_5-complexity-size.js +152 -0
- package/dist/src/pil/layer1_5-complexity-size.test.d.ts +10 -0
- package/dist/src/pil/layer1_5-complexity-size.test.js +248 -0
- package/dist/src/pil/layer3-ee-injection.js +63 -6
- package/dist/src/pil/layer4-gsd.js +7 -1
- package/dist/src/pil/layer5-context.js +15 -5
- package/dist/src/pil/layer6-output.d.ts +2 -0
- package/dist/src/pil/layer6-output.js +110 -18
- package/dist/src/pil/llm-classify.d.ts +16 -0
- package/dist/src/pil/llm-classify.js +179 -0
- package/dist/src/pil/native-capabilities-workbook.d.ts +39 -0
- package/dist/src/pil/native-capabilities-workbook.js +112 -0
- package/dist/src/pil/pipeline.d.ts +21 -0
- package/dist/src/pil/pipeline.js +89 -13
- package/dist/src/pil/response-tools.d.ts +56 -0
- package/dist/src/pil/response-tools.js +76 -2
- package/dist/src/pil/schema.d.ts +10 -1
- package/dist/src/pil/schema.js +8 -0
- package/dist/src/pil/session-state.d.ts +44 -0
- package/dist/src/pil/session-state.js +143 -0
- package/dist/src/pil/session-state.test.d.ts +1 -0
- package/dist/src/pil/session-state.test.js +73 -0
- package/dist/src/pil/task-tier-map.d.ts +6 -1
- package/dist/src/pil/task-tier-map.js +13 -6
- package/dist/src/pil/types.d.ts +18 -0
- package/dist/src/product-loop/__tests__/artifact-io.test.js +1 -1
- package/dist/src/product-loop/__tests__/assumption-ledger.test.js +1 -1
- package/dist/src/product-loop/__tests__/backlog-builder.test.d.ts +10 -0
- package/dist/src/product-loop/__tests__/backlog-builder.test.js +175 -0
- package/dist/src/product-loop/__tests__/backlog-store.test.d.ts +4 -0
- package/dist/src/product-loop/__tests__/backlog-store.test.js +96 -0
- package/dist/src/product-loop/__tests__/cb2-retry-bonus.test.js +1 -1
- package/dist/src/product-loop/__tests__/complexity-routing.spec.js +113 -7
- package/dist/src/product-loop/__tests__/context-policy.test.js +3 -3
- package/dist/src/product-loop/__tests__/cost-scoper.test.js +1 -1
- package/dist/src/product-loop/__tests__/discovery-context-format.test.d.ts +13 -0
- package/dist/src/product-loop/__tests__/discovery-context-format.test.js +100 -0
- package/dist/src/product-loop/__tests__/discovery-ecosystem.test.js +100 -1
- package/dist/src/product-loop/__tests__/discovery-prompt-specificity.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-prompt-specificity.test.js +55 -0
- package/dist/src/product-loop/__tests__/discovery-recommender-ecosystem.test.js +92 -0
- package/dist/src/product-loop/__tests__/ee-extract-wiring.test.js +8 -3
- package/dist/src/product-loop/__tests__/extract-to-ee.test.js +2 -2
- package/dist/src/product-loop/__tests__/gather-selectable-alts.test.d.ts +15 -0
- package/dist/src/product-loop/__tests__/gather-selectable-alts.test.js +109 -0
- package/dist/src/product-loop/__tests__/integration.test.js +7 -2
- package/dist/src/product-loop/__tests__/loop-driver-audit.test.js +7 -2
- package/dist/src/product-loop/__tests__/loop-driver.test.js +7 -2
- package/dist/src/product-loop/__tests__/maintenance-task-synthesis.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/maintenance-task-synthesis.test.js +67 -0
- package/dist/src/product-loop/__tests__/phase-a1-a3-sprint-runner.test.d.ts +13 -0
- package/dist/src/product-loop/__tests__/phase-a1-a3-sprint-runner.test.js +268 -0
- package/dist/src/product-loop/__tests__/phase-a2-backlog-build.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/phase-a2-backlog-build.test.js +162 -0
- package/dist/src/product-loop/__tests__/phase-rituals.test.js +1 -1
- package/dist/src/product-loop/__tests__/pick-backend-stack.test.d.ts +11 -0
- package/dist/src/product-loop/__tests__/pick-backend-stack.test.js +95 -0
- package/dist/src/product-loop/__tests__/progress-snapshot.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/progress-snapshot.test.js +152 -0
- package/dist/src/product-loop/__tests__/repo-audit.test.js +1 -1
- package/dist/src/product-loop/__tests__/repo-brief.test.d.ts +9 -0
- package/dist/src/product-loop/__tests__/repo-brief.test.js +132 -0
- package/dist/src/product-loop/__tests__/route-decision-emit.test.js +51 -2
- package/dist/src/product-loop/__tests__/ship-polish.test.js +1 -1
- package/dist/src/product-loop/__tests__/sprint-planner.test.d.ts +6 -0
- package/dist/src/product-loop/__tests__/sprint-planner.test.js +140 -0
- package/dist/src/product-loop/__tests__/sprint-runner-backlog.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/sprint-runner-backlog.test.js +221 -0
- package/dist/src/product-loop/__tests__/sprint-runner-phase-chunks.test.d.ts +14 -0
- package/dist/src/product-loop/__tests__/sprint-runner-phase-chunks.test.js +193 -0
- package/dist/src/product-loop/__tests__/sprint-self-verify.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/sprint-self-verify.test.js +73 -0
- package/dist/src/product-loop/__tests__/sprint-store.test.d.ts +7 -0
- package/dist/src/product-loop/__tests__/sprint-store.test.js +84 -0
- package/dist/src/product-loop/__tests__/sufficiency-routing.spec.js +6 -0
- package/dist/src/product-loop/__tests__/types.test.js +7 -7
- package/dist/src/product-loop/__tests__/verify-failure-threshold.test.js +3 -2
- package/dist/src/product-loop/__tests__/verify-failure-tracking.test.js +2 -2
- package/dist/src/product-loop/assumption-ledger.js +6 -6
- package/dist/src/product-loop/backlog-builder.d.ts +32 -0
- package/dist/src/product-loop/backlog-builder.js +198 -0
- package/dist/src/product-loop/backlog-store.d.ts +22 -0
- package/dist/src/product-loop/backlog-store.js +49 -0
- package/dist/src/product-loop/context-policy.js +1 -1
- package/dist/src/product-loop/cost-preview.js +17 -1
- package/dist/src/product-loop/cross-run-memory.js +11 -11
- package/dist/src/product-loop/discover.js +6 -6
- package/dist/src/product-loop/discovery-context-format.d.ts +16 -0
- package/dist/src/product-loop/discovery-context-format.js +45 -13
- package/dist/src/product-loop/discovery-council-runner.js +5 -10
- package/dist/src/product-loop/discovery-detection.js +3 -3
- package/dist/src/product-loop/discovery-ecosystem.d.ts +23 -0
- package/dist/src/product-loop/discovery-ecosystem.js +104 -0
- package/dist/src/product-loop/discovery-interview.d.ts +6 -0
- package/dist/src/product-loop/discovery-interview.js +38 -2
- package/dist/src/product-loop/discovery-recommender.d.ts +29 -0
- package/dist/src/product-loop/discovery-recommender.js +126 -7
- package/dist/src/product-loop/done-gate.js +5 -5
- package/dist/src/product-loop/gather.d.ts +12 -1
- package/dist/src/product-loop/gather.js +93 -12
- package/dist/src/product-loop/index.d.ts +23 -0
- package/dist/src/product-loop/index.js +502 -9
- package/dist/src/product-loop/loop-driver.js +27 -28
- package/dist/src/product-loop/phase-budget.js +2 -2
- package/dist/src/product-loop/progress-snapshot.d.ts +25 -0
- package/dist/src/product-loop/progress-snapshot.js +180 -0
- package/dist/src/product-loop/repo-brief.d.ts +40 -0
- package/dist/src/product-loop/repo-brief.js +212 -0
- package/dist/src/product-loop/role-registry.js +1 -1
- package/dist/src/product-loop/sprint-planner.d.ts +39 -0
- package/dist/src/product-loop/sprint-planner.js +189 -0
- package/dist/src/product-loop/sprint-runner.js +201 -9
- package/dist/src/product-loop/sprint-self-verify.d.ts +54 -0
- package/dist/src/product-loop/sprint-self-verify.js +145 -0
- package/dist/src/product-loop/sprint-store.d.ts +27 -0
- package/dist/src/product-loop/sprint-store.js +81 -0
- package/dist/src/product-loop/typed-artifacts.js +5 -5
- package/dist/src/product-loop/types.d.ts +113 -2
- package/dist/src/product-loop/verify-failure-tracking.js +1 -1
- package/dist/src/providers/__tests__/adapter-oauth-wiring.test.js +18 -2
- package/dist/src/providers/__tests__/capabilities-provider-options.test.js +23 -1
- package/dist/src/providers/__tests__/capabilities-sanitize.test.js +46 -61
- package/dist/src/providers/__tests__/reasoning-roundtrip.test.d.ts +1 -0
- package/dist/src/providers/__tests__/reasoning-roundtrip.test.js +135 -0
- package/dist/src/providers/__tests__/runtime-integration.test.js +19 -12
- package/dist/src/providers/__tests__/runtime.test.js +3 -6
- package/dist/src/providers/__tests__/siliconflow-sse-repair.test.d.ts +1 -0
- package/dist/src/providers/__tests__/siliconflow-sse-repair.test.js +267 -0
- package/dist/src/providers/auth/__tests__/browser-flow.test.js +1 -1
- package/dist/src/providers/auth/__tests__/gemini-oauth.test.js +1 -1
- package/dist/src/providers/auth/__tests__/grok-oauth.test.d.ts +8 -0
- package/dist/src/providers/auth/__tests__/grok-oauth.test.js +236 -0
- package/dist/src/providers/auth/__tests__/token-store.test.js +7 -7
- package/dist/src/providers/auth/gemini-oauth.js +2 -2
- package/dist/src/providers/auth/grok-oauth.d.ts +63 -0
- package/dist/src/providers/auth/grok-oauth.js +341 -0
- package/dist/src/providers/auth/registry.js +17 -0
- package/dist/src/providers/auth/token-store.js +1 -1
- package/dist/src/providers/capabilities.js +9 -15
- package/dist/src/providers/keychain.js +14 -2
- package/dist/src/providers/mcp-vision-bridge.js +49 -49
- package/dist/src/providers/mcp-vision-bridge.test.js +12 -12
- package/dist/src/providers/openai-compatible.js +5 -1
- package/dist/src/providers/pricing.d.ts +7 -4
- package/dist/src/providers/pricing.js +21 -5
- package/dist/src/providers/pricing.test.js +35 -9
- package/dist/src/providers/runtime.d.ts +1 -0
- package/dist/src/providers/runtime.js +39 -13
- package/dist/src/providers/siliconflow-sse-repair.d.ts +58 -0
- package/dist/src/providers/siliconflow-sse-repair.js +177 -0
- package/dist/src/providers/strategies/deepseek.strategy.js +28 -0
- package/dist/src/providers/strategies/siliconflow.strategy.js +2 -0
- package/dist/src/providers/strategies/xai.strategy.js +8 -1
- package/dist/src/providers/wire-debug.js +2 -2
- package/dist/src/reporter/__tests__/acl-check.test.d.ts +6 -0
- package/dist/src/reporter/__tests__/acl-check.test.js +59 -0
- package/dist/src/reporter/__tests__/auto-fire.test.d.ts +10 -0
- package/dist/src/reporter/__tests__/auto-fire.test.js +140 -0
- package/dist/src/reporter/__tests__/budget.test.d.ts +7 -0
- package/dist/src/reporter/__tests__/budget.test.js +60 -0
- package/dist/src/reporter/__tests__/handlers.test.d.ts +7 -0
- package/dist/src/reporter/__tests__/handlers.test.js +163 -0
- package/dist/src/reporter/__tests__/query-router.test.d.ts +6 -0
- package/dist/src/reporter/__tests__/query-router.test.js +90 -0
- package/dist/src/reporter/acl-check.d.ts +23 -0
- package/dist/src/reporter/acl-check.js +43 -0
- package/dist/src/reporter/auto-fire.d.ts +59 -0
- package/dist/src/reporter/auto-fire.js +126 -0
- package/dist/src/reporter/budget.d.ts +17 -0
- package/dist/src/reporter/budget.js +52 -0
- package/dist/src/reporter/handlers.d.ts +32 -0
- package/dist/src/reporter/handlers.js +180 -0
- package/dist/src/reporter/index.d.ts +44 -0
- package/dist/src/reporter/index.js +167 -0
- package/dist/src/reporter/query-router.d.ts +21 -0
- package/dist/src/reporter/query-router.js +32 -0
- package/dist/src/router/__tests__/step-router.test.js +3 -3
- package/dist/src/router/classifier/regex.js +49 -2
- package/dist/src/router/classifier/regex.test.js +3 -1
- package/dist/src/router/decide.d.ts +18 -0
- package/dist/src/router/decide.js +39 -7
- package/dist/src/router/decide.test.js +58 -8
- package/dist/src/router/role-override.test.d.ts +1 -0
- package/dist/src/router/role-override.test.js +26 -0
- package/dist/src/router/step-router.js +1 -1
- package/dist/src/router/warm.d.ts +2 -0
- package/dist/src/router/warm.js +42 -12
- package/dist/src/router/warm.test.js +59 -1
- package/dist/src/scaffold/__tests__/init-new.spec.js +3 -3
- package/dist/src/scaffold/bb-ecosystem-apply.js +51 -49
- package/dist/src/scaffold/bb-quality-gate.js +5 -5
- package/dist/src/scaffold/continuation-prompt.js +60 -60
- package/dist/src/scaffold/init-new.js +454 -454
- package/dist/src/self-qa/__tests__/agentic-context.test.d.ts +1 -0
- package/dist/src/self-qa/__tests__/agentic-context.test.js +98 -0
- package/dist/src/self-qa/__tests__/agentic-loop.test.d.ts +1 -0
- package/dist/src/self-qa/__tests__/agentic-loop.test.js +62 -0
- package/dist/src/self-qa/__tests__/delta-encoder.test.d.ts +1 -0
- package/dist/src/self-qa/__tests__/delta-encoder.test.js +97 -0
- package/dist/src/self-qa/__tests__/judge.test.d.ts +1 -0
- package/dist/src/self-qa/__tests__/judge.test.js +131 -0
- package/dist/src/self-qa/__tests__/scenario-planner.test.d.ts +1 -0
- package/dist/src/self-qa/__tests__/scenario-planner.test.js +79 -0
- package/dist/src/self-qa/__tests__/spec-emitter.test.d.ts +1 -0
- package/dist/src/self-qa/__tests__/spec-emitter.test.js +62 -0
- package/dist/src/self-qa/agentic-context.d.ts +29 -0
- package/dist/src/self-qa/agentic-context.js +189 -0
- package/dist/src/self-qa/agentic-loop.d.ts +96 -0
- package/dist/src/self-qa/agentic-loop.js +516 -0
- package/dist/src/self-qa/delta-encoder.d.ts +35 -0
- package/dist/src/self-qa/delta-encoder.js +138 -0
- package/dist/src/self-qa/index.d.ts +43 -0
- package/dist/src/self-qa/index.js +65 -0
- package/dist/src/self-qa/judge.d.ts +25 -0
- package/dist/src/self-qa/judge.js +233 -0
- package/dist/src/self-qa/orchestrator.d.ts +31 -0
- package/dist/src/self-qa/orchestrator.js +236 -0
- package/dist/src/self-qa/scenario-planner.d.ts +39 -0
- package/dist/src/self-qa/scenario-planner.js +262 -0
- package/dist/src/self-qa/spec-emitter.d.ts +25 -0
- package/dist/src/self-qa/spec-emitter.js +138 -0
- package/dist/src/self-qa/types.d.ts +113 -0
- package/dist/src/self-qa/types.js +11 -0
- package/dist/src/storage/__tests__/migrations.test.js +2 -2
- package/dist/src/storage/__tests__/sweep-stale-pending.test.d.ts +10 -0
- package/dist/src/storage/__tests__/sweep-stale-pending.test.js +97 -0
- package/dist/src/storage/__tests__/ui-interaction-log.test.js +30 -0
- package/dist/src/storage/atomic-io.test.js +2 -2
- package/dist/src/storage/config.test.js +1 -1
- package/dist/src/storage/interaction-log.d.ts +1 -1
- package/dist/src/storage/interaction-log.js +5 -5
- package/dist/src/storage/migrations.js +122 -122
- package/dist/src/storage/sessions.js +57 -42
- package/dist/src/storage/transcript-response-entry.test.d.ts +1 -0
- package/dist/src/storage/transcript-response-entry.test.js +98 -0
- package/dist/src/storage/transcript.d.ts +22 -0
- package/dist/src/storage/transcript.js +149 -74
- package/dist/src/storage/ui-interaction-log.d.ts +11 -1
- package/dist/src/storage/usage-cap.test.js +1 -1
- package/dist/src/storage/usage.js +14 -14
- package/dist/src/storage/workspaces.js +12 -12
- package/dist/src/tools/__tests__/vision-gate.test.d.ts +1 -0
- package/dist/src/tools/__tests__/vision-gate.test.js +56 -0
- package/dist/src/tools/bash-output-cache.d.ts +59 -0
- package/dist/src/tools/bash-output-cache.js +108 -0
- package/dist/src/tools/bash-output-cache.test.d.ts +1 -0
- package/dist/src/tools/bash-output-cache.test.js +89 -0
- package/dist/src/tools/bash-output-integration.test.d.ts +10 -0
- package/dist/src/tools/bash-output-integration.test.js +30 -0
- package/dist/src/tools/bash.d.ts +12 -0
- package/dist/src/tools/bash.js +114 -21
- package/dist/src/tools/bash.test.js +80 -3
- package/dist/src/tools/computer.test.js +1 -1
- package/dist/src/tools/file-tracker.test.js +1 -1
- package/dist/src/tools/file.js +23 -2
- package/dist/src/tools/file.test.js +49 -1
- package/dist/src/tools/registry-bash-empty-command.test.d.ts +13 -0
- package/dist/src/tools/registry-bash-empty-command.test.js +56 -0
- package/dist/src/tools/registry-bash-footer.test.d.ts +7 -0
- package/dist/src/tools/registry-bash-footer.test.js +82 -0
- package/dist/src/tools/registry-ee-query.test.d.ts +11 -0
- package/dist/src/tools/registry-ee-query.test.js +48 -0
- package/dist/src/tools/registry-session-repeat.test.d.ts +12 -0
- package/dist/src/tools/registry-session-repeat.test.js +87 -0
- package/dist/src/tools/registry.d.ts +38 -0
- package/dist/src/tools/registry.js +262 -4
- package/dist/src/tools/schedule.test.js +1 -1
- package/dist/src/tools/todo-write-snapshot.d.ts +18 -0
- package/dist/src/tools/todo-write-snapshot.js +66 -0
- package/dist/src/tools/todo-write-snapshot.test.d.ts +1 -0
- package/dist/src/tools/todo-write-snapshot.test.js +43 -0
- package/dist/src/tools/vision-gate.d.ts +41 -0
- package/dist/src/tools/vision-gate.js +67 -0
- package/dist/src/types/index.d.ts +65 -4
- package/dist/src/ui/__tests__/picker-providers.test.d.ts +1 -0
- package/dist/src/ui/__tests__/picker-providers.test.js +31 -0
- package/dist/src/ui/agents-modal.js +2 -0
- package/dist/src/ui/app.d.ts +1 -0
- package/dist/src/ui/app.js +0 -0
- package/dist/src/ui/components/__tests__/task-list-panel.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/task-list-panel.test.js +31 -0
- package/dist/src/ui/components/council-info-card.d.ts +1 -2
- package/dist/src/ui/components/council-leader-bubble.d.ts +1 -2
- package/dist/src/ui/components/council-message-bubble.d.ts +1 -2
- package/dist/src/ui/components/council-phase-timeline.js +20 -1
- package/dist/src/ui/components/council-placeholder-bubble.d.ts +1 -2
- package/dist/src/ui/components/council-question-card.js +3 -0
- package/dist/src/ui/components/council-synthesis-banner.d.ts +1 -2
- package/dist/src/ui/components/halt-recovery-card.js +1 -0
- package/dist/src/ui/components/message-view.d.ts +11 -1
- package/dist/src/ui/components/message-view.js +65 -3
- package/dist/src/ui/components/point-to-existing-form-card.js +5 -1
- package/dist/src/ui/components/task-list-panel.d.ts +32 -0
- package/dist/src/ui/components/task-list-panel.js +84 -0
- package/dist/src/ui/components/tool-group.d.ts +22 -0
- package/dist/src/ui/components/tool-group.js +85 -0
- package/dist/src/ui/hooks/use-agent-editor.js +2 -3
- package/dist/src/ui/hooks/use-model-picker.d.ts +2 -2
- package/dist/src/ui/modals/model-picker-modal.d.ts +2 -0
- package/dist/src/ui/modals/model-picker-modal.js +2 -4
- package/dist/src/ui/picker-providers.d.ts +21 -0
- package/dist/src/ui/picker-providers.js +39 -0
- package/dist/src/ui/slash/__tests__/clear.test.js +1 -1
- package/dist/src/ui/slash/__tests__/compact.test.js +1 -1
- package/dist/src/ui/slash/__tests__/discuss.test.js +1 -1
- package/dist/src/ui/slash/__tests__/execute.test.js +1 -1
- package/dist/src/ui/slash/__tests__/expand.test.js +1 -1
- package/dist/src/ui/slash/__tests__/ideal.test.js +41 -0
- package/dist/src/ui/slash/__tests__/menu-parity.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/menu-parity.test.js +1 -0
- package/dist/src/ui/slash/__tests__/plan.test.js +4 -1
- package/dist/src/ui/slash/__tests__/status-render.test.d.ts +7 -0
- package/dist/src/ui/slash/__tests__/status-render.test.js +77 -0
- package/dist/src/ui/slash/council-inspect.js +4 -4
- package/dist/src/ui/slash/export.js +32 -5
- package/dist/src/ui/slash/ideal.d.ts +9 -0
- package/dist/src/ui/slash/ideal.js +27 -1
- package/dist/src/ui/slash/menu-items.js +1 -0
- package/dist/src/ui/slash/status.d.ts +12 -0
- package/dist/src/ui/slash/status.js +32 -0
- package/dist/src/ui/state/active-run.d.ts +26 -0
- package/dist/src/ui/state/active-run.js +44 -0
- package/dist/src/ui/status-bar/index.d.ts +6 -1
- package/dist/src/ui/status-bar/index.js +21 -2
- package/dist/src/ui/status-bar/index.test.js +60 -1
- package/dist/src/ui/status-bar/store.d.ts +16 -0
- package/dist/src/ui/status-bar/store.js +120 -1
- package/dist/src/ui/utils/__tests__/format.test.d.ts +1 -0
- package/dist/src/ui/utils/__tests__/format.test.js +50 -0
- package/dist/src/ui/utils/__tests__/tools.test.d.ts +1 -0
- package/dist/src/ui/utils/__tests__/tools.test.js +48 -0
- package/dist/src/ui/utils/format.d.ts +17 -0
- package/dist/src/ui/utils/format.js +45 -2
- package/dist/src/ui/utils/text.js +2 -1
- package/dist/src/ui/utils/tools.d.ts +2 -0
- package/dist/src/ui/utils/tools.js +58 -9
- package/dist/src/usage/__tests__/product-ledger.test.js +5 -4
- package/dist/src/usage/decision-log.d.ts +1 -1
- package/dist/src/usage/downgrade.d.ts +3 -2
- package/dist/src/usage/downgrade.js +25 -9
- package/dist/src/usage/downgrade.test.js +40 -37
- package/dist/src/usage/product-ledger.d.ts +4 -0
- package/dist/src/usage/product-ledger.js +8 -1
- package/dist/src/utils/__tests__/llm-deadline.test.d.ts +1 -0
- package/dist/src/utils/__tests__/llm-deadline.test.js +56 -0
- package/dist/src/utils/__tests__/settings-disabled-models.test.js +1 -1
- package/dist/src/utils/__tests__/settings-web-research.test.js +1 -1
- package/dist/src/utils/__tests__/visible-retry.test.js +1 -1
- package/dist/src/utils/clipboard-image.js +23 -23
- package/dist/src/utils/install-manager.test.js +1 -1
- package/dist/src/utils/llm-deadline.d.ts +44 -0
- package/dist/src/utils/llm-deadline.js +80 -0
- package/dist/src/utils/permission-mode.d.ts +16 -9
- package/dist/src/utils/permission-mode.js +55 -4
- package/dist/src/utils/settings.d.ts +22 -0
- package/dist/src/utils/settings.js +47 -6
- package/dist/src/utils/shell.d.ts +12 -0
- package/dist/src/utils/shell.js +23 -12
- package/dist/src/utils/shell.test.js +27 -1
- package/dist/src/utils/side-question.js +2 -2
- package/dist/src/utils/skills.js +3 -3
- package/dist/src/utils/skills.test.js +1 -1
- package/dist/src/utils/subagents-settings.test.js +9 -3
- package/dist/src/verify/__tests__/coverage-parsers.test.js +30 -30
- package/dist/src/verify/__tests__/dotnet-recipe.test.js +1 -1
- package/dist/src/verify/checkpoint.test.js +1 -1
- package/dist/src/verify/entrypoint.d.ts +8 -8
- package/dist/src/verify/entrypoint.js +69 -32
- package/dist/src/verify/entrypoint.test.js +1 -1
- package/dist/src/verify/environment.test.js +1 -1
- package/dist/src/verify/orchestrator.test.js +1 -1
- package/dist/src/verify/runtime-prep.test.js +1 -1
- package/package.json +125 -122
- package/scripts/postinstall.cjs +76 -73
- package/dist/packages/agent-harness-core/src/driver.js.map +0 -1
- package/dist/packages/agent-harness-core/src/event-filter.js.map +0 -1
- package/dist/packages/agent-harness-core/src/event-redact.js.map +0 -1
- package/dist/packages/agent-harness-core/src/idle.js.map +0 -1
- package/dist/packages/agent-harness-core/src/index.js.map +0 -1
- package/dist/packages/agent-harness-core/src/mcp-server.js.map +0 -1
- package/dist/packages/agent-harness-core/src/mock-llm.js.map +0 -1
- package/dist/packages/agent-harness-core/src/predicate.js.map +0 -1
- package/dist/packages/agent-harness-core/src/protocol.js.map +0 -1
- package/dist/packages/agent-harness-core/src/registry.js.map +0 -1
- package/dist/packages/agent-harness-core/src/selector.js.map +0 -1
- package/dist/packages/agent-harness-core/src/spec-helpers.js.map +0 -1
- package/dist/packages/agent-harness-core/src/transports/sidechannel.js.map +0 -1
- package/dist/packages/agent-harness-core/src/transports/ws.js.map +0 -1
- package/dist/packages/agent-harness-opentui/src/agent-mode.js.map +0 -1
- package/dist/packages/agent-harness-opentui/src/index.js.map +0 -1
- package/dist/packages/agent-harness-opentui/src/input-bridge.js.map +0 -1
- package/dist/packages/agent-harness-opentui/src/install.js.map +0 -1
- package/dist/packages/agent-harness-opentui/src/reconciler-hook.js.map +0 -1
- package/dist/packages/agent-harness-opentui/src/semantic.js.map +0 -1
- package/dist/src/__test-stubs__/ee-server.js.map +0 -1
- package/dist/src/__test-stubs__/vitest-setup.js.map +0 -1
- package/dist/src/__tests__/council/bubble-layout.test.js.map +0 -1
- package/dist/src/__tests__/council/code-block-truncate.test.js.map +0 -1
- package/dist/src/__tests__/council/role-palette.test.js.map +0 -1
- package/dist/src/__tests__/first-run-wizard.test.js.map +0 -1
- package/dist/src/agent-harness/__tests__/cli-flags.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/driver.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/idle.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/mock-llm.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/mock-model.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/predicate.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/protocol.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/schema.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/selector.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/sidechannel.spec.js.map +0 -1
- package/dist/src/agent-harness/__tests__/spec-helpers.spec.js.map +0 -1
- package/dist/src/agent-harness/index.js.map +0 -1
- package/dist/src/agent-harness/mock-model.js.map +0 -1
- package/dist/src/agent-harness/test-spawn.js.map +0 -1
- package/dist/src/billing/index.js.map +0 -1
- package/dist/src/chat/__tests__/broadcast-bus.test.js.map +0 -1
- package/dist/src/chat/__tests__/channel-manager.test.js.map +0 -1
- package/dist/src/chat/__tests__/client.test.js.map +0 -1
- package/dist/src/chat/__tests__/discord-integration.test.js.map +0 -1
- package/dist/src/chat/__tests__/intent-prompt.test.js.map +0 -1
- package/dist/src/chat/__tests__/verdict-resolver.test.js.map +0 -1
- package/dist/src/chat/broadcast-bus.js.map +0 -1
- package/dist/src/chat/channel-manager.js.map +0 -1
- package/dist/src/chat/chat-keychain.js.map +0 -1
- package/dist/src/chat/factory.js.map +0 -1
- package/dist/src/chat/intent-prompt.js.map +0 -1
- package/dist/src/chat/providers/discord/client.js.map +0 -1
- package/dist/src/chat/types.js.map +0 -1
- package/dist/src/chat/verdict-constants.js.map +0 -1
- package/dist/src/chat/verdict-resolver.js.map +0 -1
- package/dist/src/cli/__tests__/bw-vault.test.js.map +0 -1
- package/dist/src/cli/__tests__/keys-bundle.test.js.map +0 -1
- package/dist/src/cli/__tests__/share-cmd.test.js.map +0 -1
- package/dist/src/cli/bw-vault.js.map +0 -1
- package/dist/src/cli/config/__tests__/model-picker.test.js.map +0 -1
- package/dist/src/cli/config/__tests__/provider-fetch.test.js.map +0 -1
- package/dist/src/cli/config/index.js.map +0 -1
- package/dist/src/cli/config/model-picker.js.map +0 -1
- package/dist/src/cli/config/provider-fetch.js.map +0 -1
- package/dist/src/cli/config/screen-council.js.map +0 -1
- package/dist/src/cli/config/screen-models.js.map +0 -1
- package/dist/src/cli/config/screen-providers.js.map +0 -1
- package/dist/src/cli/config/tui.js.map +0 -1
- package/dist/src/cli/cost-forensics.js.map +0 -1
- package/dist/src/cli/cost-forensics.test.js.map +0 -1
- package/dist/src/cli/keys-bundle.js.map +0 -1
- package/dist/src/cli/keys.js.map +0 -1
- package/dist/src/cli/keys.test.js.map +0 -1
- package/dist/src/cli/pil-report.js.map +0 -1
- package/dist/src/cli/share-cmd.js.map +0 -1
- package/dist/src/cli/usage-report.js.map +0 -1
- package/dist/src/cloud/index.js.map +0 -1
- package/dist/src/council/__tests__/accounting.test.js.map +0 -1
- package/dist/src/council/__tests__/audit-replay.test.js.map +0 -1
- package/dist/src/council/__tests__/clarifier-max-rounds.test.js.map +0 -1
- package/dist/src/council/__tests__/clarifier-options.test.js.map +0 -1
- package/dist/src/council/__tests__/cost-aware.test.js.map +0 -1
- package/dist/src/council/__tests__/debate-planner-structured.test.js.map +0 -1
- package/dist/src/council/__tests__/evaluator-metrics.test.js.map +0 -1
- package/dist/src/council/__tests__/parse-outcome-fallback.test.js.map +0 -1
- package/dist/src/council/__tests__/research-tools.test.js.map +0 -1
- package/dist/src/council/__tests__/round-tools.test.js.map +0 -1
- package/dist/src/council/__tests__/tool-trace.test.js.map +0 -1
- package/dist/src/council/__tests__/types-contract.test.js.map +0 -1
- package/dist/src/council/clarifier.js.map +0 -1
- package/dist/src/council/context.js.map +0 -1
- package/dist/src/council/debate-planner.js.map +0 -1
- package/dist/src/council/debate.js.map +0 -1
- package/dist/src/council/executor.js.map +0 -1
- package/dist/src/council/index.js.map +0 -1
- package/dist/src/council/leader.js.map +0 -1
- package/dist/src/council/llm.js.map +0 -1
- package/dist/src/council/phase-events.js.map +0 -1
- package/dist/src/council/planner.js.map +0 -1
- package/dist/src/council/preflight.js.map +0 -1
- package/dist/src/council/prompts.js.map +0 -1
- package/dist/src/council/types.js.map +0 -1
- package/dist/src/daemon/scheduler.js.map +0 -1
- package/dist/src/daemon/scheduler.test.js.map +0 -1
- package/dist/src/ee/__tests__/bb-design.test.js.map +0 -1
- package/dist/src/ee/__tests__/pil-context-bridge.test.js.map +0 -1
- package/dist/src/ee/__tests__/pipeline.integration.test.js.map +0 -1
- package/dist/src/ee/__tests__/render-sink-wiring.test.js.map +0 -1
- package/dist/src/ee/auth.js.map +0 -1
- package/dist/src/ee/auth.test.js.map +0 -1
- package/dist/src/ee/bb-design.js.map +0 -1
- package/dist/src/ee/bb-retrieval.js.map +0 -1
- package/dist/src/ee/bridge.js.map +0 -1
- package/dist/src/ee/bridge.test.js.map +0 -1
- package/dist/src/ee/client-mode.js.map +0 -1
- package/dist/src/ee/client.js.map +0 -1
- package/dist/src/ee/client.test.js.map +0 -1
- package/dist/src/ee/council-bridge.js.map +0 -1
- package/dist/src/ee/embedding-cache.js.map +0 -1
- package/dist/src/ee/extract-session.js.map +0 -1
- package/dist/src/ee/extract-session.test.js.map +0 -1
- package/dist/src/ee/health.js.map +0 -1
- package/dist/src/ee/index.js.map +0 -1
- package/dist/src/ee/intercept.js.map +0 -1
- package/dist/src/ee/intercept.test.js.map +0 -1
- package/dist/src/ee/judge.js.map +0 -1
- package/dist/src/ee/judge.test.js.map +0 -1
- package/dist/src/ee/mistake-detector.js.map +0 -1
- package/dist/src/ee/mistake-detector.test.js.map +0 -1
- package/dist/src/ee/offline-queue.js.map +0 -1
- package/dist/src/ee/offline-queue.test.js.map +0 -1
- package/dist/src/ee/phase-outcome.js.map +0 -1
- package/dist/src/ee/phase-outcome.test.js.map +0 -1
- package/dist/src/ee/phase-tracker.js.map +0 -1
- package/dist/src/ee/phase-tracker.test.js.map +0 -1
- package/dist/src/ee/posttool.js.map +0 -1
- package/dist/src/ee/posttool.test.js.map +0 -1
- package/dist/src/ee/prompt-stale.js.map +0 -1
- package/dist/src/ee/prompt-stale.test.js.map +0 -1
- package/dist/src/ee/render.js.map +0 -1
- package/dist/src/ee/render.test.js.map +0 -1
- package/dist/src/ee/scope.js.map +0 -1
- package/dist/src/ee/scope.test.js.map +0 -1
- package/dist/src/ee/session-trajectory.js.map +0 -1
- package/dist/src/ee/session-trajectory.test.js.map +0 -1
- package/dist/src/ee/tenant.js.map +0 -1
- package/dist/src/ee/touch.test.js.map +0 -1
- package/dist/src/ee/types.js.map +0 -1
- package/dist/src/flow/__tests__/migration.test.js.map +0 -1
- package/dist/src/flow/__tests__/parser.test.js.map +0 -1
- package/dist/src/flow/__tests__/run-manager-product.test.js.map +0 -1
- package/dist/src/flow/__tests__/run-manager.test.js.map +0 -1
- package/dist/src/flow/__tests__/scaffold-checkpoint.test.js.map +0 -1
- package/dist/src/flow/__tests__/scaffold.test.js.map +0 -1
- package/dist/src/flow/__tests__/warning-persist.test.js.map +0 -1
- package/dist/src/flow/artifact-io.js.map +0 -1
- package/dist/src/flow/compaction/__tests__/compress.test.js.map +0 -1
- package/dist/src/flow/compaction/__tests__/extract.test.js.map +0 -1
- package/dist/src/flow/compaction/__tests__/preserve.test.js.map +0 -1
- package/dist/src/flow/compaction/compress.js.map +0 -1
- package/dist/src/flow/compaction/extract.js.map +0 -1
- package/dist/src/flow/compaction/index.js.map +0 -1
- package/dist/src/flow/compaction/preserve.js.map +0 -1
- package/dist/src/flow/index.js.map +0 -1
- package/dist/src/flow/migration.js.map +0 -1
- package/dist/src/flow/parser.js.map +0 -1
- package/dist/src/flow/run-manager.js.map +0 -1
- package/dist/src/flow/scaffold-checkpoint.js.map +0 -1
- package/dist/src/flow/scaffold.js.map +0 -1
- package/dist/src/flow/warning-persist.js.map +0 -1
- package/dist/src/generated/version.js.map +0 -1
- package/dist/src/gsd/__tests__/complexity.test.js.map +0 -1
- package/dist/src/gsd/__tests__/directives.test.js.map +0 -1
- package/dist/src/gsd/__tests__/gray-areas.test.js.map +0 -1
- package/dist/src/gsd/__tests__/types.test.js.map +0 -1
- package/dist/src/gsd/complexity.js.map +0 -1
- package/dist/src/gsd/directives.js.map +0 -1
- package/dist/src/gsd/gray-areas.js.map +0 -1
- package/dist/src/gsd/index.js.map +0 -1
- package/dist/src/gsd/types.js.map +0 -1
- package/dist/src/headless/__tests__/council-answers.test.js.map +0 -1
- package/dist/src/headless/council-answers.js.map +0 -1
- package/dist/src/headless/output.js.map +0 -1
- package/dist/src/headless/output.test.js.map +0 -1
- package/dist/src/hooks/config.js.map +0 -1
- package/dist/src/hooks/index.js.map +0 -1
- package/dist/src/hooks/types.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/lsp/builtins.js.map +0 -1
- package/dist/src/lsp/builtins.test.js.map +0 -1
- package/dist/src/lsp/client.js.map +0 -1
- package/dist/src/lsp/manager.js.map +0 -1
- package/dist/src/lsp/manager.test.js.map +0 -1
- package/dist/src/lsp/npm-cache.js.map +0 -1
- package/dist/src/lsp/npm-cache.test.js.map +0 -1
- package/dist/src/lsp/runtime.js.map +0 -1
- package/dist/src/lsp/smoke.test.js.map +0 -1
- package/dist/src/lsp/types.js.map +0 -1
- package/dist/src/mcp/__tests__/auto-setup.test.js.map +0 -1
- package/dist/src/mcp/__tests__/harness-driver-action-tools.spec.js.map +0 -1
- package/dist/src/mcp/__tests__/harness-driver-async-tools.spec.js.map +0 -1
- package/dist/src/mcp/__tests__/harness-driver-read-tools.spec.js.map +0 -1
- package/dist/src/mcp/__tests__/harness-driver-security.spec.js.map +0 -1
- package/dist/src/mcp/__tests__/harness-driver.spec.js.map +0 -1
- package/dist/src/mcp/__tests__/lazy-schema.spec.js.map +0 -1
- package/dist/src/mcp/__tests__/mcp-keychain.test.js.map +0 -1
- package/dist/src/mcp/__tests__/research-onboarding.test.js.map +0 -1
- package/dist/src/mcp/__tests__/runtime-hydration.test.js.map +0 -1
- package/dist/src/mcp/__tests__/runtime-sanitize.test.js.map +0 -1
- package/dist/src/mcp/auto-setup.js.map +0 -1
- package/dist/src/mcp/catalog.js.map +0 -1
- package/dist/src/mcp/mcp-keychain.js.map +0 -1
- package/dist/src/mcp/oauth-callback.js.map +0 -1
- package/dist/src/mcp/oauth-provider.js.map +0 -1
- package/dist/src/mcp/opentui-spawn.js.map +0 -1
- package/dist/src/mcp/parse-headers.js.map +0 -1
- package/dist/src/mcp/parse-headers.test.js.map +0 -1
- package/dist/src/mcp/research-onboarding.js.map +0 -1
- package/dist/src/mcp/runtime.js.map +0 -1
- package/dist/src/mcp/smoke.test.js.map +0 -1
- package/dist/src/mcp/validate.js.map +0 -1
- package/dist/src/models/__tests__/registry.test.js.map +0 -1
- package/dist/src/models/catalog-client.js.map +0 -1
- package/dist/src/models/classify-tier.js.map +0 -1
- package/dist/src/models/index.js.map +0 -1
- package/dist/src/models/registry.js.map +0 -1
- package/dist/src/ops/__tests__/doctor-council-mcp.test.js.map +0 -1
- package/dist/src/ops/__tests__/doctor-ee-health.test.js.map +0 -1
- package/dist/src/ops/bug-report.js.map +0 -1
- package/dist/src/ops/bug-report.test.js.map +0 -1
- package/dist/src/ops/doctor.js.map +0 -1
- package/dist/src/ops/doctor.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/batch-turn-runner.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/council-manager.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/cross-turn-dedup.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/current-call-id.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/flow-resume.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/message-processor.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/message-write-ahead.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/read-path-budget.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/retry-classifier.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/retry-stream.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/route-feedback.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/stream-runner.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/usage-events-shape.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/usage-normalizer-c1.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/write-ahead.test.js.map +0 -1
- package/dist/src/orchestrator/abort.js.map +0 -1
- package/dist/src/orchestrator/abort.test.js.map +0 -1
- package/dist/src/orchestrator/agent-options.js.map +0 -1
- package/dist/src/orchestrator/agent.test.js.map +0 -1
- package/dist/src/orchestrator/batch-turn-runner.js.map +0 -1
- package/dist/src/orchestrator/batch-utils.js.map +0 -1
- package/dist/src/orchestrator/cleanup.test.js.map +0 -1
- package/dist/src/orchestrator/compaction.js.map +0 -1
- package/dist/src/orchestrator/compaction.test.js.map +0 -1
- package/dist/src/orchestrator/council-manager.js.map +0 -1
- package/dist/src/orchestrator/cross-turn-dedup.js.map +0 -1
- package/dist/src/orchestrator/delegations.js.map +0 -1
- package/dist/src/orchestrator/delegations.test.js.map +0 -1
- package/dist/src/orchestrator/error-utils.js.map +0 -1
- package/dist/src/orchestrator/flow-resume.js.map +0 -1
- package/dist/src/orchestrator/message-processor.js.map +0 -1
- package/dist/src/orchestrator/message-seq.js.map +0 -1
- package/dist/src/orchestrator/message-seq.test.js.map +0 -1
- package/dist/src/orchestrator/orchestrator.js.map +0 -1
- package/dist/src/orchestrator/pending-calls.js.map +0 -1
- package/dist/src/orchestrator/pending-calls.test.js.map +0 -1
- package/dist/src/orchestrator/prompts.js.map +0 -1
- package/dist/src/orchestrator/provider-options-shape.js.map +0 -1
- package/dist/src/orchestrator/provider-options-shape.spec.js.map +0 -1
- package/dist/src/orchestrator/read-path-budget.js.map +0 -1
- package/dist/src/orchestrator/reasoning.js.map +0 -1
- package/dist/src/orchestrator/reasoning.test.js.map +0 -1
- package/dist/src/orchestrator/retry-classifier.js.map +0 -1
- package/dist/src/orchestrator/retry-stream.js.map +0 -1
- package/dist/src/orchestrator/sandbox.test.js.map +0 -1
- package/dist/src/orchestrator/stream-runner.js.map +0 -1
- package/dist/src/orchestrator/sub-agent-cap.js.map +0 -1
- package/dist/src/orchestrator/sub-agent-cap.test.js.map +0 -1
- package/dist/src/orchestrator/subagent-compactor.js.map +0 -1
- package/dist/src/orchestrator/subagent-compactor.spec.js.map +0 -1
- package/dist/src/orchestrator/token-counter.js.map +0 -1
- package/dist/src/orchestrator/token-counter.test.js.map +0 -1
- package/dist/src/orchestrator/tool-utils.js.map +0 -1
- package/dist/src/orchestrator/turn-runner-deps.js.map +0 -1
- package/dist/src/pil/__tests__/budget.test.js.map +0 -1
- package/dist/src/pil/__tests__/config.test.js.map +0 -1
- package/dist/src/pil/__tests__/dual-run.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer1-intent-trace.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer1-intent.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer2-personality.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer3-ee-injection.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer3-injected-chunk.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer4-gsd.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer5-context.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer6-output.test.js.map +0 -1
- package/dist/src/pil/__tests__/ollama-classify.test.js.map +0 -1
- package/dist/src/pil/__tests__/orchestrator-integration.test.js.map +0 -1
- package/dist/src/pil/__tests__/pipeline.test.js.map +0 -1
- package/dist/src/pil/__tests__/renderer-coverage.test.js.map +0 -1
- package/dist/src/pil/__tests__/response-tools.test.js.map +0 -1
- package/dist/src/pil/__tests__/schema.test.js.map +0 -1
- package/dist/src/pil/__tests__/scoreComplexity.test.js.map +0 -1
- package/dist/src/pil/__tests__/scoreSufficiency.test.js.map +0 -1
- package/dist/src/pil/__tests__/store.test.js.map +0 -1
- package/dist/src/pil/__tests__/task-tier-map.test.js.map +0 -1
- package/dist/src/pil/budget-log.js.map +0 -1
- package/dist/src/pil/budget.js.map +0 -1
- package/dist/src/pil/config.js.map +0 -1
- package/dist/src/pil/index.js.map +0 -1
- package/dist/src/pil/layer1-intent.js.map +0 -1
- package/dist/src/pil/layer1-intent.test.js.map +0 -1
- package/dist/src/pil/layer2-personality.js.map +0 -1
- package/dist/src/pil/layer3-ee-injection.js.map +0 -1
- package/dist/src/pil/layer4-gsd.js.map +0 -1
- package/dist/src/pil/layer5-context.js.map +0 -1
- package/dist/src/pil/layer6-output.js.map +0 -1
- package/dist/src/pil/ollama-classify.js.map +0 -1
- package/dist/src/pil/pipeline.js.map +0 -1
- package/dist/src/pil/response-tools.js.map +0 -1
- package/dist/src/pil/schema.js.map +0 -1
- package/dist/src/pil/store.js.map +0 -1
- package/dist/src/pil/task-tier-map.js.map +0 -1
- package/dist/src/pil/timeout.js.map +0 -1
- package/dist/src/pil/types.js.map +0 -1
- package/dist/src/product-loop/__tests__/artifact-io.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/assumption-ledger.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/cb2-retry-bonus.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/circuit-breakers-coverage.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/circuit-breakers.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/complexity-routing.spec.js.map +0 -1
- package/dist/src/product-loop/__tests__/context-policy.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/cost-preview.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/cost-scoper.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/cross-run-memory.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/design-output.spec.js.map +0 -1
- package/dist/src/product-loop/__tests__/discover.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-council-runner.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-detection.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-ecosystem.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-integration.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-interview.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-migrations.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-persistence.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-prompt-parser.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-recommender-ecosystem.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-recommender.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/discovery-schema.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/done-gate-coverage.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/done-gate.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/ee-extract-wiring.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/extract-to-ee.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/feedback-routing.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/hot-path.spec.js.map +0 -1
- package/dist/src/product-loop/__tests__/integration.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/loop-driver-audit.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/loop-driver.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-budget.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-orchestrator-integration.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-plan.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-rituals.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-runner.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-tracker-bridge.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/product-identity.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/reality-anchor.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/repo-audit.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/role-memory.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/role-registry.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/role-routing-ee.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/route-decision-emit.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/seed-questions.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/ship-polish.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/sprint-runner-emit.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/sprint-runner.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/stakeholder-acl.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/state-md-ee-injections.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/sufficiency-routing.spec.js.map +0 -1
- package/dist/src/product-loop/__tests__/typed-artifacts.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/types.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/verify-failure-threshold.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/verify-failure-tracking.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/verify-result.test.js.map +0 -1
- package/dist/src/product-loop/artifact-io.js.map +0 -1
- package/dist/src/product-loop/assumption-ledger.js.map +0 -1
- package/dist/src/product-loop/circuit-breakers.js.map +0 -1
- package/dist/src/product-loop/context-policy.js.map +0 -1
- package/dist/src/product-loop/cost-preview.js.map +0 -1
- package/dist/src/product-loop/cost-scoper.js.map +0 -1
- package/dist/src/product-loop/cross-run-memory.js.map +0 -1
- package/dist/src/product-loop/design-output.js.map +0 -1
- package/dist/src/product-loop/discover.js.map +0 -1
- package/dist/src/product-loop/discovery-context-format.js.map +0 -1
- package/dist/src/product-loop/discovery-council-runner.js.map +0 -1
- package/dist/src/product-loop/discovery-detection.js.map +0 -1
- package/dist/src/product-loop/discovery-ecosystem.js.map +0 -1
- package/dist/src/product-loop/discovery-interview.js.map +0 -1
- package/dist/src/product-loop/discovery-migrations.js.map +0 -1
- package/dist/src/product-loop/discovery-persistence.js.map +0 -1
- package/dist/src/product-loop/discovery-prompt-parser.js.map +0 -1
- package/dist/src/product-loop/discovery-recommender.js.map +0 -1
- package/dist/src/product-loop/discovery-schema.js.map +0 -1
- package/dist/src/product-loop/done-gate.js.map +0 -1
- package/dist/src/product-loop/feedback-routing.js.map +0 -1
- package/dist/src/product-loop/gather.js.map +0 -1
- package/dist/src/product-loop/index.js.map +0 -1
- package/dist/src/product-loop/loop-driver.js.map +0 -1
- package/dist/src/product-loop/phase-budget.js.map +0 -1
- package/dist/src/product-loop/phase-plan.js.map +0 -1
- package/dist/src/product-loop/phase-rituals.js.map +0 -1
- package/dist/src/product-loop/phase-runner.js.map +0 -1
- package/dist/src/product-loop/phase-tracker-bridge.js.map +0 -1
- package/dist/src/product-loop/product-identity.js.map +0 -1
- package/dist/src/product-loop/reality-anchor.js.map +0 -1
- package/dist/src/product-loop/repo-audit.js.map +0 -1
- package/dist/src/product-loop/role-memory.js.map +0 -1
- package/dist/src/product-loop/role-registry.js.map +0 -1
- package/dist/src/product-loop/seed-questions.js.map +0 -1
- package/dist/src/product-loop/ship-polish.js.map +0 -1
- package/dist/src/product-loop/sprint-runner.js.map +0 -1
- package/dist/src/product-loop/stakeholder-acl.js.map +0 -1
- package/dist/src/product-loop/typed-artifacts.js.map +0 -1
- package/dist/src/product-loop/types.js.map +0 -1
- package/dist/src/product-loop/verify-failure-tracking.js.map +0 -1
- package/dist/src/product-loop/verify-result.js.map +0 -1
- package/dist/src/providers/__test-utils__/load-fixture.js.map +0 -1
- package/dist/src/providers/__tests__/adapter-oauth-wiring.test.js.map +0 -1
- package/dist/src/providers/__tests__/capabilities-cosmetic.test.js.map +0 -1
- package/dist/src/providers/__tests__/capabilities-flags.test.js.map +0 -1
- package/dist/src/providers/__tests__/capabilities-provider-options.test.js.map +0 -1
- package/dist/src/providers/__tests__/capabilities-sanitize.test.js.map +0 -1
- package/dist/src/providers/__tests__/capabilities.test.js.map +0 -1
- package/dist/src/providers/__tests__/provider-coverage.test.js.map +0 -1
- package/dist/src/providers/__tests__/runtime-integration.test.js.map +0 -1
- package/dist/src/providers/__tests__/runtime.test.js.map +0 -1
- package/dist/src/providers/__tests__/siliconflow-history.test.js +0 -76
- package/dist/src/providers/__tests__/siliconflow-history.test.js.map +0 -1
- package/dist/src/providers/__tests__/strategies-registry.test.js.map +0 -1
- package/dist/src/providers/__tests__/strategies-resolve.test.js.map +0 -1
- package/dist/src/providers/__tests__/wire-debug.test.js.map +0 -1
- package/dist/src/providers/adapter.js.map +0 -1
- package/dist/src/providers/adapter.test.js.map +0 -1
- package/dist/src/providers/anthropic.js.map +0 -1
- package/dist/src/providers/auth/__tests__/browser-flow.test.js.map +0 -1
- package/dist/src/providers/auth/__tests__/device-flow.test.js.map +0 -1
- package/dist/src/providers/auth/__tests__/gemini-oauth.test.js.map +0 -1
- package/dist/src/providers/auth/__tests__/openai-oauth.test.js.map +0 -1
- package/dist/src/providers/auth/__tests__/token-store.test.js.map +0 -1
- package/dist/src/providers/auth/browser-flow.js.map +0 -1
- package/dist/src/providers/auth/device-flow.js.map +0 -1
- package/dist/src/providers/auth/gemini-oauth.js.map +0 -1
- package/dist/src/providers/auth/openai-oauth.js.map +0 -1
- package/dist/src/providers/auth/registry.js.map +0 -1
- package/dist/src/providers/auth/token-store.js.map +0 -1
- package/dist/src/providers/auth/types.js.map +0 -1
- package/dist/src/providers/capabilities.js.map +0 -1
- package/dist/src/providers/endpoints.js.map +0 -1
- package/dist/src/providers/errors.js.map +0 -1
- package/dist/src/providers/errors.test.js.map +0 -1
- package/dist/src/providers/gemini.js.map +0 -1
- package/dist/src/providers/gemini.test.js.map +0 -1
- package/dist/src/providers/index.js.map +0 -1
- package/dist/src/providers/keychain.js.map +0 -1
- package/dist/src/providers/keychain.test.js.map +0 -1
- package/dist/src/providers/mcp-vision-bridge.js.map +0 -1
- package/dist/src/providers/mcp-vision-bridge.test.js.map +0 -1
- package/dist/src/providers/ollama.js.map +0 -1
- package/dist/src/providers/ollama.test.js.map +0 -1
- package/dist/src/providers/openai-compatible.js.map +0 -1
- package/dist/src/providers/openai-compatible.test.js.map +0 -1
- package/dist/src/providers/openai.js.map +0 -1
- package/dist/src/providers/openai.test.js.map +0 -1
- package/dist/src/providers/patch-zod-schema.js.map +0 -1
- package/dist/src/providers/pricing.js.map +0 -1
- package/dist/src/providers/pricing.test.js.map +0 -1
- package/dist/src/providers/prompt-cache-key.spec.js.map +0 -1
- package/dist/src/providers/runtime-mock.spec.js.map +0 -1
- package/dist/src/providers/runtime.js.map +0 -1
- package/dist/src/providers/siliconflow-history.d.ts +0 -50
- package/dist/src/providers/siliconflow-history.js +0 -64
- package/dist/src/providers/siliconflow-history.js.map +0 -1
- package/dist/src/providers/strategies/anthropic.strategy.js.map +0 -1
- package/dist/src/providers/strategies/base.strategy.js.map +0 -1
- package/dist/src/providers/strategies/deepseek.strategy.js.map +0 -1
- package/dist/src/providers/strategies/google.strategy.js.map +0 -1
- package/dist/src/providers/strategies/ollama.strategy.js.map +0 -1
- package/dist/src/providers/strategies/openai.strategy.js.map +0 -1
- package/dist/src/providers/strategies/registry.js.map +0 -1
- package/dist/src/providers/strategies/siliconflow.strategy.js.map +0 -1
- package/dist/src/providers/strategies/xai.strategy.js.map +0 -1
- package/dist/src/providers/stream-loop.js.map +0 -1
- package/dist/src/providers/types.js.map +0 -1
- package/dist/src/providers/vision-proxy.js.map +0 -1
- package/dist/src/providers/vision-proxy.test.js.map +0 -1
- package/dist/src/providers/wire-debug.js.map +0 -1
- package/dist/src/router/__tests__/step-router.test.js.map +0 -1
- package/dist/src/router/classifier/grammars.js.map +0 -1
- package/dist/src/router/classifier/index.js.map +0 -1
- package/dist/src/router/classifier/index.test.js.map +0 -1
- package/dist/src/router/classifier/regex.js.map +0 -1
- package/dist/src/router/classifier/regex.test.js.map +0 -1
- package/dist/src/router/classifier/tree-sitter.js.map +0 -1
- package/dist/src/router/classifier/tree-sitter.test.js.map +0 -1
- package/dist/src/router/cold.js.map +0 -1
- package/dist/src/router/cold.test.js.map +0 -1
- package/dist/src/router/decide.js.map +0 -1
- package/dist/src/router/decide.test.js.map +0 -1
- package/dist/src/router/health.js.map +0 -1
- package/dist/src/router/health.test.js.map +0 -1
- package/dist/src/router/provider-sentinel.js.map +0 -1
- package/dist/src/router/provider-sentinel.test.js.map +0 -1
- package/dist/src/router/step-router.js.map +0 -1
- package/dist/src/router/store.js.map +0 -1
- package/dist/src/router/types.js.map +0 -1
- package/dist/src/router/warm.js.map +0 -1
- package/dist/src/router/warm.test.js.map +0 -1
- package/dist/src/scaffold/__tests__/continuation-prompt.test.js.map +0 -1
- package/dist/src/scaffold/__tests__/continue-as-council.spec.js.map +0 -1
- package/dist/src/scaffold/__tests__/dotnet-assembly-name.test.js.map +0 -1
- package/dist/src/scaffold/__tests__/fe-scaffold-contents.test.js.map +0 -1
- package/dist/src/scaffold/__tests__/init-new.smoke.spec.js.map +0 -1
- package/dist/src/scaffold/__tests__/init-new.spec.js.map +0 -1
- package/dist/src/scaffold/__tests__/install-bb-templates.spec.js.map +0 -1
- package/dist/src/scaffold/__tests__/point-to-existing.spec.js.map +0 -1
- package/dist/src/scaffold/bb-ecosystem-apply.js.map +0 -1
- package/dist/src/scaffold/bb-quality-gate.js.map +0 -1
- package/dist/src/scaffold/continuation-prompt.js.map +0 -1
- package/dist/src/scaffold/continue-as-council.js.map +0 -1
- package/dist/src/scaffold/init-new.js.map +0 -1
- package/dist/src/scaffold/point-to-existing.js.map +0 -1
- package/dist/src/scaffold/resume-from-gate-failures.js.map +0 -1
- package/dist/src/storage/__tests__/migrations.test.js.map +0 -1
- package/dist/src/storage/__tests__/ui-interaction-log.test.js.map +0 -1
- package/dist/src/storage/atomic-io.js.map +0 -1
- package/dist/src/storage/atomic-io.test.js.map +0 -1
- package/dist/src/storage/config.js.map +0 -1
- package/dist/src/storage/config.test.js.map +0 -1
- package/dist/src/storage/db.js.map +0 -1
- package/dist/src/storage/index.js.map +0 -1
- package/dist/src/storage/interaction-log.js.map +0 -1
- package/dist/src/storage/migrations.js.map +0 -1
- package/dist/src/storage/session-dir.js.map +0 -1
- package/dist/src/storage/sessions.js.map +0 -1
- package/dist/src/storage/tool-results.js.map +0 -1
- package/dist/src/storage/transcript-view.js.map +0 -1
- package/dist/src/storage/transcript.js.map +0 -1
- package/dist/src/storage/transcript.test.js.map +0 -1
- package/dist/src/storage/ui-interaction-log.js.map +0 -1
- package/dist/src/storage/usage-cap.js.map +0 -1
- package/dist/src/storage/usage-cap.test.js.map +0 -1
- package/dist/src/storage/usage.js.map +0 -1
- package/dist/src/storage/workspaces.js.map +0 -1
- package/dist/src/tools/bash.js.map +0 -1
- package/dist/src/tools/bash.test.js.map +0 -1
- package/dist/src/tools/computer.js.map +0 -1
- package/dist/src/tools/computer.test.js.map +0 -1
- package/dist/src/tools/file-tracker.js.map +0 -1
- package/dist/src/tools/file-tracker.test.js.map +0 -1
- package/dist/src/tools/file.js.map +0 -1
- package/dist/src/tools/file.test.js.map +0 -1
- package/dist/src/tools/grep.js.map +0 -1
- package/dist/src/tools/registry.js.map +0 -1
- package/dist/src/tools/registry.test.js.map +0 -1
- package/dist/src/tools/schedule.js.map +0 -1
- package/dist/src/tools/schedule.test.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/ui/agents-modal.js.map +0 -1
- package/dist/src/ui/app.js.map +0 -1
- package/dist/src/ui/cards/__tests__/product-status-card.test.js.map +0 -1
- package/dist/src/ui/cards/product-status-card.js.map +0 -1
- package/dist/src/ui/components/SuggestionOverlay.js.map +0 -1
- package/dist/src/ui/components/Toast.js.map +0 -1
- package/dist/src/ui/components/__tests__/council-leader-bubble.test.js.map +0 -1
- package/dist/src/ui/components/__tests__/council-message-bubble.test.js.map +0 -1
- package/dist/src/ui/components/__tests__/council-phase-timeline.test.js.map +0 -1
- package/dist/src/ui/components/__tests__/council-placeholder-bubble.test.js.map +0 -1
- package/dist/src/ui/components/__tests__/council-question-card.test.js.map +0 -1
- package/dist/src/ui/components/__tests__/council-synthesis-banner.test.js.map +0 -1
- package/dist/src/ui/components/__tests__/use-pair-quote-buffer.test.js.map +0 -1
- package/dist/src/ui/components/btw-overlay.js.map +0 -1
- package/dist/src/ui/components/bubble-layout.js.map +0 -1
- package/dist/src/ui/components/code-block-truncate.js.map +0 -1
- package/dist/src/ui/components/copy-flash-banner.js.map +0 -1
- package/dist/src/ui/components/council-info-card.js.map +0 -1
- package/dist/src/ui/components/council-leader-bubble.js.map +0 -1
- package/dist/src/ui/components/council-message-bubble.js.map +0 -1
- package/dist/src/ui/components/council-phase-timeline.js.map +0 -1
- package/dist/src/ui/components/council-placeholder-bubble.js.map +0 -1
- package/dist/src/ui/components/council-question-card.js.map +0 -1
- package/dist/src/ui/components/council-status-list.js.map +0 -1
- package/dist/src/ui/components/council-synthesis-banner.js.map +0 -1
- package/dist/src/ui/components/diff-view.js.map +0 -1
- package/dist/src/ui/components/halt-recovery-card.js.map +0 -1
- package/dist/src/ui/components/hero-logo.js.map +0 -1
- package/dist/src/ui/components/init-new-form-card.js.map +0 -1
- package/dist/src/ui/components/lsp-views.js.map +0 -1
- package/dist/src/ui/components/media-views.js.map +0 -1
- package/dist/src/ui/components/message-view.js.map +0 -1
- package/dist/src/ui/components/point-to-existing-form-card.js.map +0 -1
- package/dist/src/ui/components/prompt-box.js.map +0 -1
- package/dist/src/ui/components/role-palette.js.map +0 -1
- package/dist/src/ui/components/session-header.js.map +0 -1
- package/dist/src/ui/components/slash-inline-menu.js.map +0 -1
- package/dist/src/ui/components/structured-response-view.js.map +0 -1
- package/dist/src/ui/components/tool-result-views.js.map +0 -1
- package/dist/src/ui/components/use-pair-quote-buffer.js.map +0 -1
- package/dist/src/ui/constants.js.map +0 -1
- package/dist/src/ui/hooks/use-agent-editor.js.map +0 -1
- package/dist/src/ui/hooks/use-mcp-editor.js.map +0 -1
- package/dist/src/ui/hooks/use-model-picker.js.map +0 -1
- package/dist/src/ui/hooks/useTypeahead.js.map +0 -1
- package/dist/src/ui/markdown.js.map +0 -1
- package/dist/src/ui/mcp-modal-types.js.map +0 -1
- package/dist/src/ui/mcp-modal.js.map +0 -1
- package/dist/src/ui/modals/api-key-modal.js.map +0 -1
- package/dist/src/ui/modals/connect-modal.js.map +0 -1
- package/dist/src/ui/modals/model-picker-modal.js.map +0 -1
- package/dist/src/ui/modals/sandbox-picker-modal.js.map +0 -1
- package/dist/src/ui/modals/update-modal.js.map +0 -1
- package/dist/src/ui/modals/wallet-picker-modal.js.map +0 -1
- package/dist/src/ui/plan.js.map +0 -1
- package/dist/src/ui/schedule-modal.js.map +0 -1
- package/dist/src/ui/slash/__tests__/clear.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/compact.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/cost.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/discuss.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/execute.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/expand.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/ideal.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/menu-parity.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/optimize.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/pin.test.js.map +0 -1
- package/dist/src/ui/slash/__tests__/plan.test.js.map +0 -1
- package/dist/src/ui/slash/clear.js.map +0 -1
- package/dist/src/ui/slash/compact.js.map +0 -1
- package/dist/src/ui/slash/cost.js.map +0 -1
- package/dist/src/ui/slash/council-inspect.js.map +0 -1
- package/dist/src/ui/slash/council.js.map +0 -1
- package/dist/src/ui/slash/debug.js.map +0 -1
- package/dist/src/ui/slash/discuss.js.map +0 -1
- package/dist/src/ui/slash/ee.js.map +0 -1
- package/dist/src/ui/slash/execute.js.map +0 -1
- package/dist/src/ui/slash/expand.js.map +0 -1
- package/dist/src/ui/slash/export.js.map +0 -1
- package/dist/src/ui/slash/ideal.js.map +0 -1
- package/dist/src/ui/slash/menu-items.js.map +0 -1
- package/dist/src/ui/slash/optimize.js.map +0 -1
- package/dist/src/ui/slash/pin.js.map +0 -1
- package/dist/src/ui/slash/plan.js.map +0 -1
- package/dist/src/ui/slash/registry.js.map +0 -1
- package/dist/src/ui/slash/route.js.map +0 -1
- package/dist/src/ui/slash/route.test.js.map +0 -1
- package/dist/src/ui/status-bar/index.js.map +0 -1
- package/dist/src/ui/status-bar/index.test.js.map +0 -1
- package/dist/src/ui/status-bar/store.js.map +0 -1
- package/dist/src/ui/status-bar/store.test.js.map +0 -1
- package/dist/src/ui/status-bar/tier-badge.js.map +0 -1
- package/dist/src/ui/status-bar/tier-badge.test.js.map +0 -1
- package/dist/src/ui/status-bar/usd-meter.js.map +0 -1
- package/dist/src/ui/status-bar/usd-meter.test.js.map +0 -1
- package/dist/src/ui/syntax-highlight.js.map +0 -1
- package/dist/src/ui/terminal-selection-text.js.map +0 -1
- package/dist/src/ui/theme.js.map +0 -1
- package/dist/src/ui/types.js.map +0 -1
- package/dist/src/ui/utils/color.js.map +0 -1
- package/dist/src/ui/utils/format.js.map +0 -1
- package/dist/src/ui/utils/modal.js.map +0 -1
- package/dist/src/ui/utils/text.js.map +0 -1
- package/dist/src/ui/utils/tools.js.map +0 -1
- package/dist/src/usage/__tests__/product-ledger.test.js.map +0 -1
- package/dist/src/usage/cost-log.js.map +0 -1
- package/dist/src/usage/decision-log.js.map +0 -1
- package/dist/src/usage/downgrade.js.map +0 -1
- package/dist/src/usage/downgrade.test.js.map +0 -1
- package/dist/src/usage/estimator.js.map +0 -1
- package/dist/src/usage/estimator.test.js.map +0 -1
- package/dist/src/usage/ledger.js.map +0 -1
- package/dist/src/usage/ledger.test.js.map +0 -1
- package/dist/src/usage/midstream.js.map +0 -1
- package/dist/src/usage/midstream.test.js.map +0 -1
- package/dist/src/usage/product-ledger.js.map +0 -1
- package/dist/src/usage/thresholds.js.map +0 -1
- package/dist/src/usage/thresholds.test.js.map +0 -1
- package/dist/src/usage/types.js.map +0 -1
- package/dist/src/utils/__tests__/auto-council-settings.test.js.map +0 -1
- package/dist/src/utils/__tests__/ee-logger.test.js.map +0 -1
- package/dist/src/utils/__tests__/file-lock.test.js.map +0 -1
- package/dist/src/utils/__tests__/rate-limit.test.js.map +0 -1
- package/dist/src/utils/__tests__/settings-disabled-models.test.js.map +0 -1
- package/dist/src/utils/__tests__/settings-web-research.test.js.map +0 -1
- package/dist/src/utils/__tests__/slugify.test.js.map +0 -1
- package/dist/src/utils/__tests__/visible-retry.test.js.map +0 -1
- package/dist/src/utils/at-mentions.js.map +0 -1
- package/dist/src/utils/clipboard-image.js.map +0 -1
- package/dist/src/utils/ee-logger.js.map +0 -1
- package/dist/src/utils/file-index.js.map +0 -1
- package/dist/src/utils/file-lock.js.map +0 -1
- package/dist/src/utils/git-root.js.map +0 -1
- package/dist/src/utils/host-clipboard.js.map +0 -1
- package/dist/src/utils/install-manager.js.map +0 -1
- package/dist/src/utils/install-manager.test.js.map +0 -1
- package/dist/src/utils/instructions.js.map +0 -1
- package/dist/src/utils/instructions.test.js.map +0 -1
- package/dist/src/utils/permission-mode.js.map +0 -1
- package/dist/src/utils/permission-mode.test.js.map +0 -1
- package/dist/src/utils/rate-limit.js.map +0 -1
- package/dist/src/utils/redactor.js.map +0 -1
- package/dist/src/utils/redactor.test.js.map +0 -1
- package/dist/src/utils/settings.js.map +0 -1
- package/dist/src/utils/settings.test.js.map +0 -1
- package/dist/src/utils/shell.js.map +0 -1
- package/dist/src/utils/shell.test.js.map +0 -1
- package/dist/src/utils/side-question.js.map +0 -1
- package/dist/src/utils/skills.js.map +0 -1
- package/dist/src/utils/skills.test.js.map +0 -1
- package/dist/src/utils/slugify.js.map +0 -1
- package/dist/src/utils/subagent-display.js.map +0 -1
- package/dist/src/utils/subagent-display.test.js.map +0 -1
- package/dist/src/utils/subagents-settings.test.js.map +0 -1
- package/dist/src/utils/telegram-audio-settings.test.js.map +0 -1
- package/dist/src/utils/update-checker.js.map +0 -1
- package/dist/src/utils/update-checker.test.js.map +0 -1
- package/dist/src/utils/visible-retry.js.map +0 -1
- package/dist/src/verify/__tests__/coverage-parsers.test.js.map +0 -1
- package/dist/src/verify/__tests__/dotnet-recipe.test.js.map +0 -1
- package/dist/src/verify/checkpoint.js.map +0 -1
- package/dist/src/verify/checkpoint.test.js.map +0 -1
- package/dist/src/verify/coverage-parsers.js.map +0 -1
- package/dist/src/verify/entrypoint.js.map +0 -1
- package/dist/src/verify/entrypoint.test.js.map +0 -1
- package/dist/src/verify/environment.js.map +0 -1
- package/dist/src/verify/environment.test.js.map +0 -1
- package/dist/src/verify/evidence.js.map +0 -1
- package/dist/src/verify/orchestrator.js.map +0 -1
- package/dist/src/verify/orchestrator.test.js.map +0 -1
- package/dist/src/verify/recipes.js.map +0 -1
- package/dist/src/verify/retry.js.map +0 -1
- package/dist/src/verify/runtime-prep.test.js.map +0 -1
- package/src/__test-stubs__/ee-server.ts +0 -173
- package/src/__test-stubs__/vitest-setup.ts +0 -36
- package/src/__tests__/council/bubble-layout.test.ts +0 -45
- package/src/__tests__/council/code-block-truncate.test.ts +0 -50
- package/src/__tests__/council/role-palette.test.ts +0 -66
- package/src/__tests__/first-run-wizard.test.ts +0 -9
- package/src/agent-harness/__tests__/cli-flags.spec.ts +0 -35
- package/src/agent-harness/__tests__/driver.spec.ts +0 -154
- package/src/agent-harness/__tests__/idle.spec.ts +0 -90
- package/src/agent-harness/__tests__/mock-llm.spec.ts +0 -126
- package/src/agent-harness/__tests__/mock-model.spec.ts +0 -195
- package/src/agent-harness/__tests__/predicate.spec.ts +0 -33
- package/src/agent-harness/__tests__/protocol.spec.ts +0 -62
- package/src/agent-harness/__tests__/schema.spec.ts +0 -81
- package/src/agent-harness/__tests__/selector.spec.ts +0 -82
- package/src/agent-harness/__tests__/sidechannel.spec.ts +0 -40
- package/src/agent-harness/__tests__/spec-helpers.spec.ts +0 -76
- package/src/agent-harness/index.ts +0 -24
- package/src/agent-harness/mock-model.ts +0 -394
- package/src/agent-harness/test-spawn.ts +0 -200
- package/src/billing/index.ts +0 -5
- package/src/bun-sqlite.d.ts +0 -15
- package/src/chat/__tests__/broadcast-bus.test.ts +0 -90
- package/src/chat/__tests__/channel-manager.test.ts +0 -149
- package/src/chat/__tests__/client.test.ts +0 -118
- package/src/chat/__tests__/discord-integration.test.ts +0 -162
- package/src/chat/__tests__/intent-prompt.test.ts +0 -92
- package/src/chat/__tests__/verdict-resolver.test.ts +0 -336
- package/src/chat/broadcast-bus.ts +0 -53
- package/src/chat/channel-manager.ts +0 -146
- package/src/chat/chat-keychain.ts +0 -129
- package/src/chat/factory.ts +0 -37
- package/src/chat/intent-prompt.ts +0 -72
- package/src/chat/providers/discord/client.ts +0 -91
- package/src/chat/types.ts +0 -42
- package/src/chat/verdict-constants.ts +0 -26
- package/src/chat/verdict-resolver.ts +0 -231
- package/src/cli/__tests__/bw-vault.test.ts +0 -97
- package/src/cli/__tests__/keys-bundle.test.ts +0 -46
- package/src/cli/__tests__/share-cmd.test.ts +0 -197
- package/src/cli/bw-vault.ts +0 -184
- package/src/cli/config/__tests__/model-picker.test.ts +0 -59
- package/src/cli/config/__tests__/provider-fetch.test.ts +0 -38
- package/src/cli/config/index.ts +0 -112
- package/src/cli/config/model-picker.ts +0 -193
- package/src/cli/config/provider-fetch.ts +0 -75
- package/src/cli/config/screen-council.ts +0 -245
- package/src/cli/config/screen-models.ts +0 -104
- package/src/cli/config/screen-providers.ts +0 -197
- package/src/cli/config/tui.ts +0 -153
- package/src/cli/cost-forensics.test.ts +0 -128
- package/src/cli/cost-forensics.ts +0 -264
- package/src/cli/keys-bundle.ts +0 -91
- package/src/cli/keys.test.ts +0 -104
- package/src/cli/keys.ts +0 -787
- package/src/cli/pil-report.ts +0 -202
- package/src/cli/share-cmd.ts +0 -132
- package/src/cli/usage-report.ts +0 -266
- package/src/cloud/index.ts +0 -5
- package/src/council/__tests__/accounting.test.ts +0 -72
- package/src/council/__tests__/audit-replay.test.ts +0 -344
- package/src/council/__tests__/clarifier-max-rounds.test.ts +0 -91
- package/src/council/__tests__/clarifier-options.test.ts +0 -63
- package/src/council/__tests__/cost-aware.test.ts +0 -60
- package/src/council/__tests__/debate-planner-structured.test.ts +0 -236
- package/src/council/__tests__/evaluator-metrics.test.ts +0 -513
- package/src/council/__tests__/parse-outcome-fallback.test.ts +0 -125
- package/src/council/__tests__/research-tools.test.ts +0 -239
- package/src/council/__tests__/round-tools.test.ts +0 -334
- package/src/council/__tests__/tool-trace.test.ts +0 -152
- package/src/council/__tests__/types-contract.test.ts +0 -88
- package/src/council/clarifier.ts +0 -409
- package/src/council/context.ts +0 -250
- package/src/council/debate-planner.ts +0 -264
- package/src/council/debate.ts +0 -1179
- package/src/council/executor.ts +0 -27
- package/src/council/index.ts +0 -916
- package/src/council/leader.ts +0 -262
- package/src/council/llm.ts +0 -967
- package/src/council/phase-events.ts +0 -58
- package/src/council/planner.ts +0 -303
- package/src/council/preflight.ts +0 -86
- package/src/council/prompts.ts +0 -600
- package/src/council/types.ts +0 -286
- package/src/daemon/scheduler.test.ts +0 -128
- package/src/daemon/scheduler.ts +0 -152
- package/src/ee/.gitkeep +0 -0
- package/src/ee/__tests__/bb-design.test.ts +0 -223
- package/src/ee/__tests__/pil-context-bridge.test.ts +0 -59
- package/src/ee/__tests__/pipeline.integration.test.ts +0 -193
- package/src/ee/__tests__/render-sink-wiring.test.ts +0 -89
- package/src/ee/auth.test.ts +0 -76
- package/src/ee/auth.ts +0 -80
- package/src/ee/bb-design.ts +0 -284
- package/src/ee/bb-retrieval.ts +0 -467
- package/src/ee/bridge.test.ts +0 -283
- package/src/ee/bridge.ts +0 -443
- package/src/ee/client-mode.ts +0 -161
- package/src/ee/client.test.ts +0 -171
- package/src/ee/client.ts +0 -620
- package/src/ee/council-bridge.ts +0 -89
- package/src/ee/embedding-cache.ts +0 -42
- package/src/ee/extract-session.test.ts +0 -231
- package/src/ee/extract-session.ts +0 -71
- package/src/ee/health.ts +0 -83
- package/src/ee/index.ts +0 -33
- package/src/ee/intercept.test.ts +0 -197
- package/src/ee/intercept.ts +0 -143
- package/src/ee/judge.test.ts +0 -213
- package/src/ee/judge.ts +0 -126
- package/src/ee/mistake-detector.test.ts +0 -252
- package/src/ee/mistake-detector.ts +0 -297
- package/src/ee/offline-queue.test.ts +0 -302
- package/src/ee/offline-queue.ts +0 -205
- package/src/ee/phase-outcome.test.ts +0 -107
- package/src/ee/phase-outcome.ts +0 -165
- package/src/ee/phase-tracker.test.ts +0 -175
- package/src/ee/phase-tracker.ts +0 -180
- package/src/ee/posttool.test.ts +0 -81
- package/src/ee/posttool.ts +0 -16
- package/src/ee/prompt-stale.test.ts +0 -92
- package/src/ee/prompt-stale.ts +0 -39
- package/src/ee/render.test.ts +0 -74
- package/src/ee/render.ts +0 -68
- package/src/ee/scope.test.ts +0 -112
- package/src/ee/scope.ts +0 -93
- package/src/ee/session-trajectory.test.ts +0 -139
- package/src/ee/session-trajectory.ts +0 -226
- package/src/ee/tenant.ts +0 -14
- package/src/ee/touch.test.ts +0 -73
- package/src/ee/types.ts +0 -387
- package/src/flow/.gitkeep +0 -0
- package/src/flow/__tests__/migration.test.ts +0 -133
- package/src/flow/__tests__/parser.test.ts +0 -77
- package/src/flow/__tests__/run-manager-product.test.ts +0 -59
- package/src/flow/__tests__/run-manager.test.ts +0 -95
- package/src/flow/__tests__/scaffold-checkpoint.test.ts +0 -113
- package/src/flow/__tests__/scaffold.test.ts +0 -57
- package/src/flow/__tests__/warning-persist.test.ts +0 -112
- package/src/flow/artifact-io.ts +0 -41
- package/src/flow/compaction/__tests__/compress.test.ts +0 -69
- package/src/flow/compaction/__tests__/extract.test.ts +0 -74
- package/src/flow/compaction/__tests__/preserve.test.ts +0 -69
- package/src/flow/compaction/compress.ts +0 -67
- package/src/flow/compaction/extract.ts +0 -60
- package/src/flow/compaction/index.ts +0 -86
- package/src/flow/compaction/preserve.ts +0 -48
- package/src/flow/index.ts +0 -18
- package/src/flow/migration.ts +0 -139
- package/src/flow/parser.ts +0 -78
- package/src/flow/run-manager.ts +0 -162
- package/src/flow/scaffold-checkpoint.ts +0 -132
- package/src/flow/scaffold.ts +0 -52
- package/src/flow/warning-persist.ts +0 -84
- package/src/generated/version.ts +0 -4
- package/src/gsd/.gitkeep +0 -0
- package/src/gsd/__tests__/complexity.test.ts +0 -0
- package/src/gsd/__tests__/directives.test.ts +0 -49
- package/src/gsd/__tests__/gray-areas.test.ts +0 -33
- package/src/gsd/__tests__/types.test.ts +0 -77
- package/src/gsd/complexity.ts +0 -124
- package/src/gsd/directives.ts +0 -94
- package/src/gsd/gray-areas.ts +0 -144
- package/src/gsd/index.ts +0 -1
- package/src/gsd/types.ts +0 -49
- package/src/headless/__tests__/council-answers.test.ts +0 -266
- package/src/headless/council-answers.ts +0 -130
- package/src/headless/output.test.ts +0 -201
- package/src/headless/output.ts +0 -312
- package/src/hooks/config.ts +0 -41
- package/src/hooks/index.ts +0 -547
- package/src/hooks/types.ts +0 -263
- package/src/index.ts +0 -1570
- package/src/lsp/builtins.test.ts +0 -104
- package/src/lsp/builtins.ts +0 -409
- package/src/lsp/client.ts +0 -342
- package/src/lsp/manager.test.ts +0 -164
- package/src/lsp/manager.ts +0 -293
- package/src/lsp/npm-cache.test.ts +0 -68
- package/src/lsp/npm-cache.ts +0 -108
- package/src/lsp/runtime.ts +0 -70
- package/src/lsp/smoke.test.ts +0 -74
- package/src/lsp/types.ts +0 -116
- package/src/mcp/__tests__/auto-setup.test.ts +0 -88
- package/src/mcp/__tests__/harness-driver-action-tools.spec.ts +0 -114
- package/src/mcp/__tests__/harness-driver-async-tools.spec.ts +0 -127
- package/src/mcp/__tests__/harness-driver-read-tools.spec.ts +0 -140
- package/src/mcp/__tests__/harness-driver-security.spec.ts +0 -71
- package/src/mcp/__tests__/harness-driver.spec.ts +0 -21
- package/src/mcp/__tests__/lazy-schema.spec.ts +0 -173
- package/src/mcp/__tests__/mcp-keychain.test.ts +0 -46
- package/src/mcp/__tests__/research-onboarding.test.ts +0 -163
- package/src/mcp/__tests__/runtime-hydration.test.ts +0 -86
- package/src/mcp/__tests__/runtime-sanitize.test.ts +0 -44
- package/src/mcp/auto-setup.ts +0 -99
- package/src/mcp/catalog.ts +0 -155
- package/src/mcp/mcp-keychain.ts +0 -77
- package/src/mcp/oauth-callback.ts +0 -75
- package/src/mcp/oauth-provider.ts +0 -128
- package/src/mcp/opentui-spawn.ts +0 -64
- package/src/mcp/parse-headers.test.ts +0 -54
- package/src/mcp/parse-headers.ts +0 -35
- package/src/mcp/research-onboarding.ts +0 -143
- package/src/mcp/runtime.ts +0 -171
- package/src/mcp/smoke.test.ts +0 -170
- package/src/mcp/validate.ts +0 -48
- package/src/models/__tests__/registry.test.ts +0 -95
- package/src/models/catalog-client.ts +0 -140
- package/src/models/catalog.README.md +0 -136
- package/src/models/catalog.json +0 -177
- package/src/models/classify-tier.ts +0 -48
- package/src/models/index.ts +0 -9
- package/src/models/registry.ts +0 -77
- package/src/ops/__tests__/doctor-council-mcp.test.ts +0 -161
- package/src/ops/__tests__/doctor-ee-health.test.ts +0 -129
- package/src/ops/bug-report.test.ts +0 -172
- package/src/ops/bug-report.ts +0 -80
- package/src/ops/doctor.test.ts +0 -108
- package/src/ops/doctor.ts +0 -366
- package/src/orchestrator/__tests__/batch-turn-runner.test.ts +0 -178
- package/src/orchestrator/__tests__/council-manager.test.ts +0 -171
- package/src/orchestrator/__tests__/cross-turn-dedup.test.ts +0 -174
- package/src/orchestrator/__tests__/current-call-id.test.ts +0 -160
- package/src/orchestrator/__tests__/flow-resume.test.ts +0 -71
- package/src/orchestrator/__tests__/message-processor.test.ts +0 -196
- package/src/orchestrator/__tests__/message-write-ahead.test.ts +0 -170
- package/src/orchestrator/__tests__/read-path-budget.test.ts +0 -107
- package/src/orchestrator/__tests__/retry-classifier.test.ts +0 -120
- package/src/orchestrator/__tests__/retry-stream.test.ts +0 -186
- package/src/orchestrator/__tests__/route-feedback.test.ts +0 -55
- package/src/orchestrator/__tests__/stream-runner.test.ts +0 -123
- package/src/orchestrator/__tests__/usage-events-shape.test.ts +0 -80
- package/src/orchestrator/__tests__/usage-normalizer-c1.test.ts +0 -172
- package/src/orchestrator/__tests__/write-ahead.test.ts +0 -162
- package/src/orchestrator/abort.test.ts +0 -37
- package/src/orchestrator/abort.ts +0 -51
- package/src/orchestrator/agent-options.ts +0 -168
- package/src/orchestrator/agent.test.ts +0 -184
- package/src/orchestrator/batch-turn-runner.ts +0 -425
- package/src/orchestrator/batch-utils.ts +0 -340
- package/src/orchestrator/cleanup.test.ts +0 -86
- package/src/orchestrator/compaction.test.ts +0 -181
- package/src/orchestrator/compaction.ts +0 -613
- package/src/orchestrator/council-manager.ts +0 -580
- package/src/orchestrator/cross-turn-dedup.ts +0 -187
- package/src/orchestrator/delegations.test.ts +0 -145
- package/src/orchestrator/delegations.ts +0 -364
- package/src/orchestrator/error-utils.ts +0 -72
- package/src/orchestrator/flow-resume.ts +0 -54
- package/src/orchestrator/message-processor.ts +0 -1985
- package/src/orchestrator/message-seq.test.ts +0 -29
- package/src/orchestrator/message-seq.ts +0 -19
- package/src/orchestrator/orchestrator.ts +0 -2641
- package/src/orchestrator/pending-calls.test.ts +0 -226
- package/src/orchestrator/pending-calls.ts +0 -240
- package/src/orchestrator/prompts.ts +0 -482
- package/src/orchestrator/provider-options-shape.spec.ts +0 -67
- package/src/orchestrator/provider-options-shape.ts +0 -70
- package/src/orchestrator/read-path-budget.ts +0 -128
- package/src/orchestrator/reasoning.test.ts +0 -29
- package/src/orchestrator/reasoning.ts +0 -69
- package/src/orchestrator/retry-classifier.ts +0 -131
- package/src/orchestrator/retry-stream.ts +0 -159
- package/src/orchestrator/sandbox.test.ts +0 -115
- package/src/orchestrator/stream-runner.ts +0 -729
- package/src/orchestrator/sub-agent-cap.test.ts +0 -186
- package/src/orchestrator/sub-agent-cap.ts +0 -218
- package/src/orchestrator/subagent-compactor.spec.ts +0 -144
- package/src/orchestrator/subagent-compactor.ts +0 -242
- package/src/orchestrator/token-counter.test.ts +0 -69
- package/src/orchestrator/token-counter.ts +0 -81
- package/src/orchestrator/tool-utils.ts +0 -214
- package/src/orchestrator/turn-runner-deps.ts +0 -83
- package/src/pil/__tests__/budget.test.ts +0 -39
- package/src/pil/__tests__/config.test.ts +0 -32
- package/src/pil/__tests__/dual-run.test.ts +0 -53
- package/src/pil/__tests__/layer1-intent-trace.test.ts +0 -140
- package/src/pil/__tests__/layer1-intent.test.ts +0 -346
- package/src/pil/__tests__/layer2-personality.test.ts +0 -63
- package/src/pil/__tests__/layer3-ee-injection.test.ts +0 -181
- package/src/pil/__tests__/layer3-injected-chunk.test.ts +0 -122
- package/src/pil/__tests__/layer4-gsd.test.ts +0 -109
- package/src/pil/__tests__/layer5-context.test.ts +0 -157
- package/src/pil/__tests__/layer6-output.test.ts +0 -284
- package/src/pil/__tests__/ollama-classify.test.ts +0 -81
- package/src/pil/__tests__/orchestrator-integration.test.ts +0 -107
- package/src/pil/__tests__/pipeline.test.ts +0 -190
- package/src/pil/__tests__/renderer-coverage.test.ts +0 -46
- package/src/pil/__tests__/response-tools.test.ts +0 -174
- package/src/pil/__tests__/schema.test.ts +0 -233
- package/src/pil/__tests__/scoreComplexity.test.ts +0 -134
- package/src/pil/__tests__/scoreSufficiency.test.ts +0 -104
- package/src/pil/__tests__/store.test.ts +0 -49
- package/src/pil/__tests__/task-tier-map.test.ts +0 -41
- package/src/pil/budget-log.ts +0 -86
- package/src/pil/budget.ts +0 -18
- package/src/pil/config.ts +0 -11
- package/src/pil/index.ts +0 -12
- package/src/pil/layer1-intent.test.ts +0 -127
- package/src/pil/layer1-intent.ts +0 -580
- package/src/pil/layer2-personality.ts +0 -46
- package/src/pil/layer3-ee-injection.ts +0 -345
- package/src/pil/layer4-gsd.ts +0 -118
- package/src/pil/layer5-context.ts +0 -160
- package/src/pil/layer6-output.ts +0 -260
- package/src/pil/ollama-classify.ts +0 -49
- package/src/pil/pipeline.ts +0 -207
- package/src/pil/response-tools.ts +0 -110
- package/src/pil/schema.ts +0 -103
- package/src/pil/store.ts +0 -29
- package/src/pil/task-tier-map.ts +0 -90
- package/src/pil/timeout.ts +0 -10
- package/src/pil/types.ts +0 -150
- package/src/product-loop/__tests__/artifact-io.test.ts +0 -97
- package/src/product-loop/__tests__/assumption-ledger.test.ts +0 -292
- package/src/product-loop/__tests__/cb2-retry-bonus.test.ts +0 -182
- package/src/product-loop/__tests__/circuit-breakers-coverage.test.ts +0 -82
- package/src/product-loop/__tests__/circuit-breakers.test.ts +0 -90
- package/src/product-loop/__tests__/complexity-routing.spec.ts +0 -169
- package/src/product-loop/__tests__/context-policy.test.ts +0 -280
- package/src/product-loop/__tests__/cost-preview.test.ts +0 -118
- package/src/product-loop/__tests__/cost-scoper.test.ts +0 -76
- package/src/product-loop/__tests__/cross-run-memory.test.ts +0 -195
- package/src/product-loop/__tests__/design-output.spec.ts +0 -39
- package/src/product-loop/__tests__/discover.test.ts +0 -98
- package/src/product-loop/__tests__/discovery-council-runner.test.ts +0 -13
- package/src/product-loop/__tests__/discovery-detection.test.ts +0 -180
- package/src/product-loop/__tests__/discovery-ecosystem.test.ts +0 -132
- package/src/product-loop/__tests__/discovery-integration.test.ts +0 -133
- package/src/product-loop/__tests__/discovery-interview.test.ts +0 -305
- package/src/product-loop/__tests__/discovery-migrations.test.ts +0 -75
- package/src/product-loop/__tests__/discovery-persistence.test.ts +0 -171
- package/src/product-loop/__tests__/discovery-prompt-parser.test.ts +0 -77
- package/src/product-loop/__tests__/discovery-recommender-ecosystem.test.ts +0 -94
- package/src/product-loop/__tests__/discovery-recommender.test.ts +0 -382
- package/src/product-loop/__tests__/discovery-schema.test.ts +0 -102
- package/src/product-loop/__tests__/done-gate-coverage.test.ts +0 -151
- package/src/product-loop/__tests__/done-gate.test.ts +0 -140
- package/src/product-loop/__tests__/ee-extract-wiring.test.ts +0 -216
- package/src/product-loop/__tests__/extract-to-ee.test.ts +0 -205
- package/src/product-loop/__tests__/feedback-routing.test.ts +0 -93
- package/src/product-loop/__tests__/hot-path.spec.ts +0 -177
- package/src/product-loop/__tests__/integration.test.ts +0 -344
- package/src/product-loop/__tests__/loop-driver-audit.test.ts +0 -321
- package/src/product-loop/__tests__/loop-driver.test.ts +0 -247
- package/src/product-loop/__tests__/phase-budget.test.ts +0 -172
- package/src/product-loop/__tests__/phase-orchestrator-integration.test.ts +0 -143
- package/src/product-loop/__tests__/phase-plan.test.ts +0 -241
- package/src/product-loop/__tests__/phase-rituals.test.ts +0 -211
- package/src/product-loop/__tests__/phase-runner.test.ts +0 -454
- package/src/product-loop/__tests__/phase-tracker-bridge.test.ts +0 -85
- package/src/product-loop/__tests__/product-identity.test.ts +0 -47
- package/src/product-loop/__tests__/reality-anchor.test.ts +0 -58
- package/src/product-loop/__tests__/repo-audit.test.ts +0 -103
- package/src/product-loop/__tests__/role-memory.test.ts +0 -70
- package/src/product-loop/__tests__/role-registry.test.ts +0 -235
- package/src/product-loop/__tests__/role-routing-ee.test.ts +0 -90
- package/src/product-loop/__tests__/route-decision-emit.test.ts +0 -207
- package/src/product-loop/__tests__/seed-questions.test.ts +0 -33
- package/src/product-loop/__tests__/ship-polish.test.ts +0 -109
- package/src/product-loop/__tests__/sprint-runner-emit.test.ts +0 -324
- package/src/product-loop/__tests__/sprint-runner.test.ts +0 -501
- package/src/product-loop/__tests__/stakeholder-acl.test.ts +0 -94
- package/src/product-loop/__tests__/state-md-ee-injections.test.ts +0 -229
- package/src/product-loop/__tests__/sufficiency-routing.spec.ts +0 -177
- package/src/product-loop/__tests__/typed-artifacts.test.ts +0 -261
- package/src/product-loop/__tests__/types.test.ts +0 -103
- package/src/product-loop/__tests__/verify-failure-threshold.test.ts +0 -177
- package/src/product-loop/__tests__/verify-failure-tracking.test.ts +0 -154
- package/src/product-loop/__tests__/verify-result.test.ts +0 -60
- package/src/product-loop/artifact-io.ts +0 -239
- package/src/product-loop/assumption-ledger.ts +0 -270
- package/src/product-loop/circuit-breakers.ts +0 -76
- package/src/product-loop/context-policy.ts +0 -180
- package/src/product-loop/cost-preview.ts +0 -124
- package/src/product-loop/cost-scoper.ts +0 -49
- package/src/product-loop/cross-run-memory.ts +0 -450
- package/src/product-loop/design-output.ts +0 -24
- package/src/product-loop/discover.ts +0 -159
- package/src/product-loop/discovery-context-format.ts +0 -32
- package/src/product-loop/discovery-council-runner.ts +0 -82
- package/src/product-loop/discovery-detection.ts +0 -161
- package/src/product-loop/discovery-ecosystem.ts +0 -124
- package/src/product-loop/discovery-interview.ts +0 -237
- package/src/product-loop/discovery-migrations.ts +0 -40
- package/src/product-loop/discovery-persistence.ts +0 -219
- package/src/product-loop/discovery-prompt-parser.ts +0 -80
- package/src/product-loop/discovery-recommender.ts +0 -366
- package/src/product-loop/discovery-schema.ts +0 -143
- package/src/product-loop/done-gate.ts +0 -224
- package/src/product-loop/feedback-routing.ts +0 -82
- package/src/product-loop/gather.ts +0 -304
- package/src/product-loop/index.ts +0 -1305
- package/src/product-loop/loop-driver.ts +0 -901
- package/src/product-loop/phase-budget.ts +0 -182
- package/src/product-loop/phase-plan.ts +0 -158
- package/src/product-loop/phase-rituals.ts +0 -158
- package/src/product-loop/phase-runner.ts +0 -455
- package/src/product-loop/phase-tracker-bridge.ts +0 -60
- package/src/product-loop/product-identity.ts +0 -11
- package/src/product-loop/reality-anchor.ts +0 -45
- package/src/product-loop/repo-audit.ts +0 -314
- package/src/product-loop/role-memory.ts +0 -72
- package/src/product-loop/role-registry.ts +0 -175
- package/src/product-loop/seed-questions.ts +0 -51
- package/src/product-loop/ship-polish.ts +0 -164
- package/src/product-loop/sprint-runner.ts +0 -610
- package/src/product-loop/stakeholder-acl.ts +0 -82
- package/src/product-loop/typed-artifacts.ts +0 -332
- package/src/product-loop/types.ts +0 -443
- package/src/product-loop/verify-failure-tracking.ts +0 -225
- package/src/product-loop/verify-result.ts +0 -39
- package/src/providers/.gitkeep +0 -0
- package/src/providers/__test-utils__/load-fixture.ts +0 -36
- package/src/providers/__tests__/adapter-oauth-wiring.test.ts +0 -129
- package/src/providers/__tests__/capabilities-cosmetic.test.ts +0 -119
- package/src/providers/__tests__/capabilities-flags.test.ts +0 -166
- package/src/providers/__tests__/capabilities-provider-options.test.ts +0 -203
- package/src/providers/__tests__/capabilities-sanitize.test.ts +0 -82
- package/src/providers/__tests__/capabilities.test.ts +0 -44
- package/src/providers/__tests__/provider-coverage.test.ts +0 -48
- package/src/providers/__tests__/runtime-integration.test.ts +0 -97
- package/src/providers/__tests__/runtime.test.ts +0 -96
- package/src/providers/__tests__/siliconflow-history.test.ts +0 -82
- package/src/providers/__tests__/strategies-registry.test.ts +0 -55
- package/src/providers/__tests__/strategies-resolve.test.ts +0 -137
- package/src/providers/__tests__/wire-debug.test.ts +0 -42
- package/src/providers/adapter.test.ts +0 -21
- package/src/providers/adapter.ts +0 -156
- package/src/providers/anthropic.ts +0 -174
- package/src/providers/auth/__tests__/browser-flow.test.ts +0 -235
- package/src/providers/auth/__tests__/device-flow.test.ts +0 -263
- package/src/providers/auth/__tests__/gemini-oauth.test.ts +0 -387
- package/src/providers/auth/__tests__/openai-oauth.test.ts +0 -378
- package/src/providers/auth/__tests__/token-store.test.ts +0 -152
- package/src/providers/auth/browser-flow.ts +0 -140
- package/src/providers/auth/device-flow.ts +0 -221
- package/src/providers/auth/gemini-oauth.ts +0 -351
- package/src/providers/auth/openai-oauth.ts +0 -455
- package/src/providers/auth/registry.ts +0 -121
- package/src/providers/auth/token-store.ts +0 -154
- package/src/providers/auth/types.ts +0 -111
- package/src/providers/capabilities.ts +0 -351
- package/src/providers/endpoints.ts +0 -68
- package/src/providers/errors.test.ts +0 -76
- package/src/providers/errors.ts +0 -46
- package/src/providers/gemini.test.ts +0 -46
- package/src/providers/gemini.ts +0 -42
- package/src/providers/index.ts +0 -28
- package/src/providers/keychain.test.ts +0 -100
- package/src/providers/keychain.ts +0 -267
- package/src/providers/mcp-vision-bridge.test.ts +0 -513
- package/src/providers/mcp-vision-bridge.ts +0 -1020
- package/src/providers/ollama.test.ts +0 -46
- package/src/providers/ollama.ts +0 -36
- package/src/providers/openai-compatible.test.ts +0 -63
- package/src/providers/openai-compatible.ts +0 -58
- package/src/providers/openai.test.ts +0 -65
- package/src/providers/openai.ts +0 -56
- package/src/providers/patch-zod-schema.ts +0 -126
- package/src/providers/pricing.test.ts +0 -65
- package/src/providers/pricing.ts +0 -111
- package/src/providers/prompt-cache-key.spec.ts +0 -28
- package/src/providers/runtime-mock.spec.ts +0 -86
- package/src/providers/runtime.ts +0 -283
- package/src/providers/siliconflow-history.ts +0 -74
- package/src/providers/strategies/anthropic.strategy.ts +0 -25
- package/src/providers/strategies/base.strategy.ts +0 -76
- package/src/providers/strategies/deepseek.strategy.ts +0 -26
- package/src/providers/strategies/google.strategy.ts +0 -28
- package/src/providers/strategies/ollama.strategy.ts +0 -22
- package/src/providers/strategies/openai.strategy.ts +0 -55
- package/src/providers/strategies/registry.ts +0 -43
- package/src/providers/strategies/siliconflow.strategy.ts +0 -26
- package/src/providers/strategies/xai.strategy.ts +0 -26
- package/src/providers/stream-loop.ts +0 -83
- package/src/providers/types.ts +0 -145
- package/src/providers/vision-proxy.test.ts +0 -252
- package/src/providers/vision-proxy.ts +0 -317
- package/src/providers/wire-debug.ts +0 -163
- package/src/router/.gitkeep +0 -0
- package/src/router/__tests__/step-router.test.ts +0 -150
- package/src/router/classifier/grammars.ts +0 -17
- package/src/router/classifier/index.test.ts +0 -33
- package/src/router/classifier/index.ts +0 -21
- package/src/router/classifier/regex.test.ts +0 -49
- package/src/router/classifier/regex.ts +0 -113
- package/src/router/classifier/tree-sitter.test.ts +0 -26
- package/src/router/classifier/tree-sitter.ts +0 -87
- package/src/router/cold.test.ts +0 -62
- package/src/router/cold.ts +0 -27
- package/src/router/decide.test.ts +0 -147
- package/src/router/decide.ts +0 -472
- package/src/router/health.test.ts +0 -59
- package/src/router/health.ts +0 -49
- package/src/router/provider-sentinel.test.ts +0 -22
- package/src/router/provider-sentinel.ts +0 -20
- package/src/router/step-router.ts +0 -194
- package/src/router/store.ts +0 -47
- package/src/router/types.ts +0 -20
- package/src/router/warm.test.ts +0 -168
- package/src/router/warm.ts +0 -53
- package/src/scaffold/__tests__/continuation-prompt.test.ts +0 -93
- package/src/scaffold/__tests__/continue-as-council.spec.ts +0 -124
- package/src/scaffold/__tests__/dotnet-assembly-name.test.ts +0 -28
- package/src/scaffold/__tests__/fe-scaffold-contents.test.ts +0 -127
- package/src/scaffold/__tests__/init-new.smoke.spec.ts +0 -99
- package/src/scaffold/__tests__/init-new.spec.ts +0 -450
- package/src/scaffold/__tests__/install-bb-templates.spec.ts +0 -86
- package/src/scaffold/__tests__/point-to-existing.spec.ts +0 -114
- package/src/scaffold/bb-ecosystem-apply.ts +0 -454
- package/src/scaffold/bb-quality-gate.ts +0 -287
- package/src/scaffold/continuation-prompt.ts +0 -80
- package/src/scaffold/continue-as-council.ts +0 -99
- package/src/scaffold/init-new.ts +0 -1691
- package/src/scaffold/point-to-existing.ts +0 -83
- package/src/scaffold/resume-from-gate-failures.ts +0 -167
- package/src/storage/__tests__/migrations.test.ts +0 -395
- package/src/storage/__tests__/ui-interaction-log.test.ts +0 -105
- package/src/storage/atomic-io.test.ts +0 -92
- package/src/storage/atomic-io.ts +0 -160
- package/src/storage/config.test.ts +0 -33
- package/src/storage/config.ts +0 -53
- package/src/storage/db.ts +0 -184
- package/src/storage/index.ts +0 -26
- package/src/storage/interaction-log.ts +0 -121
- package/src/storage/migrations.ts +0 -205
- package/src/storage/session-dir.ts +0 -37
- package/src/storage/sessions.ts +0 -206
- package/src/storage/tool-results.ts +0 -56
- package/src/storage/transcript-view.ts +0 -45
- package/src/storage/transcript.test.ts +0 -24
- package/src/storage/transcript.ts +0 -561
- package/src/storage/ui-interaction-log.ts +0 -160
- package/src/storage/usage-cap.test.ts +0 -59
- package/src/storage/usage-cap.ts +0 -81
- package/src/storage/usage.ts +0 -117
- package/src/storage/workspaces.ts +0 -84
- package/src/tools/bash.test.ts +0 -363
- package/src/tools/bash.ts +0 -668
- package/src/tools/computer.test.ts +0 -187
- package/src/tools/computer.ts +0 -632
- package/src/tools/file-tracker.test.ts +0 -99
- package/src/tools/file-tracker.ts +0 -70
- package/src/tools/file.test.ts +0 -95
- package/src/tools/file.ts +0 -182
- package/src/tools/grep.ts +0 -187
- package/src/tools/registry.test.ts +0 -38
- package/src/tools/registry.ts +0 -388
- package/src/tools/schedule.test.ts +0 -143
- package/src/tools/schedule.ts +0 -610
- package/src/types/index.ts +0 -474
- package/src/ui/agents-modal.tsx +0 -292
- package/src/ui/app.tsx +0 -6464
- package/src/ui/cards/__tests__/product-status-card.test.ts +0 -30
- package/src/ui/cards/product-status-card.tsx +0 -117
- package/src/ui/components/SuggestionOverlay.tsx +0 -38
- package/src/ui/components/Toast.tsx +0 -100
- package/src/ui/components/__tests__/council-leader-bubble.test.ts +0 -16
- package/src/ui/components/__tests__/council-message-bubble.test.ts +0 -85
- package/src/ui/components/__tests__/council-phase-timeline.test.ts +0 -57
- package/src/ui/components/__tests__/council-placeholder-bubble.test.ts +0 -16
- package/src/ui/components/__tests__/council-question-card.test.ts +0 -133
- package/src/ui/components/__tests__/council-synthesis-banner.test.ts +0 -12
- package/src/ui/components/__tests__/use-pair-quote-buffer.test.ts +0 -41
- package/src/ui/components/btw-overlay.tsx +0 -66
- package/src/ui/components/bubble-layout.ts +0 -66
- package/src/ui/components/code-block-truncate.ts +0 -24
- package/src/ui/components/copy-flash-banner.tsx +0 -31
- package/src/ui/components/council-info-card.tsx +0 -45
- package/src/ui/components/council-leader-bubble.tsx +0 -41
- package/src/ui/components/council-message-bubble.tsx +0 -111
- package/src/ui/components/council-phase-timeline.tsx +0 -91
- package/src/ui/components/council-placeholder-bubble.tsx +0 -65
- package/src/ui/components/council-question-card.tsx +0 -253
- package/src/ui/components/council-status-list.tsx +0 -111
- package/src/ui/components/council-synthesis-banner.tsx +0 -37
- package/src/ui/components/diff-view.tsx +0 -225
- package/src/ui/components/halt-recovery-card.tsx +0 -83
- package/src/ui/components/hero-logo.tsx +0 -62
- package/src/ui/components/init-new-form-card.tsx +0 -470
- package/src/ui/components/lsp-views.tsx +0 -104
- package/src/ui/components/media-views.tsx +0 -66
- package/src/ui/components/message-view.tsx +0 -343
- package/src/ui/components/point-to-existing-form-card.tsx +0 -136
- package/src/ui/components/prompt-box.tsx +0 -306
- package/src/ui/components/role-palette.ts +0 -62
- package/src/ui/components/session-header.tsx +0 -68
- package/src/ui/components/slash-inline-menu.tsx +0 -63
- package/src/ui/components/structured-response-view.tsx +0 -191
- package/src/ui/components/tool-result-views.tsx +0 -258
- package/src/ui/components/use-pair-quote-buffer.ts +0 -23
- package/src/ui/constants.ts +0 -242
- package/src/ui/hooks/use-agent-editor.ts +0 -64
- package/src/ui/hooks/use-mcp-editor.ts +0 -39
- package/src/ui/hooks/use-model-picker.ts +0 -50
- package/src/ui/hooks/useTypeahead.ts +0 -160
- package/src/ui/markdown.tsx +0 -49
- package/src/ui/mcp-modal-types.ts +0 -33
- package/src/ui/mcp-modal.tsx +0 -484
- package/src/ui/modals/api-key-modal.tsx +0 -99
- package/src/ui/modals/connect-modal.tsx +0 -259
- package/src/ui/modals/model-picker-modal.tsx +0 -323
- package/src/ui/modals/sandbox-picker-modal.tsx +0 -99
- package/src/ui/modals/update-modal.tsx +0 -67
- package/src/ui/modals/wallet-picker-modal.tsx +0 -186
- package/src/ui/plan.tsx +0 -346
- package/src/ui/schedule-modal.tsx +0 -138
- package/src/ui/slash/__tests__/clear.test.ts +0 -86
- package/src/ui/slash/__tests__/compact.test.ts +0 -56
- package/src/ui/slash/__tests__/cost.test.ts +0 -62
- package/src/ui/slash/__tests__/discuss.test.ts +0 -101
- package/src/ui/slash/__tests__/execute.test.ts +0 -86
- package/src/ui/slash/__tests__/expand.test.ts +0 -86
- package/src/ui/slash/__tests__/ideal.test.ts +0 -134
- package/src/ui/slash/__tests__/menu-parity.test.ts +0 -43
- package/src/ui/slash/__tests__/optimize.test.ts +0 -155
- package/src/ui/slash/__tests__/pin.test.ts +0 -47
- package/src/ui/slash/__tests__/plan.test.ts +0 -95
- package/src/ui/slash/clear.ts +0 -89
- package/src/ui/slash/compact.ts +0 -46
- package/src/ui/slash/cost.ts +0 -63
- package/src/ui/slash/council-inspect.ts +0 -188
- package/src/ui/slash/council.ts +0 -30
- package/src/ui/slash/debug.ts +0 -153
- package/src/ui/slash/discuss.ts +0 -71
- package/src/ui/slash/ee.ts +0 -304
- package/src/ui/slash/execute.ts +0 -44
- package/src/ui/slash/expand.ts +0 -51
- package/src/ui/slash/export.ts +0 -281
- package/src/ui/slash/ideal.ts +0 -254
- package/src/ui/slash/menu-items.ts +0 -106
- package/src/ui/slash/optimize.ts +0 -47
- package/src/ui/slash/pin.ts +0 -41
- package/src/ui/slash/plan.ts +0 -62
- package/src/ui/slash/registry.ts +0 -47
- package/src/ui/slash/route.test.ts +0 -82
- package/src/ui/slash/route.ts +0 -43
- package/src/ui/status-bar/index.test.tsx +0 -90
- package/src/ui/status-bar/index.tsx +0 -98
- package/src/ui/status-bar/store.test.ts +0 -131
- package/src/ui/status-bar/store.ts +0 -186
- package/src/ui/status-bar/tier-badge.test.tsx +0 -38
- package/src/ui/status-bar/tier-badge.tsx +0 -29
- package/src/ui/status-bar/usd-meter.test.tsx +0 -37
- package/src/ui/status-bar/usd-meter.tsx +0 -22
- package/src/ui/syntax-highlight.ts +0 -627
- package/src/ui/terminal-selection-text.ts +0 -72
- package/src/ui/theme.ts +0 -95
- package/src/ui/types.ts +0 -83
- package/src/ui/utils/color.ts +0 -19
- package/src/ui/utils/format.ts +0 -86
- package/src/ui/utils/modal.ts +0 -9
- package/src/ui/utils/text.ts +0 -31
- package/src/ui/utils/tools.ts +0 -95
- package/src/usage/.gitkeep +0 -0
- package/src/usage/__tests__/product-ledger.test.ts +0 -85
- package/src/usage/cost-log.ts +0 -158
- package/src/usage/decision-log.ts +0 -86
- package/src/usage/downgrade.test.ts +0 -82
- package/src/usage/downgrade.ts +0 -70
- package/src/usage/estimator.test.ts +0 -43
- package/src/usage/estimator.ts +0 -58
- package/src/usage/ledger.test.ts +0 -200
- package/src/usage/ledger.ts +0 -253
- package/src/usage/midstream.test.ts +0 -55
- package/src/usage/midstream.ts +0 -51
- package/src/usage/product-ledger.ts +0 -111
- package/src/usage/thresholds.test.ts +0 -83
- package/src/usage/thresholds.ts +0 -74
- package/src/usage/types.ts +0 -41
- package/src/utils/__tests__/auto-council-settings.test.ts +0 -46
- package/src/utils/__tests__/ee-logger.test.ts +0 -197
- package/src/utils/__tests__/file-lock.test.ts +0 -74
- package/src/utils/__tests__/rate-limit.test.ts +0 -42
- package/src/utils/__tests__/settings-disabled-models.test.ts +0 -113
- package/src/utils/__tests__/settings-web-research.test.ts +0 -45
- package/src/utils/__tests__/slugify.test.ts +0 -45
- package/src/utils/__tests__/visible-retry.test.ts +0 -195
- package/src/utils/at-mentions.ts +0 -120
- package/src/utils/clipboard-image.ts +0 -139
- package/src/utils/ee-logger.ts +0 -163
- package/src/utils/file-index.ts +0 -152
- package/src/utils/file-lock.ts +0 -66
- package/src/utils/git-root.ts +0 -17
- package/src/utils/host-clipboard.ts +0 -68
- package/src/utils/install-manager.test.ts +0 -167
- package/src/utils/install-manager.ts +0 -429
- package/src/utils/instructions.test.ts +0 -112
- package/src/utils/instructions.ts +0 -149
- package/src/utils/permission-mode.test.ts +0 -121
- package/src/utils/permission-mode.ts +0 -37
- package/src/utils/rate-limit.ts +0 -21
- package/src/utils/redactor.test.ts +0 -100
- package/src/utils/redactor.ts +0 -223
- package/src/utils/settings.test.ts +0 -181
- package/src/utils/settings.ts +0 -1108
- package/src/utils/shell.test.ts +0 -72
- package/src/utils/shell.ts +0 -193
- package/src/utils/side-question.ts +0 -39
- package/src/utils/skills.test.ts +0 -58
- package/src/utils/skills.ts +0 -207
- package/src/utils/slugify.ts +0 -9
- package/src/utils/subagent-display.test.ts +0 -23
- package/src/utils/subagent-display.ts +0 -11
- package/src/utils/subagents-settings.test.ts +0 -77
- package/src/utils/telegram-audio-settings.test.ts +0 -44
- package/src/utils/update-checker.test.ts +0 -182
- package/src/utils/update-checker.ts +0 -33
- package/src/utils/visible-retry.ts +0 -56
- package/src/verify/__tests__/coverage-parsers.test.ts +0 -86
- package/src/verify/__tests__/dotnet-recipe.test.ts +0 -88
- package/src/verify/checkpoint.test.ts +0 -186
- package/src/verify/checkpoint.ts +0 -239
- package/src/verify/coverage-parsers.ts +0 -76
- package/src/verify/entrypoint.test.ts +0 -293
- package/src/verify/entrypoint.ts +0 -439
- package/src/verify/environment.test.ts +0 -119
- package/src/verify/environment.ts +0 -115
- package/src/verify/evidence.ts +0 -104
- package/src/verify/orchestrator.test.ts +0 -159
- package/src/verify/orchestrator.ts +0 -129
- package/src/verify/recipes.ts +0 -592
- package/src/verify/retry.ts +0 -62
- package/src/verify/runtime-prep.test.ts +0 -47
- /package/dist/src/{providers/__tests__/siliconflow-history.test.d.ts → council/__tests__/clarifier-ready-gate.test.d.ts} +0 -0
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
import { stepCountIs, streamText } from "ai";
|
|
53
53
|
import { getCachedAuthToken, getCachedServerBaseUrl } from "../ee/auth.js";
|
|
54
54
|
import { routeFeedback, routeModel } from "../ee/bridge.js";
|
|
55
|
+
import { getDefaultEEClient } from "../ee/intercept.js";
|
|
55
56
|
import { getMistakeDetector } from "../ee/mistake-detector.js";
|
|
56
57
|
import { fireAndForgetPhaseOutcome } from "../ee/phase-outcome.js";
|
|
57
58
|
import * as phaseTracker from "../ee/phase-tracker.js";
|
|
@@ -59,14 +60,17 @@ import { buildScope as buildScopeForVeto } from "../ee/scope.js";
|
|
|
59
60
|
import { fireTrajectoryEvent } from "../ee/session-trajectory.js";
|
|
60
61
|
import { getTenantId as getTenantIdForVeto } from "../ee/tenant.js";
|
|
61
62
|
import { buildMcpToolSet } from "../mcp/runtime.js";
|
|
63
|
+
import { dropRedundantFsMcpTools, filterMcpServersByMessage } from "../mcp/smart-filter.js";
|
|
62
64
|
import { getModelInfo } from "../models/registry.js";
|
|
63
|
-
import {
|
|
65
|
+
import { cheapModelShellLine, injectCheapModelPlaybook, injectCheapModelShellDirective, shouldInjectCheapModelPlaybook, } from "../pil/cheap-model-playbook.js";
|
|
66
|
+
import { injectCheapModelWorkbook, shouldInjectCheapModelWorkbook } from "../pil/cheap-model-workbooks.js";
|
|
67
|
+
import { applyPilSuffix, getResponseTaskType, getResponseToolSet, isResponseTool, runPipeline, shouldHaltOnResponseTool, } from "../pil/index.js";
|
|
64
68
|
import { taskTypeToMaxTokens, taskTypeToReasoningEffort, taskTypeToTier } from "../pil/task-tier-map.js";
|
|
65
69
|
import { getProviderCapabilities } from "../providers/capabilities.js";
|
|
66
70
|
import { loadKeyForProvider } from "../providers/keychain.js";
|
|
67
|
-
import { bridgeMcpToolResult, getVisionGuidanceForTextOnly, scrubImagePayloadsInMessages, } from "../providers/mcp-vision-bridge.js";
|
|
71
|
+
import { bridgeMcpToolResult, getVisionGuidanceForTextOnly, listCachedImages, scrubImagePayloadsInMessages, } from "../providers/mcp-vision-bridge.js";
|
|
68
72
|
import { captureToolSchemas } from "../providers/patch-zod-schema.js";
|
|
69
|
-
import { buildTurnProviderOptions, detectProviderForModel, resolveModelRuntime, shouldDropParam, } from "../providers/runtime.js";
|
|
73
|
+
import { buildTurnProviderOptions, detectProviderForModel, requireRuntimeProvider, resolveModelRuntime, shouldDropParam, } from "../providers/runtime.js";
|
|
70
74
|
import { needsVisionProxy, proxyVision } from "../providers/vision-proxy.js";
|
|
71
75
|
import { wireDebug } from "../providers/wire-debug.js";
|
|
72
76
|
import { reportRouteOutcome } from "../router/decide.js";
|
|
@@ -74,22 +78,64 @@ import { decideStepRouting, getStepRouterConfig } from "../router/step-router.js
|
|
|
74
78
|
import { routerStore } from "../router/store.js";
|
|
75
79
|
import { getNextMessageSequence, logInteraction, markMessageErrored, markToolCallErrored, persistMessageWriteAhead, persistToolCallWriteAhead, } from "../storage/index.js";
|
|
76
80
|
import { createBuiltinTools } from "../tools/registry.js";
|
|
81
|
+
import { snapshotFromTodoWriteArgs } from "../tools/todo-write-snapshot.js";
|
|
82
|
+
import { visionToolsNeeded } from "../tools/vision-gate.js";
|
|
77
83
|
import { isDebugEnabled, recordTurnTrace } from "../ui/slash/debug.js";
|
|
78
84
|
import { statusBarStore } from "../ui/status-bar/store.js";
|
|
79
85
|
import { appendDecisionLog } from "../usage/decision-log.js";
|
|
80
|
-
import { toolNeedsApproval } from "../utils/permission-mode.js";
|
|
81
|
-
import { getAutoCouncilConfidence, getAutoCouncilMinRoles, getRoleModels, getTopLevelCompactKeepLast, getTopLevelCompactThresholdChars, getTopLevelToolBudgetChars, isAutoCouncilEnabled, isProviderDisabled, loadMcpServers, loadValidSubAgents, } from "../utils/settings.js";
|
|
86
|
+
import { appendAudit, toolNeedsApproval } from "../utils/permission-mode.js";
|
|
87
|
+
import { getAutoCouncilConfidence, getAutoCouncilMinRoles, getProviderStallTimeoutMs, getRoleModels, getTopLevelCompactKeepLast, getTopLevelCompactThresholdChars, getTopLevelToolBudgetChars, isAutoCouncilEnabled, isProviderDisabled, loadMcpServers, loadValidSubAgents, } from "../utils/settings.js";
|
|
88
|
+
import { resolveShell } from "../utils/shell.js";
|
|
82
89
|
import { relaxCompactionSettings } from "./compaction.js";
|
|
83
90
|
import { wrapToolSetWithDedup } from "./cross-turn-dedup.js";
|
|
84
|
-
import { humanizeApiError, isAuthenticationError, isContextLimitError } from "./error-utils.js";
|
|
91
|
+
import { humanizeApiError, isAuthenticationError, isContextLimitError, summarizeApiErrorForLog } from "./error-utils.js";
|
|
92
|
+
import { buildGroundingFootnote, findUnverifiedClaims } from "./grounding-check.js";
|
|
93
|
+
import { buildInterruptedTurnNote } from "./interrupted-turn.js";
|
|
85
94
|
import { stableCallId } from "./pending-calls.js";
|
|
86
95
|
import { applyModelConstraints, buildSystemPromptParts } from "./prompts.js";
|
|
87
96
|
import { extractProviderOptionsShape } from "./provider-options-shape.js";
|
|
88
97
|
import { wrapToolSetWithReadBudget } from "./read-path-budget.js";
|
|
89
98
|
import { containsEncryptedReasoning, sanitizeModelMessages } from "./reasoning.js";
|
|
99
|
+
import { repairToolCallHook } from "./repair-tool-call.js";
|
|
100
|
+
import { buildRepetitionReminder, recordAssistantBurst, shouldInjectRepetitionReminder, } from "./repetition-detector.js";
|
|
90
101
|
import { classifyStreamError } from "./retry-classifier.js";
|
|
102
|
+
import { forcedFinalize, getSessionLastTask, incSessionStep, parseBudgetOverride, recordSessionLastTask, resetSessionStep, resolveCeiling, } from "./scope-ceiling.js";
|
|
103
|
+
import { attachReminderToMessages, buildCheckpointReminder, buildScopeReminder, cadenceForSize, shouldInjectCeilingCrossing, shouldInjectReminder, shouldInjectSoftWarn, } from "./scope-reminder.js";
|
|
104
|
+
import { attemptStallRescue, pushStallToolResult } from "./stall-rescue.js";
|
|
105
|
+
import { createStallWatchdog, STALL_ERROR_MESSAGE } from "./stall-watchdog.js";
|
|
91
106
|
import { wrapToolSetWithCap } from "./sub-agent-cap.js";
|
|
92
107
|
import { compactSubAgentMessages } from "./subagent-compactor.js";
|
|
108
|
+
import { detectTextEmittedToolCall, parseDsmlToolCalls } from "./text-tool-call-detector.js";
|
|
109
|
+
import { createToolLoopCapPredicate } from "./tool-loop-cap.js";
|
|
110
|
+
import { buildToolRepetitionAbortMessage, recordToolError as recordToolRepetitionError, recordToolSuccess as recordToolRepetitionSuccess, } from "./tool-repetition-detector.js";
|
|
111
|
+
/**
|
|
112
|
+
* F2 — approximate the char cost of the FIXED prompt envelope (system +
|
|
113
|
+
* tools JSON-Schema) that streamText re-sends on every step. Used to feed
|
|
114
|
+
* the compactor a realistic total-prompt size so it fires when billed input
|
|
115
|
+
* is actually large, not when only `messages[]` is.
|
|
116
|
+
*/
|
|
117
|
+
function computeEnvelopeChars(system, tools) {
|
|
118
|
+
let n = 0;
|
|
119
|
+
if (typeof system === "string")
|
|
120
|
+
n += system.length;
|
|
121
|
+
else if (system && typeof system === "object") {
|
|
122
|
+
try {
|
|
123
|
+
n += JSON.stringify(system).length;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
/* ignore — best-effort estimate */
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (tools && typeof tools === "object") {
|
|
130
|
+
try {
|
|
131
|
+
n += JSON.stringify(tools).length;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
/* ignore */
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return n;
|
|
138
|
+
}
|
|
93
139
|
import { combineAbortSignals, getFinishReason, getStepNumber, getUsage, notifyObserver, toToolCall, toToolResult, } from "./tool-utils.js";
|
|
94
140
|
/**
|
|
95
141
|
* MessageProcessor — extracted streaming turn loop.
|
|
@@ -101,6 +147,15 @@ import { combineAbortSignals, getFinishReason, getStepNumber, getUsage, notifyOb
|
|
|
101
147
|
* Constructed per call (heap allocation is negligible against the streamText
|
|
102
148
|
* cost), matching the StreamRunner / CouncilManager pattern.
|
|
103
149
|
*/
|
|
150
|
+
/**
|
|
151
|
+
* Max response-tool (`respond_*`) calls tolerated within a single turn before
|
|
152
|
+
* the orchestrator finalizes early with the best answer buffered so far. A
|
|
153
|
+
* well-behaved turn emits the response tool ONCE; a hedge-then-answer emits 2.
|
|
154
|
+
* Beyond that is degenerate spam (session 8d8f498268ed: 80× identical
|
|
155
|
+
* respond_general in one generation). Set to 3 so the legitimate ≤2 patterns
|
|
156
|
+
* are never cut short.
|
|
157
|
+
*/
|
|
158
|
+
const RESPONSE_TOOL_SPAM_CAP = 3;
|
|
104
159
|
export class MessageProcessor {
|
|
105
160
|
deps;
|
|
106
161
|
constructor(deps) {
|
|
@@ -126,6 +181,20 @@ export class MessageProcessor {
|
|
|
126
181
|
}
|
|
127
182
|
const signal = deps.getAbortController().signal;
|
|
128
183
|
deps.emitSubagentStatus(null);
|
|
184
|
+
// Phase 5 Fix 1 — reset the per-session step counter at every user-turn
|
|
185
|
+
// boundary. The original Phase 4 design kept the counter per-SESSION so a
|
|
186
|
+
// wandering agent bursting 50 tools across pseudo-turns would still trip
|
|
187
|
+
// the ceiling. In practice that punishes legitimate multi-turn work: turn
|
|
188
|
+
// 1 fills the counter, turn 2 (even a deliberate continuation) is halted
|
|
189
|
+
// almost immediately because the ceiling row may resolve smaller for the
|
|
190
|
+
// continuation's classified task. A new user message is an explicit
|
|
191
|
+
// human-in-the-loop signal — the user has seen results and chose to
|
|
192
|
+
// continue. Reset the counter so each user turn gets the full budget the
|
|
193
|
+
// matrix specifies for its own (taskType, size). Within-turn wandering
|
|
194
|
+
// is still capped by the per-turn ceiling, which is the real concern.
|
|
195
|
+
if (deps.session?.id) {
|
|
196
|
+
resetSessionStep(deps.session.id);
|
|
197
|
+
}
|
|
129
198
|
// Phase C3: advance the cross-turn dedup turn counter so stubs can point
|
|
130
199
|
// back to the correct prior turn.
|
|
131
200
|
deps.crossTurnDedup?.beginTurn();
|
|
@@ -195,6 +264,13 @@ export class MessageProcessor {
|
|
|
195
264
|
};
|
|
196
265
|
signal.addEventListener("abort", aborter, { once: true });
|
|
197
266
|
}
|
|
267
|
+
// Phase 4 Plan 04 (4B) — parse `--budget-rounds N` flag BEFORE PIL so the
|
|
268
|
+
// flag never reaches the model and never biases intent classification.
|
|
269
|
+
// The stashed override is consumed after PIL produces taskType + size.
|
|
270
|
+
const _budgetOverride = parseBudgetOverride(userMessage);
|
|
271
|
+
if (_budgetOverride.override !== undefined) {
|
|
272
|
+
userMessage = _budgetOverride.cleanedPrompt;
|
|
273
|
+
}
|
|
198
274
|
// P0 native observation: cache turn-level intent fields for PreToolUse.
|
|
199
275
|
deps.setTurnUserGoalExcerpt(userMessage.slice(0, 200));
|
|
200
276
|
deps.setTurnAssistantReasoning("");
|
|
@@ -226,32 +302,162 @@ export class MessageProcessor {
|
|
|
226
302
|
const _debugTurnId = deps.messages.filter((m) => m.role === "user").length + 1;
|
|
227
303
|
// PIL: enrich prompt before pushing to messages (D-01, D-03, D-04)
|
|
228
304
|
// Promise.race timeout of 200ms is inside runPipeline — fail-open guaranteed
|
|
305
|
+
// --- PIL with discovery (interactive path) ---
|
|
306
|
+
const pilChunkQueue = [];
|
|
307
|
+
const pilResponder = deps.councilManager.createQuestionResponder();
|
|
308
|
+
const discoveryHandler = {
|
|
309
|
+
askQuestion: async (question) => {
|
|
310
|
+
pilChunkQueue.push({
|
|
311
|
+
type: "council_question",
|
|
312
|
+
content: question.question,
|
|
313
|
+
councilQuestion: question,
|
|
314
|
+
});
|
|
315
|
+
const text = await pilResponder(question.questionId);
|
|
316
|
+
return { questionId: question.questionId, text, kind: "choice" };
|
|
317
|
+
},
|
|
318
|
+
showAcceptance: async (card) => {
|
|
319
|
+
const { buildAcceptanceQuestion } = await import("../pil/layer18-acceptance.js");
|
|
320
|
+
const question = buildAcceptanceQuestion(card, crypto.randomUUID());
|
|
321
|
+
pilChunkQueue.push({
|
|
322
|
+
type: "council_question",
|
|
323
|
+
content: question.question,
|
|
324
|
+
councilQuestion: question,
|
|
325
|
+
});
|
|
326
|
+
const text = await pilResponder(question.questionId);
|
|
327
|
+
return text.toLowerCase();
|
|
328
|
+
},
|
|
329
|
+
};
|
|
229
330
|
const _pilStart = Date.now();
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
331
|
+
let pilCtxResolved = null;
|
|
332
|
+
let pilDone = false;
|
|
333
|
+
const pilTask = (async () => {
|
|
334
|
+
try {
|
|
335
|
+
// Build Pass 4 LLM fallback closure using the orchestrator's already-
|
|
336
|
+
// constructed provider factory + current model. PIL stays ignorant of
|
|
337
|
+
// provider wiring — it just receives a `classify(prompt)` callback.
|
|
338
|
+
let llmFallback;
|
|
339
|
+
try {
|
|
340
|
+
const { createLlmClassifier } = await import("../pil/llm-classify.js");
|
|
341
|
+
llmFallback = createLlmClassifier(deps.requireProvider(), deps.modelId);
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
console.error(`[pil] LLM fallback wiring failed: ${err?.message}`);
|
|
345
|
+
}
|
|
346
|
+
// Model-driven clarification proposer (for discovery interview).
|
|
347
|
+
// The actual task model (via the same provider + modelId) generates the
|
|
348
|
+
// questions based on raw + CLI enrichment. Then discovery asks user.
|
|
349
|
+
let clarificationProposer;
|
|
350
|
+
try {
|
|
351
|
+
const { createModelClarificationProposer } = await import("../pil/discovery.js");
|
|
352
|
+
clarificationProposer = createModelClarificationProposer(deps.requireProvider(), deps.modelId);
|
|
353
|
+
}
|
|
354
|
+
catch (err) {
|
|
355
|
+
console.error(`[pil] clarification proposer wiring failed: ${err?.message}`);
|
|
356
|
+
}
|
|
357
|
+
pilCtxResolved = await runPipeline(userMessage, {
|
|
358
|
+
resumeDigest: deps.getResumeDigest(),
|
|
359
|
+
activeRunId: deps.getActiveRunId(),
|
|
360
|
+
sessionId: deps.session?.id ?? null,
|
|
361
|
+
interactionHandler: discoveryHandler,
|
|
362
|
+
llmFallback,
|
|
363
|
+
clarificationProposer,
|
|
364
|
+
recentTurnsSummary: deps.buildRecentTurnsSummary(),
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
catch (err) {
|
|
368
|
+
pilCtxResolved = {
|
|
369
|
+
raw: userMessage,
|
|
370
|
+
enriched: userMessage,
|
|
371
|
+
taskType: null,
|
|
372
|
+
domain: null,
|
|
373
|
+
confidence: 0,
|
|
374
|
+
outputStyle: null,
|
|
375
|
+
tokenBudget: 500,
|
|
376
|
+
metrics: null,
|
|
377
|
+
layers: [],
|
|
378
|
+
gsdPhase: null,
|
|
379
|
+
activeRunId: null,
|
|
380
|
+
intentKind: null,
|
|
381
|
+
fallbackReason: err instanceof Error ? `orchestrator-catch:${err.name}` : "orchestrator-catch:unknown",
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
finally {
|
|
385
|
+
pilDone = true;
|
|
386
|
+
}
|
|
387
|
+
})();
|
|
388
|
+
while (!pilDone) {
|
|
389
|
+
while (pilChunkQueue.length > 0) {
|
|
390
|
+
yield pilChunkQueue.shift();
|
|
391
|
+
}
|
|
392
|
+
if (!pilDone) {
|
|
393
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
while (pilChunkQueue.length > 0) {
|
|
397
|
+
yield pilChunkQueue.shift();
|
|
398
|
+
}
|
|
399
|
+
await pilTask;
|
|
400
|
+
const pilCtx = pilCtxResolved;
|
|
401
|
+
// Phase 4 Plan 04 (4B) — resolve per-session step ceiling using
|
|
402
|
+
// (task_type × complexitySize) matrix. Override (from --budget-rounds N
|
|
403
|
+
// parsed earlier) wins. When the override differs from the natural
|
|
404
|
+
// ceiling, emit info toast so the user sees the explicit cap.
|
|
405
|
+
//
|
|
406
|
+
// Phase 5 Fix 2 — continuation phrases ("tiếp tục" / "continue") are
|
|
407
|
+
// classified `general/chitchat` by PIL Layer 1 Pass 0. Resolving the
|
|
408
|
+
// ceiling from that label collapses the budget to general × small = 5,
|
|
409
|
+
// which is wrong: the user wants the agent to RESUME the prior task,
|
|
410
|
+
// not start a generic chitchat. When this session has a recorded
|
|
411
|
+
// non-chitchat task row, inherit it for ceiling resolution. The Pass 0
|
|
412
|
+
// classification itself stays general so downstream code (style /
|
|
413
|
+
// chitchat skip / tools-empty optimization in `BUG-A guard`) reads the
|
|
414
|
+
// correct intent; only the ceiling row is borrowed.
|
|
415
|
+
const _pilTaskType = pilCtx.taskType ?? "general";
|
|
416
|
+
const _pilSize = pilCtx.complexitySize?.size ?? "medium";
|
|
417
|
+
const _sessionIdForLastTask = deps.session?.id ?? "";
|
|
418
|
+
const _isContinuationChitchat = _pilTaskType === "general" && pilCtx.intentKind === "chitchat" && _sessionIdForLastTask !== "";
|
|
419
|
+
const _lastTask = _isContinuationChitchat ? getSessionLastTask(_sessionIdForLastTask) : null;
|
|
420
|
+
const _ceilingTaskType = _lastTask?.taskType ?? _pilTaskType;
|
|
421
|
+
const _ceilingSize = _lastTask?.size ?? _pilSize;
|
|
422
|
+
const _naturalCeiling = resolveCeiling(_ceilingTaskType, _ceilingSize);
|
|
423
|
+
// Phase 5 Fix 4 (Option A) — make ceiling mutable so the stopWhen
|
|
424
|
+
// closure can bump it on auto-continue checkpoints. See checkpoint
|
|
425
|
+
// logic at dynamicStopWhen below for the bump policy.
|
|
426
|
+
const _stepCeiling = _budgetOverride.override ?? _naturalCeiling;
|
|
427
|
+
// Record this turn's task row for future continuation inheritance.
|
|
428
|
+
// Only non-chitchat task turns update the slot.
|
|
429
|
+
if (_sessionIdForLastTask && _pilTaskType !== "general" && pilCtx.intentKind === "task") {
|
|
430
|
+
recordSessionLastTask(_sessionIdForLastTask, _pilTaskType, _pilSize);
|
|
431
|
+
}
|
|
432
|
+
if (_budgetOverride.override !== undefined && _budgetOverride.override !== _naturalCeiling) {
|
|
433
|
+
try {
|
|
434
|
+
const _ar = globalThis.__muonroiAgentRuntime;
|
|
435
|
+
_ar?.emitEvent({
|
|
436
|
+
t: "event",
|
|
437
|
+
kind: "toast",
|
|
438
|
+
level: "info",
|
|
439
|
+
text: `override active: ceiling ${_budgetOverride.override}, default was ${_naturalCeiling} (task=${_ceilingTaskType}/size=${_ceilingSize})`,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
/* best-effort */
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
// Track whether forced-finalize is needed (set by stopWhen when the
|
|
447
|
+
// ceiling fires). Read AFTER the streamText fullStream finishes.
|
|
448
|
+
const _ceilingHit = false;
|
|
249
449
|
// Cheap signal forwarded from PIL Layer 1 — true when input is greeting /
|
|
250
450
|
// small-talk (≤10 chars + ≤2 words OR brain-classified "none"). Used to
|
|
251
451
|
// skip the MCP tool catalog, which dominates input tokens (~20K) and is
|
|
252
452
|
// useless for "hi" / "ok" / "thanks".
|
|
253
453
|
const isChitchat = pilCtx.intentKind === "chitchat";
|
|
254
|
-
|
|
454
|
+
let enrichedMessage = pilCtx.enriched;
|
|
455
|
+
if (pilCtx.fallbackReason) {
|
|
456
|
+
// Surface PIL degradation to the model so it can calibrate trust in
|
|
457
|
+
// routing, taskType, and any injected directives. Without this the
|
|
458
|
+
// agent has no idea the 200ms fast-path or discovery timeout fired.
|
|
459
|
+
enrichedMessage = `[PIL fallback: ${pilCtx.fallbackReason} — classification/routing may be inaccurate or layers skipped; using raw input.]\n\n${enrichedMessage}`;
|
|
460
|
+
}
|
|
255
461
|
deps.setPilActive(pilCtx.taskType !== null);
|
|
256
462
|
deps.setPilEnrichmentDelta(pilCtx.metrics?.suffixInstructionTokens ?? Math.round((enrichedMessage.length - userMessage.length) / 4));
|
|
257
463
|
const _pilEnrichmentDeltaSnapshot = pilCtx.metrics?.suffixInstructionTokens ?? Math.round((enrichedMessage.length - userMessage.length) / 4);
|
|
@@ -302,10 +508,16 @@ export class MessageProcessor {
|
|
|
302
508
|
try {
|
|
303
509
|
if (deps.session) {
|
|
304
510
|
const pilDurationMs = Date.now() - _pilStart;
|
|
511
|
+
// BUG-B telemetry — hash the raw user message so post-hoc queries can
|
|
512
|
+
// detect Layer 1 classifier drift on identical inputs within a session.
|
|
513
|
+
const { createHash } = await import("node:crypto");
|
|
514
|
+
const _userMsgSha8 = createHash("sha1").update(userMessage).digest("hex").slice(0, 8);
|
|
305
515
|
logInteraction(deps.session.id, "pil", {
|
|
306
516
|
eventSubtype: pilCtx.taskType ?? "none",
|
|
307
517
|
durationMs: pilDurationMs,
|
|
308
518
|
data: {
|
|
519
|
+
userMsgSha8: _userMsgSha8,
|
|
520
|
+
userMsgPreview: userMessage.slice(0, 60),
|
|
309
521
|
layers: pilCtx.layers?.filter((l) => l.applied).map((l) => l.name) ?? [],
|
|
310
522
|
fullLayers: pilCtx.layers?.map((l) => ({ name: l.name, applied: l.applied, delta: l.delta })) ?? [],
|
|
311
523
|
layerCount: pilCtx.layers?.length ?? 0,
|
|
@@ -407,7 +619,13 @@ export class MessageProcessor {
|
|
|
407
619
|
if (deps.session) {
|
|
408
620
|
logInteraction(deps.session.id, "routing", {
|
|
409
621
|
model: turnModelId,
|
|
410
|
-
data: {
|
|
622
|
+
data: {
|
|
623
|
+
defaultModel: deps.modelId,
|
|
624
|
+
routedModel: turnModelId,
|
|
625
|
+
taskHash,
|
|
626
|
+
pilTaskType: pilCtx.taskType ?? null,
|
|
627
|
+
pilIntentKind: pilCtx.intentKind ?? null,
|
|
628
|
+
},
|
|
411
629
|
});
|
|
412
630
|
}
|
|
413
631
|
}
|
|
@@ -578,20 +796,47 @@ export class MessageProcessor {
|
|
|
578
796
|
// for the current turn. Reset to 0 on each new user turn (we're in processMessage).
|
|
579
797
|
let streamRetryCount = 0;
|
|
580
798
|
const MAX_STREAM_RETRIES = 2; // 3 total attempts = 1 first try + 2 retries
|
|
799
|
+
// Re-steer budget for a tool-call emitted as plain text (wrong dialect). One
|
|
800
|
+
// corrective retry: if the model still emits text instead of invoking the
|
|
801
|
+
// tool, we surface the warning and stop rather than loop. Loop-persistent so
|
|
802
|
+
// a model that degrades every step can't burn unbounded re-steers.
|
|
803
|
+
let textToolReSteerCount = 0;
|
|
804
|
+
const MAX_TEXT_TOOL_RESTEER = 1;
|
|
805
|
+
// Silent-hang guard: set true when the stall watchdog aborts a stuck stream.
|
|
806
|
+
// Reset before each streamText attempt; read in the stream catch to surface a
|
|
807
|
+
// clear toast and SKIP the transient-retry (a stalled provider just stalls
|
|
808
|
+
// again, wasting another full timeout of silence).
|
|
809
|
+
let stallTriggered = false;
|
|
581
810
|
// Auto-council: route to multi-model debate when EITHER
|
|
582
|
-
// (a) PIL classified taskType=plan|analyze with high confidence
|
|
811
|
+
// (a) PIL classified taskType=plan|analyze with high confidence AND the
|
|
812
|
+
// prompt is complex enough to justify the debate cost, OR
|
|
583
813
|
// (b) GSD-native tier === "heavy" (wholesale / multi-step / cross-repo work).
|
|
584
814
|
// After the debate finishes, runCouncilV2 records synthesis on
|
|
585
815
|
// councilManager.lastSynthesis; we then re-enter processMessage with the synthesis
|
|
586
816
|
// as the next user turn so the main loop continues with full debate context.
|
|
587
817
|
// Skip if this is already a council continuation turn (prevent infinite recursion).
|
|
818
|
+
//
|
|
819
|
+
// Phase 5 BUG-I (session f1a2a2a547db) — the gate previously fired on
|
|
820
|
+
// taskType=analyze + conf≥0.85 alone, with no complexity check. Result:
|
|
821
|
+
// "improve test coverage cho src/X.ts" (single-file, scoreComplexity=low,
|
|
822
|
+
// score=2) sank 13 minutes into council debate, then halted on pattern-loop
|
|
823
|
+
// after sprint 1 read 6 files. The complexity gate below bypasses council
|
|
824
|
+
// for low-complexity analyze prompts — they get the hot-path direct exec
|
|
825
|
+
// and stay productive. `plan` keeps the old behaviour (architectural
|
|
826
|
+
// decisions deserve debate regardless of length).
|
|
588
827
|
const autoCouncilTypes = new Set(["plan", "analyze"]);
|
|
589
828
|
const councilRoles = getRoleModels();
|
|
590
829
|
const configuredRoleCount = Object.values(councilRoles).filter(Boolean).length;
|
|
591
830
|
const heavyTier = pilCtx.complexityTier === "heavy";
|
|
592
831
|
const autoCouncilConfidence = getAutoCouncilConfidence();
|
|
593
832
|
const autoCouncilMinRoles = getAutoCouncilMinRoles();
|
|
594
|
-
const
|
|
833
|
+
const _complexityFromTrace = pilCtx._intentTrace
|
|
834
|
+
?.complexity;
|
|
835
|
+
const _complexityGatePassed = pilCtx.taskType === "plan" || _complexityFromTrace === undefined || _complexityFromTrace !== "low";
|
|
836
|
+
const taskTypeMatch = pilCtx.taskType &&
|
|
837
|
+
autoCouncilTypes.has(pilCtx.taskType) &&
|
|
838
|
+
pilCtx.confidence >= autoCouncilConfidence &&
|
|
839
|
+
_complexityGatePassed;
|
|
595
840
|
const shouldAutoCouncil = !deps.councilManager.isContinuation &&
|
|
596
841
|
isAutoCouncilEnabled() &&
|
|
597
842
|
configuredRoleCount >= autoCouncilMinRoles &&
|
|
@@ -611,6 +856,8 @@ export class MessageProcessor {
|
|
|
611
856
|
return `taskType=${pilCtx.taskType ?? "null"} not in plan|analyze`;
|
|
612
857
|
if (pilCtx.confidence < autoCouncilConfidence)
|
|
613
858
|
return `confidence<${autoCouncilConfidence} (got ${pilCtx.confidence.toFixed(2)})`;
|
|
859
|
+
if (!_complexityGatePassed)
|
|
860
|
+
return `complexity=low + taskType=${pilCtx.taskType} (analyze needs medium+; plan bypasses gate)`;
|
|
614
861
|
return "no-trigger";
|
|
615
862
|
}
|
|
616
863
|
return "taken";
|
|
@@ -625,6 +872,8 @@ export class MessageProcessor {
|
|
|
625
872
|
taskType: pilCtx.taskType ?? null,
|
|
626
873
|
confidence: pilCtx.confidence,
|
|
627
874
|
complexityTier: pilCtx.complexityTier ?? null,
|
|
875
|
+
complexityScore: _complexityFromTrace ?? null,
|
|
876
|
+
complexityGatePassed: _complexityGatePassed,
|
|
628
877
|
configuredRoleCount,
|
|
629
878
|
autoCouncilConfidence,
|
|
630
879
|
autoCouncilMinRoles,
|
|
@@ -681,12 +930,20 @@ export class MessageProcessor {
|
|
|
681
930
|
}
|
|
682
931
|
deps.setCompactedThisTurn(false);
|
|
683
932
|
let assistantText = "";
|
|
933
|
+
// Tracks where `assistantText` was at the previous step boundary so
|
|
934
|
+
// `onStepFinish` can compute the text emitted within the just-finished
|
|
935
|
+
// step (input to the self-repetition detector).
|
|
936
|
+
let _assistantTextAtLastStep = 0;
|
|
684
937
|
let reasoningPreview = "";
|
|
685
938
|
let encryptedReasoningHidden = false;
|
|
686
939
|
let streamOk = false;
|
|
687
940
|
let closeMcp;
|
|
688
941
|
let stepNumber = -1;
|
|
689
942
|
const activeToolCalls = [];
|
|
943
|
+
// Capped digest of tool outputs gathered this attempt — fuels the
|
|
944
|
+
// best-effort answer rescue if the stream stalls mid-turn (see
|
|
945
|
+
// stall-rescue.ts). Reset per attempt; only the most recent results win.
|
|
946
|
+
const turnToolResults = [];
|
|
690
947
|
// SAMR: track whether Phase 1 produced tool calls
|
|
691
948
|
let phase1HadToolCalls = false;
|
|
692
949
|
try {
|
|
@@ -696,12 +953,23 @@ export class MessageProcessor {
|
|
|
696
953
|
if (modelInfo?.contextWindow) {
|
|
697
954
|
await deps.compactForContext(provider, system, modelInfo.contextWindow, signal, settings, attemptedOverflowRecovery);
|
|
698
955
|
}
|
|
956
|
+
// Vision-tool gate: for vision-proxy (text-only) models the registry
|
|
957
|
+
// adds 3 image tools (~500-700 tok) on every turn. Drop them when the
|
|
958
|
+
// turn has no plausible image involvement. Bias is KEEP — retained on
|
|
959
|
+
// any image signal, attachment, cached image, or prior-tool turn.
|
|
960
|
+
const includeVisionTools = visionToolsNeeded({
|
|
961
|
+
userMessage,
|
|
962
|
+
messages: deps.messages,
|
|
963
|
+
cachedImageCount: listCachedImages().length,
|
|
964
|
+
priorTurnHadTools: deps.messages.some((m) => m?.role === "tool"),
|
|
965
|
+
});
|
|
699
966
|
const baseToolsRaw = createBuiltinTools(deps.bash, deps.mode, {
|
|
700
967
|
runTask: (request, abortSignal) => deps.runTask(request, combineAbortSignals(signal, abortSignal)),
|
|
701
968
|
runDelegation: (request, abortSignal) => deps.runDelegation(request, combineAbortSignals(signal, abortSignal)),
|
|
702
969
|
readDelegation: (id) => deps.readDelegation(id),
|
|
703
970
|
listDelegations: () => deps.listDelegations(),
|
|
704
971
|
modelId: turnModelId,
|
|
972
|
+
includeVisionTools,
|
|
705
973
|
});
|
|
706
974
|
// Top-level cumulative cap state. We accumulate the raw tool set
|
|
707
975
|
// (base + MCP + PIL response tools) across the assembly below,
|
|
@@ -712,44 +980,96 @@ export class MessageProcessor {
|
|
|
712
980
|
// never needs bash/read_file/edit_file/grep — those schemas alone
|
|
713
981
|
// cost ~1.5K input tokens on this CLI. Falls back to baseTools for
|
|
714
982
|
// every non-chitchat turn (PIL gates conservatively).
|
|
715
|
-
|
|
983
|
+
//
|
|
984
|
+
// BUG-A guard — when prior turns already issued tool_calls (their
|
|
985
|
+
// results still live in the messages history), DROPPING tools on a
|
|
986
|
+
// continuation chitchat ("tiếp tục" / "continue") causes two
|
|
987
|
+
// failures: (1) DeepSeek goes into native DSML markup fallback
|
|
988
|
+
// because it sees tool-call history but no schema (visible in
|
|
989
|
+
// sessions 002df4014cb4 + fc19b4daee20); (2) the agent has no way
|
|
990
|
+
// to actually CONTINUE the prior task — the user's clear intent.
|
|
991
|
+
// Detect prior-tool-context and keep the base tool set in that
|
|
992
|
+
// case. The 1.5K token saving for true greetings (no prior tool
|
|
993
|
+
// history) is preserved.
|
|
994
|
+
const turnCaps = getProviderCapabilities(requireRuntimeProvider(runtime));
|
|
995
|
+
const _priorTurnHadTools = deps.messages.some((m) => m?.role === "tool");
|
|
716
996
|
let rawToolSet = !turnCaps.supportsClientTools(runtime.modelInfo)
|
|
717
997
|
? {}
|
|
718
|
-
: isChitchat
|
|
998
|
+
: isChitchat && !_priorTurnHadTools
|
|
719
999
|
? {}
|
|
720
1000
|
: baseToolsRaw;
|
|
721
1001
|
// MCP skip: chitchat / greeting inputs don't need 7 MCP servers'
|
|
722
1002
|
// worth of tool schemas (~20K input tokens). PIL Layer 1 already
|
|
723
1003
|
// gates this conservatively (≤10 chars + ≤2 words OR brain "none").
|
|
724
|
-
if (deps.mode === "agent" &&
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
//
|
|
728
|
-
//
|
|
729
|
-
//
|
|
1004
|
+
if (deps.mode === "agent" &&
|
|
1005
|
+
(!isChitchat || _priorTurnHadTools) &&
|
|
1006
|
+
turnCaps.supportsClientTools(runtime.modelInfo)) {
|
|
1007
|
+
// Smart MCP filter: drop OPTIONAL MCP servers whose category the
|
|
1008
|
+
// current message gives no signal for. Browser/vision servers
|
|
1009
|
+
// (Playwright/Chrome/Figma/Canva) skip unless the message touches a
|
|
1010
|
+
// page; docs/web servers (context7/fetch) skip unless the message
|
|
1011
|
+
// looks like an external lookup. Each MCP contributes 8-15 tools at
|
|
1012
|
+
// ~150 tok each, so local code work — the majority of turns — saves
|
|
1013
|
+
// ~13K input tokens it would otherwise pay every turn. Domain
|
|
1014
|
+
// servers (filesystem/tools/harness) always pass through. Logic is
|
|
1015
|
+
// a pure helper (src/mcp/smart-filter.ts) so it is unit-tested.
|
|
730
1016
|
// Override with MUONROI_DISABLE_SMART_MCP=1.
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
const SKIP_WHEN_NO_BROWSER = /playwright|chrome|browser|devtools|vision|figma|canva/i;
|
|
734
|
-
const allServers = loadMcpServers();
|
|
735
|
-
const filteredServers = smartMcp && !browserSignal ? allServers.filter((s) => !SKIP_WHEN_NO_BROWSER.test(s.id)) : allServers;
|
|
736
|
-
const mcpBundle = await buildMcpToolSet(filteredServers, {
|
|
737
|
-
onOAuthRequired: (_serverId, url) => {
|
|
738
|
-
const urlStr = url.toString();
|
|
739
|
-
import("child_process").then(({ exec }) => {
|
|
740
|
-
const cmd = process.platform === "win32"
|
|
741
|
-
? `start "" "${urlStr}"`
|
|
742
|
-
: process.platform === "darwin"
|
|
743
|
-
? `open "${urlStr}"`
|
|
744
|
-
: `xdg-open "${urlStr}"`;
|
|
745
|
-
exec(cmd);
|
|
746
|
-
});
|
|
747
|
-
},
|
|
1017
|
+
const filteredServers = filterMcpServersByMessage(loadMcpServers(), userMessage, {
|
|
1018
|
+
disabled: process.env.MUONROI_DISABLE_SMART_MCP === "1",
|
|
748
1019
|
});
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
1020
|
+
// MCP non-blocking: race the build against a 2500ms cap so a slow
|
|
1021
|
+
// stdio MCP server spawn (or many optional servers) does not block
|
|
1022
|
+
// the main turn's first token / streamText indefinitely. On timeout
|
|
1023
|
+
// or error we fall back to builtins only (domain servers like fs/tools
|
|
1024
|
+
// are still valuable but the optional ones can be skipped for this turn).
|
|
1025
|
+
let mcpBundle = null;
|
|
1026
|
+
try {
|
|
1027
|
+
mcpBundle = await Promise.race([
|
|
1028
|
+
buildMcpToolSet(filteredServers, {
|
|
1029
|
+
onOAuthRequired: (_serverId, url) => {
|
|
1030
|
+
const urlStr = url.toString();
|
|
1031
|
+
import("child_process").then(({ exec }) => {
|
|
1032
|
+
const cmd = process.platform === "win32"
|
|
1033
|
+
? `start "" "${urlStr}"`
|
|
1034
|
+
: process.platform === "darwin"
|
|
1035
|
+
? `open "${urlStr}"`
|
|
1036
|
+
: `xdg-open "${urlStr}"`;
|
|
1037
|
+
exec(cmd);
|
|
1038
|
+
});
|
|
1039
|
+
},
|
|
1040
|
+
}),
|
|
1041
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("MCP build timeout (2500ms)")), 2500)),
|
|
1042
|
+
]);
|
|
1043
|
+
}
|
|
1044
|
+
catch (err) {
|
|
1045
|
+
console.error("[MCP] buildMcpToolSet timed out or failed, proceeding with builtins only", err);
|
|
1046
|
+
}
|
|
1047
|
+
if (mcpBundle) {
|
|
1048
|
+
closeMcp = mcpBundle.close;
|
|
1049
|
+
// Drop filesystem-MCP read/write/edit tools that duplicate the
|
|
1050
|
+
// first-class builtin file tools. Without this, models re-read the
|
|
1051
|
+
// SAME file via both `read_file` and `mcp_filesystem__read_text_file`
|
|
1052
|
+
// (live grok session f5dfab0ce0ca: a 772-line file read 6×), wasting
|
|
1053
|
+
// ~150 tok/schema PLUS re-injecting whole files into context. The
|
|
1054
|
+
// builtins are strictly better (read-before-write, LSP, CRLF match,
|
|
1055
|
+
// dedup/read-budget wrappers). Non-duplicate fs tools are untouched.
|
|
1056
|
+
const _builtinToolNames = new Set(Object.keys(rawToolSet));
|
|
1057
|
+
const { tools: _dedupedMcpTools, dropped: _droppedFsMcp } = dropRedundantFsMcpTools(mcpBundle.tools, _builtinToolNames);
|
|
1058
|
+
rawToolSet = { ...rawToolSet, ..._dedupedMcpTools };
|
|
1059
|
+
if (_droppedFsMcp.length > 0 && deps.session) {
|
|
1060
|
+
try {
|
|
1061
|
+
logInteraction(deps.session.id, "routing", {
|
|
1062
|
+
model: turnModelId,
|
|
1063
|
+
data: { droppedRedundantFsMcp: _droppedFsMcp },
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
catch {
|
|
1067
|
+
/* telemetry best-effort */
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
if (mcpBundle.errors.length > 0) {
|
|
1071
|
+
yield { type: "content", content: `MCP unavailable: ${mcpBundle.errors.join(" | ")}\n\n` };
|
|
1072
|
+
}
|
|
753
1073
|
}
|
|
754
1074
|
}
|
|
755
1075
|
// PIL response tools: inject structured output tool when taskType detected
|
|
@@ -769,6 +1089,19 @@ export class MessageProcessor {
|
|
|
769
1089
|
const tools = wrapToolSetWithReadBudget(wrapToolSetWithDedup(topLevelCap.tools, deps.crossTurnDedup), deps.readBudget);
|
|
770
1090
|
captureToolSchemas(tools);
|
|
771
1091
|
let responseToolCalled = false;
|
|
1092
|
+
// A turn must surface exactly ONE final structured answer. Cheap
|
|
1093
|
+
// models sometimes emit the response tool MORE THAN ONCE in a single
|
|
1094
|
+
// step (session 9b1b39bf4dc6: grok emitted respond_general twice —
|
|
1095
|
+
// a 278-char "I must read the code" hedge, then the 3782-char real
|
|
1096
|
+
// answer — both in one step). Yielding each inline appends two
|
|
1097
|
+
// stacked structured_response blocks and shows the hedge first.
|
|
1098
|
+
// Instead we BUFFER the response-tool payloads and yield only the
|
|
1099
|
+
// most complete one (longest serialized data) after the stream
|
|
1100
|
+
// drains — robust to either ordering (hedge-then-answer or
|
|
1101
|
+
// answer-then-summary).
|
|
1102
|
+
let _pendingStructuredResponse = null;
|
|
1103
|
+
let _pendingStructuredResponseLen = -1;
|
|
1104
|
+
let _responseToolEmitCount = 0;
|
|
772
1105
|
// G3: providerOptions assembly is owned by the capability layer
|
|
773
1106
|
// (src/providers/capabilities.ts). buildTurnProviderOptions feeds
|
|
774
1107
|
// sessionId in so openai.promptCacheKey is derived per turn.
|
|
@@ -810,6 +1143,32 @@ export class MessageProcessor {
|
|
|
810
1143
|
// Top-level dropParam — shared with sub-agent path via shouldDropParam.
|
|
811
1144
|
// See src/providers/runtime.ts for the central rule.
|
|
812
1145
|
const dropParam = (p) => shouldDropParam(runtime, p);
|
|
1146
|
+
// Tier-aware behavioural suffix. Cheap models (DeepSeek V4 Flash etc.)
|
|
1147
|
+
// ignore well-worded tool descriptions but DO adopt instructions when
|
|
1148
|
+
// surfaced in the system prompt. Smart models don't need this — gated
|
|
1149
|
+
// by `modelInfo.tier === "fast"`. See cheap-model-playbook.ts for
|
|
1150
|
+
// motivation + escape hatch (MUONROI_DISABLE_CHEAP_MODEL_PLAYBOOK=1).
|
|
1151
|
+
// Fast-tier steering, front-loaded for primacy: task convergence
|
|
1152
|
+
// workbook (anti-ramble — cuts tool-call count, the dominant
|
|
1153
|
+
// cheap-model cost) layered UNDER the tool-use playbook so the
|
|
1154
|
+
// CRITICAL tool rules stay at the very front. Both fixed per turn, so
|
|
1155
|
+
// they stay inside the cached prefix.
|
|
1156
|
+
const systemWithWorkbook = shouldInjectCheapModelWorkbook(runtime.modelInfo)
|
|
1157
|
+
? injectCheapModelWorkbook(system, pilCtx.taskType)
|
|
1158
|
+
: system;
|
|
1159
|
+
const systemWithPlaybook = shouldInjectCheapModelPlaybook(runtime.modelInfo)
|
|
1160
|
+
? injectCheapModelPlaybook(systemWithWorkbook)
|
|
1161
|
+
: systemWithWorkbook;
|
|
1162
|
+
// A2: front-load a one-line shell/env directive for fast-tier models.
|
|
1163
|
+
// The authoritative ENVIRONMENT block already states OS/shell/cwd in
|
|
1164
|
+
// the prompt body, but budget models underweight non-front-loaded
|
|
1165
|
+
// rules — so echo the correct-syntax line at the very front. Derived
|
|
1166
|
+
// from resolveShell({}) (same source as buildEnvironmentBlock) so it
|
|
1167
|
+
// is always accurate to the actual shell the bash tool will spawn.
|
|
1168
|
+
// Gated to fast tier, so the claude branch below still sees `system`.
|
|
1169
|
+
const systemWithShell = shouldInjectCheapModelPlaybook(runtime.modelInfo)
|
|
1170
|
+
? injectCheapModelShellDirective(systemWithPlaybook, cheapModelShellLine(resolveShell({}).kind, process.platform))
|
|
1171
|
+
: systemWithPlaybook;
|
|
813
1172
|
const systemForModel = runtime.modelId.startsWith("claude")
|
|
814
1173
|
? [
|
|
815
1174
|
{
|
|
@@ -817,9 +1176,12 @@ export class MessageProcessor {
|
|
|
817
1176
|
content: systemParts.staticPrefix,
|
|
818
1177
|
providerOptions: { anthropic: { cacheControl: { type: "ephemeral" } } },
|
|
819
1178
|
},
|
|
820
|
-
{
|
|
1179
|
+
{
|
|
1180
|
+
role: "system",
|
|
1181
|
+
content: systemWithShell.slice(systemParts.staticPrefix.length),
|
|
1182
|
+
},
|
|
821
1183
|
]
|
|
822
|
-
:
|
|
1184
|
+
: systemWithShell;
|
|
823
1185
|
// Capture prompt-size breakdown so recordUsage can attach it to the
|
|
824
1186
|
// cost-log entry. Without this, "system prompt is huge" is unfalsifiable.
|
|
825
1187
|
// chars/4 ≈ tokens for English; reported as chars to keep math obvious.
|
|
@@ -869,6 +1231,11 @@ export class MessageProcessor {
|
|
|
869
1231
|
// Task 2.6a — assign a fresh correlation ID for this top-level streamText call.
|
|
870
1232
|
const _topCallId = crypto.randomUUID();
|
|
871
1233
|
deps.setCurrentCallId(_topCallId);
|
|
1234
|
+
// Capture finishReason so we can surface "round cap hit" as a visible
|
|
1235
|
+
// toast — without this, the agent silently stops mid-flight when
|
|
1236
|
+
// stepCountIs(maxToolRounds) fires and the user sees the TUI freeze
|
|
1237
|
+
// (session 7dcf8fd7d6a4 hit exactly 100 rounds → looked like a crash).
|
|
1238
|
+
let _lastFinishReason = null;
|
|
872
1239
|
// Phase B4: compact older tool_result parts before each top-level
|
|
873
1240
|
// step once cumulative message chars exceed the configured threshold.
|
|
874
1241
|
// The compactor preserves system + first user verbatim and keeps the
|
|
@@ -890,32 +1257,333 @@ export class MessageProcessor {
|
|
|
890
1257
|
providerOptions: providerOpts,
|
|
891
1258
|
});
|
|
892
1259
|
}
|
|
893
|
-
//
|
|
894
|
-
//
|
|
895
|
-
// via
|
|
1260
|
+
// sanitizeHistory is identity for every provider (kept as a hook
|
|
1261
|
+
// for future provider-specific quirks). Reasoning round-trips
|
|
1262
|
+
// natively via @ai-sdk/openai-compatible — see
|
|
1263
|
+
// src/providers/__tests__/reasoning-roundtrip.test.ts.
|
|
896
1264
|
const _topMessagesForCall = turnCaps.sanitizeHistory(deps.messages);
|
|
1265
|
+
// Closure-mutable cap for the tool-loop askcard rescue.
|
|
1266
|
+
// Phase 1 (SAMR) skips the dynamic cap (it's a single-step path).
|
|
1267
|
+
// Algorithm extracted to ./tool-loop-cap.ts so it can be unit-tested.
|
|
1268
|
+
const _baseDynamicStopWhen = createToolLoopCapPredicate({
|
|
1269
|
+
initialCap: deps.maxToolRounds,
|
|
1270
|
+
ask: deps.askToolLoopContinue,
|
|
1271
|
+
// Phase 5 BUG-H — thread the resolved natural ceiling down so the
|
|
1272
|
+
// pattern askcard can pick a context-aware default action (continue
|
|
1273
|
+
// early in the run, stop once we're past 50% of the natural budget).
|
|
1274
|
+
naturalCeiling: _naturalCeiling,
|
|
1275
|
+
});
|
|
1276
|
+
// Phase 4 Plan 04 (4B) — compose per-session ceiling alongside the
|
|
1277
|
+
// existing cap + pattern guard. Logical OR: any condition true → halt.
|
|
1278
|
+
// Counter is per-SESSION and increments once per stopWhen invocation
|
|
1279
|
+
// (i.e. once per finished tool step), persisting across user turns
|
|
1280
|
+
// so a wandering 3-turn burst still trips at the matrix limit.
|
|
1281
|
+
const _ceilingSessionId = deps.session?.id ?? "no-session";
|
|
1282
|
+
// Phase 5 Fix 3 — capture the actual step number when the ceiling
|
|
1283
|
+
// trips so the halt toast can report the real value, not the
|
|
1284
|
+
// ceiling/ceiling literal that always showed e.g. "5/5" regardless
|
|
1285
|
+
// of how many steps the turn actually ran.
|
|
1286
|
+
const _ceilingHitAtStep = 0;
|
|
1287
|
+
// Phase 5 Fix 5 — matrix ceiling is now a SOFT BOUNDARY, never a
|
|
1288
|
+
// hard halt. Phase 4's hard halt was a blunt anti-wandering
|
|
1289
|
+
// measure that also blocked legitimate multi-step work: every
|
|
1290
|
+
// long task (improve coverage, optimize startup, refactor) ran
|
|
1291
|
+
// out of budget mid-flight and required the user to manually
|
|
1292
|
+
// type "tiếp tục". Wrong philosophy — "done" must be the agent's
|
|
1293
|
+
// call, not the counter's.
|
|
1294
|
+
//
|
|
1295
|
+
// What replaced the hard halt:
|
|
1296
|
+
// - Scope-reminders (4A path, prepareStep above) inject
|
|
1297
|
+
// "[approaching ceiling]" reminder at floor(ceiling*0.7) and
|
|
1298
|
+
// repeat at K cadence. Past the ceiling, every step gets a
|
|
1299
|
+
// re-anchor so the model is repeatedly nudged toward closure.
|
|
1300
|
+
// - The dynamicStopWhen no longer checks the matrix ceiling at
|
|
1301
|
+
// all. The only halt source is `_baseDynamicStopWhen` which
|
|
1302
|
+
// enforces `deps.maxToolRounds` as the ULTIMATE runaway safety
|
|
1303
|
+
// net (default raised; see CLI default).
|
|
1304
|
+
// - 4R bash repeat detector still catches the dominant wandering
|
|
1305
|
+
// pattern (identical command twice in a row).
|
|
1306
|
+
// - F6 synthesis still ensures any natural stream-end without
|
|
1307
|
+
// text gets a final summary.
|
|
1308
|
+
//
|
|
1309
|
+
// _ceilingHit and _ceilingHitAtStep are kept for telemetry: a
|
|
1310
|
+
// crossing event is logged for forensics, but no action is taken.
|
|
1311
|
+
const dynamicStopWhen = (async (state) => {
|
|
1312
|
+
// Terminal response tool: a `respond_*` call IS the model's final
|
|
1313
|
+
// structured answer (its `execute` is identity — the payload lives
|
|
1314
|
+
// in the tool-call args). `shouldHaltOnResponseTool` decides if the
|
|
1315
|
+
// emission is terminal vs a premature "blind" announce:
|
|
1316
|
+
// - response tool AFTER real tool work (read/grep/bash) → terminal,
|
|
1317
|
+
// halt now (kills d95113d3be09 seq=27: 7 reads → 87× respond loop
|
|
1318
|
+
// at call #1, no extra round-trip for the common case).
|
|
1319
|
+
// - a single blind response (no prior investigation) → do NOT halt;
|
|
1320
|
+
// give the model the step it announced it would use to read code
|
|
1321
|
+
// (session e4a9d97a90: lone blind respond_general was force-stopped
|
|
1322
|
+
// by the old halt-on-first rule and the agent never investigated).
|
|
1323
|
+
// - a 2nd blind response with still no real work → narration loop,
|
|
1324
|
+
// halt. In-step spam (80× in one generation) is bounded separately
|
|
1325
|
+
// by RESPONSE_TOOL_SPAM_CAP — stopWhen only runs BETWEEN steps.
|
|
1326
|
+
// Read from `state.steps` (the SDK's own per-step record) rather than
|
|
1327
|
+
// the for-await consumer's `responseToolCalled` flag — stopWhen runs
|
|
1328
|
+
// between steps and may evaluate before our consumer processed the
|
|
1329
|
+
// tool-result part, so the flag would race.
|
|
1330
|
+
const _steps = state.steps;
|
|
1331
|
+
if (shouldHaltOnResponseTool(_steps))
|
|
1332
|
+
return true;
|
|
1333
|
+
const base = await _baseDynamicStopWhen(state);
|
|
1334
|
+
if (base)
|
|
1335
|
+
return true;
|
|
1336
|
+
const next = incSessionStep(_ceilingSessionId);
|
|
1337
|
+
// Telemetry-only: record the first time the counter crosses
|
|
1338
|
+
// the matrix ceiling, so post-hoc queries can correlate the
|
|
1339
|
+
// ceiling crossing with task completion outcomes. No halt.
|
|
1340
|
+
if (next === _stepCeiling) {
|
|
1341
|
+
try {
|
|
1342
|
+
if (deps.session?.id) {
|
|
1343
|
+
logInteraction(deps.session.id, "f6_synthesis", {
|
|
1344
|
+
data: {
|
|
1345
|
+
outcome: "ceiling_crossed_softly",
|
|
1346
|
+
stepAtCrossing: next,
|
|
1347
|
+
naturalCeiling: _naturalCeiling,
|
|
1348
|
+
taskType: _ceilingTaskType,
|
|
1349
|
+
size: _ceilingSize,
|
|
1350
|
+
hardCapMaxToolRounds: deps.maxToolRounds,
|
|
1351
|
+
},
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
catch {
|
|
1356
|
+
/* telemetry only */
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
return false;
|
|
1360
|
+
});
|
|
1361
|
+
// BUG-A fix — when this turn carries an empty tool set (the
|
|
1362
|
+
// chitchat optimization at line ~1107 drops all schemas), AI SDK
|
|
1363
|
+
// sends `tools:[], tool_choice:undefined` to the provider. DeepSeek
|
|
1364
|
+
// V4 Flash sees prior `tool_call`/`tool_result` parts still in the
|
|
1365
|
+
// messages history (the previous turn used 20 tools) and the
|
|
1366
|
+
// model stays in agent-mode — but with no schema to call, it
|
|
1367
|
+
// falls back to its NATIVE DSML markup syntax and emits that as
|
|
1368
|
+
// plain text. AI SDK does not parse the native format, so the
|
|
1369
|
+
// markup leaks straight to the TUI as garbage and the turn
|
|
1370
|
+
// produces no useful output. Setting `toolChoice:"none"` is the
|
|
1371
|
+
// canonical way to tell the model "you cannot call tools this
|
|
1372
|
+
// turn" so it emits text-only. Verified by stream_start telemetry
|
|
1373
|
+
// on sessions 002df4014cb4 (leak) + fc19b4daee20 (leak): both had
|
|
1374
|
+
// toolCount=0 + toolChoice=undefined on chitchat continuation.
|
|
1375
|
+
const _toolsAreEmpty = Object.keys(tools).length === 0;
|
|
1376
|
+
const _finalToolChoice = _toolsAreEmpty
|
|
1377
|
+
? "none"
|
|
1378
|
+
: _hasResponseTools && turnCaps.supportsClientTools(runtime.modelInfo)
|
|
1379
|
+
? "auto"
|
|
1380
|
+
: undefined;
|
|
1381
|
+
// BUG-C telemetry — record tool availability + toolChoice at the
|
|
1382
|
+
// call site so future regressions show up in telemetry not in TUI.
|
|
1383
|
+
try {
|
|
1384
|
+
const _toolNamesAtCall = Object.keys(tools);
|
|
1385
|
+
logInteraction(deps.session?.id ?? "no-session", "stream_start", {
|
|
1386
|
+
model: turnModelId,
|
|
1387
|
+
data: {
|
|
1388
|
+
toolCount: _toolNamesAtCall.length,
|
|
1389
|
+
hasBash: _toolNamesAtCall.includes("bash"),
|
|
1390
|
+
toolNames: _toolNamesAtCall.slice(0, 25),
|
|
1391
|
+
toolChoice: _finalToolChoice ?? "undefined",
|
|
1392
|
+
hasResponseTools: _hasResponseTools,
|
|
1393
|
+
supportsClientTools: turnCaps.supportsClientTools(runtime.modelInfo),
|
|
1394
|
+
priorTurnHadTools: _topMessagesForCall.some((m) => m?.role === "tool"),
|
|
1395
|
+
},
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
catch {
|
|
1399
|
+
/* telemetry only */
|
|
1400
|
+
}
|
|
1401
|
+
// Silent-hang guard: abort the stream (and surface a toast in the
|
|
1402
|
+
// catch below) if the provider sends no chunk for too long. Re-armed
|
|
1403
|
+
// on every chunk via stall.pet(), so it never kills an actively
|
|
1404
|
+
// streaming call. Disposed when the stream ends or errors.
|
|
1405
|
+
stallTriggered = false;
|
|
1406
|
+
const stall = createStallWatchdog(getProviderStallTimeoutMs(), () => {
|
|
1407
|
+
stallTriggered = true;
|
|
1408
|
+
});
|
|
897
1409
|
const result = streamText({
|
|
898
1410
|
model: runtime.model,
|
|
899
1411
|
system: systemForModel,
|
|
900
1412
|
messages: _topMessagesForCall,
|
|
901
1413
|
tools,
|
|
902
|
-
toolChoice:
|
|
903
|
-
stopWhen: stepRouterPhase === "phase1"
|
|
904
|
-
? stepCountIs(1) // SAMR Phase 1: stop after reasoning step
|
|
905
|
-
: stepCountIs(deps.maxToolRounds),
|
|
1414
|
+
toolChoice: _finalToolChoice,
|
|
1415
|
+
stopWhen: stepRouterPhase === "phase1" ? stepCountIs(1) : dynamicStopWhen,
|
|
906
1416
|
maxRetries: 0,
|
|
907
|
-
abortSignal: signal,
|
|
1417
|
+
abortSignal: combineAbortSignals(signal, stall.signal),
|
|
1418
|
+
// Repair malformed tool-call JSON args before they bubble up as
|
|
1419
|
+
// InvalidToolInputError → tool-error → repetition-detector abort.
|
|
1420
|
+
// Conservative: only fixes the two observed Qwen-style defects.
|
|
1421
|
+
// See src/orchestrator/tool-args-repair.ts for the transforms.
|
|
1422
|
+
experimental_repairToolCall: repairToolCallHook,
|
|
908
1423
|
prepareStep: ({ stepNumber: sn, messages: stepMessages }) => {
|
|
909
1424
|
if (sn < 1)
|
|
910
1425
|
return {};
|
|
911
1426
|
const stripped = turnCaps.sanitizeHistory(stepMessages);
|
|
1427
|
+
// Agent-controlled veto (PRESERVE) or lighter selective keep (KEEP_TOOL_IDS) for this turn's B4 compaction.
|
|
1428
|
+
// PRESERVE_FULL_CONTEXT skips the compactor entirely (full history).
|
|
1429
|
+
// KEEP_TOOL_IDS: id1,id2 (from prior stub " (id=...) ") protects only those specific tool results
|
|
1430
|
+
// without the cost of a full veto. Parsed from reasoning or assistant note.
|
|
1431
|
+
let keepToolIds = [];
|
|
1432
|
+
const hasPreserve = stripped.some((m) => {
|
|
1433
|
+
const c = m?.content;
|
|
1434
|
+
const texts = [];
|
|
1435
|
+
if (typeof c === "string")
|
|
1436
|
+
texts.push(c);
|
|
1437
|
+
if (Array.isArray(c)) {
|
|
1438
|
+
for (const p of c)
|
|
1439
|
+
if (typeof p?.text === "string")
|
|
1440
|
+
texts.push(p.text);
|
|
1441
|
+
}
|
|
1442
|
+
const joined = texts.join(" ");
|
|
1443
|
+
if (joined.includes("PRESERVE_FULL_CONTEXT"))
|
|
1444
|
+
return true;
|
|
1445
|
+
// Idea 3: parse lighter token
|
|
1446
|
+
const mKeep = joined.match(/KEEP_TOOL_IDS\s*[:=]\s*([a-z0-9_, -]+)/i);
|
|
1447
|
+
if (mKeep) {
|
|
1448
|
+
keepToolIds = mKeep[1]
|
|
1449
|
+
.split(/[,\s]+/)
|
|
1450
|
+
.map((s) => s.trim())
|
|
1451
|
+
.filter(Boolean);
|
|
1452
|
+
}
|
|
1453
|
+
return false;
|
|
1454
|
+
});
|
|
1455
|
+
if (hasPreserve) {
|
|
1456
|
+
return { messages: stripped };
|
|
1457
|
+
}
|
|
1458
|
+
// F2 — envelope = system prompt + JSON-Schema of every tool
|
|
1459
|
+
// re-sent on every step. Without this the threshold check
|
|
1460
|
+
// ignored 20-50K of fixed prompt overhead and the compactor
|
|
1461
|
+
// sat dormant just below its limit while billed input climbed.
|
|
1462
|
+
const envelopeChars = computeEnvelopeChars(systemForModel, tools);
|
|
1463
|
+
// G1 + G2 — feed the model's context window so the compactor
|
|
1464
|
+
// can pick a token-aware threshold and shrink keepLastTurns
|
|
1465
|
+
// when the window is approaching its ceiling.
|
|
1466
|
+
const contextWindowTokens = runtime.modelInfo?.contextWindow ?? 0;
|
|
1467
|
+
// Idea 4: fire-and-forget persist of elided tool outputs to EE (source=tool-artifact)
|
|
1468
|
+
// so later layer3/ee.query "tool-artifact id=xxx" or "full tool result id=..." can re-hydrate.
|
|
1469
|
+
// Use process-level fallbacks (prepareStep closure does not directly expose outer cwd/session in this scope).
|
|
1470
|
+
const _cwd = process.cwd();
|
|
1471
|
+
const _sess = undefined; // best-effort; EE artifact still indexable by content + meta.toolCallId
|
|
1472
|
+
const persistArtifact = (toolCallId, toolName, fullContent, reason) => {
|
|
1473
|
+
try {
|
|
1474
|
+
getDefaultEEClient()
|
|
1475
|
+
.extract({
|
|
1476
|
+
transcript: fullContent.slice(0, 8000),
|
|
1477
|
+
projectPath: _cwd,
|
|
1478
|
+
meta: {
|
|
1479
|
+
source: "tool-artifact",
|
|
1480
|
+
toolCallId,
|
|
1481
|
+
toolName,
|
|
1482
|
+
reason,
|
|
1483
|
+
sessionId: _sess,
|
|
1484
|
+
elidedAtStep: sn,
|
|
1485
|
+
},
|
|
1486
|
+
}, AbortSignal.timeout(700))
|
|
1487
|
+
.catch(() => { });
|
|
1488
|
+
}
|
|
1489
|
+
catch {
|
|
1490
|
+
/* fail-open, no silent swallow of the decision */
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
912
1493
|
const compacted = compactSubAgentMessages(stripped, {
|
|
913
1494
|
thresholdChars: topLevelCompactThreshold,
|
|
914
1495
|
keepLastTurns: topLevelCompactKeepLast,
|
|
915
1496
|
label: "top-level",
|
|
1497
|
+
envelopeChars,
|
|
1498
|
+
contextWindowTokens,
|
|
1499
|
+
keepToolIds: keepToolIds.length ? keepToolIds : undefined,
|
|
1500
|
+
persistArtifact,
|
|
916
1501
|
});
|
|
1502
|
+
// Pre-compaction visibility: give the agent one step of notice
|
|
1503
|
+
// before B4 actually rewrites history into stubs. This is the
|
|
1504
|
+
// advance warning that was missing — agent can now decide to
|
|
1505
|
+
// summarize, finish, or request preservation.
|
|
1506
|
+
const _preCompactWarnAt = Math.floor(topLevelCompactThreshold * 0.78);
|
|
1507
|
+
if (stripped.length > _preCompactWarnAt && compacted === stripped) {
|
|
1508
|
+
const _cp = buildCheckpointReminder(sn, true);
|
|
1509
|
+
const _pre = `[pre-compaction warning at step ${sn} — next step(s) will likely rewrite older tool results to stubs (threshold ${topLevelCompactThreshold}, keepLast=${topLevelCompactKeepLast}). ${_cp} Summarize or finish if possible.]`;
|
|
1510
|
+
return { messages: attachReminderToMessages(stripped, _pre) };
|
|
1511
|
+
}
|
|
1512
|
+
// Phase 4A — scope reminder injection (REQ-005).
|
|
1513
|
+
// Cadence K = 3/5/8 for small/medium/large. Soft-warn fires
|
|
1514
|
+
// ONCE per session at floor(ceiling*0.7). Reminder lives in
|
|
1515
|
+
// the tool_result/system channel so B3/B4 compaction cannot
|
|
1516
|
+
// strip it (system-prompt path is unsafe at high step counts).
|
|
1517
|
+
// Ceiling reuses the 4B (task_type × size) matrix result
|
|
1518
|
+
// resolved above (`_stepCeiling`, `_ceilingTaskType`,
|
|
1519
|
+
// `_ceilingSize`, `_ceilingSessionId`) so the reminder and the
|
|
1520
|
+
// halt boundary agree on the same number.
|
|
1521
|
+
const _scopeSize = _ceilingSize;
|
|
1522
|
+
const _scopeK = cadenceForSize(_scopeSize);
|
|
1523
|
+
const _scopeCeiling = Math.max(1, _stepCeiling ?? deps.maxToolRounds ?? 30);
|
|
1524
|
+
const _scopeStep = sn;
|
|
1525
|
+
const _shouldRemind = shouldInjectReminder(_scopeStep, _scopeK);
|
|
1526
|
+
const _shouldWarn = shouldInjectSoftWarn(_scopeStep, _scopeCeiling, _ceilingSessionId);
|
|
1527
|
+
// Phase 5 Fix 5 (revised) — past the natural matrix ceiling the
|
|
1528
|
+
// orchestrator emits a STRONG re-anchor reminder, but only when
|
|
1529
|
+
// (a) crossing the ceiling for the first time (one-shot), OR
|
|
1530
|
+
// (b) hitting a normal cadence step (multiple of K).
|
|
1531
|
+
// Original Phase 5 Fix 5 fired on EVERY step past ceiling, which
|
|
1532
|
+
// on long-running sessions (e.g. step 77 / ceiling 6 in session
|
|
1533
|
+
// 1f29e238a816) produced 70+ redundant reminders that bloated
|
|
1534
|
+
// the tool_result channel and forced the model into a "YES still
|
|
1535
|
+
// on scope" loop on every tool call.
|
|
1536
|
+
const _pastNaturalCeiling = _scopeStep > _naturalCeiling;
|
|
1537
|
+
const _justCrossedCeiling = shouldInjectCeilingCrossing(_scopeStep, _naturalCeiling, _ceilingSessionId);
|
|
1538
|
+
const _pastCeilingAtCadence = _pastNaturalCeiling && _shouldRemind;
|
|
1539
|
+
// Fix #8 — self-repetition one-shot. Fires when the assistant
|
|
1540
|
+
// has opened the last 3 streamText steps with the same 4-word
|
|
1541
|
+
// phrase (e.g. "YES still on scope" — session 1f29e238a816
|
|
1542
|
+
// emitted 15 such bursts past ceiling). Reminder is attached
|
|
1543
|
+
// alongside (and before) any scope reminder so the model sees
|
|
1544
|
+
// the behavioural correction first.
|
|
1545
|
+
const _shouldRepeatReminder = shouldInjectRepetitionReminder(_ceilingSessionId);
|
|
1546
|
+
if (_shouldRemind || _shouldWarn || _justCrossedCeiling || _shouldRepeatReminder) {
|
|
1547
|
+
const _baseReminder = buildScopeReminder({
|
|
1548
|
+
step: _scopeStep,
|
|
1549
|
+
ceiling: _scopeCeiling,
|
|
1550
|
+
taskType: _ceilingTaskType,
|
|
1551
|
+
size: _scopeSize,
|
|
1552
|
+
originalPrompt: userMessage,
|
|
1553
|
+
});
|
|
1554
|
+
// Strong "past natural budget" prefix only applies when we
|
|
1555
|
+
// ACTUALLY want the model to consider wrapping up — i.e. on
|
|
1556
|
+
// the crossing event or at a cadence step past ceiling, not
|
|
1557
|
+
// on every silent step in between.
|
|
1558
|
+
const _useStrong = _justCrossedCeiling || _pastCeilingAtCadence;
|
|
1559
|
+
const _scopePart = _shouldRemind || _shouldWarn || _justCrossedCeiling
|
|
1560
|
+
? _useStrong
|
|
1561
|
+
? `[past natural budget — step ${_scopeStep}/${_naturalCeiling}] If task is COMPLETE, emit final answer NOW. If wandering, simplify the next step. ${_baseReminder}`
|
|
1562
|
+
: _shouldWarn
|
|
1563
|
+
? `[approaching ceiling] ${_baseReminder}`
|
|
1564
|
+
: _baseReminder
|
|
1565
|
+
: null;
|
|
1566
|
+
const _reminder = _shouldRepeatReminder
|
|
1567
|
+
? _scopePart
|
|
1568
|
+
? `${buildRepetitionReminder(_ceilingSessionId)}\n${_scopePart}`
|
|
1569
|
+
: buildRepetitionReminder(_ceilingSessionId)
|
|
1570
|
+
: _scopePart;
|
|
1571
|
+
const withReminder = attachReminderToMessages(compacted, _reminder);
|
|
1572
|
+
return { messages: withReminder };
|
|
1573
|
+
}
|
|
917
1574
|
if (compacted === stripped && stripped === stepMessages)
|
|
918
1575
|
return {};
|
|
1576
|
+
// Self-awareness note: tell the model compaction happened so it
|
|
1577
|
+
// knows earlier context was elided and can adjust its behavior.
|
|
1578
|
+
// Enhanced per EE anti-mù plan (docs/ee-anti-mu-compaction-plan.md Phase 2): include proactive
|
|
1579
|
+
// "task finished?", "compacted yet?", "EE checkpoint" so agent can self-assess and avoid mù
|
|
1580
|
+
// even when the top-level summary is not in its immediate focus (sub-agents, long loops).
|
|
1581
|
+
const _compactNote = compacted !== stripped
|
|
1582
|
+
? `[context compacted at step ${sn} — older or low-value tool results rewritten to stubs to fit budget. High-value evidence (file reads, bash, your previous responses) is kept verbatim. ${buildCheckpointReminder(sn, true)}]`
|
|
1583
|
+
: null;
|
|
1584
|
+
if (_compactNote) {
|
|
1585
|
+
return { messages: attachReminderToMessages(compacted, _compactNote) };
|
|
1586
|
+
}
|
|
919
1587
|
return { messages: compacted };
|
|
920
1588
|
},
|
|
921
1589
|
...(dropParam("temperature") ? {} : { temperature: 0.7 }),
|
|
@@ -940,10 +1608,23 @@ export class MessageProcessor {
|
|
|
940
1608
|
});
|
|
941
1609
|
// Realtime status bar update per step
|
|
942
1610
|
if (stepUsage.inputTokens || stepUsage.outputTokens) {
|
|
943
|
-
|
|
1611
|
+
// O1 — thread THIS turn's providerOptions shape per step so every
|
|
1612
|
+
// step event records it (not just step 1) and an interleaved task
|
|
1613
|
+
// can't overwrite it. Mirrors the gate used for the call itself.
|
|
1614
|
+
deps.recordUsage(stepUsage, "message", runtime.modelId, Object.keys(providerOpts).length > 0 ? extractProviderOptionsShape(providerOpts) : null);
|
|
944
1615
|
}
|
|
1616
|
+
// Fix #8 — feed the assistant text emitted in this step into
|
|
1617
|
+
// the self-repetition detector. The slice covers everything
|
|
1618
|
+
// appended to `assistantText` since the previous step boundary;
|
|
1619
|
+
// a step with no text (pure tool call) records as empty, which
|
|
1620
|
+
// recordAssistantBurst treats as a no-op so the current run is
|
|
1621
|
+
// preserved across tool interludes.
|
|
1622
|
+
const _stepText = assistantText.slice(_assistantTextAtLastStep);
|
|
1623
|
+
_assistantTextAtLastStep = assistantText.length;
|
|
1624
|
+
recordAssistantBurst(_ceilingSessionId, _stepText);
|
|
945
1625
|
},
|
|
946
1626
|
onFinish: ({ finishReason }) => {
|
|
1627
|
+
_lastFinishReason = finishReason ?? null;
|
|
947
1628
|
// Task 2.6b — emit llm-done (agent-mode only).
|
|
948
1629
|
try {
|
|
949
1630
|
const _ar = globalThis.__muonroiAgentRuntime;
|
|
@@ -955,8 +1636,8 @@ export class MessageProcessor {
|
|
|
955
1636
|
finishReason: finishReason ?? "stop",
|
|
956
1637
|
});
|
|
957
1638
|
}
|
|
958
|
-
catch {
|
|
959
|
-
|
|
1639
|
+
catch (err) {
|
|
1640
|
+
console.error("[Agent:onFinish] failed to emit llm-done", err);
|
|
960
1641
|
}
|
|
961
1642
|
deps.setCurrentCallId("");
|
|
962
1643
|
},
|
|
@@ -964,6 +1645,7 @@ export class MessageProcessor {
|
|
|
964
1645
|
let _topTokenIndex = 0;
|
|
965
1646
|
const _wireProviderIdTop = runtime.modelInfo?.provider ?? "unknown";
|
|
966
1647
|
for await (const part of result.fullStream) {
|
|
1648
|
+
stall.pet(); // chunk arrived — reset the stall watchdog
|
|
967
1649
|
if (signal.aborted) {
|
|
968
1650
|
yield { type: "content", content: "\n\n[Cancelled]" };
|
|
969
1651
|
break;
|
|
@@ -1019,6 +1701,73 @@ export class MessageProcessor {
|
|
|
1019
1701
|
// SAMR: track that Phase 1 produced tool calls → transition to Phase 2
|
|
1020
1702
|
if (stepRouterPhase === "phase1")
|
|
1021
1703
|
phase1HadToolCalls = true;
|
|
1704
|
+
// Response tool = the terminal final answer (identity execute;
|
|
1705
|
+
// the payload lives in the call args). Buffer it (longest-wins)
|
|
1706
|
+
// straight from the args and gate UI/DB/exec spam: cheap models
|
|
1707
|
+
// sometimes emit the response tool MANY times in ONE generation
|
|
1708
|
+
// (session 8d8f498268ed: 80× identical respond_general hedge in
|
|
1709
|
+
// one step). stopWhen only halts BETWEEN steps, so it can't stop
|
|
1710
|
+
// an in-step spam — this does. Surface only the first indicator;
|
|
1711
|
+
// if the model spams past the cap, finalize NOW with the
|
|
1712
|
+
// buffered answer instead of streaming out the degenerate step.
|
|
1713
|
+
if (isResponseTool(tc.function.name)) {
|
|
1714
|
+
_responseToolEmitCount += 1;
|
|
1715
|
+
try {
|
|
1716
|
+
const _payload = JSON.parse(tc.function.arguments || "{}");
|
|
1717
|
+
const _len = JSON.stringify(_payload).length;
|
|
1718
|
+
if (_len > _pendingStructuredResponseLen) {
|
|
1719
|
+
_pendingStructuredResponseLen = _len;
|
|
1720
|
+
_pendingStructuredResponse = {
|
|
1721
|
+
taskType: getResponseTaskType(tc.function.name) ?? tc.function.name,
|
|
1722
|
+
data: _payload,
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
catch {
|
|
1727
|
+
/* keep the prior buffered payload */
|
|
1728
|
+
}
|
|
1729
|
+
responseToolCalled = true;
|
|
1730
|
+
// Only the first response-tool call gets a UI indicator.
|
|
1731
|
+
if (_responseToolEmitCount === 1) {
|
|
1732
|
+
yield { type: "tool_calls", toolCalls: [tc] };
|
|
1733
|
+
}
|
|
1734
|
+
if (_responseToolEmitCount >= RESPONSE_TOOL_SPAM_CAP && _pendingStructuredResponse) {
|
|
1735
|
+
if (deps.session) {
|
|
1736
|
+
try {
|
|
1737
|
+
logInteraction(deps.session.id, "f6_synthesis", {
|
|
1738
|
+
eventSubtype: "response_tool_spam_abort",
|
|
1739
|
+
data: { emitted: _responseToolEmitCount, keptChars: _pendingStructuredResponseLen },
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
catch {
|
|
1743
|
+
/* telemetry best-effort */
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
// Persist a clean turn (user + the single buffered answer)
|
|
1747
|
+
// so history stays usable; the spam is dropped. Mirrors the
|
|
1748
|
+
// tool-repetition abort: yield + done + return (do NOT await
|
|
1749
|
+
// result.response — the stream is still spewing calls).
|
|
1750
|
+
const _data = _pendingStructuredResponse.data;
|
|
1751
|
+
const _answerText = typeof _data.response === "string"
|
|
1752
|
+
? _data.response
|
|
1753
|
+
: JSON.stringify(_pendingStructuredResponse.data);
|
|
1754
|
+
try {
|
|
1755
|
+
deps.appendCompletedTurn(userModelMessage, [
|
|
1756
|
+
{ role: "assistant", content: _answerText },
|
|
1757
|
+
]);
|
|
1758
|
+
}
|
|
1759
|
+
catch (persistErr) {
|
|
1760
|
+
console.error(`[message-processor] response-tool-spam persist failed: ${persistErr?.message}`);
|
|
1761
|
+
}
|
|
1762
|
+
yield {
|
|
1763
|
+
type: "structured_response",
|
|
1764
|
+
structuredResponse: _pendingStructuredResponse,
|
|
1765
|
+
};
|
|
1766
|
+
yield { type: "done" };
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
break; // response tools skip write-ahead/hooks/normal tool_calls yield
|
|
1770
|
+
}
|
|
1022
1771
|
// EE PreToolUse hook: fire intercept before tool execution.
|
|
1023
1772
|
{
|
|
1024
1773
|
const turnAssistantReasoning = deps.getTurnAssistantReasoning();
|
|
@@ -1158,9 +1907,13 @@ export class MessageProcessor {
|
|
|
1158
1907
|
yield { type: "content", content: `[Vision Bridge: image → text for ${turnModelId}]\n` };
|
|
1159
1908
|
}
|
|
1160
1909
|
}
|
|
1161
|
-
catch {
|
|
1162
|
-
|
|
1910
|
+
catch (err) {
|
|
1911
|
+
console.error("[Agent:visionBridge] failed to process image for tool result", err);
|
|
1163
1912
|
}
|
|
1913
|
+
// Capture into the stall-rescue digest before any further
|
|
1914
|
+
// processing — if the stream stalls after this, these outputs
|
|
1915
|
+
// are all we have to synthesize a final answer from.
|
|
1916
|
+
pushStallToolResult(turnToolResults, part.toolName, typeof tr.output === "string" ? tr.output : JSON.stringify(tr.output));
|
|
1164
1917
|
// Pitfall 9: settle the pending call log entry.
|
|
1165
1918
|
if (deps.pendingCalls) {
|
|
1166
1919
|
const pending = activeToolCalls.find((t) => t.id === part.toolCallId);
|
|
@@ -1182,25 +1935,32 @@ export class MessageProcessor {
|
|
|
1182
1935
|
session_id: deps.session?.id,
|
|
1183
1936
|
cwd: deps.bash.getCwd(),
|
|
1184
1937
|
};
|
|
1185
|
-
await deps.fireHook(postInput, signal).catch(() => {
|
|
1938
|
+
await deps.fireHook(postInput, signal).catch((err) => {
|
|
1939
|
+
console.error("[Agent:PostToolUse hook] failed", err);
|
|
1940
|
+
});
|
|
1186
1941
|
}
|
|
1187
1942
|
// Response tool: yield as structured_response instead of tool_result.
|
|
1188
1943
|
// AI SDK v5 wraps tool outputs as `{type:"json", value:{...}}`; unwrap
|
|
1189
1944
|
// to expose the schema-shaped payload to the UI renderer.
|
|
1190
1945
|
if (isResponseTool(part.toolName)) {
|
|
1191
1946
|
responseToolCalled = true;
|
|
1947
|
+
// Payload was already buffered (longest-wins) from the
|
|
1948
|
+
// tool-CALL args above; re-buffer from the executed result as
|
|
1949
|
+
// a fallback (unwraps the AI-SDK `{type:"json",value}` shape).
|
|
1950
|
+
// Counting + the spam cap live in the tool-call branch.
|
|
1192
1951
|
const taskType = getResponseTaskType(part.toolName);
|
|
1193
1952
|
const rawOutput = part.output;
|
|
1194
1953
|
const unwrapped = rawOutput && typeof rawOutput === "object" && rawOutput.type === "json"
|
|
1195
1954
|
? (rawOutput.value ?? {})
|
|
1196
1955
|
: (rawOutput ?? {});
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1956
|
+
const _len = JSON.stringify(unwrapped ?? {}).length;
|
|
1957
|
+
if (_len > _pendingStructuredResponseLen) {
|
|
1958
|
+
_pendingStructuredResponseLen = _len;
|
|
1959
|
+
_pendingStructuredResponse = {
|
|
1200
1960
|
taskType: taskType ?? part.toolName,
|
|
1201
1961
|
data: unwrapped,
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1204
1964
|
notifyObserver(observer?.onToolFinish, { toolCall: tc, toolResult: tr, timestamp: Date.now() });
|
|
1205
1965
|
break;
|
|
1206
1966
|
}
|
|
@@ -1209,13 +1969,38 @@ export class MessageProcessor {
|
|
|
1209
1969
|
toolResult: tr,
|
|
1210
1970
|
timestamp: Date.now(),
|
|
1211
1971
|
});
|
|
1212
|
-
// Interaction log: tool result
|
|
1972
|
+
// Interaction log: tool result.
|
|
1973
|
+
// Phase 5 BUG-J — for edit/write/update tools, persist the
|
|
1974
|
+
// structured diff (file_path, +N/-M counts, isNew flag, and
|
|
1975
|
+
// a bounded patch preview) so forensics queries can audit
|
|
1976
|
+
// what actually changed in each turn without re-reading
|
|
1977
|
+
// git history. Earlier the log only had the summary string
|
|
1978
|
+
// ("Edited X (+1 -1)") — the patch text was lost.
|
|
1213
1979
|
try {
|
|
1214
1980
|
if (deps.session) {
|
|
1215
1981
|
const outputPreview = typeof tr.output === "string" ? tr.output.slice(0, 200) : JSON.stringify(tr.output).slice(0, 200);
|
|
1982
|
+
const _trWithDiff = tr;
|
|
1983
|
+
const diffMeta = _trWithDiff.diff &&
|
|
1984
|
+
(tc.function.name === "edit_file" ||
|
|
1985
|
+
tc.function.name === "write_file" ||
|
|
1986
|
+
tc.function.name === "update_file")
|
|
1987
|
+
? {
|
|
1988
|
+
filePath: _trWithDiff.diff.filePath,
|
|
1989
|
+
additions: _trWithDiff.diff.additions,
|
|
1990
|
+
removals: _trWithDiff.diff.removals,
|
|
1991
|
+
isNew: _trWithDiff.diff.isNew,
|
|
1992
|
+
// Cap at 4000 chars — enough to inspect small/medium
|
|
1993
|
+
// edits without ballooning the SQLite row. Large
|
|
1994
|
+
// refactors get truncated with a tail marker so
|
|
1995
|
+
// readers know the patch is partial.
|
|
1996
|
+
patchPreview: _trWithDiff.diff.patch.length > 4000
|
|
1997
|
+
? _trWithDiff.diff.patch.slice(0, 4000) + "\n…[truncated]"
|
|
1998
|
+
: _trWithDiff.diff.patch,
|
|
1999
|
+
}
|
|
2000
|
+
: undefined;
|
|
1216
2001
|
logInteraction(deps.session.id, "tool_result", {
|
|
1217
2002
|
eventSubtype: tc.function.name,
|
|
1218
|
-
data: { success: tr.success, outputPreview },
|
|
2003
|
+
data: { success: tr.success, outputPreview, ...(diffMeta ? { diff: diffMeta } : {}) },
|
|
1219
2004
|
});
|
|
1220
2005
|
}
|
|
1221
2006
|
}
|
|
@@ -1223,6 +2008,21 @@ export class MessageProcessor {
|
|
|
1223
2008
|
/* fail-open */
|
|
1224
2009
|
}
|
|
1225
2010
|
yield { type: "tool_result", toolCall: tc, toolResult: tr };
|
|
2011
|
+
// Reset tool-repetition counter on any non-error result. A
|
|
2012
|
+
// successful call between two failures of the same shape is
|
|
2013
|
+
// progress and should not accumulate toward the abort gate.
|
|
2014
|
+
if (tr.success) {
|
|
2015
|
+
recordToolRepetitionSuccess(deps.session?.id ?? null);
|
|
2016
|
+
}
|
|
2017
|
+
// todo_write side-effect: surface the task list to the UI via a
|
|
2018
|
+
// dedicated chunk so the sticky checklist panel can re-render
|
|
2019
|
+
// without parsing tool args itself. Skipped when the snapshot
|
|
2020
|
+
// doesn't parse (malformed args) so the UI is never poisoned.
|
|
2021
|
+
if (tc.function.name === "todo_write" && tr.success) {
|
|
2022
|
+
const snap = snapshotFromTodoWriteArgs(tc.function.arguments);
|
|
2023
|
+
if (snap)
|
|
2024
|
+
yield { type: "task_list_update", taskListSnapshot: snap };
|
|
2025
|
+
}
|
|
1226
2026
|
break;
|
|
1227
2027
|
}
|
|
1228
2028
|
case "tool-error": {
|
|
@@ -1277,11 +2077,37 @@ export class MessageProcessor {
|
|
|
1277
2077
|
});
|
|
1278
2078
|
}
|
|
1279
2079
|
}
|
|
1280
|
-
catch {
|
|
1281
|
-
|
|
2080
|
+
catch (logErr) {
|
|
2081
|
+
console.error(`[message-processor] interaction-log tool_result failed: ${logErr?.message}`);
|
|
1282
2082
|
}
|
|
1283
2083
|
notifyObserver(observer?.onToolFinish, { toolCall: tc, toolResult: tr, timestamp: Date.now() });
|
|
1284
2084
|
yield { type: "tool_result", toolCall: tc, toolResult: tr };
|
|
2085
|
+
// Tool-call perseveration guard. After N consecutive identical
|
|
2086
|
+
// (toolName, args, error) triples, abort the streaming loop
|
|
2087
|
+
// before TPM rate limits do (session 080fe2fcbf24).
|
|
2088
|
+
const repetition = recordToolRepetitionError(deps.session?.id ?? null, errPart.toolName, errPart.input, errMsg);
|
|
2089
|
+
if (repetition.shouldAbort) {
|
|
2090
|
+
const abortMsg = buildToolRepetitionAbortMessage(errPart.toolName, repetition.runLength, errMsg);
|
|
2091
|
+
try {
|
|
2092
|
+
if (deps.session) {
|
|
2093
|
+
logInteraction(deps.session.id, "error", {
|
|
2094
|
+
eventSubtype: "tool_repetition_abort",
|
|
2095
|
+
data: {
|
|
2096
|
+
toolName: errPart.toolName,
|
|
2097
|
+
runLength: repetition.runLength,
|
|
2098
|
+
errorPreview: errMsg.slice(0, 200),
|
|
2099
|
+
},
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
catch (logErr) {
|
|
2104
|
+
console.error(`[message-processor] interaction-log tool_repetition_abort failed: ${logErr?.message}`);
|
|
2105
|
+
}
|
|
2106
|
+
notifyObserver(observer?.onError, { message: abortMsg, timestamp: Date.now() });
|
|
2107
|
+
yield { type: "error", content: abortMsg, isAuthError: false };
|
|
2108
|
+
yield { type: "done" };
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
1285
2111
|
break;
|
|
1286
2112
|
}
|
|
1287
2113
|
case "tool-approval-request": {
|
|
@@ -1301,9 +2127,25 @@ export class MessageProcessor {
|
|
|
1301
2127
|
// Plan 03-01: check permission mode before yielding approval request to UI.
|
|
1302
2128
|
// auto-edit auto-approves file ops; yolo auto-approves everything.
|
|
1303
2129
|
const toolName = approvalPart.toolCall?.toolName ?? "";
|
|
1304
|
-
|
|
2130
|
+
const input = approvalPart.toolCall?.input ?? {};
|
|
2131
|
+
const context = toolName === "bash"
|
|
2132
|
+
? { command: String(input.command ?? "") }
|
|
2133
|
+
: toolName === "write_file" ||
|
|
2134
|
+
toolName === "edit_file" ||
|
|
2135
|
+
toolName === "read_file" ||
|
|
2136
|
+
toolName === "grep"
|
|
2137
|
+
? { path: String(input.path ?? input.file_path ?? "") }
|
|
2138
|
+
: undefined;
|
|
2139
|
+
if (!toolNeedsApproval(toolName, deps.permissionMode, context)) {
|
|
1305
2140
|
// Auto-approve: respond directly without surfacing to UI.
|
|
1306
2141
|
deps.respondToToolApproval(approvalPart.approvalId, true);
|
|
2142
|
+
appendAudit({
|
|
2143
|
+
kind: deps.permissionMode === "yolo" ? "yolo-override" : "permission-override",
|
|
2144
|
+
tool: toolName,
|
|
2145
|
+
mode: deps.permissionMode,
|
|
2146
|
+
context,
|
|
2147
|
+
ts: Date.now(),
|
|
2148
|
+
});
|
|
1307
2149
|
break;
|
|
1308
2150
|
}
|
|
1309
2151
|
yield {
|
|
@@ -1316,22 +2158,31 @@ export class MessageProcessor {
|
|
|
1316
2158
|
}
|
|
1317
2159
|
case "error": {
|
|
1318
2160
|
const authError = isAuthenticationError(part.error);
|
|
1319
|
-
const friendly = humanizeApiError(part.error
|
|
2161
|
+
const friendly = humanizeApiError(part.error, {
|
|
2162
|
+
modelId: runtime.modelId,
|
|
2163
|
+
providerId: runtime.modelInfo?.provider,
|
|
2164
|
+
});
|
|
2165
|
+
const forensics = summarizeApiErrorForLog(part.error);
|
|
1320
2166
|
notifyObserver(observer?.onError, {
|
|
1321
2167
|
message: friendly,
|
|
1322
2168
|
timestamp: Date.now(),
|
|
1323
2169
|
});
|
|
1324
|
-
// Interaction log: error
|
|
2170
|
+
// Interaction log: error + forensics envelope so opaque
|
|
2171
|
+
// provider 4xx ("parameter is invalid" / unknown 400s) leave
|
|
2172
|
+
// an actionable wire-level trace without needing a repro.
|
|
1325
2173
|
try {
|
|
1326
2174
|
if (deps.session) {
|
|
1327
2175
|
logInteraction(deps.session.id, "error", {
|
|
1328
2176
|
eventSubtype: authError ? "auth" : "api",
|
|
1329
|
-
data: {
|
|
2177
|
+
data: {
|
|
2178
|
+
message: friendly.slice(0, 200),
|
|
2179
|
+
...(forensics ? { forensics } : {}),
|
|
2180
|
+
},
|
|
1330
2181
|
});
|
|
1331
2182
|
}
|
|
1332
2183
|
}
|
|
1333
|
-
catch {
|
|
1334
|
-
|
|
2184
|
+
catch (logErr) {
|
|
2185
|
+
console.error(`[message-processor] interaction-log error failed: ${logErr?.message}`);
|
|
1335
2186
|
}
|
|
1336
2187
|
yield {
|
|
1337
2188
|
type: "error",
|
|
@@ -1341,17 +2192,144 @@ export class MessageProcessor {
|
|
|
1341
2192
|
break;
|
|
1342
2193
|
}
|
|
1343
2194
|
case "abort":
|
|
2195
|
+
// A stall-watchdog abort arrives here as an "abort" stream part
|
|
2196
|
+
// (the SDK surfaces it as a part, not a throw). Distinguish it
|
|
2197
|
+
// from a genuine user cancel — which is caught at the top of the
|
|
2198
|
+
// loop via `signal.aborted` — and surface it as a visible error
|
|
2199
|
+
// instead of a benign "[Cancelled]" so a hung provider no longer
|
|
2200
|
+
// looks like a silent freeze.
|
|
2201
|
+
if (stallTriggered) {
|
|
2202
|
+
stall.dispose();
|
|
2203
|
+
// A response tool already produced the terminal structured
|
|
2204
|
+
// answer (buffered from its call args) before the provider
|
|
2205
|
+
// stalled on a LATER step. Surface it and finish cleanly —
|
|
2206
|
+
// never bury the model's actual answer behind a "not
|
|
2207
|
+
// responding" error. Root cause of the "respond_* indicator
|
|
2208
|
+
// shows but no answer block renders" report: this stall-abort
|
|
2209
|
+
// path returned before the post-loop structured_response yield,
|
|
2210
|
+
// dropping the captured answer. A response tool is terminal,
|
|
2211
|
+
// so there is nothing to rescue — just emit what we have.
|
|
2212
|
+
if (_pendingStructuredResponse) {
|
|
2213
|
+
if (!streamOk) {
|
|
2214
|
+
try {
|
|
2215
|
+
const _d = _pendingStructuredResponse.data;
|
|
2216
|
+
const _ans = typeof _d.response === "string"
|
|
2217
|
+
? _d.response
|
|
2218
|
+
: JSON.stringify(_pendingStructuredResponse.data);
|
|
2219
|
+
deps.appendCompletedTurn(userModelMessage, [
|
|
2220
|
+
{ role: "assistant", content: _ans },
|
|
2221
|
+
]);
|
|
2222
|
+
streamOk = true;
|
|
2223
|
+
}
|
|
2224
|
+
catch (persistErr) {
|
|
2225
|
+
console.error(`[message-processor] stall+response-tool persist failed: ${persistErr?.message}`);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
yield {
|
|
2229
|
+
type: "structured_response",
|
|
2230
|
+
structuredResponse: _pendingStructuredResponse,
|
|
2231
|
+
};
|
|
2232
|
+
yield { type: "done" };
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2235
|
+
// Best-effort answer rescue: a turn that already ran tools but
|
|
2236
|
+
// stalled before the final synthesis would otherwise return
|
|
2237
|
+
// ONLY "Model not responding", discarding all that work (live
|
|
2238
|
+
// obs 2026-06-04, deepseek session 734e65cffdf6: 67 tool calls
|
|
2239
|
+
// → user got nothing). Make ONE guarded forced-finalize call
|
|
2240
|
+
// over the gathered tool outputs. forcedFinalize has its own
|
|
2241
|
+
// stall timeout, so a still-dead provider just falls through.
|
|
2242
|
+
let _rescued = null;
|
|
2243
|
+
if (turnToolResults.length > 0) {
|
|
2244
|
+
try {
|
|
2245
|
+
const _userText = typeof userModelMessage?.content === "string"
|
|
2246
|
+
? userModelMessage.content
|
|
2247
|
+
: JSON.stringify(userModelMessage?.content ?? "");
|
|
2248
|
+
_rescued = await attemptStallRescue({
|
|
2249
|
+
baseMessages: _topMessagesForCall,
|
|
2250
|
+
userText: _userText.slice(0, 4000),
|
|
2251
|
+
toolResults: turnToolResults,
|
|
2252
|
+
system: typeof systemForModel === "string" ? systemForModel : undefined,
|
|
2253
|
+
finalize: (a) => forcedFinalize({ model: runtime.model, messages: a.messages, system: a.system }),
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
catch {
|
|
2257
|
+
_rescued = null;
|
|
2258
|
+
}
|
|
2259
|
+
try {
|
|
2260
|
+
if (deps.session) {
|
|
2261
|
+
logInteraction(deps.session.id, "stall_rescue", {
|
|
2262
|
+
data: {
|
|
2263
|
+
outcome: _rescued ? "rescued" : "no_text",
|
|
2264
|
+
toolResultCount: turnToolResults.length,
|
|
2265
|
+
chars: _rescued?.length ?? 0,
|
|
2266
|
+
},
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
catch {
|
|
2271
|
+
/* telemetry is best-effort */
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
if (_rescued) {
|
|
2275
|
+
assistantText += (assistantText ? "\n\n" : "") + _rescued;
|
|
2276
|
+
yield { type: "content", content: _rescued };
|
|
2277
|
+
}
|
|
2278
|
+
// Persist a record of the interrupted turn BEFORE returning so
|
|
2279
|
+
// the next turn is not amnesiac. Previously this returned with
|
|
2280
|
+
// nothing persisted → the next turn saw "no previous turn" and
|
|
2281
|
+
// redid the work, orphaning any edits the stalled turn applied
|
|
2282
|
+
// (live obs 2026-06-04, deepseek-v4-flash). When rescued, the
|
|
2283
|
+
// note now carries the synthesized answer too (assistantText).
|
|
2284
|
+
// Best-effort: never let persistence failure block surfacing.
|
|
2285
|
+
if (!streamOk) {
|
|
2286
|
+
try {
|
|
2287
|
+
const _stallNote = buildInterruptedTurnNote(assistantText, activeToolCalls.map((c) => c.function.name));
|
|
2288
|
+
deps.appendCompletedTurn(userModelMessage, [
|
|
2289
|
+
{ role: "assistant", content: _stallNote },
|
|
2290
|
+
]);
|
|
2291
|
+
streamOk = true;
|
|
2292
|
+
}
|
|
2293
|
+
catch {
|
|
2294
|
+
/* best-effort — surface the stall regardless */
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
if (_rescued) {
|
|
2298
|
+
// Recovered a best-effort answer from partial data — surface
|
|
2299
|
+
// a soft notice instead of the scary "not responding" error.
|
|
2300
|
+
yield {
|
|
2301
|
+
type: "content",
|
|
2302
|
+
content: "\n\n[Note: the model connection stalled; the answer above is a best-effort synthesis " +
|
|
2303
|
+
"from the tool results gathered before the stall and may be incomplete.]",
|
|
2304
|
+
};
|
|
2305
|
+
yield { type: "done" };
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
2308
|
+
notifyObserver(observer?.onError, { message: STALL_ERROR_MESSAGE, timestamp: Date.now() });
|
|
2309
|
+
yield { type: "error", content: STALL_ERROR_MESSAGE, isAuthError: false };
|
|
2310
|
+
yield { type: "done" };
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
1344
2313
|
yield { type: "content", content: "\n\n[Cancelled]" };
|
|
1345
2314
|
break;
|
|
1346
2315
|
}
|
|
1347
2316
|
}
|
|
2317
|
+
stall.dispose(); // stream drained normally — stop the stall watchdog
|
|
1348
2318
|
// ─── SAMR Phase 1 → Phase 2 transition ─────────────────────────
|
|
1349
2319
|
// Phase 1 (premium model) produced tool calls but the SDK stopped
|
|
1350
2320
|
// before executing them (stopWhen: stepCountIs(1)). Append the
|
|
1351
2321
|
// assistant message to deps.messages and restart the loop with
|
|
1352
2322
|
// the fast execution model. Phase 2's streamText call will see
|
|
1353
2323
|
// the pending tool calls and execute them automatically.
|
|
1354
|
-
|
|
2324
|
+
//
|
|
2325
|
+
// EXCEPT when Phase 1 emitted a response tool: a `respond_*` call IS
|
|
2326
|
+
// the terminal structured answer (identity execute), not work to hand
|
|
2327
|
+
// to Phase 2. Transitioning here would (a) skip the structured_response
|
|
2328
|
+
// yield below — the answer never reaches the TUI — and (b) append a
|
|
2329
|
+
// dangling assistant tool-call WITHOUT its tool-result (only assistant
|
|
2330
|
+
// msgs are pushed), corrupting Phase 2's history. Fall through instead
|
|
2331
|
+
// so the buffered answer is yielded + persisted on this turn.
|
|
2332
|
+
if (stepRouterPhase === "phase1" && phase1HadToolCalls && !responseToolCalled) {
|
|
1355
2333
|
try {
|
|
1356
2334
|
const phase1Response = await result.response;
|
|
1357
2335
|
// Append only new messages (assistant message with tool calls)
|
|
@@ -1368,6 +2346,28 @@ export class MessageProcessor {
|
|
|
1368
2346
|
stepRouterPhase = "phase2";
|
|
1369
2347
|
continue; // Re-enter while loop with Phase 2 (fast) model
|
|
1370
2348
|
}
|
|
2349
|
+
// Surface the single most-complete response-tool answer buffered
|
|
2350
|
+
// during the stream (see _pendingStructuredResponse). Yielding here —
|
|
2351
|
+
// once, after the stream drained and after the Phase 1 transition —
|
|
2352
|
+
// collapses any duplicate response-tool emissions in the turn into a
|
|
2353
|
+
// single structured_response block for the UI.
|
|
2354
|
+
if (_pendingStructuredResponse) {
|
|
2355
|
+
yield {
|
|
2356
|
+
type: "structured_response",
|
|
2357
|
+
structuredResponse: _pendingStructuredResponse,
|
|
2358
|
+
};
|
|
2359
|
+
if (_responseToolEmitCount > 1 && deps.session) {
|
|
2360
|
+
try {
|
|
2361
|
+
logInteraction(deps.session.id, "f6_synthesis", {
|
|
2362
|
+
eventSubtype: "response_tool_deduped",
|
|
2363
|
+
data: { emitted: _responseToolEmitCount, keptChars: _pendingStructuredResponseLen },
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
catch {
|
|
2367
|
+
/* telemetry best-effort */
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
1371
2371
|
if (signal.aborted) {
|
|
1372
2372
|
deps.discardAbortedTurn(userModelMessage);
|
|
1373
2373
|
yield { type: "done" };
|
|
@@ -1383,7 +2383,162 @@ export class MessageProcessor {
|
|
|
1383
2383
|
// screenshot, ~1.5MB). Persisting that lets it accumulate and
|
|
1384
2384
|
// overflow the model's context on subsequent turns.
|
|
1385
2385
|
const scrubbed = scrubImagePayloadsInMessages(response.messages);
|
|
1386
|
-
|
|
2386
|
+
// Phase 5 F6 — synthesis step when stream ended without a final
|
|
2387
|
+
// text response. Cheap models (DeepSeek V4 Flash) frequently
|
|
2388
|
+
// emit only tool-calls in their last step and stop, leaving the
|
|
2389
|
+
// user staring at "Here's the summary:..." truncation that
|
|
2390
|
+
// required a manual "tiếp tục" turn-2 to coax out. Detect that
|
|
2391
|
+
// shape and inject ONE forcedFinalize call (same path as 4B
|
|
2392
|
+
// ceiling-hit) so the answer arrives on turn 1.
|
|
2393
|
+
//
|
|
2394
|
+
// Skip when 4B ceiling already triggered its own forcedFinalize
|
|
2395
|
+
// below — running both would double-bill and duplicate text.
|
|
2396
|
+
let _f6SynthesisText = null;
|
|
2397
|
+
const _f6LastMsg = scrubbed[scrubbed.length - 1];
|
|
2398
|
+
const _f6LastRole = _f6LastMsg?.role ?? "none";
|
|
2399
|
+
let _f6Outcome = "skip_ceiling";
|
|
2400
|
+
let _f6Elapsed = 0;
|
|
2401
|
+
let _f6ChunkChars = 0;
|
|
2402
|
+
let _f6Error = null;
|
|
2403
|
+
// A response tool already produced the final structured answer —
|
|
2404
|
+
// F6 synthesis would duplicate it as prose. Skip entirely. With
|
|
2405
|
+
// the stopWhen terminal-halt above, the turn now ends right after
|
|
2406
|
+
// the response tool (last scrubbed message is the response
|
|
2407
|
+
// tool-result, role "tool"), which would otherwise trip the
|
|
2408
|
+
// _needsSynthesis "ended on a tool" branch and double-respond.
|
|
2409
|
+
if (responseToolCalled) {
|
|
2410
|
+
_f6Outcome = "skip_response_tool";
|
|
2411
|
+
}
|
|
2412
|
+
else if (!_ceilingHit) {
|
|
2413
|
+
const _needsSynthesis = (() => {
|
|
2414
|
+
if (!_f6LastMsg)
|
|
2415
|
+
return false;
|
|
2416
|
+
if (_f6LastMsg.role === "tool")
|
|
2417
|
+
return true;
|
|
2418
|
+
if (_f6LastMsg.role !== "assistant")
|
|
2419
|
+
return false;
|
|
2420
|
+
const _c = _f6LastMsg.content;
|
|
2421
|
+
if (typeof _c === "string")
|
|
2422
|
+
return !_c.trim();
|
|
2423
|
+
if (!Array.isArray(_c))
|
|
2424
|
+
return false;
|
|
2425
|
+
return !_c.some((p) => p && p.type === "text" && typeof p.text === "string" && p.text.trim().length > 0);
|
|
2426
|
+
})();
|
|
2427
|
+
if (!_needsSynthesis) {
|
|
2428
|
+
_f6Outcome = "skip_has_text";
|
|
2429
|
+
}
|
|
2430
|
+
else {
|
|
2431
|
+
const _f6Start = Date.now();
|
|
2432
|
+
try {
|
|
2433
|
+
const _ff = await forcedFinalize({
|
|
2434
|
+
model: runtime.model,
|
|
2435
|
+
messages: _topMessagesForCall,
|
|
2436
|
+
system: typeof systemForModel === "string" ? systemForModel : undefined,
|
|
2437
|
+
});
|
|
2438
|
+
_f6Elapsed = Date.now() - _f6Start;
|
|
2439
|
+
_f6ChunkChars = (_ff.text ?? "").length;
|
|
2440
|
+
if (_ff.text.trim()) {
|
|
2441
|
+
_f6SynthesisText = _ff.text;
|
|
2442
|
+
assistantText += _ff.text;
|
|
2443
|
+
yield { type: "content", content: _ff.text };
|
|
2444
|
+
_f6Outcome = "fired_text";
|
|
2445
|
+
}
|
|
2446
|
+
else {
|
|
2447
|
+
_f6Outcome = "fired_empty";
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
catch (_err) {
|
|
2451
|
+
_f6Elapsed = Date.now() - _f6Start;
|
|
2452
|
+
_f6Outcome = "error";
|
|
2453
|
+
_f6Error = _err?.message?.slice(0, 200) ?? String(_err).slice(0, 200);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
try {
|
|
2458
|
+
if (deps.session) {
|
|
2459
|
+
logInteraction(deps.session.id, "f6_synthesis", {
|
|
2460
|
+
data: {
|
|
2461
|
+
outcome: _f6Outcome,
|
|
2462
|
+
lastMsgRole: _f6LastRole,
|
|
2463
|
+
elapsedMs: _f6Elapsed,
|
|
2464
|
+
chars: _f6ChunkChars,
|
|
2465
|
+
error: _f6Error,
|
|
2466
|
+
ceilingHit: _ceilingHit,
|
|
2467
|
+
scrubbedLen: scrubbed.length,
|
|
2468
|
+
},
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
catch {
|
|
2473
|
+
/* telemetry is best-effort */
|
|
2474
|
+
}
|
|
2475
|
+
// Summary-phase grounding check (Agent Operating Contract, runtime
|
|
2476
|
+
// half). Soft-flag counts / file:line refs in the final synthesis
|
|
2477
|
+
// that don't appear in this turn's tool outputs — possible
|
|
2478
|
+
// hallucination. Never blocks: emits a grounding-flag event + a
|
|
2479
|
+
// warn toast + an inline advisory footnote. Only runs when the
|
|
2480
|
+
// turn actually produced tool output (a corpus to ground against)
|
|
2481
|
+
// and is not chitchat. See grounding-check.ts.
|
|
2482
|
+
if (process.env.MUONROI_DISABLE_GROUNDING_CHECK !== "1" &&
|
|
2483
|
+
!isChitchat &&
|
|
2484
|
+
assistantText.trim().length > 0) {
|
|
2485
|
+
try {
|
|
2486
|
+
const _gParts = [];
|
|
2487
|
+
let _gHadTool = false;
|
|
2488
|
+
for (const _gm of scrubbed) {
|
|
2489
|
+
if (!_gm || _gm.role === "assistant")
|
|
2490
|
+
continue;
|
|
2491
|
+
if (_gm.role === "tool")
|
|
2492
|
+
_gHadTool = true;
|
|
2493
|
+
const _gc = _gm.content;
|
|
2494
|
+
_gParts.push(typeof _gc === "string" ? _gc : JSON.stringify(_gc));
|
|
2495
|
+
}
|
|
2496
|
+
if (_gHadTool) {
|
|
2497
|
+
const _claims = findUnverifiedClaims(assistantText, _gParts.join("\n"));
|
|
2498
|
+
if (_claims.length > 0) {
|
|
2499
|
+
const _footnote = buildGroundingFootnote(_claims);
|
|
2500
|
+
assistantText += _footnote;
|
|
2501
|
+
yield { type: "content", content: _footnote };
|
|
2502
|
+
const _gar = globalThis.__muonroiAgentRuntime;
|
|
2503
|
+
const _claimTexts = _claims.map((c) => c.text);
|
|
2504
|
+
_gar?.emitEvent({
|
|
2505
|
+
t: "event",
|
|
2506
|
+
kind: "grounding-flag",
|
|
2507
|
+
claims: _claimTexts,
|
|
2508
|
+
count: _claims.length,
|
|
2509
|
+
ts: Date.now(),
|
|
2510
|
+
});
|
|
2511
|
+
_gar?.emitEvent({
|
|
2512
|
+
t: "event",
|
|
2513
|
+
kind: "toast",
|
|
2514
|
+
level: "warn",
|
|
2515
|
+
text: `grounding: ${_claims.length} unverified claim(s) — ${_claimTexts.join(", ")}`,
|
|
2516
|
+
});
|
|
2517
|
+
if (deps.session) {
|
|
2518
|
+
try {
|
|
2519
|
+
logInteraction(deps.session.id, "grounding_flag", {
|
|
2520
|
+
data: { claims: _claimTexts, count: _claims.length },
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
catch {
|
|
2524
|
+
/* telemetry is best-effort */
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
catch {
|
|
2531
|
+
/* grounding check is best-effort — never break finalize */
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
const _finalMessages = sanitizeModelMessages(scrubbed);
|
|
2535
|
+
if (_f6SynthesisText !== null) {
|
|
2536
|
+
_finalMessages.push({
|
|
2537
|
+
role: "assistant",
|
|
2538
|
+
content: _f6SynthesisText,
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
deps.appendCompletedTurn(userModelMessage, _finalMessages);
|
|
1387
2542
|
streamOk = true;
|
|
1388
2543
|
}
|
|
1389
2544
|
}
|
|
@@ -1401,6 +2556,13 @@ export class MessageProcessor {
|
|
|
1401
2556
|
yield { type: "done" };
|
|
1402
2557
|
return;
|
|
1403
2558
|
}
|
|
2559
|
+
// Phase 5 Fix 5 — the Phase 4 4B forced-finalize-on-ceiling-hit
|
|
2560
|
+
// block lived here. With the matrix ceiling no longer halting the
|
|
2561
|
+
// stream (it's pure telemetry now), _ceilingHit can never be true
|
|
2562
|
+
// and this branch is dead. F6 synthesis above already covers the
|
|
2563
|
+
// "stream ended with no final text" case for both natural model
|
|
2564
|
+
// termination AND maxToolRounds halt. Keeping the comment as a
|
|
2565
|
+
// breadcrumb for future archaeology.
|
|
1404
2566
|
if (!streamOk && assistantText.trim()) {
|
|
1405
2567
|
deps.appendCompletedTurn(userModelMessage, [{ role: "assistant", content: assistantText }]);
|
|
1406
2568
|
}
|
|
@@ -1454,11 +2616,29 @@ export class MessageProcessor {
|
|
|
1454
2616
|
reportRouteOutcome(storeHash, "success", turnDuration);
|
|
1455
2617
|
}
|
|
1456
2618
|
}
|
|
2619
|
+
// Detect a tool call emitted as plain TEXT (wrong dialect) in the final
|
|
2620
|
+
// assistant answer — the action never ran, so the turn would otherwise
|
|
2621
|
+
// end silently with broken/half-done work (live: deepseek session
|
|
2622
|
+
// 905d564dbde4 emitted `<read_file>` as text after a destructive edit).
|
|
2623
|
+
// Detect regardless of how many real tool calls already succeeded: the
|
|
2624
|
+
// common failure is the model doing a few real tools, then emitting the
|
|
2625
|
+
// NEXT call as text and stopping (live deepseek-native, full-fix CLI: 2
|
|
2626
|
+
// real read_file calls, then `<read_file><path>` as text → silent stop).
|
|
2627
|
+
// An earlier `activeToolCalls.length === 0` guard suppressed exactly
|
|
2628
|
+
// that case. Detector precision (structural invocation shape, not a bare
|
|
2629
|
+
// mention) guards against false-firing on a normal final answer.
|
|
2630
|
+
const _textToolCall = detectTextEmittedToolCall(assistantText);
|
|
1457
2631
|
// Interaction log: agent response complete
|
|
1458
2632
|
try {
|
|
1459
2633
|
if (deps.session) {
|
|
1460
2634
|
const sb = statusBarStore.getState();
|
|
1461
2635
|
const turnDurationMs = Date.now() - turnStartMs;
|
|
2636
|
+
// BUG-A telemetry — detect raw DeepSeek native tool-call markup
|
|
2637
|
+
// leaking into assistant text. Signature is `<||DSML||` (the
|
|
2638
|
+
// fullwidth vertical bars are NOT pipes, they're U+FF5C).
|
|
2639
|
+
const _dsmlSig = "||DSML||";
|
|
2640
|
+
const _dsmlMatches = assistantText.includes(_dsmlSig);
|
|
2641
|
+
const _codeBlockBash = /```\s*bash\b/i.test(assistantText);
|
|
1462
2642
|
logInteraction(deps.session.id, "agent_response", {
|
|
1463
2643
|
model: turnModelId,
|
|
1464
2644
|
inputTokens: sb.in_tokens,
|
|
@@ -1468,6 +2648,10 @@ export class MessageProcessor {
|
|
|
1468
2648
|
textLength: assistantText.length,
|
|
1469
2649
|
toolCallCount: activeToolCalls.length,
|
|
1470
2650
|
compacted: deps.getCompactedThisTurn(),
|
|
2651
|
+
dsmlLeak: _dsmlMatches,
|
|
2652
|
+
bashCodeBlock: _codeBlockBash,
|
|
2653
|
+
textToolXmlLeak: _textToolCall.detected,
|
|
2654
|
+
textToolXmlTool: _textToolCall.tool,
|
|
1471
2655
|
},
|
|
1472
2656
|
});
|
|
1473
2657
|
}
|
|
@@ -1475,6 +2659,90 @@ export class MessageProcessor {
|
|
|
1475
2659
|
catch {
|
|
1476
2660
|
/* fail-open */
|
|
1477
2661
|
}
|
|
2662
|
+
// Surface the round-cap stop so the user knows why the agent halted
|
|
2663
|
+
// (session 7dcf8fd7d6a4 hit stepCountIs(100) silently, looked like a
|
|
2664
|
+
// crash). AI SDK reports finishReason='tool-calls' when the step cap
|
|
2665
|
+
// fires with tool calls still pending — distinct from 'stop' (model
|
|
2666
|
+
// chose to end). We only warn when stepNumber ≥ cap so a model that
|
|
2667
|
+
// legitimately terminates mid-tool-call (rare) doesn't get a false
|
|
2668
|
+
// warning.
|
|
2669
|
+
if (_lastFinishReason === "tool-calls" && stepNumber >= deps.maxToolRounds - 1) {
|
|
2670
|
+
yield {
|
|
2671
|
+
type: "content",
|
|
2672
|
+
content: `\n\n[Stopped: hit max-tool-rounds=${deps.maxToolRounds}. ` +
|
|
2673
|
+
`Re-run with \`--max-tool-rounds ${deps.maxToolRounds * 2}\` to continue, ` +
|
|
2674
|
+
"or accept the partial result above.]\n",
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2677
|
+
// Tool-call-as-text leak: the model wrote a tool invocation as plain
|
|
2678
|
+
// text (wrong dialect) and made NO real tool call, so the action never
|
|
2679
|
+
// ran. Auto-recover ONCE: append a corrective message and re-run the
|
|
2680
|
+
// turn so the model can invoke the tool properly. The just-finished
|
|
2681
|
+
// (text-only) turn is already persisted above — the model sees its own
|
|
2682
|
+
// mistake plus the correction. Mirrors the proven phase-switch re-entry
|
|
2683
|
+
// (it also pushes to deps.messages then `continue`s); bounded by
|
|
2684
|
+
// MAX_TEXT_TOOL_RESTEER so a persistently-degrading model can't loop.
|
|
2685
|
+
if (_textToolCall.detected && streamOk && textToolReSteerCount < MAX_TEXT_TOOL_RESTEER) {
|
|
2686
|
+
textToolReSteerCount++;
|
|
2687
|
+
// Recover the model's INTENT from the leaked markup (DeepSeek-native
|
|
2688
|
+
// DSML carries the tool + args) so the corrective restates the exact
|
|
2689
|
+
// call — far more effective than a generic "use the tool" nudge.
|
|
2690
|
+
const _parsedCalls = parseDsmlToolCalls(assistantText);
|
|
2691
|
+
const _intent = _parsedCalls.length > 0
|
|
2692
|
+
? ` You appear to have intended: ${_parsedCalls
|
|
2693
|
+
.map((c) => `${c.name}(${Object.entries(c.args)
|
|
2694
|
+
.map(([k, v]) => `${k}=${JSON.stringify(v)}`)
|
|
2695
|
+
.join(", ")})`)
|
|
2696
|
+
.join("; ")}. Make those exact call(s) via the tool interface now.`
|
|
2697
|
+
: "";
|
|
2698
|
+
deps.messages.push({
|
|
2699
|
+
role: "user",
|
|
2700
|
+
content: `Your previous reply wrote a \`${_textToolCall.tool}\` tool call as XML/text. That is NOT how tools are invoked here — ` +
|
|
2701
|
+
"writing tool calls as text does nothing, so the action did not run. " +
|
|
2702
|
+
"Use the actual tool-calling interface (function/tool calls) to perform the action now. " +
|
|
2703
|
+
"Do NOT output XML tags like <read_file>, <write_to_file>, <execute_command>, or <tool_call> (or DSML markup) as text." +
|
|
2704
|
+
_intent,
|
|
2705
|
+
});
|
|
2706
|
+
if (deps.session) {
|
|
2707
|
+
try {
|
|
2708
|
+
logInteraction(deps.session.id, "text_tool_resteer", {
|
|
2709
|
+
model: turnModelId,
|
|
2710
|
+
data: { tool: _textToolCall.tool, attempt: textToolReSteerCount },
|
|
2711
|
+
});
|
|
2712
|
+
}
|
|
2713
|
+
catch {
|
|
2714
|
+
/* telemetry best-effort */
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
{
|
|
2718
|
+
const _gar = globalThis.__muonroiAgentRuntime;
|
|
2719
|
+
_gar?.emitEvent({
|
|
2720
|
+
t: "event",
|
|
2721
|
+
kind: "toast",
|
|
2722
|
+
level: "info",
|
|
2723
|
+
text: `model wrote a ${_textToolCall.tool} tool call as text — re-steering to use the tool interface`,
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
await closeMcp?.().catch(() => { });
|
|
2727
|
+
continue;
|
|
2728
|
+
}
|
|
2729
|
+
// Re-steer budget exhausted (or no clean finish): surface the leak so
|
|
2730
|
+
// the turn is not SILENTLY wasted. The "answer" above is unexecuted XML.
|
|
2731
|
+
if (_textToolCall.detected) {
|
|
2732
|
+
yield {
|
|
2733
|
+
type: "content",
|
|
2734
|
+
content: `\n\n[⚠ The model wrote a \`${_textToolCall.tool}\` tool call as TEXT instead of invoking the tool, ` +
|
|
2735
|
+
"so that action did NOT run and this turn made no real progress. " +
|
|
2736
|
+
"Re-run the request (optionally with a more capable model) — the tool interface was not used.]\n",
|
|
2737
|
+
};
|
|
2738
|
+
const _gar = globalThis.__muonroiAgentRuntime;
|
|
2739
|
+
_gar?.emitEvent({
|
|
2740
|
+
t: "event",
|
|
2741
|
+
kind: "toast",
|
|
2742
|
+
level: "warn",
|
|
2743
|
+
text: `model emitted a ${_textToolCall.tool} tool call as text — action not executed`,
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
1478
2746
|
const stopInput = {
|
|
1479
2747
|
hook_event_name: "Stop",
|
|
1480
2748
|
session_id: deps.session?.id,
|
|
@@ -1564,7 +2832,9 @@ export class MessageProcessor {
|
|
|
1564
2832
|
// Transient network/server error retry — up to MAX_STREAM_RETRIES extra attempts.
|
|
1565
2833
|
// Only retry when no content has flowed yet (assistantText empty) to avoid
|
|
1566
2834
|
// partial-output corruption. Honour the abort signal between retries.
|
|
1567
|
-
|
|
2835
|
+
// Skip retry on a stall abort: the provider is unresponsive, so a retry
|
|
2836
|
+
// just burns another full stall timeout of silence — surface it instead.
|
|
2837
|
+
if (!assistantText.trim() && streamRetryCount < MAX_STREAM_RETRIES && !signal.aborted && !stallTriggered) {
|
|
1568
2838
|
const { transient } = classifyStreamError(err);
|
|
1569
2839
|
if (transient) {
|
|
1570
2840
|
streamRetryCount++;
|
|
@@ -1614,7 +2884,11 @@ export class MessageProcessor {
|
|
|
1614
2884
|
}
|
|
1615
2885
|
}
|
|
1616
2886
|
const authError = isAuthenticationError(err);
|
|
1617
|
-
|
|
2887
|
+
// Stall aborts carry an opaque DOMException; show the clear stall
|
|
2888
|
+
// message instead of the raw abort reason.
|
|
2889
|
+
const friendly = stallTriggered
|
|
2890
|
+
? STALL_ERROR_MESSAGE
|
|
2891
|
+
: humanizeApiError(err, { modelId: runtime.modelId, providerId: runtime.modelInfo?.provider });
|
|
1618
2892
|
notifyObserver(observer?.onError, {
|
|
1619
2893
|
message: friendly,
|
|
1620
2894
|
timestamp: Date.now(),
|