@google/gemini-cli-core 0.0.8999999 → 0.0.77777773
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 +105 -62
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +46 -0
- package/dist/src/agents/codebase-investigator.js +136 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/executor.d.ts +92 -0
- package/dist/src/agents/executor.js +579 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.d.ts +6 -0
- package/dist/src/agents/executor.test.js +595 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +46 -0
- package/dist/src/agents/invocation.js +102 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.d.ts +6 -0
- package/dist/src/agents/invocation.test.js +215 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +36 -0
- package/dist/src/agents/registry.js +60 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +146 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +112 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +145 -0
- package/dist/src/agents/types.js +18 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +1 -1
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +14 -13
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +4 -2
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/config/config.d.ts +46 -15
- package/dist/src/config/config.js +106 -27
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +88 -3
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +11 -0
- package/dist/src/config/constants.js +16 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/storage.d.ts +0 -1
- package/dist/src/config/storage.js +2 -2
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +7 -6
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +4 -0
- package/dist/src/core/baseLlmClient.js +24 -23
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +76 -13
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +3 -1
- package/dist/src/core/client.js +68 -47
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +385 -134
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.js +3 -1
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +24 -15
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +359 -23
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +11 -14
- package/dist/src/core/geminiChat.js +75 -124
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +260 -239
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/logger.test.js +2 -2
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +11 -11
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +2 -1
- package/dist/src/core/prompts.js +93 -18
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +78 -29
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +15 -6
- package/dist/src/core/turn.js +14 -13
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +14 -2
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +5 -2
- package/dist/src/ide/detect-ide.js +11 -2
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +34 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +2 -1
- package/dist/src/ide/ide-client.js +25 -20
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +6 -6
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.js +1 -1
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +13 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +1 -0
- package/dist/src/mcp/oauth-provider.js +19 -14
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +137 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.js +1 -0
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
- package/dist/src/mcp/sa-impersonation-provider.js +130 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +2 -1
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.test.js +4 -3
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +4 -3
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +3 -2
- package/dist/src/services/chatRecordingService.js +3 -2
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +11 -0
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +3 -0
- package/dist/src/services/shellExecutionService.js +165 -49
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +74 -5
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +18 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +156 -11
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +226 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +19 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +44 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.d.ts +31 -0
- package/dist/src/telemetry/config.js +76 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/config.test.d.ts +6 -0
- package/dist/src/telemetry/config.test.js +124 -0
- package/dist/src/telemetry/config.test.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +0 -34
- package/dist/src/telemetry/constants.js +0 -34
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +6 -2
- package/dist/src/telemetry/index.js +17 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +10 -2
- package/dist/src/telemetry/loggers.js +206 -273
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -3
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +260 -13
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +436 -11
- package/dist/src/telemetry/metrics.js +600 -110
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +898 -16
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +4 -1
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +13 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +18 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +167 -5
- package/dist/src/telemetry/types.js +692 -35
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
- package/dist/src/telemetry/uiTelemetry.js +1 -1
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +3 -3
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +28 -3
- package/dist/src/test-utils/mock-tool.js +71 -1
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/edit.js +6 -0
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +41 -0
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.js +4 -2
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/ls.js +1 -1
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +5 -14
- package/dist/src/tools/mcp-client.js +50 -97
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +175 -157
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.js +30 -2
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +117 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +1 -1
- package/dist/src/tools/memoryTool.js +1 -2
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +9 -8
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.d.ts +6 -0
- package/dist/src/tools/message-bus-integration.test.js +183 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/shell.js +60 -4
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +2 -1
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +1 -1
- package/dist/src/tools/smart-edit.js +122 -12
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +136 -29
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +22 -0
- package/dist/src/tools/tool-error.js +28 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +9 -0
- package/dist/src/tools/tool-names.js +18 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.test.js +10 -10
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +11 -3
- package/dist/src/tools/tools.js +94 -3
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.js +3 -0
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +44 -0
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.js +2 -1
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.js +2 -1
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +25 -0
- package/dist/src/tools/write-todos.js +151 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/tools/write-todos.test.d.ts +6 -0
- package/dist/src/tools/write-todos.test.js +89 -0
- package/dist/src/tools/write-todos.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +1 -1
- package/dist/src/utils/editCorrector.js +2 -2
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editor.js +1 -0
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +1 -0
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -1
- package/dist/src/utils/errorParsing.js +5 -33
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +0 -88
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +26 -45
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +1 -1
- package/dist/src/utils/getFolderStructure.js +1 -1
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +7 -6
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +108 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +6 -0
- package/dist/src/utils/googleErrors.test.js +212 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +35 -0
- package/dist/src/utils/googleQuotaErrors.js +108 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
- package/dist/src/utils/googleQuotaErrors.test.js +189 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/installationManager.test.js +2 -1
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +14 -4
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +81 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +2 -1
- package/dist/src/utils/memoryDiscovery.js +3 -2
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +99 -21
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +13 -20
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +14 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +0 -2
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +3 -1
- package/dist/src/utils/retry.js +60 -162
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +105 -135
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +11 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +113 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +1 -0
- package/dist/src/utils/shell-utils.js +6 -2
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +5 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +1 -4
- package/dist/src/utils/terminalSerializer.js +3 -3
- package/dist/src/utils/terminalSerializer.js.map +1 -1
- package/dist/src/utils/thoughtUtils.d.ts +21 -0
- package/dist/src/utils/thoughtUtils.js +39 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.test.d.ts +6 -0
- package/dist/src/utils/thoughtUtils.test.js +78 -0
- package/dist/src/utils/thoughtUtils.test.js.map +1 -0
- package/dist/src/utils/tool-utils.js +2 -2
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +8 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +2 -1
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/test-utils/tools.d.ts +0 -45
- package/dist/src/test-utils/tools.js +0 -105
- package/dist/src/test-utils/tools.js.map +0 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
7
7
|
import { CoreToolScheduler, convertToFunctionResponse, truncateAndSaveToFile, } from './coreToolScheduler.js';
|
|
8
8
|
import { DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES, DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD, BaseDeclarativeTool, BaseToolInvocation, ToolConfirmationOutcome, Kind, ApprovalMode, } from '../index.js';
|
|
9
|
-
import { MockModifiableTool, MockTool } from '../test-utils/
|
|
9
|
+
import { MockModifiableTool, MockTool, MOCK_TOOL_SHOULD_CONFIRM_EXECUTE, } from '../test-utils/mock-tool.js';
|
|
10
10
|
import * as fs from 'node:fs/promises';
|
|
11
11
|
import * as path from 'node:path';
|
|
12
12
|
vi.mock('fs/promises', () => ({
|
|
@@ -63,6 +63,40 @@ class TestApprovalInvocation extends BaseToolInvocation {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
class AbortDuringConfirmationInvocation extends BaseToolInvocation {
|
|
67
|
+
abortController;
|
|
68
|
+
abortError;
|
|
69
|
+
constructor(abortController, abortError, params) {
|
|
70
|
+
super(params);
|
|
71
|
+
this.abortController = abortController;
|
|
72
|
+
this.abortError = abortError;
|
|
73
|
+
}
|
|
74
|
+
async shouldConfirmExecute(_signal) {
|
|
75
|
+
this.abortController.abort();
|
|
76
|
+
throw this.abortError;
|
|
77
|
+
}
|
|
78
|
+
async execute(_abortSignal) {
|
|
79
|
+
throw new Error('execute should not be called when confirmation fails');
|
|
80
|
+
}
|
|
81
|
+
getDescription() {
|
|
82
|
+
return 'Abort during confirmation invocation';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class AbortDuringConfirmationTool extends BaseDeclarativeTool {
|
|
86
|
+
abortController;
|
|
87
|
+
abortError;
|
|
88
|
+
constructor(abortController, abortError) {
|
|
89
|
+
super('abortDuringConfirmationTool', 'Abort During Confirmation Tool', 'A tool that aborts while confirming execution.', Kind.Other, {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {},
|
|
92
|
+
});
|
|
93
|
+
this.abortController = abortController;
|
|
94
|
+
this.abortError = abortError;
|
|
95
|
+
}
|
|
96
|
+
createInvocation(params) {
|
|
97
|
+
return new AbortDuringConfirmationInvocation(this.abortController, this.abortError, params);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
66
100
|
async function waitForStatus(onToolCallsUpdate, status, timeout = 5000) {
|
|
67
101
|
return new Promise((resolve, reject) => {
|
|
68
102
|
const startTime = Date.now();
|
|
@@ -89,8 +123,10 @@ async function waitForStatus(onToolCallsUpdate, status, timeout = 5000) {
|
|
|
89
123
|
}
|
|
90
124
|
describe('CoreToolScheduler', () => {
|
|
91
125
|
it('should cancel a tool call if the signal is aborted before confirmation', async () => {
|
|
92
|
-
const mockTool = new MockTool(
|
|
93
|
-
|
|
126
|
+
const mockTool = new MockTool({
|
|
127
|
+
name: 'mockTool',
|
|
128
|
+
shouldConfirmExecute: MOCK_TOOL_SHOULD_CONFIRM_EXECUTE,
|
|
129
|
+
});
|
|
94
130
|
const declarativeTool = mockTool;
|
|
95
131
|
const mockToolRegistry = {
|
|
96
132
|
getTool: () => declarativeTool,
|
|
@@ -153,6 +189,71 @@ describe('CoreToolScheduler', () => {
|
|
|
153
189
|
.calls[0][0];
|
|
154
190
|
expect(completedCalls[0].status).toBe('cancelled');
|
|
155
191
|
});
|
|
192
|
+
it('should mark tool call as cancelled when abort happens during confirmation error', async () => {
|
|
193
|
+
const abortController = new AbortController();
|
|
194
|
+
const abortError = new Error('Abort requested during confirmation');
|
|
195
|
+
const declarativeTool = new AbortDuringConfirmationTool(abortController, abortError);
|
|
196
|
+
const mockToolRegistry = {
|
|
197
|
+
getTool: () => declarativeTool,
|
|
198
|
+
getFunctionDeclarations: () => [],
|
|
199
|
+
tools: new Map(),
|
|
200
|
+
discovery: {},
|
|
201
|
+
registerTool: () => { },
|
|
202
|
+
getToolByName: () => declarativeTool,
|
|
203
|
+
getToolByDisplayName: () => declarativeTool,
|
|
204
|
+
getTools: () => [],
|
|
205
|
+
discoverTools: async () => { },
|
|
206
|
+
getAllTools: () => [],
|
|
207
|
+
getToolsByServer: () => [],
|
|
208
|
+
};
|
|
209
|
+
const onAllToolCallsComplete = vi.fn();
|
|
210
|
+
const onToolCallsUpdate = vi.fn();
|
|
211
|
+
const mockConfig = {
|
|
212
|
+
getSessionId: () => 'test-session-id',
|
|
213
|
+
getUsageStatisticsEnabled: () => true,
|
|
214
|
+
getDebugMode: () => false,
|
|
215
|
+
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
216
|
+
getAllowedTools: () => [],
|
|
217
|
+
getContentGeneratorConfig: () => ({
|
|
218
|
+
model: 'test-model',
|
|
219
|
+
authType: 'oauth-personal',
|
|
220
|
+
}),
|
|
221
|
+
getShellExecutionConfig: () => ({
|
|
222
|
+
terminalWidth: 90,
|
|
223
|
+
terminalHeight: 30,
|
|
224
|
+
}),
|
|
225
|
+
storage: {
|
|
226
|
+
getProjectTempDir: () => '/tmp',
|
|
227
|
+
},
|
|
228
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
229
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
230
|
+
getToolRegistry: () => mockToolRegistry,
|
|
231
|
+
getUseSmartEdit: () => false,
|
|
232
|
+
getUseModelRouter: () => false,
|
|
233
|
+
getGeminiClient: () => null,
|
|
234
|
+
};
|
|
235
|
+
const scheduler = new CoreToolScheduler({
|
|
236
|
+
config: mockConfig,
|
|
237
|
+
onAllToolCallsComplete,
|
|
238
|
+
onToolCallsUpdate,
|
|
239
|
+
getPreferredEditor: () => 'vscode',
|
|
240
|
+
onEditorClose: vi.fn(),
|
|
241
|
+
});
|
|
242
|
+
const request = {
|
|
243
|
+
callId: 'abort-1',
|
|
244
|
+
name: 'abortDuringConfirmationTool',
|
|
245
|
+
args: {},
|
|
246
|
+
isClientInitiated: false,
|
|
247
|
+
prompt_id: 'prompt-id-abort',
|
|
248
|
+
};
|
|
249
|
+
await scheduler.schedule([request], abortController.signal);
|
|
250
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
251
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
252
|
+
.calls[0][0];
|
|
253
|
+
expect(completedCalls[0].status).toBe('cancelled');
|
|
254
|
+
const statuses = onToolCallsUpdate.mock.calls.flatMap((call) => call[0].map((toolCall) => toolCall.status));
|
|
255
|
+
expect(statuses).not.toContain('error');
|
|
256
|
+
});
|
|
156
257
|
describe('getToolSuggestion', () => {
|
|
157
258
|
it('should suggest the top N closest tool names for a typo', () => {
|
|
158
259
|
// Create mocked tool registry
|
|
@@ -189,6 +290,7 @@ describe('CoreToolScheduler', () => {
|
|
|
189
290
|
describe('CoreToolScheduler with payload', () => {
|
|
190
291
|
it('should update args and diff and execute tool when payload is provided', async () => {
|
|
191
292
|
const mockTool = new MockModifiableTool();
|
|
293
|
+
mockTool.executeFn = vi.fn();
|
|
192
294
|
const declarativeTool = mockTool;
|
|
193
295
|
const mockToolRegistry = {
|
|
194
296
|
getTool: () => declarativeTool,
|
|
@@ -541,13 +643,15 @@ describe('CoreToolScheduler edit cancellation', () => {
|
|
|
541
643
|
describe('CoreToolScheduler YOLO mode', () => {
|
|
542
644
|
it('should execute tool requiring confirmation directly without waiting', async () => {
|
|
543
645
|
// Arrange
|
|
544
|
-
const
|
|
545
|
-
mockTool.executeFn.mockReturnValue({
|
|
646
|
+
const executeFn = vi.fn().mockResolvedValue({
|
|
546
647
|
llmContent: 'Tool executed',
|
|
547
648
|
returnDisplay: 'Tool executed',
|
|
548
649
|
});
|
|
549
|
-
|
|
550
|
-
|
|
650
|
+
const mockTool = new MockTool({
|
|
651
|
+
name: 'mockTool',
|
|
652
|
+
execute: executeFn,
|
|
653
|
+
shouldConfirmExecute: MOCK_TOOL_SHOULD_CONFIRM_EXECUTE,
|
|
654
|
+
});
|
|
551
655
|
const declarativeTool = mockTool;
|
|
552
656
|
const mockToolRegistry = {
|
|
553
657
|
getTool: () => declarativeTool,
|
|
@@ -613,7 +717,7 @@ describe('CoreToolScheduler YOLO mode', () => {
|
|
|
613
717
|
});
|
|
614
718
|
// Assert
|
|
615
719
|
// 1. The tool's execute method was called directly.
|
|
616
|
-
expect(
|
|
720
|
+
expect(executeFn).toHaveBeenCalledWith({ param: 'value' });
|
|
617
721
|
// 2. The tool call status never entered 'awaiting_approval'.
|
|
618
722
|
const statusUpdates = onToolCallsUpdate.mock.calls
|
|
619
723
|
.map((call) => call[0][0]?.status)
|
|
@@ -642,8 +746,8 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
642
746
|
const firstCallPromise = new Promise((resolve) => {
|
|
643
747
|
resolveFirstCall = resolve;
|
|
644
748
|
});
|
|
645
|
-
const
|
|
646
|
-
mockTool
|
|
749
|
+
const executeFn = vi.fn().mockImplementation(() => firstCallPromise);
|
|
750
|
+
const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
|
|
647
751
|
const declarativeTool = mockTool;
|
|
648
752
|
const mockToolRegistry = {
|
|
649
753
|
getTool: () => declarativeTool,
|
|
@@ -713,8 +817,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
713
817
|
// Schedule the second call while the first is "running".
|
|
714
818
|
const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
|
|
715
819
|
// Ensure the second tool call hasn't been executed yet.
|
|
716
|
-
expect(
|
|
717
|
-
expect(mockTool.executeFn).toHaveBeenCalledWith({ a: 1 });
|
|
820
|
+
expect(executeFn).toHaveBeenCalledWith({ a: 1 });
|
|
718
821
|
// Complete the first tool call.
|
|
719
822
|
resolveFirstCall({
|
|
720
823
|
llmContent: 'First call complete',
|
|
@@ -732,9 +835,9 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
732
835
|
resolveFirstCall(secondCallResult);
|
|
733
836
|
await vi.waitFor(() => {
|
|
734
837
|
// Now the second tool call should have been executed.
|
|
735
|
-
expect(
|
|
838
|
+
expect(executeFn).toHaveBeenCalledTimes(2);
|
|
736
839
|
});
|
|
737
|
-
expect(
|
|
840
|
+
expect(executeFn).toHaveBeenCalledWith({ b: 2 });
|
|
738
841
|
// Wait for the second completion.
|
|
739
842
|
await vi.waitFor(() => {
|
|
740
843
|
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
@@ -745,13 +848,15 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
745
848
|
});
|
|
746
849
|
it('should auto-approve a tool call if it is on the allowedTools list', async () => {
|
|
747
850
|
// Arrange
|
|
748
|
-
const
|
|
749
|
-
mockTool.executeFn.mockReturnValue({
|
|
851
|
+
const executeFn = vi.fn().mockResolvedValue({
|
|
750
852
|
llmContent: 'Tool executed',
|
|
751
853
|
returnDisplay: 'Tool executed',
|
|
752
854
|
});
|
|
753
|
-
|
|
754
|
-
|
|
855
|
+
const mockTool = new MockTool({
|
|
856
|
+
name: 'mockTool',
|
|
857
|
+
execute: executeFn,
|
|
858
|
+
shouldConfirmExecute: MOCK_TOOL_SHOULD_CONFIRM_EXECUTE,
|
|
859
|
+
});
|
|
755
860
|
const declarativeTool = mockTool;
|
|
756
861
|
const toolRegistry = {
|
|
757
862
|
getTool: () => declarativeTool,
|
|
@@ -818,7 +923,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
818
923
|
});
|
|
819
924
|
// Assert
|
|
820
925
|
// 1. The tool's execute method was called directly.
|
|
821
|
-
expect(
|
|
926
|
+
expect(executeFn).toHaveBeenCalledWith({ param: 'value' });
|
|
822
927
|
// 2. The tool call status never entered 'awaiting_approval'.
|
|
823
928
|
const statusUpdates = onToolCallsUpdate.mock.calls
|
|
824
929
|
.map((call) => call[0][0]?.status)
|
|
@@ -842,7 +947,11 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
842
947
|
}
|
|
843
948
|
});
|
|
844
949
|
it('should handle two synchronous calls to schedule', async () => {
|
|
845
|
-
const
|
|
950
|
+
const executeFn = vi.fn().mockResolvedValue({
|
|
951
|
+
llmContent: 'Tool executed',
|
|
952
|
+
returnDisplay: 'Tool executed',
|
|
953
|
+
});
|
|
954
|
+
const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
|
|
846
955
|
const declarativeTool = mockTool;
|
|
847
956
|
const mockToolRegistry = {
|
|
848
957
|
getTool: () => declarativeTool,
|
|
@@ -911,9 +1020,9 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
911
1020
|
// Wait for both promises to resolve.
|
|
912
1021
|
await Promise.all([schedulePromise1, schedulePromise2]);
|
|
913
1022
|
// Ensure the tool was called twice with the correct arguments.
|
|
914
|
-
expect(
|
|
915
|
-
expect(
|
|
916
|
-
expect(
|
|
1023
|
+
expect(executeFn).toHaveBeenCalledTimes(2);
|
|
1024
|
+
expect(executeFn).toHaveBeenCalledWith({ a: 1 });
|
|
1025
|
+
expect(executeFn).toHaveBeenCalledWith({ b: 2 });
|
|
917
1026
|
// Ensure completion callbacks were called twice.
|
|
918
1027
|
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
919
1028
|
});
|
|
@@ -1034,6 +1143,233 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
1034
1143
|
expect(approvalMode).toBe(ApprovalMode.AUTO_EDIT);
|
|
1035
1144
|
});
|
|
1036
1145
|
});
|
|
1146
|
+
describe('CoreToolScheduler Sequential Execution', () => {
|
|
1147
|
+
it('should execute tool calls in a batch sequentially', async () => {
|
|
1148
|
+
// Arrange
|
|
1149
|
+
let firstCallFinished = false;
|
|
1150
|
+
const executeFn = vi
|
|
1151
|
+
.fn()
|
|
1152
|
+
.mockImplementation(async (args) => {
|
|
1153
|
+
if (args.call === 1) {
|
|
1154
|
+
// First call, wait for a bit to simulate work
|
|
1155
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
1156
|
+
firstCallFinished = true;
|
|
1157
|
+
return { llmContent: 'First call done' };
|
|
1158
|
+
}
|
|
1159
|
+
if (args.call === 2) {
|
|
1160
|
+
// Second call, should only happen after the first is finished
|
|
1161
|
+
if (!firstCallFinished) {
|
|
1162
|
+
throw new Error('Second tool call started before the first one finished!');
|
|
1163
|
+
}
|
|
1164
|
+
return { llmContent: 'Second call done' };
|
|
1165
|
+
}
|
|
1166
|
+
return { llmContent: 'default' };
|
|
1167
|
+
});
|
|
1168
|
+
const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
|
|
1169
|
+
const declarativeTool = mockTool;
|
|
1170
|
+
const mockToolRegistry = {
|
|
1171
|
+
getTool: () => declarativeTool,
|
|
1172
|
+
getToolByName: () => declarativeTool,
|
|
1173
|
+
getFunctionDeclarations: () => [],
|
|
1174
|
+
tools: new Map(),
|
|
1175
|
+
discovery: {},
|
|
1176
|
+
registerTool: () => { },
|
|
1177
|
+
getToolByDisplayName: () => declarativeTool,
|
|
1178
|
+
getTools: () => [],
|
|
1179
|
+
discoverTools: async () => { },
|
|
1180
|
+
getAllTools: () => [],
|
|
1181
|
+
getToolsByServer: () => [],
|
|
1182
|
+
};
|
|
1183
|
+
const onAllToolCallsComplete = vi.fn();
|
|
1184
|
+
const onToolCallsUpdate = vi.fn();
|
|
1185
|
+
const mockConfig = {
|
|
1186
|
+
getSessionId: () => 'test-session-id',
|
|
1187
|
+
getUsageStatisticsEnabled: () => true,
|
|
1188
|
+
getDebugMode: () => false,
|
|
1189
|
+
getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
|
|
1190
|
+
getAllowedTools: () => [],
|
|
1191
|
+
getContentGeneratorConfig: () => ({
|
|
1192
|
+
model: 'test-model',
|
|
1193
|
+
authType: 'oauth-personal',
|
|
1194
|
+
}),
|
|
1195
|
+
getShellExecutionConfig: () => ({
|
|
1196
|
+
terminalWidth: 90,
|
|
1197
|
+
terminalHeight: 30,
|
|
1198
|
+
}),
|
|
1199
|
+
storage: {
|
|
1200
|
+
getProjectTempDir: () => '/tmp',
|
|
1201
|
+
},
|
|
1202
|
+
getToolRegistry: () => mockToolRegistry,
|
|
1203
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
1204
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
1205
|
+
getUseSmartEdit: () => false,
|
|
1206
|
+
getUseModelRouter: () => false,
|
|
1207
|
+
getGeminiClient: () => null,
|
|
1208
|
+
};
|
|
1209
|
+
const scheduler = new CoreToolScheduler({
|
|
1210
|
+
config: mockConfig,
|
|
1211
|
+
onAllToolCallsComplete,
|
|
1212
|
+
onToolCallsUpdate,
|
|
1213
|
+
getPreferredEditor: () => 'vscode',
|
|
1214
|
+
onEditorClose: vi.fn(),
|
|
1215
|
+
});
|
|
1216
|
+
const abortController = new AbortController();
|
|
1217
|
+
const requests = [
|
|
1218
|
+
{
|
|
1219
|
+
callId: '1',
|
|
1220
|
+
name: 'mockTool',
|
|
1221
|
+
args: { call: 1 },
|
|
1222
|
+
isClientInitiated: false,
|
|
1223
|
+
prompt_id: 'prompt-1',
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
callId: '2',
|
|
1227
|
+
name: 'mockTool',
|
|
1228
|
+
args: { call: 2 },
|
|
1229
|
+
isClientInitiated: false,
|
|
1230
|
+
prompt_id: 'prompt-1',
|
|
1231
|
+
},
|
|
1232
|
+
];
|
|
1233
|
+
// Act
|
|
1234
|
+
await scheduler.schedule(requests, abortController.signal);
|
|
1235
|
+
// Assert
|
|
1236
|
+
await vi.waitFor(() => {
|
|
1237
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
1238
|
+
});
|
|
1239
|
+
// Check that execute was called twice
|
|
1240
|
+
expect(executeFn).toHaveBeenCalledTimes(2);
|
|
1241
|
+
// Check the order of calls
|
|
1242
|
+
const calls = executeFn.mock.calls;
|
|
1243
|
+
expect(calls[0][0]).toEqual({ call: 1 });
|
|
1244
|
+
expect(calls[1][0]).toEqual({ call: 2 });
|
|
1245
|
+
// The onAllToolCallsComplete should be called once with both results
|
|
1246
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
1247
|
+
.calls[0][0];
|
|
1248
|
+
expect(completedCalls).toHaveLength(2);
|
|
1249
|
+
expect(completedCalls[0].status).toBe('success');
|
|
1250
|
+
expect(completedCalls[1].status).toBe('success');
|
|
1251
|
+
});
|
|
1252
|
+
it('should cancel subsequent tools when the signal is aborted.', async () => {
|
|
1253
|
+
// Arrange
|
|
1254
|
+
const abortController = new AbortController();
|
|
1255
|
+
let secondCallStarted = false;
|
|
1256
|
+
const executeFn = vi
|
|
1257
|
+
.fn()
|
|
1258
|
+
.mockImplementation(async (args) => {
|
|
1259
|
+
if (args.call === 1) {
|
|
1260
|
+
return { llmContent: 'First call done' };
|
|
1261
|
+
}
|
|
1262
|
+
if (args.call === 2) {
|
|
1263
|
+
secondCallStarted = true;
|
|
1264
|
+
// This call will be cancelled while it's "running".
|
|
1265
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1266
|
+
// It should not return a value because it will be cancelled.
|
|
1267
|
+
return { llmContent: 'Second call should not complete' };
|
|
1268
|
+
}
|
|
1269
|
+
if (args.call === 3) {
|
|
1270
|
+
return { llmContent: 'Third call done' };
|
|
1271
|
+
}
|
|
1272
|
+
return { llmContent: 'default' };
|
|
1273
|
+
});
|
|
1274
|
+
const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
|
|
1275
|
+
const declarativeTool = mockTool;
|
|
1276
|
+
const mockToolRegistry = {
|
|
1277
|
+
getTool: () => declarativeTool,
|
|
1278
|
+
getToolByName: () => declarativeTool,
|
|
1279
|
+
getFunctionDeclarations: () => [],
|
|
1280
|
+
tools: new Map(),
|
|
1281
|
+
discovery: {},
|
|
1282
|
+
registerTool: () => { },
|
|
1283
|
+
getToolByDisplayName: () => declarativeTool,
|
|
1284
|
+
getTools: () => [],
|
|
1285
|
+
discoverTools: async () => { },
|
|
1286
|
+
getAllTools: () => [],
|
|
1287
|
+
getToolsByServer: () => [],
|
|
1288
|
+
};
|
|
1289
|
+
const onAllToolCallsComplete = vi.fn();
|
|
1290
|
+
const onToolCallsUpdate = vi.fn();
|
|
1291
|
+
const mockConfig = {
|
|
1292
|
+
getSessionId: () => 'test-session-id',
|
|
1293
|
+
getUsageStatisticsEnabled: () => true,
|
|
1294
|
+
getDebugMode: () => false,
|
|
1295
|
+
getApprovalMode: () => ApprovalMode.YOLO,
|
|
1296
|
+
getAllowedTools: () => [],
|
|
1297
|
+
getContentGeneratorConfig: () => ({
|
|
1298
|
+
model: 'test-model',
|
|
1299
|
+
authType: 'oauth-personal',
|
|
1300
|
+
}),
|
|
1301
|
+
getShellExecutionConfig: () => ({
|
|
1302
|
+
terminalWidth: 90,
|
|
1303
|
+
terminalHeight: 30,
|
|
1304
|
+
}),
|
|
1305
|
+
storage: {
|
|
1306
|
+
getProjectTempDir: () => '/tmp',
|
|
1307
|
+
},
|
|
1308
|
+
getToolRegistry: () => mockToolRegistry,
|
|
1309
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
1310
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
1311
|
+
getUseSmartEdit: () => false,
|
|
1312
|
+
getUseModelRouter: () => false,
|
|
1313
|
+
getGeminiClient: () => null,
|
|
1314
|
+
};
|
|
1315
|
+
const scheduler = new CoreToolScheduler({
|
|
1316
|
+
config: mockConfig,
|
|
1317
|
+
onAllToolCallsComplete,
|
|
1318
|
+
onToolCallsUpdate,
|
|
1319
|
+
getPreferredEditor: () => 'vscode',
|
|
1320
|
+
onEditorClose: vi.fn(),
|
|
1321
|
+
});
|
|
1322
|
+
const requests = [
|
|
1323
|
+
{
|
|
1324
|
+
callId: '1',
|
|
1325
|
+
name: 'mockTool',
|
|
1326
|
+
args: { call: 1 },
|
|
1327
|
+
isClientInitiated: false,
|
|
1328
|
+
prompt_id: 'prompt-1',
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
callId: '2',
|
|
1332
|
+
name: 'mockTool',
|
|
1333
|
+
args: { call: 2 },
|
|
1334
|
+
isClientInitiated: false,
|
|
1335
|
+
prompt_id: 'prompt-1',
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
callId: '3',
|
|
1339
|
+
name: 'mockTool',
|
|
1340
|
+
args: { call: 3 },
|
|
1341
|
+
isClientInitiated: false,
|
|
1342
|
+
prompt_id: 'prompt-1',
|
|
1343
|
+
},
|
|
1344
|
+
];
|
|
1345
|
+
// Act
|
|
1346
|
+
const schedulePromise = scheduler.schedule(requests, abortController.signal);
|
|
1347
|
+
// Wait for the second call to start, then abort.
|
|
1348
|
+
await vi.waitFor(() => {
|
|
1349
|
+
expect(secondCallStarted).toBe(true);
|
|
1350
|
+
});
|
|
1351
|
+
abortController.abort();
|
|
1352
|
+
await schedulePromise;
|
|
1353
|
+
// Assert
|
|
1354
|
+
await vi.waitFor(() => {
|
|
1355
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
1356
|
+
});
|
|
1357
|
+
// Check that execute was called for all three tools initially
|
|
1358
|
+
expect(executeFn).toHaveBeenCalledTimes(3);
|
|
1359
|
+
expect(executeFn).toHaveBeenCalledWith({ call: 1 });
|
|
1360
|
+
expect(executeFn).toHaveBeenCalledWith({ call: 2 });
|
|
1361
|
+
expect(executeFn).toHaveBeenCalledWith({ call: 3 });
|
|
1362
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
1363
|
+
.calls[0][0];
|
|
1364
|
+
expect(completedCalls).toHaveLength(3);
|
|
1365
|
+
const call1 = completedCalls.find((c) => c.request.callId === '1');
|
|
1366
|
+
const call2 = completedCalls.find((c) => c.request.callId === '2');
|
|
1367
|
+
const call3 = completedCalls.find((c) => c.request.callId === '3');
|
|
1368
|
+
expect(call1?.status).toBe('success');
|
|
1369
|
+
expect(call2?.status).toBe('cancelled');
|
|
1370
|
+
expect(call3?.status).toBe('cancelled');
|
|
1371
|
+
});
|
|
1372
|
+
});
|
|
1037
1373
|
describe('truncateAndSaveToFile', () => {
|
|
1038
1374
|
const mockWriteFile = vi.mocked(fs.writeFile);
|
|
1039
1375
|
const THRESHOLD = 40_000;
|