muonroi-cli 1.4.0 → 1.5.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 +21 -21
- package/README.md +122 -122
- package/dist/packages/agent-harness-core/src/predicate.d.ts +1 -1
- package/dist/src/agent-harness/__tests__/mock-model.spec.js +48 -1
- package/dist/src/agent-harness/mock-model.d.ts +11 -0
- package/dist/src/agent-harness/mock-model.js +21 -0
- package/dist/src/cli/cost-forensics.js +12 -12
- package/dist/src/council/__tests__/clarification-prompt.test.js +51 -0
- package/dist/src/council/__tests__/clarifier-ready-gate.test.js +32 -0
- package/dist/src/council/__tests__/decisions-lock.test.js +17 -1
- package/dist/src/council/__tests__/oauth-reachable.test.d.ts +1 -0
- package/dist/src/council/__tests__/oauth-reachable.test.js +31 -0
- package/dist/src/council/__tests__/parse-outcome-fallback.test.js +11 -0
- package/dist/src/council/clarifier.js +9 -1
- package/dist/src/council/debate.js +5 -1
- package/dist/src/council/decisions-lock.js +3 -3
- package/dist/src/council/index.js +12 -5
- package/dist/src/council/leader.d.ts +0 -17
- package/dist/src/council/leader.js +22 -15
- package/dist/src/council/planner.js +1 -1
- package/dist/src/council/prompts.js +63 -57
- package/dist/src/council/types.d.ts +7 -0
- package/dist/src/ee/__tests__/ee-onboarding.test.d.ts +1 -0
- package/dist/src/ee/__tests__/ee-onboarding.test.js +32 -0
- package/dist/src/ee/auth.d.ts +9 -0
- package/dist/src/ee/auth.js +19 -0
- package/dist/src/ee/ee-onboarding.d.ts +5 -0
- package/dist/src/ee/ee-onboarding.js +76 -0
- package/dist/src/generated/version.d.ts +1 -1
- package/dist/src/generated/version.js +1 -1
- package/dist/src/headless/output.js +6 -4
- package/dist/src/headless/output.test.js +4 -3
- package/dist/src/index.js +20 -1
- package/dist/src/mcp/__tests__/auto-setup.test.js +74 -0
- package/dist/src/mcp/__tests__/client-pool.spec.d.ts +1 -0
- package/dist/src/mcp/__tests__/client-pool.spec.js +98 -0
- package/dist/src/mcp/__tests__/parallel-build.spec.d.ts +1 -0
- package/dist/src/mcp/__tests__/parallel-build.spec.js +67 -0
- package/dist/src/mcp/__tests__/smart-filter.test.js +56 -0
- package/dist/src/mcp/auto-setup.js +56 -2
- package/dist/src/mcp/client-pool.d.ts +46 -0
- package/dist/src/mcp/client-pool.js +212 -0
- package/dist/src/mcp/oauth-callback.js +2 -2
- package/dist/src/mcp/parse-headers.test.js +14 -14
- package/dist/src/mcp/runtime.d.ts +28 -0
- package/dist/src/mcp/runtime.js +117 -51
- package/dist/src/mcp/self-verify-runner.d.ts +14 -0
- package/dist/src/mcp/self-verify-runner.js +38 -0
- package/dist/src/mcp/setup-guide-text.d.ts +9 -0
- package/dist/src/mcp/setup-guide-text.js +84 -0
- package/dist/src/mcp/smart-filter.js +49 -0
- package/dist/src/mcp/smoke.test.js +43 -43
- package/dist/src/mcp/tools-server.d.ts +7 -0
- package/dist/src/mcp/tools-server.js +19 -22
- package/dist/src/models/catalog.json +349 -349
- package/dist/src/ops/__tests__/doctor-ee-health.test.js +21 -0
- package/dist/src/ops/doctor.d.ts +3 -2
- package/dist/src/ops/doctor.js +47 -11
- package/dist/src/ops/doctor.test.js +4 -3
- package/dist/src/orchestrator/__tests__/mcp-capability-block.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/mcp-capability-block.test.js +39 -0
- package/dist/src/orchestrator/__tests__/project-stack.test.d.ts +1 -0
- package/dist/src/orchestrator/__tests__/project-stack.test.js +65 -0
- package/dist/src/orchestrator/batch-turn-runner.js +7 -11
- package/dist/src/orchestrator/message-processor.js +57 -27
- package/dist/src/orchestrator/orchestrator.js +26 -0
- package/dist/src/orchestrator/prompts.d.ts +51 -0
- package/dist/src/orchestrator/prompts.js +257 -134
- package/dist/src/orchestrator/scope-ceiling.js +6 -1
- package/dist/src/orchestrator/stream-runner.js +20 -15
- package/dist/src/orchestrator/text-tool-call-detector.test.js +13 -13
- package/dist/src/pil/__tests__/clarity-gate.test.js +24 -215
- package/dist/src/pil/__tests__/config.test.js +1 -17
- package/dist/src/pil/__tests__/discovery.test.js +144 -11
- package/dist/src/pil/__tests__/layer1-intent-trace.test.js +7 -2
- package/dist/src/pil/__tests__/layer1-intent.test.js +3 -0
- package/dist/src/pil/__tests__/layer16-clarity.test.js +32 -116
- package/dist/src/pil/__tests__/layer4-gsd.test.js +37 -0
- package/dist/src/pil/__tests__/layer6-output.test.js +137 -18
- package/dist/src/pil/__tests__/llm-classify.test.js +49 -2
- package/dist/src/pil/agent-operating-contract.d.ts +1 -1
- package/dist/src/pil/agent-operating-contract.js +2 -0
- package/dist/src/pil/agent-operating-contract.test.js +7 -2
- package/dist/src/pil/cheap-model-playbook.js +35 -35
- package/dist/src/pil/cheap-model-workbooks.js +16 -13
- package/dist/src/pil/clarity-gate.d.ts +21 -19
- package/dist/src/pil/clarity-gate.js +26 -153
- package/dist/src/pil/config.d.ts +9 -1
- package/dist/src/pil/config.js +15 -4
- package/dist/src/pil/discovery.js +211 -136
- package/dist/src/pil/layer1-intent.d.ts +12 -0
- package/dist/src/pil/layer1-intent.js +283 -38
- package/dist/src/pil/layer1-intent.test.js +210 -4
- package/dist/src/pil/layer16-clarity.d.ts +25 -11
- package/dist/src/pil/layer16-clarity.js +19 -306
- package/dist/src/pil/layer4-gsd.js +18 -6
- package/dist/src/pil/layer6-output.d.ts +2 -0
- package/dist/src/pil/layer6-output.js +137 -22
- package/dist/src/pil/llm-classify.d.ts +26 -0
- package/dist/src/pil/llm-classify.js +34 -5
- package/dist/src/pil/native-capabilities-workbook.d.ts +1 -1
- package/dist/src/pil/native-capabilities-workbook.js +82 -76
- package/dist/src/pil/schema.d.ts +8 -0
- package/dist/src/pil/schema.js +12 -1
- package/dist/src/pil/task-tier-map.js +4 -0
- package/dist/src/pil/types.d.ts +11 -1
- package/dist/src/product-loop/done-gate.js +3 -3
- package/dist/src/product-loop/loop-driver.js +18 -18
- package/dist/src/product-loop/progress-snapshot.js +4 -4
- package/dist/src/providers/auth/gemini-oauth.js +6 -15
- package/dist/src/providers/auth/grok-oauth.js +6 -15
- package/dist/src/providers/auth/openai-oauth.js +6 -15
- package/dist/src/providers/mcp-vision-bridge.js +48 -48
- package/dist/src/reporter/index.js +1 -1
- package/dist/src/scaffold/bb-ecosystem-apply.js +47 -47
- 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 +453 -453
- package/dist/src/self-qa/__tests__/scenario-planner.test.js +3 -3
- package/dist/src/self-qa/agentic-loop.js +24 -19
- package/dist/src/self-qa/spec-emitter.js +26 -23
- package/dist/src/storage/__tests__/migrations.test.js +2 -2
- package/dist/src/storage/interaction-log.js +5 -5
- package/dist/src/storage/migrations.js +122 -122
- package/dist/src/storage/sessions.js +42 -42
- package/dist/src/storage/transcript.js +91 -84
- package/dist/src/storage/usage.js +14 -14
- package/dist/src/storage/workspaces.js +12 -12
- package/dist/src/tools/__tests__/native-tools.test.d.ts +1 -0
- package/dist/src/tools/__tests__/native-tools.test.js +53 -0
- package/dist/src/tools/git-safety.d.ts +61 -0
- package/dist/src/tools/git-safety.js +141 -0
- package/dist/src/tools/git-safety.test.d.ts +1 -0
- package/dist/src/tools/git-safety.test.js +111 -0
- package/dist/src/tools/native-tools.d.ts +31 -0
- package/dist/src/tools/native-tools.js +273 -0
- package/dist/src/tools/registry-git-safety.test.d.ts +7 -0
- package/dist/src/tools/registry-git-safety.test.js +92 -0
- package/dist/src/tools/registry.js +39 -4
- package/dist/src/ui/__tests__/markdown-render.test.d.ts +1 -0
- package/dist/src/ui/__tests__/markdown-render.test.js +48 -0
- package/dist/src/ui/app.js +0 -0
- package/dist/src/ui/components/message-view.js +4 -1
- package/dist/src/ui/components/structured-response-view.js +7 -3
- package/dist/src/ui/components/tool-group.js +7 -1
- package/dist/src/ui/markdown-render.d.ts +41 -0
- package/dist/src/ui/markdown-render.js +223 -0
- package/dist/src/ui/markdown.d.ts +10 -0
- package/dist/src/ui/markdown.js +12 -35
- package/dist/src/ui/slash/council-inspect.js +4 -4
- package/dist/src/ui/slash/export.js +4 -4
- package/dist/src/ui/utils/text.d.ts +8 -0
- package/dist/src/ui/utils/text.js +16 -0
- package/dist/src/ui/utils/text.test.d.ts +1 -0
- package/dist/src/ui/utils/text.test.js +23 -0
- package/dist/src/usage/ledger.js +48 -15
- package/dist/src/utils/__tests__/footprint-gitignore.test.d.ts +1 -0
- package/dist/src/utils/__tests__/footprint-gitignore.test.js +50 -0
- package/dist/src/utils/clipboard-image.js +23 -23
- package/dist/src/utils/open-url.d.ts +56 -0
- package/dist/src/utils/open-url.js +58 -0
- package/dist/src/utils/open-url.test.d.ts +1 -0
- package/dist/src/utils/open-url.test.js +86 -0
- package/dist/src/utils/settings.d.ts +12 -0
- package/dist/src/utils/settings.js +48 -0
- package/dist/src/utils/side-question.js +2 -2
- package/dist/src/utils/skills.js +3 -3
- package/dist/src/verify/__tests__/coverage-parsers.test.js +30 -30
- package/dist/src/verify/environment.js +2 -1
- package/package.json +3 -2
- package/dist/muonroi-cli-standalone.exe +0 -0
- 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-helpers__/catalog-fixtures.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/reporter-cmd.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__/clarifier-ready-gate.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__/decisions-lock.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/decisions-lock.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__/export-transcripts.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__/recall-format.test.js.map +0 -1
- package/dist/src/ee/__tests__/recall-ledger.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/export-transcripts.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/recall-ledger.js.map +0 -1
- package/dist/src/ee/recall-mirror.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/search.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/transcript-emit.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/maintain/__tests__/codebase-intel.test.js.map +0 -1
- package/dist/src/maintain/__tests__/gh-create-pr.test.js.map +0 -1
- package/dist/src/maintain/__tests__/pr-builder.test.js.map +0 -1
- package/dist/src/maintain/__tests__/repo-map.test.js.map +0 -1
- package/dist/src/maintain/__tests__/task-runner.test.js.map +0 -1
- package/dist/src/maintain/codebase-intel.js.map +0 -1
- package/dist/src/maintain/gh-create-pr.js.map +0 -1
- package/dist/src/maintain/index.js.map +0 -1
- package/dist/src/maintain/pr-builder.js.map +0 -1
- package/dist/src/maintain/repo-map.js.map +0 -1
- package/dist/src/maintain/task-runner.js.map +0 -1
- package/dist/src/maintain/types.js.map +0 -1
- package/dist/src/mcp/__tests__/auto-setup.test.js.map +0 -1
- package/dist/src/mcp/__tests__/cap-tool-result.test.js.map +0 -1
- package/dist/src/mcp/__tests__/ee-tools.test.js.map +0 -1
- package/dist/src/mcp/__tests__/forensics-tools.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__/lsp-tools.test.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-output-cap.test.js.map +0 -1
- package/dist/src/mcp/__tests__/runtime-sanitize.test.js.map +0 -1
- package/dist/src/mcp/__tests__/self-verify-jobs.test.js.map +0 -1
- package/dist/src/mcp/__tests__/smart-filter.test.js.map +0 -1
- package/dist/src/mcp/__tests__/tools-server.smoke.test.js.map +0 -1
- package/dist/src/mcp/auto-setup.js.map +0 -1
- package/dist/src/mcp/cap-tool-result.js.map +0 -1
- package/dist/src/mcp/catalog.js.map +0 -1
- package/dist/src/mcp/ee-tools.js.map +0 -1
- package/dist/src/mcp/forensics-tools.js.map +0 -1
- package/dist/src/mcp/lsp-tools.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/self-verify-jobs.js.map +0 -1
- package/dist/src/mcp/smart-filter.js.map +0 -1
- package/dist/src/mcp/smoke.test.js.map +0 -1
- package/dist/src/mcp/tools-server.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/catalog-gemini.test.js.map +0 -1
- package/dist/src/models/catalog-url.test.js.map +0 -1
- package/dist/src/models/catalog-validation.test.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__/agent-base-url-switch.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__/error-forensics.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/flow-resume.test.js.map +0 -1
- package/dist/src/orchestrator/__tests__/humanize-api-error.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__/sub-agent-model-tier.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__/usage-shape-threading.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/grounding-check.js.map +0 -1
- package/dist/src/orchestrator/grounding-check.test.js.map +0 -1
- package/dist/src/orchestrator/interrupted-turn.js.map +0 -1
- package/dist/src/orchestrator/interrupted-turn.test.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/repair-tool-call.js.map +0 -1
- package/dist/src/orchestrator/repetition-detector.js.map +0 -1
- package/dist/src/orchestrator/repetition-detector.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/scope-ceiling.js.map +0 -1
- package/dist/src/orchestrator/scope-ceiling.test.js.map +0 -1
- package/dist/src/orchestrator/scope-reminder.js.map +0 -1
- package/dist/src/orchestrator/scope-reminder.test.js.map +0 -1
- package/dist/src/orchestrator/stall-rescue.js.map +0 -1
- package/dist/src/orchestrator/stall-rescue.test.js.map +0 -1
- package/dist/src/orchestrator/stall-watchdog.js.map +0 -1
- package/dist/src/orchestrator/stall-watchdog.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/sub-agent-model-tier.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/text-tool-call-detector.js.map +0 -1
- package/dist/src/orchestrator/text-tool-call-detector.test.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-args-hash.js.map +0 -1
- package/dist/src/orchestrator/tool-args-hash.test.js.map +0 -1
- package/dist/src/orchestrator/tool-args-repair.js.map +0 -1
- package/dist/src/orchestrator/tool-args-repair.test.js.map +0 -1
- package/dist/src/orchestrator/tool-loop-cap.js.map +0 -1
- package/dist/src/orchestrator/tool-loop-cap.test.js.map +0 -1
- package/dist/src/orchestrator/tool-repetition-detector.js.map +0 -1
- package/dist/src/orchestrator/tool-repetition-detector.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__/clarity-gate.test.js.map +0 -1
- package/dist/src/pil/__tests__/config.test.js.map +0 -1
- package/dist/src/pil/__tests__/discovery-cache.test.js.map +0 -1
- package/dist/src/pil/__tests__/discovery-types.test.js.map +0 -1
- package/dist/src/pil/__tests__/discovery.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__/layer15-context-scan.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer16-clarity.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer17-feasibility.test.js.map +0 -1
- package/dist/src/pil/__tests__/layer18-acceptance.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__/llm-classify.test.js.map +0 -1
- package/dist/src/pil/__tests__/native-capabilities-workbook.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/agent-operating-contract.js.map +0 -1
- package/dist/src/pil/agent-operating-contract.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/cheap-model-playbook.js.map +0 -1
- package/dist/src/pil/cheap-model-playbook.test.js.map +0 -1
- package/dist/src/pil/cheap-model-workbooks.js.map +0 -1
- package/dist/src/pil/cheap-model-workbooks.test.js.map +0 -1
- package/dist/src/pil/clarity-gate.js.map +0 -1
- package/dist/src/pil/config.js.map +0 -1
- package/dist/src/pil/discovery-cache.js.map +0 -1
- package/dist/src/pil/discovery-types.js.map +0 -1
- package/dist/src/pil/discovery.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/layer15-context-scan.js.map +0 -1
- package/dist/src/pil/layer16-clarity.js.map +0 -1
- package/dist/src/pil/layer16-clarity.test.js +0 -31
- package/dist/src/pil/layer16-clarity.test.js.map +0 -1
- package/dist/src/pil/layer17-feasibility.js.map +0 -1
- package/dist/src/pil/layer18-acceptance.js.map +0 -1
- package/dist/src/pil/layer1_5-complexity-size.js.map +0 -1
- package/dist/src/pil/layer1_5-complexity-size.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/llm-classify.js.map +0 -1
- package/dist/src/pil/native-capabilities-workbook.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/session-state.js.map +0 -1
- package/dist/src/pil/session-state.test.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__/backlog-builder.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/backlog-store.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-context-format.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-prompt-specificity.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__/gather-selectable-alts.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__/maintenance-task-synthesis.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-a1-a3-sprint-runner.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/phase-a2-backlog-build.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__/pick-backend-stack.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/product-identity.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/progress-snapshot.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__/repo-brief.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-planner.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/sprint-runner-backlog.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-phase-chunks.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/sprint-runner.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/sprint-self-verify.test.js.map +0 -1
- package/dist/src/product-loop/__tests__/sprint-store.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/backlog-builder.js.map +0 -1
- package/dist/src/product-loop/backlog-store.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/progress-snapshot.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/repo-brief.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-planner.js.map +0 -1
- package/dist/src/product-loop/sprint-runner.js.map +0 -1
- package/dist/src/product-loop/sprint-self-verify.js.map +0 -1
- package/dist/src/product-loop/sprint-store.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__/reasoning-roundtrip.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-sse-repair.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__/grok-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/grok-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-sse-repair.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/reporter/__tests__/acl-check.test.js.map +0 -1
- package/dist/src/reporter/__tests__/auto-fire.test.js.map +0 -1
- package/dist/src/reporter/__tests__/budget.test.js.map +0 -1
- package/dist/src/reporter/__tests__/handlers.test.js.map +0 -1
- package/dist/src/reporter/__tests__/query-router.test.js.map +0 -1
- package/dist/src/reporter/acl-check.js.map +0 -1
- package/dist/src/reporter/auto-fire.js.map +0 -1
- package/dist/src/reporter/budget.js.map +0 -1
- package/dist/src/reporter/handlers.js.map +0 -1
- package/dist/src/reporter/index.js.map +0 -1
- package/dist/src/reporter/query-router.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/role-override.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/self-qa/__tests__/agentic-context.test.js.map +0 -1
- package/dist/src/self-qa/__tests__/agentic-loop.test.js.map +0 -1
- package/dist/src/self-qa/__tests__/delta-encoder.test.js.map +0 -1
- package/dist/src/self-qa/__tests__/judge.test.js.map +0 -1
- package/dist/src/self-qa/__tests__/scenario-planner.test.js.map +0 -1
- package/dist/src/self-qa/__tests__/spec-emitter.test.js.map +0 -1
- package/dist/src/self-qa/agentic-context.js.map +0 -1
- package/dist/src/self-qa/agentic-loop.js.map +0 -1
- package/dist/src/self-qa/delta-encoder.js.map +0 -1
- package/dist/src/self-qa/index.js.map +0 -1
- package/dist/src/self-qa/judge.js.map +0 -1
- package/dist/src/self-qa/orchestrator.js.map +0 -1
- package/dist/src/self-qa/scenario-planner.js.map +0 -1
- package/dist/src/self-qa/spec-emitter.js.map +0 -1
- package/dist/src/self-qa/types.js.map +0 -1
- package/dist/src/storage/__tests__/migrations.test.js.map +0 -1
- package/dist/src/storage/__tests__/sweep-stale-pending.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-response-entry.test.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/__tests__/vision-gate.test.js.map +0 -1
- package/dist/src/tools/bash-output-cache.js.map +0 -1
- package/dist/src/tools/bash-output-cache.test.js.map +0 -1
- package/dist/src/tools/bash-output-integration.test.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-bash-empty-command.test.js.map +0 -1
- package/dist/src/tools/registry-bash-footer.test.js.map +0 -1
- package/dist/src/tools/registry-ee-query.test.js.map +0 -1
- package/dist/src/tools/registry-session-repeat.test.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/tools/todo-write-snapshot.js.map +0 -1
- package/dist/src/tools/todo-write-snapshot.test.js.map +0 -1
- package/dist/src/tools/vision-gate.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/ui/__tests__/picker-providers.test.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__/task-list-panel.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/task-list-panel.js.map +0 -1
- package/dist/src/ui/components/tool-group.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/picker-providers.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/__tests__/status-render.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/slash/status.js.map +0 -1
- package/dist/src/ui/state/active-run.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/__tests__/format.test.js.map +0 -1
- package/dist/src/ui/utils/__tests__/tools.test.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__/llm-deadline.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/llm-deadline.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-helpers__/catalog-fixtures.ts +0 -57
- 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 -445
- package/src/agent-harness/test-spawn.ts +0 -221
- 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 -137
- 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 -273
- package/src/cli/cost-forensics.ts +0 -337
- package/src/cli/keys-bundle.ts +0 -91
- package/src/cli/keys.test.ts +0 -104
- package/src/cli/keys.ts +0 -816
- package/src/cli/pil-report.ts +0 -202
- package/src/cli/reporter-cmd.ts +0 -154
- package/src/cli/share-cmd.ts +0 -132
- package/src/cli/usage-report.ts +0 -398
- 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 -90
- package/src/council/__tests__/clarifier-options.test.ts +0 -63
- package/src/council/__tests__/clarifier-ready-gate.test.ts +0 -268
- 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__/decisions-lock.test.ts +0 -404
- 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 -507
- package/src/council/context.ts +0 -249
- package/src/council/debate-planner.ts +0 -303
- package/src/council/debate.ts +0 -1179
- package/src/council/decisions-lock.ts +0 -312
- package/src/council/executor.ts +0 -27
- package/src/council/index.ts +0 -956
- package/src/council/leader.ts +0 -281
- package/src/council/llm.ts +0 -939
- package/src/council/phase-events.ts +0 -64
- package/src/council/planner.ts +0 -303
- package/src/council/preflight.ts +0 -86
- package/src/council/prompts.ts +0 -698
- package/src/council/types.ts +0 -304
- 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__/export-transcripts.test.ts +0 -222
- 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__/recall-format.test.ts +0 -66
- package/src/ee/__tests__/recall-ledger.test.ts +0 -55
- 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 -201
- package/src/ee/client.ts +0 -683
- package/src/ee/council-bridge.ts +0 -89
- package/src/ee/embedding-cache.ts +0 -42
- package/src/ee/export-transcripts.ts +0 -160
- 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 -168
- 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/recall-ledger.ts +0 -71
- package/src/ee/recall-mirror.test.ts +0 -74
- 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/search.ts +0 -259
- 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/transcript-emit.ts +0 -174
- package/src/ee/types.ts +0 -432
- 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 -5
- package/src/gsd/.gitkeep +0 -0
- package/src/gsd/__tests__/complexity.test.ts +0 -0
- package/src/gsd/__tests__/directives.test.ts +0 -88
- package/src/gsd/__tests__/gray-areas.test.ts +0 -33
- package/src/gsd/__tests__/types.test.ts +0 -91
- package/src/gsd/complexity.ts +0 -124
- package/src/gsd/directives.ts +0 -141
- package/src/gsd/gray-areas.ts +0 -144
- package/src/gsd/index.ts +0 -1
- package/src/gsd/types.ts +0 -63
- package/src/headless/__tests__/council-answers.test.ts +0 -300
- package/src/headless/council-answers.ts +0 -152
- 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 -569
- package/src/hooks/types.ts +0 -263
- package/src/index.ts +0 -1762
- package/src/lsp/builtins.test.ts +0 -129
- package/src/lsp/builtins.ts +0 -453
- package/src/lsp/client.ts +0 -342
- package/src/lsp/manager.test.ts +0 -198
- package/src/lsp/manager.ts +0 -343
- package/src/lsp/npm-cache.test.ts +0 -70
- package/src/lsp/npm-cache.ts +0 -111
- package/src/lsp/runtime.ts +0 -70
- package/src/lsp/smoke.test.ts +0 -74
- package/src/lsp/types.ts +0 -119
- package/src/maintain/__tests__/codebase-intel.test.ts +0 -320
- package/src/maintain/__tests__/gh-create-pr.test.ts +0 -195
- package/src/maintain/__tests__/pr-builder.test.ts +0 -282
- package/src/maintain/__tests__/repo-map.test.ts +0 -128
- package/src/maintain/__tests__/task-runner.test.ts +0 -347
- package/src/maintain/codebase-intel.ts +0 -595
- package/src/maintain/gh-create-pr.ts +0 -148
- package/src/maintain/index.ts +0 -14
- package/src/maintain/pr-builder.ts +0 -373
- package/src/maintain/repo-map.ts +0 -205
- package/src/maintain/task-runner.ts +0 -481
- package/src/maintain/types.ts +0 -49
- package/src/mcp/__tests__/auto-setup.test.ts +0 -88
- package/src/mcp/__tests__/cap-tool-result.test.ts +0 -65
- package/src/mcp/__tests__/ee-tools.test.ts +0 -248
- package/src/mcp/__tests__/forensics-tools.test.ts +0 -66
- package/src/mcp/__tests__/harness-driver-action-tools.spec.ts +0 -116
- package/src/mcp/__tests__/harness-driver-async-tools.spec.ts +0 -129
- package/src/mcp/__tests__/harness-driver-read-tools.spec.ts +0 -140
- package/src/mcp/__tests__/harness-driver-security.spec.ts +0 -69
- package/src/mcp/__tests__/harness-driver.spec.ts +0 -21
- package/src/mcp/__tests__/lazy-schema.spec.ts +0 -173
- package/src/mcp/__tests__/lsp-tools.test.ts +0 -72
- 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-output-cap.test.ts +0 -49
- package/src/mcp/__tests__/runtime-sanitize.test.ts +0 -44
- package/src/mcp/__tests__/self-verify-jobs.test.ts +0 -102
- package/src/mcp/__tests__/smart-filter.test.ts +0 -139
- package/src/mcp/__tests__/tools-server.smoke.test.ts +0 -41
- package/src/mcp/auto-setup.ts +0 -99
- package/src/mcp/cap-tool-result.ts +0 -68
- package/src/mcp/catalog.ts +0 -155
- package/src/mcp/ee-tools.ts +0 -204
- package/src/mcp/forensics-tools.ts +0 -65
- package/src/mcp/lsp-tools.ts +0 -78
- package/src/mcp/mcp-keychain.ts +0 -85
- 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 -182
- package/src/mcp/self-verify-jobs.ts +0 -137
- package/src/mcp/smart-filter.ts +0 -138
- package/src/mcp/smoke.test.ts +0 -170
- package/src/mcp/tools-server.ts +0 -174
- package/src/mcp/validate.ts +0 -48
- package/src/models/__tests__/registry.test.ts +0 -95
- package/src/models/catalog-client.ts +0 -234
- package/src/models/catalog-gemini.test.ts +0 -52
- package/src/models/catalog-url.test.ts +0 -27
- package/src/models/catalog-validation.test.ts +0 -74
- package/src/models/catalog.README.md +0 -136
- package/src/models/catalog.json +0 -349
- package/src/models/classify-tier.ts +0 -48
- package/src/models/index.ts +0 -9
- package/src/models/registry.ts +0 -87
- 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__/agent-base-url-switch.test.ts +0 -87
- package/src/orchestrator/__tests__/batch-turn-runner.test.ts +0 -186
- package/src/orchestrator/__tests__/council-manager.test.ts +0 -171
- package/src/orchestrator/__tests__/cross-turn-dedup.test.ts +0 -201
- package/src/orchestrator/__tests__/current-call-id.test.ts +0 -160
- package/src/orchestrator/__tests__/error-forensics.test.ts +0 -99
- package/src/orchestrator/__tests__/flow-resume.test.ts +0 -71
- package/src/orchestrator/__tests__/humanize-api-error.test.ts +0 -74
- package/src/orchestrator/__tests__/message-processor.test.ts +0 -201
- package/src/orchestrator/__tests__/message-write-ahead.test.ts +0 -170
- package/src/orchestrator/__tests__/read-path-budget.test.ts +0 -170
- package/src/orchestrator/__tests__/retry-classifier.test.ts +0 -131
- 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 -201
- package/src/orchestrator/__tests__/sub-agent-model-tier.test.ts +0 -53
- 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__/usage-shape-threading.test.ts +0 -111
- 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 -167
- package/src/orchestrator/agent.test.ts +0 -191
- 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 -200
- package/src/orchestrator/compaction.ts +0 -626
- package/src/orchestrator/council-manager.ts +0 -572
- package/src/orchestrator/cross-turn-dedup.ts +0 -208
- package/src/orchestrator/delegations.test.ts +0 -145
- package/src/orchestrator/delegations.ts +0 -370
- package/src/orchestrator/error-utils.ts +0 -165
- package/src/orchestrator/flow-resume.ts +0 -54
- package/src/orchestrator/grounding-check.test.ts +0 -111
- package/src/orchestrator/grounding-check.ts +0 -138
- package/src/orchestrator/interrupted-turn.test.ts +0 -39
- package/src/orchestrator/interrupted-turn.ts +0 -27
- package/src/orchestrator/message-processor.ts +0 -3364
- package/src/orchestrator/message-seq.test.ts +0 -29
- package/src/orchestrator/message-seq.ts +0 -19
- package/src/orchestrator/orchestrator.ts +0 -2752
- package/src/orchestrator/pending-calls.test.ts +0 -226
- package/src/orchestrator/pending-calls.ts +0 -240
- package/src/orchestrator/prompts.ts +0 -579
- 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 -205
- package/src/orchestrator/reasoning.test.ts +0 -114
- package/src/orchestrator/reasoning.ts +0 -116
- package/src/orchestrator/repair-tool-call.ts +0 -54
- package/src/orchestrator/repetition-detector.test.ts +0 -127
- package/src/orchestrator/repetition-detector.ts +0 -140
- package/src/orchestrator/retry-classifier.ts +0 -140
- package/src/orchestrator/retry-stream.ts +0 -159
- package/src/orchestrator/sandbox.test.ts +0 -117
- package/src/orchestrator/scope-ceiling.test.ts +0 -215
- package/src/orchestrator/scope-ceiling.ts +0 -234
- package/src/orchestrator/scope-reminder.test.ts +0 -232
- package/src/orchestrator/scope-reminder.ts +0 -230
- package/src/orchestrator/stall-rescue.test.ts +0 -100
- package/src/orchestrator/stall-rescue.ts +0 -95
- package/src/orchestrator/stall-watchdog.test.ts +0 -83
- package/src/orchestrator/stall-watchdog.ts +0 -87
- package/src/orchestrator/stream-runner.ts +0 -939
- package/src/orchestrator/sub-agent-cap.test.ts +0 -227
- package/src/orchestrator/sub-agent-cap.ts +0 -240
- package/src/orchestrator/sub-agent-model-tier.ts +0 -58
- package/src/orchestrator/subagent-compactor.spec.ts +0 -332
- package/src/orchestrator/subagent-compactor.ts +0 -456
- package/src/orchestrator/text-tool-call-detector.test.ts +0 -99
- package/src/orchestrator/text-tool-call-detector.ts +0 -200
- package/src/orchestrator/token-counter.test.ts +0 -69
- package/src/orchestrator/token-counter.ts +0 -81
- package/src/orchestrator/tool-args-hash.test.ts +0 -121
- package/src/orchestrator/tool-args-hash.ts +0 -221
- package/src/orchestrator/tool-args-repair.test.ts +0 -156
- package/src/orchestrator/tool-args-repair.ts +0 -227
- package/src/orchestrator/tool-loop-cap.test.ts +0 -193
- package/src/orchestrator/tool-loop-cap.ts +0 -174
- package/src/orchestrator/tool-repetition-detector.test.ts +0 -119
- package/src/orchestrator/tool-repetition-detector.ts +0 -0
- package/src/orchestrator/tool-utils.ts +0 -214
- package/src/orchestrator/turn-runner-deps.ts +0 -85
- package/src/pil/__tests__/budget.test.ts +0 -39
- package/src/pil/__tests__/clarity-gate.test.ts +0 -299
- package/src/pil/__tests__/config.test.ts +0 -78
- package/src/pil/__tests__/discovery-cache.test.ts +0 -45
- package/src/pil/__tests__/discovery-types.test.ts +0 -68
- package/src/pil/__tests__/discovery.test.ts +0 -141
- package/src/pil/__tests__/dual-run.test.ts +0 -53
- package/src/pil/__tests__/layer1-intent-trace.test.ts +0 -142
- package/src/pil/__tests__/layer1-intent.test.ts +0 -365
- package/src/pil/__tests__/layer15-context-scan.test.ts +0 -76
- package/src/pil/__tests__/layer16-clarity.test.ts +0 -184
- package/src/pil/__tests__/layer17-feasibility.test.ts +0 -42
- package/src/pil/__tests__/layer18-acceptance.test.ts +0 -116
- package/src/pil/__tests__/layer2-personality.test.ts +0 -63
- package/src/pil/__tests__/layer3-ee-injection.test.ts +0 -189
- 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 -362
- package/src/pil/__tests__/llm-classify.test.ts +0 -140
- package/src/pil/__tests__/native-capabilities-workbook.test.ts +0 -45
- 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 -191
- package/src/pil/__tests__/renderer-coverage.test.ts +0 -46
- package/src/pil/__tests__/response-tools.test.ts +0 -239
- 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/agent-operating-contract.test.ts +0 -84
- package/src/pil/agent-operating-contract.ts +0 -70
- package/src/pil/budget-log.ts +0 -86
- package/src/pil/budget.ts +0 -18
- package/src/pil/cheap-model-playbook.test.ts +0 -191
- package/src/pil/cheap-model-playbook.ts +0 -153
- package/src/pil/cheap-model-workbooks.test.ts +0 -154
- package/src/pil/cheap-model-workbooks.ts +0 -109
- package/src/pil/clarity-gate.ts +0 -188
- package/src/pil/config.ts +0 -25
- package/src/pil/discovery-cache.ts +0 -20
- package/src/pil/discovery-types.ts +0 -97
- package/src/pil/discovery.ts +0 -397
- package/src/pil/index.ts +0 -24
- package/src/pil/layer1-intent.test.ts +0 -520
- package/src/pil/layer1-intent.ts +0 -1236
- package/src/pil/layer15-context-scan.ts +0 -159
- package/src/pil/layer16-clarity.test.ts +0 -35
- package/src/pil/layer16-clarity.ts +0 -417
- package/src/pil/layer17-feasibility.ts +0 -40
- package/src/pil/layer18-acceptance.ts +0 -98
- package/src/pil/layer1_5-complexity-size.test.ts +0 -279
- package/src/pil/layer1_5-complexity-size.ts +0 -175
- package/src/pil/layer2-personality.ts +0 -46
- package/src/pil/layer3-ee-injection.ts +0 -406
- package/src/pil/layer4-gsd.ts +0 -124
- package/src/pil/layer5-context.ts +0 -171
- package/src/pil/layer6-output.ts +0 -364
- package/src/pil/llm-classify.ts +0 -199
- package/src/pil/native-capabilities-workbook.ts +0 -124
- package/src/pil/ollama-classify.ts +0 -49
- package/src/pil/pipeline.ts +0 -313
- package/src/pil/response-tools.ts +0 -187
- package/src/pil/schema.ts +0 -111
- package/src/pil/session-state.test.ts +0 -88
- package/src/pil/session-state.ts +0 -157
- package/src/pil/store.ts +0 -29
- package/src/pil/task-tier-map.ts +0 -97
- package/src/pil/timeout.ts +0 -10
- package/src/pil/types.ts +0 -168
- 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__/backlog-builder.test.ts +0 -200
- package/src/product-loop/__tests__/backlog-store.test.ts +0 -119
- 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 -315
- 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-context-format.test.ts +0 -111
- 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 -246
- 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-prompt-specificity.test.ts +0 -65
- package/src/product-loop/__tests__/discovery-recommender-ecosystem.test.ts +0 -192
- 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 -222
- 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__/gather-selectable-alts.test.ts +0 -119
- package/src/product-loop/__tests__/hot-path.spec.ts +0 -177
- package/src/product-loop/__tests__/integration.test.ts +0 -350
- package/src/product-loop/__tests__/loop-driver-audit.test.ts +0 -327
- package/src/product-loop/__tests__/loop-driver.test.ts +0 -253
- package/src/product-loop/__tests__/maintenance-task-synthesis.test.ts +0 -78
- package/src/product-loop/__tests__/phase-a1-a3-sprint-runner.test.ts +0 -315
- package/src/product-loop/__tests__/phase-a2-backlog-build.test.ts +0 -189
- 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 -205
- 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__/pick-backend-stack.test.ts +0 -117
- package/src/product-loop/__tests__/product-identity.test.ts +0 -47
- package/src/product-loop/__tests__/progress-snapshot.test.ts +0 -180
- 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__/repo-brief.test.ts +0 -155
- 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 -258
- 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-planner.test.ts +0 -166
- package/src/product-loop/__tests__/sprint-runner-backlog.test.ts +0 -248
- package/src/product-loop/__tests__/sprint-runner-emit.test.ts +0 -324
- package/src/product-loop/__tests__/sprint-runner-phase-chunks.test.ts +0 -220
- package/src/product-loop/__tests__/sprint-runner.test.ts +0 -501
- package/src/product-loop/__tests__/sprint-self-verify.test.ts +0 -77
- package/src/product-loop/__tests__/sprint-store.test.ts +0 -98
- 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 -183
- package/src/product-loop/__tests__/typed-artifacts.test.ts +0 -259
- package/src/product-loop/__tests__/types.test.ts +0 -103
- package/src/product-loop/__tests__/verify-failure-threshold.test.ts +0 -178
- 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/backlog-builder.ts +0 -253
- package/src/product-loop/backlog-store.ts +0 -62
- 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 -139
- 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 -56
- package/src/product-loop/discovery-council-runner.ts +0 -78
- package/src/product-loop/discovery-detection.ts +0 -161
- package/src/product-loop/discovery-ecosystem.ts +0 -239
- package/src/product-loop/discovery-interview.ts +0 -288
- 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 -514
- 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 -386
- package/src/product-loop/index.ts +0 -1855
- package/src/product-loop/loop-driver.ts +0 -900
- 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/progress-snapshot.ts +0 -216
- package/src/product-loop/reality-anchor.ts +0 -45
- package/src/product-loop/repo-audit.ts +0 -314
- package/src/product-loop/repo-brief.ts +0 -235
- 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-planner.ts +0 -241
- package/src/product-loop/sprint-runner.ts +0 -801
- package/src/product-loop/sprint-self-verify.ts +0 -189
- package/src/product-loop/sprint-store.ts +0 -96
- 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 -570
- 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 -147
- 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 -232
- package/src/providers/__tests__/capabilities-sanitize.test.ts +0 -66
- package/src/providers/__tests__/capabilities.test.ts +0 -44
- package/src/providers/__tests__/provider-coverage.test.ts +0 -48
- package/src/providers/__tests__/reasoning-roundtrip.test.ts +0 -150
- package/src/providers/__tests__/runtime-integration.test.ts +0 -106
- package/src/providers/__tests__/runtime.test.ts +0 -94
- package/src/providers/__tests__/siliconflow-sse-repair.test.ts +0 -300
- 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 -230
- 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__/grok-oauth.test.ts +0 -283
- 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/grok-oauth.ts +0 -406
- package/src/providers/auth/openai-oauth.ts +0 -455
- package/src/providers/auth/registry.ts +0 -138
- package/src/providers/auth/token-store.ts +0 -154
- package/src/providers/auth/types.ts +0 -111
- package/src/providers/capabilities.ts +0 -355
- 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 -278
- 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 -62
- 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 -97
- package/src/providers/pricing.ts +0 -128
- 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 -311
- package/src/providers/siliconflow-sse-repair.ts +0 -201
- 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 -55
- 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 -28
- package/src/providers/strategies/xai.strategy.ts +0 -33
- 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/reporter/__tests__/acl-check.test.ts +0 -71
- package/src/reporter/__tests__/auto-fire.test.ts +0 -161
- package/src/reporter/__tests__/budget.test.ts +0 -74
- package/src/reporter/__tests__/handlers.test.ts +0 -192
- package/src/reporter/__tests__/query-router.test.ts +0 -115
- package/src/reporter/acl-check.ts +0 -54
- package/src/reporter/auto-fire.ts +0 -168
- package/src/reporter/budget.ts +0 -59
- package/src/reporter/handlers.ts +0 -212
- package/src/reporter/index.ts +0 -210
- package/src/reporter/query-router.ts +0 -51
- 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 -51
- package/src/router/classifier/regex.ts +0 -160
- 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 -209
- package/src/router/decide.ts +0 -509
- 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/role-override.test.ts +0 -37
- 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 -234
- package/src/router/warm.ts +0 -93
- package/src/scaffold/__tests__/continuation-prompt.test.ts +0 -93
- package/src/scaffold/__tests__/continue-as-council.spec.ts +0 -122
- 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 -457
- 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/self-qa/__tests__/agentic-context.test.ts +0 -104
- package/src/self-qa/__tests__/agentic-loop.test.ts +0 -70
- package/src/self-qa/__tests__/delta-encoder.test.ts +0 -113
- package/src/self-qa/__tests__/judge.test.ts +0 -152
- package/src/self-qa/__tests__/scenario-planner.test.ts +0 -87
- package/src/self-qa/__tests__/spec-emitter.test.ts +0 -67
- package/src/self-qa/agentic-context.ts +0 -211
- package/src/self-qa/agentic-loop.ts +0 -590
- package/src/self-qa/delta-encoder.ts +0 -149
- package/src/self-qa/index.ts +0 -117
- package/src/self-qa/judge.ts +0 -248
- package/src/self-qa/orchestrator.ts +0 -269
- package/src/self-qa/scenario-planner.ts +0 -289
- package/src/self-qa/spec-emitter.ts +0 -152
- package/src/self-qa/types.ts +0 -98
- package/src/storage/__tests__/migrations.test.ts +0 -395
- package/src/storage/__tests__/sweep-stale-pending.test.ts +0 -112
- package/src/storage/__tests__/ui-interaction-log.test.ts +0 -136
- 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 -126
- package/src/storage/migrations.ts +0 -205
- package/src/storage/session-dir.ts +0 -37
- package/src/storage/sessions.ts +0 -225
- package/src/storage/tool-results.ts +0 -56
- package/src/storage/transcript-response-entry.test.ts +0 -115
- package/src/storage/transcript-view.ts +0 -45
- package/src/storage/transcript.test.ts +0 -24
- package/src/storage/transcript.ts +0 -637
- package/src/storage/ui-interaction-log.ts +0 -170
- 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/__tests__/vision-gate.test.ts +0 -66
- package/src/tools/bash-output-cache.test.ts +0 -113
- package/src/tools/bash-output-cache.ts +0 -156
- package/src/tools/bash-output-integration.test.ts +0 -33
- package/src/tools/bash.test.ts +0 -447
- package/src/tools/bash.ts +0 -769
- package/src/tools/computer.test.ts +0 -187
- package/src/tools/computer.ts +0 -632
- package/src/tools/file-tracker.test.ts +0 -101
- package/src/tools/file-tracker.ts +0 -70
- package/src/tools/file.test.ts +0 -151
- package/src/tools/file.ts +0 -203
- package/src/tools/grep.ts +0 -187
- package/src/tools/registry-bash-empty-command.test.ts +0 -64
- package/src/tools/registry-bash-footer.test.ts +0 -95
- package/src/tools/registry-ee-query.test.ts +0 -57
- package/src/tools/registry-session-repeat.test.ts +0 -105
- package/src/tools/registry.test.ts +0 -38
- package/src/tools/registry.ts +0 -704
- package/src/tools/schedule.test.ts +0 -143
- package/src/tools/schedule.ts +0 -610
- package/src/tools/todo-write-snapshot.test.ts +0 -53
- package/src/tools/todo-write-snapshot.ts +0 -63
- package/src/tools/vision-gate.ts +0 -74
- package/src/types/index.ts +0 -550
- package/src/ui/__tests__/picker-providers.test.ts +0 -37
- package/src/ui/agents-modal.tsx +0 -293
- package/src/ui/app.tsx +0 -7084
- 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__/task-list-panel.test.ts +0 -37
- 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 -44
- package/src/ui/components/council-leader-bubble.tsx +0 -40
- package/src/ui/components/council-message-bubble.tsx +0 -110
- package/src/ui/components/council-phase-timeline.tsx +0 -112
- package/src/ui/components/council-placeholder-bubble.tsx +0 -64
- package/src/ui/components/council-question-card.tsx +0 -256
- package/src/ui/components/council-status-list.tsx +0 -111
- package/src/ui/components/council-synthesis-banner.tsx +0 -36
- package/src/ui/components/diff-view.tsx +0 -225
- package/src/ui/components/halt-recovery-card.tsx +0 -84
- 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 -442
- 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/task-list-panel.tsx +0 -127
- package/src/ui/components/tool-group.tsx +0 -129
- 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 -61
- 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 -347
- 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/picker-providers.ts +0 -41
- 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 -182
- package/src/ui/slash/__tests__/menu-parity.test.ts +0 -44
- 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 -98
- package/src/ui/slash/__tests__/status-render.test.ts +0 -82
- 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 -309
- package/src/ui/slash/ideal.ts +0 -292
- package/src/ui/slash/menu-items.ts +0 -107
- 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/slash/status.ts +0 -36
- package/src/ui/state/active-run.ts +0 -56
- package/src/ui/status-bar/index.test.tsx +0 -154
- package/src/ui/status-bar/index.tsx +0 -126
- package/src/ui/status-bar/store.test.ts +0 -131
- package/src/ui/status-bar/store.ts +0 -332
- 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/__tests__/format.test.ts +0 -71
- package/src/ui/utils/__tests__/tools.test.ts +0 -57
- package/src/ui/utils/color.ts +0 -19
- package/src/ui/utils/format.ts +0 -133
- package/src/ui/utils/modal.ts +0 -9
- package/src/ui/utils/text.ts +0 -32
- package/src/ui/utils/tools.ts +0 -137
- package/src/usage/.gitkeep +0 -0
- package/src/usage/__tests__/product-ledger.test.ts +0 -86
- package/src/usage/cost-log.ts +0 -158
- package/src/usage/decision-log.ts +0 -86
- package/src/usage/downgrade.test.ts +0 -86
- package/src/usage/downgrade.ts +0 -88
- 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 -119
- 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__/llm-deadline.test.ts +0 -64
- 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/llm-deadline.ts +0 -80
- package/src/utils/permission-mode.test.ts +0 -121
- package/src/utils/permission-mode.ts +0 -94
- 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 -1163
- package/src/utils/shell.test.ts +0 -102
- package/src/utils/shell.ts +0 -204
- 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 -84
- 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 -495
- 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/{pil/layer16-clarity.test.d.ts → council/__tests__/clarification-prompt.test.d.ts} +0 -0
|
@@ -1,2752 +0,0 @@
|
|
|
1
|
-
// Multi-provider wired — runtime dispatch via providers/runtime.ts.
|
|
2
|
-
|
|
3
|
-
import type { ModelMessage, ToolSet } from "ai";
|
|
4
|
-
import { extractSession } from "../ee/extract-session.js";
|
|
5
|
-
import {
|
|
6
|
-
bootstrapEEClient,
|
|
7
|
-
getDefaultEEClient,
|
|
8
|
-
getLastSurfacedState,
|
|
9
|
-
updateLastSurfacedState,
|
|
10
|
-
} from "../ee/intercept.js";
|
|
11
|
-
import { getTenantId } from "../ee/tenant.js";
|
|
12
|
-
import { emitTranscriptToDisk } from "../ee/transcript-emit.js";
|
|
13
|
-
import { createRun, getActiveRunId, setActiveRunId } from "../flow/run-manager.js";
|
|
14
|
-
import { ensureFlowDir } from "../flow/scaffold.js";
|
|
15
|
-
import { executeEventHooks } from "../hooks/index";
|
|
16
|
-
import type {
|
|
17
|
-
NotificationHookInput,
|
|
18
|
-
PostCompactHookInput,
|
|
19
|
-
PreCompactHookInput,
|
|
20
|
-
SessionEndHookInput,
|
|
21
|
-
SubagentStartHookInput,
|
|
22
|
-
SubagentStopHookInput,
|
|
23
|
-
TaskCompletedHookInput,
|
|
24
|
-
TaskCreatedHookInput,
|
|
25
|
-
} from "../hooks/types";
|
|
26
|
-
import { shutdownWorkspaceLspManager } from "../lsp/runtime";
|
|
27
|
-
import { ensureDefaultMcpServers } from "../mcp/auto-setup.js";
|
|
28
|
-
import { getModelInfo, normalizeModelId } from "../models/registry.js";
|
|
29
|
-
import { getProviderCapabilities } from "../providers/capabilities.js";
|
|
30
|
-
import { apiBaseFor } from "../providers/endpoints.js";
|
|
31
|
-
import { loadKeyForProvider } from "../providers/keychain.js";
|
|
32
|
-
import {
|
|
33
|
-
createProviderFactory,
|
|
34
|
-
createProviderFactoryAsync,
|
|
35
|
-
detectProviderForModel,
|
|
36
|
-
requireRuntimeProvider,
|
|
37
|
-
resolveModelRuntime as resolveRuntime,
|
|
38
|
-
} from "../providers/runtime.js";
|
|
39
|
-
import { ALL_PROVIDER_IDS, type ProviderId } from "../providers/types.js";
|
|
40
|
-
import {
|
|
41
|
-
appendCompaction,
|
|
42
|
-
appendMessages,
|
|
43
|
-
appendSystemMessage,
|
|
44
|
-
buildChatEntries,
|
|
45
|
-
getNextMessageSequence,
|
|
46
|
-
getSessionTotalTokens,
|
|
47
|
-
loadTranscript,
|
|
48
|
-
loadTranscriptState,
|
|
49
|
-
logInteraction,
|
|
50
|
-
markMessageCompleted,
|
|
51
|
-
recordUsageEvent,
|
|
52
|
-
SessionStore,
|
|
53
|
-
} from "../storage/index.js";
|
|
54
|
-
import { BashTool } from "../tools/bash";
|
|
55
|
-
import { createBuiltinTools } from "../tools/registry.js";
|
|
56
|
-
import { type ScheduleDaemonStatus, ScheduleManager, type StoredSchedule } from "../tools/schedule";
|
|
57
|
-
import type {
|
|
58
|
-
AgentMode,
|
|
59
|
-
ChatEntry,
|
|
60
|
-
SessionInfo,
|
|
61
|
-
SessionSnapshot,
|
|
62
|
-
StreamChunk,
|
|
63
|
-
SubagentStatus,
|
|
64
|
-
TaskRequest,
|
|
65
|
-
ToolCall,
|
|
66
|
-
ToolResult,
|
|
67
|
-
UsageSource,
|
|
68
|
-
VerifyRecipe,
|
|
69
|
-
WorkspaceInfo,
|
|
70
|
-
} from "../types/index";
|
|
71
|
-
import { statusBarStore } from "../ui/status-bar/store.js";
|
|
72
|
-
import { appendCostLog } from "../usage/cost-log.js";
|
|
73
|
-
import { appendDecisionLog } from "../usage/decision-log.js";
|
|
74
|
-
import { projectCostUSD } from "../usage/estimator.js";
|
|
75
|
-
import type { PermissionMode } from "../utils/permission-mode.js";
|
|
76
|
-
import {
|
|
77
|
-
type CustomSubagentConfig,
|
|
78
|
-
getAutoCompactThresholdPct,
|
|
79
|
-
getCouncilRounds,
|
|
80
|
-
getCurrentModel,
|
|
81
|
-
getCurrentShellSettings,
|
|
82
|
-
getModeSpecificModel,
|
|
83
|
-
getRoleModel,
|
|
84
|
-
getRoleModels,
|
|
85
|
-
isAutoCompactAfterTurnEnabled,
|
|
86
|
-
isCouncilMultiProviderPreferred,
|
|
87
|
-
isProviderDisabled,
|
|
88
|
-
type ModelRole,
|
|
89
|
-
type SandboxMode,
|
|
90
|
-
type SandboxSettings,
|
|
91
|
-
} from "../utils/settings";
|
|
92
|
-
import { runSideQuestion, type SideQuestionResult } from "../utils/side-question";
|
|
93
|
-
import { buildVerifyDetectPrompt, normalizeVerifyRecipe } from "../verify/entrypoint";
|
|
94
|
-
import { runVerifyOrchestration } from "../verify/orchestrator";
|
|
95
|
-
import {
|
|
96
|
-
type AgentOptions,
|
|
97
|
-
type BatchChatCompletionResponse,
|
|
98
|
-
type BatchClientOptions,
|
|
99
|
-
type BatchFunctionTool,
|
|
100
|
-
COUNCIL_COLOR_BG,
|
|
101
|
-
COUNCIL_COLOR_RESET,
|
|
102
|
-
COUNCIL_ROLE_COLORS,
|
|
103
|
-
type LegacyProvider,
|
|
104
|
-
type ProcessMessageObserver,
|
|
105
|
-
type ProcessMessageUsage,
|
|
106
|
-
type ResolvedModelRuntime,
|
|
107
|
-
} from "./agent-options";
|
|
108
|
-
import { BatchTurnRunner, type BatchTurnRunnerDeps } from "./batch-turn-runner.js";
|
|
109
|
-
import {
|
|
110
|
-
accumulateUsage,
|
|
111
|
-
buildAssistantBatchMessage,
|
|
112
|
-
buildBatchChatCompletionRequest,
|
|
113
|
-
buildBatchName,
|
|
114
|
-
buildToolBatchMessage,
|
|
115
|
-
type ExecutedBatchTool,
|
|
116
|
-
extractJsonObject,
|
|
117
|
-
getBatchUsage,
|
|
118
|
-
hasUsage,
|
|
119
|
-
parseToolArgumentsOrRaw,
|
|
120
|
-
toLocalToolCall,
|
|
121
|
-
} from "./batch-utils";
|
|
122
|
-
import {
|
|
123
|
-
type CompactionSettings,
|
|
124
|
-
createCompactionSummaryMessage,
|
|
125
|
-
DEFAULT_KEEP_RECENT_TOKENS,
|
|
126
|
-
DEFAULT_RESERVE_TOKENS,
|
|
127
|
-
estimateConversationTokens,
|
|
128
|
-
extractUserContent,
|
|
129
|
-
generateCompactionSummary,
|
|
130
|
-
POST_TURN_MIN_TOKENS,
|
|
131
|
-
prepareCompaction,
|
|
132
|
-
shouldCompactContext,
|
|
133
|
-
} from "./compaction";
|
|
134
|
-
import { CouncilManager } from "./council-manager.js";
|
|
135
|
-
import { CrossTurnDedup, isCrossTurnDedupEnabled } from "./cross-turn-dedup.js";
|
|
136
|
-
import { DelegationManager } from "./delegations";
|
|
137
|
-
import { loadFlowResumeDigest } from "./flow-resume.js";
|
|
138
|
-
import { MessageProcessor, type MessageProcessorDeps } from "./message-processor.js";
|
|
139
|
-
import { lastPersistedSeq } from "./message-seq.js";
|
|
140
|
-
import { buildSystemPrompt, MAX_TOOL_ROUNDS } from "./prompts";
|
|
141
|
-
import { getReadPathBudgetCap, ReadPathBudget } from "./read-path-budget.js";
|
|
142
|
-
import { withStreamRetry } from "./retry-stream.js";
|
|
143
|
-
import { StreamRunner, type StreamRunnerDeps } from "./stream-runner.js";
|
|
144
|
-
import { type ModelTaskKind, resolveModelForTask } from "./sub-agent-model-tier.js";
|
|
145
|
-
import { setProviderHint } from "./token-counter.js";
|
|
146
|
-
import type { ToolLoopCapAsk } from "./tool-loop-cap.js";
|
|
147
|
-
import { firstLine, formatSubagentActivity, toToolResult } from "./tool-utils";
|
|
148
|
-
|
|
149
|
-
// ---------------------------------------------------------------------------
|
|
150
|
-
// Provider implementations
|
|
151
|
-
// ---------------------------------------------------------------------------
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Create a provider factory for the given provider ID using the shared runtime module.
|
|
155
|
-
*/
|
|
156
|
-
function createProvider(providerId: ProviderId, apiKey: string, baseURL?: string): LegacyProvider {
|
|
157
|
-
return createProviderFactory(providerId, { apiKey, baseURL }).factory;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* True iff `url` equals the default apiBase of ANY registered provider.
|
|
162
|
-
* Used to detect stale carryover of one provider's default URL into another
|
|
163
|
-
* provider's factory after a /model switch (see setModel + setApiKey).
|
|
164
|
-
*/
|
|
165
|
-
function isAnyProviderApiBase(url: string | null | undefined): boolean {
|
|
166
|
-
if (!url) return false;
|
|
167
|
-
for (const id of ALL_PROVIDER_IDS) {
|
|
168
|
-
if (url === apiBaseFor(id)) return true;
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Generate a session title using the Anthropic provider.
|
|
175
|
-
* Kept as a lightweight stub for Phase 0 — title generation ships in Phase 1.
|
|
176
|
-
*/
|
|
177
|
-
function genTitle(
|
|
178
|
-
_provider: LegacyProvider,
|
|
179
|
-
userMessage: string,
|
|
180
|
-
): Promise<{ title: string; modelId: string; usage?: { totalTokens?: number } }> {
|
|
181
|
-
// Phase 0 stub: return a truncated version of the first user message as title.
|
|
182
|
-
// Phase 1 will replace this with a real LLM-based title generation call.
|
|
183
|
-
const title = userMessage.slice(0, 60).trim() || "New session";
|
|
184
|
-
return Promise.resolve({ title, modelId: getCurrentModel() });
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Resolve a model ID to a runnable AI SDK LanguageModel.
|
|
189
|
-
* Uses the Anthropic provider factory created by createProvider().
|
|
190
|
-
*/
|
|
191
|
-
function resolveModelRuntime(provider: LegacyProvider, modelId: string): ResolvedModelRuntime {
|
|
192
|
-
return resolveRuntime(provider, modelId);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
async function toolSetToBatchTools(_tools: ToolSet): Promise<BatchFunctionTool[]> {
|
|
196
|
-
// Batch API not supported with Anthropic in Phase 0. Phase 1 may add this.
|
|
197
|
-
throw new Error("Batch API not available in Phase 0. Use standard streaming mode.");
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
async function createBatch(_opts: BatchClientOptions & { name?: string }): Promise<{ batch_id: string }> {
|
|
201
|
-
throw new Error("Batch API not available in Phase 0. Use standard streaming mode.");
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
async function addBatchRequests(
|
|
205
|
-
_opts: BatchClientOptions & { batchId: string; batchRequests: unknown[] },
|
|
206
|
-
): Promise<void> {
|
|
207
|
-
throw new Error("Batch API not available in Phase 0. Use standard streaming mode.");
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async function pollBatchRequestResult(
|
|
211
|
-
_opts: BatchClientOptions & { batchId: string; batchRequestId: string },
|
|
212
|
-
): Promise<unknown> {
|
|
213
|
-
throw new Error("Batch API not available in Phase 0. Use standard streaming mode.");
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function getBatchChatCompletion(_result: unknown): BatchChatCompletionResponse {
|
|
217
|
-
throw new Error("Batch API not available in Phase 0. Use standard streaming mode.");
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function createTools(
|
|
221
|
-
_bash: unknown,
|
|
222
|
-
_provider: LegacyProvider,
|
|
223
|
-
_mode: unknown,
|
|
224
|
-
_opts?: {
|
|
225
|
-
runTask?: (request: TaskRequest, abortSignal?: AbortSignal) => Promise<ToolResult>;
|
|
226
|
-
runDelegation?: (request: TaskRequest, abortSignal?: AbortSignal) => Promise<ToolResult>;
|
|
227
|
-
readDelegation?: (id: string) => Promise<ToolResult>;
|
|
228
|
-
listDelegations?: () => Promise<ToolResult>;
|
|
229
|
-
scheduleManager?: unknown;
|
|
230
|
-
subagents?: unknown[];
|
|
231
|
-
sendTelegramFile?: (filePath: string) => Promise<ToolResult>;
|
|
232
|
-
sessionId?: string;
|
|
233
|
-
modelId?: string;
|
|
234
|
-
},
|
|
235
|
-
): ToolSet {
|
|
236
|
-
return createBuiltinTools(_bash as BashTool, (_mode ?? "agent") as AgentMode, {
|
|
237
|
-
runTask: _opts?.runTask,
|
|
238
|
-
runDelegation: _opts?.runDelegation,
|
|
239
|
-
readDelegation: _opts?.readDelegation,
|
|
240
|
-
listDelegations: _opts?.listDelegations,
|
|
241
|
-
modelId: _opts?.modelId,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// ---------------------------------------------------------------------------
|
|
246
|
-
// END Plan 00-05 provider implementations
|
|
247
|
-
// (Phase 12.3 — `buildVisionUserMessages` was inlined into StreamRunner;
|
|
248
|
-
// vision is an anti-feature per PROJECT.md Out-of-Scope so the helper is gone.)
|
|
249
|
-
// ---------------------------------------------------------------------------
|
|
250
|
-
|
|
251
|
-
// ============================================================================
|
|
252
|
-
// Agent class — fields, constructor, session management, core processing loop
|
|
253
|
-
// ============================================================================
|
|
254
|
-
|
|
255
|
-
export class Agent {
|
|
256
|
-
private provider: LegacyProvider | null = null;
|
|
257
|
-
private providerId: ProviderId = null!;
|
|
258
|
-
private apiKey: string | null = null;
|
|
259
|
-
private baseURL: string | null = null;
|
|
260
|
-
private bash: BashTool;
|
|
261
|
-
private delegations: DelegationManager;
|
|
262
|
-
private schedules: ScheduleManager;
|
|
263
|
-
private sessionStore: SessionStore | null = null;
|
|
264
|
-
private workspace: WorkspaceInfo | null = null;
|
|
265
|
-
private session: SessionInfo | null = null;
|
|
266
|
-
private messages: ModelMessage[] = [];
|
|
267
|
-
private messageSeqs: Array<number | null> = [];
|
|
268
|
-
private abortController: AbortController | null = null;
|
|
269
|
-
private maxToolRounds: number;
|
|
270
|
-
private mode: AgentMode = "agent";
|
|
271
|
-
private modelId: string;
|
|
272
|
-
private maxTokens: number;
|
|
273
|
-
private planContext: string | null = null;
|
|
274
|
-
private subagentStatusListeners = new Set<(status: SubagentStatus | null) => void>();
|
|
275
|
-
private sendTelegramFile: ((filePath: string) => Promise<ToolResult>) | null = null;
|
|
276
|
-
private batchApi = false;
|
|
277
|
-
private sessionStartHookFired = false;
|
|
278
|
-
/** PIL context for current turn — set after runPipeline, cleared after recordUsage. */
|
|
279
|
-
private _pilActive = false;
|
|
280
|
-
private _pilEnrichmentDelta = 0;
|
|
281
|
-
/**
|
|
282
|
-
* Breakdown of the system prompt + messages + tools sent on the last call.
|
|
283
|
-
* Captured immediately before streamText and consumed by recordUsage to
|
|
284
|
-
* attach to the cost-log entry. Cleared after recordUsage so subsequent
|
|
285
|
-
* non-message calls don't reuse stale data.
|
|
286
|
-
*/
|
|
287
|
-
private _lastPromptBreakdown: Record<string, number> | null = null;
|
|
288
|
-
/**
|
|
289
|
-
* Phase O1 — JSON-shape of the providerOptions object on the most
|
|
290
|
-
* recent streamText call. Captured immediately before streamText and
|
|
291
|
-
* consumed by recordUsage; cleared after. Cost-leak forensics surfaces
|
|
292
|
-
* this so we can answer "did this billed call carry store=true?" etc.
|
|
293
|
-
*/
|
|
294
|
-
private _lastProviderOptionsShape: string | null = null;
|
|
295
|
-
/** External abort context from src/index.ts SIGINT handler (TUI-04). */
|
|
296
|
-
private externalAbortContext: import("./abort.js").AbortContext | null = null;
|
|
297
|
-
/** Pending calls log for Pitfall 9 staged-write tracking. */
|
|
298
|
-
private pendingCalls: import("./pending-calls.js").PendingCallsLog | null = null;
|
|
299
|
-
/** Active permission mode — controls which tool calls auto-approve vs require user confirmation. */
|
|
300
|
-
private permissionMode: PermissionMode = "safe";
|
|
301
|
-
/** Flow run init promise — awaited before first message turn. */
|
|
302
|
-
private _flowReady: Promise<void> | null = null;
|
|
303
|
-
/** Active .muonroi-flow/ run ID for this session. */
|
|
304
|
-
private _activeRunId: string | null = null;
|
|
305
|
-
/** Resume digest loaded from active flow run state.md. */
|
|
306
|
-
private _resumeDigest: string | null = null;
|
|
307
|
-
/**
|
|
308
|
-
* Phase 12.1-02: All council state (synthesis/continuation flags, resolver
|
|
309
|
-
* + buffer maps, stats) lives inside CouncilManager. Agent holds one ref.
|
|
310
|
-
*/
|
|
311
|
-
private councilManager: CouncilManager;
|
|
312
|
-
/** Whether compaction already ran during the current turn (prevents double-compact). */
|
|
313
|
-
private _compactedThisTurn = false;
|
|
314
|
-
/** Guard: OAuth provider init runs at most once per Agent instance. */
|
|
315
|
-
private _oauthInitDone = false;
|
|
316
|
-
/** P0 native observation: warning IDs surfaced earlier in this session — sent as intent_context.priorWarningIdsInSession. */
|
|
317
|
-
private _priorWarningIdsInSession = new Set<string>();
|
|
318
|
-
/** EE session guidance: structured warnings accumulated across turns — injected into model context at turn start. Keyed by principle_uuid to deduplicate. */
|
|
319
|
-
private _sessionEEGuidance = new Map<
|
|
320
|
-
string,
|
|
321
|
-
{ toolName: string; message: string; why: string; confidence: number }
|
|
322
|
-
>();
|
|
323
|
-
/** P0 native observation: rolling buffer of assistant reasoning text in current turn — last 200 chars sent as intent_context.assistantReasoningExcerpt. */
|
|
324
|
-
private _turnAssistantReasoning = "";
|
|
325
|
-
/** Per-call correlation id for top-level streamText; set in MessageProcessor, consumed by recordUsage / onFinish llm-done. */
|
|
326
|
-
private _currentCallId = "";
|
|
327
|
-
/** P0 native observation: first 200 chars of the user's current turn — sent as intent_context.userGoalExcerpt to PreToolUse. */
|
|
328
|
-
private _turnUserGoalExcerpt = "";
|
|
329
|
-
/** Compaction statistics tracking count and total tokens saved. */
|
|
330
|
-
private _compactionStats: { count: number; totalSaved: number } = { count: 0, totalSaved: 0 };
|
|
331
|
-
/**
|
|
332
|
-
* Pinned message sequences. A pinned user message is preserved verbatim across
|
|
333
|
-
* compaction — it is re-injected as a system note immediately after the
|
|
334
|
-
* compaction summary, so the model still sees the original wording.
|
|
335
|
-
* V1 only supports user messages (avoids splitting tool-call/result pairs).
|
|
336
|
-
*/
|
|
337
|
-
private _pinnedSeqs = new Set<number>();
|
|
338
|
-
/** One-shot cwd note injected at the start of the next processMessage turn after setCwd(). Cleared after injection. */
|
|
339
|
-
private _pendingCwdNote: string | null = null;
|
|
340
|
-
|
|
341
|
-
// Phase C3: cross-turn tool-output dedup. One instance per session; bumped
|
|
342
|
-
// on each user turn. Lazily initialized so disabled-via-env path stays cheap.
|
|
343
|
-
private _crossTurnDedup: CrossTurnDedup | null = isCrossTurnDedupEnabled() ? new CrossTurnDedup() : null;
|
|
344
|
-
// Phase C4 — input-keyed read-path budget. Complements C3 (output hash) by
|
|
345
|
-
// catching re-reads of files the agent edited between rounds. Disabled
|
|
346
|
-
// when MUONROI_MAX_READS_PER_PATH=0.
|
|
347
|
-
private _readBudget: ReadPathBudget | null = (() => {
|
|
348
|
-
const cap = getReadPathBudgetCap();
|
|
349
|
-
return cap > 0 ? new ReadPathBudget(cap) : null;
|
|
350
|
-
})();
|
|
351
|
-
|
|
352
|
-
constructor(
|
|
353
|
-
apiKey: string | undefined,
|
|
354
|
-
baseURL?: string,
|
|
355
|
-
model?: string,
|
|
356
|
-
maxToolRounds?: number,
|
|
357
|
-
options: AgentOptions = {},
|
|
358
|
-
) {
|
|
359
|
-
this.baseURL = baseURL || null;
|
|
360
|
-
this.bash = new BashTool(process.cwd(), {
|
|
361
|
-
sandboxMode: options.sandboxMode ?? "off",
|
|
362
|
-
sandboxSettings: options.sandboxSettings,
|
|
363
|
-
shellSettings: options.shellSettings ?? getCurrentShellSettings(),
|
|
364
|
-
});
|
|
365
|
-
this.delegations = new DelegationManager(() => this.bash.getCwd());
|
|
366
|
-
// Phase 12.1-02: council state + helpers live in CouncilManager. DI via
|
|
367
|
-
// getter callbacks so the manager reads live Agent state without holding
|
|
368
|
-
// a circular reference to the Agent instance.
|
|
369
|
-
this.councilManager = new CouncilManager({
|
|
370
|
-
getModelId: () => this.modelId,
|
|
371
|
-
getSessionId: () => this.session?.id ?? null,
|
|
372
|
-
hasSessionStore: () => this.sessionStore !== null,
|
|
373
|
-
getMessages: () => this.messages,
|
|
374
|
-
getBash: () => this.bash,
|
|
375
|
-
getMode: () => this.mode,
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
const initialMode: AgentMode = "agent";
|
|
379
|
-
this.modelId = normalizeModelId(model || getCurrentModel(initialMode));
|
|
380
|
-
this.providerId = detectProviderForModel(this.modelId);
|
|
381
|
-
setProviderHint(this.providerId);
|
|
382
|
-
if (apiKey) {
|
|
383
|
-
this.setApiKey(apiKey, baseURL);
|
|
384
|
-
}
|
|
385
|
-
this.schedules = new ScheduleManager(
|
|
386
|
-
() => this.bash.getCwd(),
|
|
387
|
-
() => this.modelId,
|
|
388
|
-
);
|
|
389
|
-
this.maxToolRounds = maxToolRounds || MAX_TOOL_ROUNDS;
|
|
390
|
-
const envMax = Number(process.env.MUONROI_MAX_TOKENS);
|
|
391
|
-
this.maxTokens = Number.isFinite(envMax) && envMax > 0 ? envMax : 16_384;
|
|
392
|
-
this.batchApi = options.batchApi ?? false;
|
|
393
|
-
// TUI-04: wire external abort context and pending calls log if provided.
|
|
394
|
-
this.externalAbortContext = options.abortContext ?? null;
|
|
395
|
-
this.pendingCalls = options.pendingCalls ?? null;
|
|
396
|
-
this.permissionMode = options.permissionMode ?? "safe";
|
|
397
|
-
ensureDefaultMcpServers();
|
|
398
|
-
|
|
399
|
-
if (options.persistSession !== false) {
|
|
400
|
-
this.sessionStore = new SessionStore(this.bash.getCwd());
|
|
401
|
-
this.workspace = this.sessionStore.getWorkspace();
|
|
402
|
-
this.session = this.sessionStore.openSession(options.session, this.modelId, this.mode, this.bash.getCwd());
|
|
403
|
-
this.mode = this.session.mode;
|
|
404
|
-
const transcript = loadTranscriptState(this.session.id);
|
|
405
|
-
this.messages = transcript.messages;
|
|
406
|
-
this.messageSeqs = transcript.seqs;
|
|
407
|
-
this.sessionStore.setModel(this.session.id, this.modelId);
|
|
408
|
-
|
|
409
|
-
// Flow run setup — fire-and-forget, awaited before first message turn.
|
|
410
|
-
this._flowReady = this._initFlow();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Initialize .muonroi-flow/ run for this session.
|
|
416
|
-
* Fail-open: any error sets _activeRunId = null silently.
|
|
417
|
-
*/
|
|
418
|
-
private async _initFlow(): Promise<void> {
|
|
419
|
-
await bootstrapEEClient().catch(() => {});
|
|
420
|
-
try {
|
|
421
|
-
const flowDir = await ensureFlowDir(this.bash.getCwd());
|
|
422
|
-
const existing = await getActiveRunId(flowDir);
|
|
423
|
-
if (existing) {
|
|
424
|
-
this._activeRunId = existing;
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
const run = await createRun(flowDir);
|
|
428
|
-
await setActiveRunId(flowDir, run.id);
|
|
429
|
-
this._activeRunId = run.id;
|
|
430
|
-
} catch {
|
|
431
|
-
this._activeRunId = null;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// Load resume digest for PIL context injection (fail-open).
|
|
435
|
-
try {
|
|
436
|
-
this._resumeDigest = await loadFlowResumeDigest(this.bash.getCwd());
|
|
437
|
-
} catch {
|
|
438
|
-
this._resumeDigest = null;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
getModel(): string {
|
|
443
|
-
return this.modelId;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
getActiveRunId(): string | null {
|
|
447
|
-
return this._activeRunId;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
setModel(model: string): void {
|
|
451
|
-
this.modelId = normalizeModelId(model);
|
|
452
|
-
const newProviderId = detectProviderForModel(this.modelId);
|
|
453
|
-
if (newProviderId !== this.providerId && this.apiKey) {
|
|
454
|
-
this.providerId = newProviderId;
|
|
455
|
-
setProviderHint(this.providerId);
|
|
456
|
-
// Drop this.baseURL when it points at a DIFFERENT provider's default
|
|
457
|
-
// apiBase — otherwise the rebuilt factory binds the new provider's
|
|
458
|
-
// strategy to the OLD provider's URL, sending requests to the wrong
|
|
459
|
-
// host. Evidence: session 2492d6579b1d — user switched defaultProvider
|
|
460
|
-
// siliconflow→ (via UI), this.baseURL was still api.deepseek.com from
|
|
461
|
-
// startup, SiliconflowStrategy.createFactory was created with that
|
|
462
|
-
// baseURL, requests landed at api.deepseek.com which rejected the SF-
|
|
463
|
-
// style model id ("deepseek-ai/DeepSeek-V4-Flash") with "supported API
|
|
464
|
-
// model names are deepseek-v4-pro or deepseek-v4-flash".
|
|
465
|
-
// A user-supplied custom baseURL is preserved only when it does NOT
|
|
466
|
-
// match any known provider's apiBase (i.e. it's a real override, not
|
|
467
|
-
// a stale default).
|
|
468
|
-
const staleBaseURL = isAnyProviderApiBase(this.baseURL) && this.baseURL !== apiBaseFor(this.providerId);
|
|
469
|
-
const effectiveBaseURL = staleBaseURL ? undefined : (this.baseURL ?? undefined);
|
|
470
|
-
if (staleBaseURL) this.baseURL = null;
|
|
471
|
-
this.provider = createProvider(this.providerId, this.apiKey, effectiveBaseURL);
|
|
472
|
-
}
|
|
473
|
-
if (this.sessionStore && this.session) {
|
|
474
|
-
this.sessionStore.setModel(this.session.id, this.modelId);
|
|
475
|
-
this.session = this.sessionStore.getRequiredSession(this.session.id);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
getMode(): AgentMode {
|
|
480
|
-
return this.mode;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
getSandboxMode(): SandboxMode {
|
|
484
|
-
return this.bash.getSandboxMode();
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
setSandboxMode(mode: SandboxMode): void {
|
|
488
|
-
this.bash.setSandboxMode(mode);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
getSandboxSettings(): SandboxSettings {
|
|
492
|
-
return this.bash.getSandboxSettings();
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
setSandboxSettings(settings: SandboxSettings): void {
|
|
496
|
-
this.bash.setSandboxSettings(settings);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
setMode(mode: AgentMode): void {
|
|
500
|
-
if (mode !== this.mode) {
|
|
501
|
-
this.mode = mode;
|
|
502
|
-
const modeModel = getModeSpecificModel(mode);
|
|
503
|
-
if (modeModel) {
|
|
504
|
-
this.modelId = normalizeModelId(modeModel);
|
|
505
|
-
}
|
|
506
|
-
if (this.sessionStore && this.session) {
|
|
507
|
-
this.sessionStore.setMode(this.session.id, mode);
|
|
508
|
-
this.sessionStore.setModel(this.session.id, this.modelId);
|
|
509
|
-
this.session = this.sessionStore.getRequiredSession(this.session.id);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
setPlanContext(ctx: string | null): void {
|
|
515
|
-
this.planContext = ctx;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
setSendTelegramFile(fn: ((filePath: string) => Promise<ToolResult>) | null): void {
|
|
519
|
-
this.sendTelegramFile = fn;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
hasApiKey(): boolean {
|
|
523
|
-
return !!this.apiKey;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
setApiKey(apiKey: string, baseURL?: string): void {
|
|
527
|
-
this.apiKey = apiKey;
|
|
528
|
-
// Drop baseURL when it points at a DIFFERENT provider's default apiBase
|
|
529
|
-
// (e.g. caller passed the legacy anthropic URL while providerId is
|
|
530
|
-
// siliconflow — without this we'd send siliconflow requests to
|
|
531
|
-
// api.anthropic.com or similar). User-supplied custom URLs that don't
|
|
532
|
-
// match any known provider's apiBase are preserved as real overrides.
|
|
533
|
-
const stale = isAnyProviderApiBase(baseURL) && baseURL !== apiBaseFor(this.providerId);
|
|
534
|
-
const effectiveBaseURL = stale ? undefined : baseURL;
|
|
535
|
-
this.baseURL = stale ? null : baseURL || null;
|
|
536
|
-
this.provider = createProvider(this.providerId, apiKey, effectiveBaseURL);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
setProviderAndKey(providerId: ProviderId, apiKey: string, baseURL?: string): void {
|
|
540
|
-
this.providerId = providerId;
|
|
541
|
-
setProviderHint(this.providerId);
|
|
542
|
-
this.setApiKey(apiKey, baseURL);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
getProviderId(): ProviderId {
|
|
546
|
-
return this.providerId;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
getCwd(): string {
|
|
550
|
-
return this.bash.getCwd();
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
setCwd(dir: string): void {
|
|
554
|
-
this.bash.setCwd(dir);
|
|
555
|
-
this._pendingCwdNote = `(system: working directory has been changed to ${dir} — subsequent shell commands run from there; do NOT cd to that path again)`;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
getMessages(): ModelMessage[] {
|
|
559
|
-
return this.messages;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
async listSchedules(): Promise<StoredSchedule[]> {
|
|
563
|
-
return this.schedules.list();
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
async removeSchedule(id: string): Promise<string> {
|
|
567
|
-
const removed = await this.schedules.remove(id);
|
|
568
|
-
return removed ? `Removed schedule "${removed.name}".` : `Schedule "${id}" not found.`;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
async getScheduleDaemonStatus(): Promise<ScheduleDaemonStatus> {
|
|
572
|
-
return this.schedules.getDaemonStatus();
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
getContextStats(
|
|
576
|
-
contextWindow: number,
|
|
577
|
-
inFlightText = "",
|
|
578
|
-
): {
|
|
579
|
-
contextWindow: number;
|
|
580
|
-
usedTokens: number;
|
|
581
|
-
remainingTokens: number;
|
|
582
|
-
ratioUsed: number;
|
|
583
|
-
ratioRemaining: number;
|
|
584
|
-
} {
|
|
585
|
-
const system = buildSystemPrompt(
|
|
586
|
-
this.bash.getCwd(),
|
|
587
|
-
this.mode,
|
|
588
|
-
this.bash.getSandboxMode(),
|
|
589
|
-
this.planContext,
|
|
590
|
-
undefined,
|
|
591
|
-
this.bash.getSandboxSettings(),
|
|
592
|
-
this.providerId,
|
|
593
|
-
);
|
|
594
|
-
const usedTokens = Math.min(contextWindow, estimateConversationTokens(system, this.messages, inFlightText));
|
|
595
|
-
const remainingTokens = Math.max(0, contextWindow - usedTokens);
|
|
596
|
-
|
|
597
|
-
return {
|
|
598
|
-
contextWindow,
|
|
599
|
-
usedTokens,
|
|
600
|
-
remainingTokens,
|
|
601
|
-
ratioUsed: usedTokens / contextWindow,
|
|
602
|
-
ratioRemaining: remainingTokens / contextWindow,
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
async generateTitle(userMessage: string): Promise<string> {
|
|
607
|
-
const provider = this.provider;
|
|
608
|
-
if (!provider) {
|
|
609
|
-
return "New session";
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
const generated = await genTitle(provider, userMessage);
|
|
613
|
-
this.recordUsage(generated.usage, "title", generated.modelId);
|
|
614
|
-
if (this.sessionStore && this.session && !this.session.title && generated.title) {
|
|
615
|
-
this.sessionStore.setTitle(this.session.id, generated.title);
|
|
616
|
-
this.session = this.sessionStore.getRequiredSession(this.session.id);
|
|
617
|
-
}
|
|
618
|
-
return generated.title;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
async askSideQuestion(question: string, signal?: AbortSignal): Promise<SideQuestionResult> {
|
|
622
|
-
if (!this.provider) {
|
|
623
|
-
return { response: "No API key configured." };
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
const contextParts: string[] = [];
|
|
627
|
-
let charBudget = 2000;
|
|
628
|
-
for (let i = this.messages.length - 1; i >= 0 && charBudget > 0; i--) {
|
|
629
|
-
const msg = this.messages[i];
|
|
630
|
-
if (msg.role !== "user" && msg.role !== "assistant") continue;
|
|
631
|
-
const text =
|
|
632
|
-
typeof msg.content === "string"
|
|
633
|
-
? msg.content
|
|
634
|
-
: Array.isArray(msg.content)
|
|
635
|
-
? msg.content
|
|
636
|
-
.filter((p: { type: string }) => p.type === "text")
|
|
637
|
-
.map((p: { type: string; text?: string }) => p.text ?? "")
|
|
638
|
-
.join("")
|
|
639
|
-
: "";
|
|
640
|
-
if (!text) continue;
|
|
641
|
-
const snippet = text.length > 400 ? `${text.slice(0, 400)}…` : text;
|
|
642
|
-
contextParts.unshift(`[${msg.role}]: ${snippet}`);
|
|
643
|
-
charBudget -= snippet.length;
|
|
644
|
-
}
|
|
645
|
-
const conversationContext = contextParts.join("\n\n");
|
|
646
|
-
|
|
647
|
-
const result = await runSideQuestion(question, this.provider, this.modelId, conversationContext, signal);
|
|
648
|
-
this.recordUsage(result.usage, "other");
|
|
649
|
-
return result;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
abort(): void {
|
|
653
|
-
this.abortController?.abort();
|
|
654
|
-
this.emitSubagentStatus(null);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
async cleanup(): Promise<void> {
|
|
658
|
-
// Slow-path sidecar — write transcript to disk SYNCHRONOUSLY before
|
|
659
|
-
// racing the async HTTP extract. Survives X-close + EE-offline.
|
|
660
|
-
try {
|
|
661
|
-
emitTranscriptToDisk(this.messages, this.getSessionId(), "cli-exit", this.bash.getCwd());
|
|
662
|
-
} catch {
|
|
663
|
-
/* fail-open */
|
|
664
|
-
}
|
|
665
|
-
await Promise.allSettled([
|
|
666
|
-
this.bash.cleanup(),
|
|
667
|
-
shutdownWorkspaceLspManager(this.bash.getCwd()),
|
|
668
|
-
extractSession(this.messages, this.bash.getCwd(), "cli-exit", this.getSessionId()),
|
|
669
|
-
]);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
// Tool-loop cap handler — set by the UI (app.tsx) at startup. Invoked from
|
|
673
|
-
// the message-processor streamText loop when stepCount reaches the current
|
|
674
|
-
// cap. The UI surfaces an askcard ("Continue +50? / Stop and answer") and
|
|
675
|
-
// resolves with the verdict. When unset, the loop stops gracefully — no
|
|
676
|
-
// hard-throw, matches the user-friendly behaviour we promised.
|
|
677
|
-
private _toolLoopCapHandler: ToolLoopCapAsk | null = null;
|
|
678
|
-
|
|
679
|
-
setToolLoopCapHandler(fn: ToolLoopCapAsk | null): void {
|
|
680
|
-
this._toolLoopCapHandler = fn;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
respondToToolApproval(approvalId: string, approved: boolean): void {
|
|
684
|
-
const toolApprovalResponse: ModelMessage = {
|
|
685
|
-
role: "tool",
|
|
686
|
-
content: [
|
|
687
|
-
{
|
|
688
|
-
type: "tool-approval-response" as const,
|
|
689
|
-
approvalId,
|
|
690
|
-
approved,
|
|
691
|
-
},
|
|
692
|
-
],
|
|
693
|
-
};
|
|
694
|
-
this.messages.push(toolApprovalResponse);
|
|
695
|
-
this.messageSeqs.push(null);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
async clearHistory(): Promise<void> {
|
|
699
|
-
// D-09: Extract messages accumulated since last clear BEFORE reset
|
|
700
|
-
try {
|
|
701
|
-
emitTranscriptToDisk(this.messages, this.getSessionId(), "cli-clear", this.bash.getCwd());
|
|
702
|
-
} catch {
|
|
703
|
-
/* fail-open */
|
|
704
|
-
}
|
|
705
|
-
await extractSession(this.messages, this.bash.getCwd(), "cli-clear", this.getSessionId()).catch(() => {}); // D-05: redundant safety — extractSession already swallows
|
|
706
|
-
this.startNewSession();
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
startNewSession(): SessionSnapshot | null {
|
|
710
|
-
if (this.sessionStartHookFired) {
|
|
711
|
-
const endInput: SessionEndHookInput = {
|
|
712
|
-
hook_event_name: "SessionEnd",
|
|
713
|
-
session_id: this.session?.id,
|
|
714
|
-
cwd: this.bash.getCwd(),
|
|
715
|
-
};
|
|
716
|
-
this.fireHook(endInput).catch(() => {});
|
|
717
|
-
this.sessionStartHookFired = false;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
// Reset token counters, cost, and compaction state for the new session
|
|
721
|
-
statusBarStore.setState({
|
|
722
|
-
in_tokens: 0,
|
|
723
|
-
out_tokens: 0,
|
|
724
|
-
cache_read_tokens: 0,
|
|
725
|
-
cache_creation_tokens: 0,
|
|
726
|
-
session_usd: 0,
|
|
727
|
-
ctx_tokens: 0,
|
|
728
|
-
compaction_summary: undefined,
|
|
729
|
-
});
|
|
730
|
-
|
|
731
|
-
this._compactionStats = { count: 0, totalSaved: 0 };
|
|
732
|
-
this._pinnedSeqs.clear();
|
|
733
|
-
|
|
734
|
-
if (!this.sessionStore) {
|
|
735
|
-
this.messages = [];
|
|
736
|
-
this.messageSeqs = [];
|
|
737
|
-
return null;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
this.sessionStore = new SessionStore(this.bash.getCwd());
|
|
741
|
-
this.workspace = this.sessionStore.getWorkspace();
|
|
742
|
-
// Collapse double startNewSession() calls into a single row. The current
|
|
743
|
-
// session is REUSED (not orphaned with a fresh createSession) when it is
|
|
744
|
-
// brand-new and empty — no persisted messages in memory AND no title.
|
|
745
|
-
// Root cause of ~60% orphaned session rows (1187/1966): the /clear slash
|
|
746
|
-
// path calls clearHistory() — which already starts a new session — and then
|
|
747
|
-
// resetToNewSession(), which started ANOTHER. The first session never
|
|
748
|
-
// received any work and was left title-less and empty. The first call here
|
|
749
|
-
// still sees the prior conversation in `this.messages` (non-empty → new
|
|
750
|
-
// row, correct); the immediate second call sees the just-cleared empty
|
|
751
|
-
// session and reuses it instead of creating a twin.
|
|
752
|
-
const cur = this.session;
|
|
753
|
-
if (cur && this.messages.length === 0 && !cur.title) {
|
|
754
|
-
this.messageSeqs = [];
|
|
755
|
-
return this.getSessionSnapshot();
|
|
756
|
-
}
|
|
757
|
-
this.session = this.sessionStore.createSession(this.modelId, this.mode, this.bash.getCwd());
|
|
758
|
-
this.messages = [];
|
|
759
|
-
this.messageSeqs = [];
|
|
760
|
-
return this.getSessionSnapshot();
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
getSessionInfo(): SessionInfo | null {
|
|
764
|
-
return this.session;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
getSessionId(): string | null {
|
|
768
|
-
return this.session?.id || null;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
getSessionTitle(): string | null {
|
|
772
|
-
return this.session?.title || null;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
getCompactionStats(): { count: number; totalSaved: number } {
|
|
776
|
-
return { ...this._compactionStats };
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
/**
|
|
780
|
-
* Pin a user message by its sequence number. Pinned messages survive
|
|
781
|
-
* compaction verbatim — re-injected as a system note after the summary.
|
|
782
|
-
* Returns true if the message was found, is a user message, and got pinned.
|
|
783
|
-
*/
|
|
784
|
-
pinMessageBySeq(seq: number): boolean {
|
|
785
|
-
const idx = this.messageSeqs.indexOf(seq);
|
|
786
|
-
if (idx < 0) return false;
|
|
787
|
-
if (this.messages[idx]?.role !== "user") return false;
|
|
788
|
-
this._pinnedSeqs.add(seq);
|
|
789
|
-
return true;
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
/** Pin the most recent user message in the live conversation. Returns its seq, or null. */
|
|
793
|
-
pinLastUserMessage(): number | null {
|
|
794
|
-
for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
795
|
-
if (this.messages[i]?.role !== "user") continue;
|
|
796
|
-
const seq = this.messageSeqs[i];
|
|
797
|
-
if (typeof seq === "number") {
|
|
798
|
-
this._pinnedSeqs.add(seq);
|
|
799
|
-
return seq;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
return null;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
unpinMessageBySeq(seq: number): boolean {
|
|
806
|
-
return this._pinnedSeqs.delete(seq);
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
getPinnedSeqs(): number[] {
|
|
810
|
-
return [...this._pinnedSeqs].sort((a, b) => a - b);
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
getChatEntries(): ChatEntry[] {
|
|
814
|
-
if (!this.session) return [];
|
|
815
|
-
return buildChatEntries(this.session.id);
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
getSessionSnapshot(): SessionSnapshot | null {
|
|
819
|
-
if (!this.session || !this.workspace) return null;
|
|
820
|
-
return {
|
|
821
|
-
workspace: this.workspace,
|
|
822
|
-
session: this.session,
|
|
823
|
-
messages: loadTranscript(this.session.id),
|
|
824
|
-
entries: buildChatEntries(this.session.id),
|
|
825
|
-
totalTokens: getSessionTotalTokens(this.session.id),
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
onSubagentStatus(listener: (status: SubagentStatus | null) => void): () => void {
|
|
830
|
-
this.subagentStatusListeners.add(listener);
|
|
831
|
-
return () => {
|
|
832
|
-
this.subagentStatusListeners.delete(listener);
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
private emitSubagentStatus(status: SubagentStatus | null): void {
|
|
837
|
-
for (const listener of this.subagentStatusListeners) {
|
|
838
|
-
listener(status);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
private discardAbortedTurn(userMessage: ModelMessage): void {
|
|
843
|
-
const idx = this.messages.lastIndexOf(userMessage);
|
|
844
|
-
if (idx >= 0) {
|
|
845
|
-
// Keep the user message but add a stub assistant response so the
|
|
846
|
-
// conversation remains valid for follow-up messages after ESC.
|
|
847
|
-
const alreadyHasResponse = idx < this.messages.length - 1 && this.messages[idx + 1]?.role === "assistant";
|
|
848
|
-
if (!alreadyHasResponse) {
|
|
849
|
-
this.messages.splice(idx + 1, 0, { role: "assistant", content: "[Interrupted]" });
|
|
850
|
-
this.messageSeqs.splice(idx + 1, 0, null);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
private recordUsage(
|
|
856
|
-
usage?: {
|
|
857
|
-
totalTokens?: number;
|
|
858
|
-
inputTokens?: number;
|
|
859
|
-
outputTokens?: number;
|
|
860
|
-
cacheReadTokens?: number;
|
|
861
|
-
cacheCreationTokens?: number;
|
|
862
|
-
},
|
|
863
|
-
source: UsageSource = "message",
|
|
864
|
-
model = this.modelId,
|
|
865
|
-
/**
|
|
866
|
-
* Phase O1 — the providerOptions shape of the call that produced THIS event,
|
|
867
|
-
* threaded explicitly per call. Multi-step turns emit one event per step and
|
|
868
|
-
* a `task` sub-agent can run mid-turn, so a single mutable
|
|
869
|
-
* `_lastProviderOptionsShape` corrupted later events (the clear nulled it
|
|
870
|
-
* after step 1; an interleaved task overwrote it). When omitted (title /
|
|
871
|
-
* other one-shot calls that set no shape), fall back to the mutable field,
|
|
872
|
-
* which is cleared after each message event so they record null, not stale.
|
|
873
|
-
*/
|
|
874
|
-
providerOptionsShape?: string | null,
|
|
875
|
-
): void {
|
|
876
|
-
if (!usage) return;
|
|
877
|
-
if (this.session) {
|
|
878
|
-
const pilActive = source === "message" ? this._pilActive : false;
|
|
879
|
-
const enrichmentDelta = source === "message" ? this._pilEnrichmentDelta : 0;
|
|
880
|
-
// Attribute usage to the most recent persisted message — this lets
|
|
881
|
-
// per-prompt cost analysis work (was null hardcoded → impossible).
|
|
882
|
-
const lastSeq = lastPersistedSeq(this.messageSeqs);
|
|
883
|
-
// Phase O1 — providerOptions shape (types only, no values) attached
|
|
884
|
-
// to every usage event so post-mortem can answer "what provider
|
|
885
|
-
// options did this billed call carry?". Prefer the explicitly-threaded
|
|
886
|
-
// shape (correct per-event, immune to the clear + task interleaving);
|
|
887
|
-
// fall back to the mutable field only when the caller passed nothing
|
|
888
|
-
// (title / other), which is cleared below so they record null, not stale.
|
|
889
|
-
const resolvedShape = providerOptionsShape !== undefined ? providerOptionsShape : this._lastProviderOptionsShape;
|
|
890
|
-
recordUsageEvent(this.session.id, source, model, usage, lastSeq, pilActive, enrichmentDelta, resolvedShape);
|
|
891
|
-
if (source === "message") {
|
|
892
|
-
this._pilActive = false;
|
|
893
|
-
this._pilEnrichmentDelta = 0;
|
|
894
|
-
this._lastProviderOptionsShape = null;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
// Phase D — surfaced for harness E2E verification. Mirror the recorded usage
|
|
898
|
-
// event onto the agent-mode sidechannel so spec processes can assert on
|
|
899
|
-
// cacheReadTokens / cacheCreationTokens normalization without poking at the
|
|
900
|
-
// child's sqlite. Best-effort, only fires when agent-mode runtime is set.
|
|
901
|
-
try {
|
|
902
|
-
const rt = (globalThis as Record<string, unknown>).__muonroiAgentRuntime as
|
|
903
|
-
| { emitEvent?: (e: unknown) => void }
|
|
904
|
-
| undefined;
|
|
905
|
-
if (rt?.emitEvent) {
|
|
906
|
-
const lastSeqForEvent = this.session ? lastPersistedSeq(this.messageSeqs) : null;
|
|
907
|
-
rt.emitEvent({
|
|
908
|
-
t: "event",
|
|
909
|
-
kind: "usage",
|
|
910
|
-
source,
|
|
911
|
-
model,
|
|
912
|
-
inputTokens: usage.inputTokens,
|
|
913
|
-
outputTokens: usage.outputTokens,
|
|
914
|
-
cacheReadTokens: usage.cacheReadTokens,
|
|
915
|
-
cacheCreationTokens: usage.cacheCreationTokens,
|
|
916
|
-
messageSeq: lastSeqForEvent,
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
|
-
} catch {
|
|
920
|
-
// best-effort: do not let sidechannel failures interrupt usage recording
|
|
921
|
-
}
|
|
922
|
-
// Update status bar token counters + provider/model + cache metrics + cost
|
|
923
|
-
const prev = statusBarStore.getState();
|
|
924
|
-
const info = getModelInfo(model);
|
|
925
|
-
const totalInput = usage.inputTokens ?? 0;
|
|
926
|
-
const cacheRead = usage.cacheReadTokens ?? 0;
|
|
927
|
-
const cacheCreate = usage.cacheCreationTokens ?? 0;
|
|
928
|
-
const output = usage.outputTokens ?? 0;
|
|
929
|
-
const priceIn = info?.inputPrice ?? 0;
|
|
930
|
-
const priceCached = info?.cachedInputPrice ?? priceIn * 0.1;
|
|
931
|
-
const priceOut = info?.outputPrice ?? 0;
|
|
932
|
-
// API inputTokens includes cacheRead — subtract to get non-cached portion
|
|
933
|
-
const nonCachedInput = Math.max(0, totalInput - cacheRead - cacheCreate);
|
|
934
|
-
const turnCostMicros =
|
|
935
|
-
nonCachedInput * priceIn + cacheRead * priceCached + cacheCreate * priceIn + output * priceOut;
|
|
936
|
-
// F5 — ctx_tokens reflects the CURRENT call's input size (≈ context
|
|
937
|
-
// window usage), not cumulative. Lets the user see "how full is my
|
|
938
|
-
// window" instead of "how much have I billed in total this session".
|
|
939
|
-
// Pair with context-fill % derived from model contextWindow.
|
|
940
|
-
const ctxWindow = info?.contextWindow ?? 0;
|
|
941
|
-
const ctxPct = ctxWindow > 0 ? Math.min(100, Math.round((totalInput / ctxWindow) * 100)) : undefined;
|
|
942
|
-
statusBarStore.setState({
|
|
943
|
-
in_tokens: prev.in_tokens + totalInput,
|
|
944
|
-
out_tokens: prev.out_tokens + output,
|
|
945
|
-
cache_read_tokens: (prev.cache_read_tokens ?? 0) + cacheRead,
|
|
946
|
-
cache_creation_tokens: (prev.cache_creation_tokens ?? 0) + cacheCreate,
|
|
947
|
-
session_usd: prev.session_usd + turnCostMicros / 1_000_000,
|
|
948
|
-
provider: this.providerId,
|
|
949
|
-
model,
|
|
950
|
-
ctx_tokens: totalInput,
|
|
951
|
-
ctx_pct: ctxPct,
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
// Append to cost-log JSONL so `usage report --by callsite` can surface
|
|
955
|
-
// where orchestrator/task/title traffic is actually spending.
|
|
956
|
-
// Best-effort: failures inside appendCostLog are swallowed (see cost-log.ts).
|
|
957
|
-
const breakdown = source === "message" ? (this._lastPromptBreakdown ?? undefined) : undefined;
|
|
958
|
-
appendCostLog({
|
|
959
|
-
ts: Date.now(),
|
|
960
|
-
provider: this.providerId,
|
|
961
|
-
model,
|
|
962
|
-
estimatedUsd: turnCostMicros / 1_000_000,
|
|
963
|
-
callsite: `orchestrator.${source}`,
|
|
964
|
-
phase: source,
|
|
965
|
-
actualInputTokens: totalInput,
|
|
966
|
-
actualOutputTokens: output,
|
|
967
|
-
cachedInputTokens: cacheRead,
|
|
968
|
-
systemChars: breakdown?.systemChars,
|
|
969
|
-
promptChars: breakdown?.messagesChars,
|
|
970
|
-
breakdown,
|
|
971
|
-
}).catch(() => undefined);
|
|
972
|
-
// Don't clear breakdown — onStepFinish fires recordUsage per step within
|
|
973
|
-
// the same streamText call, and they all share the same prompt structure.
|
|
974
|
-
// It is overwritten on the next streamText setup, which is the right scope.
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
async consumeBackgroundNotifications(): Promise<string[]> {
|
|
978
|
-
try {
|
|
979
|
-
const notifications = await this.delegations.consumeNotifications();
|
|
980
|
-
for (const notification of notifications) {
|
|
981
|
-
this.messages.push({ role: "system", content: notification.message });
|
|
982
|
-
let seq: number | null = null;
|
|
983
|
-
if (this.session) {
|
|
984
|
-
seq = appendSystemMessage(this.session.id, notification.message);
|
|
985
|
-
}
|
|
986
|
-
this.messageSeqs.push(seq);
|
|
987
|
-
|
|
988
|
-
const notifInput: NotificationHookInput = {
|
|
989
|
-
hook_event_name: "Notification",
|
|
990
|
-
message: notification.message,
|
|
991
|
-
session_id: this.session?.id,
|
|
992
|
-
cwd: this.bash.getCwd(),
|
|
993
|
-
};
|
|
994
|
-
this.fireHook(notifInput).catch(() => {});
|
|
995
|
-
}
|
|
996
|
-
return notifications.map((notification) => notification.message);
|
|
997
|
-
} catch {
|
|
998
|
-
return [];
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
private getBatchClientOptions(signal?: AbortSignal): BatchClientOptions {
|
|
1003
|
-
if (!this.apiKey) {
|
|
1004
|
-
throw new Error("API key required. Add an API key to continue.");
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
return {
|
|
1008
|
-
apiKey: this.apiKey,
|
|
1009
|
-
baseURL: this.baseURL ?? undefined,
|
|
1010
|
-
signal,
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
private async executeBatchToolCall(
|
|
1015
|
-
tools: ToolSet,
|
|
1016
|
-
toolCall: ToolCall,
|
|
1017
|
-
messages: ModelMessage[],
|
|
1018
|
-
signal?: AbortSignal,
|
|
1019
|
-
): Promise<{ input: unknown; result: ToolResult }> {
|
|
1020
|
-
const tool = tools[toolCall.function.name];
|
|
1021
|
-
if (!tool || tool.type === "provider" || typeof tool.execute !== "function") {
|
|
1022
|
-
return {
|
|
1023
|
-
input: parseToolArgumentsOrRaw(toolCall.function.arguments),
|
|
1024
|
-
result: {
|
|
1025
|
-
success: false,
|
|
1026
|
-
output: `Tool "${toolCall.function.name}" is unavailable in batch mode.`,
|
|
1027
|
-
},
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
let parsedInput: unknown;
|
|
1032
|
-
try {
|
|
1033
|
-
parsedInput = toolCall.function.arguments.trim() ? JSON.parse(toolCall.function.arguments) : {};
|
|
1034
|
-
} catch (error) {
|
|
1035
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1036
|
-
return {
|
|
1037
|
-
input: toolCall.function.arguments,
|
|
1038
|
-
result: {
|
|
1039
|
-
success: false,
|
|
1040
|
-
output: `Tool "${toolCall.function.name}" received invalid JSON arguments: ${message}`,
|
|
1041
|
-
},
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
try {
|
|
1046
|
-
const output = await tool.execute(parsedInput as never, {
|
|
1047
|
-
toolCallId: toolCall.id,
|
|
1048
|
-
messages,
|
|
1049
|
-
abortSignal: signal,
|
|
1050
|
-
});
|
|
1051
|
-
return {
|
|
1052
|
-
input: parsedInput,
|
|
1053
|
-
result: toToolResult(output),
|
|
1054
|
-
};
|
|
1055
|
-
} catch (error) {
|
|
1056
|
-
if (signal?.aborted) {
|
|
1057
|
-
throw error;
|
|
1058
|
-
}
|
|
1059
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1060
|
-
return {
|
|
1061
|
-
input: parsedInput,
|
|
1062
|
-
result: {
|
|
1063
|
-
success: false,
|
|
1064
|
-
output: `Tool "${toolCall.function.name}" failed: ${message}`,
|
|
1065
|
-
},
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
private async runTaskRequestBatch(args: {
|
|
1071
|
-
request: TaskRequest;
|
|
1072
|
-
childMessages: ModelMessage[];
|
|
1073
|
-
childSystem: string;
|
|
1074
|
-
childRuntime: ReturnType<typeof resolveModelRuntime>;
|
|
1075
|
-
childTools: ToolSet;
|
|
1076
|
-
maxSteps: number;
|
|
1077
|
-
initialDetail: string;
|
|
1078
|
-
onActivity?: (detail: string) => void;
|
|
1079
|
-
signal?: AbortSignal;
|
|
1080
|
-
}): Promise<ToolResult> {
|
|
1081
|
-
const {
|
|
1082
|
-
request,
|
|
1083
|
-
childMessages,
|
|
1084
|
-
childSystem,
|
|
1085
|
-
childRuntime,
|
|
1086
|
-
childTools,
|
|
1087
|
-
maxSteps,
|
|
1088
|
-
initialDetail,
|
|
1089
|
-
onActivity,
|
|
1090
|
-
signal,
|
|
1091
|
-
} = args;
|
|
1092
|
-
|
|
1093
|
-
const childCaps = getProviderCapabilities(requireRuntimeProvider(childRuntime));
|
|
1094
|
-
if (childCaps.usesResponsesAPI(childRuntime.modelInfo)) {
|
|
1095
|
-
throw new Error("Batch mode currently supports chat-completions models only.");
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
const batchTools = !childCaps.supportsClientTools(childRuntime.modelInfo)
|
|
1099
|
-
? []
|
|
1100
|
-
: await toolSetToBatchTools(childTools);
|
|
1101
|
-
const batch = await createBatch({
|
|
1102
|
-
...this.getBatchClientOptions(signal),
|
|
1103
|
-
name: buildBatchName(`task-${request.agent}`, request.description),
|
|
1104
|
-
});
|
|
1105
|
-
|
|
1106
|
-
const turnMessages: ModelMessage[] = [];
|
|
1107
|
-
const totalUsage: ProcessMessageUsage = {};
|
|
1108
|
-
let assistantText = "";
|
|
1109
|
-
let lastActivity = initialDetail;
|
|
1110
|
-
|
|
1111
|
-
for (let round = 0; round < maxSteps; round++) {
|
|
1112
|
-
const batchRequestId = `task-${Date.now()}-${round + 1}`;
|
|
1113
|
-
await addBatchRequests({
|
|
1114
|
-
...this.getBatchClientOptions(signal),
|
|
1115
|
-
batchId: batch.batch_id,
|
|
1116
|
-
batchRequests: [
|
|
1117
|
-
{
|
|
1118
|
-
batch_request_id: batchRequestId,
|
|
1119
|
-
batch_request: {
|
|
1120
|
-
chat_get_completion: buildBatchChatCompletionRequest({
|
|
1121
|
-
modelId: childRuntime.modelId,
|
|
1122
|
-
system: childSystem,
|
|
1123
|
-
messages: [...childMessages, ...turnMessages],
|
|
1124
|
-
temperature: request.agent === "explore" ? 0.2 : 0.5,
|
|
1125
|
-
maxOutputTokens: !childCaps.acceptsParam("maxOutputTokens", childRuntime.modelInfo)
|
|
1126
|
-
? undefined
|
|
1127
|
-
: Math.min(this.maxTokens, 8_192),
|
|
1128
|
-
reasoningEffort: childRuntime.providerOptions?.xai.reasoningEffort,
|
|
1129
|
-
tools: batchTools,
|
|
1130
|
-
}),
|
|
1131
|
-
},
|
|
1132
|
-
},
|
|
1133
|
-
],
|
|
1134
|
-
});
|
|
1135
|
-
|
|
1136
|
-
const result = await pollBatchRequestResult({
|
|
1137
|
-
...this.getBatchClientOptions(signal),
|
|
1138
|
-
batchId: batch.batch_id,
|
|
1139
|
-
batchRequestId,
|
|
1140
|
-
});
|
|
1141
|
-
const response = getBatchChatCompletion(result);
|
|
1142
|
-
accumulateUsage(totalUsage, getBatchUsage(response));
|
|
1143
|
-
|
|
1144
|
-
const choice = response.choices[0];
|
|
1145
|
-
if (!choice) {
|
|
1146
|
-
throw new Error("Batch response did not contain any choices.");
|
|
1147
|
-
}
|
|
1148
|
-
const content = choice?.message.content ?? "";
|
|
1149
|
-
if (content) {
|
|
1150
|
-
assistantText += content;
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
const requestMessages = [...childMessages, ...turnMessages];
|
|
1154
|
-
const toolCalls = (choice?.message.tool_calls ?? []).map(toLocalToolCall);
|
|
1155
|
-
const assistantMessage = buildAssistantBatchMessage(content, toolCalls);
|
|
1156
|
-
if (assistantMessage) {
|
|
1157
|
-
turnMessages.push(assistantMessage);
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
if (toolCalls.length === 0) {
|
|
1161
|
-
if (hasUsage(totalUsage)) {
|
|
1162
|
-
this.recordUsage(totalUsage, "task", childRuntime.modelId);
|
|
1163
|
-
}
|
|
1164
|
-
const output = assistantText.trim() || `Task completed. Last action: ${lastActivity}`;
|
|
1165
|
-
return {
|
|
1166
|
-
success: true,
|
|
1167
|
-
output,
|
|
1168
|
-
task: {
|
|
1169
|
-
agent: request.agent,
|
|
1170
|
-
description: request.description,
|
|
1171
|
-
summary: firstLine(output),
|
|
1172
|
-
activity: lastActivity,
|
|
1173
|
-
},
|
|
1174
|
-
};
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
const toolParts: ExecutedBatchTool[] = [];
|
|
1178
|
-
for (const toolCall of toolCalls) {
|
|
1179
|
-
const nextActivity = formatSubagentActivity(
|
|
1180
|
-
toolCall.function.name,
|
|
1181
|
-
parseToolArgumentsOrRaw(toolCall.function.arguments),
|
|
1182
|
-
);
|
|
1183
|
-
lastActivity = nextActivity;
|
|
1184
|
-
onActivity?.(nextActivity);
|
|
1185
|
-
|
|
1186
|
-
const executed = await this.executeBatchToolCall(childTools, toolCall, requestMessages, signal);
|
|
1187
|
-
toolParts.push({
|
|
1188
|
-
toolCall,
|
|
1189
|
-
input: executed.input,
|
|
1190
|
-
toolResult: executed.result,
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
const toolMessage = buildToolBatchMessage(toolParts);
|
|
1195
|
-
if (toolMessage) {
|
|
1196
|
-
turnMessages.push(toolMessage);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
if (hasUsage(totalUsage)) {
|
|
1201
|
-
this.recordUsage(totalUsage, "task", childRuntime.modelId);
|
|
1202
|
-
}
|
|
1203
|
-
const output = assistantText.trim() || `Task stopped after ${maxSteps} batch rounds. Last action: ${lastActivity}`;
|
|
1204
|
-
return {
|
|
1205
|
-
success: false,
|
|
1206
|
-
output,
|
|
1207
|
-
task: {
|
|
1208
|
-
agent: request.agent,
|
|
1209
|
-
description: request.description,
|
|
1210
|
-
summary: output,
|
|
1211
|
-
activity: lastActivity,
|
|
1212
|
-
},
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
/**
|
|
1217
|
-
* Run a sub-agent task by spawning a child `streamText` session.
|
|
1218
|
-
*
|
|
1219
|
-
* Phase 12.3 — body extracted to `StreamRunner` (`./stream-runner.ts`).
|
|
1220
|
-
* This method now builds the DI dep set and delegates to
|
|
1221
|
-
* `StreamRunner.run()`. Public signature is unchanged so all callers
|
|
1222
|
-
* (`runTask`, `tools/registry`, batch path, council path) work as before.
|
|
1223
|
-
*/
|
|
1224
|
-
async runTaskRequest(
|
|
1225
|
-
request: TaskRequest,
|
|
1226
|
-
onActivity?: (detail: string) => void,
|
|
1227
|
-
abortSignal?: AbortSignal,
|
|
1228
|
-
): Promise<ToolResult> {
|
|
1229
|
-
const provider = this.requireProvider();
|
|
1230
|
-
const deps: StreamRunnerDeps = {
|
|
1231
|
-
getProvider: () => provider,
|
|
1232
|
-
resolveModelForTask: (task) => this._resolveModelForTask(task),
|
|
1233
|
-
getModelId: () => this.modelId,
|
|
1234
|
-
getProviderId: () => this.providerId,
|
|
1235
|
-
getBash: () => this.bash,
|
|
1236
|
-
getMaxToolRounds: () => this.maxToolRounds,
|
|
1237
|
-
getMaxTokens: () => this.maxTokens,
|
|
1238
|
-
isBatchApiEnabled: () => this.batchApi,
|
|
1239
|
-
getCrossTurnDedup: () => this._crossTurnDedup,
|
|
1240
|
-
getReadBudget: () => this._readBudget,
|
|
1241
|
-
recordUsage: (usage, source, model, shape) => this.recordUsage(usage, source, model, shape),
|
|
1242
|
-
setCurrentCallId: (id) => {
|
|
1243
|
-
this._currentCallId = id;
|
|
1244
|
-
},
|
|
1245
|
-
setLastProviderOptionsShape: (shape) => {
|
|
1246
|
-
this._lastProviderOptionsShape = shape;
|
|
1247
|
-
},
|
|
1248
|
-
getSessionId: () => this.session?.id,
|
|
1249
|
-
runTaskRequestBatch: (args) => this.runTaskRequestBatch(args),
|
|
1250
|
-
};
|
|
1251
|
-
const runner = new StreamRunner(deps);
|
|
1252
|
-
return runner.run(request, onActivity, abortSignal);
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
private async runTask(request: TaskRequest, abortSignal?: AbortSignal): Promise<ToolResult> {
|
|
1256
|
-
const startInput: SubagentStartHookInput = {
|
|
1257
|
-
hook_event_name: "SubagentStart",
|
|
1258
|
-
agent_type: request.agent,
|
|
1259
|
-
description: request.description,
|
|
1260
|
-
session_id: this.session?.id,
|
|
1261
|
-
cwd: this.bash.getCwd(),
|
|
1262
|
-
};
|
|
1263
|
-
await this.fireHook(startInput, abortSignal).catch(() => {});
|
|
1264
|
-
|
|
1265
|
-
let result: ToolResult;
|
|
1266
|
-
try {
|
|
1267
|
-
result = await withStreamRetry(
|
|
1268
|
-
() =>
|
|
1269
|
-
this.runTaskRequest(
|
|
1270
|
-
request,
|
|
1271
|
-
(detail) => {
|
|
1272
|
-
if (abortSignal?.aborted) return;
|
|
1273
|
-
this.emitSubagentStatus({
|
|
1274
|
-
agent: request.agent,
|
|
1275
|
-
description: request.description,
|
|
1276
|
-
detail,
|
|
1277
|
-
});
|
|
1278
|
-
},
|
|
1279
|
-
abortSignal,
|
|
1280
|
-
),
|
|
1281
|
-
{
|
|
1282
|
-
signal: abortSignal,
|
|
1283
|
-
onRetry: (info) => {
|
|
1284
|
-
// Emit harness telemetry
|
|
1285
|
-
try {
|
|
1286
|
-
const _ar = (globalThis as Record<string, unknown>).__muonroiAgentRuntime as
|
|
1287
|
-
| { emitEvent: (e: unknown) => void }
|
|
1288
|
-
| undefined;
|
|
1289
|
-
_ar?.emitEvent({
|
|
1290
|
-
t: "event",
|
|
1291
|
-
kind: "stream-retry",
|
|
1292
|
-
...info,
|
|
1293
|
-
});
|
|
1294
|
-
} catch {
|
|
1295
|
-
/* best-effort */
|
|
1296
|
-
}
|
|
1297
|
-
try {
|
|
1298
|
-
if (this.session) {
|
|
1299
|
-
logInteraction(this.session.id, "stream_retry", {
|
|
1300
|
-
data: {
|
|
1301
|
-
attempt: info.attempt,
|
|
1302
|
-
maxAttempts: info.maxAttempts,
|
|
1303
|
-
errorName: info.errorName,
|
|
1304
|
-
errorMessage: info.errorMessage.slice(0, 200),
|
|
1305
|
-
nextDelayMs: info.nextDelayMs,
|
|
1306
|
-
},
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
} catch {
|
|
1310
|
-
/* fail-open */
|
|
1311
|
-
}
|
|
1312
|
-
},
|
|
1313
|
-
},
|
|
1314
|
-
);
|
|
1315
|
-
} finally {
|
|
1316
|
-
this.emitSubagentStatus(null);
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
const stopInput: SubagentStopHookInput = {
|
|
1320
|
-
hook_event_name: "SubagentStop",
|
|
1321
|
-
agent_type: request.agent,
|
|
1322
|
-
description: request.description,
|
|
1323
|
-
success: result.success,
|
|
1324
|
-
session_id: this.session?.id,
|
|
1325
|
-
cwd: this.bash.getCwd(),
|
|
1326
|
-
};
|
|
1327
|
-
await this.fireHook(stopInput, abortSignal).catch(() => {});
|
|
1328
|
-
|
|
1329
|
-
return result;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
private async runDelegation(request: TaskRequest, abortSignal?: AbortSignal): Promise<ToolResult> {
|
|
1333
|
-
const taskCreatedInput: TaskCreatedHookInput = {
|
|
1334
|
-
hook_event_name: "TaskCreated",
|
|
1335
|
-
agent_type: request.agent,
|
|
1336
|
-
description: request.description,
|
|
1337
|
-
session_id: this.session?.id,
|
|
1338
|
-
cwd: this.bash.getCwd(),
|
|
1339
|
-
};
|
|
1340
|
-
await this.fireHook(taskCreatedInput, abortSignal).catch(() => {});
|
|
1341
|
-
|
|
1342
|
-
let result: ToolResult;
|
|
1343
|
-
try {
|
|
1344
|
-
if (abortSignal?.aborted) {
|
|
1345
|
-
return { success: false, output: "[Cancelled]" };
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
result = await this.delegations.start(request, {
|
|
1349
|
-
model: this.modelId,
|
|
1350
|
-
sandboxMode: this.bash.getSandboxMode(),
|
|
1351
|
-
sandboxSettings: this.bash.getSandboxSettings(),
|
|
1352
|
-
maxToolRounds: this.maxToolRounds,
|
|
1353
|
-
maxTokens: this.maxTokens,
|
|
1354
|
-
batchApi: this.batchApi,
|
|
1355
|
-
});
|
|
1356
|
-
} catch (err: unknown) {
|
|
1357
|
-
if (abortSignal?.aborted) throw err;
|
|
1358
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1359
|
-
result = {
|
|
1360
|
-
success: false,
|
|
1361
|
-
output: `Delegation failed: ${msg}`,
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
const taskCompletedInput: TaskCompletedHookInput = {
|
|
1366
|
-
hook_event_name: "TaskCompleted",
|
|
1367
|
-
agent_type: request.agent,
|
|
1368
|
-
description: request.description,
|
|
1369
|
-
success: result.success,
|
|
1370
|
-
session_id: this.session?.id,
|
|
1371
|
-
cwd: this.bash.getCwd(),
|
|
1372
|
-
};
|
|
1373
|
-
await this.fireHook(taskCompletedInput, abortSignal).catch(() => {});
|
|
1374
|
-
|
|
1375
|
-
return result;
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
private async readDelegation(id: string): Promise<ToolResult> {
|
|
1379
|
-
try {
|
|
1380
|
-
return {
|
|
1381
|
-
success: true,
|
|
1382
|
-
output: await this.delegations.read(id),
|
|
1383
|
-
};
|
|
1384
|
-
} catch (err: unknown) {
|
|
1385
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1386
|
-
return {
|
|
1387
|
-
success: false,
|
|
1388
|
-
output: `Failed to read delegation: ${msg}`,
|
|
1389
|
-
};
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
private async listDelegations(): Promise<ToolResult> {
|
|
1394
|
-
try {
|
|
1395
|
-
const delegations = await this.delegations.list();
|
|
1396
|
-
if (delegations.length === 0) {
|
|
1397
|
-
return {
|
|
1398
|
-
success: true,
|
|
1399
|
-
output: "No delegations found for this project.",
|
|
1400
|
-
};
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
const lines = delegations.map((delegation) => {
|
|
1404
|
-
const title = delegation.description || delegation.id;
|
|
1405
|
-
return `- \`${delegation.id}\` [${delegation.status}] ${title}\n ${delegation.summary}`;
|
|
1406
|
-
});
|
|
1407
|
-
|
|
1408
|
-
return {
|
|
1409
|
-
success: true,
|
|
1410
|
-
output: `## Delegations\n\n${lines.join("\n")}`,
|
|
1411
|
-
};
|
|
1412
|
-
} catch (err: unknown) {
|
|
1413
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1414
|
-
return {
|
|
1415
|
-
success: false,
|
|
1416
|
-
output: `Failed to list delegations: ${msg}`,
|
|
1417
|
-
};
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
private getCompactionSettings(contextWindow?: number): CompactionSettings {
|
|
1422
|
-
let keepRecentTokens = DEFAULT_KEEP_RECENT_TOKENS;
|
|
1423
|
-
|
|
1424
|
-
// For models with very large context windows, keep more recent tokens
|
|
1425
|
-
if (contextWindow && contextWindow > 200_000) {
|
|
1426
|
-
keepRecentTokens = Math.min(100_000, Math.max(20_000, Math.floor(contextWindow * 0.1)));
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
// Compact more aggressively for long sessions to prevent runaway token growth
|
|
1430
|
-
if (this._compactionStats.count >= 2) {
|
|
1431
|
-
keepRecentTokens = Math.floor(keepRecentTokens * 0.75);
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
return {
|
|
1435
|
-
reserveTokens: Math.max(this.maxTokens, DEFAULT_RESERVE_TOKENS),
|
|
1436
|
-
keepRecentTokens,
|
|
1437
|
-
};
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
private _resolveCompactModel(): string {
|
|
1441
|
-
return this._resolveModelForTask("compact");
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
private _resolveModelForTask(task: ModelTaskKind): string {
|
|
1445
|
-
return resolveModelForTask(task, this.providerId, this.modelId);
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
private async compactForContext(
|
|
1449
|
-
provider: LegacyProvider,
|
|
1450
|
-
system: string,
|
|
1451
|
-
contextWindow: number,
|
|
1452
|
-
signal: AbortSignal,
|
|
1453
|
-
settings = this.getCompactionSettings(contextWindow),
|
|
1454
|
-
force = false,
|
|
1455
|
-
): Promise<boolean> {
|
|
1456
|
-
if (!this.session) return false;
|
|
1457
|
-
|
|
1458
|
-
const preparation = prepareCompaction(this.messages, system, settings);
|
|
1459
|
-
if (!preparation) return false;
|
|
1460
|
-
if (!force && !shouldCompactContext(preparation.tokensBefore, contextWindow, settings)) {
|
|
1461
|
-
return false;
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
const trigger = force ? "manual" : "auto";
|
|
1465
|
-
|
|
1466
|
-
// Fire-and-forget: notify EE of stale suggestions before compaction
|
|
1467
|
-
const { surfacedIds, timestamp } = getLastSurfacedState();
|
|
1468
|
-
if (surfacedIds.length > 0) {
|
|
1469
|
-
getDefaultEEClient()
|
|
1470
|
-
.promptStale({
|
|
1471
|
-
state: { surfacedIds, timestamp },
|
|
1472
|
-
nextPromptMeta: { trigger: "auto-compact", cwd: this.bash.getCwd(), tenantId: getTenantId() },
|
|
1473
|
-
})
|
|
1474
|
-
.catch(() => {});
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
// Emit pre-compact transcript snapshot so lessons survive the rewrite.
|
|
1478
|
-
try {
|
|
1479
|
-
emitTranscriptToDisk(this.messages, this.session?.id ?? null, "cli-compact", this.bash.getCwd());
|
|
1480
|
-
} catch {
|
|
1481
|
-
/* fail-open */
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
const preCompactInput: PreCompactHookInput = {
|
|
1485
|
-
hook_event_name: "PreCompact",
|
|
1486
|
-
trigger,
|
|
1487
|
-
session_id: this.session?.id,
|
|
1488
|
-
cwd: this.bash.getCwd(),
|
|
1489
|
-
};
|
|
1490
|
-
await this.fireHook(preCompactInput, signal).catch(() => {});
|
|
1491
|
-
|
|
1492
|
-
const keptSeqs = this.messageSeqs.slice(preparation.firstKeptIndex);
|
|
1493
|
-
const firstKeptSeq = keptSeqs.find((seq): seq is number => seq !== null) ?? getNextMessageSequence(this.session.id);
|
|
1494
|
-
const compactModelId = this._resolveCompactModel();
|
|
1495
|
-
const compactStartedAt = Date.now();
|
|
1496
|
-
const { summary, usage: compactUsage } = await generateCompactionSummary(
|
|
1497
|
-
provider,
|
|
1498
|
-
compactModelId,
|
|
1499
|
-
preparation,
|
|
1500
|
-
undefined,
|
|
1501
|
-
signal,
|
|
1502
|
-
);
|
|
1503
|
-
|
|
1504
|
-
// Record compaction call in cost-log — bypasses recordUsage because
|
|
1505
|
-
// compaction returns usage separately and isn't routed through the
|
|
1506
|
-
// status-bar / usage event pipeline (intentional: it's overhead, not user spend).
|
|
1507
|
-
const compactProvider = detectProviderForModel(compactModelId);
|
|
1508
|
-
appendCostLog({
|
|
1509
|
-
ts: compactStartedAt,
|
|
1510
|
-
provider: compactProvider,
|
|
1511
|
-
model: compactModelId,
|
|
1512
|
-
estimatedUsd: projectCostUSD(
|
|
1513
|
-
compactProvider,
|
|
1514
|
-
compactModelId,
|
|
1515
|
-
compactUsage.promptTokens,
|
|
1516
|
-
compactUsage.completionTokens,
|
|
1517
|
-
),
|
|
1518
|
-
callsite: "orchestrator.compaction",
|
|
1519
|
-
phase: "compaction",
|
|
1520
|
-
iteration: this._compactionStats.count + 1,
|
|
1521
|
-
actualInputTokens: compactUsage.promptTokens,
|
|
1522
|
-
actualOutputTokens: compactUsage.completionTokens,
|
|
1523
|
-
durationMs: Date.now() - compactStartedAt,
|
|
1524
|
-
}).catch(() => undefined);
|
|
1525
|
-
|
|
1526
|
-
appendCompaction(this.session.id, firstKeptSeq, summary, preparation.tokensBefore);
|
|
1527
|
-
|
|
1528
|
-
// Re-inject pinned user messages that were about to be summarized away.
|
|
1529
|
-
// Pinned seqs that are still inside keptMessages don't need re-injection.
|
|
1530
|
-
const keptSeqSet = new Set(keptSeqs.filter((s): s is number => s !== null));
|
|
1531
|
-
const pinnedReinjections: ModelMessage[] = [];
|
|
1532
|
-
const pinnedReinjectionSeqs: Array<number | null> = [];
|
|
1533
|
-
for (const seq of [...this._pinnedSeqs].sort((a, b) => a - b)) {
|
|
1534
|
-
if (keptSeqSet.has(seq)) continue;
|
|
1535
|
-
const idx = this.messageSeqs.indexOf(seq);
|
|
1536
|
-
if (idx < 0) {
|
|
1537
|
-
// Pinned seq no longer present (shouldn't happen, but stay defensive).
|
|
1538
|
-
this._pinnedSeqs.delete(seq);
|
|
1539
|
-
continue;
|
|
1540
|
-
}
|
|
1541
|
-
const original = this.messages[idx];
|
|
1542
|
-
if (!original || original.role !== "user") continue;
|
|
1543
|
-
const text = extractUserContent(original.content).trim();
|
|
1544
|
-
if (!text) continue;
|
|
1545
|
-
pinnedReinjections.push({
|
|
1546
|
-
role: "system",
|
|
1547
|
-
content: `[Pinned user message — kept verbatim across compaction]\n${text}`,
|
|
1548
|
-
});
|
|
1549
|
-
pinnedReinjectionSeqs.push(null);
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
this.messages = [createCompactionSummaryMessage(summary), ...pinnedReinjections, ...preparation.keptMessages];
|
|
1553
|
-
this.messageSeqs = [null, ...pinnedReinjectionSeqs, ...keptSeqs];
|
|
1554
|
-
|
|
1555
|
-
// EE anti-mù (Phase 1 of docs/ee-anti-mu-compaction-plan.md): immediately extract the fresh structured checkpoint summary
|
|
1556
|
-
// so pilContext / layer3 search / ee.query can recall exact prior ✔ DONE items + progress for the rest of this long session
|
|
1557
|
-
// (and sub-agents) even after further B3/B4 rewrites. Uses same client + fail-open pattern as promptStale above (1449).
|
|
1558
|
-
// Transcript is the summary itself (not full history) to keep it small and focused on task state.
|
|
1559
|
-
getDefaultEEClient()
|
|
1560
|
-
.extract(
|
|
1561
|
-
{
|
|
1562
|
-
transcript: `[Context checkpoint summary]\n${summary}`,
|
|
1563
|
-
projectPath: this.bash.getCwd(),
|
|
1564
|
-
meta: {
|
|
1565
|
-
source: "cli-compact-checkpoint",
|
|
1566
|
-
sessionId: this.session?.id ?? undefined,
|
|
1567
|
-
iteration: this._compactionStats.count + 1,
|
|
1568
|
-
tokensBefore: preparation.tokensBefore,
|
|
1569
|
-
},
|
|
1570
|
-
},
|
|
1571
|
-
AbortSignal.timeout(1500),
|
|
1572
|
-
)
|
|
1573
|
-
.catch(() => {});
|
|
1574
|
-
|
|
1575
|
-
// Mark as surfaced for prompt-stale reconciliation (per plan Phase 1).
|
|
1576
|
-
updateLastSurfacedState([`compact-checkpoint-${this._compactionStats.count + 1}`]);
|
|
1577
|
-
|
|
1578
|
-
// Track compaction stats — net of the tokens spent ON compaction itself.
|
|
1579
|
-
const tokensAfter = estimateConversationTokens(system, this.messages);
|
|
1580
|
-
const grossSaved = Math.max(0, preparation.tokensBefore - tokensAfter);
|
|
1581
|
-
const compactCost = compactUsage.promptTokens + compactUsage.completionTokens;
|
|
1582
|
-
const saved = Math.max(0, grossSaved - compactCost);
|
|
1583
|
-
const pct = preparation.tokensBefore > 0 ? ((saved / preparation.tokensBefore) * 100).toFixed(1) : "0.0";
|
|
1584
|
-
this._compactionStats.count++;
|
|
1585
|
-
this._compactionStats.totalSaved += saved;
|
|
1586
|
-
|
|
1587
|
-
// Update status bar with current context size and compaction summary
|
|
1588
|
-
const fmtCompact = (n: number) => (n >= 1000 ? `${(n / 1000).toFixed(1)}K` : String(n));
|
|
1589
|
-
const modelSuffix = compactModelId !== this.modelId ? ` via ${compactModelId}` : "";
|
|
1590
|
-
const userMsgCount = this.messages.filter((m) => m.role === "user").length;
|
|
1591
|
-
const isLongSession = this._compactionStats.count >= 3 || userMsgCount >= 200;
|
|
1592
|
-
const sessionHint = isLongSession ? " ⚠ long session — consider /clear" : "";
|
|
1593
|
-
const compactLabel = `${this._compactionStats.count} cmp, ${fmtCompact(this._compactionStats.totalSaved)} saved${modelSuffix}${sessionHint}`;
|
|
1594
|
-
statusBarStore.setState({ ctx_tokens: tokensAfter, compaction_summary: compactLabel });
|
|
1595
|
-
|
|
1596
|
-
const postCompactInput: PostCompactHookInput = {
|
|
1597
|
-
hook_event_name: "PostCompact",
|
|
1598
|
-
trigger,
|
|
1599
|
-
session_id: this.session?.id,
|
|
1600
|
-
cwd: this.bash.getCwd(),
|
|
1601
|
-
};
|
|
1602
|
-
await this.fireHook(postCompactInput, signal).catch(() => {});
|
|
1603
|
-
|
|
1604
|
-
// Interaction log: compaction
|
|
1605
|
-
try {
|
|
1606
|
-
if (this.session) {
|
|
1607
|
-
logInteraction(this.session.id, "compaction", {
|
|
1608
|
-
data: {
|
|
1609
|
-
count: this._compactionStats.count,
|
|
1610
|
-
tokensBefore: preparation.tokensBefore,
|
|
1611
|
-
tokensAfter,
|
|
1612
|
-
saved,
|
|
1613
|
-
grossSaved,
|
|
1614
|
-
compactCost,
|
|
1615
|
-
pct,
|
|
1616
|
-
isLongSession,
|
|
1617
|
-
},
|
|
1618
|
-
});
|
|
1619
|
-
}
|
|
1620
|
-
} catch {
|
|
1621
|
-
/* fail-open */
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
this._compactedThisTurn = true;
|
|
1625
|
-
return true;
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
|
-
private async postTurnCompact(
|
|
1629
|
-
provider: LegacyProvider,
|
|
1630
|
-
system: string,
|
|
1631
|
-
contextWindow: number,
|
|
1632
|
-
signal: AbortSignal,
|
|
1633
|
-
): Promise<void> {
|
|
1634
|
-
const log = (taken: boolean, reason: string, extra?: Record<string, unknown>): void => {
|
|
1635
|
-
appendDecisionLog({
|
|
1636
|
-
ts: Date.now(),
|
|
1637
|
-
sessionId: this.session?.id ?? null,
|
|
1638
|
-
kind: "post-turn-compact",
|
|
1639
|
-
taken,
|
|
1640
|
-
reason,
|
|
1641
|
-
meta: { contextWindow, ...extra },
|
|
1642
|
-
}).catch(() => undefined);
|
|
1643
|
-
};
|
|
1644
|
-
|
|
1645
|
-
if (this._compactedThisTurn) return log(false, "already-compacted-this-turn");
|
|
1646
|
-
if (!isAutoCompactAfterTurnEnabled()) return log(false, "feature-disabled");
|
|
1647
|
-
const tokens = estimateConversationTokens(system, this.messages);
|
|
1648
|
-
const thresholdPct = getAutoCompactThresholdPct();
|
|
1649
|
-
const minMeaningfulTokens = Math.max(POST_TURN_MIN_TOKENS, Math.floor(contextWindow * thresholdPct));
|
|
1650
|
-
if (tokens < minMeaningfulTokens) {
|
|
1651
|
-
return log(false, `under-threshold (${tokens} < ${minMeaningfulTokens})`, {
|
|
1652
|
-
tokens,
|
|
1653
|
-
thresholdPct,
|
|
1654
|
-
minMeaningfulTokens,
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
log(true, `over-threshold (${tokens} >= ${minMeaningfulTokens})`, { tokens, thresholdPct, minMeaningfulTokens });
|
|
1658
|
-
await this.compactForContext(
|
|
1659
|
-
provider,
|
|
1660
|
-
system,
|
|
1661
|
-
contextWindow,
|
|
1662
|
-
signal,
|
|
1663
|
-
this.getCompactionSettings(contextWindow),
|
|
1664
|
-
true,
|
|
1665
|
-
).catch((err) => console.warn("[compact] failed:", (err as Error)?.message));
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
// ========================================================================
|
|
1669
|
-
// Council system — delegated to CouncilManager (Phase 12.1-02)
|
|
1670
|
-
//
|
|
1671
|
-
// All council state + sub-call helpers (generate/research/prompt builders/
|
|
1672
|
-
// outcome parser/executor/candidate resolution) live in CouncilManager.
|
|
1673
|
-
// The thin facade below preserves the public API the UI + tests rely on
|
|
1674
|
-
// (respondToCouncilQuestion/Preflight + the internal _create*Responder
|
|
1675
|
-
// hooks used by orchestrator.agent.test.ts).
|
|
1676
|
-
// ========================================================================
|
|
1677
|
-
|
|
1678
|
-
respondToCouncilQuestion(questionId: string, answer: string): void {
|
|
1679
|
-
this.councilManager.respondToQuestion(questionId, answer);
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
respondToCouncilPreflight(preflightId: string, approved: boolean): void {
|
|
1683
|
-
this.councilManager.respondToPreflight(preflightId, approved);
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
// ========================================================================
|
|
1687
|
-
// Council v2 — Clarify → Confirm → Debate → Plan → Execute
|
|
1688
|
-
// ========================================================================
|
|
1689
|
-
|
|
1690
|
-
async *runCouncilV2(
|
|
1691
|
-
topic: string,
|
|
1692
|
-
options?: {
|
|
1693
|
-
skipClarification?: boolean;
|
|
1694
|
-
observer?: ProcessMessageObserver;
|
|
1695
|
-
userModelMessage?: ModelMessage;
|
|
1696
|
-
},
|
|
1697
|
-
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
1698
|
-
const { runCouncil } = await import("../council/index.js");
|
|
1699
|
-
const { createCouncilLLM } = await import("../council/llm.js");
|
|
1700
|
-
const councilStats = { calls: 0, startMs: Date.now(), phases: [] as Array<{ name: string; durationMs: number }> };
|
|
1701
|
-
const llm = createCouncilLLM(this.bash, this.mode, this.session?.id, councilStats);
|
|
1702
|
-
|
|
1703
|
-
const processMessageFn = (message: string) => this.processMessage(message, options?.observer);
|
|
1704
|
-
|
|
1705
|
-
const gen = runCouncil(
|
|
1706
|
-
topic,
|
|
1707
|
-
this.modelId,
|
|
1708
|
-
this.messages as Array<{ role: string; content: string | unknown }>,
|
|
1709
|
-
this.session?.id,
|
|
1710
|
-
llm,
|
|
1711
|
-
this.councilManager.createQuestionResponder(),
|
|
1712
|
-
this.councilManager.createPreflightResponder(),
|
|
1713
|
-
processMessageFn,
|
|
1714
|
-
{
|
|
1715
|
-
skipClarification: options?.skipClarification,
|
|
1716
|
-
userModelMessage: options?.userModelMessage,
|
|
1717
|
-
cwd: this.bash.getCwd(),
|
|
1718
|
-
councilStats, // NEW — share orchestrator's stats object with runCouncil (Phase 14 CQ-01)
|
|
1719
|
-
},
|
|
1720
|
-
);
|
|
1721
|
-
|
|
1722
|
-
let result: IteratorResult<StreamChunk, string | null>;
|
|
1723
|
-
do {
|
|
1724
|
-
result = await gen.next();
|
|
1725
|
-
if (!result.done && result.value) {
|
|
1726
|
-
yield result.value;
|
|
1727
|
-
}
|
|
1728
|
-
} while (!result.done);
|
|
1729
|
-
|
|
1730
|
-
const synthesis = result.value;
|
|
1731
|
-
this.councilManager.setLastSynthesis(synthesis);
|
|
1732
|
-
|
|
1733
|
-
if (options?.userModelMessage && synthesis) {
|
|
1734
|
-
this.appendCompletedTurn(options.userModelMessage, [{ role: "assistant", content: synthesis }]);
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
// ========================================================================
|
|
1739
|
-
// Product Ideal Loop (Phase 13) — mirror of runCouncilV2 wiring.
|
|
1740
|
-
// ========================================================================
|
|
1741
|
-
|
|
1742
|
-
async *runProductLoopV1(
|
|
1743
|
-
payload: {
|
|
1744
|
-
subcommand: "start" | "status" | "resume" | "abort" | "ship";
|
|
1745
|
-
idea?: string;
|
|
1746
|
-
runId?: string;
|
|
1747
|
-
flags: {
|
|
1748
|
-
maxCost: number;
|
|
1749
|
-
maxSprints: number;
|
|
1750
|
-
doneThreshold: number;
|
|
1751
|
-
budgetTokens?: number;
|
|
1752
|
-
stack?: string;
|
|
1753
|
-
noCustomerDebate?: boolean;
|
|
1754
|
-
noPriorContext?: boolean;
|
|
1755
|
-
forceCouncil?: boolean;
|
|
1756
|
-
mode?: "maintain" | "new";
|
|
1757
|
-
ghPr?: boolean;
|
|
1758
|
-
};
|
|
1759
|
-
},
|
|
1760
|
-
options?: {
|
|
1761
|
-
observer?: ProcessMessageObserver;
|
|
1762
|
-
userModelMessage?: ModelMessage;
|
|
1763
|
-
},
|
|
1764
|
-
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
1765
|
-
const { runProductLoop } = await import("../product-loop/index.js");
|
|
1766
|
-
const { createCouncilLLM } = await import("../council/llm.js");
|
|
1767
|
-
const nodePath = await import("node:path");
|
|
1768
|
-
|
|
1769
|
-
const productStats = {
|
|
1770
|
-
calls: 0,
|
|
1771
|
-
startMs: Date.now(),
|
|
1772
|
-
phases: [] as Array<{ name: string; durationMs: number }>,
|
|
1773
|
-
};
|
|
1774
|
-
const llm = createCouncilLLM(this.bash, this.mode, this.session?.id, productStats);
|
|
1775
|
-
const processMessageFn = (m: string) => this.processMessage(m, options?.observer);
|
|
1776
|
-
const flowDir = nodePath.join(this.bash.getCwd(), ".muonroi-flow");
|
|
1777
|
-
|
|
1778
|
-
// P2.7: compute complexity from the idea using PIL Layer 1 heuristics (cheap,
|
|
1779
|
-
// no LLM calls). Only meaningful for "start"; other subcommands ignore it.
|
|
1780
|
-
let complexity: "low" | "medium" | "high" | undefined;
|
|
1781
|
-
let sufficiencyMissing: readonly import("../pil/layer1-intent.js").SufficiencyMissing[] | undefined;
|
|
1782
|
-
if (payload.subcommand === "start" && payload.idea) {
|
|
1783
|
-
const { scoreComplexity, scoreSufficiency } = await import("../pil/layer1-intent.js");
|
|
1784
|
-
const result = scoreComplexity({
|
|
1785
|
-
rawText: payload.idea,
|
|
1786
|
-
taskType: null,
|
|
1787
|
-
t0HitCount: 0,
|
|
1788
|
-
hasMaxSprintsOne: payload.flags.maxSprints === 1,
|
|
1789
|
-
});
|
|
1790
|
-
complexity = result.complexity;
|
|
1791
|
-
// Sufficiency gate — vague briefs ("todo app") force Council so the
|
|
1792
|
-
// discovery AskCard can fill in persona/MVP/architecture/verify before
|
|
1793
|
-
// any code is scaffolded.
|
|
1794
|
-
const suff = scoreSufficiency({ rawText: payload.idea });
|
|
1795
|
-
sufficiencyMissing = suff.sufficient ? undefined : suff.missing;
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
const gen = runProductLoop({
|
|
1799
|
-
subcommand: payload.subcommand,
|
|
1800
|
-
idea: payload.idea ?? "",
|
|
1801
|
-
runId: payload.runId,
|
|
1802
|
-
flowDir,
|
|
1803
|
-
sessionModelId: this.modelId,
|
|
1804
|
-
llm,
|
|
1805
|
-
flags: {
|
|
1806
|
-
maxCost: payload.flags.maxCost,
|
|
1807
|
-
maxSprints: payload.flags.maxSprints,
|
|
1808
|
-
doneThreshold: payload.flags.doneThreshold,
|
|
1809
|
-
budgetTokens: payload.flags.budgetTokens,
|
|
1810
|
-
stack: payload.flags.stack,
|
|
1811
|
-
forceCouncil: payload.flags.forceCouncil,
|
|
1812
|
-
},
|
|
1813
|
-
respondToQuestion: this.councilManager.createQuestionResponder(),
|
|
1814
|
-
respondToPreflight: this.councilManager.createPreflightResponder(),
|
|
1815
|
-
cwd: this.bash.getCwd(),
|
|
1816
|
-
processMessageFn,
|
|
1817
|
-
// Mode C — wire verify-recipe detector so runProductLoop auto-detect can probe cwd.
|
|
1818
|
-
detectVerifyRecipe: () => this.detectVerifyRecipe(),
|
|
1819
|
-
skipPriorContext: payload.flags.noPriorContext === true,
|
|
1820
|
-
complexity,
|
|
1821
|
-
sufficiencyMissing,
|
|
1822
|
-
// Mode C explicit override + gh pr create opt-in (see .planning/MAINTAIN-MODE.md).
|
|
1823
|
-
mode: payload.flags.mode,
|
|
1824
|
-
ghPr: payload.flags.ghPr === true,
|
|
1825
|
-
// Chat session id — used as the FK key for interaction_logs telemetry.
|
|
1826
|
-
// The /ideal runId is NOT a sessions.id and would silently fail FK insert.
|
|
1827
|
-
sessionId: this.session?.id,
|
|
1828
|
-
} as Parameters<typeof runProductLoop>[0]);
|
|
1829
|
-
|
|
1830
|
-
for await (const chunk of gen) {
|
|
1831
|
-
yield chunk;
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
// ========================================================================
|
|
1836
|
-
// Legacy council — kept for backward compatibility, will be removed
|
|
1837
|
-
// ========================================================================
|
|
1838
|
-
|
|
1839
|
-
async *runCouncilRound(
|
|
1840
|
-
topic: string,
|
|
1841
|
-
_observer?: ProcessMessageObserver,
|
|
1842
|
-
rounds?: number,
|
|
1843
|
-
userModelMessage?: ModelMessage,
|
|
1844
|
-
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
1845
|
-
const maxRounds = rounds ?? getCouncilRounds();
|
|
1846
|
-
const ALL_ROLES: ModelRole[] = ["implement", "verify", "research"];
|
|
1847
|
-
this.councilManager.resetStats(Date.now());
|
|
1848
|
-
|
|
1849
|
-
// Resolve council participants: same-provider by default, multi-provider only when configured
|
|
1850
|
-
const candidates: Array<{ role: ModelRole; model: string }> = [];
|
|
1851
|
-
const configuredRoleModels = getRoleModels();
|
|
1852
|
-
const hasExplicitMultiProvider = this.councilManager.hasMultiProviderConfig(configuredRoleModels);
|
|
1853
|
-
|
|
1854
|
-
if (hasExplicitMultiProvider && isCouncilMultiProviderPreferred()) {
|
|
1855
|
-
// Multi-provider path: use explicitly configured role models across providers
|
|
1856
|
-
for (const role of ALL_ROLES) {
|
|
1857
|
-
const modelId = getRoleModel(role);
|
|
1858
|
-
if (!modelId) continue;
|
|
1859
|
-
const provider = detectProviderForModel(modelId);
|
|
1860
|
-
if (isProviderDisabled(provider as ProviderId)) continue;
|
|
1861
|
-
const canReach = await loadKeyForProvider(provider)
|
|
1862
|
-
.then(() => true)
|
|
1863
|
-
.catch(() => false);
|
|
1864
|
-
if (canReach) candidates.push({ role, model: modelId });
|
|
1865
|
-
}
|
|
1866
|
-
if (candidates.length >= 2) {
|
|
1867
|
-
const providers = new Set(candidates.map((c) => detectProviderForModel(c.model)));
|
|
1868
|
-
yield {
|
|
1869
|
-
type: "content",
|
|
1870
|
-
content: `\n[Multi-provider mode: ${candidates.length} roles across ${providers.size} provider(s)]\n`,
|
|
1871
|
-
};
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
// Default: same-provider mode — pick diverse models from the session's provider
|
|
1876
|
-
if (candidates.length < 2) {
|
|
1877
|
-
const mainProviderId = detectProviderForModel(this.modelId);
|
|
1878
|
-
// Skip same-provider resolution if the session's provider is disabled
|
|
1879
|
-
if (!isProviderDisabled(mainProviderId as ProviderId)) {
|
|
1880
|
-
const sameCandidates = await this.councilManager.resolveSameProviderCandidates(mainProviderId, ALL_ROLES);
|
|
1881
|
-
if (sameCandidates.length >= 2) {
|
|
1882
|
-
candidates.length = 0;
|
|
1883
|
-
candidates.push(...sameCandidates);
|
|
1884
|
-
const uniqueModels = new Set(sameCandidates.map((c) => c.model));
|
|
1885
|
-
yield {
|
|
1886
|
-
type: "content",
|
|
1887
|
-
content: `\n[Same-provider mode: ${uniqueModels.size} ${mainProviderId} model(s) for ${sameCandidates.length} roles]\n`,
|
|
1888
|
-
};
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
// Final fallback: use main model for all roles
|
|
1894
|
-
if (candidates.length < 2) {
|
|
1895
|
-
const mainProviderId = detectProviderForModel(this.modelId);
|
|
1896
|
-
const mainDisabled = isProviderDisabled(mainProviderId as ProviderId);
|
|
1897
|
-
const mainCanReach =
|
|
1898
|
-
!mainDisabled &&
|
|
1899
|
-
(await loadKeyForProvider(mainProviderId)
|
|
1900
|
-
.then(() => true)
|
|
1901
|
-
.catch(() => false));
|
|
1902
|
-
if (mainCanReach) {
|
|
1903
|
-
candidates.length = 0;
|
|
1904
|
-
for (const role of ALL_ROLES) {
|
|
1905
|
-
candidates.push({ role, model: this.modelId });
|
|
1906
|
-
}
|
|
1907
|
-
yield {
|
|
1908
|
-
type: "content",
|
|
1909
|
-
content: `\n[Fallback: using \x1b[36m${this.modelId}\x1b[0m for all roles]\n`,
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
if (candidates.length < 2) {
|
|
1915
|
-
yield {
|
|
1916
|
-
type: "content",
|
|
1917
|
-
content: "\nNo reachable provider. Check API keys in user-settings.json or environment.\n",
|
|
1918
|
-
};
|
|
1919
|
-
yield { type: "done" };
|
|
1920
|
-
return;
|
|
1921
|
-
}
|
|
1922
|
-
|
|
1923
|
-
// Build conversation context for all participants
|
|
1924
|
-
const conversationContext = this.councilManager.buildContext();
|
|
1925
|
-
|
|
1926
|
-
// ── Phase 0: Research — gather facts from codebase before discussion ──
|
|
1927
|
-
const p0Start = Date.now();
|
|
1928
|
-
yield { type: "content", content: `\n## Phase 0 — Codebase Research\n` };
|
|
1929
|
-
|
|
1930
|
-
// Find the research candidate (prefer configured research role, fallback to first available)
|
|
1931
|
-
const researchCandidate = candidates.find((c) => c.role === "research") ?? candidates[0];
|
|
1932
|
-
yield { type: "content", content: `\n### \x1b[35m[research]\x1b[0m ${researchCandidate.model}\n` };
|
|
1933
|
-
|
|
1934
|
-
const researchFindings = await this.councilManager.research(researchCandidate.model, topic, conversationContext);
|
|
1935
|
-
yield { type: "content", content: `${researchFindings}\n` };
|
|
1936
|
-
yield { type: "content", content: `\n> Phase 0: ${((Date.now() - p0Start) / 1000).toFixed(1)}s\n` };
|
|
1937
|
-
|
|
1938
|
-
// Inject research findings into conversation context for subsequent phases
|
|
1939
|
-
const enrichedContext = conversationContext
|
|
1940
|
-
? `${conversationContext}\n\n---\n\n## Research Findings (Phase 0)\n${researchFindings}`
|
|
1941
|
-
: `## Research Findings (Phase 0)\n${researchFindings}`;
|
|
1942
|
-
|
|
1943
|
-
// ── Phase 1: Parallel opening statements ──
|
|
1944
|
-
const p1Start = Date.now();
|
|
1945
|
-
yield { type: "content", content: "\n## Phase 1 — Opening Analysis\n" };
|
|
1946
|
-
|
|
1947
|
-
const openingPromises = candidates.map(({ role, model }) => {
|
|
1948
|
-
const { system, prompt } = this.councilManager.buildDiscussPrompt("open", {
|
|
1949
|
-
speakerRole: role,
|
|
1950
|
-
partnerRole: candidates.find((c) => c.role !== role)?.role ?? "colleague",
|
|
1951
|
-
topic,
|
|
1952
|
-
conversationContext: enrichedContext,
|
|
1953
|
-
});
|
|
1954
|
-
return this.councilManager
|
|
1955
|
-
.generate(model, system, prompt)
|
|
1956
|
-
.then((text) => ({ role, model, position: text, error: null as string | null }))
|
|
1957
|
-
.catch((err: unknown) => ({
|
|
1958
|
-
role,
|
|
1959
|
-
model,
|
|
1960
|
-
position: "",
|
|
1961
|
-
error: err instanceof Error ? err.message : String(err),
|
|
1962
|
-
}));
|
|
1963
|
-
});
|
|
1964
|
-
|
|
1965
|
-
const openings = await Promise.all(openingPromises);
|
|
1966
|
-
const active: Array<{ role: ModelRole; model: string; position: string }> = [];
|
|
1967
|
-
|
|
1968
|
-
for (const o of openings) {
|
|
1969
|
-
const roleColor = COUNCIL_ROLE_COLORS[o.role] ?? "";
|
|
1970
|
-
yield { type: "content", content: `\n### ${roleColor}[${o.role}]${COUNCIL_COLOR_RESET} ${o.model}\n` };
|
|
1971
|
-
if (o.error) {
|
|
1972
|
-
yield { type: "content", content: `[Error: ${o.error}]\n` };
|
|
1973
|
-
} else {
|
|
1974
|
-
active.push({ role: o.role, model: o.model, position: o.position });
|
|
1975
|
-
const bgColor = COUNCIL_COLOR_BG[o.role] ?? "";
|
|
1976
|
-
yield { type: "content", content: `${bgColor} ${o.role.toUpperCase()} ${COUNCIL_COLOR_RESET} ${o.position}\n` };
|
|
1977
|
-
}
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
yield {
|
|
1981
|
-
type: "content",
|
|
1982
|
-
content: `\n> Phase 1: ${active.length} participants, ${((Date.now() - p1Start) / 1000).toFixed(1)}s (parallel)\n`,
|
|
1983
|
-
};
|
|
1984
|
-
|
|
1985
|
-
if (active.length < 2) {
|
|
1986
|
-
yield { type: "content", content: "\nNot enough successful openings for discussion.\n" };
|
|
1987
|
-
yield { type: "done" };
|
|
1988
|
-
return;
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
// ── Phase 2: Discussion rounds with parallel pair debates ──
|
|
1992
|
-
const exchangeLogs: Map<string, string[]> = new Map();
|
|
1993
|
-
const pairConverged: Map<string, boolean> = new Map();
|
|
1994
|
-
let runningSummary = "";
|
|
1995
|
-
|
|
1996
|
-
for (let round = 1; round <= maxRounds; round++) {
|
|
1997
|
-
const p2Start = Date.now();
|
|
1998
|
-
yield { type: "content", content: `\n## Phase 2 — Discussion Round ${round}/${maxRounds}\n` };
|
|
1999
|
-
|
|
2000
|
-
// Build independent pairs
|
|
2001
|
-
const pairs: Array<{ a: (typeof active)[0]; b: (typeof active)[0]; key: string }> = [];
|
|
2002
|
-
for (let i = 0; i < active.length; i++) {
|
|
2003
|
-
const a = active[i];
|
|
2004
|
-
const b = active[(i + 1) % active.length];
|
|
2005
|
-
const key = `${a.role}<>${b.role}`;
|
|
2006
|
-
if (pairConverged.get(key)) continue;
|
|
2007
|
-
if (!exchangeLogs.has(key)) exchangeLogs.set(key, []);
|
|
2008
|
-
pairs.push({ a, b, key });
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
if (pairs.length === 0) break;
|
|
2012
|
-
|
|
2013
|
-
// Run pair debates in parallel
|
|
2014
|
-
const pairResults = await Promise.all(
|
|
2015
|
-
pairs.map(async ({ a, b, key }) => {
|
|
2016
|
-
const log = exchangeLogs.get(key)!;
|
|
2017
|
-
const chunks: Array<{ label: string; text: string }> = [];
|
|
2018
|
-
|
|
2019
|
-
try {
|
|
2020
|
-
let aResponse: string;
|
|
2021
|
-
let bResponse: string;
|
|
2022
|
-
|
|
2023
|
-
if (round === 1) {
|
|
2024
|
-
const aPrompt = this.councilManager.buildDiscussPrompt("respond", {
|
|
2025
|
-
speakerRole: a.role,
|
|
2026
|
-
partnerRole: b.role,
|
|
2027
|
-
topic,
|
|
2028
|
-
speakerPosition: a.position,
|
|
2029
|
-
partnerPosition: b.position,
|
|
2030
|
-
conversationContext: enrichedContext,
|
|
2031
|
-
});
|
|
2032
|
-
aResponse = await this.councilManager.generate(a.model, aPrompt.system, aPrompt.prompt);
|
|
2033
|
-
log.push(`[${a.role}]: ${aResponse}`);
|
|
2034
|
-
chunks.push({ label: `[${a.role}] → [${b.role}]`, text: aResponse });
|
|
2035
|
-
|
|
2036
|
-
const bPrompt = this.councilManager.buildDiscussPrompt("respond", {
|
|
2037
|
-
speakerRole: b.role,
|
|
2038
|
-
partnerRole: a.role,
|
|
2039
|
-
topic,
|
|
2040
|
-
speakerPosition: b.position,
|
|
2041
|
-
partnerPosition: aResponse,
|
|
2042
|
-
conversationContext: enrichedContext,
|
|
2043
|
-
});
|
|
2044
|
-
bResponse = await this.councilManager.generate(b.model, bPrompt.system, bPrompt.prompt);
|
|
2045
|
-
log.push(`[${b.role}]: ${bResponse}`);
|
|
2046
|
-
chunks.push({ label: `[${b.role}] → [${a.role}]`, text: bResponse });
|
|
2047
|
-
} else {
|
|
2048
|
-
const historyText = log.join("\n\n");
|
|
2049
|
-
const aPrompt = this.councilManager.buildDiscussPrompt("followup", {
|
|
2050
|
-
speakerRole: a.role,
|
|
2051
|
-
partnerRole: b.role,
|
|
2052
|
-
topic,
|
|
2053
|
-
partnerPosition: b.position,
|
|
2054
|
-
exchangeHistory: historyText,
|
|
2055
|
-
round,
|
|
2056
|
-
conversationContext: enrichedContext,
|
|
2057
|
-
runningSummary,
|
|
2058
|
-
});
|
|
2059
|
-
aResponse = await this.councilManager.generate(a.model, aPrompt.system, aPrompt.prompt, 1024);
|
|
2060
|
-
log.push(`[${a.role}] (round ${round}): ${aResponse}`);
|
|
2061
|
-
chunks.push({ label: `[${a.role}] → [${b.role}]`, text: aResponse });
|
|
2062
|
-
|
|
2063
|
-
const bPrompt = this.councilManager.buildDiscussPrompt("followup", {
|
|
2064
|
-
speakerRole: b.role,
|
|
2065
|
-
partnerRole: a.role,
|
|
2066
|
-
topic,
|
|
2067
|
-
partnerPosition: aResponse,
|
|
2068
|
-
exchangeHistory: historyText,
|
|
2069
|
-
round,
|
|
2070
|
-
conversationContext: enrichedContext,
|
|
2071
|
-
runningSummary,
|
|
2072
|
-
});
|
|
2073
|
-
bResponse = await this.councilManager.generate(b.model, bPrompt.system, bPrompt.prompt, 1024);
|
|
2074
|
-
log.push(`[${b.role}] (round ${round}): ${bResponse}`);
|
|
2075
|
-
chunks.push({ label: `[${b.role}] → [${a.role}]`, text: bResponse });
|
|
2076
|
-
}
|
|
2077
|
-
|
|
2078
|
-
b.position = bResponse;
|
|
2079
|
-
a.position = aResponse;
|
|
2080
|
-
|
|
2081
|
-
// Convergence check
|
|
2082
|
-
const convPrompt = this.councilManager.buildDiscussPrompt("convergence-check", {
|
|
2083
|
-
speakerRole: a.role,
|
|
2084
|
-
partnerRole: b.role,
|
|
2085
|
-
topic,
|
|
2086
|
-
exchangeHistory: log.slice(-4).join("\n\n"),
|
|
2087
|
-
conversationContext: enrichedContext,
|
|
2088
|
-
});
|
|
2089
|
-
let converged = false;
|
|
2090
|
-
let convReason = "";
|
|
2091
|
-
try {
|
|
2092
|
-
const raw = await this.councilManager.generate(a.model, convPrompt.system, convPrompt.prompt, 256);
|
|
2093
|
-
const match = raw.match(/\{[\s\S]*\}/);
|
|
2094
|
-
if (match) {
|
|
2095
|
-
const parsed = JSON.parse(match[0]) as { converged?: boolean; reason?: string };
|
|
2096
|
-
converged = parsed.converged === true;
|
|
2097
|
-
convReason = parsed.reason ?? "";
|
|
2098
|
-
}
|
|
2099
|
-
} catch {
|
|
2100
|
-
/* not converged */
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
return { key, chunks, converged, convReason, error: null as string | null };
|
|
2104
|
-
} catch (err: unknown) {
|
|
2105
|
-
return {
|
|
2106
|
-
key,
|
|
2107
|
-
chunks,
|
|
2108
|
-
converged: false,
|
|
2109
|
-
convReason: "",
|
|
2110
|
-
error: err instanceof Error ? err.message : String(err),
|
|
2111
|
-
};
|
|
2112
|
-
}
|
|
2113
|
-
}),
|
|
2114
|
-
);
|
|
2115
|
-
|
|
2116
|
-
// Emit results (sequential yield — maintains readable order)
|
|
2117
|
-
let allConverged = true;
|
|
2118
|
-
for (const pr of pairResults) {
|
|
2119
|
-
for (const chunk of pr.chunks) {
|
|
2120
|
-
const labelParts = chunk.label.match(/\[(\w+)\] → \[(\w+)\]/);
|
|
2121
|
-
let coloredLabel = chunk.label;
|
|
2122
|
-
if (labelParts) {
|
|
2123
|
-
const fromColor = COUNCIL_ROLE_COLORS[labelParts[1]] ?? "";
|
|
2124
|
-
const toColor = COUNCIL_ROLE_COLORS[labelParts[2]] ?? "";
|
|
2125
|
-
coloredLabel = `${fromColor}[${labelParts[1]}]${COUNCIL_COLOR_RESET} → ${toColor}[${labelParts[2]}]${COUNCIL_COLOR_RESET}`;
|
|
2126
|
-
}
|
|
2127
|
-
yield { type: "content", content: `\n### ${coloredLabel}\n${chunk.text}\n` };
|
|
2128
|
-
}
|
|
2129
|
-
if (pr.error) {
|
|
2130
|
-
yield { type: "content", content: `[Discussion error: ${pr.error}]\n` };
|
|
2131
|
-
allConverged = false;
|
|
2132
|
-
} else if (pr.converged) {
|
|
2133
|
-
pairConverged.set(pr.key, true);
|
|
2134
|
-
yield { type: "content", content: `\n> ✓ ${pr.key.replace("<>", " ↔ ")} converged: ${pr.convReason}\n` };
|
|
2135
|
-
} else {
|
|
2136
|
-
allConverged = false;
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
yield {
|
|
2141
|
-
type: "content",
|
|
2142
|
-
content: `\n> Round ${round}: ${((Date.now() - p2Start) / 1000).toFixed(1)}s (${pairs.length} pairs parallel)\n`,
|
|
2143
|
-
};
|
|
2144
|
-
|
|
2145
|
-
if (allConverged) {
|
|
2146
|
-
yield { type: "content", content: `\n> All pairs converged at round ${round}. Moving to synthesis.\n` };
|
|
2147
|
-
break;
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
// Generate inter-round summary for next round's focus
|
|
2151
|
-
if (round < maxRounds) {
|
|
2152
|
-
try {
|
|
2153
|
-
runningSummary = await this.councilManager.generateRoundSummary(exchangeLogs, topic, round, active[0].model);
|
|
2154
|
-
yield {
|
|
2155
|
-
type: "content",
|
|
2156
|
-
content: `\n> **Discussion state:** ${runningSummary
|
|
2157
|
-
.split("\n")
|
|
2158
|
-
.filter((l) => l.trim())
|
|
2159
|
-
.slice(0, 3)
|
|
2160
|
-
.join(" | ")}\n`,
|
|
2161
|
-
};
|
|
2162
|
-
} catch {
|
|
2163
|
-
// Non-critical — continue without summary
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
// ── Phase 3: Leader synthesis ──
|
|
2169
|
-
const p3Start = Date.now();
|
|
2170
|
-
yield { type: "content", content: "\n## Phase 3 — Leader Synthesis\n" };
|
|
2171
|
-
|
|
2172
|
-
const leaderModelId = getRoleModel("leader") ?? this.modelId;
|
|
2173
|
-
yield { type: "content", content: `\n### \x1b[32m[leader]\x1b[0m ${leaderModelId}\n` };
|
|
2174
|
-
|
|
2175
|
-
const allExchanges = [...exchangeLogs.entries()]
|
|
2176
|
-
.map(([pair, log]) => `### Discussion: ${pair}\n${log.join("\n\n")}`)
|
|
2177
|
-
.join("\n\n---\n\n");
|
|
2178
|
-
|
|
2179
|
-
const finalPositions = active.map((p) => `**${p.role}** (${p.model}): ${p.position.slice(0, 500)}...`).join("\n\n");
|
|
2180
|
-
|
|
2181
|
-
let synthesisText = "";
|
|
2182
|
-
try {
|
|
2183
|
-
synthesisText = await this.councilManager.generate(
|
|
2184
|
-
leaderModelId,
|
|
2185
|
-
"You are the team lead. Multiple specialists just had a structured discussion about a topic.\n\n" +
|
|
2186
|
-
"Output TWO parts separated by the exact line `---READABLE---`:\n\n" +
|
|
2187
|
-
"**Part 1: JSON** — a single JSON object:\n" +
|
|
2188
|
-
"```\n" +
|
|
2189
|
-
'{ "type": "decision"|"action_items"|"plan_update"|"resolve_question",\n' +
|
|
2190
|
-
' "summary": "1-2 sentence executive summary",\n' +
|
|
2191
|
-
' "agreed": ["point 1", "point 2"],\n' +
|
|
2192
|
-
' "tradeoffs": ["trade-off 1"],\n' +
|
|
2193
|
-
' "recommendation": "Your decisive recommendation",\n' +
|
|
2194
|
-
' "actionItems": ["step 1", "step 2"],\n' +
|
|
2195
|
-
' "planUpdate": "paragraph for plan update (only if type=plan_update)",\n' +
|
|
2196
|
-
' "resolvedQuestion": {"question": "...", "answer": "..."} }\n' +
|
|
2197
|
-
"```\n" +
|
|
2198
|
-
"Choose type: decision (general), action_items (concrete steps), plan_update (modify active plan), resolve_question (answer a specific question).\n\n" +
|
|
2199
|
-
"**Part 2: Human-readable** — after `---READABLE---`, write the synthesis in markdown:\n" +
|
|
2200
|
-
"## AGREED\n## TRADE-OFFS\n## RECOMMENDATION\n## NEXT STEPS\n\n" +
|
|
2201
|
-
"Be decisive. Output Part 1 JSON first, then ---READABLE---, then Part 2.",
|
|
2202
|
-
`Topic: ${topic}\n\nFinal positions:\n${finalPositions}\n\nFull discussion:\n${allExchanges}`,
|
|
2203
|
-
4096,
|
|
2204
|
-
);
|
|
2205
|
-
|
|
2206
|
-
// Display human-readable part
|
|
2207
|
-
const readablePart = synthesisText.includes("---READABLE---")
|
|
2208
|
-
? synthesisText.split("---READABLE---")[1]?.trim()
|
|
2209
|
-
: synthesisText;
|
|
2210
|
-
yield { type: "content", content: `${readablePart || synthesisText}\n` };
|
|
2211
|
-
|
|
2212
|
-
// Parse structured outcome and execute actions
|
|
2213
|
-
const structuredOutcome = this.councilManager.parseOutcome(synthesisText, topic);
|
|
2214
|
-
if (structuredOutcome) {
|
|
2215
|
-
yield* this.councilManager.executeOutcome(structuredOutcome, topic);
|
|
2216
|
-
if (this.session) {
|
|
2217
|
-
try {
|
|
2218
|
-
appendSystemMessage(this.session.id, `[Council Outcome]\n${JSON.stringify(structuredOutcome)}`);
|
|
2219
|
-
} catch {
|
|
2220
|
-
/* non-critical */
|
|
2221
|
-
}
|
|
2222
|
-
}
|
|
2223
|
-
} else {
|
|
2224
|
-
// Fallback: store text-only outcome (backward compatible)
|
|
2225
|
-
if (this.session) {
|
|
2226
|
-
try {
|
|
2227
|
-
appendSystemMessage(this.session.id, `[Council Outcome]\nTopic: ${topic}\n${synthesisText.slice(0, 2000)}`);
|
|
2228
|
-
} catch {
|
|
2229
|
-
/* non-critical */
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
} catch (err: unknown) {
|
|
2234
|
-
yield { type: "content", content: `[Synthesis error: ${err instanceof Error ? err.message : err}]\n` };
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
// ── Stats + Memory ──
|
|
2238
|
-
const councilStats = this.councilManager.stats;
|
|
2239
|
-
const totalMs = Date.now() - councilStats.startMs;
|
|
2240
|
-
yield {
|
|
2241
|
-
type: "content",
|
|
2242
|
-
content:
|
|
2243
|
-
`\n---\n` +
|
|
2244
|
-
`> Council stats: ${councilStats.calls} API calls, ${(totalMs / 1000).toFixed(1)}s total, ` +
|
|
2245
|
-
`${active.length} participants, synthesis ${((Date.now() - p3Start) / 1000).toFixed(1)}s\n`,
|
|
2246
|
-
};
|
|
2247
|
-
|
|
2248
|
-
// Save council result to session for memory across conversations
|
|
2249
|
-
if (this.session && this.sessionStore) {
|
|
2250
|
-
const councilRecord = {
|
|
2251
|
-
topic,
|
|
2252
|
-
participants: active.map((a) => ({ role: a.role, model: a.model })),
|
|
2253
|
-
finalPositions: active.map((a) => ({ role: a.role, position: a.position.slice(0, 1000) })),
|
|
2254
|
-
synthesis: synthesisText.slice(0, 2000),
|
|
2255
|
-
convergedPairs: [...pairConverged.entries()].filter(([, v]) => v).map(([k]) => k),
|
|
2256
|
-
stats: { calls: councilStats.calls, durationMs: totalMs },
|
|
2257
|
-
timestamp: new Date().toISOString(),
|
|
2258
|
-
};
|
|
2259
|
-
try {
|
|
2260
|
-
appendSystemMessage(this.session.id, `[Council Memory] ${JSON.stringify(councilRecord)}`);
|
|
2261
|
-
} catch {
|
|
2262
|
-
/* non-critical */
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
// Store council output as assistant message so the conversation history
|
|
2267
|
-
// stays valid (user→assistant alternation required by most APIs).
|
|
2268
|
-
const councilResponse = synthesisText || "[Council completed — see discussion above]";
|
|
2269
|
-
if (userModelMessage) {
|
|
2270
|
-
this.appendCompletedTurn(userModelMessage, [{ role: "assistant", content: councilResponse }]);
|
|
2271
|
-
}
|
|
2272
|
-
this.councilManager.setLastSynthesis(councilResponse);
|
|
2273
|
-
|
|
2274
|
-
yield { type: "done" };
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
|
-
// ========================================================================
|
|
2278
|
-
// processMessageBatchTurn — batch API message processing loop.
|
|
2279
|
-
// Body extracted into BatchTurnRunner (Phase 12.5). Thin wrapper preserved
|
|
2280
|
-
// so MessageProcessorDeps' `processMessageBatchTurn` callback continues to
|
|
2281
|
-
// dispatch through `Agent.processMessageBatchTurn` unchanged.
|
|
2282
|
-
// ========================================================================
|
|
2283
|
-
|
|
2284
|
-
private async *processMessageBatchTurn(args: {
|
|
2285
|
-
userModelMessage: ModelMessage;
|
|
2286
|
-
observer?: ProcessMessageObserver;
|
|
2287
|
-
provider: LegacyProvider;
|
|
2288
|
-
subagents: CustomSubagentConfig[];
|
|
2289
|
-
system: string;
|
|
2290
|
-
runtime: ReturnType<typeof resolveModelRuntime>;
|
|
2291
|
-
modelInfo: ReturnType<typeof getModelInfo>;
|
|
2292
|
-
signal: AbortSignal;
|
|
2293
|
-
}): AsyncGenerator<StreamChunk, void, unknown> {
|
|
2294
|
-
const runner = new BatchTurnRunner(this._buildBatchTurnRunnerDeps());
|
|
2295
|
-
yield* runner.run(args);
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
|
-
/**
|
|
2299
|
-
* Build the DI surface BatchTurnRunner (Phase 12.5) needs to reach back
|
|
2300
|
-
* into Agent state without holding a circular reference. Callback names
|
|
2301
|
-
* align with `MessageProcessorDeps` where the signature matches so a
|
|
2302
|
-
* future `TurnRunnerDepsBase` hoist is mechanical. Built per call —
|
|
2303
|
-
* allocation cost is negligible against the batch polling spend.
|
|
2304
|
-
*/
|
|
2305
|
-
private _buildBatchTurnRunnerDeps(): BatchTurnRunnerDeps {
|
|
2306
|
-
const self = this;
|
|
2307
|
-
return {
|
|
2308
|
-
get messages() {
|
|
2309
|
-
return self.messages;
|
|
2310
|
-
},
|
|
2311
|
-
get bash() {
|
|
2312
|
-
return self.bash;
|
|
2313
|
-
},
|
|
2314
|
-
get mode() {
|
|
2315
|
-
return self.mode;
|
|
2316
|
-
},
|
|
2317
|
-
get maxToolRounds() {
|
|
2318
|
-
return self.maxToolRounds;
|
|
2319
|
-
},
|
|
2320
|
-
get maxTokens() {
|
|
2321
|
-
return self.maxTokens;
|
|
2322
|
-
},
|
|
2323
|
-
get schedules() {
|
|
2324
|
-
return self.schedules;
|
|
2325
|
-
},
|
|
2326
|
-
get sendTelegramFile() {
|
|
2327
|
-
return self.sendTelegramFile;
|
|
2328
|
-
},
|
|
2329
|
-
getSessionId: () => self.session?.id ?? null,
|
|
2330
|
-
getCompactedThisTurn: () => self._compactedThisTurn,
|
|
2331
|
-
setCompactedThisTurn: (v) => {
|
|
2332
|
-
self._compactedThisTurn = v;
|
|
2333
|
-
},
|
|
2334
|
-
setLastProviderOptionsShape: (shape) => {
|
|
2335
|
-
self._lastProviderOptionsShape = shape;
|
|
2336
|
-
},
|
|
2337
|
-
getBatchClientOptions: (signal) => self.getBatchClientOptions(signal),
|
|
2338
|
-
getCompactionSettings: (cw) => self.getCompactionSettings(cw),
|
|
2339
|
-
compactForContext: (provider, system, cw, signal, settings, overflow) =>
|
|
2340
|
-
self.compactForContext(provider, system, cw, signal, settings, overflow),
|
|
2341
|
-
postTurnCompact: (provider, system, cw, signal) => self.postTurnCompact(provider, system, cw, signal),
|
|
2342
|
-
createTools: (bash, provider, mode, opts) => createTools(bash, provider, mode, opts),
|
|
2343
|
-
runTask: (request, signal) => self.runTask(request, signal),
|
|
2344
|
-
runDelegation: (request, signal) => self.runDelegation(request, signal),
|
|
2345
|
-
readDelegation: (id) => self.readDelegation(id),
|
|
2346
|
-
listDelegations: () => self.listDelegations(),
|
|
2347
|
-
executeBatchToolCall: (tools, toolCall, messages, signal) =>
|
|
2348
|
-
self.executeBatchToolCall(tools, toolCall, messages, signal),
|
|
2349
|
-
appendCompletedTurn: (user, asst) => self.appendCompletedTurn(user, asst),
|
|
2350
|
-
discardAbortedTurn: (user) => self.discardAbortedTurn(user),
|
|
2351
|
-
recordUsage: (usage, source, model, shape) => self.recordUsage(usage, source, model, shape),
|
|
2352
|
-
};
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
private appendCompletedTurn(userMessage: ModelMessage, newMessages: ModelMessage[]): void {
|
|
2356
|
-
if (newMessages.length === 0) return;
|
|
2357
|
-
|
|
2358
|
-
const userIndex = this.messages.lastIndexOf(userMessage);
|
|
2359
|
-
if (!this.sessionStore || !this.session) {
|
|
2360
|
-
if (userIndex >= 0 && this.messageSeqs[userIndex] == null) {
|
|
2361
|
-
this.messageSeqs[userIndex] = null;
|
|
2362
|
-
}
|
|
2363
|
-
this.messages.push(...newMessages);
|
|
2364
|
-
this.messageSeqs.push(...newMessages.map(() => null));
|
|
2365
|
-
return;
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
// Phase A5 — if the user message already has a persisted seq (set by
|
|
2369
|
-
// the write-ahead path), skip re-inserting it. The write-ahead row
|
|
2370
|
-
// will be upserted to status='completed' on the next `appendMessages`
|
|
2371
|
-
// call that sees it via ON CONFLICT, but here we only need to insert
|
|
2372
|
-
// the *new* assistant/tool messages so they get fresh sequence
|
|
2373
|
-
// numbers contiguous with the user row.
|
|
2374
|
-
const existingUserSeq = userIndex >= 0 ? this.messageSeqs[userIndex] : null;
|
|
2375
|
-
if (typeof existingUserSeq === "number") {
|
|
2376
|
-
// User row is already persisted (write-ahead). Insert only the new
|
|
2377
|
-
// assistant/tool messages so they get fresh sequence numbers
|
|
2378
|
-
// contiguous with the user row. Then flip the user row's status
|
|
2379
|
-
// from 'pending' to 'completed' so forensics + replay tooling can
|
|
2380
|
-
// tell the turn settled cleanly.
|
|
2381
|
-
const insertedSeqs = appendMessages(this.session.id, newMessages);
|
|
2382
|
-
markMessageCompleted(this.session.id, existingUserSeq);
|
|
2383
|
-
this.messages.push(...newMessages);
|
|
2384
|
-
this.messageSeqs.push(...insertedSeqs);
|
|
2385
|
-
this.sessionStore.touchSession(this.session.id, this.bash.getCwd());
|
|
2386
|
-
this.session = this.sessionStore.getRequiredSession(this.session.id);
|
|
2387
|
-
return;
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
const insertedSeqs = appendMessages(this.session.id, [userMessage, ...newMessages]);
|
|
2391
|
-
if (userIndex >= 0) {
|
|
2392
|
-
this.messageSeqs[userIndex] = insertedSeqs[0] ?? this.messageSeqs[userIndex];
|
|
2393
|
-
}
|
|
2394
|
-
this.messages.push(...newMessages);
|
|
2395
|
-
this.messageSeqs.push(...insertedSeqs.slice(1));
|
|
2396
|
-
this.sessionStore.touchSession(this.session.id, this.bash.getCwd());
|
|
2397
|
-
this.session = this.sessionStore.getRequiredSession(this.session.id);
|
|
2398
|
-
}
|
|
2399
|
-
|
|
2400
|
-
private fireHook(
|
|
2401
|
-
input: Parameters<typeof executeEventHooks>[0],
|
|
2402
|
-
signal?: AbortSignal,
|
|
2403
|
-
): Promise<Awaited<ReturnType<typeof executeEventHooks>>> {
|
|
2404
|
-
return executeEventHooks(input, this.bash.getCwd(), signal);
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
// ========================================================================
|
|
2408
|
-
// processMessage — main streaming turn loop (PIL enrichment, routing, LLM
|
|
2409
|
-
// stream, tool execution, compaction, hooks, observer notifications)
|
|
2410
|
-
// ========================================================================
|
|
2411
|
-
|
|
2412
|
-
async *processMessage(
|
|
2413
|
-
userMessage: string,
|
|
2414
|
-
observer?: ProcessMessageObserver,
|
|
2415
|
-
images?: Array<{ path: string; mediaType: string; base64: string }>,
|
|
2416
|
-
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
2417
|
-
const processor = new MessageProcessor(this._buildMessageProcessorDeps());
|
|
2418
|
-
yield* processor.run(userMessage, observer, images);
|
|
2419
|
-
}
|
|
2420
|
-
|
|
2421
|
-
/**
|
|
2422
|
-
* Build the DI surface MessageProcessor (Phase 12.4) needs to reach back
|
|
2423
|
-
* into Agent state without holding a circular reference. Exposes array
|
|
2424
|
-
* references for in-place mutation (messages/messageSeqs) and bound
|
|
2425
|
-
* callbacks for behavior. Built per call — allocation cost is negligible
|
|
2426
|
-
* against the streamText spend.
|
|
2427
|
-
*/
|
|
2428
|
-
private _buildMessageProcessorDeps(): MessageProcessorDeps {
|
|
2429
|
-
const self = this;
|
|
2430
|
-
return {
|
|
2431
|
-
get messages() {
|
|
2432
|
-
return self.messages;
|
|
2433
|
-
},
|
|
2434
|
-
get messageSeqs() {
|
|
2435
|
-
return self.messageSeqs;
|
|
2436
|
-
},
|
|
2437
|
-
get session() {
|
|
2438
|
-
return self.session;
|
|
2439
|
-
},
|
|
2440
|
-
get sessionStore() {
|
|
2441
|
-
return self.sessionStore;
|
|
2442
|
-
},
|
|
2443
|
-
get bash() {
|
|
2444
|
-
return self.bash;
|
|
2445
|
-
},
|
|
2446
|
-
get mode() {
|
|
2447
|
-
return self.mode;
|
|
2448
|
-
},
|
|
2449
|
-
get modelId() {
|
|
2450
|
-
return self.modelId;
|
|
2451
|
-
},
|
|
2452
|
-
get providerId() {
|
|
2453
|
-
return self.providerId;
|
|
2454
|
-
},
|
|
2455
|
-
get maxToolRounds() {
|
|
2456
|
-
return self.maxToolRounds;
|
|
2457
|
-
},
|
|
2458
|
-
get batchApi() {
|
|
2459
|
-
return self.batchApi;
|
|
2460
|
-
},
|
|
2461
|
-
get permissionMode() {
|
|
2462
|
-
return self.permissionMode;
|
|
2463
|
-
},
|
|
2464
|
-
get schedules() {
|
|
2465
|
-
return self.schedules;
|
|
2466
|
-
},
|
|
2467
|
-
get sendTelegramFile() {
|
|
2468
|
-
return self.sendTelegramFile;
|
|
2469
|
-
},
|
|
2470
|
-
get externalAbortContext() {
|
|
2471
|
-
return self.externalAbortContext;
|
|
2472
|
-
},
|
|
2473
|
-
get pendingCalls() {
|
|
2474
|
-
return self.pendingCalls;
|
|
2475
|
-
},
|
|
2476
|
-
get councilManager() {
|
|
2477
|
-
return self.councilManager;
|
|
2478
|
-
},
|
|
2479
|
-
get crossTurnDedup() {
|
|
2480
|
-
return self._crossTurnDedup;
|
|
2481
|
-
},
|
|
2482
|
-
get readBudget() {
|
|
2483
|
-
return self._readBudget;
|
|
2484
|
-
},
|
|
2485
|
-
get priorWarningIdsInSession() {
|
|
2486
|
-
return self._priorWarningIdsInSession;
|
|
2487
|
-
},
|
|
2488
|
-
get sessionEEGuidance() {
|
|
2489
|
-
return self._sessionEEGuidance;
|
|
2490
|
-
},
|
|
2491
|
-
get flowReady() {
|
|
2492
|
-
return self._flowReady;
|
|
2493
|
-
},
|
|
2494
|
-
getAbortController: () => self.abortController,
|
|
2495
|
-
setAbortController: (c) => {
|
|
2496
|
-
self.abortController = c;
|
|
2497
|
-
},
|
|
2498
|
-
getSessionStartHookFired: () => self.sessionStartHookFired,
|
|
2499
|
-
setSessionStartHookFired: (v) => {
|
|
2500
|
-
self.sessionStartHookFired = v;
|
|
2501
|
-
},
|
|
2502
|
-
getPlanContext: () => self.planContext,
|
|
2503
|
-
setPlanContext: (v) => {
|
|
2504
|
-
self.planContext = v;
|
|
2505
|
-
},
|
|
2506
|
-
getResumeDigest: () => self._resumeDigest,
|
|
2507
|
-
setResumeDigest: (v) => {
|
|
2508
|
-
self._resumeDigest = v;
|
|
2509
|
-
},
|
|
2510
|
-
getActiveRunId: () => self._activeRunId,
|
|
2511
|
-
getPendingCwdNote: () => self._pendingCwdNote,
|
|
2512
|
-
setPendingCwdNote: (v) => {
|
|
2513
|
-
self._pendingCwdNote = v;
|
|
2514
|
-
},
|
|
2515
|
-
setPilActive: (v) => {
|
|
2516
|
-
self._pilActive = v;
|
|
2517
|
-
},
|
|
2518
|
-
setPilEnrichmentDelta: (n) => {
|
|
2519
|
-
self._pilEnrichmentDelta = n;
|
|
2520
|
-
},
|
|
2521
|
-
setCurrentCallId: (id) => {
|
|
2522
|
-
self._currentCallId = id;
|
|
2523
|
-
},
|
|
2524
|
-
setLastProviderOptionsShape: (shape) => {
|
|
2525
|
-
self._lastProviderOptionsShape = shape;
|
|
2526
|
-
},
|
|
2527
|
-
setLastPromptBreakdown: (b) => {
|
|
2528
|
-
self._lastPromptBreakdown = b;
|
|
2529
|
-
},
|
|
2530
|
-
setCompactedThisTurn: (v) => {
|
|
2531
|
-
self._compactedThisTurn = v;
|
|
2532
|
-
},
|
|
2533
|
-
getCompactedThisTurn: () => self._compactedThisTurn,
|
|
2534
|
-
setTurnUserGoalExcerpt: (v) => {
|
|
2535
|
-
self._turnUserGoalExcerpt = v;
|
|
2536
|
-
},
|
|
2537
|
-
setTurnAssistantReasoning: (v) => {
|
|
2538
|
-
self._turnAssistantReasoning = v;
|
|
2539
|
-
},
|
|
2540
|
-
appendTurnAssistantReasoning: (delta) => {
|
|
2541
|
-
self._turnAssistantReasoning = (self._turnAssistantReasoning + delta).slice(-400);
|
|
2542
|
-
},
|
|
2543
|
-
getTurnAssistantReasoning: () => self._turnAssistantReasoning,
|
|
2544
|
-
setPriorWarningIdsInSession: (s) => {
|
|
2545
|
-
self._priorWarningIdsInSession = s;
|
|
2546
|
-
},
|
|
2547
|
-
setMessages: (m) => {
|
|
2548
|
-
self.messages = m;
|
|
2549
|
-
},
|
|
2550
|
-
requireProvider: () => self.requireProvider(),
|
|
2551
|
-
emitSubagentStatus: (s) => self.emitSubagentStatus(s),
|
|
2552
|
-
fireHook: (input, signal) =>
|
|
2553
|
-
self.fireHook(input as Parameters<Agent["fireHook"]>[0], signal) as ReturnType<
|
|
2554
|
-
MessageProcessorDeps["fireHook"]
|
|
2555
|
-
>,
|
|
2556
|
-
consumeBackgroundNotifications: () => self.consumeBackgroundNotifications(),
|
|
2557
|
-
initOAuthProvider: () => self._initOAuthProvider(),
|
|
2558
|
-
buildRecentTurnsSummary: () => self._buildRecentTurnsSummary(),
|
|
2559
|
-
estimateProjectSize: () => self._estimateProjectSize(),
|
|
2560
|
-
countFilesTouched: () => self._countFilesTouched(),
|
|
2561
|
-
getCompactionSettings: (cw) => self.getCompactionSettings(cw),
|
|
2562
|
-
compactForContext: (provider, system, cw, signal, settings, overflow) =>
|
|
2563
|
-
self.compactForContext(provider, system, cw, signal, settings, overflow),
|
|
2564
|
-
postTurnCompact: (provider, system, cw, signal) => self.postTurnCompact(provider, system, cw, signal),
|
|
2565
|
-
runTask: (request, signal) => self.runTask(request, signal),
|
|
2566
|
-
runDelegation: (request, signal) => self.runDelegation(request, signal),
|
|
2567
|
-
readDelegation: (id) => self.readDelegation(id),
|
|
2568
|
-
listDelegations: () => self.listDelegations(),
|
|
2569
|
-
appendCompletedTurn: (user, asst) => self.appendCompletedTurn(user, asst),
|
|
2570
|
-
discardAbortedTurn: (user) => self.discardAbortedTurn(user),
|
|
2571
|
-
recordUsage: (usage, source, model, shape) => self.recordUsage(usage, source, model, shape),
|
|
2572
|
-
respondToToolApproval: (id, ok) => self.respondToToolApproval(id, ok),
|
|
2573
|
-
askToolLoopContinue: async (info) => {
|
|
2574
|
-
const h = self._toolLoopCapHandler;
|
|
2575
|
-
if (!h) return "stop";
|
|
2576
|
-
try {
|
|
2577
|
-
return await h(info);
|
|
2578
|
-
} catch (err) {
|
|
2579
|
-
console.error(`[Agent] askToolLoopContinue crashed: ${(err as Error)?.message ?? err}`);
|
|
2580
|
-
return "stop";
|
|
2581
|
-
}
|
|
2582
|
-
},
|
|
2583
|
-
runCouncilV2: (msg, opts) => self.runCouncilV2(msg, opts),
|
|
2584
|
-
processMessage: (msg, obs, imgs) => self.processMessage(msg, obs, imgs),
|
|
2585
|
-
processMessageBatchTurn: (args) => self.processMessageBatchTurn(args),
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2589
|
-
// ========================================================================
|
|
2590
|
-
// processMessage body extracted into MessageProcessor (Phase 12.4).
|
|
2591
|
-
// The single original implementation now lives in
|
|
2592
|
-
// `src/orchestrator/message-processor.ts`. The thin wrapper above is the
|
|
2593
|
-
// only entry point.
|
|
2594
|
-
// ========================================================================
|
|
2595
|
-
|
|
2596
|
-
// ========================================================================
|
|
2597
|
-
// Private helper methods — summary, estimation, verify
|
|
2598
|
-
// ========================================================================
|
|
2599
|
-
|
|
2600
|
-
private _buildRecentTurnsSummary(): string | null {
|
|
2601
|
-
if (this.messages.length < 2) return null;
|
|
2602
|
-
const recent = this.messages.slice(-6);
|
|
2603
|
-
const parts: string[] = [];
|
|
2604
|
-
for (const msg of recent) {
|
|
2605
|
-
if (msg.role !== "user" && msg.role !== "assistant") continue;
|
|
2606
|
-
const text =
|
|
2607
|
-
typeof msg.content === "string"
|
|
2608
|
-
? msg.content
|
|
2609
|
-
: Array.isArray(msg.content)
|
|
2610
|
-
? msg.content
|
|
2611
|
-
.filter((p: { type: string }) => p.type === "text")
|
|
2612
|
-
.map((p: { type: string; text?: string }) => p.text ?? "")
|
|
2613
|
-
.join("")
|
|
2614
|
-
: "";
|
|
2615
|
-
if (!text) continue;
|
|
2616
|
-
const snippet = text.length > 80 ? `${text.slice(0, 77)}...` : text;
|
|
2617
|
-
parts.push(`[${msg.role}]: ${snippet}`);
|
|
2618
|
-
}
|
|
2619
|
-
return parts.length > 0 ? parts.join(" | ") : null;
|
|
2620
|
-
}
|
|
2621
|
-
|
|
2622
|
-
private _estimateProjectSize(): "small" | "medium" | "large" | null {
|
|
2623
|
-
try {
|
|
2624
|
-
const fs = require("fs");
|
|
2625
|
-
const path = require("path");
|
|
2626
|
-
const cwd = this.bash.getCwd();
|
|
2627
|
-
const srcDir = path.join(cwd, "src");
|
|
2628
|
-
if (!fs.existsSync(srcDir)) return null;
|
|
2629
|
-
let count = 0;
|
|
2630
|
-
const walk = (dir: string) => {
|
|
2631
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
2632
|
-
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
2633
|
-
if (entry.isDirectory()) walk(path.join(dir, entry.name));
|
|
2634
|
-
else if (/\.(ts|tsx|js|jsx|py|go|rs)$/.test(entry.name)) count++;
|
|
2635
|
-
if (count > 200) return;
|
|
2636
|
-
}
|
|
2637
|
-
};
|
|
2638
|
-
walk(srcDir);
|
|
2639
|
-
if (count <= 20) return "small";
|
|
2640
|
-
if (count <= 100) return "medium";
|
|
2641
|
-
return "large";
|
|
2642
|
-
} catch {
|
|
2643
|
-
return null;
|
|
2644
|
-
}
|
|
2645
|
-
}
|
|
2646
|
-
|
|
2647
|
-
private _countFilesTouched(): number {
|
|
2648
|
-
let count = 0;
|
|
2649
|
-
for (const msg of this.messages) {
|
|
2650
|
-
if (msg.role !== "assistant" || !Array.isArray(msg.content)) continue;
|
|
2651
|
-
for (const part of msg.content) {
|
|
2652
|
-
if ((part as { type: string }).type === "tool-call") {
|
|
2653
|
-
const tc = part as { type: string; toolName?: string; args?: Record<string, unknown> };
|
|
2654
|
-
if (tc.toolName === "write_file" || tc.toolName === "edit_file" || tc.toolName === "bash") count++;
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
return count;
|
|
2659
|
-
}
|
|
2660
|
-
|
|
2661
|
-
private requireProvider(): LegacyProvider {
|
|
2662
|
-
if (!this.provider) {
|
|
2663
|
-
throw new Error("API key required. Add an API key to continue.");
|
|
2664
|
-
}
|
|
2665
|
-
|
|
2666
|
-
return this.provider;
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
/**
|
|
2670
|
-
* One-shot async init: upgrades the OpenAI provider to use OAuth tokens when
|
|
2671
|
-
* stored tokens are available and no explicit API key was supplied by the user.
|
|
2672
|
-
* Called at the start of processMessage so the first real LLM call benefits
|
|
2673
|
-
* from OAuth without requiring a sync constructor change.
|
|
2674
|
-
*
|
|
2675
|
-
* Idempotent: skips on second call and for non-OpenAI providers.
|
|
2676
|
-
* Fail-open: any error leaves the existing provider untouched.
|
|
2677
|
-
*/
|
|
2678
|
-
private async _initOAuthProvider(): Promise<void> {
|
|
2679
|
-
if (this._oauthInitDone) return;
|
|
2680
|
-
this._oauthInitDone = true;
|
|
2681
|
-
|
|
2682
|
-
// Only upgrade when there is no explicit API key — OAuth is an alternative
|
|
2683
|
-
// auth path, not an override when the user deliberately passed a key.
|
|
2684
|
-
// The boot wizard in src/index.ts uses the literal "oauth" as a sentinel
|
|
2685
|
-
// to signal "no API key but OAuth tokens exist", so treat that as "no
|
|
2686
|
-
// key" here.
|
|
2687
|
-
if (this.apiKey && this.apiKey !== "oauth") return;
|
|
2688
|
-
|
|
2689
|
-
try {
|
|
2690
|
-
const { listOAuthProviderIds } = await import("../providers/auth/registry.js");
|
|
2691
|
-
const ids = await listOAuthProviderIds();
|
|
2692
|
-
if (!ids.includes(this.providerId)) return;
|
|
2693
|
-
|
|
2694
|
-
const effectiveBaseURL =
|
|
2695
|
-
this.baseURL &&
|
|
2696
|
-
this.baseURL !== (await import("../providers/endpoints.js").then((m) => m.apiBaseFor("anthropic")))
|
|
2697
|
-
? this.baseURL
|
|
2698
|
-
: undefined;
|
|
2699
|
-
const result = await createProviderFactoryAsync(this.providerId, {
|
|
2700
|
-
baseURL: effectiveBaseURL ?? undefined,
|
|
2701
|
-
});
|
|
2702
|
-
this.provider = result.factory;
|
|
2703
|
-
} catch {
|
|
2704
|
-
// Fail-open — provider remains null; requireProvider() will surface the error
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
async detectVerifyRecipe(settings?: SandboxSettings, abortSignal?: AbortSignal): Promise<VerifyRecipe | null> {
|
|
2709
|
-
try {
|
|
2710
|
-
const result = await this.runTaskRequest(
|
|
2711
|
-
{
|
|
2712
|
-
agent: "verify-detect",
|
|
2713
|
-
description: "Detect verification recipe",
|
|
2714
|
-
prompt: buildVerifyDetectPrompt(this.bash.getCwd(), settings ?? this.bash.getSandboxSettings()),
|
|
2715
|
-
},
|
|
2716
|
-
undefined,
|
|
2717
|
-
abortSignal,
|
|
2718
|
-
);
|
|
2719
|
-
if (!result.success || !result.output) return null;
|
|
2720
|
-
const maybeJson = extractJsonObject(result.output);
|
|
2721
|
-
if (!maybeJson) return null;
|
|
2722
|
-
return normalizeVerifyRecipe(JSON.parse(maybeJson));
|
|
2723
|
-
} catch {
|
|
2724
|
-
return null;
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
|
-
|
|
2728
|
-
async runVerify(onProgress?: (detail: string) => void, abortSignal?: AbortSignal): Promise<ToolResult> {
|
|
2729
|
-
this.abortController = new AbortController();
|
|
2730
|
-
const signal = abortSignal ?? this.abortController.signal;
|
|
2731
|
-
const userModelMessage: ModelMessage = { role: "user", content: "/verify" };
|
|
2732
|
-
this.messages.push(userModelMessage);
|
|
2733
|
-
this.messageSeqs.push(null);
|
|
2734
|
-
|
|
2735
|
-
try {
|
|
2736
|
-
await this.consumeBackgroundNotifications();
|
|
2737
|
-
const result = await runVerifyOrchestration(this, { onProgress, abortSignal: signal });
|
|
2738
|
-
const assistantText = result.output || result.error || "Verification completed.";
|
|
2739
|
-
this.appendCompletedTurn(userModelMessage, [{ role: "assistant", content: assistantText }]);
|
|
2740
|
-
return result;
|
|
2741
|
-
} catch (err: unknown) {
|
|
2742
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
2743
|
-
const failureText = signal.aborted ? "Verification aborted." : `Verification failed: ${msg}`;
|
|
2744
|
-
this.appendCompletedTurn(userModelMessage, [{ role: "assistant", content: failureText }]);
|
|
2745
|
-
return { success: false, output: failureText };
|
|
2746
|
-
} finally {
|
|
2747
|
-
if (this.abortController?.signal === signal) {
|
|
2748
|
-
this.abortController = null;
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
}
|
|
2752
|
-
}
|