@machina.ai/cell-cli-core 1.22.5-rc1 → 1.25.0-rc2
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/dist/docs/AFTER_MERGE_PROMPT.md +26 -0
- package/dist/docs/CHANGES.md +124 -0
- package/dist/docs/api-proxy.md +27 -0
- package/dist/docs/architecture.md +80 -0
- package/dist/docs/assets/connected_devtools.png +0 -0
- package/dist/docs/assets/gemini-screenshot.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-logs.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-metrics.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-overview.png +0 -0
- package/dist/docs/assets/release_patch.png +0 -0
- package/dist/docs/assets/theme-ansi-light.png +0 -0
- package/dist/docs/assets/theme-ansi.png +0 -0
- package/dist/docs/assets/theme-atom-one.png +0 -0
- package/dist/docs/assets/theme-ayu-light.png +0 -0
- package/dist/docs/assets/theme-ayu.png +0 -0
- package/dist/docs/assets/theme-custom.png +0 -0
- package/dist/docs/assets/theme-default-light.png +0 -0
- package/dist/docs/assets/theme-default.png +0 -0
- package/dist/docs/assets/theme-dracula.png +0 -0
- package/dist/docs/assets/theme-github-light.png +0 -0
- package/dist/docs/assets/theme-github.png +0 -0
- package/dist/docs/assets/theme-google-light.png +0 -0
- package/dist/docs/assets/theme-xcode-light.png +0 -0
- package/dist/docs/changelogs/index.md +612 -0
- package/dist/docs/changelogs/latest.md +153 -0
- package/dist/docs/changelogs/preview.md +131 -0
- package/dist/docs/changelogs/releases.md +1162 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +357 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +564 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +109 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +388 -0
- package/dist/docs/cli/index.md +63 -0
- package/dist/docs/cli/keyboard-shortcuts.md +136 -0
- package/dist/docs/cli/model-routing.md +37 -0
- package/dist/docs/cli/model.md +62 -0
- package/dist/docs/cli/sandbox.md +171 -0
- package/dist/docs/cli/session-management.md +158 -0
- package/dist/docs/cli/settings.md +148 -0
- package/dist/docs/cli/skills.md +188 -0
- package/dist/docs/cli/system-prompt.md +94 -0
- package/dist/docs/cli/telemetry.md +813 -0
- package/dist/docs/cli/themes.md +237 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +124 -0
- package/dist/docs/cli/tutorials.md +87 -0
- package/dist/docs/cli/uninstall.md +47 -0
- package/dist/docs/core/index.md +101 -0
- package/dist/docs/core/memport.md +246 -0
- package/dist/docs/core/policy-engine.md +268 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +244 -0
- package/dist/docs/extensions/index.md +343 -0
- package/dist/docs/faq.md +153 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +890 -0
- package/dist/docs/get-started/configuration.md +1643 -0
- package/dist/docs/get-started/examples.md +218 -0
- package/dist/docs/get-started/gemini-3.md +101 -0
- package/dist/docs/get-started/index.md +71 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/hooks/best-practices.md +856 -0
- package/dist/docs/hooks/index.md +723 -0
- package/dist/docs/hooks/reference.md +178 -0
- package/dist/docs/hooks/writing-hooks.md +1044 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +201 -0
- package/dist/docs/index.md +147 -0
- package/dist/docs/integration-tests.md +211 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +128 -0
- package/dist/docs/mcp_integration.md +160 -0
- package/dist/docs/mermaid/context.mmd +103 -0
- package/dist/docs/mermaid/render-path.mmd +64 -0
- package/dist/docs/npm.md +62 -0
- package/dist/docs/quota-and-pricing.md +158 -0
- package/dist/docs/release-confidence.md +164 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/sidebar.json +301 -0
- package/dist/docs/tools/file-system.md +217 -0
- package/dist/docs/tools/index.md +95 -0
- package/dist/docs/tools/mcp-server.md +1045 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +56 -0
- package/dist/docs/tools/web-fetch.md +59 -0
- package/dist/docs/tools/web-search.md +42 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +162 -0
- package/dist/package.json +7 -4
- package/dist/src/agents/a2a-client-manager.d.ts +82 -0
- package/dist/src/agents/a2a-client-manager.js +295 -0
- package/dist/src/agents/a2a-client-manager.js.map +1 -0
- package/dist/src/agents/a2a-client-manager.test.js +281 -0
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -0
- package/dist/src/agents/a2aUtils.d.ts +29 -0
- package/dist/src/agents/a2aUtils.js +113 -0
- package/dist/src/agents/a2aUtils.js.map +1 -0
- package/dist/src/agents/a2aUtils.test.js +147 -0
- package/dist/src/agents/a2aUtils.test.js.map +1 -0
- package/dist/src/agents/agentLoader.d.ts +68 -0
- package/dist/src/agents/agentLoader.js +255 -0
- package/dist/src/agents/agentLoader.js.map +1 -0
- package/dist/src/agents/agentLoader.test.js +307 -0
- package/dist/src/agents/agentLoader.test.js.map +1 -0
- package/dist/src/agents/cli-help-agent.d.ts +24 -0
- package/dist/src/agents/cli-help-agent.js +85 -0
- package/dist/src/agents/cli-help-agent.js.map +1 -0
- package/dist/src/agents/cli-help-agent.test.js +65 -0
- package/dist/src/agents/cli-help-agent.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -2
- package/dist/src/agents/codebase-investigator.js +14 -8
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/delegate-to-agent-tool.d.ts +2 -2
- package/dist/src/agents/delegate-to-agent-tool.js +25 -14
- package/dist/src/agents/delegate-to-agent-tool.js.map +1 -1
- package/dist/src/agents/delegate-to-agent-tool.test.js +101 -21
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -1
- package/dist/src/agents/{executor.d.ts → local-executor.d.ts} +5 -11
- package/dist/src/agents/{executor.js → local-executor.js} +123 -62
- package/dist/src/agents/local-executor.js.map +1 -0
- package/dist/src/agents/local-executor.test.d.ts +6 -0
- package/dist/src/agents/{executor.test.js → local-executor.test.js} +136 -58
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/{invocation.d.ts → local-invocation.d.ts} +6 -7
- package/dist/src/agents/{invocation.js → local-invocation.js} +9 -10
- package/dist/src/agents/local-invocation.js.map +1 -0
- package/dist/src/agents/local-invocation.test.d.ts +6 -0
- package/dist/src/agents/{invocation.test.js → local-invocation.test.js} +29 -20
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +22 -1
- package/dist/src/agents/registry.js +192 -35
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +407 -33
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/remote-invocation.d.ts +35 -0
- package/dist/src/agents/remote-invocation.js +126 -0
- package/dist/src/agents/remote-invocation.js.map +1 -0
- package/dist/src/agents/remote-invocation.test.d.ts +6 -0
- package/dist/src/agents/remote-invocation.test.js +201 -0
- package/dist/src/agents/remote-invocation.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +2 -2
- package/dist/src/agents/subagent-tool-wrapper.js +11 -6
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +33 -19
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/types.d.ts +21 -15
- package/dist/src/agents/types.js.map +1 -1
- package/dist/src/availability/fallbackIntegration.test.d.ts +6 -0
- package/dist/src/availability/fallbackIntegration.test.js +58 -0
- package/dist/src/availability/fallbackIntegration.test.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +2 -1
- package/dist/src/availability/policyHelpers.d.ts +4 -3
- package/dist/src/availability/policyHelpers.js +13 -22
- package/dist/src/availability/policyHelpers.js.map +1 -1
- package/dist/src/availability/policyHelpers.test.js +28 -18
- package/dist/src/availability/policyHelpers.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.d.ts +1 -1
- package/dist/src/code_assist/experiments/experiments.js +21 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments_local.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js +110 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +3 -4
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +32 -2
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +111 -16
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +9 -1
- package/dist/src/code_assist/server.js +74 -11
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +199 -27
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +6 -4
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +63 -0
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/telemetry.d.ts +14 -0
- package/dist/src/code_assist/telemetry.js +157 -0
- package/dist/src/code_assist/telemetry.js.map +1 -0
- package/dist/src/code_assist/telemetry.test.d.ts +6 -0
- package/dist/src/code_assist/telemetry.test.js +301 -0
- package/dist/src/code_assist/telemetry.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +77 -1
- package/dist/src/code_assist/types.js +28 -0
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/memory.d.ts +11 -0
- package/dist/src/commands/memory.js +80 -0
- package/dist/src/commands/memory.js.map +1 -0
- package/dist/src/commands/memory.test.d.ts +6 -0
- package/dist/src/commands/memory.test.js +155 -0
- package/dist/src/commands/memory.test.js.map +1 -0
- package/dist/src/config/config.d.ts +120 -26
- package/dist/src/config/config.js +241 -120
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +215 -43
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/flashFallback.test.js +11 -35
- package/dist/src/config/flashFallback.test.js.map +1 -1
- package/dist/src/config/models.d.ts +8 -9
- package/dist/src/config/models.js +18 -15
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +52 -16
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +5 -0
- package/dist/src/config/storage.js +17 -2
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +16 -0
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.js +2 -1
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/core/baseLlmClient.js +44 -43
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +12 -19
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +7 -1
- package/dist/src/core/client.js +245 -114
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +277 -74
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.js +2 -2
- package/dist/src/core/clientHookTriggers.js.map +1 -1
- package/dist/src/core/contentGenerator.js +3 -3
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +1 -7
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +9 -5
- package/dist/src/core/coreToolHookTriggers.js +119 -21
- package/dist/src/core/coreToolHookTriggers.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.test.d.ts +6 -0
- package/dist/src/core/coreToolHookTriggers.test.js +191 -0
- package/dist/src/core/coreToolHookTriggers.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +7 -93
- package/dist/src/core/coreToolScheduler.js +133 -369
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +252 -394
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +26 -1
- package/dist/src/core/geminiChat.js +112 -79
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +125 -92
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +8 -4
- package/dist/src/core/geminiChatHookTriggers.js +34 -12
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.test.d.ts +6 -0
- package/dist/src/core/geminiChatHookTriggers.test.js +153 -0
- package/dist/src/core/geminiChatHookTriggers.test.js.map +1 -0
- package/dist/src/core/geminiChat_network_retry.test.js +4 -6
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.js +19 -2
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.js +30 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +4 -4
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.js +37 -13
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +47 -3
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/tokenLimits.js +6 -12
- package/dist/src/core/tokenLimits.js.map +1 -1
- package/dist/src/core/tokenLimits.test.js +8 -4
- package/dist/src/core/tokenLimits.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +21 -22
- package/dist/src/core/turn.js +31 -21
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +79 -5
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +1 -7
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +10 -29
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/hooks/hookAggregator.js +7 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +9 -5
- package/dist/src/hooks/hookEventHandler.js +61 -15
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +223 -8
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- package/dist/src/hooks/hookPlanner.d.ts +1 -5
- package/dist/src/hooks/hookPlanner.js +2 -7
- package/dist/src/hooks/hookPlanner.js.map +1 -1
- package/dist/src/hooks/hookPlanner.test.js +62 -2
- package/dist/src/hooks/hookPlanner.test.js.map +1 -1
- package/dist/src/hooks/hookRegistry.d.ts +6 -11
- package/dist/src/hooks/hookRegistry.js +41 -14
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRegistry.test.js +166 -2
- package/dist/src/hooks/hookRegistry.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.d.ts +5 -3
- package/dist/src/hooks/hookRunner.js +57 -17
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +172 -35
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +12 -0
- package/dist/src/hooks/hookSystem.js +39 -1
- package/dist/src/hooks/hookSystem.js.map +1 -1
- package/dist/src/hooks/hookTranslator.js +2 -1
- package/dist/src/hooks/hookTranslator.js.map +1 -1
- package/dist/src/hooks/index.d.ts +1 -2
- package/dist/src/hooks/index.js +1 -3
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/trustedHooks.d.ts +28 -0
- package/dist/src/hooks/trustedHooks.js +90 -0
- package/dist/src/hooks/trustedHooks.js.map +1 -0
- package/dist/src/hooks/trustedHooks.test.d.ts +6 -0
- package/dist/src/hooks/trustedHooks.test.js +154 -0
- package/dist/src/hooks/trustedHooks.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +41 -9
- package/dist/src/hooks/types.js +31 -41
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +9 -52
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +4 -0
- package/dist/src/ide/detect-ide.js +7 -2
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +10 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +4 -1
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-installer.js +2 -2
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +11 -2
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/index.d.ts +16 -2
- package/dist/src/index.js +18 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +7 -3
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +4 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +8 -1
- package/dist/src/mcp/oauth-utils.js +31 -2
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +42 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.js +2 -2
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/policy/config.js +62 -23
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/policy/config.test.js +24 -2
- package/dist/src/policy/config.test.js.map +1 -1
- package/dist/src/policy/persistence.test.js +1 -1
- package/dist/src/policy/persistence.test.js.map +1 -1
- package/dist/src/policy/policies/agent.toml +1 -1
- package/dist/src/policy/policies/write.toml +5 -0
- package/dist/src/policy/policies/yolo.toml +1 -0
- package/dist/src/policy/policy-engine.d.ts +4 -0
- package/dist/src/policy/policy-engine.js +137 -53
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +289 -1
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/policy-updater.test.js +5 -5
- package/dist/src/policy/policy-updater.test.js.map +1 -1
- package/dist/src/policy/shell-safety.test.js +371 -8
- package/dist/src/policy/shell-safety.test.js.map +1 -1
- package/dist/src/policy/toml-loader.d.ts +0 -8
- package/dist/src/policy/toml-loader.js +13 -45
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +13 -0
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +10 -0
- package/dist/src/policy/utils.d.ts +21 -0
- package/dist/src/policy/utils.js +45 -0
- package/dist/src/policy/utils.js.map +1 -0
- package/dist/src/policy/utils.test.d.ts +6 -0
- package/dist/src/policy/utils.test.js +92 -0
- package/dist/src/policy/utils.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +2 -0
- package/dist/src/routing/strategies/classifierStrategy.js +1 -1
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +16 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +4 -2
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.test.js +11 -10
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +2 -5
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +13 -6
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +6 -6
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +14 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
- package/dist/src/scheduler/tool-executor.d.ts +22 -0
- package/dist/src/scheduler/tool-executor.js +198 -0
- package/dist/src/scheduler/tool-executor.js.map +1 -0
- package/dist/src/scheduler/tool-executor.test.d.ts +6 -0
- package/dist/src/scheduler/tool-executor.test.js +231 -0
- package/dist/src/scheduler/tool-executor.test.js.map +1 -0
- package/dist/src/scheduler/tool-modifier.d.ts +23 -0
- package/dist/src/scheduler/tool-modifier.js +50 -0
- package/dist/src/scheduler/tool-modifier.js.map +1 -0
- package/dist/src/scheduler/tool-modifier.test.d.ts +6 -0
- package/dist/src/scheduler/tool-modifier.test.js +159 -0
- package/dist/src/scheduler/tool-modifier.test.js.map +1 -0
- package/dist/src/scheduler/types.d.ts +95 -0
- package/dist/src/scheduler/types.js +7 -0
- package/dist/src/scheduler/types.js.map +1 -0
- package/dist/src/services/chatCompressionService.js +3 -10
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +1 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +7 -1
- package/dist/src/services/chatRecordingService.js +20 -2
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +43 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +5 -11
- package/dist/src/services/contextManager.js +20 -17
- package/dist/src/services/contextManager.js.map +1 -1
- package/dist/src/services/contextManager.test.js +40 -41
- package/dist/src/services/contextManager.test.js.map +1 -1
- package/dist/src/services/environmentSanitization.d.ts +15 -0
- package/dist/src/services/environmentSanitization.js +142 -0
- package/dist/src/services/environmentSanitization.js.map +1 -0
- package/dist/src/services/environmentSanitization.test.d.ts +6 -0
- package/dist/src/services/environmentSanitization.test.js +284 -0
- package/dist/src/services/environmentSanitization.test.js.map +1 -0
- package/dist/src/services/gitService.js +10 -1
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +28 -2
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +2 -1
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +14 -8
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.integration.test.js +3 -3
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +38 -4
- package/dist/src/services/modelConfigService.js +135 -76
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +116 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +2 -0
- package/dist/src/services/shellExecutionService.js +6 -50
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +68 -4
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/skills/skillLoader.d.ts +31 -0
- package/dist/src/skills/skillLoader.js +77 -0
- package/dist/src/skills/skillLoader.js.map +1 -0
- package/dist/src/skills/skillLoader.test.d.ts +6 -0
- package/dist/src/skills/skillLoader.test.js +75 -0
- package/dist/src/skills/skillLoader.test.js.map +1 -0
- package/dist/src/skills/skillManager.d.ts +69 -0
- package/dist/src/skills/skillManager.js +127 -0
- package/dist/src/skills/skillManager.js.map +1 -0
- package/dist/src/skills/skillManager.test.d.ts +6 -0
- package/dist/src/skills/skillManager.test.js +210 -0
- package/dist/src/skills/skillManager.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +18 -9
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +234 -160
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +162 -32
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +11 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +24 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +3 -3
- package/dist/src/telemetry/loggers.js +6 -5
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +1 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +51 -10
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +5 -6
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +7 -7
- package/dist/src/telemetry/types.js +14 -12
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/test-utils/mock-message-bus.d.ts +1 -0
- package/dist/src/test-utils/mock-message-bus.js +29 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +5 -3
- package/dist/src/test-utils/mock-tool.js +11 -10
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/activate-skill.d.ts +27 -0
- package/dist/src/tools/activate-skill.js +133 -0
- package/dist/src/tools/activate-skill.js.map +1 -0
- package/dist/src/tools/activate-skill.test.d.ts +6 -0
- package/dist/src/tools/activate-skill.test.js +113 -0
- package/dist/src/tools/activate-skill.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.js +3 -12
- package/dist/src/tools/confirmation-policy.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +27 -5
- package/dist/src/tools/edit.js +455 -136
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +292 -526
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/get-internal-docs.d.ts +27 -0
- package/dist/src/tools/get-internal-docs.js +122 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
- package/dist/src/tools/get-internal-docs.test.js +57 -0
- package/dist/src/tools/get-internal-docs.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +2 -2
- package/dist/src/tools/glob.js +1 -1
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +2 -1
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +2 -2
- package/dist/src/tools/grep.js +1 -1
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +5 -4
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +2 -2
- package/dist/src/tools/ls.js +2 -2
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +2 -1
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.js +14 -7
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +28 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +5 -4
- package/dist/src/tools/mcp-client.js +10 -8
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +47 -42
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +20 -5
- package/dist/src/tools/mcp-tool.js +8 -8
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +11 -6
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +3 -3
- package/dist/src/tools/memoryTool.js +2 -4
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +5 -2
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.js +10 -37
- package/dist/src/tools/message-bus-integration.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +2 -2
- package/dist/src/tools/read-file.js +1 -1
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +3 -2
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +2 -2
- package/dist/src/tools/read-many-files.js +2 -3
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +3 -2
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +3 -2
- package/dist/src/tools/ripGrep.js +18 -7
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +60 -4
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +3 -6
- package/dist/src/tools/shell.js +21 -49
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +35 -59
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +6 -1
- package/dist/src/tools/tool-error.js +6 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +15 -0
- package/dist/src/tools/tool-names.js +57 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-names.test.d.ts +6 -0
- package/dist/src/tools/tool-names.test.js +43 -0
- package/dist/src/tools/tool-names.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +11 -7
- package/dist/src/tools/tool-registry.js +15 -10
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +16 -11
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +8 -6
- package/dist/src/tools/tools.js +16 -18
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +3 -1
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +2 -2
- package/dist/src/tools/web-fetch.js +4 -4
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +17 -19
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +2 -2
- package/dist/src/tools/web-search.js +5 -5
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +2 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +2 -2
- package/dist/src/tools/write-file.js +9 -6
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +49 -7
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +2 -2
- package/dist/src/tools/write-todos.js +5 -4
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/write-todos.test.js +2 -1
- package/dist/src/tools/write-todos.test.js.map +1 -1
- package/dist/src/utils/apiConversionUtils.d.ts +12 -0
- package/dist/src/utils/apiConversionUtils.js +46 -0
- package/dist/src/utils/apiConversionUtils.js.map +1 -0
- package/dist/src/utils/apiConversionUtils.test.d.ts +6 -0
- package/dist/src/utils/apiConversionUtils.test.js +150 -0
- package/dist/src/utils/apiConversionUtils.test.js.map +1 -0
- package/dist/src/utils/checkpointUtils.d.ts +1 -1
- package/dist/src/utils/checkpointUtils.js +1 -1
- package/dist/src/utils/checkpointUtils.js.map +1 -1
- package/dist/src/utils/checkpointUtils.test.js +1 -1
- package/dist/src/utils/checkpointUtils.test.js.map +1 -1
- package/dist/src/utils/debugLogger.js +1 -0
- package/dist/src/utils/debugLogger.js.map +1 -1
- package/dist/src/utils/editCorrector.d.ts +3 -3
- package/dist/src/utils/editCorrector.js +27 -10
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +23 -23
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +3 -2
- package/dist/src/utils/editor.js +26 -6
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +27 -4
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +1 -0
- package/dist/src/utils/environmentContext.js +4 -0
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +2 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errorReporting.js +13 -12
- package/dist/src/utils/errorReporting.js.map +1 -1
- package/dist/src/utils/errorReporting.test.js +17 -14
- package/dist/src/utils/errorReporting.test.js.map +1 -1
- package/dist/src/utils/events.d.ts +71 -19
- package/dist/src/utils/events.js +35 -9
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/events.test.js +25 -0
- package/dist/src/utils/events.test.js.map +1 -1
- package/dist/src/utils/fileDiffUtils.d.ts +18 -0
- package/dist/src/utils/fileDiffUtils.js +37 -0
- package/dist/src/utils/fileDiffUtils.js.map +1 -0
- package/dist/src/utils/fileDiffUtils.test.d.ts +6 -0
- package/dist/src/utils/fileDiffUtils.test.js +84 -0
- package/dist/src/utils/fileDiffUtils.test.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +4 -0
- package/dist/src/utils/fileUtils.js +53 -0
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +112 -1
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.d.ts +11 -0
- package/dist/src/utils/geminiIgnoreParser.js +20 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.test.js +48 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.d.ts +3 -1
- package/dist/src/utils/generateContentResponseUtilities.js +106 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +279 -2
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.js +7 -2
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.js +9 -10
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/installationManager.test.js +11 -3
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.js +3 -4
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +12 -1
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/partUtils.js +1 -1
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/paths.d.ts +10 -0
- package/dist/src/utils/paths.js +20 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/retry.d.ts +1 -0
- package/dist/src/utils/retry.js +17 -5
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +11 -11
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +6 -0
- package/dist/src/utils/shell-utils.js +97 -12
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +99 -1
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +3 -2
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +4 -0
- package/dist/src/utils/terminal.js +12 -0
- package/dist/src/utils/terminal.js.map +1 -1
- package/dist/src/utils/tokenCalculation.js +20 -5
- package/dist/src/utils/tokenCalculation.js.map +1 -1
- package/dist/src/utils/tokenCalculation.test.js +11 -2
- package/dist/src/utils/tokenCalculation.test.js.map +1 -1
- package/dist/src/utils/tool-utils.d.ts +9 -0
- package/dist/src/utils/tool-utils.js +29 -0
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +17 -2
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +5 -5
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +1 -1
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/dist/src/agents/executor.js.map +0 -1
- package/dist/src/agents/executor.test.js.map +0 -1
- package/dist/src/agents/invocation.js.map +0 -1
- package/dist/src/agents/invocation.test.js.map +0 -1
- package/dist/src/core/sessionHookTriggers.d.ts +0 -28
- package/dist/src/core/sessionHookTriggers.js +0 -68
- package/dist/src/core/sessionHookTriggers.js.map +0 -1
- package/dist/src/tools/smart-edit.d.ts +0 -78
- package/dist/src/tools/smart-edit.js +0 -722
- package/dist/src/tools/smart-edit.js.map +0 -1
- package/dist/src/tools/smart-edit.test.js +0 -592
- package/dist/src/tools/smart-edit.test.js.map +0 -1
- package/dist/src/utils/shell-permissions.d.ts +0 -52
- package/dist/src/utils/shell-permissions.js +0 -188
- package/dist/src/utils/shell-permissions.js.map +0 -1
- package/dist/src/utils/shell-permissions.test.js +0 -347
- package/dist/src/utils/shell-permissions.test.js.map +0 -1
- /package/dist/src/agents/{executor.test.d.ts → a2a-client-manager.test.d.ts} +0 -0
- /package/dist/src/agents/{invocation.test.d.ts → a2aUtils.test.d.ts} +0 -0
- /package/dist/src/{tools/smart-edit.test.d.ts → agents/agentLoader.test.d.ts} +0 -0
- /package/dist/src/{utils/shell-permissions.test.d.ts → agents/cli-help-agent.test.d.ts} +0 -0
|
@@ -3,115 +3,19 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { ToolConfirmationOutcome,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import { doesToolInvocationMatch } from '../utils/tool-utils.js';
|
|
15
|
-
import { isShellInvocationAllowlisted } from '../utils/shell-permissions.js';
|
|
16
|
-
import levenshtein from 'fast-levenshtein';
|
|
17
|
-
import { ShellToolInvocation } from '../tools/shell.js';
|
|
6
|
+
import { ToolConfirmationOutcome, } from '../tools/tools.js';
|
|
7
|
+
import { PolicyDecision } from '../policy/types.js';
|
|
8
|
+
import { logToolCall } from '../telemetry/loggers.js';
|
|
9
|
+
import { ToolErrorType } from '../tools/tool-error.js';
|
|
10
|
+
import { ToolCallEvent } from '../telemetry/types.js';
|
|
11
|
+
import { runInDevTraceSpan } from '../telemetry/trace.js';
|
|
12
|
+
import { ToolModificationHandler } from '../scheduler/tool-modifier.js';
|
|
13
|
+
import { getToolSuggestion } from '../utils/tool-utils.js';
|
|
18
14
|
import { MessageBusType } from '../confirmation-bus/types.js';
|
|
19
|
-
import { fireToolNotificationHook
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
function createFunctionResponsePart(callId, toolName, output) {
|
|
25
|
-
return {
|
|
26
|
-
functionResponse: {
|
|
27
|
-
id: callId,
|
|
28
|
-
name: toolName,
|
|
29
|
-
response: { output },
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function convertToFunctionResponse(toolName, callId, llmContent, model) {
|
|
34
|
-
if (typeof llmContent === 'string') {
|
|
35
|
-
return [createFunctionResponsePart(callId, toolName, llmContent)];
|
|
36
|
-
}
|
|
37
|
-
const parts = toParts(llmContent);
|
|
38
|
-
// Separate text from binary types
|
|
39
|
-
const textParts = [];
|
|
40
|
-
const inlineDataParts = [];
|
|
41
|
-
const fileDataParts = [];
|
|
42
|
-
for (const part of parts) {
|
|
43
|
-
if (part.text !== undefined) {
|
|
44
|
-
textParts.push(part.text);
|
|
45
|
-
}
|
|
46
|
-
else if (part.inlineData) {
|
|
47
|
-
inlineDataParts.push(part);
|
|
48
|
-
}
|
|
49
|
-
else if (part.fileData) {
|
|
50
|
-
fileDataParts.push(part);
|
|
51
|
-
}
|
|
52
|
-
else if (part.functionResponse) {
|
|
53
|
-
if (parts.length > 1) {
|
|
54
|
-
debugLogger.warn('convertToFunctionResponse received multiple parts with a functionResponse. Only the functionResponse will be used, other parts will be ignored');
|
|
55
|
-
}
|
|
56
|
-
// Handle passthrough case
|
|
57
|
-
return [
|
|
58
|
-
{
|
|
59
|
-
functionResponse: {
|
|
60
|
-
id: callId,
|
|
61
|
-
name: toolName,
|
|
62
|
-
response: part.functionResponse.response,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
// Ignore other part types
|
|
68
|
-
}
|
|
69
|
-
// Build the primary response part
|
|
70
|
-
const part = {
|
|
71
|
-
functionResponse: {
|
|
72
|
-
id: callId,
|
|
73
|
-
name: toolName,
|
|
74
|
-
response: textParts.length > 0 ? { output: textParts.join('\n') } : {},
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
const isMultimodalFRSupported = supportsMultimodalFunctionResponse(model);
|
|
78
|
-
const siblingParts = [...fileDataParts];
|
|
79
|
-
if (inlineDataParts.length > 0) {
|
|
80
|
-
if (isMultimodalFRSupported) {
|
|
81
|
-
// Nest inlineData if supported by the model
|
|
82
|
-
part.functionResponse.parts =
|
|
83
|
-
inlineDataParts;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// Otherwise treat as siblings
|
|
87
|
-
siblingParts.push(...inlineDataParts);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Add descriptive text if the response object is empty but we have binary content
|
|
91
|
-
if (textParts.length === 0 &&
|
|
92
|
-
(inlineDataParts.length > 0 || fileDataParts.length > 0)) {
|
|
93
|
-
const totalBinaryItems = inlineDataParts.length + fileDataParts.length;
|
|
94
|
-
part.functionResponse.response = {
|
|
95
|
-
output: `Binary content provided (${totalBinaryItems} item(s)).`,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
if (siblingParts.length > 0) {
|
|
99
|
-
return [part, ...siblingParts];
|
|
100
|
-
}
|
|
101
|
-
return [part];
|
|
102
|
-
}
|
|
103
|
-
function toParts(input) {
|
|
104
|
-
const parts = [];
|
|
105
|
-
for (const part of Array.isArray(input) ? input : [input]) {
|
|
106
|
-
if (typeof part === 'string') {
|
|
107
|
-
parts.push({ text: part });
|
|
108
|
-
}
|
|
109
|
-
else if (part) {
|
|
110
|
-
parts.push(part);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return parts;
|
|
114
|
-
}
|
|
15
|
+
import { fireToolNotificationHook } from './coreToolHookTriggers.js';
|
|
16
|
+
import {} from '../scheduler/types.js';
|
|
17
|
+
import { ToolExecutor } from '../scheduler/tool-executor.js';
|
|
18
|
+
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
|
|
115
19
|
const createErrorResponse = (request, error, errorType) => ({
|
|
116
20
|
callId: request.callId,
|
|
117
21
|
error,
|
|
@@ -128,58 +32,6 @@ const createErrorResponse = (request, error, errorType) => ({
|
|
|
128
32
|
errorType,
|
|
129
33
|
contentLength: error.message.length,
|
|
130
34
|
});
|
|
131
|
-
export async function truncateAndSaveToFile(content, callId, projectTempDir, threshold, truncateLines) {
|
|
132
|
-
if (content.length <= threshold) {
|
|
133
|
-
return { content };
|
|
134
|
-
}
|
|
135
|
-
let lines = content.split('\n');
|
|
136
|
-
let fileContent = content;
|
|
137
|
-
// If the content is long but has few lines, wrap it to enable line-based truncation.
|
|
138
|
-
if (lines.length <= truncateLines) {
|
|
139
|
-
const wrapWidth = 120; // A reasonable width for wrapping.
|
|
140
|
-
const wrappedLines = [];
|
|
141
|
-
for (const line of lines) {
|
|
142
|
-
if (line.length > wrapWidth) {
|
|
143
|
-
for (let i = 0; i < line.length; i += wrapWidth) {
|
|
144
|
-
wrappedLines.push(line.substring(i, i + wrapWidth));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
wrappedLines.push(line);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
lines = wrappedLines;
|
|
152
|
-
fileContent = lines.join('\n');
|
|
153
|
-
}
|
|
154
|
-
const head = Math.floor(truncateLines / 5);
|
|
155
|
-
const beginning = lines.slice(0, head);
|
|
156
|
-
const end = lines.slice(-(truncateLines - head));
|
|
157
|
-
const truncatedContent = beginning.join('\n') + '\n... [CONTENT TRUNCATED] ...\n' + end.join('\n');
|
|
158
|
-
// Sanitize callId to prevent path traversal.
|
|
159
|
-
const safeFileName = `${path.basename(callId)}.output`;
|
|
160
|
-
const outputFile = path.join(projectTempDir, safeFileName);
|
|
161
|
-
try {
|
|
162
|
-
await fs.writeFile(outputFile, fileContent);
|
|
163
|
-
return {
|
|
164
|
-
content: `Tool output was too large and has been truncated.
|
|
165
|
-
The full output has been saved to: ${outputFile}
|
|
166
|
-
To read the complete output, use the ${READ_FILE_TOOL_NAME} tool with the absolute file path above. For large files, you can use the offset and limit parameters to read specific sections:
|
|
167
|
-
- ${READ_FILE_TOOL_NAME} tool with offset=0, limit=100 to see the first 100 lines
|
|
168
|
-
- ${READ_FILE_TOOL_NAME} tool with offset=N to skip N lines from the beginning
|
|
169
|
-
- ${READ_FILE_TOOL_NAME} tool with limit=M to read only M lines at a time
|
|
170
|
-
The truncated output below shows the beginning and end of the content. The marker '... [CONTENT TRUNCATED] ...' indicates where content was removed.
|
|
171
|
-
This allows you to efficiently examine different parts of the output without loading the entire file.
|
|
172
|
-
Truncated part of the output:
|
|
173
|
-
${truncatedContent}`,
|
|
174
|
-
outputFile,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
catch (_error) {
|
|
178
|
-
return {
|
|
179
|
-
content: truncatedContent + `\n[Note: Could not save full output to file]`,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
35
|
export class CoreToolScheduler {
|
|
184
36
|
// Static WeakMap to track which MessageBus instances already have a handler subscribed
|
|
185
37
|
// This prevents duplicate subscriptions when multiple CoreToolScheduler instances are created
|
|
@@ -196,36 +48,38 @@ export class CoreToolScheduler {
|
|
|
196
48
|
requestQueue = [];
|
|
197
49
|
toolCallQueue = [];
|
|
198
50
|
completedToolCallsForBatch = [];
|
|
51
|
+
toolExecutor;
|
|
52
|
+
toolModifier;
|
|
199
53
|
constructor(options) {
|
|
200
54
|
this.config = options.config;
|
|
201
55
|
this.outputUpdateHandler = options.outputUpdateHandler;
|
|
202
56
|
this.onAllToolCallsComplete = options.onAllToolCallsComplete;
|
|
203
57
|
this.onToolCallsUpdate = options.onToolCallsUpdate;
|
|
204
58
|
this.getPreferredEditor = options.getPreferredEditor;
|
|
59
|
+
this.toolExecutor = new ToolExecutor(this.config);
|
|
60
|
+
this.toolModifier = new ToolModificationHandler();
|
|
205
61
|
// Subscribe to message bus for ASK_USER policy decisions
|
|
206
62
|
// Use a static WeakMap to ensure we only subscribe ONCE per MessageBus instance
|
|
207
63
|
// This prevents memory leaks when multiple CoreToolScheduler instances are created
|
|
208
64
|
// (e.g., on every React render, or for each non-interactive tool call)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
CoreToolScheduler.subscribedMessageBuses.set(messageBus, sharedHandler);
|
|
228
|
-
}
|
|
65
|
+
const messageBus = this.config.getMessageBus();
|
|
66
|
+
// Check if we've already subscribed a handler to this message bus
|
|
67
|
+
if (!CoreToolScheduler.subscribedMessageBuses.has(messageBus)) {
|
|
68
|
+
// Create a shared handler that will be used for this message bus
|
|
69
|
+
const sharedHandler = (request) => {
|
|
70
|
+
// When ASK_USER policy decision is made, respond with requiresUserConfirmation=true
|
|
71
|
+
// to tell tools to use their legacy confirmation flow
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
73
|
+
messageBus.publish({
|
|
74
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
75
|
+
correlationId: request.correlationId,
|
|
76
|
+
confirmed: false,
|
|
77
|
+
requiresUserConfirmation: true,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
messageBus.subscribe(MessageBusType.TOOL_CONFIRMATION_REQUEST, sharedHandler);
|
|
81
|
+
// Store the handler in the WeakMap so we don't subscribe again
|
|
82
|
+
CoreToolScheduler.subscribedMessageBuses.set(messageBus, sharedHandler);
|
|
229
83
|
}
|
|
230
84
|
}
|
|
231
85
|
setStatusInternal(targetCallId, newStatus, signal, auxiliaryData) {
|
|
@@ -302,6 +156,7 @@ export class CoreToolScheduler {
|
|
|
302
156
|
fileName: waitingCall.confirmationDetails.fileName,
|
|
303
157
|
originalContent: waitingCall.confirmationDetails.originalContent,
|
|
304
158
|
newContent: waitingCall.confirmationDetails.newContent,
|
|
159
|
+
filePath: waitingCall.confirmationDetails.filePath,
|
|
305
160
|
};
|
|
306
161
|
}
|
|
307
162
|
}
|
|
@@ -398,34 +253,6 @@ export class CoreToolScheduler {
|
|
|
398
253
|
return new Error(String(e));
|
|
399
254
|
}
|
|
400
255
|
}
|
|
401
|
-
/**
|
|
402
|
-
* Generates a suggestion string for a tool name that was not found in the registry.
|
|
403
|
-
* It finds the closest matches based on Levenshtein distance.
|
|
404
|
-
* @param unknownToolName The tool name that was not found.
|
|
405
|
-
* @param topN The number of suggestions to return. Defaults to 3.
|
|
406
|
-
* @returns A suggestion string like " Did you mean 'tool'?" or " Did you mean one of: 'tool1', 'tool2'?", or an empty string if no suggestions are found.
|
|
407
|
-
*/
|
|
408
|
-
getToolSuggestion(unknownToolName, topN = 3) {
|
|
409
|
-
const allToolNames = this.config.getToolRegistry().getAllToolNames();
|
|
410
|
-
const matches = allToolNames.map((toolName) => ({
|
|
411
|
-
name: toolName,
|
|
412
|
-
distance: levenshtein.get(unknownToolName, toolName),
|
|
413
|
-
}));
|
|
414
|
-
matches.sort((a, b) => a.distance - b.distance);
|
|
415
|
-
const topNResults = matches.slice(0, topN);
|
|
416
|
-
if (topNResults.length === 0) {
|
|
417
|
-
return '';
|
|
418
|
-
}
|
|
419
|
-
const suggestedNames = topNResults
|
|
420
|
-
.map((match) => `"${match.name}"`)
|
|
421
|
-
.join(', ');
|
|
422
|
-
if (topNResults.length > 1) {
|
|
423
|
-
return ` Did you mean one of: ${suggestedNames}?`;
|
|
424
|
-
}
|
|
425
|
-
else {
|
|
426
|
-
return ` Did you mean ${suggestedNames}?`;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
256
|
schedule(request, signal) {
|
|
430
257
|
return runInDevTraceSpan({ name: 'schedule' }, async ({ metadata: spanMetadata }) => {
|
|
431
258
|
spanMetadata.input = request;
|
|
@@ -492,7 +319,7 @@ export class CoreToolScheduler {
|
|
|
492
319
|
.getToolRegistry()
|
|
493
320
|
.getTool(reqInfo.name);
|
|
494
321
|
if (!toolInstance) {
|
|
495
|
-
const suggestion =
|
|
322
|
+
const suggestion = getToolSuggestion(reqInfo.name, this.config.getToolRegistry().getAllToolNames());
|
|
496
323
|
const errorMessage = `Tool "${reqInfo.name}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
|
|
497
324
|
return {
|
|
498
325
|
status: 'error',
|
|
@@ -559,13 +386,33 @@ export class CoreToolScheduler {
|
|
|
559
386
|
await this.checkAndNotifyCompletion(signal);
|
|
560
387
|
return;
|
|
561
388
|
}
|
|
562
|
-
|
|
563
|
-
|
|
389
|
+
// Policy Check using PolicyEngine
|
|
390
|
+
// We must reconstruct the FunctionCall format expected by PolicyEngine
|
|
391
|
+
const toolCallForPolicy = {
|
|
392
|
+
name: toolCall.request.name,
|
|
393
|
+
args: toolCall.request.args,
|
|
394
|
+
};
|
|
395
|
+
const serverName = toolCall.tool instanceof DiscoveredMCPTool
|
|
396
|
+
? toolCall.tool.serverName
|
|
397
|
+
: undefined;
|
|
398
|
+
const { decision } = await this.config
|
|
399
|
+
.getPolicyEngine()
|
|
400
|
+
.check(toolCallForPolicy, serverName);
|
|
401
|
+
if (decision === PolicyDecision.DENY) {
|
|
402
|
+
const errorMessage = `Tool execution denied by policy.`;
|
|
403
|
+
this.setStatusInternal(reqInfo.callId, 'error', signal, createErrorResponse(reqInfo, new Error(errorMessage), ToolErrorType.POLICY_VIOLATION));
|
|
404
|
+
await this.checkAndNotifyCompletion(signal);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (decision === PolicyDecision.ALLOW) {
|
|
564
408
|
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
565
409
|
this.setStatusInternal(reqInfo.callId, 'scheduled', signal);
|
|
566
410
|
}
|
|
567
411
|
else {
|
|
568
|
-
|
|
412
|
+
// PolicyDecision.ASK_USER
|
|
413
|
+
// We need confirmation details to show to the user
|
|
414
|
+
const confirmationDetails = await invocation.shouldConfirmExecute(signal);
|
|
415
|
+
if (!confirmationDetails) {
|
|
569
416
|
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
570
417
|
this.setStatusInternal(reqInfo.callId, 'scheduled', signal);
|
|
571
418
|
}
|
|
@@ -629,61 +476,50 @@ export class CoreToolScheduler {
|
|
|
629
476
|
}
|
|
630
477
|
else if (outcome === ToolConfirmationOutcome.ModifyWithEditor) {
|
|
631
478
|
const waitingToolCall = toolCall;
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
479
|
+
const editorType = this.getPreferredEditor();
|
|
480
|
+
if (!editorType) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
this.setStatusInternal(callId, 'awaiting_approval', signal, {
|
|
484
|
+
...waitingToolCall.confirmationDetails,
|
|
485
|
+
isModifying: true,
|
|
486
|
+
});
|
|
487
|
+
const result = await this.toolModifier.handleModifyWithEditor(waitingToolCall, editorType, signal);
|
|
488
|
+
// Restore status (isModifying: false) and update diff if result exists
|
|
489
|
+
if (result) {
|
|
490
|
+
this.setArgsInternal(callId, result.updatedParams);
|
|
638
491
|
this.setStatusInternal(callId, 'awaiting_approval', signal, {
|
|
639
492
|
...waitingToolCall.confirmationDetails,
|
|
640
|
-
|
|
493
|
+
fileDiff: result.updatedDiff,
|
|
494
|
+
isModifying: false,
|
|
641
495
|
});
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
currentContent: waitingToolCall.confirmationDetails.originalContent,
|
|
645
|
-
proposedContent: waitingToolCall.confirmationDetails.newContent,
|
|
646
|
-
}
|
|
647
|
-
: undefined;
|
|
648
|
-
const { updatedParams, updatedDiff } = await modifyWithEditor(waitingToolCall.request.args, modifyContext, editorType, signal, contentOverrides);
|
|
649
|
-
this.setArgsInternal(callId, updatedParams);
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
650
498
|
this.setStatusInternal(callId, 'awaiting_approval', signal, {
|
|
651
499
|
...waitingToolCall.confirmationDetails,
|
|
652
|
-
fileDiff: updatedDiff,
|
|
653
500
|
isModifying: false,
|
|
654
501
|
});
|
|
655
502
|
}
|
|
656
503
|
}
|
|
657
504
|
else {
|
|
658
|
-
// If the client provided new content, apply it
|
|
505
|
+
// If the client provided new content, apply it and wait for
|
|
506
|
+
// re-confirmation.
|
|
659
507
|
if (payload?.newContent && toolCall) {
|
|
660
|
-
await this.
|
|
508
|
+
const result = await this.toolModifier.applyInlineModify(toolCall, payload, signal);
|
|
509
|
+
if (result) {
|
|
510
|
+
this.setArgsInternal(callId, result.updatedParams);
|
|
511
|
+
this.setStatusInternal(callId, 'awaiting_approval', signal, {
|
|
512
|
+
...toolCall.confirmationDetails,
|
|
513
|
+
fileDiff: result.updatedDiff,
|
|
514
|
+
});
|
|
515
|
+
// After an inline modification, wait for another user confirmation.
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
661
518
|
}
|
|
662
519
|
this.setStatusInternal(callId, 'scheduled', signal);
|
|
663
520
|
}
|
|
664
521
|
await this.attemptExecutionOfScheduledCalls(signal);
|
|
665
522
|
}
|
|
666
|
-
/**
|
|
667
|
-
* Applies user-provided content changes to a tool call that is awaiting confirmation.
|
|
668
|
-
* This method updates the tool's arguments and refreshes the confirmation prompt with a new diff
|
|
669
|
-
* before the tool is scheduled for execution.
|
|
670
|
-
* @private
|
|
671
|
-
*/
|
|
672
|
-
async _applyInlineModify(toolCall, payload, signal) {
|
|
673
|
-
if (toolCall.confirmationDetails.type !== 'edit' ||
|
|
674
|
-
!isModifiableDeclarativeTool(toolCall.tool)) {
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
const modifyContext = toolCall.tool.getModifyContext(signal);
|
|
678
|
-
const currentContent = await modifyContext.getCurrentContent(toolCall.request.args);
|
|
679
|
-
const updatedParams = modifyContext.createUpdatedParams(currentContent, payload.newContent, toolCall.request.args);
|
|
680
|
-
const updatedDiff = Diff.createPatch(modifyContext.getFilePath(toolCall.request.args), currentContent, payload.newContent, 'Current', 'Proposed');
|
|
681
|
-
this.setArgsInternal(toolCall.request.callId, updatedParams);
|
|
682
|
-
this.setStatusInternal(toolCall.request.callId, 'awaiting_approval', signal, {
|
|
683
|
-
...toolCall.confirmationDetails,
|
|
684
|
-
fileDiff: updatedDiff,
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
523
|
async attemptExecutionOfScheduledCalls(signal) {
|
|
688
524
|
const allCallsFinalOrScheduled = this.toolCalls.every((call) => call.status === 'scheduled' ||
|
|
689
525
|
call.status === 'cancelled' ||
|
|
@@ -694,111 +530,36 @@ export class CoreToolScheduler {
|
|
|
694
530
|
for (const toolCall of callsToExecute) {
|
|
695
531
|
if (toolCall.status !== 'scheduled')
|
|
696
532
|
continue;
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
533
|
+
this.setStatusInternal(toolCall.request.callId, 'executing', signal);
|
|
534
|
+
const executingCall = this.toolCalls.find((c) => c.request.callId === toolCall.request.callId);
|
|
535
|
+
if (!executingCall) {
|
|
536
|
+
// Should not happen, but safe guard
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
const completedCall = await this.toolExecutor.execute({
|
|
540
|
+
call: executingCall,
|
|
541
|
+
signal,
|
|
542
|
+
outputUpdateHandler: (callId, output) => {
|
|
703
543
|
if (this.outputUpdateHandler) {
|
|
704
|
-
this.outputUpdateHandler(callId,
|
|
544
|
+
this.outputUpdateHandler(callId, output);
|
|
705
545
|
}
|
|
706
546
|
this.toolCalls = this.toolCalls.map((tc) => tc.request.callId === callId && tc.status === 'executing'
|
|
707
|
-
? { ...tc, liveOutput:
|
|
547
|
+
? { ...tc, liveOutput: output }
|
|
708
548
|
: tc);
|
|
709
549
|
this.notifyToolCallsUpdate();
|
|
710
|
-
}
|
|
711
|
-
:
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
attributes: { type: 'tool-call' },
|
|
718
|
-
}, async ({ metadata: spanMetadata }) => {
|
|
719
|
-
spanMetadata.input = {
|
|
720
|
-
request: toolCall.request,
|
|
721
|
-
};
|
|
722
|
-
// TODO: Refactor to remove special casing for ShellToolInvocation.
|
|
723
|
-
// Introduce a generic callbacks object for the execute method to handle
|
|
724
|
-
// things like `onPid` and `onLiveOutput`. This will make the scheduler
|
|
725
|
-
// agnostic to the invocation type.
|
|
726
|
-
let promise;
|
|
727
|
-
if (invocation instanceof ShellToolInvocation) {
|
|
728
|
-
const setPidCallback = (pid) => {
|
|
729
|
-
this.toolCalls = this.toolCalls.map((tc) => tc.request.callId === callId && tc.status === 'executing'
|
|
730
|
-
? { ...tc, pid }
|
|
731
|
-
: tc);
|
|
732
|
-
this.notifyToolCallsUpdate();
|
|
733
|
-
};
|
|
734
|
-
promise = executeToolWithHooks(invocation, toolName, signal, messageBus, hooksEnabled, liveOutputCallback, shellExecutionConfig, setPidCallback);
|
|
735
|
-
}
|
|
736
|
-
else {
|
|
737
|
-
promise = executeToolWithHooks(invocation, toolName, signal, messageBus, hooksEnabled, liveOutputCallback, shellExecutionConfig);
|
|
738
|
-
}
|
|
739
|
-
try {
|
|
740
|
-
const toolResult = await promise;
|
|
741
|
-
spanMetadata.output = toolResult;
|
|
742
|
-
if (signal.aborted) {
|
|
743
|
-
this.setStatusInternal(callId, 'cancelled', signal, 'User cancelled tool execution.');
|
|
744
|
-
}
|
|
745
|
-
else if (toolResult.error === undefined) {
|
|
746
|
-
let content = toolResult.llmContent;
|
|
747
|
-
let outputFile = undefined;
|
|
748
|
-
const contentLength = typeof content === 'string' ? content.length : undefined;
|
|
749
|
-
if (typeof content === 'string' &&
|
|
750
|
-
toolName === SHELL_TOOL_NAME &&
|
|
751
|
-
this.config.getEnableToolOutputTruncation() &&
|
|
752
|
-
this.config.getTruncateToolOutputThreshold() > 0 &&
|
|
753
|
-
this.config.getTruncateToolOutputLines() > 0) {
|
|
754
|
-
const originalContentLength = content.length;
|
|
755
|
-
const threshold = this.config.getTruncateToolOutputThreshold();
|
|
756
|
-
const lines = this.config.getTruncateToolOutputLines();
|
|
757
|
-
const truncatedResult = await truncateAndSaveToFile(content, callId, this.config.storage.getProjectTempDir(), threshold, lines);
|
|
758
|
-
content = truncatedResult.content;
|
|
759
|
-
outputFile = truncatedResult.outputFile;
|
|
760
|
-
if (outputFile) {
|
|
761
|
-
logToolOutputTruncated(this.config, new ToolOutputTruncatedEvent(scheduledCall.request.prompt_id, {
|
|
762
|
-
toolName,
|
|
763
|
-
originalContentLength,
|
|
764
|
-
truncatedContentLength: content.length,
|
|
765
|
-
threshold,
|
|
766
|
-
lines,
|
|
767
|
-
}));
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
const response = convertToFunctionResponse(toolName, callId, content, this.config.getActiveModel());
|
|
771
|
-
const successResponse = {
|
|
772
|
-
callId,
|
|
773
|
-
responseParts: response,
|
|
774
|
-
resultDisplay: toolResult.returnDisplay,
|
|
775
|
-
error: undefined,
|
|
776
|
-
errorType: undefined,
|
|
777
|
-
outputFile,
|
|
778
|
-
contentLength,
|
|
779
|
-
};
|
|
780
|
-
this.setStatusInternal(callId, 'success', signal, successResponse);
|
|
781
|
-
}
|
|
782
|
-
else {
|
|
783
|
-
// It is a failure
|
|
784
|
-
const error = new Error(toolResult.error.message);
|
|
785
|
-
const errorResponse = createErrorResponse(scheduledCall.request, error, toolResult.error.type);
|
|
786
|
-
this.setStatusInternal(callId, 'error', signal, errorResponse);
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
catch (executionError) {
|
|
790
|
-
spanMetadata.error = executionError;
|
|
791
|
-
if (signal.aborted) {
|
|
792
|
-
this.setStatusInternal(callId, 'cancelled', signal, 'User cancelled tool execution.');
|
|
793
|
-
}
|
|
794
|
-
else {
|
|
795
|
-
this.setStatusInternal(callId, 'error', signal, createErrorResponse(scheduledCall.request, executionError instanceof Error
|
|
796
|
-
? executionError
|
|
797
|
-
: new Error(String(executionError)), ToolErrorType.UNHANDLED_EXCEPTION));
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
await this.checkAndNotifyCompletion(signal);
|
|
550
|
+
},
|
|
551
|
+
onUpdateToolCall: (updatedCall) => {
|
|
552
|
+
this.toolCalls = this.toolCalls.map((tc) => tc.request.callId === updatedCall.request.callId
|
|
553
|
+
? updatedCall
|
|
554
|
+
: tc);
|
|
555
|
+
this.notifyToolCallsUpdate();
|
|
556
|
+
},
|
|
801
557
|
});
|
|
558
|
+
this.toolCalls = this.toolCalls.map((tc) => tc.request.callId === completedCall.request.callId
|
|
559
|
+
? completedCall
|
|
560
|
+
: tc);
|
|
561
|
+
this.notifyToolCallsUpdate();
|
|
562
|
+
await this.checkAndNotifyCompletion(signal);
|
|
802
563
|
}
|
|
803
564
|
}
|
|
804
565
|
}
|
|
@@ -833,20 +594,35 @@ export class CoreToolScheduler {
|
|
|
833
594
|
if (signal.aborted) {
|
|
834
595
|
this._cancelAllQueuedCalls();
|
|
835
596
|
}
|
|
597
|
+
// If we are already finalizing, another concurrent call to
|
|
598
|
+
// checkAndNotifyCompletion will just return. The ongoing finalized loop
|
|
599
|
+
// will pick up any new tools added to completedToolCallsForBatch.
|
|
600
|
+
if (this.isFinalizingToolCalls) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
836
603
|
// If there's nothing to report and we weren't cancelled, we can stop.
|
|
837
604
|
// But if we were cancelled, we must proceed to potentially start the next queued request.
|
|
838
605
|
if (this.completedToolCallsForBatch.length === 0 && !signal.aborted) {
|
|
839
606
|
return;
|
|
840
607
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
//
|
|
844
|
-
|
|
845
|
-
|
|
608
|
+
this.isFinalizingToolCalls = true;
|
|
609
|
+
try {
|
|
610
|
+
// We use a while loop here to ensure that if new tools are added to the
|
|
611
|
+
// batch (e.g., via cancellation) while we are awaiting
|
|
612
|
+
// onAllToolCallsComplete, they are also reported before we finish.
|
|
613
|
+
while (this.completedToolCallsForBatch.length > 0) {
|
|
614
|
+
const batchToReport = [...this.completedToolCallsForBatch];
|
|
615
|
+
this.completedToolCallsForBatch = [];
|
|
616
|
+
if (this.onAllToolCallsComplete) {
|
|
617
|
+
await this.onAllToolCallsComplete(batchToReport);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
finally {
|
|
846
622
|
this.isFinalizingToolCalls = false;
|
|
623
|
+
this.isCancelling = false;
|
|
624
|
+
this.notifyToolCallsUpdate();
|
|
847
625
|
}
|
|
848
|
-
this.isCancelling = false;
|
|
849
|
-
this.notifyToolCallsUpdate();
|
|
850
626
|
// After completion of the entire batch, process the next item in the main request queue.
|
|
851
627
|
if (this.requestQueue.length > 0) {
|
|
852
628
|
const next = this.requestQueue.shift();
|
|
@@ -919,17 +695,5 @@ export class CoreToolScheduler {
|
|
|
919
695
|
};
|
|
920
696
|
});
|
|
921
697
|
}
|
|
922
|
-
isAutoApproved(toolCall) {
|
|
923
|
-
if (this.config.getApprovalMode() === ApprovalMode.YOLO) {
|
|
924
|
-
return true;
|
|
925
|
-
}
|
|
926
|
-
const allowedTools = this.config.getAllowedTools() || [];
|
|
927
|
-
const { tool, invocation } = toolCall;
|
|
928
|
-
const toolName = typeof tool === 'string' ? tool : tool.name;
|
|
929
|
-
if (SHELL_TOOL_NAMES.includes(toolName)) {
|
|
930
|
-
return isShellInvocationAllowlisted(invocation, allowedTools);
|
|
931
|
-
}
|
|
932
|
-
return doesToolInvocationMatch(tool, invocation, allowedTools);
|
|
933
|
-
}
|
|
934
698
|
}
|
|
935
699
|
//# sourceMappingURL=coreToolScheduler.js.map
|