@machina.ai/cell-cli-core 1.0.21-rc4 → 1.4.0-rc1
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/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +25 -11
- package/dist/src/code_assist/codeAssist.d.ts +6 -3
- package/dist/src/code_assist/codeAssist.js +12 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/converter.d.ts +3 -1
- package/dist/src/code_assist/converter.js +37 -5
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +83 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -1
- package/dist/src/code_assist/oauth2.js +85 -49
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +317 -15
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +5 -5
- package/dist/src/code_assist/server.js +1 -1
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +1 -1
- package/dist/src/code_assist/setup.js +1 -1
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/config/config.d.ts +53 -15
- package/dist/src/config/config.js +127 -47
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +151 -6
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/models.d.ts +1 -0
- package/dist/src/config/models.js +2 -0
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/storage.d.ts +32 -0
- package/dist/src/config/storage.js +90 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.js +43 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/core/client.d.ts +21 -11
- package/dist/src/core/client.js +83 -26
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +398 -88
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +6 -6
- package/dist/src/core/contentGenerator.js +4 -3
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +14 -5
- package/dist/src/core/coreToolScheduler.js +120 -49
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +383 -72
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +48 -15
- package/dist/src/core/geminiChat.js +327 -154
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +1041 -257
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiRequest.js +1 -0
- package/dist/src/core/geminiRequest.js.map +1 -1
- package/dist/src/core/logger.d.ts +4 -2
- package/dist/src/core/logger.js +4 -3
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +19 -18
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +3 -3
- package/dist/src/core/loggingContentGenerator.js +11 -9
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -5
- package/dist/src/core/nonInteractiveToolExecutor.js +15 -123
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +116 -90
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.js +8 -7
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +21 -21
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/subagent.d.ts +24 -18
- package/dist/src/core/subagent.js +126 -89
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +51 -35
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +33 -8
- package/dist/src/core/turn.js +59 -14
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +349 -90
- 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/constants.d.ts +1 -1
- package/dist/src/ide/constants.js +1 -1
- package/dist/src/ide/constants.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +8 -3
- package/dist/src/ide/detect-ide.js +29 -11
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +96 -52
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +18 -9
- package/dist/src/ide/ide-client.js +151 -33
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +147 -25
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +1 -1
- package/dist/src/ide/ide-installer.js +31 -22
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +82 -22
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +12 -0
- package/dist/src/ide/ideContext.js +1 -0
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +13 -6
- package/dist/src/ide/process-utils.js +142 -35
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.js +158 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/index.d.ts +12 -2
- package/dist/src/index.js +11 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +3 -3
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +13 -13
- package/dist/src/mcp/oauth-provider.js +32 -31
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +75 -36
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +9 -31
- package/dist/src/mcp/oauth-token-storage.js +10 -13
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +30 -27
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +9 -1
- package/dist/src/mcp/oauth-utils.js +41 -27
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +41 -1
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +160 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +144 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +235 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +31 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +190 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +254 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +38 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +2 -2
- package/dist/src/prompts/prompt-registry.d.ts +1 -1
- package/dist/src/services/chatRecordingService.d.ts +6 -13
- package/dist/src/services/chatRecordingService.js +31 -19
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +64 -25
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.js +1 -1
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +3 -3
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/fileSystemService.js +1 -1
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/fileSystemService.test.js +1 -1
- package/dist/src/services/fileSystemService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +3 -1
- package/dist/src/services/gitService.js +21 -12
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +22 -19
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +3 -2
- package/dist/src/services/loopDetectionService.js +28 -4
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +23 -1
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +8 -10
- package/dist/src/services/shellExecutionService.js +292 -135
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +277 -42
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +18 -4
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +171 -11
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +103 -11
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +31 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +75 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +9 -0
- package/dist/src/telemetry/constants.js +9 -0
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/file-exporters.d.ts +5 -4
- package/dist/src/telemetry/file-exporters.js +1 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +5 -2
- package/dist/src/telemetry/index.js +3 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +8 -2
- package/dist/src/telemetry/loggers.js +130 -2
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +105 -9
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +15 -4
- package/dist/src/telemetry/metrics.js +46 -8
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +5 -25
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sdk.d.ts +1 -1
- package/dist/src/telemetry/sdk.js +3 -3
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +40 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +61 -6
- package/dist/src/telemetry/types.js +105 -4
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +2 -2
- package/dist/src/telemetry/uiTelemetry.js +5 -5
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +20 -16
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +2 -1
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +41 -0
- package/dist/src/test-utils/mock-tool.js +51 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +1 -1
- package/dist/src/test-utils/tools.d.ts +3 -2
- package/dist/src/test-utils/tools.js.map +1 -1
- package/dist/src/tools/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +21 -13
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +58 -22
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +6 -5
- package/dist/src/tools/edit.js +47 -36
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +77 -12
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +3 -2
- package/dist/src/tools/glob.js +17 -6
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +29 -4
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +3 -2
- package/dist/src/tools/grep.js +35 -15
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +26 -3
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +3 -2
- package/dist/src/tools/ls.js +12 -7
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +7 -2
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +8 -6
- package/dist/src/tools/mcp-client-manager.js +30 -5
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +20 -1
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +18 -11
- package/dist/src/tools/mcp-client.js +67 -57
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +29 -4
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +6 -4
- package/dist/src/tools/mcp-tool.js +21 -11
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +49 -12
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +4 -3
- package/dist/src/tools/memoryTool.js +15 -38
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +24 -12
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.d.ts +2 -2
- package/dist/src/tools/modifiable-tool.js +3 -3
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +4 -4
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +3 -2
- package/dist/src/tools/read-file.js +12 -34
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +9 -6
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +3 -2
- package/dist/src/tools/read-many-files.js +35 -58
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +64 -11
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +47 -0
- package/dist/src/tools/ripGrep.js +368 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +874 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +3 -2
- package/dist/src/tools/shell.js +30 -25
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +34 -25
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +73 -0
- package/dist/src/tools/smart-edit.js +607 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +6 -0
- package/dist/src/tools/smart-edit.test.js +405 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +17 -1
- package/dist/src/tools/tool-error.js +26 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +10 -4
- package/dist/src/tools/tool-registry.js +19 -7
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +86 -3
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +15 -9
- package/dist/src/tools/tools.js +12 -0
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +1 -2
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +3 -2
- package/dist/src/tools/web-fetch.js +14 -10
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +55 -16
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +4 -3
- package/dist/src/tools/web-search.js +31 -8
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +69 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +4 -3
- package/dist/src/tools/write-file.js +14 -14
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +14 -14
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.d.ts +2 -2
- package/dist/src/utils/bfsFileSearch.js +2 -2
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +3 -3
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/editCorrector.d.ts +2 -2
- package/dist/src/utils/editCorrector.js +1 -1
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +3 -3
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.js +2 -2
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +2 -2
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +2 -2
- package/dist/src/utils/environmentContext.js +1 -1
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +1 -1
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errors.d.ts +19 -0
- package/dist/src/utils/errors.js +32 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/fetch.js +1 -1
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +23 -12
- package/dist/src/utils/fileUtils.js +160 -79
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +314 -21
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +2 -2
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +14 -9
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
- package/dist/src/utils/generateContentResponseUtilities.js +1 -13
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.d.ts +2 -2
- package/dist/src/utils/getFolderStructure.js +2 -2
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +13 -13
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/getPty.d.ts +19 -0
- package/dist/src/utils/getPty.js +23 -0
- package/dist/src/utils/getPty.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +1 -0
- package/dist/src/utils/gitIgnoreParser.js +104 -13
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +69 -3
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/gitUtils.js +2 -2
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/ide-trust.d.ts +10 -0
- package/dist/src/utils/ide-trust.js +14 -0
- package/dist/src/utils/ide-trust.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +250 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +50 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +6 -0
- package/dist/src/utils/installationManager.test.js +83 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +25 -0
- package/dist/src/utils/llm-edit-fixer.js +112 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +7 -6
- package/dist/src/utils/memoryDiscovery.js +68 -33
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +76 -20
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +2 -2
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +2 -141
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/messageInspectors.d.ts +1 -1
- package/dist/src/utils/nextSpeakerChecker.d.ts +2 -2
- package/dist/src/utils/nextSpeakerChecker.test.js +33 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/partUtils.d.ts +22 -1
- package/dist/src/utils/partUtils.js +68 -0
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/partUtils.test.js +112 -1
- package/dist/src/utils/partUtils.test.js.map +1 -1
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +363 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +1 -18
- package/dist/src/utils/paths.js +3 -29
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/quotaErrorDetection.d.ts +1 -1
- package/dist/src/utils/retry.test.js +4 -1
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +4 -0
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/session.js +1 -1
- package/dist/src/utils/session.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +1 -1
- package/dist/src/utils/shell-utils.js +23 -29
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +7 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/summarizer.d.ts +2 -2
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +2 -2
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +2 -2
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/tool-utils.d.ts +19 -0
- package/dist/src/utils/tool-utils.js +58 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +6 -0
- package/dist/src/utils/tool-utils.test.js +61 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +114 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +33 -30
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.js +13 -7
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +41 -16
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -13
- package/dist/src/utils/user_account.d.ts +0 -9
- package/dist/src/utils/user_account.js +0 -109
- package/dist/src/utils/user_account.js.map +0 -1
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.d.ts +0 -11
- package/dist/src/utils/user_id.js +0 -49
- package/dist/src/utils/user_id.js.map +0 -1
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- /package/dist/src/{utils/user_account.test.d.ts → config/storage.test.d.ts} +0 -0
- /package/dist/src/{utils/user_id.test.d.ts → ide/process-utils.test.d.ts} +0 -0
|
@@ -7,12 +7,87 @@ import { describe, it, expect, vi } from 'vitest';
|
|
|
7
7
|
import { CoreToolScheduler, convertToFunctionResponse, } from './coreToolScheduler.js';
|
|
8
8
|
import { BaseDeclarativeTool, BaseToolInvocation, ToolConfirmationOutcome, Kind, ApprovalMode, } from '../index.js';
|
|
9
9
|
import { MockModifiableTool, MockTool } from '../test-utils/tools.js';
|
|
10
|
+
class TestApprovalTool extends BaseDeclarativeTool {
|
|
11
|
+
config;
|
|
12
|
+
static Name = 'testApprovalTool';
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(TestApprovalTool.Name, 'TestApprovalTool', 'A tool for testing approval logic', Kind.Edit, {
|
|
15
|
+
properties: { id: { type: 'string' } },
|
|
16
|
+
required: ['id'],
|
|
17
|
+
type: 'object',
|
|
18
|
+
});
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
createInvocation(params) {
|
|
22
|
+
return new TestApprovalInvocation(this.config, params);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class TestApprovalInvocation extends BaseToolInvocation {
|
|
26
|
+
config;
|
|
27
|
+
constructor(config, params) {
|
|
28
|
+
super(params);
|
|
29
|
+
this.config = config;
|
|
30
|
+
}
|
|
31
|
+
getDescription() {
|
|
32
|
+
return `Test tool ${this.params.id}`;
|
|
33
|
+
}
|
|
34
|
+
async shouldConfirmExecute() {
|
|
35
|
+
// Need confirmation unless approval mode is AUTO_EDIT
|
|
36
|
+
if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
type: 'edit',
|
|
41
|
+
title: `Confirm Test Tool ${this.params.id}`,
|
|
42
|
+
fileName: `test-${this.params.id}.txt`,
|
|
43
|
+
filePath: `/test-${this.params.id}.txt`,
|
|
44
|
+
fileDiff: 'Test diff content',
|
|
45
|
+
originalContent: '',
|
|
46
|
+
newContent: 'Test content',
|
|
47
|
+
onConfirm: async (outcome) => {
|
|
48
|
+
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
49
|
+
this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async execute() {
|
|
55
|
+
return {
|
|
56
|
+
llmContent: `Executed test tool ${this.params.id}`,
|
|
57
|
+
returnDisplay: `Executed test tool ${this.params.id}`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function waitForStatus(onToolCallsUpdate, status, timeout = 5000) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const startTime = Date.now();
|
|
64
|
+
const check = () => {
|
|
65
|
+
if (Date.now() - startTime > timeout) {
|
|
66
|
+
const seenStatuses = onToolCallsUpdate.mock.calls
|
|
67
|
+
.flatMap((call) => call[0])
|
|
68
|
+
.map((toolCall) => toolCall.status);
|
|
69
|
+
reject(new Error(`Timed out waiting for status "${status}". Seen statuses: ${seenStatuses.join(', ')}`));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const foundCall = onToolCallsUpdate.mock.calls
|
|
73
|
+
.flatMap((call) => call[0])
|
|
74
|
+
.find((toolCall) => toolCall.status === status);
|
|
75
|
+
if (foundCall) {
|
|
76
|
+
resolve(foundCall);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
setTimeout(check, 10); // Check again in 10ms
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
check();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
10
85
|
describe('CoreToolScheduler', () => {
|
|
11
86
|
it('should cancel a tool call if the signal is aborted before confirmation', async () => {
|
|
12
87
|
const mockTool = new MockTool();
|
|
13
88
|
mockTool.shouldConfirm = true;
|
|
14
89
|
const declarativeTool = mockTool;
|
|
15
|
-
const
|
|
90
|
+
const mockToolRegistry = {
|
|
16
91
|
getTool: () => declarativeTool,
|
|
17
92
|
getFunctionDeclarations: () => [],
|
|
18
93
|
tools: new Map(),
|
|
@@ -32,14 +107,17 @@ describe('CoreToolScheduler', () => {
|
|
|
32
107
|
getUsageStatisticsEnabled: () => true,
|
|
33
108
|
getDebugMode: () => false,
|
|
34
109
|
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
110
|
+
getAllowedTools: () => [],
|
|
35
111
|
getContentGeneratorConfig: () => ({
|
|
36
112
|
model: 'test-model',
|
|
37
113
|
authType: 'oauth-personal',
|
|
38
114
|
}),
|
|
115
|
+
getToolRegistry: () => mockToolRegistry,
|
|
116
|
+
getUseSmartEdit: () => false,
|
|
117
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
39
118
|
};
|
|
40
119
|
const scheduler = new CoreToolScheduler({
|
|
41
120
|
config: mockConfig,
|
|
42
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
43
121
|
onAllToolCallsComplete,
|
|
44
122
|
onToolCallsUpdate,
|
|
45
123
|
getPreferredEditor: () => 'vscode',
|
|
@@ -60,12 +138,43 @@ describe('CoreToolScheduler', () => {
|
|
|
60
138
|
.calls[0][0];
|
|
61
139
|
expect(completedCalls[0].status).toBe('cancelled');
|
|
62
140
|
});
|
|
141
|
+
describe('getToolSuggestion', () => {
|
|
142
|
+
it('should suggest the top N closest tool names for a typo', () => {
|
|
143
|
+
// Create mocked tool registry
|
|
144
|
+
const mockConfig = {
|
|
145
|
+
getToolRegistry: () => mockToolRegistry,
|
|
146
|
+
getUseSmartEdit: () => false,
|
|
147
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
148
|
+
};
|
|
149
|
+
const mockToolRegistry = {
|
|
150
|
+
getAllToolNames: () => ['list_files', 'read_file', 'write_file'],
|
|
151
|
+
};
|
|
152
|
+
// Create scheduler
|
|
153
|
+
const scheduler = new CoreToolScheduler({
|
|
154
|
+
config: mockConfig,
|
|
155
|
+
getPreferredEditor: () => 'vscode',
|
|
156
|
+
onEditorClose: vi.fn(),
|
|
157
|
+
});
|
|
158
|
+
// Test that the right tool is selected, with only 1 result, for typos
|
|
159
|
+
// @ts-expect-error accessing private method
|
|
160
|
+
const misspelledTool = scheduler.getToolSuggestion('list_fils', 1);
|
|
161
|
+
expect(misspelledTool).toBe(' Did you mean "list_files"?');
|
|
162
|
+
// Test that the right tool is selected, with only 1 result, for prefixes
|
|
163
|
+
// @ts-expect-error accessing private method
|
|
164
|
+
const prefixedTool = scheduler.getToolSuggestion('github.list_files', 1);
|
|
165
|
+
expect(prefixedTool).toBe(' Did you mean "list_files"?');
|
|
166
|
+
// Test that the right tool is first
|
|
167
|
+
// @ts-expect-error accessing private method
|
|
168
|
+
const suggestionMultiple = scheduler.getToolSuggestion('list_fils');
|
|
169
|
+
expect(suggestionMultiple).toBe(' Did you mean one of: "list_files", "read_file", "write_file"?');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
63
172
|
});
|
|
64
173
|
describe('CoreToolScheduler with payload', () => {
|
|
65
174
|
it('should update args and diff and execute tool when payload is provided', async () => {
|
|
66
175
|
const mockTool = new MockModifiableTool();
|
|
67
176
|
const declarativeTool = mockTool;
|
|
68
|
-
const
|
|
177
|
+
const mockToolRegistry = {
|
|
69
178
|
getTool: () => declarativeTool,
|
|
70
179
|
getFunctionDeclarations: () => [],
|
|
71
180
|
tools: new Map(),
|
|
@@ -85,14 +194,17 @@ describe('CoreToolScheduler with payload', () => {
|
|
|
85
194
|
getUsageStatisticsEnabled: () => true,
|
|
86
195
|
getDebugMode: () => false,
|
|
87
196
|
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
197
|
+
getAllowedTools: () => [],
|
|
88
198
|
getContentGeneratorConfig: () => ({
|
|
89
199
|
model: 'test-model',
|
|
90
200
|
authType: 'oauth-personal',
|
|
91
201
|
}),
|
|
202
|
+
getToolRegistry: () => mockToolRegistry,
|
|
203
|
+
getUseSmartEdit: () => false,
|
|
204
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
92
205
|
};
|
|
93
206
|
const scheduler = new CoreToolScheduler({
|
|
94
207
|
config: mockConfig,
|
|
95
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
96
208
|
onAllToolCallsComplete,
|
|
97
209
|
onToolCallsUpdate,
|
|
98
210
|
getPreferredEditor: () => 'vscode',
|
|
@@ -107,11 +219,7 @@ describe('CoreToolScheduler with payload', () => {
|
|
|
107
219
|
prompt_id: 'prompt-id-2',
|
|
108
220
|
};
|
|
109
221
|
await scheduler.schedule([request], abortController.signal);
|
|
110
|
-
await
|
|
111
|
-
const awaitingCall = onToolCallsUpdate.mock.calls.find((call) => call[0][0].status === 'awaiting_approval')?.[0][0];
|
|
112
|
-
expect(awaitingCall).toBeDefined();
|
|
113
|
-
});
|
|
114
|
-
const awaitingCall = onToolCallsUpdate.mock.calls.find((call) => call[0][0].status === 'awaiting_approval')?.[0][0];
|
|
222
|
+
const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
|
|
115
223
|
const confirmationDetails = awaitingCall.confirmationDetails;
|
|
116
224
|
if (confirmationDetails) {
|
|
117
225
|
const payload = { newContent: 'final version' };
|
|
@@ -132,35 +240,41 @@ describe('convertToFunctionResponse', () => {
|
|
|
132
240
|
it('should handle simple string llmContent', () => {
|
|
133
241
|
const llmContent = 'Simple text output';
|
|
134
242
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
135
|
-
expect(result).toEqual(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
243
|
+
expect(result).toEqual([
|
|
244
|
+
{
|
|
245
|
+
functionResponse: {
|
|
246
|
+
name: toolName,
|
|
247
|
+
id: callId,
|
|
248
|
+
response: { output: 'Simple text output' },
|
|
249
|
+
},
|
|
140
250
|
},
|
|
141
|
-
|
|
251
|
+
]);
|
|
142
252
|
});
|
|
143
253
|
it('should handle llmContent as a single Part with text', () => {
|
|
144
254
|
const llmContent = { text: 'Text from Part object' };
|
|
145
255
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
146
|
-
expect(result).toEqual(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
256
|
+
expect(result).toEqual([
|
|
257
|
+
{
|
|
258
|
+
functionResponse: {
|
|
259
|
+
name: toolName,
|
|
260
|
+
id: callId,
|
|
261
|
+
response: { output: 'Text from Part object' },
|
|
262
|
+
},
|
|
151
263
|
},
|
|
152
|
-
|
|
264
|
+
]);
|
|
153
265
|
});
|
|
154
266
|
it('should handle llmContent as a PartListUnion array with a single text Part', () => {
|
|
155
267
|
const llmContent = [{ text: 'Text from array' }];
|
|
156
268
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
157
|
-
expect(result).toEqual(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
269
|
+
expect(result).toEqual([
|
|
270
|
+
{
|
|
271
|
+
functionResponse: {
|
|
272
|
+
name: toolName,
|
|
273
|
+
id: callId,
|
|
274
|
+
response: { output: 'Text from array' },
|
|
275
|
+
},
|
|
162
276
|
},
|
|
163
|
-
|
|
277
|
+
]);
|
|
164
278
|
});
|
|
165
279
|
it('should handle llmContent with inlineData', () => {
|
|
166
280
|
const llmContent = {
|
|
@@ -237,24 +351,28 @@ describe('convertToFunctionResponse', () => {
|
|
|
237
351
|
it('should handle llmContent as a generic Part (not text, inlineData, or fileData)', () => {
|
|
238
352
|
const llmContent = { functionCall: { name: 'test', args: {} } };
|
|
239
353
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
240
|
-
expect(result).toEqual(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
354
|
+
expect(result).toEqual([
|
|
355
|
+
{
|
|
356
|
+
functionResponse: {
|
|
357
|
+
name: toolName,
|
|
358
|
+
id: callId,
|
|
359
|
+
response: { output: 'Tool execution succeeded.' },
|
|
360
|
+
},
|
|
245
361
|
},
|
|
246
|
-
|
|
362
|
+
]);
|
|
247
363
|
});
|
|
248
364
|
it('should handle empty string llmContent', () => {
|
|
249
365
|
const llmContent = '';
|
|
250
366
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
251
|
-
expect(result).toEqual(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
367
|
+
expect(result).toEqual([
|
|
368
|
+
{
|
|
369
|
+
functionResponse: {
|
|
370
|
+
name: toolName,
|
|
371
|
+
id: callId,
|
|
372
|
+
response: { output: '' },
|
|
373
|
+
},
|
|
256
374
|
},
|
|
257
|
-
|
|
375
|
+
]);
|
|
258
376
|
});
|
|
259
377
|
it('should handle llmContent as an empty array', () => {
|
|
260
378
|
const llmContent = [];
|
|
@@ -272,13 +390,15 @@ describe('convertToFunctionResponse', () => {
|
|
|
272
390
|
it('should handle llmContent as a Part with undefined inlineData/fileData/text', () => {
|
|
273
391
|
const llmContent = {}; // An empty part object
|
|
274
392
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
275
|
-
expect(result).toEqual(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
393
|
+
expect(result).toEqual([
|
|
394
|
+
{
|
|
395
|
+
functionResponse: {
|
|
396
|
+
name: toolName,
|
|
397
|
+
id: callId,
|
|
398
|
+
response: { output: 'Tool execution succeeded.' },
|
|
399
|
+
},
|
|
280
400
|
},
|
|
281
|
-
|
|
401
|
+
]);
|
|
282
402
|
});
|
|
283
403
|
});
|
|
284
404
|
class MockEditToolInvocation extends BaseToolInvocation {
|
|
@@ -318,15 +438,14 @@ class MockEditTool extends BaseDeclarativeTool {
|
|
|
318
438
|
describe('CoreToolScheduler edit cancellation', () => {
|
|
319
439
|
it('should preserve diff when an edit is cancelled', async () => {
|
|
320
440
|
const mockEditTool = new MockEditTool();
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
getTool: () => declarativeTool,
|
|
441
|
+
const mockToolRegistry = {
|
|
442
|
+
getTool: () => mockEditTool,
|
|
324
443
|
getFunctionDeclarations: () => [],
|
|
325
444
|
tools: new Map(),
|
|
326
445
|
discovery: {},
|
|
327
446
|
registerTool: () => { },
|
|
328
|
-
getToolByName: () =>
|
|
329
|
-
getToolByDisplayName: () =>
|
|
447
|
+
getToolByName: () => mockEditTool,
|
|
448
|
+
getToolByDisplayName: () => mockEditTool,
|
|
330
449
|
getTools: () => [],
|
|
331
450
|
discoverTools: async () => { },
|
|
332
451
|
getAllTools: () => [],
|
|
@@ -339,14 +458,17 @@ describe('CoreToolScheduler edit cancellation', () => {
|
|
|
339
458
|
getUsageStatisticsEnabled: () => true,
|
|
340
459
|
getDebugMode: () => false,
|
|
341
460
|
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
461
|
+
getAllowedTools: () => [],
|
|
342
462
|
getContentGeneratorConfig: () => ({
|
|
343
463
|
model: 'test-model',
|
|
344
464
|
authType: 'oauth-personal',
|
|
345
465
|
}),
|
|
466
|
+
getToolRegistry: () => mockToolRegistry,
|
|
467
|
+
getUseSmartEdit: () => false,
|
|
468
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
346
469
|
};
|
|
347
470
|
const scheduler = new CoreToolScheduler({
|
|
348
471
|
config: mockConfig,
|
|
349
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
350
472
|
onAllToolCallsComplete,
|
|
351
473
|
onToolCallsUpdate,
|
|
352
474
|
getPreferredEditor: () => 'vscode',
|
|
@@ -361,9 +483,7 @@ describe('CoreToolScheduler edit cancellation', () => {
|
|
|
361
483
|
prompt_id: 'prompt-id-1',
|
|
362
484
|
};
|
|
363
485
|
await scheduler.schedule([request], abortController.signal);
|
|
364
|
-
|
|
365
|
-
const awaitingCall = onToolCallsUpdate.mock.calls.find((call) => call[0][0].status === 'awaiting_approval')?.[0][0];
|
|
366
|
-
expect(awaitingCall).toBeDefined();
|
|
486
|
+
const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
|
|
367
487
|
// Cancel the edit
|
|
368
488
|
const confirmationDetails = awaitingCall.confirmationDetails;
|
|
369
489
|
if (confirmationDetails) {
|
|
@@ -392,7 +512,7 @@ describe('CoreToolScheduler YOLO mode', () => {
|
|
|
392
512
|
// This tool would normally require confirmation.
|
|
393
513
|
mockTool.shouldConfirm = true;
|
|
394
514
|
const declarativeTool = mockTool;
|
|
395
|
-
const
|
|
515
|
+
const mockToolRegistry = {
|
|
396
516
|
getTool: () => declarativeTool,
|
|
397
517
|
getToolByName: () => declarativeTool,
|
|
398
518
|
// Other properties are not needed for this test but are included for type consistency.
|
|
@@ -414,14 +534,17 @@ describe('CoreToolScheduler YOLO mode', () => {
|
|
|
414
534
|
getUsageStatisticsEnabled: () => true,
|
|
415
535
|
getDebugMode: () => false,
|
|
416
536
|
getApprovalMode: () => ApprovalMode.YOLO,
|
|
537
|
+
getAllowedTools: () => [],
|
|
417
538
|
getContentGeneratorConfig: () => ({
|
|
418
539
|
model: 'test-model',
|
|
419
540
|
authType: 'oauth-personal',
|
|
420
541
|
}),
|
|
542
|
+
getToolRegistry: () => mockToolRegistry,
|
|
543
|
+
getUseSmartEdit: () => false,
|
|
544
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
421
545
|
};
|
|
422
546
|
const scheduler = new CoreToolScheduler({
|
|
423
547
|
config: mockConfig,
|
|
424
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
425
548
|
onAllToolCallsComplete,
|
|
426
549
|
onToolCallsUpdate,
|
|
427
550
|
getPreferredEditor: () => 'vscode',
|
|
@@ -472,7 +595,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
472
595
|
const mockTool = new MockTool();
|
|
473
596
|
mockTool.executeFn.mockImplementation(() => firstCallPromise);
|
|
474
597
|
const declarativeTool = mockTool;
|
|
475
|
-
const
|
|
598
|
+
const mockToolRegistry = {
|
|
476
599
|
getTool: () => declarativeTool,
|
|
477
600
|
getToolByName: () => declarativeTool,
|
|
478
601
|
getFunctionDeclarations: () => [],
|
|
@@ -492,14 +615,17 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
492
615
|
getUsageStatisticsEnabled: () => true,
|
|
493
616
|
getDebugMode: () => false,
|
|
494
617
|
getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
|
|
618
|
+
getAllowedTools: () => [],
|
|
495
619
|
getContentGeneratorConfig: () => ({
|
|
496
620
|
model: 'test-model',
|
|
497
621
|
authType: 'oauth-personal',
|
|
498
622
|
}),
|
|
623
|
+
getToolRegistry: () => mockToolRegistry,
|
|
624
|
+
getUseSmartEdit: () => false,
|
|
625
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
499
626
|
};
|
|
500
627
|
const scheduler = new CoreToolScheduler({
|
|
501
628
|
config: mockConfig,
|
|
502
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
503
629
|
onAllToolCallsComplete,
|
|
504
630
|
onToolCallsUpdate,
|
|
505
631
|
getPreferredEditor: () => 'vscode',
|
|
@@ -523,10 +649,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
523
649
|
// Schedule the first call, which will pause execution.
|
|
524
650
|
scheduler.schedule([request1], abortController.signal);
|
|
525
651
|
// Wait for the first call to be in the 'executing' state.
|
|
526
|
-
await
|
|
527
|
-
const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
|
|
528
|
-
expect(calls?.[0]?.status).toBe('executing');
|
|
529
|
-
});
|
|
652
|
+
await waitForStatus(onToolCallsUpdate, 'executing');
|
|
530
653
|
// Schedule the second call while the first is "running".
|
|
531
654
|
const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
|
|
532
655
|
// Ensure the second tool call hasn't been executed yet.
|
|
@@ -539,14 +662,6 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
539
662
|
});
|
|
540
663
|
// Wait for the second schedule promise to resolve.
|
|
541
664
|
await schedulePromise2;
|
|
542
|
-
// Wait for the second call to be in the 'executing' state.
|
|
543
|
-
await vi.waitFor(() => {
|
|
544
|
-
const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
|
|
545
|
-
expect(calls?.[0]?.status).toBe('executing');
|
|
546
|
-
});
|
|
547
|
-
// Now the second tool call should have been executed.
|
|
548
|
-
expect(mockTool.executeFn).toHaveBeenCalledTimes(2);
|
|
549
|
-
expect(mockTool.executeFn).toHaveBeenCalledWith({ b: 2 });
|
|
550
665
|
// Let the second call finish.
|
|
551
666
|
const secondCallResult = {
|
|
552
667
|
llmContent: 'Second call complete',
|
|
@@ -555,6 +670,11 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
555
670
|
// Since the mock is shared, we need to resolve the current promise.
|
|
556
671
|
// In a real scenario, a new promise would be created for the second call.
|
|
557
672
|
resolveFirstCall(secondCallResult);
|
|
673
|
+
await vi.waitFor(() => {
|
|
674
|
+
// Now the second tool call should have been executed.
|
|
675
|
+
expect(mockTool.executeFn).toHaveBeenCalledTimes(2);
|
|
676
|
+
});
|
|
677
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ b: 2 });
|
|
558
678
|
// Wait for the second completion.
|
|
559
679
|
await vi.waitFor(() => {
|
|
560
680
|
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
@@ -563,10 +683,92 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
563
683
|
expect(onAllToolCallsComplete.mock.calls[0][0][0].status).toBe('success');
|
|
564
684
|
expect(onAllToolCallsComplete.mock.calls[1][0][0].status).toBe('success');
|
|
565
685
|
});
|
|
686
|
+
it('should auto-approve a tool call if it is on the allowedTools list', async () => {
|
|
687
|
+
// Arrange
|
|
688
|
+
const mockTool = new MockTool('mockTool');
|
|
689
|
+
mockTool.executeFn.mockReturnValue({
|
|
690
|
+
llmContent: 'Tool executed',
|
|
691
|
+
returnDisplay: 'Tool executed',
|
|
692
|
+
});
|
|
693
|
+
// This tool would normally require confirmation.
|
|
694
|
+
mockTool.shouldConfirm = true;
|
|
695
|
+
const declarativeTool = mockTool;
|
|
696
|
+
const toolRegistry = {
|
|
697
|
+
getTool: () => declarativeTool,
|
|
698
|
+
getToolByName: () => declarativeTool,
|
|
699
|
+
getFunctionDeclarations: () => [],
|
|
700
|
+
tools: new Map(),
|
|
701
|
+
discovery: {},
|
|
702
|
+
registerTool: () => { },
|
|
703
|
+
getToolByDisplayName: () => declarativeTool,
|
|
704
|
+
getTools: () => [],
|
|
705
|
+
discoverTools: async () => { },
|
|
706
|
+
getAllTools: () => [],
|
|
707
|
+
getToolsByServer: () => [],
|
|
708
|
+
};
|
|
709
|
+
const onAllToolCallsComplete = vi.fn();
|
|
710
|
+
const onToolCallsUpdate = vi.fn();
|
|
711
|
+
// Configure the scheduler to auto-approve the specific tool call.
|
|
712
|
+
const mockConfig = {
|
|
713
|
+
getSessionId: () => 'test-session-id',
|
|
714
|
+
getUsageStatisticsEnabled: () => true,
|
|
715
|
+
getDebugMode: () => false,
|
|
716
|
+
getApprovalMode: () => ApprovalMode.DEFAULT, // Not YOLO mode
|
|
717
|
+
getAllowedTools: () => ['mockTool'], // Auto-approve this tool
|
|
718
|
+
getToolRegistry: () => toolRegistry,
|
|
719
|
+
getContentGeneratorConfig: () => ({
|
|
720
|
+
model: 'test-model',
|
|
721
|
+
authType: 'oauth-personal',
|
|
722
|
+
}),
|
|
723
|
+
getUseSmartEdit: () => false,
|
|
724
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
725
|
+
};
|
|
726
|
+
const scheduler = new CoreToolScheduler({
|
|
727
|
+
config: mockConfig,
|
|
728
|
+
onAllToolCallsComplete,
|
|
729
|
+
onToolCallsUpdate,
|
|
730
|
+
getPreferredEditor: () => 'vscode',
|
|
731
|
+
onEditorClose: vi.fn(),
|
|
732
|
+
});
|
|
733
|
+
const abortController = new AbortController();
|
|
734
|
+
const request = {
|
|
735
|
+
callId: '1',
|
|
736
|
+
name: 'mockTool',
|
|
737
|
+
args: { param: 'value' },
|
|
738
|
+
isClientInitiated: false,
|
|
739
|
+
prompt_id: 'prompt-auto-approved',
|
|
740
|
+
};
|
|
741
|
+
// Act
|
|
742
|
+
await scheduler.schedule([request], abortController.signal);
|
|
743
|
+
// Assert
|
|
744
|
+
// 1. The tool's execute method was called directly.
|
|
745
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ param: 'value' });
|
|
746
|
+
// 2. The tool call status never entered 'awaiting_approval'.
|
|
747
|
+
const statusUpdates = onToolCallsUpdate.mock.calls
|
|
748
|
+
.map((call) => call[0][0]?.status)
|
|
749
|
+
.filter(Boolean);
|
|
750
|
+
expect(statusUpdates).not.toContain('awaiting_approval');
|
|
751
|
+
expect(statusUpdates).toEqual([
|
|
752
|
+
'validating',
|
|
753
|
+
'scheduled',
|
|
754
|
+
'executing',
|
|
755
|
+
'success',
|
|
756
|
+
]);
|
|
757
|
+
// 3. The final callback indicates the tool call was successful.
|
|
758
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
759
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
760
|
+
.calls[0][0];
|
|
761
|
+
expect(completedCalls).toHaveLength(1);
|
|
762
|
+
const completedCall = completedCalls[0];
|
|
763
|
+
expect(completedCall.status).toBe('success');
|
|
764
|
+
if (completedCall.status === 'success') {
|
|
765
|
+
expect(completedCall.response.resultDisplay).toBe('Tool executed');
|
|
766
|
+
}
|
|
767
|
+
});
|
|
566
768
|
it('should handle two synchronous calls to schedule', async () => {
|
|
567
769
|
const mockTool = new MockTool();
|
|
568
770
|
const declarativeTool = mockTool;
|
|
569
|
-
const
|
|
771
|
+
const mockToolRegistry = {
|
|
570
772
|
getTool: () => declarativeTool,
|
|
571
773
|
getToolByName: () => declarativeTool,
|
|
572
774
|
getFunctionDeclarations: () => [],
|
|
@@ -586,14 +788,17 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
586
788
|
getUsageStatisticsEnabled: () => true,
|
|
587
789
|
getDebugMode: () => false,
|
|
588
790
|
getApprovalMode: () => ApprovalMode.YOLO,
|
|
791
|
+
getAllowedTools: () => [],
|
|
589
792
|
getContentGeneratorConfig: () => ({
|
|
590
793
|
model: 'test-model',
|
|
591
794
|
authType: 'oauth-personal',
|
|
592
795
|
}),
|
|
796
|
+
getToolRegistry: () => mockToolRegistry,
|
|
797
|
+
getUseSmartEdit: () => false,
|
|
798
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
593
799
|
};
|
|
594
800
|
const scheduler = new CoreToolScheduler({
|
|
595
801
|
config: mockConfig,
|
|
596
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
597
802
|
onAllToolCallsComplete,
|
|
598
803
|
onToolCallsUpdate,
|
|
599
804
|
getPreferredEditor: () => 'vscode',
|
|
@@ -626,5 +831,111 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
626
831
|
// Ensure completion callbacks were called twice.
|
|
627
832
|
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
628
833
|
});
|
|
834
|
+
it('should auto-approve remaining tool calls when first tool call is approved with ProceedAlways', async () => {
|
|
835
|
+
let approvalMode = ApprovalMode.DEFAULT;
|
|
836
|
+
const mockConfig = {
|
|
837
|
+
getSessionId: () => 'test-session-id',
|
|
838
|
+
getUsageStatisticsEnabled: () => true,
|
|
839
|
+
getDebugMode: () => false,
|
|
840
|
+
getApprovalMode: () => approvalMode,
|
|
841
|
+
getAllowedTools: () => [],
|
|
842
|
+
setApprovalMode: (mode) => {
|
|
843
|
+
approvalMode = mode;
|
|
844
|
+
},
|
|
845
|
+
getUseSmartEdit: () => false,
|
|
846
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
847
|
+
};
|
|
848
|
+
const testTool = new TestApprovalTool(mockConfig);
|
|
849
|
+
const toolRegistry = {
|
|
850
|
+
getTool: () => testTool,
|
|
851
|
+
getFunctionDeclarations: () => [],
|
|
852
|
+
getFunctionDeclarationsFiltered: () => [],
|
|
853
|
+
registerTool: () => { },
|
|
854
|
+
discoverAllTools: async () => { },
|
|
855
|
+
discoverMcpTools: async () => { },
|
|
856
|
+
discoverToolsForServer: async () => { },
|
|
857
|
+
removeMcpToolsByServer: () => { },
|
|
858
|
+
getAllTools: () => [],
|
|
859
|
+
getToolsByServer: () => [],
|
|
860
|
+
tools: new Map(),
|
|
861
|
+
config: mockConfig,
|
|
862
|
+
mcpClientManager: undefined,
|
|
863
|
+
getToolByName: () => testTool,
|
|
864
|
+
getToolByDisplayName: () => testTool,
|
|
865
|
+
getTools: () => [],
|
|
866
|
+
discoverTools: async () => { },
|
|
867
|
+
discovery: {},
|
|
868
|
+
};
|
|
869
|
+
mockConfig.getToolRegistry = () => toolRegistry;
|
|
870
|
+
const onAllToolCallsComplete = vi.fn();
|
|
871
|
+
const onToolCallsUpdate = vi.fn();
|
|
872
|
+
const pendingConfirmations = [];
|
|
873
|
+
const scheduler = new CoreToolScheduler({
|
|
874
|
+
config: mockConfig,
|
|
875
|
+
onAllToolCallsComplete,
|
|
876
|
+
onToolCallsUpdate: (toolCalls) => {
|
|
877
|
+
onToolCallsUpdate(toolCalls);
|
|
878
|
+
// Capture confirmation handlers for awaiting_approval tools
|
|
879
|
+
toolCalls.forEach((call) => {
|
|
880
|
+
if (call.status === 'awaiting_approval') {
|
|
881
|
+
const waitingCall = call;
|
|
882
|
+
if (waitingCall.confirmationDetails?.onConfirm) {
|
|
883
|
+
const originalHandler = pendingConfirmations.find((h) => h === waitingCall.confirmationDetails.onConfirm);
|
|
884
|
+
if (!originalHandler) {
|
|
885
|
+
pendingConfirmations.push(waitingCall.confirmationDetails.onConfirm);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
},
|
|
891
|
+
getPreferredEditor: () => 'vscode',
|
|
892
|
+
onEditorClose: vi.fn(),
|
|
893
|
+
});
|
|
894
|
+
const abortController = new AbortController();
|
|
895
|
+
// Schedule multiple tools that need confirmation
|
|
896
|
+
const requests = [
|
|
897
|
+
{
|
|
898
|
+
callId: '1',
|
|
899
|
+
name: 'testApprovalTool',
|
|
900
|
+
args: { id: 'first' },
|
|
901
|
+
isClientInitiated: false,
|
|
902
|
+
prompt_id: 'prompt-1',
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
callId: '2',
|
|
906
|
+
name: 'testApprovalTool',
|
|
907
|
+
args: { id: 'second' },
|
|
908
|
+
isClientInitiated: false,
|
|
909
|
+
prompt_id: 'prompt-2',
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
callId: '3',
|
|
913
|
+
name: 'testApprovalTool',
|
|
914
|
+
args: { id: 'third' },
|
|
915
|
+
isClientInitiated: false,
|
|
916
|
+
prompt_id: 'prompt-3',
|
|
917
|
+
},
|
|
918
|
+
];
|
|
919
|
+
await scheduler.schedule(requests, abortController.signal);
|
|
920
|
+
// Wait for all tools to be awaiting approval
|
|
921
|
+
await vi.waitFor(() => {
|
|
922
|
+
const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
|
|
923
|
+
expect(calls?.length).toBe(3);
|
|
924
|
+
expect(calls?.every((call) => call.status === 'awaiting_approval')).toBe(true);
|
|
925
|
+
});
|
|
926
|
+
expect(pendingConfirmations.length).toBe(3);
|
|
927
|
+
// Approve the first tool with ProceedAlways
|
|
928
|
+
const firstConfirmation = pendingConfirmations[0];
|
|
929
|
+
firstConfirmation(ToolConfirmationOutcome.ProceedAlways);
|
|
930
|
+
// Wait for all tools to be completed
|
|
931
|
+
await vi.waitFor(() => {
|
|
932
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
933
|
+
const completedCalls = onAllToolCallsComplete.mock.calls.at(-1)?.[0];
|
|
934
|
+
expect(completedCalls?.length).toBe(3);
|
|
935
|
+
expect(completedCalls?.every((call) => call.status === 'success')).toBe(true);
|
|
936
|
+
});
|
|
937
|
+
// Verify approval mode was changed
|
|
938
|
+
expect(approvalMode).toBe(ApprovalMode.AUTO_EDIT);
|
|
939
|
+
});
|
|
629
940
|
});
|
|
630
941
|
//# sourceMappingURL=coreToolScheduler.test.js.map
|