muonroi-cli 1.8.4 → 1.9.0
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 +17 -5
- package/dist/packages/agent-harness-core/src/driver.d.ts +27 -1
- package/dist/packages/agent-harness-core/src/driver.js +46 -0
- package/dist/packages/agent-harness-core/src/event-filter.js +11 -0
- package/dist/packages/agent-harness-core/src/event-redact.js +7 -0
- package/dist/packages/agent-harness-core/src/event-tee.d.ts +64 -0
- package/dist/packages/agent-harness-core/src/event-tee.js +104 -0
- package/dist/packages/agent-harness-core/src/mcp-server.d.ts +25 -0
- package/dist/packages/agent-harness-core/src/mcp-server.js +169 -21
- package/dist/packages/agent-harness-core/src/predicate.d.ts +1 -1
- package/dist/packages/agent-harness-core/src/protocol.d.ts +90 -4
- package/dist/packages/agent-harness-core/src/protocol.js +15 -0
- package/dist/packages/agent-harness-core/src/visual-quality.d.ts +58 -0
- package/dist/packages/agent-harness-core/src/visual-quality.js +141 -0
- package/dist/packages/agent-harness-opentui/src/agent-mode.d.ts +6 -0
- package/dist/packages/agent-harness-opentui/src/agent-mode.js +14 -1
- package/dist/packages/agent-harness-opentui/src/input-bridge.d.ts +2 -10
- package/dist/packages/agent-harness-opentui/src/input-bridge.js +103 -16
- package/dist/packages/agent-harness-opentui/src/install.d.ts +8 -0
- package/dist/packages/agent-harness-opentui/src/install.js +10 -0
- package/dist/packages/agent-harness-opentui/src/semantic.js +12 -10
- package/dist/packages/agent-harness-opentui/src/visual-capture.d.ts +56 -0
- package/dist/packages/agent-harness-opentui/src/visual-capture.js +103 -0
- package/dist/src/agent-harness/mock-model.d.ts +38 -0
- package/dist/src/agent-harness/mock-model.js +69 -3
- package/dist/src/agent-harness/test-spawn.js +31 -0
- package/dist/src/chat/chat-keychain.d.ts +7 -12
- package/dist/src/chat/chat-keychain.js +19 -86
- package/dist/src/cli/config/screen-providers.js +1 -1
- package/dist/src/cli/cost-forensics.d.ts +10 -0
- package/dist/src/cli/cost-forensics.js +18 -3
- package/dist/src/cli/keys-bundle.d.ts +1 -1
- package/dist/src/cli/keys-bundle.js +1 -1
- package/dist/src/cli/keys.d.ts +10 -47
- package/dist/src/cli/keys.js +31 -399
- package/dist/src/council/clarifier.d.ts +31 -3
- package/dist/src/council/clarifier.js +220 -32
- package/dist/src/council/context.js +49 -15
- package/dist/src/council/debate-checkpoint.d.ts +129 -0
- package/dist/src/council/debate-checkpoint.js +176 -0
- package/dist/src/council/debate-planner.js +54 -5
- package/dist/src/council/debate-summary.d.ts +25 -0
- package/dist/src/council/debate-summary.js +85 -0
- package/dist/src/council/debate.d.ts +169 -2
- package/dist/src/council/debate.js +1265 -135
- package/dist/src/council/index.d.ts +108 -1
- package/dist/src/council/index.js +670 -197
- package/dist/src/council/leader.d.ts +26 -0
- package/dist/src/council/leader.js +150 -9
- package/dist/src/council/llm.d.ts +94 -0
- package/dist/src/council/llm.js +348 -55
- package/dist/src/council/panel-select.d.ts +30 -0
- package/dist/src/council/panel-select.js +82 -0
- package/dist/src/council/planner.js +40 -0
- package/dist/src/council/preflight.d.ts +17 -0
- package/dist/src/council/preflight.js +50 -2
- package/dist/src/council/prompts.d.ts +39 -4
- package/dist/src/council/prompts.js +256 -69
- package/dist/src/council/stance-recall.d.ts +42 -0
- package/dist/src/council/stance-recall.js +57 -0
- package/dist/src/council/strip-think.d.ts +17 -0
- package/dist/src/council/strip-think.js +33 -0
- package/dist/src/council/types.d.ts +138 -0
- package/dist/src/ee/artifact-cache.d.ts +16 -0
- package/dist/src/ee/artifact-cache.js +32 -0
- package/dist/src/ee/auth.d.ts +20 -0
- package/dist/src/ee/auth.js +54 -2
- package/dist/src/ee/bridge.d.ts +10 -0
- package/dist/src/ee/bridge.js +58 -0
- package/dist/src/ee/client.js +109 -21
- package/dist/src/ee/ee-onboarding.js +6 -26
- package/dist/src/ee/export-transcripts.d.ts +1 -0
- package/dist/src/ee/export-transcripts.js +8 -10
- package/dist/src/ee/extract-session.js +29 -0
- package/dist/src/ee/extract-style.d.ts +58 -0
- package/dist/src/ee/extract-style.js +270 -0
- package/dist/src/ee/recall-ledger.d.ts +9 -0
- package/dist/src/ee/recall-ledger.js +3 -0
- package/dist/src/ee/scope.d.ts +1 -0
- package/dist/src/ee/scope.js +26 -1
- package/dist/src/ee/search.d.ts +7 -0
- package/dist/src/ee/search.js +24 -0
- package/dist/src/ee/transcript-emit.js +2 -0
- package/dist/src/ee/types.d.ts +22 -0
- package/dist/src/ee/who-am-i-brain.d.ts +35 -0
- package/dist/src/ee/who-am-i-brain.js +220 -0
- package/dist/src/ee/who-am-i.d.ts +10 -3
- package/dist/src/ee/who-am-i.js +12 -0
- package/dist/src/ee/workflow-event.d.ts +48 -0
- package/dist/src/ee/workflow-event.js +81 -0
- package/dist/src/flow/compaction/compress.d.ts +3 -3
- package/dist/src/flow/compaction/compress.js +58 -8
- package/dist/src/flow/compaction/extract.d.ts +4 -7
- package/dist/src/flow/compaction/extract.js +50 -10
- package/dist/src/flow/compaction/index.d.ts +14 -1
- package/dist/src/flow/compaction/index.js +96 -3
- package/dist/src/flow/compaction/input-guard.d.ts +24 -0
- package/dist/src/flow/compaction/input-guard.js +43 -0
- package/dist/src/flow/compaction/progress.d.ts +35 -0
- package/dist/src/flow/compaction/progress.js +35 -0
- package/dist/src/flow/fold-planning.d.ts +36 -0
- package/dist/src/flow/fold-planning.js +83 -0
- package/dist/src/flow/hierarchy.d.ts +146 -0
- package/dist/src/flow/hierarchy.js +427 -0
- package/dist/src/flow/index.d.ts +1 -0
- package/dist/src/flow/index.js +2 -0
- package/dist/src/flow/run-artifacts.d.ts +102 -0
- package/dist/src/flow/run-artifacts.js +208 -0
- package/dist/src/generated/version.d.ts +1 -1
- package/dist/src/generated/version.js +1 -1
- package/dist/src/gsd/assessment-schema.d.ts +44 -0
- package/dist/src/gsd/assessment-schema.js +134 -0
- package/dist/src/gsd/capability-registry.d.ts +45 -0
- package/dist/src/gsd/capability-registry.js +337 -0
- package/dist/src/gsd/complexity-assessor.d.ts +39 -0
- package/dist/src/gsd/complexity-assessor.js +152 -0
- package/dist/src/gsd/config-bridge.d.ts +7 -0
- package/dist/src/gsd/config-bridge.js +114 -0
- package/dist/src/gsd/config-loader.d.ts +27 -0
- package/dist/src/gsd/config-loader.js +50 -0
- package/dist/src/gsd/council-context.d.ts +44 -0
- package/dist/src/gsd/council-context.js +114 -0
- package/dist/src/gsd/ee-closure.d.ts +28 -0
- package/dist/src/gsd/ee-closure.js +49 -0
- package/dist/src/gsd/flags.d.ts +66 -0
- package/dist/src/gsd/flags.js +102 -0
- package/dist/src/gsd/gsd-dispatch.d.ts +58 -0
- package/dist/src/gsd/gsd-dispatch.js +131 -0
- package/dist/src/gsd/gsd-runtime.d.ts +22 -0
- package/dist/src/gsd/gsd-runtime.js +37 -0
- package/dist/src/gsd/host-adapter.d.ts +11 -0
- package/dist/src/gsd/host-adapter.js +29 -0
- package/dist/src/gsd/index.d.ts +24 -1
- package/dist/src/gsd/index.js +27 -0
- package/dist/src/gsd/loop-host-contract.d.ts +21 -0
- package/dist/src/gsd/loop-host-contract.js +39 -0
- package/dist/src/gsd/loop-host.d.ts +69 -0
- package/dist/src/gsd/loop-host.js +245 -0
- package/dist/src/gsd/loop-resolver.d.ts +36 -0
- package/dist/src/gsd/loop-resolver.js +79 -0
- package/dist/src/gsd/model-tier.d.ts +13 -0
- package/dist/src/gsd/model-tier.js +45 -0
- package/dist/src/gsd/mutation-gate.d.ts +16 -0
- package/dist/src/gsd/mutation-gate.js +41 -0
- package/dist/src/gsd/native-roadmap.d.ts +89 -0
- package/dist/src/gsd/native-roadmap.js +343 -0
- package/dist/src/gsd/native-state.d.ts +47 -0
- package/dist/src/gsd/native-state.js +220 -0
- package/dist/src/gsd/paths.d.ts +23 -0
- package/dist/src/gsd/paths.js +66 -0
- package/dist/src/gsd/phase-dag.d.ts +12 -0
- package/dist/src/gsd/phase-dag.js +94 -0
- package/dist/src/gsd/phase-sync.d.ts +42 -0
- package/dist/src/gsd/phase-sync.js +321 -0
- package/dist/src/gsd/pil-gate-context.d.ts +13 -0
- package/dist/src/gsd/pil-gate-context.js +64 -0
- package/dist/src/gsd/pil-gate-critic.d.ts +19 -0
- package/dist/src/gsd/pil-gate-critic.js +74 -0
- package/dist/src/gsd/plan-council-prompts.d.ts +25 -0
- package/dist/src/gsd/plan-council-prompts.js +79 -0
- package/dist/src/gsd/plan-council.d.ts +44 -0
- package/dist/src/gsd/plan-council.js +283 -0
- package/dist/src/gsd/plan-gate-vocabulary.d.ts +40 -0
- package/dist/src/gsd/plan-gate-vocabulary.js +64 -0
- package/dist/src/gsd/product-workspace.d.ts +13 -0
- package/dist/src/gsd/product-workspace.js +124 -0
- package/dist/src/gsd/ship-bridge.d.ts +25 -0
- package/dist/src/gsd/ship-bridge.js +65 -0
- package/dist/src/gsd/state-document.d.ts +40 -0
- package/dist/src/gsd/state-document.js +163 -0
- package/dist/src/gsd/verdict-schema.d.ts +39 -0
- package/dist/src/gsd/verdict-schema.js +144 -0
- package/dist/src/gsd/verify-context.d.ts +22 -0
- package/dist/src/gsd/verify-context.js +27 -0
- package/dist/src/gsd/verify-council-prompts.d.ts +19 -0
- package/dist/src/gsd/verify-council-prompts.js +85 -0
- package/dist/src/gsd/verify-council.d.ts +25 -0
- package/dist/src/gsd/verify-council.js +119 -0
- package/dist/src/gsd/verify-gate-vocabulary.d.ts +25 -0
- package/dist/src/gsd/verify-gate-vocabulary.js +46 -0
- package/dist/src/gsd/workflow-engine.d.ts +60 -0
- package/dist/src/gsd/workflow-engine.js +207 -0
- package/dist/src/gsd/workflow-tools.d.ts +13 -0
- package/dist/src/gsd/workflow-tools.js +277 -0
- package/dist/src/headless/council-answers.js +4 -0
- package/dist/src/hooks/index.js +1 -1
- package/dist/src/index.js +172 -270
- package/dist/src/lsp/builtins.js +3 -1
- package/dist/src/lsp/manager.d.ts +5 -1
- package/dist/src/lsp/manager.js +249 -3
- package/dist/src/lsp/npm-cache.d.ts +11 -1
- package/dist/src/lsp/npm-cache.js +17 -1
- package/dist/src/lsp/runtime.d.ts +6 -1
- package/dist/src/lsp/runtime.js +17 -1
- package/dist/src/lsp/types.d.ts +83 -1
- package/dist/src/lsp/types.js +10 -0
- package/dist/src/maintain/pr-builder.js +23 -13
- package/dist/src/mcp/auto-setup.js +57 -32
- package/dist/src/mcp/client-pool.js +44 -16
- package/dist/src/mcp/lsp-tools.d.ts +5 -1
- package/dist/src/mcp/lsp-tools.js +93 -2
- package/dist/src/mcp/mcp-keychain.d.ts +3 -5
- package/dist/src/mcp/mcp-keychain.js +9 -49
- package/dist/src/mcp/research-onboarding.js +8 -7
- package/dist/src/mcp/runtime.js +34 -2
- package/dist/src/mcp/setup-guide-text.d.ts +1 -1
- package/dist/src/mcp/setup-guide-text.js +22 -2
- package/dist/src/mcp/tools-server.d.ts +10 -0
- package/dist/src/mcp/tools-server.js +10 -2
- package/dist/src/models/catalog-client.d.ts +87 -0
- package/dist/src/models/catalog-client.js +105 -38
- package/dist/src/models/catalog.json +528 -265
- package/dist/src/models/registry.d.ts +22 -7
- package/dist/src/models/registry.js +73 -10
- package/dist/src/ops/doctor.js +1 -1
- package/dist/src/orchestrator/ask-user.d.ts +61 -0
- package/dist/src/orchestrator/ask-user.js +65 -0
- package/dist/src/orchestrator/auto-commit.js +1 -1
- package/dist/src/orchestrator/batch-turn-runner.js +2 -2
- package/dist/src/orchestrator/cache-prefix.d.ts +67 -0
- package/dist/src/orchestrator/cache-prefix.js +83 -0
- package/dist/src/orchestrator/compact-request.d.ts +32 -0
- package/dist/src/orchestrator/compact-request.js +41 -0
- package/dist/src/orchestrator/compaction.d.ts +12 -3
- package/dist/src/orchestrator/compaction.js +35 -15
- package/dist/src/orchestrator/council-manager.d.ts +12 -3
- package/dist/src/orchestrator/council-manager.js +74 -32
- package/dist/src/orchestrator/council-request.d.ts +49 -0
- package/dist/src/orchestrator/council-request.js +62 -0
- package/dist/src/orchestrator/cross-turn-dedup.d.ts +6 -0
- package/dist/src/orchestrator/cross-turn-dedup.js +22 -1
- package/dist/src/orchestrator/error-utils.d.ts +29 -0
- package/dist/src/orchestrator/error-utils.js +132 -24
- package/dist/src/orchestrator/grounding-check.js +39 -1
- package/dist/src/orchestrator/interactive-pause.d.ts +26 -0
- package/dist/src/orchestrator/interactive-pause.js +36 -0
- package/dist/src/orchestrator/message-processor.d.ts +4 -0
- package/dist/src/orchestrator/message-processor.js +268 -41
- package/dist/src/orchestrator/orchestrator.d.ts +64 -3
- package/dist/src/orchestrator/orchestrator.js +823 -120
- package/dist/src/orchestrator/preprocessor.js +3 -3
- package/dist/src/orchestrator/proactive-compact-detector.d.ts +26 -0
- package/dist/src/orchestrator/proactive-compact-detector.js +36 -0
- package/dist/src/orchestrator/prompts.js +17 -17
- package/dist/src/orchestrator/reactive-delegation.d.ts +39 -0
- package/dist/src/orchestrator/reactive-delegation.js +59 -0
- package/dist/src/orchestrator/retry-classifier.d.ts +2 -1
- package/dist/src/orchestrator/retry-classifier.js +46 -2
- package/dist/src/orchestrator/safety-askcard.d.ts +1 -1
- package/dist/src/orchestrator/safety-askcard.js +5 -2
- package/dist/src/orchestrator/safety-intercept.d.ts +50 -0
- package/dist/src/orchestrator/safety-intercept.js +62 -0
- package/dist/src/orchestrator/scope-reminder.js +1 -1
- package/dist/src/orchestrator/session-experience.d.ts +2 -1
- package/dist/src/orchestrator/session-experience.js +2 -1
- package/dist/src/orchestrator/should-run-gate.d.ts +5 -0
- package/dist/src/orchestrator/should-run-gate.js +18 -0
- package/dist/src/orchestrator/stall-watchdog.d.ts +31 -3
- package/dist/src/orchestrator/stall-watchdog.js +65 -10
- package/dist/src/orchestrator/stream-runner.d.ts +13 -3
- package/dist/src/orchestrator/stream-runner.js +115 -49
- package/dist/src/orchestrator/sub-agent-cap.d.ts +13 -1
- package/dist/src/orchestrator/sub-agent-cap.js +16 -1
- package/dist/src/orchestrator/sub-agent-model-tier.d.ts +13 -1
- package/dist/src/orchestrator/sub-agent-model-tier.js +16 -2
- package/dist/src/orchestrator/subagent-compactor.d.ts +53 -1
- package/dist/src/orchestrator/subagent-compactor.js +126 -15
- package/dist/src/orchestrator/tool-engine.d.ts +41 -0
- package/dist/src/orchestrator/tool-engine.js +846 -66
- package/dist/src/orchestrator/tool-limit-auto-recover.d.ts +22 -0
- package/dist/src/orchestrator/tool-limit-auto-recover.js +30 -0
- package/dist/src/orchestrator/turn-runner-deps.d.ts +19 -0
- package/dist/src/orchestrator/turn-watchdog.d.ts +44 -0
- package/dist/src/orchestrator/turn-watchdog.js +84 -0
- package/dist/src/pil/agent-operating-contract.d.ts +1 -1
- package/dist/src/pil/agent-operating-contract.js +6 -4
- package/dist/src/pil/cheap-model-playbook.d.ts +1 -1
- package/dist/src/pil/cheap-model-playbook.js +5 -1
- package/dist/src/pil/cheap-model-workbooks.d.ts +1 -1
- package/dist/src/pil/cheap-model-workbooks.js +1 -1
- package/dist/src/pil/discovery-types.d.ts +1 -0
- package/dist/src/pil/discovery.d.ts +1 -1
- package/dist/src/pil/discovery.js +18 -13
- package/dist/src/pil/layer1-intent.d.ts +18 -6
- package/dist/src/pil/layer1-intent.js +66 -757
- package/dist/src/pil/layer15-context-scan.js +15 -1
- package/dist/src/pil/layer1_5-complexity-size.d.ts +7 -0
- package/dist/src/pil/layer1_5-complexity-size.js +31 -5
- package/dist/src/pil/layer3-ee-injection.js +23 -8
- package/dist/src/pil/layer4-gsd.js +69 -16
- package/dist/src/pil/layer5-context.js +7 -3
- package/dist/src/pil/layer6-output.d.ts +23 -0
- package/dist/src/pil/layer6-output.js +5 -1
- package/dist/src/pil/llm-classify.d.ts +111 -5
- package/dist/src/pil/llm-classify.js +421 -189
- package/dist/src/pil/native-capabilities-workbook.d.ts +1 -1
- package/dist/src/pil/native-capabilities-workbook.js +8 -0
- package/dist/src/pil/pipeline.js +36 -2
- package/dist/src/pil/repo-grounding-probe.d.ts +15 -0
- package/dist/src/pil/repo-grounding-probe.js +136 -0
- package/dist/src/pil/repo-structure-hints.d.ts +7 -0
- package/dist/src/pil/repo-structure-hints.js +45 -0
- package/dist/src/pil/response-tools.js +5 -3
- package/dist/src/pil/schema.d.ts +1 -0
- package/dist/src/pil/schema.js +2 -0
- package/dist/src/pil/types.d.ts +18 -0
- package/dist/src/playbook/directives.d.ts +4 -0
- package/dist/src/playbook/directives.js +17 -5
- package/dist/src/product-loop/artifact-io.js +4 -0
- package/dist/src/product-loop/backlog-builder.d.ts +14 -1
- package/dist/src/product-loop/backlog-builder.js +30 -6
- package/dist/src/product-loop/criteria-seed.d.ts +51 -0
- package/dist/src/product-loop/criteria-seed.js +200 -0
- package/dist/src/product-loop/discovery-context-format.js +3 -1
- package/dist/src/product-loop/discovery-ecosystem.js +4 -1
- package/dist/src/product-loop/discovery-interview.d.ts +9 -0
- package/dist/src/product-loop/discovery-interview.js +60 -12
- package/dist/src/product-loop/discovery-recommender.js +2 -1
- package/dist/src/product-loop/discovery-schema.js +19 -2
- package/dist/src/product-loop/discovery-triage.d.ts +23 -0
- package/dist/src/product-loop/discovery-triage.js +109 -0
- package/dist/src/product-loop/gather.js +150 -2
- package/dist/src/product-loop/ideal-trace.d.ts +7 -0
- package/dist/src/product-loop/ideal-trace.js +64 -0
- package/dist/src/product-loop/index.d.ts +13 -1
- package/dist/src/product-loop/index.js +340 -52
- package/dist/src/product-loop/loop-driver.d.ts +7 -0
- package/dist/src/product-loop/loop-driver.js +330 -106
- package/dist/src/product-loop/phase-plan.d.ts +21 -0
- package/dist/src/product-loop/phase-plan.js +81 -6
- package/dist/src/product-loop/phase-rituals.d.ts +3 -0
- package/dist/src/product-loop/phase-rituals.js +8 -3
- package/dist/src/product-loop/phase-runner.js +39 -12
- package/dist/src/product-loop/plan-adherence-review.d.ts +26 -0
- package/dist/src/product-loop/plan-adherence-review.js +144 -0
- package/dist/src/product-loop/sprint-runner.d.ts +173 -0
- package/dist/src/product-loop/sprint-runner.js +863 -19
- package/dist/src/product-loop/types.d.ts +61 -5
- package/dist/src/providers/adapter.d.ts +1 -1
- package/dist/src/providers/adapter.js +3 -4
- package/dist/src/providers/anthropic.d.ts +9 -8
- package/dist/src/providers/anthropic.js +13 -47
- package/dist/src/providers/auth/browser-flow.d.ts +1 -1
- package/dist/src/providers/auth/browser-flow.js +1 -1
- package/dist/src/providers/auth/grok-oauth.d.ts +1 -0
- package/dist/src/providers/auth/grok-oauth.js +30 -5
- package/dist/src/providers/auth/openai-oauth.d.ts +1 -0
- package/dist/src/providers/auth/openai-oauth.js +15 -1
- package/dist/src/providers/auth/registry.js +0 -34
- package/dist/src/providers/auth/token-store.d.ts +9 -9
- package/dist/src/providers/auth/token-store.js +8 -67
- package/dist/src/providers/auth/types.d.ts +9 -1
- package/dist/src/providers/auth/types.js +1 -1
- package/dist/src/providers/capabilities.d.ts +24 -5
- package/dist/src/providers/capabilities.js +42 -24
- package/dist/src/providers/endpoints.d.ts +2 -2
- package/dist/src/providers/endpoints.js +11 -10
- package/dist/src/providers/env-store.d.ts +17 -0
- package/dist/src/providers/env-store.js +228 -0
- package/dist/src/providers/keychain.d.ts +22 -18
- package/dist/src/providers/keychain.js +127 -140
- package/dist/src/providers/mcp-vision-bridge.js +56 -146
- package/dist/src/providers/openai-compatible.js +8 -1
- package/dist/src/providers/pricing.d.ts +2 -2
- package/dist/src/providers/pricing.js +3 -13
- package/dist/src/providers/runtime.d.ts +43 -3
- package/dist/src/providers/runtime.js +88 -14
- package/dist/src/providers/strategies/base.strategy.d.ts +16 -0
- package/dist/src/providers/strategies/base.strategy.js +24 -1
- package/dist/src/providers/strategies/{siliconflow.strategy.d.ts → opencode-go.strategy.d.ts} +3 -3
- package/dist/src/providers/strategies/opencode-go.strategy.js +83 -0
- package/dist/src/providers/strategies/registry.js +4 -4
- package/dist/src/providers/strategies/thinking-mode.d.ts +109 -0
- package/dist/src/providers/strategies/thinking-mode.js +288 -1
- package/dist/src/providers/strategies/xai.strategy.js +27 -0
- package/dist/src/providers/strategies/zai.strategy.d.ts +14 -0
- package/dist/src/providers/strategies/zai.strategy.js +44 -0
- package/dist/src/providers/types.d.ts +5 -6
- package/dist/src/providers/types.js +2 -2
- package/dist/src/providers/vision-backend.d.ts +47 -0
- package/dist/src/providers/vision-backend.js +258 -0
- package/dist/src/providers/vision-proxy.d.ts +22 -9
- package/dist/src/providers/vision-proxy.js +63 -132
- package/dist/src/providers/warm.d.ts +65 -0
- package/dist/src/providers/warm.js +145 -0
- package/dist/src/providers/wire-debug.js +95 -0
- package/dist/src/router/decide.d.ts +13 -0
- package/dist/src/router/decide.js +138 -36
- package/dist/src/router/peak-hour.d.ts +38 -0
- package/dist/src/router/peak-hour.js +107 -0
- package/dist/src/router/step-router.js +3 -2
- package/dist/src/router/warm.js +4 -5
- package/dist/src/scaffold/continuation-prompt.d.ts +11 -0
- package/dist/src/scaffold/continuation-prompt.js +26 -0
- package/dist/src/scaffold/point-to-existing.d.ts +21 -0
- package/dist/src/scaffold/point-to-existing.js +25 -0
- package/dist/src/self-qa/agentic-loop.js +6 -5
- package/dist/src/{ui/state → state}/active-run.d.ts +19 -0
- package/dist/src/{ui/state → state}/active-run.js +21 -0
- package/dist/src/{ui/status-bar/store.d.ts → state/status-bar-store.d.ts} +4 -1
- package/dist/src/{ui/status-bar/store.js → state/status-bar-store.js} +12 -9
- package/dist/src/state/turn-trace.d.ts +43 -0
- package/dist/src/state/turn-trace.js +32 -0
- package/dist/src/storage/db.js +2 -1
- package/dist/src/storage/index.d.ts +1 -1
- package/dist/src/storage/index.js +1 -1
- package/dist/src/storage/interaction-log.d.ts +1 -1
- package/dist/src/storage/migrations.js +71 -1
- package/dist/src/storage/sessions.d.ts +28 -10
- package/dist/src/storage/sessions.js +78 -21
- package/dist/src/storage/transcript-view.js +1 -1
- package/dist/src/storage/transcript.d.ts +51 -0
- package/dist/src/storage/transcript.js +340 -15
- package/dist/src/tools/file.d.ts +15 -0
- package/dist/src/tools/file.js +32 -0
- package/dist/src/tools/git-safety.d.ts +19 -0
- package/dist/src/tools/git-safety.js +168 -0
- package/dist/src/tools/native-tools.d.ts +1 -1
- package/dist/src/tools/native-tools.js +81 -1
- package/dist/src/tools/registry.d.ts +20 -0
- package/dist/src/tools/registry.js +576 -23
- package/dist/src/tools/research.d.ts +29 -0
- package/dist/src/tools/research.js +233 -0
- package/dist/src/types/index.d.ts +147 -4
- package/dist/src/ui/app.js +0 -0
- package/dist/src/ui/cards/product-status-card.js +1 -1
- package/dist/src/ui/components/agent-rail-activities.d.ts +26 -0
- package/dist/src/ui/components/agent-rail-activities.js +47 -0
- package/dist/src/ui/components/bubble-body-guard.d.ts +27 -0
- package/dist/src/ui/components/bubble-body-guard.js +50 -0
- package/dist/src/ui/components/compact-progress-card.d.ts +24 -0
- package/dist/src/ui/components/compact-progress-card.js +42 -0
- package/dist/src/ui/components/context-rail.d.ts +26 -0
- package/dist/src/ui/components/context-rail.js +33 -0
- package/dist/src/ui/components/council-conclusion-card.d.ts +73 -0
- package/dist/src/ui/components/council-conclusion-card.js +420 -0
- package/dist/src/ui/components/council-debate-pill.d.ts +36 -0
- package/dist/src/ui/components/council-debate-pill.js +34 -0
- package/dist/src/ui/components/council-info-card.js +2 -2
- package/dist/src/ui/components/council-leader-bubble.d.ts +10 -3
- package/dist/src/ui/components/council-leader-bubble.js +21 -11
- package/dist/src/ui/components/council-message-bubble.d.ts +15 -2
- package/dist/src/ui/components/council-message-bubble.js +16 -15
- package/dist/src/ui/components/council-phase-timeline.d.ts +9 -1
- package/dist/src/ui/components/council-phase-timeline.js +66 -17
- package/dist/src/ui/components/council-placeholder-bubble.d.ts +16 -9
- package/dist/src/ui/components/council-placeholder-bubble.js +32 -29
- package/dist/src/ui/components/council-question-card.js +13 -12
- package/dist/src/ui/components/council-rail-rounds.d.ts +26 -0
- package/dist/src/ui/components/council-rail-rounds.js +57 -0
- package/dist/src/ui/components/council-round-group.d.ts +38 -0
- package/dist/src/ui/components/council-round-group.js +88 -0
- package/dist/src/ui/components/council-status-list.d.ts +3 -1
- package/dist/src/ui/components/council-status-list.js +36 -24
- package/dist/src/ui/components/council-synthesis-banner.d.ts +7 -2
- package/dist/src/ui/components/council-synthesis-banner.js +20 -5
- package/dist/src/ui/components/halt-recovery-card.js +9 -5
- package/dist/src/ui/components/jump-to-latest-pill.d.ts +11 -0
- package/dist/src/ui/components/jump-to-latest-pill.js +14 -0
- package/dist/src/ui/components/message-view.d.ts +15 -0
- package/dist/src/ui/components/message-view.js +50 -1
- package/dist/src/ui/components/prompt-box.js +18 -16
- package/dist/src/ui/components/session-tree-card.d.ts +14 -0
- package/dist/src/ui/components/session-tree-card.js +46 -0
- package/dist/src/ui/components/slash-inline-menu.d.ts +12 -0
- package/dist/src/ui/components/slash-inline-menu.js +26 -5
- package/dist/src/ui/components/task-list-panel.d.ts +14 -1
- package/dist/src/ui/components/task-list-panel.js +22 -2
- package/dist/src/ui/components/tool-group.d.ts +15 -3
- package/dist/src/ui/components/tool-group.js +69 -11
- package/dist/src/ui/containers/modals-layer.d.ts +4 -2
- package/dist/src/ui/containers/modals-layer.js +2 -2
- package/dist/src/ui/council-harness-event.d.ts +57 -0
- package/dist/src/ui/council-harness-event.js +46 -0
- package/dist/src/ui/heartbeat-debug.d.ts +29 -0
- package/dist/src/ui/heartbeat-debug.js +45 -0
- package/dist/src/ui/hooks/use-session-picker.d.ts +3 -3
- package/dist/src/ui/mcp-modal.js +2 -4
- package/dist/src/ui/modals/api-key-modal.js +1 -1
- package/dist/src/ui/modals/connect-modal.js +4 -3
- package/dist/src/ui/modals/model-picker-modal.d.ts +8 -18
- package/dist/src/ui/modals/model-picker-modal.js +8 -10
- package/dist/src/ui/modals/session-picker-modal.d.ts +2 -2
- package/dist/src/ui/modals/session-picker-modal.js +3 -5
- package/dist/src/ui/picker-providers.d.ts +1 -1
- package/dist/src/ui/picker-providers.js +1 -1
- package/dist/src/ui/primitives/index.d.ts +1 -0
- package/dist/src/ui/primitives/index.js +2 -0
- package/dist/src/ui/primitives/semantic-primitives.d.ts +76 -0
- package/dist/src/ui/primitives/semantic-primitives.js +81 -0
- package/dist/src/ui/slash/compact.js +5 -7
- package/dist/src/ui/slash/cost.js +1 -1
- package/dist/src/ui/slash/council.js +19 -1
- package/dist/src/ui/slash/debug.d.ts +3 -31
- package/dist/src/ui/slash/debug.js +9 -20
- package/dist/src/ui/slash/ee.js +81 -0
- package/dist/src/ui/slash/ideal.d.ts +6 -2
- package/dist/src/ui/slash/ideal.js +97 -7
- package/dist/src/ui/slash/menu-items.d.ts +7 -0
- package/dist/src/ui/slash/menu-items.js +23 -20
- package/dist/src/ui/slash/registry.d.ts +2 -0
- package/dist/src/ui/slash/registry.js +4 -0
- package/dist/src/ui/status-bar/cache-hit.d.ts +6 -0
- package/dist/src/ui/status-bar/cache-hit.js +9 -0
- package/dist/src/ui/status-bar/index.d.ts +1 -1
- package/dist/src/ui/status-bar/index.js +7 -3
- package/dist/src/ui/status-bar/usd-meter.d.ts +5 -4
- package/dist/src/ui/status-bar/usd-meter.js +6 -4
- package/dist/src/ui/theme.d.ts +1 -0
- package/dist/src/ui/theme.js +2 -0
- package/dist/src/ui/types.d.ts +7 -0
- package/dist/src/ui/use-app-logic.js +0 -0
- package/dist/src/ui/utils/agent-activities.d.ts +39 -0
- package/dist/src/ui/utils/agent-activities.js +96 -0
- package/dist/src/ui/utils/format.d.ts +14 -0
- package/dist/src/ui/utils/format.js +23 -3
- package/dist/src/ui/utils/group-tool-entries.d.ts +26 -0
- package/dist/src/ui/utils/group-tool-entries.js +111 -0
- package/dist/src/ui/utils/tool-summary.d.ts +21 -0
- package/dist/src/ui/utils/tool-summary.js +91 -0
- package/dist/src/usage/downgrade.js +2 -2
- package/dist/src/usage/product-ledger.js +2 -2
- package/dist/src/utils/event-loop-monitor.d.ts +85 -0
- package/dist/src/utils/event-loop-monitor.js +107 -0
- package/dist/src/utils/install-manager.js +2 -1
- package/dist/src/utils/llm-deadline.d.ts +14 -0
- package/dist/src/utils/llm-deadline.js +19 -0
- package/dist/src/utils/logger.js +2 -2
- package/dist/src/utils/loop-profiler.d.ts +102 -0
- package/dist/src/utils/loop-profiler.js +202 -0
- package/dist/src/utils/permission-mode.js +5 -3
- package/dist/src/utils/redactor.js +1 -1
- package/dist/src/utils/settings.d.ts +180 -5
- package/dist/src/utils/settings.js +271 -31
- package/dist/src/utils/side-question.d.ts +1 -2
- package/dist/src/utils/side-question.js +2 -2
- package/dist/src/utils/visible-retry.d.ts +11 -0
- package/dist/src/utils/visible-retry.js +10 -1
- package/dist/src/verify/entrypoint.d.ts +1 -1
- package/dist/src/verify/entrypoint.js +52 -17
- package/dist/src/verify/orchestrator.d.ts +1 -1
- package/dist/src/verify/orchestrator.js +20 -3
- package/dist/src/verify/recipes.d.ts +13 -0
- package/dist/src/verify/recipes.js +15 -0
- package/package.json +134 -132
- package/dist/src/cli/bw-vault.d.ts +0 -55
- package/dist/src/cli/bw-vault.js +0 -133
- package/dist/src/mcp/ee-tools.d.ts +0 -46
- package/dist/src/mcp/ee-tools.js +0 -193
- package/dist/src/providers/auth/gcloud.d.ts +0 -28
- package/dist/src/providers/auth/gcloud.js +0 -102
- package/dist/src/providers/auth/gemini-oauth.d.ts +0 -82
- package/dist/src/providers/auth/gemini-oauth.js +0 -472
- package/dist/src/providers/gemini.d.ts +0 -11
- package/dist/src/providers/gemini.js +0 -45
- package/dist/src/providers/siliconflow-sse-repair.d.ts +0 -58
- package/dist/src/providers/siliconflow-sse-repair.js +0 -177
- package/dist/src/providers/strategies/google.strategy.d.ts +0 -22
- package/dist/src/providers/strategies/google.strategy.js +0 -174
- package/dist/src/providers/strategies/siliconflow.strategy.js +0 -29
- package/dist/src/ui/containers/chat-feed.d.ts +0 -40
- package/dist/src/ui/containers/chat-feed.js +0 -66
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { generateText } from "ai";
|
|
2
2
|
import { isMetaAnalysisPrompt } from "../pil/layer6-output.js";
|
|
3
3
|
import { getProviderCapabilities } from "../providers/capabilities.js";
|
|
4
|
-
import { requireRuntimeProvider, resolveModelRuntime } from "../providers/runtime.js";
|
|
4
|
+
import { requireRuntimeProvider, resolveModelRuntime, resolveTemperatureParam } from "../providers/runtime.js";
|
|
5
|
+
import { logger } from "../utils/logger.js";
|
|
5
6
|
import { COMPACT_PROPOSER_SYSTEM_PROMPT } from "./compaction-proposer-prompt.js";
|
|
6
7
|
import { containsEncryptedReasoning } from "./reasoning.js";
|
|
7
8
|
import { countTokens } from "./token-counter.js";
|
|
@@ -10,9 +11,9 @@ import { countTokens } from "./token-counter.js";
|
|
|
10
11
|
* The model sees the current messages and decides whether compaction is needed at all.
|
|
11
12
|
* Returns null if the proposer call fails (caller should fall back gracefully).
|
|
12
13
|
*/
|
|
13
|
-
export async function proposeCompaction(
|
|
14
|
+
export async function proposeCompaction(modelId, messages, signal) {
|
|
14
15
|
try {
|
|
15
|
-
const runtime = resolveModelRuntime(
|
|
16
|
+
const runtime = resolveModelRuntime(modelId);
|
|
16
17
|
const compactCaps = getProviderCapabilities(requireRuntimeProvider(runtime));
|
|
17
18
|
const serialized = serializeConversation(messages);
|
|
18
19
|
const result = await generateText({
|
|
@@ -21,28 +22,35 @@ export async function proposeCompaction(provider, modelId, messages, signal) {
|
|
|
21
22
|
prompt: `Current conversation messages:\n\n${serialized}\n\nDecide if compaction is needed and what to keep/drop/summarize. Return strict JSON.`,
|
|
22
23
|
abortSignal: signal,
|
|
23
24
|
maxRetries: 1,
|
|
24
|
-
|
|
25
|
+
...resolveTemperatureParam(runtime, 0.1),
|
|
25
26
|
...(!compactCaps.acceptsParam("maxOutputTokens", runtime.modelInfo) ? {} : { maxOutputTokens: 2048 }),
|
|
26
27
|
...(runtime.providerOptions ? { providerOptions: runtime.providerOptions } : {}),
|
|
27
28
|
});
|
|
28
29
|
const text = result.text.trim();
|
|
29
|
-
// Attempt to parse
|
|
30
|
-
const
|
|
31
|
-
|
|
30
|
+
// Attempt to parse JSON object robustly, even if the model wraps it in conversational text or markdown fences.
|
|
31
|
+
const jsonMatch = text.match(/\{[\s\S]*\}/);
|
|
32
|
+
if (!jsonMatch) {
|
|
33
|
+
logger.warn("orchestrator", "Failed to extract JSON from proposer output", { text });
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
32
37
|
// Validate shape
|
|
33
38
|
if (typeof parsed.shouldCompact !== "boolean" || !Array.isArray(parsed.actions)) {
|
|
39
|
+
logger.warn("orchestrator", "Invalid JSON shape from proposer", { parsed });
|
|
34
40
|
return null;
|
|
35
41
|
}
|
|
36
42
|
// Validate each action
|
|
37
43
|
for (const action of parsed.actions) {
|
|
38
44
|
if (typeof action.messageIndex !== "number" || !["keep", "drop", "summarize"].includes(action.action)) {
|
|
45
|
+
logger.warn("orchestrator", "Invalid action shape from proposer", { action });
|
|
39
46
|
return null;
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
49
|
return parsed;
|
|
43
50
|
}
|
|
44
|
-
catch {
|
|
51
|
+
catch (err) {
|
|
45
52
|
// Proposer failure is non-fatal — caller falls back to heuristic or no-compact
|
|
53
|
+
logger.warn("orchestrator", "Proposer failure", { error: err });
|
|
46
54
|
return null;
|
|
47
55
|
}
|
|
48
56
|
}
|
|
@@ -347,6 +355,18 @@ export function estimateConversationTokens(systemPrompt, messages, inFlightText
|
|
|
347
355
|
export function shouldCompactContext(contextTokens, contextWindow, settings) {
|
|
348
356
|
return contextTokens > contextWindow - settings.reserveTokens;
|
|
349
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Cross-turn anti-thrash guard: true when a post-turn compaction should be
|
|
360
|
+
* SKIPPED because too few new tokens have accumulated since the last
|
|
361
|
+
* compaction's `tokensAfter` — i.e. the cache-reset cost would not be
|
|
362
|
+
* amortized (observed: session ff932f8568e8 re-compacted after only ~14K
|
|
363
|
+
* new tokens against a 20K floor).
|
|
364
|
+
*
|
|
365
|
+
* `lastAfter === null` means no prior compaction this session — never skip.
|
|
366
|
+
*/
|
|
367
|
+
export function isCompactionThrash(tokens, lastAfter, minNew) {
|
|
368
|
+
return lastAfter !== null && tokens - lastAfter < minNew;
|
|
369
|
+
}
|
|
350
370
|
function isValidCutPoint(message) {
|
|
351
371
|
return message.role !== "tool";
|
|
352
372
|
}
|
|
@@ -497,7 +517,7 @@ function readUsage(usage) {
|
|
|
497
517
|
: 0;
|
|
498
518
|
return { promptTokens: prompt, completionTokens: completion };
|
|
499
519
|
}
|
|
500
|
-
async function summarizeConversation(
|
|
520
|
+
async function summarizeConversation(modelId, messages, reserveTokens, customInstructions, previousSummary, promptOverride, signal) {
|
|
501
521
|
const serialized = serializeConversation(messages);
|
|
502
522
|
const promptParts = [serialized];
|
|
503
523
|
// Improvement from session df2dbb878984 analysis: detect meta-analysis (self-evaluation of agent/PIL)
|
|
@@ -515,7 +535,7 @@ async function summarizeConversation(provider, modelId, messages, reserveTokens,
|
|
|
515
535
|
if (customInstructions?.trim()) {
|
|
516
536
|
promptParts.push(`Additional focus: ${customInstructions.trim()}`);
|
|
517
537
|
}
|
|
518
|
-
const runtime = resolveModelRuntime(
|
|
538
|
+
const runtime = resolveModelRuntime(modelId);
|
|
519
539
|
const compactCaps = getProviderCapabilities(requireRuntimeProvider(runtime));
|
|
520
540
|
const result = await generateText({
|
|
521
541
|
model: runtime.model,
|
|
@@ -523,7 +543,7 @@ async function summarizeConversation(provider, modelId, messages, reserveTokens,
|
|
|
523
543
|
prompt: promptParts.filter(Boolean).join("\n\n"),
|
|
524
544
|
abortSignal: signal,
|
|
525
545
|
maxRetries: 0,
|
|
526
|
-
|
|
546
|
+
...resolveTemperatureParam(runtime, 0.2),
|
|
527
547
|
...(!compactCaps.acceptsParam("maxOutputTokens", runtime.modelInfo) ? {} : { maxOutputTokens: effectiveMax }),
|
|
528
548
|
...(runtime.providerOptions ? { providerOptions: runtime.providerOptions } : {}),
|
|
529
549
|
});
|
|
@@ -538,14 +558,14 @@ function addUsage(a, b) {
|
|
|
538
558
|
completionTokens: a.completionTokens + b.completionTokens,
|
|
539
559
|
};
|
|
540
560
|
}
|
|
541
|
-
export async function generateCompactionSummary(
|
|
561
|
+
export async function generateCompactionSummary(modelId, preparation, customInstructions, signal) {
|
|
542
562
|
const { messagesToSummarize, turnPrefixMessages, isSplitTurn, previousSummary, settings } = preparation;
|
|
543
563
|
if (isSplitTurn && turnPrefixMessages.length > 0) {
|
|
544
564
|
const [historyResult, prefixResult] = await Promise.all([
|
|
545
565
|
messagesToSummarize.length > 0
|
|
546
|
-
? summarizeConversation(
|
|
566
|
+
? summarizeConversation(modelId, messagesToSummarize, settings.reserveTokens, customInstructions, previousSummary, undefined, signal)
|
|
547
567
|
: Promise.resolve({ summary: previousSummary?.trim() || "", usage: emptyUsage() }),
|
|
548
|
-
summarizeConversation(
|
|
568
|
+
summarizeConversation(modelId, turnPrefixMessages, settings.reserveTokens, undefined, undefined, TURN_PREFIX_SUMMARIZATION_PROMPT, signal),
|
|
549
569
|
]);
|
|
550
570
|
const usage = addUsage(historyResult.usage, prefixResult.usage);
|
|
551
571
|
if (historyResult.summary && prefixResult.summary) {
|
|
@@ -553,6 +573,6 @@ export async function generateCompactionSummary(provider, modelId, preparation,
|
|
|
553
573
|
}
|
|
554
574
|
return { summary: (historyResult.summary || prefixResult.summary).trim(), usage };
|
|
555
575
|
}
|
|
556
|
-
return summarizeConversation(
|
|
576
|
+
return summarizeConversation(modelId, messagesToSummarize, settings.reserveTokens, customInstructions, previousSummary, undefined, signal);
|
|
557
577
|
}
|
|
558
578
|
//# sourceMappingURL=compaction.js.map
|
|
@@ -36,6 +36,12 @@ export interface CouncilManagerDeps {
|
|
|
36
36
|
export declare class CouncilManager {
|
|
37
37
|
private deps;
|
|
38
38
|
private _lastSynthesis;
|
|
39
|
+
/**
|
|
40
|
+
* Post-debate action the user chose on the last runCouncilV2 (e.g.
|
|
41
|
+
* "continue_session", "save_exit"). Relayed to the auto-council caller
|
|
42
|
+
* (tool-engine) so it can honor the choice instead of always continuing.
|
|
43
|
+
*/
|
|
44
|
+
private _lastPostDebateAction;
|
|
39
45
|
private _isContinuation;
|
|
40
46
|
private _questionResolvers;
|
|
41
47
|
private _preflightResolvers;
|
|
@@ -49,10 +55,12 @@ export declare class CouncilManager {
|
|
|
49
55
|
constructor(deps: CouncilManagerDeps);
|
|
50
56
|
get lastSynthesis(): string | null;
|
|
51
57
|
setLastSynthesis(v: string | null): void;
|
|
58
|
+
get lastPostDebateAction(): string | null;
|
|
59
|
+
setLastPostDebateAction(v: string | null): void;
|
|
52
60
|
get isContinuation(): boolean;
|
|
53
61
|
setContinuation(v: boolean): void;
|
|
54
62
|
resetStats(startMs?: number): void;
|
|
55
|
-
respondToQuestion(questionId: string, answer: string): void;
|
|
63
|
+
respondToQuestion(questionId: string, answer: string, questionText?: string): void;
|
|
56
64
|
respondToPreflight(preflightId: string, approved: boolean): void;
|
|
57
65
|
createQuestionResponder(): (questionId: string) => Promise<string>;
|
|
58
66
|
createPreflightResponder(): (preflightId: string) => Promise<boolean>;
|
|
@@ -84,8 +92,9 @@ export declare class CouncilManager {
|
|
|
84
92
|
generateRoundSummary(exchangeLogs: Map<string, string[]>, topic: string, round: number, modelId: string): Promise<string>;
|
|
85
93
|
/**
|
|
86
94
|
* Build conversation context for council discussion from current session messages.
|
|
87
|
-
* Extracts: compaction summary, recent user
|
|
88
|
-
*
|
|
95
|
+
* Extracts: compaction summary, recent conversation (user + analytical assistant),
|
|
96
|
+
* key decisions/outcomes/plans.
|
|
97
|
+
* Limited to ~8000 tokens (~32K chars) to balance depth vs cost.
|
|
89
98
|
*/
|
|
90
99
|
buildContext(): string;
|
|
91
100
|
parseOutcome(synthesisText: string, _topic: string): CouncilOutcome | null;
|
|
@@ -11,14 +11,15 @@
|
|
|
11
11
|
// original orchestrator.ts (see commit history), only `this.xxx` → `this.deps.xxx()`
|
|
12
12
|
// transposition where the field/method originally lived on Agent.
|
|
13
13
|
import { generateText, stepCountIs } from "ai";
|
|
14
|
-
import {
|
|
14
|
+
import { getModelsForProvider } from "../models/registry.js";
|
|
15
15
|
import { loadKeyForProvider } from "../providers/keychain.js";
|
|
16
|
-
import { createProviderFactory, detectProviderForModel, resolveModelRuntime, shouldDropParam, } from "../providers/runtime.js";
|
|
16
|
+
import { createProviderFactory, detectProviderForModel, resolveModelRuntime, resolveTemperatureParam, shouldDropParam, } from "../providers/runtime.js";
|
|
17
17
|
import { ALL_PROVIDER_IDS } from "../providers/types.js";
|
|
18
|
+
import { getRoutedModelByTier } from "../router/peak-hour.js";
|
|
18
19
|
import { appendSystemMessage } from "../storage/index.js";
|
|
19
20
|
import { createBuiltinTools } from "../tools/registry.js";
|
|
20
21
|
import { isProviderDisabled } from "../utils/settings.js";
|
|
21
|
-
import { COUNCIL_COLOR_BG, COUNCIL_COLOR_RESET, COUNCIL_ROLE_COLORS
|
|
22
|
+
import { COUNCIL_COLOR_BG, COUNCIL_COLOR_RESET, COUNCIL_ROLE_COLORS } from "./agent-options.js";
|
|
22
23
|
import { extractUserContent, getCompactionSummaryText, isCompactionSummaryMessage } from "./compaction.js";
|
|
23
24
|
/**
|
|
24
25
|
* CouncilManager — extracted council subsystem.
|
|
@@ -35,6 +36,12 @@ export class CouncilManager {
|
|
|
35
36
|
deps;
|
|
36
37
|
// ---- Mutable state (was Agent private fields) ----
|
|
37
38
|
_lastSynthesis = null;
|
|
39
|
+
/**
|
|
40
|
+
* Post-debate action the user chose on the last runCouncilV2 (e.g.
|
|
41
|
+
* "continue_session", "save_exit"). Relayed to the auto-council caller
|
|
42
|
+
* (tool-engine) so it can honor the choice instead of always continuing.
|
|
43
|
+
*/
|
|
44
|
+
_lastPostDebateAction = null;
|
|
38
45
|
_isContinuation = false;
|
|
39
46
|
_questionResolvers = new Map();
|
|
40
47
|
_preflightResolvers = new Map();
|
|
@@ -52,6 +59,12 @@ export class CouncilManager {
|
|
|
52
59
|
setLastSynthesis(v) {
|
|
53
60
|
this._lastSynthesis = v;
|
|
54
61
|
}
|
|
62
|
+
get lastPostDebateAction() {
|
|
63
|
+
return this._lastPostDebateAction;
|
|
64
|
+
}
|
|
65
|
+
setLastPostDebateAction(v) {
|
|
66
|
+
this._lastPostDebateAction = v;
|
|
67
|
+
}
|
|
55
68
|
get isContinuation() {
|
|
56
69
|
return this._isContinuation;
|
|
57
70
|
}
|
|
@@ -62,7 +75,7 @@ export class CouncilManager {
|
|
|
62
75
|
this.stats = { calls: 0, startMs: startMs ?? 0 };
|
|
63
76
|
}
|
|
64
77
|
// ---- Public responder API (delegated from Agent.respondToCouncilQuestion etc) ----
|
|
65
|
-
respondToQuestion(questionId, answer) {
|
|
78
|
+
respondToQuestion(questionId, answer, questionText) {
|
|
66
79
|
if (process.env.MUONROI_DEBUG_LEADER === "1") {
|
|
67
80
|
process.stderr.write(`[responder] respondToCouncilQuestion: ${JSON.stringify({
|
|
68
81
|
questionId,
|
|
@@ -75,6 +88,14 @@ export class CouncilManager {
|
|
|
75
88
|
if (resolver) {
|
|
76
89
|
resolver(answer);
|
|
77
90
|
this._questionResolvers.delete(questionId);
|
|
91
|
+
if (questionText) {
|
|
92
|
+
import("../gsd/phase-sync.js")
|
|
93
|
+
.then(({ appendClarificationToContext }) => {
|
|
94
|
+
const cwd = this.deps.getBash().getCwd();
|
|
95
|
+
appendClarificationToContext(cwd, questionText, answer);
|
|
96
|
+
})
|
|
97
|
+
.catch(() => { });
|
|
98
|
+
}
|
|
78
99
|
}
|
|
79
100
|
else {
|
|
80
101
|
// Headless auto-answer: response arrived before the generator registered
|
|
@@ -128,14 +149,14 @@ export class CouncilManager {
|
|
|
128
149
|
async generate(modelId, system, prompt, maxTokens = 2048) {
|
|
129
150
|
const providerId = detectProviderForModel(modelId);
|
|
130
151
|
const key = await loadKeyForProvider(providerId);
|
|
131
|
-
|
|
132
|
-
const runtime = resolveModelRuntime(
|
|
152
|
+
ensureCouncilProvider(providerId, key);
|
|
153
|
+
const runtime = resolveModelRuntime(modelId);
|
|
133
154
|
const { text } = await generateText({
|
|
134
155
|
model: runtime.model,
|
|
135
156
|
system,
|
|
136
157
|
prompt,
|
|
137
158
|
...(shouldDropParam(runtime, "maxOutputTokens") ? {} : { maxOutputTokens: maxTokens }),
|
|
138
|
-
...(
|
|
159
|
+
...resolveTemperatureParam(runtime, 0.7),
|
|
139
160
|
...(runtime.providerOptions ? { providerOptions: runtime.providerOptions } : {}),
|
|
140
161
|
});
|
|
141
162
|
this.stats.calls++;
|
|
@@ -149,11 +170,12 @@ export class CouncilManager {
|
|
|
149
170
|
async research(modelId, topic, conversationContext, signal) {
|
|
150
171
|
const providerId = detectProviderForModel(modelId);
|
|
151
172
|
const key = await loadKeyForProvider(providerId);
|
|
152
|
-
|
|
153
|
-
const runtime = resolveModelRuntime(
|
|
173
|
+
ensureCouncilProvider(providerId, key);
|
|
174
|
+
const runtime = resolveModelRuntime(modelId);
|
|
154
175
|
// Build tool set with bash, grep, read_file for codebase research
|
|
155
176
|
const researchTools = createBuiltinTools(this.deps.getBash(), this.deps.getMode(), {
|
|
156
|
-
|
|
177
|
+
// research phase intentionally has no runTask/runDelegation handlers
|
|
178
|
+
sessionId: this.deps.getSessionId() ?? undefined,
|
|
157
179
|
});
|
|
158
180
|
const systemPrompt = `You are a research specialist. Your job is to gather FACTS about the topic below.\n\n` +
|
|
159
181
|
`## Instructions\n` +
|
|
@@ -182,7 +204,7 @@ export class CouncilManager {
|
|
|
182
204
|
tools: researchTools,
|
|
183
205
|
stopWhen: stepCountIs(10),
|
|
184
206
|
...(shouldDropParam(runtime, "maxOutputTokens") ? {} : { maxOutputTokens: 4096 }),
|
|
185
|
-
...(
|
|
207
|
+
...resolveTemperatureParam(runtime, 0.3),
|
|
186
208
|
...(runtime.providerOptions ? { providerOptions: runtime.providerOptions } : {}),
|
|
187
209
|
...(signal ? { abortSignal: signal } : {}),
|
|
188
210
|
});
|
|
@@ -251,8 +273,9 @@ export class CouncilManager {
|
|
|
251
273
|
}
|
|
252
274
|
/**
|
|
253
275
|
* Build conversation context for council discussion from current session messages.
|
|
254
|
-
* Extracts: compaction summary, recent user
|
|
255
|
-
*
|
|
276
|
+
* Extracts: compaction summary, recent conversation (user + analytical assistant),
|
|
277
|
+
* key decisions/outcomes/plans.
|
|
278
|
+
* Limited to ~8000 tokens (~32K chars) to balance depth vs cost.
|
|
256
279
|
*/
|
|
257
280
|
buildContext() {
|
|
258
281
|
const messages = this.deps.getMessages();
|
|
@@ -267,34 +290,52 @@ export class CouncilManager {
|
|
|
267
290
|
}
|
|
268
291
|
}
|
|
269
292
|
}
|
|
270
|
-
// 2. Recent user
|
|
271
|
-
|
|
272
|
-
|
|
293
|
+
// 2. Recent conversation turns — user + analytical assistant messages.
|
|
294
|
+
// Previously only captured user messages, losing assistant analysis,
|
|
295
|
+
// code changes, and decisions made during the session.
|
|
296
|
+
const conversationTurns = [];
|
|
297
|
+
for (let i = messages.length - 1; i >= 0 && conversationTurns.length < 8; i--) {
|
|
273
298
|
const msg = messages[i];
|
|
274
299
|
if (msg.role === "user") {
|
|
275
300
|
const text = typeof msg.content === "string" ? msg.content : extractUserContent(msg.content);
|
|
276
301
|
if (text.trim()) {
|
|
277
|
-
|
|
302
|
+
conversationTurns.unshift(`[User] ${text.slice(0, 3000).trim()}`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else if (msg.role === "assistant") {
|
|
306
|
+
const text = typeof msg.content === "string" ? msg.content : extractUserContent(msg.content);
|
|
307
|
+
// Only include analytical assistant turns (≥80 chars of text — excludes pure tool-call results)
|
|
308
|
+
if (text.trim().length >= 80) {
|
|
309
|
+
conversationTurns.unshift(`[Assistant] ${text.slice(0, 1500).trim()}`);
|
|
278
310
|
}
|
|
279
311
|
}
|
|
280
312
|
}
|
|
281
|
-
if (
|
|
282
|
-
parts.push(`## Recent
|
|
313
|
+
if (conversationTurns.length > 0) {
|
|
314
|
+
parts.push(`## Recent Conversation\n${conversationTurns.join("\n\n")}`);
|
|
283
315
|
}
|
|
284
|
-
// 3. Key decisions from council
|
|
285
|
-
const
|
|
316
|
+
// 3. Key decisions from system messages (task outcomes, council results, plans, etc.)
|
|
317
|
+
const decisionMsgs = [];
|
|
286
318
|
for (const msg of messages) {
|
|
287
|
-
if (msg.role
|
|
288
|
-
|
|
319
|
+
if (msg.role !== "system" || typeof msg.content !== "string")
|
|
320
|
+
continue;
|
|
321
|
+
const c = msg.content;
|
|
322
|
+
if (c.includes("[Council Memory]") ||
|
|
323
|
+
c.includes("[Council Decision]") ||
|
|
324
|
+
c.includes("[Council Action Items]") ||
|
|
325
|
+
c.includes("[Council Plan Update]") ||
|
|
326
|
+
c.includes("[Decision]") ||
|
|
327
|
+
c.includes("[Task Completed]") ||
|
|
328
|
+
c.includes("[NEEDS HUMAN REVIEW]")) {
|
|
329
|
+
decisionMsgs.push(c);
|
|
289
330
|
}
|
|
290
331
|
}
|
|
291
|
-
if (
|
|
292
|
-
parts.push(`##
|
|
332
|
+
if (decisionMsgs.length > 0) {
|
|
333
|
+
parts.push(`## Key Decisions\n${decisionMsgs.slice(-4).join("\n\n")}`);
|
|
293
334
|
}
|
|
294
335
|
const combined = parts.join("\n\n---\n\n");
|
|
295
|
-
//
|
|
296
|
-
if (combined.length >
|
|
297
|
-
return `${combined.slice(0,
|
|
336
|
+
// ~8K token budget (char/4 ≈ token count; cap raised from original 12K chars)
|
|
337
|
+
if (combined.length > 32000) {
|
|
338
|
+
return `${combined.slice(0, 32000)}\n\n[... context truncated to fit token budget]`;
|
|
298
339
|
}
|
|
299
340
|
return combined;
|
|
300
341
|
}
|
|
@@ -414,7 +455,7 @@ export class CouncilManager {
|
|
|
414
455
|
if (!isProviderDisabled(p)) {
|
|
415
456
|
const key = await loadKeyForProvider(p).catch(() => null);
|
|
416
457
|
if (key) {
|
|
417
|
-
const m =
|
|
458
|
+
const m = getRoutedModelByTier("balanced", p);
|
|
418
459
|
// Guard: getModelByTier may return a model from a different provider
|
|
419
460
|
// when the preferred provider has no model for the requested tier.
|
|
420
461
|
if (m && m.provider === p)
|
|
@@ -463,11 +504,12 @@ export class CouncilManager {
|
|
|
463
504
|
static COLOR_RESET = COUNCIL_COLOR_RESET;
|
|
464
505
|
}
|
|
465
506
|
/**
|
|
466
|
-
* Internal:
|
|
507
|
+
* Internal: register a provider factory using the shared runtime factory, so a
|
|
508
|
+
* council sub-call on a provider the session never built can still resolve.
|
|
467
509
|
* Mirrors `createProvider` in orchestrator.ts to keep council sub-calls
|
|
468
510
|
* decoupled from Agent state.
|
|
469
511
|
*/
|
|
470
|
-
function
|
|
471
|
-
|
|
512
|
+
function ensureCouncilProvider(providerId, apiKey, baseURL) {
|
|
513
|
+
createProviderFactory(providerId, { apiKey, baseURL });
|
|
472
514
|
}
|
|
473
515
|
//# sourceMappingURL=council-manager.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/orchestrator/council-request.ts
|
|
3
|
+
*
|
|
4
|
+
* Process-global one-shot channel for an AGENT-initiated council convening.
|
|
5
|
+
*
|
|
6
|
+
* The `convene_council` tool (src/tools/registry.ts) sets a pending request when
|
|
7
|
+
* the model decides THIS request warrants a multi-model debate; the tool-engine
|
|
8
|
+
* consumes it from the OUTER restart loop after a stream drain (NOT solely via
|
|
9
|
+
* dynamicStopWhen — a phase-1 SAMR step ends on stepCountIs(1) and never
|
|
10
|
+
* evaluates the stop hook), runs `runCouncilV2({ convenePath: true })`, splices
|
|
11
|
+
* the synthesis into the convene tool's tool_result, and restarts streamText so
|
|
12
|
+
* the model reads the conclusion as the tool's result and continues the turn.
|
|
13
|
+
*
|
|
14
|
+
* Modelled on compact-request.ts. Two differences that matter for correctness:
|
|
15
|
+
* 1. It carries the `toolCallId` of the convene_council call so the tool-engine
|
|
16
|
+
* can (a) confirm the pending request actually belongs to THIS drain's
|
|
17
|
+
* messages before running council — guarding against a nested sub-session
|
|
18
|
+
* whose convene call would otherwise be consumed by the parent loop — and
|
|
19
|
+
* (b) locate the exact tool-result to replace with the synthesis.
|
|
20
|
+
* 2. `peekCouncilConveneToolCallId()` is a NON-consuming read for that guard;
|
|
21
|
+
* the flag is only cleared by `consumeCouncilConvene()` (on run) or by the
|
|
22
|
+
* turn-teardown `finally` (discard) so a request can never leak into the
|
|
23
|
+
* next user turn when the convene call shared a step with a terminal
|
|
24
|
+
* `respond_*` tool.
|
|
25
|
+
*
|
|
26
|
+
* Single-active-turn assumption (inherited from compact-request.ts): the TUI
|
|
27
|
+
* streams one turn at a time, so a process-global slot cannot cross-talk between
|
|
28
|
+
* concurrent user turns.
|
|
29
|
+
*/
|
|
30
|
+
export interface CouncilConveneRequestState {
|
|
31
|
+
/** Model-supplied justification for convening (the specific tradeoff/decision at stake). */
|
|
32
|
+
reason: string | null;
|
|
33
|
+
/** Tool-call id of the convene_council call, so the tool-engine can match + replace its result. */
|
|
34
|
+
toolCallId: string | null;
|
|
35
|
+
}
|
|
36
|
+
/** Queue a council convening to run before the model's next step. */
|
|
37
|
+
export declare function requestCouncilConvene(reason?: string | null, toolCallId?: string | null): void;
|
|
38
|
+
/** True when a council convening is queued (non-consuming peek). */
|
|
39
|
+
export declare function hasPendingCouncilConvene(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Non-consuming read of the pending request's toolCallId. Used by the tool-engine
|
|
42
|
+
* to check whether the pending convene belongs to THIS drain's response.messages
|
|
43
|
+
* before committing to a (possibly expensive, possibly wrong-frame) debate.
|
|
44
|
+
*/
|
|
45
|
+
export declare function peekCouncilConveneToolCallId(): string | null;
|
|
46
|
+
/** Consume the pending request exactly once (returns null when none queued). */
|
|
47
|
+
export declare function consumeCouncilConvene(): CouncilConveneRequestState | null;
|
|
48
|
+
/** Test hook — clear any queued request. */
|
|
49
|
+
export declare function __resetCouncilConveneForTests(): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/orchestrator/council-request.ts
|
|
3
|
+
*
|
|
4
|
+
* Process-global one-shot channel for an AGENT-initiated council convening.
|
|
5
|
+
*
|
|
6
|
+
* The `convene_council` tool (src/tools/registry.ts) sets a pending request when
|
|
7
|
+
* the model decides THIS request warrants a multi-model debate; the tool-engine
|
|
8
|
+
* consumes it from the OUTER restart loop after a stream drain (NOT solely via
|
|
9
|
+
* dynamicStopWhen — a phase-1 SAMR step ends on stepCountIs(1) and never
|
|
10
|
+
* evaluates the stop hook), runs `runCouncilV2({ convenePath: true })`, splices
|
|
11
|
+
* the synthesis into the convene tool's tool_result, and restarts streamText so
|
|
12
|
+
* the model reads the conclusion as the tool's result and continues the turn.
|
|
13
|
+
*
|
|
14
|
+
* Modelled on compact-request.ts. Two differences that matter for correctness:
|
|
15
|
+
* 1. It carries the `toolCallId` of the convene_council call so the tool-engine
|
|
16
|
+
* can (a) confirm the pending request actually belongs to THIS drain's
|
|
17
|
+
* messages before running council — guarding against a nested sub-session
|
|
18
|
+
* whose convene call would otherwise be consumed by the parent loop — and
|
|
19
|
+
* (b) locate the exact tool-result to replace with the synthesis.
|
|
20
|
+
* 2. `peekCouncilConveneToolCallId()` is a NON-consuming read for that guard;
|
|
21
|
+
* the flag is only cleared by `consumeCouncilConvene()` (on run) or by the
|
|
22
|
+
* turn-teardown `finally` (discard) so a request can never leak into the
|
|
23
|
+
* next user turn when the convene call shared a step with a terminal
|
|
24
|
+
* `respond_*` tool.
|
|
25
|
+
*
|
|
26
|
+
* Single-active-turn assumption (inherited from compact-request.ts): the TUI
|
|
27
|
+
* streams one turn at a time, so a process-global slot cannot cross-talk between
|
|
28
|
+
* concurrent user turns.
|
|
29
|
+
*/
|
|
30
|
+
let pending = null;
|
|
31
|
+
/** Queue a council convening to run before the model's next step. */
|
|
32
|
+
export function requestCouncilConvene(reason, toolCallId) {
|
|
33
|
+
const trimmedReason = typeof reason === "string" ? reason.trim() : "";
|
|
34
|
+
const trimmedId = typeof toolCallId === "string" ? toolCallId.trim() : "";
|
|
35
|
+
pending = {
|
|
36
|
+
reason: trimmedReason.length > 0 ? trimmedReason : null,
|
|
37
|
+
toolCallId: trimmedId.length > 0 ? trimmedId : null,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** True when a council convening is queued (non-consuming peek). */
|
|
41
|
+
export function hasPendingCouncilConvene() {
|
|
42
|
+
return pending !== null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Non-consuming read of the pending request's toolCallId. Used by the tool-engine
|
|
46
|
+
* to check whether the pending convene belongs to THIS drain's response.messages
|
|
47
|
+
* before committing to a (possibly expensive, possibly wrong-frame) debate.
|
|
48
|
+
*/
|
|
49
|
+
export function peekCouncilConveneToolCallId() {
|
|
50
|
+
return pending?.toolCallId ?? null;
|
|
51
|
+
}
|
|
52
|
+
/** Consume the pending request exactly once (returns null when none queued). */
|
|
53
|
+
export function consumeCouncilConvene() {
|
|
54
|
+
const p = pending;
|
|
55
|
+
pending = null;
|
|
56
|
+
return p;
|
|
57
|
+
}
|
|
58
|
+
/** Test hook — clear any queued request. */
|
|
59
|
+
export function __resetCouncilConveneForTests() {
|
|
60
|
+
pending = null;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=council-request.js.map
|
|
@@ -32,6 +32,12 @@ export interface CrossTurnDedupEntry {
|
|
|
32
32
|
firstSeenTurn: number;
|
|
33
33
|
/** Tool name that originally produced the content (for the stub). */
|
|
34
34
|
firstSeenToolName: string;
|
|
35
|
+
/**
|
|
36
|
+
* Number of SAME-TURN repeat calls seen for this content (0 until the first
|
|
37
|
+
* in-turn re-call). Used to re-serve content once before hard-stopping a
|
|
38
|
+
* loop — see the same-turn branch of maybeDedup.
|
|
39
|
+
*/
|
|
40
|
+
sameTurnRepeats: number;
|
|
35
41
|
}
|
|
36
42
|
export interface CrossTurnDedupStats {
|
|
37
43
|
/** Total dedup hits across the lifetime of this instance. */
|
|
@@ -75,10 +75,30 @@ export class CrossTurnDedup {
|
|
|
75
75
|
const hash = shortHash(raw);
|
|
76
76
|
const existing = this.cache.get(hash);
|
|
77
77
|
if (existing) {
|
|
78
|
-
this.hits += 1;
|
|
79
78
|
// Refresh LRU position so frequently-reused outputs survive eviction.
|
|
80
79
|
this.cache.delete(hash);
|
|
81
80
|
this.cache.set(hash, existing);
|
|
81
|
+
const thisTurn = this.currentTurn || 1;
|
|
82
|
+
const sameTurnLoop = existing.firstSeenTurn === thisTurn;
|
|
83
|
+
if (sameTurnLoop) {
|
|
84
|
+
// O1/O2 fix — a re-call of identical content WITHIN the same turn is a
|
|
85
|
+
// model loop, not genuine cross-turn reuse. A cheap model (kimi /
|
|
86
|
+
// deepseek) that re-issues the same read usually did so because it did
|
|
87
|
+
// NOT retain the earlier result; a bare "reuse" stub then triggers a
|
|
88
|
+
// WORSE fallback — it re-reads each file singly, inflating fresh input
|
|
89
|
+
// (measured: batch read → stub → stub → 4 single reads). Re-serve the
|
|
90
|
+
// content ONCE (passthrough) to satisfy the loop, then hard-stop on any
|
|
91
|
+
// further in-turn repeat so an infinite loop stays bounded.
|
|
92
|
+
existing.sameTurnRepeats += 1;
|
|
93
|
+
if (existing.sameTurnRepeats === 1)
|
|
94
|
+
return null;
|
|
95
|
+
this.hits += 1;
|
|
96
|
+
return `[${existing.firstSeenToolName} already returned this EXACT result ${existing.sameTurnRepeats + 1}× this turn — it is unchanged and already in the context above. STOP re-calling it; answer from the result you already have.]`;
|
|
97
|
+
}
|
|
98
|
+
// Genuine cross-turn reuse (C3): the user prompted again and the agent
|
|
99
|
+
// re-ran an identical read. The model is not looping, so the short stub
|
|
100
|
+
// is the right, token-saving behavior.
|
|
101
|
+
this.hits += 1;
|
|
82
102
|
// G3 — short marker. Old format was ~110 chars; this is ~45.
|
|
83
103
|
return `[dup of ${existing.firstSeenToolName} from turn ${existing.firstSeenTurn} — reuse]`;
|
|
84
104
|
}
|
|
@@ -87,6 +107,7 @@ export class CrossTurnDedup {
|
|
|
87
107
|
content: raw,
|
|
88
108
|
firstSeenTurn: this.currentTurn || 1,
|
|
89
109
|
firstSeenToolName: toolName,
|
|
110
|
+
sameTurnRepeats: 0,
|
|
90
111
|
});
|
|
91
112
|
this.inserts += 1;
|
|
92
113
|
while (this.cache.size > this.maxEntries) {
|
|
@@ -27,6 +27,35 @@ export interface ApiErrorForensics {
|
|
|
27
27
|
urlHost: string | undefined;
|
|
28
28
|
responseBodyTrunc: string | undefined;
|
|
29
29
|
requestParamKeys: string[] | undefined;
|
|
30
|
+
/** Field-key signature per distinct assistant message shape (PII-safe).
|
|
31
|
+
* Diagnoses Z.ai 1210 / SiliconFlow 20015 "invalid parameter" rejections
|
|
32
|
+
* where the culprit is a missing/extra field on assistant turns in a
|
|
33
|
+
* multi-step tool loop (e.g. reasoning_content present on some turns but
|
|
34
|
+
* absent on tool-only turns). */
|
|
35
|
+
assistantFieldKeys: string[] | undefined;
|
|
36
|
+
/** Per-assistant-message char counts (PII-safe — lengths only, no text).
|
|
37
|
+
* Distinguishes the "uniform shape but still rejected" failure mode:
|
|
38
|
+
* H1 cumulative reasoning budget exceeded vs H2 empty reasoning_content
|
|
39
|
+
* string vs H3 oversized text/tool payload. Set when messages are present. */
|
|
40
|
+
assistantReasoningLens: number[] | undefined;
|
|
41
|
+
/** Total reasoning_content chars across assistant messages. */
|
|
42
|
+
totalReasoningChars: number | undefined;
|
|
43
|
+
/** Values of scalar SDK-config params (reasoning_effort, verbosity,
|
|
44
|
+
* tool_choice, response_format, max_tokens, temperature, top_p,
|
|
45
|
+
* frequency_penalty, presence_penalty, seed, stop, parallel_tool_calls).
|
|
46
|
+
* PII-safe (generation config, not prompt content) — pinpoints WHICH
|
|
47
|
+
* param value a provider rejects when the error is generic (Z.ai 1210,
|
|
48
|
+
* SiliconFlow 20015). */
|
|
49
|
+
configParamValues: Record<string, unknown> | undefined;
|
|
50
|
+
/** Per-assistant tool_calls counts (from assistant messages in the request
|
|
51
|
+
* that failed). Captures H3 for Z.ai 1210: a single assistant response
|
|
52
|
+
* emitting many parallel tool_calls (e.g. 8 or 12) → the follow-up request
|
|
53
|
+
* carrying that many role:tool results gets rejected by the coding endpoint
|
|
54
|
+
* with generic 1210. */
|
|
55
|
+
assistantToolCallCounts: number[] | undefined;
|
|
56
|
+
/** Count of role:"tool" messages in the failing request body. Complements
|
|
57
|
+
* assistantToolCallCounts to show the round-trip payload size for H3. */
|
|
58
|
+
toolMessageCount: number | undefined;
|
|
30
59
|
isRetryable: boolean | undefined;
|
|
31
60
|
}
|
|
32
61
|
export declare function summarizeApiErrorForLog(error: unknown): ApiErrorForensics | null;
|