@phuetz/code-buddy 1.1.0 → 1.3.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/README.md +211 -163
- package/dist/agent/autonomous/agentic-coding-contract.d.ts +12 -12
- package/dist/agent/base-agent.d.ts +4 -0
- package/dist/agent/base-agent.js +6 -0
- package/dist/agent/codebuddy-agent.d.ts +1 -1
- package/dist/agent/codebuddy-agent.js +69 -14
- package/dist/agent/execution/agent-executor.js +122 -12
- package/dist/agent/execution/tool-dependency-graph.js +7 -0
- package/dist/agent/execution/tool-hooks.d.ts +6 -0
- package/dist/agent/execution/tool-hooks.js +13 -5
- package/dist/agent/execution/tool-selection-strategy.d.ts +11 -2
- package/dist/agent/execution/tool-selection-strategy.js +67 -10
- package/dist/agent/extended-thinking.d.ts +8 -0
- package/dist/agent/extended-thinking.js +27 -0
- package/dist/agent/facades/infrastructure-facade.d.ts +9 -2
- package/dist/agent/facades/infrastructure-facade.js +15 -6
- package/dist/agent/hermes-browser-backends.js +151 -11
- package/dist/agent/hermes-claw-migrate.d.ts +59 -0
- package/dist/agent/hermes-claw-migrate.js +427 -26
- package/dist/agent/hermes-parity-manifest.js +78 -71
- package/dist/agent/hermes-runtime-lifecycle.d.ts +67 -0
- package/dist/agent/hermes-runtime-lifecycle.js +468 -0
- package/dist/agent/middleware/index.d.ts +1 -0
- package/dist/agent/middleware/index.js +1 -0
- package/dist/agent/middleware/visual-validation-middleware.d.ts +17 -0
- package/dist/agent/middleware/visual-validation-middleware.js +67 -0
- package/dist/agent/model-benchmark.d.ts +77 -0
- package/dist/agent/model-benchmark.js +309 -0
- package/dist/agent/model-tier.d.ts +14 -0
- package/dist/agent/model-tier.js +71 -0
- package/dist/agent/multi-agent/agents/orchestrator-agent.js +17 -6
- package/dist/agent/multi-agent/multi-agent-system.js +3 -1
- package/dist/agent/multi-agent/session-fleet-bridge.d.ts +2 -0
- package/dist/agent/multi-agent/session-fleet-bridge.js +9 -1
- package/dist/agent/multi-agent/session-tools.js +22 -5
- package/dist/agent/reasoning/mcts.js +20 -6
- package/dist/agent/self-improvement/authored-artifact-gate.d.ts +18 -0
- package/dist/agent/self-improvement/authored-artifact-gate.js +42 -0
- package/dist/agent/self-improvement/authored-tool-runtime.d.ts +27 -0
- package/dist/agent/self-improvement/authored-tool-runtime.js +57 -0
- package/dist/agent/self-improvement/authored-tool-store.d.ts +24 -0
- package/dist/agent/self-improvement/authored-tool-store.js +57 -0
- package/dist/agent/self-improvement/llm-tool-proposer.d.ts +41 -0
- package/dist/agent/self-improvement/llm-tool-proposer.js +136 -0
- package/dist/agent/self-improvement/sandbox-scorer.d.ts +17 -0
- package/dist/agent/self-improvement/sandbox-scorer.js +43 -0
- package/dist/agent/self-improvement/self-knowledge.d.ts +8 -0
- package/dist/agent/self-improvement/self-knowledge.js +24 -0
- package/dist/agent/self-improvement/skill-benchmark.d.ts +9 -0
- package/dist/agent/self-improvement/skill-benchmark.js +22 -0
- package/dist/agent/self-improvement/skill-consolidator.d.ts +71 -0
- package/dist/agent/self-improvement/skill-consolidator.js +137 -0
- package/dist/agent/self-improvement/skill-engine.d.ts +42 -0
- package/dist/agent/self-improvement/skill-engine.js +87 -0
- package/dist/agent/self-improvement/skill-gate.d.ts +19 -0
- package/dist/agent/self-improvement/skill-gate.js +62 -0
- package/dist/agent/self-improvement/skill-mutator.d.ts +74 -0
- package/dist/agent/self-improvement/skill-mutator.js +223 -0
- package/dist/agent/self-improvement/skill-proposer.d.ts +40 -0
- package/dist/agent/self-improvement/skill-proposer.js +82 -0
- package/dist/agent/self-improvement/skill-types.d.ts +41 -0
- package/dist/agent/self-improvement/skill-types.js +13 -0
- package/dist/agent/self-improvement/tool-benchmark.d.ts +10 -0
- package/dist/agent/self-improvement/tool-benchmark.js +37 -0
- package/dist/agent/self-improvement/tool-engine.d.ts +54 -0
- package/dist/agent/self-improvement/tool-engine.js +101 -0
- package/dist/agent/self-improvement/tool-gate.d.ts +20 -0
- package/dist/agent/self-improvement/tool-gate.js +78 -0
- package/dist/agent/self-improvement/tool-proposer.d.ts +31 -0
- package/dist/agent/self-improvement/tool-proposer.js +34 -0
- package/dist/agent/self-improvement/tool-skill-mutator.d.ts +40 -0
- package/dist/agent/self-improvement/tool-skill-mutator.js +79 -0
- package/dist/agent/self-improvement/tool-types.d.ts +48 -0
- package/dist/agent/self-improvement/tool-types.js +9 -0
- package/dist/agent/self-improvement/types.d.ts +3 -1
- package/dist/agent/session-end-flush.d.ts +6 -1
- package/dist/agent/session-end-flush.js +20 -4
- package/dist/agent/streaming/streaming-handler.d.ts +7 -0
- package/dist/agent/streaming/streaming-handler.js +8 -1
- package/dist/agent/tool-executor.js +1 -0
- package/dist/agent/tool-handler.d.ts +5 -0
- package/dist/agent/tool-handler.js +133 -4
- package/dist/browser-automation/browser-operator-executor.js +15 -0
- package/dist/browser-automation/browser-use-runner.d.ts +96 -0
- package/dist/browser-automation/browser-use-runner.js +492 -0
- package/dist/browser-automation/camofox-runner.d.ts +107 -0
- package/dist/browser-automation/camofox-runner.js +287 -0
- package/dist/channels/dingtalk/index.js +3 -0
- package/dist/channels/discord/client.d.ts +9 -0
- package/dist/channels/discord/client.js +12 -0
- package/dist/channels/feishu/index.d.ts +167 -1
- package/dist/channels/feishu/index.js +432 -7
- package/dist/channels/gateway-lifecycle.d.ts +132 -0
- package/dist/channels/gateway-lifecycle.js +219 -0
- package/dist/channels/google-chat/index.d.ts +5 -1
- package/dist/channels/google-chat/index.js +5 -1
- package/dist/channels/imessage/index.d.ts +14 -0
- package/dist/channels/imessage/index.js +64 -17
- package/dist/channels/index.d.ts +4 -0
- package/dist/channels/index.js +4 -0
- package/dist/channels/irc/index.d.ts +73 -3
- package/dist/channels/irc/index.js +446 -11
- package/dist/channels/line/index.js +3 -0
- package/dist/channels/mattermost/index.d.ts +51 -4
- package/dist/channels/mattermost/index.js +303 -20
- package/dist/channels/nextcloud-talk/index.d.ts +89 -8
- package/dist/channels/nextcloud-talk/index.js +367 -16
- package/dist/channels/nostr/index.d.ts +121 -1
- package/dist/channels/nostr/index.js +396 -8
- package/dist/channels/ntfy/index.js +3 -0
- package/dist/channels/qq/index.js +3 -0
- package/dist/channels/slash-parity.d.ts +117 -0
- package/dist/channels/slash-parity.js +185 -0
- package/dist/channels/synology-chat/index.js +3 -0
- package/dist/channels/teams/index.d.ts +3 -0
- package/dist/channels/teams/index.js +3 -0
- package/dist/channels/telegram/client.d.ts +9 -0
- package/dist/channels/telegram/client.js +12 -0
- package/dist/channels/twilio-voice/index.js +3 -0
- package/dist/channels/webchat/index.d.ts +7 -1
- package/dist/channels/webchat/index.js +7 -1
- package/dist/channels/wecom/index.js +3 -0
- package/dist/channels/weixin/index.js +3 -0
- package/dist/channels/zalo/index.js +3 -0
- package/dist/cli/config-loader.js +1 -1
- package/dist/codebuddy/client.d.ts +30 -1
- package/dist/codebuddy/client.js +167 -20
- package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +5 -0
- package/dist/codebuddy/providers/provider-chatgpt-responses.js +7 -1
- package/dist/codebuddy/providers/provider-gemini-native.js +1 -1
- package/dist/codebuddy/providers/provider-openai-compat.d.ts +5 -0
- package/dist/codebuddy/providers/provider-openai-compat.js +82 -2
- package/dist/codebuddy/tool-definitions/computer-control-tools.js +32 -2
- package/dist/codebuddy/tool-definitions/core-tools.js +3 -3
- package/dist/codebuddy/tool-definitions/index.d.ts +2 -1
- package/dist/codebuddy/tool-definitions/index.js +2 -1
- package/dist/codebuddy/tool-definitions/multimodal-tools.d.ts +1 -0
- package/dist/codebuddy/tool-definitions/multimodal-tools.js +44 -1
- package/dist/codebuddy/tool-definitions/windows-tools.d.ts +2 -0
- package/dist/codebuddy/tool-definitions/windows-tools.js +34 -0
- package/dist/codebuddy/tools.d.ts +8 -1
- package/dist/codebuddy/tools.js +67 -24
- package/dist/commands/cli/hermes-commands.js +108 -0
- package/dist/commands/cli/improve-command.js +123 -0
- package/dist/commands/cli/native-engine-commands.js +102 -3
- package/dist/commands/cli/utility-commands.js +45 -0
- package/dist/commands/enhanced-command-handler.js +2 -2
- package/dist/commands/goal-cli.d.ts +30 -0
- package/dist/commands/goal-cli.js +210 -27
- package/dist/commands/handlers/goal-handler.d.ts +9 -2
- package/dist/commands/handlers/goal-handler.js +36 -9
- package/dist/commands/handlers/infra-handlers.js +36 -0
- package/dist/commands/handlers/memory-handlers.js +96 -1
- package/dist/commands/handlers/missing-handlers.d.ts +1 -1
- package/dist/commands/handlers/missing-handlers.js +26 -3
- package/dist/commands/headless-slash.d.ts +2 -0
- package/dist/commands/headless-slash.js +12 -0
- package/dist/commands/llm-provider-resolution.d.ts +5 -3
- package/dist/commands/llm-provider-resolution.js +87 -33
- package/dist/commands/ollama.d.ts +25 -0
- package/dist/commands/ollama.js +100 -0
- package/dist/commands/provider.d.ts +5 -0
- package/dist/commands/provider.js +106 -55
- package/dist/commands/skills-cli/index.js +123 -0
- package/dist/commands/slash/builtin-commands.js +1 -1
- package/dist/commands/spec-next.js +2 -1
- package/dist/commands/spec-plan.js +5 -16
- package/dist/commands/tunnel.d.ts +2 -0
- package/dist/commands/tunnel.js +48 -0
- package/dist/companion/percepts.js +11 -1
- package/dist/config/config-resolver.d.ts +2 -1
- package/dist/config/config-resolver.js +54 -41
- package/dist/config/constants.d.ts +28 -0
- package/dist/config/constants.js +7 -0
- package/dist/config/env-schema.js +756 -0
- package/dist/config/model-tools.js +4 -4
- package/dist/config/toml-config.d.ts +16 -0
- package/dist/config/toml-config.js +3 -0
- package/dist/context/bootstrap-loader.js +6 -23
- package/dist/context/context-manager-v2.js +1 -0
- package/dist/context/import-directive-parser.d.ts +4 -0
- package/dist/context/import-directive-parser.js +51 -6
- package/dist/context/instruction-excludes.d.ts +30 -1
- package/dist/context/instruction-excludes.js +71 -1
- package/dist/context/jit-context.d.ts +8 -10
- package/dist/context/jit-context.js +28 -106
- package/dist/context/project-context.d.ts +90 -0
- package/dist/context/project-context.js +295 -0
- package/dist/daemon/autonomous-daemon.d.ts +1 -1
- package/dist/daemon/autonomous-daemon.js +3 -3
- package/dist/daemon/autonomous-loop.d.ts +31 -1
- package/dist/daemon/autonomous-loop.js +91 -4
- package/dist/daemon/colab-goal.js +9 -1
- package/dist/daemon/cron-agent-bridge.d.ts +12 -3
- package/dist/daemon/cron-agent-bridge.js +25 -9
- package/dist/desktop/codebuddy-engine-adapter.d.ts +32 -0
- package/dist/desktop/codebuddy-engine-adapter.js +257 -80
- package/dist/desktop/engine-adapter.d.ts +14 -0
- package/dist/desktop-automation/automation-manager.js +16 -0
- package/dist/desktop-automation/omniparser-runner.d.ts +63 -0
- package/dist/desktop-automation/omniparser-runner.js +115 -0
- package/dist/desktop-automation/smart-snapshot.d.ts +11 -0
- package/dist/desktop-automation/smart-snapshot.js +72 -5
- package/dist/doctor/index.js +40 -23
- package/dist/events/types.d.ts +11 -0
- package/dist/fleet/colab-store.js +14 -2
- package/dist/fleet/peer-session-bridge.js +50 -12
- package/dist/fleet/peer-tool-bridge.js +14 -0
- package/dist/goals/goal-decomposer.d.ts +27 -0
- package/dist/goals/goal-decomposer.js +293 -0
- package/dist/goals/goal-judge-client.d.ts +15 -0
- package/dist/goals/goal-judge-client.js +45 -0
- package/dist/goals/goal-judge.d.ts +2 -0
- package/dist/goals/goal-judge.js +35 -6
- package/dist/goals/goal-loop.d.ts +14 -0
- package/dist/goals/goal-loop.js +47 -2
- package/dist/goals/goal-manager.d.ts +6 -0
- package/dist/goals/goal-manager.js +67 -14
- package/dist/goals/goal-state.d.ts +13 -0
- package/dist/goals/goal-state.js +83 -13
- package/dist/goals/goal-store.d.ts +3 -0
- package/dist/goals/goal-store.js +31 -15
- package/dist/harness/contract.d.ts +28 -28
- package/dist/hooks/user-hooks.js +17 -3
- package/dist/identity/identity-manager.js +3 -2
- package/dist/index.js +481 -26
- package/dist/input/text-to-speech.d.ts +2 -6
- package/dist/input/text-to-speech.js +2 -27
- package/dist/integrations/screenpipe/screenpipe-client.d.ts +10 -0
- package/dist/integrations/screenpipe/screenpipe-client.js +12 -2
- package/dist/integrations/tailscale.d.ts +13 -0
- package/dist/integrations/tailscale.js +87 -34
- package/dist/knowledge/workspace-indexer.js +53 -9
- package/dist/mcp/client.js +1 -0
- package/dist/mcp/mcp-desktop-tools.d.ts +23 -0
- package/dist/mcp/mcp-desktop-tools.js +158 -0
- package/dist/mcp/mcp-resources.js +2 -3
- package/dist/mcp/mcp-server.js +2 -0
- package/dist/memory/enhanced-memory.d.ts +10 -0
- package/dist/memory/enhanced-memory.js +33 -2
- package/dist/memory/index.d.ts +3 -1
- package/dist/memory/index.js +4 -1
- package/dist/memory/memory-auto-proposer.d.ts +23 -0
- package/dist/memory/memory-auto-proposer.js +308 -0
- package/dist/memory/memory-candidate-queue.d.ts +92 -0
- package/dist/memory/memory-candidate-queue.js +261 -0
- package/dist/memory/persistent-memory.d.ts +45 -2
- package/dist/memory/persistent-memory.js +236 -40
- package/dist/ml/bayesian-qualifier.d.ts +1 -1
- package/dist/ml/bayesian-qualifier.js +35 -2
- package/dist/openclaw/gateway-bridge.js +5 -0
- package/dist/plugins/marketplace.d.ts +1 -0
- package/dist/plugins/marketplace.js +7 -0
- package/dist/prompts/execution-discipline.d.ts +14 -0
- package/dist/prompts/execution-discipline.js +29 -0
- package/dist/prompts/variation-injector.js +9 -2
- package/dist/protocols/acp/acp-agentic-runner.d.ts +7 -6
- package/dist/protocols/acp/acp-agentic-runner.js +115 -18
- package/dist/protocols/acp/acp-session-store.d.ts +23 -0
- package/dist/protocols/acp/acp-session-store.js +77 -0
- package/dist/protocols/acp/acp-stdio-server.d.ts +7 -0
- package/dist/protocols/acp/acp-stdio-server.js +71 -16
- package/dist/providers/active-llm-registry.d.ts +37 -0
- package/dist/providers/active-llm-registry.js +186 -0
- package/dist/providers/auxiliary-provider.d.ts +25 -0
- package/dist/providers/auxiliary-provider.js +192 -0
- package/dist/providers/codex-oauth.d.ts +1 -1
- package/dist/providers/codex-oauth.js +27 -4
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.js +4 -0
- package/dist/providers/provider-catalog.d.ts +70 -0
- package/dist/providers/provider-catalog.js +738 -0
- package/dist/providers/provider-fallback.d.ts +35 -0
- package/dist/providers/provider-fallback.js +171 -0
- package/dist/providers/xai-oauth.d.ts +128 -0
- package/dist/providers/xai-oauth.js +735 -0
- package/dist/scheduler/cron-scheduler.d.ts +15 -3
- package/dist/scheduler/cron-scheduler.js +53 -7
- package/dist/scheduler/script-runner.d.ts +2 -0
- package/dist/scheduler/script-runner.js +19 -4
- package/dist/scheduler/watchdog-handlers.js +7 -20
- package/dist/search/usearch-index.js +7 -2
- package/dist/security/tool-policy/tool-groups.js +2 -0
- package/dist/sensory/dreaming.d.ts +45 -0
- package/dist/sensory/dreaming.js +114 -0
- package/dist/sensory/heartbeat-scheduler.d.ts +38 -0
- package/dist/sensory/heartbeat-scheduler.js +72 -0
- package/dist/sensory/reactions.d.ts +24 -0
- package/dist/sensory/reactions.js +31 -0
- package/dist/sensory/screen-reaction.d.ts +23 -0
- package/dist/sensory/screen-reaction.js +59 -0
- package/dist/sensory/sensory-bridge.d.ts +23 -0
- package/dist/sensory/sensory-bridge.js +85 -0
- package/dist/sensory/sensory-memory.d.ts +20 -0
- package/dist/sensory/sensory-memory.js +39 -0
- package/dist/sensory/speech-reaction.d.ts +21 -0
- package/dist/sensory/speech-reaction.js +83 -0
- package/dist/sensory/vision-reaction.d.ts +31 -0
- package/dist/sensory/vision-reaction.js +74 -0
- package/dist/server/index.js +106 -2
- package/dist/server/routes/mobile.d.ts +12 -4
- package/dist/server/routes/mobile.js +116 -1
- package/dist/server/tls-config.d.ts +35 -0
- package/dist/server/tls-config.js +142 -0
- package/dist/server/tunnel-manager.d.ts +20 -0
- package/dist/server/tunnel-manager.js +58 -0
- package/dist/server/websocket/fleet-bridge.js +5 -0
- package/dist/services/prompt-builder.d.ts +11 -0
- package/dist/services/prompt-builder.js +124 -17
- package/dist/shared/engine-types.d.ts +15 -1
- package/dist/sidecar/sidecar-bridge.d.ts +1 -0
- package/dist/sidecar/sidecar-bridge.js +21 -10
- package/dist/skills/parser.js +3 -0
- package/dist/skills/skill-importer.d.ts +58 -0
- package/dist/skills/skill-importer.js +261 -0
- package/dist/skills/skill-sources.d.ts +20 -0
- package/dist/skills/skill-sources.js +102 -0
- package/dist/skills/types.d.ts +6 -0
- package/dist/spec/spec-store.js +8 -1
- package/dist/talk-mode/providers/audioreader-tts.d.ts +1 -1
- package/dist/talk-mode/providers/audioreader-tts.js +8 -8
- package/dist/templates/project-scaffolding.js +3 -2
- package/dist/themes/theme-schema.d.ts +10 -10
- package/dist/tools/application-profiles.js +38 -0
- package/dist/tools/bash/bash-tool.d.ts +1 -0
- package/dist/tools/bash/bash-tool.js +16 -2
- package/dist/tools/bash/command-validator.js +3 -0
- package/dist/tools/bash/rtk-rewrite.d.ts +16 -0
- package/dist/tools/bash/rtk-rewrite.js +100 -0
- package/dist/tools/bash/streaming-executor.js +14 -1
- package/dist/tools/computer-control-tool.d.ts +16 -1
- package/dist/tools/computer-control-tool.js +317 -5
- package/dist/tools/document-generator.d.ts +14 -0
- package/dist/tools/document-generator.js +79 -0
- package/dist/tools/execute-code-rpc-invoker.d.ts +26 -2
- package/dist/tools/execute-code-rpc-invoker.js +46 -5
- package/dist/tools/metadata.js +28 -0
- package/dist/tools/office-macro-tool.d.ts +10 -0
- package/dist/tools/office-macro-tool.js +93 -0
- package/dist/tools/register-tool-handler.d.ts +25 -0
- package/dist/tools/register-tool-handler.js +100 -0
- package/dist/tools/registry/index.d.ts +2 -1
- package/dist/tools/registry/index.js +2 -1
- package/dist/tools/registry/memory-tools.d.ts +20 -0
- package/dist/tools/registry/memory-tools.js +225 -3
- package/dist/tools/registry/multimodal-tools.js +2 -2
- package/dist/tools/registry/vision-tools.d.ts +33 -0
- package/dist/tools/registry/vision-tools.js +308 -6
- package/dist/tools/registry/windows-tools.d.ts +2 -0
- package/dist/tools/registry/windows-tools.js +47 -0
- package/dist/tools/registry.d.ts +6 -0
- package/dist/tools/registry.js +8 -0
- package/dist/tools/route-peer-tool.js +14 -0
- package/dist/tools/screenshot-tool.js +14 -2
- package/dist/tools/text-to-speech-tool.d.ts +1 -1
- package/dist/tools/text-to-speech-tool.js +2 -12
- package/dist/tools/tool-selector.js +3 -59
- package/dist/utils/config-validation/schema.d.ts +40 -7
- package/dist/utils/config-validation/schema.js +130 -1
- package/dist/utils/cost-tracker.js +21 -1
- package/dist/utils/disk-guard.d.ts +180 -0
- package/dist/utils/disk-guard.js +404 -0
- package/dist/utils/init-project.d.ts +7 -0
- package/dist/utils/init-project.js +37 -0
- package/dist/utils/interactive-setup.js +35 -2
- package/dist/utils/model-utils.js +11 -2
- package/dist/utils/output-sanitizer.js +11 -0
- package/dist/utils/provider-detector.d.ts +8 -7
- package/dist/utils/provider-detector.js +19 -77
- package/dist/utils/settings-manager.d.ts +19 -0
- package/dist/utils/token-display.d.ts +3 -3
- package/dist/utils/token-display.js +22 -4
- package/dist/wizard/onboarding.d.ts +39 -0
- package/dist/wizard/onboarding.js +433 -21
- package/dist/wizard/provider-onboarding.d.ts +8 -23
- package/dist/wizard/provider-onboarding.js +39 -158
- package/package.json +4 -2
- package/dist/plugins/provider-onboarding.d.ts +0 -23
- package/dist/plugins/provider-onboarding.js +0 -116
- package/dist/utils/kokoro-tts.d.ts +0 -8
- package/dist/utils/kokoro-tts.js +0 -67
|
@@ -28,14 +28,14 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
28
28
|
* Create a task executor function for the CronScheduler
|
|
29
29
|
*/
|
|
30
30
|
createTaskExecutor() {
|
|
31
|
-
return async (job) => {
|
|
32
|
-
return this.executeJob(job);
|
|
31
|
+
return async (job, inputData) => {
|
|
32
|
+
return this.executeJob(job, inputData);
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Execute a cron job by creating an agent instance
|
|
37
37
|
*/
|
|
38
|
-
async executeJob(job) {
|
|
38
|
+
async executeJob(job, inputData) {
|
|
39
39
|
const startTime = Date.now();
|
|
40
40
|
const abortController = new AbortController();
|
|
41
41
|
this.activeJobs.set(job.id, abortController);
|
|
@@ -80,9 +80,10 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
80
80
|
}
|
|
81
81
|
let output;
|
|
82
82
|
let watchdogOk;
|
|
83
|
+
let scriptStdout;
|
|
83
84
|
switch (job.task.type) {
|
|
84
85
|
case 'message': {
|
|
85
|
-
output = await this.executeMessageTask(job);
|
|
86
|
+
output = await this.executeMessageTask(job, inputData);
|
|
86
87
|
break;
|
|
87
88
|
}
|
|
88
89
|
case 'tool': {
|
|
@@ -100,7 +101,9 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
100
101
|
break;
|
|
101
102
|
}
|
|
102
103
|
case 'script': {
|
|
103
|
-
|
|
104
|
+
const scriptResult = await this.executeScriptTaskFull(job);
|
|
105
|
+
output = scriptResult.output;
|
|
106
|
+
scriptStdout = scriptResult.stdout;
|
|
104
107
|
break;
|
|
105
108
|
}
|
|
106
109
|
case 'skill': {
|
|
@@ -132,6 +135,10 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
132
135
|
deliveryChannel,
|
|
133
136
|
...(watchdogOk !== undefined ? { watchdogOk } : {}),
|
|
134
137
|
});
|
|
138
|
+
// For script jobs, outputData is the captured stdout only (structured
|
|
139
|
+
// data channel, capped at 64KB in the script runner). For all other
|
|
140
|
+
// task types, the full output serves as outputData.
|
|
141
|
+
const outputData = job.task.type === 'script' ? scriptStdout : output;
|
|
135
142
|
const result = {
|
|
136
143
|
jobId: job.id,
|
|
137
144
|
runId: recordedRunId ?? `run-${Date.now()}`,
|
|
@@ -140,6 +147,7 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
140
147
|
duration,
|
|
141
148
|
delivered,
|
|
142
149
|
deliveryChannel,
|
|
150
|
+
outputData,
|
|
143
151
|
...(watchdogOk !== undefined ? { watchdogOk } : {}),
|
|
144
152
|
};
|
|
145
153
|
this.emit('job:complete', result);
|
|
@@ -223,7 +231,7 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
223
231
|
/**
|
|
224
232
|
* Execute a message-type task
|
|
225
233
|
*/
|
|
226
|
-
async executeMessageTask(job) {
|
|
234
|
+
async executeMessageTask(job, inputData) {
|
|
227
235
|
if (!job.task.message) {
|
|
228
236
|
throw new Error('Message task requires a message');
|
|
229
237
|
}
|
|
@@ -245,7 +253,12 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
245
253
|
logger.debug(`Cron job ${job.id}: could not load session ${job.resolvedSessionId}, starting fresh`);
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
|
-
|
|
256
|
+
// Prepend inputData from parent chained job if available
|
|
257
|
+
let message = job.task.message;
|
|
258
|
+
if (inputData) {
|
|
259
|
+
message = `[Chained job context — output from parent job]:\n${inputData}\n\n[Task]:\n${message}`;
|
|
260
|
+
}
|
|
261
|
+
const entries = await agent.processUserMessage(message);
|
|
249
262
|
const assistantEntries = entries.filter(e => e.type === 'assistant');
|
|
250
263
|
return assistantEntries.map(e => e.content).join('\n') || 'No response';
|
|
251
264
|
}
|
|
@@ -292,8 +305,11 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
292
305
|
* WITHOUT instantiating a CodeBuddyAgent or calling any model provider.
|
|
293
306
|
* A non-zero exit (or timeout) throws so the run is recorded as failed and
|
|
294
307
|
* any chained `then` job does not fire.
|
|
308
|
+
*
|
|
309
|
+
* Returns both the combined output (for logging/delivery) and the separate
|
|
310
|
+
* stdout (for cross-job data passing, capped at 64KB by the script runner).
|
|
295
311
|
*/
|
|
296
|
-
async
|
|
312
|
+
async executeScriptTaskFull(job) {
|
|
297
313
|
const command = job.task.command;
|
|
298
314
|
if (!command || typeof command.executable !== 'string' || command.executable.length === 0) {
|
|
299
315
|
throw new Error('Script task requires a command with an executable');
|
|
@@ -312,7 +328,7 @@ export class CronAgentBridge extends EventEmitter {
|
|
|
312
328
|
if (result.exitCode !== 0) {
|
|
313
329
|
throw new Error(`script failed: ${command.executable} (exit ${result.exitCode})\n${result.output}`.trim());
|
|
314
330
|
}
|
|
315
|
-
return result.output;
|
|
331
|
+
return { output: result.output, stdout: result.stdout };
|
|
316
332
|
}
|
|
317
333
|
/**
|
|
318
334
|
* Execute a skill-type task — resolves a named skill from the SkillRegistry
|
|
@@ -40,6 +40,12 @@ export declare class CodeBuddyEngineAdapter implements EngineAdapter {
|
|
|
40
40
|
* effect on the next turn (Phase 8).
|
|
41
41
|
*/
|
|
42
42
|
private agentIdentities;
|
|
43
|
+
/**
|
|
44
|
+
* Configured reasoning/thinking level (`off | minimal | … | xhigh`), set via
|
|
45
|
+
* {@link setThinkingLevel}. Re-applied to each freshly-created agent so a
|
|
46
|
+
* model swap / new session keeps the user's chosen level.
|
|
47
|
+
*/
|
|
48
|
+
private thinkingLevel?;
|
|
43
49
|
/**
|
|
44
50
|
* Hard cap on cached agents — matches the pi-runner's
|
|
45
51
|
* `MAX_CACHED_SESSIONS` (50) so memory pressure is comparable
|
|
@@ -50,6 +56,7 @@ export declare class CodeBuddyEngineAdapter implements EngineAdapter {
|
|
|
50
56
|
constructor(config: EngineSessionConfig);
|
|
51
57
|
runSession(sessionId: string, messages: EngineMessage[], onEvent: EngineStreamCallback, options?: Partial<EngineSessionConfig>): Promise<EngineSessionResult>;
|
|
52
58
|
cancel(sessionId: string): void;
|
|
59
|
+
steer(sessionId: string, prompt: string): boolean;
|
|
53
60
|
clearSession(sessionId: string): void;
|
|
54
61
|
/**
|
|
55
62
|
* Drop oldest cached agents until `agents.size <= maxRetained`.
|
|
@@ -70,6 +77,21 @@ export declare class CodeBuddyEngineAdapter implements EngineAdapter {
|
|
|
70
77
|
* returns whatever survived the previous load.
|
|
71
78
|
*/
|
|
72
79
|
reloadSkills(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Hot-swap the reasoning/thinking level for live sessions. Updates the global
|
|
82
|
+
* extended-thinking budget (read per-turn by the OpenAI-compat / Grok / Ollama
|
|
83
|
+
* providers → effective next turn, no rebuild) and the Gemini-native default on
|
|
84
|
+
* every cached agent. The level is remembered so future agents inherit it.
|
|
85
|
+
*/
|
|
86
|
+
setThinkingLevel(level: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Map a UI level to the Gemini-native default thinking level on a single
|
|
89
|
+
* agent's client. `GeminiThinkingLevel` is `minimal|low|medium|high`, so
|
|
90
|
+
* `xhigh` clamps to `high` and `off`/unknown leaves the Gemini default
|
|
91
|
+
* untouched (the global extended-thinking switch already disables it for the
|
|
92
|
+
* OpenAI-compat path). Best-effort; never throws.
|
|
93
|
+
*/
|
|
94
|
+
private applyGeminiThinkingLevel;
|
|
73
95
|
/**
|
|
74
96
|
* Synchronise the core MCPManager singleton with the host's view of
|
|
75
97
|
* the MCP servers. Called by Cowork at boot and after any
|
|
@@ -97,3 +119,13 @@ export declare class CodeBuddyEngineAdapter implements EngineAdapter {
|
|
|
97
119
|
*/
|
|
98
120
|
updateConfig(config: Partial<EngineSessionConfig>): void;
|
|
99
121
|
}
|
|
122
|
+
/** Cap a single failure detail so the footer stays compact for the judge. */
|
|
123
|
+
export declare function truncateFailureDetail(detail: string, max?: number): string;
|
|
124
|
+
/**
|
|
125
|
+
* Build a prominent, NON-bracketed footer listing failed tool actions. The goal
|
|
126
|
+
* judge prompt (goal-state.ts) treats `[tool:…]` bracketed lines as ignorable
|
|
127
|
+
* metadata, so failures must be surfaced as a plain instruction line or the
|
|
128
|
+
* judge discounts them. Returns '' when there are no failures.
|
|
129
|
+
*/
|
|
130
|
+
export declare function buildToolFailureFooter(failures: string[]): string;
|
|
131
|
+
export declare function buildGoalJudgeResponse(content: string, toolEvidence: string[], toolFailures?: string[]): string;
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { logger } from '../utils/logger.js';
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
|
+
import { maybeContinueGoalAfterTurn } from '../goals/goal-loop.js';
|
|
13
|
+
import { getGoalManager } from '../goals/goal-manager.js';
|
|
14
|
+
const COWORK_GOAL_SESSION_PREFIX = 'cowork:';
|
|
15
|
+
const GOAL_LOOP_HARD_BACKSTOP = 100;
|
|
12
16
|
/**
|
|
13
17
|
* Concrete implementation of EngineAdapter that wraps CodeBuddyAgent.
|
|
14
18
|
*
|
|
@@ -40,6 +44,12 @@ export class CodeBuddyEngineAdapter {
|
|
|
40
44
|
* effect on the next turn (Phase 8).
|
|
41
45
|
*/
|
|
42
46
|
agentIdentities = new Map();
|
|
47
|
+
/**
|
|
48
|
+
* Configured reasoning/thinking level (`off | minimal | … | xhigh`), set via
|
|
49
|
+
* {@link setThinkingLevel}. Re-applied to each freshly-created agent so a
|
|
50
|
+
* model swap / new session keeps the user's chosen level.
|
|
51
|
+
*/
|
|
52
|
+
thinkingLevel;
|
|
43
53
|
/**
|
|
44
54
|
* Hard cap on cached agents — matches the pi-runner's
|
|
45
55
|
* `MAX_CACHED_SESSIONS` (50) so memory pressure is comparable
|
|
@@ -102,6 +112,13 @@ export class CodeBuddyEngineAdapter {
|
|
|
102
112
|
if (typeof agent.setVisionGroundingModel === 'function') {
|
|
103
113
|
agent.setVisionGroundingModel(this.config.visionGroundingModel);
|
|
104
114
|
}
|
|
115
|
+
// Re-apply the configured thinking level so a freshly-created agent
|
|
116
|
+
// (new session or post model-swap) keeps the user's chosen level on the
|
|
117
|
+
// Gemini-native path. The OpenAI-compat / Grok / Ollama path reads the
|
|
118
|
+
// global extended-thinking budget per turn, so it needs no per-agent step.
|
|
119
|
+
if (this.thinkingLevel) {
|
|
120
|
+
this.applyGeminiThinkingLevel(agent, this.thinkingLevel);
|
|
121
|
+
}
|
|
105
122
|
// Phase 9 — enforce LRU before insertion so we never exceed
|
|
106
123
|
// the cap. Evict the least-recently-used (head of the
|
|
107
124
|
// insertion-ordered Map) until there's room.
|
|
@@ -165,92 +182,166 @@ export class CodeBuddyEngineAdapter {
|
|
|
165
182
|
toolCallCount,
|
|
166
183
|
};
|
|
167
184
|
}
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
const streamingAgent = agent;
|
|
186
|
+
const goalSessionKey = buildCoworkGoalSessionKey(sessionId);
|
|
187
|
+
const runPromptTurn = async (prompt) => {
|
|
188
|
+
let turnContent = '';
|
|
189
|
+
const toolEvidence = [];
|
|
190
|
+
// Tracks FAILED tool actions this turn so the goal judge can't be fooled
|
|
191
|
+
// into a premature "done" by an assistant that narrates success after a
|
|
192
|
+
// write/patch/command actually failed (Hermes-style mutation verifier).
|
|
193
|
+
const toolFailures = [];
|
|
194
|
+
const stream = streamingAgent.processUserMessageStream(prompt);
|
|
195
|
+
for await (const chunk of stream) {
|
|
196
|
+
// Check for abort
|
|
197
|
+
if (abortController.signal.aborted) {
|
|
198
|
+
return { interrupted: true, judgeResponse: buildGoalJudgeResponse(turnContent, toolEvidence, toolFailures) };
|
|
199
|
+
}
|
|
200
|
+
switch (chunk.type) {
|
|
201
|
+
case 'content':
|
|
202
|
+
if (chunk.content) {
|
|
203
|
+
turnContent += chunk.content;
|
|
204
|
+
fullContent += chunk.content;
|
|
205
|
+
onEvent({ type: 'content', content: chunk.content });
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
case 'reasoning':
|
|
209
|
+
if (chunk.reasoning) {
|
|
210
|
+
onEvent({ type: 'thinking', thinking: chunk.reasoning });
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case 'tool_calls':
|
|
214
|
+
if (chunk.toolCalls) {
|
|
215
|
+
for (const tc of chunk.toolCalls) {
|
|
216
|
+
toolCallCount++;
|
|
217
|
+
onEvent({
|
|
218
|
+
type: 'tool_start',
|
|
219
|
+
tool: {
|
|
220
|
+
id: tc.id,
|
|
221
|
+
name: tc.function.name,
|
|
222
|
+
input: tc.function.arguments,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
case 'tool_result':
|
|
229
|
+
if (chunk.toolCall && chunk.toolResult) {
|
|
230
|
+
const finalOutput = chunk.toolResult.output || chunk.toolResult.error;
|
|
231
|
+
const toolStatus = chunk.toolResult.success ? 'success' : 'error';
|
|
232
|
+
if (finalOutput) {
|
|
233
|
+
toolEvidence.push(`[tool:${chunk.toolCall.function.name} ${toolStatus}]\n${String(finalOutput)}`);
|
|
234
|
+
}
|
|
235
|
+
// Record failures INDEPENDENTLY of finalOutput — a tool that
|
|
236
|
+
// fails with no output/error would otherwise be invisible to the
|
|
237
|
+
// judge (the silent-failure hole).
|
|
238
|
+
if (!chunk.toolResult.success) {
|
|
239
|
+
const detail = finalOutput ? `: ${truncateFailureDetail(String(finalOutput))}` : '';
|
|
240
|
+
toolFailures.push(`${chunk.toolCall.function.name}${detail}`);
|
|
241
|
+
}
|
|
191
242
|
onEvent({
|
|
192
|
-
type: '
|
|
243
|
+
type: 'tool_end',
|
|
193
244
|
tool: {
|
|
194
|
-
id:
|
|
195
|
-
name:
|
|
196
|
-
input:
|
|
245
|
+
id: chunk.toolCall.id,
|
|
246
|
+
name: chunk.toolCall.function.name,
|
|
247
|
+
input: chunk.toolCall.function.arguments,
|
|
248
|
+
output: finalOutput,
|
|
249
|
+
isError: !chunk.toolResult.success,
|
|
250
|
+
data: chunk.toolResult.data,
|
|
197
251
|
},
|
|
198
252
|
});
|
|
199
253
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
254
|
+
break;
|
|
255
|
+
case 'tool_stream':
|
|
256
|
+
if (chunk.toolStreamData) {
|
|
257
|
+
onEvent({
|
|
258
|
+
type: 'tool_stream',
|
|
259
|
+
tool: {
|
|
260
|
+
id: chunk.toolStreamData.toolCallId,
|
|
261
|
+
name: chunk.toolStreamData.toolName,
|
|
262
|
+
delta: chunk.toolStreamData.delta,
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
case 'token_count':
|
|
268
|
+
if (chunk.tokenCount !== undefined) {
|
|
269
|
+
totalTokens = chunk.tokenCount;
|
|
270
|
+
onEvent({ type: 'token_count', tokenCount: chunk.tokenCount });
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
case 'ask_user':
|
|
274
|
+
if (chunk.askUser) {
|
|
275
|
+
onEvent({ type: 'ask_user', askUser: chunk.askUser });
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case 'plan_progress':
|
|
279
|
+
if (chunk.planProgress) {
|
|
280
|
+
onEvent({ type: 'plan_progress', planProgress: chunk.planProgress });
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case 'steer':
|
|
284
|
+
if (chunk.steer) {
|
|
285
|
+
onEvent({ type: 'steer', steer: chunk.steer });
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
case 'diff_preview':
|
|
289
|
+
if (chunk.diffPreview) {
|
|
290
|
+
onEvent({ type: 'diff_preview', diffPreview: chunk.diffPreview });
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
case 'done':
|
|
294
|
+
onEvent({ type: 'done' });
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return { interrupted: false, judgeResponse: buildGoalJudgeResponse(turnContent, toolEvidence, toolFailures) };
|
|
299
|
+
};
|
|
300
|
+
const emitGoalStatus = (message) => {
|
|
301
|
+
const content = `${fullContent ? '\n\n' : ''}${message}\n\n`;
|
|
302
|
+
fullContent += content;
|
|
303
|
+
onEvent({ type: 'content', content });
|
|
304
|
+
};
|
|
305
|
+
// Structured goal-status event for host UIs (Cowork goal banner). Emits the
|
|
306
|
+
// current GoalState snapshot so the renderer can show turn progress without
|
|
307
|
+
// re-reading goal storage. Safe no-op when no goal is set.
|
|
308
|
+
const emitGoalSnapshot = () => {
|
|
309
|
+
const s = getGoalManager(goalSessionKey).state;
|
|
310
|
+
if (!s || s.status === 'cleared')
|
|
311
|
+
return;
|
|
312
|
+
onEvent({
|
|
313
|
+
type: 'goal_status',
|
|
314
|
+
goalStatus: {
|
|
315
|
+
goal: s.goal,
|
|
316
|
+
status: s.status,
|
|
317
|
+
turnsUsed: s.turnsUsed,
|
|
318
|
+
maxTurns: s.maxTurns,
|
|
319
|
+
...(s.lastVerdict ? { lastVerdict: s.lastVerdict } : {}),
|
|
320
|
+
...(s.lastReason ? { lastReason: s.lastReason } : {}),
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
// Emit once up-front so the banner appears the instant a goal turn starts
|
|
325
|
+
// (before the first judge verdict), then again after each judged turn.
|
|
326
|
+
emitGoalSnapshot();
|
|
327
|
+
let turn = await runPromptTurn(lastMessage.content);
|
|
328
|
+
for (let i = 0; i < GOAL_LOOP_HARD_BACKSTOP; i++) {
|
|
329
|
+
const outcome = await maybeContinueGoalAfterTurn({
|
|
330
|
+
client: streamingAgent.getClient?.() ?? null,
|
|
331
|
+
lastResponse: turn.judgeResponse,
|
|
332
|
+
interrupted: turn.interrupted,
|
|
333
|
+
sessionKey: goalSessionKey,
|
|
334
|
+
});
|
|
335
|
+
if (outcome?.message) {
|
|
336
|
+
emitGoalStatus(outcome.message);
|
|
253
337
|
}
|
|
338
|
+
if (outcome) {
|
|
339
|
+
emitGoalSnapshot();
|
|
340
|
+
}
|
|
341
|
+
if (turn.interrupted || !outcome?.continuationPrompt) {
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
turn = await runPromptTurn(outcome.continuationPrompt);
|
|
254
345
|
}
|
|
255
346
|
return {
|
|
256
347
|
content: fullContent,
|
|
@@ -278,6 +369,18 @@ export class CodeBuddyEngineAdapter {
|
|
|
278
369
|
logger.info('[CodeBuddyEngineAdapter] cancelled session', { sessionId });
|
|
279
370
|
}
|
|
280
371
|
}
|
|
372
|
+
steer(sessionId, prompt) {
|
|
373
|
+
const controller = this.abortControllers.get(sessionId);
|
|
374
|
+
const agent = this.agents.get(sessionId);
|
|
375
|
+
const queue = agent?.getMessageQueue?.();
|
|
376
|
+
if (!controller || controller.signal.aborted || !queue) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
queue.setMode('steer');
|
|
380
|
+
queue.enqueue({ content: prompt, source: 'cowork', timestamp: new Date() });
|
|
381
|
+
logger.info('[CodeBuddyEngineAdapter] steer delivered', { sessionId });
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
281
384
|
clearSession(sessionId) {
|
|
282
385
|
const agent = this.agents.get(sessionId);
|
|
283
386
|
if (agent && typeof agent.dispose === 'function') {
|
|
@@ -352,6 +455,51 @@ export class CodeBuddyEngineAdapter {
|
|
|
352
455
|
logger.warn('[CodeBuddyEngineAdapter] reloadSkills failed', { err });
|
|
353
456
|
}
|
|
354
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Hot-swap the reasoning/thinking level for live sessions. Updates the global
|
|
460
|
+
* extended-thinking budget (read per-turn by the OpenAI-compat / Grok / Ollama
|
|
461
|
+
* providers → effective next turn, no rebuild) and the Gemini-native default on
|
|
462
|
+
* every cached agent. The level is remembered so future agents inherit it.
|
|
463
|
+
*/
|
|
464
|
+
async setThinkingLevel(level) {
|
|
465
|
+
this.thinkingLevel = level;
|
|
466
|
+
try {
|
|
467
|
+
const { getExtendedThinking } = await import('../agent/extended-thinking.js');
|
|
468
|
+
getExtendedThinking().applyThinkingLevel(level);
|
|
469
|
+
}
|
|
470
|
+
catch (err) {
|
|
471
|
+
logger.warn('[CodeBuddyEngineAdapter] applyThinkingLevel failed', { err });
|
|
472
|
+
}
|
|
473
|
+
for (const agent of this.agents.values()) {
|
|
474
|
+
this.applyGeminiThinkingLevel(agent, level);
|
|
475
|
+
}
|
|
476
|
+
logger.info('[CodeBuddyEngineAdapter] thinkingLevel set', { level });
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Map a UI level to the Gemini-native default thinking level on a single
|
|
480
|
+
* agent's client. `GeminiThinkingLevel` is `minimal|low|medium|high`, so
|
|
481
|
+
* `xhigh` clamps to `high` and `off`/unknown leaves the Gemini default
|
|
482
|
+
* untouched (the global extended-thinking switch already disables it for the
|
|
483
|
+
* OpenAI-compat path). Best-effort; never throws.
|
|
484
|
+
*/
|
|
485
|
+
applyGeminiThinkingLevel(agent, level) {
|
|
486
|
+
const geminiLevel = level === 'minimal' || level === 'low' || level === 'medium'
|
|
487
|
+
? level
|
|
488
|
+
: level === 'high' || level === 'xhigh'
|
|
489
|
+
? 'high'
|
|
490
|
+
: null;
|
|
491
|
+
if (!geminiLevel)
|
|
492
|
+
return;
|
|
493
|
+
try {
|
|
494
|
+
const getClient = agent.getClient;
|
|
495
|
+
if (typeof getClient === 'function') {
|
|
496
|
+
getClient.call(agent)?.setDefaultThinkingLevel(geminiLevel);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
/* best effort — Gemini path only */
|
|
501
|
+
}
|
|
502
|
+
}
|
|
355
503
|
/**
|
|
356
504
|
* Synchronise the core MCPManager singleton with the host's view of
|
|
357
505
|
* the MCP servers. Called by Cowork at boot and after any
|
|
@@ -481,4 +629,33 @@ export class CodeBuddyEngineAdapter {
|
|
|
481
629
|
});
|
|
482
630
|
}
|
|
483
631
|
}
|
|
632
|
+
function buildCoworkGoalSessionKey(sessionId) {
|
|
633
|
+
return `${COWORK_GOAL_SESSION_PREFIX}${sessionId}`;
|
|
634
|
+
}
|
|
635
|
+
/** Cap a single failure detail so the footer stays compact for the judge. */
|
|
636
|
+
export function truncateFailureDetail(detail, max = 160) {
|
|
637
|
+
const flat = detail.replace(/\s+/g, ' ').trim();
|
|
638
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Build a prominent, NON-bracketed footer listing failed tool actions. The goal
|
|
642
|
+
* judge prompt (goal-state.ts) treats `[tool:…]` bracketed lines as ignorable
|
|
643
|
+
* metadata, so failures must be surfaced as a plain instruction line or the
|
|
644
|
+
* judge discounts them. Returns '' when there are no failures.
|
|
645
|
+
*/
|
|
646
|
+
export function buildToolFailureFooter(failures) {
|
|
647
|
+
if (!failures.length)
|
|
648
|
+
return '';
|
|
649
|
+
return (`⚠️ ${failures.length} tool action(s) failed this turn: ${failures.join('; ')}. ` +
|
|
650
|
+
`Do NOT treat the goal as done if these failures block it — fix or work around them first.`);
|
|
651
|
+
}
|
|
652
|
+
export function buildGoalJudgeResponse(content, toolEvidence, toolFailures = []) {
|
|
653
|
+
const footer = buildToolFailureFooter(toolFailures);
|
|
654
|
+
const parts = [
|
|
655
|
+
content.trim(),
|
|
656
|
+
...toolEvidence.map((part) => part.trim()),
|
|
657
|
+
footer, // last → most prominent for the LLM judge
|
|
658
|
+
].filter(Boolean);
|
|
659
|
+
return parts.join('\n\n');
|
|
660
|
+
}
|
|
484
661
|
//# sourceMappingURL=codebuddy-engine-adapter.js.map
|
|
@@ -40,6 +40,11 @@ export interface EngineAdapter {
|
|
|
40
40
|
* Cancel a running session.
|
|
41
41
|
*/
|
|
42
42
|
cancel(sessionId: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Deliver user guidance into an active run when the underlying agent
|
|
45
|
+
* supports steer mode. Returns false when there is no active run/agent.
|
|
46
|
+
*/
|
|
47
|
+
steer?(sessionId: string, prompt: string): boolean | Promise<boolean>;
|
|
43
48
|
/**
|
|
44
49
|
* Clear internal state for a session (free memory, close resources).
|
|
45
50
|
*/
|
|
@@ -80,6 +85,15 @@ export interface EngineAdapter {
|
|
|
80
85
|
* Optional — adapters without a skills system can omit this.
|
|
81
86
|
*/
|
|
82
87
|
reloadSkills?(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Hot-swap the reasoning/thinking level for live sessions —
|
|
90
|
+
* `off | minimal | low | medium | high | xhigh`. Updates the global
|
|
91
|
+
* extended-thinking budget (read per-turn by the OpenAI-compat / Grok /
|
|
92
|
+
* Ollama providers) and the Gemini-native default on cached agents, so the
|
|
93
|
+
* Cowork ReasoningLevelPicker takes effect on the next turn without a session
|
|
94
|
+
* restart. Optional — adapters without a thinking system can omit this.
|
|
95
|
+
*/
|
|
96
|
+
setThinkingLevel?(level: string): Promise<void>;
|
|
83
97
|
/**
|
|
84
98
|
* Set the default visual grounding fallback configuration.
|
|
85
99
|
*/
|
|
@@ -320,6 +320,13 @@ export class DesktopAutomationManager extends EventEmitter {
|
|
|
320
320
|
const nativeProvider = await this.createNativeProvider();
|
|
321
321
|
if (nativeProvider) {
|
|
322
322
|
this.registerProvider(nativeProvider);
|
|
323
|
+
// The created provider registers under its own name (e.g. 'nutjs' on
|
|
324
|
+
// Linux when xdotool/xclip are unavailable). Also expose it under the
|
|
325
|
+
// requested 'native' key so the preferred-provider lookup resolves it
|
|
326
|
+
// instead of silently falling through to the mock provider.
|
|
327
|
+
if (!this.providers.has('native')) {
|
|
328
|
+
this.providers.set('native', nativeProvider);
|
|
329
|
+
}
|
|
323
330
|
}
|
|
324
331
|
}
|
|
325
332
|
// Try preferred provider first
|
|
@@ -689,6 +696,15 @@ export class DesktopAutomationManager extends EventEmitter {
|
|
|
689
696
|
return new WindowsNativeProvider({ wsl: false });
|
|
690
697
|
}
|
|
691
698
|
case 'linux': {
|
|
699
|
+
// Prefer nut-js (libnut): it provides mouse/keyboard/screen control
|
|
700
|
+
// without xdotool/xclip/wmctrl, which are frequently absent on minimal
|
|
701
|
+
// or remote Linux desktops. Fall back to the xdotool-based provider
|
|
702
|
+
// (which also does window management) only when libnut is unavailable.
|
|
703
|
+
const { NutJsProvider } = await import('./nutjs-provider.js');
|
|
704
|
+
const nut = new NutJsProvider();
|
|
705
|
+
if (await nut.isAvailable()) {
|
|
706
|
+
return nut;
|
|
707
|
+
}
|
|
692
708
|
const { LinuxNativeProvider } = await import('./linux-native-provider.js');
|
|
693
709
|
return new LinuxNativeProvider();
|
|
694
710
|
}
|