@google/gemini-cli-core 0.0.1
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/LICENSE +202 -0
- package/README.md +320 -0
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/src/__mocks__/fs/promises.d.ts +11 -0
- package/dist/src/__mocks__/fs/promises.js +17 -0
- package/dist/src/__mocks__/fs/promises.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +12 -0
- package/dist/src/code_assist/codeAssist.js +31 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +74 -0
- package/dist/src/code_assist/converter.js +160 -0
- package/dist/src/code_assist/converter.js.map +1 -0
- package/dist/src/code_assist/converter.test.d.ts +6 -0
- package/dist/src/code_assist/converter.test.js +372 -0
- package/dist/src/code_assist/converter.test.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +109 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.test.d.ts +6 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js +136 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +22 -0
- package/dist/src/code_assist/oauth2.js +416 -0
- package/dist/src/code_assist/oauth2.js.map +1 -0
- package/dist/src/code_assist/oauth2.test.d.ts +6 -0
- package/dist/src/code_assist/oauth2.test.js +817 -0
- package/dist/src/code_assist/oauth2.test.js.map +1 -0
- package/dist/src/code_assist/server.d.ts +37 -0
- package/dist/src/code_assist/server.js +148 -0
- package/dist/src/code_assist/server.js.map +1 -0
- package/dist/src/code_assist/server.test.d.ts +6 -0
- package/dist/src/code_assist/server.test.js +159 -0
- package/dist/src/code_assist/server.test.js.map +1 -0
- package/dist/src/code_assist/setup.d.ts +20 -0
- package/dist/src/code_assist/setup.js +101 -0
- package/dist/src/code_assist/setup.js.map +1 -0
- package/dist/src/code_assist/setup.test.d.ts +6 -0
- package/dist/src/code_assist/setup.test.js +171 -0
- package/dist/src/code_assist/setup.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +163 -0
- package/dist/src/code_assist/types.js +46 -0
- package/dist/src/code_assist/types.js.map +1 -0
- package/dist/src/config/config.d.ts +378 -0
- package/dist/src/config/config.js +765 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/config.test.d.ts +6 -0
- package/dist/src/config/config.test.js +712 -0
- package/dist/src/config/config.test.js.map +1 -0
- package/dist/src/config/flashFallback.test.d.ts +6 -0
- package/dist/src/config/flashFallback.test.js +87 -0
- package/dist/src/config/flashFallback.test.js.map +1 -0
- package/dist/src/config/models.d.ts +25 -0
- package/dist/src/config/models.js +39 -0
- package/dist/src/config/models.js.map +1 -0
- package/dist/src/config/models.test.d.ts +6 -0
- package/dist/src/config/models.test.js +55 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +34 -0
- package/dist/src/config/storage.js +95 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +6 -0
- package/dist/src/config/storage.test.js +47 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +7 -0
- package/dist/src/confirmation-bus/index.js +8 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +17 -0
- package/dist/src/confirmation-bus/message-bus.js +81 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.test.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.test.js +164 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +38 -0
- package/dist/src/confirmation-bus/types.js +15 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +46 -0
- package/dist/src/core/baseLlmClient.js +112 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/baseLlmClient.test.d.ts +6 -0
- package/dist/src/core/baseLlmClient.test.js +253 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +60 -0
- package/dist/src/core/client.js +602 -0
- package/dist/src/core/client.js.map +1 -0
- package/dist/src/core/client.test.d.ts +6 -0
- package/dist/src/core/client.test.js +1758 -0
- package/dist/src/core/client.test.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +32 -0
- package/dist/src/core/contentGenerator.js +76 -0
- package/dist/src/core/contentGenerator.js.map +1 -0
- package/dist/src/core/contentGenerator.test.d.ts +6 -0
- package/dist/src/core/contentGenerator.test.js +122 -0
- package/dist/src/core/contentGenerator.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +131 -0
- package/dist/src/core/coreToolScheduler.js +706 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -0
- package/dist/src/core/coreToolScheduler.test.d.ts +6 -0
- package/dist/src/core/coreToolScheduler.test.js +1151 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +128 -0
- package/dist/src/core/geminiChat.js +537 -0
- package/dist/src/core/geminiChat.js.map +1 -0
- package/dist/src/core/geminiChat.test.d.ts +6 -0
- package/dist/src/core/geminiChat.test.js +1163 -0
- package/dist/src/core/geminiChat.test.js.map +1 -0
- package/dist/src/core/geminiRequest.d.ts +13 -0
- package/dist/src/core/geminiRequest.js +11 -0
- package/dist/src/core/geminiRequest.js.map +1 -0
- package/dist/src/core/logger.d.ts +60 -0
- package/dist/src/core/logger.js +360 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/logger.test.d.ts +6 -0
- package/dist/src/core/logger.test.js +534 -0
- package/dist/src/core/logger.test.js.map +1 -0
- package/dist/src/core/loggingContentGenerator.d.ts +25 -0
- package/dist/src/core/loggingContentGenerator.js +94 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +10 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +24 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +6 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js +294 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +17 -0
- package/dist/src/core/prompts.js +380 -0
- package/dist/src/core/prompts.js.map +1 -0
- package/dist/src/core/prompts.test.d.ts +6 -0
- package/dist/src/core/prompts.test.js +343 -0
- package/dist/src/core/prompts.test.js.map +1 -0
- package/dist/src/core/subagent.d.ts +236 -0
- package/dist/src/core/subagent.js +482 -0
- package/dist/src/core/subagent.js.map +1 -0
- package/dist/src/core/subagent.test.d.ts +6 -0
- package/dist/src/core/subagent.test.js +530 -0
- package/dist/src/core/subagent.test.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +10 -0
- package/dist/src/core/tokenLimits.js +28 -0
- package/dist/src/core/tokenLimits.js.map +1 -0
- package/dist/src/core/turn.d.ts +141 -0
- package/dist/src/core/turn.js +188 -0
- package/dist/src/core/turn.js.map +1 -0
- package/dist/src/core/turn.test.d.ts +6 -0
- package/dist/src/core/turn.test.js +628 -0
- package/dist/src/core/turn.test.js.map +1 -0
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +51 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/handler.test.d.ts +6 -0
- package/dist/src/fallback/handler.test.js +130 -0
- package/dist/src/fallback/handler.test.js.map +1 -0
- package/dist/src/fallback/types.d.ts +14 -0
- package/dist/src/fallback/types.js +7 -0
- package/dist/src/fallback/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +7 -0
- package/dist/src/generated/git-commit.js +10 -0
- package/dist/src/generated/git-commit.js.map +1 -0
- package/dist/src/ide/constants.d.ts +9 -0
- package/dist/src/ide/constants.js +10 -0
- package/dist/src/ide/constants.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +53 -0
- package/dist/src/ide/detect-ide.js +58 -0
- package/dist/src/ide/detect-ide.js.map +1 -0
- package/dist/src/ide/detect-ide.test.d.ts +6 -0
- package/dist/src/ide/detect-ide.test.js +69 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +109 -0
- package/dist/src/ide/ide-client.js +640 -0
- package/dist/src/ide/ide-client.js.map +1 -0
- package/dist/src/ide/ide-client.test.d.ts +6 -0
- package/dist/src/ide/ide-client.test.js +388 -0
- package/dist/src/ide/ide-client.test.js.map +1 -0
- package/dist/src/ide/ide-installer.d.ts +14 -0
- package/dist/src/ide/ide-installer.js +111 -0
- package/dist/src/ide/ide-installer.js.map +1 -0
- package/dist/src/ide/ide-installer.test.d.ts +6 -0
- package/dist/src/ide/ide-installer.test.js +131 -0
- package/dist/src/ide/ide-installer.test.js.map +1 -0
- package/dist/src/ide/ideContext.d.ts +44 -0
- package/dist/src/ide/ideContext.js +101 -0
- package/dist/src/ide/ideContext.js.map +1 -0
- package/dist/src/ide/ideContext.test.d.ts +6 -0
- package/dist/src/ide/ideContext.test.js +393 -0
- package/dist/src/ide/ideContext.test.js.map +1 -0
- package/dist/src/ide/process-utils.d.ts +21 -0
- package/dist/src/ide/process-utils.js +171 -0
- package/dist/src/ide/process-utils.js.map +1 -0
- package/dist/src/ide/process-utils.test.d.ts +6 -0
- package/dist/src/ide/process-utils.test.js +158 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/ide/types.d.ts +486 -0
- package/dist/src/ide/types.js +138 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +87 -0
- package/dist/src/index.js +97 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.test.d.ts +6 -0
- package/dist/src/index.test.js +12 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +23 -0
- package/dist/src/mcp/google-auth-provider.js +72 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.test.d.ts +6 -0
- package/dist/src/mcp/google-auth-provider.test.js +89 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +149 -0
- package/dist/src/mcp/oauth-provider.js +608 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-provider.test.d.ts +6 -0
- package/dist/src/mcp/oauth-provider.test.js +711 -0
- package/dist/src/mcp/oauth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.d.ts +65 -0
- package/dist/src/mcp/oauth-token-storage.js +180 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/oauth-token-storage.test.js +299 -0
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -0
- package/dist/src/mcp/oauth-utils.d.ts +119 -0
- package/dist/src/mcp/oauth-utils.js +235 -0
- package/dist/src/mcp/oauth-utils.js.map +1 -0
- package/dist/src/mcp/oauth-utils.test.d.ts +6 -0
- package/dist/src/mcp/oauth-utils.test.js +199 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -0
- 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/index.d.ts +11 -0
- package/dist/src/mcp/token-storage/index.js +12 -0
- package/dist/src/mcp/token-storage/index.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/mocks/msw.d.ts +6 -0
- package/dist/src/mocks/msw.js +8 -0
- package/dist/src/mocks/msw.js.map +1 -0
- package/dist/src/output/json-formatter.d.ts +11 -0
- package/dist/src/output/json-formatter.js +30 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/json-formatter.test.d.ts +6 -0
- package/dist/src/output/json-formatter.test.js +266 -0
- package/dist/src/output/json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +20 -0
- package/dist/src/output/types.js +11 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/index.d.ts +7 -0
- package/dist/src/policy/index.js +8 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policy-engine.d.ts +30 -0
- package/dist/src/policy/policy-engine.js +83 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/policy-engine.test.d.ts +6 -0
- package/dist/src/policy/policy-engine.test.js +470 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -0
- package/dist/src/policy/stable-stringify.d.ts +58 -0
- package/dist/src/policy/stable-stringify.js +122 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- package/dist/src/policy/types.d.ts +47 -0
- package/dist/src/policy/types.js +12 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +8 -0
- package/dist/src/prompts/mcp-prompts.js +13 -0
- package/dist/src/prompts/mcp-prompts.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +34 -0
- package/dist/src/prompts/prompt-registry.js +63 -0
- package/dist/src/prompts/prompt-registry.js.map +1 -0
- package/dist/src/routing/modelRouterService.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +70 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/modelRouterService.test.d.ts +6 -0
- package/dist/src/routing/modelRouterService.test.js +98 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +62 -0
- package/dist/src/routing/routingStrategy.js +7 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/classifierStrategy.js +173 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js +192 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
- package/dist/src/routing/strategies/compositeStrategy.js +67 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js +123 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/defaultStrategy.js +20 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js +26 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +25 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js +55 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
- package/dist/src/routing/strategies/overrideStrategy.js +28 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js +42 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +144 -0
- package/dist/src/services/chatRecordingService.js +330 -0
- package/dist/src/services/chatRecordingService.js.map +1 -0
- package/dist/src/services/chatRecordingService.test.d.ts +6 -0
- package/dist/src/services/chatRecordingService.test.js +332 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.d.ts +45 -0
- package/dist/src/services/fileDiscoveryService.js +105 -0
- package/dist/src/services/fileDiscoveryService.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.test.d.ts +6 -0
- package/dist/src/services/fileDiscoveryService.test.js +143 -0
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +31 -0
- package/dist/src/services/fileSystemService.js +18 -0
- package/dist/src/services/fileSystemService.js.map +1 -0
- package/dist/src/services/fileSystemService.test.d.ts +6 -0
- package/dist/src/services/fileSystemService.test.js +41 -0
- package/dist/src/services/fileSystemService.test.js.map +1 -0
- package/dist/src/services/gitService.d.ts +23 -0
- package/dist/src/services/gitService.js +107 -0
- package/dist/src/services/gitService.js.map +1 -0
- package/dist/src/services/gitService.test.d.ts +6 -0
- package/dist/src/services/gitService.test.js +202 -0
- package/dist/src/services/gitService.test.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +103 -0
- package/dist/src/services/loopDetectionService.js +379 -0
- package/dist/src/services/loopDetectionService.js.map +1 -0
- package/dist/src/services/loopDetectionService.test.d.ts +6 -0
- package/dist/src/services/loopDetectionService.test.js +587 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +100 -0
- package/dist/src/services/shellExecutionService.js +466 -0
- package/dist/src/services/shellExecutionService.js.map +1 -0
- package/dist/src/services/shellExecutionService.test.d.ts +6 -0
- package/dist/src/services/shellExecutionService.test.js +614 -0
- package/dist/src/services/shellExecutionService.test.js.map +1 -0
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +135 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +892 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +17 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +507 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +107 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +275 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +40 -0
- package/dist/src/telemetry/constants.js +41 -0
- package/dist/src/telemetry/constants.js.map +1 -0
- package/dist/src/telemetry/file-exporters.d.ts +29 -0
- package/dist/src/telemetry/file-exporters.js +62 -0
- package/dist/src/telemetry/file-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.d.ts +34 -0
- package/dist/src/telemetry/gcp-exporters.js +117 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/gcp-exporters.test.js +318 -0
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +6 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js +152 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +26 -0
- package/dist/src/telemetry/index.js +26 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/integration.test.circular.d.ts +6 -0
- package/dist/src/telemetry/integration.test.circular.js +54 -0
- package/dist/src/telemetry/integration.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +33 -0
- package/dist/src/telemetry/loggers.js +536 -0
- package/dist/src/telemetry/loggers.js.map +1 -0
- package/dist/src/telemetry/loggers.test.circular.d.ts +6 -0
- package/dist/src/telemetry/loggers.test.circular.js +107 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.test.d.ts +6 -0
- package/dist/src/telemetry/loggers.test.js +887 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +37 -0
- package/dist/src/telemetry/metrics.js +231 -0
- package/dist/src/telemetry/metrics.js.map +1 -0
- package/dist/src/telemetry/metrics.test.d.ts +6 -0
- package/dist/src/telemetry/metrics.test.js +264 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.d.ts +48 -0
- package/dist/src/telemetry/rate-limiter.js +100 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.test.d.ts +6 -0
- package/dist/src/telemetry/rate-limiter.test.js +207 -0
- package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +9 -0
- package/dist/src/telemetry/sdk.js +178 -0
- package/dist/src/telemetry/sdk.js.map +1 -0
- package/dist/src/telemetry/sdk.test.d.ts +6 -0
- package/dist/src/telemetry/sdk.test.js +177 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -0
- 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/telemetry.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry.test.js +50 -0
- package/dist/src/telemetry/telemetry.test.js.map +1 -0
- package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
- package/dist/src/telemetry/tool-call-decision.js +29 -0
- package/dist/src/telemetry/tool-call-decision.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +284 -0
- package/dist/src/telemetry/types.js +487 -0
- package/dist/src/telemetry/types.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.d.ts +75 -0
- package/dist/src/telemetry/uiTelemetry.js +152 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.test.d.ts +6 -0
- package/dist/src/telemetry/uiTelemetry.test.js +558 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
- package/dist/src/test-utils/config.d.ts +17 -0
- package/dist/src/test-utils/config.js +32 -0
- package/dist/src/test-utils/config.js.map +1 -0
- 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 +13 -0
- package/dist/src/test-utils/mockWorkspaceContext.js +24 -0
- package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
- package/dist/src/test-utils/tools.d.ts +45 -0
- package/dist/src/test-utils/tools.js +105 -0
- package/dist/src/test-utils/tools.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +9 -0
- package/dist/src/tools/diffOptions.js +46 -0
- package/dist/src/tools/diffOptions.js.map +1 -0
- package/dist/src/tools/diffOptions.test.d.ts +6 -0
- package/dist/src/tools/diffOptions.test.js +155 -0
- package/dist/src/tools/diffOptions.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +56 -0
- package/dist/src/tools/edit.js +414 -0
- package/dist/src/tools/edit.js.map +1 -0
- package/dist/src/tools/edit.test.d.ts +6 -0
- package/dist/src/tools/edit.test.js +824 -0
- package/dist/src/tools/edit.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +56 -0
- package/dist/src/tools/glob.js +243 -0
- package/dist/src/tools/glob.js.map +1 -0
- package/dist/src/tools/glob.test.d.ts +6 -0
- package/dist/src/tools/glob.test.js +426 -0
- package/dist/src/tools/glob.test.js.map +1 -0
- package/dist/src/tools/grep.d.ts +47 -0
- package/dist/src/tools/grep.js +517 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/grep.test.d.ts +6 -0
- package/dist/src/tools/grep.test.js +295 -0
- package/dist/src/tools/grep.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +68 -0
- package/dist/src/tools/ls.js +214 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/ls.test.d.ts +6 -0
- package/dist/src/tools/ls.test.js +249 -0
- package/dist/src/tools/ls.test.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.d.ts +40 -0
- package/dist/src/tools/mcp-client-manager.js +83 -0
- package/dist/src/tools/mcp-client-manager.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.test.d.ts +6 -0
- package/dist/src/tools/mcp-client-manager.test.js +58 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +199 -0
- package/dist/src/tools/mcp-client.js +1000 -0
- package/dist/src/tools/mcp-client.js.map +1 -0
- package/dist/src/tools/mcp-client.test.d.ts +6 -0
- package/dist/src/tools/mcp-client.test.js +454 -0
- package/dist/src/tools/mcp-client.test.js.map +1 -0
- package/dist/src/tools/mcp-tool.d.ts +24 -0
- package/dist/src/tools/mcp-tool.js +240 -0
- package/dist/src/tools/mcp-tool.js.map +1 -0
- package/dist/src/tools/mcp-tool.test.d.ts +6 -0
- package/dist/src/tools/mcp-tool.test.js +597 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +40 -0
- package/dist/src/tools/memoryTool.js +268 -0
- package/dist/src/tools/memoryTool.js.map +1 -0
- package/dist/src/tools/memoryTool.test.d.ts +6 -0
- package/dist/src/tools/memoryTool.test.js +298 -0
- package/dist/src/tools/memoryTool.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +32 -0
- package/dist/src/tools/modifiable-tool.js +88 -0
- package/dist/src/tools/modifiable-tool.js.map +1 -0
- package/dist/src/tools/modifiable-tool.test.d.ts +6 -0
- package/dist/src/tools/modifiable-tool.test.js +193 -0
- package/dist/src/tools/modifiable-tool.test.js.map +1 -0
- package/dist/src/tools/read-file.d.ts +35 -0
- package/dist/src/tools/read-file.js +132 -0
- package/dist/src/tools/read-file.js.map +1 -0
- package/dist/src/tools/read-file.test.d.ts +6 -0
- package/dist/src/tools/read-file.test.js +340 -0
- package/dist/src/tools/read-file.test.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +60 -0
- package/dist/src/tools/read-many-files.js +382 -0
- package/dist/src/tools/read-many-files.js.map +1 -0
- package/dist/src/tools/read-many-files.test.d.ts +6 -0
- package/dist/src/tools/read-many-files.test.js +565 -0
- package/dist/src/tools/read-many-files.test.js.map +1 -0
- package/dist/src/tools/ripGrep.d.ts +55 -0
- package/dist/src/tools/ripGrep.js +393 -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 +976 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +32 -0
- package/dist/src/tools/shell.js +316 -0
- package/dist/src/tools/shell.js.map +1 -0
- package/dist/src/tools/shell.test.d.ts +6 -0
- package/dist/src/tools/shell.test.js +301 -0
- package/dist/src/tools/shell.test.js.map +1 -0
- package/dist/src/tools/smart-edit.d.ts +72 -0
- package/dist/src/tools/smart-edit.js +594 -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 +419 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +43 -0
- package/dist/src/tools/tool-error.js +58 -0
- package/dist/src/tools/tool-error.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +87 -0
- package/dist/src/tools/tool-registry.js +370 -0
- package/dist/src/tools/tool-registry.js.map +1 -0
- package/dist/src/tools/tool-registry.test.d.ts +6 -0
- package/dist/src/tools/tool-registry.test.js +332 -0
- package/dist/src/tools/tool-registry.test.js.map +1 -0
- package/dist/src/tools/tools.d.ts +281 -0
- package/dist/src/tools/tools.js +257 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/tools.test.d.ts +6 -0
- package/dist/src/tools/tools.test.js +205 -0
- package/dist/src/tools/tools.test.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +27 -0
- package/dist/src/tools/web-fetch.js +244 -0
- package/dist/src/tools/web-fetch.js.map +1 -0
- package/dist/src/tools/web-fetch.test.d.ts +6 -0
- package/dist/src/tools/web-fetch.test.js +114 -0
- package/dist/src/tools/web-fetch.test.js.map +1 -0
- package/dist/src/tools/web-search.d.ts +49 -0
- package/dist/src/tools/web-search.js +139 -0
- package/dist/src/tools/web-search.js.map +1 -0
- package/dist/src/tools/web-search.test.d.ts +6 -0
- package/dist/src/tools/web-search.test.js +207 -0
- package/dist/src/tools/web-search.test.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +52 -0
- package/dist/src/tools/write-file.js +309 -0
- package/dist/src/tools/write-file.js.map +1 -0
- package/dist/src/tools/write-file.test.d.ts +6 -0
- package/dist/src/tools/write-file.test.js +611 -0
- package/dist/src/tools/write-file.test.js.map +1 -0
- package/dist/src/utils/LruCache.d.ts +13 -0
- package/dist/src/utils/LruCache.js +38 -0
- package/dist/src/utils/LruCache.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +24 -0
- package/dist/src/utils/bfsFileSearch.js +95 -0
- package/dist/src/utils/bfsFileSearch.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.test.d.ts +6 -0
- package/dist/src/utils/bfsFileSearch.test.js +163 -0
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
- package/dist/src/utils/browser.d.ts +13 -0
- package/dist/src/utils/browser.js +50 -0
- package/dist/src/utils/browser.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +54 -0
- package/dist/src/utils/editCorrector.js +588 -0
- package/dist/src/utils/editCorrector.js.map +1 -0
- package/dist/src/utils/editCorrector.test.d.ts +6 -0
- package/dist/src/utils/editCorrector.test.js +515 -0
- package/dist/src/utils/editCorrector.test.js.map +1 -0
- package/dist/src/utils/editor.d.ts +28 -0
- package/dist/src/utils/editor.js +173 -0
- package/dist/src/utils/editor.js.map +1 -0
- package/dist/src/utils/editor.test.d.ts +6 -0
- package/dist/src/utils/editor.test.js +431 -0
- package/dist/src/utils/editor.test.js.map +1 -0
- package/dist/src/utils/environmentContext.d.ts +21 -0
- package/dist/src/utils/environmentContext.js +90 -0
- package/dist/src/utils/environmentContext.js.map +1 -0
- package/dist/src/utils/environmentContext.test.d.ts +6 -0
- package/dist/src/utils/environmentContext.test.js +140 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -0
- package/dist/src/utils/errorParsing.d.ts +8 -0
- package/dist/src/utils/errorParsing.js +93 -0
- package/dist/src/utils/errorParsing.js.map +1 -0
- package/dist/src/utils/errorParsing.test.d.ts +6 -0
- package/dist/src/utils/errorParsing.test.js +172 -0
- package/dist/src/utils/errorParsing.test.js.map +1 -0
- package/dist/src/utils/errorReporting.d.ts +14 -0
- package/dist/src/utils/errorReporting.js +88 -0
- package/dist/src/utils/errorReporting.js.map +1 -0
- package/dist/src/utils/errorReporting.test.d.ts +6 -0
- package/dist/src/utils/errorReporting.test.js +130 -0
- package/dist/src/utils/errorReporting.test.js.map +1 -0
- package/dist/src/utils/errors.d.ts +39 -0
- package/dist/src/utils/errors.js +96 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +11 -0
- package/dist/src/utils/fetch.js +51 -0
- package/dist/src/utils/fetch.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +69 -0
- package/dist/src/utils/fileUtils.js +405 -0
- package/dist/src/utils/fileUtils.js.map +1 -0
- package/dist/src/utils/fileUtils.test.d.ts +6 -0
- package/dist/src/utils/fileUtils.test.js +682 -0
- package/dist/src/utils/fileUtils.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.d.ts +25 -0
- package/dist/src/utils/filesearch/crawlCache.js +57 -0
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.test.d.ts +6 -0
- package/dist/src/utils/filesearch/crawlCache.test.js +103 -0
- package/dist/src/utils/filesearch/crawlCache.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.d.ts +15 -0
- package/dist/src/utils/filesearch/crawler.js +50 -0
- package/dist/src/utils/filesearch/crawler.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.test.d.ts +6 -0
- package/dist/src/utils/filesearch/crawler.test.js +468 -0
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.d.ts +38 -0
- package/dist/src/utils/filesearch/fileSearch.js +191 -0
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.test.d.ts +6 -0
- package/dist/src/utils/filesearch/fileSearch.test.js +642 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.d.ts +42 -0
- package/dist/src/utils/filesearch/ignore.js +106 -0
- package/dist/src/utils/filesearch/ignore.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.test.d.ts +6 -0
- package/dist/src/utils/filesearch/ignore.test.js +144 -0
- package/dist/src/utils/filesearch/ignore.test.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.d.ts +33 -0
- package/dist/src/utils/filesearch/result-cache.js +59 -0
- package/dist/src/utils/filesearch/result-cache.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.test.d.ts +6 -0
- package/dist/src/utils/filesearch/result-cache.test.js +46 -0
- package/dist/src/utils/filesearch/result-cache.test.js.map +1 -0
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.test.js +122 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +6 -0
- package/dist/src/utils/formatters.js +16 -0
- package/dist/src/utils/formatters.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.d.ts +18 -0
- package/dist/src/utils/geminiIgnoreParser.js +61 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/geminiIgnoreParser.test.js +50 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +13 -0
- package/dist/src/utils/generateContentResponseUtilities.js +80 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.test.d.ts +6 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js +235 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +31 -0
- package/dist/src/utils/getFolderStructure.js +246 -0
- package/dist/src/utils/getFolderStructure.js.map +1 -0
- package/dist/src/utils/getFolderStructure.test.d.ts +6 -0
- package/dist/src/utils/getFolderStructure.test.js +282 -0
- package/dist/src/utils/getFolderStructure.test.js.map +1 -0
- 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 +16 -0
- package/dist/src/utils/gitIgnoreParser.js +152 -0
- package/dist/src/utils/gitIgnoreParser.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/gitIgnoreParser.test.js +185 -0
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +17 -0
- package/dist/src/utils/gitUtils.js +61 -0
- package/dist/src/utils/gitUtils.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 +26 -0
- package/dist/src/utils/llm-edit-fixer.js +121 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.test.d.ts +6 -0
- package/dist/src/utils/llm-edit-fixer.test.js +105 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +16 -0
- package/dist/src/utils/memoryDiscovery.js +254 -0
- package/dist/src/utils/memoryDiscovery.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.test.d.ts +6 -0
- package/dist/src/utils/memoryDiscovery.test.js +244 -0
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.d.ts +42 -0
- package/dist/src/utils/memoryImportProcessor.js +296 -0
- package/dist/src/utils/memoryImportProcessor.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.test.d.ts +6 -0
- package/dist/src/utils/memoryImportProcessor.test.js +573 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -0
- package/dist/src/utils/messageInspectors.d.ts +8 -0
- package/dist/src/utils/messageInspectors.js +16 -0
- package/dist/src/utils/messageInspectors.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.d.ts +12 -0
- package/dist/src/utils/nextSpeakerChecker.js +97 -0
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.test.d.ts +6 -0
- package/dist/src/utils/nextSpeakerChecker.test.js +179 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
- package/dist/src/utils/partUtils.d.ts +35 -0
- package/dist/src/utils/partUtils.js +133 -0
- package/dist/src/utils/partUtils.js.map +1 -0
- package/dist/src/utils/partUtils.test.d.ts +6 -0
- package/dist/src/utils/partUtils.test.js +241 -0
- package/dist/src/utils/partUtils.test.js.map +1 -0
- 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 +58 -0
- package/dist/src/utils/paths.js +159 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/paths.test.d.ts +6 -0
- package/dist/src/utils/paths.test.js +225 -0
- package/dist/src/utils/paths.test.js.map +1 -0
- package/dist/src/utils/promptIdContext.d.ts +7 -0
- package/dist/src/utils/promptIdContext.js +8 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +18 -0
- package/dist/src/utils/quotaErrorDetection.js +65 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -0
- package/dist/src/utils/retry.d.ts +30 -0
- package/dist/src/utils/retry.js +276 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/utils/retry.test.d.ts +6 -0
- package/dist/src/utils/retry.test.js +325 -0
- package/dist/src/utils/retry.test.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.d.ts +13 -0
- package/dist/src/utils/safeJsonStringify.js +25 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.test.d.ts +6 -0
- package/dist/src/utils/safeJsonStringify.test.js +61 -0
- package/dist/src/utils/safeJsonStringify.test.js.map +1 -0
- package/dist/src/utils/schemaValidator.d.ts +15 -0
- package/dist/src/utils/schemaValidator.js +38 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.d.ts +23 -0
- package/dist/src/utils/secure-browser-launcher.js +165 -0
- package/dist/src/utils/secure-browser-launcher.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.test.d.ts +6 -0
- package/dist/src/utils/secure-browser-launcher.test.js +149 -0
- package/dist/src/utils/secure-browser-launcher.test.js.map +1 -0
- package/dist/src/utils/session.d.ts +6 -0
- package/dist/src/utils/session.js +8 -0
- package/dist/src/utils/session.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +122 -0
- package/dist/src/utils/shell-utils.js +393 -0
- package/dist/src/utils/shell-utils.js.map +1 -0
- package/dist/src/utils/shell-utils.test.d.ts +6 -0
- package/dist/src/utils/shell-utils.test.js +332 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +25 -0
- package/dist/src/utils/summarizer.js +51 -0
- package/dist/src/utils/summarizer.js.map +1 -0
- package/dist/src/utils/summarizer.test.d.ts +6 -0
- package/dist/src/utils/summarizer.test.js +131 -0
- package/dist/src/utils/summarizer.test.js.map +1 -0
- package/dist/src/utils/systemEncoding.d.ts +40 -0
- package/dist/src/utils/systemEncoding.js +149 -0
- package/dist/src/utils/systemEncoding.js.map +1 -0
- package/dist/src/utils/systemEncoding.test.d.ts +6 -0
- package/dist/src/utils/systemEncoding.test.js +368 -0
- package/dist/src/utils/systemEncoding.test.js.map +1 -0
- package/dist/src/utils/terminalSerializer.d.ts +28 -0
- package/dist/src/utils/terminalSerializer.js +432 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/terminalSerializer.test.d.ts +6 -0
- package/dist/src/utils/terminalSerializer.test.js +176 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -0
- package/dist/src/utils/testUtils.d.ts +29 -0
- package/dist/src/utils/testUtils.js +70 -0
- package/dist/src/utils/testUtils.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +18 -0
- package/dist/src/utils/textUtils.js +42 -0
- package/dist/src/utils/textUtils.js.map +1 -0
- package/dist/src/utils/textUtils.test.d.ts +6 -0
- package/dist/src/utils/textUtils.test.js +59 -0
- package/dist/src/utils/textUtils.test.js.map +1 -0
- 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/userAccountManager.test.js +223 -0
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +66 -0
- package/dist/src/utils/workspaceContext.js +171 -0
- package/dist/src/utils/workspaceContext.js.map +1 -0
- package/dist/src/utils/workspaceContext.test.d.ts +6 -0
- package/dist/src/utils/workspaceContext.test.js +318 -0
- package/dist/src/utils/workspaceContext.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,1151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
7
|
+
import { CoreToolScheduler, convertToFunctionResponse, truncateAndSaveToFile, } from './coreToolScheduler.js';
|
|
8
|
+
import { DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES, DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD, BaseDeclarativeTool, BaseToolInvocation, ToolConfirmationOutcome, Kind, ApprovalMode, } from '../index.js';
|
|
9
|
+
import { MockModifiableTool, MockTool } from '../test-utils/tools.js';
|
|
10
|
+
import * as fs from 'node:fs/promises';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
vi.mock('fs/promises', () => ({
|
|
13
|
+
writeFile: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
class TestApprovalTool extends BaseDeclarativeTool {
|
|
16
|
+
config;
|
|
17
|
+
static Name = 'testApprovalTool';
|
|
18
|
+
constructor(config) {
|
|
19
|
+
super(TestApprovalTool.Name, 'TestApprovalTool', 'A tool for testing approval logic', Kind.Edit, {
|
|
20
|
+
properties: { id: { type: 'string' } },
|
|
21
|
+
required: ['id'],
|
|
22
|
+
type: 'object',
|
|
23
|
+
});
|
|
24
|
+
this.config = config;
|
|
25
|
+
}
|
|
26
|
+
createInvocation(params) {
|
|
27
|
+
return new TestApprovalInvocation(this.config, params);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class TestApprovalInvocation extends BaseToolInvocation {
|
|
31
|
+
config;
|
|
32
|
+
constructor(config, params) {
|
|
33
|
+
super(params);
|
|
34
|
+
this.config = config;
|
|
35
|
+
}
|
|
36
|
+
getDescription() {
|
|
37
|
+
return `Test tool ${this.params.id}`;
|
|
38
|
+
}
|
|
39
|
+
async shouldConfirmExecute() {
|
|
40
|
+
// Need confirmation unless approval mode is AUTO_EDIT
|
|
41
|
+
if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
type: 'edit',
|
|
46
|
+
title: `Confirm Test Tool ${this.params.id}`,
|
|
47
|
+
fileName: `test-${this.params.id}.txt`,
|
|
48
|
+
filePath: `/test-${this.params.id}.txt`,
|
|
49
|
+
fileDiff: 'Test diff content',
|
|
50
|
+
originalContent: '',
|
|
51
|
+
newContent: 'Test content',
|
|
52
|
+
onConfirm: async (outcome) => {
|
|
53
|
+
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
54
|
+
this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async execute() {
|
|
60
|
+
return {
|
|
61
|
+
llmContent: `Executed test tool ${this.params.id}`,
|
|
62
|
+
returnDisplay: `Executed test tool ${this.params.id}`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function waitForStatus(onToolCallsUpdate, status, timeout = 5000) {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
const check = () => {
|
|
70
|
+
if (Date.now() - startTime > timeout) {
|
|
71
|
+
const seenStatuses = onToolCallsUpdate.mock.calls
|
|
72
|
+
.flatMap((call) => call[0])
|
|
73
|
+
.map((toolCall) => toolCall.status);
|
|
74
|
+
reject(new Error(`Timed out waiting for status "${status}". Seen statuses: ${seenStatuses.join(', ')}`));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const foundCall = onToolCallsUpdate.mock.calls
|
|
78
|
+
.flatMap((call) => call[0])
|
|
79
|
+
.find((toolCall) => toolCall.status === status);
|
|
80
|
+
if (foundCall) {
|
|
81
|
+
resolve(foundCall);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
setTimeout(check, 10); // Check again in 10ms
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
check();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
describe('CoreToolScheduler', () => {
|
|
91
|
+
it('should cancel a tool call if the signal is aborted before confirmation', async () => {
|
|
92
|
+
const mockTool = new MockTool();
|
|
93
|
+
mockTool.shouldConfirm = true;
|
|
94
|
+
const declarativeTool = mockTool;
|
|
95
|
+
const mockToolRegistry = {
|
|
96
|
+
getTool: () => declarativeTool,
|
|
97
|
+
getFunctionDeclarations: () => [],
|
|
98
|
+
tools: new Map(),
|
|
99
|
+
discovery: {},
|
|
100
|
+
registerTool: () => { },
|
|
101
|
+
getToolByName: () => declarativeTool,
|
|
102
|
+
getToolByDisplayName: () => declarativeTool,
|
|
103
|
+
getTools: () => [],
|
|
104
|
+
discoverTools: async () => { },
|
|
105
|
+
getAllTools: () => [],
|
|
106
|
+
getToolsByServer: () => [],
|
|
107
|
+
};
|
|
108
|
+
const onAllToolCallsComplete = vi.fn();
|
|
109
|
+
const onToolCallsUpdate = vi.fn();
|
|
110
|
+
const mockConfig = {
|
|
111
|
+
getSessionId: () => 'test-session-id',
|
|
112
|
+
getUsageStatisticsEnabled: () => true,
|
|
113
|
+
getDebugMode: () => false,
|
|
114
|
+
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
115
|
+
getAllowedTools: () => [],
|
|
116
|
+
getContentGeneratorConfig: () => ({
|
|
117
|
+
model: 'test-model',
|
|
118
|
+
authType: 'oauth-personal',
|
|
119
|
+
}),
|
|
120
|
+
getShellExecutionConfig: () => ({
|
|
121
|
+
terminalWidth: 90,
|
|
122
|
+
terminalHeight: 30,
|
|
123
|
+
}),
|
|
124
|
+
storage: {
|
|
125
|
+
getProjectTempDir: () => '/tmp',
|
|
126
|
+
},
|
|
127
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
128
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
129
|
+
getToolRegistry: () => mockToolRegistry,
|
|
130
|
+
getUseSmartEdit: () => false,
|
|
131
|
+
getUseModelRouter: () => false,
|
|
132
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
133
|
+
};
|
|
134
|
+
const scheduler = new CoreToolScheduler({
|
|
135
|
+
config: mockConfig,
|
|
136
|
+
onAllToolCallsComplete,
|
|
137
|
+
onToolCallsUpdate,
|
|
138
|
+
getPreferredEditor: () => 'vscode',
|
|
139
|
+
onEditorClose: vi.fn(),
|
|
140
|
+
});
|
|
141
|
+
const abortController = new AbortController();
|
|
142
|
+
const request = {
|
|
143
|
+
callId: '1',
|
|
144
|
+
name: 'mockTool',
|
|
145
|
+
args: {},
|
|
146
|
+
isClientInitiated: false,
|
|
147
|
+
prompt_id: 'prompt-id-1',
|
|
148
|
+
};
|
|
149
|
+
abortController.abort();
|
|
150
|
+
await scheduler.schedule([request], abortController.signal);
|
|
151
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
152
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
153
|
+
.calls[0][0];
|
|
154
|
+
expect(completedCalls[0].status).toBe('cancelled');
|
|
155
|
+
});
|
|
156
|
+
describe('getToolSuggestion', () => {
|
|
157
|
+
it('should suggest the top N closest tool names for a typo', () => {
|
|
158
|
+
// Create mocked tool registry
|
|
159
|
+
const mockConfig = {
|
|
160
|
+
getToolRegistry: () => mockToolRegistry,
|
|
161
|
+
getUseSmartEdit: () => false,
|
|
162
|
+
getUseModelRouter: () => false,
|
|
163
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
164
|
+
};
|
|
165
|
+
const mockToolRegistry = {
|
|
166
|
+
getAllToolNames: () => ['list_files', 'read_file', 'write_file'],
|
|
167
|
+
};
|
|
168
|
+
// Create scheduler
|
|
169
|
+
const scheduler = new CoreToolScheduler({
|
|
170
|
+
config: mockConfig,
|
|
171
|
+
getPreferredEditor: () => 'vscode',
|
|
172
|
+
onEditorClose: vi.fn(),
|
|
173
|
+
});
|
|
174
|
+
// Test that the right tool is selected, with only 1 result, for typos
|
|
175
|
+
// @ts-expect-error accessing private method
|
|
176
|
+
const misspelledTool = scheduler.getToolSuggestion('list_fils', 1);
|
|
177
|
+
expect(misspelledTool).toBe(' Did you mean "list_files"?');
|
|
178
|
+
// Test that the right tool is selected, with only 1 result, for prefixes
|
|
179
|
+
// @ts-expect-error accessing private method
|
|
180
|
+
const prefixedTool = scheduler.getToolSuggestion('github.list_files', 1);
|
|
181
|
+
expect(prefixedTool).toBe(' Did you mean "list_files"?');
|
|
182
|
+
// Test that the right tool is first
|
|
183
|
+
// @ts-expect-error accessing private method
|
|
184
|
+
const suggestionMultiple = scheduler.getToolSuggestion('list_fils');
|
|
185
|
+
expect(suggestionMultiple).toBe(' Did you mean one of: "list_files", "read_file", "write_file"?');
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe('CoreToolScheduler with payload', () => {
|
|
190
|
+
it('should update args and diff and execute tool when payload is provided', async () => {
|
|
191
|
+
const mockTool = new MockModifiableTool();
|
|
192
|
+
const declarativeTool = mockTool;
|
|
193
|
+
const mockToolRegistry = {
|
|
194
|
+
getTool: () => declarativeTool,
|
|
195
|
+
getFunctionDeclarations: () => [],
|
|
196
|
+
tools: new Map(),
|
|
197
|
+
discovery: {},
|
|
198
|
+
registerTool: () => { },
|
|
199
|
+
getToolByName: () => declarativeTool,
|
|
200
|
+
getToolByDisplayName: () => declarativeTool,
|
|
201
|
+
getTools: () => [],
|
|
202
|
+
discoverTools: async () => { },
|
|
203
|
+
getAllTools: () => [],
|
|
204
|
+
getToolsByServer: () => [],
|
|
205
|
+
};
|
|
206
|
+
const onAllToolCallsComplete = vi.fn();
|
|
207
|
+
const onToolCallsUpdate = vi.fn();
|
|
208
|
+
const mockConfig = {
|
|
209
|
+
getSessionId: () => 'test-session-id',
|
|
210
|
+
getUsageStatisticsEnabled: () => true,
|
|
211
|
+
getDebugMode: () => false,
|
|
212
|
+
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
213
|
+
getAllowedTools: () => [],
|
|
214
|
+
getContentGeneratorConfig: () => ({
|
|
215
|
+
model: 'test-model',
|
|
216
|
+
authType: 'oauth-personal',
|
|
217
|
+
}),
|
|
218
|
+
getShellExecutionConfig: () => ({
|
|
219
|
+
terminalWidth: 90,
|
|
220
|
+
terminalHeight: 30,
|
|
221
|
+
}),
|
|
222
|
+
storage: {
|
|
223
|
+
getProjectTempDir: () => '/tmp',
|
|
224
|
+
},
|
|
225
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
226
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
227
|
+
getToolRegistry: () => mockToolRegistry,
|
|
228
|
+
getUseSmartEdit: () => false,
|
|
229
|
+
getUseModelRouter: () => false,
|
|
230
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
231
|
+
};
|
|
232
|
+
const scheduler = new CoreToolScheduler({
|
|
233
|
+
config: mockConfig,
|
|
234
|
+
onAllToolCallsComplete,
|
|
235
|
+
onToolCallsUpdate,
|
|
236
|
+
getPreferredEditor: () => 'vscode',
|
|
237
|
+
onEditorClose: vi.fn(),
|
|
238
|
+
});
|
|
239
|
+
const abortController = new AbortController();
|
|
240
|
+
const request = {
|
|
241
|
+
callId: '1',
|
|
242
|
+
name: 'mockModifiableTool',
|
|
243
|
+
args: {},
|
|
244
|
+
isClientInitiated: false,
|
|
245
|
+
prompt_id: 'prompt-id-2',
|
|
246
|
+
};
|
|
247
|
+
await scheduler.schedule([request], abortController.signal);
|
|
248
|
+
const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
|
|
249
|
+
const confirmationDetails = awaitingCall.confirmationDetails;
|
|
250
|
+
if (confirmationDetails) {
|
|
251
|
+
const payload = { newContent: 'final version' };
|
|
252
|
+
await confirmationDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce, payload);
|
|
253
|
+
}
|
|
254
|
+
// Wait for the tool execution to complete
|
|
255
|
+
await vi.waitFor(() => {
|
|
256
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
257
|
+
});
|
|
258
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
259
|
+
.calls[0][0];
|
|
260
|
+
expect(completedCalls[0].status).toBe('success');
|
|
261
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({
|
|
262
|
+
newContent: 'final version',
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
describe('convertToFunctionResponse', () => {
|
|
267
|
+
const toolName = 'testTool';
|
|
268
|
+
const callId = 'call1';
|
|
269
|
+
it('should handle simple string llmContent', () => {
|
|
270
|
+
const llmContent = 'Simple text output';
|
|
271
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
272
|
+
expect(result).toEqual([
|
|
273
|
+
{
|
|
274
|
+
functionResponse: {
|
|
275
|
+
name: toolName,
|
|
276
|
+
id: callId,
|
|
277
|
+
response: { output: 'Simple text output' },
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
]);
|
|
281
|
+
});
|
|
282
|
+
it('should handle llmContent as a single Part with text', () => {
|
|
283
|
+
const llmContent = { text: 'Text from Part object' };
|
|
284
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
285
|
+
expect(result).toEqual([
|
|
286
|
+
{
|
|
287
|
+
functionResponse: {
|
|
288
|
+
name: toolName,
|
|
289
|
+
id: callId,
|
|
290
|
+
response: { output: 'Text from Part object' },
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
]);
|
|
294
|
+
});
|
|
295
|
+
it('should handle llmContent as a PartListUnion array with a single text Part', () => {
|
|
296
|
+
const llmContent = [{ text: 'Text from array' }];
|
|
297
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
298
|
+
expect(result).toEqual([
|
|
299
|
+
{
|
|
300
|
+
functionResponse: {
|
|
301
|
+
name: toolName,
|
|
302
|
+
id: callId,
|
|
303
|
+
response: { output: 'Text from array' },
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
]);
|
|
307
|
+
});
|
|
308
|
+
it('should handle llmContent with inlineData', () => {
|
|
309
|
+
const llmContent = {
|
|
310
|
+
inlineData: { mimeType: 'image/png', data: 'base64...' },
|
|
311
|
+
};
|
|
312
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
313
|
+
expect(result).toEqual([
|
|
314
|
+
{
|
|
315
|
+
functionResponse: {
|
|
316
|
+
name: toolName,
|
|
317
|
+
id: callId,
|
|
318
|
+
response: {
|
|
319
|
+
output: 'Binary content of type image/png was processed.',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
llmContent,
|
|
324
|
+
]);
|
|
325
|
+
});
|
|
326
|
+
it('should handle llmContent with fileData', () => {
|
|
327
|
+
const llmContent = {
|
|
328
|
+
fileData: { mimeType: 'application/pdf', fileUri: 'gs://...' },
|
|
329
|
+
};
|
|
330
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
331
|
+
expect(result).toEqual([
|
|
332
|
+
{
|
|
333
|
+
functionResponse: {
|
|
334
|
+
name: toolName,
|
|
335
|
+
id: callId,
|
|
336
|
+
response: {
|
|
337
|
+
output: 'Binary content of type application/pdf was processed.',
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
llmContent,
|
|
342
|
+
]);
|
|
343
|
+
});
|
|
344
|
+
it('should handle llmContent as an array of multiple Parts (text and inlineData)', () => {
|
|
345
|
+
const llmContent = [
|
|
346
|
+
{ text: 'Some textual description' },
|
|
347
|
+
{ inlineData: { mimeType: 'image/jpeg', data: 'base64data...' } },
|
|
348
|
+
{ text: 'Another text part' },
|
|
349
|
+
];
|
|
350
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
351
|
+
expect(result).toEqual([
|
|
352
|
+
{
|
|
353
|
+
functionResponse: {
|
|
354
|
+
name: toolName,
|
|
355
|
+
id: callId,
|
|
356
|
+
response: { output: 'Tool execution succeeded.' },
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
...llmContent,
|
|
360
|
+
]);
|
|
361
|
+
});
|
|
362
|
+
it('should handle llmContent as an array with a single inlineData Part', () => {
|
|
363
|
+
const llmContent = [
|
|
364
|
+
{ inlineData: { mimeType: 'image/gif', data: 'gifdata...' } },
|
|
365
|
+
];
|
|
366
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
367
|
+
expect(result).toEqual([
|
|
368
|
+
{
|
|
369
|
+
functionResponse: {
|
|
370
|
+
name: toolName,
|
|
371
|
+
id: callId,
|
|
372
|
+
response: {
|
|
373
|
+
output: 'Binary content of type image/gif was processed.',
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
...llmContent,
|
|
378
|
+
]);
|
|
379
|
+
});
|
|
380
|
+
it('should handle llmContent as a generic Part (not text, inlineData, or fileData)', () => {
|
|
381
|
+
const llmContent = { functionCall: { name: 'test', args: {} } };
|
|
382
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
383
|
+
expect(result).toEqual([
|
|
384
|
+
{
|
|
385
|
+
functionResponse: {
|
|
386
|
+
name: toolName,
|
|
387
|
+
id: callId,
|
|
388
|
+
response: { output: 'Tool execution succeeded.' },
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
]);
|
|
392
|
+
});
|
|
393
|
+
it('should handle empty string llmContent', () => {
|
|
394
|
+
const llmContent = '';
|
|
395
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
396
|
+
expect(result).toEqual([
|
|
397
|
+
{
|
|
398
|
+
functionResponse: {
|
|
399
|
+
name: toolName,
|
|
400
|
+
id: callId,
|
|
401
|
+
response: { output: '' },
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
]);
|
|
405
|
+
});
|
|
406
|
+
it('should handle llmContent as an empty array', () => {
|
|
407
|
+
const llmContent = [];
|
|
408
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
409
|
+
expect(result).toEqual([
|
|
410
|
+
{
|
|
411
|
+
functionResponse: {
|
|
412
|
+
name: toolName,
|
|
413
|
+
id: callId,
|
|
414
|
+
response: { output: 'Tool execution succeeded.' },
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
]);
|
|
418
|
+
});
|
|
419
|
+
it('should handle llmContent as a Part with undefined inlineData/fileData/text', () => {
|
|
420
|
+
const llmContent = {}; // An empty part object
|
|
421
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
422
|
+
expect(result).toEqual([
|
|
423
|
+
{
|
|
424
|
+
functionResponse: {
|
|
425
|
+
name: toolName,
|
|
426
|
+
id: callId,
|
|
427
|
+
response: { output: 'Tool execution succeeded.' },
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
]);
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
class MockEditToolInvocation extends BaseToolInvocation {
|
|
434
|
+
constructor(params) {
|
|
435
|
+
super(params);
|
|
436
|
+
}
|
|
437
|
+
getDescription() {
|
|
438
|
+
return 'A mock edit tool invocation';
|
|
439
|
+
}
|
|
440
|
+
async shouldConfirmExecute(_abortSignal) {
|
|
441
|
+
return {
|
|
442
|
+
type: 'edit',
|
|
443
|
+
title: 'Confirm Edit',
|
|
444
|
+
fileName: 'test.txt',
|
|
445
|
+
filePath: 'test.txt',
|
|
446
|
+
fileDiff: '--- test.txt\n+++ test.txt\n@@ -1,1 +1,1 @@\n-old content\n+new content',
|
|
447
|
+
originalContent: 'old content',
|
|
448
|
+
newContent: 'new content',
|
|
449
|
+
onConfirm: async () => { },
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
async execute(_abortSignal) {
|
|
453
|
+
return {
|
|
454
|
+
llmContent: 'Edited successfully',
|
|
455
|
+
returnDisplay: 'Edited successfully',
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
class MockEditTool extends BaseDeclarativeTool {
|
|
460
|
+
constructor() {
|
|
461
|
+
super('mockEditTool', 'mockEditTool', 'A mock edit tool', Kind.Edit, {});
|
|
462
|
+
}
|
|
463
|
+
createInvocation(params) {
|
|
464
|
+
return new MockEditToolInvocation(params);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
describe('CoreToolScheduler edit cancellation', () => {
|
|
468
|
+
it('should preserve diff when an edit is cancelled', async () => {
|
|
469
|
+
const mockEditTool = new MockEditTool();
|
|
470
|
+
const mockToolRegistry = {
|
|
471
|
+
getTool: () => mockEditTool,
|
|
472
|
+
getFunctionDeclarations: () => [],
|
|
473
|
+
tools: new Map(),
|
|
474
|
+
discovery: {},
|
|
475
|
+
registerTool: () => { },
|
|
476
|
+
getToolByName: () => mockEditTool,
|
|
477
|
+
getToolByDisplayName: () => mockEditTool,
|
|
478
|
+
getTools: () => [],
|
|
479
|
+
discoverTools: async () => { },
|
|
480
|
+
getAllTools: () => [],
|
|
481
|
+
getToolsByServer: () => [],
|
|
482
|
+
};
|
|
483
|
+
const onAllToolCallsComplete = vi.fn();
|
|
484
|
+
const onToolCallsUpdate = vi.fn();
|
|
485
|
+
const mockConfig = {
|
|
486
|
+
getSessionId: () => 'test-session-id',
|
|
487
|
+
getUsageStatisticsEnabled: () => true,
|
|
488
|
+
getDebugMode: () => false,
|
|
489
|
+
getApprovalMode: () => ApprovalMode.DEFAULT,
|
|
490
|
+
getAllowedTools: () => [],
|
|
491
|
+
getContentGeneratorConfig: () => ({
|
|
492
|
+
model: 'test-model',
|
|
493
|
+
authType: 'oauth-personal',
|
|
494
|
+
}),
|
|
495
|
+
getShellExecutionConfig: () => ({
|
|
496
|
+
terminalWidth: 90,
|
|
497
|
+
terminalHeight: 30,
|
|
498
|
+
}),
|
|
499
|
+
storage: {
|
|
500
|
+
getProjectTempDir: () => '/tmp',
|
|
501
|
+
},
|
|
502
|
+
getToolRegistry: () => mockToolRegistry,
|
|
503
|
+
getUseSmartEdit: () => false,
|
|
504
|
+
getUseModelRouter: () => false,
|
|
505
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
506
|
+
};
|
|
507
|
+
const scheduler = new CoreToolScheduler({
|
|
508
|
+
config: mockConfig,
|
|
509
|
+
onAllToolCallsComplete,
|
|
510
|
+
onToolCallsUpdate,
|
|
511
|
+
getPreferredEditor: () => 'vscode',
|
|
512
|
+
onEditorClose: vi.fn(),
|
|
513
|
+
});
|
|
514
|
+
const abortController = new AbortController();
|
|
515
|
+
const request = {
|
|
516
|
+
callId: '1',
|
|
517
|
+
name: 'mockEditTool',
|
|
518
|
+
args: {},
|
|
519
|
+
isClientInitiated: false,
|
|
520
|
+
prompt_id: 'prompt-id-1',
|
|
521
|
+
};
|
|
522
|
+
await scheduler.schedule([request], abortController.signal);
|
|
523
|
+
const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
|
|
524
|
+
// Cancel the edit
|
|
525
|
+
const confirmationDetails = awaitingCall.confirmationDetails;
|
|
526
|
+
if (confirmationDetails) {
|
|
527
|
+
await confirmationDetails.onConfirm(ToolConfirmationOutcome.Cancel);
|
|
528
|
+
}
|
|
529
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
530
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
531
|
+
.calls[0][0];
|
|
532
|
+
expect(completedCalls[0].status).toBe('cancelled');
|
|
533
|
+
// Check that the diff is preserved
|
|
534
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
535
|
+
const cancelledCall = completedCalls[0];
|
|
536
|
+
expect(cancelledCall.response.resultDisplay).toBeDefined();
|
|
537
|
+
expect(cancelledCall.response.resultDisplay.fileDiff).toBe('--- test.txt\n+++ test.txt\n@@ -1,1 +1,1 @@\n-old content\n+new content');
|
|
538
|
+
expect(cancelledCall.response.resultDisplay.fileName).toBe('test.txt');
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
describe('CoreToolScheduler YOLO mode', () => {
|
|
542
|
+
it('should execute tool requiring confirmation directly without waiting', async () => {
|
|
543
|
+
// Arrange
|
|
544
|
+
const mockTool = new MockTool();
|
|
545
|
+
mockTool.executeFn.mockReturnValue({
|
|
546
|
+
llmContent: 'Tool executed',
|
|
547
|
+
returnDisplay: 'Tool executed',
|
|
548
|
+
});
|
|
549
|
+
// This tool would normally require confirmation.
|
|
550
|
+
mockTool.shouldConfirm = true;
|
|
551
|
+
const declarativeTool = mockTool;
|
|
552
|
+
const mockToolRegistry = {
|
|
553
|
+
getTool: () => declarativeTool,
|
|
554
|
+
getToolByName: () => declarativeTool,
|
|
555
|
+
// Other properties are not needed for this test but are included for type consistency.
|
|
556
|
+
getFunctionDeclarations: () => [],
|
|
557
|
+
tools: new Map(),
|
|
558
|
+
discovery: {},
|
|
559
|
+
registerTool: () => { },
|
|
560
|
+
getToolByDisplayName: () => declarativeTool,
|
|
561
|
+
getTools: () => [],
|
|
562
|
+
discoverTools: async () => { },
|
|
563
|
+
getAllTools: () => [],
|
|
564
|
+
getToolsByServer: () => [],
|
|
565
|
+
};
|
|
566
|
+
const onAllToolCallsComplete = vi.fn();
|
|
567
|
+
const onToolCallsUpdate = vi.fn();
|
|
568
|
+
// Configure the scheduler for YOLO mode.
|
|
569
|
+
const mockConfig = {
|
|
570
|
+
getSessionId: () => 'test-session-id',
|
|
571
|
+
getUsageStatisticsEnabled: () => true,
|
|
572
|
+
getDebugMode: () => false,
|
|
573
|
+
getApprovalMode: () => ApprovalMode.YOLO,
|
|
574
|
+
getAllowedTools: () => [],
|
|
575
|
+
getContentGeneratorConfig: () => ({
|
|
576
|
+
model: 'test-model',
|
|
577
|
+
authType: 'oauth-personal',
|
|
578
|
+
}),
|
|
579
|
+
getShellExecutionConfig: () => ({
|
|
580
|
+
terminalWidth: 90,
|
|
581
|
+
terminalHeight: 30,
|
|
582
|
+
}),
|
|
583
|
+
storage: {
|
|
584
|
+
getProjectTempDir: () => '/tmp',
|
|
585
|
+
},
|
|
586
|
+
getToolRegistry: () => mockToolRegistry,
|
|
587
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
588
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
589
|
+
getUseSmartEdit: () => false,
|
|
590
|
+
getUseModelRouter: () => false,
|
|
591
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
592
|
+
};
|
|
593
|
+
const scheduler = new CoreToolScheduler({
|
|
594
|
+
config: mockConfig,
|
|
595
|
+
onAllToolCallsComplete,
|
|
596
|
+
onToolCallsUpdate,
|
|
597
|
+
getPreferredEditor: () => 'vscode',
|
|
598
|
+
onEditorClose: vi.fn(),
|
|
599
|
+
});
|
|
600
|
+
const abortController = new AbortController();
|
|
601
|
+
const request = {
|
|
602
|
+
callId: '1',
|
|
603
|
+
name: 'mockTool',
|
|
604
|
+
args: { param: 'value' },
|
|
605
|
+
isClientInitiated: false,
|
|
606
|
+
prompt_id: 'prompt-id-yolo',
|
|
607
|
+
};
|
|
608
|
+
// Act
|
|
609
|
+
await scheduler.schedule([request], abortController.signal);
|
|
610
|
+
// Wait for the tool execution to complete
|
|
611
|
+
await vi.waitFor(() => {
|
|
612
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
613
|
+
});
|
|
614
|
+
// Assert
|
|
615
|
+
// 1. The tool's execute method was called directly.
|
|
616
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ param: 'value' });
|
|
617
|
+
// 2. The tool call status never entered 'awaiting_approval'.
|
|
618
|
+
const statusUpdates = onToolCallsUpdate.mock.calls
|
|
619
|
+
.map((call) => call[0][0]?.status)
|
|
620
|
+
.filter(Boolean);
|
|
621
|
+
expect(statusUpdates).not.toContain('awaiting_approval');
|
|
622
|
+
expect(statusUpdates).toEqual([
|
|
623
|
+
'validating',
|
|
624
|
+
'scheduled',
|
|
625
|
+
'executing',
|
|
626
|
+
'success',
|
|
627
|
+
]);
|
|
628
|
+
// 3. The final callback indicates the tool call was successful.
|
|
629
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
630
|
+
.calls[0][0];
|
|
631
|
+
expect(completedCalls).toHaveLength(1);
|
|
632
|
+
const completedCall = completedCalls[0];
|
|
633
|
+
expect(completedCall.status).toBe('success');
|
|
634
|
+
if (completedCall.status === 'success') {
|
|
635
|
+
expect(completedCall.response.resultDisplay).toBe('Tool executed');
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
describe('CoreToolScheduler request queueing', () => {
|
|
640
|
+
it('should queue a request if another is running', async () => {
|
|
641
|
+
let resolveFirstCall;
|
|
642
|
+
const firstCallPromise = new Promise((resolve) => {
|
|
643
|
+
resolveFirstCall = resolve;
|
|
644
|
+
});
|
|
645
|
+
const mockTool = new MockTool();
|
|
646
|
+
mockTool.executeFn.mockImplementation(() => firstCallPromise);
|
|
647
|
+
const declarativeTool = mockTool;
|
|
648
|
+
const mockToolRegistry = {
|
|
649
|
+
getTool: () => declarativeTool,
|
|
650
|
+
getToolByName: () => declarativeTool,
|
|
651
|
+
getFunctionDeclarations: () => [],
|
|
652
|
+
tools: new Map(),
|
|
653
|
+
discovery: {},
|
|
654
|
+
registerTool: () => { },
|
|
655
|
+
getToolByDisplayName: () => declarativeTool,
|
|
656
|
+
getTools: () => [],
|
|
657
|
+
discoverTools: async () => { },
|
|
658
|
+
getAllTools: () => [],
|
|
659
|
+
getToolsByServer: () => [],
|
|
660
|
+
};
|
|
661
|
+
const onAllToolCallsComplete = vi.fn();
|
|
662
|
+
const onToolCallsUpdate = vi.fn();
|
|
663
|
+
const mockConfig = {
|
|
664
|
+
getSessionId: () => 'test-session-id',
|
|
665
|
+
getUsageStatisticsEnabled: () => true,
|
|
666
|
+
getDebugMode: () => false,
|
|
667
|
+
getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
|
|
668
|
+
getAllowedTools: () => [],
|
|
669
|
+
getContentGeneratorConfig: () => ({
|
|
670
|
+
model: 'test-model',
|
|
671
|
+
authType: 'oauth-personal',
|
|
672
|
+
}),
|
|
673
|
+
getShellExecutionConfig: () => ({
|
|
674
|
+
terminalWidth: 90,
|
|
675
|
+
terminalHeight: 30,
|
|
676
|
+
}),
|
|
677
|
+
storage: {
|
|
678
|
+
getProjectTempDir: () => '/tmp',
|
|
679
|
+
},
|
|
680
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
681
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
682
|
+
getToolRegistry: () => mockToolRegistry,
|
|
683
|
+
getUseSmartEdit: () => false,
|
|
684
|
+
getUseModelRouter: () => false,
|
|
685
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
686
|
+
};
|
|
687
|
+
const scheduler = new CoreToolScheduler({
|
|
688
|
+
config: mockConfig,
|
|
689
|
+
onAllToolCallsComplete,
|
|
690
|
+
onToolCallsUpdate,
|
|
691
|
+
getPreferredEditor: () => 'vscode',
|
|
692
|
+
onEditorClose: vi.fn(),
|
|
693
|
+
});
|
|
694
|
+
const abortController = new AbortController();
|
|
695
|
+
const request1 = {
|
|
696
|
+
callId: '1',
|
|
697
|
+
name: 'mockTool',
|
|
698
|
+
args: { a: 1 },
|
|
699
|
+
isClientInitiated: false,
|
|
700
|
+
prompt_id: 'prompt-1',
|
|
701
|
+
};
|
|
702
|
+
const request2 = {
|
|
703
|
+
callId: '2',
|
|
704
|
+
name: 'mockTool',
|
|
705
|
+
args: { b: 2 },
|
|
706
|
+
isClientInitiated: false,
|
|
707
|
+
prompt_id: 'prompt-2',
|
|
708
|
+
};
|
|
709
|
+
// Schedule the first call, which will pause execution.
|
|
710
|
+
scheduler.schedule([request1], abortController.signal);
|
|
711
|
+
// Wait for the first call to be in the 'executing' state.
|
|
712
|
+
await waitForStatus(onToolCallsUpdate, 'executing');
|
|
713
|
+
// Schedule the second call while the first is "running".
|
|
714
|
+
const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
|
|
715
|
+
// Ensure the second tool call hasn't been executed yet.
|
|
716
|
+
expect(mockTool.executeFn).toHaveBeenCalledTimes(1);
|
|
717
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ a: 1 });
|
|
718
|
+
// Complete the first tool call.
|
|
719
|
+
resolveFirstCall({
|
|
720
|
+
llmContent: 'First call complete',
|
|
721
|
+
returnDisplay: 'First call complete',
|
|
722
|
+
});
|
|
723
|
+
// Wait for the second schedule promise to resolve.
|
|
724
|
+
await schedulePromise2;
|
|
725
|
+
// Let the second call finish.
|
|
726
|
+
const secondCallResult = {
|
|
727
|
+
llmContent: 'Second call complete',
|
|
728
|
+
returnDisplay: 'Second call complete',
|
|
729
|
+
};
|
|
730
|
+
// Since the mock is shared, we need to resolve the current promise.
|
|
731
|
+
// In a real scenario, a new promise would be created for the second call.
|
|
732
|
+
resolveFirstCall(secondCallResult);
|
|
733
|
+
await vi.waitFor(() => {
|
|
734
|
+
// Now the second tool call should have been executed.
|
|
735
|
+
expect(mockTool.executeFn).toHaveBeenCalledTimes(2);
|
|
736
|
+
});
|
|
737
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ b: 2 });
|
|
738
|
+
// Wait for the second completion.
|
|
739
|
+
await vi.waitFor(() => {
|
|
740
|
+
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
741
|
+
});
|
|
742
|
+
// Verify the completion callbacks were called correctly.
|
|
743
|
+
expect(onAllToolCallsComplete.mock.calls[0][0][0].status).toBe('success');
|
|
744
|
+
expect(onAllToolCallsComplete.mock.calls[1][0][0].status).toBe('success');
|
|
745
|
+
});
|
|
746
|
+
it('should auto-approve a tool call if it is on the allowedTools list', async () => {
|
|
747
|
+
// Arrange
|
|
748
|
+
const mockTool = new MockTool('mockTool');
|
|
749
|
+
mockTool.executeFn.mockReturnValue({
|
|
750
|
+
llmContent: 'Tool executed',
|
|
751
|
+
returnDisplay: 'Tool executed',
|
|
752
|
+
});
|
|
753
|
+
// This tool would normally require confirmation.
|
|
754
|
+
mockTool.shouldConfirm = true;
|
|
755
|
+
const declarativeTool = mockTool;
|
|
756
|
+
const toolRegistry = {
|
|
757
|
+
getTool: () => declarativeTool,
|
|
758
|
+
getToolByName: () => declarativeTool,
|
|
759
|
+
getFunctionDeclarations: () => [],
|
|
760
|
+
tools: new Map(),
|
|
761
|
+
discovery: {},
|
|
762
|
+
registerTool: () => { },
|
|
763
|
+
getToolByDisplayName: () => declarativeTool,
|
|
764
|
+
getTools: () => [],
|
|
765
|
+
discoverTools: async () => { },
|
|
766
|
+
getAllTools: () => [],
|
|
767
|
+
getToolsByServer: () => [],
|
|
768
|
+
};
|
|
769
|
+
const onAllToolCallsComplete = vi.fn();
|
|
770
|
+
const onToolCallsUpdate = vi.fn();
|
|
771
|
+
// Configure the scheduler to auto-approve the specific tool call.
|
|
772
|
+
const mockConfig = {
|
|
773
|
+
getSessionId: () => 'test-session-id',
|
|
774
|
+
getUsageStatisticsEnabled: () => true,
|
|
775
|
+
getDebugMode: () => false,
|
|
776
|
+
getApprovalMode: () => ApprovalMode.DEFAULT, // Not YOLO mode
|
|
777
|
+
getAllowedTools: () => ['mockTool'], // Auto-approve this tool
|
|
778
|
+
getToolRegistry: () => toolRegistry,
|
|
779
|
+
getContentGeneratorConfig: () => ({
|
|
780
|
+
model: 'test-model',
|
|
781
|
+
authType: 'oauth-personal',
|
|
782
|
+
}),
|
|
783
|
+
getShellExecutionConfig: () => ({
|
|
784
|
+
terminalWidth: 80,
|
|
785
|
+
terminalHeight: 24,
|
|
786
|
+
}),
|
|
787
|
+
getTerminalWidth: vi.fn(() => 80),
|
|
788
|
+
getTerminalHeight: vi.fn(() => 24),
|
|
789
|
+
storage: {
|
|
790
|
+
getProjectTempDir: () => '/tmp',
|
|
791
|
+
},
|
|
792
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
793
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
794
|
+
getUseSmartEdit: () => false,
|
|
795
|
+
getUseModelRouter: () => false,
|
|
796
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
797
|
+
};
|
|
798
|
+
const scheduler = new CoreToolScheduler({
|
|
799
|
+
config: mockConfig,
|
|
800
|
+
onAllToolCallsComplete,
|
|
801
|
+
onToolCallsUpdate,
|
|
802
|
+
getPreferredEditor: () => 'vscode',
|
|
803
|
+
onEditorClose: vi.fn(),
|
|
804
|
+
});
|
|
805
|
+
const abortController = new AbortController();
|
|
806
|
+
const request = {
|
|
807
|
+
callId: '1',
|
|
808
|
+
name: 'mockTool',
|
|
809
|
+
args: { param: 'value' },
|
|
810
|
+
isClientInitiated: false,
|
|
811
|
+
prompt_id: 'prompt-auto-approved',
|
|
812
|
+
};
|
|
813
|
+
// Act
|
|
814
|
+
await scheduler.schedule([request], abortController.signal);
|
|
815
|
+
// Wait for the tool execution to complete
|
|
816
|
+
await vi.waitFor(() => {
|
|
817
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
818
|
+
});
|
|
819
|
+
// Assert
|
|
820
|
+
// 1. The tool's execute method was called directly.
|
|
821
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ param: 'value' });
|
|
822
|
+
// 2. The tool call status never entered 'awaiting_approval'.
|
|
823
|
+
const statusUpdates = onToolCallsUpdate.mock.calls
|
|
824
|
+
.map((call) => call[0][0]?.status)
|
|
825
|
+
.filter(Boolean);
|
|
826
|
+
expect(statusUpdates).not.toContain('awaiting_approval');
|
|
827
|
+
expect(statusUpdates).toEqual([
|
|
828
|
+
'validating',
|
|
829
|
+
'scheduled',
|
|
830
|
+
'executing',
|
|
831
|
+
'success',
|
|
832
|
+
]);
|
|
833
|
+
// 3. The final callback indicates the tool call was successful.
|
|
834
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
835
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
836
|
+
.calls[0][0];
|
|
837
|
+
expect(completedCalls).toHaveLength(1);
|
|
838
|
+
const completedCall = completedCalls[0];
|
|
839
|
+
expect(completedCall.status).toBe('success');
|
|
840
|
+
if (completedCall.status === 'success') {
|
|
841
|
+
expect(completedCall.response.resultDisplay).toBe('Tool executed');
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
it('should handle two synchronous calls to schedule', async () => {
|
|
845
|
+
const mockTool = new MockTool();
|
|
846
|
+
const declarativeTool = mockTool;
|
|
847
|
+
const mockToolRegistry = {
|
|
848
|
+
getTool: () => declarativeTool,
|
|
849
|
+
getToolByName: () => declarativeTool,
|
|
850
|
+
getFunctionDeclarations: () => [],
|
|
851
|
+
tools: new Map(),
|
|
852
|
+
discovery: {},
|
|
853
|
+
registerTool: () => { },
|
|
854
|
+
getToolByDisplayName: () => declarativeTool,
|
|
855
|
+
getTools: () => [],
|
|
856
|
+
discoverTools: async () => { },
|
|
857
|
+
getAllTools: () => [],
|
|
858
|
+
getToolsByServer: () => [],
|
|
859
|
+
};
|
|
860
|
+
const onAllToolCallsComplete = vi.fn();
|
|
861
|
+
const onToolCallsUpdate = vi.fn();
|
|
862
|
+
const mockConfig = {
|
|
863
|
+
getSessionId: () => 'test-session-id',
|
|
864
|
+
getUsageStatisticsEnabled: () => true,
|
|
865
|
+
getDebugMode: () => false,
|
|
866
|
+
getApprovalMode: () => ApprovalMode.YOLO,
|
|
867
|
+
getAllowedTools: () => [],
|
|
868
|
+
getContentGeneratorConfig: () => ({
|
|
869
|
+
model: 'test-model',
|
|
870
|
+
authType: 'oauth-personal',
|
|
871
|
+
}),
|
|
872
|
+
getShellExecutionConfig: () => ({
|
|
873
|
+
terminalWidth: 90,
|
|
874
|
+
terminalHeight: 30,
|
|
875
|
+
}),
|
|
876
|
+
storage: {
|
|
877
|
+
getProjectTempDir: () => '/tmp',
|
|
878
|
+
},
|
|
879
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
880
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
881
|
+
getToolRegistry: () => mockToolRegistry,
|
|
882
|
+
getUseSmartEdit: () => false,
|
|
883
|
+
getUseModelRouter: () => false,
|
|
884
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
885
|
+
};
|
|
886
|
+
const scheduler = new CoreToolScheduler({
|
|
887
|
+
config: mockConfig,
|
|
888
|
+
onAllToolCallsComplete,
|
|
889
|
+
onToolCallsUpdate,
|
|
890
|
+
getPreferredEditor: () => 'vscode',
|
|
891
|
+
onEditorClose: vi.fn(),
|
|
892
|
+
});
|
|
893
|
+
const abortController = new AbortController();
|
|
894
|
+
const request1 = {
|
|
895
|
+
callId: '1',
|
|
896
|
+
name: 'mockTool',
|
|
897
|
+
args: { a: 1 },
|
|
898
|
+
isClientInitiated: false,
|
|
899
|
+
prompt_id: 'prompt-1',
|
|
900
|
+
};
|
|
901
|
+
const request2 = {
|
|
902
|
+
callId: '2',
|
|
903
|
+
name: 'mockTool',
|
|
904
|
+
args: { b: 2 },
|
|
905
|
+
isClientInitiated: false,
|
|
906
|
+
prompt_id: 'prompt-2',
|
|
907
|
+
};
|
|
908
|
+
// Schedule two calls synchronously.
|
|
909
|
+
const schedulePromise1 = scheduler.schedule([request1], abortController.signal);
|
|
910
|
+
const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
|
|
911
|
+
// Wait for both promises to resolve.
|
|
912
|
+
await Promise.all([schedulePromise1, schedulePromise2]);
|
|
913
|
+
// Ensure the tool was called twice with the correct arguments.
|
|
914
|
+
expect(mockTool.executeFn).toHaveBeenCalledTimes(2);
|
|
915
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ a: 1 });
|
|
916
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({ b: 2 });
|
|
917
|
+
// Ensure completion callbacks were called twice.
|
|
918
|
+
expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
|
|
919
|
+
});
|
|
920
|
+
it('should auto-approve remaining tool calls when first tool call is approved with ProceedAlways', async () => {
|
|
921
|
+
let approvalMode = ApprovalMode.DEFAULT;
|
|
922
|
+
const mockConfig = {
|
|
923
|
+
getSessionId: () => 'test-session-id',
|
|
924
|
+
getUsageStatisticsEnabled: () => true,
|
|
925
|
+
getDebugMode: () => false,
|
|
926
|
+
getApprovalMode: () => approvalMode,
|
|
927
|
+
getAllowedTools: () => [],
|
|
928
|
+
setApprovalMode: (mode) => {
|
|
929
|
+
approvalMode = mode;
|
|
930
|
+
},
|
|
931
|
+
getShellExecutionConfig: () => ({
|
|
932
|
+
terminalWidth: 90,
|
|
933
|
+
terminalHeight: 30,
|
|
934
|
+
}),
|
|
935
|
+
storage: {
|
|
936
|
+
getProjectTempDir: () => '/tmp',
|
|
937
|
+
},
|
|
938
|
+
getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
939
|
+
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
|
940
|
+
getUseSmartEdit: () => false,
|
|
941
|
+
getUseModelRouter: () => false,
|
|
942
|
+
getGeminiClient: () => null, // No client needed for these tests
|
|
943
|
+
};
|
|
944
|
+
const testTool = new TestApprovalTool(mockConfig);
|
|
945
|
+
const toolRegistry = {
|
|
946
|
+
getTool: () => testTool,
|
|
947
|
+
getFunctionDeclarations: () => [],
|
|
948
|
+
getFunctionDeclarationsFiltered: () => [],
|
|
949
|
+
registerTool: () => { },
|
|
950
|
+
discoverAllTools: async () => { },
|
|
951
|
+
discoverMcpTools: async () => { },
|
|
952
|
+
discoverToolsForServer: async () => { },
|
|
953
|
+
removeMcpToolsByServer: () => { },
|
|
954
|
+
getAllTools: () => [],
|
|
955
|
+
getToolsByServer: () => [],
|
|
956
|
+
tools: new Map(),
|
|
957
|
+
config: mockConfig,
|
|
958
|
+
mcpClientManager: undefined,
|
|
959
|
+
getToolByName: () => testTool,
|
|
960
|
+
getToolByDisplayName: () => testTool,
|
|
961
|
+
getTools: () => [],
|
|
962
|
+
discoverTools: async () => { },
|
|
963
|
+
discovery: {},
|
|
964
|
+
};
|
|
965
|
+
mockConfig.getToolRegistry = () => toolRegistry;
|
|
966
|
+
const onAllToolCallsComplete = vi.fn();
|
|
967
|
+
const onToolCallsUpdate = vi.fn();
|
|
968
|
+
const pendingConfirmations = [];
|
|
969
|
+
const scheduler = new CoreToolScheduler({
|
|
970
|
+
config: mockConfig,
|
|
971
|
+
onAllToolCallsComplete,
|
|
972
|
+
onToolCallsUpdate: (toolCalls) => {
|
|
973
|
+
onToolCallsUpdate(toolCalls);
|
|
974
|
+
// Capture confirmation handlers for awaiting_approval tools
|
|
975
|
+
toolCalls.forEach((call) => {
|
|
976
|
+
if (call.status === 'awaiting_approval') {
|
|
977
|
+
const waitingCall = call;
|
|
978
|
+
if (waitingCall.confirmationDetails?.onConfirm) {
|
|
979
|
+
const originalHandler = pendingConfirmations.find((h) => h === waitingCall.confirmationDetails.onConfirm);
|
|
980
|
+
if (!originalHandler) {
|
|
981
|
+
pendingConfirmations.push(waitingCall.confirmationDetails.onConfirm);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
},
|
|
987
|
+
getPreferredEditor: () => 'vscode',
|
|
988
|
+
onEditorClose: vi.fn(),
|
|
989
|
+
});
|
|
990
|
+
const abortController = new AbortController();
|
|
991
|
+
// Schedule multiple tools that need confirmation
|
|
992
|
+
const requests = [
|
|
993
|
+
{
|
|
994
|
+
callId: '1',
|
|
995
|
+
name: 'testApprovalTool',
|
|
996
|
+
args: { id: 'first' },
|
|
997
|
+
isClientInitiated: false,
|
|
998
|
+
prompt_id: 'prompt-1',
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
callId: '2',
|
|
1002
|
+
name: 'testApprovalTool',
|
|
1003
|
+
args: { id: 'second' },
|
|
1004
|
+
isClientInitiated: false,
|
|
1005
|
+
prompt_id: 'prompt-2',
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
callId: '3',
|
|
1009
|
+
name: 'testApprovalTool',
|
|
1010
|
+
args: { id: 'third' },
|
|
1011
|
+
isClientInitiated: false,
|
|
1012
|
+
prompt_id: 'prompt-3',
|
|
1013
|
+
},
|
|
1014
|
+
];
|
|
1015
|
+
await scheduler.schedule(requests, abortController.signal);
|
|
1016
|
+
// Wait for all tools to be awaiting approval
|
|
1017
|
+
await vi.waitFor(() => {
|
|
1018
|
+
const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
|
|
1019
|
+
expect(calls?.length).toBe(3);
|
|
1020
|
+
expect(calls?.every((call) => call.status === 'awaiting_approval')).toBe(true);
|
|
1021
|
+
});
|
|
1022
|
+
expect(pendingConfirmations.length).toBe(3);
|
|
1023
|
+
// Approve the first tool with ProceedAlways
|
|
1024
|
+
const firstConfirmation = pendingConfirmations[0];
|
|
1025
|
+
firstConfirmation(ToolConfirmationOutcome.ProceedAlways);
|
|
1026
|
+
// Wait for all tools to be completed
|
|
1027
|
+
await vi.waitFor(() => {
|
|
1028
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
1029
|
+
const completedCalls = onAllToolCallsComplete.mock.calls.at(-1)?.[0];
|
|
1030
|
+
expect(completedCalls?.length).toBe(3);
|
|
1031
|
+
expect(completedCalls?.every((call) => call.status === 'success')).toBe(true);
|
|
1032
|
+
});
|
|
1033
|
+
// Verify approval mode was changed
|
|
1034
|
+
expect(approvalMode).toBe(ApprovalMode.AUTO_EDIT);
|
|
1035
|
+
});
|
|
1036
|
+
});
|
|
1037
|
+
describe('truncateAndSaveToFile', () => {
|
|
1038
|
+
const mockWriteFile = vi.mocked(fs.writeFile);
|
|
1039
|
+
const THRESHOLD = 40_000;
|
|
1040
|
+
const TRUNCATE_LINES = 1000;
|
|
1041
|
+
beforeEach(() => {
|
|
1042
|
+
vi.clearAllMocks();
|
|
1043
|
+
});
|
|
1044
|
+
it('should return content unchanged if below threshold', async () => {
|
|
1045
|
+
const content = 'Short content';
|
|
1046
|
+
const callId = 'test-call-id';
|
|
1047
|
+
const projectTempDir = '/tmp';
|
|
1048
|
+
const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
|
|
1049
|
+
expect(result).toEqual({ content });
|
|
1050
|
+
expect(mockWriteFile).not.toHaveBeenCalled();
|
|
1051
|
+
});
|
|
1052
|
+
it('should truncate content by lines when content has many lines', async () => {
|
|
1053
|
+
// Create content that exceeds 100,000 character threshold with many lines
|
|
1054
|
+
const lines = Array(2000).fill('x'.repeat(100)); // 100 chars per line * 2000 lines = 200,000 chars
|
|
1055
|
+
const content = lines.join('\n');
|
|
1056
|
+
const callId = 'test-call-id';
|
|
1057
|
+
const projectTempDir = '/tmp';
|
|
1058
|
+
mockWriteFile.mockResolvedValue(undefined);
|
|
1059
|
+
const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
|
|
1060
|
+
expect(result.outputFile).toBe(path.join(projectTempDir, `${callId}.output`));
|
|
1061
|
+
expect(mockWriteFile).toHaveBeenCalledWith(path.join(projectTempDir, `${callId}.output`), content);
|
|
1062
|
+
// Should contain the first and last lines with 1/5 head and 4/5 tail
|
|
1063
|
+
const head = Math.floor(TRUNCATE_LINES / 5);
|
|
1064
|
+
const beginning = lines.slice(0, head);
|
|
1065
|
+
const end = lines.slice(-(TRUNCATE_LINES - head));
|
|
1066
|
+
const expectedTruncated = beginning.join('\n') + '\n... [CONTENT TRUNCATED] ...\n' + end.join('\n');
|
|
1067
|
+
expect(result.content).toContain('Tool output was too large and has been truncated');
|
|
1068
|
+
expect(result.content).toContain('Truncated part of the output:');
|
|
1069
|
+
expect(result.content).toContain(expectedTruncated);
|
|
1070
|
+
});
|
|
1071
|
+
it('should wrap and truncate content when content has few but long lines', async () => {
|
|
1072
|
+
const content = 'a'.repeat(200_000); // A single very long line
|
|
1073
|
+
const callId = 'test-call-id';
|
|
1074
|
+
const projectTempDir = '/tmp';
|
|
1075
|
+
const wrapWidth = 120;
|
|
1076
|
+
mockWriteFile.mockResolvedValue(undefined);
|
|
1077
|
+
// Manually wrap the content to generate the expected file content
|
|
1078
|
+
const wrappedLines = [];
|
|
1079
|
+
for (let i = 0; i < content.length; i += wrapWidth) {
|
|
1080
|
+
wrappedLines.push(content.substring(i, i + wrapWidth));
|
|
1081
|
+
}
|
|
1082
|
+
const expectedFileContent = wrappedLines.join('\n');
|
|
1083
|
+
const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
|
|
1084
|
+
expect(result.outputFile).toBe(path.join(projectTempDir, `${callId}.output`));
|
|
1085
|
+
// Check that the file was written with the wrapped content
|
|
1086
|
+
expect(mockWriteFile).toHaveBeenCalledWith(path.join(projectTempDir, `${callId}.output`), expectedFileContent);
|
|
1087
|
+
// Should contain the first and last lines with 1/5 head and 4/5 tail of the wrapped content
|
|
1088
|
+
const head = Math.floor(TRUNCATE_LINES / 5);
|
|
1089
|
+
const beginning = wrappedLines.slice(0, head);
|
|
1090
|
+
const end = wrappedLines.slice(-(TRUNCATE_LINES - head));
|
|
1091
|
+
const expectedTruncated = beginning.join('\n') + '\n... [CONTENT TRUNCATED] ...\n' + end.join('\n');
|
|
1092
|
+
expect(result.content).toContain('Tool output was too large and has been truncated');
|
|
1093
|
+
expect(result.content).toContain('Truncated part of the output:');
|
|
1094
|
+
expect(result.content).toContain(expectedTruncated);
|
|
1095
|
+
});
|
|
1096
|
+
it('should handle file write errors gracefully', async () => {
|
|
1097
|
+
const content = 'a'.repeat(2_000_000);
|
|
1098
|
+
const callId = 'test-call-id';
|
|
1099
|
+
const projectTempDir = '/tmp';
|
|
1100
|
+
mockWriteFile.mockRejectedValue(new Error('File write failed'));
|
|
1101
|
+
const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
|
|
1102
|
+
expect(result.outputFile).toBeUndefined();
|
|
1103
|
+
expect(result.content).toContain('[Note: Could not save full output to file]');
|
|
1104
|
+
expect(mockWriteFile).toHaveBeenCalled();
|
|
1105
|
+
});
|
|
1106
|
+
it('should save to correct file path with call ID', async () => {
|
|
1107
|
+
const content = 'a'.repeat(200_000);
|
|
1108
|
+
const callId = 'unique-call-123';
|
|
1109
|
+
const projectTempDir = '/custom/temp/dir';
|
|
1110
|
+
const wrapWidth = 120;
|
|
1111
|
+
mockWriteFile.mockResolvedValue(undefined);
|
|
1112
|
+
// Manually wrap the content to generate the expected file content
|
|
1113
|
+
const wrappedLines = [];
|
|
1114
|
+
for (let i = 0; i < content.length; i += wrapWidth) {
|
|
1115
|
+
wrappedLines.push(content.substring(i, i + wrapWidth));
|
|
1116
|
+
}
|
|
1117
|
+
const expectedFileContent = wrappedLines.join('\n');
|
|
1118
|
+
const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
|
|
1119
|
+
const expectedPath = path.join(projectTempDir, `${callId}.output`);
|
|
1120
|
+
expect(result.outputFile).toBe(expectedPath);
|
|
1121
|
+
expect(mockWriteFile).toHaveBeenCalledWith(expectedPath, expectedFileContent);
|
|
1122
|
+
});
|
|
1123
|
+
it('should include helpful instructions in truncated message', async () => {
|
|
1124
|
+
const content = 'a'.repeat(2_000_000);
|
|
1125
|
+
const callId = 'test-call-id';
|
|
1126
|
+
const projectTempDir = '/tmp';
|
|
1127
|
+
mockWriteFile.mockResolvedValue(undefined);
|
|
1128
|
+
const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
|
|
1129
|
+
expect(result.content).toContain('read_file tool with the absolute file path above');
|
|
1130
|
+
expect(result.content).toContain('read_file tool with offset=0, limit=100');
|
|
1131
|
+
expect(result.content).toContain('read_file tool with offset=N to skip N lines');
|
|
1132
|
+
expect(result.content).toContain('read_file tool with limit=M to read only M lines');
|
|
1133
|
+
});
|
|
1134
|
+
it('should sanitize callId to prevent path traversal', async () => {
|
|
1135
|
+
const content = 'a'.repeat(200_000);
|
|
1136
|
+
const callId = '../../../../../etc/passwd';
|
|
1137
|
+
const projectTempDir = '/tmp/safe_dir';
|
|
1138
|
+
const wrapWidth = 120;
|
|
1139
|
+
mockWriteFile.mockResolvedValue(undefined);
|
|
1140
|
+
// Manually wrap the content to generate the expected file content
|
|
1141
|
+
const wrappedLines = [];
|
|
1142
|
+
for (let i = 0; i < content.length; i += wrapWidth) {
|
|
1143
|
+
wrappedLines.push(content.substring(i, i + wrapWidth));
|
|
1144
|
+
}
|
|
1145
|
+
const expectedFileContent = wrappedLines.join('\n');
|
|
1146
|
+
await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
|
|
1147
|
+
const expectedPath = path.join(projectTempDir, 'passwd.output');
|
|
1148
|
+
expect(mockWriteFile).toHaveBeenCalledWith(expectedPath, expectedFileContent);
|
|
1149
|
+
});
|
|
1150
|
+
});
|
|
1151
|
+
//# sourceMappingURL=coreToolScheduler.test.js.map
|