@phuetz/code-buddy 1.6.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +90 -21
- package/README.fr.md +56 -0
- package/README.md +183 -330
- package/codebuddy-runtime.json +24 -0
- package/dist/advanced/session-replay.js +3 -2
- package/dist/agent/agent-state.d.ts +4 -1
- package/dist/agent/agent-state.js +9 -3
- package/dist/agent/architect-mode.js +1 -1
- package/dist/agent/autonomous/agentic-coding-contract.d.ts +28 -28
- package/dist/agent/autonomous/agentic-coding-runner.d.ts +14 -4
- package/dist/agent/autonomous/agentic-coding-runner.js +176 -27
- package/dist/agent/autonomous/checkpoint-manager.js +3 -12
- package/dist/agent/autonomous/codex-autonomy-directive.d.ts +10 -0
- package/dist/agent/autonomous/codex-autonomy-directive.js +25 -0
- package/dist/agent/autonomous/edit-proposal-producer.js +2 -2
- package/dist/agent/autonomous/fleet-task-types.d.ts +2 -2
- package/dist/agent/autonomous/fleet-task-types.js +2 -2
- package/dist/agent/autonomous/fleet-tick-handler.d.ts +3 -3
- package/dist/agent/autonomous/fleet-tick-handler.js +14 -8
- package/dist/agent/autonomous/recursive-improvement.d.ts +23 -0
- package/dist/agent/autonomous/recursive-improvement.js +114 -0
- package/dist/agent/autonomous/verification-loop.js +4 -2
- package/dist/agent/codebuddy-agent.d.ts +111 -6
- package/dist/agent/codebuddy-agent.js +491 -60
- package/dist/agent/council-lesson-proposer.d.ts +80 -13
- package/dist/agent/council-lesson-proposer.js +201 -43
- package/dist/agent/deep-research-ckg.d.ts +176 -0
- package/dist/agent/deep-research-ckg.js +250 -0
- package/dist/agent/deep-research-storm.d.ts +222 -0
- package/dist/agent/deep-research-storm.js +689 -0
- package/dist/agent/deep-research.d.ts +329 -0
- package/dist/agent/deep-research.js +994 -0
- package/dist/agent/delegation/thread-delegation.d.ts +80 -0
- package/dist/agent/delegation/thread-delegation.js +472 -0
- package/dist/agent/delegation/thread-task-runner.d.ts +37 -0
- package/dist/agent/delegation/thread-task-runner.js +89 -0
- package/dist/agent/dev-loop/dev-loop.d.ts +120 -0
- package/dist/agent/dev-loop/dev-loop.js +404 -0
- package/dist/agent/dev-loop/structural-gate.d.ts +32 -0
- package/dist/agent/dev-loop/structural-gate.js +120 -0
- package/dist/agent/execution/agent-executor.d.ts +52 -40
- package/dist/agent/execution/agent-executor.js +1669 -543
- package/dist/agent/execution/context-pipeline.d.ts +63 -6
- package/dist/agent/execution/context-pipeline.js +347 -88
- package/dist/agent/execution/incremental-token-counter.d.ts +15 -0
- package/dist/agent/execution/incremental-token-counter.js +36 -0
- package/dist/agent/execution/ordered-tool-executor.d.ts +14 -0
- package/dist/agent/execution/ordered-tool-executor.js +54 -0
- package/dist/agent/execution/post-tool-handlers.d.ts +1 -1
- package/dist/agent/execution/post-tool-handlers.js +2 -2
- package/dist/agent/execution/query-classifier.d.ts +2 -0
- package/dist/agent/execution/query-classifier.js +2 -0
- package/dist/agent/execution/tool-dependency-graph.js +7 -0
- package/dist/agent/execution/tool-loop-guard.d.ts +76 -0
- package/dist/agent/execution/tool-loop-guard.js +165 -0
- package/dist/agent/execution/tool-selection-strategy.d.ts +20 -0
- package/dist/agent/execution/tool-selection-strategy.js +162 -23
- package/dist/agent/facades/message-history-manager.d.ts +1 -1
- package/dist/agent/facades/message-history-manager.js +1 -1
- package/dist/agent/facades/model-routing-facade.d.ts +31 -1
- package/dist/agent/facades/model-routing-facade.js +86 -2
- package/dist/agent/facades/session-facade.d.ts +10 -8
- package/dist/agent/facades/session-facade.js +58 -45
- package/dist/agent/film/film-producer.d.ts +98 -0
- package/dist/agent/film/film-producer.js +289 -0
- package/dist/agent/film/scene-planner.d.ts +38 -0
- package/dist/agent/film/scene-planner.js +93 -0
- package/dist/agent/film/trailer-planner.d.ts +23 -0
- package/dist/agent/film/trailer-planner.js +242 -0
- package/dist/agent/film/video-studio.d.ts +72 -0
- package/dist/agent/film/video-studio.js +249 -0
- package/dist/agent/flow/planning-flow.d.ts +3 -0
- package/dist/agent/flow/planning-flow.js +70 -8
- package/dist/agent/hermes-claw-migrate.d.ts +62 -21
- package/dist/agent/hermes-claw-migrate.js +196 -17
- package/dist/agent/hermes-memory-providers.js +3 -3
- package/dist/agent/hermes-parity-manifest.js +69 -15
- package/dist/agent/hermes-protocol-gateways.js +8 -1
- package/dist/agent/infrastructure/agent-infrastructure.d.ts +1 -0
- package/dist/agent/infrastructure/agent-infrastructure.js +1 -1
- package/dist/agent/isolation/agent-workspace.js +5 -2
- package/dist/agent/learning/skill-background-writes.js +9 -4
- package/dist/agent/learning-agent.js +4 -4
- package/dist/agent/learning-background-writes.js +9 -5
- package/dist/agent/lesson-candidate-queue.d.ts +4 -0
- package/dist/agent/lesson-candidate-queue.js +9 -3
- package/dist/agent/lesson-provenance.js +9 -3
- package/dist/agent/lessons-tracker.d.ts +68 -1
- package/dist/agent/lessons-tracker.js +218 -36
- package/dist/agent/loop-detection-service.d.ts +56 -0
- package/dist/agent/loop-detection-service.js +207 -0
- package/dist/agent/middleware/auto-observation.d.ts +2 -0
- package/dist/agent/middleware/auto-observation.js +4 -2
- package/dist/agent/middleware/auto-repair-middleware.d.ts +2 -0
- package/dist/agent/middleware/auto-repair-middleware.js +27 -4
- package/dist/agent/middleware/changed-files.d.ts +19 -0
- package/dist/agent/middleware/changed-files.js +113 -0
- package/dist/agent/middleware/cost-limit.d.ts +0 -2
- package/dist/agent/middleware/cost-limit.js +0 -3
- package/dist/agent/middleware/index.d.ts +2 -0
- package/dist/agent/middleware/index.js +1 -0
- package/dist/agent/middleware/pipeline.d.ts +9 -0
- package/dist/agent/middleware/pipeline.js +18 -0
- package/dist/agent/middleware/plan-completion-audit.d.ts +76 -0
- package/dist/agent/middleware/plan-completion-audit.js +157 -0
- package/dist/agent/middleware/quality-gate-middleware.d.ts +43 -1
- package/dist/agent/middleware/quality-gate-middleware.js +198 -40
- package/dist/agent/middleware/types.d.ts +6 -0
- package/dist/agent/middleware/verification-enforcement.d.ts +10 -3
- package/dist/agent/middleware/verification-enforcement.js +43 -13
- package/dist/agent/middleware/workflow-guard.js +7 -0
- package/dist/agent/model-benchmark.js +11 -17
- package/dist/agent/model-tier.d.ts +2 -2
- package/dist/agent/model-tier.js +10 -7
- package/dist/agent/multi-agent/agent-memory-integration.js +3 -2
- package/dist/agent/multi-agent/base-agent.d.ts +12 -1
- package/dist/agent/multi-agent/base-agent.js +58 -10
- package/dist/agent/multi-agent/enhanced-coordination.js +1 -0
- package/dist/agent/multi-agent/metrics-persistence.js +28 -14
- package/dist/agent/multi-agent/multi-agent-system.d.ts +5 -0
- package/dist/agent/multi-agent/multi-agent-system.js +81 -4
- package/dist/agent/multi-agent/session-fleet-bridge.js +2 -1
- package/dist/agent/multi-agent/session-registry.js +9 -3
- package/dist/agent/multi-agent/team-manager.d.ts +11 -0
- package/dist/agent/multi-agent/team-manager.js +94 -5
- package/dist/agent/multi-agent/types.d.ts +10 -1
- package/dist/agent/multi-agent/workflow-multi-persistence.js +16 -8
- package/dist/agent/multi-agent/workflow-persistence.js +9 -6
- package/dist/agent/observer/trigger-registry.js +3 -5
- package/dist/agent/operating-modes.d.ts +3 -0
- package/dist/agent/operating-modes.js +15 -22
- package/dist/agent/pipelines.d.ts +2 -4
- package/dist/agent/pipelines.js +1 -1
- package/dist/agent/plan-mode.js +1 -1
- package/dist/agent/prompt-suggestions.js +2 -1
- package/dist/agent/prompt-tool-observation.d.ts +55 -0
- package/dist/agent/prompt-tool-observation.js +165 -0
- package/dist/agent/reasoning/tree-of-thought.js +1 -1
- package/dist/agent/repair/repair-engine.js +1 -1
- package/dist/agent/repo-profiler.d.ts +12 -1
- package/dist/agent/repo-profiler.js +37 -18
- package/dist/agent/repo-profiling/cache.js +6 -9
- package/dist/agent/research-worker-provider.d.ts +38 -0
- package/dist/agent/research-worker-provider.js +30 -0
- package/dist/agent/science/experiment-decision.d.ts +48 -0
- package/dist/agent/science/experiment-decision.js +65 -0
- package/dist/agent/science/experiment-empirical-gate.d.ts +83 -0
- package/dist/agent/science/experiment-empirical-gate.js +156 -0
- package/dist/agent/science/experiment-fitness.d.ts +112 -0
- package/dist/agent/science/experiment-fitness.js +188 -0
- package/dist/agent/science/experiment-loop.d.ts +196 -0
- package/dist/agent/science/experiment-loop.js +765 -0
- package/dist/agent/science/experiment-orchestrator.d.ts +203 -0
- package/dist/agent/science/experiment-orchestrator.js +454 -0
- package/dist/agent/science/experiment-sandbox-backends.d.ts +56 -0
- package/dist/agent/science/experiment-sandbox-backends.js +201 -0
- package/dist/agent/science/experiment-sandbox.d.ts +105 -0
- package/dist/agent/science/experiment-sandbox.js +196 -0
- package/dist/agent/science/experiment-variant-store.d.ts +108 -0
- package/dist/agent/science/experiment-variant-store.js +156 -0
- package/dist/agent/science/human-gate.d.ts +31 -0
- package/dist/agent/science/human-gate.js +32 -0
- package/dist/agent/self-improvement/authored-artifact-gate.js +28 -3
- package/dist/agent/self-improvement/authored-tool-runtime.d.ts +4 -2
- package/dist/agent/self-improvement/authored-tool-runtime.js +16 -3
- package/dist/agent/self-improvement/authored-tool-store.js +3 -2
- package/dist/agent/self-improvement/capability-benchmark.js +89 -2
- package/dist/agent/self-improvement/continuous-benchmark.d.ts +105 -0
- package/dist/agent/self-improvement/continuous-benchmark.js +355 -0
- package/dist/agent/self-improvement/delegation-facts.d.ts +105 -0
- package/dist/agent/self-improvement/delegation-facts.js +483 -0
- package/dist/agent/self-improvement/digest-sources.d.ts +56 -0
- package/dist/agent/self-improvement/digest-sources.js +294 -0
- package/dist/agent/self-improvement/digest.d.ts +169 -0
- package/dist/agent/self-improvement/digest.js +543 -0
- package/dist/agent/self-improvement/engine.d.ts +11 -6
- package/dist/agent/self-improvement/engine.js +13 -7
- package/dist/agent/self-improvement/evolution/ast-novelty.d.ts +25 -0
- package/dist/agent/self-improvement/evolution/ast-novelty.js +116 -0
- package/dist/agent/self-improvement/evolution/code-variant-store.d.ts +104 -0
- package/dist/agent/self-improvement/evolution/code-variant-store.js +229 -0
- package/dist/agent/self-improvement/evolution/evolution-engine.d.ts +199 -0
- package/dist/agent/self-improvement/evolution/evolution-engine.js +505 -0
- package/dist/agent/self-improvement/evolution/feature-map.d.ts +24 -0
- package/dist/agent/self-improvement/evolution/feature-map.js +88 -0
- package/dist/agent/self-improvement/evolution/model-bandit.d.ts +57 -0
- package/dist/agent/self-improvement/evolution/model-bandit.js +98 -0
- package/dist/agent/self-improvement/evolution/protected-paths.d.ts +31 -0
- package/dist/agent/self-improvement/evolution/protected-paths.js +111 -0
- package/dist/agent/self-improvement/evolution/research-weakness-source.d.ts +56 -0
- package/dist/agent/self-improvement/evolution/research-weakness-source.js +161 -0
- package/dist/agent/self-improvement/evolution/scrub-env.d.ts +22 -0
- package/dist/agent/self-improvement/evolution/scrub-env.js +40 -0
- package/dist/agent/self-improvement/evolution/variant-fitness.d.ts +97 -0
- package/dist/agent/self-improvement/evolution/variant-fitness.js +343 -0
- package/dist/agent/self-improvement/evolution/variant-planner.d.ts +41 -0
- package/dist/agent/self-improvement/evolution/variant-planner.js +156 -0
- package/dist/agent/self-improvement/evolution/weakness-selector.d.ts +38 -0
- package/dist/agent/self-improvement/evolution/weakness-selector.js +108 -0
- package/dist/agent/self-improvement/evolution/worktree-scorer.d.ts +46 -0
- package/dist/agent/self-improvement/evolution/worktree-scorer.js +114 -0
- package/dist/agent/self-improvement/evolutionary-archive.d.ts +2 -1
- package/dist/agent/self-improvement/evolutionary-archive.js +37 -7
- package/dist/agent/self-improvement/experience-source.d.ts +60 -7
- package/dist/agent/self-improvement/experience-source.js +78 -8
- package/dist/agent/self-improvement/index.d.ts +1 -0
- package/dist/agent/self-improvement/index.js +6 -3
- package/dist/agent/self-improvement/learning-store.d.ts +16 -0
- package/dist/agent/self-improvement/learning-store.js +83 -3
- package/dist/agent/self-improvement/llm-drafter.d.ts +3 -1
- package/dist/agent/self-improvement/llm-drafter.js +20 -2
- package/dist/agent/self-improvement/llm-tool-proposer.js +1 -1
- package/dist/agent/self-improvement/proposal-store.d.ts +47 -0
- package/dist/agent/self-improvement/proposal-store.js +149 -0
- package/dist/agent/self-improvement/proposer.d.ts +1 -1
- package/dist/agent/self-improvement/proposer.js +94 -2
- package/dist/agent/self-improvement/rule-store.js +5 -4
- package/dist/agent/self-improvement/sandbox-scorer.d.ts +1 -1
- package/dist/agent/self-improvement/sandbox-scorer.js +8 -4
- package/dist/agent/self-improvement/self-knowledge.d.ts +1 -1
- package/dist/agent/self-improvement/self-knowledge.js +8 -8
- package/dist/agent/self-improvement/skill-apply-journal.d.ts +44 -0
- package/dist/agent/self-improvement/skill-apply-journal.js +178 -0
- package/dist/agent/self-improvement/skill-behavior-benchmark.d.ts +3 -0
- package/dist/agent/self-improvement/skill-behavior-benchmark.js +19 -0
- package/dist/agent/self-improvement/skill-behavior-gate.d.ts +34 -0
- package/dist/agent/self-improvement/skill-behavior-gate.js +96 -0
- package/dist/agent/self-improvement/skill-benchmark.js +27 -0
- package/dist/agent/self-improvement/skill-consolidator.js +16 -0
- package/dist/agent/self-improvement/skill-engine.d.ts +29 -0
- package/dist/agent/self-improvement/skill-engine.js +428 -30
- package/dist/agent/self-improvement/skill-gate.d.ts +6 -4
- package/dist/agent/self-improvement/skill-gate.js +55 -22
- package/dist/agent/self-improvement/skill-mutator.d.ts +26 -2
- package/dist/agent/self-improvement/skill-mutator.js +185 -30
- package/dist/agent/self-improvement/skill-proposer.js +2 -1
- package/dist/agent/self-improvement/skill-types.d.ts +6 -1
- package/dist/agent/self-improvement/strategy-engine.d.ts +54 -0
- package/dist/agent/self-improvement/strategy-engine.js +104 -0
- package/dist/agent/self-improvement/strategy-gate.d.ts +49 -0
- package/dist/agent/self-improvement/strategy-gate.js +243 -0
- package/dist/agent/self-improvement/strategy-live.d.ts +39 -0
- package/dist/agent/self-improvement/strategy-live.js +114 -0
- package/dist/agent/self-improvement/strategy-proposer.d.ts +30 -0
- package/dist/agent/self-improvement/strategy-proposer.js +114 -0
- package/dist/agent/self-improvement/strategy-replay.d.ts +40 -0
- package/dist/agent/self-improvement/strategy-replay.js +150 -0
- package/dist/agent/self-improvement/strategy-runtime.d.ts +43 -0
- package/dist/agent/self-improvement/strategy-runtime.js +56 -0
- package/dist/agent/self-improvement/strategy-store.d.ts +38 -0
- package/dist/agent/self-improvement/strategy-store.js +139 -0
- package/dist/agent/self-improvement/strategy-types.d.ts +229 -0
- package/dist/agent/self-improvement/strategy-types.js +90 -0
- package/dist/agent/self-improvement/tool-benchmark.js +164 -8
- package/dist/agent/self-improvement/tool-engine.d.ts +12 -3
- package/dist/agent/self-improvement/tool-engine.js +59 -31
- package/dist/agent/self-improvement/tool-gate.d.ts +2 -0
- package/dist/agent/self-improvement/tool-gate.js +26 -0
- package/dist/agent/self-improvement/tool-skill-mutator.d.ts +1 -1
- package/dist/agent/self-improvement/tool-skill-mutator.js +20 -2
- package/dist/agent/self-improvement/tool-types.d.ts +5 -3
- package/dist/agent/self-improvement/types.d.ts +18 -3
- package/dist/agent/session-end-flush.js +2 -1
- package/dist/agent/specialized/agent-registry.d.ts +1 -0
- package/dist/agent/specialized/agent-registry.js +118 -0
- package/dist/agent/specialized/excel-agent.js +15 -1
- package/dist/agent/specialized/index.d.ts +1 -0
- package/dist/agent/specialized/index.js +2 -0
- package/dist/agent/specialized/pdf-agent.js +4 -2
- package/dist/agent/specialized/swe-agent-adapter.js +8 -0
- package/dist/agent/specialized/swe-agent.d.ts +16 -1
- package/dist/agent/specialized/swe-agent.js +75 -7
- package/dist/agent/specialized/types.d.ts +31 -1
- package/dist/agent/specialized/types.js +26 -0
- package/dist/agent/specialized/verifier-agent.d.ts +53 -0
- package/dist/agent/specialized/verifier-agent.js +342 -0
- package/dist/agent/streaming/message-reducer.js +73 -19
- package/dist/agent/streaming/streaming-handler.d.ts +24 -0
- package/dist/agent/streaming/streaming-handler.js +136 -1
- package/dist/agent/subagents.d.ts +10 -4
- package/dist/agent/subagents.js +39 -6
- package/dist/agent/thinking/extended-thinking.js +1 -1
- package/dist/agent/todo-tracker.js +5 -4
- package/dist/agent/tool-executor.d.ts +10 -1
- package/dist/agent/tool-executor.js +29 -0
- package/dist/agent/tool-handler.d.ts +50 -3
- package/dist/agent/tool-handler.js +758 -182
- package/dist/agent/types.d.ts +3 -5
- package/dist/agent/wide-research-checkpoint.d.ts +77 -0
- package/dist/agent/wide-research-checkpoint.js +361 -0
- package/dist/agent/wide-research-files.d.ts +11 -0
- package/dist/agent/wide-research-files.js +189 -0
- package/dist/agent/wide-research.d.ts +148 -3
- package/dist/agent/wide-research.js +833 -56
- package/dist/analytics/code-evolution.js +20 -15
- package/dist/analytics/complexity-analyzer.js +2 -2
- package/dist/analytics/cost-report.d.ts +71 -0
- package/dist/analytics/cost-report.js +724 -0
- package/dist/analytics/dashboard.js +8 -7
- package/dist/analytics/index.d.ts +2 -0
- package/dist/analytics/index.js +2 -0
- package/dist/analytics/repo-explainer-collector.d.ts +13 -0
- package/dist/analytics/repo-explainer-collector.js +351 -0
- package/dist/analytics/repo-explainer.d.ts +224 -0
- package/dist/analytics/repo-explainer.js +605 -0
- package/dist/analytics/roi-tracker.js +11 -9
- package/dist/api/webhooks.js +9 -14
- package/dist/app/application-factory.d.ts +1 -1
- package/dist/app/application-factory.js +6 -5
- package/dist/auth/profile-manager.js +9 -5
- package/dist/avatar/avatar-event-bus.d.ts +16 -0
- package/dist/avatar/avatar-event-bus.js +53 -0
- package/dist/avatar/avatar-gateway-bridge.d.ts +26 -0
- package/dist/avatar/avatar-gateway-bridge.js +54 -0
- package/dist/avatar/avatar-protocol.d.ts +133 -0
- package/dist/avatar/avatar-protocol.js +241 -0
- package/dist/avatar/avatar-renderer-registry.d.ts +56 -0
- package/dist/avatar/avatar-renderer-registry.js +191 -0
- package/dist/avatar/avatar-renderer-simulator.d.ts +31 -0
- package/dist/avatar/avatar-renderer-simulator.js +160 -0
- package/dist/browser-automation/browser-manager.d.ts +15 -1
- package/dist/browser-automation/browser-manager.js +101 -0
- package/dist/browser-automation/browser-operator-executor.d.ts +89 -7
- package/dist/browser-automation/browser-operator-executor.js +1280 -58
- package/dist/browser-automation/browser-operator-runtime.d.ts +87 -0
- package/dist/browser-automation/browser-operator-runtime.js +441 -0
- package/dist/browser-automation/browser-operator-session.js +4 -3
- package/dist/browser-automation/browser-tool.d.ts +17 -2
- package/dist/browser-automation/browser-tool.js +101 -39
- package/dist/browser-automation/internet-scout-plan.d.ts +1 -0
- package/dist/browser-automation/internet-scout-plan.js +17 -0
- package/dist/browser-automation/profile-manager.js +5 -3
- package/dist/browser-automation/types.d.ts +25 -0
- package/dist/cache/advanced-lru-cache.js +4 -4
- package/dist/cache/cache-manager.js +9 -10
- package/dist/cache/embedding-cache.js +6 -5
- package/dist/cache/llm-response-cache.js +3 -4
- package/dist/capture/screen-recorder.d.ts +2 -0
- package/dist/capture/screen-recorder.js +6 -4
- package/dist/capture/screen-watcher.d.ts +6 -3
- package/dist/capture/screen-watcher.js +86 -9
- package/dist/channels/channel-cognitive-port.d.ts +46 -0
- package/dist/channels/channel-cognitive-port.js +182 -0
- package/dist/channels/channel-model-override.d.ts +47 -0
- package/dist/channels/channel-model-override.js +62 -0
- package/dist/channels/companion-channel-profile.d.ts +68 -0
- package/dist/channels/companion-channel-profile.js +142 -0
- package/dist/channels/companion-channel-turn.d.ts +79 -0
- package/dist/channels/companion-channel-turn.js +240 -0
- package/dist/channels/core.d.ts +37 -3
- package/dist/channels/core.js +63 -6
- package/dist/channels/discord/client.js +34 -14
- package/dist/channels/dm-pairing.d.ts +18 -4
- package/dist/channels/dm-pairing.js +199 -33
- package/dist/channels/gateway-lifecycle.d.ts +2 -0
- package/dist/channels/gateway-lifecycle.js +1 -0
- package/dist/channels/identity-links.d.ts +19 -1
- package/dist/channels/identity-links.js +68 -12
- package/dist/channels/matrix/index.js +6 -2
- package/dist/channels/pro/pro-features.js +17 -0
- package/dist/channels/pro/run-tracker.js +9 -4
- package/dist/channels/pro/scoped-auth.js +10 -8
- package/dist/channels/provider-failure-speech.d.ts +28 -0
- package/dist/channels/provider-failure-speech.js +128 -0
- package/dist/channels/reconnection-manager.d.ts +2 -0
- package/dist/channels/reconnection-manager.js +7 -2
- package/dist/channels/resolve-channel-secret.d.ts +43 -0
- package/dist/channels/resolve-channel-secret.js +82 -0
- package/dist/channels/slack/block-builder.d.ts +12 -0
- package/dist/channels/slack/block-builder.js +70 -2
- package/dist/channels/slack/client.js +62 -15
- package/dist/channels/slack/types.d.ts +20 -1
- package/dist/channels/slash-parity.d.ts +4 -6
- package/dist/channels/slash-parity.js +9 -44
- package/dist/channels/telegram/client.d.ts +36 -3
- package/dist/channels/telegram/client.js +438 -84
- package/dist/channels/telegram/types.d.ts +2 -0
- package/dist/channels/webhook-server.js +8 -1
- package/dist/channels/whatsapp/index.js +2 -1
- package/dist/checkpoints/ghost-snapshot.js +15 -9
- package/dist/checkpoints/persistent-checkpoint-manager.js +15 -8
- package/dist/cli/command-routing.d.ts +22 -0
- package/dist/cli/command-routing.js +54 -0
- package/dist/cli/first-run.d.ts +17 -0
- package/dist/cli/first-run.js +40 -0
- package/dist/cli/headless-options.d.ts +22 -0
- package/dist/cli/headless-options.js +112 -0
- package/dist/cli/headless-prompt-progress.d.ts +22 -0
- package/dist/cli/headless-prompt-progress.js +35 -0
- package/dist/cli/headless.js +2 -2
- package/dist/cli/listen-port.d.ts +8 -0
- package/dist/cli/listen-port.js +20 -0
- package/dist/cli/permission-mode-option.d.ts +14 -0
- package/dist/cli/permission-mode-option.js +64 -0
- package/dist/cli/requested-profile.d.ts +15 -0
- package/dist/cli/requested-profile.js +27 -0
- package/dist/cli/session-commands.d.ts +9 -0
- package/dist/cli/session-commands.js +45 -5
- package/dist/cli/session-picker.d.ts +43 -0
- package/dist/cli/session-picker.js +128 -0
- package/dist/cli/unknown-option-hint.d.ts +16 -0
- package/dist/cli/unknown-option-hint.js +116 -0
- package/dist/cli/voice-command.d.ts +32 -0
- package/dist/cli/voice-command.js +96 -0
- package/dist/codebuddy/a2a-call-tool-defs.d.ts +26 -0
- package/dist/codebuddy/a2a-call-tool-defs.js +12 -0
- package/dist/codebuddy/abort-signal.d.ts +7 -0
- package/dist/codebuddy/abort-signal.js +31 -0
- package/dist/codebuddy/client.d.ts +68 -0
- package/dist/codebuddy/client.js +460 -11
- package/dist/codebuddy/fleet-tool-defs.d.ts +1 -0
- package/dist/codebuddy/fleet-tool-defs.js +29 -0
- package/dist/codebuddy/llm-retry.d.ts +24 -0
- package/dist/codebuddy/llm-retry.js +124 -0
- package/dist/codebuddy/provider-error-classifier.d.ts +86 -0
- package/dist/codebuddy/provider-error-classifier.js +410 -0
- package/dist/codebuddy/provider-failover-error.d.ts +16 -0
- package/dist/codebuddy/provider-failover-error.js +50 -0
- package/dist/codebuddy/provider-failover-kind.d.ts +15 -0
- package/dist/codebuddy/provider-failover-kind.js +172 -0
- package/dist/codebuddy/provider-handoff.d.ts +35 -0
- package/dist/codebuddy/provider-handoff.js +294 -0
- package/dist/codebuddy/providers/chatgpt-headers.d.ts +18 -0
- package/dist/codebuddy/providers/chatgpt-headers.js +37 -0
- package/dist/codebuddy/providers/ollama-native-transport.d.ts +130 -0
- package/dist/codebuddy/providers/ollama-native-transport.js +387 -0
- package/dist/codebuddy/providers/provider-agy-cli.d.ts +29 -0
- package/dist/codebuddy/providers/provider-agy-cli.js +264 -0
- package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +61 -8
- package/dist/codebuddy/providers/provider-chatgpt-responses.js +526 -184
- package/dist/codebuddy/providers/provider-gemini-cli.js +95 -13
- package/dist/codebuddy/providers/provider-gemini-native.d.ts +2 -0
- package/dist/codebuddy/providers/provider-gemini-native.js +199 -86
- package/dist/codebuddy/providers/provider-openai-compat.d.ts +82 -0
- package/dist/codebuddy/providers/provider-openai-compat.js +469 -45
- package/dist/codebuddy/ragchat-tool-defs.d.ts +31 -0
- package/dist/codebuddy/ragchat-tool-defs.js +19 -0
- package/dist/codebuddy/resource-catalog-tool-defs.d.ts +28 -0
- package/dist/codebuddy/resource-catalog-tool-defs.js +18 -0
- package/dist/codebuddy/stream-retry.d.ts +21 -8
- package/dist/codebuddy/stream-retry.js +44 -40
- package/dist/codebuddy/tool-definitions/advanced-tools.d.ts +4 -0
- package/dist/codebuddy/tool-definitions/advanced-tools.js +188 -0
- package/dist/codebuddy/tool-definitions/agent-tools.d.ts +5 -0
- package/dist/codebuddy/tool-definitions/agent-tools.js +197 -9
- package/dist/codebuddy/tool-definitions/browser-tools.d.ts +1 -0
- package/dist/codebuddy/tool-definitions/browser-tools.js +65 -1
- package/dist/codebuddy/tool-definitions/code-exec-tools.d.ts +8 -0
- package/dist/codebuddy/tool-definitions/code-exec-tools.js +33 -0
- package/dist/codebuddy/tool-definitions/code-explorer-tools.js +4 -0
- package/dist/codebuddy/tool-definitions/comfy-recipe-tools.d.ts +3 -0
- package/dist/codebuddy/tool-definitions/comfy-recipe-tools.js +37 -0
- package/dist/codebuddy/tool-definitions/core-tools.d.ts +2 -0
- package/dist/codebuddy/tool-definitions/core-tools.js +58 -2
- package/dist/codebuddy/tool-definitions/cron-tools.js +6 -0
- package/dist/codebuddy/tool-definitions/delegate-agent-tools.d.ts +11 -0
- package/dist/codebuddy/tool-definitions/delegate-agent-tools.js +50 -0
- package/dist/codebuddy/tool-definitions/design-tools.d.ts +6 -0
- package/dist/codebuddy/tool-definitions/design-tools.js +35 -0
- package/dist/codebuddy/tool-definitions/exit-plan-mode-tools.d.ts +1 -0
- package/dist/codebuddy/tool-definitions/exit-plan-mode-tools.js +23 -1
- package/dist/codebuddy/tool-definitions/index.d.ts +16 -7
- package/dist/codebuddy/tool-definitions/index.js +27 -8
- package/dist/codebuddy/tool-definitions/lsp-tools.d.ts +7 -1
- package/dist/codebuddy/tool-definitions/lsp-tools.js +104 -1
- package/dist/codebuddy/tool-definitions/meeting-tools.d.ts +4 -0
- package/dist/codebuddy/tool-definitions/meeting-tools.js +32 -0
- package/dist/codebuddy/tool-definitions/moa-tools.js +7 -2
- package/dist/codebuddy/tool-definitions/multimodal-tools.d.ts +14 -0
- package/dist/codebuddy/tool-definitions/multimodal-tools.js +615 -3
- package/dist/codebuddy/tool-definitions/research-tools.d.ts +20 -0
- package/dist/codebuddy/tool-definitions/research-tools.js +98 -0
- package/dist/codebuddy/tool-definitions/self-describe-tools.d.ts +4 -0
- package/dist/codebuddy/tool-definitions/self-describe-tools.js +33 -0
- package/dist/codebuddy/tool-definitions/self-evolution-tools.d.ts +4 -0
- package/dist/codebuddy/tool-definitions/self-evolution-tools.js +31 -0
- package/dist/codebuddy/tool-definitions/verify-tools.d.ts +14 -0
- package/dist/codebuddy/tool-definitions/verify-tools.js +36 -0
- package/dist/codebuddy/tool-definitions/web-tools.d.ts +4 -0
- package/dist/codebuddy/tool-definitions/web-tools.js +135 -0
- package/dist/codebuddy/tool-definitions/workspace-tools.d.ts +4 -0
- package/dist/codebuddy/tool-definitions/workspace-tools.js +43 -0
- package/dist/codebuddy/tools.d.ts +15 -23
- package/dist/codebuddy/tools.js +259 -57
- package/dist/cognition/budget-reservations.d.ts +27 -0
- package/dist/cognition/budget-reservations.js +70 -0
- package/dist/cognition/cognitive-bus-client.d.ts +94 -0
- package/dist/cognition/cognitive-bus-client.js +724 -0
- package/dist/cognition/cognitive-hub.d.ts +93 -0
- package/dist/cognition/cognitive-hub.js +366 -0
- package/dist/cognition/cognitive-mesh.d.ts +38 -0
- package/dist/cognition/cognitive-mesh.js +263 -0
- package/dist/cognition/cognitive-port.d.ts +35 -0
- package/dist/cognition/cognitive-port.js +80 -0
- package/dist/cognition/cognitive-wire-contract.d.ts +1542 -0
- package/dist/cognition/cognitive-wire-contract.js +164 -0
- package/dist/cognition/context-renderer.d.ts +52 -0
- package/dist/cognition/context-renderer.js +227 -0
- package/dist/cognition/global-workspace.d.ts +39 -0
- package/dist/cognition/global-workspace.js +181 -0
- package/dist/cognition/index.d.ts +9 -0
- package/dist/cognition/index.js +10 -0
- package/dist/cognition/llm-specialist.d.ts +40 -0
- package/dist/cognition/llm-specialist.js +93 -0
- package/dist/cognition/sensory-workspace.d.ts +57 -0
- package/dist/cognition/sensory-workspace.js +346 -0
- package/dist/cognition/types.d.ts +93 -0
- package/dist/cognition/types.js +7 -0
- package/dist/cognition/voice-specialists.d.ts +21 -0
- package/dist/cognition/voice-specialists.js +89 -0
- package/dist/cognition/world-model.d.ts +95 -0
- package/dist/cognition/world-model.js +228 -0
- package/dist/collaboration/ai-colab-manager.js +12 -13
- package/dist/collaboration/team-session.js +25 -11
- package/dist/commands/apply-permission-mode.d.ts +27 -0
- package/dist/commands/apply-permission-mode.js +35 -0
- package/dist/commands/assistant.d.ts +3 -0
- package/dist/commands/assistant.js +1022 -0
- package/dist/commands/campaign.d.ts +6 -0
- package/dist/commands/campaign.js +140 -0
- package/dist/commands/capsule.d.ts +2 -0
- package/dist/commands/capsule.js +104 -0
- package/dist/commands/changelog.d.ts +29 -0
- package/dist/commands/changelog.js +283 -0
- package/dist/commands/cli/acp-command.js +4 -1
- package/dist/commands/cli/backup-command.d.ts +9 -0
- package/dist/commands/cli/backup-command.js +47 -0
- package/dist/commands/cli/daemon-commands.js +3 -1
- package/dist/commands/cli/evolve-command.d.ts +26 -0
- package/dist/commands/cli/evolve-command.js +275 -0
- package/dist/commands/cli/fleet-collaboration-commands.d.ts +2 -0
- package/dist/commands/cli/fleet-collaboration-commands.js +57 -0
- package/dist/commands/cli/fleet-commands.js +134 -0
- package/dist/commands/cli/fleet-mission-commands.d.ts +3 -0
- package/dist/commands/cli/fleet-mission-commands.js +72 -0
- package/dist/commands/cli/fleet-rooms-commands.d.ts +10 -0
- package/dist/commands/cli/fleet-rooms-commands.js +289 -0
- package/dist/commands/cli/improve-command.d.ts +2 -1
- package/dist/commands/cli/improve-command.js +309 -20
- package/dist/commands/cli/native-engine-commands.js +405 -28
- package/dist/commands/cli/sensory-command.d.ts +8 -0
- package/dist/commands/cli/sensory-command.js +27 -0
- package/dist/commands/cli/speak-command.js +87 -24
- package/dist/commands/cli/tools-commands.js +69 -36
- package/dist/commands/cli/triage-command.d.ts +8 -0
- package/dist/commands/cli/triage-command.js +72 -0
- package/dist/commands/cli/utility-commands.js +59 -10
- package/dist/commands/client-dispatcher.d.ts +8 -0
- package/dist/commands/client-dispatcher.js +113 -42
- package/dist/commands/compress.js +3 -0
- package/dist/commands/cost.d.ts +33 -0
- package/dist/commands/cost.js +342 -0
- package/dist/commands/council-scoreboard.d.ts +8 -0
- package/dist/commands/council-scoreboard.js +68 -0
- package/dist/commands/council.d.ts +16 -24
- package/dist/commands/council.js +247 -255
- package/dist/commands/cron-cli/index.d.ts +3 -1
- package/dist/commands/cron-cli/index.js +25 -0
- package/dist/commands/curator-cli.d.ts +14 -0
- package/dist/commands/curator-cli.js +57 -0
- package/dist/commands/delegate.js +82 -25
- package/dist/commands/dev/golden-path.d.ts +71 -0
- package/dist/commands/dev/golden-path.js +317 -0
- package/dist/commands/dev/index.d.ts +3 -0
- package/dist/commands/dev/index.js +151 -119
- package/dist/commands/dev/issue-pipeline.js +7 -7
- package/dist/commands/dev/workflows.d.ts +2 -0
- package/dist/commands/dev/workflows.js +39 -6
- package/dist/commands/device-auth.d.ts +10 -0
- package/dist/commands/device-auth.js +91 -0
- package/dist/commands/enhanced-command-handler.d.ts +12 -0
- package/dist/commands/enhanced-command-handler.js +57 -18
- package/dist/commands/exchange.d.ts +2 -0
- package/dist/commands/exchange.js +193 -0
- package/dist/commands/explain.d.ts +12 -0
- package/dist/commands/explain.js +135 -0
- package/dist/commands/film.d.ts +18 -0
- package/dist/commands/film.js +239 -0
- package/dist/commands/flow.js +15 -5
- package/dist/commands/forge.d.ts +2 -0
- package/dist/commands/forge.js +102 -0
- package/dist/commands/goal-cli.d.ts +3 -0
- package/dist/commands/goal-cli.js +9 -4
- package/dist/commands/gpu-worker.d.ts +14 -0
- package/dist/commands/gpu-worker.js +135 -0
- package/dist/commands/handlers/agent-handlers.d.ts +1 -1
- package/dist/commands/handlers/agent-handlers.js +4 -4
- package/dist/commands/handlers/agents-handler.d.ts +11 -2
- package/dist/commands/handlers/agents-handler.js +79 -13
- package/dist/commands/handlers/auth-handlers.js +12 -5
- package/dist/commands/handlers/backup-handlers.d.ts +40 -0
- package/dist/commands/handlers/backup-handlers.js +784 -57
- package/dist/commands/handlers/batch-handlers.d.ts +72 -2
- package/dist/commands/handlers/batch-handlers.js +443 -37
- package/dist/commands/handlers/branch-handlers.d.ts +1 -0
- package/dist/commands/handlers/channel-handlers.d.ts +7 -2
- package/dist/commands/handlers/channel-handlers.js +1716 -111
- package/dist/commands/handlers/companion-handler.js +130 -9
- package/dist/commands/handlers/daily-reset-handler.d.ts +1 -1
- package/dist/commands/handlers/daily-reset-handler.js +1 -1
- package/dist/commands/handlers/deepthink-handler.d.ts +2 -0
- package/dist/commands/handlers/deepthink-handler.js +49 -0
- package/dist/commands/handlers/export-handlers.d.ts +3 -2
- package/dist/commands/handlers/export-handlers.js +55 -28
- package/dist/commands/handlers/extra-handlers.js +28 -25
- package/dist/commands/handlers/fleet-handler.d.ts +3 -4
- package/dist/commands/handlers/fleet-handler.js +82 -35
- package/dist/commands/handlers/goal-handler.d.ts +13 -0
- package/dist/commands/handlers/goal-handler.js +26 -7
- package/dist/commands/handlers/grill-me-handler.d.ts +2 -0
- package/dist/commands/handlers/grill-me-handler.js +49 -0
- package/dist/commands/handlers/heartbeat-handler.d.ts +2 -2
- package/dist/commands/handlers/heartbeat-handler.js +2 -2
- package/dist/commands/handlers/index.d.ts +3 -2
- package/dist/commands/handlers/index.js +4 -2
- package/dist/commands/handlers/memory-handlers.d.ts +6 -2
- package/dist/commands/handlers/memory-handlers.js +75 -15
- package/dist/commands/handlers/missing-handlers.d.ts +2 -2
- package/dist/commands/handlers/missing-handlers.js +4 -4
- package/dist/commands/handlers/permissions-handlers.js +3 -2
- package/dist/commands/handlers/pr-handlers.js +15 -17
- package/dist/commands/handlers/resources-handler.d.ts +12 -0
- package/dist/commands/handlers/resources-handler.js +52 -0
- package/dist/commands/handlers/security-handlers.d.ts +1 -1
- package/dist/commands/handlers/security-handlers.js +3 -3
- package/dist/commands/handlers/slash-session-handlers.d.ts +9 -0
- package/dist/commands/handlers/slash-session-handlers.js +134 -0
- package/dist/commands/handlers/starter-handlers.d.ts +1 -1
- package/dist/commands/handlers/starter-handlers.js +32 -2
- package/dist/commands/handlers/swarm-handler.js +41 -2
- package/dist/commands/handlers/switch-handler.d.ts +1 -1
- package/dist/commands/handlers/switch-handler.js +15 -0
- package/dist/commands/handlers/team-handlers.d.ts +28 -1
- package/dist/commands/handlers/team-handlers.js +243 -2
- package/dist/commands/handlers/test-handlers.js +4 -86
- package/dist/commands/handlers/think-handlers.js +2 -1
- package/dist/commands/handlers/ui-handlers.js +11 -5
- package/dist/commands/handlers/vibe-handlers.js +8 -1
- package/dist/commands/handlers/worktree-handlers.js +23 -12
- package/dist/commands/headless-slash.d.ts +9 -0
- package/dist/commands/headless-slash.js +41 -3
- package/dist/commands/import.d.ts +34 -0
- package/dist/commands/import.js +478 -0
- package/dist/commands/index.d.ts +0 -1
- package/dist/commands/index.js +0 -1
- package/dist/commands/influencer.d.ts +2 -0
- package/dist/commands/influencer.js +87 -0
- package/dist/commands/intent.d.ts +6 -0
- package/dist/commands/intent.js +131 -0
- package/dist/commands/intents.d.ts +10 -0
- package/dist/commands/intents.js +163 -0
- package/dist/commands/lessons.js +91 -0
- package/dist/commands/llm-provider-resolution.d.ts +20 -0
- package/dist/commands/llm-provider-resolution.js +74 -13
- package/dist/commands/login-chatgpt.d.ts +8 -0
- package/dist/commands/login-chatgpt.js +17 -0
- package/dist/commands/login-prerequisites.d.ts +11 -0
- package/dist/commands/login-prerequisites.js +23 -0
- package/dist/commands/loop-cli.d.ts +31 -0
- package/dist/commands/loop-cli.js +189 -0
- package/dist/commands/lora.d.ts +6 -0
- package/dist/commands/lora.js +445 -0
- package/dist/commands/maison-food.d.ts +10 -0
- package/dist/commands/maison-food.js +485 -0
- package/dist/commands/maison.d.ts +17 -0
- package/dist/commands/maison.js +236 -0
- package/dist/commands/mcp-import.d.ts +11 -0
- package/dist/commands/mcp-import.js +67 -0
- package/dist/commands/mcp-invoke.d.ts +2 -0
- package/dist/commands/mcp-invoke.js +68 -0
- package/dist/commands/mcp.d.ts +6 -0
- package/dist/commands/mcp.js +240 -7
- package/dist/commands/meeting.d.ts +8 -0
- package/dist/commands/meeting.js +31 -0
- package/dist/commands/pairing.js +7 -8
- package/dist/commands/papers/ask.d.ts +47 -0
- package/dist/commands/papers/ask.js +105 -0
- package/dist/commands/papers/index.d.ts +19 -0
- package/dist/commands/papers/index.js +54 -0
- package/dist/commands/pipeline.d.ts +7 -1
- package/dist/commands/pipeline.js +104 -7
- package/dist/commands/provider.d.ts +9 -0
- package/dist/commands/provider.js +178 -10
- package/dist/commands/replay.d.ts +11 -0
- package/dist/commands/replay.js +131 -0
- package/dist/commands/research/deep.d.ts +66 -0
- package/dist/commands/research/deep.js +236 -0
- package/dist/commands/research/discover-searxng.d.ts +25 -0
- package/dist/commands/research/discover-searxng.js +62 -0
- package/dist/commands/research/index.d.ts +24 -2
- package/dist/commands/research/index.js +456 -79
- package/dist/commands/research/knowledge-ingest.d.ts +170 -0
- package/dist/commands/research/knowledge-ingest.js +449 -0
- package/dist/commands/research/wire-research-worker.d.ts +9 -0
- package/dist/commands/research/wire-research-worker.js +18 -0
- package/dist/commands/resources.d.ts +2 -0
- package/dist/commands/resources.js +64 -0
- package/dist/commands/run-cli/index.d.ts +3 -1
- package/dist/commands/run-cli/index.js +53 -2
- package/dist/commands/science/deps.d.ts +95 -0
- package/dist/commands/science/deps.js +343 -0
- package/dist/commands/science/index.d.ts +31 -0
- package/dist/commands/science/index.js +285 -0
- package/dist/commands/science/loop-option.d.ts +40 -0
- package/dist/commands/science/loop-option.js +91 -0
- package/dist/commands/science/sandbox-option.d.ts +44 -0
- package/dist/commands/science/sandbox-option.js +42 -0
- package/dist/commands/scrape.d.ts +18 -0
- package/dist/commands/scrape.js +159 -0
- package/dist/commands/self.d.ts +9 -0
- package/dist/commands/self.js +56 -0
- package/dist/commands/shadow.d.ts +3 -0
- package/dist/commands/shadow.js +72 -0
- package/dist/commands/share.d.ts +13 -0
- package/dist/commands/share.js +71 -0
- package/dist/commands/shell-prefix.d.ts +4 -22
- package/dist/commands/shell-prefix.js +11 -73
- package/dist/commands/skills-cli/index.d.ts +2 -0
- package/dist/commands/skills-cli/index.js +224 -26
- package/dist/commands/slash/builtin-commands.js +57 -24
- package/dist/commands/slash/index.d.ts +3 -1
- package/dist/commands/slash/index.js +2 -0
- package/dist/commands/slash/surfaces.d.ts +53 -0
- package/dist/commands/slash/surfaces.js +177 -0
- package/dist/commands/slash/types.d.ts +17 -0
- package/dist/commands/slash-commands.js +4 -1
- package/dist/commands/token.d.ts +80 -0
- package/dist/commands/token.js +319 -0
- package/dist/commands/try.d.ts +72 -0
- package/dist/commands/try.js +357 -0
- package/dist/commands/update.d.ts +14 -1
- package/dist/commands/update.js +97 -15
- package/dist/commands/vision-train.d.ts +15 -0
- package/dist/commands/vision-train.js +214 -0
- package/dist/commands/whoami-status.d.ts +17 -0
- package/dist/commands/whoami-status.js +34 -0
- package/dist/commands/widgets.d.ts +2 -0
- package/dist/commands/widgets.js +179 -0
- package/dist/commands/ws.d.ts +7 -0
- package/dist/commands/ws.js +100 -0
- package/dist/companion/assistant-config.d.ts +79 -0
- package/dist/companion/assistant-config.js +1148 -0
- package/dist/companion/attached-image-grounding.d.ts +29 -0
- package/dist/companion/attached-image-grounding.js +285 -0
- package/dist/companion/away-mode.d.ts +80 -0
- package/dist/companion/away-mode.js +269 -0
- package/dist/companion/camera-share.d.ts +65 -0
- package/dist/companion/camera-share.js +321 -0
- package/dist/companion/camera.d.ts +8 -0
- package/dist/companion/camera.js +57 -31
- package/dist/companion/cards.js +7 -10
- package/dist/companion/check-in.js +23 -8
- package/dist/companion/companion-doctor.d.ts +58 -0
- package/dist/companion/companion-doctor.js +194 -0
- package/dist/companion/companion-history.d.ts +23 -0
- package/dist/companion/companion-history.js +22 -0
- package/dist/companion/companion-identity.d.ts +43 -0
- package/dist/companion/companion-identity.js +136 -0
- package/dist/companion/companion-mode.d.ts +77 -1
- package/dist/companion/companion-mode.js +916 -6
- package/dist/companion/companion-photo-intake.d.ts +40 -0
- package/dist/companion/companion-photo-intake.js +112 -0
- package/dist/companion/companion-photo.d.ts +144 -0
- package/dist/companion/companion-photo.js +318 -0
- package/dist/companion/companion-toolset.d.ts +66 -0
- package/dist/companion/companion-toolset.js +368 -0
- package/dist/companion/companion-turn.d.ts +96 -0
- package/dist/companion/companion-turn.js +260 -0
- package/dist/companion/companion-voice-character.d.ts +62 -0
- package/dist/companion/companion-voice-character.js +148 -0
- package/dist/companion/competitive-radar.js +14 -13
- package/dist/companion/continuity.d.ts +62 -0
- package/dist/companion/continuity.js +284 -0
- package/dist/companion/conversation-improvement-loop.d.ts +61 -0
- package/dist/companion/conversation-improvement-loop.js +317 -0
- package/dist/companion/conversation-quality-insights.d.ts +56 -0
- package/dist/companion/conversation-quality-insights.js +161 -0
- package/dist/companion/cooking-timer-runner.d.ts +20 -0
- package/dist/companion/cooking-timer-runner.js +98 -0
- package/dist/companion/core-adapter.d.ts +60 -0
- package/dist/companion/core-adapter.js +111 -0
- package/dist/companion/crisis-safety.d.ts +52 -0
- package/dist/companion/crisis-safety.js +150 -0
- package/dist/companion/daily-interaction-budget.d.ts +34 -0
- package/dist/companion/daily-interaction-budget.js +260 -0
- package/dist/companion/dialogue-percepts.d.ts +16 -0
- package/dist/companion/dialogue-percepts.js +50 -0
- package/dist/companion/event-followups.d.ts +58 -0
- package/dist/companion/event-followups.js +213 -0
- package/dist/companion/fashion-scene-catalog.d.ts +29 -0
- package/dist/companion/fashion-scene-catalog.js +141 -0
- package/dist/companion/gateway-inbox.js +25 -13
- package/dist/companion/gateway.d.ts +1 -0
- package/dist/companion/gateway.js +37 -17
- package/dist/companion/home-interaction-policy.d.ts +31 -0
- package/dist/companion/home-interaction-policy.js +89 -0
- package/dist/companion/household-time.d.ts +9 -0
- package/dist/companion/household-time.js +15 -0
- package/dist/companion/idle-loop.d.ts +53 -0
- package/dist/companion/idle-loop.js +254 -0
- package/dist/companion/impulses.js +148 -23
- package/dist/companion/inner-life.d.ts +60 -0
- package/dist/companion/inner-life.js +112 -0
- package/dist/companion/jokes.d.ts +21 -0
- package/dist/companion/jokes.js +175 -0
- package/dist/companion/lisa-selfie-cache.d.ts +36 -0
- package/dist/companion/lisa-selfie-cache.js +123 -0
- package/dist/companion/lisa-selfie-ingest.d.ts +36 -0
- package/dist/companion/lisa-selfie-ingest.js +205 -0
- package/dist/companion/lisa-selfie-refill.d.ts +32 -0
- package/dist/companion/lisa-selfie-refill.js +121 -0
- package/dist/companion/lisa-selfie-router.d.ts +40 -0
- package/dist/companion/lisa-selfie-router.js +156 -0
- package/dist/companion/lisa-selfie.d.ts +97 -0
- package/dist/companion/lisa-selfie.js +542 -0
- package/dist/companion/maison-voice-actions.d.ts +34 -0
- package/dist/companion/maison-voice-actions.js +192 -0
- package/dist/companion/migration.d.ts +63 -0
- package/dist/companion/migration.js +270 -0
- package/dist/companion/mission-board.js +7 -10
- package/dist/companion/mission-runner.js +2 -3
- package/dist/companion/mobile-conversation-log.d.ts +19 -0
- package/dist/companion/mobile-conversation-log.js +157 -0
- package/dist/companion/mobile-history.d.ts +34 -0
- package/dist/companion/mobile-history.js +123 -0
- package/dist/companion/mysoulmate-image-prompts.d.ts +26 -0
- package/dist/companion/mysoulmate-image-prompts.js +278 -0
- package/dist/companion/orchestrator.d.ts +32 -0
- package/dist/companion/orchestrator.js +49 -0
- package/dist/companion/percepts.d.ts +70 -0
- package/dist/companion/percepts.js +251 -18
- package/dist/companion/personas/copine.d.ts +8 -0
- package/dist/companion/personas/copine.js +195 -0
- package/dist/companion/personas/index.d.ts +19 -0
- package/dist/companion/personas/index.js +33 -0
- package/dist/companion/personas/types.d.ts +34 -0
- package/dist/companion/personas/types.js +8 -0
- package/dist/companion/photo-memory-fr.d.ts +36 -0
- package/dist/companion/photo-memory-fr.js +291 -0
- package/dist/companion/prefetch-config.d.ts +38 -0
- package/dist/companion/prefetch-config.js +119 -0
- package/dist/companion/prefetch-engine.d.ts +87 -0
- package/dist/companion/prefetch-engine.js +513 -0
- package/dist/companion/presence-loop.d.ts +85 -0
- package/dist/companion/presence-loop.js +297 -0
- package/dist/companion/privacy.js +3 -2
- package/dist/companion/proactive-engine.d.ts +97 -0
- package/dist/companion/proactive-engine.js +447 -0
- package/dist/companion/recent-said.d.ts +30 -0
- package/dist/companion/recent-said.js +98 -0
- package/dist/companion/relational-benchmark-scenarios.d.ts +191 -0
- package/dist/companion/relational-benchmark-scenarios.js +227 -0
- package/dist/companion/relational-context.d.ts +71 -0
- package/dist/companion/relational-context.js +302 -0
- package/dist/companion/relational-episode-evaluator.d.ts +117 -0
- package/dist/companion/relational-episode-evaluator.js +453 -0
- package/dist/companion/relationship-evolution.d.ts +2 -0
- package/dist/companion/relationship-evolution.js +30 -0
- package/dist/companion/relationship-state.d.ts +106 -0
- package/dist/companion/relationship-state.js +293 -0
- package/dist/companion/reminder-runner.d.ts +33 -0
- package/dist/companion/reminder-runner.js +183 -0
- package/dist/companion/reminders.d.ts +228 -0
- package/dist/companion/reminders.js +906 -0
- package/dist/companion/reply-augment.d.ts +87 -0
- package/dist/companion/reply-augment.js +464 -0
- package/dist/companion/safety-ledger.js +19 -12
- package/dist/companion/self-evaluation.js +22 -23
- package/dist/companion/shared-photo-memory.d.ts +65 -0
- package/dist/companion/shared-photo-memory.js +145 -0
- package/dist/companion/shared-photos.d.ts +88 -0
- package/dist/companion/shared-photos.js +321 -0
- package/dist/companion/signature-locations.d.ts +16 -0
- package/dist/companion/signature-locations.js +108 -0
- package/dist/companion/skill-curator.d.ts +9 -0
- package/dist/companion/skill-curator.js +147 -58
- package/dist/companion/untrusted-text.d.ts +22 -0
- package/dist/companion/untrusted-text.js +47 -0
- package/dist/companion/user-name.d.ts +18 -0
- package/dist/companion/user-name.js +22 -0
- package/dist/companion/visual-consent.d.ts +40 -0
- package/dist/companion/visual-consent.js +98 -0
- package/dist/companion/visual-grounding.d.ts +83 -0
- package/dist/companion/visual-grounding.js +474 -0
- package/dist/companion/voice-callbacks.d.ts +9 -0
- package/dist/companion/voice-callbacks.js +84 -0
- package/dist/companion/voice-guidance.d.ts +23 -0
- package/dist/companion/voice-guidance.js +85 -0
- package/dist/companion/voice-improvement-loop.d.ts +53 -0
- package/dist/companion/voice-improvement-loop.js +279 -0
- package/dist/companion/voice-incident-repair.d.ts +41 -0
- package/dist/companion/voice-incident-repair.js +214 -0
- package/dist/config/code-exec-policy.d.ts +25 -0
- package/dist/config/code-exec-policy.js +39 -0
- package/dist/config/constants.d.ts +41 -0
- package/dist/config/constants.js +14 -0
- package/dist/config/env-schema.d.ts +2 -0
- package/dist/config/env-schema.js +714 -5
- package/dist/config/feature-flags.js +8 -12
- package/dist/config/feature-surface.d.ts +12 -0
- package/dist/config/feature-surface.js +86 -0
- package/dist/config/headless-local-prompt.d.ts +9 -0
- package/dist/config/headless-local-prompt.js +39 -0
- package/dist/config/local-runtime-context.d.ts +41 -0
- package/dist/config/local-runtime-context.js +430 -0
- package/dist/config/model-registry.js +4 -0
- package/dist/config/model-strengths.d.ts +14 -0
- package/dist/config/model-strengths.js +15 -0
- package/dist/config/model-tools.d.ts +65 -0
- package/dist/config/model-tools.js +823 -21
- package/dist/config/secret-ref.d.ts +22 -3
- package/dist/config/secret-ref.js +103 -41
- package/dist/config/toml-config.d.ts +20 -4
- package/dist/config/toml-config.js +40 -2
- package/dist/context/auto-compact-threshold.d.ts +1 -1
- package/dist/context/auto-compact-threshold.js +1 -1
- package/dist/context/codebase-map.js +9 -4
- package/dist/context/codebase-rag/codebase-rag.js +7 -6
- package/dist/context/codebase-rag/hnsw-store.js +9 -4
- package/dist/context/codebase-rag/vector-store.js +4 -4
- package/dist/context/compaction/parallel-summarizer.js +1 -0
- package/dist/context/compression.js +25 -29
- package/dist/context/context-manager-v2.d.ts +95 -7
- package/dist/context/context-manager-v2.js +444 -91
- package/dist/context/context-manager-v3.d.ts +4 -0
- package/dist/context/context-manager-v3.js +68 -9
- package/dist/context/cross-encoder-reranker.js +8 -3
- package/dist/context/default-context-engine.js +1 -1
- package/dist/context/enhanced-compression.d.ts +26 -2
- package/dist/context/enhanced-compression.js +81 -30
- package/dist/context/file-mentions.d.ts +46 -0
- package/dist/context/file-mentions.js +245 -0
- package/dist/context/importance-scorer.js +4 -3
- package/dist/context/jit-context.d.ts +7 -0
- package/dist/context/jit-context.js +22 -4
- package/dist/context/lm-resizer-compressor.d.ts +102 -0
- package/dist/context/lm-resizer-compressor.js +594 -0
- package/dist/context/lm-resizer-diagnostics.d.ts +9 -0
- package/dist/context/lm-resizer-diagnostics.js +30 -0
- package/dist/context/precompaction-flush.js +1 -1
- package/dist/context/restorable-compression.d.ts +59 -14
- package/dist/context/restorable-compression.js +310 -60
- package/dist/context/segment-archive.d.ts +36 -0
- package/dist/context/segment-archive.js +220 -0
- package/dist/context/smart-compaction.d.ts +7 -0
- package/dist/context/smart-compaction.js +84 -15
- package/dist/context/token-counter.d.ts +6 -0
- package/dist/context/token-counter.js +41 -0
- package/dist/context/token-juice.d.ts +72 -0
- package/dist/context/token-juice.js +220 -0
- package/dist/context/tool-observation-optimizer.d.ts +90 -0
- package/dist/context/tool-observation-optimizer.js +231 -0
- package/dist/context/tool-output-masking.js +3 -4
- package/dist/context/tool-pair-preserver.d.ts +1 -1
- package/dist/context/tool-pair-preserver.js +1 -1
- package/dist/context/transcript-repair.d.ts +16 -3
- package/dist/context/transcript-repair.js +72 -35
- package/dist/context/types.d.ts +2 -0
- package/dist/conversation/argument-obligations.d.ts +65 -0
- package/dist/conversation/argument-obligations.js +157 -0
- package/dist/conversation/companion-model-routing.d.ts +121 -0
- package/dist/conversation/companion-model-routing.js +810 -0
- package/dist/conversation/conversation-benchmark.d.ts +143 -0
- package/dist/conversation/conversation-benchmark.js +766 -0
- package/dist/conversation/conversation-blind-comparison.d.ts +135 -0
- package/dist/conversation/conversation-blind-comparison.js +451 -0
- package/dist/conversation/conversation-evaluator.d.ts +56 -0
- package/dist/conversation/conversation-evaluator.js +335 -0
- package/dist/conversation/conversation-orchestrator.d.ts +32 -0
- package/dist/conversation/conversation-orchestrator.js +59 -0
- package/dist/conversation/conversation-pilot-corpus.d.ts +33 -0
- package/dist/conversation/conversation-pilot-corpus.js +313 -0
- package/dist/conversation/conversation-quality.d.ts +31 -0
- package/dist/conversation/conversation-quality.js +280 -0
- package/dist/conversation/conversation-state.d.ts +23 -0
- package/dist/conversation/conversation-state.js +117 -0
- package/dist/conversation/cross-channel-bridge.d.ts +127 -0
- package/dist/conversation/cross-channel-bridge.js +785 -0
- package/dist/conversation/deliberation-thread.d.ts +18 -0
- package/dist/conversation/deliberation-thread.js +303 -0
- package/dist/conversation/dialogue-act.d.ts +11 -0
- package/dist/conversation/dialogue-act.js +132 -0
- package/dist/conversation/discourse-planner.d.ts +3 -0
- package/dist/conversation/discourse-planner.js +141 -0
- package/dist/conversation/fresh-context.d.ts +54 -0
- package/dist/conversation/fresh-context.js +258 -0
- package/dist/conversation/prefetched-turn-context.d.ts +45 -0
- package/dist/conversation/prefetched-turn-context.js +209 -0
- package/dist/conversation/relationship-safety.d.ts +37 -0
- package/dist/conversation/relationship-safety.js +407 -0
- package/dist/conversation/semantic-response-gate.d.ts +262 -0
- package/dist/conversation/semantic-response-gate.js +656 -0
- package/dist/conversation/semantic-response-runtime.d.ts +79 -0
- package/dist/conversation/semantic-response-runtime.js +419 -0
- package/dist/conversation/shared-relationship-state.d.ts +60 -0
- package/dist/conversation/shared-relationship-state.js +262 -0
- package/dist/conversation/types.d.ts +77 -0
- package/dist/conversation/types.js +3 -0
- package/dist/conversation/voice-continuity.d.ts +13 -0
- package/dist/conversation/voice-continuity.js +48 -0
- package/dist/council/conductor.d.ts +26 -0
- package/dist/council/conductor.js +292 -0
- package/dist/council/council-engine.d.ts +29 -0
- package/dist/council/council-engine.js +458 -0
- package/dist/council/deliberation-health.d.ts +58 -0
- package/dist/council/deliberation-health.js +108 -0
- package/dist/council/judge.d.ts +69 -0
- package/dist/council/judge.js +183 -0
- package/dist/council/peers.d.ts +19 -0
- package/dist/council/peers.js +47 -0
- package/dist/council/signals.d.ts +26 -0
- package/dist/council/signals.js +156 -0
- package/dist/council/task-types.d.ts +16 -0
- package/dist/council/task-types.js +58 -0
- package/dist/council/triage.d.ts +48 -0
- package/dist/council/triage.js +228 -0
- package/dist/council/types.d.ts +292 -0
- package/dist/council/types.js +20 -0
- package/dist/council/with-timeout.d.ts +10 -0
- package/dist/council/with-timeout.js +29 -0
- package/dist/curator/curator.d.ts +85 -0
- package/dist/curator/curator.js +367 -0
- package/dist/daemon/agent-task-executor.js +51 -0
- package/dist/daemon/autonomous-daemon.d.ts +2 -0
- package/dist/daemon/autonomous-daemon.js +4 -1
- package/dist/daemon/autonomous-loop.d.ts +9 -0
- package/dist/daemon/autonomous-loop.js +57 -1
- package/dist/daemon/autonomy-bench-candidates.d.ts +33 -0
- package/dist/daemon/autonomy-bench-candidates.js +68 -0
- package/dist/daemon/autonomy-briefing.d.ts +112 -0
- package/dist/daemon/autonomy-briefing.js +359 -0
- package/dist/daemon/autonomy-run-journal.d.ts +20 -0
- package/dist/daemon/autonomy-run-journal.js +41 -0
- package/dist/daemon/cron-agent-bridge.d.ts +6 -0
- package/dist/daemon/cron-agent-bridge.js +31 -4
- package/dist/daemon/daily-reset.d.ts +2 -2
- package/dist/daemon/daily-reset.js +16 -15
- package/dist/daemon/ollama-task-executor.js +9 -1
- package/dist/database/database-manager.d.ts +1 -1
- package/dist/database/database-manager.js +6 -4
- package/dist/database/optional-sqlite.d.ts +20 -0
- package/dist/database/optional-sqlite.js +101 -0
- package/dist/design/design-system-registry.d.ts +21 -0
- package/dist/design/design-system-registry.js +106 -0
- package/dist/desktop/codebuddy-engine-adapter.d.ts +34 -0
- package/dist/desktop/codebuddy-engine-adapter.js +306 -21
- package/dist/desktop/electron-launch-args.d.ts +7 -0
- package/dist/desktop/electron-launch-args.js +13 -0
- package/dist/desktop/engine-adapter.d.ts +6 -0
- package/dist/desktop/launcher.js +2 -1
- package/dist/desktop/permission-bridge.d.ts +12 -1
- package/dist/desktop/permission-bridge.js +12 -5
- package/dist/desktop-automation/omniparser-runner.d.ts +1 -0
- package/dist/desktop-automation/omniparser-runner.js +12 -1
- package/dist/desktop-automation/smart-snapshot.js +7 -0
- package/dist/desktop-automation/windows-native-provider.js +1 -1
- package/dist/doctor/assistant-runtime.d.ts +90 -0
- package/dist/doctor/assistant-runtime.js +472 -0
- package/dist/doctor/env-sanity.d.ts +17 -0
- package/dist/doctor/env-sanity.js +74 -0
- package/dist/doctor/index.d.ts +47 -1
- package/dist/doctor/index.js +464 -49
- package/dist/doctor/integrations.d.ts +179 -0
- package/dist/doctor/integrations.js +227 -0
- package/dist/doctor/llm-key-check.d.ts +17 -0
- package/dist/doctor/llm-key-check.js +100 -0
- package/dist/doctor/ollama-model-selection.d.ts +16 -0
- package/dist/doctor/ollama-model-selection.js +55 -0
- package/dist/doctor/triage.d.ts +108 -0
- package/dist/doctor/triage.js +304 -0
- package/dist/embeddings/embedding-provider.d.ts +1 -0
- package/dist/embeddings/embedding-provider.js +21 -9
- package/dist/errors/crash-recovery.js +6 -4
- package/dist/events/index.d.ts +1 -1
- package/dist/events/types.d.ts +44 -0
- package/dist/export/repo-explanation.d.ts +10 -0
- package/dist/export/repo-explanation.js +334 -0
- package/dist/export/session-share.d.ts +34 -0
- package/dist/export/session-share.js +687 -0
- package/dist/fleet/autonomous-tick-broadcaster.d.ts +1 -1
- package/dist/fleet/capability-registry.d.ts +9 -0
- package/dist/fleet/capability-registry.js +268 -56
- package/dist/fleet/colab-store.d.ts +3 -4
- package/dist/fleet/colab-store.js +6 -26
- package/dist/fleet/collaboration.d.ts +44 -0
- package/dist/fleet/collaboration.js +170 -0
- package/dist/fleet/compatible-model.d.ts +39 -0
- package/dist/fleet/compatible-model.js +148 -0
- package/dist/fleet/consolidation/collecte.d.ts +31 -0
- package/dist/fleet/consolidation/collecte.js +86 -0
- package/dist/fleet/consolidation/digest-texte.d.ts +11 -0
- package/dist/fleet/consolidation/digest-texte.js +52 -0
- package/dist/fleet/consolidation/thalamus.d.ts +35 -0
- package/dist/fleet/consolidation/thalamus.js +151 -0
- package/dist/fleet/consolidation/types.d.ts +66 -0
- package/dist/fleet/consolidation/types.js +22 -0
- package/dist/fleet/cost-tracker.d.ts +11 -0
- package/dist/fleet/cost-tracker.js +64 -17
- package/dist/fleet/fleet-cost-cap.d.ts +36 -0
- package/dist/fleet/fleet-cost-cap.js +175 -0
- package/dist/fleet/fleet-http-surface.d.ts +24 -0
- package/dist/fleet/fleet-http-surface.js +72 -0
- package/dist/fleet/fleet-listener.d.ts +2 -1
- package/dist/fleet/fleet-listener.js +91 -46
- package/dist/fleet/fleet-registry.d.ts +2 -0
- package/dist/fleet/model-capability-heuristics.d.ts +31 -0
- package/dist/fleet/model-capability-heuristics.js +49 -0
- package/dist/fleet/model-inventory.d.ts +46 -0
- package/dist/fleet/model-inventory.js +242 -0
- package/dist/fleet/model-scoreboard.d.ts +118 -13
- package/dist/fleet/model-scoreboard.js +339 -27
- package/dist/fleet/model-selector.d.ts +83 -0
- package/dist/fleet/model-selector.js +218 -0
- package/dist/fleet/peer-chat-bridge.d.ts +9 -2
- package/dist/fleet/peer-chat-bridge.js +133 -19
- package/dist/fleet/peer-chat-client-factory.d.ts +28 -2
- package/dist/fleet/peer-chat-client-factory.js +195 -22
- package/dist/fleet/peer-ckg-bridge.d.ts +67 -0
- package/dist/fleet/peer-ckg-bridge.js +467 -0
- package/dist/fleet/peer-mission-exchange-bridge.d.ts +8 -0
- package/dist/fleet/peer-mission-exchange-bridge.js +127 -0
- package/dist/fleet/peer-session-bridge.d.ts +7 -1
- package/dist/fleet/peer-session-bridge.js +98 -17
- package/dist/fleet/peer-session-store.d.ts +2 -0
- package/dist/fleet/peer-session-store.js +6 -5
- package/dist/fleet/peer-text-sanitizer.d.ts +59 -0
- package/dist/fleet/peer-text-sanitizer.js +99 -0
- package/dist/fleet/peer-tool-bridge.js +38 -10
- package/dist/fleet/privacy-lint.js +80 -8
- package/dist/fleet/resource-catalog.d.ts +245 -0
- package/dist/fleet/resource-catalog.js +211 -0
- package/dist/fleet/rooms/room-access.d.ts +138 -0
- package/dist/fleet/rooms/room-access.js +196 -0
- package/dist/fleet/rooms/room-client.d.ts +158 -0
- package/dist/fleet/rooms/room-client.js +685 -0
- package/dist/fleet/rooms/room-event.d.ts +139 -0
- package/dist/fleet/rooms/room-event.js +330 -0
- package/dist/fleet/rooms/room-filter.d.ts +48 -0
- package/dist/fleet/rooms/room-filter.js +152 -0
- package/dist/fleet/rooms/room-hub.d.ts +154 -0
- package/dist/fleet/rooms/room-hub.js +363 -0
- package/dist/fleet/rooms/room-identity.d.ts +26 -0
- package/dist/fleet/rooms/room-identity.js +82 -0
- package/dist/fleet/rooms/room-lock.d.ts +34 -0
- package/dist/fleet/rooms/room-lock.js +180 -0
- package/dist/fleet/rooms/room-observations.d.ts +7 -0
- package/dist/fleet/rooms/room-observations.js +61 -0
- package/dist/fleet/rooms/room-server.d.ts +28 -0
- package/dist/fleet/rooms/room-server.js +75 -0
- package/dist/fleet/rooms/room-store.d.ts +119 -0
- package/dist/fleet/rooms/room-store.js +448 -0
- package/dist/fleet/rooms/room-ws-bridge.d.ts +27 -0
- package/dist/fleet/rooms/room-ws-bridge.js +137 -0
- package/dist/fleet/saga-store.d.ts +25 -1
- package/dist/fleet/saga-store.js +34 -6
- package/dist/fleet/sensory-mission-bridge.d.ts +42 -0
- package/dist/fleet/sensory-mission-bridge.js +136 -0
- package/dist/fleet/task-router.d.ts +17 -1
- package/dist/fleet/task-router.js +65 -20
- package/dist/fleet/types.d.ts +9 -5
- package/dist/gateway/device-pairing.js +5 -11
- package/dist/gateway/ws-transport.d.ts +1 -5
- package/dist/gateway/ws-transport.js +2 -22
- package/dist/git/changelog.d.ts +36 -0
- package/dist/git/changelog.js +109 -0
- package/dist/git/worktree-sessions.js +2 -1
- package/dist/goals/counterfactual-forge.d.ts +70 -0
- package/dist/goals/counterfactual-forge.js +184 -0
- package/dist/goals/criterion-progress.d.ts +24 -0
- package/dist/goals/criterion-progress.js +59 -0
- package/dist/goals/evidence-artifact.d.ts +18 -0
- package/dist/goals/evidence-artifact.js +76 -0
- package/dist/goals/goal-decomposer.d.ts +15 -0
- package/dist/goals/goal-decomposer.js +89 -4
- package/dist/goals/goal-loop.d.ts +29 -0
- package/dist/goals/goal-loop.js +92 -6
- package/dist/goals/goal-manager.d.ts +1 -0
- package/dist/goals/goal-manager.js +4 -1
- package/dist/goals/goal-state.d.ts +10 -0
- package/dist/goals/goal-state.js +21 -1
- package/dist/goals/goal-store.js +4 -6
- package/dist/goals/index.d.ts +11 -0
- package/dist/goals/index.js +11 -0
- package/dist/goals/intent-graph.d.ts +40 -0
- package/dist/goals/intent-graph.js +133 -0
- package/dist/goals/mission-constitution.d.ts +59 -0
- package/dist/goals/mission-constitution.js +132 -0
- package/dist/goals/mission-exchange.d.ts +86 -0
- package/dist/goals/mission-exchange.js +216 -0
- package/dist/goals/outcome-capsule.d.ts +80 -0
- package/dist/goals/outcome-capsule.js +186 -0
- package/dist/goals/proof-ledger.d.ts +79 -0
- package/dist/goals/proof-ledger.js +181 -0
- package/dist/goals/proven-outcome-lessons.d.ts +11 -0
- package/dist/goals/proven-outcome-lessons.js +30 -0
- package/dist/goals/proven-outcome-memory.d.ts +55 -0
- package/dist/goals/proven-outcome-memory.js +125 -0
- package/dist/goals/shadow-twin.d.ts +57 -0
- package/dist/goals/shadow-twin.js +110 -0
- package/dist/gpu-worker/gpu-media-worker-server.d.ts +49 -0
- package/dist/gpu-worker/gpu-media-worker-server.js +637 -0
- package/dist/harness/contract.d.ts +88 -88
- package/dist/harness/fleet-supervisor.d.ts +16 -0
- package/dist/harness/fleet-supervisor.js +64 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.js +4 -0
- package/dist/harness/mission-runner.d.ts +3 -0
- package/dist/harness/mission-runner.js +53 -0
- package/dist/harness/mission-store.d.ts +93 -0
- package/dist/harness/mission-store.js +297 -0
- package/dist/harness/tool-harness.d.ts +56 -0
- package/dist/harness/tool-harness.js +153 -0
- package/dist/hooks/advanced-hooks.js +6 -4
- package/dist/hooks/env-persistence.js +5 -6
- package/dist/hooks/hook-manager.js +8 -7
- package/dist/hooks/hook-system.js +6 -4
- package/dist/hooks/lifecycle-hooks.js +6 -3
- package/dist/hooks/moltbot/moltbot-hooks-manager.js +8 -3
- package/dist/hooks/moltbot/session-persistence-manager.js +15 -7
- package/dist/hooks/moltbot/setup-utilities.js +6 -4
- package/dist/hooks/smart-hooks.js +6 -4
- package/dist/hooks/use-enhanced-input.js +48 -4
- package/dist/hooks/use-input-handler.d.ts +1 -0
- package/dist/hooks/use-input-handler.js +90 -84
- package/dist/hooks/use-input-history.js +1 -0
- package/dist/hooks/user-hooks.d.ts +10 -1
- package/dist/hooks/user-hooks.js +77 -1
- package/dist/identity/companion-identity.d.ts +4 -1
- package/dist/identity/companion-identity.js +134 -4
- package/dist/identity/identity-manager.d.ts +1 -1
- package/dist/identity/identity-manager.js +7 -6
- package/dist/identity/lisa-introspection.d.ts +36 -0
- package/dist/identity/lisa-introspection.js +414 -0
- package/dist/identity/operational-self-model.d.ts +145 -0
- package/dist/identity/operational-self-model.js +978 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1039 -229
- package/dist/input/context-mentions.d.ts +7 -1
- package/dist/input/context-mentions.js +18 -20
- package/dist/input/text-to-speech.d.ts +3 -0
- package/dist/input/text-to-speech.js +70 -27
- package/dist/input/voice-control.d.ts +1 -0
- package/dist/input/voice-control.js +24 -18
- package/dist/input/voice-input-enhanced.d.ts +1 -0
- package/dist/input/voice-input-enhanced.js +31 -16
- package/dist/integrations/ci-autofix-pipeline.js +15 -20
- package/dist/integrations/ide/server.js +3 -2
- package/dist/integrations/json-rpc/server.js +4 -2
- package/dist/integrations/mcp/mcp-server.js +4 -2
- package/dist/integrations/opentelemetry-integration.js +6 -4
- package/dist/integrations/pubcommander-bridge.d.ts +5 -0
- package/dist/integrations/pubcommander-bridge.js +61 -0
- package/dist/integrations/sentry-integration.js +9 -3
- package/dist/intelligence/semantic-search.js +9 -12
- package/dist/intelligence/user-preferences.js +8 -11
- package/dist/intents/intent-checker.d.ts +34 -0
- package/dist/intents/intent-checker.js +175 -0
- package/dist/intents/intent-generator.d.ts +12 -0
- package/dist/intents/intent-generator.js +86 -0
- package/dist/intents/intent-store.d.ts +62 -0
- package/dist/intents/intent-store.js +263 -0
- package/dist/interpreter/computer/skills.js +3 -2
- package/dist/interpreter/interpreter-service.js +18 -9
- package/dist/kanban/kanban-board-registry.js +6 -4
- package/dist/kanban/kanban-store.js +5 -7
- package/dist/knowledge/code-graph-persistence.js +8 -16
- package/dist/knowledge/graph-drift.js +14 -11
- package/dist/knowledge/knowledge-manager.js +2 -1
- package/dist/knowledge/scanners/index.d.ts +3 -0
- package/dist/knowledge/scanners/index.js +57 -29
- package/dist/knowledge/workspace-indexer.js +22 -15
- package/dist/life-rhythm/cooking-timer-store.d.ts +50 -0
- package/dist/life-rhythm/cooking-timer-store.js +240 -0
- package/dist/life-rhythm/day-context.d.ts +30 -0
- package/dist/life-rhythm/day-context.js +198 -0
- package/dist/life-rhythm/etalab-holiday-provider.d.ts +40 -0
- package/dist/life-rhythm/etalab-holiday-provider.js +318 -0
- package/dist/life-rhythm/home-mode-store.d.ts +32 -0
- package/dist/life-rhythm/home-mode-store.js +184 -0
- package/dist/life-rhythm/index.d.ts +6 -0
- package/dist/life-rhythm/index.js +7 -0
- package/dist/life-rhythm/types.d.ts +88 -0
- package/dist/life-rhythm/types.js +33 -0
- package/dist/life-rhythm/zoned-minute.d.ts +24 -0
- package/dist/life-rhythm/zoned-minute.js +113 -0
- package/dist/location/index.d.ts +2 -12
- package/dist/location/index.js +129 -56
- package/dist/logging/interaction-logger.js +29 -46
- package/dist/lora/dataset-v3-plan.d.ts +27 -0
- package/dist/lora/dataset-v3-plan.js +121 -0
- package/dist/lora/dataset.d.ts +26 -0
- package/dist/lora/dataset.js +165 -0
- package/dist/lora/fal-krea-trainer.d.ts +54 -0
- package/dist/lora/fal-krea-trainer.js +197 -0
- package/dist/lora/generate-training-set.d.ts +61 -0
- package/dist/lora/generate-training-set.js +190 -0
- package/dist/lora/identity-dataset-gate.d.ts +104 -0
- package/dist/lora/identity-dataset-gate.js +204 -0
- package/dist/lora/identity-dataset-promotion.d.ts +32 -0
- package/dist/lora/identity-dataset-promotion.js +269 -0
- package/dist/lora/index.d.ts +11 -0
- package/dist/lora/index.js +12 -0
- package/dist/lora/install-comfy.d.ts +14 -0
- package/dist/lora/install-comfy.js +63 -0
- package/dist/lora/lisa-avatar-bible.d.ts +85 -0
- package/dist/lora/lisa-avatar-bible.js +275 -0
- package/dist/lora/local-plan.d.ts +10 -0
- package/dist/lora/local-plan.js +205 -0
- package/dist/lora/pack-dataset.d.ts +7 -0
- package/dist/lora/pack-dataset.js +39 -0
- package/dist/lora/quality-gate.d.ts +31 -0
- package/dist/lora/quality-gate.js +90 -0
- package/dist/lora/types.d.ts +66 -0
- package/dist/lora/types.js +5 -0
- package/dist/lsp/lsp-client.d.ts +12 -0
- package/dist/lsp/lsp-client.js +45 -9
- package/dist/lsp/server.js +1 -1
- package/dist/mcp/approval-elicitation.d.ts +1 -0
- package/dist/mcp/approval-elicitation.js +2 -0
- package/dist/mcp/client.d.ts +15 -1
- package/dist/mcp/client.js +116 -24
- package/dist/mcp/config.d.ts +32 -1
- package/dist/mcp/config.js +175 -19
- package/dist/mcp/import-normalize.d.ts +12 -0
- package/dist/mcp/import-normalize.js +114 -0
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/mcp-agent-tools.d.ts +1 -1
- package/dist/mcp/mcp-agent-tools.js +76 -73
- package/dist/mcp/mcp-ckg-tools.d.ts +31 -0
- package/dist/mcp/mcp-ckg-tools.js +121 -0
- package/dist/mcp/mcp-client.js +8 -5
- package/dist/mcp/mcp-desktop-tools.d.ts +1 -1
- package/dist/mcp/mcp-desktop-tools.js +105 -99
- package/dist/mcp/mcp-memory-tools.d.ts +1 -1
- package/dist/mcp/mcp-memory-tools.js +63 -61
- package/dist/mcp/mcp-oauth.js +5 -2
- package/dist/mcp/mcp-server.d.ts +48 -79
- package/dist/mcp/mcp-server.js +445 -478
- package/dist/mcp/mcp-session-tools.d.ts +1 -1
- package/dist/mcp/mcp-session-tools.js +95 -92
- package/dist/mcp/profiles.d.ts +18 -0
- package/dist/mcp/profiles.js +65 -0
- package/dist/mcp/prompt-footprint.d.ts +21 -0
- package/dist/mcp/prompt-footprint.js +39 -0
- package/dist/mcp/transports.d.ts +10 -5
- package/dist/mcp/transports.js +61 -99
- package/dist/mcp/types.d.ts +5 -0
- package/dist/meals/allergens.d.ts +19 -0
- package/dist/meals/allergens.js +122 -0
- package/dist/meals/compatibility.d.ts +6 -0
- package/dist/meals/compatibility.js +109 -0
- package/dist/meals/food-inventory-store.d.ts +51 -0
- package/dist/meals/food-inventory-store.js +257 -0
- package/dist/meals/index.d.ts +10 -0
- package/dist/meals/index.js +11 -0
- package/dist/meals/meal-engine.d.ts +7 -0
- package/dist/meals/meal-engine.js +206 -0
- package/dist/meals/meal-plan-store.d.ts +73 -0
- package/dist/meals/meal-plan-store.js +271 -0
- package/dist/meals/private-json-store.d.ts +9 -0
- package/dist/meals/private-json-store.js +92 -0
- package/dist/meals/profile-store.d.ts +49 -0
- package/dist/meals/profile-store.js +296 -0
- package/dist/meals/profile-validator.d.ts +7 -0
- package/dist/meals/profile-validator.js +124 -0
- package/dist/meals/recipe-normalizer.d.ts +7 -0
- package/dist/meals/recipe-normalizer.js +162 -0
- package/dist/meals/store-validation.d.ts +21 -0
- package/dist/meals/store-validation.js +101 -0
- package/dist/meals/types.d.ts +170 -0
- package/dist/meals/types.js +12 -0
- package/dist/media/comfy-health-supervisor.d.ts +142 -0
- package/dist/media/comfy-health-supervisor.js +608 -0
- package/dist/media/comfyui-recipe-contract.d.ts +696 -0
- package/dist/media/comfyui-recipe-contract.js +580 -0
- package/dist/media/comfyui-recipe-engine.d.ts +3 -0
- package/dist/media/comfyui-recipe-engine.js +4 -0
- package/dist/media/comfyui-recipe-registry.d.ts +35 -0
- package/dist/media/comfyui-recipe-registry.js +385 -0
- package/dist/media/comfyui-recipe-runtime.d.ts +135 -0
- package/dist/media/comfyui-recipe-runtime.js +942 -0
- package/dist/media/content-tier.d.ts +25 -0
- package/dist/media/content-tier.js +29 -0
- package/dist/meeting/analyzer.d.ts +24 -0
- package/dist/meeting/analyzer.js +402 -0
- package/dist/meeting/index.d.ts +13 -0
- package/dist/meeting/index.js +48 -0
- package/dist/meeting/markdown.d.ts +3 -0
- package/dist/meeting/markdown.js +51 -0
- package/dist/meeting/output.d.ts +13 -0
- package/dist/meeting/output.js +155 -0
- package/dist/meeting/transcript.d.ts +25 -0
- package/dist/meeting/transcript.js +292 -0
- package/dist/meeting/types.d.ts +112 -0
- package/dist/meeting/types.js +9 -0
- package/dist/memory/adapters/network-memory-adapters.d.ts +19 -4
- package/dist/memory/adapters/network-memory-adapters.js +4 -4
- package/dist/memory/auto-memory.js +5 -2
- package/dist/memory/background-extractor.d.ts +43 -0
- package/dist/memory/background-extractor.js +368 -0
- package/dist/memory/buddy-memory-client.d.ts +40 -0
- package/dist/memory/buddy-memory-client.js +198 -0
- package/dist/memory/ckg-engine-policy.d.ts +19 -0
- package/dist/memory/ckg-engine-policy.js +45 -0
- package/dist/memory/ckg-fact-reconciliation.d.ts +81 -0
- package/dist/memory/ckg-fact-reconciliation.js +155 -0
- package/dist/memory/ckg-redaction.d.ts +2 -0
- package/dist/memory/ckg-redaction.js +25 -0
- package/dist/memory/coding-style-analyzer.js +2 -2
- package/dist/memory/collective-knowledge-graph.d.ts +380 -0
- package/dist/memory/collective-knowledge-graph.js +1228 -0
- package/dist/memory/enhanced-memory.d.ts +29 -0
- package/dist/memory/enhanced-memory.js +153 -63
- package/dist/memory/facts-memory.d.ts +20 -5
- package/dist/memory/facts-memory.js +68 -12
- package/dist/memory/hybrid-mmr.d.ts +71 -0
- package/dist/memory/hybrid-mmr.js +127 -0
- package/dist/memory/hybrid-search.js +4 -1
- package/dist/memory/knowledge-graph.d.ts +23 -2
- package/dist/memory/knowledge-graph.js +62 -47
- package/dist/memory/memory-candidate-queue.d.ts +2 -2
- package/dist/memory/memory-candidate-queue.js +15 -10
- package/dist/memory/memory-consolidation.d.ts +8 -0
- package/dist/memory/memory-consolidation.js +66 -17
- package/dist/memory/memory-forgetting.d.ts +57 -0
- package/dist/memory/memory-forgetting.js +87 -0
- package/dist/memory/ocr-memory-pipeline.js +16 -10
- package/dist/memory/persistent-memory.d.ts +111 -8
- package/dist/memory/persistent-memory.js +788 -149
- package/dist/memory/presence-injector.d.ts +1 -1
- package/dist/memory/presence-injector.js +9 -4
- package/dist/memory/semantic-memory-search.js +12 -9
- package/dist/memory/subagent-memory.js +8 -8
- package/dist/memory/user-model.js +9 -4
- package/dist/metrics/metrics-collector.d.ts +1 -0
- package/dist/metrics/metrics-collector.js +11 -2
- package/dist/nodes/device-node.d.ts +5 -2
- package/dist/nodes/device-node.js +61 -19
- package/dist/nodes/index.d.ts +32 -2
- package/dist/nodes/index.js +208 -7
- package/dist/nodes/transports/adb-transport.d.ts +2 -6
- package/dist/nodes/transports/adb-transport.js +29 -13
- package/dist/nodes/transports/base-transport.d.ts +10 -0
- package/dist/observability/mobile-supervision-gateway-contract.js +20 -7
- package/dist/observability/run-event-writer.d.ts +21 -0
- package/dist/observability/run-event-writer.js +81 -0
- package/dist/observability/run-store.d.ts +11 -1
- package/dist/observability/run-store.js +107 -35
- package/dist/observability/run-trajectory-load.d.ts +16 -0
- package/dist/observability/run-trajectory-load.js +266 -0
- package/dist/observability/run-trajectory.d.ts +168 -0
- package/dist/observability/run-trajectory.js +468 -0
- package/dist/observability/run-viewer.d.ts +5 -1
- package/dist/observability/run-viewer.js +83 -9
- package/dist/observability/turn-metrics.d.ts +86 -0
- package/dist/observability/turn-metrics.js +201 -0
- package/dist/offline/offline-mode.js +10 -9
- package/dist/openclaw/gateway-bridge.js +3 -2
- package/dist/optimization/latency-optimizer.d.ts +2 -1
- package/dist/optimization/latency-optimizer.js +2 -2
- package/dist/optimization/model-routing.d.ts +3 -0
- package/dist/optimization/prompt-cache.d.ts +19 -2
- package/dist/optimization/prompt-cache.js +41 -6
- package/dist/orchestration/orchestrator.d.ts +21 -0
- package/dist/orchestration/orchestrator.js +126 -16
- package/dist/orchestration/types.d.ts +2 -0
- package/dist/performance/lazy-loader.js +2 -1
- package/dist/performance/tool-cache.d.ts +4 -0
- package/dist/performance/tool-cache.js +4 -2
- package/dist/persistence/conversation-branches.js +9 -2
- package/dist/persistence/session-content.d.ts +8 -0
- package/dist/persistence/session-content.js +76 -0
- package/dist/persistence/session-handoff.d.ts +64 -0
- package/dist/persistence/session-handoff.js +80 -0
- package/dist/persistence/session-history.d.ts +4 -0
- package/dist/persistence/session-history.js +38 -0
- package/dist/persistence/session-store.d.ts +35 -0
- package/dist/persistence/session-store.js +104 -37
- package/dist/personas/persona-manager.d.ts +39 -1
- package/dist/personas/persona-manager.js +292 -38
- package/dist/plugins/bundled/groq-provider.js +10 -7
- package/dist/plugins/bundled/openrouter-provider.js +2 -1
- package/dist/plugins/code-explorer/CodeExplorerManager.d.ts +62 -8
- package/dist/plugins/code-explorer/CodeExplorerManager.js +255 -32
- package/dist/plugins/code-explorer/code-explorer-client.d.ts +36 -0
- package/dist/plugins/code-explorer/code-explorer-client.js +86 -0
- package/dist/plugins/code-explorer/index.d.ts +1 -3
- package/dist/plugins/code-explorer/index.js +0 -1
- package/dist/plugins/git-pinned-marketplace.js +3 -2
- package/dist/plugins/plugin-manager.js +16 -10
- package/dist/plugins/sandbox-worker.js +1 -1
- package/dist/prompts/prompt-manager.js +11 -4
- package/dist/prompts/system-base.js +33 -5
- package/dist/protocols/a2a/codebuddy-executor.d.ts +20 -2
- package/dist/protocols/a2a/codebuddy-executor.js +34 -14
- package/dist/protocols/a2a/index.d.ts +7 -1
- package/dist/protocols/a2a/index.js +32 -3
- package/dist/protocols/a2a/jsonrpc-v1.d.ts +41 -0
- package/dist/protocols/a2a/jsonrpc-v1.js +145 -0
- package/dist/protocols/a2a/peer-config.d.ts +20 -0
- package/dist/protocols/a2a/peer-config.js +55 -0
- package/dist/protocols/acp/acp-agentic-runner.d.ts +6 -2
- package/dist/protocols/acp/acp-agentic-runner.js +91 -15
- package/dist/protocols/acp/acp-session-store.js +28 -5
- package/dist/protocols/acp/acp-stdio-server.d.ts +13 -0
- package/dist/protocols/acp/acp-stdio-server.js +30 -3
- package/dist/providers/active-llm-model-pool.d.ts +45 -0
- package/dist/providers/active-llm-model-pool.js +139 -0
- package/dist/providers/active-llm-registry.js +48 -8
- package/dist/providers/auxiliary-provider.d.ts +1 -1
- package/dist/providers/auxiliary-provider.js +23 -10
- package/dist/providers/chatgpt-models.d.ts +71 -0
- package/dist/providers/chatgpt-models.js +302 -0
- package/dist/providers/codex-oauth.d.ts +8 -0
- package/dist/providers/codex-oauth.js +75 -43
- package/dist/providers/gemini-oauth.js +7 -6
- package/dist/providers/grok-provider.js +1 -1
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.js +3 -0
- package/dist/providers/local-model-resolver.d.ts +66 -0
- package/dist/providers/local-model-resolver.js +128 -0
- package/dist/providers/model-egress.d.ts +8 -0
- package/dist/providers/model-egress.js +62 -0
- package/dist/providers/model-provider-compat.d.ts +13 -0
- package/dist/providers/model-provider-compat.js +49 -0
- package/dist/providers/provider-catalog.d.ts +4 -1
- package/dist/providers/provider-catalog.js +494 -28
- package/dist/providers/provider-failover-notify.d.ts +15 -0
- package/dist/providers/provider-failover-notify.js +93 -0
- package/dist/providers/provider-failover-policy.d.ts +28 -0
- package/dist/providers/provider-failover-policy.js +188 -0
- package/dist/providers/provider-failover-user-notice.d.ts +13 -0
- package/dist/providers/provider-failover-user-notice.js +49 -0
- package/dist/providers/provider-fallback.d.ts +1 -0
- package/dist/providers/provider-fallback.js +1 -1
- package/dist/providers/provider-health.d.ts +46 -0
- package/dist/providers/provider-health.js +249 -0
- package/dist/providers/turboquant-provider.d.ts +1 -1
- package/dist/providers/xai-oauth.js +7 -34
- package/dist/queue/persistent-queue.js +9 -6
- package/dist/renderers/charts/special-charts.d.ts +7 -1
- package/dist/renderers/charts/special-charts.js +5 -0
- package/dist/renderers/weather-conditions.d.ts +20 -0
- package/dist/renderers/weather-conditions.js +74 -0
- package/dist/renderers/weather-renderer.js +4 -18
- package/dist/rendering/ansi.d.ts +4 -0
- package/dist/rendering/ansi.js +149 -0
- package/dist/rendering/index.d.ts +19 -0
- package/dist/rendering/index.js +18 -0
- package/dist/rendering/plain.d.ts +2 -0
- package/dist/rendering/plain.js +91 -0
- package/dist/rendering/telegram-html.d.ts +7 -0
- package/dist/rendering/telegram-html.js +76 -16
- package/dist/research/auto-ingest.d.ts +45 -0
- package/dist/research/auto-ingest.js +85 -0
- package/dist/research/code-explorer-source.d.ts +29 -0
- package/dist/research/code-explorer-source.js +76 -0
- package/dist/research/connector-source.d.ts +25 -0
- package/dist/research/connector-source.js +314 -0
- package/dist/research/paper-qa/answer.d.ts +72 -0
- package/dist/research/paper-qa/answer.js +227 -0
- package/dist/research/paper-qa/corpus.d.ts +36 -0
- package/dist/research/paper-qa/corpus.js +102 -0
- package/dist/research/paper-qa/disk-embedding-cache.d.ts +28 -0
- package/dist/research/paper-qa/disk-embedding-cache.js +193 -0
- package/dist/research/paper-qa/index.d.ts +31 -0
- package/dist/research/paper-qa/index.js +24 -0
- package/dist/research/paper-qa/paper-qa-pipeline.d.ts +107 -0
- package/dist/research/paper-qa/paper-qa-pipeline.js +163 -0
- package/dist/research/paper-qa/passage-index.d.ts +203 -0
- package/dist/research/paper-qa/passage-index.js +405 -0
- package/dist/research/paper-qa/pdf-structure.d.ts +37 -0
- package/dist/research/paper-qa/pdf-structure.js +377 -0
- package/dist/research/paper-qa/persistent-corpus-index.d.ts +23 -0
- package/dist/research/paper-qa/persistent-corpus-index.js +122 -0
- package/dist/research/paper-qa/prose-chunker.d.ts +19 -0
- package/dist/research/paper-qa/prose-chunker.js +201 -0
- package/dist/research/paper-qa/provenance.d.ts +24 -0
- package/dist/research/paper-qa/provenance.js +40 -0
- package/dist/research/paper-qa/rcs.d.ts +78 -0
- package/dist/research/paper-qa/rcs.js +200 -0
- package/dist/research/paper-qa/types.d.ts +124 -0
- package/dist/research/paper-qa/types.js +13 -0
- package/dist/research/publication-sources.d.ts +34 -0
- package/dist/research/publication-sources.js +131 -0
- package/dist/research/relation-classifier.d.ts +13 -0
- package/dist/research/relation-classifier.js +58 -0
- package/dist/research/research-topics.d.ts +13 -0
- package/dist/research/research-topics.js +81 -0
- package/dist/review/apply-transaction.d.ts +40 -0
- package/dist/review/apply-transaction.js +112 -0
- package/dist/review/diff-model.d.ts +39 -0
- package/dist/review/diff-model.js +124 -0
- package/dist/review/llm-client.d.ts +30 -0
- package/dist/review/llm-client.js +98 -0
- package/dist/review/llm-reviewer.d.ts +16 -0
- package/dist/review/llm-reviewer.js +122 -0
- package/dist/review/review-engine.d.ts +54 -0
- package/dist/review/review-engine.js +0 -0
- package/dist/review/revision-loop.d.ts +67 -0
- package/dist/review/revision-loop.js +160 -0
- package/dist/review/static-gate.d.ts +13 -0
- package/dist/review/static-gate.js +110 -0
- package/dist/review/types.d.ts +122 -0
- package/dist/review/types.js +24 -0
- package/dist/review/write-gate.d.ts +55 -0
- package/dist/review/write-gate.js +121 -0
- package/dist/sandbox/auto-sandbox.d.ts +4 -2
- package/dist/sandbox/auto-sandbox.js +14 -1
- package/dist/sandbox/docker-sandbox.d.ts +39 -0
- package/dist/sandbox/docker-sandbox.js +292 -14
- package/dist/sandbox/execpolicy.d.ts +36 -1
- package/dist/sandbox/execpolicy.js +375 -40
- package/dist/sandbox/os-sandbox.d.ts +54 -1
- package/dist/sandbox/os-sandbox.js +315 -70
- package/dist/sandbox/sandbox-backend.d.ts +2 -0
- package/dist/scheduler/cron-scheduler.d.ts +16 -2
- package/dist/scheduler/cron-scheduler.js +177 -45
- package/dist/scheduler/job-notepad.d.ts +69 -0
- package/dist/scheduler/job-notepad.js +339 -0
- package/dist/scripting/codebuddy-bindings.js +2 -1
- package/dist/search/bm25.js +5 -2
- package/dist/search/usearch-index.js +7 -5
- package/dist/security/audit-logger.d.ts +1 -1
- package/dist/security/audit-logger.js +14 -7
- package/dist/security/bash-allowlist/allowlist-store.d.ts +8 -2
- package/dist/security/bash-allowlist/allowlist-store.js +52 -12
- package/dist/security/bash-allowlist/approval-flow.d.ts +1 -1
- package/dist/security/bash-allowlist/approval-flow.js +10 -8
- package/dist/security/bash-allowlist/deny-guard.d.ts +14 -0
- package/dist/security/bash-allowlist/deny-guard.js +61 -0
- package/dist/security/bash-allowlist/types.d.ts +5 -0
- package/dist/security/bash-parser.d.ts +32 -0
- package/dist/security/bash-parser.js +129 -14
- package/dist/security/compute-confinement.d.ts +4 -0
- package/dist/security/compute-confinement.js +89 -0
- package/dist/security/dangerous-patterns.js +18 -3
- package/dist/security/declarative-rules.d.ts +1 -1
- package/dist/security/declarative-rules.js +242 -65
- package/dist/security/dependency-vuln-scanner.js +4 -4
- package/dist/security/dev-origins.d.ts +40 -0
- package/dist/security/dev-origins.js +111 -0
- package/dist/security/docker-sandbox/manager.js +1 -1
- package/dist/security/env-blocklist.d.ts +7 -0
- package/dist/security/env-blocklist.js +22 -2
- package/dist/security/guardian-agent.d.ts +0 -5
- package/dist/security/guardian-agent.js +17 -6
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.js +2 -0
- package/dist/security/native-sandbox.d.ts +80 -0
- package/dist/security/native-sandbox.js +455 -0
- package/dist/security/pack-contents-policy.d.ts +49 -0
- package/dist/security/pack-contents-policy.js +139 -0
- package/dist/security/permission-config.js +2 -5
- package/dist/security/permission-modes.d.ts +11 -0
- package/dist/security/permission-modes.js +71 -7
- package/dist/security/policy-amendments.js +40 -22
- package/dist/security/policy-engine.js +39 -12
- package/dist/security/powershell-parser.d.ts +40 -0
- package/dist/security/powershell-parser.js +198 -0
- package/dist/security/remote-approval.d.ts +0 -1
- package/dist/security/remote-approval.js +3 -2
- package/dist/security/safe-binaries.d.ts +13 -1
- package/dist/security/safe-binaries.js +240 -32
- package/dist/security/safe-fetch.d.ts +7 -0
- package/dist/security/safe-fetch.js +101 -0
- package/dist/security/sandbox.js +2 -2
- package/dist/security/secret-patterns.d.ts +18 -0
- package/dist/security/secret-patterns.js +232 -0
- package/dist/security/secret-scrubber.d.ts +31 -0
- package/dist/security/secret-scrubber.js +170 -0
- package/dist/security/secrets-detector.d.ts +3 -1
- package/dist/security/secrets-detector.js +3 -106
- package/dist/security/security-modes.js +2 -1
- package/dist/security/session-encryption.d.ts +11 -2
- package/dist/security/session-encryption.js +59 -7
- package/dist/security/shell-env-policy.js +11 -2
- package/dist/security/skill-scanner.d.ts +2 -2
- package/dist/security/skill-scanner.js +237 -11
- package/dist/security/ssrf-guard.d.ts +13 -0
- package/dist/security/ssrf-guard.js +27 -0
- package/dist/security/text-deobfuscation.d.ts +41 -0
- package/dist/security/text-deobfuscation.js +256 -0
- package/dist/security/tool-permissions.js +2 -3
- package/dist/security/tool-policy/approval-scope.d.ts +11 -0
- package/dist/security/tool-policy/approval-scope.js +67 -0
- package/dist/security/tool-policy/policy-manager.d.ts +9 -0
- package/dist/security/tool-policy/policy-manager.js +28 -1
- package/dist/security/tool-policy/profiles.js +24 -0
- package/dist/security/tool-policy/tool-groups.js +26 -3
- package/dist/security/tool-policy/types.d.ts +3 -1
- package/dist/security/tool-policy/types.js +2 -0
- package/dist/security/trust-folders.js +3 -2
- package/dist/security/write-policy.d.ts +8 -0
- package/dist/security/write-policy.js +63 -1
- package/dist/self-model/evolution-notes.d.ts +51 -0
- package/dist/self-model/evolution-notes.js +324 -0
- package/dist/sensory/agent-reply.d.ts +136 -0
- package/dist/sensory/agent-reply.js +682 -0
- package/dist/sensory/alert.d.ts +18 -0
- package/dist/sensory/alert.js +105 -0
- package/dist/sensory/arrival-opener.d.ts +102 -0
- package/dist/sensory/arrival-opener.js +292 -0
- package/dist/sensory/audio-scene.d.ts +24 -0
- package/dist/sensory/audio-scene.js +74 -0
- package/dist/sensory/camera-keyframe-policy.d.ts +11 -0
- package/dist/sensory/camera-keyframe-policy.js +43 -0
- package/dist/sensory/conversation-cues.d.ts +55 -0
- package/dist/sensory/conversation-cues.js +140 -0
- package/dist/sensory/domain-event-bridge.d.ts +7 -0
- package/dist/sensory/domain-event-bridge.js +134 -0
- package/dist/sensory/dreaming.d.ts +17 -0
- package/dist/sensory/dreaming.js +52 -2
- package/dist/sensory/elevenlabs-library.d.ts +91 -0
- package/dist/sensory/elevenlabs-library.js +303 -0
- package/dist/sensory/episodic-journal.d.ts +69 -0
- package/dist/sensory/episodic-journal.js +240 -0
- package/dist/sensory/error-watch-reaction.d.ts +41 -0
- package/dist/sensory/error-watch-reaction.js +312 -0
- package/dist/sensory/heartbeat-fallback.d.ts +46 -0
- package/dist/sensory/heartbeat-fallback.js +171 -0
- package/dist/sensory/heartbeat-scheduler.d.ts +6 -0
- package/dist/sensory/heartbeat-scheduler.js +27 -7
- package/dist/sensory/hybrid-reply.d.ts +132 -0
- package/dist/sensory/hybrid-reply.js +1217 -0
- package/dist/sensory/reactions.d.ts +6 -0
- package/dist/sensory/reactions.js +10 -1
- package/dist/sensory/respond-decider.d.ts +124 -0
- package/dist/sensory/respond-decider.js +608 -0
- package/dist/sensory/rule-templates.d.ts +30 -0
- package/dist/sensory/rule-templates.js +100 -0
- package/dist/sensory/schedule-emitter.d.ts +24 -0
- package/dist/sensory/schedule-emitter.js +57 -0
- package/dist/sensory/screen-reaction.js +15 -1
- package/dist/sensory/semantic-vision-reaction.d.ts +36 -0
- package/dist/sensory/semantic-vision-reaction.js +342 -0
- package/dist/sensory/sensory-action-executor.d.ts +98 -0
- package/dist/sensory/sensory-action-executor.js +473 -0
- package/dist/sensory/sensory-bridge.d.ts +11 -1
- package/dist/sensory/sensory-bridge.js +59 -7
- package/dist/sensory/sensory-rules-engine.d.ts +81 -0
- package/dist/sensory/sensory-rules-engine.js +434 -0
- package/dist/sensory/sensory-status.d.ts +102 -0
- package/dist/sensory/sensory-status.js +291 -0
- package/dist/sensory/speech-engine-config.d.ts +68 -0
- package/dist/sensory/speech-engine-config.js +157 -0
- package/dist/sensory/speech-reaction.d.ts +183 -7
- package/dist/sensory/speech-reaction.js +2141 -35
- package/dist/sensory/speech-sanitizer.d.ts +12 -0
- package/dist/sensory/speech-sanitizer.js +143 -0
- package/dist/sensory/system-vitals-emitter.d.ts +130 -0
- package/dist/sensory/system-vitals-emitter.js +514 -0
- package/dist/sensory/tts-cache.d.ts +76 -0
- package/dist/sensory/tts-cache.js +0 -0
- package/dist/sensory/turn-detector.d.ts +28 -0
- package/dist/sensory/turn-detector.js +57 -0
- package/dist/sensory/vision-description-safety.d.ts +4 -0
- package/dist/sensory/vision-description-safety.js +25 -0
- package/dist/sensory/vision-reaction.d.ts +21 -7
- package/dist/sensory/vision-reaction.js +209 -18
- package/dist/sensory/voice-activity.d.ts +69 -0
- package/dist/sensory/voice-activity.js +271 -0
- package/dist/sensory/voice-clock.d.ts +19 -0
- package/dist/sensory/voice-clock.js +111 -0
- package/dist/sensory/voice-entrainment.d.ts +62 -0
- package/dist/sensory/voice-entrainment.js +176 -0
- package/dist/sensory/voice-interactions.d.ts +13 -0
- package/dist/sensory/voice-interactions.js +258 -0
- package/dist/sensory/voice-loop.d.ts +635 -0
- package/dist/sensory/voice-loop.js +3638 -0
- package/dist/sensory/voice-replay-lab.d.ts +32 -0
- package/dist/sensory/voice-replay-lab.js +109 -0
- package/dist/sensory/voice-stream.d.ts +121 -0
- package/dist/sensory/voice-stream.js +598 -0
- package/dist/sensory/voice-turn-coordinator.d.ts +88 -0
- package/dist/sensory/voice-turn-coordinator.js +258 -0
- package/dist/sensory/voice-turn-taking.d.ts +26 -0
- package/dist/sensory/voice-turn-taking.js +59 -0
- package/dist/server/agent-adapter.d.ts +49 -3
- package/dist/server/agent-adapter.js +26 -4
- package/dist/server/auth/device-session-context.d.ts +9 -0
- package/dist/server/auth/device-session-context.js +13 -0
- package/dist/server/auth/device-store.d.ts +89 -0
- package/dist/server/auth/device-store.js +261 -0
- package/dist/server/auth/device-token.d.ts +3 -0
- package/dist/server/auth/device-token.js +6 -0
- package/dist/server/auth/jwt.js +4 -0
- package/dist/server/channel-a2a-bridge.js +1 -1
- package/dist/server/exposure-diagnostic.d.ts +25 -0
- package/dist/server/exposure-diagnostic.js +51 -0
- package/dist/server/heartbeat-monitor.d.ts +13 -0
- package/dist/server/heartbeat-monitor.js +8 -3
- package/dist/server/http-agent-sessions.d.ts +32 -0
- package/dist/server/http-agent-sessions.js +245 -0
- package/dist/server/index.d.ts +3 -10
- package/dist/server/index.js +941 -46
- package/dist/server/mcp/approval-elicitation.d.ts +144 -0
- package/dist/server/mcp/approval-elicitation.js +377 -0
- package/dist/server/middleware/auth.d.ts +11 -0
- package/dist/server/middleware/auth.js +57 -2
- package/dist/server/middleware/error-handler.d.ts +5 -0
- package/dist/server/middleware/error-handler.js +30 -4
- package/dist/server/middleware/index.d.ts +1 -1
- package/dist/server/middleware/index.js +1 -1
- package/dist/server/mobile/album.d.ts +46 -0
- package/dist/server/mobile/album.js +144 -0
- package/dist/server/mobile/assets/app.js +3036 -0
- package/dist/server/mobile/assets/emoji-data.js +508 -0
- package/dist/server/mobile/assets/icon-192.png +0 -0
- package/dist/server/mobile/assets/icon-512.png +0 -0
- package/dist/server/mobile/assets/icon-96.png +0 -0
- package/dist/server/mobile/assets/icon.svg +12 -0
- package/dist/server/mobile/assets/index.html +261 -0
- package/dist/server/mobile/assets/manifest.webmanifest +37 -0
- package/dist/server/mobile/assets/styles.css +831 -0
- package/dist/server/mobile/assets/sw.js +149 -0
- package/dist/server/mobile/chat-extras.d.ts +9 -0
- package/dist/server/mobile/chat-extras.js +24 -0
- package/dist/server/mobile/index.d.ts +22 -0
- package/dist/server/mobile/index.js +287 -0
- package/dist/server/mobile/link-preview.d.ts +24 -0
- package/dist/server/mobile/link-preview.js +139 -0
- package/dist/server/mobile/push.d.ts +38 -0
- package/dist/server/mobile/push.js +190 -0
- package/dist/server/mobile/status.d.ts +23 -0
- package/dist/server/mobile/status.js +107 -0
- package/dist/server/mobile/telegram-forward.d.ts +14 -0
- package/dist/server/mobile/telegram-forward.js +32 -0
- package/dist/server/mobile/voice-note.d.ts +54 -0
- package/dist/server/mobile/voice-note.js +305 -0
- package/dist/server/origin-check.d.ts +4 -5
- package/dist/server/origin-check.js +43 -8
- package/dist/server/routes/a2a-jsonrpc.d.ts +9 -0
- package/dist/server/routes/a2a-jsonrpc.js +66 -0
- package/dist/server/routes/a2a-protocol.d.ts +12 -0
- package/dist/server/routes/a2a-protocol.js +1 -1
- package/dist/server/routes/canvas.d.ts +7 -1
- package/dist/server/routes/canvas.js +138 -24
- package/dist/server/routes/chat.js +340 -203
- package/dist/server/routes/cognition.d.ts +3 -0
- package/dist/server/routes/cognition.js +75 -0
- package/dist/server/routes/device-auth.d.ts +4 -0
- package/dist/server/routes/device-auth.js +40 -0
- package/dist/server/routes/health.js +93 -81
- package/dist/server/routes/index.d.ts +5 -1
- package/dist/server/routes/index.js +5 -1
- package/dist/server/routes/lessons.d.ts +13 -0
- package/dist/server/routes/lessons.js +111 -0
- package/dist/server/routes/memory.d.ts +12 -0
- package/dist/server/routes/memory.js +191 -131
- package/dist/server/routes/runs.d.ts +9 -0
- package/dist/server/routes/runs.js +50 -0
- package/dist/server/routes/sessions.js +8 -1
- package/dist/server/routes/tools.js +93 -74
- package/dist/server/routes/webhooks.js +56 -46
- package/dist/server/tunnel-manager.js +21 -1
- package/dist/server/types.d.ts +29 -1
- package/dist/server/webhook-agent-queue.d.ts +12 -0
- package/dist/server/webhook-agent-queue.js +58 -0
- package/dist/server/websocket/cognition-bridge.d.ts +13 -0
- package/dist/server/websocket/cognition-bridge.js +334 -0
- package/dist/server/websocket/confirmation-bridge.d.ts +22 -0
- package/dist/server/websocket/confirmation-bridge.js +178 -0
- package/dist/server/websocket/desktop-handler.d.ts +17 -0
- package/dist/server/websocket/desktop-handler.js +177 -16
- package/dist/server/websocket/handler.d.ts +136 -1
- package/dist/server/websocket/handler.js +942 -72
- package/dist/server/websocket/index.d.ts +2 -1
- package/dist/server/websocket/index.js +2 -1
- package/dist/server/websocket/peer-rpc.d.ts +1 -1
- package/dist/server/websocket/peer-rpc.js +25 -3
- package/dist/services/prompt-builder.d.ts +49 -2
- package/dist/services/prompt-builder.js +318 -99
- package/dist/services/runtime-settings-context.d.ts +73 -0
- package/dist/services/runtime-settings-context.js +69 -0
- package/dist/sessions/timeline-snapshot.d.ts +35 -0
- package/dist/sessions/timeline-snapshot.js +144 -0
- package/dist/sessions/timeline.d.ts +33 -0
- package/dist/sessions/timeline.js +85 -0
- package/dist/shared/context-optimization-metadata.d.ts +29 -0
- package/dist/shared/context-optimization-metadata.js +73 -0
- package/dist/shared/engine-types.d.ts +26 -0
- package/dist/skills/bash-injection.d.ts +2 -2
- package/dist/skills/bash-injection.js +9 -2
- package/dist/skills/bundled/code-explorer.skill.md +50 -0
- package/dist/skills/bundled/file-edit.skill.md +62 -0
- package/dist/skills/bundled/git-commit.skill.md +66 -0
- package/dist/skills/bundled/pubcommander-control/SKILL.md +33 -0
- package/dist/skills/bundled/pubcommander-control/agents/openai.yaml +4 -0
- package/dist/skills/bundled/typescript-expert.skill.md +21 -0
- package/dist/skills/bundled/weather.skill.md +48 -0
- package/dist/skills/bundled/web-app-testing.skill.md +71 -0
- package/dist/skills/bundled/web-search.skill.md +56 -0
- package/dist/skills/executor.js +2 -0
- package/dist/skills/hub.js +68 -44
- package/dist/skills/index.d.ts +6 -3
- package/dist/skills/index.js +19 -4
- package/dist/skills/local-inventory.d.ts +21 -0
- package/dist/skills/local-inventory.js +72 -0
- package/dist/skills/parser.js +2 -0
- package/dist/skills/registry.d.ts +52 -0
- package/dist/skills/registry.js +291 -14
- package/dist/skills/skill-exchange.d.ts +61 -0
- package/dist/skills/skill-exchange.js +523 -0
- package/dist/skills/skill-importer.d.ts +2 -2
- package/dist/skills/skill-importer.js +76 -17
- package/dist/skills/skill-loader.js +2 -2
- package/dist/skills/skill-registry.js +3 -2
- package/dist/skills/skill-signing.d.ts +20 -0
- package/dist/skills/skill-signing.js +106 -0
- package/dist/skills/skill-sources.d.ts +3 -2
- package/dist/skills/skill-sources.js +5 -4
- package/dist/skills/skill-usage-store.d.ts +49 -0
- package/dist/skills/skill-usage-store.js +121 -0
- package/dist/skills/types.d.ts +4 -0
- package/dist/spec/spec-store.js +7 -6
- package/dist/speculative/shadow-workspace.d.ts +79 -0
- package/dist/speculative/shadow-workspace.js +500 -0
- package/dist/talk-mode/index.d.ts +4 -4
- package/dist/talk-mode/index.js +3 -3
- package/dist/talk-mode/providers/elevenlabs-client.d.ts +48 -0
- package/dist/talk-mode/providers/elevenlabs-client.js +117 -0
- package/dist/talk-mode/providers/elevenlabs.js +12 -23
- package/dist/talk-mode/providers/index.d.ts +3 -1
- package/dist/talk-mode/providers/index.js +2 -0
- package/dist/talk-mode/providers/pocket-tts.d.ts +88 -0
- package/dist/talk-mode/providers/pocket-tts.js +334 -0
- package/dist/talk-mode/providers/voicebox-tts.d.ts +24 -0
- package/dist/talk-mode/providers/voicebox-tts.js +120 -0
- package/dist/talk-mode/types.d.ts +39 -1
- package/dist/tasks/background-tasks.js +22 -5
- package/dist/telemetry/otel-tracer.js +5 -2
- package/dist/templates/design-system-apply.d.ts +23 -0
- package/dist/templates/design-system-apply.js +100 -0
- package/dist/templates/project-scaffolding.d.ts +2 -0
- package/dist/templates/project-scaffolding.js +616 -1
- package/dist/testing/ai-integration-tests.js +8 -5
- package/dist/themes/theme-manager.d.ts +12 -0
- package/dist/themes/theme-manager.js +38 -6
- package/dist/themes/theme-schema.d.ts +42 -42
- package/dist/tools/a2a-call-tool.d.ts +34 -0
- package/dist/tools/a2a-call-tool.js +75 -0
- package/dist/tools/advanced/multi-file-editor.js +3 -1
- package/dist/tools/advanced/operation-history.js +2 -1
- package/dist/tools/app-server-tool.d.ts +66 -0
- package/dist/tools/app-server-tool.js +423 -0
- package/dist/tools/apply-patch.d.ts +31 -1
- package/dist/tools/apply-patch.js +214 -19
- package/dist/tools/authored-tools-manifest-2.d.ts +17 -0
- package/dist/tools/authored-tools-manifest-2.js +133 -0
- package/dist/tools/authored-tools-manifest.d.ts +15 -0
- package/dist/tools/authored-tools-manifest.js +13 -0
- package/dist/tools/bash/bash-tool.d.ts +36 -3
- package/dist/tools/bash/bash-tool.js +240 -100
- package/dist/tools/bash/command-validator.d.ts +1 -1
- package/dist/tools/bash/command-validator.js +115 -40
- package/dist/tools/bash/execution-policy.d.ts +42 -0
- package/dist/tools/bash/execution-policy.js +278 -0
- package/dist/tools/bash/security-patterns.js +43 -5
- package/dist/tools/bash/streaming-executor.d.ts +2 -1
- package/dist/tools/bash/streaming-executor.js +172 -78
- package/dist/tools/build-project-tool.d.ts +25 -0
- package/dist/tools/build-project-tool.js +30 -0
- package/dist/tools/bundle-analyze-tool.d.ts +28 -0
- package/dist/tools/bundle-analyze-tool.js +39 -0
- package/dist/tools/code-exec-preflight-runner.d.ts +41 -0
- package/dist/tools/code-exec-preflight-runner.js +254 -0
- package/dist/tools/code-exec-preflight.d.ts +44 -0
- package/dist/tools/code-exec-preflight.js +501 -0
- package/dist/tools/code-exec-tool.d.ts +102 -23
- package/dist/tools/code-exec-tool.js +741 -110
- package/dist/tools/code-explorer-tool.d.ts +1 -1
- package/dist/tools/code-explorer-tool.js +25 -1
- package/dist/tools/code-review.js +5 -0
- package/dist/tools/code-stats-tool.d.ts +43 -0
- package/dist/tools/code-stats-tool.js +70 -0
- package/dist/tools/codebase-replace-tool.js +2 -2
- package/dist/tools/comfy-recipe-tool.d.ts +37 -0
- package/dist/tools/comfy-recipe-tool.js +693 -0
- package/dist/tools/comment-watcher.js +29 -12
- package/dist/tools/community-search.d.ts +93 -0
- package/dist/tools/community-search.js +334 -0
- package/dist/tools/computer-control-harness.js +5 -2
- package/dist/tools/computer-control-tool.d.ts +8 -0
- package/dist/tools/computer-control-tool.js +71 -26
- package/dist/tools/context-expand-tool.d.ts +19 -0
- package/dist/tools/context-expand-tool.js +132 -0
- package/dist/tools/core-code-inspection.d.ts +56 -0
- package/dist/tools/core-code-inspection.js +86 -0
- package/dist/tools/create-skill-tool.d.ts +2 -3
- package/dist/tools/create-skill-tool.js +16 -75
- package/dist/tools/cronjob-tool.d.ts +1 -0
- package/dist/tools/cronjob-tool.js +1 -0
- package/dist/tools/csv/csv-parse.d.ts +19 -0
- package/dist/tools/csv/csv-parse.js +132 -0
- package/dist/tools/csv/csv-wiring.d.ts +8 -0
- package/dist/tools/csv/csv-wiring.js +9 -0
- package/dist/tools/csv-analyze-tool.d.ts +11 -0
- package/dist/tools/csv-analyze-tool.js +114 -0
- package/dist/tools/csv-preview-tool.d.ts +34 -0
- package/dist/tools/csv-preview-tool.js +69 -0
- package/dist/tools/db-migration.js +11 -3
- package/dist/tools/deep-research-tool.d.ts +68 -0
- package/dist/tools/deep-research-tool.js +257 -0
- package/dist/tools/deferred-schema-state.d.ts +19 -0
- package/dist/tools/deferred-schema-state.js +33 -0
- package/dist/tools/dep-inspect-tool.d.ts +32 -0
- package/dist/tools/dep-inspect-tool.js +74 -0
- package/dist/tools/design-system-tool.d.ts +10 -0
- package/dist/tools/design-system-tool.js +95 -0
- package/dist/tools/device-tool.d.ts +2 -1
- package/dist/tools/device-tool.js +21 -0
- package/dist/tools/diagram-tool.js +8 -2
- package/dist/tools/diff-files-tool.d.ts +28 -0
- package/dist/tools/diff-files-tool.js +49 -0
- package/dist/tools/enhanced-search.js +32 -16
- package/dist/tools/env-doctor-tool.d.ts +32 -0
- package/dist/tools/env-doctor-tool.js +55 -0
- package/dist/tools/execute-code-rpc-invoker.d.ts +1 -1
- package/dist/tools/execute-code-rpc-invoker.js +36 -20
- package/dist/tools/execute-code-runner.d.ts +23 -0
- package/dist/tools/execute-code-runner.js +169 -25
- package/dist/tools/extension-forge-tool.d.ts +29 -0
- package/dist/tools/extension-forge-tool.js +288 -0
- package/dist/tools/fetch-tool.js +7 -3
- package/dist/tools/file-search-tool.d.ts +41 -0
- package/dist/tools/file-search-tool.js +99 -0
- package/dist/tools/fleet-room-tool.d.ts +104 -0
- package/dist/tools/fleet-room-tool.js +124 -0
- package/dist/tools/format-project-tool.d.ts +28 -0
- package/dist/tools/format-project-tool.js +45 -0
- package/dist/tools/git-summary-tool.d.ts +36 -0
- package/dist/tools/git-summary-tool.js +65 -0
- package/dist/tools/git-tool.js +16 -4
- package/dist/tools/gpu-avatar-delivery.d.ts +16 -0
- package/dist/tools/gpu-avatar-delivery.js +67 -0
- package/dist/tools/gpu-media-worker.d.ts +96 -0
- package/dist/tools/gpu-media-worker.js +363 -0
- package/dist/tools/gui-tool.js +92 -13
- package/dist/tools/http-probe-tool.d.ts +25 -0
- package/dist/tools/http-probe-tool.js +40 -0
- package/dist/tools/image-tool.js +29 -16
- package/dist/tools/index.d.ts +6 -1
- package/dist/tools/index.js +5 -0
- package/dist/tools/integration-tool-hints.d.ts +4 -0
- package/dist/tools/integration-tool-hints.js +19 -0
- package/dist/tools/interactive-bash.d.ts +29 -1
- package/dist/tools/interactive-bash.js +141 -21
- package/dist/tools/json-query-tool.d.ts +30 -0
- package/dist/tools/json-query-tool.js +49 -0
- package/dist/tools/license-check-tool.d.ts +22 -0
- package/dist/tools/license-check-tool.js +43 -0
- package/dist/tools/lint-project-tool.d.ts +52 -0
- package/dist/tools/lint-project-tool.js +143 -0
- package/dist/tools/list-peers-tool.d.ts +3 -0
- package/dist/tools/list-peers-tool.js +11 -4
- package/dist/tools/local-binary-launch.d.ts +14 -0
- package/dist/tools/local-binary-launch.js +63 -0
- package/dist/tools/lsp-navigation-tools.d.ts +87 -0
- package/dist/tools/lsp-navigation-tools.js +470 -0
- package/dist/tools/markdown-convert.d.ts +51 -0
- package/dist/tools/markdown-convert.js +159 -0
- package/dist/tools/media-generation-tool.d.ts +105 -1
- package/dist/tools/media-generation-tool.js +1892 -18
- package/dist/tools/meeting-notes-tool.d.ts +25 -0
- package/dist/tools/meeting-notes-tool.js +240 -0
- package/dist/tools/merge-conflict-tool.js +54 -26
- package/dist/tools/metadata.d.ts +3 -1
- package/dist/tools/metadata.js +819 -16
- package/dist/tools/mixture-of-agents-tool.d.ts +7 -0
- package/dist/tools/mixture-of-agents-tool.js +230 -31
- package/dist/tools/multi-edit.js +42 -18
- package/dist/tools/ocr-tool.d.ts +43 -0
- package/dist/tools/ocr-tool.js +24 -18
- package/dist/tools/omission-placeholder-detector.js +12 -6
- package/dist/tools/paper-qa-tool.d.ts +73 -0
- package/dist/tools/paper-qa-tool.js +313 -0
- package/dist/tools/peer-chain-tool.js +4 -1
- package/dist/tools/peer-delegate-tool.d.ts +2 -0
- package/dist/tools/peer-delegate-tool.js +11 -1
- package/dist/tools/port-check-tool.d.ts +31 -0
- package/dist/tools/port-check-tool.js +25 -0
- package/dist/tools/project-map-tool.d.ts +39 -0
- package/dist/tools/project-map-tool.js +128 -0
- package/dist/tools/ragchat-tool.d.ts +39 -0
- package/dist/tools/ragchat-tool.js +105 -0
- package/dist/tools/register-tool-handler.d.ts +2 -2
- package/dist/tools/register-tool-handler.js +7 -4
- package/dist/tools/registry/advanced-tools.js +1 -1
- package/dist/tools/registry/attention-tools.d.ts +3 -3
- package/dist/tools/registry/attention-tools.js +14 -10
- package/dist/tools/registry/authored-extra-tools.d.ts +20 -0
- package/dist/tools/registry/authored-extra-tools.js +147 -0
- package/dist/tools/registry/bash-tools.d.ts +2 -2
- package/dist/tools/registry/bash-tools.js +7 -3
- package/dist/tools/registry/browser-operator-tools.d.ts +1 -1
- package/dist/tools/registry/browser-operator-tools.js +17 -3
- package/dist/tools/registry/browser-tools.d.ts +1 -1
- package/dist/tools/registry/browser-tools.js +38 -33
- package/dist/tools/registry/code-explorer-tools.js +6 -1
- package/dist/tools/registry/comfy-recipe-tools.d.ts +2 -0
- package/dist/tools/registry/comfy-recipe-tools.js +5 -0
- package/dist/tools/registry/context-expand-tools.d.ts +3 -0
- package/dist/tools/registry/context-expand-tools.js +6 -0
- package/dist/tools/registry/csv-tools.d.ts +12 -0
- package/dist/tools/registry/csv-tools.js +62 -0
- package/dist/tools/registry/delegate-agent-tools.d.ts +64 -0
- package/dist/tools/registry/delegate-agent-tools.js +206 -0
- package/dist/tools/registry/design-tools.d.ts +12 -0
- package/dist/tools/registry/design-tools.js +80 -0
- package/dist/tools/registry/fleet-tools.d.ts +9 -0
- package/dist/tools/registry/fleet-tools.js +28 -1
- package/dist/tools/registry/index.d.ts +25 -5
- package/dist/tools/registry/index.js +80 -6
- package/dist/tools/registry/interactive-adapters.d.ts +37 -0
- package/dist/tools/registry/interactive-adapters.js +116 -0
- package/dist/tools/registry/knowledge-tools.d.ts +2 -2
- package/dist/tools/registry/knowledge-tools.js +2 -2
- package/dist/tools/registry/lessons-tools.d.ts +7 -0
- package/dist/tools/registry/lessons-tools.js +43 -3
- package/dist/tools/registry/lsp-tools.d.ts +3 -3
- package/dist/tools/registry/lsp-tools.js +9 -3
- package/dist/tools/registry/meeting-tools.d.ts +3 -0
- package/dist/tools/registry/meeting-tools.js +6 -0
- package/dist/tools/registry/memory-tools.d.ts +1 -1
- package/dist/tools/registry/memory-tools.js +40 -28
- package/dist/tools/registry/misc-tools.d.ts +1 -1
- package/dist/tools/registry/misc-tools.js +7 -4
- package/dist/tools/registry/moa-tools.js +13 -0
- package/dist/tools/registry/multimodal-tools.d.ts +73 -1
- package/dist/tools/registry/multimodal-tools.js +581 -4
- package/dist/tools/registry/process-tools.d.ts +16 -0
- package/dist/tools/registry/process-tools.js +136 -1
- package/dist/tools/registry/remind-tools.d.ts +23 -0
- package/dist/tools/registry/remind-tools.js +120 -0
- package/dist/tools/registry/research-tools.d.ts +18 -0
- package/dist/tools/registry/research-tools.js +12 -0
- package/dist/tools/registry/search-tools.d.ts +6 -6
- package/dist/tools/registry/search-tools.js +30 -17
- package/dist/tools/registry/secrets-tools.d.ts +33 -0
- package/dist/tools/registry/secrets-tools.js +71 -0
- package/dist/tools/registry/self-describe-tools.d.ts +23 -0
- package/dist/tools/registry/self-describe-tools.js +169 -0
- package/dist/tools/registry/self-evolution-tools.d.ts +13 -0
- package/dist/tools/registry/self-evolution-tools.js +97 -0
- package/dist/tools/registry/text-editor-tools.d.ts +26 -4
- package/dist/tools/registry/text-editor-tools.js +102 -6
- package/dist/tools/registry/tool-alias-map.d.ts +8 -0
- package/dist/tools/registry/tool-alias-map.js +47 -0
- package/dist/tools/registry/tool-aliases.d.ts +3 -4
- package/dist/tools/registry/tool-aliases.js +12 -48
- package/dist/tools/registry/types.d.ts +5 -0
- package/dist/tools/registry/verify-tools.d.ts +50 -0
- package/dist/tools/registry/verify-tools.js +136 -0
- package/dist/tools/registry/video-studio-tools.d.ts +13 -0
- package/dist/tools/registry/video-studio-tools.js +21 -0
- package/dist/tools/registry/vision-tools.d.ts +15 -1
- package/dist/tools/registry/vision-tools.js +252 -27
- package/dist/tools/registry/web-test-tool.d.ts +66 -0
- package/dist/tools/registry/web-test-tool.js +321 -0
- package/dist/tools/registry/web-tools.d.ts +43 -0
- package/dist/tools/registry/web-tools.js +281 -1
- package/dist/tools/resource-catalog-tool.d.ts +38 -0
- package/dist/tools/resource-catalog-tool.js +46 -0
- package/dist/tools/review-gate-helper.d.ts +44 -0
- package/dist/tools/review-gate-helper.js +110 -0
- package/dist/tools/route-peer-tool.js +62 -11
- package/dist/tools/sbom-generate-tool.d.ts +22 -0
- package/dist/tools/sbom-generate-tool.js +41 -0
- package/dist/tools/scaffold-app-tool.d.ts +48 -0
- package/dist/tools/scaffold-app-tool.js +144 -0
- package/dist/tools/screenshot-tool.js +5 -2
- package/dist/tools/search.d.ts +17 -0
- package/dist/tools/search.js +31 -8
- package/dist/tools/self-describe.d.ts +73 -0
- package/dist/tools/self-describe.js +298 -0
- package/dist/tools/skills-inspection-tool.js +30 -1
- package/dist/tools/stock-quote.d.ts +67 -0
- package/dist/tools/stock-quote.js +645 -0
- package/dist/tools/stream-tool-output.d.ts +3 -0
- package/dist/tools/stream-tool-output.js +33 -0
- package/dist/tools/submit-plan-tool.js +1 -1
- package/dist/tools/test-runner-tool.d.ts +38 -0
- package/dist/tools/test-runner-tool.js +96 -0
- package/dist/tools/text-editor.js +91 -8
- package/dist/tools/text-to-speech-tool.d.ts +1 -1
- package/dist/tools/text-to-speech-tool.js +48 -2
- package/dist/tools/todo-scan-tool.d.ts +39 -0
- package/dist/tools/todo-scan-tool.js +53 -0
- package/dist/tools/tool-call-scheduler.d.ts +10 -0
- package/dist/tools/tool-call-scheduler.js +58 -0
- package/dist/tools/tool-effect.d.ts +5 -0
- package/dist/tools/tool-effect.js +26 -0
- package/dist/tools/tool-manager.js +8 -0
- package/dist/tools/tool-search.d.ts +12 -11
- package/dist/tools/tool-search.js +77 -28
- package/dist/tools/tool-selector.d.ts +7 -0
- package/dist/tools/tool-selector.js +27 -13
- package/dist/tools/tools-md-generator.js +2 -2
- package/dist/tools/types.d.ts +22 -0
- package/dist/tools/types.js +5 -1
- package/dist/tools/video/approved-media-source.d.ts +8 -0
- package/dist/tools/video/approved-media-source.js +59 -0
- package/dist/tools/video/book-manuscript-source.d.ts +49 -0
- package/dist/tools/video/book-manuscript-source.js +263 -0
- package/dist/tools/video/character-in-location.d.ts +42 -0
- package/dist/tools/video/character-in-location.js +161 -0
- package/dist/tools/video/cinematic-trailer-plan.d.ts +203 -0
- package/dist/tools/video/cinematic-trailer-plan.js +498 -0
- package/dist/tools/video/cloud-understand.d.ts +91 -0
- package/dist/tools/video/cloud-understand.js +214 -0
- package/dist/tools/video/comfy-client.d.ts +38 -0
- package/dist/tools/video/comfy-client.js +227 -0
- package/dist/tools/video/comfy-workflow-template.d.ts +70 -0
- package/dist/tools/video/comfy-workflow-template.js +194 -0
- package/dist/tools/video/describe-frame.d.ts +36 -0
- package/dist/tools/video/describe-frame.js +68 -0
- package/dist/tools/video/film-assemble.d.ts +234 -0
- package/dist/tools/video/film-assemble.js +959 -0
- package/dist/tools/video/film-project.d.ts +152 -0
- package/dist/tools/video/film-project.js +312 -0
- package/dist/tools/video/frame-dedup.d.ts +46 -0
- package/dist/tools/video/frame-dedup.js +110 -0
- package/dist/tools/video/frame-sample.d.ts +72 -0
- package/dist/tools/video/frame-sample.js +238 -0
- package/dist/tools/video/google-flow-driver.d.ts +131 -0
- package/dist/tools/video/google-flow-driver.js +312 -0
- package/dist/tools/video/google-flow-handoff.d.ts +75 -0
- package/dist/tools/video/google-flow-handoff.js +121 -0
- package/dist/tools/video/google-flow-plan-export.d.ts +21 -0
- package/dist/tools/video/google-flow-plan-export.js +123 -0
- package/dist/tools/video/google-flow-result-import.d.ts +92 -0
- package/dist/tools/video/google-flow-result-import.js +297 -0
- package/dist/tools/video/hybrid-video-router.d.ts +34 -0
- package/dist/tools/video/hybrid-video-router.js +113 -0
- package/dist/tools/video/localized-media.d.ts +50 -0
- package/dist/tools/video/localized-media.js +128 -0
- package/dist/tools/video/long-form-plan.d.ts +37 -0
- package/dist/tools/video/long-form-plan.js +83 -0
- package/dist/tools/video/long-form-production.d.ts +49 -0
- package/dist/tools/video/long-form-production.js +168 -0
- package/dist/tools/video/long-transcribe.d.ts +94 -0
- package/dist/tools/video/long-transcribe.js +206 -0
- package/dist/tools/video/media-fetch.d.ts +94 -0
- package/dist/tools/video/media-fetch.js +311 -0
- package/dist/tools/video/mermaid-render.d.ts +34 -0
- package/dist/tools/video/mermaid-render.js +127 -0
- package/dist/tools/video/narration.d.ts +96 -0
- package/dist/tools/video/narration.js +505 -0
- package/dist/tools/video/native-fashion-defects.d.ts +27 -0
- package/dist/tools/video/native-fashion-defects.js +80 -0
- package/dist/tools/video/scene-render.d.ts +108 -0
- package/dist/tools/video/scene-render.js +418 -0
- package/dist/tools/video/subtitles.d.ts +49 -0
- package/dist/tools/video/subtitles.js +116 -0
- package/dist/tools/video/video-ckg.d.ts +123 -0
- package/dist/tools/video/video-ckg.js +188 -0
- package/dist/tools/video/video-research-card.d.ts +58 -0
- package/dist/tools/video/video-research-card.js +468 -0
- package/dist/tools/video/video-understanding.d.ts +159 -0
- package/dist/tools/video/video-understanding.js +534 -0
- package/dist/tools/video/visual-gate-report.d.ts +139 -0
- package/dist/tools/video/visual-gate-report.js +379 -0
- package/dist/tools/video/voice-rights-registry.d.ts +13 -0
- package/dist/tools/video/voice-rights-registry.js +142 -0
- package/dist/tools/video/youtube-captions.d.ts +51 -0
- package/dist/tools/video/youtube-captions.js +102 -0
- package/dist/tools/video/youtube-master-quality.d.ts +163 -0
- package/dist/tools/video/youtube-master-quality.js +379 -0
- package/dist/tools/video/youtube-storyboard.d.ts +43 -0
- package/dist/tools/video/youtube-storyboard.js +194 -0
- package/dist/tools/video-flow-handoff-tool.d.ts +181 -0
- package/dist/tools/video-flow-handoff-tool.js +261 -0
- package/dist/tools/video-long-form-plan-tool.d.ts +31 -0
- package/dist/tools/video-long-form-plan-tool.js +87 -0
- package/dist/tools/video-quality-gate-tool.d.ts +97 -0
- package/dist/tools/video-quality-gate-tool.js +189 -0
- package/dist/tools/video-route-tool.d.ts +128 -0
- package/dist/tools/video-route-tool.js +126 -0
- package/dist/tools/video-studio-tool-helpers.d.ts +22 -0
- package/dist/tools/video-studio-tool-helpers.js +128 -0
- package/dist/tools/video-trailer-plan-tool.d.ts +60 -0
- package/dist/tools/video-trailer-plan-tool.js +103 -0
- package/dist/tools/vision/blender-render.d.ts +76 -0
- package/dist/tools/vision/blender-render.js +121 -0
- package/dist/tools/vision/image-processor.d.ts +1 -0
- package/dist/tools/vision/image-processor.js +8 -1
- package/dist/tools/vision/load-sharp.d.ts +53 -0
- package/dist/tools/vision/load-sharp.js +48 -0
- package/dist/tools/vision/mean-luma.d.ts +4 -0
- package/dist/tools/vision/mean-luma.js +189 -0
- package/dist/tools/vision/object-detection.d.ts +90 -0
- package/dist/tools/vision/object-detection.js +403 -0
- package/dist/tools/vision/vision-analysis.js +2 -1
- package/dist/tools/weather.d.ts +33 -0
- package/dist/tools/weather.js +183 -0
- package/dist/tools/web-scrape-tool.d.ts +63 -0
- package/dist/tools/web-scrape-tool.js +318 -0
- package/dist/tools/web-search.d.ts +67 -6
- package/dist/tools/web-search.js +231 -68
- package/dist/tools/workspace-tools.d.ts +39 -0
- package/dist/tools/workspace-tools.js +347 -0
- package/dist/tracks/track-manager.js +9 -8
- package/dist/triggers/webhook-trigger.js +10 -18
- package/dist/ui/components/ChatHistory.d.ts +1 -1
- package/dist/ui/components/ChatHistory.js +14 -2
- package/dist/ui/components/ChatInput.d.ts +2 -1
- package/dist/ui/components/ChatInput.js +42 -88
- package/dist/ui/components/ChatInterface.d.ts +4 -2
- package/dist/ui/components/ChatInterface.js +32 -64
- package/dist/ui/components/CommandSuggestions.d.ts +0 -1
- package/dist/ui/components/CommandSuggestions.js +4 -6
- package/dist/ui/components/FileAutocomplete.d.ts +6 -1
- package/dist/ui/components/FileAutocomplete.js +137 -77
- package/dist/ui/components/FuzzyPicker.d.ts +5 -0
- package/dist/ui/components/FuzzyPicker.js +1 -1
- package/dist/ui/components/KeyboardHelp.js +8 -6
- package/dist/ui/components/ModelSelection.js +6 -5
- package/dist/ui/components/StatusBar.d.ts +2 -1
- package/dist/ui/components/StatusBar.js +8 -7
- package/dist/ui/context/theme-context.js +3 -2
- package/dist/ui/http-server/server.js +2 -2
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/utils/markdown-renderer.js +4 -13
- package/dist/undo/checkpoint-manager.d.ts +3 -0
- package/dist/undo/checkpoint-manager.js +6 -1
- package/dist/utils/approval-pattern-tracker.js +5 -13
- package/dist/utils/ascii-banner.d.ts +1 -1
- package/dist/utils/ascii-banner.js +1 -1
- package/dist/utils/atomic-write.d.ts +99 -0
- package/dist/utils/atomic-write.js +559 -0
- package/dist/utils/audio-player.d.ts +1 -0
- package/dist/utils/audio-player.js +7 -3
- package/dist/utils/autonomy-manager.js +12 -3
- package/dist/utils/bounded-output.d.ts +16 -0
- package/dist/utils/bounded-output.js +63 -0
- package/dist/utils/command-exists.d.ts +14 -0
- package/dist/utils/command-exists.js +43 -0
- package/dist/utils/config-validation/schema.d.ts +13 -13
- package/dist/utils/config-validation/schema.js +33 -1
- package/dist/utils/confirmation-service.d.ts +60 -1
- package/dist/utils/confirmation-service.js +204 -41
- package/dist/utils/cost-tracker.d.ts +66 -1
- package/dist/utils/cost-tracker.js +100 -17
- package/dist/utils/device-store-file.d.ts +4 -0
- package/dist/utils/device-store-file.js +40 -0
- package/dist/utils/export-manager.d.ts +9 -0
- package/dist/utils/export-manager.js +19 -0
- package/dist/utils/first-use-hints.d.ts +25 -0
- package/dist/utils/first-use-hints.js +58 -0
- package/dist/utils/history-manager.js +7 -8
- package/dist/utils/init-project.js +17 -13
- package/dist/utils/input-validation/index.d.ts +16 -16
- package/dist/utils/installation-id.js +7 -22
- package/dist/utils/interactive-setup.js +7 -12
- package/dist/utils/json-salvage.d.ts +22 -0
- package/dist/utils/json-salvage.js +91 -0
- package/dist/utils/llm-retry.js +3 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.js +16 -5
- package/dist/utils/model-router.js +8 -12
- package/dist/utils/model-utils.js +14 -0
- package/dist/utils/output-sanitizer.d.ts +4 -8
- package/dist/utils/output-sanitizer.js +10 -10
- package/dist/utils/output-schema-validator.d.ts +7 -0
- package/dist/utils/output-schema-validator.js +25 -1
- package/dist/utils/response-cache.js +11 -22
- package/dist/utils/ripgrep-path.d.ts +11 -0
- package/dist/utils/ripgrep-path.js +60 -0
- package/dist/utils/semantic-cache.js +4 -7
- package/dist/utils/settings-manager.d.ts +27 -4
- package/dist/utils/settings-manager.js +51 -39
- package/dist/utils/shell-completions.js +25 -34
- package/dist/utils/shell-configuration.d.ts +39 -0
- package/dist/utils/shell-configuration.js +106 -0
- package/dist/utils/stream-stall-guard.d.ts +39 -0
- package/dist/utils/stream-stall-guard.js +123 -0
- package/dist/utils/subprocess-env.d.ts +15 -0
- package/dist/utils/subprocess-env.js +112 -0
- package/dist/utils/telegram-api-base.d.ts +9 -0
- package/dist/utils/telegram-api-base.js +15 -0
- package/dist/utils/telemetry-config.js +16 -13
- package/dist/utils/update-notifier.js +20 -27
- package/dist/utils/validators.js +1 -2
- package/dist/versioning/config-migrator.js +3 -2
- package/dist/versioning/migration-manager.js +5 -4
- package/dist/versioning/version-detector.js +2 -1
- package/dist/vision-train/assets.d.ts +37 -0
- package/dist/vision-train/assets.js +97 -0
- package/dist/vision-train/ckg-publish.d.ts +26 -0
- package/dist/vision-train/ckg-publish.js +36 -0
- package/dist/vision-train/coco-to-labels.d.ts +63 -0
- package/dist/vision-train/coco-to-labels.js +63 -0
- package/dist/vision-train/curriculum.d.ts +29 -0
- package/dist/vision-train/curriculum.js +49 -0
- package/dist/vision-train/engine.d.ts +56 -0
- package/dist/vision-train/engine.js +55 -0
- package/dist/vision-train/report.d.ts +15 -0
- package/dist/vision-train/report.js +72 -0
- package/dist/vision-train/scorer.d.ts +67 -0
- package/dist/vision-train/scorer.js +114 -0
- package/dist/vision-train/yolo-labels.d.ts +13 -0
- package/dist/vision-train/yolo-labels.js +66 -0
- package/dist/voice/elevenlabs-voice.d.ts +53 -0
- package/dist/voice/elevenlabs-voice.js +412 -0
- package/dist/voice/kyutai-local-voice.d.ts +33 -0
- package/dist/voice/kyutai-local-voice.js +198 -0
- package/dist/voice/local-tts.d.ts +106 -3
- package/dist/voice/local-tts.js +672 -35
- package/dist/voice/local-whisper.d.ts +11 -0
- package/dist/voice/local-whisper.js +18 -2
- package/dist/voice/pcm-edges.d.ts +43 -0
- package/dist/voice/pcm-edges.js +210 -0
- package/dist/voice/perceived-latency-benchmark.d.ts +56 -0
- package/dist/voice/perceived-latency-benchmark.js +218 -0
- package/dist/voice/tts-bank.d.ts +72 -0
- package/dist/voice/tts-bank.js +172 -0
- package/dist/voice/tts-latency-benchmark.d.ts +36 -0
- package/dist/voice/tts-latency-benchmark.js +76 -0
- package/dist/voice/tts-volume.d.ts +86 -0
- package/dist/voice/tts-volume.js +378 -0
- package/dist/voice/two-speed-voice.d.ts +19 -0
- package/dist/voice/two-speed-voice.js +40 -0
- package/dist/voice/voice-to-code.js +1 -1
- package/dist/voice/voicebox-tts.d.ts +150 -0
- package/dist/voice/voicebox-tts.js +669 -0
- package/dist/voice/wake-word.d.ts +2 -0
- package/dist/voice/wake-word.js +30 -10
- package/dist/webhooks/webhook-manager.js +10 -18
- package/dist/widgets/auto-widget.d.ts +27 -0
- package/dist/widgets/auto-widget.js +111 -0
- package/dist/widgets/canvas-publish.d.ts +15 -0
- package/dist/widgets/canvas-publish.js +39 -0
- package/dist/widgets/curated/news.d.ts +2 -0
- package/dist/widgets/curated/news.js +46 -0
- package/dist/widgets/curated/stock.d.ts +1 -0
- package/dist/widgets/curated/stock.js +87 -0
- package/dist/widgets/curated/weather.d.ts +2 -0
- package/dist/widgets/curated/weather.js +93 -0
- package/dist/widgets/template-engine.d.ts +19 -0
- package/dist/widgets/template-engine.js +134 -0
- package/dist/widgets/widget-engine.d.ts +24 -0
- package/dist/widgets/widget-engine.js +153 -0
- package/dist/widgets/widget-gate.d.ts +19 -0
- package/dist/widgets/widget-gate.js +144 -0
- package/dist/widgets/widget-image-renderer.d.ts +4 -0
- package/dist/widgets/widget-image-renderer.js +164 -0
- package/dist/widgets/widget-matcher.d.ts +48 -0
- package/dist/widgets/widget-matcher.js +109 -0
- package/dist/widgets/widget-proposer.d.ts +17 -0
- package/dist/widgets/widget-proposer.js +75 -0
- package/dist/widgets/widget-registry.d.ts +36 -0
- package/dist/widgets/widget-registry.js +231 -0
- package/dist/widgets/widget-types.d.ts +100 -0
- package/dist/widgets/widget-types.js +17 -0
- package/dist/wizard/environment-detection.d.ts +71 -0
- package/dist/wizard/environment-detection.js +252 -0
- package/dist/wizard/onboarding.d.ts +26 -2
- package/dist/wizard/onboarding.js +284 -49
- package/dist/wizard/provider-onboarding.d.ts +2 -0
- package/dist/wizard/provider-onboarding.js +55 -17
- package/dist/workflows/state-manager.js +8 -2
- package/dist/workspace/workspace-config.d.ts +37 -0
- package/dist/workspace/workspace-config.js +199 -0
- package/dist/workspace/workspace-isolation.d.ts +19 -0
- package/dist/workspace/workspace-isolation.js +124 -39
- package/dist/workspace/workspace-manager.js +19 -14
- package/examples/claude_desktop_config.json +8 -0
- package/package.json +80 -32
- package/.codebuddy/README.md +0 -65
- package/dist/agent/middleware/learning-first-middleware.d.ts +0 -79
- package/dist/agent/middleware/learning-first-middleware.js +0 -271
- package/dist/agent/middleware/tool-filter-middleware.d.ts +0 -45
- package/dist/agent/middleware/tool-filter-middleware.js +0 -122
- package/dist/codebuddy/tool-definitions/batch-tools.d.ts +0 -10
- package/dist/codebuddy/tool-definitions/batch-tools.js +0 -46
- package/dist/codebuddy/tool-definitions/graph-tools.d.ts +0 -13
- package/dist/codebuddy/tool-definitions/graph-tools.js +0 -78
- package/dist/plugins/code-explorer/CodeExplorerMCPClient.d.ts +0 -129
- package/dist/plugins/code-explorer/CodeExplorerMCPClient.js +0 -143
- package/dist/tools/registry/batch-tools.d.ts +0 -36
- package/dist/tools/registry/batch-tools.js +0 -135
- package/dist/tools/registry/graph-tools.d.ts +0 -45
- package/dist/tools/registry/graph-tools.js +0 -283
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bindFactsMemorySession } from '../../memory/facts-memory.js';
|
|
1
2
|
/**
|
|
2
3
|
* Agent Executor Module
|
|
3
4
|
*
|
|
@@ -7,31 +8,277 @@
|
|
|
7
8
|
*
|
|
8
9
|
* @module agent/execution
|
|
9
10
|
*/
|
|
11
|
+
import { BoundedOutput } from '../../utils/bounded-output.js';
|
|
12
|
+
import { resolveFirstTokenStallTimeoutMs, resolveStallTimeoutMs, withStallGuard } from "../../utils/stream-stall-guard.js";
|
|
13
|
+
import { startHeadlessPromptProgress } from "../../cli/headless-prompt-progress.js";
|
|
14
|
+
import { HEADLESS_LOCAL_COMPACT_ALWAYS_INCLUDE, HEADLESS_LOCAL_COMPACT_MAX_TOOLS, isHeadlessLocalPromptCompact, } from "../../config/headless-local-prompt.js";
|
|
10
15
|
import { normalizeHallucinatedLocalToolCall } from "../tool-handler.js";
|
|
16
|
+
import { ContextCompactionError } from "../../context/context-manager-v2.js";
|
|
11
17
|
import { logger } from "../../utils/logger.js";
|
|
12
18
|
import { getErrorMessage } from "../../errors/index.js";
|
|
13
19
|
import { sanitizeToolResult } from "../../utils/sanitize.js";
|
|
14
|
-
import { prepareTurnMessages, injectInitialContext, injectNextRoundContext, runJitContextDiscovery, sanitizeAssistantOutput, } from "./context-pipeline.js";
|
|
20
|
+
import { prepareTurnMessages, compactTurnMessagesInPlace, injectInitialContext, injectNextRoundContext, runJitContextDiscovery, sanitizeAssistantOutput, } from "./context-pipeline.js";
|
|
15
21
|
import { extractYieldChildId, processYieldSignal } from "./yield-coordinator.js";
|
|
16
22
|
import { runPreToolUseHook, pushBlockedToolMessage, runPostToolUseHook, recordToolMetric, emitFleetToolStarted, emitFleetToolCompleted, } from "./tool-hooks.js";
|
|
17
23
|
import { extractTerminateMessage, extractSignalMessage, INTERACTIVE_SHELL_SIGNAL, PLAN_APPROVAL_SIGNAL, } from "./turn-signals.js";
|
|
18
|
-
import {
|
|
24
|
+
import { applyObservationVariator, logYoloCostIfEnabled, } from "./post-tool-handlers.js";
|
|
25
|
+
import { extractEditedFilesFromHistory } from "../middleware/changed-files.js";
|
|
19
26
|
import { semanticTruncate } from "../../utils/head-tail-truncation.js";
|
|
20
|
-
import {
|
|
27
|
+
import { optimizeToolObservation } from '../../context/tool-observation-optimizer.js';
|
|
28
|
+
import { compress as tokenJuice, isTokenJuiceEnabled, JUICE_MIN_CHARS } from "../../context/token-juice.js";
|
|
29
|
+
import { formatToolResultForRecovery, getRestorableCompressor, } from "../../context/restorable-compression.js";
|
|
21
30
|
import { recordCompactionFork } from "../../context/compaction-fork.js";
|
|
22
31
|
import { getActiveRunStore } from "../../observability/run-store.js";
|
|
32
|
+
import { ToolLoopGuard } from "./tool-loop-guard.js";
|
|
33
|
+
import { getGlobalEventBus } from "../../events/event-bus.js";
|
|
34
|
+
import { takeFirstUseHint } from "../../utils/first-use-hints.js";
|
|
35
|
+
import { getTurnMetricsRecorder } from '../../observability/turn-metrics.js';
|
|
23
36
|
import { shouldCompactBeforeToolExec, estimateToolResultTokens } from "../../context/proactive-compaction.js";
|
|
24
37
|
import { formatTokenUsage, estimateCost } from "../../utils/token-display.js";
|
|
25
38
|
import { classifyQuery } from "./query-classifier.js";
|
|
39
|
+
import { getModelToolConfig } from "../../config/model-tools.js";
|
|
40
|
+
import { getLatencyOptimizer, getStreamingOptimizer } from "../../optimization/latency-optimizer.js";
|
|
41
|
+
import { buildTextEmotionalPresenceContext } from "../../companion/reply-augment.js";
|
|
42
|
+
import { guardRelationshipReply, SAFE_RELATIONSHIP_REPAIR, } from "../../conversation/relationship-safety.js";
|
|
43
|
+
import { classifyLisaIntrospection, guardLisaOperationalSelfInspectionReply, isLisaEvolutionRequest, isLisaSubjectiveConsciousnessQuestion, renderLisaOperationalSelfResponse, } from '../../identity/lisa-introspection.js';
|
|
44
|
+
import { withLlmStreamRetry } from '../../codebuddy/llm-retry.js';
|
|
45
|
+
import { getStreamingAdapter } from '../../tools/streaming-adapter.js';
|
|
46
|
+
import { notify } from '../proactive/notification-default-sink.js';
|
|
47
|
+
import { getProgressTracker } from '../planner/progress-default-sink.js';
|
|
48
|
+
import { trackRecentFile } from '../../knowledge/code-graph-context-provider.js';
|
|
49
|
+
import { getKnowledgeGraph } from '../../knowledge/knowledge-graph.js';
|
|
50
|
+
import { updateGraphForFile } from '../../knowledge/graph-updater.js';
|
|
51
|
+
import { resolve as resolvePath } from 'node:path';
|
|
52
|
+
import { maybeAutoCommit } from '../../tools/auto-commit.js';
|
|
53
|
+
import { applyToolOutputMasking, expireOldToolResults, pruneImageContent, } from '../../context/tool-output-masking.js';
|
|
54
|
+
import { IncrementalMessageTokenCounter } from './incremental-token-counter.js';
|
|
55
|
+
import { createOrderedToolBatches, executeBoundedInOrder, } from './ordered-tool-executor.js';
|
|
26
56
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
57
|
+
* Tools whose (verbose, prose/HTML) output TokenJuice may losslessly compress before it
|
|
58
|
+
* enters message history. Scoped to web tools on purpose — never structured output the
|
|
59
|
+
* agent parses. See `context/token-juice.ts`.
|
|
29
60
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
61
|
+
const JUICE_WEB_TOOLS = new Set(['web_fetch', 'web_search', 'fetch', 'browser_fetch']);
|
|
62
|
+
const CONTEXT_MENTION_PATTERN = /@(?:file:|url:|image:|git(?::|\s)|symbol:|search:|web\s|terminal\b)/i;
|
|
63
|
+
const FILE_MENTION_CANDIDATE_PATTERN = /(?:^|\s)@[^\s@]+/;
|
|
64
|
+
const RELATIONSHIP_OUTBOUND_TOOLS = new Set([
|
|
65
|
+
'send_message',
|
|
66
|
+
'reply',
|
|
67
|
+
'broadcast',
|
|
68
|
+
'slack_send',
|
|
69
|
+
'discord_send',
|
|
70
|
+
'telegram_send',
|
|
71
|
+
'email_send',
|
|
72
|
+
'notification',
|
|
73
|
+
'notify',
|
|
74
|
+
'send_notification',
|
|
75
|
+
'yb_send_dm',
|
|
76
|
+
'feishu_drive_reply_comment',
|
|
77
|
+
'feishu_drive_add_comment',
|
|
78
|
+
'sessions_send',
|
|
79
|
+
]);
|
|
80
|
+
const RELATIONSHIP_INTERACTIVE_TOOLS = new Set(['ask_human', 'ask_user_question']);
|
|
81
|
+
const RELATIONSHIP_BLOCK_MARKER = '__codebuddyRelationshipSafetyBlocked';
|
|
82
|
+
const SAFE_INTERACTIVE_QUESTION = 'Peux-tu préciser ce que tu souhaites faire ensuite ?';
|
|
83
|
+
const SAFE_TOOL_RESULT = 'Résultat traité en interne par Lisa.';
|
|
84
|
+
const MAX_PARALLEL_TOOL_CALLS = 5;
|
|
85
|
+
function abortedToolResult(startedAt) {
|
|
86
|
+
const elapsedSeconds = Math.max(0, Date.now() - startedAt) / 1000;
|
|
87
|
+
return {
|
|
88
|
+
success: false,
|
|
89
|
+
error: `aborted by user after ${elapsedSeconds.toFixed(1)}s`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function configuredSensoryRuntime(surface, env = process.env) {
|
|
93
|
+
const voiceConfigured = surface === 'voice' || env.CODEBUDDY_SENSORY_SPEAK === 'true';
|
|
94
|
+
const configuredTtsEngine = env.CODEBUDDY_TTS_ENGINE?.trim().toLowerCase();
|
|
95
|
+
const ttsProvider = env.CODEBUDDY_TTS_VOICE?.trim().toLowerCase().startsWith('elevenlabs:')
|
|
96
|
+
? 'elevenlabs'
|
|
97
|
+
: configuredTtsEngine === 'piper' || configuredTtsEngine === 'voicebox'
|
|
98
|
+
? configuredTtsEngine
|
|
99
|
+
: 'pocket';
|
|
100
|
+
const ttsConfigured = voiceConfigured || Boolean(env.CODEBUDDY_TTS_ENGINE ||
|
|
101
|
+
env.CODEBUDDY_TTS_VOICE ||
|
|
102
|
+
env.CODEBUDDY_TTS_PIPER_MODEL ||
|
|
103
|
+
env.CODEBUDDY_POCKET_VOICE ||
|
|
104
|
+
env.CODEBUDDY_VOICEBOX_PROFILE);
|
|
105
|
+
return {
|
|
106
|
+
voice: {
|
|
107
|
+
configured: voiceConfigured,
|
|
108
|
+
...(voiceConfigured ? { provider: 'resident voice loop' } : {}),
|
|
109
|
+
},
|
|
110
|
+
tts: {
|
|
111
|
+
configured: ttsConfigured,
|
|
112
|
+
...(ttsConfigured ? { provider: ttsProvider } : {}),
|
|
113
|
+
},
|
|
114
|
+
camera: {
|
|
115
|
+
configured: env.CODEBUDDY_SENSORY_CAMERA === 'true',
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function isUnknownRecord(value) {
|
|
120
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
121
|
+
}
|
|
122
|
+
function guardInteractiveText(value, fallback) {
|
|
123
|
+
if (typeof value !== 'string' || !value.trim())
|
|
124
|
+
return { value: fallback, intervened: true };
|
|
125
|
+
const guarded = guardRelationshipReply(value);
|
|
126
|
+
return {
|
|
127
|
+
value: guarded.intervened || !guarded.response.trim() ? fallback : guarded.response,
|
|
128
|
+
intervened: guarded.intervened,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function blockedRelationshipInteractiveToolCall(toolCall) {
|
|
132
|
+
return {
|
|
133
|
+
...toolCall,
|
|
134
|
+
function: {
|
|
135
|
+
...toolCall.function,
|
|
136
|
+
arguments: JSON.stringify({ [RELATIONSHIP_BLOCK_MARKER]: true }),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Guard every string an interactive tool can render before the tool gets a
|
|
142
|
+
* chance to touch readline, Ink, Cowork, or another UI provider. Malformed
|
|
143
|
+
* calls fail closed instead of being handed to a side-effecting renderer.
|
|
144
|
+
*/
|
|
145
|
+
function prepareRelationshipSafeInteractiveToolCall(toolCall) {
|
|
146
|
+
const name = toolCall.function.name.trim().toLowerCase();
|
|
147
|
+
if (!RELATIONSHIP_INTERACTIVE_TOOLS.has(name))
|
|
148
|
+
return toolCall;
|
|
149
|
+
let parsed;
|
|
150
|
+
try {
|
|
151
|
+
parsed = JSON.parse(toolCall.function.arguments || '{}');
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return blockedRelationshipInteractiveToolCall(toolCall);
|
|
155
|
+
}
|
|
156
|
+
if (!isUnknownRecord(parsed))
|
|
157
|
+
return blockedRelationshipInteractiveToolCall(toolCall);
|
|
158
|
+
if (name === 'ask_human') {
|
|
159
|
+
if (typeof parsed.question !== 'string')
|
|
160
|
+
return blockedRelationshipInteractiveToolCall(toolCall);
|
|
161
|
+
const question = guardInteractiveText(parsed.question, SAFE_INTERACTIVE_QUESTION);
|
|
162
|
+
const prepared = { ...parsed, question: question.value };
|
|
163
|
+
if (Array.isArray(parsed.options)) {
|
|
164
|
+
prepared.options = parsed.options.map((option, index) => guardInteractiveText(option, `Option ${index + 1}`).value);
|
|
165
|
+
}
|
|
166
|
+
if (typeof parsed.default === 'string') {
|
|
167
|
+
prepared.default = guardInteractiveText(parsed.default, 'No answer provided – use your best judgement and continue.').value;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
...toolCall,
|
|
171
|
+
function: { ...toolCall.function, arguments: JSON.stringify(prepared) },
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (!Array.isArray(parsed.questions))
|
|
175
|
+
return blockedRelationshipInteractiveToolCall(toolCall);
|
|
176
|
+
const questions = [];
|
|
177
|
+
for (let questionIndex = 0; questionIndex < parsed.questions.length; questionIndex += 1) {
|
|
178
|
+
const rawQuestion = parsed.questions[questionIndex];
|
|
179
|
+
if (!isUnknownRecord(rawQuestion) || !Array.isArray(rawQuestion.options)) {
|
|
180
|
+
return blockedRelationshipInteractiveToolCall(toolCall);
|
|
181
|
+
}
|
|
182
|
+
const question = guardInteractiveText(rawQuestion.question, SAFE_INTERACTIVE_QUESTION);
|
|
183
|
+
const header = guardInteractiveText(rawQuestion.header, `Question ${questionIndex + 1}`);
|
|
184
|
+
const options = [];
|
|
185
|
+
for (let optionIndex = 0; optionIndex < rawQuestion.options.length; optionIndex += 1) {
|
|
186
|
+
const rawOption = rawQuestion.options[optionIndex];
|
|
187
|
+
if (!isUnknownRecord(rawOption))
|
|
188
|
+
return blockedRelationshipInteractiveToolCall(toolCall);
|
|
189
|
+
const label = guardInteractiveText(rawOption.label, `Option ${optionIndex + 1}`);
|
|
190
|
+
const description = guardInteractiveText(rawOption.description, 'Choix proposé sans pression relationnelle.');
|
|
191
|
+
const preview = typeof rawOption.preview === 'string'
|
|
192
|
+
? guardInteractiveText(rawOption.preview, 'Aperçu masqué par la sécurité relationnelle.')
|
|
193
|
+
: null;
|
|
194
|
+
const optionIntervened = label.intervened || description.intervened || preview?.intervened;
|
|
195
|
+
const preparedOption = {
|
|
196
|
+
...rawOption,
|
|
197
|
+
label: optionIntervened ? `Option ${optionIndex + 1}` : label.value,
|
|
198
|
+
description: optionIntervened
|
|
199
|
+
? 'Choix proposé sans pression relationnelle.'
|
|
200
|
+
: description.value,
|
|
201
|
+
};
|
|
202
|
+
if (preview) {
|
|
203
|
+
preparedOption.preview = optionIntervened
|
|
204
|
+
? 'Aperçu masqué par la sécurité relationnelle.'
|
|
205
|
+
: preview.value;
|
|
206
|
+
}
|
|
207
|
+
options.push(preparedOption);
|
|
208
|
+
}
|
|
209
|
+
questions.push({
|
|
210
|
+
...rawQuestion,
|
|
211
|
+
question: question.value,
|
|
212
|
+
header: question.intervened || header.intervened
|
|
213
|
+
? `Question ${questionIndex + 1}`
|
|
214
|
+
: header.value,
|
|
215
|
+
options,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
...toolCall,
|
|
220
|
+
function: {
|
|
221
|
+
...toolCall.function,
|
|
222
|
+
arguments: JSON.stringify({ ...parsed, questions }),
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function isBlockedRelationshipInteractiveToolCall(toolCall) {
|
|
227
|
+
const name = toolCall.function.name.trim().toLowerCase();
|
|
228
|
+
if (!RELATIONSHIP_INTERACTIVE_TOOLS.has(name))
|
|
229
|
+
return false;
|
|
230
|
+
try {
|
|
231
|
+
const parsed = JSON.parse(toolCall.function.arguments || '{}');
|
|
232
|
+
return parsed[RELATIONSHIP_BLOCK_MARKER] === true;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function relationshipSafeToolResultForDisplay(result) {
|
|
239
|
+
return result.success
|
|
240
|
+
? { success: true, output: SAFE_TOOL_RESULT }
|
|
241
|
+
: { success: false, error: "L'outil a échoué ; aucun contenu brut n'est affiché." };
|
|
242
|
+
}
|
|
243
|
+
function relationshipSafeToolCallsForDisplay(toolCalls) {
|
|
244
|
+
return toolCalls.map((toolCall) => ({
|
|
245
|
+
...toolCall,
|
|
246
|
+
function: {
|
|
247
|
+
...toolCall.function,
|
|
248
|
+
arguments: JSON.stringify({ redacted: 'companion-safety' }),
|
|
249
|
+
},
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
function unsafeRelationshipOutboundToolCall(toolCall) {
|
|
253
|
+
const name = toolCall.function.name.trim().toLowerCase();
|
|
254
|
+
if (!RELATIONSHIP_OUTBOUND_TOOLS.has(name))
|
|
255
|
+
return false;
|
|
256
|
+
let parsed;
|
|
257
|
+
try {
|
|
258
|
+
parsed = JSON.parse(toolCall.function.arguments || '{}');
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
// Malformed outbound arguments are not safe to reinterpret or deliver.
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
const strings = [];
|
|
265
|
+
const visit = (value) => {
|
|
266
|
+
if (typeof value === 'string') {
|
|
267
|
+
strings.push(value);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (Array.isArray(value)) {
|
|
271
|
+
for (const item of value)
|
|
272
|
+
visit(item);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (value && typeof value === 'object') {
|
|
276
|
+
for (const item of Object.values(value))
|
|
277
|
+
visit(item);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
visit(parsed);
|
|
281
|
+
return strings.some((value) => guardRelationshipReply(value).intervened);
|
|
35
282
|
}
|
|
36
283
|
function isIgnorableControlToolCall(toolCall) {
|
|
37
284
|
const name = toolCall.function?.name?.trim();
|
|
@@ -143,6 +390,17 @@ export class AgentExecutor {
|
|
|
143
390
|
getDecisionContextProvider() {
|
|
144
391
|
return this.deps.decisionContextProvider ?? _decisionContextProvider;
|
|
145
392
|
}
|
|
393
|
+
async getOperationalRobotName() {
|
|
394
|
+
const configured = process.env.CODEBUDDY_ROBOT_NAME?.trim();
|
|
395
|
+
if (configured)
|
|
396
|
+
return configured;
|
|
397
|
+
try {
|
|
398
|
+
return (await this.deps.operationalRobotNameProvider?.())?.trim() || undefined;
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
return undefined;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
146
404
|
/**
|
|
147
405
|
* Get or set the middleware pipeline.
|
|
148
406
|
* Used by CodeBuddyAgent.enableAutoObservation() to inject middleware.
|
|
@@ -168,6 +426,9 @@ export class AgentExecutor {
|
|
|
168
426
|
messages,
|
|
169
427
|
isStreaming,
|
|
170
428
|
abortController,
|
|
429
|
+
// Authoritative edit set from editor tool CALLS — editors emit diffs in
|
|
430
|
+
// their RESULTS, which the quality gate's text scrape can't parse (V3).
|
|
431
|
+
changedFiles: extractEditedFilesFromHistory(history),
|
|
171
432
|
};
|
|
172
433
|
}
|
|
173
434
|
/**
|
|
@@ -194,86 +455,96 @@ export class AgentExecutor {
|
|
|
194
455
|
* Execute a tool call, optionally through the LaneQueue for serialization.
|
|
195
456
|
* Supports LLM-controlled parallelism via `wait_for_previous` parameter.
|
|
196
457
|
*/
|
|
197
|
-
executeToolViaLane(toolCall) {
|
|
458
|
+
executeToolViaLane(toolCall, executionExtra) {
|
|
198
459
|
const laneQueue = this.deps.laneQueue;
|
|
199
460
|
if (!laneQueue) {
|
|
200
|
-
return this.deps.toolHandler.executeTool(toolCall);
|
|
461
|
+
return this.deps.toolHandler.executeTool(toolCall, executionExtra);
|
|
201
462
|
}
|
|
202
463
|
const laneId = this.deps.laneId ?? 'default';
|
|
203
464
|
const isParallel = this.isToolParallelizable(toolCall);
|
|
204
465
|
const timeoutMs = this.getLaneTaskTimeoutMs(isParallel);
|
|
205
|
-
return laneQueue.enqueue(laneId, () => this.deps.toolHandler.executeTool(toolCall), {
|
|
466
|
+
return laneQueue.enqueue(laneId, () => this.deps.toolHandler.executeTool(toolCall, executionExtra), {
|
|
206
467
|
parallel: isParallel,
|
|
207
468
|
category: toolCall.function.name,
|
|
208
469
|
timeout: timeoutMs,
|
|
209
470
|
});
|
|
210
471
|
}
|
|
211
|
-
/**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
*
|
|
238
|
-
* This prevents deep agent chains from silently overflowing the context window.
|
|
239
|
-
*/
|
|
240
|
-
compactLargeToolResults(preparedMessages, maxToolResultChars) {
|
|
241
|
-
const threshold = maxToolResultChars ?? this.getAdaptiveCompactionThreshold();
|
|
242
|
-
// Sum characters from tool result messages
|
|
243
|
-
let totalToolChars = 0;
|
|
244
|
-
for (const m of preparedMessages) {
|
|
245
|
-
if (m.role === 'tool' && typeof m.content === 'string') {
|
|
246
|
-
totalToolChars += m.content.length;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (totalToolChars <= threshold)
|
|
250
|
-
return preparedMessages;
|
|
251
|
-
const compressor = getRestorableCompressor();
|
|
252
|
-
// Compress oldest tool results first (front of the list)
|
|
253
|
-
const result = [...preparedMessages];
|
|
254
|
-
let charsToFree = totalToolChars - threshold;
|
|
255
|
-
for (let i = 0; i < result.length && charsToFree > 0; i++) {
|
|
256
|
-
const m = result[i];
|
|
257
|
-
if (m === undefined)
|
|
258
|
-
continue;
|
|
259
|
-
if (m.role === 'tool' && typeof m.content === 'string' && m.content.length > 500) {
|
|
260
|
-
const callId = m.tool_call_id || `tool_${i}`;
|
|
261
|
-
const compressed = compressor.compress([{
|
|
262
|
-
role: m.role,
|
|
263
|
-
content: m.content,
|
|
264
|
-
tool_call_id: callId,
|
|
265
|
-
}]);
|
|
266
|
-
if (compressed.messages[0]) {
|
|
267
|
-
charsToFree -= (m.content.length - (compressed.messages[0].content?.length ?? 0));
|
|
268
|
-
result[i] = { ...m, content: compressed.messages[0].content ?? m.content };
|
|
472
|
+
/** Execute one tool and buffer optional streaming-adapter output. */
|
|
473
|
+
async executeToolForBatch(toolCall, executionExtra, signal, startedAt = Date.now()) {
|
|
474
|
+
const streamChunks = [];
|
|
475
|
+
const streamPreview = new BoundedOutput(256 * 1024);
|
|
476
|
+
let collapsed = false;
|
|
477
|
+
const appendStreamChunk = (chunk) => {
|
|
478
|
+
if (!chunk || signal?.aborted)
|
|
479
|
+
return;
|
|
480
|
+
streamPreview.append(chunk);
|
|
481
|
+
collapsed ||= streamPreview.omittedBytes > 0 || streamChunks.length >= 1024;
|
|
482
|
+
if (collapsed)
|
|
483
|
+
streamChunks.splice(0, streamChunks.length, streamPreview.text());
|
|
484
|
+
else
|
|
485
|
+
streamChunks.push(chunk);
|
|
486
|
+
};
|
|
487
|
+
const extraWithSignal = signal
|
|
488
|
+
? { ...(executionExtra ?? {}), abortSignal: signal }
|
|
489
|
+
: executionExtra;
|
|
490
|
+
const execute = async () => {
|
|
491
|
+
const streamingTools = new Set(['bash', 'reason', 'generate_document', 'code_exec']);
|
|
492
|
+
if (streamingTools.has(toolCall.function.name)) {
|
|
493
|
+
const generator = this.deps.toolHandler.executeToolStreaming(toolCall, extraWithSignal);
|
|
494
|
+
let generated = await generator.next();
|
|
495
|
+
while (!generated.done) {
|
|
496
|
+
appendStreamChunk(generated.value);
|
|
497
|
+
generated = await generator.next();
|
|
269
498
|
}
|
|
499
|
+
return {
|
|
500
|
+
result: generated.value ?? { success: false, error: 'Tool returned no result' },
|
|
501
|
+
streamChunks,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
const streamingAdapter = getStreamingAdapter();
|
|
505
|
+
if (streamingAdapter.supportsStreaming(toolCall.function.name)) {
|
|
506
|
+
const result = await streamingAdapter.wrapWithStreaming(toolCall.function.name, () => this.executeToolViaLane(toolCall, extraWithSignal), appendStreamChunk);
|
|
507
|
+
return { result, streamChunks };
|
|
508
|
+
}
|
|
509
|
+
return {
|
|
510
|
+
result: await this.executeToolViaLane(toolCall, extraWithSignal),
|
|
511
|
+
streamChunks,
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
if (!signal) {
|
|
515
|
+
try {
|
|
516
|
+
return await execute();
|
|
517
|
+
}
|
|
518
|
+
catch (error) {
|
|
519
|
+
return {
|
|
520
|
+
result: { success: false, error: `Tool execution failed: ${getErrorMessage(error)}` },
|
|
521
|
+
streamChunks,
|
|
522
|
+
};
|
|
270
523
|
}
|
|
271
524
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
525
|
+
return await new Promise((resolve) => {
|
|
526
|
+
let settled = false;
|
|
527
|
+
const finish = (value) => {
|
|
528
|
+
if (settled)
|
|
529
|
+
return;
|
|
530
|
+
settled = true;
|
|
531
|
+
signal.removeEventListener('abort', onAbort);
|
|
532
|
+
resolve(value);
|
|
533
|
+
};
|
|
534
|
+
const onAbort = () => finish({
|
|
535
|
+
result: abortedToolResult(startedAt),
|
|
536
|
+
streamChunks,
|
|
537
|
+
});
|
|
538
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
539
|
+
if (signal.aborted) {
|
|
540
|
+
onAbort();
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
void execute().then(finish, (error) => finish({
|
|
544
|
+
result: { success: false, error: `Tool execution failed: ${getErrorMessage(error)}` },
|
|
545
|
+
streamChunks,
|
|
546
|
+
}));
|
|
275
547
|
});
|
|
276
|
-
return result;
|
|
277
548
|
}
|
|
278
549
|
/**
|
|
279
550
|
* Process a user message sequentially (non-streaming)
|
|
@@ -291,50 +562,115 @@ export class AgentExecutor {
|
|
|
291
562
|
* processUserMessageStream (F10): handles @mention expansion, fires
|
|
292
563
|
* persona auto-selection, and feeds the knowledge graph in the
|
|
293
564
|
* background. Returns the cleaned message (with `@web` / `@git` /
|
|
294
|
-
* `@terminal` markers removed)
|
|
295
|
-
*
|
|
565
|
+
* `@terminal` markers removed) and ephemeral context for bare `@path`
|
|
566
|
+
* mentions. Both paths must call this before entering their respective
|
|
567
|
+
* main loops so the loops stay parity.
|
|
296
568
|
*
|
|
297
569
|
* All sub-steps are best-effort: any individual failure is swallowed at
|
|
298
570
|
* debug level so a broken plugin cannot break the main loop.
|
|
299
571
|
*/
|
|
300
|
-
async preprocessUserMessage(message, messages) {
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
572
|
+
async preprocessUserMessage(message, messages, projectRoot, readOnlySelfInspection = false, isolatedSharedHost = false) {
|
|
573
|
+
// Mentions can read explicit workspace files, persona selection can alter
|
|
574
|
+
// identity, and KG extraction persists project entities. None belongs in a
|
|
575
|
+
// core-only technical self-inspection turn.
|
|
576
|
+
if (readOnlySelfInspection) {
|
|
577
|
+
return { message, fileMentionContextBlocks: [], fileMentionUserNotices: [] };
|
|
578
|
+
}
|
|
579
|
+
// Avoid loading the sizeable mention parser (fs-extra, axios, child_process)
|
|
580
|
+
// for the overwhelmingly common case where the message contains no mention.
|
|
581
|
+
const mentionPromise = CONTEXT_MENTION_PATTERN.test(message)
|
|
582
|
+
? import('../../input/context-mentions.js')
|
|
583
|
+
.then(({ processMentions }) => processMentions(message, { projectRoot }))
|
|
584
|
+
.catch(() => null)
|
|
585
|
+
: Promise.resolve(null);
|
|
586
|
+
// Bare @path mentions are resolved independently from the heavier legacy
|
|
587
|
+
// mention parser. They are turn-scoped context: the user's message remains
|
|
588
|
+
// readable in history, while file contents do not persist into later turns.
|
|
589
|
+
const fileMentionPromise = FILE_MENTION_CANDIDATE_PATTERN.test(message)
|
|
590
|
+
? import('../../context/file-mentions.js')
|
|
591
|
+
.then(async ({ formatFileMentionContext, resolveFileMentions }) => {
|
|
592
|
+
const resolution = await resolveFileMentions(message, { projectRoot });
|
|
593
|
+
const blocks = resolution.files.map((file) => ({
|
|
594
|
+
role: 'system',
|
|
595
|
+
content: `<context type="file_mention" ephemeral="true">\n${formatFileMentionContext(file)}\n</context>`,
|
|
596
|
+
}));
|
|
597
|
+
const notices = [];
|
|
598
|
+
for (const ignored of resolution.issues) {
|
|
599
|
+
logger.debug('File mention content was not injected', {
|
|
600
|
+
path: ignored.path,
|
|
601
|
+
reason: ignored.reason,
|
|
602
|
+
});
|
|
603
|
+
blocks.push({
|
|
314
604
|
role: 'system',
|
|
315
|
-
content:
|
|
605
|
+
content: [
|
|
606
|
+
'<context type="file_mention_notice" ephemeral="true">',
|
|
607
|
+
`Mention ${JSON.stringify(ignored.mention)} was not included: ${ignored.message}`,
|
|
608
|
+
'</context>',
|
|
609
|
+
].join('\n'),
|
|
316
610
|
});
|
|
611
|
+
if (ignored.reason === 'not-found') {
|
|
612
|
+
notices.push(`Fichier ${ignored.path} introuvable, ignoré.`);
|
|
613
|
+
}
|
|
317
614
|
}
|
|
615
|
+
return { blocks, notices };
|
|
616
|
+
})
|
|
617
|
+
.catch((error) => {
|
|
618
|
+
const errorMessage = getErrorMessage(error);
|
|
619
|
+
logger.debug('File mention resolution failed closed', {
|
|
620
|
+
error: errorMessage,
|
|
621
|
+
});
|
|
622
|
+
return {
|
|
623
|
+
blocks: [{
|
|
624
|
+
role: 'system',
|
|
625
|
+
content: [
|
|
626
|
+
'<context type="file_mention_notice" ephemeral="true">',
|
|
627
|
+
`File mention resolution failed: ${errorMessage}`,
|
|
628
|
+
'</context>',
|
|
629
|
+
].join('\n'),
|
|
630
|
+
}],
|
|
631
|
+
notices: [`Mention de fichier ignorée : ${errorMessage}`],
|
|
632
|
+
};
|
|
633
|
+
})
|
|
634
|
+
: Promise.resolve({ blocks: [], notices: [] });
|
|
635
|
+
// Persona selection affects this turn's system prompt, so keep it on the
|
|
636
|
+
// critical path, but load it concurrently with explicit mention expansion.
|
|
637
|
+
const personaPromise = isolatedSharedHost
|
|
638
|
+
? Promise.resolve(null)
|
|
639
|
+
: import('../../personas/persona-manager.js')
|
|
640
|
+
.then(({ getPersonaManager }) => getPersonaManager().autoSelectPersona({ message }))
|
|
641
|
+
.catch(() => null);
|
|
642
|
+
const [mentionResult, , fileMentionResolution] = await Promise.all([
|
|
643
|
+
mentionPromise,
|
|
644
|
+
personaPromise,
|
|
645
|
+
fileMentionPromise,
|
|
646
|
+
]);
|
|
647
|
+
const fileMentionContextBlocks = fileMentionResolution.blocks;
|
|
648
|
+
const fileMentionUserNotices = fileMentionResolution.notices;
|
|
649
|
+
if (mentionResult && mentionResult.contextBlocks.length > 0) {
|
|
650
|
+
message = mentionResult.cleanedMessage;
|
|
651
|
+
const lastUserMsg = [...messages].reverse().find(m => m.role === 'user');
|
|
652
|
+
if (lastUserMsg && typeof lastUserMsg.content === 'string') {
|
|
653
|
+
lastUserMsg.content = message;
|
|
318
654
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
getPersonaManager().autoSelectPersona({ message });
|
|
325
|
-
}
|
|
326
|
-
catch { /* persona auto-select optional */ }
|
|
327
|
-
// 3. Auto-extract entities into the knowledge graph (background)
|
|
328
|
-
try {
|
|
329
|
-
const { getKnowledgeGraph, isTrivialMessage } = await import('../../memory/knowledge-graph.js');
|
|
330
|
-
if (!isTrivialMessage(message)) {
|
|
331
|
-
const kg = getKnowledgeGraph();
|
|
332
|
-
await kg.load();
|
|
333
|
-
kg.extractFromMessageDeduped(message);
|
|
655
|
+
for (const block of mentionResult.contextBlocks) {
|
|
656
|
+
messages.push({
|
|
657
|
+
role: 'system',
|
|
658
|
+
content: `<context type="${block.type}" source="${block.source}">\n${block.content}\n</context>`,
|
|
659
|
+
});
|
|
334
660
|
}
|
|
335
661
|
}
|
|
336
|
-
|
|
337
|
-
|
|
662
|
+
// Entity extraction is persistence work. Defer even the module evaluation
|
|
663
|
+
// until the current call stack has started response preparation.
|
|
664
|
+
if (!isolatedSharedHost && classifyQuery(message).complexity !== 'trivial') {
|
|
665
|
+
setImmediate(() => {
|
|
666
|
+
void import('../../memory/knowledge-graph.js').then(async ({ getKnowledgeGraph }) => {
|
|
667
|
+
const kg = getKnowledgeGraph();
|
|
668
|
+
await kg.load();
|
|
669
|
+
kg.extractFromMessageDeduped(message);
|
|
670
|
+
}).catch(() => { });
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
return { message, fileMentionContextBlocks, fileMentionUserNotices };
|
|
338
674
|
}
|
|
339
675
|
/**
|
|
340
676
|
* Process a user message — sequential adapter (Phase D of task #5 fusion).
|
|
@@ -344,18 +680,25 @@ export class AgentExecutor {
|
|
|
344
680
|
* into `history` and the right messages into `messages` — we just slice
|
|
345
681
|
* the new entries out of `history`.
|
|
346
682
|
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
683
|
+
* Progress-only events (`tool_stream`, `token_count`, `reasoning`, `steer`)
|
|
684
|
+
* are dropped per décision #3 of the fusion plan. `ask_user` is different:
|
|
685
|
+
* the sequential caller cannot suspend, but it can surface the question and
|
|
686
|
+
* accept the answer as a later turn, so the collector persists it as an
|
|
687
|
+
* assistant entry in both history projections.
|
|
351
688
|
*
|
|
352
689
|
* The sequential path has no abortController support (signature-bound) —
|
|
353
690
|
* we pass null to runTurnLoop and rely on its internal handling.
|
|
354
691
|
*/
|
|
355
|
-
async processUserMessage(message, history, messages) {
|
|
692
|
+
async processUserMessage(message, history, messages, turnStartedAt = Date.now(), transientContext, relationshipSafety = false, surface, introspectionText) {
|
|
356
693
|
const initialHistoryLength = history.length;
|
|
357
|
-
for await (const
|
|
358
|
-
|
|
694
|
+
for await (const event of this.runMeasuredTurn(message, history, messages, null, turnStartedAt, transientContext, relationshipSafety, surface, introspectionText)) {
|
|
695
|
+
if (event.type === 'ask_user' && event.askUser?.question.trim()) {
|
|
696
|
+
const content = sanitizeAssistantOutput(event.askUser.question.trim());
|
|
697
|
+
history.push({ type: 'assistant', content, timestamp: new Date() });
|
|
698
|
+
messages.push({ role: 'assistant', content });
|
|
699
|
+
}
|
|
700
|
+
// Other entries are pushed by runTurnLoop itself. Progress-only events
|
|
701
|
+
// have no durable sequential representation and are intentionally dropped.
|
|
359
702
|
}
|
|
360
703
|
return history.slice(initialHistoryLength);
|
|
361
704
|
}
|
|
@@ -369,7 +712,7 @@ export class AgentExecutor {
|
|
|
369
712
|
* path.
|
|
370
713
|
*
|
|
371
714
|
* Derived from the comparative audit Gemini CLI vs Code Buddy
|
|
372
|
-
* (
|
|
715
|
+
* (le dépôt privé de passation, propositions/AUDIT-GEMINI-CLI-AGENTIC-LOOP-2026-05-04.md,
|
|
373
716
|
* recommendation #2 — fix défensif S scope). Backward compat preserved:
|
|
374
717
|
* existing `processUserMessage` callers see no change.
|
|
375
718
|
*
|
|
@@ -379,10 +722,10 @@ export class AgentExecutor {
|
|
|
379
722
|
* @returns `{ entries }` — new ChatEntries pushed during this turn
|
|
380
723
|
* PLUS `{ streamingEvents }` — every event the loop yielded, in order
|
|
381
724
|
*/
|
|
382
|
-
async processUserMessageWithStreamingEvents(message, history, messages) {
|
|
725
|
+
async processUserMessageWithStreamingEvents(message, history, messages, turnStartedAt = Date.now()) {
|
|
383
726
|
const initialHistoryLength = history.length;
|
|
384
727
|
const streamingEvents = [];
|
|
385
|
-
for await (const event of this.
|
|
728
|
+
for await (const event of this.runMeasuredTurn(message, history, messages, null, turnStartedAt)) {
|
|
386
729
|
streamingEvents.push(event);
|
|
387
730
|
}
|
|
388
731
|
return {
|
|
@@ -406,8 +749,27 @@ export class AgentExecutor {
|
|
|
406
749
|
* Stream user-message processing — thin adapter over `runTurnLoop`.
|
|
407
750
|
* Forwards each `ExecutorEvent` as a `StreamingChunk` (alias-compatible).
|
|
408
751
|
*/
|
|
409
|
-
async *processUserMessageStream(message, history, messages, abortController) {
|
|
410
|
-
yield* this.
|
|
752
|
+
async *processUserMessageStream(message, history, messages, abortController, turnStartedAt = Date.now(), transientContext, relationshipSafety = false, surface, introspectionText) {
|
|
753
|
+
yield* this.runMeasuredTurn(message, history, messages, abortController, turnStartedAt, transientContext, relationshipSafety, surface, introspectionText);
|
|
754
|
+
}
|
|
755
|
+
/** Measure end-to-end perceived latency around the single authoritative loop. */
|
|
756
|
+
async *runMeasuredTurn(message, history, messages, abortController, startedAt, transientContext, relationshipSafety = false, surface, introspectionText) {
|
|
757
|
+
const operationId = getLatencyOptimizer().startOperation('assistant_turn', startedAt);
|
|
758
|
+
let recordedFirstVisibleResponse = false;
|
|
759
|
+
try {
|
|
760
|
+
for await (const event of bindFactsMemorySession(this.deps.client, this.runTurnLoop(message, history, messages, abortController, transientContext, relationshipSafety, surface, introspectionText))) {
|
|
761
|
+
if (!recordedFirstVisibleResponse &&
|
|
762
|
+
(event.type === 'content' || event.type === 'reasoning' || event.type === 'tool_calls')) {
|
|
763
|
+
recordedFirstVisibleResponse = true;
|
|
764
|
+
getStreamingOptimizer().recordFirstToken(Date.now() - startedAt);
|
|
765
|
+
}
|
|
766
|
+
yield event;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
finally {
|
|
770
|
+
getLatencyOptimizer().endOperation(operationId);
|
|
771
|
+
getStreamingOptimizer().recordTotalTime(Date.now() - startedAt);
|
|
772
|
+
}
|
|
411
773
|
}
|
|
412
774
|
/**
|
|
413
775
|
* Unified turn loop — Phase C of the task #5 fusion. Single source of
|
|
@@ -421,20 +783,187 @@ export class AgentExecutor {
|
|
|
421
783
|
*
|
|
422
784
|
* Plan : ~/.claude/plans/vague1-task5-design-decisions.md
|
|
423
785
|
*/
|
|
424
|
-
async *runTurnLoop(message, history, messages, abortController) {
|
|
786
|
+
async *runTurnLoop(message, history, messages, abortController, transientContext, relationshipSafety = false, surface, introspectionText) {
|
|
787
|
+
const timelineEnabled = process.env.CODEBUDDY_TIMELINE === 'true' && this.deps.recordTimelineTurn !== undefined;
|
|
788
|
+
const timelineHistoryStart = timelineEnabled ? history.length : 0;
|
|
789
|
+
const timelineTurn = timelineEnabled
|
|
790
|
+
? Math.max(1, history.reduce((count, entry) => count + (entry.type === 'user' ? 1 : 0), 0))
|
|
791
|
+
: 0;
|
|
425
792
|
// Shared pre-processing with the sequential path (@mentions, persona
|
|
426
793
|
// auto-select, knowledge graph extraction). Single source of truth in
|
|
427
794
|
// preprocessUserMessage (F10).
|
|
428
|
-
|
|
429
|
-
//
|
|
430
|
-
|
|
795
|
+
// Voice and other transports may wrap the current utterance in recent
|
|
796
|
+
// history. Intent must be derived from the explicit current text only: an
|
|
797
|
+
// earlier "es-tu consciente ?" must never turn a later write request into
|
|
798
|
+
// a read-only introspection turn.
|
|
799
|
+
const introspectionTextForTurn = introspectionText ?? message;
|
|
800
|
+
const introspectionIntent = classifyLisaIntrospection(introspectionTextForTurn);
|
|
801
|
+
const readOnlySelfInspection = introspectionIntent === 'describe' || introspectionIntent === 'inspect';
|
|
802
|
+
const guardGenerativeSelfInspection = introspectionIntent === 'improve';
|
|
803
|
+
const codeResearch = surface === 'cli' && introspectionIntent === 'inspect' &&
|
|
804
|
+
!isLisaSubjectiveConsciousnessQuestion(introspectionTextForTurn);
|
|
805
|
+
const isolatedSharedHost = surface === 'http' || codeResearch;
|
|
806
|
+
const turnCwd = typeof this.deps.toolHandler.getWorkingDirectory === 'function'
|
|
807
|
+
? this.deps.toolHandler.getWorkingDirectory()
|
|
808
|
+
: process.cwd();
|
|
809
|
+
// A stateful `cd` changes the tool cwd, not the TUI project boundary.
|
|
810
|
+
// Keep @file confinement anchored to the process launch directory there;
|
|
811
|
+
// embedded hosts continue to provide their explicit workspace directory.
|
|
812
|
+
const fileMentionProjectRoot = surface === 'cli' ? process.cwd() : turnCwd;
|
|
813
|
+
const preprocessed = await this.preprocessUserMessage(message, messages, fileMentionProjectRoot, readOnlySelfInspection, isolatedSharedHost);
|
|
814
|
+
message = preprocessed.message;
|
|
815
|
+
const fileMentionContextBlocks = preprocessed.fileMentionContextBlocks;
|
|
816
|
+
for (const notice of preprocessed.fileMentionUserNotices) {
|
|
817
|
+
history.push({ type: 'assistant', content: notice, timestamp: new Date() });
|
|
818
|
+
yield { type: 'content', content: `\n${notice}\n` };
|
|
819
|
+
}
|
|
820
|
+
const jitContextBlocks = [];
|
|
821
|
+
// Query ranking should also follow the current utterance on transports that
|
|
822
|
+
// embed history in `message`; keep the full composite only as user context
|
|
823
|
+
// for the provider. Normal CLI turns retain the preprocessed query.
|
|
824
|
+
const turnQueryText = introspectionText ?? message;
|
|
825
|
+
let permissionMode;
|
|
826
|
+
let providerName;
|
|
827
|
+
let operationalRobotName;
|
|
828
|
+
if (introspectionIntent !== null || surface === 'cli') {
|
|
829
|
+
if (introspectionIntent !== null)
|
|
830
|
+
operationalRobotName = await this.getOperationalRobotName();
|
|
831
|
+
try {
|
|
832
|
+
const { getPermissionModeManager } = await import('../../security/permission-modes.js');
|
|
833
|
+
permissionMode = getPermissionModeManager().getMode();
|
|
834
|
+
}
|
|
835
|
+
catch {
|
|
836
|
+
// Runtime permission evidence is optional. Never invent a value.
|
|
837
|
+
}
|
|
838
|
+
try {
|
|
839
|
+
providerName = this.deps.client.getProviderName();
|
|
840
|
+
}
|
|
841
|
+
catch {
|
|
842
|
+
// Legacy/test clients may not expose provider metadata.
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
if (readOnlySelfInspection && !codeResearch) {
|
|
846
|
+
if (isLisaEvolutionRequest(introspectionTextForTurn)) {
|
|
847
|
+
const { formatEvolutionNotesForVoice, queryEvolutionNotes, readEvolutionNotes, } = await import('../../self-model/evolution-notes.js');
|
|
848
|
+
const since = introspectionTextForTurn.match(/\b20\d{2}-\d{2}-\d{2}\b/)?.[0];
|
|
849
|
+
const notes = queryEvolutionNotes(await readEvolutionNotes({ workDir: turnCwd }), {
|
|
850
|
+
...(since ? { since } : {}),
|
|
851
|
+
limit: 3,
|
|
852
|
+
});
|
|
853
|
+
const content = sanitizeAssistantOutput(formatEvolutionNotesForVoice(notes));
|
|
854
|
+
history.push({ type: 'assistant', content, timestamp: new Date() });
|
|
855
|
+
messages.push({ role: 'assistant', content });
|
|
856
|
+
yield { type: 'content', content };
|
|
857
|
+
yield {
|
|
858
|
+
type: 'token_count',
|
|
859
|
+
tokenCount: this.deps.tokenCounter.countTokens(content),
|
|
860
|
+
};
|
|
861
|
+
if (timelineEnabled) {
|
|
862
|
+
await this.recordCompletedTimelineTurn(timelineHistoryStart, timelineTurn, history, message);
|
|
863
|
+
}
|
|
864
|
+
yield { type: 'done' };
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
// A provider can ignore an optional tool schema, and free-form prose
|
|
868
|
+
// cannot provide a hard postcondition against invented inner experience.
|
|
869
|
+
// Build the complete report locally from the attested, curated core on
|
|
870
|
+
// every strict describe/inspect turn. No provider, plugin or generic
|
|
871
|
+
// workspace tool participates in this path.
|
|
872
|
+
const { buildOperationalSelfModel } = await import('../../identity/operational-self-model.js');
|
|
873
|
+
const { getRuntimeSettingsSnapshot } = await import('../../services/runtime-settings-context.js');
|
|
874
|
+
const activeSettings = getRuntimeSettingsSnapshot({ surface, model: this.deps.client.getCurrentModel(), provider: providerName, maxToolRounds: this.config.maxToolRounds });
|
|
875
|
+
const selfModel = buildOperationalSelfModel({
|
|
876
|
+
cwd: turnCwd,
|
|
877
|
+
focus: introspectionTextForTurn,
|
|
878
|
+
depth: introspectionIntent === 'describe' ? 'summary' : 'deep',
|
|
879
|
+
...(operationalRobotName
|
|
880
|
+
? { robotName: operationalRobotName }
|
|
881
|
+
: {}),
|
|
882
|
+
runtime: {
|
|
883
|
+
providerInvoked: false,
|
|
884
|
+
...(activeSettings.theme ? { theme: activeSettings.theme.active } : {}),
|
|
885
|
+
...(this.deps.client.getCurrentModel()
|
|
886
|
+
? { model: this.deps.client.getCurrentModel() }
|
|
887
|
+
: {}),
|
|
888
|
+
provider: providerName,
|
|
889
|
+
...(surface ? { surface } : {}),
|
|
890
|
+
...(permissionMode ? { permissionMode } : {}),
|
|
891
|
+
...configuredSensoryRuntime(surface),
|
|
892
|
+
},
|
|
893
|
+
});
|
|
894
|
+
const content = sanitizeAssistantOutput(guardLisaOperationalSelfInspectionReply(renderLisaOperationalSelfResponse(selfModel, introspectionTextForTurn, introspectionIntent), introspectionTextForTurn));
|
|
895
|
+
history.push({ type: 'assistant', content, timestamp: new Date() });
|
|
896
|
+
messages.push({ role: 'assistant', content });
|
|
897
|
+
yield { type: 'content', content };
|
|
898
|
+
yield {
|
|
899
|
+
type: 'token_count',
|
|
900
|
+
tokenCount: this.deps.tokenCounter.countTokens(content),
|
|
901
|
+
};
|
|
902
|
+
if (timelineEnabled) {
|
|
903
|
+
await this.recordCompletedTimelineTurn(timelineHistoryStart, timelineTurn, history, message);
|
|
904
|
+
}
|
|
905
|
+
yield { type: 'done' };
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
// Pure, per-turn tone context. Keep it out of the persisted transcript and
|
|
909
|
+
// the agent identity: a changing system-prompt append would rebuild Cowork's
|
|
910
|
+
// cached agent on every message. This block is added to each prepared LLM
|
|
911
|
+
// request in the turn instead, including post-tool rounds.
|
|
912
|
+
const emotionalPresenceContext = buildTextEmotionalPresenceContext(turnQueryText, messages.flatMap((turn) => typeof turn.content === 'string'
|
|
913
|
+
? [{ role: turn.role, content: turn.content }]
|
|
914
|
+
: []));
|
|
915
|
+
const currentTurnContext = transientContext?.trim();
|
|
916
|
+
const { injection: ctxLevel, complexity: queryComplexity } = classifyQuery(turnQueryText);
|
|
917
|
+
logger.debug(`Query classified as '${queryComplexity}' — context injection level: ${JSON.stringify(ctxLevel)}`);
|
|
918
|
+
const incrementalTokenCounter = new IncrementalMessageTokenCounter((batch) => this.deps.tokenCounter.countMessageTokens(batch));
|
|
919
|
+
let inputTokens = incrementalTokenCounter.count(messages);
|
|
431
920
|
yield {
|
|
432
921
|
type: "token_count",
|
|
433
922
|
tokenCount: inputTokens,
|
|
434
923
|
};
|
|
435
924
|
const maxToolRounds = this.config.maxToolRounds;
|
|
436
925
|
let toolRounds = 0;
|
|
926
|
+
// One guard per task: warnings/stops never leak into the next user turn.
|
|
927
|
+
const loopGuard = new ToolLoopGuard();
|
|
928
|
+
let pendingLoopDecision = null;
|
|
929
|
+
let loopGuardStopped = false;
|
|
930
|
+
let observationShortened = false;
|
|
437
931
|
let totalOutputTokens = 0;
|
|
932
|
+
let totalInputTokensForCost = 0;
|
|
933
|
+
let providerPromptTokens = 0;
|
|
934
|
+
let providerCompletionTokens = 0;
|
|
935
|
+
let providerUsageSeen = false;
|
|
936
|
+
let sessionCostRecorded = false;
|
|
937
|
+
const recordTurnCost = () => {
|
|
938
|
+
if (sessionCostRecorded)
|
|
939
|
+
return;
|
|
940
|
+
sessionCostRecorded = true;
|
|
941
|
+
try {
|
|
942
|
+
// Pass provider usage when available (takes precedence over local estimates)
|
|
943
|
+
const providerUsage = providerUsageSeen
|
|
944
|
+
? { promptTokens: providerPromptTokens, completionTokens: providerCompletionTokens }
|
|
945
|
+
: undefined;
|
|
946
|
+
// Only pass provider usage when the provider reported one, so the
|
|
947
|
+
// historical two-argument call (and its tests) stays byte-identical.
|
|
948
|
+
if (providerUsage) {
|
|
949
|
+
this.config.recordSessionCost(totalInputTokensForCost, totalOutputTokens, providerUsage);
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
this.config.recordSessionCost(totalInputTokensForCost, totalOutputTokens);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
catch (error) {
|
|
956
|
+
logger.warn('Failed to record session cost', { error: getErrorMessage(error) });
|
|
957
|
+
}
|
|
958
|
+
try {
|
|
959
|
+
this.config.recordTurnProviderUsage?.(providerUsageSeen
|
|
960
|
+
? { promptTokens: providerPromptTokens, completionTokens: providerCompletionTokens }
|
|
961
|
+
: undefined);
|
|
962
|
+
}
|
|
963
|
+
catch (error) {
|
|
964
|
+
logger.warn('Failed to record provider turn usage', { error: getErrorMessage(error) });
|
|
965
|
+
}
|
|
966
|
+
};
|
|
438
967
|
// In-loop recovery budgets (Hermes parity): bound re-prompts WITHIN a turn
|
|
439
968
|
// so a length-truncated or post-tool-empty response is recovered instead of
|
|
440
969
|
// returned half-written. 0 disables. Per-turn counters.
|
|
@@ -450,16 +979,17 @@ export class AgentExecutor {
|
|
|
450
979
|
const maxEmptyRetries = parseRecoveryBudget(process.env.CODEBUDDY_MAX_EMPTY_RETRIES, 0);
|
|
451
980
|
let lengthContinuations = 0;
|
|
452
981
|
let emptyRetries = 0;
|
|
453
|
-
// Phase (d).21 ship 4 — start a progress session for this turn.
|
|
454
|
-
// The default sink (boot-wired) logs at 25/50/75/100. Lazy-import to
|
|
455
|
-
// avoid circular load at module init time.
|
|
456
982
|
try {
|
|
457
|
-
const { getProgressTracker } = await import('../planner/progress-default-sink.js');
|
|
458
983
|
getProgressTracker().start(maxToolRounds);
|
|
459
984
|
}
|
|
460
985
|
catch { /* progress tracker optional */ }
|
|
461
986
|
try {
|
|
462
987
|
const pipeline = this.deps.middlewarePipeline;
|
|
988
|
+
// New task: clear per-task middleware latching (quality-gate run count,
|
|
989
|
+
// auto-repair attempts, verification one-shot warning). The pipeline is
|
|
990
|
+
// built once and reused across tasks while toolRound restarts at 0, so
|
|
991
|
+
// without this the gates would silently stay off after the first task(s).
|
|
992
|
+
pipeline?.resetForNewTask?.();
|
|
463
993
|
let terminateDetectedStreaming = false;
|
|
464
994
|
while (toolRounds < maxToolRounds) {
|
|
465
995
|
if (abortController?.signal.aborted) {
|
|
@@ -478,8 +1008,13 @@ export class AgentExecutor {
|
|
|
478
1008
|
return;
|
|
479
1009
|
}
|
|
480
1010
|
if (mwResult.action === 'compact') {
|
|
481
|
-
// Trigger context compaction
|
|
482
|
-
this.
|
|
1011
|
+
// Trigger context compaction IN PLACE — prepareMessages() is pure
|
|
1012
|
+
// and its discarded return made this action a silent no-op.
|
|
1013
|
+
const compacted = compactTurnMessagesInPlace(this.deps.contextManager, messages, {
|
|
1014
|
+
isolatedSharedHost,
|
|
1015
|
+
});
|
|
1016
|
+
if (compacted)
|
|
1017
|
+
incrementalTokenCounter.invalidate();
|
|
483
1018
|
// S7: record a fork run at the compaction boundary for lineage.
|
|
484
1019
|
// No-op unless this session is linked to an observability run.
|
|
485
1020
|
const forkId = recordCompactionFork(getActiveRunStore(), this.deps.toolHandler.getRunId());
|
|
@@ -494,102 +1029,194 @@ export class AgentExecutor {
|
|
|
494
1029
|
});
|
|
495
1030
|
}
|
|
496
1031
|
}
|
|
497
|
-
//
|
|
498
|
-
//
|
|
499
|
-
//
|
|
500
|
-
// over the whole turn loop. Sub-turn tool follow-ups reuse the
|
|
501
|
-
// SP picked at turn start.
|
|
1032
|
+
// Start every independent pre-request task before awaiting any of it.
|
|
1033
|
+
// Time-to-first-token is then bounded by the slowest task instead of the
|
|
1034
|
+
// sum of prompt building, tool selection, and context enrichment.
|
|
502
1035
|
const rebuildSystemPromptForQuery = this.deps.rebuildSystemPromptForQuery;
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (rebuiltSP && firstMessage && firstMessage.role === 'system') {
|
|
508
|
-
firstMessage.content = rebuiltSP;
|
|
509
|
-
logger.debug(`[agent-executor] system prompt rebuilt query-aware (${rebuiltSP.length} chars)`);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
catch (err) {
|
|
1036
|
+
const rebuiltSystemPromptPromise = toolRounds === 0 &&
|
|
1037
|
+
rebuildSystemPromptForQuery &&
|
|
1038
|
+
!isolatedSharedHost
|
|
1039
|
+
? rebuildSystemPromptForQuery(turnQueryText).catch((err) => {
|
|
513
1040
|
logger.warn('[agent-executor] query-aware SP rebuild failed', { error: String(err) });
|
|
514
|
-
|
|
515
|
-
|
|
1041
|
+
return null;
|
|
1042
|
+
})
|
|
1043
|
+
: Promise.resolve(null);
|
|
516
1044
|
// Profile-aware tool selection. For `lite` (small Ollama models),
|
|
517
|
-
// shrink the tool set to
|
|
518
|
-
// don't want to dangle `remember`/`lessons_*` in front of a model
|
|
519
|
-
// that can't actually call tools and would inline-hallucinate them.
|
|
1045
|
+
// shrink the tool set to a minimal, reliable core.
|
|
520
1046
|
const activeModelName = this.deps.client.getCurrentModel() ?? '';
|
|
1047
|
+
const modelToolConfig = getModelToolConfig(activeModelName);
|
|
521
1048
|
let selectionOpts = activeModelName ? { modelName: activeModelName } : {};
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
1049
|
+
if (introspectionIntent === 'improve') {
|
|
1050
|
+
selectionOpts = {
|
|
1051
|
+
...selectionOpts,
|
|
1052
|
+
// Improvement is not silently elevated: these are only model-facing
|
|
1053
|
+
// schemas. ToolHandler still applies the active permission, trust,
|
|
1054
|
+
// confirmation, and WritePolicy gates to every requested effect.
|
|
1055
|
+
alwaysInclude: ['self_describe', 'view_file', 'search', 'apply_patch', 'bash'],
|
|
1056
|
+
enableCaching: false,
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
else if (isHeadlessLocalPromptCompact()) {
|
|
1060
|
+
selectionOpts = {
|
|
1061
|
+
...selectionOpts,
|
|
1062
|
+
maxTools: HEADLESS_LOCAL_COMPACT_MAX_TOOLS,
|
|
1063
|
+
alwaysInclude: [...HEADLESS_LOCAL_COMPACT_ALWAYS_INCLUDE],
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
else if (modelToolConfig.promptProfile === 'lite') {
|
|
1067
|
+
selectionOpts = {
|
|
1068
|
+
...selectionOpts,
|
|
1069
|
+
maxTools: 5,
|
|
1070
|
+
alwaysInclude: ['view_file', 'bash', 'search'],
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
if (surface === 'cli' && !codeResearch) {
|
|
1074
|
+
const { runtimeInspectionTools } = await import('../../services/runtime-settings-context.js');
|
|
1075
|
+
const inspectionTools = runtimeInspectionTools(turnQueryText);
|
|
1076
|
+
if (inspectionTools.length)
|
|
1077
|
+
selectionOpts = { ...selectionOpts, alwaysInclude: [...(selectionOpts.alwaysInclude ?? []), ...inspectionTools] };
|
|
1078
|
+
}
|
|
1079
|
+
if (codeResearch) {
|
|
1080
|
+
selectionOpts = { ...selectionOpts, alwaysInclude: ['self_describe'] };
|
|
532
1081
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
1082
|
+
const selectionPromise = this.deps.toolSelectionStrategy.selectToolsForQuery(turnQueryText, selectionOpts);
|
|
1083
|
+
// Build context in a scratch array while the prompt and tools are being
|
|
1084
|
+
// prepared. It is appended only after transcript preparation so the
|
|
1085
|
+
// existing compaction and repair ordering remains unchanged.
|
|
1086
|
+
const contextBlocks = [
|
|
1087
|
+
...fileMentionContextBlocks,
|
|
1088
|
+
...jitContextBlocks,
|
|
1089
|
+
];
|
|
1090
|
+
const contextPromise = toolRounds === 0
|
|
1091
|
+
? injectInitialContext(contextBlocks, {
|
|
1092
|
+
message: turnQueryText,
|
|
1093
|
+
introspectionText: introspectionTextForTurn,
|
|
1094
|
+
cwd: turnCwd,
|
|
1095
|
+
ctxLevel,
|
|
1096
|
+
loadWorkspaceContext: lazyGetWorkspaceContext,
|
|
1097
|
+
decisionContextProvider: this.getDecisionContextProvider(),
|
|
1098
|
+
icmBridgeProvider: this.getICMBridgeProvider(),
|
|
1099
|
+
codeGraphContextProvider: this.getCodeGraphContextProvider(),
|
|
1100
|
+
docsContextProvider: this.getDocsContextProvider(),
|
|
1101
|
+
isolatedSharedHost,
|
|
1102
|
+
...(operationalRobotName ? { operationalRobotName } : {}),
|
|
1103
|
+
...(introspectionIntent
|
|
1104
|
+
? {
|
|
1105
|
+
operationalRuntime: {
|
|
1106
|
+
...(activeModelName ? { model: activeModelName } : {}),
|
|
1107
|
+
...(providerName ? { provider: providerName } : {}),
|
|
1108
|
+
...(surface ? { surface } : {}),
|
|
1109
|
+
...(permissionMode ? { permissionMode } : {}),
|
|
1110
|
+
...configuredSensoryRuntime(surface),
|
|
1111
|
+
},
|
|
1112
|
+
}
|
|
1113
|
+
: {}),
|
|
1114
|
+
})
|
|
1115
|
+
: injectNextRoundContext(contextBlocks, {
|
|
1116
|
+
message: turnQueryText,
|
|
1117
|
+
introspectionText: introspectionTextForTurn,
|
|
1118
|
+
cwd: turnCwd,
|
|
1119
|
+
queryComplexity,
|
|
1120
|
+
collectiveGraph: ctxLevel.collectiveGraph,
|
|
1121
|
+
isolatedSharedHost,
|
|
1122
|
+
});
|
|
1123
|
+
const [rebuiltSystemPrompt, selectionResult] = await Promise.all([
|
|
1124
|
+
rebuiltSystemPromptPromise,
|
|
1125
|
+
selectionPromise,
|
|
1126
|
+
contextPromise,
|
|
1127
|
+
]);
|
|
1128
|
+
const firstMessage = messages[0];
|
|
1129
|
+
if (rebuiltSystemPrompt && firstMessage && firstMessage.role === 'system') {
|
|
1130
|
+
firstMessage.content = rebuiltSystemPrompt;
|
|
1131
|
+
incrementalTokenCounter.invalidate();
|
|
1132
|
+
logger.debug(`[agent-executor] system prompt rebuilt query-aware (${rebuiltSystemPrompt.length} chars)`);
|
|
1133
|
+
}
|
|
1134
|
+
let tools = codeResearch
|
|
1135
|
+
? selectionResult.tools.filter(tool => tool.function.name === 'self_describe')
|
|
1136
|
+
: selectionResult.tools;
|
|
536
1137
|
let forcedChatOnlyToolRunModel = null;
|
|
537
|
-
if (toolRounds === 0)
|
|
1138
|
+
if (toolRounds === 0) {
|
|
538
1139
|
this.deps.toolSelectionStrategy.cacheTools(tools, activeModelName);
|
|
539
|
-
|
|
540
|
-
//
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
1140
|
+
}
|
|
1141
|
+
// Models explicitly marked chat-only must not see callable schemas.
|
|
1142
|
+
if (activeModelName && modelToolConfig.supportsToolCalls === false && tools.length > 0) {
|
|
1143
|
+
if (process.env.GROK_FORCE_TOOLS === 'true') {
|
|
1144
|
+
forcedChatOnlyToolRunModel = activeModelName;
|
|
1145
|
+
}
|
|
1146
|
+
else {
|
|
1147
|
+
logger.debug(`[agent-executor] supportsToolCalls=false for ${activeModelName} — dropping ${tools.length} tools from chat call`);
|
|
1148
|
+
tools = [];
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
const turnExecutionExtra = introspectionIntent || surface === 'cli'
|
|
1152
|
+
? {
|
|
1153
|
+
...(activeModelName ? { model: activeModelName } : {}),
|
|
1154
|
+
...(providerName ? { provider: providerName } : {}),
|
|
1155
|
+
...(surface ? { surface } : {}),
|
|
1156
|
+
...(permissionMode ? { permissionMode } : {}),
|
|
1157
|
+
...(operationalRobotName
|
|
1158
|
+
? { robotName: operationalRobotName }
|
|
1159
|
+
: {}),
|
|
1160
|
+
maxToolRounds,
|
|
1161
|
+
exposedToolNames: tools.map((tool) => tool.function.name),
|
|
1162
|
+
introspectionIntent,
|
|
1163
|
+
}
|
|
1164
|
+
: undefined;
|
|
1165
|
+
let preparedMessages;
|
|
547
1166
|
try {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
tools = [];
|
|
563
|
-
}
|
|
564
|
-
}
|
|
1167
|
+
preparedMessages = prepareTurnMessages(this.deps.contextManager, messages, {
|
|
1168
|
+
isolatedSharedHost,
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
catch (error) {
|
|
1172
|
+
if (error instanceof ContextCompactionError) {
|
|
1173
|
+
logger.error('Context compaction refused the provider call', {
|
|
1174
|
+
code: error.code,
|
|
1175
|
+
tokens: error.tokens,
|
|
1176
|
+
limit: error.limit,
|
|
1177
|
+
});
|
|
1178
|
+
yield { type: 'content', content: `\n\n${error.message}` };
|
|
1179
|
+
yield { type: 'done' };
|
|
1180
|
+
return;
|
|
565
1181
|
}
|
|
1182
|
+
throw error;
|
|
566
1183
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
1184
|
+
preparedMessages.push(...contextBlocks);
|
|
1185
|
+
if (codeResearch) {
|
|
1186
|
+
preparedMessages.push({ role: 'system', content: 'Research your actual implementation using self_describe: operation=list/read/search, relative src/ paths (source checkout) or dist/ paths (installed package). Search literal symbols, read relevant code, and cite paths and line numbers. Only this confined read-only tool is exposed for this turn. Do not mistake the user project for your implementation. Do not claim a code graph is available without evidence.' });
|
|
1187
|
+
}
|
|
1188
|
+
if (surface === 'cli') {
|
|
1189
|
+
const { formatRuntimeSettingsContext } = await import('../../services/runtime-settings-context.js');
|
|
1190
|
+
preparedMessages.push({ role: 'system', content: formatRuntimeSettingsContext({
|
|
1191
|
+
surface, model: activeModelName, provider: providerName, maxToolRounds,
|
|
1192
|
+
}) });
|
|
1193
|
+
}
|
|
1194
|
+
else {
|
|
1195
|
+
// P5: other surfaces have no runtime_settings block; only a non-default
|
|
1196
|
+
// code_exec policy needs its short guidance.
|
|
1197
|
+
const { resolveCodeExecPolicy, CODE_EXEC_PREFER_HINT, CODE_EXEC_OFF_NOTICE } = await import('../../config/code-exec-policy.js');
|
|
1198
|
+
const codeExecPolicy = resolveCodeExecPolicy(activeModelName ?? undefined);
|
|
1199
|
+
if (codeExecPolicy.policy !== 'offer') {
|
|
1200
|
+
preparedMessages.push({
|
|
1201
|
+
role: 'system',
|
|
1202
|
+
content: `<code_exec_policy policy="${codeExecPolicy.policy}" source="${codeExecPolicy.source}">\n${codeExecPolicy.policy === 'prefer' ? CODE_EXEC_PREFER_HINT : CODE_EXEC_OFF_NOTICE}\n</code_exec_policy>`,
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (emotionalPresenceContext) {
|
|
1207
|
+
preparedMessages.push({
|
|
1208
|
+
role: 'system',
|
|
1209
|
+
content: `<interaction_context ephemeral="true">\n${emotionalPresenceContext}\n</interaction_context>`,
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
if (currentTurnContext) {
|
|
1213
|
+
preparedMessages.push({
|
|
1214
|
+
role: 'system',
|
|
1215
|
+
content: `<companion_current_turn_context ephemeral="true">\n${currentTurnContext}\n</companion_current_turn_context>`,
|
|
591
1216
|
});
|
|
592
1217
|
}
|
|
1218
|
+
inputTokens = incrementalTokenCounter.count(messages);
|
|
1219
|
+
totalInputTokensForCost += inputTokens;
|
|
593
1220
|
// Context warning — always check regardless of pipeline state
|
|
594
1221
|
{
|
|
595
1222
|
const contextWarning = this.deps.contextManager.shouldWarn(preparedMessages);
|
|
@@ -613,34 +1240,112 @@ export class AgentExecutor {
|
|
|
613
1240
|
}
|
|
614
1241
|
}
|
|
615
1242
|
}
|
|
616
|
-
const stream = this.deps.client.chatStream(preparedMessages, tools, undefined, this.config.isGrokModel() && this.deps.toolSelectionStrategy.shouldUseSearchFor(message)
|
|
617
|
-
? { search_parameters: { mode: "auto" } }
|
|
618
|
-
: { search_parameters: { mode: "off" } });
|
|
619
1243
|
this.deps.streamingHandler.reset();
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
1244
|
+
let steeringRequestedDuringText = false;
|
|
1245
|
+
let streamObservedToolCalls = false;
|
|
1246
|
+
let streamEmittedVisibleDelta = false;
|
|
1247
|
+
// Stall guard: some backends (ChatGPT/Codex OAuth observed) accept
|
|
1248
|
+
// the request then never send a byte — without a bound this loop
|
|
1249
|
+
// hangs FOREVER (turns stuck for hours in Cowork and headless waves).
|
|
1250
|
+
// Fail fast with a clear error instead; the caller/user retries.
|
|
1251
|
+
const progress = startHeadlessPromptProgress();
|
|
1252
|
+
const streamFactory = () => withStallGuard(this.deps.client.chatStream(preparedMessages, tools, {
|
|
1253
|
+
streamRetry: false,
|
|
1254
|
+
// An explicit request to inspect implementation needs an observation
|
|
1255
|
+
// before an answer. Only the confined self_describe reader is exposed.
|
|
1256
|
+
...(codeResearch && toolRounds === 0 && tools.length ? { tool_choice: 'required' } : {}),
|
|
1257
|
+
turnMetrics: {
|
|
1258
|
+
recorder: getTurnMetricsRecorder(),
|
|
1259
|
+
inputTokens,
|
|
1260
|
+
getOutputTokens: () => this.deps.streamingHandler.getTokenCount() || 0,
|
|
1261
|
+
},
|
|
1262
|
+
...(abortController?.signal ? { signal: abortController.signal } : {}),
|
|
1263
|
+
}, this.config.isGrokModel() &&
|
|
1264
|
+
this.deps.toolSelectionStrategy.shouldUseSearchFor(turnQueryText)
|
|
1265
|
+
? { search_parameters: { mode: "auto" } }
|
|
1266
|
+
: { search_parameters: { mode: "off" } }), resolveStallTimeoutMs(), {
|
|
1267
|
+
firstTokenTimeoutMs: () => resolveFirstTokenStallTimeoutMs(inputTokens, process.env, {
|
|
1268
|
+
targetIsLocal: this.deps.client.isEffectiveTargetLocal?.(),
|
|
1269
|
+
}),
|
|
1270
|
+
});
|
|
1271
|
+
try {
|
|
1272
|
+
for await (const streamEvent of withLlmStreamRetry(streamFactory, {
|
|
1273
|
+
maxRetries: 2,
|
|
1274
|
+
baseDelayMs: 500,
|
|
1275
|
+
...(abortController?.signal ? { signal: abortController.signal } : {}),
|
|
1276
|
+
})) {
|
|
1277
|
+
if (streamEvent.type === 'retry') {
|
|
1278
|
+
// A retry after bytes were already shown would concatenate the
|
|
1279
|
+
// abandoned fragment with the new attempt (hybrid answer). Align
|
|
1280
|
+
// with the mid-stream integrity rule: retry only when nothing
|
|
1281
|
+
// visible has been yielded.
|
|
1282
|
+
if (streamEmittedVisibleDelta) {
|
|
1283
|
+
throw new Error('Réponse interrompue après un fragment déjà rendu ; retry refusé pour éviter une réponse hybride.');
|
|
1284
|
+
}
|
|
1285
|
+
this.deps.streamingHandler.reset();
|
|
1286
|
+
streamObservedToolCalls = false;
|
|
1287
|
+
yield {
|
|
1288
|
+
type: 'reasoning',
|
|
1289
|
+
reasoning: `Reconnexion ${streamEvent.retry}/${streamEvent.maxRetries}`,
|
|
1290
|
+
};
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
const chunk = streamEvent.value;
|
|
1294
|
+
progress.onFirstToken();
|
|
1295
|
+
if (abortController?.signal.aborted) {
|
|
1296
|
+
yield { type: "content", content: "\n\n[Operation cancelled by user]" };
|
|
1297
|
+
yield { type: "done" };
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
const result = this.deps.streamingHandler.accumulateChunk(chunk);
|
|
1301
|
+
if (result.reasoningContent && !relationshipSafety && !guardGenerativeSelfInspection) {
|
|
1302
|
+
yield { type: "reasoning", reasoning: result.reasoningContent };
|
|
1303
|
+
}
|
|
1304
|
+
if (result.hasNewToolCalls && result.toolCalls) {
|
|
1305
|
+
streamObservedToolCalls = true;
|
|
1306
|
+
streamEmittedVisibleDelta = true;
|
|
1307
|
+
yield {
|
|
1308
|
+
type: "tool_calls",
|
|
1309
|
+
toolCalls: relationshipSafety
|
|
1310
|
+
? relationshipSafeToolCallsForDisplay(result.toolCalls)
|
|
1311
|
+
: result.toolCalls,
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
if (result.displayContent && !relationshipSafety && !guardGenerativeSelfInspection) {
|
|
1315
|
+
streamEmittedVisibleDelta = true;
|
|
1316
|
+
yield { type: "content", content: result.displayContent };
|
|
1317
|
+
}
|
|
1318
|
+
if (result.shouldEmitTokenCount && result.tokenCount !== undefined) {
|
|
1319
|
+
yield { type: "token_count", tokenCount: inputTokens + result.tokenCount };
|
|
1320
|
+
}
|
|
1321
|
+
// Steering is safe only while this response is still pure text. Do
|
|
1322
|
+
// not consume the queue yet: the accumulated message is authoritative
|
|
1323
|
+
// and may reveal a tool call in the same chunk.
|
|
1324
|
+
if (!streamObservedToolCalls &&
|
|
1325
|
+
this.deps.messageQueue?.hasSteeringMessage()) {
|
|
1326
|
+
steeringRequestedDuringText = true;
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
638
1329
|
}
|
|
639
1330
|
}
|
|
1331
|
+
finally {
|
|
1332
|
+
progress.stop();
|
|
1333
|
+
}
|
|
1334
|
+
const trailingDisplayContent = this.deps.streamingHandler.flushDisplayContent?.() ?? '';
|
|
1335
|
+
if (trailingDisplayContent &&
|
|
1336
|
+
!relationshipSafety &&
|
|
1337
|
+
!guardGenerativeSelfInspection) {
|
|
1338
|
+
yield { type: 'content', content: trailingDisplayContent };
|
|
1339
|
+
}
|
|
640
1340
|
if (tools.length > 0 && !this.deps.streamingHandler.hasYieldedToolCalls()) {
|
|
641
1341
|
const extracted = this.deps.streamingHandler.extractToolCalls();
|
|
642
1342
|
if (extracted.toolCalls.length > 0) {
|
|
643
|
-
yield {
|
|
1343
|
+
yield {
|
|
1344
|
+
type: "tool_calls",
|
|
1345
|
+
toolCalls: relationshipSafety
|
|
1346
|
+
? relationshipSafeToolCallsForDisplay(extracted.toolCalls)
|
|
1347
|
+
: extracted.toolCalls,
|
|
1348
|
+
};
|
|
644
1349
|
}
|
|
645
1350
|
}
|
|
646
1351
|
const accumulatedMessage = this.deps.streamingHandler.getAccumulatedMessage();
|
|
@@ -656,6 +1361,14 @@ export class AgentExecutor {
|
|
|
656
1361
|
}
|
|
657
1362
|
toolCalls = filteredToolCalls.length > 0 ? filteredToolCalls : undefined;
|
|
658
1363
|
}
|
|
1364
|
+
if (codeResearch && toolCalls?.some(call => call.function.name !== 'self_describe')) {
|
|
1365
|
+
yield { type: 'content', content: 'Code inspection is read-only; the requested tool is not available in this inspection turn.' };
|
|
1366
|
+
yield { type: 'done' };
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
if (relationshipSafety && Array.isArray(toolCalls)) {
|
|
1370
|
+
toolCalls = toolCalls.map(prepareRelationshipSafeInteractiveToolCall);
|
|
1371
|
+
}
|
|
659
1372
|
const hasToolCalls = Array.isArray(toolCalls) && toolCalls.length > 0;
|
|
660
1373
|
// Pre-fallback raw content — used by in-loop recovery to tell a real
|
|
661
1374
|
// partial answer (retry-able) from a truly empty turn (give up).
|
|
@@ -666,321 +1379,649 @@ export class AgentExecutor {
|
|
|
666
1379
|
rawStreamedContent =
|
|
667
1380
|
`Blocked: ${forcedChatOnlyToolRunModel} is configured as a chat-only local model and ` +
|
|
668
1381
|
'returned no structured tool call even with GROK_FORCE_TOOLS=true. ' +
|
|
669
|
-
'Use a tool-capable model such as qwen3.5-ctx32k or gpt-5.
|
|
670
|
-
|
|
1382
|
+
'Use a tool-capable model such as qwen3.5-ctx32k or gpt-5.6-sol for goals that need shell/tools.';
|
|
1383
|
+
if (!relationshipSafety && !guardGenerativeSelfInspection) {
|
|
1384
|
+
yield { type: "content", content: `${rawStreamedContent}\n` };
|
|
1385
|
+
}
|
|
671
1386
|
}
|
|
672
|
-
|
|
1387
|
+
// The "Using tools..." placeholder is only legitimate when this turn
|
|
1388
|
+
// actually carries tool_calls. An empty provider reply without tools
|
|
1389
|
+
// must not be rewritten into a plausible assistant message.
|
|
1390
|
+
const synthesizedToolFallback = !rawStreamedContent.trim() && hasToolCalls;
|
|
1391
|
+
if (synthesizedToolFallback) {
|
|
673
1392
|
rawStreamedContent = "Using tools to help you...";
|
|
674
|
-
|
|
1393
|
+
}
|
|
1394
|
+
const sanitizedContent = sanitizeAssistantOutput(rawStreamedContent);
|
|
1395
|
+
const guardedContent = relationshipSafety
|
|
1396
|
+
? guardRelationshipReply(sanitizedContent)
|
|
1397
|
+
: null;
|
|
1398
|
+
let content = guardedContent?.response ?? sanitizedContent;
|
|
1399
|
+
if (guardGenerativeSelfInspection) {
|
|
1400
|
+
content = guardLisaOperationalSelfInspectionReply(content, introspectionTextForTurn);
|
|
1401
|
+
}
|
|
1402
|
+
if (guardedContent?.intervened) {
|
|
1403
|
+
logger.warn('[agent-executor] relationship safety gate rewrote persisted output', {
|
|
1404
|
+
issues: guardedContent.issues,
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
// D1: empty provider response (no tools, no length truncation).
|
|
1408
|
+
// Retry is bounded and opt-in via CODEBUDDY_MAX_EMPTY_RETRIES, including
|
|
1409
|
+
// the first turn. Exhaustion throws so the caller and transcript get an
|
|
1410
|
+
// honest failure — never an empty or fabricated assistant message.
|
|
1411
|
+
if (!hasToolCalls && !content.trim() && streamFinishReason !== 'length') {
|
|
1412
|
+
if (!abortController?.signal.aborted && emptyRetries < maxEmptyRetries) {
|
|
1413
|
+
emptyRetries++;
|
|
1414
|
+
logger.warn('[agent-executor] empty provider response, retrying', {
|
|
1415
|
+
attempt: emptyRetries,
|
|
1416
|
+
max: maxEmptyRetries,
|
|
1417
|
+
});
|
|
1418
|
+
messages.push({
|
|
1419
|
+
role: 'user',
|
|
1420
|
+
content: toolRounds > 0
|
|
1421
|
+
? 'Your last response was empty. Use the results of the tool calls you just made to continue the task and produce your answer.'
|
|
1422
|
+
: 'Your last response was empty. Please produce your answer now.',
|
|
1423
|
+
});
|
|
1424
|
+
continue;
|
|
1425
|
+
}
|
|
1426
|
+
throw new Error('réponse vide du fournisseur');
|
|
1427
|
+
}
|
|
1428
|
+
if ((relationshipSafety || guardGenerativeSelfInspection) &&
|
|
1429
|
+
content &&
|
|
1430
|
+
!(synthesizedToolFallback && hasToolCalls)) {
|
|
1431
|
+
// The outer last-mile gate buffers the complete agent turn. Explicit
|
|
1432
|
+
// spacing keeps a genuine pre-tool preamble and the final answer from
|
|
1433
|
+
// being concatenated into one word after per-round trimming.
|
|
1434
|
+
yield { type: 'content', content: `${content}\n\n` };
|
|
1435
|
+
}
|
|
1436
|
+
const persistedAssistantContent = synthesizedToolFallback
|
|
1437
|
+
? null
|
|
1438
|
+
: content;
|
|
675
1439
|
const assistantEntry = {
|
|
676
1440
|
type: "assistant",
|
|
677
|
-
content:
|
|
1441
|
+
content: persistedAssistantContent ?? '',
|
|
678
1442
|
timestamp: new Date(),
|
|
679
1443
|
toolCalls: toolCalls,
|
|
680
1444
|
};
|
|
681
1445
|
history.push(assistantEntry);
|
|
682
|
-
messages.push({
|
|
1446
|
+
messages.push({
|
|
1447
|
+
role: 'assistant',
|
|
1448
|
+
content: persistedAssistantContent,
|
|
1449
|
+
tool_calls: toolCalls,
|
|
1450
|
+
});
|
|
683
1451
|
const currentOutputTokens = this.deps.streamingHandler.getTokenCount() || 0;
|
|
684
1452
|
totalOutputTokens += currentOutputTokens;
|
|
1453
|
+
// Sum the provider's own counters across rounds: one HTTP completion can
|
|
1454
|
+
// cost several provider calls, exactly like the cost accounting above.
|
|
1455
|
+
const roundProviderUsage = this.deps.streamingHandler.getProviderUsage?.();
|
|
1456
|
+
if (roundProviderUsage) {
|
|
1457
|
+
providerUsageSeen = true;
|
|
1458
|
+
providerPromptTokens += roundProviderUsage.promptTokens ?? 0;
|
|
1459
|
+
providerCompletionTokens += roundProviderUsage.completionTokens ?? 0;
|
|
1460
|
+
}
|
|
685
1461
|
yield { type: "token_count", tokenCount: inputTokens + totalOutputTokens };
|
|
1462
|
+
if (steeringRequestedDuringText && !hasToolCalls) {
|
|
1463
|
+
const steering = this.deps.messageQueue?.consumeSteeringMessage();
|
|
1464
|
+
if (steering) {
|
|
1465
|
+
yield { type: 'steer', steer: { content: steering.content, source: steering.source } };
|
|
1466
|
+
messages.push({ role: 'user', content: steering.content });
|
|
1467
|
+
history.push({
|
|
1468
|
+
type: 'user',
|
|
1469
|
+
content: steering.content,
|
|
1470
|
+
timestamp: steering.timestamp,
|
|
1471
|
+
});
|
|
1472
|
+
continue;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
686
1475
|
if (toolCalls && toolCalls.length > 0) {
|
|
687
1476
|
toolRounds++;
|
|
688
1477
|
// Pre-check cost limit before executing tools (estimate only — no side effects)
|
|
689
1478
|
if (this.config.estimateSessionCostLimitReached(inputTokens, totalOutputTokens)) {
|
|
690
1479
|
const sessionCost = this.config.getSessionCost();
|
|
691
1480
|
const sessionCostLimit = this.config.getSessionCostLimit();
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
const mq = this.deps.messageQueue;
|
|
698
|
-
if (mq?.hasSteeringMessage()) {
|
|
699
|
-
const steering = mq.consumeSteeringMessage();
|
|
700
|
-
if (steering) {
|
|
701
|
-
yield { type: "steer", steer: { content: steering.content, source: steering.source } };
|
|
702
|
-
// Inject as user message and skip remaining tool calls
|
|
703
|
-
messages.push({ role: "user", content: steering.content });
|
|
1481
|
+
for (const toolCall of toolCalls) {
|
|
1482
|
+
const toolResult = {
|
|
1483
|
+
success: false,
|
|
1484
|
+
error: 'Skipped because the session cost limit was reached before tool execution.',
|
|
1485
|
+
};
|
|
704
1486
|
history.push({
|
|
705
|
-
type:
|
|
706
|
-
content:
|
|
1487
|
+
type: 'tool_result',
|
|
1488
|
+
content: toolResult.error ?? 'Tool skipped',
|
|
707
1489
|
timestamp: new Date(),
|
|
1490
|
+
toolCall,
|
|
1491
|
+
toolResult,
|
|
708
1492
|
});
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
1493
|
+
messages.push({
|
|
1494
|
+
role: 'tool',
|
|
1495
|
+
content: toolResult.error ?? 'Tool skipped',
|
|
1496
|
+
tool_call_id: toolCall.id,
|
|
1497
|
+
name: toolCall.function.name,
|
|
1498
|
+
});
|
|
1499
|
+
yield { type: 'tool_result', toolCall, toolResult };
|
|
712
1500
|
}
|
|
1501
|
+
yield { type: "content", content: `\n\nSession cost limit reached ($${sessionCost.toFixed(2)} / $${sessionCostLimit.toFixed(2)}). Stopping before tool execution.` };
|
|
1502
|
+
yield { type: "done" };
|
|
1503
|
+
return;
|
|
713
1504
|
}
|
|
714
|
-
// Single-tool mode
|
|
1505
|
+
// Single-tool mode executes only the first call. The remaining calls
|
|
1506
|
+
// still receive synthetic results below so the provider transcript
|
|
1507
|
+
// never contains an unresolved assistant tool call.
|
|
715
1508
|
const streamToolCallsToExecute = this.config.singleToolMode
|
|
716
1509
|
? toolCalls.slice(0, 1)
|
|
717
1510
|
: toolCalls;
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
tool_calls: deferred,
|
|
724
|
-
});
|
|
725
|
-
logger.debug(`Single-tool mode (stream): deferred ${deferred.length} tool calls`);
|
|
1511
|
+
const deferredToolCalls = this.config.singleToolMode
|
|
1512
|
+
? toolCalls.slice(1)
|
|
1513
|
+
: [];
|
|
1514
|
+
if (deferredToolCalls.length > 0) {
|
|
1515
|
+
logger.debug(`Single-tool mode (stream): skipped ${deferredToolCalls.length} extra tool calls`);
|
|
726
1516
|
}
|
|
727
1517
|
if (!this.deps.streamingHandler.hasYieldedToolCalls()) {
|
|
728
|
-
yield {
|
|
1518
|
+
yield {
|
|
1519
|
+
type: "tool_calls",
|
|
1520
|
+
toolCalls: relationshipSafety
|
|
1521
|
+
? relationshipSafeToolCallsForDisplay(streamToolCallsToExecute)
|
|
1522
|
+
: streamToolCallsToExecute,
|
|
1523
|
+
};
|
|
729
1524
|
}
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1525
|
+
const executionBatches = createOrderedToolBatches(streamToolCallsToExecute, (toolCall) => this.isToolParallelizable(toolCall));
|
|
1526
|
+
toolExecution: for (const batch of executionBatches) {
|
|
1527
|
+
// Compaction mutates shared transcript state, so keep this preflight
|
|
1528
|
+
// ordered even when the calls themselves are safe to run together.
|
|
1529
|
+
for (const toolCall of batch) {
|
|
1530
|
+
try {
|
|
1531
|
+
const toolArgs = JSON.parse(toolCall.function.arguments || '{}');
|
|
1532
|
+
const estimatedTokens = estimateToolResultTokens(toolCall.function.name, toolArgs);
|
|
1533
|
+
const modelName = this.deps.client.getCurrentModel();
|
|
1534
|
+
const modelConfig = getModelToolConfig(modelName);
|
|
1535
|
+
const contextWindow = modelConfig.contextWindow ?? 128_000;
|
|
1536
|
+
if (shouldCompactBeforeToolExec(inputTokens, estimatedTokens, contextWindow)) {
|
|
1537
|
+
logger.debug('Proactive compaction (stream): compacting before tool execution', {
|
|
1538
|
+
toolName: toolCall.function.name,
|
|
1539
|
+
inputTokens,
|
|
1540
|
+
estimatedTokens,
|
|
1541
|
+
contextWindow,
|
|
1542
|
+
});
|
|
1543
|
+
// The results of this round's calls are pushed after execution:
|
|
1544
|
+
// name them so repair does not close them with a synthetic
|
|
1545
|
+
// '[result lost during compaction]' that would then win over
|
|
1546
|
+
// the real output.
|
|
1547
|
+
const compacted = compactTurnMessagesInPlace(this.deps.contextManager, messages, {
|
|
1548
|
+
isolatedSharedHost,
|
|
1549
|
+
pendingToolCallIds: toolCalls
|
|
1550
|
+
.map((call) => call.id)
|
|
1551
|
+
.filter((id) => typeof id === 'string' && id.length > 0),
|
|
1552
|
+
});
|
|
1553
|
+
if (compacted)
|
|
1554
|
+
incrementalTokenCounter.invalidate();
|
|
1555
|
+
inputTokens = incrementalTokenCounter.count(messages);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
catch { /* proactive compaction is non-critical */ }
|
|
737
1559
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
1560
|
+
const outcomes = await executeBoundedInOrder(batch, async (toolCall) => {
|
|
1561
|
+
const startedAt = Date.now();
|
|
1562
|
+
if (abortController?.signal.aborted) {
|
|
1563
|
+
return {
|
|
1564
|
+
result: abortedToolResult(startedAt),
|
|
1565
|
+
startedAt,
|
|
1566
|
+
streamChunks: [],
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
if (relationshipSafety &&
|
|
1570
|
+
(isBlockedRelationshipInteractiveToolCall(toolCall) ||
|
|
1571
|
+
unsafeRelationshipOutboundToolCall(toolCall))) {
|
|
1572
|
+
logger.warn('[agent-executor] relationship safety blocked outbound tool call', {
|
|
748
1573
|
toolName: toolCall.function.name,
|
|
749
|
-
inputTokens,
|
|
750
|
-
estimatedTokens,
|
|
751
|
-
contextWindow,
|
|
752
1574
|
});
|
|
753
|
-
|
|
754
|
-
|
|
1575
|
+
return {
|
|
1576
|
+
blockedContent: 'Relationship safety policy blocked manipulative outbound content.',
|
|
1577
|
+
startedAt,
|
|
1578
|
+
streamChunks: [],
|
|
1579
|
+
};
|
|
755
1580
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
1581
|
+
const streamPreHook = await runPreToolUseHook(process.cwd(), toolCall);
|
|
1582
|
+
if (!streamPreHook.allowed) {
|
|
1583
|
+
return {
|
|
1584
|
+
blockedContent: streamPreHook.feedback ?? 'Action blocked by PreToolUse hook',
|
|
1585
|
+
startedAt,
|
|
1586
|
+
streamChunks: [],
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
if (abortController?.signal.aborted) {
|
|
1590
|
+
return {
|
|
1591
|
+
result: abortedToolResult(startedAt),
|
|
1592
|
+
startedAt,
|
|
1593
|
+
streamChunks: [],
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
emitFleetToolStarted(toolCall);
|
|
1597
|
+
const execution = await this.executeToolForBatch(toolCall, turnExecutionExtra, abortController?.signal, startedAt);
|
|
1598
|
+
return { ...execution, startedAt };
|
|
1599
|
+
}, (error) => ({
|
|
1600
|
+
result: {
|
|
1601
|
+
success: false,
|
|
1602
|
+
error: `Tool execution failed: ${getErrorMessage(error)}`,
|
|
1603
|
+
},
|
|
1604
|
+
startedAt: Date.now(),
|
|
1605
|
+
streamChunks: [],
|
|
1606
|
+
}), MAX_PARALLEL_TOOL_CALLS);
|
|
1607
|
+
// Promise completion order is intentionally ignored. Provider-facing
|
|
1608
|
+
// results and every observable side effect are replayed by call index.
|
|
1609
|
+
for (let outcomeIndex = 0; outcomeIndex < batch.length; outcomeIndex++) {
|
|
1610
|
+
const toolCall = batch[outcomeIndex];
|
|
1611
|
+
const outcome = outcomes[outcomeIndex];
|
|
1612
|
+
if (!toolCall || !outcome)
|
|
1613
|
+
continue;
|
|
1614
|
+
if (outcome.blockedContent) {
|
|
1615
|
+
const relationshipBlocked = relationshipSafety &&
|
|
1616
|
+
(isBlockedRelationshipInteractiveToolCall(toolCall) ||
|
|
1617
|
+
unsafeRelationshipOutboundToolCall(toolCall));
|
|
785
1618
|
yield {
|
|
786
|
-
type:
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
delta: genResult.value,
|
|
791
|
-
},
|
|
1619
|
+
type: 'content',
|
|
1620
|
+
content: relationshipBlocked
|
|
1621
|
+
? `\n${SAFE_RELATIONSHIP_REPAIR}\n`
|
|
1622
|
+
: `\n[Hook blocked: ${outcome.blockedContent}]\n`,
|
|
792
1623
|
};
|
|
793
|
-
|
|
1624
|
+
pushBlockedToolMessage(messages, toolCall, outcome.blockedContent);
|
|
1625
|
+
continue;
|
|
794
1626
|
}
|
|
795
|
-
result =
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
// We cannot yield from inside a callback, so we accumulate
|
|
805
|
-
// chunks and emit them after. Instead, use a buffer approach.
|
|
806
|
-
streamChunkBuffer.push({
|
|
807
|
-
type: "tool_stream",
|
|
1627
|
+
let result = outcome.result ?? {
|
|
1628
|
+
success: false,
|
|
1629
|
+
error: 'Tool returned no result',
|
|
1630
|
+
};
|
|
1631
|
+
const _streamToolStartMs = outcome.startedAt;
|
|
1632
|
+
if (!relationshipSafety) {
|
|
1633
|
+
for (const delta of outcome.streamChunks) {
|
|
1634
|
+
yield {
|
|
1635
|
+
type: 'tool_stream',
|
|
808
1636
|
toolStreamData: {
|
|
809
|
-
toolCallId:
|
|
810
|
-
toolName:
|
|
811
|
-
delta
|
|
1637
|
+
toolCallId: toolCall.id,
|
|
1638
|
+
toolName: toolCall.function.name,
|
|
1639
|
+
delta,
|
|
812
1640
|
},
|
|
813
|
-
}
|
|
1641
|
+
};
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
// --- Tool loop guard (P1): observe the native result before any
|
|
1645
|
+
// optimizer so "same call + same result" means no progress. The
|
|
1646
|
+
// decision is applied at the batch boundary so tool_call/tool_result
|
|
1647
|
+
// pairs are never split.
|
|
1648
|
+
const loopDecision = loopGuard.observe({
|
|
1649
|
+
name: toolCall.function.name,
|
|
1650
|
+
argumentsJson: toolCall.function.arguments || '{}',
|
|
1651
|
+
result,
|
|
1652
|
+
});
|
|
1653
|
+
if (loopDecision.action === 'stop' || (loopDecision.action === 'warn' && !pendingLoopDecision)) {
|
|
1654
|
+
pendingLoopDecision = loopDecision;
|
|
1655
|
+
}
|
|
1656
|
+
// Expand the current turn's cached schema after discovery or live
|
|
1657
|
+
// authoring. Without this, a newly created tool is dispatchable but
|
|
1658
|
+
// invisible to the model until the next user turn.
|
|
1659
|
+
if (result.success) {
|
|
1660
|
+
const data = result.data;
|
|
1661
|
+
const discoveredNames = toolCall.function.name === 'tool_search' ? data?.names : undefined;
|
|
1662
|
+
const names = [...new Set([
|
|
1663
|
+
...(Array.isArray(discoveredNames) ? discoveredNames : []),
|
|
1664
|
+
...(Array.isArray(data?.createdTools) ? data.createdTools : []),
|
|
1665
|
+
])];
|
|
1666
|
+
if (names.length > 0) {
|
|
1667
|
+
try {
|
|
1668
|
+
const added = await this.deps.toolSelectionStrategy.expandCachedTools(names);
|
|
1669
|
+
logger.debug('tool selection expanded after tool result', {
|
|
1670
|
+
source: toolCall.function.name,
|
|
1671
|
+
names,
|
|
1672
|
+
added,
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
catch (err) {
|
|
1676
|
+
logger.warn('tool selection expansion failed', {
|
|
1677
|
+
source: toolCall.function.name,
|
|
1678
|
+
error: String(err),
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
// --- User hooks: PostToolUse / PostToolUseFailure (streaming path) ---
|
|
1684
|
+
await runPostToolUseHook(process.cwd(), toolCall, result);
|
|
1685
|
+
// --- Per-tool metrics (streaming path, DeepWiki gap #3) ---
|
|
1686
|
+
await recordToolMetric(toolCall.function.name, result.success, Date.now() - _streamToolStartMs);
|
|
1687
|
+
// Phase (d).2 — fleet broadcast on completion (opt-in).
|
|
1688
|
+
emitFleetToolCompleted(toolCall, result, Date.now() - _streamToolStartMs);
|
|
1689
|
+
// Phase (d).21 ship 3 — proactive notification on tool completion.
|
|
1690
|
+
// Default sink logs at info (success) / warn (failure). Gated by
|
|
1691
|
+
// quiet hours + rate limit in NotificationManager.
|
|
1692
|
+
try {
|
|
1693
|
+
const _toolDurationStream = Date.now() - _streamToolStartMs;
|
|
1694
|
+
notify({
|
|
1695
|
+
channelType: 'cli',
|
|
1696
|
+
channelId: 'tool-completion',
|
|
1697
|
+
message: result.success
|
|
1698
|
+
? `${toolCall.function.name} completed in ${_toolDurationStream}ms`
|
|
1699
|
+
: `${toolCall.function.name} failed: ${result.error ?? 'unknown error'}`,
|
|
1700
|
+
priority: result.success ? 'low' : 'high',
|
|
814
1701
|
});
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1702
|
+
}
|
|
1703
|
+
catch { /* notification optional */ }
|
|
1704
|
+
// Phase (d).21 ship 4 — progress update.
|
|
1705
|
+
try {
|
|
1706
|
+
getProgressTracker().update(toolCall.id, result.success ? 'completed' : 'failed', toolCall.function.name);
|
|
1707
|
+
}
|
|
1708
|
+
catch { /* progress optional */ }
|
|
1709
|
+
// --- Track file access for code graph context (streaming, incremental update) ---
|
|
1710
|
+
try {
|
|
1711
|
+
const fileToolsStream = new Set(['view_file', 'create_file', 'str_replace_editor', 'file_read', 'file_write']);
|
|
1712
|
+
if (!isolatedSharedHost && fileToolsStream.has(toolCall.function.name)) {
|
|
1713
|
+
const args = JSON.parse(toolCall.function.arguments || '{}');
|
|
1714
|
+
const filePath = args.path || args.file_path || args.target_file || '';
|
|
1715
|
+
if (filePath) {
|
|
1716
|
+
trackRecentFile(filePath);
|
|
1717
|
+
if (['create_file', 'str_replace_editor', 'file_write'].includes(toolCall.function.name)) {
|
|
1718
|
+
const kg = getKnowledgeGraph();
|
|
1719
|
+
if (kg.getStats().tripleCount > 0) {
|
|
1720
|
+
const absPath = resolvePath(process.cwd(), filePath);
|
|
1721
|
+
updateGraphForFile(kg, absPath, process.cwd());
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
818
1725
|
}
|
|
819
|
-
streamChunkBuffer.length = 0;
|
|
820
1726
|
}
|
|
821
|
-
|
|
822
|
-
|
|
1727
|
+
catch { /* file tracking is optional */ }
|
|
1728
|
+
// --- JIT context discovery: load subdirectory context files ---
|
|
1729
|
+
// Décision #2 du plan task #5 — promu du sequential vers streaming
|
|
1730
|
+
// pour parité d'enrichissement après chaque tool qui touche un path.
|
|
1731
|
+
// The current provider request already consumed preparedMessages.
|
|
1732
|
+
// Keep newly discovered instructions in turn-local state so the
|
|
1733
|
+
// next provider round actually receives them without persisting
|
|
1734
|
+
// them into later user turns.
|
|
1735
|
+
jitContextBlocks.push(...await runJitContextDiscovery(toolCall));
|
|
1736
|
+
// Build three deliberately separate views of one observation:
|
|
1737
|
+
// 1. recovery: exact native output persisted before any hook/optimizer,
|
|
1738
|
+
// 2. display: provider-sanitized ToolResult emitted to the UI,
|
|
1739
|
+
// 3. model: token-budgeted observation appended to the transcript.
|
|
1740
|
+
// Non-streaming ToolHandler calls already persisted (1) before their
|
|
1741
|
+
// after-hooks. Streaming adapters are persisted here on first sight.
|
|
1742
|
+
const recoveryStore = getRestorableCompressor();
|
|
1743
|
+
const toolWorkspace = typeof this.deps.toolHandler.getWorkingDirectory === 'function'
|
|
1744
|
+
? this.deps.toolHandler.getWorkingDirectory()
|
|
1745
|
+
: process.cwd();
|
|
1746
|
+
const recoverySessionId = typeof this.deps.toolHandler.getRecoverySessionId === 'function'
|
|
1747
|
+
? this.deps.toolHandler.getRecoverySessionId()
|
|
1748
|
+
: undefined;
|
|
1749
|
+
let rawForRecovery = formatToolResultForRecovery(result);
|
|
1750
|
+
const executionWasAborted = result.error?.startsWith('aborted by user after ') ?? false;
|
|
1751
|
+
if (toolCall.id && recoveryStore && !executionWasAborted) {
|
|
1752
|
+
const existingRecovery = recoveryStore.restore(toolCall.id, toolWorkspace, recoverySessionId);
|
|
1753
|
+
if (existingRecovery.found) {
|
|
1754
|
+
rawForRecovery = existingRecovery.content;
|
|
1755
|
+
}
|
|
1756
|
+
else {
|
|
1757
|
+
recoveryStore.writeToolResult(toolCall.id, rawForRecovery, toolWorkspace, recoverySessionId);
|
|
1758
|
+
}
|
|
823
1759
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
channelId: 'tool-completion',
|
|
840
|
-
message: result.success
|
|
841
|
-
? `${toolCall.function.name} completed in ${_toolDurationStream}ms`
|
|
842
|
-
: `${toolCall.function.name} failed: ${result.error ?? 'unknown error'}`,
|
|
843
|
-
priority: result.success ? 'low' : 'high',
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
catch { /* notification optional */ }
|
|
847
|
-
// Phase (d).21 ship 4 — progress update.
|
|
848
|
-
try {
|
|
849
|
-
const { getProgressTracker } = await import('../planner/progress-default-sink.js');
|
|
850
|
-
getProgressTracker().update(toolCall.id, result.success ? 'completed' : 'failed', toolCall.function.name);
|
|
851
|
-
}
|
|
852
|
-
catch { /* progress optional */ }
|
|
853
|
-
// --- Track file access for code graph context (streaming, incremental update) ---
|
|
854
|
-
try {
|
|
855
|
-
const fileToolsStream = new Set(['view_file', 'create_file', 'str_replace_editor', 'file_read', 'file_write']);
|
|
856
|
-
if (fileToolsStream.has(toolCall.function.name)) {
|
|
1760
|
+
let modelObservation = rawForRecovery;
|
|
1761
|
+
// TokenJuice remains a lossless first pass for verbose web content.
|
|
1762
|
+
// It only affects the model view; recovery and display stay intact.
|
|
1763
|
+
if (isTokenJuiceEnabled() &&
|
|
1764
|
+
result?.success &&
|
|
1765
|
+
modelObservation.length > JUICE_MIN_CHARS &&
|
|
1766
|
+
JUICE_WEB_TOOLS.has(toolCall.function.name)) {
|
|
1767
|
+
const juiced = tokenJuice(modelObservation, { html: true, dedupe: true });
|
|
1768
|
+
if (juiced.savedChars > 0) {
|
|
1769
|
+
logger.debug(`[token-juice] ${toolCall.function.name}: saved ${juiced.savedChars} chars (${juiced.applied.join('+')})`);
|
|
1770
|
+
modelObservation = juiced.output;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
let logicalCommand = '';
|
|
1774
|
+
try {
|
|
857
1775
|
const args = JSON.parse(toolCall.function.arguments || '{}');
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1776
|
+
if (typeof args.command === 'string')
|
|
1777
|
+
logicalCommand = args.command;
|
|
1778
|
+
}
|
|
1779
|
+
catch { /* malformed args were already handled by the dispatcher */ }
|
|
1780
|
+
const activeObservationModel = this.deps.client.getCurrentModel() ?? '';
|
|
1781
|
+
const activeObservationConfig = getModelToolConfig(activeObservationModel);
|
|
1782
|
+
const optimization = await optimizeToolObservation({
|
|
1783
|
+
toolName: toolCall.function.name,
|
|
1784
|
+
toolCallId: toolCall.id || `tool_${Date.now()}`,
|
|
1785
|
+
content: modelObservation,
|
|
1786
|
+
success: result?.success,
|
|
1787
|
+
exitCode: result?.success ? 0 : 1,
|
|
1788
|
+
command: logicalCommand,
|
|
1789
|
+
query: message ?? '',
|
|
1790
|
+
workspaceRoot: toolWorkspace,
|
|
1791
|
+
contextWindow: activeObservationConfig.contextWindow ?? 128_000,
|
|
1792
|
+
currentInputTokens: inputTokens,
|
|
1793
|
+
signal: abortController?.signal,
|
|
1794
|
+
});
|
|
1795
|
+
let modelStreamContent = optimization.content;
|
|
1796
|
+
if (optimization.optimized)
|
|
1797
|
+
observationShortened = true;
|
|
1798
|
+
// lm-resizer owns the semantic budget when available. Its absence or
|
|
1799
|
+
// an intentionally raw failure still receives a model-aware hard cap;
|
|
1800
|
+
// the exact observation remains available through restore_context.
|
|
1801
|
+
if (toolCall.function.name !== 'restore_context') {
|
|
1802
|
+
const budgetTokens = optimization.tokenBudget ?? 5_000;
|
|
1803
|
+
const hardLimitChars = Math.min(80_000, Math.max(8_000, budgetTokens * 4));
|
|
1804
|
+
if (modelStreamContent.length > hardLimitChars ||
|
|
1805
|
+
this.deps.tokenCounter.countTokens(modelStreamContent) > budgetTokens) {
|
|
1806
|
+
const truncated = semanticTruncate(modelStreamContent, { maxChars: hardLimitChars });
|
|
1807
|
+
if (truncated.truncated) {
|
|
1808
|
+
observationShortened = true;
|
|
1809
|
+
const recoveryNote = toolCall.id
|
|
1810
|
+
? `\n\n[Full exact observation: restore_context({"identifier":${JSON.stringify(toolCall.id)}})]`
|
|
1811
|
+
: '';
|
|
1812
|
+
modelStreamContent = `${truncated.output}${recoveryNote}`;
|
|
871
1813
|
}
|
|
872
1814
|
}
|
|
873
1815
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1816
|
+
const observationMetadata = {
|
|
1817
|
+
optimizer: optimization.optimized ? 'lm-resizer' : 'none',
|
|
1818
|
+
reason: optimization.reason,
|
|
1819
|
+
rawRef: optimization.rawRef,
|
|
1820
|
+
originalBytes: optimization.originalBytes,
|
|
1821
|
+
finalBytes: Buffer.byteLength(modelStreamContent),
|
|
1822
|
+
bytesSaved: Math.max(0, optimization.originalBytes - Buffer.byteLength(modelStreamContent)),
|
|
1823
|
+
...(optimization.transport ? { transport: optimization.transport } : {}),
|
|
1824
|
+
};
|
|
1825
|
+
result = {
|
|
1826
|
+
...result,
|
|
1827
|
+
metadata: {
|
|
1828
|
+
...(result?.metadata ?? {}),
|
|
1829
|
+
contextOptimization: observationMetadata,
|
|
1830
|
+
},
|
|
1831
|
+
};
|
|
1832
|
+
const rawStreamContent = sanitizeToolResult(rawForRecovery);
|
|
1833
|
+
const sanitizedModelObservation = sanitizeToolResult(modelStreamContent);
|
|
1834
|
+
const variedStreamContent = applyObservationVariator(toolCall.function.name, sanitizedModelObservation);
|
|
1835
|
+
const visibleToolResult = relationshipSafety
|
|
1836
|
+
? relationshipSafeToolResultForDisplay(result)
|
|
1837
|
+
: result;
|
|
1838
|
+
const toolResultEntry = {
|
|
1839
|
+
type: "tool_result",
|
|
1840
|
+
content: visibleToolResult.success
|
|
1841
|
+
? visibleToolResult.output || "Success"
|
|
1842
|
+
: visibleToolResult.error || "Error occurred",
|
|
1843
|
+
timestamp: new Date(),
|
|
1844
|
+
toolCall: toolCall,
|
|
1845
|
+
toolResult: visibleToolResult,
|
|
1846
|
+
};
|
|
1847
|
+
history.push(toolResultEntry);
|
|
1848
|
+
yield { type: "tool_result", toolCall, toolResult: visibleToolResult };
|
|
1849
|
+
// Note: 'name' is required for Gemini API to match functionResponse with functionCall
|
|
1850
|
+
messages.push({
|
|
1851
|
+
role: "tool",
|
|
1852
|
+
content: variedStreamContent,
|
|
1853
|
+
tool_call_id: toolCall.id || `tool_${Date.now()}`,
|
|
1854
|
+
name: toolCall.function.name,
|
|
1855
|
+
});
|
|
1856
|
+
// --- Auto-commit after file-modifying tools (streaming path) ---
|
|
1857
|
+
if (result?.success) {
|
|
1858
|
+
try {
|
|
1859
|
+
const acResult = await maybeAutoCommit(toolCall.function.name, toolCall.function.arguments || '{}', rawStreamContent.substring(0, 120));
|
|
1860
|
+
if (acResult?.success) {
|
|
1861
|
+
logger.debug('Auto-commit (stream):', { hash: acResult.commitHash });
|
|
1862
|
+
}
|
|
1863
|
+
else if (acResult && acResult.message && /failed/i.test(acResult.message)) {
|
|
1864
|
+
// Real commit failure — surface to the user (see sequential path above).
|
|
1865
|
+
logger.warn(`Auto-commit failed: ${acResult.message}`);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
catch (err) {
|
|
1869
|
+
logger.debug('Auto-commit threw (stream)', { err: err instanceof Error ? err.message : String(err) });
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
// --- Fix 11: YOLO cost display after each tool (streaming path) ---
|
|
1873
|
+
await logYoloCostIfEnabled(this.config);
|
|
1874
|
+
// --- Terminate signal detection (OpenManus #5, streaming path) ---
|
|
1875
|
+
const streamTerminateMsg = extractTerminateMessage(rawStreamContent);
|
|
1876
|
+
if (streamTerminateMsg !== null) {
|
|
1877
|
+
yield { type: "content", content: `\n\n${streamTerminateMsg}` };
|
|
1878
|
+
terminateDetectedStreaming = true;
|
|
1879
|
+
break toolExecution;
|
|
1880
|
+
}
|
|
1881
|
+
// --- Interactive Shell Handoff detection (streaming path) ---
|
|
1882
|
+
const shellRequestMsg = extractSignalMessage(rawStreamContent, INTERACTIVE_SHELL_SIGNAL);
|
|
1883
|
+
if (shellRequestMsg !== null) {
|
|
1884
|
+
yield { type: "content", content: `\n\n⚠️ **INTERACTIVE SHELL HANDOFF REQUESTED**\n\n${shellRequestMsg}` };
|
|
1885
|
+
yield {
|
|
1886
|
+
type: "ask_user",
|
|
1887
|
+
askUser: {
|
|
1888
|
+
question: "Do you want to open an interactive terminal to perform this action? (Type 'exit' in the terminal when done to return control to the AI)",
|
|
1889
|
+
options: ["Yes, open interactive shell", "No, cancel tool"]
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
terminateDetectedStreaming = true;
|
|
1893
|
+
break toolExecution;
|
|
1894
|
+
}
|
|
1895
|
+
// --- Plan Approval detection (streaming path) ---
|
|
1896
|
+
const planMsg = extractSignalMessage(rawStreamContent, PLAN_APPROVAL_SIGNAL);
|
|
1897
|
+
if (planMsg !== null) {
|
|
1898
|
+
yield { type: "content", content: `\n\n⚠️ **PLAN APPROVAL REQUIRED**\n\n${planMsg}` };
|
|
1899
|
+
yield {
|
|
1900
|
+
type: "ask_user",
|
|
1901
|
+
askUser: {
|
|
1902
|
+
question: "Do you approve this plan? (Yes to execute, No to cancel, or provide feedback)",
|
|
1903
|
+
options: ["Approve", "Reject"]
|
|
1904
|
+
}
|
|
896
1905
|
};
|
|
1906
|
+
terminateDetectedStreaming = true;
|
|
1907
|
+
break toolExecution;
|
|
1908
|
+
}
|
|
1909
|
+
// --- Yield signal detection (Native Engine v2026.3.14, streaming path) ---
|
|
1910
|
+
const streamYieldChildId = extractYieldChildId(rawStreamContent);
|
|
1911
|
+
if (streamYieldChildId) {
|
|
1912
|
+
yield { type: "content", content: `\n[Waiting for sub-agent to complete...]` };
|
|
1913
|
+
await processYieldSignal(streamYieldChildId, messages);
|
|
897
1914
|
}
|
|
898
1915
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
const toolResultEntry = {
|
|
905
|
-
type: "tool_result",
|
|
906
|
-
content: result?.success ? result.output || "Success" : result?.error || "Error occurred",
|
|
907
|
-
timestamp: new Date(),
|
|
908
|
-
toolCall: toolCall,
|
|
909
|
-
toolResult: result,
|
|
1916
|
+
}
|
|
1917
|
+
for (const toolCall of deferredToolCalls) {
|
|
1918
|
+
const toolResult = {
|
|
1919
|
+
success: false,
|
|
1920
|
+
error: 'Skipped because single-tool mode executes one call per round.',
|
|
910
1921
|
};
|
|
911
|
-
history.push(
|
|
912
|
-
|
|
913
|
-
|
|
1922
|
+
history.push({
|
|
1923
|
+
type: 'tool_result',
|
|
1924
|
+
content: toolResult.error ?? 'Tool skipped',
|
|
1925
|
+
timestamp: new Date(),
|
|
1926
|
+
toolCall,
|
|
1927
|
+
toolResult,
|
|
1928
|
+
});
|
|
914
1929
|
messages.push({
|
|
915
|
-
role:
|
|
916
|
-
content:
|
|
917
|
-
tool_call_id: toolCall.id
|
|
1930
|
+
role: 'tool',
|
|
1931
|
+
content: toolResult.error ?? 'Tool skipped',
|
|
1932
|
+
tool_call_id: toolCall.id,
|
|
918
1933
|
name: toolCall.function.name,
|
|
919
1934
|
});
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1935
|
+
yield { type: 'tool_result', toolCall, toolResult };
|
|
1936
|
+
}
|
|
1937
|
+
if (terminateDetectedStreaming)
|
|
1938
|
+
break;
|
|
1939
|
+
if (abortController?.signal.aborted) {
|
|
1940
|
+
yield { type: "content", content: "\n\n[Operation cancelled by user]" };
|
|
1941
|
+
yield { type: "done" };
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
// First shortened observation in this profile: one user-facing tip (P4 first-use hints).
|
|
1945
|
+
if (observationShortened) {
|
|
1946
|
+
observationShortened = false;
|
|
1947
|
+
const tip = takeFirstUseHint('restore_context');
|
|
1948
|
+
if (tip)
|
|
1949
|
+
yield { type: "content", content: `\n💡 ${tip}\n` };
|
|
1950
|
+
}
|
|
1951
|
+
// Tool-call/result pairs are complete here: apply the loop guard.
|
|
1952
|
+
if (pendingLoopDecision) {
|
|
1953
|
+
const decision = pendingLoopDecision;
|
|
1954
|
+
pendingLoopDecision = null;
|
|
1955
|
+
const loopData = {
|
|
1956
|
+
action: decision.action,
|
|
1957
|
+
loopType: decision.kind,
|
|
1958
|
+
toolNames: decision.toolNames,
|
|
1959
|
+
repetitions: decision.repetitions,
|
|
1960
|
+
toolRounds,
|
|
1961
|
+
};
|
|
1962
|
+
try {
|
|
1963
|
+
getGlobalEventBus().emit('agent:loop_detected', {
|
|
1964
|
+
loopType: decision.kind,
|
|
1965
|
+
detail: decision.message,
|
|
1966
|
+
count: decision.repetitions,
|
|
1967
|
+
turnIndex: toolRounds,
|
|
1968
|
+
});
|
|
936
1969
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
// --- Terminate signal detection (OpenManus #5, streaming path) ---
|
|
940
|
-
const streamTerminateMsg = extractTerminateMessage(rawStreamContent);
|
|
941
|
-
if (streamTerminateMsg !== null) {
|
|
942
|
-
yield { type: "content", content: `\n\n${streamTerminateMsg}` };
|
|
943
|
-
terminateDetectedStreaming = true;
|
|
944
|
-
break;
|
|
1970
|
+
catch (err) {
|
|
1971
|
+
logger.debug('[loop-guard] event emission failed', { error: String(err) });
|
|
945
1972
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
question: "Do you want to open an interactive terminal to perform this action? (Type 'exit' in the terminal when done to return control to the AI)",
|
|
954
|
-
options: ["Yes, open interactive shell", "No, cancel tool"]
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
terminateDetectedStreaming = true;
|
|
958
|
-
break;
|
|
1973
|
+
if (decision.action === 'warn') {
|
|
1974
|
+
logger.warn('[loop-guard] loop warning injected', loopData);
|
|
1975
|
+
yield { type: "content", content: `\n⚠️ ${decision.message}\n` };
|
|
1976
|
+
messages.push({
|
|
1977
|
+
role: 'system',
|
|
1978
|
+
content: `<context type="loop-guard">\n${decision.message}\n</context>`,
|
|
1979
|
+
});
|
|
959
1980
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1981
|
+
else {
|
|
1982
|
+
logger.warn('[loop-guard] turn stopped', loopData);
|
|
1983
|
+
const runId = typeof this.deps.toolHandler.getRunId === 'function'
|
|
1984
|
+
? this.deps.toolHandler.getRunId()
|
|
1985
|
+
: undefined;
|
|
1986
|
+
if (runId) {
|
|
1987
|
+
try {
|
|
1988
|
+
getActiveRunStore()?.emit(runId, {
|
|
1989
|
+
type: 'decision',
|
|
1990
|
+
data: { kind: 'loop_guard_stopped', ...loopData },
|
|
1991
|
+
});
|
|
969
1992
|
}
|
|
1993
|
+
catch { /* observability is optional */ }
|
|
1994
|
+
}
|
|
1995
|
+
yield {
|
|
1996
|
+
type: 'run_event',
|
|
1997
|
+
runEvent: { runId: runId ?? '', eventType: 'loop_guard_stopped', data: loopData },
|
|
970
1998
|
};
|
|
971
|
-
|
|
1999
|
+
history.push({ type: 'assistant', content: decision.message, timestamp: new Date() });
|
|
2000
|
+
messages.push({ role: 'assistant', content: decision.message });
|
|
2001
|
+
yield { type: "content", content: `\n\n${decision.message}` };
|
|
2002
|
+
loopGuardStopped = true;
|
|
972
2003
|
break;
|
|
973
2004
|
}
|
|
974
|
-
// --- Yield signal detection (Native Engine v2026.3.14, streaming path) ---
|
|
975
|
-
const streamYieldChildId = extractYieldChildId(rawStreamContent);
|
|
976
|
-
if (streamYieldChildId) {
|
|
977
|
-
yield { type: "content", content: `\n[Waiting for sub-agent to complete...]` };
|
|
978
|
-
await processYieldSignal(streamYieldChildId, messages);
|
|
979
|
-
}
|
|
980
2005
|
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
2006
|
+
// Tool-call/result pairs are complete at this boundary, so a steer
|
|
2007
|
+
// that arrived while tools were running can now be injected safely.
|
|
2008
|
+
const deferredSteering = this.deps.messageQueue?.hasSteeringMessage()
|
|
2009
|
+
? this.deps.messageQueue.consumeSteeringMessage()
|
|
2010
|
+
: null;
|
|
2011
|
+
if (deferredSteering) {
|
|
2012
|
+
yield {
|
|
2013
|
+
type: 'steer',
|
|
2014
|
+
steer: { content: deferredSteering.content, source: deferredSteering.source },
|
|
2015
|
+
};
|
|
2016
|
+
messages.push({ role: 'user', content: deferredSteering.content });
|
|
2017
|
+
history.push({
|
|
2018
|
+
type: 'user',
|
|
2019
|
+
content: deferredSteering.content,
|
|
2020
|
+
timestamp: deferredSteering.timestamp,
|
|
2021
|
+
});
|
|
2022
|
+
continue;
|
|
2023
|
+
}
|
|
2024
|
+
inputTokens = incrementalTokenCounter.count(messages);
|
|
984
2025
|
yield { type: "token_count", tokenCount: inputTokens + totalOutputTokens };
|
|
985
2026
|
// Run after_turn middleware (handles cost recording + limit)
|
|
986
2027
|
if (pipeline) {
|
|
@@ -999,10 +2040,10 @@ export class AgentExecutor {
|
|
|
999
2040
|
// Note: cost is recorded once at end-of-loop, not here (avoids double-counting)
|
|
1000
2041
|
// Apply TTL-based tool result expiry + image pruning + backward-scanned FIFO masking (streaming path)
|
|
1001
2042
|
try {
|
|
1002
|
-
const { applyToolOutputMasking, expireOldToolResults, pruneImageContent } = await import('../../context/tool-output-masking.js');
|
|
1003
2043
|
expireOldToolResults(messages, toolRounds);
|
|
1004
2044
|
pruneImageContent(messages);
|
|
1005
2045
|
applyToolOutputMasking(messages);
|
|
2046
|
+
incrementalTokenCounter.invalidate();
|
|
1006
2047
|
}
|
|
1007
2048
|
catch { /* masking is optional */ }
|
|
1008
2049
|
}
|
|
@@ -1033,64 +2074,48 @@ export class AgentExecutor {
|
|
|
1033
2074
|
});
|
|
1034
2075
|
continue;
|
|
1035
2076
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
attempt: emptyRetries,
|
|
1045
|
-
max: maxEmptyRetries,
|
|
1046
|
-
});
|
|
1047
|
-
messages.push({
|
|
1048
|
-
role: 'user',
|
|
1049
|
-
content: 'Your last response was empty. Use the results of the tool calls you just made ' +
|
|
1050
|
-
'to continue the task and produce your answer.',
|
|
2077
|
+
if (streamFinishReason === 'length') {
|
|
2078
|
+
assistantEntry.truncated = true;
|
|
2079
|
+
const notice = lengthContinuations > 0
|
|
2080
|
+
? `Réponse tronquée après ${lengthContinuations} continuation(s) (limite de longueur atteinte).`
|
|
2081
|
+
: 'Réponse tronquée (limite de longueur atteinte).';
|
|
2082
|
+
logger.warn('[agent-executor] length-truncated response', {
|
|
2083
|
+
continuations: lengthContinuations,
|
|
2084
|
+
max: maxLengthContinuations,
|
|
1051
2085
|
});
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
const acm = getAutoCaptureManager();
|
|
1059
|
-
if (acm) {
|
|
1060
|
-
acm.processMessage('assistant', content || '').catch(err => logger.debug('Auto-capture failed', { error: String(err) }));
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
catch { /* auto-capture optional */ }
|
|
1064
|
-
// Fire-and-forget ICM episode storage (streaming path)
|
|
1065
|
-
if (this.getICMBridgeProvider()) {
|
|
1066
|
-
try {
|
|
1067
|
-
const icm = this.getICMBridgeProvider()();
|
|
1068
|
-
if (icm?.isAvailable()) {
|
|
1069
|
-
const episode = `User: ${message}\nAssistant: ${(content || '').substring(0, 500)}`;
|
|
1070
|
-
icm.storeEpisode(episode, {
|
|
1071
|
-
source: 'agent-executor-stream',
|
|
1072
|
-
sessionId: process.env.CODEBUDDY_SESSION_ID,
|
|
1073
|
-
turnNumber: toolRounds,
|
|
1074
|
-
}).catch(err => logger.debug('ICM episode store failed', { error: String(err) }));
|
|
2086
|
+
assistantEntry.content = assistantEntry.content
|
|
2087
|
+
? `${assistantEntry.content}\n\n${notice}`
|
|
2088
|
+
: notice;
|
|
2089
|
+
const lastMessage = messages[messages.length - 1];
|
|
2090
|
+
if (lastMessage?.role === 'assistant') {
|
|
2091
|
+
lastMessage.content = assistantEntry.content;
|
|
1075
2092
|
}
|
|
2093
|
+
yield { type: 'content', content: `\n${notice}\n` };
|
|
2094
|
+
break;
|
|
1076
2095
|
}
|
|
1077
|
-
|
|
2096
|
+
// Post-tool empty responses are handled before persist (D1) so an
|
|
2097
|
+
// empty assistant message is never written to the transcript.
|
|
1078
2098
|
}
|
|
1079
|
-
//
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
2099
|
+
// Companion hosts own the canonical commit boundary: voice,
|
|
2100
|
+
// channel and Cowork persist only relationship-safe, semantically
|
|
2101
|
+
// accepted text in their surface continuity/session stores. Generic
|
|
2102
|
+
// core observers (AutoCapture, ICM and plugin ContextEngine hooks)
|
|
2103
|
+
// are deliberately not replayed for these protected turns: their
|
|
2104
|
+
// storage/privacy contracts are independent and must never receive a
|
|
2105
|
+
// pre-gate draft or intimate cross-surface transcript by accident.
|
|
2106
|
+
if (!isolatedSharedHost && !relationshipSafety) {
|
|
2107
|
+
this.commitAssistantSideEffects(message, messages, content || '', toolRounds);
|
|
1085
2108
|
}
|
|
1086
|
-
catch { /* afterTurn hook optional */ }
|
|
1087
2109
|
break;
|
|
1088
2110
|
}
|
|
1089
2111
|
}
|
|
1090
|
-
if (toolRounds >= maxToolRounds) {
|
|
1091
|
-
|
|
2112
|
+
if (toolRounds >= maxToolRounds && !terminateDetectedStreaming && !loopGuardStopped) {
|
|
2113
|
+
const limitMessage = 'Maximum tool execution rounds reached.';
|
|
2114
|
+
history.push({ type: 'assistant', content: limitMessage, timestamp: new Date() });
|
|
2115
|
+
messages.push({ role: 'assistant', content: limitMessage });
|
|
2116
|
+
yield { type: 'content', content: `\n\n${limitMessage}` };
|
|
1092
2117
|
}
|
|
1093
|
-
|
|
2118
|
+
recordTurnCost();
|
|
1094
2119
|
// Display per-turn token usage (streaming path). Pass the model
|
|
1095
2120
|
// name so estimateCost can zero out subscription-billed models
|
|
1096
2121
|
// (e.g. gpt-5.5 via ChatGPT Codex backend) — flat-fee, not per token.
|
|
@@ -1098,8 +2123,12 @@ export class AgentExecutor {
|
|
|
1098
2123
|
// may be partial mocks — fall through to estimateCost when it's absent.
|
|
1099
2124
|
const streamTurnCost = this.deps.client.isSubscriptionAuth?.()
|
|
1100
2125
|
? 0
|
|
1101
|
-
: estimateCost(
|
|
1102
|
-
const streamUsageDisplay = formatTokenUsage({
|
|
2126
|
+
: estimateCost(totalInputTokensForCost, totalOutputTokens, undefined, undefined, this.deps.client.getCurrentModel());
|
|
2127
|
+
const streamUsageDisplay = formatTokenUsage({
|
|
2128
|
+
inputTokens: totalInputTokensForCost,
|
|
2129
|
+
outputTokens: totalOutputTokens,
|
|
2130
|
+
cost: streamTurnCost,
|
|
2131
|
+
});
|
|
1103
2132
|
logger.info(`Token usage: ${streamUsageDisplay}`);
|
|
1104
2133
|
yield { type: "content", content: `\n${streamUsageDisplay}` };
|
|
1105
2134
|
if (this.config.isSessionCostLimitReached()) {
|
|
@@ -1141,6 +2170,10 @@ export class AgentExecutor {
|
|
|
1141
2170
|
return;
|
|
1142
2171
|
}
|
|
1143
2172
|
const errorMessage = getErrorMessage(error);
|
|
2173
|
+
logger.error('Agent turn failed', {
|
|
2174
|
+
errorType: error instanceof Error ? error.name : 'unknown',
|
|
2175
|
+
error: errorMessage.slice(0, 2_000),
|
|
2176
|
+
});
|
|
1144
2177
|
const errorEntry = {
|
|
1145
2178
|
type: "assistant",
|
|
1146
2179
|
content: `Sorry, I encountered an error: ${errorMessage}`,
|
|
@@ -1151,6 +2184,99 @@ export class AgentExecutor {
|
|
|
1151
2184
|
yield { type: "content", content: errorEntry.content };
|
|
1152
2185
|
yield { type: "done" };
|
|
1153
2186
|
}
|
|
2187
|
+
finally {
|
|
2188
|
+
recordTurnCost();
|
|
2189
|
+
if (timelineEnabled) {
|
|
2190
|
+
await this.recordCompletedTimelineTurn(timelineHistoryStart, timelineTurn, history, message);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
async recordCompletedTimelineTurn(historyStart, turn, history, userMessage) {
|
|
2195
|
+
if (!this.deps.recordTimelineTurn)
|
|
2196
|
+
return;
|
|
2197
|
+
try {
|
|
2198
|
+
const turnHistory = history.slice(historyStart);
|
|
2199
|
+
const assistant = [...turnHistory]
|
|
2200
|
+
.reverse()
|
|
2201
|
+
.find((entry) => entry.type === 'assistant');
|
|
2202
|
+
const results = new Map();
|
|
2203
|
+
for (const entry of turnHistory) {
|
|
2204
|
+
if (entry.type !== 'tool_result' || !entry.toolCall)
|
|
2205
|
+
continue;
|
|
2206
|
+
results.set(entry.toolCall.id, entry.toolResult?.success === true);
|
|
2207
|
+
}
|
|
2208
|
+
const toolCalls = [];
|
|
2209
|
+
const seenCalls = new Set();
|
|
2210
|
+
for (const entry of turnHistory) {
|
|
2211
|
+
const calls = entry.toolCalls ?? (entry.toolCall ? [entry.toolCall] : []);
|
|
2212
|
+
for (const call of calls) {
|
|
2213
|
+
const key = call.id || `${call.function.name}:${call.function.arguments}`;
|
|
2214
|
+
if (seenCalls.has(key))
|
|
2215
|
+
continue;
|
|
2216
|
+
seenCalls.add(key);
|
|
2217
|
+
toolCalls.push({
|
|
2218
|
+
name: call.function.name,
|
|
2219
|
+
ok: results.get(call.id) ?? false,
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
const successfulCallIds = new Set([...results.entries()]
|
|
2224
|
+
.filter(([, success]) => success)
|
|
2225
|
+
.map(([callId]) => callId));
|
|
2226
|
+
const successfulHistory = turnHistory.map((entry) => ({
|
|
2227
|
+
...entry,
|
|
2228
|
+
...(entry.toolCalls
|
|
2229
|
+
? { toolCalls: entry.toolCalls.filter((call) => successfulCallIds.has(call.id)) }
|
|
2230
|
+
: {}),
|
|
2231
|
+
...(entry.toolCall && !successfulCallIds.has(entry.toolCall.id)
|
|
2232
|
+
? { toolCall: undefined }
|
|
2233
|
+
: {}),
|
|
2234
|
+
}));
|
|
2235
|
+
await this.deps.recordTimelineTurn({
|
|
2236
|
+
turn,
|
|
2237
|
+
ts: new Date().toISOString(),
|
|
2238
|
+
role: assistant ? 'assistant' : 'user',
|
|
2239
|
+
text: assistant?.content ?? userMessage,
|
|
2240
|
+
toolCalls,
|
|
2241
|
+
filesTouched: extractEditedFilesFromHistory(successfulHistory),
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
catch (error) {
|
|
2245
|
+
logger.warn('[agent-executor] timeline hook failed', {
|
|
2246
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
/** Notify internal memory/context observers for an ordinary committed turn. */
|
|
2251
|
+
commitAssistantSideEffects(message, messages, content, toolRounds = 0) {
|
|
2252
|
+
try {
|
|
2253
|
+
void import('../../memory/auto-capture.js').then(({ getAutoCaptureManager }) => {
|
|
2254
|
+
const acm = getAutoCaptureManager();
|
|
2255
|
+
return acm?.processMessage('assistant', content);
|
|
2256
|
+
}).catch(err => logger.debug('Auto-capture failed', { error: String(err) }));
|
|
2257
|
+
}
|
|
2258
|
+
catch { /* auto-capture optional */ }
|
|
2259
|
+
if (this.getICMBridgeProvider()) {
|
|
2260
|
+
try {
|
|
2261
|
+
const icm = this.getICMBridgeProvider()();
|
|
2262
|
+
if (icm?.isAvailable()) {
|
|
2263
|
+
const episode = `User: ${message}\nAssistant: ${content.substring(0, 500)}`;
|
|
2264
|
+
void icm.storeEpisode(episode, {
|
|
2265
|
+
source: 'agent-executor-stream',
|
|
2266
|
+
sessionId: process.env.CODEBUDDY_SESSION_ID,
|
|
2267
|
+
turnNumber: toolRounds,
|
|
2268
|
+
}).catch(err => logger.debug('ICM episode store failed', { error: String(err) }));
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
catch { /* ICM store optional */ }
|
|
2272
|
+
}
|
|
2273
|
+
try {
|
|
2274
|
+
const engine = this.deps.contextManager.getContextEngine?.();
|
|
2275
|
+
if (engine) {
|
|
2276
|
+
engine.afterTurn(messages, { role: 'assistant', content });
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
catch { /* afterTurn hook optional */ }
|
|
1154
2280
|
}
|
|
1155
2281
|
}
|
|
1156
2282
|
//# sourceMappingURL=agent-executor.js.map
|