@machina.ai/cell-cli-core 1.0.21-rc4 → 1.2.2-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 +3 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +24 -11
- package/dist/src/code_assist/codeAssist.d.ts +4 -3
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/converter.d.ts +2 -1
- package/dist/src/code_assist/converter.js +36 -4
- 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 +29 -24
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +65 -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 -11
- package/dist/src/config/config.js +113 -29
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +103 -5
- 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 +17 -9
- package/dist/src/core/client.js +76 -19
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +366 -84
- 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 +365 -72
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +18 -14
- package/dist/src/core/geminiChat.js +223 -156
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +862 -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 +3 -1
- 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 +114 -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 +125 -87
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +31 -26
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +24 -7
- package/dist/src/core/turn.js +41 -11
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +157 -1
- 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 +11 -7
- package/dist/src/ide/ide-client.js +127 -29
- 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/process-utils.d.ts +14 -6
- package/dist/src/ide/process-utils.js +136 -34
- 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 +11 -2
- package/dist/src/index.js +10 -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 +2 -2
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +1 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +5 -27
- package/dist/src/mcp/oauth-token-storage.js +2 -5
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +7 -6
- 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/types.d.ts +34 -0
- package/dist/src/mcp/token-storage/types.js +7 -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 +2 -2
- package/dist/src/services/chatRecordingService.js +6 -3
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +10 -8
- 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 +2 -2
- package/dist/src/services/loopDetectionService.js +9 -3
- 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 +16 -4
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +140 -9
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +84 -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 +26 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +62 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +8 -0
- package/dist/src/telemetry/constants.js +8 -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 +105 -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 +69 -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 +52 -6
- package/dist/src/telemetry/types.js +87 -2
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +2 -2
- package/dist/src/telemetry/uiTelemetry.js +1 -1
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +16 -12
- 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/edit.d.ts +6 -5
- package/dist/src/tools/edit.js +36 -17
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +45 -8
- 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 +38 -33
- 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 -3
- package/dist/src/tools/mcp-tool.js +21 -7
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +49 -6
- 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 +60 -7
- 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 +26 -24
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +33 -24
- 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 +397 -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 +9 -7
- 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 +10 -7
- 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 +28 -7
- 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 +13 -13
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +9 -5
- 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 +155 -75
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +293 -1
- 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.js +3 -3
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +3 -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/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.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 +8 -1
- 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 +25 -12
- 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,15 @@ 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,
|
|
39
116
|
};
|
|
40
117
|
const scheduler = new CoreToolScheduler({
|
|
41
118
|
config: mockConfig,
|
|
42
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
43
119
|
onAllToolCallsComplete,
|
|
44
120
|
onToolCallsUpdate,
|
|
45
121
|
getPreferredEditor: () => 'vscode',
|
|
@@ -60,12 +136,41 @@ describe('CoreToolScheduler', () => {
|
|
|
60
136
|
.calls[0][0];
|
|
61
137
|
expect(completedCalls[0].status).toBe('cancelled');
|
|
62
138
|
});
|
|
139
|
+
describe('getToolSuggestion', () => {
|
|
140
|
+
it('should suggest the top N closest tool names for a typo', () => {
|
|
141
|
+
// Create mocked tool registry
|
|
142
|
+
const mockConfig = {
|
|
143
|
+
getToolRegistry: () => mockToolRegistry,
|
|
144
|
+
};
|
|
145
|
+
const mockToolRegistry = {
|
|
146
|
+
getAllToolNames: () => ['list_files', 'read_file', 'write_file'],
|
|
147
|
+
};
|
|
148
|
+
// Create scheduler
|
|
149
|
+
const scheduler = new CoreToolScheduler({
|
|
150
|
+
config: mockConfig,
|
|
151
|
+
getPreferredEditor: () => 'vscode',
|
|
152
|
+
onEditorClose: vi.fn(),
|
|
153
|
+
});
|
|
154
|
+
// Test that the right tool is selected, with only 1 result, for typos
|
|
155
|
+
// @ts-expect-error accessing private method
|
|
156
|
+
const misspelledTool = scheduler.getToolSuggestion('list_fils', 1);
|
|
157
|
+
expect(misspelledTool).toBe(' Did you mean "list_files"?');
|
|
158
|
+
// Test that the right tool is selected, with only 1 result, for prefixes
|
|
159
|
+
// @ts-expect-error accessing private method
|
|
160
|
+
const prefixedTool = scheduler.getToolSuggestion('github.list_files', 1);
|
|
161
|
+
expect(prefixedTool).toBe(' Did you mean "list_files"?');
|
|
162
|
+
// Test that the right tool is first
|
|
163
|
+
// @ts-expect-error accessing private method
|
|
164
|
+
const suggestionMultiple = scheduler.getToolSuggestion('list_fils');
|
|
165
|
+
expect(suggestionMultiple).toBe(' Did you mean one of: "list_files", "read_file", "write_file"?');
|
|
166
|
+
});
|
|
167
|
+
});
|
|
63
168
|
});
|
|
64
169
|
describe('CoreToolScheduler with payload', () => {
|
|
65
170
|
it('should update args and diff and execute tool when payload is provided', async () => {
|
|
66
171
|
const mockTool = new MockModifiableTool();
|
|
67
172
|
const declarativeTool = mockTool;
|
|
68
|
-
const
|
|
173
|
+
const mockToolRegistry = {
|
|
69
174
|
getTool: () => declarativeTool,
|
|
70
175
|
getFunctionDeclarations: () => [],
|
|
71
176
|
tools: new Map(),
|
|
@@ -85,14 +190,15 @@ describe('CoreToolScheduler with payload', () => {
|
|
|
85
190
|
getUsageStatisticsEnabled: () => true,
|
|
86
191
|
getDebugMode: () => false,
|
|
87
192
|
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
193
|
+
getAllowedTools: () => [],
|
|
88
194
|
getContentGeneratorConfig: () => ({
|
|
89
195
|
model: 'test-model',
|
|
90
196
|
authType: 'oauth-personal',
|
|
91
197
|
}),
|
|
198
|
+
getToolRegistry: () => mockToolRegistry,
|
|
92
199
|
};
|
|
93
200
|
const scheduler = new CoreToolScheduler({
|
|
94
201
|
config: mockConfig,
|
|
95
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
96
202
|
onAllToolCallsComplete,
|
|
97
203
|
onToolCallsUpdate,
|
|
98
204
|
getPreferredEditor: () => 'vscode',
|
|
@@ -107,11 +213,7 @@ describe('CoreToolScheduler with payload', () => {
|
|
|
107
213
|
prompt_id: 'prompt-id-2',
|
|
108
214
|
};
|
|
109
215
|
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];
|
|
216
|
+
const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
|
|
115
217
|
const confirmationDetails = awaitingCall.confirmationDetails;
|
|
116
218
|
if (confirmationDetails) {
|
|
117
219
|
const payload = { newContent: 'final version' };
|
|
@@ -132,35 +234,41 @@ describe('convertToFunctionResponse', () => {
|
|
|
132
234
|
it('should handle simple string llmContent', () => {
|
|
133
235
|
const llmContent = 'Simple text output';
|
|
134
236
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
135
|
-
expect(result).toEqual(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
237
|
+
expect(result).toEqual([
|
|
238
|
+
{
|
|
239
|
+
functionResponse: {
|
|
240
|
+
name: toolName,
|
|
241
|
+
id: callId,
|
|
242
|
+
response: { output: 'Simple text output' },
|
|
243
|
+
},
|
|
140
244
|
},
|
|
141
|
-
|
|
245
|
+
]);
|
|
142
246
|
});
|
|
143
247
|
it('should handle llmContent as a single Part with text', () => {
|
|
144
248
|
const llmContent = { text: 'Text from Part object' };
|
|
145
249
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
146
|
-
expect(result).toEqual(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
250
|
+
expect(result).toEqual([
|
|
251
|
+
{
|
|
252
|
+
functionResponse: {
|
|
253
|
+
name: toolName,
|
|
254
|
+
id: callId,
|
|
255
|
+
response: { output: 'Text from Part object' },
|
|
256
|
+
},
|
|
151
257
|
},
|
|
152
|
-
|
|
258
|
+
]);
|
|
153
259
|
});
|
|
154
260
|
it('should handle llmContent as a PartListUnion array with a single text Part', () => {
|
|
155
261
|
const llmContent = [{ text: 'Text from array' }];
|
|
156
262
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
157
|
-
expect(result).toEqual(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
263
|
+
expect(result).toEqual([
|
|
264
|
+
{
|
|
265
|
+
functionResponse: {
|
|
266
|
+
name: toolName,
|
|
267
|
+
id: callId,
|
|
268
|
+
response: { output: 'Text from array' },
|
|
269
|
+
},
|
|
162
270
|
},
|
|
163
|
-
|
|
271
|
+
]);
|
|
164
272
|
});
|
|
165
273
|
it('should handle llmContent with inlineData', () => {
|
|
166
274
|
const llmContent = {
|
|
@@ -237,24 +345,28 @@ describe('convertToFunctionResponse', () => {
|
|
|
237
345
|
it('should handle llmContent as a generic Part (not text, inlineData, or fileData)', () => {
|
|
238
346
|
const llmContent = { functionCall: { name: 'test', args: {} } };
|
|
239
347
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
240
|
-
expect(result).toEqual(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
348
|
+
expect(result).toEqual([
|
|
349
|
+
{
|
|
350
|
+
functionResponse: {
|
|
351
|
+
name: toolName,
|
|
352
|
+
id: callId,
|
|
353
|
+
response: { output: 'Tool execution succeeded.' },
|
|
354
|
+
},
|
|
245
355
|
},
|
|
246
|
-
|
|
356
|
+
]);
|
|
247
357
|
});
|
|
248
358
|
it('should handle empty string llmContent', () => {
|
|
249
359
|
const llmContent = '';
|
|
250
360
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
251
|
-
expect(result).toEqual(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
361
|
+
expect(result).toEqual([
|
|
362
|
+
{
|
|
363
|
+
functionResponse: {
|
|
364
|
+
name: toolName,
|
|
365
|
+
id: callId,
|
|
366
|
+
response: { output: '' },
|
|
367
|
+
},
|
|
256
368
|
},
|
|
257
|
-
|
|
369
|
+
]);
|
|
258
370
|
});
|
|
259
371
|
it('should handle llmContent as an empty array', () => {
|
|
260
372
|
const llmContent = [];
|
|
@@ -272,13 +384,15 @@ describe('convertToFunctionResponse', () => {
|
|
|
272
384
|
it('should handle llmContent as a Part with undefined inlineData/fileData/text', () => {
|
|
273
385
|
const llmContent = {}; // An empty part object
|
|
274
386
|
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
275
|
-
expect(result).toEqual(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
387
|
+
expect(result).toEqual([
|
|
388
|
+
{
|
|
389
|
+
functionResponse: {
|
|
390
|
+
name: toolName,
|
|
391
|
+
id: callId,
|
|
392
|
+
response: { output: 'Tool execution succeeded.' },
|
|
393
|
+
},
|
|
280
394
|
},
|
|
281
|
-
|
|
395
|
+
]);
|
|
282
396
|
});
|
|
283
397
|
});
|
|
284
398
|
class MockEditToolInvocation extends BaseToolInvocation {
|
|
@@ -318,15 +432,14 @@ class MockEditTool extends BaseDeclarativeTool {
|
|
|
318
432
|
describe('CoreToolScheduler edit cancellation', () => {
|
|
319
433
|
it('should preserve diff when an edit is cancelled', async () => {
|
|
320
434
|
const mockEditTool = new MockEditTool();
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
getTool: () => declarativeTool,
|
|
435
|
+
const mockToolRegistry = {
|
|
436
|
+
getTool: () => mockEditTool,
|
|
324
437
|
getFunctionDeclarations: () => [],
|
|
325
438
|
tools: new Map(),
|
|
326
439
|
discovery: {},
|
|
327
440
|
registerTool: () => { },
|
|
328
|
-
getToolByName: () =>
|
|
329
|
-
getToolByDisplayName: () =>
|
|
441
|
+
getToolByName: () => mockEditTool,
|
|
442
|
+
getToolByDisplayName: () => mockEditTool,
|
|
330
443
|
getTools: () => [],
|
|
331
444
|
discoverTools: async () => { },
|
|
332
445
|
getAllTools: () => [],
|
|
@@ -339,14 +452,15 @@ describe('CoreToolScheduler edit cancellation', () => {
|
|
|
339
452
|
getUsageStatisticsEnabled: () => true,
|
|
340
453
|
getDebugMode: () => false,
|
|
341
454
|
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
455
|
+
getAllowedTools: () => [],
|
|
342
456
|
getContentGeneratorConfig: () => ({
|
|
343
457
|
model: 'test-model',
|
|
344
458
|
authType: 'oauth-personal',
|
|
345
459
|
}),
|
|
460
|
+
getToolRegistry: () => mockToolRegistry,
|
|
346
461
|
};
|
|
347
462
|
const scheduler = new CoreToolScheduler({
|
|
348
463
|
config: mockConfig,
|
|
349
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
350
464
|
onAllToolCallsComplete,
|
|
351
465
|
onToolCallsUpdate,
|
|
352
466
|
getPreferredEditor: () => 'vscode',
|
|
@@ -361,9 +475,7 @@ describe('CoreToolScheduler edit cancellation', () => {
|
|
|
361
475
|
prompt_id: 'prompt-id-1',
|
|
362
476
|
};
|
|
363
477
|
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();
|
|
478
|
+
const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
|
|
367
479
|
// Cancel the edit
|
|
368
480
|
const confirmationDetails = awaitingCall.confirmationDetails;
|
|
369
481
|
if (confirmationDetails) {
|
|
@@ -392,7 +504,7 @@ describe('CoreToolScheduler YOLO mode', () => {
|
|
|
392
504
|
// This tool would normally require confirmation.
|
|
393
505
|
mockTool.shouldConfirm = true;
|
|
394
506
|
const declarativeTool = mockTool;
|
|
395
|
-
const
|
|
507
|
+
const mockToolRegistry = {
|
|
396
508
|
getTool: () => declarativeTool,
|
|
397
509
|
getToolByName: () => declarativeTool,
|
|
398
510
|
// Other properties are not needed for this test but are included for type consistency.
|
|
@@ -414,14 +526,15 @@ describe('CoreToolScheduler YOLO mode', () => {
|
|
|
414
526
|
getUsageStatisticsEnabled: () => true,
|
|
415
527
|
getDebugMode: () => false,
|
|
416
528
|
getApprovalMode: () => ApprovalMode.YOLO,
|
|
529
|
+
getAllowedTools: () => [],
|
|
417
530
|
getContentGeneratorConfig: () => ({
|
|
418
531
|
model: 'test-model',
|
|
419
532
|
authType: 'oauth-personal',
|
|
420
533
|
}),
|
|
534
|
+
getToolRegistry: () => mockToolRegistry,
|
|
421
535
|
};
|
|
422
536
|
const scheduler = new CoreToolScheduler({
|
|
423
537
|
config: mockConfig,
|
|
424
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
425
538
|
onAllToolCallsComplete,
|
|
426
539
|
onToolCallsUpdate,
|
|
427
540
|
getPreferredEditor: () => 'vscode',
|
|
@@ -472,7 +585,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
472
585
|
const mockTool = new MockTool();
|
|
473
586
|
mockTool.executeFn.mockImplementation(() => firstCallPromise);
|
|
474
587
|
const declarativeTool = mockTool;
|
|
475
|
-
const
|
|
588
|
+
const mockToolRegistry = {
|
|
476
589
|
getTool: () => declarativeTool,
|
|
477
590
|
getToolByName: () => declarativeTool,
|
|
478
591
|
getFunctionDeclarations: () => [],
|
|
@@ -492,14 +605,15 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
492
605
|
getUsageStatisticsEnabled: () => true,
|
|
493
606
|
getDebugMode: () => false,
|
|
494
607
|
getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
|
|
608
|
+
getAllowedTools: () => [],
|
|
495
609
|
getContentGeneratorConfig: () => ({
|
|
496
610
|
model: 'test-model',
|
|
497
611
|
authType: 'oauth-personal',
|
|
498
612
|
}),
|
|
613
|
+
getToolRegistry: () => mockToolRegistry,
|
|
499
614
|
};
|
|
500
615
|
const scheduler = new CoreToolScheduler({
|
|
501
616
|
config: mockConfig,
|
|
502
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
503
617
|
onAllToolCallsComplete,
|
|
504
618
|
onToolCallsUpdate,
|
|
505
619
|
getPreferredEditor: () => 'vscode',
|
|
@@ -523,10 +637,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
523
637
|
// Schedule the first call, which will pause execution.
|
|
524
638
|
scheduler.schedule([request1], abortController.signal);
|
|
525
639
|
// 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
|
-
});
|
|
640
|
+
await waitForStatus(onToolCallsUpdate, 'executing');
|
|
530
641
|
// Schedule the second call while the first is "running".
|
|
531
642
|
const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
|
|
532
643
|
// Ensure the second tool call hasn't been executed yet.
|
|
@@ -539,14 +650,6 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
539
650
|
});
|
|
540
651
|
// Wait for the second schedule promise to resolve.
|
|
541
652
|
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
653
|
// Let the second call finish.
|
|
551
654
|
const secondCallResult = {
|
|
552
655
|
llmContent: 'Second call complete',
|
|
@@ -555,6 +658,11 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
555
658
|
// Since the mock is shared, we need to resolve the current promise.
|
|
556
659
|
// In a real scenario, a new promise would be created for the second call.
|
|
557
660
|
resolveFirstCall(secondCallResult);
|
|
661
|
+
await vi.waitFor(() => {
|
|
662
|
+
// Now the second tool call should have been executed.
|
|
663
|
+
expect(mockTool.executeFn).toHaveBeenCalledTimes(2);
|
|
664
|
+
});
|
|
665
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ b: 2 });
|
|
558
666
|
// Wait for the second completion.
|
|
559
667
|
await vi.waitFor(() => {
|
|
560
668
|
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
@@ -563,10 +671,90 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
563
671
|
expect(onAllToolCallsComplete.mock.calls[0][0][0].status).toBe('success');
|
|
564
672
|
expect(onAllToolCallsComplete.mock.calls[1][0][0].status).toBe('success');
|
|
565
673
|
});
|
|
674
|
+
it('should auto-approve a tool call if it is on the allowedTools list', async () => {
|
|
675
|
+
// Arrange
|
|
676
|
+
const mockTool = new MockTool('mockTool');
|
|
677
|
+
mockTool.executeFn.mockReturnValue({
|
|
678
|
+
llmContent: 'Tool executed',
|
|
679
|
+
returnDisplay: 'Tool executed',
|
|
680
|
+
});
|
|
681
|
+
// This tool would normally require confirmation.
|
|
682
|
+
mockTool.shouldConfirm = true;
|
|
683
|
+
const declarativeTool = mockTool;
|
|
684
|
+
const toolRegistry = {
|
|
685
|
+
getTool: () => declarativeTool,
|
|
686
|
+
getToolByName: () => declarativeTool,
|
|
687
|
+
getFunctionDeclarations: () => [],
|
|
688
|
+
tools: new Map(),
|
|
689
|
+
discovery: {},
|
|
690
|
+
registerTool: () => { },
|
|
691
|
+
getToolByDisplayName: () => declarativeTool,
|
|
692
|
+
getTools: () => [],
|
|
693
|
+
discoverTools: async () => { },
|
|
694
|
+
getAllTools: () => [],
|
|
695
|
+
getToolsByServer: () => [],
|
|
696
|
+
};
|
|
697
|
+
const onAllToolCallsComplete = vi.fn();
|
|
698
|
+
const onToolCallsUpdate = vi.fn();
|
|
699
|
+
// Configure the scheduler to auto-approve the specific tool call.
|
|
700
|
+
const mockConfig = {
|
|
701
|
+
getSessionId: () => 'test-session-id',
|
|
702
|
+
getUsageStatisticsEnabled: () => true,
|
|
703
|
+
getDebugMode: () => false,
|
|
704
|
+
getApprovalMode: () => ApprovalMode.DEFAULT, // Not YOLO mode
|
|
705
|
+
getAllowedTools: () => ['mockTool'], // Auto-approve this tool
|
|
706
|
+
getToolRegistry: () => toolRegistry,
|
|
707
|
+
getContentGeneratorConfig: () => ({
|
|
708
|
+
model: 'test-model',
|
|
709
|
+
authType: 'oauth-personal',
|
|
710
|
+
}),
|
|
711
|
+
};
|
|
712
|
+
const scheduler = new CoreToolScheduler({
|
|
713
|
+
config: mockConfig,
|
|
714
|
+
onAllToolCallsComplete,
|
|
715
|
+
onToolCallsUpdate,
|
|
716
|
+
getPreferredEditor: () => 'vscode',
|
|
717
|
+
onEditorClose: vi.fn(),
|
|
718
|
+
});
|
|
719
|
+
const abortController = new AbortController();
|
|
720
|
+
const request = {
|
|
721
|
+
callId: '1',
|
|
722
|
+
name: 'mockTool',
|
|
723
|
+
args: { param: 'value' },
|
|
724
|
+
isClientInitiated: false,
|
|
725
|
+
prompt_id: 'prompt-auto-approved',
|
|
726
|
+
};
|
|
727
|
+
// Act
|
|
728
|
+
await scheduler.schedule([request], abortController.signal);
|
|
729
|
+
// Assert
|
|
730
|
+
// 1. The tool's execute method was called directly.
|
|
731
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ param: 'value' });
|
|
732
|
+
// 2. The tool call status never entered 'awaiting_approval'.
|
|
733
|
+
const statusUpdates = onToolCallsUpdate.mock.calls
|
|
734
|
+
.map((call) => call[0][0]?.status)
|
|
735
|
+
.filter(Boolean);
|
|
736
|
+
expect(statusUpdates).not.toContain('awaiting_approval');
|
|
737
|
+
expect(statusUpdates).toEqual([
|
|
738
|
+
'validating',
|
|
739
|
+
'scheduled',
|
|
740
|
+
'executing',
|
|
741
|
+
'success',
|
|
742
|
+
]);
|
|
743
|
+
// 3. The final callback indicates the tool call was successful.
|
|
744
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
745
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
746
|
+
.calls[0][0];
|
|
747
|
+
expect(completedCalls).toHaveLength(1);
|
|
748
|
+
const completedCall = completedCalls[0];
|
|
749
|
+
expect(completedCall.status).toBe('success');
|
|
750
|
+
if (completedCall.status === 'success') {
|
|
751
|
+
expect(completedCall.response.resultDisplay).toBe('Tool executed');
|
|
752
|
+
}
|
|
753
|
+
});
|
|
566
754
|
it('should handle two synchronous calls to schedule', async () => {
|
|
567
755
|
const mockTool = new MockTool();
|
|
568
756
|
const declarativeTool = mockTool;
|
|
569
|
-
const
|
|
757
|
+
const mockToolRegistry = {
|
|
570
758
|
getTool: () => declarativeTool,
|
|
571
759
|
getToolByName: () => declarativeTool,
|
|
572
760
|
getFunctionDeclarations: () => [],
|
|
@@ -586,14 +774,15 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
586
774
|
getUsageStatisticsEnabled: () => true,
|
|
587
775
|
getDebugMode: () => false,
|
|
588
776
|
getApprovalMode: () => ApprovalMode.YOLO,
|
|
777
|
+
getAllowedTools: () => [],
|
|
589
778
|
getContentGeneratorConfig: () => ({
|
|
590
779
|
model: 'test-model',
|
|
591
780
|
authType: 'oauth-personal',
|
|
592
781
|
}),
|
|
782
|
+
getToolRegistry: () => mockToolRegistry,
|
|
593
783
|
};
|
|
594
784
|
const scheduler = new CoreToolScheduler({
|
|
595
785
|
config: mockConfig,
|
|
596
|
-
toolRegistry: Promise.resolve(toolRegistry),
|
|
597
786
|
onAllToolCallsComplete,
|
|
598
787
|
onToolCallsUpdate,
|
|
599
788
|
getPreferredEditor: () => 'vscode',
|
|
@@ -626,5 +815,109 @@ describe('CoreToolScheduler request queueing', () => {
|
|
|
626
815
|
// Ensure completion callbacks were called twice.
|
|
627
816
|
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
628
817
|
});
|
|
818
|
+
it('should auto-approve remaining tool calls when first tool call is approved with ProceedAlways', async () => {
|
|
819
|
+
let approvalMode = ApprovalMode.DEFAULT;
|
|
820
|
+
const mockConfig = {
|
|
821
|
+
getSessionId: () => 'test-session-id',
|
|
822
|
+
getUsageStatisticsEnabled: () => true,
|
|
823
|
+
getDebugMode: () => false,
|
|
824
|
+
getApprovalMode: () => approvalMode,
|
|
825
|
+
getAllowedTools: () => [],
|
|
826
|
+
setApprovalMode: (mode) => {
|
|
827
|
+
approvalMode = mode;
|
|
828
|
+
},
|
|
829
|
+
};
|
|
830
|
+
const testTool = new TestApprovalTool(mockConfig);
|
|
831
|
+
const toolRegistry = {
|
|
832
|
+
getTool: () => testTool,
|
|
833
|
+
getFunctionDeclarations: () => [],
|
|
834
|
+
getFunctionDeclarationsFiltered: () => [],
|
|
835
|
+
registerTool: () => { },
|
|
836
|
+
discoverAllTools: async () => { },
|
|
837
|
+
discoverMcpTools: async () => { },
|
|
838
|
+
discoverToolsForServer: async () => { },
|
|
839
|
+
removeMcpToolsByServer: () => { },
|
|
840
|
+
getAllTools: () => [],
|
|
841
|
+
getToolsByServer: () => [],
|
|
842
|
+
tools: new Map(),
|
|
843
|
+
config: mockConfig,
|
|
844
|
+
mcpClientManager: undefined,
|
|
845
|
+
getToolByName: () => testTool,
|
|
846
|
+
getToolByDisplayName: () => testTool,
|
|
847
|
+
getTools: () => [],
|
|
848
|
+
discoverTools: async () => { },
|
|
849
|
+
discovery: {},
|
|
850
|
+
};
|
|
851
|
+
mockConfig.getToolRegistry = () => toolRegistry;
|
|
852
|
+
const onAllToolCallsComplete = vi.fn();
|
|
853
|
+
const onToolCallsUpdate = vi.fn();
|
|
854
|
+
const pendingConfirmations = [];
|
|
855
|
+
const scheduler = new CoreToolScheduler({
|
|
856
|
+
config: mockConfig,
|
|
857
|
+
onAllToolCallsComplete,
|
|
858
|
+
onToolCallsUpdate: (toolCalls) => {
|
|
859
|
+
onToolCallsUpdate(toolCalls);
|
|
860
|
+
// Capture confirmation handlers for awaiting_approval tools
|
|
861
|
+
toolCalls.forEach((call) => {
|
|
862
|
+
if (call.status === 'awaiting_approval') {
|
|
863
|
+
const waitingCall = call;
|
|
864
|
+
if (waitingCall.confirmationDetails?.onConfirm) {
|
|
865
|
+
const originalHandler = pendingConfirmations.find((h) => h === waitingCall.confirmationDetails.onConfirm);
|
|
866
|
+
if (!originalHandler) {
|
|
867
|
+
pendingConfirmations.push(waitingCall.confirmationDetails.onConfirm);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
},
|
|
873
|
+
getPreferredEditor: () => 'vscode',
|
|
874
|
+
onEditorClose: vi.fn(),
|
|
875
|
+
});
|
|
876
|
+
const abortController = new AbortController();
|
|
877
|
+
// Schedule multiple tools that need confirmation
|
|
878
|
+
const requests = [
|
|
879
|
+
{
|
|
880
|
+
callId: '1',
|
|
881
|
+
name: 'testApprovalTool',
|
|
882
|
+
args: { id: 'first' },
|
|
883
|
+
isClientInitiated: false,
|
|
884
|
+
prompt_id: 'prompt-1',
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
callId: '2',
|
|
888
|
+
name: 'testApprovalTool',
|
|
889
|
+
args: { id: 'second' },
|
|
890
|
+
isClientInitiated: false,
|
|
891
|
+
prompt_id: 'prompt-2',
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
callId: '3',
|
|
895
|
+
name: 'testApprovalTool',
|
|
896
|
+
args: { id: 'third' },
|
|
897
|
+
isClientInitiated: false,
|
|
898
|
+
prompt_id: 'prompt-3',
|
|
899
|
+
},
|
|
900
|
+
];
|
|
901
|
+
await scheduler.schedule(requests, abortController.signal);
|
|
902
|
+
// Wait for all tools to be awaiting approval
|
|
903
|
+
await vi.waitFor(() => {
|
|
904
|
+
const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
|
|
905
|
+
expect(calls?.length).toBe(3);
|
|
906
|
+
expect(calls?.every((call) => call.status === 'awaiting_approval')).toBe(true);
|
|
907
|
+
});
|
|
908
|
+
expect(pendingConfirmations.length).toBe(3);
|
|
909
|
+
// Approve the first tool with ProceedAlways
|
|
910
|
+
const firstConfirmation = pendingConfirmations[0];
|
|
911
|
+
firstConfirmation(ToolConfirmationOutcome.ProceedAlways);
|
|
912
|
+
// Wait for all tools to be completed
|
|
913
|
+
await vi.waitFor(() => {
|
|
914
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
915
|
+
const completedCalls = onAllToolCallsComplete.mock.calls.at(-1)?.[0];
|
|
916
|
+
expect(completedCalls?.length).toBe(3);
|
|
917
|
+
expect(completedCalls?.every((call) => call.status === 'success')).toBe(true);
|
|
918
|
+
});
|
|
919
|
+
// Verify approval mode was changed
|
|
920
|
+
expect(approvalMode).toBe(ApprovalMode.AUTO_EDIT);
|
|
921
|
+
});
|
|
629
922
|
});
|
|
630
923
|
//# sourceMappingURL=coreToolScheduler.test.js.map
|