muonroi-cli 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -316
- package/dist/packages/agent-harness-core/src/driver.d.ts +77 -0
- package/dist/packages/agent-harness-core/src/driver.js +311 -0
- package/dist/packages/agent-harness-core/src/driver.js.map +1 -0
- package/dist/packages/agent-harness-core/src/event-filter.d.ts +34 -0
- package/dist/packages/agent-harness-core/src/event-filter.js +70 -0
- package/dist/packages/agent-harness-core/src/event-filter.js.map +1 -0
- package/dist/packages/agent-harness-core/src/event-redact.d.ts +24 -0
- package/dist/packages/agent-harness-core/src/event-redact.js +150 -0
- package/dist/packages/agent-harness-core/src/event-redact.js.map +1 -0
- package/dist/packages/agent-harness-core/src/idle.d.ts +18 -0
- package/dist/packages/agent-harness-core/src/idle.js +57 -0
- package/dist/packages/agent-harness-core/src/idle.js.map +1 -0
- package/dist/packages/agent-harness-core/src/index.d.ts +10 -0
- package/dist/packages/agent-harness-core/src/index.js +12 -0
- package/dist/packages/agent-harness-core/src/index.js.map +1 -0
- package/dist/packages/agent-harness-core/src/mcp-server.d.ts +89 -0
- package/dist/packages/agent-harness-core/src/mcp-server.js +427 -0
- package/dist/packages/agent-harness-core/src/mcp-server.js.map +1 -0
- package/dist/packages/agent-harness-core/src/mock-llm.d.ts +75 -0
- package/dist/packages/agent-harness-core/src/mock-llm.js +116 -0
- package/dist/packages/agent-harness-core/src/mock-llm.js.map +1 -0
- package/dist/packages/agent-harness-core/src/predicate.d.ts +34 -0
- package/dist/packages/agent-harness-core/src/predicate.js +46 -0
- package/dist/packages/agent-harness-core/src/predicate.js.map +1 -0
- package/dist/packages/agent-harness-core/src/protocol.d.ts +198 -0
- package/dist/packages/agent-harness-core/src/protocol.js +2 -0
- package/dist/packages/agent-harness-core/src/protocol.js.map +1 -0
- package/dist/packages/agent-harness-core/src/registry.d.ts +30 -0
- package/dist/packages/agent-harness-core/src/registry.js +86 -0
- package/dist/packages/agent-harness-core/src/registry.js.map +1 -0
- package/dist/packages/agent-harness-core/src/selector.d.ts +14 -0
- package/dist/packages/agent-harness-core/src/selector.js +199 -0
- package/dist/packages/agent-harness-core/src/selector.js.map +1 -0
- package/dist/packages/agent-harness-core/src/spec-helpers.d.ts +24 -0
- package/dist/packages/agent-harness-core/src/spec-helpers.js +61 -0
- package/dist/packages/agent-harness-core/src/spec-helpers.js.map +1 -0
- package/dist/packages/agent-harness-core/src/transports/sidechannel.d.ts +11 -0
- package/dist/packages/agent-harness-core/src/transports/sidechannel.js +34 -0
- package/dist/packages/agent-harness-core/src/transports/sidechannel.js.map +1 -0
- package/dist/packages/agent-harness-core/src/transports/ws.d.ts +150 -0
- package/dist/packages/agent-harness-core/src/transports/ws.js +222 -0
- package/dist/packages/agent-harness-core/src/transports/ws.js.map +1 -0
- package/dist/packages/agent-harness-opentui/src/agent-mode.d.ts +46 -0
- package/dist/packages/agent-harness-opentui/src/agent-mode.js +178 -0
- package/dist/packages/agent-harness-opentui/src/agent-mode.js.map +1 -0
- package/dist/packages/agent-harness-opentui/src/index.d.ts +5 -0
- package/dist/packages/agent-harness-opentui/src/index.js +6 -0
- package/dist/packages/agent-harness-opentui/src/index.js.map +1 -0
- package/dist/packages/agent-harness-opentui/src/input-bridge.d.ts +27 -0
- package/dist/packages/agent-harness-opentui/src/input-bridge.js +126 -0
- package/dist/packages/agent-harness-opentui/src/input-bridge.js.map +1 -0
- package/dist/packages/agent-harness-opentui/src/install.d.ts +65 -0
- package/dist/packages/agent-harness-opentui/src/install.js +62 -0
- package/dist/packages/agent-harness-opentui/src/install.js.map +1 -0
- package/dist/packages/agent-harness-opentui/src/reconciler-hook.d.ts +15 -0
- package/dist/packages/agent-harness-opentui/src/reconciler-hook.js +52 -0
- package/dist/packages/agent-harness-opentui/src/reconciler-hook.js.map +1 -0
- package/dist/packages/agent-harness-opentui/src/semantic.d.ts +12 -0
- package/dist/packages/agent-harness-opentui/src/semantic.js +58 -0
- package/dist/packages/agent-harness-opentui/src/semantic.js.map +1 -0
- package/dist/src/__test-stubs__/ee-server.js.map +1 -0
- package/dist/src/__test-stubs__/vitest-setup.js +34 -0
- package/dist/src/__test-stubs__/vitest-setup.js.map +1 -0
- package/dist/src/__tests__/council/bubble-layout.test.js +39 -0
- package/dist/src/__tests__/council/bubble-layout.test.js.map +1 -0
- package/dist/src/__tests__/council/code-block-truncate.test.js +45 -0
- package/dist/src/__tests__/council/code-block-truncate.test.js.map +1 -0
- package/dist/src/__tests__/council/role-palette.test.js +59 -0
- package/dist/src/__tests__/council/role-palette.test.js.map +1 -0
- package/dist/src/__tests__/first-run-wizard.test.js +9 -0
- package/dist/src/__tests__/first-run-wizard.test.js.map +1 -0
- package/dist/src/agent-harness/__tests__/cli-flags.spec.js +33 -0
- package/dist/src/agent-harness/__tests__/cli-flags.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/driver.spec.js +141 -0
- package/dist/src/agent-harness/__tests__/driver.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/idle.spec.js +84 -0
- package/dist/src/agent-harness/__tests__/idle.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/mock-llm.spec.js +91 -0
- package/dist/src/agent-harness/__tests__/mock-llm.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/mock-model.spec.d.ts +5 -0
- package/dist/src/agent-harness/__tests__/mock-model.spec.js +169 -0
- package/dist/src/agent-harness/__tests__/mock-model.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/predicate.spec.js +27 -0
- package/dist/src/agent-harness/__tests__/predicate.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/protocol.spec.js +56 -0
- package/dist/src/agent-harness/__tests__/protocol.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/schema.spec.js +76 -0
- package/dist/src/agent-harness/__tests__/schema.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/selector.spec.js +70 -0
- package/dist/src/agent-harness/__tests__/selector.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/sidechannel.spec.js +29 -0
- package/dist/src/agent-harness/__tests__/sidechannel.spec.js.map +1 -0
- package/dist/src/agent-harness/__tests__/spec-helpers.spec.js +68 -0
- package/dist/src/agent-harness/__tests__/spec-helpers.spec.js.map +1 -0
- package/dist/src/agent-harness/index.d.ts +2 -0
- package/dist/src/agent-harness/index.js +20 -0
- package/dist/src/agent-harness/index.js.map +1 -0
- package/dist/src/agent-harness/mock-model.d.ts +149 -0
- package/dist/src/agent-harness/mock-model.js +291 -0
- package/dist/src/agent-harness/mock-model.js.map +1 -0
- package/dist/src/agent-harness/test-spawn.d.ts +42 -0
- package/dist/src/agent-harness/test-spawn.js +165 -0
- package/dist/src/agent-harness/test-spawn.js.map +1 -0
- package/dist/src/billing/index.js.map +1 -0
- package/dist/src/chat/__tests__/broadcast-bus.test.js +81 -0
- package/dist/src/chat/__tests__/broadcast-bus.test.js.map +1 -0
- package/dist/src/chat/__tests__/channel-manager.test.js +133 -0
- package/dist/src/chat/__tests__/channel-manager.test.js.map +1 -0
- package/dist/src/chat/__tests__/client.test.js +109 -0
- package/dist/src/chat/__tests__/client.test.js.map +1 -0
- package/dist/src/chat/__tests__/discord-integration.test.js +153 -0
- package/dist/src/chat/__tests__/discord-integration.test.js.map +1 -0
- package/dist/src/chat/__tests__/intent-prompt.test.js +80 -0
- package/dist/src/chat/__tests__/intent-prompt.test.js.map +1 -0
- package/dist/src/chat/__tests__/verdict-resolver.test.js +308 -0
- package/dist/src/chat/__tests__/verdict-resolver.test.js.map +1 -0
- package/dist/src/chat/broadcast-bus.d.ts +10 -0
- package/dist/src/chat/broadcast-bus.js +52 -0
- package/dist/src/chat/broadcast-bus.js.map +1 -0
- package/dist/src/chat/channel-manager.d.ts +16 -0
- package/dist/src/chat/channel-manager.js +121 -0
- package/dist/src/chat/channel-manager.js.map +1 -0
- package/dist/src/chat/chat-keychain.d.ts +26 -0
- package/dist/src/chat/chat-keychain.js +113 -0
- package/dist/src/chat/chat-keychain.js.map +1 -0
- package/dist/src/chat/factory.d.ts +3 -0
- package/dist/src/chat/factory.js +29 -0
- package/dist/src/chat/factory.js.map +1 -0
- package/dist/src/chat/intent-prompt.d.ts +17 -0
- package/dist/src/chat/intent-prompt.js +52 -0
- package/dist/src/chat/intent-prompt.js.map +1 -0
- package/dist/src/chat/providers/discord/client.d.ts +28 -0
- package/dist/src/chat/providers/discord/client.js +77 -0
- package/dist/src/chat/providers/discord/client.js.map +1 -0
- package/dist/src/chat/types.d.ts +51 -0
- package/dist/src/chat/types.js +8 -0
- package/dist/src/chat/types.js.map +1 -0
- package/dist/src/chat/verdict-constants.d.ts +13 -0
- package/dist/src/chat/verdict-constants.js +18 -0
- package/dist/src/chat/verdict-constants.js.map +1 -0
- package/dist/src/chat/verdict-resolver.d.ts +28 -0
- package/dist/src/chat/verdict-resolver.js +181 -0
- package/dist/src/chat/verdict-resolver.js.map +1 -0
- package/dist/src/cli/__tests__/bw-vault.test.js +87 -0
- package/dist/src/cli/__tests__/bw-vault.test.js.map +1 -0
- package/dist/src/cli/__tests__/keys-bundle.test.js +40 -0
- package/dist/src/cli/__tests__/keys-bundle.test.js.map +1 -0
- package/dist/src/cli/__tests__/share-cmd.test.js +175 -0
- package/dist/src/cli/__tests__/share-cmd.test.js.map +1 -0
- package/dist/src/cli/bw-vault.d.ts +55 -0
- package/dist/src/cli/bw-vault.js +133 -0
- package/dist/src/cli/bw-vault.js.map +1 -0
- package/dist/src/cli/config/__tests__/model-picker.test.js +56 -0
- package/dist/src/cli/config/__tests__/model-picker.test.js.map +1 -0
- package/dist/src/cli/config/__tests__/provider-fetch.test.js +38 -0
- package/dist/src/cli/config/__tests__/provider-fetch.test.js.map +1 -0
- package/dist/src/cli/config/index.d.ts +2 -0
- package/dist/src/cli/config/index.js +106 -0
- package/dist/src/cli/config/index.js.map +1 -0
- package/dist/src/cli/config/model-picker.d.ts +17 -0
- package/dist/src/cli/config/model-picker.js +149 -0
- package/dist/src/cli/config/model-picker.js.map +1 -0
- package/dist/src/cli/config/provider-fetch.d.ts +8 -0
- package/dist/src/cli/config/provider-fetch.js +59 -0
- package/dist/src/cli/config/provider-fetch.js.map +1 -0
- package/dist/src/cli/config/screen-council.d.ts +1 -0
- package/dist/src/cli/config/screen-council.js +196 -0
- package/dist/src/cli/config/screen-council.js.map +1 -0
- package/dist/src/cli/config/screen-models.d.ts +1 -0
- package/dist/src/cli/config/screen-models.js +86 -0
- package/dist/src/cli/config/screen-models.js.map +1 -0
- package/dist/src/cli/config/screen-providers.d.ts +1 -0
- package/dist/src/cli/config/screen-providers.js +167 -0
- package/dist/src/cli/config/screen-providers.js.map +1 -0
- package/dist/src/cli/config/tui.d.ts +34 -0
- package/dist/src/cli/config/tui.js +145 -0
- package/dist/src/cli/config/tui.js.map +1 -0
- package/dist/src/cli/cost-forensics.d.ts +46 -0
- package/dist/src/cli/cost-forensics.js +188 -0
- package/dist/src/cli/cost-forensics.js.map +1 -0
- package/dist/src/cli/cost-forensics.test.js +99 -0
- package/dist/src/cli/cost-forensics.test.js.map +1 -0
- package/dist/src/cli/keys-bundle.d.ts +28 -0
- package/dist/src/cli/keys-bundle.js +77 -0
- package/dist/src/cli/keys-bundle.js.map +1 -0
- package/dist/src/cli/keys.d.ts +74 -0
- package/dist/src/cli/keys.js +709 -0
- package/dist/src/cli/keys.js.map +1 -0
- package/dist/src/cli/keys.test.js +86 -0
- package/dist/src/cli/keys.test.js.map +1 -0
- package/dist/src/cli/pil-report.d.ts +17 -0
- package/dist/src/cli/pil-report.js +163 -0
- package/dist/src/cli/pil-report.js.map +1 -0
- package/dist/src/cli/share-cmd.d.ts +31 -0
- package/dist/src/cli/share-cmd.js +110 -0
- package/dist/src/cli/share-cmd.js.map +1 -0
- package/dist/src/cli/usage-report.d.ts +17 -0
- package/dist/src/cli/usage-report.js +226 -0
- package/dist/src/cli/usage-report.js.map +1 -0
- package/dist/src/cloud/index.js.map +1 -0
- package/dist/src/council/__tests__/accounting.test.js +66 -0
- package/dist/src/council/__tests__/accounting.test.js.map +1 -0
- package/dist/src/council/__tests__/audit-replay.test.js +241 -0
- package/dist/src/council/__tests__/audit-replay.test.js.map +1 -0
- package/dist/src/council/__tests__/clarifier-max-rounds.test.js +46 -0
- package/dist/src/council/__tests__/clarifier-max-rounds.test.js.map +1 -0
- package/dist/src/council/__tests__/clarifier-options.test.js +54 -0
- package/dist/src/council/__tests__/clarifier-options.test.js.map +1 -0
- package/dist/src/council/__tests__/cost-aware.test.js +49 -0
- package/dist/src/council/__tests__/cost-aware.test.js.map +1 -0
- package/dist/src/council/__tests__/debate-planner-structured.test.js +209 -0
- package/dist/src/council/__tests__/debate-planner-structured.test.js.map +1 -0
- package/dist/src/council/__tests__/evaluator-metrics.test.js +460 -0
- package/dist/src/council/__tests__/evaluator-metrics.test.js.map +1 -0
- package/dist/src/council/__tests__/parse-outcome-fallback.test.js +103 -0
- package/dist/src/council/__tests__/parse-outcome-fallback.test.js.map +1 -0
- package/dist/src/council/__tests__/research-tools.test.js +210 -0
- package/dist/src/council/__tests__/research-tools.test.js.map +1 -0
- package/dist/src/council/__tests__/round-tools.test.js +300 -0
- package/dist/src/council/__tests__/round-tools.test.js.map +1 -0
- package/dist/src/council/__tests__/tool-trace.test.js +131 -0
- package/dist/src/council/__tests__/tool-trace.test.js.map +1 -0
- package/dist/src/council/__tests__/types-contract.test.d.ts +9 -0
- package/dist/src/council/__tests__/types-contract.test.js +82 -0
- package/dist/src/council/__tests__/types-contract.test.js.map +1 -0
- package/dist/src/council/clarifier.d.ts +42 -0
- package/dist/src/council/clarifier.js +332 -0
- package/dist/src/council/clarifier.js.map +1 -0
- package/dist/src/council/context.d.ts +18 -0
- package/dist/src/council/context.js +221 -0
- package/dist/src/council/context.js.map +1 -0
- package/dist/src/council/debate-planner.d.ts +8 -0
- package/dist/src/council/debate-planner.js +243 -0
- package/dist/src/council/debate-planner.js.map +1 -0
- package/dist/src/council/debate.d.ts +4 -0
- package/dist/src/council/debate.js +1014 -0
- package/dist/src/council/debate.js.map +1 -0
- package/dist/src/council/executor.d.ts +3 -0
- package/dist/src/council/executor.js +15 -0
- package/dist/src/council/executor.js.map +1 -0
- package/dist/src/council/index.d.ts +17 -0
- package/dist/src/council/index.js +747 -0
- package/dist/src/council/index.js.map +1 -0
- package/dist/src/council/leader.d.ts +60 -0
- package/dist/src/council/leader.js +216 -0
- package/dist/src/council/leader.js.map +1 -0
- package/dist/src/council/llm.d.ts +39 -0
- package/dist/src/council/llm.js +784 -0
- package/dist/src/council/llm.js.map +1 -0
- package/dist/src/council/phase-events.d.ts +26 -0
- package/dist/src/council/phase-events.js +37 -0
- package/dist/src/council/phase-events.js.map +1 -0
- package/dist/src/council/planner.d.ts +9 -0
- package/dist/src/council/planner.js +262 -0
- package/dist/src/council/planner.js.map +1 -0
- package/dist/src/council/preflight.d.ts +10 -0
- package/dist/src/council/preflight.js +66 -0
- package/dist/src/council/preflight.js.map +1 -0
- package/dist/src/council/prompts.d.ts +97 -0
- package/dist/src/council/prompts.js +491 -0
- package/dist/src/council/prompts.js.map +1 -0
- package/dist/src/council/types.d.ts +263 -0
- package/dist/src/council/types.js.map +1 -0
- package/dist/src/daemon/scheduler.d.ts +15 -0
- package/dist/src/daemon/scheduler.js +126 -0
- package/dist/src/daemon/scheduler.js.map +1 -0
- package/dist/src/daemon/scheduler.test.js +103 -0
- package/dist/src/daemon/scheduler.test.js.map +1 -0
- package/dist/src/ee/__tests__/bb-design.test.d.ts +14 -0
- package/dist/src/ee/__tests__/bb-design.test.js +180 -0
- package/dist/src/ee/__tests__/bb-design.test.js.map +1 -0
- package/dist/src/ee/__tests__/pil-context-bridge.test.js +54 -0
- package/dist/src/ee/__tests__/pil-context-bridge.test.js.map +1 -0
- package/dist/src/ee/__tests__/pipeline.integration.test.js +151 -0
- package/dist/src/ee/__tests__/pipeline.integration.test.js.map +1 -0
- package/dist/src/ee/__tests__/render-sink-wiring.test.js +74 -0
- package/dist/src/ee/__tests__/render-sink-wiring.test.js.map +1 -0
- package/dist/src/ee/auth.d.ts +21 -0
- package/dist/src/ee/auth.js +69 -0
- package/dist/src/ee/auth.js.map +1 -0
- package/dist/src/ee/auth.test.js.map +1 -0
- package/dist/src/ee/bb-design.d.ts +54 -0
- package/dist/src/ee/bb-design.js +213 -0
- package/dist/src/ee/bb-design.js.map +1 -0
- package/dist/src/ee/bb-retrieval.d.ts +107 -0
- package/dist/src/ee/bb-retrieval.js +341 -0
- package/dist/src/ee/bb-retrieval.js.map +1 -0
- package/dist/src/ee/bridge.d.ts +102 -0
- package/dist/src/ee/bridge.js +338 -0
- package/dist/src/ee/bridge.js.map +1 -0
- package/dist/src/ee/bridge.test.js.map +1 -0
- package/dist/src/ee/client-mode.d.ts +57 -0
- package/dist/src/ee/client-mode.js +140 -0
- package/dist/src/ee/client-mode.js.map +1 -0
- package/dist/src/ee/client.js +564 -0
- package/dist/src/ee/client.js.map +1 -0
- package/dist/src/ee/client.test.js.map +1 -0
- package/dist/src/ee/council-bridge.d.ts +27 -0
- package/dist/src/ee/council-bridge.js +60 -0
- package/dist/src/ee/council-bridge.js.map +1 -0
- package/dist/src/ee/embedding-cache.js.map +1 -0
- package/dist/src/ee/extract-session.js +55 -0
- package/dist/src/ee/extract-session.js.map +1 -0
- package/dist/src/ee/extract-session.test.js +192 -0
- package/dist/src/ee/extract-session.test.js.map +1 -0
- package/dist/src/ee/health.js +64 -0
- package/dist/src/ee/health.js.map +1 -0
- package/dist/src/ee/index.d.ts +10 -0
- package/dist/src/ee/index.js +9 -0
- package/dist/src/ee/index.js.map +1 -0
- package/dist/src/ee/intercept.js +122 -0
- package/dist/src/ee/intercept.js.map +1 -0
- package/dist/src/ee/intercept.test.js +171 -0
- package/dist/src/ee/intercept.test.js.map +1 -0
- package/dist/src/ee/judge.d.ts +55 -0
- package/dist/src/ee/judge.js +111 -0
- package/dist/src/ee/judge.js.map +1 -0
- package/dist/src/ee/judge.test.js +190 -0
- package/dist/src/ee/judge.test.js.map +1 -0
- package/dist/src/ee/mistake-detector.d.ts +129 -0
- package/dist/src/ee/mistake-detector.js +272 -0
- package/dist/src/ee/mistake-detector.js.map +1 -0
- package/dist/src/ee/mistake-detector.test.js +221 -0
- package/dist/src/ee/mistake-detector.test.js.map +1 -0
- package/dist/src/ee/offline-queue.js.map +1 -0
- package/dist/src/ee/offline-queue.test.js +246 -0
- package/dist/src/ee/offline-queue.test.js.map +1 -0
- package/dist/src/ee/phase-outcome.d.ts +83 -0
- package/dist/src/ee/phase-outcome.js +98 -0
- package/dist/src/ee/phase-outcome.js.map +1 -0
- package/dist/src/ee/phase-outcome.test.js +94 -0
- package/dist/src/ee/phase-outcome.test.js.map +1 -0
- package/dist/src/ee/phase-tracker.d.ts +91 -0
- package/dist/src/ee/phase-tracker.js +154 -0
- package/dist/src/ee/phase-tracker.js.map +1 -0
- package/dist/src/ee/phase-tracker.test.js +142 -0
- package/dist/src/ee/phase-tracker.test.js.map +1 -0
- package/dist/src/ee/posttool.js.map +1 -0
- package/dist/src/ee/posttool.test.js.map +1 -0
- package/dist/src/ee/prompt-stale.js.map +1 -0
- package/dist/src/ee/prompt-stale.test.js +76 -0
- package/dist/src/ee/prompt-stale.test.js.map +1 -0
- package/dist/src/ee/render.d.ts +25 -0
- package/dist/src/ee/render.js +62 -0
- package/dist/src/ee/render.js.map +1 -0
- package/dist/src/ee/render.test.js +63 -0
- package/dist/src/ee/render.test.js.map +1 -0
- package/dist/src/ee/scope.js.map +1 -0
- package/dist/src/ee/scope.test.js.map +1 -0
- package/dist/src/ee/session-trajectory.d.ts +81 -0
- package/dist/src/ee/session-trajectory.js +168 -0
- package/dist/src/ee/session-trajectory.js.map +1 -0
- package/dist/src/ee/session-trajectory.test.js +120 -0
- package/dist/src/ee/session-trajectory.test.js.map +1 -0
- package/dist/src/ee/tenant.js.map +1 -0
- package/dist/src/ee/touch.test.js +62 -0
- package/dist/src/ee/touch.test.js.map +1 -0
- package/dist/src/ee/types.d.ts +366 -0
- package/dist/src/ee/types.js.map +1 -0
- package/dist/src/flow/__tests__/migration.test.js.map +1 -0
- package/dist/src/flow/__tests__/parser.test.js.map +1 -0
- package/dist/src/flow/__tests__/run-manager-product.test.js +49 -0
- package/dist/src/flow/__tests__/run-manager-product.test.js.map +1 -0
- package/dist/src/flow/__tests__/run-manager.test.js.map +1 -0
- package/dist/src/flow/__tests__/scaffold-checkpoint.test.js +93 -0
- package/dist/src/flow/__tests__/scaffold-checkpoint.test.js.map +1 -0
- package/dist/src/flow/__tests__/scaffold.test.js.map +1 -0
- package/dist/src/flow/__tests__/warning-persist.test.js.map +1 -0
- package/dist/src/flow/artifact-io.js.map +1 -0
- package/dist/src/flow/compaction/__tests__/compress.test.js.map +1 -0
- package/dist/src/flow/compaction/__tests__/extract.test.js.map +1 -0
- package/dist/src/flow/compaction/__tests__/preserve.test.js.map +1 -0
- package/dist/src/flow/compaction/compress.js.map +1 -0
- package/dist/src/flow/compaction/extract.js.map +1 -0
- package/dist/src/flow/compaction/index.js.map +1 -0
- package/dist/src/flow/compaction/preserve.js.map +1 -0
- package/dist/src/flow/index.js.map +1 -0
- package/dist/src/flow/migration.js.map +1 -0
- package/dist/src/flow/parser.js.map +1 -0
- package/dist/src/flow/run-manager.d.ts +38 -0
- package/dist/src/flow/run-manager.js +139 -0
- package/dist/src/flow/run-manager.js.map +1 -0
- package/dist/src/flow/scaffold-checkpoint.d.ts +63 -0
- package/dist/src/flow/scaffold-checkpoint.js +101 -0
- package/dist/src/flow/scaffold-checkpoint.js.map +1 -0
- package/dist/src/flow/scaffold.js.map +1 -0
- package/dist/src/flow/warning-persist.js.map +1 -0
- package/dist/src/generated/version.d.ts +2 -0
- package/dist/src/generated/version.js +5 -0
- package/dist/src/generated/version.js.map +1 -0
- package/dist/src/gsd/__tests__/complexity.test.js +0 -0
- package/dist/src/gsd/__tests__/complexity.test.js.map +1 -0
- package/dist/src/gsd/__tests__/directives.test.js +44 -0
- package/dist/src/gsd/__tests__/directives.test.js.map +1 -0
- package/dist/src/gsd/__tests__/gray-areas.test.js +29 -0
- package/dist/src/gsd/__tests__/gray-areas.test.js.map +1 -0
- package/dist/src/gsd/__tests__/types.test.js +65 -0
- package/dist/src/gsd/__tests__/types.test.js.map +1 -0
- package/dist/src/gsd/complexity.d.ts +28 -0
- package/dist/src/gsd/complexity.js +103 -0
- package/dist/src/gsd/complexity.js.map +1 -0
- package/dist/src/gsd/directives.d.ts +31 -0
- package/dist/src/gsd/directives.js +73 -0
- package/dist/src/gsd/directives.js.map +1 -0
- package/dist/src/gsd/gray-areas.d.ts +30 -0
- package/dist/src/gsd/gray-areas.js +97 -0
- package/dist/src/gsd/gray-areas.js.map +1 -0
- package/dist/src/gsd/index.js.map +1 -0
- package/dist/src/gsd/types.d.ts +5 -0
- package/dist/src/gsd/types.js.map +1 -0
- package/dist/src/headless/__tests__/council-answers.test.js +226 -0
- package/dist/src/headless/__tests__/council-answers.test.js.map +1 -0
- package/dist/src/headless/council-answers.d.ts +53 -0
- package/dist/src/headless/council-answers.js +77 -0
- package/dist/src/headless/council-answers.js.map +1 -0
- package/dist/src/headless/output.d.ts +68 -0
- package/dist/src/headless/output.js.map +1 -0
- package/dist/src/headless/output.test.js +178 -0
- package/dist/src/headless/output.test.js.map +1 -0
- package/dist/src/hooks/config.js.map +1 -0
- package/dist/src/hooks/index.d.ts +44 -0
- package/dist/src/hooks/index.js +471 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/types.d.ts +175 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +1347 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lsp/builtins.d.ts +9 -0
- package/dist/src/lsp/builtins.js +351 -0
- package/dist/src/lsp/builtins.js.map +1 -0
- package/dist/src/lsp/builtins.test.js +91 -0
- package/dist/src/lsp/builtins.test.js.map +1 -0
- package/dist/src/lsp/client.d.ts +20 -0
- package/dist/src/lsp/client.js +290 -0
- package/dist/src/lsp/client.js.map +1 -0
- package/dist/src/lsp/manager.d.ts +20 -0
- package/dist/src/lsp/manager.js +235 -0
- package/dist/src/lsp/manager.js.map +1 -0
- package/dist/src/lsp/manager.test.js +133 -0
- package/dist/src/lsp/manager.test.js.map +1 -0
- package/dist/src/lsp/npm-cache.js.map +1 -0
- package/dist/src/lsp/npm-cache.test.js +53 -0
- package/dist/src/lsp/npm-cache.test.js.map +1 -0
- package/dist/src/lsp/runtime.d.ts +6 -0
- package/dist/src/lsp/runtime.js +53 -0
- package/dist/src/lsp/runtime.js.map +1 -0
- package/dist/src/lsp/smoke.test.js.map +1 -0
- package/dist/src/lsp/types.js.map +1 -0
- package/dist/src/mcp/__tests__/auto-setup.test.js +81 -0
- package/dist/src/mcp/__tests__/auto-setup.test.js.map +1 -0
- package/dist/src/mcp/__tests__/harness-driver-action-tools.spec.js +101 -0
- package/dist/src/mcp/__tests__/harness-driver-action-tools.spec.js.map +1 -0
- package/dist/src/mcp/__tests__/harness-driver-async-tools.spec.js +110 -0
- package/dist/src/mcp/__tests__/harness-driver-async-tools.spec.js.map +1 -0
- package/dist/src/mcp/__tests__/harness-driver-read-tools.spec.js +124 -0
- package/dist/src/mcp/__tests__/harness-driver-read-tools.spec.js.map +1 -0
- package/dist/src/mcp/__tests__/harness-driver-security.spec.js +61 -0
- package/dist/src/mcp/__tests__/harness-driver-security.spec.js.map +1 -0
- package/dist/src/mcp/__tests__/harness-driver.spec.js +20 -0
- package/dist/src/mcp/__tests__/harness-driver.spec.js.map +1 -0
- package/dist/src/mcp/__tests__/lazy-schema.spec.js +152 -0
- package/dist/src/mcp/__tests__/lazy-schema.spec.js.map +1 -0
- package/dist/src/mcp/__tests__/mcp-keychain.test.js +40 -0
- package/dist/src/mcp/__tests__/mcp-keychain.test.js.map +1 -0
- package/dist/src/mcp/__tests__/research-onboarding.test.js +148 -0
- package/dist/src/mcp/__tests__/research-onboarding.test.js.map +1 -0
- package/dist/src/mcp/__tests__/runtime-hydration.test.js +78 -0
- package/dist/src/mcp/__tests__/runtime-hydration.test.js.map +1 -0
- package/dist/src/mcp/__tests__/runtime-sanitize.test.js +40 -0
- package/dist/src/mcp/__tests__/runtime-sanitize.test.js.map +1 -0
- package/dist/src/mcp/auto-setup.js +98 -0
- package/dist/src/mcp/auto-setup.js.map +1 -0
- package/dist/src/mcp/catalog.js +145 -0
- package/dist/src/mcp/catalog.js.map +1 -0
- package/dist/src/mcp/mcp-keychain.d.ts +13 -0
- package/dist/src/mcp/mcp-keychain.js +65 -0
- package/dist/src/mcp/mcp-keychain.js.map +1 -0
- package/dist/src/mcp/oauth-callback.d.ts +16 -0
- package/dist/src/mcp/oauth-callback.js +52 -0
- package/dist/src/mcp/oauth-callback.js.map +1 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/opentui-spawn.d.ts +11 -0
- package/dist/src/mcp/opentui-spawn.js +58 -0
- package/dist/src/mcp/opentui-spawn.js.map +1 -0
- package/dist/src/mcp/parse-headers.js.map +1 -0
- package/dist/src/mcp/parse-headers.test.js +43 -0
- package/dist/src/mcp/parse-headers.test.js.map +1 -0
- package/dist/src/mcp/research-onboarding.d.ts +20 -0
- package/dist/src/mcp/research-onboarding.js +123 -0
- package/dist/src/mcp/research-onboarding.js.map +1 -0
- package/dist/src/mcp/runtime.js +148 -0
- package/dist/src/mcp/runtime.js.map +1 -0
- package/dist/src/mcp/smoke.test.js.map +1 -0
- package/dist/src/mcp/validate.d.ts +9 -0
- package/dist/src/mcp/validate.js.map +1 -0
- package/dist/src/models/__tests__/registry.test.js +74 -0
- package/dist/src/models/__tests__/registry.test.js.map +1 -0
- package/dist/src/models/catalog-client.js +104 -0
- package/dist/src/models/catalog-client.js.map +1 -0
- package/dist/src/models/catalog.json +177 -0
- package/dist/src/models/classify-tier.js +45 -0
- package/dist/src/models/classify-tier.js.map +1 -0
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/models/index.js +2 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/models/registry.d.ts +20 -0
- package/dist/src/models/registry.js +68 -0
- package/dist/src/models/registry.js.map +1 -0
- package/dist/src/ops/__tests__/doctor-council-mcp.test.js +139 -0
- package/dist/src/ops/__tests__/doctor-council-mcp.test.js.map +1 -0
- package/dist/src/ops/__tests__/doctor-ee-health.test.js +113 -0
- package/dist/src/ops/__tests__/doctor-ee-health.test.js.map +1 -0
- package/dist/src/ops/bug-report.js.map +1 -0
- package/dist/src/ops/bug-report.test.js.map +1 -0
- package/dist/src/ops/doctor.js +333 -0
- package/dist/src/ops/doctor.js.map +1 -0
- package/dist/src/ops/doctor.test.js +96 -0
- package/dist/src/ops/doctor.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/batch-turn-runner.test.js +154 -0
- package/dist/src/orchestrator/__tests__/batch-turn-runner.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/council-manager.test.js +148 -0
- package/dist/src/orchestrator/__tests__/council-manager.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/cross-turn-dedup.test.js +153 -0
- package/dist/src/orchestrator/__tests__/cross-turn-dedup.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/current-call-id.test.d.ts +16 -0
- package/dist/src/orchestrator/__tests__/current-call-id.test.js +138 -0
- package/dist/src/orchestrator/__tests__/current-call-id.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/flow-resume.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/message-processor.test.js +182 -0
- package/dist/src/orchestrator/__tests__/message-processor.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/message-write-ahead.test.d.ts +22 -0
- package/dist/src/orchestrator/__tests__/message-write-ahead.test.js +149 -0
- package/dist/src/orchestrator/__tests__/message-write-ahead.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/read-path-budget.test.js +98 -0
- package/dist/src/orchestrator/__tests__/read-path-budget.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/retry-classifier.test.js +102 -0
- package/dist/src/orchestrator/__tests__/retry-classifier.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/retry-stream.test.js +151 -0
- package/dist/src/orchestrator/__tests__/retry-stream.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/route-feedback.test.js +47 -0
- package/dist/src/orchestrator/__tests__/route-feedback.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/stream-runner.test.js +100 -0
- package/dist/src/orchestrator/__tests__/stream-runner.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/usage-events-shape.test.d.ts +8 -0
- package/dist/src/orchestrator/__tests__/usage-events-shape.test.js +58 -0
- package/dist/src/orchestrator/__tests__/usage-events-shape.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/usage-normalizer-c1.test.d.ts +21 -0
- package/dist/src/orchestrator/__tests__/usage-normalizer-c1.test.js +155 -0
- package/dist/src/orchestrator/__tests__/usage-normalizer-c1.test.js.map +1 -0
- package/dist/src/orchestrator/__tests__/write-ahead.test.d.ts +20 -0
- package/dist/src/orchestrator/__tests__/write-ahead.test.js +134 -0
- package/dist/src/orchestrator/__tests__/write-ahead.test.js.map +1 -0
- package/dist/src/orchestrator/abort.js.map +1 -0
- package/dist/src/orchestrator/abort.test.js.map +1 -0
- package/dist/src/orchestrator/agent-options.d.ts +144 -0
- package/dist/src/orchestrator/agent-options.js +15 -0
- package/dist/src/orchestrator/agent-options.js.map +1 -0
- package/dist/src/orchestrator/agent.test.js +160 -0
- package/dist/src/orchestrator/agent.test.js.map +1 -0
- package/dist/src/orchestrator/batch-turn-runner.d.ts +57 -0
- package/dist/src/orchestrator/batch-turn-runner.js +312 -0
- package/dist/src/orchestrator/batch-turn-runner.js.map +1 -0
- package/dist/src/orchestrator/batch-utils.d.ts +41 -0
- package/dist/src/orchestrator/batch-utils.js +268 -0
- package/dist/src/orchestrator/batch-utils.js.map +1 -0
- package/dist/src/orchestrator/cleanup.test.d.ts +1 -0
- package/dist/src/orchestrator/cleanup.test.js +67 -0
- package/dist/src/orchestrator/cleanup.test.js.map +1 -0
- package/dist/src/orchestrator/compaction.d.ts +47 -0
- package/dist/src/orchestrator/compaction.js +491 -0
- package/dist/src/orchestrator/compaction.js.map +1 -0
- package/dist/src/orchestrator/compaction.test.d.ts +1 -0
- package/dist/src/orchestrator/compaction.test.js +146 -0
- package/dist/src/orchestrator/compaction.test.js.map +1 -0
- package/dist/src/orchestrator/council-manager.d.ts +109 -0
- package/dist/src/orchestrator/council-manager.js +480 -0
- package/dist/src/orchestrator/council-manager.js.map +1 -0
- package/dist/src/orchestrator/cross-turn-dedup.d.ts +87 -0
- package/dist/src/orchestrator/cross-turn-dedup.js +153 -0
- package/dist/src/orchestrator/cross-turn-dedup.js.map +1 -0
- package/dist/src/orchestrator/delegations.d.ts +49 -0
- package/dist/src/orchestrator/delegations.js.map +1 -0
- package/dist/src/orchestrator/delegations.test.d.ts +1 -0
- package/dist/src/orchestrator/delegations.test.js +107 -0
- package/dist/src/orchestrator/delegations.test.js.map +1 -0
- package/dist/src/orchestrator/error-utils.d.ts +7 -0
- package/dist/src/orchestrator/error-utils.js +66 -0
- package/dist/src/orchestrator/error-utils.js.map +1 -0
- package/dist/src/orchestrator/flow-resume.d.ts +24 -0
- package/dist/src/orchestrator/flow-resume.js +52 -0
- package/dist/src/orchestrator/flow-resume.js.map +1 -0
- package/dist/src/orchestrator/message-processor.d.ts +132 -0
- package/dist/src/orchestrator/message-processor.js +1675 -0
- package/dist/src/orchestrator/message-processor.js.map +1 -0
- package/dist/src/orchestrator/message-seq.d.ts +13 -0
- package/dist/src/orchestrator/message-seq.js +21 -0
- package/dist/src/orchestrator/message-seq.js.map +1 -0
- package/dist/src/orchestrator/message-seq.test.d.ts +1 -0
- package/dist/src/orchestrator/message-seq.test.js +24 -0
- package/dist/src/orchestrator/message-seq.test.js.map +1 -0
- package/dist/src/orchestrator/orchestrator.d.ts +245 -0
- package/dist/src/orchestrator/orchestrator.js +2173 -0
- package/dist/src/orchestrator/orchestrator.js.map +1 -0
- package/dist/src/orchestrator/pending-calls.js.map +1 -0
- package/dist/src/orchestrator/pending-calls.test.d.ts +1 -0
- package/dist/src/orchestrator/pending-calls.test.js.map +1 -0
- package/dist/src/orchestrator/prompts.d.ts +31 -0
- package/dist/src/orchestrator/prompts.js +387 -0
- package/dist/src/orchestrator/prompts.js.map +1 -0
- package/dist/src/orchestrator/provider-options-shape.d.ts +23 -0
- package/dist/src/orchestrator/provider-options-shape.js +68 -0
- package/dist/src/orchestrator/provider-options-shape.js.map +1 -0
- package/dist/src/orchestrator/provider-options-shape.spec.d.ts +1 -0
- package/dist/src/orchestrator/provider-options-shape.spec.js +63 -0
- package/dist/src/orchestrator/provider-options-shape.spec.js.map +1 -0
- package/dist/src/orchestrator/read-path-budget.d.ts +57 -0
- package/dist/src/orchestrator/read-path-budget.js +103 -0
- package/dist/src/orchestrator/read-path-budget.js.map +1 -0
- package/dist/src/orchestrator/reasoning.js +57 -0
- package/dist/src/orchestrator/reasoning.js.map +1 -0
- package/dist/src/orchestrator/reasoning.test.d.ts +1 -0
- package/dist/src/orchestrator/reasoning.test.js +26 -0
- package/dist/src/orchestrator/reasoning.test.js.map +1 -0
- package/dist/src/orchestrator/retry-classifier.d.ts +26 -0
- package/dist/src/orchestrator/retry-classifier.js +103 -0
- package/dist/src/orchestrator/retry-classifier.js.map +1 -0
- package/dist/src/orchestrator/retry-stream.d.ts +43 -0
- package/dist/src/orchestrator/retry-stream.js +110 -0
- package/dist/src/orchestrator/retry-stream.js.map +1 -0
- package/dist/src/orchestrator/sandbox.test.d.ts +1 -0
- package/dist/src/orchestrator/sandbox.test.js +94 -0
- package/dist/src/orchestrator/sandbox.test.js.map +1 -0
- package/dist/src/orchestrator/stream-runner.d.ts +131 -0
- package/dist/src/orchestrator/stream-runner.js +549 -0
- package/dist/src/orchestrator/stream-runner.js.map +1 -0
- package/dist/src/orchestrator/sub-agent-cap.d.ts +98 -0
- package/dist/src/orchestrator/sub-agent-cap.js +146 -0
- package/dist/src/orchestrator/sub-agent-cap.js.map +1 -0
- package/dist/src/orchestrator/sub-agent-cap.test.d.ts +1 -0
- package/dist/src/orchestrator/sub-agent-cap.test.js +170 -0
- package/dist/src/orchestrator/sub-agent-cap.test.js.map +1 -0
- package/dist/src/orchestrator/subagent-compactor.d.ts +74 -0
- package/dist/src/orchestrator/subagent-compactor.js +218 -0
- package/dist/src/orchestrator/subagent-compactor.js.map +1 -0
- package/dist/src/orchestrator/subagent-compactor.spec.d.ts +1 -0
- package/dist/src/orchestrator/subagent-compactor.spec.js +131 -0
- package/dist/src/orchestrator/subagent-compactor.spec.js.map +1 -0
- package/dist/src/orchestrator/token-counter.d.ts +27 -0
- package/dist/src/orchestrator/token-counter.js +76 -0
- package/dist/src/orchestrator/token-counter.js.map +1 -0
- package/dist/src/orchestrator/token-counter.test.d.ts +1 -0
- package/dist/src/orchestrator/token-counter.test.js +57 -0
- package/dist/src/orchestrator/token-counter.test.js.map +1 -0
- package/dist/src/orchestrator/tool-utils.d.ts +38 -0
- package/dist/src/orchestrator/tool-utils.js +201 -0
- package/dist/src/orchestrator/tool-utils.js.map +1 -0
- package/dist/src/orchestrator/turn-runner-deps.d.ts +47 -0
- package/dist/src/orchestrator/turn-runner-deps.js +14 -0
- package/dist/src/orchestrator/turn-runner-deps.js.map +1 -0
- package/dist/src/pil/__tests__/budget.test.d.ts +1 -0
- package/dist/src/pil/__tests__/budget.test.js +33 -0
- package/dist/src/pil/__tests__/budget.test.js.map +1 -0
- package/dist/src/pil/__tests__/config.test.d.ts +1 -0
- package/dist/src/pil/__tests__/config.test.js +30 -0
- package/dist/src/pil/__tests__/config.test.js.map +1 -0
- package/dist/src/pil/__tests__/dual-run.test.d.ts +1 -0
- package/dist/src/pil/__tests__/dual-run.test.js +49 -0
- package/dist/src/pil/__tests__/dual-run.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer1-intent-trace.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer1-intent-trace.test.js +128 -0
- package/dist/src/pil/__tests__/layer1-intent-trace.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer1-intent.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer1-intent.test.js +305 -0
- package/dist/src/pil/__tests__/layer1-intent.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer2-personality.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer2-personality.test.js +57 -0
- package/dist/src/pil/__tests__/layer2-personality.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer3-ee-injection.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer3-ee-injection.test.js +153 -0
- package/dist/src/pil/__tests__/layer3-ee-injection.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer3-injected-chunk.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer3-injected-chunk.test.js +91 -0
- package/dist/src/pil/__tests__/layer3-injected-chunk.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer4-gsd.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer4-gsd.test.js +97 -0
- package/dist/src/pil/__tests__/layer4-gsd.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer5-context.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer5-context.test.js +137 -0
- package/dist/src/pil/__tests__/layer5-context.test.js.map +1 -0
- package/dist/src/pil/__tests__/layer6-output.test.d.ts +1 -0
- package/dist/src/pil/__tests__/layer6-output.test.js +237 -0
- package/dist/src/pil/__tests__/layer6-output.test.js.map +1 -0
- package/dist/src/pil/__tests__/ollama-classify.test.d.ts +1 -0
- package/dist/src/pil/__tests__/ollama-classify.test.js.map +1 -0
- package/dist/src/pil/__tests__/orchestrator-integration.test.js.map +1 -0
- package/dist/src/pil/__tests__/pipeline.test.d.ts +1 -0
- package/dist/src/pil/__tests__/pipeline.test.js +167 -0
- package/dist/src/pil/__tests__/pipeline.test.js.map +1 -0
- package/dist/src/pil/__tests__/renderer-coverage.test.d.ts +7 -0
- package/dist/src/pil/__tests__/renderer-coverage.test.js +42 -0
- package/dist/src/pil/__tests__/renderer-coverage.test.js.map +1 -0
- package/dist/src/pil/__tests__/response-tools.test.d.ts +1 -0
- package/dist/src/pil/__tests__/response-tools.test.js +142 -0
- package/dist/src/pil/__tests__/response-tools.test.js.map +1 -0
- package/dist/src/pil/__tests__/schema.test.d.ts +1 -0
- package/dist/src/pil/__tests__/schema.test.js +202 -0
- package/dist/src/pil/__tests__/schema.test.js.map +1 -0
- package/dist/src/pil/__tests__/scoreComplexity.test.d.ts +1 -0
- package/dist/src/pil/__tests__/scoreComplexity.test.js +119 -0
- package/dist/src/pil/__tests__/scoreComplexity.test.js.map +1 -0
- package/dist/src/pil/__tests__/scoreSufficiency.test.d.ts +8 -0
- package/dist/src/pil/__tests__/scoreSufficiency.test.js +89 -0
- package/dist/src/pil/__tests__/scoreSufficiency.test.js.map +1 -0
- package/dist/src/pil/__tests__/store.test.d.ts +1 -0
- package/dist/src/pil/__tests__/store.test.js.map +1 -0
- package/dist/src/pil/__tests__/task-tier-map.test.d.ts +1 -0
- package/dist/src/pil/__tests__/task-tier-map.test.js.map +1 -0
- package/dist/src/pil/budget-log.d.ts +26 -0
- package/dist/src/pil/budget-log.js +59 -0
- package/dist/src/pil/budget-log.js.map +1 -0
- package/dist/src/pil/budget.js.map +1 -0
- package/dist/src/pil/config.d.ts +7 -0
- package/dist/src/pil/config.js +14 -0
- package/dist/src/pil/config.js.map +1 -0
- package/dist/src/pil/index.d.ts +11 -0
- package/dist/src/pil/index.js +11 -0
- package/dist/src/pil/index.js.map +1 -0
- package/dist/src/pil/layer1-intent.d.ts +49 -0
- package/dist/src/pil/layer1-intent.js +514 -0
- package/dist/src/pil/layer1-intent.js.map +1 -0
- package/dist/src/pil/layer1-intent.test.d.ts +1 -0
- package/dist/src/pil/layer1-intent.test.js +98 -0
- package/dist/src/pil/layer1-intent.test.js.map +1 -0
- package/dist/src/pil/layer2-personality.js +37 -0
- package/dist/src/pil/layer2-personality.js.map +1 -0
- package/dist/src/pil/layer3-ee-injection.d.ts +18 -0
- package/dist/src/pil/layer3-ee-injection.js +305 -0
- package/dist/src/pil/layer3-ee-injection.js.map +1 -0
- package/dist/src/pil/layer4-gsd.d.ts +20 -0
- package/dist/src/pil/layer4-gsd.js +108 -0
- package/dist/src/pil/layer4-gsd.js.map +1 -0
- package/dist/src/pil/layer5-context.js +151 -0
- package/dist/src/pil/layer5-context.js.map +1 -0
- package/dist/src/pil/layer6-output.d.ts +20 -0
- package/dist/src/pil/layer6-output.js +237 -0
- package/dist/src/pil/layer6-output.js.map +1 -0
- package/dist/src/pil/ollama-classify.js.map +1 -0
- package/dist/src/pil/pipeline.d.ts +23 -0
- package/dist/src/pil/pipeline.js +182 -0
- package/dist/src/pil/pipeline.js.map +1 -0
- package/dist/src/pil/response-tools.d.ts +63 -0
- package/dist/src/pil/response-tools.js +87 -0
- package/dist/src/pil/response-tools.js.map +1 -0
- package/dist/src/pil/schema.d.ts +160 -0
- package/dist/src/pil/schema.js +88 -0
- package/dist/src/pil/schema.js.map +1 -0
- package/dist/src/pil/store.js.map +1 -0
- package/dist/src/pil/task-tier-map.js.map +1 -0
- package/dist/src/pil/timeout.js.map +1 -0
- package/dist/src/pil/types.d.ts +149 -0
- package/dist/src/pil/types.js.map +1 -0
- package/dist/src/product-loop/__tests__/artifact-io.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/artifact-io.test.js +83 -0
- package/dist/src/product-loop/__tests__/artifact-io.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/assumption-ledger.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/assumption-ledger.test.js +261 -0
- package/dist/src/product-loop/__tests__/assumption-ledger.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/cb2-retry-bonus.test.d.ts +13 -0
- package/dist/src/product-loop/__tests__/cb2-retry-bonus.test.js +158 -0
- package/dist/src/product-loop/__tests__/cb2-retry-bonus.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/circuit-breakers-coverage.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/circuit-breakers-coverage.test.js +67 -0
- package/dist/src/product-loop/__tests__/circuit-breakers-coverage.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/circuit-breakers.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/circuit-breakers.test.js +79 -0
- package/dist/src/product-loop/__tests__/circuit-breakers.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/complexity-routing.spec.d.ts +11 -0
- package/dist/src/product-loop/__tests__/complexity-routing.spec.js +134 -0
- package/dist/src/product-loop/__tests__/complexity-routing.spec.js.map +1 -0
- package/dist/src/product-loop/__tests__/context-policy.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/context-policy.test.js +266 -0
- package/dist/src/product-loop/__tests__/context-policy.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/cost-preview.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/cost-preview.test.js +111 -0
- package/dist/src/product-loop/__tests__/cost-preview.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/cost-scoper.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/cost-scoper.test.js +50 -0
- package/dist/src/product-loop/__tests__/cost-scoper.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/cross-run-memory.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/cross-run-memory.test.js +168 -0
- package/dist/src/product-loop/__tests__/cross-run-memory.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/design-output.spec.d.ts +1 -0
- package/dist/src/product-loop/__tests__/design-output.spec.js +36 -0
- package/dist/src/product-loop/__tests__/design-output.spec.js.map +1 -0
- package/dist/src/product-loop/__tests__/discover.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discover.test.js +83 -0
- package/dist/src/product-loop/__tests__/discover.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-council-runner.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-council-runner.test.js +13 -0
- package/dist/src/product-loop/__tests__/discovery-council-runner.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-detection.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-detection.test.js +151 -0
- package/dist/src/product-loop/__tests__/discovery-detection.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-ecosystem.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/discovery-ecosystem.test.js +110 -0
- package/dist/src/product-loop/__tests__/discovery-ecosystem.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-integration.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-integration.test.js +126 -0
- package/dist/src/product-loop/__tests__/discovery-integration.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-interview.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-interview.test.js +292 -0
- package/dist/src/product-loop/__tests__/discovery-interview.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-migrations.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-migrations.test.js +69 -0
- package/dist/src/product-loop/__tests__/discovery-migrations.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-persistence.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-persistence.test.js +146 -0
- package/dist/src/product-loop/__tests__/discovery-persistence.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-prompt-parser.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-prompt-parser.test.js +65 -0
- package/dist/src/product-loop/__tests__/discovery-prompt-parser.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-recommender-ecosystem.test.d.ts +9 -0
- package/dist/src/product-loop/__tests__/discovery-recommender-ecosystem.test.js +86 -0
- package/dist/src/product-loop/__tests__/discovery-recommender-ecosystem.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-recommender.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-recommender.test.js +316 -0
- package/dist/src/product-loop/__tests__/discovery-recommender.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/discovery-schema.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/discovery-schema.test.js +77 -0
- package/dist/src/product-loop/__tests__/discovery-schema.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/done-gate-coverage.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/done-gate-coverage.test.js +135 -0
- package/dist/src/product-loop/__tests__/done-gate-coverage.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/done-gate.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/done-gate.test.js +122 -0
- package/dist/src/product-loop/__tests__/done-gate.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/ee-extract-wiring.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/ee-extract-wiring.test.js +181 -0
- package/dist/src/product-loop/__tests__/ee-extract-wiring.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/extract-to-ee.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/extract-to-ee.test.js +161 -0
- package/dist/src/product-loop/__tests__/extract-to-ee.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/feedback-routing.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/feedback-routing.test.js +83 -0
- package/dist/src/product-loop/__tests__/feedback-routing.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/hot-path.spec.d.ts +11 -0
- package/dist/src/product-loop/__tests__/hot-path.spec.js +146 -0
- package/dist/src/product-loop/__tests__/hot-path.spec.js.map +1 -0
- package/dist/src/product-loop/__tests__/integration.test.d.ts +7 -0
- package/dist/src/product-loop/__tests__/integration.test.js +296 -0
- package/dist/src/product-loop/__tests__/integration.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/loop-driver-audit.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/loop-driver-audit.test.js +264 -0
- package/dist/src/product-loop/__tests__/loop-driver-audit.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/loop-driver.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/loop-driver.test.js +220 -0
- package/dist/src/product-loop/__tests__/loop-driver.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/phase-budget.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/phase-budget.test.js +149 -0
- package/dist/src/product-loop/__tests__/phase-budget.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/phase-orchestrator-integration.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/phase-orchestrator-integration.test.js +138 -0
- package/dist/src/product-loop/__tests__/phase-orchestrator-integration.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/phase-plan.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/phase-plan.test.js +208 -0
- package/dist/src/product-loop/__tests__/phase-plan.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/phase-rituals.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/phase-rituals.test.js +174 -0
- package/dist/src/product-loop/__tests__/phase-rituals.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/phase-runner.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/phase-runner.test.js +414 -0
- package/dist/src/product-loop/__tests__/phase-runner.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/phase-tracker-bridge.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/phase-tracker-bridge.test.js +67 -0
- package/dist/src/product-loop/__tests__/phase-tracker-bridge.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/product-identity.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/product-identity.test.js +40 -0
- package/dist/src/product-loop/__tests__/product-identity.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/reality-anchor.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/reality-anchor.test.js +49 -0
- package/dist/src/product-loop/__tests__/reality-anchor.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/repo-audit.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/repo-audit.test.js +97 -0
- package/dist/src/product-loop/__tests__/repo-audit.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/role-memory.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/role-memory.test.js +56 -0
- package/dist/src/product-loop/__tests__/role-memory.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/role-registry.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/role-registry.test.js +222 -0
- package/dist/src/product-loop/__tests__/role-registry.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/role-routing-ee.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/role-routing-ee.test.js +79 -0
- package/dist/src/product-loop/__tests__/role-routing-ee.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/route-decision-emit.test.d.ts +10 -0
- package/dist/src/product-loop/__tests__/route-decision-emit.test.js +173 -0
- package/dist/src/product-loop/__tests__/route-decision-emit.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/seed-questions.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/seed-questions.test.js +30 -0
- package/dist/src/product-loop/__tests__/seed-questions.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/ship-polish.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/ship-polish.test.js +96 -0
- package/dist/src/product-loop/__tests__/ship-polish.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/sprint-runner-emit.test.d.ts +14 -0
- package/dist/src/product-loop/__tests__/sprint-runner-emit.test.js +279 -0
- package/dist/src/product-loop/__tests__/sprint-runner-emit.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/sprint-runner.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/sprint-runner.test.js +432 -0
- package/dist/src/product-loop/__tests__/sprint-runner.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/stakeholder-acl.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/stakeholder-acl.test.js +83 -0
- package/dist/src/product-loop/__tests__/stakeholder-acl.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/state-md-ee-injections.test.d.ts +8 -0
- package/dist/src/product-loop/__tests__/state-md-ee-injections.test.js +182 -0
- package/dist/src/product-loop/__tests__/state-md-ee-injections.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/sufficiency-routing.spec.d.ts +12 -0
- package/dist/src/product-loop/__tests__/sufficiency-routing.spec.js +134 -0
- package/dist/src/product-loop/__tests__/sufficiency-routing.spec.js.map +1 -0
- package/dist/src/product-loop/__tests__/typed-artifacts.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/typed-artifacts.test.js +222 -0
- package/dist/src/product-loop/__tests__/typed-artifacts.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/types.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/types.test.js +79 -0
- package/dist/src/product-loop/__tests__/types.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/verify-failure-threshold.test.d.ts +9 -0
- package/dist/src/product-loop/__tests__/verify-failure-threshold.test.js +145 -0
- package/dist/src/product-loop/__tests__/verify-failure-threshold.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/verify-failure-tracking.test.d.ts +4 -0
- package/dist/src/product-loop/__tests__/verify-failure-tracking.test.js +122 -0
- package/dist/src/product-loop/__tests__/verify-failure-tracking.test.js.map +1 -0
- package/dist/src/product-loop/__tests__/verify-result.test.d.ts +1 -0
- package/dist/src/product-loop/__tests__/verify-result.test.js +53 -0
- package/dist/src/product-loop/__tests__/verify-result.test.js.map +1 -0
- package/dist/src/product-loop/artifact-io.d.ts +41 -0
- package/dist/src/product-loop/artifact-io.js +223 -0
- package/dist/src/product-loop/artifact-io.js.map +1 -0
- package/dist/src/product-loop/assumption-ledger.d.ts +101 -0
- package/dist/src/product-loop/assumption-ledger.js +190 -0
- package/dist/src/product-loop/assumption-ledger.js.map +1 -0
- package/dist/src/product-loop/circuit-breakers.d.ts +34 -0
- package/dist/src/product-loop/circuit-breakers.js +54 -0
- package/dist/src/product-loop/circuit-breakers.js.map +1 -0
- package/dist/src/product-loop/context-policy.d.ts +29 -0
- package/dist/src/product-loop/context-policy.js +141 -0
- package/dist/src/product-loop/context-policy.js.map +1 -0
- package/dist/src/product-loop/cost-preview.d.ts +46 -0
- package/dist/src/product-loop/cost-preview.js +75 -0
- package/dist/src/product-loop/cost-preview.js.map +1 -0
- package/dist/src/product-loop/cost-scoper.d.ts +21 -0
- package/dist/src/product-loop/cost-scoper.js +33 -0
- package/dist/src/product-loop/cost-scoper.js.map +1 -0
- package/dist/src/product-loop/cross-run-memory.d.ts +73 -0
- package/dist/src/product-loop/cross-run-memory.js +390 -0
- package/dist/src/product-loop/cross-run-memory.js.map +1 -0
- package/dist/src/product-loop/design-output.d.ts +4 -0
- package/dist/src/product-loop/design-output.js +21 -0
- package/dist/src/product-loop/design-output.js.map +1 -0
- package/dist/src/product-loop/discover.d.ts +25 -0
- package/dist/src/product-loop/discover.js +113 -0
- package/dist/src/product-loop/discover.js.map +1 -0
- package/dist/src/product-loop/discovery-context-format.d.ts +2 -0
- package/dist/src/product-loop/discovery-context-format.js +22 -0
- package/dist/src/product-loop/discovery-context-format.js.map +1 -0
- package/dist/src/product-loop/discovery-council-runner.d.ts +25 -0
- package/dist/src/product-loop/discovery-council-runner.js +66 -0
- package/dist/src/product-loop/discovery-council-runner.js.map +1 -0
- package/dist/src/product-loop/discovery-detection.d.ts +2 -0
- package/dist/src/product-loop/discovery-detection.js +163 -0
- package/dist/src/product-loop/discovery-detection.js.map +1 -0
- package/dist/src/product-loop/discovery-ecosystem.d.ts +57 -0
- package/dist/src/product-loop/discovery-ecosystem.js +106 -0
- package/dist/src/product-loop/discovery-ecosystem.js.map +1 -0
- package/dist/src/product-loop/discovery-interview.d.ts +40 -0
- package/dist/src/product-loop/discovery-interview.js +176 -0
- package/dist/src/product-loop/discovery-interview.js.map +1 -0
- package/dist/src/product-loop/discovery-migrations.d.ts +5 -0
- package/dist/src/product-loop/discovery-migrations.js +39 -0
- package/dist/src/product-loop/discovery-migrations.js.map +1 -0
- package/dist/src/product-loop/discovery-persistence.d.ts +19 -0
- package/dist/src/product-loop/discovery-persistence.js +182 -0
- package/dist/src/product-loop/discovery-persistence.js.map +1 -0
- package/dist/src/product-loop/discovery-prompt-parser.d.ts +15 -0
- package/dist/src/product-loop/discovery-prompt-parser.js +64 -0
- package/dist/src/product-loop/discovery-prompt-parser.js.map +1 -0
- package/dist/src/product-loop/discovery-recommender.d.ts +50 -0
- package/dist/src/product-loop/discovery-recommender.js +288 -0
- package/dist/src/product-loop/discovery-recommender.js.map +1 -0
- package/dist/src/product-loop/discovery-schema.d.ts +33 -0
- package/dist/src/product-loop/discovery-schema.js +120 -0
- package/dist/src/product-loop/discovery-schema.js.map +1 -0
- package/dist/src/product-loop/done-gate.d.ts +6 -0
- package/dist/src/product-loop/done-gate.js +196 -0
- package/dist/src/product-loop/done-gate.js.map +1 -0
- package/dist/src/product-loop/feedback-routing.d.ts +27 -0
- package/dist/src/product-loop/feedback-routing.js +64 -0
- package/dist/src/product-loop/feedback-routing.js.map +1 -0
- package/dist/src/product-loop/gather.d.ts +17 -0
- package/dist/src/product-loop/gather.js +253 -0
- package/dist/src/product-loop/gather.js.map +1 -0
- package/dist/src/product-loop/index.d.ts +74 -0
- package/dist/src/product-loop/index.js +1154 -0
- package/dist/src/product-loop/index.js.map +1 -0
- package/dist/src/product-loop/loop-driver.d.ts +4 -0
- package/dist/src/product-loop/loop-driver.js +824 -0
- package/dist/src/product-loop/loop-driver.js.map +1 -0
- package/dist/src/product-loop/phase-budget.d.ts +65 -0
- package/dist/src/product-loop/phase-budget.js +114 -0
- package/dist/src/product-loop/phase-budget.js.map +1 -0
- package/dist/src/product-loop/phase-plan.d.ts +21 -0
- package/dist/src/product-loop/phase-plan.js +140 -0
- package/dist/src/product-loop/phase-plan.js.map +1 -0
- package/dist/src/product-loop/phase-rituals.d.ts +38 -0
- package/dist/src/product-loop/phase-rituals.js +106 -0
- package/dist/src/product-loop/phase-rituals.js.map +1 -0
- package/dist/src/product-loop/phase-runner.d.ts +28 -0
- package/dist/src/product-loop/phase-runner.js +383 -0
- package/dist/src/product-loop/phase-runner.js.map +1 -0
- package/dist/src/product-loop/phase-tracker-bridge.d.ts +27 -0
- package/dist/src/product-loop/phase-tracker-bridge.js +37 -0
- package/dist/src/product-loop/phase-tracker-bridge.js.map +1 -0
- package/dist/src/product-loop/product-identity.d.ts +1 -0
- package/dist/src/product-loop/product-identity.js +10 -0
- package/dist/src/product-loop/product-identity.js.map +1 -0
- package/dist/src/product-loop/reality-anchor.d.ts +19 -0
- package/dist/src/product-loop/reality-anchor.js +39 -0
- package/dist/src/product-loop/reality-anchor.js.map +1 -0
- package/dist/src/product-loop/repo-audit.d.ts +46 -0
- package/dist/src/product-loop/repo-audit.js +300 -0
- package/dist/src/product-loop/repo-audit.js.map +1 -0
- package/dist/src/product-loop/role-memory.d.ts +13 -0
- package/dist/src/product-loop/role-memory.js +63 -0
- package/dist/src/product-loop/role-memory.js.map +1 -0
- package/dist/src/product-loop/role-registry.d.ts +22 -0
- package/dist/src/product-loop/role-registry.js +146 -0
- package/dist/src/product-loop/role-registry.js.map +1 -0
- package/dist/src/product-loop/seed-questions.d.ts +7 -0
- package/dist/src/product-loop/seed-questions.js +50 -0
- package/dist/src/product-loop/seed-questions.js.map +1 -0
- package/dist/src/product-loop/ship-polish.d.ts +29 -0
- package/dist/src/product-loop/ship-polish.js +134 -0
- package/dist/src/product-loop/ship-polish.js.map +1 -0
- package/dist/src/product-loop/sprint-runner.d.ts +63 -0
- package/dist/src/product-loop/sprint-runner.js +515 -0
- package/dist/src/product-loop/sprint-runner.js.map +1 -0
- package/dist/src/product-loop/stakeholder-acl.d.ts +16 -0
- package/dist/src/product-loop/stakeholder-acl.js +66 -0
- package/dist/src/product-loop/stakeholder-acl.js.map +1 -0
- package/dist/src/product-loop/typed-artifacts.d.ts +77 -0
- package/dist/src/product-loop/typed-artifacts.js +262 -0
- package/dist/src/product-loop/typed-artifacts.js.map +1 -0
- package/dist/src/product-loop/types.d.ts +395 -0
- package/dist/src/product-loop/types.js +2 -0
- package/dist/src/product-loop/types.js.map +1 -0
- package/dist/src/product-loop/verify-failure-tracking.d.ts +76 -0
- package/dist/src/product-loop/verify-failure-tracking.js +172 -0
- package/dist/src/product-loop/verify-failure-tracking.js.map +1 -0
- package/dist/src/product-loop/verify-result.d.ts +18 -0
- package/dist/src/product-loop/verify-result.js +31 -0
- package/dist/src/product-loop/verify-result.js.map +1 -0
- package/dist/src/providers/__test-utils__/load-fixture.js.map +1 -0
- package/dist/src/providers/__tests__/adapter-oauth-wiring.test.d.ts +8 -0
- package/dist/src/providers/__tests__/adapter-oauth-wiring.test.js +109 -0
- package/dist/src/providers/__tests__/adapter-oauth-wiring.test.js.map +1 -0
- package/dist/src/providers/__tests__/capabilities-cosmetic.test.d.ts +1 -0
- package/dist/src/providers/__tests__/capabilities-cosmetic.test.js +109 -0
- package/dist/src/providers/__tests__/capabilities-cosmetic.test.js.map +1 -0
- package/dist/src/providers/__tests__/capabilities-flags.test.d.ts +1 -0
- package/dist/src/providers/__tests__/capabilities-flags.test.js +145 -0
- package/dist/src/providers/__tests__/capabilities-flags.test.js.map +1 -0
- package/dist/src/providers/__tests__/capabilities-provider-options.test.d.ts +1 -0
- package/dist/src/providers/__tests__/capabilities-provider-options.test.js +179 -0
- package/dist/src/providers/__tests__/capabilities-provider-options.test.js.map +1 -0
- package/dist/src/providers/__tests__/capabilities-sanitize.test.d.ts +1 -0
- package/dist/src/providers/__tests__/capabilities-sanitize.test.js +75 -0
- package/dist/src/providers/__tests__/capabilities-sanitize.test.js.map +1 -0
- package/dist/src/providers/__tests__/capabilities.test.d.ts +1 -0
- package/dist/src/providers/__tests__/capabilities.test.js +41 -0
- package/dist/src/providers/__tests__/capabilities.test.js.map +1 -0
- package/dist/src/providers/__tests__/provider-coverage.test.d.ts +1 -0
- package/dist/src/providers/__tests__/provider-coverage.test.js +45 -0
- package/dist/src/providers/__tests__/provider-coverage.test.js.map +1 -0
- package/dist/src/providers/__tests__/runtime-integration.test.d.ts +1 -0
- package/dist/src/providers/__tests__/runtime-integration.test.js +86 -0
- package/dist/src/providers/__tests__/runtime-integration.test.js.map +1 -0
- package/dist/src/providers/__tests__/runtime.test.d.ts +1 -0
- package/dist/src/providers/__tests__/runtime.test.js +83 -0
- package/dist/src/providers/__tests__/runtime.test.js.map +1 -0
- package/dist/src/providers/__tests__/siliconflow-history.test.d.ts +1 -0
- package/dist/src/providers/__tests__/siliconflow-history.test.js +76 -0
- package/dist/src/providers/__tests__/siliconflow-history.test.js.map +1 -0
- package/dist/src/providers/__tests__/strategies-registry.test.d.ts +8 -0
- package/dist/src/providers/__tests__/strategies-registry.test.js +49 -0
- package/dist/src/providers/__tests__/strategies-registry.test.js.map +1 -0
- package/dist/src/providers/__tests__/strategies-resolve.test.d.ts +12 -0
- package/dist/src/providers/__tests__/strategies-resolve.test.js +128 -0
- package/dist/src/providers/__tests__/strategies-resolve.test.js.map +1 -0
- package/dist/src/providers/__tests__/wire-debug.test.d.ts +1 -0
- package/dist/src/providers/__tests__/wire-debug.test.js +39 -0
- package/dist/src/providers/__tests__/wire-debug.test.js.map +1 -0
- package/dist/src/providers/adapter.d.ts +61 -0
- package/dist/src/providers/adapter.js +127 -0
- package/dist/src/providers/adapter.js.map +1 -0
- package/dist/src/providers/adapter.test.d.ts +1 -0
- package/dist/src/providers/adapter.test.js.map +1 -0
- package/dist/src/providers/anthropic.js +146 -0
- package/dist/src/providers/anthropic.js.map +1 -0
- package/dist/src/providers/auth/__tests__/browser-flow.test.d.ts +8 -0
- package/dist/src/providers/auth/__tests__/browser-flow.test.js +186 -0
- package/dist/src/providers/auth/__tests__/browser-flow.test.js.map +1 -0
- package/dist/src/providers/auth/__tests__/device-flow.test.d.ts +6 -0
- package/dist/src/providers/auth/__tests__/device-flow.test.js +219 -0
- package/dist/src/providers/auth/__tests__/device-flow.test.js.map +1 -0
- package/dist/src/providers/auth/__tests__/gemini-oauth.test.d.ts +8 -0
- package/dist/src/providers/auth/__tests__/gemini-oauth.test.js +310 -0
- package/dist/src/providers/auth/__tests__/gemini-oauth.test.js.map +1 -0
- package/dist/src/providers/auth/__tests__/openai-oauth.test.d.ts +7 -0
- package/dist/src/providers/auth/__tests__/openai-oauth.test.js +309 -0
- package/dist/src/providers/auth/__tests__/openai-oauth.test.js.map +1 -0
- package/dist/src/providers/auth/__tests__/token-store.test.d.ts +7 -0
- package/dist/src/providers/auth/__tests__/token-store.test.js +125 -0
- package/dist/src/providers/auth/__tests__/token-store.test.js.map +1 -0
- package/dist/src/providers/auth/browser-flow.d.ts +60 -0
- package/dist/src/providers/auth/browser-flow.js +78 -0
- package/dist/src/providers/auth/browser-flow.js.map +1 -0
- package/dist/src/providers/auth/device-flow.d.ts +66 -0
- package/dist/src/providers/auth/device-flow.js +147 -0
- package/dist/src/providers/auth/device-flow.js.map +1 -0
- package/dist/src/providers/auth/gemini-oauth.d.ts +55 -0
- package/dist/src/providers/auth/gemini-oauth.js +294 -0
- package/dist/src/providers/auth/gemini-oauth.js.map +1 -0
- package/dist/src/providers/auth/openai-oauth.d.ts +60 -0
- package/dist/src/providers/auth/openai-oauth.js +373 -0
- package/dist/src/providers/auth/openai-oauth.js.map +1 -0
- package/dist/src/providers/auth/registry.d.ts +65 -0
- package/dist/src/providers/auth/registry.js +82 -0
- package/dist/src/providers/auth/registry.js.map +1 -0
- package/dist/src/providers/auth/token-store.d.ts +28 -0
- package/dist/src/providers/auth/token-store.js +134 -0
- package/dist/src/providers/auth/token-store.js.map +1 -0
- package/dist/src/providers/auth/types.d.ts +77 -0
- package/dist/src/providers/auth/types.js +30 -0
- package/dist/src/providers/auth/types.js.map +1 -0
- package/dist/src/providers/capabilities.d.ts +135 -0
- package/dist/src/providers/capabilities.js +241 -0
- package/dist/src/providers/capabilities.js.map +1 -0
- package/dist/src/providers/endpoints.d.ts +25 -0
- package/dist/src/providers/endpoints.js +58 -0
- package/dist/src/providers/endpoints.js.map +1 -0
- package/dist/src/providers/errors.js.map +1 -0
- package/dist/src/providers/errors.test.d.ts +1 -0
- package/dist/src/providers/errors.test.js.map +1 -0
- package/dist/src/providers/gemini.js +38 -0
- package/dist/src/providers/gemini.js.map +1 -0
- package/dist/src/providers/gemini.test.d.ts +1 -0
- package/dist/src/providers/gemini.test.js.map +1 -0
- package/dist/src/providers/index.d.ts +11 -0
- package/dist/src/providers/index.js +15 -0
- package/dist/src/providers/index.js.map +1 -0
- package/dist/src/providers/keychain.d.ts +66 -0
- package/dist/src/providers/keychain.js +250 -0
- package/dist/src/providers/keychain.js.map +1 -0
- package/dist/src/providers/keychain.test.d.ts +1 -0
- package/dist/src/providers/keychain.test.js +84 -0
- package/dist/src/providers/keychain.test.js.map +1 -0
- package/dist/src/providers/mcp-vision-bridge.d.ts +60 -0
- package/dist/src/providers/mcp-vision-bridge.js +861 -0
- package/dist/src/providers/mcp-vision-bridge.js.map +1 -0
- package/dist/src/providers/mcp-vision-bridge.test.d.ts +1 -0
- package/dist/src/providers/mcp-vision-bridge.test.js +381 -0
- package/dist/src/providers/mcp-vision-bridge.test.js.map +1 -0
- package/dist/src/providers/ollama.js.map +1 -0
- package/dist/src/providers/ollama.test.d.ts +1 -0
- package/dist/src/providers/ollama.test.js.map +1 -0
- package/dist/src/providers/openai-compatible.js +54 -0
- package/dist/src/providers/openai-compatible.js.map +1 -0
- package/dist/src/providers/openai-compatible.test.d.ts +1 -0
- package/dist/src/providers/openai-compatible.test.js +53 -0
- package/dist/src/providers/openai-compatible.test.js.map +1 -0
- package/dist/src/providers/openai.d.ts +22 -0
- package/dist/src/providers/openai.js +46 -0
- package/dist/src/providers/openai.js.map +1 -0
- package/dist/src/providers/openai.test.d.ts +1 -0
- package/dist/src/providers/openai.test.js.map +1 -0
- package/dist/src/providers/patch-zod-schema.js +120 -0
- package/dist/src/providers/patch-zod-schema.js.map +1 -0
- package/dist/src/providers/pricing.d.ts +35 -0
- package/dist/src/providers/pricing.js +92 -0
- package/dist/src/providers/pricing.js.map +1 -0
- package/dist/src/providers/pricing.test.d.ts +1 -0
- package/dist/src/providers/pricing.test.js +55 -0
- package/dist/src/providers/pricing.test.js.map +1 -0
- package/dist/src/providers/prompt-cache-key.spec.d.ts +5 -0
- package/dist/src/providers/prompt-cache-key.spec.js +24 -0
- package/dist/src/providers/prompt-cache-key.spec.js.map +1 -0
- package/dist/src/providers/runtime-mock.spec.d.ts +8 -0
- package/dist/src/providers/runtime-mock.spec.js +69 -0
- package/dist/src/providers/runtime-mock.spec.js.map +1 -0
- package/dist/src/providers/runtime.d.ts +90 -0
- package/dist/src/providers/runtime.js +226 -0
- package/dist/src/providers/runtime.js.map +1 -0
- package/dist/src/providers/siliconflow-history.d.ts +50 -0
- package/dist/src/providers/siliconflow-history.js +64 -0
- package/dist/src/providers/siliconflow-history.js.map +1 -0
- package/dist/src/providers/strategies/anthropic.strategy.d.ts +15 -0
- package/dist/src/providers/strategies/anthropic.strategy.js +21 -0
- package/dist/src/providers/strategies/anthropic.strategy.js.map +1 -0
- package/dist/src/providers/strategies/base.strategy.d.ts +52 -0
- package/dist/src/providers/strategies/base.strategy.js +38 -0
- package/dist/src/providers/strategies/base.strategy.js.map +1 -0
- package/dist/src/providers/strategies/deepseek.strategy.d.ts +14 -0
- package/dist/src/providers/strategies/deepseek.strategy.js +22 -0
- package/dist/src/providers/strategies/deepseek.strategy.js.map +1 -0
- package/dist/src/providers/strategies/google.strategy.d.ts +15 -0
- package/dist/src/providers/strategies/google.strategy.js +24 -0
- package/dist/src/providers/strategies/google.strategy.js.map +1 -0
- package/dist/src/providers/strategies/ollama.strategy.d.ts +15 -0
- package/dist/src/providers/strategies/ollama.strategy.js +18 -0
- package/dist/src/providers/strategies/ollama.strategy.js.map +1 -0
- package/dist/src/providers/strategies/openai.strategy.d.ts +23 -0
- package/dist/src/providers/strategies/openai.strategy.js +48 -0
- package/dist/src/providers/strategies/openai.strategy.js.map +1 -0
- package/dist/src/providers/strategies/registry.d.ts +14 -0
- package/dist/src/providers/strategies/registry.js +37 -0
- package/dist/src/providers/strategies/registry.js.map +1 -0
- package/dist/src/providers/strategies/siliconflow.strategy.d.ts +14 -0
- package/dist/src/providers/strategies/siliconflow.strategy.js +22 -0
- package/dist/src/providers/strategies/siliconflow.strategy.js.map +1 -0
- package/dist/src/providers/strategies/xai.strategy.d.ts +14 -0
- package/dist/src/providers/strategies/xai.strategy.js +22 -0
- package/dist/src/providers/strategies/xai.strategy.js.map +1 -0
- package/dist/src/providers/stream-loop.d.ts +20 -0
- package/dist/src/providers/stream-loop.js +79 -0
- package/dist/src/providers/stream-loop.js.map +1 -0
- package/dist/src/providers/types.d.ts +128 -0
- package/dist/src/providers/types.js +31 -0
- package/dist/src/providers/types.js.map +1 -0
- package/dist/src/providers/vision-proxy.js +256 -0
- package/dist/src/providers/vision-proxy.js.map +1 -0
- package/dist/src/providers/vision-proxy.test.d.ts +1 -0
- package/dist/src/providers/vision-proxy.test.js +212 -0
- package/dist/src/providers/vision-proxy.test.js.map +1 -0
- package/dist/src/providers/wire-debug.d.ts +28 -0
- package/dist/src/providers/wire-debug.js +146 -0
- package/dist/src/providers/wire-debug.js.map +1 -0
- package/dist/src/router/__tests__/step-router.test.d.ts +4 -0
- package/dist/src/router/__tests__/step-router.test.js +131 -0
- package/dist/src/router/__tests__/step-router.test.js.map +1 -0
- package/dist/src/router/classifier/grammars.js.map +1 -0
- package/dist/src/router/classifier/index.js.map +1 -0
- package/dist/src/router/classifier/index.test.d.ts +1 -0
- package/dist/src/router/classifier/index.test.js.map +1 -0
- package/dist/src/router/classifier/regex.js +104 -0
- package/dist/src/router/classifier/regex.js.map +1 -0
- package/dist/src/router/classifier/regex.test.d.ts +1 -0
- package/dist/src/router/classifier/regex.test.js.map +1 -0
- package/dist/src/router/classifier/tree-sitter.js.map +1 -0
- package/dist/src/router/classifier/tree-sitter.test.d.ts +1 -0
- package/dist/src/router/classifier/tree-sitter.test.js.map +1 -0
- package/dist/src/router/cold.js.map +1 -0
- package/dist/src/router/cold.test.d.ts +1 -0
- package/dist/src/router/cold.test.js +56 -0
- package/dist/src/router/cold.test.js.map +1 -0
- package/dist/src/router/decide.js +410 -0
- package/dist/src/router/decide.js.map +1 -0
- package/dist/src/router/decide.test.d.ts +1 -0
- package/dist/src/router/decide.test.js +116 -0
- package/dist/src/router/decide.test.js.map +1 -0
- package/dist/src/router/health.js.map +1 -0
- package/dist/src/router/health.test.d.ts +1 -0
- package/dist/src/router/health.test.js.map +1 -0
- package/dist/src/router/provider-sentinel.d.ts +16 -0
- package/dist/src/router/provider-sentinel.js +18 -0
- package/dist/src/router/provider-sentinel.js.map +1 -0
- package/dist/src/router/provider-sentinel.test.d.ts +1 -0
- package/dist/src/router/provider-sentinel.test.js +20 -0
- package/dist/src/router/provider-sentinel.test.js.map +1 -0
- package/dist/src/router/step-router.d.ts +57 -0
- package/dist/src/router/step-router.js +143 -0
- package/dist/src/router/step-router.js.map +1 -0
- package/dist/src/router/store.js.map +1 -0
- package/dist/src/router/types.js +2 -0
- package/dist/src/router/types.js.map +1 -0
- package/dist/src/router/warm.js +46 -0
- package/dist/src/router/warm.js.map +1 -0
- package/dist/src/router/warm.test.d.ts +1 -0
- package/dist/src/router/warm.test.js +144 -0
- package/dist/src/router/warm.test.js.map +1 -0
- package/dist/src/scaffold/__tests__/continuation-prompt.test.d.ts +4 -0
- package/dist/src/scaffold/__tests__/continuation-prompt.test.js +79 -0
- package/dist/src/scaffold/__tests__/continuation-prompt.test.js.map +1 -0
- package/dist/src/scaffold/__tests__/continue-as-council.spec.d.ts +10 -0
- package/dist/src/scaffold/__tests__/continue-as-council.spec.js +102 -0
- package/dist/src/scaffold/__tests__/continue-as-council.spec.js.map +1 -0
- package/dist/src/scaffold/__tests__/dotnet-assembly-name.test.d.ts +1 -0
- package/dist/src/scaffold/__tests__/dotnet-assembly-name.test.js +27 -0
- package/dist/src/scaffold/__tests__/dotnet-assembly-name.test.js.map +1 -0
- package/dist/src/scaffold/__tests__/fe-scaffold-contents.test.d.ts +1 -0
- package/dist/src/scaffold/__tests__/fe-scaffold-contents.test.js +106 -0
- package/dist/src/scaffold/__tests__/fe-scaffold-contents.test.js.map +1 -0
- package/dist/src/scaffold/__tests__/init-new.smoke.spec.d.ts +15 -0
- package/dist/src/scaffold/__tests__/init-new.smoke.spec.js +81 -0
- package/dist/src/scaffold/__tests__/init-new.smoke.spec.js.map +1 -0
- package/dist/src/scaffold/__tests__/init-new.spec.d.ts +5 -0
- package/dist/src/scaffold/__tests__/init-new.spec.js +378 -0
- package/dist/src/scaffold/__tests__/init-new.spec.js.map +1 -0
- package/dist/src/scaffold/__tests__/install-bb-templates.spec.d.ts +1 -0
- package/dist/src/scaffold/__tests__/install-bb-templates.spec.js +77 -0
- package/dist/src/scaffold/__tests__/install-bb-templates.spec.js.map +1 -0
- package/dist/src/scaffold/__tests__/point-to-existing.spec.d.ts +7 -0
- package/dist/src/scaffold/__tests__/point-to-existing.spec.js +94 -0
- package/dist/src/scaffold/__tests__/point-to-existing.spec.js.map +1 -0
- package/dist/src/scaffold/bb-ecosystem-apply.d.ts +80 -0
- package/dist/src/scaffold/bb-ecosystem-apply.js +315 -0
- package/dist/src/scaffold/bb-ecosystem-apply.js.map +1 -0
- package/dist/src/scaffold/bb-quality-gate.d.ts +59 -0
- package/dist/src/scaffold/bb-quality-gate.js +185 -0
- package/dist/src/scaffold/bb-quality-gate.js.map +1 -0
- package/dist/src/scaffold/continuation-prompt.d.ts +12 -0
- package/dist/src/scaffold/continuation-prompt.js +66 -0
- package/dist/src/scaffold/continuation-prompt.js.map +1 -0
- package/dist/src/scaffold/continue-as-council.d.ts +47 -0
- package/dist/src/scaffold/continue-as-council.js +60 -0
- package/dist/src/scaffold/continue-as-council.js.map +1 -0
- package/dist/src/scaffold/init-new.d.ts +239 -0
- package/dist/src/scaffold/init-new.js +1414 -0
- package/dist/src/scaffold/init-new.js.map +1 -0
- package/dist/src/scaffold/point-to-existing.d.ts +38 -0
- package/dist/src/scaffold/point-to-existing.js +51 -0
- package/dist/src/scaffold/point-to-existing.js.map +1 -0
- package/dist/src/scaffold/resume-from-gate-failures.d.ts +48 -0
- package/dist/src/scaffold/resume-from-gate-failures.js +113 -0
- package/dist/src/scaffold/resume-from-gate-failures.js.map +1 -0
- package/dist/src/storage/__tests__/migrations.test.js.map +1 -0
- package/dist/src/storage/__tests__/ui-interaction-log.test.d.ts +7 -0
- package/dist/src/storage/__tests__/ui-interaction-log.test.js +97 -0
- package/dist/src/storage/__tests__/ui-interaction-log.test.js.map +1 -0
- package/dist/src/storage/atomic-io.d.ts +30 -0
- package/dist/src/storage/atomic-io.js +163 -0
- package/dist/src/storage/atomic-io.js.map +1 -0
- package/dist/src/storage/atomic-io.test.d.ts +1 -0
- package/dist/src/storage/atomic-io.test.js +74 -0
- package/dist/src/storage/atomic-io.test.js.map +1 -0
- package/dist/src/storage/config.js +39 -0
- package/dist/src/storage/config.js.map +1 -0
- package/dist/src/storage/config.test.d.ts +1 -0
- package/dist/src/storage/config.test.js.map +1 -0
- package/dist/src/storage/db.js +143 -0
- package/dist/src/storage/db.js.map +1 -0
- package/dist/src/storage/index.d.ts +10 -0
- package/dist/src/storage/index.js +12 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/interaction-log.d.ts +33 -0
- package/dist/src/storage/interaction-log.js +73 -0
- package/dist/src/storage/interaction-log.js.map +1 -0
- package/dist/src/storage/migrations.d.ts +2 -0
- package/dist/src/storage/migrations.js +200 -0
- package/dist/src/storage/migrations.js.map +1 -0
- package/dist/src/storage/session-dir.js.map +1 -0
- package/dist/src/storage/sessions.d.ts +22 -0
- package/dist/src/storage/sessions.js +168 -0
- package/dist/src/storage/sessions.js.map +1 -0
- package/dist/src/storage/tool-results.d.ts +4 -0
- package/dist/src/storage/tool-results.js.map +1 -0
- package/dist/src/storage/transcript-view.js +23 -0
- package/dist/src/storage/transcript-view.js.map +1 -0
- package/dist/src/storage/transcript.d.ts +85 -0
- package/dist/src/storage/transcript.js +461 -0
- package/dist/src/storage/transcript.js.map +1 -0
- package/dist/src/storage/transcript.test.d.ts +1 -0
- package/dist/src/storage/transcript.test.js +22 -0
- package/dist/src/storage/transcript.test.js.map +1 -0
- package/dist/src/storage/ui-interaction-log.d.ts +146 -0
- package/dist/src/storage/ui-interaction-log.js +34 -0
- package/dist/src/storage/ui-interaction-log.js.map +1 -0
- package/dist/src/storage/usage-cap.js.map +1 -0
- package/dist/src/storage/usage-cap.test.d.ts +1 -0
- package/dist/src/storage/usage-cap.test.js.map +1 -0
- package/dist/src/storage/usage.d.ts +11 -0
- package/dist/src/storage/usage.js +65 -0
- package/dist/src/storage/usage.js.map +1 -0
- package/dist/src/storage/workspaces.d.ts +9 -0
- package/dist/src/storage/workspaces.js +60 -0
- package/dist/src/storage/workspaces.js.map +1 -0
- package/dist/src/tools/bash.d.ts +53 -0
- package/dist/src/tools/bash.js +593 -0
- package/dist/src/tools/bash.js.map +1 -0
- package/dist/src/tools/bash.test.d.ts +1 -0
- package/dist/src/tools/bash.test.js +268 -0
- package/dist/src/tools/bash.test.js.map +1 -0
- package/dist/src/tools/computer.d.ts +88 -0
- package/dist/src/tools/computer.js.map +1 -0
- package/dist/src/tools/computer.test.d.ts +1 -0
- package/dist/src/tools/computer.test.js +142 -0
- package/dist/src/tools/computer.test.js.map +1 -0
- package/dist/src/tools/file-tracker.d.ts +35 -0
- package/dist/src/tools/file-tracker.js +40 -0
- package/dist/src/tools/file-tracker.js.map +1 -0
- package/dist/src/tools/file-tracker.test.d.ts +1 -0
- package/dist/src/tools/file-tracker.test.js +77 -0
- package/dist/src/tools/file-tracker.test.js.map +1 -0
- package/dist/src/tools/file.d.ts +18 -0
- package/dist/src/tools/file.js +135 -0
- package/dist/src/tools/file.js.map +1 -0
- package/dist/src/tools/file.test.d.ts +1 -0
- package/dist/src/tools/file.test.js +58 -0
- package/dist/src/tools/file.test.js.map +1 -0
- package/dist/src/tools/grep.d.ts +8 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/registry.d.ts +21 -0
- package/dist/src/tools/registry.js +346 -0
- package/dist/src/tools/registry.js.map +1 -0
- package/dist/src/tools/registry.test.d.ts +1 -0
- package/dist/src/tools/registry.test.js +34 -0
- package/dist/src/tools/registry.test.js.map +1 -0
- package/dist/src/tools/schedule.js +498 -0
- package/dist/src/tools/schedule.js.map +1 -0
- package/dist/src/tools/schedule.test.d.ts +1 -0
- package/dist/src/tools/schedule.test.js +118 -0
- package/dist/src/tools/schedule.test.js.map +1 -0
- package/dist/src/types/index.d.ts +396 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/ui/agents-modal.d.ts +36 -0
- package/dist/src/ui/agents-modal.js +55 -0
- package/dist/src/ui/agents-modal.js.map +1 -0
- package/dist/src/ui/app.d.ts +20 -0
- package/dist/src/ui/app.js +5423 -0
- package/dist/src/ui/app.js.map +1 -0
- package/dist/src/ui/cards/__tests__/product-status-card.test.d.ts +1 -0
- package/dist/src/ui/cards/__tests__/product-status-card.test.js +27 -0
- package/dist/src/ui/cards/__tests__/product-status-card.test.js.map +1 -0
- package/dist/src/ui/cards/product-status-card.d.ts +25 -0
- package/dist/src/ui/cards/product-status-card.js +55 -0
- package/dist/src/ui/cards/product-status-card.js.map +1 -0
- package/dist/src/ui/components/SuggestionOverlay.js.map +1 -0
- package/dist/src/ui/components/Toast.d.ts +23 -0
- package/dist/src/ui/components/Toast.js +70 -0
- package/dist/src/ui/components/Toast.js.map +1 -0
- package/dist/src/ui/components/__tests__/council-leader-bubble.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/council-leader-bubble.test.js +14 -0
- package/dist/src/ui/components/__tests__/council-leader-bubble.test.js.map +1 -0
- package/dist/src/ui/components/__tests__/council-message-bubble.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/council-message-bubble.test.js +74 -0
- package/dist/src/ui/components/__tests__/council-message-bubble.test.js.map +1 -0
- package/dist/src/ui/components/__tests__/council-phase-timeline.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/council-phase-timeline.test.js +51 -0
- package/dist/src/ui/components/__tests__/council-phase-timeline.test.js.map +1 -0
- package/dist/src/ui/components/__tests__/council-placeholder-bubble.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/council-placeholder-bubble.test.js +14 -0
- package/dist/src/ui/components/__tests__/council-placeholder-bubble.test.js.map +1 -0
- package/dist/src/ui/components/__tests__/council-question-card.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/council-question-card.test.js +121 -0
- package/dist/src/ui/components/__tests__/council-question-card.test.js.map +1 -0
- package/dist/src/ui/components/__tests__/council-synthesis-banner.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/council-synthesis-banner.test.js +11 -0
- package/dist/src/ui/components/__tests__/council-synthesis-banner.test.js.map +1 -0
- package/dist/src/ui/components/__tests__/use-pair-quote-buffer.test.d.ts +1 -0
- package/dist/src/ui/components/__tests__/use-pair-quote-buffer.test.js +37 -0
- package/dist/src/ui/components/__tests__/use-pair-quote-buffer.test.js.map +1 -0
- package/dist/src/ui/components/btw-overlay.js.map +1 -0
- package/dist/src/ui/components/bubble-layout.d.ts +36 -0
- package/dist/src/ui/components/bubble-layout.js +43 -0
- package/dist/src/ui/components/bubble-layout.js.map +1 -0
- package/dist/src/ui/components/code-block-truncate.d.ts +8 -0
- package/dist/src/ui/components/code-block-truncate.js +22 -0
- package/dist/src/ui/components/code-block-truncate.js.map +1 -0
- package/dist/src/ui/components/copy-flash-banner.d.ts +5 -0
- package/dist/src/ui/components/copy-flash-banner.js +5 -0
- package/dist/src/ui/components/copy-flash-banner.js.map +1 -0
- package/dist/src/ui/components/council-info-card.d.ts +9 -0
- package/dist/src/ui/components/council-info-card.js +10 -0
- package/dist/src/ui/components/council-info-card.js.map +1 -0
- package/dist/src/ui/components/council-leader-bubble.d.ts +11 -0
- package/dist/src/ui/components/council-leader-bubble.js +17 -0
- package/dist/src/ui/components/council-leader-bubble.js.map +1 -0
- package/dist/src/ui/components/council-message-bubble.d.ts +21 -0
- package/dist/src/ui/components/council-message-bubble.js +47 -0
- package/dist/src/ui/components/council-message-bubble.js.map +1 -0
- package/dist/src/ui/components/council-phase-timeline.d.ts +14 -0
- package/dist/src/ui/components/council-phase-timeline.js +64 -0
- package/dist/src/ui/components/council-phase-timeline.js.map +1 -0
- package/dist/src/ui/components/council-placeholder-bubble.d.ts +22 -0
- package/dist/src/ui/components/council-placeholder-bubble.js +37 -0
- package/dist/src/ui/components/council-placeholder-bubble.js.map +1 -0
- package/dist/src/ui/components/council-question-card.d.ts +64 -0
- package/dist/src/ui/components/council-question-card.js +135 -0
- package/dist/src/ui/components/council-question-card.js.map +1 -0
- package/dist/src/ui/components/council-status-list.d.ts +15 -0
- package/dist/src/ui/components/council-status-list.js +83 -0
- package/dist/src/ui/components/council-status-list.js.map +1 -0
- package/dist/src/ui/components/council-synthesis-banner.d.ts +10 -0
- package/dist/src/ui/components/council-synthesis-banner.js +15 -0
- package/dist/src/ui/components/council-synthesis-banner.js.map +1 -0
- package/dist/src/ui/components/diff-view.d.ts +31 -0
- package/dist/src/ui/components/diff-view.js +109 -0
- package/dist/src/ui/components/diff-view.js.map +1 -0
- package/dist/src/ui/components/halt-recovery-card.d.ts +9 -0
- package/dist/src/ui/components/halt-recovery-card.js +26 -0
- package/dist/src/ui/components/halt-recovery-card.js.map +1 -0
- package/dist/src/ui/components/hero-logo.d.ts +4 -0
- package/dist/src/ui/components/hero-logo.js +41 -0
- package/dist/src/ui/components/hero-logo.js.map +1 -0
- package/dist/src/ui/components/init-new-form-card.d.ts +109 -0
- package/dist/src/ui/components/init-new-form-card.js +106 -0
- package/dist/src/ui/components/init-new-form-card.js.map +1 -0
- package/dist/src/ui/components/lsp-views.d.ts +14 -0
- package/dist/src/ui/components/lsp-views.js +34 -0
- package/dist/src/ui/components/lsp-views.js.map +1 -0
- package/dist/src/ui/components/media-views.d.ts +13 -0
- package/dist/src/ui/components/media-views.js +29 -0
- package/dist/src/ui/components/media-views.js.map +1 -0
- package/dist/src/ui/components/message-view.d.ts +31 -0
- package/dist/src/ui/components/message-view.js +174 -0
- package/dist/src/ui/components/message-view.js.map +1 -0
- package/dist/src/ui/components/point-to-existing-form-card.d.ts +33 -0
- package/dist/src/ui/components/point-to-existing-form-card.js +34 -0
- package/dist/src/ui/components/point-to-existing-form-card.js.map +1 -0
- package/dist/src/ui/components/prompt-box.d.ts +50 -0
- package/dist/src/ui/components/prompt-box.js +66 -0
- package/dist/src/ui/components/prompt-box.js.map +1 -0
- package/dist/src/ui/components/role-palette.d.ts +22 -0
- package/dist/src/ui/components/role-palette.js +50 -0
- package/dist/src/ui/components/role-palette.js.map +1 -0
- package/dist/src/ui/components/session-header.d.ts +14 -0
- package/dist/src/ui/components/session-header.js +24 -0
- package/dist/src/ui/components/session-header.js.map +1 -0
- package/dist/src/ui/components/slash-inline-menu.d.ts +7 -0
- package/dist/src/ui/components/slash-inline-menu.js +14 -0
- package/dist/src/ui/components/slash-inline-menu.js.map +1 -0
- package/dist/src/ui/components/structured-response-view.d.ts +7 -0
- package/dist/src/ui/components/structured-response-view.js +59 -0
- package/dist/src/ui/components/structured-response-view.js.map +1 -0
- package/dist/src/ui/components/tool-result-views.d.ts +60 -0
- package/dist/src/ui/components/tool-result-views.js +83 -0
- package/dist/src/ui/components/tool-result-views.js.map +1 -0
- package/dist/src/ui/components/use-pair-quote-buffer.d.ts +11 -0
- package/dist/src/ui/components/use-pair-quote-buffer.js +17 -0
- package/dist/src/ui/components/use-pair-quote-buffer.js.map +1 -0
- package/dist/src/ui/constants.d.ts +37 -0
- package/dist/src/ui/constants.js +221 -0
- package/dist/src/ui/constants.js.map +1 -0
- package/dist/src/ui/hooks/use-agent-editor.d.ts +40 -0
- package/dist/src/ui/hooks/use-agent-editor.js +54 -0
- package/dist/src/ui/hooks/use-agent-editor.js.map +1 -0
- package/dist/src/ui/hooks/use-mcp-editor.d.ts +24 -0
- package/dist/src/ui/hooks/use-mcp-editor.js +38 -0
- package/dist/src/ui/hooks/use-mcp-editor.js.map +1 -0
- package/dist/src/ui/hooks/use-model-picker.d.ts +26 -0
- package/dist/src/ui/hooks/use-model-picker.js +44 -0
- package/dist/src/ui/hooks/use-model-picker.js.map +1 -0
- package/dist/src/ui/hooks/useTypeahead.js +127 -0
- package/dist/src/ui/hooks/useTypeahead.js.map +1 -0
- package/dist/src/ui/markdown.d.ts +5 -0
- package/dist/src/ui/markdown.js.map +1 -0
- package/dist/src/ui/mcp-modal-types.d.ts +24 -0
- package/dist/src/ui/mcp-modal-types.js.map +1 -0
- package/dist/src/ui/mcp-modal.d.ts +33 -0
- package/dist/src/ui/mcp-modal.js +95 -0
- package/dist/src/ui/mcp-modal.js.map +1 -0
- package/dist/src/ui/modals/api-key-modal.d.ts +11 -0
- package/dist/src/ui/modals/api-key-modal.js +15 -0
- package/dist/src/ui/modals/api-key-modal.js.map +1 -0
- package/dist/src/ui/modals/connect-modal.d.ts +30 -0
- package/dist/src/ui/modals/connect-modal.js +34 -0
- package/dist/src/ui/modals/connect-modal.js.map +1 -0
- package/dist/src/ui/modals/model-picker-modal.d.ts +50 -0
- package/dist/src/ui/modals/model-picker-modal.js +57 -0
- package/dist/src/ui/modals/model-picker-modal.js.map +1 -0
- package/dist/src/ui/modals/sandbox-picker-modal.d.ts +12 -0
- package/dist/src/ui/modals/sandbox-picker-modal.js +18 -0
- package/dist/src/ui/modals/sandbox-picker-modal.js.map +1 -0
- package/dist/src/ui/modals/update-modal.d.ts +8 -0
- package/dist/src/ui/modals/update-modal.js +10 -0
- package/dist/src/ui/modals/update-modal.js.map +1 -0
- package/dist/src/ui/modals/wallet-picker-modal.d.ts +26 -0
- package/dist/src/ui/modals/wallet-picker-modal.js +33 -0
- package/dist/src/ui/modals/wallet-picker-modal.js.map +1 -0
- package/dist/src/ui/plan.d.ts +24 -0
- package/dist/src/ui/plan.js.map +1 -0
- package/dist/src/ui/schedule-modal.d.ts +15 -0
- package/dist/src/ui/schedule-modal.js +37 -0
- package/dist/src/ui/schedule-modal.js.map +1 -0
- package/dist/src/ui/slash/__tests__/clear.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/compact.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/cost.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/discuss.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/discuss.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/execute.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/execute.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/expand.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/ideal.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/ideal.test.js +117 -0
- package/dist/src/ui/slash/__tests__/ideal.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/menu-parity.test.d.ts +15 -0
- package/dist/src/ui/slash/__tests__/menu-parity.test.js +41 -0
- package/dist/src/ui/slash/__tests__/menu-parity.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/optimize.test.js +130 -0
- package/dist/src/ui/slash/__tests__/optimize.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/pin.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/pin.test.js +38 -0
- package/dist/src/ui/slash/__tests__/pin.test.js.map +1 -0
- package/dist/src/ui/slash/__tests__/plan.test.d.ts +1 -0
- package/dist/src/ui/slash/__tests__/plan.test.js.map +1 -0
- package/dist/src/ui/slash/clear.js.map +1 -0
- package/dist/src/ui/slash/compact.js.map +1 -0
- package/dist/src/ui/slash/cost.js +55 -0
- package/dist/src/ui/slash/cost.js.map +1 -0
- package/dist/src/ui/slash/council-inspect.d.ts +9 -0
- package/dist/src/ui/slash/council-inspect.js +146 -0
- package/dist/src/ui/slash/council-inspect.js.map +1 -0
- package/dist/src/ui/slash/council.js +23 -0
- package/dist/src/ui/slash/council.js.map +1 -0
- package/dist/src/ui/slash/debug.js +109 -0
- package/dist/src/ui/slash/debug.js.map +1 -0
- package/dist/src/ui/slash/discuss.js.map +1 -0
- package/dist/src/ui/slash/ee.js +271 -0
- package/dist/src/ui/slash/ee.js.map +1 -0
- package/dist/src/ui/slash/execute.js.map +1 -0
- package/dist/src/ui/slash/expand.js.map +1 -0
- package/dist/src/ui/slash/export.d.ts +20 -0
- package/dist/src/ui/slash/export.js +253 -0
- package/dist/src/ui/slash/export.js.map +1 -0
- package/dist/src/ui/slash/ideal.d.ts +60 -0
- package/dist/src/ui/slash/ideal.js +198 -0
- package/dist/src/ui/slash/ideal.js.map +1 -0
- package/dist/src/ui/slash/menu-items.d.ts +42 -0
- package/dist/src/ui/slash/menu-items.js +92 -0
- package/dist/src/ui/slash/menu-items.js.map +1 -0
- package/dist/src/ui/slash/optimize.js +37 -0
- package/dist/src/ui/slash/optimize.js.map +1 -0
- package/dist/src/ui/slash/pin.d.ts +15 -0
- package/dist/src/ui/slash/pin.js +36 -0
- package/dist/src/ui/slash/pin.js.map +1 -0
- package/dist/src/ui/slash/plan.js.map +1 -0
- package/dist/src/ui/slash/registry.d.ts +32 -0
- package/dist/src/ui/slash/registry.js.map +1 -0
- package/dist/src/ui/slash/route.js.map +1 -0
- package/dist/src/ui/slash/route.test.js.map +1 -0
- package/dist/src/ui/status-bar/index.d.ts +14 -0
- package/dist/src/ui/status-bar/index.js +79 -0
- package/dist/src/ui/status-bar/index.js.map +1 -0
- package/dist/src/ui/status-bar/index.test.d.ts +1 -0
- package/dist/src/ui/status-bar/index.test.js.map +1 -0
- package/dist/src/ui/status-bar/store.d.ts +40 -0
- package/dist/src/ui/status-bar/store.js +161 -0
- package/dist/src/ui/status-bar/store.js.map +1 -0
- package/dist/src/ui/status-bar/store.test.d.ts +1 -0
- package/dist/src/ui/status-bar/store.test.js.map +1 -0
- package/dist/src/ui/status-bar/tier-badge.js.map +1 -0
- package/dist/src/ui/status-bar/tier-badge.test.d.ts +1 -0
- package/dist/src/ui/status-bar/tier-badge.test.js.map +1 -0
- package/dist/src/ui/status-bar/usd-meter.js.map +1 -0
- package/dist/src/ui/status-bar/usd-meter.test.d.ts +1 -0
- package/dist/src/ui/status-bar/usd-meter.test.js.map +1 -0
- package/dist/src/ui/syntax-highlight.d.ts +8 -0
- package/dist/src/ui/syntax-highlight.js +623 -0
- package/dist/src/ui/syntax-highlight.js.map +1 -0
- package/dist/src/ui/terminal-selection-text.js.map +1 -0
- package/dist/src/ui/theme.d.ts +91 -0
- package/dist/src/ui/theme.js +94 -0
- package/dist/src/ui/theme.js.map +1 -0
- package/dist/src/ui/types.d.ts +82 -0
- package/dist/src/ui/types.js +2 -0
- package/dist/src/ui/types.js.map +1 -0
- package/dist/src/ui/utils/color.d.ts +1 -0
- package/dist/src/ui/utils/color.js +18 -0
- package/dist/src/ui/utils/color.js.map +1 -0
- package/dist/src/ui/utils/format.d.ts +21 -0
- package/dist/src/ui/utils/format.js +75 -0
- package/dist/src/ui/utils/format.js.map +1 -0
- package/dist/src/ui/utils/modal.d.ts +3 -0
- package/dist/src/ui/utils/modal.js +7 -0
- package/dist/src/ui/utils/modal.js.map +1 -0
- package/dist/src/ui/utils/text.d.ts +6 -0
- package/dist/src/ui/utils/text.js +31 -0
- package/dist/src/ui/utils/text.js.map +1 -0
- package/dist/src/ui/utils/tools.d.ts +8 -0
- package/dist/src/ui/utils/tools.js +123 -0
- package/dist/src/ui/utils/tools.js.map +1 -0
- package/dist/src/usage/__tests__/product-ledger.test.d.ts +1 -0
- package/dist/src/usage/__tests__/product-ledger.test.js +59 -0
- package/dist/src/usage/__tests__/product-ledger.test.js.map +1 -0
- package/dist/src/usage/cost-log.d.ts +65 -0
- package/dist/src/usage/cost-log.js +117 -0
- package/dist/src/usage/cost-log.js.map +1 -0
- package/dist/src/usage/decision-log.d.ts +32 -0
- package/dist/src/usage/decision-log.js +70 -0
- package/dist/src/usage/decision-log.js.map +1 -0
- package/dist/src/usage/downgrade.js.map +1 -0
- package/dist/src/usage/downgrade.test.d.ts +1 -0
- package/dist/src/usage/downgrade.test.js.map +1 -0
- package/dist/src/usage/estimator.d.ts +26 -0
- package/dist/src/usage/estimator.js +46 -0
- package/dist/src/usage/estimator.js.map +1 -0
- package/dist/src/usage/estimator.test.d.ts +1 -0
- package/dist/src/usage/estimator.test.js.map +1 -0
- package/dist/src/usage/ledger.d.ts +48 -0
- package/dist/src/usage/ledger.js +208 -0
- package/dist/src/usage/ledger.js.map +1 -0
- package/dist/src/usage/ledger.test.d.ts +1 -0
- package/dist/src/usage/ledger.test.js.map +1 -0
- package/dist/src/usage/midstream.js.map +1 -0
- package/dist/src/usage/midstream.test.d.ts +1 -0
- package/dist/src/usage/midstream.test.js.map +1 -0
- package/dist/src/usage/product-ledger.d.ts +47 -0
- package/dist/src/usage/product-ledger.js +73 -0
- package/dist/src/usage/product-ledger.js.map +1 -0
- package/dist/src/usage/thresholds.js.map +1 -0
- package/dist/src/usage/thresholds.test.d.ts +1 -0
- package/dist/src/usage/thresholds.test.js.map +1 -0
- package/dist/src/usage/types.d.ts +31 -0
- package/dist/src/usage/types.js.map +1 -0
- package/dist/src/utils/__tests__/auto-council-settings.test.d.ts +1 -0
- package/dist/src/utils/__tests__/auto-council-settings.test.js +41 -0
- package/dist/src/utils/__tests__/auto-council-settings.test.js.map +1 -0
- package/dist/src/utils/__tests__/ee-logger.test.d.ts +11 -0
- package/dist/src/utils/__tests__/ee-logger.test.js +165 -0
- package/dist/src/utils/__tests__/ee-logger.test.js.map +1 -0
- package/dist/src/utils/__tests__/file-lock.test.d.ts +1 -0
- package/dist/src/utils/__tests__/file-lock.test.js +66 -0
- package/dist/src/utils/__tests__/file-lock.test.js.map +1 -0
- package/dist/src/utils/__tests__/rate-limit.test.d.ts +1 -0
- package/dist/src/utils/__tests__/rate-limit.test.js +38 -0
- package/dist/src/utils/__tests__/rate-limit.test.js.map +1 -0
- package/dist/src/utils/__tests__/settings-disabled-models.test.d.ts +7 -0
- package/dist/src/utils/__tests__/settings-disabled-models.test.js +99 -0
- package/dist/src/utils/__tests__/settings-disabled-models.test.js.map +1 -0
- package/dist/src/utils/__tests__/settings-web-research.test.d.ts +1 -0
- package/dist/src/utils/__tests__/settings-web-research.test.js +46 -0
- package/dist/src/utils/__tests__/settings-web-research.test.js.map +1 -0
- package/dist/src/utils/__tests__/slugify.test.d.ts +1 -0
- package/dist/src/utils/__tests__/slugify.test.js +37 -0
- package/dist/src/utils/__tests__/slugify.test.js.map +1 -0
- package/dist/src/utils/__tests__/visible-retry.test.d.ts +1 -0
- package/dist/src/utils/__tests__/visible-retry.test.js +143 -0
- package/dist/src/utils/__tests__/visible-retry.test.js.map +1 -0
- package/dist/src/utils/at-mentions.js.map +1 -0
- package/dist/src/utils/clipboard-image.js +146 -0
- package/dist/src/utils/clipboard-image.js.map +1 -0
- package/dist/src/utils/ee-logger.d.ts +65 -0
- package/dist/src/utils/ee-logger.js +150 -0
- package/dist/src/utils/ee-logger.js.map +1 -0
- package/dist/src/utils/file-index.js.map +1 -0
- package/dist/src/utils/file-lock.d.ts +5 -0
- package/dist/src/utils/file-lock.js +58 -0
- package/dist/src/utils/file-lock.js.map +1 -0
- package/dist/src/utils/git-root.js.map +1 -0
- package/dist/src/utils/host-clipboard.d.ts +10 -0
- package/dist/src/utils/host-clipboard.js +69 -0
- package/dist/src/utils/host-clipboard.js.map +1 -0
- package/dist/src/utils/install-manager.js.map +1 -0
- package/dist/src/utils/install-manager.test.d.ts +1 -0
- package/dist/src/utils/install-manager.test.js +127 -0
- package/dist/src/utils/install-manager.test.js.map +1 -0
- package/dist/src/utils/instructions.js +140 -0
- package/dist/src/utils/instructions.js.map +1 -0
- package/dist/src/utils/instructions.test.d.ts +1 -0
- package/dist/src/utils/instructions.test.js +93 -0
- package/dist/src/utils/instructions.test.js.map +1 -0
- package/dist/src/utils/permission-mode.js.map +1 -0
- package/dist/src/utils/permission-mode.test.d.ts +1 -0
- package/dist/src/utils/permission-mode.test.js.map +1 -0
- package/dist/src/utils/rate-limit.d.ts +4 -0
- package/dist/src/utils/rate-limit.js +21 -0
- package/dist/src/utils/rate-limit.js.map +1 -0
- package/dist/src/utils/redactor.js.map +1 -0
- package/dist/src/utils/redactor.test.d.ts +1 -0
- package/dist/src/utils/redactor.test.js +84 -0
- package/dist/src/utils/redactor.test.js.map +1 -0
- package/dist/src/utils/settings.d.ts +346 -0
- package/dist/src/utils/settings.js +791 -0
- package/dist/src/utils/settings.js.map +1 -0
- package/dist/src/utils/settings.test.d.ts +1 -0
- package/dist/src/utils/settings.test.js +160 -0
- package/dist/src/utils/settings.test.js.map +1 -0
- package/dist/src/utils/shell.d.ts +34 -0
- package/dist/src/utils/shell.js +171 -0
- package/dist/src/utils/shell.js.map +1 -0
- package/dist/src/utils/shell.test.d.ts +1 -0
- package/dist/src/utils/shell.test.js +71 -0
- package/dist/src/utils/shell.test.js.map +1 -0
- package/dist/src/utils/side-question.js.map +1 -0
- package/dist/src/utils/skills.js +194 -0
- package/dist/src/utils/skills.js.map +1 -0
- package/dist/src/utils/skills.test.d.ts +1 -0
- package/dist/src/utils/skills.test.js +45 -0
- package/dist/src/utils/skills.test.js.map +1 -0
- package/dist/src/utils/slugify.d.ts +1 -0
- package/dist/src/utils/slugify.js +10 -0
- package/dist/src/utils/slugify.js.map +1 -0
- package/dist/src/utils/subagent-display.js.map +1 -0
- package/dist/src/utils/subagent-display.test.d.ts +1 -0
- package/dist/src/utils/subagent-display.test.js +21 -0
- package/dist/src/utils/subagent-display.test.js.map +1 -0
- package/dist/src/utils/subagents-settings.test.d.ts +1 -0
- package/dist/src/utils/subagents-settings.test.js +58 -0
- package/dist/src/utils/subagents-settings.test.js.map +1 -0
- package/dist/src/utils/telegram-audio-settings.test.d.ts +1 -0
- package/dist/src/utils/telegram-audio-settings.test.js +39 -0
- package/dist/src/utils/telegram-audio-settings.test.js.map +1 -0
- package/dist/src/utils/update-checker.js +22 -0
- package/dist/src/utils/update-checker.js.map +1 -0
- package/dist/src/utils/update-checker.test.d.ts +1 -0
- package/dist/src/utils/update-checker.test.js +125 -0
- package/dist/src/utils/update-checker.test.js.map +1 -0
- package/dist/src/utils/visible-retry.d.ts +20 -0
- package/dist/src/utils/visible-retry.js +34 -0
- package/dist/src/utils/visible-retry.js.map +1 -0
- package/dist/src/verify/__tests__/coverage-parsers.test.d.ts +1 -0
- package/dist/src/verify/__tests__/coverage-parsers.test.js +69 -0
- package/dist/src/verify/__tests__/coverage-parsers.test.js.map +1 -0
- package/dist/src/verify/__tests__/dotnet-recipe.test.d.ts +10 -0
- package/dist/src/verify/__tests__/dotnet-recipe.test.js +70 -0
- package/dist/src/verify/__tests__/dotnet-recipe.test.js.map +1 -0
- package/dist/src/verify/checkpoint.d.ts +11 -0
- package/dist/src/verify/checkpoint.js.map +1 -0
- package/dist/src/verify/checkpoint.test.d.ts +1 -0
- package/dist/src/verify/checkpoint.test.js +160 -0
- package/dist/src/verify/checkpoint.test.js.map +1 -0
- package/dist/src/verify/coverage-parsers.d.ts +29 -0
- package/dist/src/verify/coverage-parsers.js +72 -0
- package/dist/src/verify/coverage-parsers.js.map +1 -0
- package/dist/src/verify/entrypoint.d.ts +30 -0
- package/dist/src/verify/entrypoint.js +349 -0
- package/dist/src/verify/entrypoint.js.map +1 -0
- package/dist/src/verify/entrypoint.test.d.ts +1 -0
- package/dist/src/verify/entrypoint.test.js +233 -0
- package/dist/src/verify/entrypoint.test.js.map +1 -0
- package/dist/src/verify/environment.d.ts +9 -0
- package/dist/src/verify/environment.js +116 -0
- package/dist/src/verify/environment.js.map +1 -0
- package/dist/src/verify/environment.test.d.ts +1 -0
- package/dist/src/verify/environment.test.js +94 -0
- package/dist/src/verify/environment.test.js.map +1 -0
- package/dist/src/verify/evidence.d.ts +10 -0
- package/dist/src/verify/evidence.js.map +1 -0
- package/dist/src/verify/orchestrator.d.ts +25 -0
- package/dist/src/verify/orchestrator.js +87 -0
- package/dist/src/verify/orchestrator.js.map +1 -0
- package/dist/src/verify/orchestrator.test.d.ts +1 -0
- package/dist/src/verify/orchestrator.test.js +126 -0
- package/dist/src/verify/orchestrator.test.js.map +1 -0
- package/dist/src/verify/recipes.d.ts +22 -0
- package/dist/src/verify/recipes.js +528 -0
- package/dist/src/verify/recipes.js.map +1 -0
- package/dist/src/verify/retry.d.ts +4 -0
- package/dist/src/verify/retry.js.map +1 -0
- package/dist/src/verify/runtime-prep.test.d.ts +1 -0
- package/dist/src/verify/runtime-prep.test.js +38 -0
- package/dist/src/verify/runtime-prep.test.js.map +1 -0
- package/package.json +30 -10
- package/src/__test-stubs__/vitest-setup.ts +36 -0
- package/src/__tests__/council/bubble-layout.test.ts +45 -0
- package/src/__tests__/council/code-block-truncate.test.ts +50 -0
- package/src/__tests__/council/role-palette.test.ts +66 -0
- package/src/__tests__/first-run-wizard.test.ts +9 -0
- package/src/agent-harness/__tests__/cli-flags.spec.ts +35 -0
- package/src/agent-harness/__tests__/driver.spec.ts +154 -0
- package/src/agent-harness/__tests__/idle.spec.ts +90 -0
- package/src/agent-harness/__tests__/mock-llm.spec.ts +126 -0
- package/src/agent-harness/__tests__/mock-model.spec.ts +195 -0
- package/src/agent-harness/__tests__/predicate.spec.ts +33 -0
- package/src/agent-harness/__tests__/protocol.spec.ts +62 -0
- package/src/agent-harness/__tests__/schema.spec.ts +81 -0
- package/src/agent-harness/__tests__/selector.spec.ts +82 -0
- package/src/agent-harness/__tests__/sidechannel.spec.ts +40 -0
- package/src/agent-harness/__tests__/spec-helpers.spec.ts +76 -0
- package/src/agent-harness/index.ts +24 -0
- package/src/agent-harness/mock-model.ts +394 -0
- package/src/agent-harness/test-spawn.ts +200 -0
- package/src/chat/__tests__/broadcast-bus.test.ts +90 -0
- package/src/chat/__tests__/channel-manager.test.ts +149 -0
- package/src/chat/__tests__/client.test.ts +118 -0
- package/src/chat/__tests__/discord-integration.test.ts +162 -0
- package/src/chat/__tests__/intent-prompt.test.ts +92 -0
- package/src/chat/__tests__/verdict-resolver.test.ts +336 -0
- package/src/chat/broadcast-bus.ts +53 -0
- package/src/chat/channel-manager.ts +146 -0
- package/src/chat/chat-keychain.ts +129 -0
- package/src/chat/factory.ts +37 -0
- package/src/chat/intent-prompt.ts +72 -0
- package/src/chat/providers/discord/client.ts +91 -0
- package/src/chat/types.ts +42 -0
- package/src/chat/verdict-constants.ts +26 -0
- package/src/chat/verdict-resolver.ts +231 -0
- package/src/cli/__tests__/bw-vault.test.ts +97 -0
- package/src/cli/__tests__/keys-bundle.test.ts +46 -0
- package/src/cli/__tests__/share-cmd.test.ts +197 -0
- package/src/cli/bw-vault.ts +184 -0
- package/src/cli/config/__tests__/model-picker.test.ts +59 -0
- package/src/cli/config/__tests__/provider-fetch.test.ts +38 -0
- package/src/cli/config/index.ts +112 -0
- package/src/cli/config/model-picker.ts +193 -0
- package/src/cli/config/provider-fetch.ts +75 -0
- package/src/cli/config/screen-council.ts +245 -0
- package/src/cli/config/screen-models.ts +104 -0
- package/src/cli/config/screen-providers.ts +197 -0
- package/src/cli/config/tui.ts +153 -0
- package/src/cli/cost-forensics.test.ts +128 -0
- package/src/cli/cost-forensics.ts +264 -0
- package/src/cli/keys-bundle.ts +91 -0
- package/src/cli/keys.test.ts +104 -0
- package/src/cli/keys.ts +787 -0
- package/src/cli/pil-report.ts +202 -0
- package/src/cli/share-cmd.ts +132 -0
- package/src/cli/usage-report.ts +266 -0
- package/src/council/__tests__/accounting.test.ts +72 -0
- package/src/council/__tests__/audit-replay.test.ts +344 -0
- package/src/council/__tests__/clarifier-max-rounds.test.ts +91 -0
- package/src/council/__tests__/clarifier-options.test.ts +63 -0
- package/src/council/__tests__/cost-aware.test.ts +60 -0
- package/src/council/__tests__/debate-planner-structured.test.ts +236 -0
- package/src/council/__tests__/evaluator-metrics.test.ts +513 -0
- package/src/council/__tests__/parse-outcome-fallback.test.ts +125 -0
- package/src/council/__tests__/research-tools.test.ts +239 -0
- package/src/council/__tests__/round-tools.test.ts +334 -0
- package/src/council/__tests__/tool-trace.test.ts +152 -0
- package/src/council/__tests__/types-contract.test.ts +88 -0
- package/src/council/clarifier.ts +409 -0
- package/src/council/context.ts +250 -0
- package/src/council/debate-planner.ts +264 -0
- package/src/council/debate.ts +1179 -0
- package/src/council/executor.ts +27 -0
- package/src/council/index.ts +916 -0
- package/src/council/leader.ts +262 -0
- package/src/council/llm.ts +967 -0
- package/src/council/phase-events.ts +58 -0
- package/src/council/planner.ts +303 -0
- package/src/council/preflight.ts +86 -0
- package/src/council/prompts.ts +600 -0
- package/src/council/types.ts +286 -0
- package/src/daemon/scheduler.ts +1 -1
- package/src/ee/__tests__/bb-design.test.ts +223 -0
- package/src/ee/__tests__/pil-context-bridge.test.ts +59 -0
- package/src/ee/__tests__/pipeline.integration.test.ts +6 -6
- package/src/ee/__tests__/render-sink-wiring.test.ts +89 -0
- package/src/ee/auth.ts +21 -0
- package/src/ee/bb-design.ts +284 -0
- package/src/ee/bb-retrieval.ts +467 -0
- package/src/ee/bridge.test.ts +1 -8
- package/src/ee/bridge.ts +201 -12
- package/src/ee/client-mode.ts +161 -0
- package/src/ee/client.test.ts +171 -171
- package/src/ee/client.ts +127 -19
- package/src/ee/council-bridge.ts +89 -0
- package/src/ee/extract-session.test.ts +3 -8
- package/src/ee/extract-session.ts +4 -2
- package/src/ee/health.ts +1 -1
- package/src/ee/index.ts +11 -10
- package/src/ee/intercept.test.ts +197 -191
- package/src/ee/intercept.ts +13 -2
- package/src/ee/judge.test.ts +56 -0
- package/src/ee/judge.ts +59 -1
- package/src/ee/mistake-detector.test.ts +252 -0
- package/src/ee/mistake-detector.ts +297 -0
- package/src/ee/offline-queue.test.ts +14 -63
- package/src/ee/offline-queue.ts +2 -9
- package/src/ee/phase-outcome.test.ts +107 -0
- package/src/ee/phase-outcome.ts +165 -0
- package/src/ee/phase-tracker.test.ts +175 -0
- package/src/ee/phase-tracker.ts +180 -0
- package/src/ee/prompt-stale.test.ts +6 -1
- package/src/ee/render.test.ts +7 -4
- package/src/ee/render.ts +25 -4
- package/src/ee/session-trajectory.test.ts +139 -0
- package/src/ee/session-trajectory.ts +226 -0
- package/src/ee/touch.test.ts +73 -71
- package/src/ee/types.ts +72 -7
- package/src/flow/__tests__/run-manager-product.test.ts +59 -0
- package/src/flow/__tests__/scaffold-checkpoint.test.ts +113 -0
- package/src/flow/run-manager.ts +35 -2
- package/src/flow/scaffold-checkpoint.ts +132 -0
- package/src/generated/version.ts +4 -0
- package/src/gsd/__tests__/complexity.test.ts +0 -0
- package/src/gsd/__tests__/directives.test.ts +49 -0
- package/src/gsd/__tests__/gray-areas.test.ts +33 -0
- package/src/gsd/complexity.ts +124 -0
- package/src/gsd/directives.ts +94 -0
- package/src/gsd/gray-areas.ts +144 -0
- package/src/gsd/types.ts +2 -0
- package/src/headless/__tests__/council-answers.test.ts +266 -0
- package/src/headless/council-answers.ts +130 -0
- package/src/headless/output.ts +1 -1
- package/src/hooks/index.ts +316 -19
- package/src/hooks/types.ts +42 -0
- package/src/index.ts +1564 -677
- package/src/lsp/client.ts +1 -1
- package/src/lsp/smoke.test.ts +15 -13
- package/src/mcp/__tests__/auto-setup.test.ts +88 -0
- package/src/mcp/__tests__/harness-driver-action-tools.spec.ts +114 -0
- package/src/mcp/__tests__/harness-driver-async-tools.spec.ts +127 -0
- package/src/mcp/__tests__/harness-driver-read-tools.spec.ts +140 -0
- package/src/mcp/__tests__/harness-driver-security.spec.ts +71 -0
- package/src/mcp/__tests__/harness-driver.spec.ts +21 -0
- package/src/mcp/__tests__/lazy-schema.spec.ts +173 -0
- package/src/mcp/__tests__/mcp-keychain.test.ts +46 -0
- package/src/mcp/__tests__/research-onboarding.test.ts +163 -0
- package/src/mcp/__tests__/runtime-hydration.test.ts +86 -0
- package/src/mcp/__tests__/runtime-sanitize.test.ts +44 -0
- package/src/mcp/auto-setup.ts +26 -7
- package/src/mcp/catalog.ts +31 -14
- package/src/mcp/mcp-keychain.ts +77 -0
- package/src/mcp/oauth-callback.ts +18 -6
- package/src/mcp/oauth-provider.ts +1 -3
- package/src/mcp/opentui-spawn.ts +64 -0
- package/src/mcp/research-onboarding.ts +143 -0
- package/src/mcp/runtime.ts +85 -27
- package/src/models/__tests__/registry.test.ts +11 -11
- package/src/models/catalog-client.ts +2 -2
- package/src/models/catalog.README.md +136 -0
- package/src/models/catalog.json +108 -245
- package/src/models/classify-tier.ts +20 -9
- package/src/models/registry.ts +5 -1
- package/src/ops/__tests__/doctor-council-mcp.test.ts +161 -0
- package/src/ops/__tests__/doctor-ee-health.test.ts +129 -0
- package/src/ops/doctor.test.ts +6 -5
- package/src/ops/doctor.ts +207 -13
- package/src/orchestrator/__tests__/batch-turn-runner.test.ts +178 -0
- package/src/orchestrator/__tests__/council-manager.test.ts +171 -0
- package/src/orchestrator/__tests__/cross-turn-dedup.test.ts +174 -0
- package/src/orchestrator/__tests__/current-call-id.test.ts +160 -0
- package/src/orchestrator/__tests__/message-processor.test.ts +196 -0
- package/src/orchestrator/__tests__/message-write-ahead.test.ts +170 -0
- package/src/orchestrator/__tests__/read-path-budget.test.ts +107 -0
- package/src/orchestrator/__tests__/retry-classifier.test.ts +120 -0
- package/src/orchestrator/__tests__/retry-stream.test.ts +186 -0
- package/src/orchestrator/__tests__/route-feedback.test.ts +1 -1
- package/src/orchestrator/__tests__/stream-runner.test.ts +123 -0
- package/src/orchestrator/__tests__/usage-events-shape.test.ts +80 -0
- package/src/orchestrator/__tests__/usage-normalizer-c1.test.ts +172 -0
- package/src/orchestrator/__tests__/write-ahead.test.ts +162 -0
- package/src/orchestrator/agent-options.ts +168 -0
- package/src/orchestrator/agent.test.ts +47 -1
- package/src/orchestrator/batch-turn-runner.ts +425 -0
- package/src/orchestrator/batch-utils.ts +340 -0
- package/src/orchestrator/cleanup.test.ts +3 -5
- package/src/orchestrator/compaction.test.ts +50 -3
- package/src/orchestrator/compaction.ts +178 -52
- package/src/orchestrator/council-manager.ts +580 -0
- package/src/orchestrator/cross-turn-dedup.ts +187 -0
- package/src/orchestrator/error-utils.ts +72 -0
- package/src/orchestrator/flow-resume.ts +0 -1
- package/src/orchestrator/message-processor.ts +1985 -0
- package/src/orchestrator/message-seq.test.ts +29 -0
- package/src/orchestrator/message-seq.ts +19 -0
- package/src/orchestrator/orchestrator.ts +1266 -2590
- package/src/orchestrator/prompts.ts +482 -0
- package/src/orchestrator/provider-options-shape.spec.ts +67 -0
- package/src/orchestrator/provider-options-shape.ts +70 -0
- package/src/orchestrator/read-path-budget.ts +128 -0
- package/src/orchestrator/reasoning.ts +5 -0
- package/src/orchestrator/retry-classifier.ts +131 -0
- package/src/orchestrator/retry-stream.ts +159 -0
- package/src/orchestrator/sandbox.test.ts +1 -1
- package/src/orchestrator/stream-runner.ts +729 -0
- package/src/orchestrator/sub-agent-cap.test.ts +186 -0
- package/src/orchestrator/sub-agent-cap.ts +218 -0
- package/src/orchestrator/subagent-compactor.spec.ts +144 -0
- package/src/orchestrator/subagent-compactor.ts +242 -0
- package/src/orchestrator/token-counter.test.ts +69 -0
- package/src/orchestrator/token-counter.ts +81 -0
- package/src/orchestrator/tool-utils.ts +214 -0
- package/src/orchestrator/turn-runner-deps.ts +83 -0
- package/src/pil/__tests__/config.test.ts +32 -0
- package/src/pil/__tests__/dual-run.test.ts +53 -0
- package/src/pil/__tests__/layer1-intent-trace.test.ts +140 -0
- package/src/pil/__tests__/layer1-intent.test.ts +130 -27
- package/src/pil/__tests__/layer3-ee-injection.test.ts +94 -30
- package/src/pil/__tests__/layer3-injected-chunk.test.ts +122 -0
- package/src/pil/__tests__/layer4-gsd.test.ts +56 -23
- package/src/pil/__tests__/layer5-context.test.ts +41 -0
- package/src/pil/__tests__/layer6-output.test.ts +154 -9
- package/src/pil/__tests__/ollama-classify.test.ts +81 -81
- package/src/pil/__tests__/pipeline.test.ts +19 -2
- package/src/pil/__tests__/renderer-coverage.test.ts +46 -0
- package/src/pil/__tests__/response-tools.test.ts +12 -3
- package/src/pil/__tests__/schema.test.ts +109 -4
- package/src/pil/__tests__/scoreComplexity.test.ts +134 -0
- package/src/pil/__tests__/scoreSufficiency.test.ts +104 -0
- package/src/pil/budget-log.ts +86 -0
- package/src/pil/config.ts +11 -0
- package/src/pil/index.ts +1 -1
- package/src/pil/layer1-intent.test.ts +127 -0
- package/src/pil/layer1-intent.ts +468 -43
- package/src/pil/layer2-personality.ts +9 -0
- package/src/pil/layer3-ee-injection.ts +298 -32
- package/src/pil/layer4-gsd.ts +73 -32
- package/src/pil/layer5-context.ts +53 -18
- package/src/pil/layer6-output.ts +157 -10
- package/src/pil/pipeline.ts +114 -19
- package/src/pil/response-tools.ts +2 -2
- package/src/pil/schema.ts +56 -2
- package/src/pil/types.ts +110 -2
- package/src/product-loop/__tests__/artifact-io.test.ts +97 -0
- package/src/product-loop/__tests__/assumption-ledger.test.ts +292 -0
- package/src/product-loop/__tests__/cb2-retry-bonus.test.ts +182 -0
- package/src/product-loop/__tests__/circuit-breakers-coverage.test.ts +82 -0
- package/src/product-loop/__tests__/circuit-breakers.test.ts +90 -0
- package/src/product-loop/__tests__/complexity-routing.spec.ts +169 -0
- package/src/product-loop/__tests__/context-policy.test.ts +280 -0
- package/src/product-loop/__tests__/cost-preview.test.ts +118 -0
- package/src/product-loop/__tests__/cost-scoper.test.ts +76 -0
- package/src/product-loop/__tests__/cross-run-memory.test.ts +195 -0
- package/src/product-loop/__tests__/design-output.spec.ts +39 -0
- package/src/product-loop/__tests__/discover.test.ts +98 -0
- package/src/product-loop/__tests__/discovery-council-runner.test.ts +13 -0
- package/src/product-loop/__tests__/discovery-detection.test.ts +180 -0
- package/src/product-loop/__tests__/discovery-ecosystem.test.ts +132 -0
- package/src/product-loop/__tests__/discovery-integration.test.ts +133 -0
- package/src/product-loop/__tests__/discovery-interview.test.ts +305 -0
- package/src/product-loop/__tests__/discovery-migrations.test.ts +75 -0
- package/src/product-loop/__tests__/discovery-persistence.test.ts +171 -0
- package/src/product-loop/__tests__/discovery-prompt-parser.test.ts +77 -0
- package/src/product-loop/__tests__/discovery-recommender-ecosystem.test.ts +94 -0
- package/src/product-loop/__tests__/discovery-recommender.test.ts +382 -0
- package/src/product-loop/__tests__/discovery-schema.test.ts +102 -0
- package/src/product-loop/__tests__/done-gate-coverage.test.ts +151 -0
- package/src/product-loop/__tests__/done-gate.test.ts +140 -0
- package/src/product-loop/__tests__/ee-extract-wiring.test.ts +216 -0
- package/src/product-loop/__tests__/extract-to-ee.test.ts +205 -0
- package/src/product-loop/__tests__/feedback-routing.test.ts +93 -0
- package/src/product-loop/__tests__/hot-path.spec.ts +177 -0
- package/src/product-loop/__tests__/integration.test.ts +344 -0
- package/src/product-loop/__tests__/loop-driver-audit.test.ts +321 -0
- package/src/product-loop/__tests__/loop-driver.test.ts +247 -0
- package/src/product-loop/__tests__/phase-budget.test.ts +172 -0
- package/src/product-loop/__tests__/phase-orchestrator-integration.test.ts +143 -0
- package/src/product-loop/__tests__/phase-plan.test.ts +241 -0
- package/src/product-loop/__tests__/phase-rituals.test.ts +211 -0
- package/src/product-loop/__tests__/phase-runner.test.ts +454 -0
- package/src/product-loop/__tests__/phase-tracker-bridge.test.ts +85 -0
- package/src/product-loop/__tests__/product-identity.test.ts +47 -0
- package/src/product-loop/__tests__/reality-anchor.test.ts +58 -0
- package/src/product-loop/__tests__/repo-audit.test.ts +103 -0
- package/src/product-loop/__tests__/role-memory.test.ts +70 -0
- package/src/product-loop/__tests__/role-registry.test.ts +235 -0
- package/src/product-loop/__tests__/role-routing-ee.test.ts +90 -0
- package/src/product-loop/__tests__/route-decision-emit.test.ts +207 -0
- package/src/product-loop/__tests__/seed-questions.test.ts +33 -0
- package/src/product-loop/__tests__/ship-polish.test.ts +109 -0
- package/src/product-loop/__tests__/sprint-runner-emit.test.ts +324 -0
- package/src/product-loop/__tests__/sprint-runner.test.ts +501 -0
- package/src/product-loop/__tests__/stakeholder-acl.test.ts +94 -0
- package/src/product-loop/__tests__/state-md-ee-injections.test.ts +229 -0
- package/src/product-loop/__tests__/sufficiency-routing.spec.ts +177 -0
- package/src/product-loop/__tests__/typed-artifacts.test.ts +261 -0
- package/src/product-loop/__tests__/types.test.ts +103 -0
- package/src/product-loop/__tests__/verify-failure-threshold.test.ts +177 -0
- package/src/product-loop/__tests__/verify-failure-tracking.test.ts +154 -0
- package/src/product-loop/__tests__/verify-result.test.ts +60 -0
- package/src/product-loop/artifact-io.ts +239 -0
- package/src/product-loop/assumption-ledger.ts +270 -0
- package/src/product-loop/circuit-breakers.ts +76 -0
- package/src/product-loop/context-policy.ts +180 -0
- package/src/product-loop/cost-preview.ts +124 -0
- package/src/product-loop/cost-scoper.ts +49 -0
- package/src/product-loop/cross-run-memory.ts +450 -0
- package/src/product-loop/design-output.ts +24 -0
- package/src/product-loop/discover.ts +159 -0
- package/src/product-loop/discovery-context-format.ts +32 -0
- package/src/product-loop/discovery-council-runner.ts +82 -0
- package/src/product-loop/discovery-detection.ts +161 -0
- package/src/product-loop/discovery-ecosystem.ts +124 -0
- package/src/product-loop/discovery-interview.ts +237 -0
- package/src/product-loop/discovery-migrations.ts +40 -0
- package/src/product-loop/discovery-persistence.ts +219 -0
- package/src/product-loop/discovery-prompt-parser.ts +80 -0
- package/src/product-loop/discovery-recommender.ts +366 -0
- package/src/product-loop/discovery-schema.ts +143 -0
- package/src/product-loop/done-gate.ts +224 -0
- package/src/product-loop/feedback-routing.ts +82 -0
- package/src/product-loop/gather.ts +304 -0
- package/src/product-loop/index.ts +1305 -0
- package/src/product-loop/loop-driver.ts +901 -0
- package/src/product-loop/phase-budget.ts +182 -0
- package/src/product-loop/phase-plan.ts +158 -0
- package/src/product-loop/phase-rituals.ts +158 -0
- package/src/product-loop/phase-runner.ts +455 -0
- package/src/product-loop/phase-tracker-bridge.ts +60 -0
- package/src/product-loop/product-identity.ts +11 -0
- package/src/product-loop/reality-anchor.ts +45 -0
- package/src/product-loop/repo-audit.ts +314 -0
- package/src/product-loop/role-memory.ts +72 -0
- package/src/product-loop/role-registry.ts +175 -0
- package/src/product-loop/seed-questions.ts +51 -0
- package/src/product-loop/ship-polish.ts +164 -0
- package/src/product-loop/sprint-runner.ts +610 -0
- package/src/product-loop/stakeholder-acl.ts +82 -0
- package/src/product-loop/typed-artifacts.ts +332 -0
- package/src/product-loop/types.ts +443 -0
- package/src/product-loop/verify-failure-tracking.ts +225 -0
- package/src/product-loop/verify-result.ts +39 -0
- package/src/providers/__tests__/adapter-oauth-wiring.test.ts +129 -0
- package/src/providers/__tests__/capabilities-cosmetic.test.ts +119 -0
- package/src/providers/__tests__/capabilities-flags.test.ts +166 -0
- package/src/providers/__tests__/capabilities-provider-options.test.ts +203 -0
- package/src/providers/__tests__/capabilities-sanitize.test.ts +82 -0
- package/src/providers/__tests__/capabilities.test.ts +44 -0
- package/src/providers/__tests__/provider-coverage.test.ts +48 -0
- package/src/providers/__tests__/runtime-integration.test.ts +41 -24
- package/src/providers/__tests__/runtime.test.ts +23 -13
- package/src/providers/__tests__/siliconflow-history.test.ts +82 -0
- package/src/providers/__tests__/strategies-registry.test.ts +55 -0
- package/src/providers/__tests__/strategies-resolve.test.ts +137 -0
- package/src/providers/__tests__/wire-debug.test.ts +42 -0
- package/src/providers/adapter.ts +135 -27
- package/src/providers/anthropic.ts +7 -2
- package/src/providers/auth/__tests__/browser-flow.test.ts +235 -0
- package/src/providers/auth/__tests__/device-flow.test.ts +263 -0
- package/src/providers/auth/__tests__/gemini-oauth.test.ts +387 -0
- package/src/providers/auth/__tests__/openai-oauth.test.ts +378 -0
- package/src/providers/auth/__tests__/token-store.test.ts +152 -0
- package/src/providers/auth/browser-flow.ts +140 -0
- package/src/providers/auth/device-flow.ts +221 -0
- package/src/providers/auth/gemini-oauth.ts +351 -0
- package/src/providers/auth/openai-oauth.ts +455 -0
- package/src/providers/auth/registry.ts +121 -0
- package/src/providers/auth/token-store.ts +154 -0
- package/src/providers/auth/types.ts +111 -0
- package/src/providers/capabilities.ts +351 -0
- package/src/providers/endpoints.ts +68 -0
- package/src/providers/gemini.ts +7 -2
- package/src/providers/index.ts +5 -9
- package/src/providers/keychain.test.ts +5 -0
- package/src/providers/keychain.ts +137 -3
- package/src/providers/mcp-vision-bridge.test.ts +513 -0
- package/src/providers/mcp-vision-bridge.ts +1020 -0
- package/src/providers/openai-compatible.test.ts +2 -2
- package/src/providers/openai-compatible.ts +16 -8
- package/src/providers/openai.ts +21 -2
- package/src/providers/patch-zod-schema.ts +10 -13
- package/src/providers/pricing.test.ts +11 -2
- package/src/providers/pricing.ts +66 -10
- package/src/providers/prompt-cache-key.spec.ts +28 -0
- package/src/providers/runtime-mock.spec.ts +86 -0
- package/src/providers/runtime.ts +227 -55
- package/src/providers/siliconflow-history.ts +74 -0
- package/src/providers/strategies/anthropic.strategy.ts +25 -0
- package/src/providers/strategies/base.strategy.ts +76 -0
- package/src/providers/strategies/deepseek.strategy.ts +26 -0
- package/src/providers/strategies/google.strategy.ts +28 -0
- package/src/providers/strategies/ollama.strategy.ts +22 -0
- package/src/providers/strategies/openai.strategy.ts +55 -0
- package/src/providers/strategies/registry.ts +43 -0
- package/src/providers/strategies/siliconflow.strategy.ts +26 -0
- package/src/providers/strategies/xai.strategy.ts +26 -0
- package/src/providers/stream-loop.ts +15 -1
- package/src/providers/types.ts +34 -0
- package/src/providers/vision-proxy.test.ts +96 -11
- package/src/providers/vision-proxy.ts +153 -45
- package/src/providers/wire-debug.ts +163 -0
- package/src/router/__tests__/step-router.test.ts +150 -0
- package/src/router/classifier/regex.test.ts +3 -1
- package/src/router/classifier/regex.ts +71 -12
- package/src/router/cold.test.ts +5 -5
- package/src/router/decide.test.ts +17 -5
- package/src/router/decide.ts +144 -26
- package/src/router/provider-sentinel.test.ts +22 -0
- package/src/router/provider-sentinel.ts +20 -0
- package/src/router/step-router.ts +194 -0
- package/src/router/warm.test.ts +3 -2
- package/src/router/warm.ts +7 -1
- package/src/scaffold/__tests__/continuation-prompt.test.ts +93 -0
- package/src/scaffold/__tests__/continue-as-council.spec.ts +124 -0
- package/src/scaffold/__tests__/dotnet-assembly-name.test.ts +28 -0
- package/src/scaffold/__tests__/fe-scaffold-contents.test.ts +127 -0
- package/src/scaffold/__tests__/init-new.smoke.spec.ts +99 -0
- package/src/scaffold/__tests__/init-new.spec.ts +450 -0
- package/src/scaffold/__tests__/install-bb-templates.spec.ts +86 -0
- package/src/scaffold/__tests__/point-to-existing.spec.ts +114 -0
- package/src/scaffold/bb-ecosystem-apply.ts +454 -0
- package/src/scaffold/bb-quality-gate.ts +287 -0
- package/src/scaffold/continuation-prompt.ts +80 -0
- package/src/scaffold/continue-as-council.ts +99 -0
- package/src/scaffold/init-new.ts +1691 -0
- package/src/scaffold/point-to-existing.ts +83 -0
- package/src/scaffold/resume-from-gate-failures.ts +167 -0
- package/src/storage/__tests__/ui-interaction-log.test.ts +105 -0
- package/src/storage/atomic-io.test.ts +32 -1
- package/src/storage/atomic-io.ts +107 -9
- package/src/storage/config.ts +5 -1
- package/src/storage/db.ts +93 -4
- package/src/storage/index.ts +8 -1
- package/src/storage/interaction-log.ts +121 -0
- package/src/storage/migrations.ts +66 -4
- package/src/storage/sessions.ts +28 -0
- package/src/storage/transcript.ts +207 -4
- package/src/storage/ui-interaction-log.ts +160 -0
- package/src/storage/usage.ts +4 -2
- package/src/tools/bash.test.ts +27 -0
- package/src/tools/bash.ts +60 -4
- package/src/tools/file-tracker.test.ts +99 -0
- package/src/tools/file-tracker.ts +70 -0
- package/src/tools/file.ts +59 -5
- package/src/tools/registry.test.ts +38 -0
- package/src/tools/registry.ts +133 -27
- package/src/types/index.ts +166 -3
- package/src/ui/agents-modal.tsx +164 -144
- package/src/ui/app.tsx +6464 -6277
- package/src/ui/cards/__tests__/product-status-card.test.ts +30 -0
- package/src/ui/cards/product-status-card.tsx +117 -0
- package/src/ui/components/Toast.tsx +100 -0
- package/src/ui/components/__tests__/council-leader-bubble.test.ts +16 -0
- package/src/ui/components/__tests__/council-message-bubble.test.ts +85 -0
- package/src/ui/components/__tests__/council-phase-timeline.test.ts +57 -0
- package/src/ui/components/__tests__/council-placeholder-bubble.test.ts +16 -0
- package/src/ui/components/__tests__/council-question-card.test.ts +133 -0
- package/src/ui/components/__tests__/council-synthesis-banner.test.ts +12 -0
- package/src/ui/components/__tests__/use-pair-quote-buffer.test.ts +41 -0
- package/src/ui/components/bubble-layout.ts +66 -0
- package/src/ui/components/code-block-truncate.ts +24 -0
- package/src/ui/components/copy-flash-banner.tsx +31 -0
- package/src/ui/components/council-info-card.tsx +45 -0
- package/src/ui/components/council-leader-bubble.tsx +41 -0
- package/src/ui/components/council-message-bubble.tsx +111 -0
- package/src/ui/components/council-phase-timeline.tsx +91 -0
- package/src/ui/components/council-placeholder-bubble.tsx +65 -0
- package/src/ui/components/council-question-card.tsx +253 -0
- package/src/ui/components/council-status-list.tsx +111 -0
- package/src/ui/components/council-synthesis-banner.tsx +37 -0
- package/src/ui/components/diff-view.tsx +225 -0
- package/src/ui/components/halt-recovery-card.tsx +83 -0
- package/src/ui/components/hero-logo.tsx +62 -0
- package/src/ui/components/init-new-form-card.tsx +470 -0
- package/src/ui/components/lsp-views.tsx +104 -0
- package/src/ui/components/media-views.tsx +66 -0
- package/src/ui/components/message-view.tsx +343 -0
- package/src/ui/components/point-to-existing-form-card.tsx +136 -0
- package/src/ui/components/prompt-box.tsx +306 -0
- package/src/ui/components/role-palette.ts +62 -0
- package/src/ui/components/session-header.tsx +68 -0
- package/src/ui/components/slash-inline-menu.tsx +63 -0
- package/src/ui/components/structured-response-view.tsx +191 -0
- package/src/ui/components/tool-result-views.tsx +258 -0
- package/src/ui/components/use-pair-quote-buffer.ts +23 -0
- package/src/ui/constants.ts +242 -0
- package/src/ui/hooks/use-agent-editor.ts +64 -0
- package/src/ui/hooks/use-mcp-editor.ts +39 -0
- package/src/ui/hooks/use-model-picker.ts +50 -0
- package/src/ui/hooks/useTypeahead.ts +17 -3
- package/src/ui/mcp-modal.tsx +306 -278
- package/src/ui/modals/api-key-modal.tsx +99 -0
- package/src/ui/modals/connect-modal.tsx +259 -0
- package/src/ui/modals/model-picker-modal.tsx +323 -0
- package/src/ui/modals/sandbox-picker-modal.tsx +99 -0
- package/src/ui/modals/update-modal.tsx +67 -0
- package/src/ui/modals/wallet-picker-modal.tsx +186 -0
- package/src/ui/schedule-modal.tsx +75 -63
- package/src/ui/slash/__tests__/ideal.test.ts +134 -0
- package/src/ui/slash/__tests__/menu-parity.test.ts +43 -0
- package/src/ui/slash/__tests__/optimize.test.ts +2 -2
- package/src/ui/slash/__tests__/pin.test.ts +47 -0
- package/src/ui/slash/cost.ts +7 -3
- package/src/ui/slash/council-inspect.ts +188 -0
- package/src/ui/slash/council.ts +11 -8
- package/src/ui/slash/debug.ts +5 -5
- package/src/ui/slash/ee.ts +43 -10
- package/src/ui/slash/export.ts +281 -0
- package/src/ui/slash/ideal.ts +254 -0
- package/src/ui/slash/menu-items.ts +106 -0
- package/src/ui/slash/optimize.ts +1 -1
- package/src/ui/slash/pin.ts +41 -0
- package/src/ui/slash/registry.ts +9 -0
- package/src/ui/status-bar/index.tsx +22 -18
- package/src/ui/status-bar/store.ts +23 -3
- package/src/ui/syntax-highlight.ts +627 -0
- package/src/ui/theme.ts +41 -0
- package/src/ui/types.ts +83 -0
- package/src/ui/utils/color.ts +19 -0
- package/src/ui/utils/format.ts +86 -0
- package/src/ui/utils/modal.ts +9 -0
- package/src/ui/utils/text.ts +31 -0
- package/src/ui/utils/tools.ts +95 -0
- package/src/usage/__tests__/product-ledger.test.ts +85 -0
- package/src/usage/cost-log.ts +158 -0
- package/src/usage/decision-log.ts +86 -0
- package/src/usage/estimator.ts +24 -0
- package/src/usage/ledger.ts +40 -0
- package/src/usage/product-ledger.ts +111 -0
- package/src/usage/types.ts +1 -0
- package/src/utils/__tests__/auto-council-settings.test.ts +46 -0
- package/src/utils/__tests__/ee-logger.test.ts +197 -0
- package/src/utils/__tests__/file-lock.test.ts +74 -0
- package/src/utils/__tests__/rate-limit.test.ts +42 -0
- package/src/utils/__tests__/settings-disabled-models.test.ts +113 -0
- package/src/utils/__tests__/settings-web-research.test.ts +45 -0
- package/src/utils/__tests__/slugify.test.ts +45 -0
- package/src/utils/__tests__/visible-retry.test.ts +195 -0
- package/src/utils/clipboard-image.ts +38 -13
- package/src/utils/ee-logger.ts +163 -0
- package/src/utils/file-lock.ts +66 -0
- package/src/utils/host-clipboard.ts +38 -0
- package/src/utils/instructions.test.ts +28 -0
- package/src/utils/instructions.ts +37 -4
- package/src/utils/rate-limit.ts +21 -0
- package/src/utils/settings.test.ts +4 -4
- package/src/utils/settings.ts +1108 -787
- package/src/utils/shell.test.ts +72 -0
- package/src/utils/shell.ts +193 -0
- package/src/utils/slugify.ts +9 -0
- package/src/utils/visible-retry.ts +56 -0
- package/src/verify/__tests__/coverage-parsers.test.ts +86 -0
- package/src/verify/__tests__/dotnet-recipe.test.ts +88 -0
- package/src/verify/coverage-parsers.ts +76 -0
- package/src/verify/recipes.ts +76 -0
- package/dist/__test-stubs__/ee-server.js.map +0 -1
- package/dist/billing/index.js.map +0 -1
- package/dist/cloud/index.js.map +0 -1
- package/dist/daemon/scheduler.d.ts +0 -15
- package/dist/daemon/scheduler.js +0 -126
- package/dist/daemon/scheduler.js.map +0 -1
- package/dist/daemon/scheduler.test.js +0 -103
- package/dist/daemon/scheduler.test.js.map +0 -1
- package/dist/ee/__tests__/pipeline.integration.test.js +0 -151
- package/dist/ee/__tests__/pipeline.integration.test.js.map +0 -1
- package/dist/ee/auth.d.ts +0 -19
- package/dist/ee/auth.js +0 -48
- package/dist/ee/auth.js.map +0 -1
- package/dist/ee/auth.test.js.map +0 -1
- package/dist/ee/bridge.d.ts +0 -68
- package/dist/ee/bridge.js +0 -177
- package/dist/ee/bridge.js.map +0 -1
- package/dist/ee/bridge.test.js.map +0 -1
- package/dist/ee/client.js +0 -464
- package/dist/ee/client.js.map +0 -1
- package/dist/ee/client.test.js.map +0 -1
- package/dist/ee/embedding-cache.js.map +0 -1
- package/dist/ee/extract-session.js +0 -53
- package/dist/ee/extract-session.js.map +0 -1
- package/dist/ee/extract-session.test.js +0 -197
- package/dist/ee/extract-session.test.js.map +0 -1
- package/dist/ee/health.js +0 -64
- package/dist/ee/health.js.map +0 -1
- package/dist/ee/index.d.ts +0 -10
- package/dist/ee/index.js +0 -9
- package/dist/ee/index.js.map +0 -1
- package/dist/ee/intercept.js +0 -117
- package/dist/ee/intercept.js.map +0 -1
- package/dist/ee/intercept.test.js +0 -170
- package/dist/ee/intercept.test.js.map +0 -1
- package/dist/ee/judge.d.ts +0 -36
- package/dist/ee/judge.js +0 -56
- package/dist/ee/judge.js.map +0 -1
- package/dist/ee/judge.test.js +0 -139
- package/dist/ee/judge.test.js.map +0 -1
- package/dist/ee/offline-queue.js.map +0 -1
- package/dist/ee/offline-queue.test.js +0 -246
- package/dist/ee/offline-queue.test.js.map +0 -1
- package/dist/ee/posttool.js.map +0 -1
- package/dist/ee/posttool.test.js.map +0 -1
- package/dist/ee/prompt-stale.js.map +0 -1
- package/dist/ee/prompt-stale.test.js +0 -76
- package/dist/ee/prompt-stale.test.js.map +0 -1
- package/dist/ee/render.d.ts +0 -20
- package/dist/ee/render.js +0 -30
- package/dist/ee/render.js.map +0 -1
- package/dist/ee/render.test.js +0 -61
- package/dist/ee/render.test.js.map +0 -1
- package/dist/ee/scope.js.map +0 -1
- package/dist/ee/scope.test.js.map +0 -1
- package/dist/ee/tenant.js.map +0 -1
- package/dist/ee/touch.test.js +0 -60
- package/dist/ee/touch.test.js.map +0 -1
- package/dist/ee/types.d.ts +0 -300
- package/dist/ee/types.js.map +0 -1
- package/dist/flow/__tests__/migration.test.js.map +0 -1
- package/dist/flow/__tests__/parser.test.js.map +0 -1
- package/dist/flow/__tests__/run-manager.test.js.map +0 -1
- package/dist/flow/__tests__/scaffold.test.js.map +0 -1
- package/dist/flow/__tests__/warning-persist.test.js.map +0 -1
- package/dist/flow/artifact-io.js.map +0 -1
- package/dist/flow/compaction/__tests__/compress.test.js.map +0 -1
- package/dist/flow/compaction/__tests__/extract.test.js.map +0 -1
- package/dist/flow/compaction/__tests__/preserve.test.js.map +0 -1
- package/dist/flow/compaction/compress.js.map +0 -1
- package/dist/flow/compaction/extract.js.map +0 -1
- package/dist/flow/compaction/index.js.map +0 -1
- package/dist/flow/compaction/preserve.js.map +0 -1
- package/dist/flow/index.js.map +0 -1
- package/dist/flow/migration.js.map +0 -1
- package/dist/flow/parser.js.map +0 -1
- package/dist/flow/run-manager.d.ts +0 -36
- package/dist/flow/run-manager.js +0 -110
- package/dist/flow/run-manager.js.map +0 -1
- package/dist/flow/scaffold.js.map +0 -1
- package/dist/flow/warning-persist.js.map +0 -1
- package/dist/gsd/__tests__/types.test.js +0 -65
- package/dist/gsd/__tests__/types.test.js.map +0 -1
- package/dist/gsd/index.js.map +0 -1
- package/dist/gsd/types.d.ts +0 -4
- package/dist/gsd/types.js.map +0 -1
- package/dist/headless/output.d.ts +0 -68
- package/dist/headless/output.js.map +0 -1
- package/dist/headless/output.test.js +0 -178
- package/dist/headless/output.test.js.map +0 -1
- package/dist/hooks/config.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -44
- package/dist/hooks/index.js +0 -187
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -130
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -531
- package/dist/index.js.map +0 -1
- package/dist/lsp/builtins.d.ts +0 -9
- package/dist/lsp/builtins.js +0 -351
- package/dist/lsp/builtins.js.map +0 -1
- package/dist/lsp/builtins.test.js +0 -91
- package/dist/lsp/builtins.test.js.map +0 -1
- package/dist/lsp/client.d.ts +0 -20
- package/dist/lsp/client.js +0 -290
- package/dist/lsp/client.js.map +0 -1
- package/dist/lsp/manager.d.ts +0 -20
- package/dist/lsp/manager.js +0 -235
- package/dist/lsp/manager.js.map +0 -1
- package/dist/lsp/manager.test.js +0 -133
- package/dist/lsp/manager.test.js.map +0 -1
- package/dist/lsp/npm-cache.js.map +0 -1
- package/dist/lsp/npm-cache.test.js +0 -53
- package/dist/lsp/npm-cache.test.js.map +0 -1
- package/dist/lsp/runtime.d.ts +0 -6
- package/dist/lsp/runtime.js +0 -53
- package/dist/lsp/runtime.js.map +0 -1
- package/dist/lsp/smoke.test.js.map +0 -1
- package/dist/lsp/types.js.map +0 -1
- package/dist/mcp/auto-setup.js +0 -76
- package/dist/mcp/auto-setup.js.map +0 -1
- package/dist/mcp/catalog.js +0 -121
- package/dist/mcp/catalog.js.map +0 -1
- package/dist/mcp/oauth-callback.d.ts +0 -9
- package/dist/mcp/oauth-callback.js +0 -49
- package/dist/mcp/oauth-callback.js.map +0 -1
- package/dist/mcp/oauth-provider.js.map +0 -1
- package/dist/mcp/parse-headers.js.map +0 -1
- package/dist/mcp/parse-headers.test.js +0 -43
- package/dist/mcp/parse-headers.test.js.map +0 -1
- package/dist/mcp/runtime.js +0 -81
- package/dist/mcp/runtime.js.map +0 -1
- package/dist/mcp/smoke.test.js.map +0 -1
- package/dist/mcp/validate.d.ts +0 -9
- package/dist/mcp/validate.js.map +0 -1
- package/dist/models/__tests__/registry.test.js +0 -74
- package/dist/models/__tests__/registry.test.js.map +0 -1
- package/dist/models/catalog-client.js +0 -104
- package/dist/models/catalog-client.js.map +0 -1
- package/dist/models/catalog.json +0 -314
- package/dist/models/classify-tier.js +0 -34
- package/dist/models/classify-tier.js.map +0 -1
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.js +0 -2
- package/dist/models/index.js.map +0 -1
- package/dist/models/registry.d.ts +0 -19
- package/dist/models/registry.js +0 -65
- package/dist/models/registry.js.map +0 -1
- package/dist/ops/bug-report.js.map +0 -1
- package/dist/ops/bug-report.test.js.map +0 -1
- package/dist/ops/doctor.js +0 -162
- package/dist/ops/doctor.js.map +0 -1
- package/dist/ops/doctor.test.js +0 -95
- package/dist/ops/doctor.test.js.map +0 -1
- package/dist/orchestrator/__tests__/flow-resume.test.js.map +0 -1
- package/dist/orchestrator/__tests__/route-feedback.test.js +0 -47
- package/dist/orchestrator/__tests__/route-feedback.test.js.map +0 -1
- package/dist/orchestrator/abort.js.map +0 -1
- package/dist/orchestrator/abort.test.js.map +0 -1
- package/dist/orchestrator/agent.test.js +0 -126
- package/dist/orchestrator/agent.test.js.map +0 -1
- package/dist/orchestrator/cleanup.test.js +0 -67
- package/dist/orchestrator/cleanup.test.js.map +0 -1
- package/dist/orchestrator/compaction.d.ts +0 -36
- package/dist/orchestrator/compaction.js +0 -375
- package/dist/orchestrator/compaction.js.map +0 -1
- package/dist/orchestrator/compaction.test.js +0 -105
- package/dist/orchestrator/compaction.test.js.map +0 -1
- package/dist/orchestrator/delegations.d.ts +0 -49
- package/dist/orchestrator/delegations.js.map +0 -1
- package/dist/orchestrator/delegations.test.js +0 -107
- package/dist/orchestrator/delegations.test.js.map +0 -1
- package/dist/orchestrator/flow-resume.d.ts +0 -25
- package/dist/orchestrator/flow-resume.js +0 -53
- package/dist/orchestrator/flow-resume.js.map +0 -1
- package/dist/orchestrator/orchestrator.d.ts +0 -239
- package/dist/orchestrator/orchestrator.js +0 -3209
- package/dist/orchestrator/orchestrator.js.map +0 -1
- package/dist/orchestrator/pending-calls.js.map +0 -1
- package/dist/orchestrator/pending-calls.test.js.map +0 -1
- package/dist/orchestrator/reasoning.js +0 -53
- package/dist/orchestrator/reasoning.js.map +0 -1
- package/dist/orchestrator/reasoning.test.js +0 -26
- package/dist/orchestrator/reasoning.test.js.map +0 -1
- package/dist/orchestrator/sandbox.test.js +0 -94
- package/dist/orchestrator/sandbox.test.js.map +0 -1
- package/dist/pil/__tests__/budget.test.js +0 -33
- package/dist/pil/__tests__/budget.test.js.map +0 -1
- package/dist/pil/__tests__/layer1-intent.test.js +0 -199
- package/dist/pil/__tests__/layer1-intent.test.js.map +0 -1
- package/dist/pil/__tests__/layer2-personality.test.js +0 -57
- package/dist/pil/__tests__/layer2-personality.test.js.map +0 -1
- package/dist/pil/__tests__/layer3-ee-injection.test.js +0 -96
- package/dist/pil/__tests__/layer3-ee-injection.test.js.map +0 -1
- package/dist/pil/__tests__/layer4-gsd.test.js +0 -68
- package/dist/pil/__tests__/layer4-gsd.test.js.map +0 -1
- package/dist/pil/__tests__/layer5-context.test.js +0 -100
- package/dist/pil/__tests__/layer5-context.test.js.map +0 -1
- package/dist/pil/__tests__/layer6-output.test.js +0 -115
- package/dist/pil/__tests__/layer6-output.test.js.map +0 -1
- package/dist/pil/__tests__/ollama-classify.test.js.map +0 -1
- package/dist/pil/__tests__/orchestrator-integration.test.js.map +0 -1
- package/dist/pil/__tests__/pipeline.test.js +0 -150
- package/dist/pil/__tests__/pipeline.test.js.map +0 -1
- package/dist/pil/__tests__/response-tools.test.js +0 -133
- package/dist/pil/__tests__/response-tools.test.js.map +0 -1
- package/dist/pil/__tests__/schema.test.js +0 -112
- package/dist/pil/__tests__/schema.test.js.map +0 -1
- package/dist/pil/__tests__/store.test.js.map +0 -1
- package/dist/pil/__tests__/task-tier-map.test.js.map +0 -1
- package/dist/pil/budget.js.map +0 -1
- package/dist/pil/index.d.ts +0 -11
- package/dist/pil/index.js +0 -11
- package/dist/pil/index.js.map +0 -1
- package/dist/pil/layer1-intent.d.ts +0 -13
- package/dist/pil/layer1-intent.js +0 -142
- package/dist/pil/layer1-intent.js.map +0 -1
- package/dist/pil/layer2-personality.js +0 -29
- package/dist/pil/layer2-personality.js.map +0 -1
- package/dist/pil/layer3-ee-injection.d.ts +0 -10
- package/dist/pil/layer3-ee-injection.js +0 -72
- package/dist/pil/layer3-ee-injection.js.map +0 -1
- package/dist/pil/layer4-gsd.d.ts +0 -2
- package/dist/pil/layer4-gsd.js +0 -64
- package/dist/pil/layer4-gsd.js.map +0 -1
- package/dist/pil/layer5-context.js +0 -124
- package/dist/pil/layer5-context.js.map +0 -1
- package/dist/pil/layer6-output.d.ts +0 -18
- package/dist/pil/layer6-output.js +0 -105
- package/dist/pil/layer6-output.js.map +0 -1
- package/dist/pil/ollama-classify.js.map +0 -1
- package/dist/pil/pipeline.d.ts +0 -16
- package/dist/pil/pipeline.js +0 -96
- package/dist/pil/pipeline.js.map +0 -1
- package/dist/pil/response-tools.d.ts +0 -63
- package/dist/pil/response-tools.js +0 -87
- package/dist/pil/response-tools.js.map +0 -1
- package/dist/pil/schema.d.ts +0 -80
- package/dist/pil/schema.js +0 -43
- package/dist/pil/schema.js.map +0 -1
- package/dist/pil/store.js.map +0 -1
- package/dist/pil/task-tier-map.js.map +0 -1
- package/dist/pil/timeout.js.map +0 -1
- package/dist/pil/types.d.ts +0 -39
- package/dist/pil/types.js.map +0 -1
- package/dist/providers/__test-utils__/load-fixture.js.map +0 -1
- package/dist/providers/__tests__/runtime-integration.test.js +0 -71
- package/dist/providers/__tests__/runtime-integration.test.js.map +0 -1
- package/dist/providers/__tests__/runtime.test.js +0 -76
- package/dist/providers/__tests__/runtime.test.js.map +0 -1
- package/dist/providers/adapter.d.ts +0 -15
- package/dist/providers/adapter.js +0 -45
- package/dist/providers/adapter.js.map +0 -1
- package/dist/providers/adapter.test.js.map +0 -1
- package/dist/providers/anthropic.js +0 -141
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/errors.js.map +0 -1
- package/dist/providers/errors.test.js.map +0 -1
- package/dist/providers/gemini.js +0 -33
- package/dist/providers/gemini.js.map +0 -1
- package/dist/providers/gemini.test.js.map +0 -1
- package/dist/providers/index.d.ts +0 -11
- package/dist/providers/index.js +0 -15
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/keychain.d.ts +0 -32
- package/dist/providers/keychain.js +0 -127
- package/dist/providers/keychain.js.map +0 -1
- package/dist/providers/keychain.test.js +0 -80
- package/dist/providers/keychain.test.js.map +0 -1
- package/dist/providers/ollama.js.map +0 -1
- package/dist/providers/ollama.test.js.map +0 -1
- package/dist/providers/openai-compatible.js +0 -45
- package/dist/providers/openai-compatible.js.map +0 -1
- package/dist/providers/openai-compatible.test.js +0 -53
- package/dist/providers/openai-compatible.test.js.map +0 -1
- package/dist/providers/openai.d.ts +0 -11
- package/dist/providers/openai.js +0 -33
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/openai.test.js.map +0 -1
- package/dist/providers/patch-zod-schema.js +0 -121
- package/dist/providers/patch-zod-schema.js.map +0 -1
- package/dist/providers/pricing.d.ts +0 -21
- package/dist/providers/pricing.js +0 -50
- package/dist/providers/pricing.js.map +0 -1
- package/dist/providers/pricing.test.js +0 -47
- package/dist/providers/pricing.test.js.map +0 -1
- package/dist/providers/runtime.d.ts +0 -21
- package/dist/providers/runtime.js +0 -83
- package/dist/providers/runtime.js.map +0 -1
- package/dist/providers/stream-loop.d.ts +0 -16
- package/dist/providers/stream-loop.js +0 -63
- package/dist/providers/stream-loop.js.map +0 -1
- package/dist/providers/types.d.ts +0 -106
- package/dist/providers/types.js +0 -12
- package/dist/providers/types.js.map +0 -1
- package/dist/providers/vision-proxy.js +0 -152
- package/dist/providers/vision-proxy.js.map +0 -1
- package/dist/providers/vision-proxy.test.js +0 -136
- package/dist/providers/vision-proxy.test.js.map +0 -1
- package/dist/router/classifier/grammars.js.map +0 -1
- package/dist/router/classifier/index.js.map +0 -1
- package/dist/router/classifier/index.test.js.map +0 -1
- package/dist/router/classifier/regex.js +0 -45
- package/dist/router/classifier/regex.js.map +0 -1
- package/dist/router/classifier/regex.test.js.map +0 -1
- package/dist/router/classifier/tree-sitter.js.map +0 -1
- package/dist/router/classifier/tree-sitter.test.js.map +0 -1
- package/dist/router/cold.js.map +0 -1
- package/dist/router/cold.test.js +0 -56
- package/dist/router/cold.test.js.map +0 -1
- package/dist/router/decide.js +0 -300
- package/dist/router/decide.js.map +0 -1
- package/dist/router/decide.test.js +0 -116
- package/dist/router/decide.test.js.map +0 -1
- package/dist/router/health.js.map +0 -1
- package/dist/router/health.test.js.map +0 -1
- package/dist/router/store.js.map +0 -1
- package/dist/router/types.js.map +0 -1
- package/dist/router/warm.js +0 -40
- package/dist/router/warm.js.map +0 -1
- package/dist/router/warm.test.js +0 -144
- package/dist/router/warm.test.js.map +0 -1
- package/dist/storage/__tests__/migrations.test.js.map +0 -1
- package/dist/storage/atomic-io.d.ts +0 -18
- package/dist/storage/atomic-io.js +0 -65
- package/dist/storage/atomic-io.js.map +0 -1
- package/dist/storage/atomic-io.test.js +0 -49
- package/dist/storage/atomic-io.test.js.map +0 -1
- package/dist/storage/config.js +0 -35
- package/dist/storage/config.js.map +0 -1
- package/dist/storage/config.test.js.map +0 -1
- package/dist/storage/db.js +0 -71
- package/dist/storage/db.js.map +0 -1
- package/dist/storage/index.d.ts +0 -8
- package/dist/storage/index.js +0 -10
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/migrations.d.ts +0 -2
- package/dist/storage/migrations.js +0 -138
- package/dist/storage/migrations.js.map +0 -1
- package/dist/storage/session-dir.js.map +0 -1
- package/dist/storage/sessions.d.ts +0 -16
- package/dist/storage/sessions.js +0 -142
- package/dist/storage/sessions.js.map +0 -1
- package/dist/storage/tool-results.d.ts +0 -4
- package/dist/storage/tool-results.js.map +0 -1
- package/dist/storage/transcript-view.js +0 -23
- package/dist/storage/transcript-view.js.map +0 -1
- package/dist/storage/transcript.d.ts +0 -12
- package/dist/storage/transcript.js +0 -269
- package/dist/storage/transcript.js.map +0 -1
- package/dist/storage/transcript.test.js +0 -22
- package/dist/storage/transcript.test.js.map +0 -1
- package/dist/storage/usage-cap.js.map +0 -1
- package/dist/storage/usage-cap.test.js.map +0 -1
- package/dist/storage/usage.d.ts +0 -11
- package/dist/storage/usage.js +0 -65
- package/dist/storage/usage.js.map +0 -1
- package/dist/storage/workspaces.d.ts +0 -9
- package/dist/storage/workspaces.js +0 -60
- package/dist/storage/workspaces.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -46
- package/dist/tools/bash.js +0 -541
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/bash.test.js +0 -240
- package/dist/tools/bash.test.js.map +0 -1
- package/dist/tools/computer.d.ts +0 -88
- package/dist/tools/computer.js.map +0 -1
- package/dist/tools/computer.test.js +0 -142
- package/dist/tools/computer.test.js.map +0 -1
- package/dist/tools/file.d.ts +0 -17
- package/dist/tools/file.js +0 -101
- package/dist/tools/file.js.map +0 -1
- package/dist/tools/file.test.js +0 -58
- package/dist/tools/file.test.js.map +0 -1
- package/dist/tools/grep.d.ts +0 -8
- package/dist/tools/grep.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -19
- package/dist/tools/registry.js +0 -245
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/schedule.js +0 -498
- package/dist/tools/schedule.js.map +0 -1
- package/dist/tools/schedule.test.js +0 -118
- package/dist/tools/schedule.test.js.map +0 -1
- package/dist/types/index.d.ts +0 -279
- package/dist/types/index.js.map +0 -1
- package/dist/ui/agents-modal.d.ts +0 -36
- package/dist/ui/agents-modal.js +0 -54
- package/dist/ui/agents-modal.js.map +0 -1
- package/dist/ui/app.d.ts +0 -31
- package/dist/ui/app.js +0 -3957
- package/dist/ui/app.js.map +0 -1
- package/dist/ui/components/SuggestionOverlay.js.map +0 -1
- package/dist/ui/components/btw-overlay.js.map +0 -1
- package/dist/ui/hooks/useTypeahead.js +0 -111
- package/dist/ui/hooks/useTypeahead.js.map +0 -1
- package/dist/ui/markdown.d.ts +0 -5
- package/dist/ui/markdown.js.map +0 -1
- package/dist/ui/mcp-modal-types.d.ts +0 -24
- package/dist/ui/mcp-modal-types.js.map +0 -1
- package/dist/ui/mcp-modal.d.ts +0 -33
- package/dist/ui/mcp-modal.js +0 -94
- package/dist/ui/mcp-modal.js.map +0 -1
- package/dist/ui/plan.d.ts +0 -24
- package/dist/ui/plan.js.map +0 -1
- package/dist/ui/schedule-modal.d.ts +0 -15
- package/dist/ui/schedule-modal.js +0 -36
- package/dist/ui/schedule-modal.js.map +0 -1
- package/dist/ui/slash/__tests__/clear.test.js.map +0 -1
- package/dist/ui/slash/__tests__/compact.test.js.map +0 -1
- package/dist/ui/slash/__tests__/cost.test.js.map +0 -1
- package/dist/ui/slash/__tests__/discuss.test.js.map +0 -1
- package/dist/ui/slash/__tests__/execute.test.js.map +0 -1
- package/dist/ui/slash/__tests__/expand.test.js.map +0 -1
- package/dist/ui/slash/__tests__/optimize.test.js +0 -130
- package/dist/ui/slash/__tests__/optimize.test.js.map +0 -1
- package/dist/ui/slash/__tests__/plan.test.js.map +0 -1
- package/dist/ui/slash/clear.js.map +0 -1
- package/dist/ui/slash/compact.js.map +0 -1
- package/dist/ui/slash/cost.js +0 -55
- package/dist/ui/slash/cost.js.map +0 -1
- package/dist/ui/slash/council.js +0 -22
- package/dist/ui/slash/council.js.map +0 -1
- package/dist/ui/slash/debug.js +0 -111
- package/dist/ui/slash/debug.js.map +0 -1
- package/dist/ui/slash/discuss.js.map +0 -1
- package/dist/ui/slash/ee.js +0 -247
- package/dist/ui/slash/ee.js.map +0 -1
- package/dist/ui/slash/execute.js.map +0 -1
- package/dist/ui/slash/expand.js.map +0 -1
- package/dist/ui/slash/optimize.js +0 -37
- package/dist/ui/slash/optimize.js.map +0 -1
- package/dist/ui/slash/plan.js.map +0 -1
- package/dist/ui/slash/registry.d.ts +0 -23
- package/dist/ui/slash/registry.js.map +0 -1
- package/dist/ui/slash/route.js.map +0 -1
- package/dist/ui/slash/route.test.js.map +0 -1
- package/dist/ui/status-bar/index.d.ts +0 -14
- package/dist/ui/status-bar/index.js +0 -74
- package/dist/ui/status-bar/index.js.map +0 -1
- package/dist/ui/status-bar/index.test.js.map +0 -1
- package/dist/ui/status-bar/store.d.ts +0 -38
- package/dist/ui/status-bar/store.js +0 -144
- package/dist/ui/status-bar/store.js.map +0 -1
- package/dist/ui/status-bar/store.test.js.map +0 -1
- package/dist/ui/status-bar/tier-badge.js.map +0 -1
- package/dist/ui/status-bar/tier-badge.test.js.map +0 -1
- package/dist/ui/status-bar/usd-meter.js.map +0 -1
- package/dist/ui/status-bar/usd-meter.test.js.map +0 -1
- package/dist/ui/terminal-selection-text.js.map +0 -1
- package/dist/ui/theme.d.ts +0 -53
- package/dist/ui/theme.js +0 -53
- package/dist/ui/theme.js.map +0 -1
- package/dist/usage/downgrade.js.map +0 -1
- package/dist/usage/downgrade.test.js.map +0 -1
- package/dist/usage/estimator.d.ts +0 -17
- package/dist/usage/estimator.js +0 -28
- package/dist/usage/estimator.js.map +0 -1
- package/dist/usage/estimator.test.js.map +0 -1
- package/dist/usage/ledger.d.ts +0 -42
- package/dist/usage/ledger.js +0 -181
- package/dist/usage/ledger.js.map +0 -1
- package/dist/usage/ledger.test.js.map +0 -1
- package/dist/usage/midstream.js.map +0 -1
- package/dist/usage/midstream.test.js.map +0 -1
- package/dist/usage/thresholds.js.map +0 -1
- package/dist/usage/thresholds.test.js.map +0 -1
- package/dist/usage/types.d.ts +0 -30
- package/dist/usage/types.js.map +0 -1
- package/dist/utils/at-mentions.js.map +0 -1
- package/dist/utils/clipboard-image.js +0 -121
- package/dist/utils/clipboard-image.js.map +0 -1
- package/dist/utils/file-index.js.map +0 -1
- package/dist/utils/git-root.js.map +0 -1
- package/dist/utils/host-clipboard.d.ts +0 -4
- package/dist/utils/host-clipboard.js +0 -32
- package/dist/utils/host-clipboard.js.map +0 -1
- package/dist/utils/install-manager.js.map +0 -1
- package/dist/utils/install-manager.test.js +0 -127
- package/dist/utils/install-manager.test.js.map +0 -1
- package/dist/utils/instructions.js +0 -107
- package/dist/utils/instructions.js.map +0 -1
- package/dist/utils/instructions.test.js +0 -68
- package/dist/utils/instructions.test.js.map +0 -1
- package/dist/utils/permission-mode.js.map +0 -1
- package/dist/utils/permission-mode.test.js.map +0 -1
- package/dist/utils/redactor.js.map +0 -1
- package/dist/utils/redactor.test.js +0 -84
- package/dist/utils/redactor.test.js.map +0 -1
- package/dist/utils/settings.d.ts +0 -179
- package/dist/utils/settings.js +0 -579
- package/dist/utils/settings.js.map +0 -1
- package/dist/utils/settings.test.js +0 -160
- package/dist/utils/settings.test.js.map +0 -1
- package/dist/utils/side-question.js.map +0 -1
- package/dist/utils/skills.js +0 -194
- package/dist/utils/skills.js.map +0 -1
- package/dist/utils/skills.test.js +0 -45
- package/dist/utils/skills.test.js.map +0 -1
- package/dist/utils/subagent-display.js.map +0 -1
- package/dist/utils/subagent-display.test.js +0 -21
- package/dist/utils/subagent-display.test.js.map +0 -1
- package/dist/utils/subagents-settings.test.js +0 -58
- package/dist/utils/subagents-settings.test.js.map +0 -1
- package/dist/utils/telegram-audio-settings.test.js +0 -39
- package/dist/utils/telegram-audio-settings.test.js.map +0 -1
- package/dist/utils/update-checker.js +0 -22
- package/dist/utils/update-checker.js.map +0 -1
- package/dist/utils/update-checker.test.js +0 -125
- package/dist/utils/update-checker.test.js.map +0 -1
- package/dist/verify/checkpoint.d.ts +0 -11
- package/dist/verify/checkpoint.js.map +0 -1
- package/dist/verify/checkpoint.test.js +0 -160
- package/dist/verify/checkpoint.test.js.map +0 -1
- package/dist/verify/entrypoint.d.ts +0 -30
- package/dist/verify/entrypoint.js +0 -349
- package/dist/verify/entrypoint.js.map +0 -1
- package/dist/verify/entrypoint.test.js +0 -233
- package/dist/verify/entrypoint.test.js.map +0 -1
- package/dist/verify/environment.d.ts +0 -9
- package/dist/verify/environment.js +0 -116
- package/dist/verify/environment.js.map +0 -1
- package/dist/verify/environment.test.js +0 -94
- package/dist/verify/environment.test.js.map +0 -1
- package/dist/verify/evidence.d.ts +0 -10
- package/dist/verify/evidence.js.map +0 -1
- package/dist/verify/orchestrator.d.ts +0 -25
- package/dist/verify/orchestrator.js +0 -87
- package/dist/verify/orchestrator.js.map +0 -1
- package/dist/verify/orchestrator.test.js +0 -126
- package/dist/verify/orchestrator.test.js.map +0 -1
- package/dist/verify/recipes.d.ts +0 -20
- package/dist/verify/recipes.js +0 -451
- package/dist/verify/recipes.js.map +0 -1
- package/dist/verify/retry.d.ts +0 -4
- package/dist/verify/retry.js.map +0 -1
- package/dist/verify/runtime-prep.test.js +0 -38
- package/dist/verify/runtime-prep.test.js.map +0 -1
- /package/dist/{__test-stubs__ → src/__test-stubs__}/ee-server.d.ts +0 -0
- /package/dist/{__test-stubs__ → src/__test-stubs__}/ee-server.js +0 -0
- /package/dist/{daemon/scheduler.test.d.ts → src/__test-stubs__/vitest-setup.d.ts} +0 -0
- /package/dist/{ee/auth.test.d.ts → src/__tests__/council/bubble-layout.test.d.ts} +0 -0
- /package/dist/{ee/bridge.test.d.ts → src/__tests__/council/code-block-truncate.test.d.ts} +0 -0
- /package/dist/{ee/client.test.d.ts → src/__tests__/council/role-palette.test.d.ts} +0 -0
- /package/dist/{ee/extract-session.test.d.ts → src/__tests__/first-run-wizard.test.d.ts} +0 -0
- /package/dist/{ee/intercept.test.d.ts → src/agent-harness/__tests__/cli-flags.spec.d.ts} +0 -0
- /package/dist/{ee/judge.test.d.ts → src/agent-harness/__tests__/driver.spec.d.ts} +0 -0
- /package/dist/{ee/offline-queue.test.d.ts → src/agent-harness/__tests__/idle.spec.d.ts} +0 -0
- /package/dist/{ee/posttool.test.d.ts → src/agent-harness/__tests__/mock-llm.spec.d.ts} +0 -0
- /package/dist/{ee/render.test.d.ts → src/agent-harness/__tests__/predicate.spec.d.ts} +0 -0
- /package/dist/{ee/scope.test.d.ts → src/agent-harness/__tests__/protocol.spec.d.ts} +0 -0
- /package/dist/{ee/touch.test.d.ts → src/agent-harness/__tests__/schema.spec.d.ts} +0 -0
- /package/dist/{flow/__tests__/migration.test.d.ts → src/agent-harness/__tests__/selector.spec.d.ts} +0 -0
- /package/dist/{flow/__tests__/parser.test.d.ts → src/agent-harness/__tests__/sidechannel.spec.d.ts} +0 -0
- /package/dist/{flow/__tests__/run-manager.test.d.ts → src/agent-harness/__tests__/spec-helpers.spec.d.ts} +0 -0
- /package/dist/{billing → src/billing}/index.d.ts +0 -0
- /package/dist/{billing → src/billing}/index.js +0 -0
- /package/dist/{flow/__tests__/scaffold.test.d.ts → src/chat/__tests__/broadcast-bus.test.d.ts} +0 -0
- /package/dist/{flow/compaction/__tests__/compress.test.d.ts → src/chat/__tests__/channel-manager.test.d.ts} +0 -0
- /package/dist/{flow/compaction/__tests__/extract.test.d.ts → src/chat/__tests__/client.test.d.ts} +0 -0
- /package/dist/{flow/compaction/__tests__/preserve.test.d.ts → src/chat/__tests__/discord-integration.test.d.ts} +0 -0
- /package/dist/{gsd/__tests__/types.test.d.ts → src/chat/__tests__/intent-prompt.test.d.ts} +0 -0
- /package/dist/{headless/output.test.d.ts → src/chat/__tests__/verdict-resolver.test.d.ts} +0 -0
- /package/dist/{lsp/builtins.test.d.ts → src/cli/__tests__/bw-vault.test.d.ts} +0 -0
- /package/dist/{lsp/manager.test.d.ts → src/cli/__tests__/keys-bundle.test.d.ts} +0 -0
- /package/dist/{lsp/npm-cache.test.d.ts → src/cli/__tests__/share-cmd.test.d.ts} +0 -0
- /package/dist/{lsp/smoke.test.d.ts → src/cli/config/__tests__/model-picker.test.d.ts} +0 -0
- /package/dist/{mcp/parse-headers.test.d.ts → src/cli/config/__tests__/provider-fetch.test.d.ts} +0 -0
- /package/dist/{mcp/smoke.test.d.ts → src/cli/cost-forensics.test.d.ts} +0 -0
- /package/dist/{models/__tests__/registry.test.d.ts → src/cli/keys.test.d.ts} +0 -0
- /package/dist/{cloud → src/cloud}/index.d.ts +0 -0
- /package/dist/{cloud → src/cloud}/index.js +0 -0
- /package/dist/{ops/bug-report.test.d.ts → src/council/__tests__/accounting.test.d.ts} +0 -0
- /package/dist/{ops/doctor.test.d.ts → src/council/__tests__/audit-replay.test.d.ts} +0 -0
- /package/dist/{orchestrator/__tests__/route-feedback.test.d.ts → src/council/__tests__/clarifier-max-rounds.test.d.ts} +0 -0
- /package/dist/{orchestrator/abort.test.d.ts → src/council/__tests__/clarifier-options.test.d.ts} +0 -0
- /package/dist/{orchestrator/agent.test.d.ts → src/council/__tests__/cost-aware.test.d.ts} +0 -0
- /package/dist/{orchestrator/cleanup.test.d.ts → src/council/__tests__/debate-planner-structured.test.d.ts} +0 -0
- /package/dist/{orchestrator/compaction.test.d.ts → src/council/__tests__/evaluator-metrics.test.d.ts} +0 -0
- /package/dist/{orchestrator/delegations.test.d.ts → src/council/__tests__/parse-outcome-fallback.test.d.ts} +0 -0
- /package/dist/{orchestrator/pending-calls.test.d.ts → src/council/__tests__/research-tools.test.d.ts} +0 -0
- /package/dist/{orchestrator/reasoning.test.d.ts → src/council/__tests__/round-tools.test.d.ts} +0 -0
- /package/dist/{orchestrator/sandbox.test.d.ts → src/council/__tests__/tool-trace.test.d.ts} +0 -0
- /package/dist/{router → src/council}/types.js +0 -0
- /package/dist/{pil/__tests__/budget.test.d.ts → src/daemon/scheduler.test.d.ts} +0 -0
- /package/dist/{pil/__tests__/layer1-intent.test.d.ts → src/ee/__tests__/pil-context-bridge.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/__tests__/pipeline.integration.test.d.ts +0 -0
- /package/dist/{pil/__tests__/layer2-personality.test.d.ts → src/ee/__tests__/render-sink-wiring.test.d.ts} +0 -0
- /package/dist/{pil/__tests__/layer3-ee-injection.test.d.ts → src/ee/auth.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/auth.test.js +0 -0
- /package/dist/{pil/__tests__/layer4-gsd.test.d.ts → src/ee/bridge.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/bridge.test.js +0 -0
- /package/dist/{ee → src/ee}/client.d.ts +0 -0
- /package/dist/{pil/__tests__/layer5-context.test.d.ts → src/ee/client.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/client.test.js +0 -0
- /package/dist/{ee → src/ee}/embedding-cache.d.ts +0 -0
- /package/dist/{ee → src/ee}/embedding-cache.js +0 -0
- /package/dist/{ee → src/ee}/extract-session.d.ts +0 -0
- /package/dist/{pil/__tests__/layer6-output.test.d.ts → src/ee/extract-session.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/health.d.ts +0 -0
- /package/dist/{ee → src/ee}/intercept.d.ts +0 -0
- /package/dist/{pil/__tests__/ollama-classify.test.d.ts → src/ee/intercept.test.d.ts} +0 -0
- /package/dist/{pil/__tests__/pipeline.test.d.ts → src/ee/judge.test.d.ts} +0 -0
- /package/dist/{pil/__tests__/response-tools.test.d.ts → src/ee/mistake-detector.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/offline-queue.d.ts +0 -0
- /package/dist/{ee → src/ee}/offline-queue.js +0 -0
- /package/dist/{pil/__tests__/schema.test.d.ts → src/ee/offline-queue.test.d.ts} +0 -0
- /package/dist/{pil/__tests__/store.test.d.ts → src/ee/phase-outcome.test.d.ts} +0 -0
- /package/dist/{pil/__tests__/task-tier-map.test.d.ts → src/ee/phase-tracker.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/posttool.d.ts +0 -0
- /package/dist/{ee → src/ee}/posttool.js +0 -0
- /package/dist/{providers/__tests__/runtime-integration.test.d.ts → src/ee/posttool.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/posttool.test.js +0 -0
- /package/dist/{ee → src/ee}/prompt-stale.d.ts +0 -0
- /package/dist/{ee → src/ee}/prompt-stale.js +0 -0
- /package/dist/{ee → src/ee}/prompt-stale.test.d.ts +0 -0
- /package/dist/{providers/__tests__/runtime.test.d.ts → src/ee/render.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/scope.d.ts +0 -0
- /package/dist/{ee → src/ee}/scope.js +0 -0
- /package/dist/{providers/adapter.test.d.ts → src/ee/scope.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/scope.test.js +0 -0
- /package/dist/{providers/errors.test.d.ts → src/ee/session-trajectory.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/tenant.d.ts +0 -0
- /package/dist/{ee → src/ee}/tenant.js +0 -0
- /package/dist/{providers/gemini.test.d.ts → src/ee/touch.test.d.ts} +0 -0
- /package/dist/{ee → src/ee}/types.js +0 -0
- /package/dist/{providers/keychain.test.d.ts → src/flow/__tests__/migration.test.d.ts} +0 -0
- /package/dist/{flow → src/flow}/__tests__/migration.test.js +0 -0
- /package/dist/{providers/ollama.test.d.ts → src/flow/__tests__/parser.test.d.ts} +0 -0
- /package/dist/{flow → src/flow}/__tests__/parser.test.js +0 -0
- /package/dist/{providers/openai-compatible.test.d.ts → src/flow/__tests__/run-manager-product.test.d.ts} +0 -0
- /package/dist/{providers/openai.test.d.ts → src/flow/__tests__/run-manager.test.d.ts} +0 -0
- /package/dist/{flow → src/flow}/__tests__/run-manager.test.js +0 -0
- /package/dist/{providers/pricing.test.d.ts → src/flow/__tests__/scaffold-checkpoint.test.d.ts} +0 -0
- /package/dist/{providers/vision-proxy.test.d.ts → src/flow/__tests__/scaffold.test.d.ts} +0 -0
- /package/dist/{flow → src/flow}/__tests__/scaffold.test.js +0 -0
- /package/dist/{flow → src/flow}/__tests__/warning-persist.test.d.ts +0 -0
- /package/dist/{flow → src/flow}/__tests__/warning-persist.test.js +0 -0
- /package/dist/{flow → src/flow}/artifact-io.d.ts +0 -0
- /package/dist/{flow → src/flow}/artifact-io.js +0 -0
- /package/dist/{router/classifier/index.test.d.ts → src/flow/compaction/__tests__/compress.test.d.ts} +0 -0
- /package/dist/{flow → src/flow}/compaction/__tests__/compress.test.js +0 -0
- /package/dist/{router/classifier/regex.test.d.ts → src/flow/compaction/__tests__/extract.test.d.ts} +0 -0
- /package/dist/{flow → src/flow}/compaction/__tests__/extract.test.js +0 -0
- /package/dist/{router/classifier/tree-sitter.test.d.ts → src/flow/compaction/__tests__/preserve.test.d.ts} +0 -0
- /package/dist/{flow → src/flow}/compaction/__tests__/preserve.test.js +0 -0
- /package/dist/{flow → src/flow}/compaction/compress.d.ts +0 -0
- /package/dist/{flow → src/flow}/compaction/compress.js +0 -0
- /package/dist/{flow → src/flow}/compaction/extract.d.ts +0 -0
- /package/dist/{flow → src/flow}/compaction/extract.js +0 -0
- /package/dist/{flow → src/flow}/compaction/index.d.ts +0 -0
- /package/dist/{flow → src/flow}/compaction/index.js +0 -0
- /package/dist/{flow → src/flow}/compaction/preserve.d.ts +0 -0
- /package/dist/{flow → src/flow}/compaction/preserve.js +0 -0
- /package/dist/{flow → src/flow}/index.d.ts +0 -0
- /package/dist/{flow → src/flow}/index.js +0 -0
- /package/dist/{flow → src/flow}/migration.d.ts +0 -0
- /package/dist/{flow → src/flow}/migration.js +0 -0
- /package/dist/{flow → src/flow}/parser.d.ts +0 -0
- /package/dist/{flow → src/flow}/parser.js +0 -0
- /package/dist/{flow → src/flow}/scaffold.d.ts +0 -0
- /package/dist/{flow → src/flow}/scaffold.js +0 -0
- /package/dist/{flow → src/flow}/warning-persist.d.ts +0 -0
- /package/dist/{flow → src/flow}/warning-persist.js +0 -0
- /package/dist/{router/cold.test.d.ts → src/gsd/__tests__/complexity.test.d.ts} +0 -0
- /package/dist/{router/decide.test.d.ts → src/gsd/__tests__/directives.test.d.ts} +0 -0
- /package/dist/{router/health.test.d.ts → src/gsd/__tests__/gray-areas.test.d.ts} +0 -0
- /package/dist/{router/warm.test.d.ts → src/gsd/__tests__/types.test.d.ts} +0 -0
- /package/dist/{gsd → src/gsd}/index.d.ts +0 -0
- /package/dist/{gsd → src/gsd}/index.js +0 -0
- /package/dist/{gsd → src/gsd}/types.js +0 -0
- /package/dist/{storage/atomic-io.test.d.ts → src/headless/__tests__/council-answers.test.d.ts} +0 -0
- /package/dist/{headless → src/headless}/output.js +0 -0
- /package/dist/{storage/config.test.d.ts → src/headless/output.test.d.ts} +0 -0
- /package/dist/{hooks → src/hooks}/config.d.ts +0 -0
- /package/dist/{hooks → src/hooks}/config.js +0 -0
- /package/dist/{hooks → src/hooks}/types.js +0 -0
- /package/dist/{storage/transcript.test.d.ts → src/lsp/builtins.test.d.ts} +0 -0
- /package/dist/{storage/usage-cap.test.d.ts → src/lsp/manager.test.d.ts} +0 -0
- /package/dist/{lsp → src/lsp}/npm-cache.d.ts +0 -0
- /package/dist/{lsp → src/lsp}/npm-cache.js +0 -0
- /package/dist/{tools/bash.test.d.ts → src/lsp/npm-cache.test.d.ts} +0 -0
- /package/dist/{tools/computer.test.d.ts → src/lsp/smoke.test.d.ts} +0 -0
- /package/dist/{lsp → src/lsp}/smoke.test.js +0 -0
- /package/dist/{lsp → src/lsp}/types.d.ts +0 -0
- /package/dist/{lsp → src/lsp}/types.js +0 -0
- /package/dist/{tools/file.test.d.ts → src/mcp/__tests__/auto-setup.test.d.ts} +0 -0
- /package/dist/{tools/schedule.test.d.ts → src/mcp/__tests__/harness-driver-action-tools.spec.d.ts} +0 -0
- /package/dist/{ui/slash/__tests__/discuss.test.d.ts → src/mcp/__tests__/harness-driver-async-tools.spec.d.ts} +0 -0
- /package/dist/{ui/slash/__tests__/execute.test.d.ts → src/mcp/__tests__/harness-driver-read-tools.spec.d.ts} +0 -0
- /package/dist/{ui/slash/__tests__/plan.test.d.ts → src/mcp/__tests__/harness-driver-security.spec.d.ts} +0 -0
- /package/dist/{ui/status-bar/index.test.d.ts → src/mcp/__tests__/harness-driver.spec.d.ts} +0 -0
- /package/dist/{ui/status-bar/store.test.d.ts → src/mcp/__tests__/lazy-schema.spec.d.ts} +0 -0
- /package/dist/{ui/status-bar/tier-badge.test.d.ts → src/mcp/__tests__/mcp-keychain.test.d.ts} +0 -0
- /package/dist/{ui/status-bar/usd-meter.test.d.ts → src/mcp/__tests__/research-onboarding.test.d.ts} +0 -0
- /package/dist/{usage/downgrade.test.d.ts → src/mcp/__tests__/runtime-hydration.test.d.ts} +0 -0
- /package/dist/{usage/estimator.test.d.ts → src/mcp/__tests__/runtime-sanitize.test.d.ts} +0 -0
- /package/dist/{mcp → src/mcp}/auto-setup.d.ts +0 -0
- /package/dist/{mcp → src/mcp}/catalog.d.ts +0 -0
- /package/dist/{mcp → src/mcp}/oauth-provider.d.ts +0 -0
- /package/dist/{mcp → src/mcp}/oauth-provider.js +0 -0
- /package/dist/{mcp → src/mcp}/parse-headers.d.ts +0 -0
- /package/dist/{mcp → src/mcp}/parse-headers.js +0 -0
- /package/dist/{usage/ledger.test.d.ts → src/mcp/parse-headers.test.d.ts} +0 -0
- /package/dist/{mcp → src/mcp}/runtime.d.ts +0 -0
- /package/dist/{usage/midstream.test.d.ts → src/mcp/smoke.test.d.ts} +0 -0
- /package/dist/{mcp → src/mcp}/smoke.test.js +0 -0
- /package/dist/{mcp → src/mcp}/validate.js +0 -0
- /package/dist/{usage/thresholds.test.d.ts → src/models/__tests__/registry.test.d.ts} +0 -0
- /package/dist/{models → src/models}/catalog-client.d.ts +0 -0
- /package/dist/{models → src/models}/classify-tier.d.ts +0 -0
- /package/dist/{utils/install-manager.test.d.ts → src/ops/__tests__/doctor-council-mcp.test.d.ts} +0 -0
- /package/dist/{utils/instructions.test.d.ts → src/ops/__tests__/doctor-ee-health.test.d.ts} +0 -0
- /package/dist/{ops → src/ops}/bug-report.d.ts +0 -0
- /package/dist/{ops → src/ops}/bug-report.js +0 -0
- /package/dist/{utils/permission-mode.test.d.ts → src/ops/bug-report.test.d.ts} +0 -0
- /package/dist/{ops → src/ops}/bug-report.test.js +0 -0
- /package/dist/{ops → src/ops}/doctor.d.ts +0 -0
- /package/dist/{utils/redactor.test.d.ts → src/ops/doctor.test.d.ts} +0 -0
- /package/dist/{utils/settings.test.d.ts → src/orchestrator/__tests__/batch-turn-runner.test.d.ts} +0 -0
- /package/dist/{utils/skills.test.d.ts → src/orchestrator/__tests__/council-manager.test.d.ts} +0 -0
- /package/dist/{utils/subagent-display.test.d.ts → src/orchestrator/__tests__/cross-turn-dedup.test.d.ts} +0 -0
- /package/dist/{orchestrator → src/orchestrator}/__tests__/flow-resume.test.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/__tests__/flow-resume.test.js +0 -0
- /package/dist/{utils/subagents-settings.test.d.ts → src/orchestrator/__tests__/message-processor.test.d.ts} +0 -0
- /package/dist/{utils/telegram-audio-settings.test.d.ts → src/orchestrator/__tests__/read-path-budget.test.d.ts} +0 -0
- /package/dist/{utils/update-checker.test.d.ts → src/orchestrator/__tests__/retry-classifier.test.d.ts} +0 -0
- /package/dist/{verify/checkpoint.test.d.ts → src/orchestrator/__tests__/retry-stream.test.d.ts} +0 -0
- /package/dist/{verify/entrypoint.test.d.ts → src/orchestrator/__tests__/route-feedback.test.d.ts} +0 -0
- /package/dist/{verify/environment.test.d.ts → src/orchestrator/__tests__/stream-runner.test.d.ts} +0 -0
- /package/dist/{orchestrator → src/orchestrator}/abort.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/abort.js +0 -0
- /package/dist/{verify/orchestrator.test.d.ts → src/orchestrator/abort.test.d.ts} +0 -0
- /package/dist/{orchestrator → src/orchestrator}/abort.test.js +0 -0
- /package/dist/{verify/runtime-prep.test.d.ts → src/orchestrator/agent.test.d.ts} +0 -0
- /package/dist/{orchestrator → src/orchestrator}/delegations.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/pending-calls.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/pending-calls.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/pending-calls.test.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/reasoning.d.ts +0 -0
- /package/dist/{pil → src/pil}/__tests__/ollama-classify.test.js +0 -0
- /package/dist/{pil → src/pil}/__tests__/orchestrator-integration.test.d.ts +0 -0
- /package/dist/{pil → src/pil}/__tests__/orchestrator-integration.test.js +0 -0
- /package/dist/{pil → src/pil}/__tests__/store.test.js +0 -0
- /package/dist/{pil → src/pil}/__tests__/task-tier-map.test.js +0 -0
- /package/dist/{pil → src/pil}/budget.d.ts +0 -0
- /package/dist/{pil → src/pil}/budget.js +0 -0
- /package/dist/{pil → src/pil}/layer2-personality.d.ts +0 -0
- /package/dist/{pil → src/pil}/layer5-context.d.ts +0 -0
- /package/dist/{pil → src/pil}/ollama-classify.d.ts +0 -0
- /package/dist/{pil → src/pil}/ollama-classify.js +0 -0
- /package/dist/{pil → src/pil}/store.d.ts +0 -0
- /package/dist/{pil → src/pil}/store.js +0 -0
- /package/dist/{pil → src/pil}/task-tier-map.d.ts +0 -0
- /package/dist/{pil → src/pil}/task-tier-map.js +0 -0
- /package/dist/{pil → src/pil}/timeout.d.ts +0 -0
- /package/dist/{pil → src/pil}/timeout.js +0 -0
- /package/dist/{pil → src/pil}/types.js +0 -0
- /package/dist/{providers → src/providers}/__test-utils__/load-fixture.d.ts +0 -0
- /package/dist/{providers → src/providers}/__test-utils__/load-fixture.js +0 -0
- /package/dist/{providers → src/providers}/adapter.test.js +0 -0
- /package/dist/{providers → src/providers}/anthropic.d.ts +0 -0
- /package/dist/{providers → src/providers}/errors.d.ts +0 -0
- /package/dist/{providers → src/providers}/errors.js +0 -0
- /package/dist/{providers → src/providers}/errors.test.js +0 -0
- /package/dist/{providers → src/providers}/gemini.d.ts +0 -0
- /package/dist/{providers → src/providers}/gemini.test.js +0 -0
- /package/dist/{providers → src/providers}/ollama.d.ts +0 -0
- /package/dist/{providers → src/providers}/ollama.js +0 -0
- /package/dist/{providers → src/providers}/ollama.test.js +0 -0
- /package/dist/{providers → src/providers}/openai-compatible.d.ts +0 -0
- /package/dist/{providers → src/providers}/openai.test.js +0 -0
- /package/dist/{providers → src/providers}/patch-zod-schema.d.ts +0 -0
- /package/dist/{providers → src/providers}/vision-proxy.d.ts +0 -0
- /package/dist/{router → src/router}/classifier/grammars.d.ts +0 -0
- /package/dist/{router → src/router}/classifier/grammars.js +0 -0
- /package/dist/{router → src/router}/classifier/index.d.ts +0 -0
- /package/dist/{router → src/router}/classifier/index.js +0 -0
- /package/dist/{router → src/router}/classifier/index.test.js +0 -0
- /package/dist/{router → src/router}/classifier/regex.d.ts +0 -0
- /package/dist/{router → src/router}/classifier/regex.test.js +0 -0
- /package/dist/{router → src/router}/classifier/tree-sitter.d.ts +0 -0
- /package/dist/{router → src/router}/classifier/tree-sitter.js +0 -0
- /package/dist/{router → src/router}/classifier/tree-sitter.test.js +0 -0
- /package/dist/{router → src/router}/cold.d.ts +0 -0
- /package/dist/{router → src/router}/cold.js +0 -0
- /package/dist/{router → src/router}/decide.d.ts +0 -0
- /package/dist/{router → src/router}/health.d.ts +0 -0
- /package/dist/{router → src/router}/health.js +0 -0
- /package/dist/{router → src/router}/health.test.js +0 -0
- /package/dist/{router → src/router}/store.d.ts +0 -0
- /package/dist/{router → src/router}/store.js +0 -0
- /package/dist/{router → src/router}/types.d.ts +0 -0
- /package/dist/{router → src/router}/warm.d.ts +0 -0
- /package/dist/{storage → src/storage}/__tests__/migrations.test.d.ts +0 -0
- /package/dist/{storage → src/storage}/__tests__/migrations.test.js +0 -0
- /package/dist/{storage → src/storage}/config.d.ts +0 -0
- /package/dist/{storage → src/storage}/config.test.js +0 -0
- /package/dist/{storage → src/storage}/db.d.ts +0 -0
- /package/dist/{storage → src/storage}/session-dir.d.ts +0 -0
- /package/dist/{storage → src/storage}/session-dir.js +0 -0
- /package/dist/{storage → src/storage}/tool-results.js +0 -0
- /package/dist/{storage → src/storage}/transcript-view.d.ts +0 -0
- /package/dist/{storage → src/storage}/usage-cap.d.ts +0 -0
- /package/dist/{storage → src/storage}/usage-cap.js +0 -0
- /package/dist/{storage → src/storage}/usage-cap.test.js +0 -0
- /package/dist/{tools → src/tools}/computer.js +0 -0
- /package/dist/{tools → src/tools}/grep.js +0 -0
- /package/dist/{tools → src/tools}/schedule.d.ts +0 -0
- /package/dist/{types → src/types}/index.js +0 -0
- /package/dist/{ui → src/ui}/components/SuggestionOverlay.d.ts +0 -0
- /package/dist/{ui → src/ui}/components/SuggestionOverlay.js +0 -0
- /package/dist/{ui → src/ui}/components/btw-overlay.d.ts +0 -0
- /package/dist/{ui → src/ui}/components/btw-overlay.js +0 -0
- /package/dist/{ui → src/ui}/hooks/useTypeahead.d.ts +0 -0
- /package/dist/{ui → src/ui}/markdown.js +0 -0
- /package/dist/{ui → src/ui}/mcp-modal-types.js +0 -0
- /package/dist/{ui → src/ui}/plan.js +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/clear.test.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/clear.test.js +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/compact.test.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/compact.test.js +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/cost.test.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/cost.test.js +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/discuss.test.js +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/execute.test.js +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/expand.test.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/expand.test.js +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/optimize.test.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/__tests__/plan.test.js +0 -0
- /package/dist/{ui → src/ui}/slash/clear.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/clear.js +0 -0
- /package/dist/{ui → src/ui}/slash/compact.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/compact.js +0 -0
- /package/dist/{ui → src/ui}/slash/cost.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/council.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/debug.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/discuss.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/discuss.js +0 -0
- /package/dist/{ui → src/ui}/slash/ee.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/execute.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/execute.js +0 -0
- /package/dist/{ui → src/ui}/slash/expand.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/expand.js +0 -0
- /package/dist/{ui → src/ui}/slash/optimize.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/plan.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/plan.js +0 -0
- /package/dist/{ui → src/ui}/slash/registry.js +0 -0
- /package/dist/{ui → src/ui}/slash/route.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/route.js +0 -0
- /package/dist/{ui → src/ui}/slash/route.test.d.ts +0 -0
- /package/dist/{ui → src/ui}/slash/route.test.js +0 -0
- /package/dist/{ui → src/ui}/status-bar/index.test.js +0 -0
- /package/dist/{ui → src/ui}/status-bar/store.test.js +0 -0
- /package/dist/{ui → src/ui}/status-bar/tier-badge.d.ts +0 -0
- /package/dist/{ui → src/ui}/status-bar/tier-badge.js +0 -0
- /package/dist/{ui → src/ui}/status-bar/tier-badge.test.js +0 -0
- /package/dist/{ui → src/ui}/status-bar/usd-meter.d.ts +0 -0
- /package/dist/{ui → src/ui}/status-bar/usd-meter.js +0 -0
- /package/dist/{ui → src/ui}/status-bar/usd-meter.test.js +0 -0
- /package/dist/{ui → src/ui}/terminal-selection-text.d.ts +0 -0
- /package/dist/{ui → src/ui}/terminal-selection-text.js +0 -0
- /package/dist/{usage → src/usage}/downgrade.d.ts +0 -0
- /package/dist/{usage → src/usage}/downgrade.js +0 -0
- /package/dist/{usage → src/usage}/downgrade.test.js +0 -0
- /package/dist/{usage → src/usage}/estimator.test.js +0 -0
- /package/dist/{usage → src/usage}/ledger.test.js +0 -0
- /package/dist/{usage → src/usage}/midstream.d.ts +0 -0
- /package/dist/{usage → src/usage}/midstream.js +0 -0
- /package/dist/{usage → src/usage}/midstream.test.js +0 -0
- /package/dist/{usage → src/usage}/thresholds.d.ts +0 -0
- /package/dist/{usage → src/usage}/thresholds.js +0 -0
- /package/dist/{usage → src/usage}/thresholds.test.js +0 -0
- /package/dist/{usage → src/usage}/types.js +0 -0
- /package/dist/{utils → src/utils}/at-mentions.d.ts +0 -0
- /package/dist/{utils → src/utils}/at-mentions.js +0 -0
- /package/dist/{utils → src/utils}/clipboard-image.d.ts +0 -0
- /package/dist/{utils → src/utils}/file-index.d.ts +0 -0
- /package/dist/{utils → src/utils}/file-index.js +0 -0
- /package/dist/{utils → src/utils}/git-root.d.ts +0 -0
- /package/dist/{utils → src/utils}/git-root.js +0 -0
- /package/dist/{utils → src/utils}/install-manager.d.ts +0 -0
- /package/dist/{utils → src/utils}/install-manager.js +0 -0
- /package/dist/{utils → src/utils}/instructions.d.ts +0 -0
- /package/dist/{utils → src/utils}/permission-mode.d.ts +0 -0
- /package/dist/{utils → src/utils}/permission-mode.js +0 -0
- /package/dist/{utils → src/utils}/permission-mode.test.js +0 -0
- /package/dist/{utils → src/utils}/redactor.d.ts +0 -0
- /package/dist/{utils → src/utils}/redactor.js +0 -0
- /package/dist/{utils → src/utils}/side-question.d.ts +0 -0
- /package/dist/{utils → src/utils}/side-question.js +0 -0
- /package/dist/{utils → src/utils}/skills.d.ts +0 -0
- /package/dist/{utils → src/utils}/subagent-display.d.ts +0 -0
- /package/dist/{utils → src/utils}/subagent-display.js +0 -0
- /package/dist/{utils → src/utils}/update-checker.d.ts +0 -0
- /package/dist/{verify → src/verify}/checkpoint.js +0 -0
- /package/dist/{verify → src/verify}/evidence.js +0 -0
- /package/dist/{verify → src/verify}/retry.js +0 -0
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
// Multi-provider wired — runtime dispatch via providers/runtime.ts.
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import type { ModelMessage, ToolSet } from "ai";
|
|
4
|
+
import { extractSession } from "../ee/extract-session.js";
|
|
5
|
+
import { bootstrapEEClient, getDefaultEEClient, getLastSurfacedState } from "../ee/intercept.js";
|
|
6
|
+
import { getTenantId } from "../ee/tenant.js";
|
|
6
7
|
import { createRun, getActiveRunId, setActiveRunId } from "../flow/run-manager.js";
|
|
7
8
|
import { ensureFlowDir } from "../flow/scaffold.js";
|
|
8
9
|
import { executeEventHooks } from "../hooks/index";
|
|
9
|
-
import type { PreToolUseHookInput, PostToolUseHookInput } from "../hooks/types";
|
|
10
|
-
import { bootstrapEEClient, getDefaultEEClient, getLastSurfacedState } from "../ee/intercept.js";
|
|
11
|
-
import { getTenantId } from "../ee/tenant.js";
|
|
12
|
-
import { routeFeedback, routeModel } from "../ee/bridge.js";
|
|
13
|
-
import { reportRouteOutcome } from "../router/decide.js";
|
|
14
|
-
import { routerStore } from "../router/store.js";
|
|
15
|
-
import { statusBarStore } from "../ui/status-bar/store.js";
|
|
16
|
-
import { taskTypeToTier, taskTypeToMaxTokens, taskTypeToReasoningEffort } from "../pil/task-tier-map.js";
|
|
17
10
|
import type {
|
|
18
11
|
NotificationHookInput,
|
|
19
12
|
PostCompactHookInput,
|
|
20
13
|
PreCompactHookInput,
|
|
21
14
|
SessionEndHookInput,
|
|
22
|
-
SessionStartHookInput,
|
|
23
|
-
StopFailureHookInput,
|
|
24
|
-
StopHookInput,
|
|
25
15
|
SubagentStartHookInput,
|
|
26
16
|
SubagentStopHookInput,
|
|
27
17
|
TaskCompletedHookInput,
|
|
28
18
|
TaskCreatedHookInput,
|
|
29
|
-
UserPromptSubmitHookInput,
|
|
30
19
|
} from "../hooks/types";
|
|
31
20
|
import { shutdownWorkspaceLspManager } from "../lsp/runtime";
|
|
32
|
-
import { extractSession } from "../ee/extract-session.js";
|
|
33
21
|
import { ensureDefaultMcpServers } from "../mcp/auto-setup.js";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
22
|
+
import { getModelByTier, getModelInfo, normalizeModelId } from "../models/registry.js";
|
|
23
|
+
import { getProviderCapabilities } from "../providers/capabilities.js";
|
|
24
|
+
import { apiBaseFor } from "../providers/endpoints.js";
|
|
36
25
|
import { loadKeyForProvider } from "../providers/keychain.js";
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
import {
|
|
27
|
+
createProviderFactory,
|
|
28
|
+
createProviderFactoryAsync,
|
|
29
|
+
detectProviderForModel,
|
|
30
|
+
resolveModelRuntime as resolveRuntime,
|
|
31
|
+
} from "../providers/runtime.js";
|
|
32
|
+
import type { ProviderId } from "../providers/types.js";
|
|
42
33
|
import {
|
|
43
34
|
appendCompaction,
|
|
44
35
|
appendMessages,
|
|
@@ -48,16 +39,17 @@ import {
|
|
|
48
39
|
getSessionTotalTokens,
|
|
49
40
|
loadTranscript,
|
|
50
41
|
loadTranscriptState,
|
|
42
|
+
logInteraction,
|
|
43
|
+
markMessageCompleted,
|
|
51
44
|
recordUsageEvent,
|
|
52
45
|
SessionStore,
|
|
53
46
|
} from "../storage/index";
|
|
54
47
|
import { BashTool } from "../tools/bash";
|
|
48
|
+
import { createBuiltinTools } from "../tools/registry.js";
|
|
55
49
|
import { type ScheduleDaemonStatus, ScheduleManager, type StoredSchedule } from "../tools/schedule";
|
|
56
50
|
import type {
|
|
57
51
|
AgentMode,
|
|
58
52
|
ChatEntry,
|
|
59
|
-
ModelInfo,
|
|
60
|
-
Plan,
|
|
61
53
|
SessionInfo,
|
|
62
54
|
SessionSnapshot,
|
|
63
55
|
StreamChunk,
|
|
@@ -69,114 +61,82 @@ import type {
|
|
|
69
61
|
VerifyRecipe,
|
|
70
62
|
WorkspaceInfo,
|
|
71
63
|
} from "../types/index";
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
64
|
+
import { statusBarStore } from "../ui/status-bar/store.js";
|
|
65
|
+
import { appendCostLog } from "../usage/cost-log.js";
|
|
66
|
+
import { appendDecisionLog } from "../usage/decision-log.js";
|
|
67
|
+
import { projectCostUSD } from "../usage/estimator.js";
|
|
68
|
+
import type { PermissionMode } from "../utils/permission-mode.js";
|
|
74
69
|
import {
|
|
75
70
|
type CustomSubagentConfig,
|
|
71
|
+
getAutoCompactThresholdPct,
|
|
72
|
+
getCouncilRounds,
|
|
76
73
|
getCurrentModel,
|
|
74
|
+
getCurrentShellSettings,
|
|
77
75
|
getModeSpecificModel,
|
|
78
|
-
getCouncilRounds,
|
|
79
76
|
getRoleModel,
|
|
80
77
|
getRoleModels,
|
|
81
78
|
isAutoCompactAfterTurnEnabled,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
loadValidSubAgents,
|
|
79
|
+
isCouncilMultiProviderPreferred,
|
|
80
|
+
isProviderDisabled,
|
|
85
81
|
type ModelRole,
|
|
86
82
|
type SandboxMode,
|
|
87
83
|
type SandboxSettings,
|
|
88
84
|
} from "../utils/settings";
|
|
89
85
|
import { runSideQuestion, type SideQuestionResult } from "../utils/side-question";
|
|
90
|
-
import {
|
|
91
|
-
import { buildVerifyDetectPrompt, normalizeVerifyRecipe, prepareVerifySandbox } from "../verify/entrypoint";
|
|
86
|
+
import { buildVerifyDetectPrompt, normalizeVerifyRecipe } from "../verify/entrypoint";
|
|
92
87
|
import { runVerifyOrchestration } from "../verify/orchestrator";
|
|
88
|
+
import {
|
|
89
|
+
type AgentOptions,
|
|
90
|
+
type BatchChatCompletionResponse,
|
|
91
|
+
type BatchClientOptions,
|
|
92
|
+
type BatchFunctionTool,
|
|
93
|
+
COUNCIL_COLOR_BG,
|
|
94
|
+
COUNCIL_COLOR_RESET,
|
|
95
|
+
COUNCIL_ROLE_COLORS,
|
|
96
|
+
type LegacyProvider,
|
|
97
|
+
type ProcessMessageObserver,
|
|
98
|
+
type ProcessMessageUsage,
|
|
99
|
+
type ResolvedModelRuntime,
|
|
100
|
+
} from "./agent-options";
|
|
101
|
+
import { BatchTurnRunner, type BatchTurnRunnerDeps } from "./batch-turn-runner.js";
|
|
102
|
+
import {
|
|
103
|
+
accumulateUsage,
|
|
104
|
+
buildAssistantBatchMessage,
|
|
105
|
+
buildBatchChatCompletionRequest,
|
|
106
|
+
buildBatchName,
|
|
107
|
+
buildToolBatchMessage,
|
|
108
|
+
type ExecutedBatchTool,
|
|
109
|
+
extractJsonObject,
|
|
110
|
+
getBatchFinishReason,
|
|
111
|
+
getBatchUsage,
|
|
112
|
+
hasUsage,
|
|
113
|
+
parseToolArgumentsOrRaw,
|
|
114
|
+
toLocalToolCall,
|
|
115
|
+
} from "./batch-utils";
|
|
93
116
|
import {
|
|
94
117
|
type CompactionSettings,
|
|
95
118
|
createCompactionSummaryMessage,
|
|
96
119
|
DEFAULT_KEEP_RECENT_TOKENS,
|
|
97
120
|
DEFAULT_RESERVE_TOKENS,
|
|
98
|
-
POST_TURN_MIN_TOKENS,
|
|
99
121
|
estimateConversationTokens,
|
|
122
|
+
extractUserContent,
|
|
100
123
|
generateCompactionSummary,
|
|
124
|
+
POST_TURN_MIN_TOKENS,
|
|
101
125
|
prepareCompaction,
|
|
102
|
-
relaxCompactionSettings,
|
|
103
126
|
shouldCompactContext,
|
|
104
127
|
} from "./compaction";
|
|
128
|
+
import { CouncilManager } from "./council-manager.js";
|
|
129
|
+
import { CrossTurnDedup, isCrossTurnDedupEnabled } from "./cross-turn-dedup.js";
|
|
105
130
|
import { DelegationManager } from "./delegations";
|
|
106
131
|
import { loadFlowResumeDigest } from "./flow-resume.js";
|
|
107
|
-
import {
|
|
108
|
-
import {
|
|
109
|
-
import {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} from "../providers/runtime.js";
|
|
116
|
-
import type { ProviderId } from "../providers/types.js";
|
|
117
|
-
|
|
118
|
-
// ---------------------------------------------------------------------------
|
|
119
|
-
// Re-export types from shared runtime module for back-compat
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
|
|
122
|
-
export type { ProviderFactory as LegacyProvider, ResolvedModelRuntime } from "../providers/runtime.js";
|
|
123
|
-
type LegacyProvider = ProviderFactory;
|
|
124
|
-
type ResolvedModelRuntime = RuntimeResult;
|
|
125
|
-
|
|
126
|
-
/** @deprecated Use ModelInfo from "../types/index" instead. */
|
|
127
|
-
export type ModelInfoStub = ModelInfo;
|
|
128
|
-
|
|
129
|
-
// Batch API type stubs
|
|
130
|
-
export interface BatchClientOptions {
|
|
131
|
-
apiKey: string;
|
|
132
|
-
baseURL?: string;
|
|
133
|
-
signal?: AbortSignal;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface BatchChatMessage {
|
|
137
|
-
role: string;
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
-
content: any;
|
|
140
|
-
tool_call_id?: string;
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
-
tool_calls?: any[];
|
|
143
|
-
name?: string;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export interface BatchFunctionTool {
|
|
147
|
-
type: "function";
|
|
148
|
-
function: { name: string; description?: string; parameters?: unknown };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface BatchToolCall {
|
|
152
|
-
id: string;
|
|
153
|
-
type: "function";
|
|
154
|
-
function: { name: string; arguments: string };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface BatchChatCompletionRequest {
|
|
158
|
-
model: string;
|
|
159
|
-
messages: BatchChatMessage[];
|
|
160
|
-
tools?: BatchFunctionTool[];
|
|
161
|
-
temperature?: number;
|
|
162
|
-
max_tokens?: number;
|
|
163
|
-
reasoning_effort?: string;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export interface BatchChatCompletionResponse {
|
|
167
|
-
choices: Array<{
|
|
168
|
-
message: { role: string; content: string | null; tool_calls?: BatchToolCall[] };
|
|
169
|
-
finish_reason: string;
|
|
170
|
-
}>;
|
|
171
|
-
usage?: {
|
|
172
|
-
prompt_tokens: number;
|
|
173
|
-
completion_tokens: number;
|
|
174
|
-
total_tokens: number;
|
|
175
|
-
input_tokens?: number;
|
|
176
|
-
output_tokens?: number;
|
|
177
|
-
cost_in_usd_ticks?: number;
|
|
178
|
-
};
|
|
179
|
-
}
|
|
132
|
+
import { MessageProcessor, type MessageProcessorDeps } from "./message-processor.js";
|
|
133
|
+
import { lastPersistedSeq } from "./message-seq.js";
|
|
134
|
+
import { buildSystemPrompt, MAX_TOOL_ROUNDS } from "./prompts";
|
|
135
|
+
import { getReadPathBudgetCap, ReadPathBudget } from "./read-path-budget.js";
|
|
136
|
+
import { withStreamRetry } from "./retry-stream.js";
|
|
137
|
+
import { StreamRunner, type StreamRunnerDeps } from "./stream-runner.js";
|
|
138
|
+
import { setProviderHint } from "./token-counter.js";
|
|
139
|
+
import { firstLine, formatSubagentActivity, toToolResult } from "./tool-utils";
|
|
180
140
|
|
|
181
141
|
// ---------------------------------------------------------------------------
|
|
182
142
|
// Provider implementations
|
|
@@ -251,514 +211,27 @@ function createTools(
|
|
|
251
211
|
subagents?: unknown[];
|
|
252
212
|
sendTelegramFile?: (filePath: string) => Promise<ToolResult>;
|
|
253
213
|
sessionId?: string;
|
|
214
|
+
modelId?: string;
|
|
254
215
|
},
|
|
255
216
|
): ToolSet {
|
|
256
|
-
return createBuiltinTools(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
listDelegations: _opts?.listDelegations,
|
|
264
|
-
},
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
async function buildVisionUserMessages(_prompt: string, _cwd: string, _signal?: AbortSignal): Promise<ModelMessage[]> {
|
|
269
|
-
// Vision input is an anti-feature per PROJECT.md Out-of-Scope. Always throws.
|
|
270
|
-
throw new Error("Vision input is not supported in muonroi-cli (anti-feature per PROJECT.md).");
|
|
217
|
+
return createBuiltinTools(_bash as BashTool, (_mode ?? "agent") as AgentMode, {
|
|
218
|
+
runTask: _opts?.runTask,
|
|
219
|
+
runDelegation: _opts?.runDelegation,
|
|
220
|
+
readDelegation: _opts?.readDelegation,
|
|
221
|
+
listDelegations: _opts?.listDelegations,
|
|
222
|
+
modelId: _opts?.modelId,
|
|
223
|
+
});
|
|
271
224
|
}
|
|
272
225
|
|
|
273
226
|
// ---------------------------------------------------------------------------
|
|
274
227
|
// END Plan 00-05 provider implementations
|
|
228
|
+
// (Phase 12.3 — `buildVisionUserMessages` was inlined into StreamRunner;
|
|
229
|
+
// vision is an anti-feature per PROJECT.md Out-of-Scope so the helper is gone.)
|
|
275
230
|
// ---------------------------------------------------------------------------
|
|
276
231
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
interface AgentOptions {
|
|
282
|
-
persistSession?: boolean;
|
|
283
|
-
session?: string;
|
|
284
|
-
sandboxMode?: SandboxMode;
|
|
285
|
-
sandboxSettings?: SandboxSettings;
|
|
286
|
-
batchApi?: boolean;
|
|
287
|
-
/** Optional external AbortContext (from src/index.ts SIGINT handler). When provided,
|
|
288
|
-
* the orchestrator uses its signal instead of creating a new AbortController per turn.
|
|
289
|
-
* TUI-04: Ctrl+C mid-tool-call abort safety. */
|
|
290
|
-
abortContext?: import("./abort.js").AbortContext;
|
|
291
|
-
/** Optional PendingCallsLog for Pitfall 9 staged-write tracking per tool call. */
|
|
292
|
-
pendingCalls?: import("./pending-calls.js").PendingCallsLog;
|
|
293
|
-
/** Permission mode controlling which tool calls require manual approval.
|
|
294
|
-
* safe (default) = confirm all; auto-edit = auto-approve file ops; yolo = auto-approve all. */
|
|
295
|
-
permissionMode?: PermissionMode;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
type ProcessMessageFinishReason = "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other";
|
|
299
|
-
|
|
300
|
-
export interface ProcessMessageUsage {
|
|
301
|
-
inputTokens?: number;
|
|
302
|
-
outputTokens?: number;
|
|
303
|
-
totalTokens?: number;
|
|
304
|
-
costUsdTicks?: number;
|
|
305
|
-
cacheReadTokens?: number;
|
|
306
|
-
cacheCreationTokens?: number;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export interface ProcessMessageStepStart {
|
|
310
|
-
stepNumber: number;
|
|
311
|
-
timestamp: number;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export interface ProcessMessageStepFinish {
|
|
315
|
-
stepNumber: number;
|
|
316
|
-
timestamp: number;
|
|
317
|
-
finishReason: ProcessMessageFinishReason;
|
|
318
|
-
usage: ProcessMessageUsage;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export interface ProcessMessageToolStart {
|
|
322
|
-
toolCall: ToolCall;
|
|
323
|
-
timestamp: number;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export interface ProcessMessageToolFinish {
|
|
327
|
-
toolCall: ToolCall;
|
|
328
|
-
toolResult: ToolResult;
|
|
329
|
-
timestamp: number;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export interface ProcessMessageError {
|
|
333
|
-
message: string;
|
|
334
|
-
timestamp: number;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export interface ProcessMessageObserver {
|
|
338
|
-
onStepStart?(info: ProcessMessageStepStart): void;
|
|
339
|
-
onStepFinish?(info: ProcessMessageStepFinish): void;
|
|
340
|
-
onToolStart?(info: ProcessMessageToolStart): void;
|
|
341
|
-
onToolFinish?(info: ProcessMessageToolFinish): void;
|
|
342
|
-
onError?(info: ProcessMessageError): void;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const ENVIRONMENT = `ENVIRONMENT:
|
|
346
|
-
You are running inside a terminal (CLI). Your text output is rendered in a plain terminal — not a browser, not a rich text editor.
|
|
347
|
-
- Use plain text only. No markdown tables, no HTML, no images, no colored text.
|
|
348
|
-
- Use simple markers like dashes (-) or asterisks (*) for lists.
|
|
349
|
-
- Use indentation and blank lines for structure.
|
|
350
|
-
- Keep lines under 100 characters when possible.
|
|
351
|
-
- Use backticks for inline code and triple backticks for code blocks — these are rendered.
|
|
352
|
-
- Never use unicode box-drawing, fancy borders, or ASCII art in your responses.`;
|
|
353
|
-
|
|
354
|
-
const MODE_PROMPTS: Record<AgentMode, string> = {
|
|
355
|
-
agent: `You are muonroi-cli in Agent mode — a powerful AI coding agent. You execute tasks directly using tools.
|
|
356
|
-
|
|
357
|
-
${ENVIRONMENT}
|
|
358
|
-
|
|
359
|
-
TOOLS:
|
|
360
|
-
- read_file: Read file contents with start_line/end_line for iterative reading. Use for examining code.
|
|
361
|
-
- grep: Fast regex content search across the codebase. Prefer this over bash for finding patterns in files. Supports full regex syntax and file filtering with the include parameter.
|
|
362
|
-
- lsp: Experimental semantic code intelligence for definitions, references, hover, symbols, implementations, and call hierarchy when a matching language server is available.
|
|
363
|
-
- write_file: Create new files or overwrite existing ones with full content.
|
|
364
|
-
- edit_file: Replace a unique string in a file with new content. The old_string must be unique — include enough context lines.
|
|
365
|
-
- bash: Execute shell commands. Set background=true for long-running processes (dev servers, watchers, builds). Returns a process ID immediately.
|
|
366
|
-
- process_logs: View recent output from a background process by ID.
|
|
367
|
-
- process_stop: Stop a background process by ID.
|
|
368
|
-
- process_list: List all background processes with status and uptime.
|
|
369
|
-
- wallet_info: Check the local wallet address, chain, and current ETH/USDC balances.
|
|
370
|
-
- wallet_history: Show recent x402 payment history from the audit log.
|
|
371
|
-
- fetch_payment_info: Inspect a URL for x402 payment requirements without paying. Returns payment options and a brin security score. Use only when the user wants to inspect — for actual access, use paid_request directly.
|
|
372
|
-
- paid_request: Access an x402-protected URL using the local wallet. Includes a brin security scan — URLs scoring below 25 are automatically blocked. The user will be prompted to approve the payment before it executes. Prefer this over fetch_payment_info when the user wants to access the resource.
|
|
373
|
-
- task: Delegate a focused foreground task to a sub-agent. Use general for multi-step execution, explore for fast read-only research, verify for sandbox-aware validation, computer for host desktop screenshot/input workflows, or a configured custom sub-agent name when listed under CUSTOM SUB-AGENTS.
|
|
374
|
-
- delegate: Launch a read-only background agent for longer research while you continue working.
|
|
375
|
-
- delegation_read: Retrieve a completed background delegation result by ID.
|
|
376
|
-
- delegation_list: List running and completed background delegations. Do not poll it repeatedly.
|
|
377
|
-
- schedule_create: Create a recurring or one-time scheduled headless run.
|
|
378
|
-
- schedule_list: List saved schedules and their status.
|
|
379
|
-
- schedule_remove: Remove a saved schedule.
|
|
380
|
-
- schedule_read_log: Read recent log output from a schedule.
|
|
381
|
-
- schedule_daemon_status: Check whether the schedule daemon is running.
|
|
382
|
-
- schedule_daemon_start: Start the schedule daemon in the background.
|
|
383
|
-
- schedule_daemon_stop: Stop the schedule daemon.
|
|
384
|
-
- search_web: Search the web for current information, documentation, APIs, tutorials, etc.
|
|
385
|
-
- search_x: Search X/Twitter for real-time posts, discussions, opinions, and trends.
|
|
386
|
-
- generate_image: Generate a new image or edit an existing image. It saves image files locally and returns their paths.
|
|
387
|
-
- generate_video: Generate a new video or animate an existing image. It saves video files locally and returns their paths.
|
|
388
|
-
- computer_snapshot: Capture an accessibility-tree snapshot with stable refs like @e1 for desktop interaction.
|
|
389
|
-
- computer_screenshot: Capture a host desktop screenshot for visual confirmation or fallback inspection.
|
|
390
|
-
- computer_click: Click a desktop element by ref, or coordinates as a fallback.
|
|
391
|
-
- computer_mouse_move: Hover a desktop element by ref, or coordinates as a fallback.
|
|
392
|
-
- computer_type: Type text into a specific desktop element ref.
|
|
393
|
-
- computer_press: Press a key or key chord in the focused host application.
|
|
394
|
-
- computer_scroll: Scroll a desktop element by ref.
|
|
395
|
-
- computer_launch: Launch an application and wait for its window to appear.
|
|
396
|
-
- computer_list_windows: List visible windows and their ids.
|
|
397
|
-
- computer_focus_window: Bring a target window to the front.
|
|
398
|
-
- computer_wait: Wait for time, elements, windows, or text during desktop workflows.
|
|
399
|
-
- computer_get: Read a property from a desktop element ref.
|
|
400
|
-
- MCP tools: Enabled servers appear as tools named like mcp_<server>__<tool>.
|
|
401
|
-
|
|
402
|
-
WORKFLOW:
|
|
403
|
-
1. Understand the request
|
|
404
|
-
2. Decide whether a sub-agent should handle the first investigation pass
|
|
405
|
-
3. Use read_file, grep, lsp, and bash to explore the codebase directly when the task is small or tightly scoped
|
|
406
|
-
4. Use bash with background=true for dev servers, watchers, or any long-running process — then continue working
|
|
407
|
-
5. Use delegate for read-only work that can run in parallel, then continue productive work
|
|
408
|
-
6. Use edit_file for targeted changes, write_file for new files or full rewrites
|
|
409
|
-
7. Verify changes by reading modified files
|
|
410
|
-
8. Run tests or builds with bash to confirm correctness
|
|
411
|
-
9. Use search_web or search_x when you need up-to-date information
|
|
412
|
-
|
|
413
|
-
DEFAULT DELEGATION POLICY:
|
|
414
|
-
- Prefer the task tool by default for code review, code quality analysis, architecture research, root-cause investigation, bug triage, verification, or any request that likely needs reading multiple files before acting.
|
|
415
|
-
- Prefer delegate for longer-running read-only exploration when you can keep making progress without blocking.
|
|
416
|
-
- Use the explore sub-agent for read-only investigation, reviews, research, and "how does this work?" tasks.
|
|
417
|
-
- Use the general sub-agent for delegated work that may need editing files, running commands, or producing a concrete implementation.
|
|
418
|
-
- Use the verify sub-agent for sandbox-aware build, test, app boot, and smoke validation work.
|
|
419
|
-
- Use the computer sub-agent for host desktop interaction workflows that need screenshots, clicks, typing, keypresses, or scrolling.
|
|
420
|
-
- Use a matching custom sub-agent when the task fits one of the configured specializations.
|
|
421
|
-
- Never use delegate for tasks that should edit files or make shell changes.
|
|
422
|
-
- When a background delegation is running, do not wait idly and do not spam delegation_list(). Continue useful work.
|
|
423
|
-
- Do not wait for the user to explicitly ask for a sub-agent when delegation would clearly help.
|
|
424
|
-
- Skip delegation only when the task is trivial, single-file, or you already have the exact answer.
|
|
425
|
-
|
|
426
|
-
EXAMPLES:
|
|
427
|
-
- "review this change" -> delegate to explore first
|
|
428
|
-
- "research how auth works" -> delegate to explore first
|
|
429
|
-
- "investigate why this test fails" -> delegate to explore first, then continue with findings
|
|
430
|
-
- "refactor this module" -> delegate a focused part to general when helpful
|
|
431
|
-
- "verify this feature locally" -> use verify
|
|
432
|
-
- "open the host app and click through it" -> use computer
|
|
433
|
-
- "generate a logo" -> use generate_image
|
|
434
|
-
- "animate this still image" -> use generate_video
|
|
435
|
-
- Recurring specialized workflows -> use the matching custom sub-agent via task
|
|
436
|
-
- "every weekday at 9am run this check" -> use schedule_create with a cron expression
|
|
437
|
-
- "run this once automatically" -> use schedule_create with the right timing
|
|
438
|
-
- "make sure scheduled jobs keep running" -> use schedule_daemon_status and schedule_daemon_start
|
|
439
|
-
|
|
440
|
-
IMPORTANT:
|
|
441
|
-
- Prefer edit_file for surgical changes to existing files — it shows a clean diff.
|
|
442
|
-
- Prefer grep over bash for searching file contents. Use bash only for find, ls, git, and other shell commands.
|
|
443
|
-
- Prefer lsp over text search when you need exact definitions, references, implementations, or call hierarchy and a server is available.
|
|
444
|
-
- Use write_file only for new files or when most of the file is changing.
|
|
445
|
-
- Use read_file instead of cat/head/tail for reading files.
|
|
446
|
-
- When the user asks for an automated recurring or one-time run, use the schedule tools instead of only describing the setup.
|
|
447
|
-
- After creating a recurring schedule, check the daemon status and start it with \`schedule_daemon_start\` if needed.
|
|
448
|
-
|
|
449
|
-
Be direct. Execute, don't just describe. Show results, not plans.`,
|
|
450
|
-
|
|
451
|
-
plan: `You are muonroi-cli in Plan mode — you analyze and plan but DO NOT execute changes.
|
|
452
|
-
|
|
453
|
-
${ENVIRONMENT}
|
|
454
|
-
|
|
455
|
-
TOOLS:
|
|
456
|
-
- read_file: Read file contents for analysis.
|
|
457
|
-
- grep: Fast regex content search across the codebase. Prefer this over bash for finding patterns in files.
|
|
458
|
-
- lsp: Experimental semantic code intelligence for read-only planning and research.
|
|
459
|
-
- bash: ONLY for searching (find, ls), git inspection — NEVER modify files.
|
|
460
|
-
- task: Delegate a focused task to a sub-agent when deeper research or specialized analysis would help.
|
|
461
|
-
- generate_plan: ALWAYS use this to present your plan. Creates an interactive UI with steps and questions.
|
|
462
|
-
|
|
463
|
-
BEHAVIOR:
|
|
464
|
-
- Explore the codebase first using read_file, grep, and bash to understand the current state
|
|
465
|
-
- Prefer lsp for exact symbol navigation when a matching server is available
|
|
466
|
-
- ALWAYS call generate_plan to present your plan — never just describe it in text
|
|
467
|
-
- Include clear, ordered steps with affected file paths
|
|
468
|
-
- Include questions when you need user input on approach, trade-offs, or preferences
|
|
469
|
-
- Use "select" questions for single-choice decisions, "multiselect" for picking multiple options, and "text" for free-form input
|
|
470
|
-
- Highlight potential risks, edge cases, and dependencies in the plan summary
|
|
471
|
-
- NEVER create, modify, or delete files — only read and analyze`,
|
|
472
|
-
|
|
473
|
-
ask: `You are muonroi-cli in Ask mode — you answer questions clearly and thoroughly.
|
|
474
|
-
|
|
475
|
-
${ENVIRONMENT}
|
|
476
|
-
|
|
477
|
-
TOOLS:
|
|
478
|
-
- read_file: Read file contents for context.
|
|
479
|
-
- grep: Fast regex content search across the codebase. Prefer this over bash for finding patterns in files.
|
|
480
|
-
- lsp: Experimental semantic code intelligence for definitions, references, hover, and symbols.
|
|
481
|
-
- bash: ONLY for searching (find, ls), git inspection — NEVER modify.
|
|
482
|
-
- task: Delegate a focused task to a sub-agent when specialized analysis or deeper investigation would help.
|
|
483
|
-
|
|
484
|
-
BEHAVIOR:
|
|
485
|
-
- Answer the user's question directly and thoroughly
|
|
486
|
-
- Use tools to gather context when needed, preferring lsp for exact symbol questions when available
|
|
487
|
-
- Provide code examples when helpful
|
|
488
|
-
- NEVER create, modify, or delete files
|
|
489
|
-
- Focus on explanation, not execution`,
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
function findCustomSubagent(
|
|
493
|
-
agent: string,
|
|
494
|
-
subagents: CustomSubagentConfig[] = loadValidSubAgents(),
|
|
495
|
-
): CustomSubagentConfig | undefined {
|
|
496
|
-
return (
|
|
497
|
-
subagents.find((item) => item.name === agent) ??
|
|
498
|
-
subagents.find((item) => item.name.toLowerCase() === agent.toLowerCase())
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function formatCustomSubagentsPromptSection(subagents: CustomSubagentConfig[]): string {
|
|
503
|
-
if (subagents.length === 0) return "";
|
|
504
|
-
|
|
505
|
-
const lines = subagents.map((agent) => {
|
|
506
|
-
const instruction = agent.instruction.trim() || "(none)";
|
|
507
|
-
return `### ${agent.name}\n- model: ${agent.model}\n- instruction:\n${instruction}`;
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
return `\n\nCUSTOM SUB-AGENTS:\nUser-defined foreground sub-agents from ~/.muonroi-cli/user-settings.json. When one matches the task, call the task tool with agent set to the exact name.\n\n${lines.join("\n\n")}\n`;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
interface SystemPromptParts {
|
|
514
|
-
staticPrefix: string;
|
|
515
|
-
dynamicSuffix: string;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
const NON_ANTHROPIC_TOOL_PREAMBLE = `\n\nIMPORTANT — TOOL CALLING:
|
|
519
|
-
You MUST invoke tools ONLY via the structured function calling API provided to you.
|
|
520
|
-
NEVER output XML tags like <tool_name>, <bash>, <read_file>, or <delegate> as text.
|
|
521
|
-
If you want to call a tool, use the function calling mechanism — do NOT write tool invocations as text in your response.
|
|
522
|
-
Any XML-like tool invocation in your text output will be ignored by the system.\n`;
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Strip the TOOLS: listing section from system prompt.
|
|
526
|
-
* Non-Anthropic models receive tool definitions via the API's structured `tools` parameter;
|
|
527
|
-
* keeping the text listing causes them to output raw XML instead of structured tool calls.
|
|
528
|
-
*/
|
|
529
|
-
function stripToolsSection(text: string): string {
|
|
530
|
-
return text.replace(/\nTOOLS:\n[\s\S]*?\n(?=WORKFLOW:|BEHAVIOR:|IMPORTANT:|DEFAULT DELEGATION|EXAMPLES:|$)/g, "\n");
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function buildSystemPromptParts(
|
|
534
|
-
cwd: string,
|
|
535
|
-
mode: AgentMode,
|
|
536
|
-
sandboxMode: SandboxMode,
|
|
537
|
-
planContext?: string | null,
|
|
538
|
-
subagents?: CustomSubagentConfig[],
|
|
539
|
-
sandboxSettings?: SandboxSettings,
|
|
540
|
-
providerId?: string,
|
|
541
|
-
): SystemPromptParts {
|
|
542
|
-
const custom = loadCustomInstructions(cwd);
|
|
543
|
-
const customSection = custom
|
|
544
|
-
? `\n\nCUSTOM INSTRUCTIONS:\n${custom}\n\nFollow the above alongside standard instructions.\n`
|
|
545
|
-
: "";
|
|
546
|
-
|
|
547
|
-
const skillsText = formatSkillsForPrompt(discoverSkills(cwd));
|
|
548
|
-
const skillsSection = skillsText ? `\n\n${skillsText}\n` : "";
|
|
549
|
-
const subagentsSection = formatCustomSubagentsPromptSection(subagents ?? loadValidSubAgents());
|
|
550
|
-
const sandboxSection = formatSandboxPromptSection(sandboxMode, sandboxSettings);
|
|
551
|
-
|
|
552
|
-
let modePrompt = MODE_PROMPTS[mode];
|
|
553
|
-
if (providerId && providerId !== "anthropic") {
|
|
554
|
-
modePrompt = stripToolsSection(modePrompt) + NON_ANTHROPIC_TOOL_PREAMBLE;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
const staticPrefix = `${modePrompt}${sandboxSection}${customSection}${skillsSection}${subagentsSection}`;
|
|
558
|
-
|
|
559
|
-
const planSection = planContext
|
|
560
|
-
? `\n\nAPPROVED PLAN:\nThe following plan has been approved by the user. Execute it now.\n${planContext}\n`
|
|
561
|
-
: "";
|
|
562
|
-
|
|
563
|
-
const dynamicSuffix = `${planSection}\n\nCurrent working directory: ${cwd}`;
|
|
564
|
-
|
|
565
|
-
return { staticPrefix, dynamicSuffix };
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
function buildSystemPrompt(
|
|
569
|
-
cwd: string,
|
|
570
|
-
mode: AgentMode,
|
|
571
|
-
sandboxMode: SandboxMode,
|
|
572
|
-
planContext?: string | null,
|
|
573
|
-
subagents?: CustomSubagentConfig[],
|
|
574
|
-
sandboxSettings?: SandboxSettings,
|
|
575
|
-
providerId?: string,
|
|
576
|
-
): string {
|
|
577
|
-
const { staticPrefix, dynamicSuffix } = buildSystemPromptParts(cwd, mode, sandboxMode, planContext, subagents, sandboxSettings, providerId);
|
|
578
|
-
return `${staticPrefix}${dynamicSuffix}`;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
function buildSubagentPrompt(
|
|
582
|
-
request: TaskRequest,
|
|
583
|
-
cwd: string,
|
|
584
|
-
custom: CustomSubagentConfig | null,
|
|
585
|
-
sandboxMode: SandboxMode,
|
|
586
|
-
subagents?: CustomSubagentConfig[],
|
|
587
|
-
sandboxSettings?: SandboxSettings,
|
|
588
|
-
providerId?: string,
|
|
589
|
-
): string {
|
|
590
|
-
const isExplore = request.agent === "explore";
|
|
591
|
-
const isVision = request.agent === "vision";
|
|
592
|
-
const isVerify = request.agent === "verify";
|
|
593
|
-
const isVerifyDetect = request.agent === "verify-detect";
|
|
594
|
-
const isVerifyManifest = request.agent === "verify-manifest";
|
|
595
|
-
const isComputer = request.agent === "computer";
|
|
596
|
-
const mode: AgentMode = isExplore || isVerifyDetect ? "ask" : "agent";
|
|
597
|
-
const role = custom
|
|
598
|
-
? `You are the custom sub-agent "${custom.name}". You can investigate, edit files, and run commands unless the delegated task says otherwise.`
|
|
599
|
-
: request.agent === "explore"
|
|
600
|
-
? "You are the Explore sub-agent. You are read-only and focus on fast codebase research."
|
|
601
|
-
: isVision
|
|
602
|
-
? "You are the Vision sub-agent."
|
|
603
|
-
: isVerifyDetect
|
|
604
|
-
? "You are the Verify Detect sub-agent. You inspect a repository to produce a structured verification recipe. You are read-only."
|
|
605
|
-
: isVerifyManifest
|
|
606
|
-
? "You are the Verify Manifest sub-agent. You inspect a repository and create or update .muonroi-cli/environment.json so verification can run reproducibly."
|
|
607
|
-
: isVerify
|
|
608
|
-
? "You are the Verify sub-agent. You specialize in sandbox-aware local verification using builds, tests, app boot checks, and optional browser smoke tests."
|
|
609
|
-
: isComputer
|
|
610
|
-
? "You are the Computer sub-agent. You specialize in host desktop automation using accessibility snapshots, semantic element refs, screenshots, and careful mouse and keyboard actions."
|
|
611
|
-
: "You are the General sub-agent. You can investigate, edit files, and run commands to complete delegated work.";
|
|
612
|
-
|
|
613
|
-
const rules = isExplore
|
|
614
|
-
? [
|
|
615
|
-
"Do not create, modify, or delete files.",
|
|
616
|
-
"Prefer `read_file` and search commands over broad shell exploration.",
|
|
617
|
-
"Return concise findings for the parent agent.",
|
|
618
|
-
]
|
|
619
|
-
: isVerifyDetect
|
|
620
|
-
? [
|
|
621
|
-
"Do not create, modify, or delete files.",
|
|
622
|
-
"Read config files, package manifests, scripts, and source layout to understand the project.",
|
|
623
|
-
"Return ONLY a valid JSON object with the VerifyRecipe schema. No markdown, no prose, no explanation outside the JSON.",
|
|
624
|
-
]
|
|
625
|
-
: isVerifyManifest
|
|
626
|
-
? [
|
|
627
|
-
"Focus on creating or updating .muonroi-cli/environment.json as the primary verification contract for this repository.",
|
|
628
|
-
"Read package.json and key config files to understand the project, then write .muonroi-cli/environment.json.",
|
|
629
|
-
"Prefer editing only .muonroi-cli/environment.json unless the delegated task explicitly requires something else.",
|
|
630
|
-
"",
|
|
631
|
-
"SANDBOX ENVIRONMENT (Shuru):",
|
|
632
|
-
"- OS: Debian GNU/Linux 13 (trixie)",
|
|
633
|
-
"- Architecture: aarch64 (ARM64)",
|
|
634
|
-
"- Pre-installed: NOTHING. No node, npm, npx, bun, python3, pip, go, cargo, java, or any runtime.",
|
|
635
|
-
"- Only basic system tools exist (sh, apt-get, curl, etc).",
|
|
636
|
-
"- Network access is available during bootstrap and install.",
|
|
637
|
-
"- The workspace is mounted at /workspace.",
|
|
638
|
-
"",
|
|
639
|
-
"MANIFEST REQUIREMENTS:",
|
|
640
|
-
"- bootstrapCommands: MUST install every runtime and build tool the project needs from scratch via apt-get or curl.",
|
|
641
|
-
"- For Node.js/Next.js/Vite/etc: `apt-get update && apt-get install -y curl unzip ca-certificates git python3 make g++ pkg-config nodejs npm`",
|
|
642
|
-
"- For Bun projects: also `curl -fsSL https://bun.sh/install | bash` and shellInitCommands with BUN_INSTALL/PATH exports.",
|
|
643
|
-
"- For Python: `apt-get update && apt-get install -y python3 python3-pip python3-venv ca-certificates git`",
|
|
644
|
-
"- For Go: `apt-get update && apt-get install -y golang ca-certificates git`",
|
|
645
|
-
"- For Rust: `apt-get update && apt-get install -y curl ca-certificates git build-essential && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y`",
|
|
646
|
-
"- installCommands: The package install command (npm install, pip install, etc).",
|
|
647
|
-
"- buildCommands: Build commands if applicable.",
|
|
648
|
-
"- testCommands: Test/lint commands if applicable.",
|
|
649
|
-
"- startCommand + startPort: How to start the app for smoke testing.",
|
|
650
|
-
"- smokeKind: 'http' if the app has a web UI, 'cli' for CLI tools, 'none' otherwise.",
|
|
651
|
-
"- Do NOT leave bootstrapCommands empty. The sandbox has nothing.",
|
|
652
|
-
"",
|
|
653
|
-
"Return a concise summary of what you wrote and why.",
|
|
654
|
-
]
|
|
655
|
-
: isVision
|
|
656
|
-
? ["Validate the image."]
|
|
657
|
-
: isComputer
|
|
658
|
-
? [
|
|
659
|
-
"Operate carefully on the HOST desktop, not inside the shell sandbox.",
|
|
660
|
-
"Start with `computer_snapshot` when possible. It returns stable refs like @e1 that remain valid until the next snapshot.",
|
|
661
|
-
"Prefer accessibility refs over coordinates. Use `computer_click`, `computer_type`, `computer_scroll`, and `computer_get` with refs from the latest snapshot.",
|
|
662
|
-
"After any meaningful UI transition, launch, dialog open, or menu change, take another `computer_snapshot` before reusing old refs.",
|
|
663
|
-
"Use `computer_launch`, `computer_list_windows`, `computer_focus_window`, and `computer_wait` to manage apps and window state.",
|
|
664
|
-
"Use `computer_press` for shortcuts like Enter or cmd+k. Use `computer_screenshot` only for visual confirmation or when the accessibility tree is insufficient.",
|
|
665
|
-
"If `agent-desktop` is unavailable, permissions are missing, refs go stale, or the state is ambiguous, stop and return the blocker clearly to the parent agent.",
|
|
666
|
-
"Do not perform destructive or high-risk desktop actions unless the delegated task explicitly requires them.",
|
|
667
|
-
]
|
|
668
|
-
: isVerify
|
|
669
|
-
? [
|
|
670
|
-
"You are a QA engineer. Your job is to prove the app works end-to-end, not just that it builds.",
|
|
671
|
-
"Do not make durable source edits unless the delegated task explicitly asks for fixes.",
|
|
672
|
-
"",
|
|
673
|
-
"MANDATORY VERIFICATION STEPS (do ALL of these in order):",
|
|
674
|
-
"1. Install dependencies (run installCommands from the recipe).",
|
|
675
|
-
"2. Build the project (run buildCommands from the recipe).",
|
|
676
|
-
"3. Run tests/lint if available (run testCommands from the recipe).",
|
|
677
|
-
"4. Start the app (run startCommand from the recipe in the background).",
|
|
678
|
-
"5. Wait for the app to be ready (curl readiness check or agent-browser wait).",
|
|
679
|
-
"6. Run browser smoke tests like a real human QA tester:",
|
|
680
|
-
" - Open the app in the browser, record a video, take screenshots.",
|
|
681
|
-
" - Navigate the app: click links, buttons, menus. Verify pages load.",
|
|
682
|
-
" - Check for JavaScript console errors.",
|
|
683
|
-
" - Spend 3-5 interactions testing the critical path.",
|
|
684
|
-
"7. Stop recording, close browser, then stop the dev server.",
|
|
685
|
-
"",
|
|
686
|
-
"Do NOT stop after build/lint. Starting the app and testing it in the browser is the most important part.",
|
|
687
|
-
"agent-browser commands run on the HOST, not inside the sandbox. They WILL work. Do not skip them.",
|
|
688
|
-
"Return a concise verification report. Keep it compact but always include Evidence with artifact file paths.",
|
|
689
|
-
]
|
|
690
|
-
: [
|
|
691
|
-
"Work only on the delegated task below.",
|
|
692
|
-
"Use tools directly instead of narrating your intent.",
|
|
693
|
-
"Return a concise summary for the parent agent with key outcomes and any open risks.",
|
|
694
|
-
];
|
|
695
|
-
|
|
696
|
-
const instructionLines = custom?.instruction.trim() ? ["", "SUB-AGENT INSTRUCTIONS:", custom.instruction.trim()] : [];
|
|
697
|
-
|
|
698
|
-
return [
|
|
699
|
-
role,
|
|
700
|
-
...instructionLines,
|
|
701
|
-
"",
|
|
702
|
-
"You are helping a parent agent. Do not address the end user directly.",
|
|
703
|
-
"Focus tightly on the delegated scope and summarize what matters back to the parent agent.",
|
|
704
|
-
"",
|
|
705
|
-
...rules,
|
|
706
|
-
"",
|
|
707
|
-
`Delegated task: ${request.description}`,
|
|
708
|
-
"",
|
|
709
|
-
buildSystemPrompt(cwd, mode, sandboxMode, undefined, subagents, sandboxSettings, providerId),
|
|
710
|
-
].join("\n");
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
function formatSandboxPromptSection(sandboxMode: SandboxMode, settings?: SandboxSettings): string {
|
|
714
|
-
if (sandboxMode === "off") return "";
|
|
715
|
-
|
|
716
|
-
const s = settings ?? {};
|
|
717
|
-
let networkLine: string;
|
|
718
|
-
if (s.allowNet) {
|
|
719
|
-
networkLine = s.allowedHosts?.length
|
|
720
|
-
? `- Network access is restricted to: ${s.allowedHosts.join(", ")}.`
|
|
721
|
-
: "- Network access is enabled.";
|
|
722
|
-
} else {
|
|
723
|
-
networkLine = "- Network is disabled.";
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
const lines = [
|
|
727
|
-
"",
|
|
728
|
-
"SANDBOX MODE:",
|
|
729
|
-
"- Bash commands run inside a Shuru sandbox.",
|
|
730
|
-
networkLine,
|
|
731
|
-
"- The current workspace is mounted inside the sandbox at `/workspace`.",
|
|
732
|
-
"- Shell-side workspace file changes do not persist back to the host in this version.",
|
|
733
|
-
"- Use `read_file`, `edit_file`, and `write_file` for durable source edits.",
|
|
734
|
-
"- If a task needs a host-persistent shell mutation, explain that sandbox mode blocks that workflow and ask whether to disable sandbox mode.",
|
|
735
|
-
];
|
|
736
|
-
|
|
737
|
-
if (s.ports?.length) {
|
|
738
|
-
lines.push(`- Port forwards: ${s.ports.join(", ")}.`);
|
|
739
|
-
}
|
|
740
|
-
if (s.from) {
|
|
741
|
-
lines.push(`- Starting from checkpoint: ${s.from}.`);
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
return lines.join("\n");
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
function applyModelConstraints(system: string, modelId: string): string {
|
|
748
|
-
const modelInfo = getModelInfo(modelId);
|
|
749
|
-
if (modelInfo?.supportsClientTools !== false) {
|
|
750
|
-
return system;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
return [
|
|
754
|
-
system,
|
|
755
|
-
"",
|
|
756
|
-
"MODEL CONSTRAINTS:",
|
|
757
|
-
"- The selected model does not support client-side CLI tool calls in this environment.",
|
|
758
|
-
"- Do not call bash, read_file, lsp, write_file, edit_file, task, delegate, delegation, or MCP tools.",
|
|
759
|
-
"- Answer directly using only the conversation context already provided.",
|
|
760
|
-
].join("\n");
|
|
761
|
-
}
|
|
232
|
+
// ============================================================================
|
|
233
|
+
// Agent class — fields, constructor, session management, core processing loop
|
|
234
|
+
// ============================================================================
|
|
762
235
|
|
|
763
236
|
export class Agent {
|
|
764
237
|
private provider: LegacyProvider | null = null;
|
|
@@ -786,6 +259,20 @@ export class Agent {
|
|
|
786
259
|
/** PIL context for current turn — set after runPipeline, cleared after recordUsage. */
|
|
787
260
|
private _pilActive = false;
|
|
788
261
|
private _pilEnrichmentDelta = 0;
|
|
262
|
+
/**
|
|
263
|
+
* Breakdown of the system prompt + messages + tools sent on the last call.
|
|
264
|
+
* Captured immediately before streamText and consumed by recordUsage to
|
|
265
|
+
* attach to the cost-log entry. Cleared after recordUsage so subsequent
|
|
266
|
+
* non-message calls don't reuse stale data.
|
|
267
|
+
*/
|
|
268
|
+
private _lastPromptBreakdown: Record<string, number> | null = null;
|
|
269
|
+
/**
|
|
270
|
+
* Phase O1 — JSON-shape of the providerOptions object on the most
|
|
271
|
+
* recent streamText call. Captured immediately before streamText and
|
|
272
|
+
* consumed by recordUsage; cleared after. Cost-leak forensics surfaces
|
|
273
|
+
* this so we can answer "did this billed call carry store=true?" etc.
|
|
274
|
+
*/
|
|
275
|
+
private _lastProviderOptionsShape: string | null = null;
|
|
789
276
|
/** External abort context from src/index.ts SIGINT handler (TUI-04). */
|
|
790
277
|
private externalAbortContext: import("./abort.js").AbortContext | null = null;
|
|
791
278
|
/** Pending calls log for Pitfall 9 staged-write tracking. */
|
|
@@ -798,8 +285,50 @@ export class Agent {
|
|
|
798
285
|
private _activeRunId: string | null = null;
|
|
799
286
|
/** Resume digest loaded from active flow run state.md. */
|
|
800
287
|
private _resumeDigest: string | null = null;
|
|
288
|
+
/**
|
|
289
|
+
* Phase 12.1-02: All council state (synthesis/continuation flags, resolver
|
|
290
|
+
* + buffer maps, stats) lives inside CouncilManager. Agent holds one ref.
|
|
291
|
+
*/
|
|
292
|
+
private councilManager: CouncilManager;
|
|
801
293
|
/** Whether compaction already ran during the current turn (prevents double-compact). */
|
|
802
294
|
private _compactedThisTurn = false;
|
|
295
|
+
/** Guard: OAuth provider init runs at most once per Agent instance. */
|
|
296
|
+
private _oauthInitDone = false;
|
|
297
|
+
/** P0 native observation: warning IDs surfaced earlier in this session — sent as intent_context.priorWarningIdsInSession. */
|
|
298
|
+
private _priorWarningIdsInSession = new Set<string>();
|
|
299
|
+
/** EE session guidance: structured warnings accumulated across turns — injected into model context at turn start. Keyed by principle_uuid to deduplicate. */
|
|
300
|
+
private _sessionEEGuidance = new Map<
|
|
301
|
+
string,
|
|
302
|
+
{ toolName: string; message: string; why: string; confidence: number }
|
|
303
|
+
>();
|
|
304
|
+
/** P0 native observation: rolling buffer of assistant reasoning text in current turn — last 200 chars sent as intent_context.assistantReasoningExcerpt. */
|
|
305
|
+
private _turnAssistantReasoning = "";
|
|
306
|
+
/** Per-call correlation id for top-level streamText; set in MessageProcessor, consumed by recordUsage / onFinish llm-done. */
|
|
307
|
+
private _currentCallId = "";
|
|
308
|
+
/** P0 native observation: first 200 chars of the user's current turn — sent as intent_context.userGoalExcerpt to PreToolUse. */
|
|
309
|
+
private _turnUserGoalExcerpt = "";
|
|
310
|
+
/** Compaction statistics tracking count and total tokens saved. */
|
|
311
|
+
private _compactionStats: { count: number; totalSaved: number } = { count: 0, totalSaved: 0 };
|
|
312
|
+
/**
|
|
313
|
+
* Pinned message sequences. A pinned user message is preserved verbatim across
|
|
314
|
+
* compaction — it is re-injected as a system note immediately after the
|
|
315
|
+
* compaction summary, so the model still sees the original wording.
|
|
316
|
+
* V1 only supports user messages (avoids splitting tool-call/result pairs).
|
|
317
|
+
*/
|
|
318
|
+
private _pinnedSeqs = new Set<number>();
|
|
319
|
+
/** One-shot cwd note injected at the start of the next processMessage turn after setCwd(). Cleared after injection. */
|
|
320
|
+
private _pendingCwdNote: string | null = null;
|
|
321
|
+
|
|
322
|
+
// Phase C3: cross-turn tool-output dedup. One instance per session; bumped
|
|
323
|
+
// on each user turn. Lazily initialized so disabled-via-env path stays cheap.
|
|
324
|
+
private _crossTurnDedup: CrossTurnDedup | null = isCrossTurnDedupEnabled() ? new CrossTurnDedup() : null;
|
|
325
|
+
// Phase C4 — input-keyed read-path budget. Complements C3 (output hash) by
|
|
326
|
+
// catching re-reads of files the agent edited between rounds. Disabled
|
|
327
|
+
// when MUONROI_MAX_READS_PER_PATH=0.
|
|
328
|
+
private _readBudget: ReadPathBudget | null = (() => {
|
|
329
|
+
const cap = getReadPathBudgetCap();
|
|
330
|
+
return cap > 0 ? new ReadPathBudget(cap) : null;
|
|
331
|
+
})();
|
|
803
332
|
|
|
804
333
|
constructor(
|
|
805
334
|
apiKey: string | undefined,
|
|
@@ -812,12 +341,25 @@ export class Agent {
|
|
|
812
341
|
this.bash = new BashTool(process.cwd(), {
|
|
813
342
|
sandboxMode: options.sandboxMode ?? "off",
|
|
814
343
|
sandboxSettings: options.sandboxSettings,
|
|
344
|
+
shellSettings: options.shellSettings ?? getCurrentShellSettings(),
|
|
815
345
|
});
|
|
816
346
|
this.delegations = new DelegationManager(() => this.bash.getCwd());
|
|
347
|
+
// Phase 12.1-02: council state + helpers live in CouncilManager. DI via
|
|
348
|
+
// getter callbacks so the manager reads live Agent state without holding
|
|
349
|
+
// a circular reference to the Agent instance.
|
|
350
|
+
this.councilManager = new CouncilManager({
|
|
351
|
+
getModelId: () => this.modelId,
|
|
352
|
+
getSessionId: () => this.session?.id ?? null,
|
|
353
|
+
hasSessionStore: () => this.sessionStore !== null,
|
|
354
|
+
getMessages: () => this.messages,
|
|
355
|
+
getBash: () => this.bash,
|
|
356
|
+
getMode: () => this.mode,
|
|
357
|
+
});
|
|
817
358
|
|
|
818
359
|
const initialMode: AgentMode = "agent";
|
|
819
360
|
this.modelId = normalizeModelId(model || getCurrentModel(initialMode));
|
|
820
361
|
this.providerId = detectProviderForModel(this.modelId);
|
|
362
|
+
setProviderHint(this.providerId);
|
|
821
363
|
if (apiKey) {
|
|
822
364
|
this.setApiKey(apiKey, baseURL);
|
|
823
365
|
}
|
|
@@ -855,7 +397,7 @@ export class Agent {
|
|
|
855
397
|
* Fail-open: any error sets _activeRunId = null silently.
|
|
856
398
|
*/
|
|
857
399
|
private async _initFlow(): Promise<void> {
|
|
858
|
-
bootstrapEEClient().catch(() => {});
|
|
400
|
+
await bootstrapEEClient().catch(() => {});
|
|
859
401
|
try {
|
|
860
402
|
const flowDir = await ensureFlowDir(this.bash.getCwd());
|
|
861
403
|
const existing = await getActiveRunId(flowDir);
|
|
@@ -891,9 +433,11 @@ export class Agent {
|
|
|
891
433
|
const newProviderId = detectProviderForModel(this.modelId);
|
|
892
434
|
if (newProviderId !== this.providerId && this.apiKey) {
|
|
893
435
|
this.providerId = newProviderId;
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
436
|
+
setProviderHint(this.providerId);
|
|
437
|
+
const effectiveBaseURL =
|
|
438
|
+
this.providerId !== "anthropic" && this.baseURL === apiBaseFor("anthropic")
|
|
439
|
+
? undefined
|
|
440
|
+
: (this.baseURL ?? undefined);
|
|
897
441
|
this.provider = createProvider(this.providerId, this.apiKey, effectiveBaseURL);
|
|
898
442
|
}
|
|
899
443
|
if (this.sessionStore && this.session) {
|
|
@@ -954,14 +498,14 @@ export class Agent {
|
|
|
954
498
|
this.baseURL = baseURL || null;
|
|
955
499
|
// Only pass baseURL to provider factory if it's an explicit override,
|
|
956
500
|
// not the default Anthropic URL (which would break non-Anthropic providers).
|
|
957
|
-
const effectiveBaseURL =
|
|
958
|
-
? undefined
|
|
959
|
-
: baseURL;
|
|
501
|
+
const effectiveBaseURL =
|
|
502
|
+
this.providerId !== "anthropic" && baseURL === apiBaseFor("anthropic") ? undefined : baseURL;
|
|
960
503
|
this.provider = createProvider(this.providerId, apiKey, effectiveBaseURL);
|
|
961
504
|
}
|
|
962
505
|
|
|
963
506
|
setProviderAndKey(providerId: ProviderId, apiKey: string, baseURL?: string): void {
|
|
964
507
|
this.providerId = providerId;
|
|
508
|
+
setProviderHint(this.providerId);
|
|
965
509
|
this.setApiKey(apiKey, baseURL);
|
|
966
510
|
}
|
|
967
511
|
|
|
@@ -973,6 +517,11 @@ export class Agent {
|
|
|
973
517
|
return this.bash.getCwd();
|
|
974
518
|
}
|
|
975
519
|
|
|
520
|
+
setCwd(dir: string): void {
|
|
521
|
+
this.bash.setCwd(dir);
|
|
522
|
+
this._pendingCwdNote = `(system: working directory has been changed to ${dir} — subsequent shell commands run from there; do NOT cd to that path again)`;
|
|
523
|
+
}
|
|
524
|
+
|
|
976
525
|
getMessages(): ModelMessage[] {
|
|
977
526
|
return this.messages;
|
|
978
527
|
}
|
|
@@ -1097,8 +646,7 @@ export class Agent {
|
|
|
1097
646
|
|
|
1098
647
|
async clearHistory(): Promise<void> {
|
|
1099
648
|
// D-09: Extract messages accumulated since last clear BEFORE reset
|
|
1100
|
-
await extractSession(this.messages, this.bash.getCwd(), "cli-clear", this.getSessionId())
|
|
1101
|
-
.catch(() => {}); // D-05: redundant safety — extractSession already swallows
|
|
649
|
+
await extractSession(this.messages, this.bash.getCwd(), "cli-clear", this.getSessionId()).catch(() => {}); // D-05: redundant safety — extractSession already swallows
|
|
1102
650
|
this.startNewSession();
|
|
1103
651
|
}
|
|
1104
652
|
|
|
@@ -1113,15 +661,20 @@ export class Agent {
|
|
|
1113
661
|
this.sessionStartHookFired = false;
|
|
1114
662
|
}
|
|
1115
663
|
|
|
1116
|
-
// Reset token counters and
|
|
664
|
+
// Reset token counters, cost, and compaction state for the new session
|
|
1117
665
|
statusBarStore.setState({
|
|
1118
666
|
in_tokens: 0,
|
|
1119
667
|
out_tokens: 0,
|
|
1120
668
|
cache_read_tokens: 0,
|
|
1121
669
|
cache_creation_tokens: 0,
|
|
1122
670
|
session_usd: 0,
|
|
671
|
+
ctx_tokens: 0,
|
|
672
|
+
compaction_summary: undefined,
|
|
1123
673
|
});
|
|
1124
674
|
|
|
675
|
+
this._compactionStats = { count: 0, totalSaved: 0 };
|
|
676
|
+
this._pinnedSeqs.clear();
|
|
677
|
+
|
|
1125
678
|
if (!this.sessionStore) {
|
|
1126
679
|
this.messages = [];
|
|
1127
680
|
this.messageSeqs = [];
|
|
@@ -1148,6 +701,44 @@ export class Agent {
|
|
|
1148
701
|
return this.session?.title || null;
|
|
1149
702
|
}
|
|
1150
703
|
|
|
704
|
+
getCompactionStats(): { count: number; totalSaved: number } {
|
|
705
|
+
return { ...this._compactionStats };
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Pin a user message by its sequence number. Pinned messages survive
|
|
710
|
+
* compaction verbatim — re-injected as a system note after the summary.
|
|
711
|
+
* Returns true if the message was found, is a user message, and got pinned.
|
|
712
|
+
*/
|
|
713
|
+
pinMessageBySeq(seq: number): boolean {
|
|
714
|
+
const idx = this.messageSeqs.indexOf(seq);
|
|
715
|
+
if (idx < 0) return false;
|
|
716
|
+
if (this.messages[idx]?.role !== "user") return false;
|
|
717
|
+
this._pinnedSeqs.add(seq);
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/** Pin the most recent user message in the live conversation. Returns its seq, or null. */
|
|
722
|
+
pinLastUserMessage(): number | null {
|
|
723
|
+
for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
724
|
+
if (this.messages[i]?.role !== "user") continue;
|
|
725
|
+
const seq = this.messageSeqs[i];
|
|
726
|
+
if (typeof seq === "number") {
|
|
727
|
+
this._pinnedSeqs.add(seq);
|
|
728
|
+
return seq;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return null;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
unpinMessageBySeq(seq: number): boolean {
|
|
735
|
+
return this._pinnedSeqs.delete(seq);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
getPinnedSeqs(): number[] {
|
|
739
|
+
return [...this._pinnedSeqs].sort((a, b) => a - b);
|
|
740
|
+
}
|
|
741
|
+
|
|
1151
742
|
getChatEntries(): ChatEntry[] {
|
|
1152
743
|
if (!this.session) return [];
|
|
1153
744
|
return buildChatEntries(this.session.id);
|
|
@@ -1180,13 +771,24 @@ export class Agent {
|
|
|
1180
771
|
private discardAbortedTurn(userMessage: ModelMessage): void {
|
|
1181
772
|
const idx = this.messages.lastIndexOf(userMessage);
|
|
1182
773
|
if (idx >= 0) {
|
|
1183
|
-
|
|
1184
|
-
|
|
774
|
+
// Keep the user message but add a stub assistant response so the
|
|
775
|
+
// conversation remains valid for follow-up messages after ESC.
|
|
776
|
+
const alreadyHasResponse = idx < this.messages.length - 1 && this.messages[idx + 1]?.role === "assistant";
|
|
777
|
+
if (!alreadyHasResponse) {
|
|
778
|
+
this.messages.splice(idx + 1, 0, { role: "assistant", content: "[Interrupted]" });
|
|
779
|
+
this.messageSeqs.splice(idx + 1, 0, null);
|
|
780
|
+
}
|
|
1185
781
|
}
|
|
1186
782
|
}
|
|
1187
783
|
|
|
1188
784
|
private recordUsage(
|
|
1189
|
-
usage?: {
|
|
785
|
+
usage?: {
|
|
786
|
+
totalTokens?: number;
|
|
787
|
+
inputTokens?: number;
|
|
788
|
+
outputTokens?: number;
|
|
789
|
+
cacheReadTokens?: number;
|
|
790
|
+
cacheCreationTokens?: number;
|
|
791
|
+
},
|
|
1190
792
|
source: UsageSource = "message",
|
|
1191
793
|
model = this.modelId,
|
|
1192
794
|
): void {
|
|
@@ -1194,12 +796,55 @@ export class Agent {
|
|
|
1194
796
|
if (this.session) {
|
|
1195
797
|
const pilActive = source === "message" ? this._pilActive : false;
|
|
1196
798
|
const enrichmentDelta = source === "message" ? this._pilEnrichmentDelta : 0;
|
|
1197
|
-
|
|
799
|
+
// Attribute usage to the most recent persisted message — this lets
|
|
800
|
+
// per-prompt cost analysis work (was null hardcoded → impossible).
|
|
801
|
+
const lastSeq = lastPersistedSeq(this.messageSeqs);
|
|
802
|
+
// Phase O1 — providerOptions shape (types only, no values) attached
|
|
803
|
+
// to every usage event so post-mortem can answer "what provider
|
|
804
|
+
// options did this billed call carry?". Cleared below for "message"
|
|
805
|
+
// sources so non-message calls don't reuse stale data.
|
|
806
|
+
const providerOptionsShape = this._lastProviderOptionsShape;
|
|
807
|
+
recordUsageEvent(
|
|
808
|
+
this.session.id,
|
|
809
|
+
source,
|
|
810
|
+
model,
|
|
811
|
+
usage,
|
|
812
|
+
lastSeq,
|
|
813
|
+
pilActive,
|
|
814
|
+
enrichmentDelta,
|
|
815
|
+
providerOptionsShape,
|
|
816
|
+
);
|
|
1198
817
|
if (source === "message") {
|
|
1199
818
|
this._pilActive = false;
|
|
1200
819
|
this._pilEnrichmentDelta = 0;
|
|
820
|
+
this._lastProviderOptionsShape = null;
|
|
1201
821
|
}
|
|
1202
822
|
}
|
|
823
|
+
// Phase D — surfaced for harness E2E verification. Mirror the recorded usage
|
|
824
|
+
// event onto the agent-mode sidechannel so spec processes can assert on
|
|
825
|
+
// cacheReadTokens / cacheCreationTokens normalization without poking at the
|
|
826
|
+
// child's sqlite. Best-effort, only fires when agent-mode runtime is set.
|
|
827
|
+
try {
|
|
828
|
+
const rt = (globalThis as Record<string, unknown>).__muonroiAgentRuntime as
|
|
829
|
+
| { emitEvent?: (e: unknown) => void }
|
|
830
|
+
| undefined;
|
|
831
|
+
if (rt?.emitEvent) {
|
|
832
|
+
const lastSeqForEvent = this.session ? lastPersistedSeq(this.messageSeqs) : null;
|
|
833
|
+
rt.emitEvent({
|
|
834
|
+
t: "event",
|
|
835
|
+
kind: "usage",
|
|
836
|
+
source,
|
|
837
|
+
model,
|
|
838
|
+
inputTokens: usage.inputTokens,
|
|
839
|
+
outputTokens: usage.outputTokens,
|
|
840
|
+
cacheReadTokens: usage.cacheReadTokens,
|
|
841
|
+
cacheCreationTokens: usage.cacheCreationTokens,
|
|
842
|
+
messageSeq: lastSeqForEvent,
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
} catch {
|
|
846
|
+
// best-effort: do not let sidechannel failures interrupt usage recording
|
|
847
|
+
}
|
|
1203
848
|
// Update status bar token counters + provider/model + cache metrics + cost
|
|
1204
849
|
const prev = statusBarStore.getState();
|
|
1205
850
|
const info = getModelInfo(model);
|
|
@@ -1212,7 +857,8 @@ export class Agent {
|
|
|
1212
857
|
const priceOut = info?.outputPrice ?? 0;
|
|
1213
858
|
// API inputTokens includes cacheRead — subtract to get non-cached portion
|
|
1214
859
|
const nonCachedInput = Math.max(0, totalInput - cacheRead - cacheCreate);
|
|
1215
|
-
const turnCostMicros =
|
|
860
|
+
const turnCostMicros =
|
|
861
|
+
nonCachedInput * priceIn + cacheRead * priceCached + cacheCreate * priceIn + output * priceOut;
|
|
1216
862
|
statusBarStore.setState({
|
|
1217
863
|
in_tokens: prev.in_tokens + totalInput,
|
|
1218
864
|
out_tokens: prev.out_tokens + output,
|
|
@@ -1222,6 +868,28 @@ export class Agent {
|
|
|
1222
868
|
provider: this.providerId,
|
|
1223
869
|
model,
|
|
1224
870
|
});
|
|
871
|
+
|
|
872
|
+
// Append to cost-log JSONL so `usage report --by callsite` can surface
|
|
873
|
+
// where orchestrator/task/title traffic is actually spending.
|
|
874
|
+
// Best-effort: failures inside appendCostLog are swallowed (see cost-log.ts).
|
|
875
|
+
const breakdown = source === "message" ? (this._lastPromptBreakdown ?? undefined) : undefined;
|
|
876
|
+
appendCostLog({
|
|
877
|
+
ts: Date.now(),
|
|
878
|
+
provider: this.providerId,
|
|
879
|
+
model,
|
|
880
|
+
estimatedUsd: turnCostMicros / 1_000_000,
|
|
881
|
+
callsite: `orchestrator.${source}`,
|
|
882
|
+
phase: source,
|
|
883
|
+
actualInputTokens: totalInput,
|
|
884
|
+
actualOutputTokens: output,
|
|
885
|
+
cachedInputTokens: cacheRead,
|
|
886
|
+
systemChars: breakdown?.systemChars,
|
|
887
|
+
promptChars: breakdown?.messagesChars,
|
|
888
|
+
breakdown,
|
|
889
|
+
}).catch(() => undefined);
|
|
890
|
+
// Don't clear breakdown — onStepFinish fires recordUsage per step within
|
|
891
|
+
// the same streamText call, and they all share the same prompt structure.
|
|
892
|
+
// It is overwritten on the next streamText setup, which is the right scope.
|
|
1225
893
|
}
|
|
1226
894
|
|
|
1227
895
|
async consumeBackgroundNotifications(): Promise<string[]> {
|
|
@@ -1340,12 +1008,14 @@ export class Agent {
|
|
|
1340
1008
|
signal,
|
|
1341
1009
|
} = args;
|
|
1342
1010
|
|
|
1343
|
-
|
|
1011
|
+
const childCaps = getProviderCapabilities(childRuntime.modelInfo?.provider ?? "anthropic");
|
|
1012
|
+
if (childCaps.usesResponsesAPI(childRuntime.modelInfo)) {
|
|
1344
1013
|
throw new Error("Batch mode currently supports chat-completions models only.");
|
|
1345
1014
|
}
|
|
1346
1015
|
|
|
1347
|
-
const batchTools =
|
|
1348
|
-
|
|
1016
|
+
const batchTools = !childCaps.supportsClientTools(childRuntime.modelInfo)
|
|
1017
|
+
? []
|
|
1018
|
+
: await toolSetToBatchTools(childTools);
|
|
1349
1019
|
const batch = await createBatch({
|
|
1350
1020
|
...this.getBatchClientOptions(signal),
|
|
1351
1021
|
name: buildBatchName(`task-${request.agent}`, request.description),
|
|
@@ -1370,10 +1040,9 @@ export class Agent {
|
|
|
1370
1040
|
system: childSystem,
|
|
1371
1041
|
messages: [...childMessages, ...turnMessages],
|
|
1372
1042
|
temperature: request.agent === "explore" ? 0.2 : 0.5,
|
|
1373
|
-
maxOutputTokens:
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
: Math.min(this.maxTokens, 8_192),
|
|
1043
|
+
maxOutputTokens: !childCaps.acceptsParam("maxOutputTokens", childRuntime.modelInfo)
|
|
1044
|
+
? undefined
|
|
1045
|
+
: Math.min(this.maxTokens, 8_192),
|
|
1377
1046
|
reasoningEffort: childRuntime.providerOptions?.xai.reasoningEffort,
|
|
1378
1047
|
tools: batchTools,
|
|
1379
1048
|
}),
|
|
@@ -1462,244 +1131,42 @@ export class Agent {
|
|
|
1462
1131
|
};
|
|
1463
1132
|
}
|
|
1464
1133
|
|
|
1134
|
+
/**
|
|
1135
|
+
* Run a sub-agent task by spawning a child `streamText` session.
|
|
1136
|
+
*
|
|
1137
|
+
* Phase 12.3 — body extracted to `StreamRunner` (`./stream-runner.ts`).
|
|
1138
|
+
* This method now builds the DI dep set and delegates to
|
|
1139
|
+
* `StreamRunner.run()`. Public signature is unchanged so all callers
|
|
1140
|
+
* (`runTask`, `tools/registry`, batch path, council path) work as before.
|
|
1141
|
+
*/
|
|
1465
1142
|
async runTaskRequest(
|
|
1466
1143
|
request: TaskRequest,
|
|
1467
1144
|
onActivity?: (detail: string) => void,
|
|
1468
1145
|
abortSignal?: AbortSignal,
|
|
1469
1146
|
): Promise<ToolResult> {
|
|
1470
1147
|
const provider = this.requireProvider();
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
!isComputer &&
|
|
1494
|
-
!custom
|
|
1495
|
-
) {
|
|
1496
|
-
const message = `Unknown sub-agent "${agentKey}". Use general, explore, vision, verify, verify-detect, verify-manifest, computer, or a configured name from ~/.muonroi-cli/user-settings.json.`;
|
|
1497
|
-
return {
|
|
1498
|
-
success: false,
|
|
1499
|
-
output: message,
|
|
1500
|
-
task: {
|
|
1501
|
-
agent: agentKey,
|
|
1502
|
-
description: request.description,
|
|
1503
|
-
summary: message,
|
|
1504
|
-
},
|
|
1505
|
-
};
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
const childMode: AgentMode = isExplore || isVerifyDetect ? "ask" : "agent";
|
|
1509
|
-
const verifySandboxOverrides: SandboxSettings = isVerify
|
|
1510
|
-
? { allowNet: true, allowedHosts: undefined, allowEphemeralInstall: true, hostBrowserCommandsOnHost: true }
|
|
1511
|
-
: {};
|
|
1512
|
-
let verifyPreparedSettings: SandboxSettings | null = null;
|
|
1513
|
-
let verifyPreparedRecipe: VerifyRecipe | null = null;
|
|
1514
|
-
if (isVerify) {
|
|
1515
|
-
const prepared = await prepareVerifySandbox(
|
|
1516
|
-
this.bash.getCwd(),
|
|
1517
|
-
{ ...this.bash.getSandboxSettings(), ...verifySandboxOverrides },
|
|
1518
|
-
undefined,
|
|
1519
|
-
onActivity,
|
|
1520
|
-
);
|
|
1521
|
-
verifyPreparedSettings = prepared.sandboxSettings;
|
|
1522
|
-
verifyPreparedRecipe = prepared.profile.recipe;
|
|
1523
|
-
}
|
|
1524
|
-
const childBash = new BashTool(this.bash.getCwd(), {
|
|
1525
|
-
sandboxMode: isVerify ? "shuru" : this.bash.getSandboxMode(),
|
|
1526
|
-
sandboxSettings: isVerify
|
|
1527
|
-
? (verifyPreparedSettings ?? { ...this.bash.getSandboxSettings(), ...verifySandboxOverrides })
|
|
1528
|
-
: this.bash.getSandboxSettings(),
|
|
1529
|
-
});
|
|
1530
|
-
const childBaseTools = createTools(childBash, provider, childMode);
|
|
1531
|
-
const initialDetail = isExplore
|
|
1532
|
-
? "Scanning the codebase"
|
|
1533
|
-
: isVerifyDetect
|
|
1534
|
-
? "Detecting verification recipe"
|
|
1535
|
-
: isVerifyManifest
|
|
1536
|
-
? "Creating verification manifest"
|
|
1537
|
-
: isVerify
|
|
1538
|
-
? "Preparing verification pass"
|
|
1539
|
-
: isComputer
|
|
1540
|
-
? "Preparing computer control pass"
|
|
1541
|
-
: "Planning delegated work";
|
|
1542
|
-
let assistantText = "";
|
|
1543
|
-
let lastActivity = initialDetail;
|
|
1544
|
-
let childTools: ToolSet = childBaseTools;
|
|
1545
|
-
let closeMcp: (() => Promise<void>) | undefined;
|
|
1546
|
-
const childModelId = normalizeModelId(
|
|
1547
|
-
isVision
|
|
1548
|
-
? VISION_MODEL
|
|
1549
|
-
: isComputer
|
|
1550
|
-
? COMPUTER_MODEL
|
|
1551
|
-
: isExplore
|
|
1552
|
-
? DEFAULT_MODEL
|
|
1553
|
-
: custom
|
|
1554
|
-
? custom.model
|
|
1555
|
-
: this.modelId,
|
|
1556
|
-
);
|
|
1557
|
-
const childRuntime = isVision
|
|
1558
|
-
? { ...resolveModelRuntime(provider, childModelId), model: provider.responses?.(childModelId) ?? provider(childModelId) }
|
|
1559
|
-
: resolveModelRuntime(provider, childModelId);
|
|
1560
|
-
if (isComputer && childRuntime.modelInfo?.supportsClientTools === false) {
|
|
1561
|
-
return {
|
|
1562
|
-
success: false,
|
|
1563
|
-
output:
|
|
1564
|
-
"Computer sub-agent requires a tool-capable model, but the selected runtime does not support client tools.",
|
|
1565
|
-
task: {
|
|
1566
|
-
agent: agentKey,
|
|
1567
|
-
description: request.description,
|
|
1568
|
-
summary: "Computer sub-agent could not start because the chosen model does not support tools.",
|
|
1569
|
-
},
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
|
-
const childSystem = applyModelConstraints(
|
|
1573
|
-
buildSubagentPrompt(
|
|
1574
|
-
request,
|
|
1575
|
-
childBash.getCwd(),
|
|
1576
|
-
custom ?? null,
|
|
1577
|
-
childBash.getSandboxMode(),
|
|
1578
|
-
subagents,
|
|
1579
|
-
childBash.getSandboxSettings(),
|
|
1580
|
-
childRuntime.modelInfo?.provider ?? this.providerId,
|
|
1581
|
-
),
|
|
1582
|
-
childRuntime.modelId,
|
|
1583
|
-
);
|
|
1584
|
-
|
|
1585
|
-
onActivity?.(initialDetail);
|
|
1586
|
-
|
|
1587
|
-
try {
|
|
1588
|
-
if (childMode === "agent" && childRuntime.modelInfo?.supportsClientTools !== false) {
|
|
1589
|
-
const mcpBundle = await buildMcpToolSet(loadMcpServers(), {
|
|
1590
|
-
onOAuthRequired: (_serverId, url) => {
|
|
1591
|
-
const urlStr = url.toString();
|
|
1592
|
-
import("child_process").then(({ exec }) => {
|
|
1593
|
-
const cmd = process.platform === "win32" ? `start "" "${urlStr}"`
|
|
1594
|
-
: process.platform === "darwin" ? `open "${urlStr}"`
|
|
1595
|
-
: `xdg-open "${urlStr}"`;
|
|
1596
|
-
exec(cmd);
|
|
1597
|
-
});
|
|
1598
|
-
},
|
|
1599
|
-
});
|
|
1600
|
-
closeMcp = mcpBundle.close;
|
|
1601
|
-
childTools = { ...childBaseTools, ...mcpBundle.tools };
|
|
1602
|
-
captureToolSchemas(childTools);
|
|
1603
|
-
if (mcpBundle.errors.length > 0) {
|
|
1604
|
-
lastActivity = `MCP unavailable: ${mcpBundle.errors.join(" | ")}`;
|
|
1605
|
-
onActivity?.(lastActivity);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
const childPrompt =
|
|
1610
|
-
isVerify && verifyPreparedRecipe
|
|
1611
|
-
? `${request.prompt}\n\nPrepared verify recipe JSON (use this as the primary execution recipe and keep .muonroi-cli/environment.json aligned with it if present):\n${JSON.stringify(verifyPreparedRecipe, null, 2)}`
|
|
1612
|
-
: request.prompt;
|
|
1613
|
-
|
|
1614
|
-
const childMessages = isVision
|
|
1615
|
-
? await buildVisionUserMessages(request.prompt, childBash.getCwd(), signal)
|
|
1616
|
-
: [{ role: "user" as const, content: childPrompt }];
|
|
1617
|
-
|
|
1618
|
-
if (this.batchApi) {
|
|
1619
|
-
return await this.runTaskRequestBatch({
|
|
1620
|
-
request,
|
|
1621
|
-
childMessages,
|
|
1622
|
-
childSystem,
|
|
1623
|
-
childRuntime,
|
|
1624
|
-
childTools,
|
|
1625
|
-
maxSteps: Math.min(this.maxToolRounds, isExplore ? 60 : 120),
|
|
1626
|
-
initialDetail,
|
|
1627
|
-
onActivity,
|
|
1628
|
-
signal,
|
|
1629
|
-
});
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
const result = streamText({
|
|
1633
|
-
model: childRuntime.model,
|
|
1634
|
-
system: childSystem,
|
|
1635
|
-
messages: childMessages,
|
|
1636
|
-
tools: childRuntime.modelInfo?.supportsClientTools === false ? {} : childTools,
|
|
1637
|
-
stopWhen: stepCountIs(Math.min(this.maxToolRounds, isExplore ? 60 : 120)),
|
|
1638
|
-
maxRetries: 0,
|
|
1639
|
-
abortSignal: signal,
|
|
1640
|
-
temperature: isExplore ? 0.2 : 0.5,
|
|
1641
|
-
...(childRuntime.modelInfo?.supportsMaxOutputTokens === false
|
|
1642
|
-
? {}
|
|
1643
|
-
: { maxOutputTokens: Math.min(this.maxTokens, 8_192) }),
|
|
1644
|
-
...(childRuntime.providerOptions ? { providerOptions: childRuntime.providerOptions } : {}),
|
|
1645
|
-
onFinish: ({ totalUsage, providerMetadata }) => {
|
|
1646
|
-
const anthropicMeta = providerMetadata?.anthropic as Record<string, unknown> | undefined;
|
|
1647
|
-
const cacheReadTokens = asNumber(anthropicMeta?.cacheReadInputTokens) ?? 0;
|
|
1648
|
-
const cacheCreationTokens = asNumber(anthropicMeta?.cacheCreationInputTokens) ?? 0;
|
|
1649
|
-
this.recordUsage({ ...totalUsage, cacheReadTokens, cacheCreationTokens }, "task", childRuntime.modelId);
|
|
1650
|
-
},
|
|
1651
|
-
});
|
|
1652
|
-
|
|
1653
|
-
for await (const part of result.fullStream) {
|
|
1654
|
-
if (signal?.aborted) {
|
|
1655
|
-
break;
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
if (part.type === "text-delta") {
|
|
1659
|
-
assistantText += part.text;
|
|
1660
|
-
continue;
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
if (part.type === "tool-call") {
|
|
1664
|
-
lastActivity = formatSubagentActivity(part.toolName, part.input);
|
|
1665
|
-
onActivity?.(lastActivity);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
if (signal?.aborted) {
|
|
1670
|
-
return { success: false, output: "[Cancelled]" };
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
await result.response;
|
|
1674
|
-
|
|
1675
|
-
const output = assistantText.trim() || `Task completed. Last action: ${lastActivity}`;
|
|
1676
|
-
return {
|
|
1677
|
-
success: true,
|
|
1678
|
-
output,
|
|
1679
|
-
task: {
|
|
1680
|
-
agent: request.agent,
|
|
1681
|
-
description: request.description,
|
|
1682
|
-
summary: firstLine(output),
|
|
1683
|
-
activity: lastActivity,
|
|
1684
|
-
},
|
|
1685
|
-
};
|
|
1686
|
-
} catch (err: unknown) {
|
|
1687
|
-
if (signal?.aborted) throw err;
|
|
1688
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1689
|
-
const output = `Task failed: ${msg}`;
|
|
1690
|
-
return {
|
|
1691
|
-
success: false,
|
|
1692
|
-
output,
|
|
1693
|
-
task: {
|
|
1694
|
-
agent: request.agent,
|
|
1695
|
-
description: request.description,
|
|
1696
|
-
summary: output,
|
|
1697
|
-
activity: lastActivity,
|
|
1698
|
-
},
|
|
1699
|
-
};
|
|
1700
|
-
} finally {
|
|
1701
|
-
await closeMcp?.().catch(() => {});
|
|
1702
|
-
}
|
|
1148
|
+
const deps: StreamRunnerDeps = {
|
|
1149
|
+
getProvider: () => provider,
|
|
1150
|
+
resolveModelForTask: (task) => this._resolveModelForTask(task),
|
|
1151
|
+
getModelId: () => this.modelId,
|
|
1152
|
+
getProviderId: () => this.providerId,
|
|
1153
|
+
getBash: () => this.bash,
|
|
1154
|
+
getMaxToolRounds: () => this.maxToolRounds,
|
|
1155
|
+
getMaxTokens: () => this.maxTokens,
|
|
1156
|
+
isBatchApiEnabled: () => this.batchApi,
|
|
1157
|
+
getCrossTurnDedup: () => this._crossTurnDedup,
|
|
1158
|
+
getReadBudget: () => this._readBudget,
|
|
1159
|
+
recordUsage: (usage, source, model) => this.recordUsage(usage, source, model),
|
|
1160
|
+
setCurrentCallId: (id) => {
|
|
1161
|
+
this._currentCallId = id;
|
|
1162
|
+
},
|
|
1163
|
+
setLastProviderOptionsShape: (shape) => {
|
|
1164
|
+
this._lastProviderOptionsShape = shape;
|
|
1165
|
+
},
|
|
1166
|
+
runTaskRequestBatch: (args) => this.runTaskRequestBatch(args),
|
|
1167
|
+
};
|
|
1168
|
+
const runner = new StreamRunner(deps);
|
|
1169
|
+
return runner.run(request, onActivity, abortSignal);
|
|
1703
1170
|
}
|
|
1704
1171
|
|
|
1705
1172
|
private async runTask(request: TaskRequest, abortSignal?: AbortSignal): Promise<ToolResult> {
|
|
@@ -1714,17 +1181,53 @@ export class Agent {
|
|
|
1714
1181
|
|
|
1715
1182
|
let result: ToolResult;
|
|
1716
1183
|
try {
|
|
1717
|
-
result = await
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1184
|
+
result = await withStreamRetry(
|
|
1185
|
+
() =>
|
|
1186
|
+
this.runTaskRequest(
|
|
1187
|
+
request,
|
|
1188
|
+
(detail) => {
|
|
1189
|
+
if (abortSignal?.aborted) return;
|
|
1190
|
+
this.emitSubagentStatus({
|
|
1191
|
+
agent: request.agent,
|
|
1192
|
+
description: request.description,
|
|
1193
|
+
detail,
|
|
1194
|
+
});
|
|
1195
|
+
},
|
|
1196
|
+
abortSignal,
|
|
1197
|
+
),
|
|
1198
|
+
{
|
|
1199
|
+
signal: abortSignal,
|
|
1200
|
+
onRetry: (info) => {
|
|
1201
|
+
// Emit harness telemetry
|
|
1202
|
+
try {
|
|
1203
|
+
const _ar = (globalThis as Record<string, unknown>).__muonroiAgentRuntime as
|
|
1204
|
+
| { emitEvent: (e: unknown) => void }
|
|
1205
|
+
| undefined;
|
|
1206
|
+
_ar?.emitEvent({
|
|
1207
|
+
t: "event",
|
|
1208
|
+
kind: "stream-retry",
|
|
1209
|
+
...info,
|
|
1210
|
+
});
|
|
1211
|
+
} catch {
|
|
1212
|
+
/* best-effort */
|
|
1213
|
+
}
|
|
1214
|
+
try {
|
|
1215
|
+
if (this.session) {
|
|
1216
|
+
logInteraction(this.session.id, "stream_retry", {
|
|
1217
|
+
data: {
|
|
1218
|
+
attempt: info.attempt,
|
|
1219
|
+
maxAttempts: info.maxAttempts,
|
|
1220
|
+
errorName: info.errorName,
|
|
1221
|
+
errorMessage: info.errorMessage.slice(0, 200),
|
|
1222
|
+
nextDelayMs: info.nextDelayMs,
|
|
1223
|
+
},
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
} catch {
|
|
1227
|
+
/* fail-open */
|
|
1228
|
+
}
|
|
1229
|
+
},
|
|
1726
1230
|
},
|
|
1727
|
-
abortSignal,
|
|
1728
1231
|
);
|
|
1729
1232
|
} finally {
|
|
1730
1233
|
this.emitSubagentStatus(null);
|
|
@@ -1832,19 +1335,49 @@ export class Agent {
|
|
|
1832
1335
|
}
|
|
1833
1336
|
}
|
|
1834
1337
|
|
|
1835
|
-
private getCompactionSettings(): CompactionSettings {
|
|
1338
|
+
private getCompactionSettings(contextWindow?: number): CompactionSettings {
|
|
1339
|
+
let keepRecentTokens = DEFAULT_KEEP_RECENT_TOKENS;
|
|
1340
|
+
|
|
1341
|
+
// For models with very large context windows, keep more recent tokens
|
|
1342
|
+
if (contextWindow && contextWindow > 200_000) {
|
|
1343
|
+
keepRecentTokens = Math.min(100_000, Math.max(20_000, Math.floor(contextWindow * 0.1)));
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// Compact more aggressively for long sessions to prevent runaway token growth
|
|
1347
|
+
if (this._compactionStats.count >= 2) {
|
|
1348
|
+
keepRecentTokens = Math.floor(keepRecentTokens * 0.75);
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1836
1351
|
return {
|
|
1837
1352
|
reserveTokens: Math.max(this.maxTokens, DEFAULT_RESERVE_TOKENS),
|
|
1838
|
-
keepRecentTokens
|
|
1353
|
+
keepRecentTokens,
|
|
1839
1354
|
};
|
|
1840
1355
|
}
|
|
1841
1356
|
|
|
1357
|
+
private _resolveCompactModel(): string {
|
|
1358
|
+
return this._resolveModelForTask("compact");
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
private _resolveModelForTask(task: "compact" | "explore" | "general" | "title"): string {
|
|
1362
|
+
const tierPrefs: Record<string, Array<"fast" | "balanced" | "premium">> = {
|
|
1363
|
+
compact: ["fast", "balanced"],
|
|
1364
|
+
title: ["fast", "balanced"],
|
|
1365
|
+
explore: ["balanced", "fast"],
|
|
1366
|
+
general: ["premium", "balanced"],
|
|
1367
|
+
};
|
|
1368
|
+
for (const tier of tierPrefs[task] ?? ["balanced"]) {
|
|
1369
|
+
const m = getModelByTier(tier, this.providerId);
|
|
1370
|
+
if (m?.provider === this.providerId) return m.id;
|
|
1371
|
+
}
|
|
1372
|
+
return this.modelId;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1842
1375
|
private async compactForContext(
|
|
1843
1376
|
provider: LegacyProvider,
|
|
1844
1377
|
system: string,
|
|
1845
1378
|
contextWindow: number,
|
|
1846
1379
|
signal: AbortSignal,
|
|
1847
|
-
settings = this.getCompactionSettings(),
|
|
1380
|
+
settings = this.getCompactionSettings(contextWindow),
|
|
1848
1381
|
force = false,
|
|
1849
1382
|
): Promise<boolean> {
|
|
1850
1383
|
if (!this.session) return false;
|
|
@@ -1878,11 +1411,84 @@ export class Agent {
|
|
|
1878
1411
|
|
|
1879
1412
|
const keptSeqs = this.messageSeqs.slice(preparation.firstKeptIndex);
|
|
1880
1413
|
const firstKeptSeq = keptSeqs.find((seq): seq is number => seq !== null) ?? getNextMessageSequence(this.session.id);
|
|
1881
|
-
const
|
|
1414
|
+
const compactModelId = this._resolveCompactModel();
|
|
1415
|
+
const compactStartedAt = Date.now();
|
|
1416
|
+
const { summary, usage: compactUsage } = await generateCompactionSummary(
|
|
1417
|
+
provider,
|
|
1418
|
+
compactModelId,
|
|
1419
|
+
preparation,
|
|
1420
|
+
undefined,
|
|
1421
|
+
signal,
|
|
1422
|
+
);
|
|
1423
|
+
|
|
1424
|
+
// Record compaction call in cost-log — bypasses recordUsage because
|
|
1425
|
+
// compaction returns usage separately and isn't routed through the
|
|
1426
|
+
// status-bar / usage event pipeline (intentional: it's overhead, not user spend).
|
|
1427
|
+
const compactProvider = detectProviderForModel(compactModelId);
|
|
1428
|
+
appendCostLog({
|
|
1429
|
+
ts: compactStartedAt,
|
|
1430
|
+
provider: compactProvider,
|
|
1431
|
+
model: compactModelId,
|
|
1432
|
+
estimatedUsd: projectCostUSD(
|
|
1433
|
+
compactProvider,
|
|
1434
|
+
compactModelId,
|
|
1435
|
+
compactUsage.promptTokens,
|
|
1436
|
+
compactUsage.completionTokens,
|
|
1437
|
+
),
|
|
1438
|
+
callsite: "orchestrator.compaction",
|
|
1439
|
+
phase: "compaction",
|
|
1440
|
+
iteration: this._compactionStats.count + 1,
|
|
1441
|
+
actualInputTokens: compactUsage.promptTokens,
|
|
1442
|
+
actualOutputTokens: compactUsage.completionTokens,
|
|
1443
|
+
durationMs: Date.now() - compactStartedAt,
|
|
1444
|
+
}).catch(() => undefined);
|
|
1882
1445
|
|
|
1883
1446
|
appendCompaction(this.session.id, firstKeptSeq, summary, preparation.tokensBefore);
|
|
1884
|
-
|
|
1885
|
-
|
|
1447
|
+
|
|
1448
|
+
// Re-inject pinned user messages that were about to be summarized away.
|
|
1449
|
+
// Pinned seqs that are still inside keptMessages don't need re-injection.
|
|
1450
|
+
const keptSeqSet = new Set(keptSeqs.filter((s): s is number => s !== null));
|
|
1451
|
+
const pinnedReinjections: ModelMessage[] = [];
|
|
1452
|
+
const pinnedReinjectionSeqs: Array<number | null> = [];
|
|
1453
|
+
for (const seq of [...this._pinnedSeqs].sort((a, b) => a - b)) {
|
|
1454
|
+
if (keptSeqSet.has(seq)) continue;
|
|
1455
|
+
const idx = this.messageSeqs.indexOf(seq);
|
|
1456
|
+
if (idx < 0) {
|
|
1457
|
+
// Pinned seq no longer present (shouldn't happen, but stay defensive).
|
|
1458
|
+
this._pinnedSeqs.delete(seq);
|
|
1459
|
+
continue;
|
|
1460
|
+
}
|
|
1461
|
+
const original = this.messages[idx];
|
|
1462
|
+
if (!original || original.role !== "user") continue;
|
|
1463
|
+
const text = extractUserContent(original.content).trim();
|
|
1464
|
+
if (!text) continue;
|
|
1465
|
+
pinnedReinjections.push({
|
|
1466
|
+
role: "system",
|
|
1467
|
+
content: `[Pinned user message — kept verbatim across compaction]\n${text}`,
|
|
1468
|
+
});
|
|
1469
|
+
pinnedReinjectionSeqs.push(null);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
this.messages = [createCompactionSummaryMessage(summary), ...pinnedReinjections, ...preparation.keptMessages];
|
|
1473
|
+
this.messageSeqs = [null, ...pinnedReinjectionSeqs, ...keptSeqs];
|
|
1474
|
+
|
|
1475
|
+
// Track compaction stats — net of the tokens spent ON compaction itself.
|
|
1476
|
+
const tokensAfter = estimateConversationTokens(system, this.messages);
|
|
1477
|
+
const grossSaved = Math.max(0, preparation.tokensBefore - tokensAfter);
|
|
1478
|
+
const compactCost = compactUsage.promptTokens + compactUsage.completionTokens;
|
|
1479
|
+
const saved = Math.max(0, grossSaved - compactCost);
|
|
1480
|
+
const pct = preparation.tokensBefore > 0 ? ((saved / preparation.tokensBefore) * 100).toFixed(1) : "0.0";
|
|
1481
|
+
this._compactionStats.count++;
|
|
1482
|
+
this._compactionStats.totalSaved += saved;
|
|
1483
|
+
|
|
1484
|
+
// Update status bar with current context size and compaction summary
|
|
1485
|
+
const fmtCompact = (n: number) => (n >= 1000 ? `${(n / 1000).toFixed(1)}K` : String(n));
|
|
1486
|
+
const modelSuffix = compactModelId !== this.modelId ? ` via ${compactModelId}` : "";
|
|
1487
|
+
const userMsgCount = this.messages.filter((m) => m.role === "user").length;
|
|
1488
|
+
const isLongSession = this._compactionStats.count >= 3 || userMsgCount >= 200;
|
|
1489
|
+
const sessionHint = isLongSession ? " ⚠ long session — consider /clear" : "";
|
|
1490
|
+
const compactLabel = `${this._compactionStats.count} cmp, ${fmtCompact(this._compactionStats.totalSaved)} saved${modelSuffix}${sessionHint}`;
|
|
1491
|
+
statusBarStore.setState({ ctx_tokens: tokensAfter, compaction_summary: compactLabel });
|
|
1886
1492
|
|
|
1887
1493
|
const postCompactInput: PostCompactHookInput = {
|
|
1888
1494
|
hook_event_name: "PostCompact",
|
|
@@ -1892,6 +1498,26 @@ export class Agent {
|
|
|
1892
1498
|
};
|
|
1893
1499
|
await this.fireHook(postCompactInput, signal).catch(() => {});
|
|
1894
1500
|
|
|
1501
|
+
// Interaction log: compaction
|
|
1502
|
+
try {
|
|
1503
|
+
if (this.session) {
|
|
1504
|
+
logInteraction(this.session.id, "compaction", {
|
|
1505
|
+
data: {
|
|
1506
|
+
count: this._compactionStats.count,
|
|
1507
|
+
tokensBefore: preparation.tokensBefore,
|
|
1508
|
+
tokensAfter,
|
|
1509
|
+
saved,
|
|
1510
|
+
grossSaved,
|
|
1511
|
+
compactCost,
|
|
1512
|
+
pct,
|
|
1513
|
+
isLongSession,
|
|
1514
|
+
},
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
} catch {
|
|
1518
|
+
/* fail-open */
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1895
1521
|
this._compactedThisTurn = true;
|
|
1896
1522
|
return true;
|
|
1897
1523
|
}
|
|
@@ -1902,135 +1528,330 @@ export class Agent {
|
|
|
1902
1528
|
contextWindow: number,
|
|
1903
1529
|
signal: AbortSignal,
|
|
1904
1530
|
): Promise<void> {
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1531
|
+
const log = (taken: boolean, reason: string, extra?: Record<string, unknown>): void => {
|
|
1532
|
+
appendDecisionLog({
|
|
1533
|
+
ts: Date.now(),
|
|
1534
|
+
sessionId: this.session?.id ?? null,
|
|
1535
|
+
kind: "post-turn-compact",
|
|
1536
|
+
taken,
|
|
1537
|
+
reason,
|
|
1538
|
+
meta: { contextWindow, ...extra },
|
|
1539
|
+
}).catch(() => undefined);
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
if (this._compactedThisTurn) return log(false, "already-compacted-this-turn");
|
|
1543
|
+
if (!isAutoCompactAfterTurnEnabled()) return log(false, "feature-disabled");
|
|
1544
|
+
const tokens = estimateConversationTokens(system, this.messages);
|
|
1545
|
+
const thresholdPct = getAutoCompactThresholdPct();
|
|
1546
|
+
const minMeaningfulTokens = Math.max(POST_TURN_MIN_TOKENS, Math.floor(contextWindow * thresholdPct));
|
|
1547
|
+
if (tokens < minMeaningfulTokens) {
|
|
1548
|
+
return log(false, `under-threshold (${tokens} < ${minMeaningfulTokens})`, {
|
|
1549
|
+
tokens,
|
|
1550
|
+
thresholdPct,
|
|
1551
|
+
minMeaningfulTokens,
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
log(true, `over-threshold (${tokens} >= ${minMeaningfulTokens})`, { tokens, thresholdPct, minMeaningfulTokens });
|
|
1555
|
+
await this.compactForContext(
|
|
1556
|
+
provider,
|
|
1557
|
+
system,
|
|
1558
|
+
contextWindow,
|
|
1559
|
+
signal,
|
|
1560
|
+
this.getCompactionSettings(contextWindow),
|
|
1561
|
+
true,
|
|
1562
|
+
).catch((err) => console.warn("[compact] failed:", (err as Error)?.message));
|
|
1912
1563
|
}
|
|
1913
1564
|
|
|
1914
|
-
|
|
1565
|
+
// ========================================================================
|
|
1566
|
+
// Council system — delegated to CouncilManager (Phase 12.1-02)
|
|
1567
|
+
//
|
|
1568
|
+
// All council state + sub-call helpers (generate/research/prompt builders/
|
|
1569
|
+
// outcome parser/executor/candidate resolution) live in CouncilManager.
|
|
1570
|
+
// The thin facade below preserves the public API the UI + tests rely on
|
|
1571
|
+
// (respondToCouncilQuestion/Preflight + the internal _create*Responder
|
|
1572
|
+
// hooks used by orchestrator.agent.test.ts).
|
|
1573
|
+
// ========================================================================
|
|
1915
1574
|
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
partnerPosition?: string;
|
|
1946
|
-
exchangeHistory?: string;
|
|
1947
|
-
round?: number;
|
|
1575
|
+
respondToCouncilQuestion(questionId: string, answer: string): void {
|
|
1576
|
+
this.councilManager.respondToQuestion(questionId, answer);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
respondToCouncilPreflight(preflightId: string, approved: boolean): void {
|
|
1580
|
+
this.councilManager.respondToPreflight(preflightId, approved);
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
// Internal hooks used by orchestrator.agent.test.ts to exercise buffered
|
|
1584
|
+
// question / preflight delivery through CouncilManager. They are reached
|
|
1585
|
+
// through `as unknown as` casts in the test; keep them private but stable.
|
|
1586
|
+
private _createQuestionResponder(): (questionId: string) => Promise<string> {
|
|
1587
|
+
return this.councilManager.createQuestionResponder();
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
private _createPreflightResponder(): (preflightId: string) => Promise<boolean> {
|
|
1591
|
+
return this.councilManager.createPreflightResponder();
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
// ========================================================================
|
|
1595
|
+
// Council v2 — Clarify → Confirm → Debate → Plan → Execute
|
|
1596
|
+
// ========================================================================
|
|
1597
|
+
|
|
1598
|
+
async *runCouncilV2(
|
|
1599
|
+
topic: string,
|
|
1600
|
+
options?: {
|
|
1601
|
+
skipClarification?: boolean;
|
|
1602
|
+
observer?: ProcessMessageObserver;
|
|
1603
|
+
userModelMessage?: ModelMessage;
|
|
1948
1604
|
},
|
|
1949
|
-
):
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1605
|
+
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
1606
|
+
const { runCouncil } = await import("../council/index.js");
|
|
1607
|
+
const { createCouncilLLM } = await import("../council/llm.js");
|
|
1608
|
+
const councilStats = { calls: 0, startMs: Date.now(), phases: [] as Array<{ name: string; durationMs: number }> };
|
|
1609
|
+
const llm = createCouncilLLM(this.bash, this.mode, this.session?.id, councilStats);
|
|
1610
|
+
|
|
1611
|
+
const processMessageFn = (message: string) => this.processMessage(message, options?.observer);
|
|
1612
|
+
|
|
1613
|
+
const gen = runCouncil(
|
|
1614
|
+
topic,
|
|
1615
|
+
this.modelId,
|
|
1616
|
+
this.messages as Array<{ role: string; content: string | unknown }>,
|
|
1617
|
+
this.session?.id,
|
|
1618
|
+
llm,
|
|
1619
|
+
this.councilManager.createQuestionResponder(),
|
|
1620
|
+
this.councilManager.createPreflightResponder(),
|
|
1621
|
+
processMessageFn,
|
|
1622
|
+
{
|
|
1623
|
+
skipClarification: options?.skipClarification,
|
|
1624
|
+
userModelMessage: options?.userModelMessage,
|
|
1625
|
+
cwd: this.bash.getCwd(),
|
|
1626
|
+
councilStats, // NEW — share orchestrator's stats object with runCouncil (Phase 14 CQ-01)
|
|
1627
|
+
},
|
|
1628
|
+
);
|
|
1959
1629
|
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
`- Share what you think they might be missing from your ${ctx.speakerRole} perspective\n\n` +
|
|
1968
|
-
`End with a question back to them: based on your analysis, what's their view? Do they agree, or do they see it differently?`,
|
|
1969
|
-
prompt:
|
|
1970
|
-
`Their analysis (${ctx.partnerRole}):\n${ctx.partnerPosition}\n\n` +
|
|
1971
|
-
`Your own analysis for context:\n${ctx.speakerPosition}`,
|
|
1972
|
-
};
|
|
1630
|
+
let result: IteratorResult<StreamChunk, string | null>;
|
|
1631
|
+
do {
|
|
1632
|
+
result = await gen.next();
|
|
1633
|
+
if (!result.done && result.value) {
|
|
1634
|
+
yield result.value;
|
|
1635
|
+
}
|
|
1636
|
+
} while (!result.done);
|
|
1973
1637
|
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
system:
|
|
1977
|
-
`You are a ${ctx.speakerRole} specialist continuing a discussion (round ${ctx.round}) with a ${ctx.partnerRole} specialist.\n\n` +
|
|
1978
|
-
`Read their latest response and the exchange so far. Then:\n` +
|
|
1979
|
-
`- If they raised valid points, acknowledge them and update your thinking\n` +
|
|
1980
|
-
`- If you still disagree on something, explain why — bring new evidence or a different angle, not the same argument again\n` +
|
|
1981
|
-
`- If you've changed your mind on something, say so explicitly\n\n` +
|
|
1982
|
-
`End with: do you agree with where we've landed? Or is there something we're still seeing differently?`,
|
|
1983
|
-
prompt:
|
|
1984
|
-
`Discussion so far:\n${ctx.exchangeHistory}\n\n` +
|
|
1985
|
-
`Their latest response (${ctx.partnerRole}):\n${ctx.partnerPosition}`,
|
|
1986
|
-
};
|
|
1638
|
+
const synthesis = result.value;
|
|
1639
|
+
this.councilManager.setLastSynthesis(synthesis);
|
|
1987
1640
|
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1641
|
+
if (options?.userModelMessage && synthesis) {
|
|
1642
|
+
this.appendCompletedTurn(options.userModelMessage, [{ role: "assistant", content: synthesis }]);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
// ========================================================================
|
|
1647
|
+
// Product Ideal Loop (Phase 13) — mirror of runCouncilV2 wiring.
|
|
1648
|
+
// ========================================================================
|
|
1649
|
+
|
|
1650
|
+
async *runProductLoopV1(
|
|
1651
|
+
payload: {
|
|
1652
|
+
subcommand: "start" | "status" | "resume" | "abort" | "ship";
|
|
1653
|
+
idea?: string;
|
|
1654
|
+
runId?: string;
|
|
1655
|
+
flags: {
|
|
1656
|
+
maxCost: number;
|
|
1657
|
+
maxSprints: number;
|
|
1658
|
+
doneThreshold: number;
|
|
1659
|
+
stack?: string;
|
|
1660
|
+
noCustomerDebate?: boolean;
|
|
1661
|
+
noPriorContext?: boolean;
|
|
1662
|
+
forceCouncil?: boolean;
|
|
1663
|
+
};
|
|
1664
|
+
},
|
|
1665
|
+
options?: {
|
|
1666
|
+
observer?: ProcessMessageObserver;
|
|
1667
|
+
userModelMessage?: ModelMessage;
|
|
1668
|
+
},
|
|
1669
|
+
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
1670
|
+
const { runProductLoop } = await import("../product-loop/index.js");
|
|
1671
|
+
const { createCouncilLLM } = await import("../council/llm.js");
|
|
1672
|
+
const nodePath = await import("node:path");
|
|
1673
|
+
|
|
1674
|
+
const productStats = {
|
|
1675
|
+
calls: 0,
|
|
1676
|
+
startMs: Date.now(),
|
|
1677
|
+
phases: [] as Array<{ name: string; durationMs: number }>,
|
|
1678
|
+
};
|
|
1679
|
+
const llm = createCouncilLLM(this.bash, this.mode, this.session?.id, productStats);
|
|
1680
|
+
const processMessageFn = (m: string) => this.processMessage(m, options?.observer);
|
|
1681
|
+
const flowDir = nodePath.join(this.bash.getCwd(), ".muonroi-flow");
|
|
1682
|
+
|
|
1683
|
+
// P2.7: compute complexity from the idea using PIL Layer 1 heuristics (cheap,
|
|
1684
|
+
// no LLM calls). Only meaningful for "start"; other subcommands ignore it.
|
|
1685
|
+
let complexity: "low" | "medium" | "high" | undefined;
|
|
1686
|
+
let sufficiencyMissing: readonly import("../pil/layer1-intent.js").SufficiencyMissing[] | undefined;
|
|
1687
|
+
if (payload.subcommand === "start" && payload.idea) {
|
|
1688
|
+
const { scoreComplexity, scoreSufficiency } = await import("../pil/layer1-intent.js");
|
|
1689
|
+
const result = scoreComplexity({
|
|
1690
|
+
rawText: payload.idea,
|
|
1691
|
+
taskType: null,
|
|
1692
|
+
t0HitCount: 0,
|
|
1693
|
+
hasMaxSprintsOne: payload.flags.maxSprints === 1,
|
|
1694
|
+
});
|
|
1695
|
+
complexity = result.complexity;
|
|
1696
|
+
// Sufficiency gate — vague briefs ("todo app") force Council so the
|
|
1697
|
+
// discovery AskCard can fill in persona/MVP/architecture/verify before
|
|
1698
|
+
// any code is scaffolded.
|
|
1699
|
+
const suff = scoreSufficiency({ rawText: payload.idea });
|
|
1700
|
+
sufficiencyMissing = suff.sufficient ? undefined : suff.missing;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
const gen = runProductLoop({
|
|
1704
|
+
subcommand: payload.subcommand,
|
|
1705
|
+
idea: payload.idea ?? "",
|
|
1706
|
+
runId: payload.runId,
|
|
1707
|
+
flowDir,
|
|
1708
|
+
sessionModelId: this.modelId,
|
|
1709
|
+
llm,
|
|
1710
|
+
flags: {
|
|
1711
|
+
maxCost: payload.flags.maxCost,
|
|
1712
|
+
maxSprints: payload.flags.maxSprints,
|
|
1713
|
+
doneThreshold: payload.flags.doneThreshold,
|
|
1714
|
+
stack: payload.flags.stack,
|
|
1715
|
+
forceCouncil: payload.flags.forceCouncil,
|
|
1716
|
+
},
|
|
1717
|
+
respondToQuestion: this.councilManager.createQuestionResponder(),
|
|
1718
|
+
respondToPreflight: this.councilManager.createPreflightResponder(),
|
|
1719
|
+
cwd: this.bash.getCwd(),
|
|
1720
|
+
processMessageFn,
|
|
1721
|
+
skipPriorContext: payload.flags.noPriorContext === true,
|
|
1722
|
+
complexity,
|
|
1723
|
+
sufficiencyMissing,
|
|
1724
|
+
// Chat session id — used as the FK key for interaction_logs telemetry.
|
|
1725
|
+
// The /ideal runId is NOT a sessions.id and would silently fail FK insert.
|
|
1726
|
+
sessionId: this.session?.id,
|
|
1727
|
+
} as Parameters<typeof runProductLoop>[0]);
|
|
1728
|
+
|
|
1729
|
+
for await (const chunk of gen) {
|
|
1730
|
+
yield chunk;
|
|
1996
1731
|
}
|
|
1997
1732
|
}
|
|
1998
1733
|
|
|
1734
|
+
// ========================================================================
|
|
1735
|
+
// Legacy council — kept for backward compatibility, will be removed
|
|
1736
|
+
// ========================================================================
|
|
1737
|
+
|
|
1999
1738
|
async *runCouncilRound(
|
|
2000
1739
|
topic: string,
|
|
2001
|
-
|
|
1740
|
+
_observer?: ProcessMessageObserver,
|
|
2002
1741
|
rounds?: number,
|
|
1742
|
+
userModelMessage?: ModelMessage,
|
|
2003
1743
|
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
2004
1744
|
const maxRounds = rounds ?? getCouncilRounds();
|
|
2005
1745
|
const ALL_ROLES: ModelRole[] = ["implement", "verify", "research"];
|
|
2006
|
-
this.
|
|
1746
|
+
this.councilManager.resetStats(Date.now());
|
|
2007
1747
|
|
|
2008
|
-
// Resolve
|
|
1748
|
+
// Resolve council participants: same-provider by default, multi-provider only when configured
|
|
2009
1749
|
const candidates: Array<{ role: ModelRole; model: string }> = [];
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
1750
|
+
const configuredRoleModels = getRoleModels();
|
|
1751
|
+
const hasExplicitMultiProvider = this.councilManager.hasMultiProviderConfig(configuredRoleModels);
|
|
1752
|
+
|
|
1753
|
+
if (hasExplicitMultiProvider && isCouncilMultiProviderPreferred()) {
|
|
1754
|
+
// Multi-provider path: use explicitly configured role models across providers
|
|
1755
|
+
for (const role of ALL_ROLES) {
|
|
1756
|
+
const modelId = getRoleModel(role);
|
|
1757
|
+
if (!modelId) continue;
|
|
1758
|
+
const provider = detectProviderForModel(modelId);
|
|
1759
|
+
if (isProviderDisabled(provider as ProviderId)) continue;
|
|
1760
|
+
const canReach = await loadKeyForProvider(provider)
|
|
1761
|
+
.then(() => true)
|
|
1762
|
+
.catch(() => false);
|
|
1763
|
+
if (canReach) candidates.push({ role, model: modelId });
|
|
1764
|
+
}
|
|
1765
|
+
if (candidates.length >= 2) {
|
|
1766
|
+
const providers = new Set(candidates.map((c) => detectProviderForModel(c.model)));
|
|
1767
|
+
yield {
|
|
1768
|
+
type: "content",
|
|
1769
|
+
content: `\n[Multi-provider mode: ${candidates.length} roles across ${providers.size} provider(s)]\n`,
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// Default: same-provider mode — pick diverse models from the session's provider
|
|
1775
|
+
if (candidates.length < 2) {
|
|
1776
|
+
const mainProviderId = detectProviderForModel(this.modelId);
|
|
1777
|
+
// Skip same-provider resolution if the session's provider is disabled
|
|
1778
|
+
if (!isProviderDisabled(mainProviderId as ProviderId)) {
|
|
1779
|
+
const sameCandidates = await this.councilManager.resolveSameProviderCandidates(mainProviderId, ALL_ROLES);
|
|
1780
|
+
if (sameCandidates.length >= 2) {
|
|
1781
|
+
candidates.length = 0;
|
|
1782
|
+
candidates.push(...sameCandidates);
|
|
1783
|
+
const uniqueModels = new Set(sameCandidates.map((c) => c.model));
|
|
1784
|
+
yield {
|
|
1785
|
+
type: "content",
|
|
1786
|
+
content: `\n[Same-provider mode: ${uniqueModels.size} ${mainProviderId} model(s) for ${sameCandidates.length} roles]\n`,
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
// Final fallback: use main model for all roles
|
|
1793
|
+
if (candidates.length < 2) {
|
|
1794
|
+
const mainProviderId = detectProviderForModel(this.modelId);
|
|
1795
|
+
const mainDisabled = isProviderDisabled(mainProviderId as ProviderId);
|
|
1796
|
+
const mainCanReach =
|
|
1797
|
+
!mainDisabled &&
|
|
1798
|
+
(await loadKeyForProvider(mainProviderId)
|
|
1799
|
+
.then(() => true)
|
|
1800
|
+
.catch(() => false));
|
|
1801
|
+
if (mainCanReach) {
|
|
1802
|
+
candidates.length = 0;
|
|
1803
|
+
for (const role of ALL_ROLES) {
|
|
1804
|
+
candidates.push({ role, model: this.modelId });
|
|
1805
|
+
}
|
|
1806
|
+
yield {
|
|
1807
|
+
type: "content",
|
|
1808
|
+
content: `\n[Fallback: using \x1b[36m${this.modelId}\x1b[0m for all roles]\n`,
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
2015
1811
|
}
|
|
2016
1812
|
|
|
2017
1813
|
if (candidates.length < 2) {
|
|
2018
|
-
yield {
|
|
1814
|
+
yield {
|
|
1815
|
+
type: "content",
|
|
1816
|
+
content: "\nNo reachable provider. Check API keys in user-settings.json or environment.\n",
|
|
1817
|
+
};
|
|
2019
1818
|
yield { type: "done" };
|
|
2020
1819
|
return;
|
|
2021
1820
|
}
|
|
2022
1821
|
|
|
1822
|
+
// Build conversation context for all participants
|
|
1823
|
+
const conversationContext = this.councilManager.buildContext();
|
|
1824
|
+
|
|
1825
|
+
// ── Phase 0: Research — gather facts from codebase before discussion ──
|
|
1826
|
+
const p0Start = Date.now();
|
|
1827
|
+
yield { type: "content", content: `\n## Phase 0 — Codebase Research\n` };
|
|
1828
|
+
|
|
1829
|
+
// Find the research candidate (prefer configured research role, fallback to first available)
|
|
1830
|
+
const researchCandidate = candidates.find((c) => c.role === "research") ?? candidates[0];
|
|
1831
|
+
yield { type: "content", content: `\n### \x1b[35m[research]\x1b[0m ${researchCandidate.model}\n` };
|
|
1832
|
+
|
|
1833
|
+
const researchFindings = await this.councilManager.research(researchCandidate.model, topic, conversationContext);
|
|
1834
|
+
yield { type: "content", content: `${researchFindings}\n` };
|
|
1835
|
+
yield { type: "content", content: `\n> Phase 0: ${((Date.now() - p0Start) / 1000).toFixed(1)}s\n` };
|
|
1836
|
+
|
|
1837
|
+
// Inject research findings into conversation context for subsequent phases
|
|
1838
|
+
const enrichedContext = conversationContext
|
|
1839
|
+
? `${conversationContext}\n\n---\n\n## Research Findings (Phase 0)\n${researchFindings}`
|
|
1840
|
+
: `## Research Findings (Phase 0)\n${researchFindings}`;
|
|
1841
|
+
|
|
2023
1842
|
// ── Phase 1: Parallel opening statements ──
|
|
2024
1843
|
const p1Start = Date.now();
|
|
2025
1844
|
yield { type: "content", content: "\n## Phase 1 — Opening Analysis\n" };
|
|
2026
1845
|
|
|
2027
1846
|
const openingPromises = candidates.map(({ role, model }) => {
|
|
2028
|
-
const { system, prompt } = this.
|
|
1847
|
+
const { system, prompt } = this.councilManager.buildDiscussPrompt("open", {
|
|
2029
1848
|
speakerRole: role,
|
|
2030
1849
|
partnerRole: candidates.find((c) => c.role !== role)?.role ?? "colleague",
|
|
2031
1850
|
topic,
|
|
1851
|
+
conversationContext: enrichedContext,
|
|
2032
1852
|
});
|
|
2033
|
-
return this.
|
|
1853
|
+
return this.councilManager
|
|
1854
|
+
.generate(model, system, prompt)
|
|
2034
1855
|
.then((text) => ({ role, model, position: text, error: null as string | null }))
|
|
2035
1856
|
.catch((err: unknown) => ({
|
|
2036
1857
|
role,
|
|
@@ -2044,16 +1865,21 @@ export class Agent {
|
|
|
2044
1865
|
const active: Array<{ role: ModelRole; model: string; position: string }> = [];
|
|
2045
1866
|
|
|
2046
1867
|
for (const o of openings) {
|
|
2047
|
-
|
|
1868
|
+
const roleColor = COUNCIL_ROLE_COLORS[o.role] ?? "";
|
|
1869
|
+
yield { type: "content", content: `\n### ${roleColor}[${o.role}]${COUNCIL_COLOR_RESET} ${o.model}\n` };
|
|
2048
1870
|
if (o.error) {
|
|
2049
1871
|
yield { type: "content", content: `[Error: ${o.error}]\n` };
|
|
2050
1872
|
} else {
|
|
2051
1873
|
active.push({ role: o.role, model: o.model, position: o.position });
|
|
2052
|
-
|
|
1874
|
+
const bgColor = COUNCIL_COLOR_BG[o.role] ?? "";
|
|
1875
|
+
yield { type: "content", content: `${bgColor} ${o.role.toUpperCase()} ${COUNCIL_COLOR_RESET} ${o.position}\n` };
|
|
2053
1876
|
}
|
|
2054
1877
|
}
|
|
2055
1878
|
|
|
2056
|
-
yield {
|
|
1879
|
+
yield {
|
|
1880
|
+
type: "content",
|
|
1881
|
+
content: `\n> Phase 1: ${active.length} participants, ${((Date.now() - p1Start) / 1000).toFixed(1)}s (parallel)\n`,
|
|
1882
|
+
};
|
|
2057
1883
|
|
|
2058
1884
|
if (active.length < 2) {
|
|
2059
1885
|
yield { type: "content", content: "\nNot enough successful openings for discussion.\n" };
|
|
@@ -2064,6 +1890,7 @@ export class Agent {
|
|
|
2064
1890
|
// ── Phase 2: Discussion rounds with parallel pair debates ──
|
|
2065
1891
|
const exchangeLogs: Map<string, string[]> = new Map();
|
|
2066
1892
|
const pairConverged: Map<string, boolean> = new Map();
|
|
1893
|
+
let runningSummary = "";
|
|
2067
1894
|
|
|
2068
1895
|
for (let round = 1; round <= maxRounds; round++) {
|
|
2069
1896
|
const p2Start = Date.now();
|
|
@@ -2093,36 +1920,56 @@ export class Agent {
|
|
|
2093
1920
|
let bResponse: string;
|
|
2094
1921
|
|
|
2095
1922
|
if (round === 1) {
|
|
2096
|
-
const aPrompt = this.
|
|
2097
|
-
speakerRole: a.role,
|
|
2098
|
-
|
|
1923
|
+
const aPrompt = this.councilManager.buildDiscussPrompt("respond", {
|
|
1924
|
+
speakerRole: a.role,
|
|
1925
|
+
partnerRole: b.role,
|
|
1926
|
+
topic,
|
|
1927
|
+
speakerPosition: a.position,
|
|
1928
|
+
partnerPosition: b.position,
|
|
1929
|
+
conversationContext: enrichedContext,
|
|
2099
1930
|
});
|
|
2100
|
-
aResponse = await this.
|
|
1931
|
+
aResponse = await this.councilManager.generate(a.model, aPrompt.system, aPrompt.prompt);
|
|
2101
1932
|
log.push(`[${a.role}]: ${aResponse}`);
|
|
2102
1933
|
chunks.push({ label: `[${a.role}] → [${b.role}]`, text: aResponse });
|
|
2103
1934
|
|
|
2104
|
-
const bPrompt = this.
|
|
2105
|
-
speakerRole: b.role,
|
|
2106
|
-
|
|
1935
|
+
const bPrompt = this.councilManager.buildDiscussPrompt("respond", {
|
|
1936
|
+
speakerRole: b.role,
|
|
1937
|
+
partnerRole: a.role,
|
|
1938
|
+
topic,
|
|
1939
|
+
speakerPosition: b.position,
|
|
1940
|
+
partnerPosition: aResponse,
|
|
1941
|
+
conversationContext: enrichedContext,
|
|
2107
1942
|
});
|
|
2108
|
-
bResponse = await this.
|
|
1943
|
+
bResponse = await this.councilManager.generate(b.model, bPrompt.system, bPrompt.prompt);
|
|
2109
1944
|
log.push(`[${b.role}]: ${bResponse}`);
|
|
2110
1945
|
chunks.push({ label: `[${b.role}] → [${a.role}]`, text: bResponse });
|
|
2111
1946
|
} else {
|
|
2112
1947
|
const historyText = log.join("\n\n");
|
|
2113
|
-
const aPrompt = this.
|
|
2114
|
-
speakerRole: a.role,
|
|
2115
|
-
|
|
1948
|
+
const aPrompt = this.councilManager.buildDiscussPrompt("followup", {
|
|
1949
|
+
speakerRole: a.role,
|
|
1950
|
+
partnerRole: b.role,
|
|
1951
|
+
topic,
|
|
1952
|
+
partnerPosition: b.position,
|
|
1953
|
+
exchangeHistory: historyText,
|
|
1954
|
+
round,
|
|
1955
|
+
conversationContext: enrichedContext,
|
|
1956
|
+
runningSummary,
|
|
2116
1957
|
});
|
|
2117
|
-
aResponse = await this.
|
|
1958
|
+
aResponse = await this.councilManager.generate(a.model, aPrompt.system, aPrompt.prompt, 1024);
|
|
2118
1959
|
log.push(`[${a.role}] (round ${round}): ${aResponse}`);
|
|
2119
1960
|
chunks.push({ label: `[${a.role}] → [${b.role}]`, text: aResponse });
|
|
2120
1961
|
|
|
2121
|
-
const bPrompt = this.
|
|
2122
|
-
speakerRole: b.role,
|
|
2123
|
-
|
|
1962
|
+
const bPrompt = this.councilManager.buildDiscussPrompt("followup", {
|
|
1963
|
+
speakerRole: b.role,
|
|
1964
|
+
partnerRole: a.role,
|
|
1965
|
+
topic,
|
|
1966
|
+
partnerPosition: aResponse,
|
|
1967
|
+
exchangeHistory: historyText,
|
|
1968
|
+
round,
|
|
1969
|
+
conversationContext: enrichedContext,
|
|
1970
|
+
runningSummary,
|
|
2124
1971
|
});
|
|
2125
|
-
bResponse = await this.
|
|
1972
|
+
bResponse = await this.councilManager.generate(b.model, bPrompt.system, bPrompt.prompt, 1024);
|
|
2126
1973
|
log.push(`[${b.role}] (round ${round}): ${bResponse}`);
|
|
2127
1974
|
chunks.push({ label: `[${b.role}] → [${a.role}]`, text: bResponse });
|
|
2128
1975
|
}
|
|
@@ -2131,26 +1978,34 @@ export class Agent {
|
|
|
2131
1978
|
a.position = aResponse;
|
|
2132
1979
|
|
|
2133
1980
|
// Convergence check
|
|
2134
|
-
const convPrompt = this.
|
|
2135
|
-
speakerRole: a.role,
|
|
1981
|
+
const convPrompt = this.councilManager.buildDiscussPrompt("convergence-check", {
|
|
1982
|
+
speakerRole: a.role,
|
|
1983
|
+
partnerRole: b.role,
|
|
1984
|
+
topic,
|
|
2136
1985
|
exchangeHistory: log.slice(-4).join("\n\n"),
|
|
1986
|
+
conversationContext: enrichedContext,
|
|
2137
1987
|
});
|
|
2138
1988
|
let converged = false;
|
|
2139
1989
|
let convReason = "";
|
|
2140
1990
|
try {
|
|
2141
|
-
const raw = await this.
|
|
1991
|
+
const raw = await this.councilManager.generate(a.model, convPrompt.system, convPrompt.prompt, 256);
|
|
2142
1992
|
const match = raw.match(/\{[\s\S]*\}/);
|
|
2143
1993
|
if (match) {
|
|
2144
1994
|
const parsed = JSON.parse(match[0]) as { converged?: boolean; reason?: string };
|
|
2145
1995
|
converged = parsed.converged === true;
|
|
2146
1996
|
convReason = parsed.reason ?? "";
|
|
2147
1997
|
}
|
|
2148
|
-
} catch {
|
|
1998
|
+
} catch {
|
|
1999
|
+
/* not converged */
|
|
2000
|
+
}
|
|
2149
2001
|
|
|
2150
2002
|
return { key, chunks, converged, convReason, error: null as string | null };
|
|
2151
2003
|
} catch (err: unknown) {
|
|
2152
2004
|
return {
|
|
2153
|
-
key,
|
|
2005
|
+
key,
|
|
2006
|
+
chunks,
|
|
2007
|
+
converged: false,
|
|
2008
|
+
convReason: "",
|
|
2154
2009
|
error: err instanceof Error ? err.message : String(err),
|
|
2155
2010
|
};
|
|
2156
2011
|
}
|
|
@@ -2161,7 +2016,14 @@ export class Agent {
|
|
|
2161
2016
|
let allConverged = true;
|
|
2162
2017
|
for (const pr of pairResults) {
|
|
2163
2018
|
for (const chunk of pr.chunks) {
|
|
2164
|
-
|
|
2019
|
+
const labelParts = chunk.label.match(/\[(\w+)\] → \[(\w+)\]/);
|
|
2020
|
+
let coloredLabel = chunk.label;
|
|
2021
|
+
if (labelParts) {
|
|
2022
|
+
const fromColor = COUNCIL_ROLE_COLORS[labelParts[1]] ?? "";
|
|
2023
|
+
const toColor = COUNCIL_ROLE_COLORS[labelParts[2]] ?? "";
|
|
2024
|
+
coloredLabel = `${fromColor}[${labelParts[1]}]${COUNCIL_COLOR_RESET} → ${toColor}[${labelParts[2]}]${COUNCIL_COLOR_RESET}`;
|
|
2025
|
+
}
|
|
2026
|
+
yield { type: "content", content: `\n### ${coloredLabel}\n${chunk.text}\n` };
|
|
2165
2027
|
}
|
|
2166
2028
|
if (pr.error) {
|
|
2167
2029
|
yield { type: "content", content: `[Discussion error: ${pr.error}]\n` };
|
|
@@ -2174,12 +2036,32 @@ export class Agent {
|
|
|
2174
2036
|
}
|
|
2175
2037
|
}
|
|
2176
2038
|
|
|
2177
|
-
yield {
|
|
2039
|
+
yield {
|
|
2040
|
+
type: "content",
|
|
2041
|
+
content: `\n> Round ${round}: ${((Date.now() - p2Start) / 1000).toFixed(1)}s (${pairs.length} pairs parallel)\n`,
|
|
2042
|
+
};
|
|
2178
2043
|
|
|
2179
2044
|
if (allConverged) {
|
|
2180
2045
|
yield { type: "content", content: `\n> All pairs converged at round ${round}. Moving to synthesis.\n` };
|
|
2181
2046
|
break;
|
|
2182
2047
|
}
|
|
2048
|
+
|
|
2049
|
+
// Generate inter-round summary for next round's focus
|
|
2050
|
+
if (round < maxRounds) {
|
|
2051
|
+
try {
|
|
2052
|
+
runningSummary = await this.councilManager.generateRoundSummary(exchangeLogs, topic, round, active[0].model);
|
|
2053
|
+
yield {
|
|
2054
|
+
type: "content",
|
|
2055
|
+
content: `\n> **Discussion state:** ${runningSummary
|
|
2056
|
+
.split("\n")
|
|
2057
|
+
.filter((l) => l.trim())
|
|
2058
|
+
.slice(0, 3)
|
|
2059
|
+
.join(" | ")}\n`,
|
|
2060
|
+
};
|
|
2061
|
+
} catch {
|
|
2062
|
+
// Non-critical — continue without summary
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2183
2065
|
}
|
|
2184
2066
|
|
|
2185
2067
|
// ── Phase 3: Leader synthesis ──
|
|
@@ -2187,41 +2069,78 @@ export class Agent {
|
|
|
2187
2069
|
yield { type: "content", content: "\n## Phase 3 — Leader Synthesis\n" };
|
|
2188
2070
|
|
|
2189
2071
|
const leaderModelId = getRoleModel("leader") ?? this.modelId;
|
|
2190
|
-
yield { type: "content", content: `\n### [leader] ${leaderModelId}\n` };
|
|
2072
|
+
yield { type: "content", content: `\n### \x1b[32m[leader]\x1b[0m ${leaderModelId}\n` };
|
|
2191
2073
|
|
|
2192
2074
|
const allExchanges = [...exchangeLogs.entries()]
|
|
2193
2075
|
.map(([pair, log]) => `### Discussion: ${pair}\n${log.join("\n\n")}`)
|
|
2194
2076
|
.join("\n\n---\n\n");
|
|
2195
2077
|
|
|
2196
|
-
const finalPositions = active
|
|
2197
|
-
.map((p) => `**${p.role}** (${p.model}): ${p.position.slice(0, 500)}...`)
|
|
2198
|
-
.join("\n\n");
|
|
2078
|
+
const finalPositions = active.map((p) => `**${p.role}** (${p.model}): ${p.position.slice(0, 500)}...`).join("\n\n");
|
|
2199
2079
|
|
|
2200
2080
|
let synthesisText = "";
|
|
2201
2081
|
try {
|
|
2202
|
-
synthesisText = await this.
|
|
2082
|
+
synthesisText = await this.councilManager.generate(
|
|
2203
2083
|
leaderModelId,
|
|
2204
|
-
"You are the team lead. Multiple specialists just had a structured discussion
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2084
|
+
"You are the team lead. Multiple specialists just had a structured discussion about a topic.\n\n" +
|
|
2085
|
+
"Output TWO parts separated by the exact line `---READABLE---`:\n\n" +
|
|
2086
|
+
"**Part 1: JSON** — a single JSON object:\n" +
|
|
2087
|
+
"```\n" +
|
|
2088
|
+
'{ "type": "decision"|"action_items"|"plan_update"|"resolve_question",\n' +
|
|
2089
|
+
' "summary": "1-2 sentence executive summary",\n' +
|
|
2090
|
+
' "agreed": ["point 1", "point 2"],\n' +
|
|
2091
|
+
' "tradeoffs": ["trade-off 1"],\n' +
|
|
2092
|
+
' "recommendation": "Your decisive recommendation",\n' +
|
|
2093
|
+
' "actionItems": ["step 1", "step 2"],\n' +
|
|
2094
|
+
' "planUpdate": "paragraph for plan update (only if type=plan_update)",\n' +
|
|
2095
|
+
' "resolvedQuestion": {"question": "...", "answer": "..."} }\n' +
|
|
2096
|
+
"```\n" +
|
|
2097
|
+
"Choose type: decision (general), action_items (concrete steps), plan_update (modify active plan), resolve_question (answer a specific question).\n\n" +
|
|
2098
|
+
"**Part 2: Human-readable** — after `---READABLE---`, write the synthesis in markdown:\n" +
|
|
2099
|
+
"## AGREED\n## TRADE-OFFS\n## RECOMMENDATION\n## NEXT STEPS\n\n" +
|
|
2100
|
+
"Be decisive. Output Part 1 JSON first, then ---READABLE---, then Part 2.",
|
|
2210
2101
|
`Topic: ${topic}\n\nFinal positions:\n${finalPositions}\n\nFull discussion:\n${allExchanges}`,
|
|
2211
2102
|
4096,
|
|
2212
2103
|
);
|
|
2213
|
-
|
|
2104
|
+
|
|
2105
|
+
// Display human-readable part
|
|
2106
|
+
const readablePart = synthesisText.includes("---READABLE---")
|
|
2107
|
+
? synthesisText.split("---READABLE---")[1]?.trim()
|
|
2108
|
+
: synthesisText;
|
|
2109
|
+
yield { type: "content", content: `${readablePart || synthesisText}\n` };
|
|
2110
|
+
|
|
2111
|
+
// Parse structured outcome and execute actions
|
|
2112
|
+
const structuredOutcome = this.councilManager.parseOutcome(synthesisText, topic);
|
|
2113
|
+
if (structuredOutcome) {
|
|
2114
|
+
yield* this.councilManager.executeOutcome(structuredOutcome, topic);
|
|
2115
|
+
if (this.session) {
|
|
2116
|
+
try {
|
|
2117
|
+
appendSystemMessage(this.session.id, `[Council Outcome]\n${JSON.stringify(structuredOutcome)}`);
|
|
2118
|
+
} catch {
|
|
2119
|
+
/* non-critical */
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
} else {
|
|
2123
|
+
// Fallback: store text-only outcome (backward compatible)
|
|
2124
|
+
if (this.session) {
|
|
2125
|
+
try {
|
|
2126
|
+
appendSystemMessage(this.session.id, `[Council Outcome]\nTopic: ${topic}\n${synthesisText.slice(0, 2000)}`);
|
|
2127
|
+
} catch {
|
|
2128
|
+
/* non-critical */
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2214
2132
|
} catch (err: unknown) {
|
|
2215
2133
|
yield { type: "content", content: `[Synthesis error: ${err instanceof Error ? err.message : err}]\n` };
|
|
2216
2134
|
}
|
|
2217
2135
|
|
|
2218
2136
|
// ── Stats + Memory ──
|
|
2219
|
-
const
|
|
2137
|
+
const councilStats = this.councilManager.stats;
|
|
2138
|
+
const totalMs = Date.now() - councilStats.startMs;
|
|
2220
2139
|
yield {
|
|
2221
2140
|
type: "content",
|
|
2222
2141
|
content:
|
|
2223
2142
|
`\n---\n` +
|
|
2224
|
-
`> Council stats: ${
|
|
2143
|
+
`> Council stats: ${councilStats.calls} API calls, ${(totalMs / 1000).toFixed(1)}s total, ` +
|
|
2225
2144
|
`${active.length} participants, synthesis ${((Date.now() - p3Start) / 1000).toFixed(1)}s\n`,
|
|
2226
2145
|
};
|
|
2227
2146
|
|
|
@@ -2233,17 +2152,34 @@ export class Agent {
|
|
|
2233
2152
|
finalPositions: active.map((a) => ({ role: a.role, position: a.position.slice(0, 1000) })),
|
|
2234
2153
|
synthesis: synthesisText.slice(0, 2000),
|
|
2235
2154
|
convergedPairs: [...pairConverged.entries()].filter(([, v]) => v).map(([k]) => k),
|
|
2236
|
-
stats: { calls:
|
|
2155
|
+
stats: { calls: councilStats.calls, durationMs: totalMs },
|
|
2237
2156
|
timestamp: new Date().toISOString(),
|
|
2238
2157
|
};
|
|
2239
2158
|
try {
|
|
2240
2159
|
appendSystemMessage(this.session.id, `[Council Memory] ${JSON.stringify(councilRecord)}`);
|
|
2241
|
-
} catch {
|
|
2160
|
+
} catch {
|
|
2161
|
+
/* non-critical */
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// Store council output as assistant message so the conversation history
|
|
2166
|
+
// stays valid (user→assistant alternation required by most APIs).
|
|
2167
|
+
const councilResponse = synthesisText || "[Council completed — see discussion above]";
|
|
2168
|
+
if (userModelMessage) {
|
|
2169
|
+
this.appendCompletedTurn(userModelMessage, [{ role: "assistant", content: councilResponse }]);
|
|
2242
2170
|
}
|
|
2171
|
+
this.councilManager.setLastSynthesis(councilResponse);
|
|
2243
2172
|
|
|
2244
2173
|
yield { type: "done" };
|
|
2245
2174
|
}
|
|
2246
2175
|
|
|
2176
|
+
// ========================================================================
|
|
2177
|
+
// processMessageBatchTurn — batch API message processing loop.
|
|
2178
|
+
// Body extracted into BatchTurnRunner (Phase 12.5). Thin wrapper preserved
|
|
2179
|
+
// so MessageProcessorDeps' `processMessageBatchTurn` callback continues to
|
|
2180
|
+
// dispatch through `Agent.processMessageBatchTurn` unchanged.
|
|
2181
|
+
// ========================================================================
|
|
2182
|
+
|
|
2247
2183
|
private async *processMessageBatchTurn(args: {
|
|
2248
2184
|
userModelMessage: ModelMessage;
|
|
2249
2185
|
observer?: ProcessMessageObserver;
|
|
@@ -2254,226 +2190,65 @@ export class Agent {
|
|
|
2254
2190
|
modelInfo: ReturnType<typeof getModelInfo>;
|
|
2255
2191
|
signal: AbortSignal;
|
|
2256
2192
|
}): AsyncGenerator<StreamChunk, void, unknown> {
|
|
2257
|
-
const
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
while (true) {
|
|
2261
|
-
this._compactedThisTurn = false;
|
|
2262
|
-
let closeMcp: (() => Promise<void>) | undefined;
|
|
2263
|
-
const turnMessages: ModelMessage[] = [];
|
|
2264
|
-
const totalUsage: ProcessMessageUsage = {};
|
|
2265
|
-
|
|
2266
|
-
try {
|
|
2267
|
-
const settings = attemptedOverflowRecovery
|
|
2268
|
-
? relaxCompactionSettings(this.getCompactionSettings())
|
|
2269
|
-
: this.getCompactionSettings();
|
|
2270
|
-
if (modelInfo?.contextWindow) {
|
|
2271
|
-
await this.compactForContext(
|
|
2272
|
-
provider,
|
|
2273
|
-
system,
|
|
2274
|
-
modelInfo.contextWindow,
|
|
2275
|
-
signal,
|
|
2276
|
-
settings,
|
|
2277
|
-
attemptedOverflowRecovery,
|
|
2278
|
-
);
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
if (runtime.modelInfo?.responsesOnly) {
|
|
2282
|
-
throw new Error("Batch mode currently supports chat-completions models only.");
|
|
2283
|
-
}
|
|
2284
|
-
|
|
2285
|
-
const baseTools = createTools(this.bash, provider, this.mode, {
|
|
2286
|
-
runTask: (request, abortSignal) => this.runTask(request, combineAbortSignals(signal, abortSignal)),
|
|
2287
|
-
runDelegation: (request, abortSignal) =>
|
|
2288
|
-
this.runDelegation(request, combineAbortSignals(signal, abortSignal)),
|
|
2289
|
-
readDelegation: (id) => this.readDelegation(id),
|
|
2290
|
-
listDelegations: () => this.listDelegations(),
|
|
2291
|
-
scheduleManager: this.schedules,
|
|
2292
|
-
subagents,
|
|
2293
|
-
sendTelegramFile: this.sendTelegramFile ?? undefined,
|
|
2294
|
-
sessionId: this.session?.id ?? undefined,
|
|
2295
|
-
});
|
|
2296
|
-
let tools: ToolSet = runtime.modelInfo?.supportsClientTools === false ? {} : baseTools;
|
|
2297
|
-
if (this.mode === "agent" && runtime.modelInfo?.supportsClientTools !== false) {
|
|
2298
|
-
const mcpBundle = await buildMcpToolSet(loadMcpServers(), {
|
|
2299
|
-
onOAuthRequired: (_serverId, url) => {
|
|
2300
|
-
const urlStr = url.toString();
|
|
2301
|
-
import("child_process").then(({ exec }) => {
|
|
2302
|
-
const cmd = process.platform === "win32" ? `start "" "${urlStr}"`
|
|
2303
|
-
: process.platform === "darwin" ? `open "${urlStr}"`
|
|
2304
|
-
: `xdg-open "${urlStr}"`;
|
|
2305
|
-
exec(cmd);
|
|
2306
|
-
});
|
|
2307
|
-
},
|
|
2308
|
-
});
|
|
2309
|
-
closeMcp = mcpBundle.close;
|
|
2310
|
-
tools = { ...baseTools, ...mcpBundle.tools };
|
|
2311
|
-
if (mcpBundle.errors.length > 0) {
|
|
2312
|
-
yield { type: "content", content: `MCP unavailable: ${mcpBundle.errors.join(" | ")}\n\n` };
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
const batchTools = runtime.modelInfo?.supportsClientTools === false ? [] : await toolSetToBatchTools(tools);
|
|
2317
|
-
const batch = await createBatch({
|
|
2318
|
-
...this.getBatchClientOptions(signal),
|
|
2319
|
-
name: buildBatchName("session", this.getSessionId() || runtime.modelId),
|
|
2320
|
-
});
|
|
2321
|
-
|
|
2322
|
-
for (let round = 0; round < this.maxToolRounds; round++) {
|
|
2323
|
-
const stepNumber = round + 1;
|
|
2324
|
-
notifyObserver(observer?.onStepStart, {
|
|
2325
|
-
stepNumber,
|
|
2326
|
-
timestamp: Date.now(),
|
|
2327
|
-
});
|
|
2328
|
-
|
|
2329
|
-
const batchRequestId = `turn-${Date.now()}-${stepNumber}`;
|
|
2330
|
-
await addBatchRequests({
|
|
2331
|
-
...this.getBatchClientOptions(signal),
|
|
2332
|
-
batchId: batch.batch_id,
|
|
2333
|
-
batchRequests: [
|
|
2334
|
-
{
|
|
2335
|
-
batch_request_id: batchRequestId,
|
|
2336
|
-
batch_request: {
|
|
2337
|
-
chat_get_completion: buildBatchChatCompletionRequest({
|
|
2338
|
-
modelId: runtime.modelId,
|
|
2339
|
-
system,
|
|
2340
|
-
messages: [...this.messages, ...turnMessages],
|
|
2341
|
-
temperature: 0.7,
|
|
2342
|
-
maxOutputTokens: runtime.modelInfo?.supportsMaxOutputTokens === false ? undefined : this.maxTokens,
|
|
2343
|
-
reasoningEffort: runtime.providerOptions?.xai.reasoningEffort,
|
|
2344
|
-
tools: batchTools,
|
|
2345
|
-
}),
|
|
2346
|
-
},
|
|
2347
|
-
},
|
|
2348
|
-
],
|
|
2349
|
-
});
|
|
2350
|
-
|
|
2351
|
-
const result = await pollBatchRequestResult({
|
|
2352
|
-
...this.getBatchClientOptions(signal),
|
|
2353
|
-
batchId: batch.batch_id,
|
|
2354
|
-
batchRequestId,
|
|
2355
|
-
});
|
|
2356
|
-
const response = getBatchChatCompletion(result);
|
|
2357
|
-
const choice = response.choices[0];
|
|
2358
|
-
if (!choice) {
|
|
2359
|
-
throw new Error("Batch response did not contain any choices.");
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
const usage = getBatchUsage(response);
|
|
2363
|
-
accumulateUsage(totalUsage, usage);
|
|
2364
|
-
const finishReason = getBatchFinishReason(choice.finish_reason);
|
|
2365
|
-
|
|
2366
|
-
const content = choice.message.content ?? "";
|
|
2367
|
-
if (content) {
|
|
2368
|
-
yield { type: "content", content };
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2371
|
-
const requestMessages = [...this.messages, ...turnMessages];
|
|
2372
|
-
const toolCalls = (choice.message.tool_calls ?? []).map(toLocalToolCall);
|
|
2373
|
-
const assistantMessage = buildAssistantBatchMessage(content, toolCalls);
|
|
2374
|
-
if (assistantMessage) {
|
|
2375
|
-
turnMessages.push(assistantMessage);
|
|
2376
|
-
}
|
|
2377
|
-
|
|
2378
|
-
if (toolCalls.length === 0) {
|
|
2379
|
-
notifyObserver(observer?.onStepFinish, {
|
|
2380
|
-
stepNumber,
|
|
2381
|
-
timestamp: Date.now(),
|
|
2382
|
-
finishReason,
|
|
2383
|
-
usage,
|
|
2384
|
-
});
|
|
2385
|
-
if (hasUsage(totalUsage)) {
|
|
2386
|
-
this.recordUsage(totalUsage, "message", runtime.modelId);
|
|
2387
|
-
}
|
|
2388
|
-
this.appendCompletedTurn(userModelMessage, turnMessages);
|
|
2389
|
-
if (modelInfo?.contextWindow) {
|
|
2390
|
-
await this.postTurnCompact(provider, system, modelInfo.contextWindow, signal);
|
|
2391
|
-
}
|
|
2392
|
-
yield { type: "done" };
|
|
2393
|
-
return;
|
|
2394
|
-
}
|
|
2395
|
-
|
|
2396
|
-
yield { type: "tool_calls", toolCalls };
|
|
2397
|
-
|
|
2398
|
-
const toolParts: ExecutedBatchTool[] = [];
|
|
2399
|
-
for (const toolCall of toolCalls) {
|
|
2400
|
-
notifyObserver(observer?.onToolStart, {
|
|
2401
|
-
toolCall,
|
|
2402
|
-
timestamp: Date.now(),
|
|
2403
|
-
});
|
|
2404
|
-
|
|
2405
|
-
const executed = await this.executeBatchToolCall(tools, toolCall, requestMessages, signal);
|
|
2406
|
-
notifyObserver(observer?.onToolFinish, {
|
|
2407
|
-
toolCall,
|
|
2408
|
-
toolResult: executed.result,
|
|
2409
|
-
timestamp: Date.now(),
|
|
2410
|
-
});
|
|
2411
|
-
yield { type: "tool_result", toolCall, toolResult: executed.result };
|
|
2412
|
-
toolParts.push({
|
|
2413
|
-
toolCall,
|
|
2414
|
-
input: executed.input,
|
|
2415
|
-
toolResult: executed.result,
|
|
2416
|
-
});
|
|
2417
|
-
}
|
|
2418
|
-
|
|
2419
|
-
const toolMessage = buildToolBatchMessage(toolParts);
|
|
2420
|
-
if (toolMessage) {
|
|
2421
|
-
turnMessages.push(toolMessage);
|
|
2422
|
-
}
|
|
2423
|
-
notifyObserver(observer?.onStepFinish, {
|
|
2424
|
-
stepNumber,
|
|
2425
|
-
timestamp: Date.now(),
|
|
2426
|
-
finishReason,
|
|
2427
|
-
usage,
|
|
2428
|
-
});
|
|
2429
|
-
}
|
|
2430
|
-
|
|
2431
|
-
const message = `Error: Reached max tool rounds (${this.maxToolRounds}) in batch mode.`;
|
|
2432
|
-
notifyObserver(observer?.onError, {
|
|
2433
|
-
message,
|
|
2434
|
-
timestamp: Date.now(),
|
|
2435
|
-
});
|
|
2436
|
-
if (hasUsage(totalUsage)) {
|
|
2437
|
-
this.recordUsage(totalUsage, "message", runtime.modelId);
|
|
2438
|
-
}
|
|
2439
|
-
this.appendCompletedTurn(userModelMessage, turnMessages);
|
|
2440
|
-
yield { type: "error", content: message };
|
|
2441
|
-
yield { type: "done" };
|
|
2442
|
-
return;
|
|
2443
|
-
} catch (err: unknown) {
|
|
2444
|
-
if (signal.aborted) {
|
|
2445
|
-
this.discardAbortedTurn(userModelMessage);
|
|
2446
|
-
yield { type: "content", content: "\n\n[Cancelled]" };
|
|
2447
|
-
yield { type: "done" };
|
|
2448
|
-
return;
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
|
-
if (!attemptedOverflowRecovery && turnMessages.length === 0 && modelInfo && isContextLimitError(err)) {
|
|
2452
|
-
attemptedOverflowRecovery = true;
|
|
2453
|
-
continue;
|
|
2454
|
-
}
|
|
2193
|
+
const runner = new BatchTurnRunner(this._buildBatchTurnRunnerDeps());
|
|
2194
|
+
yield* runner.run(args);
|
|
2195
|
+
}
|
|
2455
2196
|
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2197
|
+
/**
|
|
2198
|
+
* Build the DI surface BatchTurnRunner (Phase 12.5) needs to reach back
|
|
2199
|
+
* into Agent state without holding a circular reference. Callback names
|
|
2200
|
+
* align with `MessageProcessorDeps` where the signature matches so a
|
|
2201
|
+
* future `TurnRunnerDepsBase` hoist is mechanical. Built per call —
|
|
2202
|
+
* allocation cost is negligible against the batch polling spend.
|
|
2203
|
+
*/
|
|
2204
|
+
private _buildBatchTurnRunnerDeps(): BatchTurnRunnerDeps {
|
|
2205
|
+
const self = this;
|
|
2206
|
+
return {
|
|
2207
|
+
get messages() {
|
|
2208
|
+
return self.messages;
|
|
2209
|
+
},
|
|
2210
|
+
get bash() {
|
|
2211
|
+
return self.bash;
|
|
2212
|
+
},
|
|
2213
|
+
get mode() {
|
|
2214
|
+
return self.mode;
|
|
2215
|
+
},
|
|
2216
|
+
get maxToolRounds() {
|
|
2217
|
+
return self.maxToolRounds;
|
|
2218
|
+
},
|
|
2219
|
+
get maxTokens() {
|
|
2220
|
+
return self.maxTokens;
|
|
2221
|
+
},
|
|
2222
|
+
get schedules() {
|
|
2223
|
+
return self.schedules;
|
|
2224
|
+
},
|
|
2225
|
+
get sendTelegramFile() {
|
|
2226
|
+
return self.sendTelegramFile;
|
|
2227
|
+
},
|
|
2228
|
+
getSessionId: () => self.session?.id ?? null,
|
|
2229
|
+
getCompactedThisTurn: () => self._compactedThisTurn,
|
|
2230
|
+
setCompactedThisTurn: (v) => {
|
|
2231
|
+
self._compactedThisTurn = v;
|
|
2232
|
+
},
|
|
2233
|
+
setLastProviderOptionsShape: (shape) => {
|
|
2234
|
+
self._lastProviderOptionsShape = shape;
|
|
2235
|
+
},
|
|
2236
|
+
getBatchClientOptions: (signal) => self.getBatchClientOptions(signal),
|
|
2237
|
+
getCompactionSettings: (cw) => self.getCompactionSettings(cw),
|
|
2238
|
+
compactForContext: (provider, system, cw, signal, settings, overflow) =>
|
|
2239
|
+
self.compactForContext(provider, system, cw, signal, settings, overflow),
|
|
2240
|
+
postTurnCompact: (provider, system, cw, signal) => self.postTurnCompact(provider, system, cw, signal),
|
|
2241
|
+
createTools: (bash, provider, mode, opts) => createTools(bash, provider, mode, opts),
|
|
2242
|
+
runTask: (request, signal) => self.runTask(request, signal),
|
|
2243
|
+
runDelegation: (request, signal) => self.runDelegation(request, signal),
|
|
2244
|
+
readDelegation: (id) => self.readDelegation(id),
|
|
2245
|
+
listDelegations: () => self.listDelegations(),
|
|
2246
|
+
executeBatchToolCall: (tools, toolCall, messages, signal) =>
|
|
2247
|
+
self.executeBatchToolCall(tools, toolCall, messages, signal),
|
|
2248
|
+
appendCompletedTurn: (user, asst) => self.appendCompletedTurn(user, asst),
|
|
2249
|
+
discardAbortedTurn: (user) => self.discardAbortedTurn(user),
|
|
2250
|
+
recordUsage: (usage, source, model) => self.recordUsage(usage, source, model),
|
|
2251
|
+
};
|
|
2477
2252
|
}
|
|
2478
2253
|
|
|
2479
2254
|
private appendCompletedTurn(userMessage: ModelMessage, newMessages: ModelMessage[]): void {
|
|
@@ -2489,6 +2264,28 @@ export class Agent {
|
|
|
2489
2264
|
return;
|
|
2490
2265
|
}
|
|
2491
2266
|
|
|
2267
|
+
// Phase A5 — if the user message already has a persisted seq (set by
|
|
2268
|
+
// the write-ahead path), skip re-inserting it. The write-ahead row
|
|
2269
|
+
// will be upserted to status='completed' on the next `appendMessages`
|
|
2270
|
+
// call that sees it via ON CONFLICT, but here we only need to insert
|
|
2271
|
+
// the *new* assistant/tool messages so they get fresh sequence
|
|
2272
|
+
// numbers contiguous with the user row.
|
|
2273
|
+
const existingUserSeq = userIndex >= 0 ? this.messageSeqs[userIndex] : null;
|
|
2274
|
+
if (typeof existingUserSeq === "number") {
|
|
2275
|
+
// User row is already persisted (write-ahead). Insert only the new
|
|
2276
|
+
// assistant/tool messages so they get fresh sequence numbers
|
|
2277
|
+
// contiguous with the user row. Then flip the user row's status
|
|
2278
|
+
// from 'pending' to 'completed' so forensics + replay tooling can
|
|
2279
|
+
// tell the turn settled cleanly.
|
|
2280
|
+
const insertedSeqs = appendMessages(this.session.id, newMessages);
|
|
2281
|
+
markMessageCompleted(this.session.id, existingUserSeq);
|
|
2282
|
+
this.messages.push(...newMessages);
|
|
2283
|
+
this.messageSeqs.push(...insertedSeqs);
|
|
2284
|
+
this.sessionStore.touchSession(this.session.id, this.bash.getCwd());
|
|
2285
|
+
this.session = this.sessionStore.getRequiredSession(this.session.id);
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2492
2289
|
const insertedSeqs = appendMessages(this.session.id, [userMessage, ...newMessages]);
|
|
2493
2290
|
if (userIndex >= 0) {
|
|
2494
2291
|
this.messageSeqs[userIndex] = insertedSeqs[0] ?? this.messageSeqs[userIndex];
|
|
@@ -2506,844 +2303,212 @@ export class Agent {
|
|
|
2506
2303
|
return executeEventHooks(input, this.bash.getCwd(), signal);
|
|
2507
2304
|
}
|
|
2508
2305
|
|
|
2306
|
+
// ========================================================================
|
|
2307
|
+
// processMessage — main streaming turn loop (PIL enrichment, routing, LLM
|
|
2308
|
+
// stream, tool execution, compaction, hooks, observer notifications)
|
|
2309
|
+
// ========================================================================
|
|
2310
|
+
|
|
2509
2311
|
async *processMessage(
|
|
2510
2312
|
userMessage: string,
|
|
2511
2313
|
observer?: ProcessMessageObserver,
|
|
2512
2314
|
images?: Array<{ path: string; mediaType: string; base64: string }>,
|
|
2513
2315
|
): AsyncGenerator<StreamChunk, void, unknown> {
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
)
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2316
|
+
const processor = new MessageProcessor(this._buildMessageProcessorDeps());
|
|
2317
|
+
yield* processor.run(userMessage, observer, images);
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
/**
|
|
2321
|
+
* Build the DI surface MessageProcessor (Phase 12.4) needs to reach back
|
|
2322
|
+
* into Agent state without holding a circular reference. Exposes array
|
|
2323
|
+
* references for in-place mutation (messages/messageSeqs) and bound
|
|
2324
|
+
* callbacks for behavior. Built per call — allocation cost is negligible
|
|
2325
|
+
* against the streamText spend.
|
|
2326
|
+
*/
|
|
2327
|
+
private _buildMessageProcessorDeps(): MessageProcessorDeps {
|
|
2328
|
+
const self = this;
|
|
2329
|
+
return {
|
|
2330
|
+
get messages() {
|
|
2331
|
+
return self.messages;
|
|
2332
|
+
},
|
|
2333
|
+
get messageSeqs() {
|
|
2334
|
+
return self.messageSeqs;
|
|
2335
|
+
},
|
|
2336
|
+
get session() {
|
|
2337
|
+
return self.session;
|
|
2338
|
+
},
|
|
2339
|
+
get sessionStore() {
|
|
2340
|
+
return self.sessionStore;
|
|
2341
|
+
},
|
|
2342
|
+
get bash() {
|
|
2343
|
+
return self.bash;
|
|
2344
|
+
},
|
|
2345
|
+
get mode() {
|
|
2346
|
+
return self.mode;
|
|
2347
|
+
},
|
|
2348
|
+
get modelId() {
|
|
2349
|
+
return self.modelId;
|
|
2350
|
+
},
|
|
2351
|
+
get providerId() {
|
|
2352
|
+
return self.providerId;
|
|
2353
|
+
},
|
|
2354
|
+
get maxToolRounds() {
|
|
2355
|
+
return self.maxToolRounds;
|
|
2356
|
+
},
|
|
2357
|
+
get batchApi() {
|
|
2358
|
+
return self.batchApi;
|
|
2359
|
+
},
|
|
2360
|
+
get permissionMode() {
|
|
2361
|
+
return self.permissionMode;
|
|
2362
|
+
},
|
|
2363
|
+
get schedules() {
|
|
2364
|
+
return self.schedules;
|
|
2365
|
+
},
|
|
2366
|
+
get sendTelegramFile() {
|
|
2367
|
+
return self.sendTelegramFile;
|
|
2368
|
+
},
|
|
2369
|
+
get externalAbortContext() {
|
|
2370
|
+
return self.externalAbortContext;
|
|
2371
|
+
},
|
|
2372
|
+
get pendingCalls() {
|
|
2373
|
+
return self.pendingCalls;
|
|
2374
|
+
},
|
|
2375
|
+
get councilManager() {
|
|
2376
|
+
return self.councilManager;
|
|
2377
|
+
},
|
|
2378
|
+
get crossTurnDedup() {
|
|
2379
|
+
return self._crossTurnDedup;
|
|
2380
|
+
},
|
|
2381
|
+
get readBudget() {
|
|
2382
|
+
return self._readBudget;
|
|
2383
|
+
},
|
|
2384
|
+
get priorWarningIdsInSession() {
|
|
2385
|
+
return self._priorWarningIdsInSession;
|
|
2386
|
+
},
|
|
2387
|
+
get sessionEEGuidance() {
|
|
2388
|
+
return self._sessionEEGuidance;
|
|
2389
|
+
},
|
|
2390
|
+
get flowReady() {
|
|
2391
|
+
return self._flowReady;
|
|
2392
|
+
},
|
|
2393
|
+
getAbortController: () => self.abortController,
|
|
2394
|
+
setAbortController: (c) => {
|
|
2395
|
+
self.abortController = c;
|
|
2396
|
+
},
|
|
2397
|
+
getSessionStartHookFired: () => self.sessionStartHookFired,
|
|
2398
|
+
setSessionStartHookFired: (v) => {
|
|
2399
|
+
self.sessionStartHookFired = v;
|
|
2400
|
+
},
|
|
2401
|
+
getPlanContext: () => self.planContext,
|
|
2402
|
+
setPlanContext: (v) => {
|
|
2403
|
+
self.planContext = v;
|
|
2404
|
+
},
|
|
2405
|
+
getResumeDigest: () => self._resumeDigest,
|
|
2406
|
+
setResumeDigest: (v) => {
|
|
2407
|
+
self._resumeDigest = v;
|
|
2408
|
+
},
|
|
2409
|
+
getActiveRunId: () => self._activeRunId,
|
|
2410
|
+
getPendingCwdNote: () => self._pendingCwdNote,
|
|
2411
|
+
setPendingCwdNote: (v) => {
|
|
2412
|
+
self._pendingCwdNote = v;
|
|
2413
|
+
},
|
|
2414
|
+
setPilActive: (v) => {
|
|
2415
|
+
self._pilActive = v;
|
|
2416
|
+
},
|
|
2417
|
+
setPilEnrichmentDelta: (n) => {
|
|
2418
|
+
self._pilEnrichmentDelta = n;
|
|
2419
|
+
},
|
|
2420
|
+
setCurrentCallId: (id) => {
|
|
2421
|
+
self._currentCallId = id;
|
|
2422
|
+
},
|
|
2423
|
+
setLastProviderOptionsShape: (shape) => {
|
|
2424
|
+
self._lastProviderOptionsShape = shape;
|
|
2425
|
+
},
|
|
2426
|
+
setLastPromptBreakdown: (b) => {
|
|
2427
|
+
self._lastPromptBreakdown = b;
|
|
2428
|
+
},
|
|
2429
|
+
setCompactedThisTurn: (v) => {
|
|
2430
|
+
self._compactedThisTurn = v;
|
|
2431
|
+
},
|
|
2432
|
+
getCompactedThisTurn: () => self._compactedThisTurn,
|
|
2433
|
+
setTurnUserGoalExcerpt: (v) => {
|
|
2434
|
+
self._turnUserGoalExcerpt = v;
|
|
2435
|
+
},
|
|
2436
|
+
setTurnAssistantReasoning: (v) => {
|
|
2437
|
+
self._turnAssistantReasoning = v;
|
|
2438
|
+
},
|
|
2439
|
+
appendTurnAssistantReasoning: (delta) => {
|
|
2440
|
+
self._turnAssistantReasoning = (self._turnAssistantReasoning + delta).slice(-400);
|
|
2441
|
+
},
|
|
2442
|
+
getTurnAssistantReasoning: () => self._turnAssistantReasoning,
|
|
2443
|
+
setPriorWarningIdsInSession: (s) => {
|
|
2444
|
+
self._priorWarningIdsInSession = s;
|
|
2445
|
+
},
|
|
2446
|
+
setMessages: (m) => {
|
|
2447
|
+
self.messages = m;
|
|
2448
|
+
},
|
|
2449
|
+
requireProvider: () => self.requireProvider(),
|
|
2450
|
+
emitSubagentStatus: (s) => self.emitSubagentStatus(s),
|
|
2451
|
+
fireHook: (input, signal) =>
|
|
2452
|
+
self.fireHook(input as Parameters<Agent["fireHook"]>[0], signal) as ReturnType<
|
|
2453
|
+
MessageProcessorDeps["fireHook"]
|
|
2454
|
+
>,
|
|
2455
|
+
consumeBackgroundNotifications: () => self.consumeBackgroundNotifications(),
|
|
2456
|
+
initOAuthProvider: () => self._initOAuthProvider(),
|
|
2457
|
+
buildRecentTurnsSummary: () => self._buildRecentTurnsSummary(),
|
|
2458
|
+
estimateProjectSize: () => self._estimateProjectSize(),
|
|
2459
|
+
countFilesTouched: () => self._countFilesTouched(),
|
|
2460
|
+
getCompactionSettings: (cw) => self.getCompactionSettings(cw),
|
|
2461
|
+
compactForContext: (provider, system, cw, signal, settings, overflow) =>
|
|
2462
|
+
self.compactForContext(provider, system, cw, signal, settings, overflow),
|
|
2463
|
+
postTurnCompact: (provider, system, cw, signal) => self.postTurnCompact(provider, system, cw, signal),
|
|
2464
|
+
runTask: (request, signal) => self.runTask(request, signal),
|
|
2465
|
+
runDelegation: (request, signal) => self.runDelegation(request, signal),
|
|
2466
|
+
readDelegation: (id) => self.readDelegation(id),
|
|
2467
|
+
listDelegations: () => self.listDelegations(),
|
|
2468
|
+
appendCompletedTurn: (user, asst) => self.appendCompletedTurn(user, asst),
|
|
2469
|
+
discardAbortedTurn: (user) => self.discardAbortedTurn(user),
|
|
2470
|
+
recordUsage: (usage, source, model) => self.recordUsage(usage, source, model),
|
|
2471
|
+
respondToToolApproval: (id, ok) => self.respondToToolApproval(id, ok),
|
|
2472
|
+
runCouncilV2: (msg, opts) => self.runCouncilV2(msg, opts),
|
|
2473
|
+
processMessage: (msg, obs, imgs) => self.processMessage(msg, obs, imgs),
|
|
2474
|
+
processMessageBatchTurn: (args) => self.processMessageBatchTurn(args),
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2534
2477
|
|
|
2535
|
-
|
|
2536
|
-
|
|
2478
|
+
// ========================================================================
|
|
2479
|
+
// processMessage body extracted into MessageProcessor (Phase 12.4).
|
|
2480
|
+
// The single original implementation now lives in
|
|
2481
|
+
// `src/orchestrator/message-processor.ts`. The thin wrapper above is the
|
|
2482
|
+
// only entry point.
|
|
2483
|
+
// ========================================================================
|
|
2537
2484
|
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
const sessionStartInput: SessionStartHookInput = {
|
|
2542
|
-
hook_event_name: "SessionStart",
|
|
2543
|
-
source: isResume ? "resume" : "startup",
|
|
2544
|
-
session_id: this.session?.id,
|
|
2545
|
-
cwd: this.bash.getCwd(),
|
|
2546
|
-
};
|
|
2547
|
-
await this.fireHook(sessionStartInput, signal).catch(() => {});
|
|
2548
|
-
}
|
|
2485
|
+
// ========================================================================
|
|
2486
|
+
// Private helper methods — summary, estimation, verify
|
|
2487
|
+
// ========================================================================
|
|
2549
2488
|
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
resumeDigest: this._resumeDigest,
|
|
2569
|
-
activeRunId: this._activeRunId,
|
|
2570
|
-
}).catch(() => ({
|
|
2571
|
-
raw: userMessage,
|
|
2572
|
-
enriched: userMessage,
|
|
2573
|
-
taskType: null,
|
|
2574
|
-
domain: null,
|
|
2575
|
-
confidence: 0,
|
|
2576
|
-
outputStyle: null,
|
|
2577
|
-
tokenBudget: 500,
|
|
2578
|
-
metrics: null,
|
|
2579
|
-
layers: [],
|
|
2580
|
-
gsdPhase: null,
|
|
2581
|
-
activeRunId: null,
|
|
2582
|
-
}));
|
|
2583
|
-
const enrichedMessage = pilCtx.enriched;
|
|
2584
|
-
this._pilActive = pilCtx.taskType !== null;
|
|
2585
|
-
this._pilEnrichmentDelta =
|
|
2586
|
-
pilCtx.metrics?.estimatedTokensSaved ?? Math.round((enrichedMessage.length - userMessage.length) / 4);
|
|
2587
|
-
|
|
2588
|
-
if (_debugOn) {
|
|
2589
|
-
const appliedLayers = pilCtx.layers?.filter((l) => l.applied).map((l) => l.name) ?? [];
|
|
2590
|
-
_debugSteps.push({
|
|
2591
|
-
name: "PIL Pipeline",
|
|
2592
|
-
duration_ms: Date.now() - _pilStart,
|
|
2593
|
-
input_summary: `"${userMessage.slice(0, 60)}${userMessage.length > 60 ? "..." : ""}"`,
|
|
2594
|
-
output_summary: `task=${pilCtx.taskType ?? "none"} domain=${pilCtx.domain ?? "none"} layers=[${appliedLayers.join(",")}]`,
|
|
2595
|
-
tokens_saved: this._pilEnrichmentDelta > 0 ? this._pilEnrichmentDelta : undefined,
|
|
2596
|
-
});
|
|
2489
|
+
private _buildRecentTurnsSummary(): string | null {
|
|
2490
|
+
if (this.messages.length < 2) return null;
|
|
2491
|
+
const recent = this.messages.slice(-6);
|
|
2492
|
+
const parts: string[] = [];
|
|
2493
|
+
for (const msg of recent) {
|
|
2494
|
+
if (msg.role !== "user" && msg.role !== "assistant") continue;
|
|
2495
|
+
const text =
|
|
2496
|
+
typeof msg.content === "string"
|
|
2497
|
+
? msg.content
|
|
2498
|
+
: Array.isArray(msg.content)
|
|
2499
|
+
? msg.content
|
|
2500
|
+
.filter((p: { type: string }) => p.type === "text")
|
|
2501
|
+
.map((p: { type: string; text?: string }) => p.text ?? "")
|
|
2502
|
+
.join("")
|
|
2503
|
+
: "";
|
|
2504
|
+
if (!text) continue;
|
|
2505
|
+
const snippet = text.length > 80 ? `${text.slice(0, 77)}...` : text;
|
|
2506
|
+
parts.push(`[${msg.role}]: ${snippet}`);
|
|
2597
2507
|
}
|
|
2508
|
+
return parts.length > 0 ? parts.join(" | ") : null;
|
|
2509
|
+
}
|
|
2598
2510
|
|
|
2599
|
-
|
|
2600
|
-
const turnStartMs = Date.now();
|
|
2601
|
-
let turnModelId = this.modelId;
|
|
2602
|
-
let taskHash: string | null = null;
|
|
2603
|
-
const _routeStart = Date.now();
|
|
2604
|
-
try {
|
|
2605
|
-
const { decide } = await import("../router/decide.js");
|
|
2606
|
-
const routeDecision = await decide(userMessage, {
|
|
2607
|
-
tenantId: "local",
|
|
2608
|
-
cwd: this.bash.getCwd(),
|
|
2609
|
-
defaultModel: this.modelId,
|
|
2610
|
-
defaultProvider: this.providerId,
|
|
2611
|
-
pil: {
|
|
2612
|
-
domain: pilCtx.domain,
|
|
2613
|
-
taskType: pilCtx.taskType,
|
|
2614
|
-
confidence: pilCtx.confidence,
|
|
2615
|
-
gsdPhase: pilCtx.gsdPhase ?? null,
|
|
2616
|
-
activeRunId: pilCtx.activeRunId ?? null,
|
|
2617
|
-
recentTurnsSummary: this._buildRecentTurnsSummary(),
|
|
2618
|
-
projectSize: this._estimateProjectSize(),
|
|
2619
|
-
filesTouched: this._countFilesTouched(),
|
|
2620
|
-
mode: this.mode,
|
|
2621
|
-
},
|
|
2622
|
-
});
|
|
2623
|
-
if (routeDecision.model && routeDecision.model !== "HALT") {
|
|
2624
|
-
turnModelId = routeDecision.model;
|
|
2625
|
-
}
|
|
2626
|
-
taskHash = routeDecision.taskHash ?? null;
|
|
2627
|
-
// Update status bar with router switch info
|
|
2628
|
-
if (turnModelId !== this.modelId) {
|
|
2629
|
-
statusBarStore.setState({ routed_from: this.modelId, model: turnModelId });
|
|
2630
|
-
}
|
|
2631
|
-
if (_debugOn) {
|
|
2632
|
-
_debugSteps.push({
|
|
2633
|
-
name: "Router",
|
|
2634
|
-
duration_ms: Date.now() - _routeStart,
|
|
2635
|
-
input_summary: `default=${this.modelId}`,
|
|
2636
|
-
output_summary: turnModelId !== this.modelId ? `routed→${turnModelId}` : `kept ${turnModelId}`,
|
|
2637
|
-
});
|
|
2638
|
-
}
|
|
2639
|
-
} catch {
|
|
2640
|
-
// Router unavailable — use session default model
|
|
2641
|
-
const eeRoute = await routeModel(userMessage, {}, "claude").catch(() => null);
|
|
2642
|
-
taskHash = eeRoute?.taskHash ?? null;
|
|
2643
|
-
}
|
|
2644
|
-
|
|
2645
|
-
// Re-detect provider if router picked a model from a different provider
|
|
2646
|
-
const turnProviderId = detectProviderForModel(turnModelId);
|
|
2647
|
-
let turnProvider: LegacyProvider;
|
|
2648
|
-
if (turnProviderId !== this.providerId) {
|
|
2649
|
-
const turnKey = await loadKeyForProvider(turnProviderId).catch(() => null);
|
|
2650
|
-
if (turnKey) {
|
|
2651
|
-
turnProvider = createProvider(turnProviderId, turnKey);
|
|
2652
|
-
} else {
|
|
2653
|
-
turnModelId = this.modelId;
|
|
2654
|
-
turnProvider = this.requireProvider();
|
|
2655
|
-
}
|
|
2656
|
-
} else {
|
|
2657
|
-
turnProvider = this.requireProvider();
|
|
2658
|
-
}
|
|
2659
|
-
|
|
2660
|
-
let userModelMessage: ModelMessage;
|
|
2661
|
-
if (images?.length) {
|
|
2662
|
-
const parts: Array<{ type: "text"; text: string } | { type: "image"; image: string; mediaType: string }> = [
|
|
2663
|
-
{ type: "text", text: enrichedMessage },
|
|
2664
|
-
];
|
|
2665
|
-
for (const img of images) {
|
|
2666
|
-
parts.push({ type: "image", image: img.base64, mediaType: img.mediaType });
|
|
2667
|
-
}
|
|
2668
|
-
userModelMessage = { role: "user", content: parts };
|
|
2669
|
-
} else {
|
|
2670
|
-
userModelMessage = { role: "user", content: enrichedMessage };
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
// Vision proxy: convert images to text for models that don't support vision
|
|
2674
|
-
if (images?.length && needsVisionProxy(turnModelId)) {
|
|
2675
|
-
try {
|
|
2676
|
-
const proxyResult = await proxyVision([userModelMessage], turnModelId, signal);
|
|
2677
|
-
if (proxyResult.proxied) {
|
|
2678
|
-
userModelMessage = proxyResult.messages[0];
|
|
2679
|
-
yield { type: "content", content: `[Vision proxy: ${proxyResult.imageCount} image(s) → ${turnModelId} via SiliconFlow]\n` };
|
|
2680
|
-
}
|
|
2681
|
-
} catch {
|
|
2682
|
-
yield { type: "content", content: "[Vision proxy: failed, images dropped]\n" };
|
|
2683
|
-
userModelMessage = { role: "user", content: enrichedMessage };
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
this.messages.push(userModelMessage);
|
|
2688
|
-
this.messageSeqs.push(null);
|
|
2689
|
-
|
|
2690
|
-
const provider = turnProvider;
|
|
2691
|
-
const subagents = loadValidSubAgents();
|
|
2692
|
-
const _pilResponseTools = getResponseToolSet(pilCtx);
|
|
2693
|
-
const _hasResponseTools = Object.keys(_pilResponseTools).length > 0;
|
|
2694
|
-
const systemParts = buildSystemPromptParts(
|
|
2695
|
-
this.bash.getCwd(),
|
|
2696
|
-
this.mode,
|
|
2697
|
-
this.bash.getSandboxMode(),
|
|
2698
|
-
this.planContext,
|
|
2699
|
-
subagents,
|
|
2700
|
-
this.bash.getSandboxSettings(),
|
|
2701
|
-
this.providerId,
|
|
2702
|
-
);
|
|
2703
|
-
const system = applyModelConstraints(
|
|
2704
|
-
applyPilSuffix(
|
|
2705
|
-
`${systemParts.staticPrefix}${systemParts.dynamicSuffix}`,
|
|
2706
|
-
pilCtx,
|
|
2707
|
-
_hasResponseTools,
|
|
2708
|
-
),
|
|
2709
|
-
turnModelId,
|
|
2710
|
-
);
|
|
2711
|
-
const runtime = resolveModelRuntime(provider, turnModelId);
|
|
2712
|
-
const modelInfo = runtime.modelInfo;
|
|
2713
|
-
this.planContext = null;
|
|
2714
|
-
let attemptedOverflowRecovery = false;
|
|
2715
|
-
|
|
2716
|
-
// Auto-council: for plan/analyze tasks with high confidence, run multi-model debate
|
|
2717
|
-
const autoCouncilTypes = new Set(["plan", "analyze"]);
|
|
2718
|
-
const councilRoles = getRoleModels();
|
|
2719
|
-
const configuredRoleCount = Object.values(councilRoles).filter(Boolean).length;
|
|
2720
|
-
if (
|
|
2721
|
-
isAutoCouncilEnabled() &&
|
|
2722
|
-
pilCtx.taskType &&
|
|
2723
|
-
autoCouncilTypes.has(pilCtx.taskType) &&
|
|
2724
|
-
pilCtx.confidence >= 0.75 &&
|
|
2725
|
-
configuredRoleCount >= 2
|
|
2726
|
-
) {
|
|
2727
|
-
yield { type: "content", content: `\n[Auto-council triggered: ${pilCtx.taskType} task detected with ${(pilCtx.confidence * 100).toFixed(0)}% confidence]\n` };
|
|
2728
|
-
yield* this.runCouncilRound(userMessage, observer);
|
|
2729
|
-
return;
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
if (this.batchApi) {
|
|
2733
|
-
try {
|
|
2734
|
-
yield* this.processMessageBatchTurn({
|
|
2735
|
-
userModelMessage,
|
|
2736
|
-
observer,
|
|
2737
|
-
provider,
|
|
2738
|
-
subagents,
|
|
2739
|
-
system,
|
|
2740
|
-
runtime,
|
|
2741
|
-
modelInfo,
|
|
2742
|
-
signal,
|
|
2743
|
-
});
|
|
2744
|
-
} finally {
|
|
2745
|
-
if (this.abortController?.signal === signal) {
|
|
2746
|
-
this.abortController = null;
|
|
2747
|
-
}
|
|
2748
|
-
}
|
|
2749
|
-
return;
|
|
2750
|
-
}
|
|
2751
|
-
|
|
2752
|
-
try {
|
|
2753
|
-
while (true) {
|
|
2754
|
-
this._compactedThisTurn = false;
|
|
2755
|
-
let assistantText = "";
|
|
2756
|
-
let reasoningPreview = "";
|
|
2757
|
-
let encryptedReasoningHidden = false;
|
|
2758
|
-
let streamOk = false;
|
|
2759
|
-
let closeMcp: (() => Promise<void>) | undefined;
|
|
2760
|
-
let stepNumber = -1;
|
|
2761
|
-
const activeToolCalls: ToolCall[] = [];
|
|
2762
|
-
|
|
2763
|
-
try {
|
|
2764
|
-
const settings = attemptedOverflowRecovery
|
|
2765
|
-
? relaxCompactionSettings(this.getCompactionSettings())
|
|
2766
|
-
: this.getCompactionSettings();
|
|
2767
|
-
if (modelInfo?.contextWindow) {
|
|
2768
|
-
await this.compactForContext(
|
|
2769
|
-
provider,
|
|
2770
|
-
system,
|
|
2771
|
-
modelInfo.contextWindow,
|
|
2772
|
-
signal,
|
|
2773
|
-
settings,
|
|
2774
|
-
attemptedOverflowRecovery,
|
|
2775
|
-
);
|
|
2776
|
-
}
|
|
2777
|
-
|
|
2778
|
-
const baseTools = createTools(this.bash, provider, this.mode, {
|
|
2779
|
-
runTask: (request, abortSignal) => this.runTask(request, combineAbortSignals(signal, abortSignal)),
|
|
2780
|
-
runDelegation: (request, abortSignal) =>
|
|
2781
|
-
this.runDelegation(request, combineAbortSignals(signal, abortSignal)),
|
|
2782
|
-
readDelegation: (id) => this.readDelegation(id),
|
|
2783
|
-
listDelegations: () => this.listDelegations(),
|
|
2784
|
-
scheduleManager: this.schedules,
|
|
2785
|
-
subagents,
|
|
2786
|
-
sendTelegramFile: this.sendTelegramFile ?? undefined,
|
|
2787
|
-
sessionId: this.session?.id ?? undefined,
|
|
2788
|
-
});
|
|
2789
|
-
let tools: ToolSet = runtime.modelInfo?.supportsClientTools === false ? {} : baseTools;
|
|
2790
|
-
if (this.mode === "agent" && runtime.modelInfo?.supportsClientTools !== false) {
|
|
2791
|
-
const mcpBundle = await buildMcpToolSet(loadMcpServers(), {
|
|
2792
|
-
onOAuthRequired: (_serverId, url) => {
|
|
2793
|
-
const urlStr = url.toString();
|
|
2794
|
-
import("child_process").then(({ exec }) => {
|
|
2795
|
-
const cmd = process.platform === "win32" ? `start "" "${urlStr}"`
|
|
2796
|
-
: process.platform === "darwin" ? `open "${urlStr}"`
|
|
2797
|
-
: `xdg-open "${urlStr}"`;
|
|
2798
|
-
exec(cmd);
|
|
2799
|
-
});
|
|
2800
|
-
},
|
|
2801
|
-
});
|
|
2802
|
-
closeMcp = mcpBundle.close;
|
|
2803
|
-
tools = { ...baseTools, ...mcpBundle.tools };
|
|
2804
|
-
captureToolSchemas(tools);
|
|
2805
|
-
if (mcpBundle.errors.length > 0) {
|
|
2806
|
-
yield { type: "content", content: `MCP unavailable: ${mcpBundle.errors.join(" | ")}\n\n` };
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
|
-
// PIL response tools: inject structured output tool when taskType detected
|
|
2811
|
-
if (_hasResponseTools && runtime.modelInfo?.supportsClientTools !== false) {
|
|
2812
|
-
tools = { ...tools, ..._pilResponseTools };
|
|
2813
|
-
captureToolSchemas(_pilResponseTools);
|
|
2814
|
-
}
|
|
2815
|
-
let responseToolCalled = false;
|
|
2816
|
-
|
|
2817
|
-
// Build provider options, optionally adding reasoning budget for capable models
|
|
2818
|
-
const baseProviderOpts = runtime.providerOptions ?? {};
|
|
2819
|
-
const providerOpts = runtime.modelInfo?.reasoning
|
|
2820
|
-
? {
|
|
2821
|
-
...baseProviderOpts,
|
|
2822
|
-
anthropic: {
|
|
2823
|
-
...(baseProviderOpts.anthropic ?? {}),
|
|
2824
|
-
thinking: {
|
|
2825
|
-
type: "enabled" as const,
|
|
2826
|
-
budgetTokens:
|
|
2827
|
-
taskTypeToReasoningEffort(pilCtx.taskType) === "high"
|
|
2828
|
-
? 32_768
|
|
2829
|
-
: taskTypeToReasoningEffort(pilCtx.taskType) === "medium"
|
|
2830
|
-
? 8_192
|
|
2831
|
-
: 2_048,
|
|
2832
|
-
},
|
|
2833
|
-
},
|
|
2834
|
-
}
|
|
2835
|
-
: baseProviderOpts;
|
|
2836
|
-
// Use catalog's thinkingType field instead of regex matching
|
|
2837
|
-
const thinkingModelInfo = getModelInfo(runtime.modelId);
|
|
2838
|
-
if (providerOpts.anthropic?.thinking?.type === "enabled" && thinkingModelInfo?.thinkingType === "adaptive") {
|
|
2839
|
-
providerOpts.anthropic.thinking = { type: "adaptive" as any };
|
|
2840
|
-
}
|
|
2841
|
-
|
|
2842
|
-
// Multi-provider caching: OpenAI stored completions, DeepSeek prefix cache
|
|
2843
|
-
const turnProvider = runtime.modelInfo?.provider ?? this.providerId;
|
|
2844
|
-
if (turnProvider === "openai") {
|
|
2845
|
-
providerOpts.openai = { ...(providerOpts.openai ?? {}), store: true };
|
|
2846
|
-
}
|
|
2847
|
-
|
|
2848
|
-
const systemForModel = runtime.modelId.startsWith("claude")
|
|
2849
|
-
? [
|
|
2850
|
-
{ role: "system" as const, content: systemParts.staticPrefix, providerOptions: { anthropic: { cacheControl: { type: "ephemeral" as const } } } },
|
|
2851
|
-
{ role: "system" as const, content: system.slice(systemParts.staticPrefix.length) },
|
|
2852
|
-
]
|
|
2853
|
-
: system;
|
|
2854
|
-
|
|
2855
|
-
const result = streamText({
|
|
2856
|
-
model: runtime.model,
|
|
2857
|
-
system: systemForModel,
|
|
2858
|
-
messages: this.messages,
|
|
2859
|
-
tools,
|
|
2860
|
-
toolChoice:
|
|
2861
|
-
_hasResponseTools && runtime.modelInfo?.supportsClientTools !== false
|
|
2862
|
-
? "auto"
|
|
2863
|
-
: undefined,
|
|
2864
|
-
stopWhen: stepCountIs(this.maxToolRounds),
|
|
2865
|
-
maxRetries: 0,
|
|
2866
|
-
abortSignal: signal,
|
|
2867
|
-
temperature: 0.7,
|
|
2868
|
-
...(runtime.modelInfo?.supportsMaxOutputTokens === false ? {} : { maxOutputTokens: taskTypeToMaxTokens(pilCtx.taskType) }),
|
|
2869
|
-
...(Object.keys(providerOpts).length > 0 ? { providerOptions: providerOpts } : {}),
|
|
2870
|
-
experimental_onStepStart: (event: unknown) => {
|
|
2871
|
-
stepNumber = getStepNumber(event, stepNumber + 1);
|
|
2872
|
-
notifyObserver(observer?.onStepStart, {
|
|
2873
|
-
stepNumber,
|
|
2874
|
-
timestamp: Date.now(),
|
|
2875
|
-
});
|
|
2876
|
-
},
|
|
2877
|
-
onStepFinish: (event: unknown) => {
|
|
2878
|
-
const currentStep = getStepNumber(event, Math.max(stepNumber, 0));
|
|
2879
|
-
stepNumber = Math.max(stepNumber, currentStep);
|
|
2880
|
-
const stepUsage = getUsage(event);
|
|
2881
|
-
notifyObserver(observer?.onStepFinish, {
|
|
2882
|
-
stepNumber: currentStep,
|
|
2883
|
-
timestamp: Date.now(),
|
|
2884
|
-
finishReason: getFinishReason(event),
|
|
2885
|
-
usage: stepUsage,
|
|
2886
|
-
});
|
|
2887
|
-
// Realtime status bar update per step
|
|
2888
|
-
if (stepUsage.inputTokens || stepUsage.outputTokens) {
|
|
2889
|
-
this.recordUsage(stepUsage, "message", runtime.modelId);
|
|
2890
|
-
}
|
|
2891
|
-
},
|
|
2892
|
-
onFinish: ({ providerMetadata }) => {
|
|
2893
|
-
// Cache metrics only available in onFinish (Anthropic provider metadata)
|
|
2894
|
-
const anthropicMeta = providerMetadata?.anthropic as Record<string, unknown> | undefined;
|
|
2895
|
-
const cacheReadTokens = asNumber(anthropicMeta?.cacheReadInputTokens) ?? 0;
|
|
2896
|
-
const cacheCreationTokens = asNumber(anthropicMeta?.cacheCreationInputTokens) ?? 0;
|
|
2897
|
-
if (cacheReadTokens || cacheCreationTokens) {
|
|
2898
|
-
const prev = statusBarStore.getState();
|
|
2899
|
-
statusBarStore.setState({
|
|
2900
|
-
cache_read_tokens: (prev.cache_read_tokens ?? 0) + cacheReadTokens,
|
|
2901
|
-
cache_creation_tokens: (prev.cache_creation_tokens ?? 0) + cacheCreationTokens,
|
|
2902
|
-
});
|
|
2903
|
-
}
|
|
2904
|
-
},
|
|
2905
|
-
});
|
|
2906
|
-
|
|
2907
|
-
for await (const part of result.fullStream) {
|
|
2908
|
-
if (signal.aborted) {
|
|
2909
|
-
yield { type: "content", content: "\n\n[Cancelled]" };
|
|
2910
|
-
break;
|
|
2911
|
-
}
|
|
2912
|
-
|
|
2913
|
-
switch (part.type) {
|
|
2914
|
-
case "text-delta":
|
|
2915
|
-
assistantText += part.text;
|
|
2916
|
-
yield { type: "content", content: part.text };
|
|
2917
|
-
break;
|
|
2918
|
-
|
|
2919
|
-
case "reasoning-delta":
|
|
2920
|
-
reasoningPreview = `${reasoningPreview}${part.text}`.slice(-256);
|
|
2921
|
-
if (containsEncryptedReasoning(reasoningPreview)) {
|
|
2922
|
-
if (!encryptedReasoningHidden) {
|
|
2923
|
-
encryptedReasoningHidden = true;
|
|
2924
|
-
yield { type: "reasoning", content: "[Encrypted reasoning hidden]" };
|
|
2925
|
-
}
|
|
2926
|
-
break;
|
|
2927
|
-
}
|
|
2928
|
-
yield { type: "reasoning", content: part.text };
|
|
2929
|
-
break;
|
|
2930
|
-
|
|
2931
|
-
case "tool-call": {
|
|
2932
|
-
const tc = toToolCall(part);
|
|
2933
|
-
activeToolCalls.push(tc);
|
|
2934
|
-
|
|
2935
|
-
// EE PreToolUse hook: fire intercept before tool execution.
|
|
2936
|
-
{
|
|
2937
|
-
const preInput: PreToolUseHookInput = {
|
|
2938
|
-
hook_event_name: "PreToolUse",
|
|
2939
|
-
tool_name: tc.function.name,
|
|
2940
|
-
tool_input: JSON.parse(tc.function.arguments || "{}"),
|
|
2941
|
-
session_id: this.session?.id,
|
|
2942
|
-
cwd: this.bash.getCwd(),
|
|
2943
|
-
};
|
|
2944
|
-
const preResult = await this.fireHook(preInput, signal).catch(() => ({
|
|
2945
|
-
blocked: false,
|
|
2946
|
-
blockingErrors: [],
|
|
2947
|
-
preventContinuation: false,
|
|
2948
|
-
additionalContexts: [] as string[],
|
|
2949
|
-
results: [],
|
|
2950
|
-
}));
|
|
2951
|
-
for (const ctx of preResult.additionalContexts ?? []) {
|
|
2952
|
-
yield { type: "content", content: `${ctx}\n` };
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2956
|
-
// Pitfall 9: log the pending call so reconcile() can recover any
|
|
2957
|
-
// staged .tmp files if the process is killed before tool-result.
|
|
2958
|
-
if (this.pendingCalls) {
|
|
2959
|
-
const turnId = this.session?.id ?? "anon";
|
|
2960
|
-
const callId = stableCallId(turnId, tc.function.name, tc.function.arguments);
|
|
2961
|
-
// Phase 0: predictStagedPaths = [] for all tools (refined in Phase 1).
|
|
2962
|
-
void this.pendingCalls.begin({ call_id: callId, tool_name: tc.function.name }).catch(() => {});
|
|
2963
|
-
// Attach callId to the ToolCall so tool-result can end it.
|
|
2964
|
-
(tc as ToolCall & { _pendingCallId?: string })._pendingCallId = callId;
|
|
2965
|
-
}
|
|
2966
|
-
notifyObserver(observer?.onToolStart, {
|
|
2967
|
-
toolCall: tc,
|
|
2968
|
-
timestamp: Date.now(),
|
|
2969
|
-
});
|
|
2970
|
-
yield { type: "tool_calls", toolCalls: [tc] };
|
|
2971
|
-
break;
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2974
|
-
case "tool-result": {
|
|
2975
|
-
const tc: ToolCall = {
|
|
2976
|
-
id: part.toolCallId,
|
|
2977
|
-
type: "function",
|
|
2978
|
-
function: { name: part.toolName, arguments: JSON.stringify(part.input ?? {}) },
|
|
2979
|
-
};
|
|
2980
|
-
const tr = toToolResult(part.output);
|
|
2981
|
-
// Pitfall 9: settle the pending call log entry.
|
|
2982
|
-
if (this.pendingCalls) {
|
|
2983
|
-
const pending = activeToolCalls.find((t) => t.id === part.toolCallId);
|
|
2984
|
-
const callId = (pending as ToolCall & { _pendingCallId?: string })?._pendingCallId;
|
|
2985
|
-
if (callId) {
|
|
2986
|
-
const endStatus = signal.aborted ? "aborted" : "settled";
|
|
2987
|
-
void this.pendingCalls.end(callId, endStatus).catch(() => {});
|
|
2988
|
-
}
|
|
2989
|
-
}
|
|
2990
|
-
// EE PostToolUse hook: fire-and-forget after tool execution.
|
|
2991
|
-
{
|
|
2992
|
-
const postInput: PostToolUseHookInput = {
|
|
2993
|
-
hook_event_name: "PostToolUse",
|
|
2994
|
-
tool_name: part.toolName,
|
|
2995
|
-
tool_input: (part.input as Record<string, unknown>) ?? {},
|
|
2996
|
-
tool_output: typeof tr.output === "string" ? { text: tr.output } : ((tr.output as unknown as Record<string, unknown>) ?? {}),
|
|
2997
|
-
session_id: this.session?.id,
|
|
2998
|
-
cwd: this.bash.getCwd(),
|
|
2999
|
-
};
|
|
3000
|
-
await this.fireHook(postInput, signal).catch(() => {});
|
|
3001
|
-
}
|
|
3002
|
-
|
|
3003
|
-
// Response tool: yield as structured_response instead of tool_result
|
|
3004
|
-
if (isResponseTool(part.toolName)) {
|
|
3005
|
-
responseToolCalled = true;
|
|
3006
|
-
const taskType = getResponseTaskType(part.toolName);
|
|
3007
|
-
yield {
|
|
3008
|
-
type: "structured_response" as StreamChunk["type"],
|
|
3009
|
-
structuredResponse: {
|
|
3010
|
-
taskType: taskType ?? part.toolName,
|
|
3011
|
-
data: (part.output ?? {}) as Record<string, unknown>,
|
|
3012
|
-
},
|
|
3013
|
-
};
|
|
3014
|
-
notifyObserver(observer?.onToolFinish, { toolCall: tc, toolResult: tr, timestamp: Date.now() });
|
|
3015
|
-
break;
|
|
3016
|
-
}
|
|
3017
|
-
|
|
3018
|
-
notifyObserver(observer?.onToolFinish, {
|
|
3019
|
-
toolCall: tc,
|
|
3020
|
-
toolResult: tr,
|
|
3021
|
-
timestamp: Date.now(),
|
|
3022
|
-
});
|
|
3023
|
-
yield { type: "tool_result", toolCall: tc, toolResult: tr };
|
|
3024
|
-
break;
|
|
3025
|
-
}
|
|
3026
|
-
|
|
3027
|
-
case "tool-approval-request": {
|
|
3028
|
-
const approvalPart = part as unknown as {
|
|
3029
|
-
approvalId: string;
|
|
3030
|
-
toolCall: { toolCallId: string; toolName: string; input: unknown };
|
|
3031
|
-
};
|
|
3032
|
-
const toolCallId = approvalPart.toolCall?.toolCallId ?? "";
|
|
3033
|
-
const pendingTc = activeToolCalls.find((tc) => tc.id === toolCallId);
|
|
3034
|
-
const tcForChunk = pendingTc ?? {
|
|
3035
|
-
id: toolCallId,
|
|
3036
|
-
type: "function" as const,
|
|
3037
|
-
function: {
|
|
3038
|
-
name: approvalPart.toolCall?.toolName ?? "paid_request",
|
|
3039
|
-
arguments: JSON.stringify(approvalPart.toolCall?.input ?? {}),
|
|
3040
|
-
},
|
|
3041
|
-
};
|
|
3042
|
-
|
|
3043
|
-
// Payment pre-check disabled — Stripe billing pending.
|
|
3044
|
-
const paymentPrecheck: import("../types/index").PaymentPrecheck | undefined = undefined;
|
|
3045
|
-
|
|
3046
|
-
// Plan 03-01: check permission mode before yielding approval request to UI.
|
|
3047
|
-
// auto-edit auto-approves file ops; yolo auto-approves everything.
|
|
3048
|
-
const toolName = approvalPart.toolCall?.toolName ?? "";
|
|
3049
|
-
if (!toolNeedsApproval(toolName, this.permissionMode)) {
|
|
3050
|
-
// Auto-approve: respond directly without surfacing to UI.
|
|
3051
|
-
this.respondToToolApproval(approvalPart.approvalId, true);
|
|
3052
|
-
break;
|
|
3053
|
-
}
|
|
3054
|
-
|
|
3055
|
-
yield {
|
|
3056
|
-
type: "tool_approval_request",
|
|
3057
|
-
approvalId: approvalPart.approvalId,
|
|
3058
|
-
toolCall: tcForChunk,
|
|
3059
|
-
paymentPrecheck,
|
|
3060
|
-
};
|
|
3061
|
-
break;
|
|
3062
|
-
}
|
|
3063
|
-
|
|
3064
|
-
case "error": {
|
|
3065
|
-
const authError = isAuthenticationError(part.error);
|
|
3066
|
-
const friendly = humanizeApiError(part.error);
|
|
3067
|
-
notifyObserver(observer?.onError, {
|
|
3068
|
-
message: friendly,
|
|
3069
|
-
timestamp: Date.now(),
|
|
3070
|
-
});
|
|
3071
|
-
yield {
|
|
3072
|
-
type: "error",
|
|
3073
|
-
content: friendly,
|
|
3074
|
-
isAuthError: authError,
|
|
3075
|
-
};
|
|
3076
|
-
break;
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3079
|
-
case "abort":
|
|
3080
|
-
yield { type: "content", content: "\n\n[Cancelled]" };
|
|
3081
|
-
break;
|
|
3082
|
-
}
|
|
3083
|
-
}
|
|
3084
|
-
|
|
3085
|
-
if (signal.aborted) {
|
|
3086
|
-
this.discardAbortedTurn(userModelMessage);
|
|
3087
|
-
yield { type: "done" };
|
|
3088
|
-
return;
|
|
3089
|
-
}
|
|
3090
|
-
|
|
3091
|
-
try {
|
|
3092
|
-
const response = await result.response;
|
|
3093
|
-
if (!signal.aborted) {
|
|
3094
|
-
this.appendCompletedTurn(userModelMessage, sanitizeModelMessages(response.messages));
|
|
3095
|
-
streamOk = true;
|
|
3096
|
-
}
|
|
3097
|
-
} catch (responseError: unknown) {
|
|
3098
|
-
if (
|
|
3099
|
-
!attemptedOverflowRecovery &&
|
|
3100
|
-
!assistantText.trim() &&
|
|
3101
|
-
modelInfo &&
|
|
3102
|
-
isContextLimitError(responseError)
|
|
3103
|
-
) {
|
|
3104
|
-
attemptedOverflowRecovery = true;
|
|
3105
|
-
continue;
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
|
|
3109
|
-
if (signal.aborted) {
|
|
3110
|
-
this.discardAbortedTurn(userModelMessage);
|
|
3111
|
-
yield { type: "done" };
|
|
3112
|
-
return;
|
|
3113
|
-
}
|
|
3114
|
-
|
|
3115
|
-
if (!streamOk && assistantText.trim()) {
|
|
3116
|
-
this.appendCompletedTurn(userModelMessage, [{ role: "assistant", content: assistantText }]);
|
|
3117
|
-
}
|
|
3118
|
-
|
|
3119
|
-
// Fallback: model responded in text despite tool_choice=required
|
|
3120
|
-
// Attempt JSON extraction from assistant text → yield as structured_response
|
|
3121
|
-
if (_hasResponseTools && !responseToolCalled && pilCtx.taskType && assistantText.trim()) {
|
|
3122
|
-
try {
|
|
3123
|
-
const jsonMatch = assistantText.match(/\{[\s\S]*\}/);
|
|
3124
|
-
if (jsonMatch) {
|
|
3125
|
-
const parsed = JSON.parse(jsonMatch[0]) as Record<string, unknown>;
|
|
3126
|
-
if (Object.keys(parsed).length > 0) {
|
|
3127
|
-
responseToolCalled = true;
|
|
3128
|
-
yield {
|
|
3129
|
-
type: "structured_response" as StreamChunk["type"],
|
|
3130
|
-
structuredResponse: {
|
|
3131
|
-
taskType: pilCtx.taskType,
|
|
3132
|
-
data: parsed,
|
|
3133
|
-
},
|
|
3134
|
-
};
|
|
3135
|
-
}
|
|
3136
|
-
}
|
|
3137
|
-
} catch {
|
|
3138
|
-
// JSON parse failed — leave as text-fallback
|
|
3139
|
-
}
|
|
3140
|
-
}
|
|
3141
|
-
|
|
3142
|
-
// Track PIL output mode for /optimize metrics
|
|
3143
|
-
{
|
|
3144
|
-
const { setLastOutputMode } = await import("../pil/store.js");
|
|
3145
|
-
if (!_hasResponseTools) setLastOutputMode("conversational");
|
|
3146
|
-
else if (responseToolCalled) setLastOutputMode("structured");
|
|
3147
|
-
else setLastOutputMode("text-fallback");
|
|
3148
|
-
}
|
|
3149
|
-
|
|
3150
|
-
// ROUTE-11: Fire routeFeedback after turn completes (success path).
|
|
3151
|
-
// Must come AFTER posttool calls (posttool fires during tool-result processing above).
|
|
3152
|
-
// Fire-and-forget — no await. Skipped when taskHash is null (bridge absent).
|
|
3153
|
-
{
|
|
3154
|
-
const turnDuration = Date.now() - turnStartMs;
|
|
3155
|
-
if (taskHash) {
|
|
3156
|
-
const tier = taskTypeToTier(pilCtx.taskType);
|
|
3157
|
-
void routeFeedback(
|
|
3158
|
-
taskHash,
|
|
3159
|
-
tier,
|
|
3160
|
-
runtime.modelId,
|
|
3161
|
-
"success", // Phase 6: all normal completions = 'success'
|
|
3162
|
-
0, // retryCount: 0 for first attempt
|
|
3163
|
-
turnDuration,
|
|
3164
|
-
);
|
|
3165
|
-
}
|
|
3166
|
-
// HTTP path: also report via router store taskHash (covers warm/cold EE routes)
|
|
3167
|
-
const storeHash = routerStore.getState().taskHash;
|
|
3168
|
-
if (storeHash) {
|
|
3169
|
-
reportRouteOutcome(storeHash, "success", turnDuration);
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
|
|
3173
|
-
const stopInput: StopHookInput = {
|
|
3174
|
-
hook_event_name: "Stop",
|
|
3175
|
-
session_id: this.session?.id,
|
|
3176
|
-
cwd: this.bash.getCwd(),
|
|
3177
|
-
};
|
|
3178
|
-
await this.fireHook(stopInput, signal).catch(() => {});
|
|
3179
|
-
|
|
3180
|
-
// Debug trace: emit pipeline summary
|
|
3181
|
-
if (_debugOn) {
|
|
3182
|
-
const sb = statusBarStore.getState();
|
|
3183
|
-
const defaultInfo = getModelInfo(this.modelId);
|
|
3184
|
-
const usedInfo = getModelInfo(turnModelId);
|
|
3185
|
-
const routerSaved = (defaultInfo && usedInfo && defaultInfo.outputPrice > usedInfo.outputPrice)
|
|
3186
|
-
? (sb.out_tokens * (defaultInfo.outputPrice - usedInfo.outputPrice)) / 1_000_000
|
|
3187
|
-
: 0;
|
|
3188
|
-
const cacheSaved = sb.cache_read_tokens > 0 && defaultInfo
|
|
3189
|
-
? (sb.cache_read_tokens * (defaultInfo.inputPrice - (defaultInfo.cachedInputPrice ?? defaultInfo.inputPrice * 0.1))) / 1_000_000
|
|
3190
|
-
: 0;
|
|
3191
|
-
const trace: TurnTrace = {
|
|
3192
|
-
turn_id: _debugTurnId,
|
|
3193
|
-
timestamp: turnStartMs,
|
|
3194
|
-
raw_prompt: userMessage,
|
|
3195
|
-
steps: _debugSteps,
|
|
3196
|
-
model_requested: this.modelId,
|
|
3197
|
-
model_used: turnModelId,
|
|
3198
|
-
routed: turnModelId !== this.modelId,
|
|
3199
|
-
input_tokens: sb.in_tokens,
|
|
3200
|
-
output_tokens: sb.out_tokens,
|
|
3201
|
-
cache_read_tokens: sb.cache_read_tokens,
|
|
3202
|
-
cost_usd: sb.session_usd,
|
|
3203
|
-
estimated_savings: {
|
|
3204
|
-
pil_tokens_saved: this._pilEnrichmentDelta > 0 ? this._pilEnrichmentDelta : 0,
|
|
3205
|
-
cache_tokens_saved: sb.cache_read_tokens,
|
|
3206
|
-
router_cost_saved_usd: routerSaved,
|
|
3207
|
-
total_tokens_saved: (this._pilEnrichmentDelta > 0 ? this._pilEnrichmentDelta : 0) + sb.cache_read_tokens,
|
|
3208
|
-
total_cost_saved_usd: routerSaved + cacheSaved,
|
|
3209
|
-
},
|
|
3210
|
-
};
|
|
3211
|
-
recordTurnTrace(trace);
|
|
3212
|
-
|
|
3213
|
-
const traceLines: string[] = [];
|
|
3214
|
-
traceLines.push("\n┌─ Pipeline Trace ─────────────────────────");
|
|
3215
|
-
for (const step of _debugSteps) {
|
|
3216
|
-
const dur = step.duration_ms < 1 ? "<1ms" : `${step.duration_ms}ms`;
|
|
3217
|
-
const saved = step.tokens_saved ? ` (saved ~${step.tokens_saved} tok)` : "";
|
|
3218
|
-
traceLines.push(`│ ▸ ${step.name} [${dur}]${saved}`);
|
|
3219
|
-
traceLines.push(`│ ${step.output_summary}`);
|
|
3220
|
-
}
|
|
3221
|
-
const routeLabel = trace.routed ? `${trace.model_requested}→${trace.model_used}` : trace.model_used;
|
|
3222
|
-
traceLines.push(`│ Model: ${routeLabel} | ↑${sb.in_tokens} ↓${sb.out_tokens} | $${sb.session_usd.toFixed(4)}`);
|
|
3223
|
-
if (trace.estimated_savings.total_cost_saved_usd > 0) {
|
|
3224
|
-
traceLines.push(`│ Savings: ~${trace.estimated_savings.total_tokens_saved} tok, ~$${trace.estimated_savings.total_cost_saved_usd.toFixed(4)}`);
|
|
3225
|
-
}
|
|
3226
|
-
traceLines.push("└──────────────────────────────────────────\n");
|
|
3227
|
-
yield { type: "content", content: traceLines.join("\n") };
|
|
3228
|
-
}
|
|
3229
|
-
|
|
3230
|
-
if (modelInfo?.contextWindow) {
|
|
3231
|
-
await this.postTurnCompact(provider, system, modelInfo.contextWindow, signal);
|
|
3232
|
-
}
|
|
3233
|
-
yield { type: "done" };
|
|
3234
|
-
return;
|
|
3235
|
-
} catch (err: unknown) {
|
|
3236
|
-
if (signal.aborted) {
|
|
3237
|
-
this.discardAbortedTurn(userModelMessage);
|
|
3238
|
-
// ROUTE-11: Fire routeFeedback for cancelled turns (abort path).
|
|
3239
|
-
// Fire-and-forget — no await. Skipped when taskHash is null.
|
|
3240
|
-
{
|
|
3241
|
-
const turnDuration = Date.now() - turnStartMs;
|
|
3242
|
-
if (taskHash) {
|
|
3243
|
-
const tier = taskTypeToTier(pilCtx.taskType);
|
|
3244
|
-
void routeFeedback(
|
|
3245
|
-
taskHash,
|
|
3246
|
-
tier,
|
|
3247
|
-
runtime.modelId,
|
|
3248
|
-
"cancelled",
|
|
3249
|
-
0,
|
|
3250
|
-
turnDuration,
|
|
3251
|
-
);
|
|
3252
|
-
}
|
|
3253
|
-
const storeHash = routerStore.getState().taskHash;
|
|
3254
|
-
if (storeHash) {
|
|
3255
|
-
reportRouteOutcome(storeHash, "cancelled", turnDuration);
|
|
3256
|
-
}
|
|
3257
|
-
}
|
|
3258
|
-
yield { type: "content", content: "\n\n[Cancelled]" };
|
|
3259
|
-
yield { type: "done" };
|
|
3260
|
-
return;
|
|
3261
|
-
}
|
|
3262
|
-
|
|
3263
|
-
if (!attemptedOverflowRecovery && !assistantText.trim() && modelInfo && isContextLimitError(err)) {
|
|
3264
|
-
attemptedOverflowRecovery = true;
|
|
3265
|
-
continue;
|
|
3266
|
-
}
|
|
3267
|
-
|
|
3268
|
-
const authError = isAuthenticationError(err);
|
|
3269
|
-
const friendly = humanizeApiError(err);
|
|
3270
|
-
notifyObserver(observer?.onError, {
|
|
3271
|
-
message: friendly,
|
|
3272
|
-
timestamp: Date.now(),
|
|
3273
|
-
});
|
|
3274
|
-
yield {
|
|
3275
|
-
type: "error",
|
|
3276
|
-
content: friendly,
|
|
3277
|
-
isAuthError: authError,
|
|
3278
|
-
};
|
|
3279
|
-
if (assistantText.trim()) {
|
|
3280
|
-
this.appendCompletedTurn(userModelMessage, [{ role: "assistant", content: assistantText }]);
|
|
3281
|
-
}
|
|
3282
|
-
|
|
3283
|
-
// ROUTE-11: Fire routeFeedback for failed turns (error path).
|
|
3284
|
-
// Must come AFTER posttool calls. Fire-and-forget — no await.
|
|
3285
|
-
{
|
|
3286
|
-
const turnDuration = Date.now() - turnStartMs;
|
|
3287
|
-
if (taskHash) {
|
|
3288
|
-
const tier = taskTypeToTier(pilCtx.taskType);
|
|
3289
|
-
void routeFeedback(
|
|
3290
|
-
taskHash,
|
|
3291
|
-
tier,
|
|
3292
|
-
runtime.modelId,
|
|
3293
|
-
"fail",
|
|
3294
|
-
0,
|
|
3295
|
-
turnDuration,
|
|
3296
|
-
);
|
|
3297
|
-
}
|
|
3298
|
-
const storeHash = routerStore.getState().taskHash;
|
|
3299
|
-
if (storeHash) {
|
|
3300
|
-
reportRouteOutcome(storeHash, "fail", turnDuration);
|
|
3301
|
-
}
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
const stopFailureInput: StopFailureHookInput = {
|
|
3305
|
-
hook_event_name: "StopFailure",
|
|
3306
|
-
error: friendly,
|
|
3307
|
-
session_id: this.session?.id,
|
|
3308
|
-
cwd: this.bash.getCwd(),
|
|
3309
|
-
};
|
|
3310
|
-
await this.fireHook(stopFailureInput, signal).catch(() => {});
|
|
3311
|
-
|
|
3312
|
-
if (modelInfo?.contextWindow) {
|
|
3313
|
-
await this.postTurnCompact(provider, system, modelInfo.contextWindow, signal);
|
|
3314
|
-
}
|
|
3315
|
-
yield { type: "done" };
|
|
3316
|
-
return;
|
|
3317
|
-
} finally {
|
|
3318
|
-
await closeMcp?.().catch(() => {});
|
|
3319
|
-
}
|
|
3320
|
-
}
|
|
3321
|
-
} finally {
|
|
3322
|
-
if (this.abortController?.signal === signal) {
|
|
3323
|
-
this.abortController = null;
|
|
3324
|
-
}
|
|
3325
|
-
}
|
|
3326
|
-
}
|
|
3327
|
-
|
|
3328
|
-
private _buildRecentTurnsSummary(): string | null {
|
|
3329
|
-
if (this.messages.length < 2) return null;
|
|
3330
|
-
const recent = this.messages.slice(-6);
|
|
3331
|
-
const parts: string[] = [];
|
|
3332
|
-
for (const msg of recent) {
|
|
3333
|
-
if (msg.role !== "user" && msg.role !== "assistant") continue;
|
|
3334
|
-
const text = typeof msg.content === "string"
|
|
3335
|
-
? msg.content
|
|
3336
|
-
: Array.isArray(msg.content)
|
|
3337
|
-
? msg.content.filter((p: { type: string }) => p.type === "text").map((p: { type: string; text?: string }) => p.text ?? "").join("")
|
|
3338
|
-
: "";
|
|
3339
|
-
if (!text) continue;
|
|
3340
|
-
const snippet = text.length > 80 ? `${text.slice(0, 77)}...` : text;
|
|
3341
|
-
parts.push(`[${msg.role}]: ${snippet}`);
|
|
3342
|
-
}
|
|
3343
|
-
return parts.length > 0 ? parts.join(" | ") : null;
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
private _estimateProjectSize(): "small" | "medium" | "large" | null {
|
|
2511
|
+
private _estimateProjectSize(): "small" | "medium" | "large" | null {
|
|
3347
2512
|
try {
|
|
3348
2513
|
const fs = require("fs");
|
|
3349
2514
|
const path = require("path");
|
|
@@ -3390,6 +2555,45 @@ export class Agent {
|
|
|
3390
2555
|
return this.provider;
|
|
3391
2556
|
}
|
|
3392
2557
|
|
|
2558
|
+
/**
|
|
2559
|
+
* One-shot async init: upgrades the OpenAI provider to use OAuth tokens when
|
|
2560
|
+
* stored tokens are available and no explicit API key was supplied by the user.
|
|
2561
|
+
* Called at the start of processMessage so the first real LLM call benefits
|
|
2562
|
+
* from OAuth without requiring a sync constructor change.
|
|
2563
|
+
*
|
|
2564
|
+
* Idempotent: skips on second call and for non-OpenAI providers.
|
|
2565
|
+
* Fail-open: any error leaves the existing provider untouched.
|
|
2566
|
+
*/
|
|
2567
|
+
private async _initOAuthProvider(): Promise<void> {
|
|
2568
|
+
if (this._oauthInitDone) return;
|
|
2569
|
+
this._oauthInitDone = true;
|
|
2570
|
+
|
|
2571
|
+
// Only upgrade when there is no explicit API key — OAuth is an alternative
|
|
2572
|
+
// auth path, not an override when the user deliberately passed a key.
|
|
2573
|
+
// The boot wizard in src/index.ts uses the literal "oauth" as a sentinel
|
|
2574
|
+
// to signal "no API key but OAuth tokens exist", so treat that as "no
|
|
2575
|
+
// key" here.
|
|
2576
|
+
if (this.apiKey && this.apiKey !== "oauth") return;
|
|
2577
|
+
|
|
2578
|
+
try {
|
|
2579
|
+
const { listOAuthProviderIds } = await import("../providers/auth/registry.js");
|
|
2580
|
+
const ids = await listOAuthProviderIds();
|
|
2581
|
+
if (!ids.includes(this.providerId)) return;
|
|
2582
|
+
|
|
2583
|
+
const effectiveBaseURL =
|
|
2584
|
+
this.baseURL &&
|
|
2585
|
+
this.baseURL !== (await import("../providers/endpoints.js").then((m) => m.apiBaseFor("anthropic")))
|
|
2586
|
+
? this.baseURL
|
|
2587
|
+
: undefined;
|
|
2588
|
+
const result = await createProviderFactoryAsync(this.providerId, {
|
|
2589
|
+
baseURL: effectiveBaseURL ?? undefined,
|
|
2590
|
+
});
|
|
2591
|
+
this.provider = result.factory;
|
|
2592
|
+
} catch {
|
|
2593
|
+
// Fail-open — provider remains null; requireProvider() will surface the error
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
|
|
3393
2597
|
async detectVerifyRecipe(settings?: SandboxSettings, abortSignal?: AbortSignal): Promise<VerifyRecipe | null> {
|
|
3394
2598
|
try {
|
|
3395
2599
|
const result = await this.runTaskRequest(
|
|
@@ -3435,531 +2639,3 @@ export class Agent {
|
|
|
3435
2639
|
}
|
|
3436
2640
|
}
|
|
3437
2641
|
}
|
|
3438
|
-
|
|
3439
|
-
interface ExecutedBatchTool {
|
|
3440
|
-
toolCall: ToolCall;
|
|
3441
|
-
input: unknown;
|
|
3442
|
-
toolResult: ToolResult;
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3445
|
-
type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
|
|
3446
|
-
|
|
3447
|
-
function extractJsonObject(text: string): string | null {
|
|
3448
|
-
const start = text.indexOf("{");
|
|
3449
|
-
const end = text.lastIndexOf("}");
|
|
3450
|
-
if (start < 0 || end < start) return null;
|
|
3451
|
-
return text.slice(start, end + 1);
|
|
3452
|
-
}
|
|
3453
|
-
|
|
3454
|
-
function buildBatchName(prefix: string, label: string): string {
|
|
3455
|
-
const compact =
|
|
3456
|
-
label
|
|
3457
|
-
.replace(/\s+/g, "-")
|
|
3458
|
-
.replace(/[^a-zA-Z0-9._-]+/g, "")
|
|
3459
|
-
.slice(0, 48) || "run";
|
|
3460
|
-
return `muonroi-cli-${prefix}-${compact}`;
|
|
3461
|
-
}
|
|
3462
|
-
|
|
3463
|
-
function buildBatchChatCompletionRequest(args: {
|
|
3464
|
-
modelId: string;
|
|
3465
|
-
system: string;
|
|
3466
|
-
messages: ModelMessage[];
|
|
3467
|
-
temperature: number;
|
|
3468
|
-
maxOutputTokens?: number;
|
|
3469
|
-
reasoningEffort?: BatchChatCompletionRequest["reasoning_effort"];
|
|
3470
|
-
tools: BatchFunctionTool[];
|
|
3471
|
-
}): BatchChatCompletionRequest {
|
|
3472
|
-
return {
|
|
3473
|
-
model: args.modelId,
|
|
3474
|
-
messages: toBatchChatMessages(args.system, args.messages),
|
|
3475
|
-
temperature: args.temperature,
|
|
3476
|
-
...(args.maxOutputTokens != null ? { max_completion_tokens: args.maxOutputTokens } : {}),
|
|
3477
|
-
...(args.reasoningEffort ? { reasoning_effort: args.reasoningEffort } : {}),
|
|
3478
|
-
...(args.tools.length > 0 ? { tools: args.tools } : {}),
|
|
3479
|
-
};
|
|
3480
|
-
}
|
|
3481
|
-
|
|
3482
|
-
function toBatchChatMessages(system: string, messages: ModelMessage[]): BatchChatMessage[] {
|
|
3483
|
-
const batchMessages: BatchChatMessage[] = [{ role: "system", content: system }];
|
|
3484
|
-
|
|
3485
|
-
for (const message of messages) {
|
|
3486
|
-
const { role, content } = message;
|
|
3487
|
-
|
|
3488
|
-
switch (role) {
|
|
3489
|
-
case "system":
|
|
3490
|
-
batchMessages.push({ role: "system", content });
|
|
3491
|
-
break;
|
|
3492
|
-
|
|
3493
|
-
case "user": {
|
|
3494
|
-
if (typeof content === "string") {
|
|
3495
|
-
batchMessages.push({ role: "user", content });
|
|
3496
|
-
break;
|
|
3497
|
-
}
|
|
3498
|
-
|
|
3499
|
-
if (!Array.isArray(content)) {
|
|
3500
|
-
break;
|
|
3501
|
-
}
|
|
3502
|
-
|
|
3503
|
-
if (content.length === 1 && content[0]?.type === "text") {
|
|
3504
|
-
batchMessages.push({ role: "user", content: content[0].text });
|
|
3505
|
-
break;
|
|
3506
|
-
}
|
|
3507
|
-
|
|
3508
|
-
const userContent: Array<{ type: "text"; text: string } | { type: "image_url"; image_url: { url: string } }> =
|
|
3509
|
-
[];
|
|
3510
|
-
for (const part of content) {
|
|
3511
|
-
switch (part.type) {
|
|
3512
|
-
case "text":
|
|
3513
|
-
userContent.push({ type: "text", text: part.text });
|
|
3514
|
-
break;
|
|
3515
|
-
|
|
3516
|
-
case "image": {
|
|
3517
|
-
const mediaType = part.mediaType === "image/*" || !part.mediaType ? "image/jpeg" : part.mediaType;
|
|
3518
|
-
const data =
|
|
3519
|
-
part.image instanceof URL
|
|
3520
|
-
? part.image.toString()
|
|
3521
|
-
: `data:${mediaType};base64,${toBase64DataContent(part.image)}`;
|
|
3522
|
-
userContent.push({ type: "image_url", image_url: { url: data } });
|
|
3523
|
-
break;
|
|
3524
|
-
}
|
|
3525
|
-
|
|
3526
|
-
case "file": {
|
|
3527
|
-
if (!part.mediaType.startsWith("image/")) {
|
|
3528
|
-
break;
|
|
3529
|
-
}
|
|
3530
|
-
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
3531
|
-
const data =
|
|
3532
|
-
part.data instanceof URL
|
|
3533
|
-
? part.data.toString()
|
|
3534
|
-
: `data:${mediaType};base64,${toBase64DataContent(part.data)}`;
|
|
3535
|
-
userContent.push({ type: "image_url", image_url: { url: data } });
|
|
3536
|
-
break;
|
|
3537
|
-
}
|
|
3538
|
-
}
|
|
3539
|
-
}
|
|
3540
|
-
batchMessages.push({
|
|
3541
|
-
role: "user",
|
|
3542
|
-
content: userContent,
|
|
3543
|
-
});
|
|
3544
|
-
break;
|
|
3545
|
-
}
|
|
3546
|
-
|
|
3547
|
-
case "assistant": {
|
|
3548
|
-
if (typeof content === "string") {
|
|
3549
|
-
batchMessages.push({ role: "assistant", content });
|
|
3550
|
-
break;
|
|
3551
|
-
}
|
|
3552
|
-
|
|
3553
|
-
if (!Array.isArray(content)) {
|
|
3554
|
-
break;
|
|
3555
|
-
}
|
|
3556
|
-
|
|
3557
|
-
let assistantText = "";
|
|
3558
|
-
const toolCalls: BatchToolCall[] = [];
|
|
3559
|
-
for (const part of content) {
|
|
3560
|
-
if (part.type === "text") {
|
|
3561
|
-
assistantText += part.text;
|
|
3562
|
-
} else if (part.type === "tool-call") {
|
|
3563
|
-
toolCalls.push({
|
|
3564
|
-
id: part.toolCallId,
|
|
3565
|
-
type: "function",
|
|
3566
|
-
function: {
|
|
3567
|
-
name: part.toolName,
|
|
3568
|
-
arguments: JSON.stringify(part.input),
|
|
3569
|
-
},
|
|
3570
|
-
});
|
|
3571
|
-
}
|
|
3572
|
-
}
|
|
3573
|
-
|
|
3574
|
-
if (assistantText || toolCalls.length > 0) {
|
|
3575
|
-
batchMessages.push({
|
|
3576
|
-
role: "assistant",
|
|
3577
|
-
content: assistantText,
|
|
3578
|
-
...(toolCalls.length > 0 ? { tool_calls: toolCalls } : {}),
|
|
3579
|
-
});
|
|
3580
|
-
}
|
|
3581
|
-
break;
|
|
3582
|
-
}
|
|
3583
|
-
|
|
3584
|
-
case "tool":
|
|
3585
|
-
for (const part of content) {
|
|
3586
|
-
if (part.type === "tool-approval-response") {
|
|
3587
|
-
continue;
|
|
3588
|
-
}
|
|
3589
|
-
batchMessages.push({
|
|
3590
|
-
role: "tool",
|
|
3591
|
-
tool_call_id: part.toolCallId,
|
|
3592
|
-
content: toolOutputToText(part.output),
|
|
3593
|
-
});
|
|
3594
|
-
}
|
|
3595
|
-
break;
|
|
3596
|
-
}
|
|
3597
|
-
}
|
|
3598
|
-
|
|
3599
|
-
return batchMessages;
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3602
|
-
function toBase64DataContent(value: string | Uint8Array | ArrayBuffer): string {
|
|
3603
|
-
return convertToBase64(value instanceof ArrayBuffer ? new Uint8Array(value) : value);
|
|
3604
|
-
}
|
|
3605
|
-
|
|
3606
|
-
function toolOutputToText(output: {
|
|
3607
|
-
type: "text" | "json" | "execution-denied" | "error-text" | "error-json" | "content";
|
|
3608
|
-
value?: unknown;
|
|
3609
|
-
reason?: string;
|
|
3610
|
-
}): string {
|
|
3611
|
-
switch (output.type) {
|
|
3612
|
-
case "text":
|
|
3613
|
-
case "error-text":
|
|
3614
|
-
return String(output.value ?? "");
|
|
3615
|
-
case "execution-denied":
|
|
3616
|
-
return output.reason ?? "Tool execution denied.";
|
|
3617
|
-
case "json":
|
|
3618
|
-
case "error-json":
|
|
3619
|
-
case "content":
|
|
3620
|
-
return JSON.stringify(output.value ?? null);
|
|
3621
|
-
}
|
|
3622
|
-
}
|
|
3623
|
-
|
|
3624
|
-
function getBatchUsage(response: BatchChatCompletionResponse): ProcessMessageUsage {
|
|
3625
|
-
const usage = response.usage as BatchChatCompletionResponse["usage"] | undefined;
|
|
3626
|
-
const inputTokens = asNumber(usage?.input_tokens) ?? asNumber(usage?.prompt_tokens);
|
|
3627
|
-
const outputTokens = asNumber(usage?.output_tokens) ?? asNumber(usage?.completion_tokens);
|
|
3628
|
-
const totalTokens = asNumber(usage?.total_tokens) ?? sumDefined(inputTokens, outputTokens);
|
|
3629
|
-
const u = usage as Record<string, unknown> | undefined;
|
|
3630
|
-
return {
|
|
3631
|
-
inputTokens,
|
|
3632
|
-
outputTokens,
|
|
3633
|
-
totalTokens,
|
|
3634
|
-
costUsdTicks: asNumber(usage?.cost_in_usd_ticks),
|
|
3635
|
-
cacheReadTokens: asNumber(u?.cache_read_input_tokens),
|
|
3636
|
-
cacheCreationTokens: asNumber(u?.cache_creation_input_tokens),
|
|
3637
|
-
};
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3640
|
-
function accumulateUsage(target: ProcessMessageUsage, usage: ProcessMessageUsage): void {
|
|
3641
|
-
target.inputTokens = (target.inputTokens ?? 0) + (usage.inputTokens ?? 0);
|
|
3642
|
-
target.outputTokens = (target.outputTokens ?? 0) + (usage.outputTokens ?? 0);
|
|
3643
|
-
target.totalTokens = (target.totalTokens ?? 0) + (usage.totalTokens ?? 0);
|
|
3644
|
-
target.costUsdTicks = (target.costUsdTicks ?? 0) + (usage.costUsdTicks ?? 0);
|
|
3645
|
-
target.cacheReadTokens = (target.cacheReadTokens ?? 0) + (usage.cacheReadTokens ?? 0);
|
|
3646
|
-
target.cacheCreationTokens = (target.cacheCreationTokens ?? 0) + (usage.cacheCreationTokens ?? 0);
|
|
3647
|
-
}
|
|
3648
|
-
|
|
3649
|
-
function hasUsage(usage: ProcessMessageUsage): boolean {
|
|
3650
|
-
return Boolean(
|
|
3651
|
-
(usage.inputTokens ?? 0) || (usage.outputTokens ?? 0) || (usage.totalTokens ?? 0) || (usage.costUsdTicks ?? 0),
|
|
3652
|
-
);
|
|
3653
|
-
}
|
|
3654
|
-
|
|
3655
|
-
function getBatchFinishReason(finishReason: string | null | undefined): ProcessMessageFinishReason {
|
|
3656
|
-
switch (finishReason) {
|
|
3657
|
-
case "stop":
|
|
3658
|
-
case "length":
|
|
3659
|
-
case "content-filter":
|
|
3660
|
-
case "tool-calls":
|
|
3661
|
-
case "error":
|
|
3662
|
-
case "other":
|
|
3663
|
-
return finishReason;
|
|
3664
|
-
case "tool_calls":
|
|
3665
|
-
return "tool-calls";
|
|
3666
|
-
default:
|
|
3667
|
-
return "other";
|
|
3668
|
-
}
|
|
3669
|
-
}
|
|
3670
|
-
|
|
3671
|
-
function toLocalToolCall(toolCall: BatchToolCall): ToolCall {
|
|
3672
|
-
return {
|
|
3673
|
-
id: toolCall.id,
|
|
3674
|
-
type: "function",
|
|
3675
|
-
function: {
|
|
3676
|
-
name: toolCall.function.name,
|
|
3677
|
-
arguments: toolCall.function.arguments,
|
|
3678
|
-
},
|
|
3679
|
-
};
|
|
3680
|
-
}
|
|
3681
|
-
|
|
3682
|
-
function buildAssistantBatchMessage(content: string, toolCalls: ToolCall[]): ModelMessage | null {
|
|
3683
|
-
if (toolCalls.length === 0) {
|
|
3684
|
-
return content ? { role: "assistant", content } : null;
|
|
3685
|
-
}
|
|
3686
|
-
|
|
3687
|
-
const parts: Array<
|
|
3688
|
-
{ type: "text"; text: string } | { type: "tool-call"; toolCallId: string; toolName: string; input: unknown }
|
|
3689
|
-
> = [];
|
|
3690
|
-
if (content) {
|
|
3691
|
-
parts.push({ type: "text", text: content });
|
|
3692
|
-
}
|
|
3693
|
-
for (const toolCall of toolCalls) {
|
|
3694
|
-
parts.push({
|
|
3695
|
-
type: "tool-call",
|
|
3696
|
-
toolCallId: toolCall.id,
|
|
3697
|
-
toolName: toolCall.function.name,
|
|
3698
|
-
input: parseToolArgumentsOrRaw(toolCall.function.arguments),
|
|
3699
|
-
});
|
|
3700
|
-
}
|
|
3701
|
-
return { role: "assistant", content: parts };
|
|
3702
|
-
}
|
|
3703
|
-
|
|
3704
|
-
function buildToolBatchMessage(toolParts: ExecutedBatchTool[]): ModelMessage | null {
|
|
3705
|
-
if (toolParts.length === 0) {
|
|
3706
|
-
return null;
|
|
3707
|
-
}
|
|
3708
|
-
|
|
3709
|
-
return {
|
|
3710
|
-
role: "tool",
|
|
3711
|
-
content: toolParts.map((part) => ({
|
|
3712
|
-
type: "tool-result" as const,
|
|
3713
|
-
toolCallId: part.toolCall.id,
|
|
3714
|
-
toolName: part.toolCall.function.name,
|
|
3715
|
-
output: part.toolResult.success
|
|
3716
|
-
? ({ type: "json", value: toSerializableValue(part.toolResult) } as const)
|
|
3717
|
-
: ({ type: "error-json", value: toSerializableValue(part.toolResult) } as const),
|
|
3718
|
-
})),
|
|
3719
|
-
};
|
|
3720
|
-
}
|
|
3721
|
-
|
|
3722
|
-
function parseToolArgumentsOrRaw(raw: string): unknown {
|
|
3723
|
-
try {
|
|
3724
|
-
return raw.trim() ? JSON.parse(raw) : {};
|
|
3725
|
-
} catch {
|
|
3726
|
-
return raw;
|
|
3727
|
-
}
|
|
3728
|
-
}
|
|
3729
|
-
|
|
3730
|
-
function toSerializableValue(value: unknown): JsonValue {
|
|
3731
|
-
try {
|
|
3732
|
-
return JSON.parse(JSON.stringify(value ?? null)) as JsonValue;
|
|
3733
|
-
} catch {
|
|
3734
|
-
return String(value);
|
|
3735
|
-
}
|
|
3736
|
-
}
|
|
3737
|
-
|
|
3738
|
-
function asNumber(value: unknown): number | undefined {
|
|
3739
|
-
return typeof value === "number" ? value : undefined;
|
|
3740
|
-
}
|
|
3741
|
-
|
|
3742
|
-
function sumDefined(left?: number, right?: number): number | undefined {
|
|
3743
|
-
if (left == null && right == null) {
|
|
3744
|
-
return undefined;
|
|
3745
|
-
}
|
|
3746
|
-
return (left ?? 0) + (right ?? 0);
|
|
3747
|
-
}
|
|
3748
|
-
|
|
3749
|
-
function toToolCall(part: { toolCallId: string; toolName: string; args?: unknown; input?: unknown }): ToolCall {
|
|
3750
|
-
return {
|
|
3751
|
-
id: part.toolCallId,
|
|
3752
|
-
type: "function",
|
|
3753
|
-
function: {
|
|
3754
|
-
name: part.toolName,
|
|
3755
|
-
arguments: JSON.stringify(part.input ?? part.args ?? {}),
|
|
3756
|
-
},
|
|
3757
|
-
};
|
|
3758
|
-
}
|
|
3759
|
-
|
|
3760
|
-
function notifyObserver<T>(listener: ((payload: T) => void) | undefined, payload: T): void {
|
|
3761
|
-
if (!listener) {
|
|
3762
|
-
return;
|
|
3763
|
-
}
|
|
3764
|
-
|
|
3765
|
-
try {
|
|
3766
|
-
listener(payload);
|
|
3767
|
-
} catch {
|
|
3768
|
-
// Observer failures should never break generation.
|
|
3769
|
-
}
|
|
3770
|
-
}
|
|
3771
|
-
|
|
3772
|
-
function getStepNumber(event: unknown, fallback: number): number {
|
|
3773
|
-
if (event && typeof event === "object" && "stepNumber" in event && typeof event.stepNumber === "number") {
|
|
3774
|
-
return event.stepNumber;
|
|
3775
|
-
}
|
|
3776
|
-
|
|
3777
|
-
return fallback;
|
|
3778
|
-
}
|
|
3779
|
-
|
|
3780
|
-
function getFinishReason(event: unknown): ProcessMessageFinishReason {
|
|
3781
|
-
if (event && typeof event === "object" && "finishReason" in event) {
|
|
3782
|
-
switch (event.finishReason) {
|
|
3783
|
-
case "stop":
|
|
3784
|
-
case "length":
|
|
3785
|
-
case "content-filter":
|
|
3786
|
-
case "tool-calls":
|
|
3787
|
-
case "error":
|
|
3788
|
-
case "other":
|
|
3789
|
-
return event.finishReason;
|
|
3790
|
-
}
|
|
3791
|
-
}
|
|
3792
|
-
|
|
3793
|
-
return "other";
|
|
3794
|
-
}
|
|
3795
|
-
|
|
3796
|
-
function getUsage(event: unknown): ProcessMessageUsage {
|
|
3797
|
-
if (!(event && typeof event === "object" && "usage" in event)) {
|
|
3798
|
-
return {};
|
|
3799
|
-
}
|
|
3800
|
-
|
|
3801
|
-
const usage = event.usage;
|
|
3802
|
-
if (!usage || typeof usage !== "object") {
|
|
3803
|
-
return {};
|
|
3804
|
-
}
|
|
3805
|
-
|
|
3806
|
-
const u = usage as Record<string, unknown>;
|
|
3807
|
-
return {
|
|
3808
|
-
inputTokens: typeof u.inputTokens === "number" ? u.inputTokens : undefined,
|
|
3809
|
-
outputTokens: typeof u.outputTokens === "number" ? u.outputTokens : undefined,
|
|
3810
|
-
totalTokens: typeof u.totalTokens === "number" ? u.totalTokens : undefined,
|
|
3811
|
-
cacheReadTokens: typeof u.cacheReadTokens === "number" ? u.cacheReadTokens : undefined,
|
|
3812
|
-
cacheCreationTokens: typeof u.cacheCreationTokens === "number" ? u.cacheCreationTokens : undefined,
|
|
3813
|
-
};
|
|
3814
|
-
}
|
|
3815
|
-
|
|
3816
|
-
function toToolResult(output: unknown): ToolResult {
|
|
3817
|
-
if (output && typeof output === "object" && "success" in output) {
|
|
3818
|
-
const r = output as {
|
|
3819
|
-
success: boolean;
|
|
3820
|
-
output?: string;
|
|
3821
|
-
error?: string;
|
|
3822
|
-
diff?: ToolResult["diff"];
|
|
3823
|
-
plan?: Plan;
|
|
3824
|
-
task?: ToolResult["task"];
|
|
3825
|
-
delegation?: ToolResult["delegation"];
|
|
3826
|
-
backgroundProcess?: ToolResult["backgroundProcess"];
|
|
3827
|
-
media?: ToolResult["media"];
|
|
3828
|
-
computer?: ToolResult["computer"];
|
|
3829
|
-
lspDiagnostics?: ToolResult["lspDiagnostics"];
|
|
3830
|
-
};
|
|
3831
|
-
return {
|
|
3832
|
-
success: r.success,
|
|
3833
|
-
output: r.output,
|
|
3834
|
-
error: r.error ?? (r.success ? undefined : r.output),
|
|
3835
|
-
diff: r.diff,
|
|
3836
|
-
plan: r.plan,
|
|
3837
|
-
task: r.task,
|
|
3838
|
-
delegation: r.delegation,
|
|
3839
|
-
backgroundProcess: r.backgroundProcess,
|
|
3840
|
-
media: r.media,
|
|
3841
|
-
computer: r.computer,
|
|
3842
|
-
lspDiagnostics: r.lspDiagnostics,
|
|
3843
|
-
};
|
|
3844
|
-
}
|
|
3845
|
-
return { success: true, output: String(output) };
|
|
3846
|
-
}
|
|
3847
|
-
|
|
3848
|
-
function formatSubagentActivity(toolName: string, args?: unknown): string {
|
|
3849
|
-
const parsed = parseToolArgs(args);
|
|
3850
|
-
if (toolName === "read_file") return `Read ${parsed.path || "file"}`;
|
|
3851
|
-
if (toolName === "lsp") return `LSP ${parsed.operation || "query"} ${parsed.filePath || ""}`.trim();
|
|
3852
|
-
if (toolName === "write_file") return `Write ${parsed.path || "file"}`;
|
|
3853
|
-
if (toolName === "edit_file") return `Edit ${parsed.path || "file"}`;
|
|
3854
|
-
if (toolName === "search_web") return `Web search "${truncate(parsed.query || "", 50)}"`;
|
|
3855
|
-
if (toolName === "search_x") return `X search "${truncate(parsed.query || "", 50)}"`;
|
|
3856
|
-
if (toolName === "generate_image") return `Generate image "${truncate(parsed.prompt || "", 50)}"`;
|
|
3857
|
-
if (toolName === "generate_video") return `Generate video "${truncate(parsed.prompt || "", 50)}"`;
|
|
3858
|
-
if (toolName === "computer_snapshot") return `Snapshot ${parsed.app || "desktop"}`;
|
|
3859
|
-
if (toolName === "computer_screenshot") return "Capture desktop screenshot";
|
|
3860
|
-
if (toolName === "computer_click")
|
|
3861
|
-
return parsed.ref ? `Click ${parsed.ref}` : `Click at ${parsed.x || "?"},${parsed.y || "?"}`;
|
|
3862
|
-
if (toolName === "computer_mouse_move")
|
|
3863
|
-
return parsed.ref ? `Hover ${parsed.ref}` : `Move mouse to ${parsed.x || "?"},${parsed.y || "?"}`;
|
|
3864
|
-
if (toolName === "computer_type") return `Type into ${parsed.ref || "element"}`;
|
|
3865
|
-
if (toolName === "computer_press") return `Press ${parsed.key || "key"}`;
|
|
3866
|
-
if (toolName === "computer_scroll") return `Scroll ${parsed.ref || "element"} ${parsed.direction || "down"}`;
|
|
3867
|
-
if (toolName === "computer_launch") return `Launch ${parsed.app || "app"}`;
|
|
3868
|
-
if (toolName === "computer_list_windows") return `List windows${parsed.app ? ` for ${parsed.app}` : ""}`;
|
|
3869
|
-
if (toolName === "computer_focus_window")
|
|
3870
|
-
return `Focus window ${parsed.window_id || parsed.title || parsed.app || ""}`.trim();
|
|
3871
|
-
if (toolName === "computer_wait") return "Wait for desktop state";
|
|
3872
|
-
if (toolName === "computer_get") return `Read ${parsed.property || "text"} from ${parsed.ref || "element"}`;
|
|
3873
|
-
if (toolName === "bash") return truncate(parsed.command || "Run command", 70);
|
|
3874
|
-
return truncate(`${toolName}`, 70);
|
|
3875
|
-
}
|
|
3876
|
-
|
|
3877
|
-
function parseToolArgs(args: unknown): Record<string, string> {
|
|
3878
|
-
if (!args || typeof args !== "object") return {};
|
|
3879
|
-
const result: Record<string, string> = {};
|
|
3880
|
-
for (const [key, value] of Object.entries(args)) {
|
|
3881
|
-
result[key] = typeof value === "string" ? value : JSON.stringify(value);
|
|
3882
|
-
}
|
|
3883
|
-
return result;
|
|
3884
|
-
}
|
|
3885
|
-
|
|
3886
|
-
function firstLine(text: string): string {
|
|
3887
|
-
return text.trim().split("\n").find(Boolean)?.trim() || "Task completed.";
|
|
3888
|
-
}
|
|
3889
|
-
|
|
3890
|
-
function truncate(text: string, max: number): string {
|
|
3891
|
-
return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
|
|
3892
|
-
}
|
|
3893
|
-
|
|
3894
|
-
function combineAbortSignals(...signals: Array<AbortSignal | undefined>): AbortSignal | undefined {
|
|
3895
|
-
const activeSignals = signals.filter((signal): signal is AbortSignal => Boolean(signal));
|
|
3896
|
-
if (activeSignals.length === 0) return undefined;
|
|
3897
|
-
if (activeSignals.length === 1) return activeSignals[0];
|
|
3898
|
-
|
|
3899
|
-
if (typeof AbortSignal.any === "function") {
|
|
3900
|
-
return AbortSignal.any(activeSignals);
|
|
3901
|
-
}
|
|
3902
|
-
|
|
3903
|
-
const controller = new AbortController();
|
|
3904
|
-
for (const signal of activeSignals) {
|
|
3905
|
-
if (signal.aborted) {
|
|
3906
|
-
controller.abort();
|
|
3907
|
-
break;
|
|
3908
|
-
}
|
|
3909
|
-
|
|
3910
|
-
signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
3911
|
-
}
|
|
3912
|
-
|
|
3913
|
-
return controller.signal;
|
|
3914
|
-
}
|
|
3915
|
-
|
|
3916
|
-
function isContextLimitError(error: unknown): boolean {
|
|
3917
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3918
|
-
return /(context|token|prompt).*(limit|length|large|window|overflow)|too many tokens|maximum context/i.test(message);
|
|
3919
|
-
}
|
|
3920
|
-
|
|
3921
|
-
function isAuthenticationError(error: unknown): boolean {
|
|
3922
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3923
|
-
return /\b(401|403)\b|unauthori[sz]ed|invalid.*(api[_ ]?key|token|credential)|authentication failed|forbidden|access denied/i.test(
|
|
3924
|
-
message,
|
|
3925
|
-
);
|
|
3926
|
-
}
|
|
3927
|
-
|
|
3928
|
-
const STATUS_MESSAGES: Record<number, string> = {
|
|
3929
|
-
400: "The request was invalid. This may be caused by an unsupported parameter or model.",
|
|
3930
|
-
401: "Authentication failed. Your API key may be invalid or expired.",
|
|
3931
|
-
403: "Access denied. Your API key does not have permission for this request.",
|
|
3932
|
-
404: "The requested model or endpoint was not found. Check your model name and base URL.",
|
|
3933
|
-
408: "The request timed out. Please try again.",
|
|
3934
|
-
422: "The request could not be processed. Check your message format or parameters.",
|
|
3935
|
-
429: "Rate limit exceeded. Please wait a moment and try again.",
|
|
3936
|
-
500: "The API server encountered an internal error. Please try again later.",
|
|
3937
|
-
502: "The API server is temporarily unavailable. Please try again later.",
|
|
3938
|
-
503: "The API service is temporarily overloaded. Please try again later.",
|
|
3939
|
-
529: "The API service is overloaded. Please try again later.",
|
|
3940
|
-
};
|
|
3941
|
-
|
|
3942
|
-
function humanizeApiError(error: unknown): string {
|
|
3943
|
-
if (APICallError.isInstance(error)) {
|
|
3944
|
-
const detail = extractResponseDetail(error.responseBody);
|
|
3945
|
-
if (detail) return detail;
|
|
3946
|
-
if (error.statusCode && STATUS_MESSAGES[error.statusCode]) {
|
|
3947
|
-
return STATUS_MESSAGES[error.statusCode];
|
|
3948
|
-
}
|
|
3949
|
-
}
|
|
3950
|
-
|
|
3951
|
-
const raw = error instanceof Error ? error.message : String(error);
|
|
3952
|
-
return raw.replace(/^AI_\w+Error:\s*/i, "").trim() || raw;
|
|
3953
|
-
}
|
|
3954
|
-
|
|
3955
|
-
function extractResponseDetail(body: string | undefined): string | null {
|
|
3956
|
-
if (!body) return null;
|
|
3957
|
-
try {
|
|
3958
|
-
const parsed = JSON.parse(body);
|
|
3959
|
-
const msg = parsed?.error?.message ?? parsed?.message ?? parsed?.detail;
|
|
3960
|
-
if (typeof msg === "string" && msg.trim()) return msg.trim();
|
|
3961
|
-
} catch {
|
|
3962
|
-
/* not JSON */
|
|
3963
|
-
}
|
|
3964
|
-
return null;
|
|
3965
|
-
}
|