@google/gemini-cli-core 0.0.3-preview.4
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 +310 -0
- package/dist/.last_build +0 -0
- package/dist/google-gemini-cli-core-0.3.0-preview.3.tgz +0 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +13 -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 +10 -0
- package/dist/src/code_assist/codeAssist.js +19 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +72 -0
- package/dist/src/code_assist/converter.js +159 -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 +362 -0
- package/dist/src/code_assist/converter.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +22 -0
- package/dist/src/code_assist/oauth2.js +353 -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 +427 -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 +125 -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 +134 -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 +148 -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 +318 -0
- package/dist/src/config/config.js +633 -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 +585 -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 +9 -0
- package/dist/src/config/models.js +10 -0
- package/dist/src/config/models.js.map +1 -0
- package/dist/src/config/storage.d.ts +32 -0
- package/dist/src/config/storage.js +90 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +6 -0
- package/dist/src/config/storage.test.js +43 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/core/client.d.ts +65 -0
- package/dist/src/core/client.js +689 -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 +1857 -0
- package/dist/src/core/client.test.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +33 -0
- package/dist/src/core/contentGenerator.js +80 -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 +124 -0
- package/dist/src/core/contentGenerator.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +126 -0
- package/dist/src/core/coreToolScheduler.js +605 -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 +923 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +122 -0
- package/dist/src/core/geminiChat.js +547 -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 +875 -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 +97 -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 +236 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +12 -0
- package/dist/src/core/prompts.js +359 -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 +214 -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 +485 -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 +520 -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 +125 -0
- package/dist/src/core/turn.js +154 -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 +388 -0
- package/dist/src/core/turn.test.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 +6 -0
- package/dist/src/ide/constants.js +7 -0
- package/dist/src/ide/constants.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +25 -0
- package/dist/src/ide/detect-ide.js +104 -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 +109 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +67 -0
- package/dist/src/ide/ide-client.js +418 -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 +155 -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 +107 -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 +113 -0
- package/dist/src/ide/ide-installer.test.js.map +1 -0
- package/dist/src/ide/ideContext.d.ts +374 -0
- package/dist/src/ide/ideContext.js +147 -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 +265 -0
- package/dist/src/ide/ideContext.test.js.map +1 -0
- package/dist/src/ide/process-utils.d.ts +22 -0
- package/dist/src/ide/process-utils.js +153 -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 +72 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/index.d.ts +81 -0
- package/dist/src/index.js +90 -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 +146 -0
- package/dist/src/mcp/oauth-provider.js +601 -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 +672 -0
- package/dist/src/mcp/oauth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.d.ts +61 -0
- package/dist/src/mcp/oauth-token-storage.js +148 -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 +206 -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/types.d.ts +34 -0
- package/dist/src/mcp/token-storage/types.js +7 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/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/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/services/chatRecordingService.d.ts +150 -0
- package/dist/src/services/chatRecordingService.js +321 -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 +290 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.d.ts +35 -0
- package/dist/src/services/fileDiscoveryService.js +91 -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 +110 -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 +212 -0
- package/dist/src/services/gitService.test.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +98 -0
- package/dist/src/services/loopDetectionService.js +363 -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 +558 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +68 -0
- package/dist/src/services/shellExecutionService.js +332 -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 +517 -0
- package/dist/src/services/shellExecutionService.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +121 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +773 -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 +407 -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 +90 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +229 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +32 -0
- package/dist/src/telemetry/constants.js +33 -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/index.d.ts +21 -0
- package/dist/src/telemetry/index.js +21 -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 +26 -0
- package/dist/src/telemetry/loggers.js +404 -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 +658 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +36 -0
- package/dist/src/telemetry/metrics.js +208 -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 +242 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +9 -0
- package/dist/src/telemetry/sdk.js +163 -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 +82 -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 +220 -0
- package/dist/src/telemetry/types.js +383 -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 +153 -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/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 +38 -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 +119 -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 +423 -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 +713 -0
- package/dist/src/tools/edit.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +52 -0
- package/dist/src/tools/glob.js +236 -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 +375 -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 +227 -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 +389 -0
- package/dist/src/tools/ls.test.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.d.ts +38 -0
- package/dist/src/tools/mcp-client-manager.js +74 -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 +39 -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 +995 -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 +23 -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 +576 -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 +296 -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 +127 -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 +311 -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 +414 -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 +47 -0
- package/dist/src/tools/ripGrep.js +368 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +874 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +22 -0
- package/dist/src/tools/shell.js +320 -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 +336 -0
- package/dist/src/tools/shell.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 +86 -0
- package/dist/src/tools/tool-registry.js +369 -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 +274 -0
- package/dist/src/tools/tools.js +250 -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 +243 -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 +137 -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 +314 -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 +531 -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 +89 -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 +53 -0
- package/dist/src/utils/editCorrector.js +545 -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 +564 -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 +186 -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 +445 -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 +33 -0
- package/dist/src/utils/errors.js +86 -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 +52 -0
- package/dist/src/utils/fileUtils.js +283 -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 +364 -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.integration.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.integration.test.js +118 -0
- package/dist/src/utils/flashFallback.integration.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/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 +20 -0
- package/dist/src/utils/gitIgnoreParser.js +61 -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 +154 -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/memoryDiscovery.d.ts +15 -0
- package/dist/src/utils/memoryDiscovery.js +253 -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 +219 -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 +91 -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 +168 -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/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 +117 -0
- package/dist/src/utils/shell-utils.js +370 -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/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 +13 -0
- package/dist/src/utils/textUtils.js +28 -0
- package/dist/src/utils/textUtils.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 +85 -0
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { AuthType, EditTool, GeminiClient, ToolConfirmationOutcome, ToolErrorType, ToolRegistry, } from '../index.js';
|
|
7
|
+
import { logs } from '@opentelemetry/api-logs';
|
|
8
|
+
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
|
|
9
|
+
import { EVENT_API_REQUEST, EVENT_API_RESPONSE, EVENT_CLI_CONFIG, EVENT_TOOL_CALL, EVENT_USER_PROMPT, EVENT_FLASH_FALLBACK, EVENT_MALFORMED_JSON_RESPONSE, } from './constants.js';
|
|
10
|
+
import { logApiRequest, logApiResponse, logCliConfiguration, logUserPrompt, logToolCall, logFlashFallback, logChatCompression, logMalformedJsonResponse, } from './loggers.js';
|
|
11
|
+
import { ToolCallDecision } from './tool-call-decision.js';
|
|
12
|
+
import { ApiRequestEvent, ApiResponseEvent, StartSessionEvent, ToolCallEvent, UserPromptEvent, FlashFallbackEvent, MalformedJsonResponseEvent, makeChatCompressionEvent, } from './types.js';
|
|
13
|
+
import * as metrics from './metrics.js';
|
|
14
|
+
import * as sdk from './sdk.js';
|
|
15
|
+
import { vi, describe, beforeEach, it, expect } from 'vitest';
|
|
16
|
+
import * as uiTelemetry from './uiTelemetry.js';
|
|
17
|
+
import { makeFakeConfig } from '../test-utils/config.js';
|
|
18
|
+
import { ClearcutLogger } from './clearcut-logger/clearcut-logger.js';
|
|
19
|
+
import { UserAccountManager } from '../utils/userAccountManager.js';
|
|
20
|
+
describe('loggers', () => {
|
|
21
|
+
const mockLogger = {
|
|
22
|
+
emit: vi.fn(),
|
|
23
|
+
};
|
|
24
|
+
const mockUiEvent = {
|
|
25
|
+
addEvent: vi.fn(),
|
|
26
|
+
};
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
vi.clearAllMocks();
|
|
29
|
+
vi.spyOn(sdk, 'isTelemetrySdkInitialized').mockReturnValue(true);
|
|
30
|
+
vi.spyOn(logs, 'getLogger').mockReturnValue(mockLogger);
|
|
31
|
+
vi.spyOn(uiTelemetry.uiTelemetryService, 'addEvent').mockImplementation(mockUiEvent.addEvent);
|
|
32
|
+
vi.spyOn(UserAccountManager.prototype, 'getCachedGoogleAccount').mockReturnValue('test-user@example.com');
|
|
33
|
+
vi.useFakeTimers();
|
|
34
|
+
vi.setSystemTime(new Date('2025-01-01T00:00:00.000Z'));
|
|
35
|
+
});
|
|
36
|
+
describe('logChatCompression', () => {
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
vi.spyOn(metrics, 'recordChatCompressionMetrics');
|
|
39
|
+
vi.spyOn(ClearcutLogger.prototype, 'logChatCompressionEvent');
|
|
40
|
+
});
|
|
41
|
+
it('logs the chat compression event to Clearcut', () => {
|
|
42
|
+
const mockConfig = makeFakeConfig();
|
|
43
|
+
const event = makeChatCompressionEvent({
|
|
44
|
+
tokens_before: 9001,
|
|
45
|
+
tokens_after: 9000,
|
|
46
|
+
});
|
|
47
|
+
logChatCompression(mockConfig, event);
|
|
48
|
+
expect(ClearcutLogger.prototype.logChatCompressionEvent).toHaveBeenCalledWith(event);
|
|
49
|
+
});
|
|
50
|
+
it('records the chat compression event to OTEL', () => {
|
|
51
|
+
const mockConfig = makeFakeConfig();
|
|
52
|
+
logChatCompression(mockConfig, makeChatCompressionEvent({
|
|
53
|
+
tokens_before: 9001,
|
|
54
|
+
tokens_after: 9000,
|
|
55
|
+
}));
|
|
56
|
+
expect(metrics.recordChatCompressionMetrics).toHaveBeenCalledWith(mockConfig, { tokens_before: 9001, tokens_after: 9000 });
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('logCliConfiguration', () => {
|
|
60
|
+
it('should log the cli configuration', () => {
|
|
61
|
+
const mockConfig = {
|
|
62
|
+
getSessionId: () => 'test-session-id',
|
|
63
|
+
getModel: () => 'test-model',
|
|
64
|
+
getEmbeddingModel: () => 'test-embedding-model',
|
|
65
|
+
getSandbox: () => true,
|
|
66
|
+
getCoreTools: () => ['ls', 'read-file'],
|
|
67
|
+
getApprovalMode: () => 'default',
|
|
68
|
+
getContentGeneratorConfig: () => ({
|
|
69
|
+
model: 'test-model',
|
|
70
|
+
apiKey: 'test-api-key',
|
|
71
|
+
authType: AuthType.USE_VERTEX_AI,
|
|
72
|
+
}),
|
|
73
|
+
getTelemetryEnabled: () => true,
|
|
74
|
+
getUsageStatisticsEnabled: () => true,
|
|
75
|
+
getTelemetryLogPromptsEnabled: () => true,
|
|
76
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
77
|
+
getFileFilteringAllowBuildArtifacts: () => false,
|
|
78
|
+
getDebugMode: () => true,
|
|
79
|
+
getMcpServers: () => ({
|
|
80
|
+
'test-server': {
|
|
81
|
+
command: 'test-command',
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
getQuestion: () => 'test-question',
|
|
85
|
+
getTargetDir: () => 'target-dir',
|
|
86
|
+
getProxy: () => 'http://test.proxy.com:8080',
|
|
87
|
+
};
|
|
88
|
+
const startSessionEvent = new StartSessionEvent(mockConfig);
|
|
89
|
+
logCliConfiguration(mockConfig, startSessionEvent);
|
|
90
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
91
|
+
body: 'CLI configuration loaded.',
|
|
92
|
+
attributes: {
|
|
93
|
+
'session.id': 'test-session-id',
|
|
94
|
+
'user.email': 'test-user@example.com',
|
|
95
|
+
'event.name': EVENT_CLI_CONFIG,
|
|
96
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
97
|
+
model: 'test-model',
|
|
98
|
+
embedding_model: 'test-embedding-model',
|
|
99
|
+
sandbox_enabled: true,
|
|
100
|
+
core_tools_enabled: 'ls,read-file',
|
|
101
|
+
approval_mode: 'default',
|
|
102
|
+
api_key_enabled: true,
|
|
103
|
+
vertex_ai_enabled: true,
|
|
104
|
+
log_user_prompts_enabled: true,
|
|
105
|
+
file_filtering_respect_git_ignore: true,
|
|
106
|
+
debug_mode: true,
|
|
107
|
+
mcp_servers: 'test-server',
|
|
108
|
+
mcp_servers_count: 1,
|
|
109
|
+
mcp_tools: undefined,
|
|
110
|
+
mcp_tools_count: undefined,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
describe('logUserPrompt', () => {
|
|
116
|
+
const mockConfig = {
|
|
117
|
+
getSessionId: () => 'test-session-id',
|
|
118
|
+
getTelemetryEnabled: () => true,
|
|
119
|
+
getTelemetryLogPromptsEnabled: () => true,
|
|
120
|
+
getUsageStatisticsEnabled: () => true,
|
|
121
|
+
};
|
|
122
|
+
it('should log a user prompt', () => {
|
|
123
|
+
const event = new UserPromptEvent(11, 'prompt-id-8', AuthType.USE_VERTEX_AI, 'test-prompt');
|
|
124
|
+
logUserPrompt(mockConfig, event);
|
|
125
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
126
|
+
body: 'User prompt. Length: 11.',
|
|
127
|
+
attributes: {
|
|
128
|
+
'session.id': 'test-session-id',
|
|
129
|
+
'user.email': 'test-user@example.com',
|
|
130
|
+
'event.name': EVENT_USER_PROMPT,
|
|
131
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
132
|
+
prompt_length: 11,
|
|
133
|
+
prompt: 'test-prompt',
|
|
134
|
+
prompt_id: 'prompt-id-8',
|
|
135
|
+
auth_type: 'vertex-ai',
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
it('should not log prompt if disabled', () => {
|
|
140
|
+
const mockConfig = {
|
|
141
|
+
getSessionId: () => 'test-session-id',
|
|
142
|
+
getTelemetryEnabled: () => true,
|
|
143
|
+
getTelemetryLogPromptsEnabled: () => false,
|
|
144
|
+
getTargetDir: () => 'target-dir',
|
|
145
|
+
getUsageStatisticsEnabled: () => true,
|
|
146
|
+
};
|
|
147
|
+
const event = new UserPromptEvent(11, 'prompt-id-9', AuthType.CLOUD_SHELL, 'test-prompt');
|
|
148
|
+
logUserPrompt(mockConfig, event);
|
|
149
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
150
|
+
body: 'User prompt. Length: 11.',
|
|
151
|
+
attributes: {
|
|
152
|
+
'session.id': 'test-session-id',
|
|
153
|
+
'user.email': 'test-user@example.com',
|
|
154
|
+
'event.name': EVENT_USER_PROMPT,
|
|
155
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
156
|
+
prompt_length: 11,
|
|
157
|
+
prompt_id: 'prompt-id-9',
|
|
158
|
+
auth_type: 'cloud-shell',
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
describe('logApiResponse', () => {
|
|
164
|
+
const mockConfig = {
|
|
165
|
+
getSessionId: () => 'test-session-id',
|
|
166
|
+
getTargetDir: () => 'target-dir',
|
|
167
|
+
getUsageStatisticsEnabled: () => true,
|
|
168
|
+
getTelemetryEnabled: () => true,
|
|
169
|
+
getTelemetryLogPromptsEnabled: () => true,
|
|
170
|
+
};
|
|
171
|
+
const mockMetrics = {
|
|
172
|
+
recordApiResponseMetrics: vi.fn(),
|
|
173
|
+
recordTokenUsageMetrics: vi.fn(),
|
|
174
|
+
};
|
|
175
|
+
beforeEach(() => {
|
|
176
|
+
vi.spyOn(metrics, 'recordApiResponseMetrics').mockImplementation(mockMetrics.recordApiResponseMetrics);
|
|
177
|
+
vi.spyOn(metrics, 'recordTokenUsageMetrics').mockImplementation(mockMetrics.recordTokenUsageMetrics);
|
|
178
|
+
});
|
|
179
|
+
it('should log an API response with all fields', () => {
|
|
180
|
+
const usageData = {
|
|
181
|
+
promptTokenCount: 17,
|
|
182
|
+
candidatesTokenCount: 50,
|
|
183
|
+
cachedContentTokenCount: 10,
|
|
184
|
+
thoughtsTokenCount: 5,
|
|
185
|
+
toolUsePromptTokenCount: 2,
|
|
186
|
+
};
|
|
187
|
+
const event = new ApiResponseEvent('test-model', 100, 'prompt-id-1', AuthType.LOGIN_WITH_GOOGLE, usageData, 'test-response');
|
|
188
|
+
logApiResponse(mockConfig, event);
|
|
189
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
190
|
+
body: 'API response from test-model. Status: 200. Duration: 100ms.',
|
|
191
|
+
attributes: {
|
|
192
|
+
'session.id': 'test-session-id',
|
|
193
|
+
'user.email': 'test-user@example.com',
|
|
194
|
+
'event.name': EVENT_API_RESPONSE,
|
|
195
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
196
|
+
[SemanticAttributes.HTTP_STATUS_CODE]: 200,
|
|
197
|
+
model: 'test-model',
|
|
198
|
+
status_code: 200,
|
|
199
|
+
duration_ms: 100,
|
|
200
|
+
input_token_count: 17,
|
|
201
|
+
output_token_count: 50,
|
|
202
|
+
cached_content_token_count: 10,
|
|
203
|
+
thoughts_token_count: 5,
|
|
204
|
+
tool_token_count: 2,
|
|
205
|
+
total_token_count: 0,
|
|
206
|
+
response_text: 'test-response',
|
|
207
|
+
prompt_id: 'prompt-id-1',
|
|
208
|
+
auth_type: 'oauth-personal',
|
|
209
|
+
error: undefined,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
expect(mockMetrics.recordApiResponseMetrics).toHaveBeenCalledWith(mockConfig, 'test-model', 100, 200, undefined);
|
|
213
|
+
expect(mockMetrics.recordTokenUsageMetrics).toHaveBeenCalledWith(mockConfig, 'test-model', 50, 'output');
|
|
214
|
+
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
|
215
|
+
...event,
|
|
216
|
+
'event.name': EVENT_API_RESPONSE,
|
|
217
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
it('should log an API response with an error', () => {
|
|
221
|
+
const usageData = {
|
|
222
|
+
promptTokenCount: 17,
|
|
223
|
+
candidatesTokenCount: 50,
|
|
224
|
+
cachedContentTokenCount: 10,
|
|
225
|
+
thoughtsTokenCount: 5,
|
|
226
|
+
toolUsePromptTokenCount: 2,
|
|
227
|
+
};
|
|
228
|
+
const event = new ApiResponseEvent('test-model', 100, 'prompt-id-1', AuthType.USE_GEMINI, usageData, 'test-response', 'test-error');
|
|
229
|
+
logApiResponse(mockConfig, event);
|
|
230
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
231
|
+
body: 'API response from test-model. Status: 200. Duration: 100ms.',
|
|
232
|
+
attributes: {
|
|
233
|
+
'session.id': 'test-session-id',
|
|
234
|
+
'user.email': 'test-user@example.com',
|
|
235
|
+
...event,
|
|
236
|
+
'event.name': EVENT_API_RESPONSE,
|
|
237
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
238
|
+
'error.message': 'test-error',
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
|
242
|
+
...event,
|
|
243
|
+
'event.name': EVENT_API_RESPONSE,
|
|
244
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
describe('logApiRequest', () => {
|
|
249
|
+
const mockConfig = {
|
|
250
|
+
getSessionId: () => 'test-session-id',
|
|
251
|
+
getTargetDir: () => 'target-dir',
|
|
252
|
+
getUsageStatisticsEnabled: () => true,
|
|
253
|
+
getTelemetryEnabled: () => true,
|
|
254
|
+
getTelemetryLogPromptsEnabled: () => true,
|
|
255
|
+
};
|
|
256
|
+
it('should log an API request with request_text', () => {
|
|
257
|
+
const event = new ApiRequestEvent('test-model', 'prompt-id-7', 'This is a test request');
|
|
258
|
+
logApiRequest(mockConfig, event);
|
|
259
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
260
|
+
body: 'API request to test-model.',
|
|
261
|
+
attributes: {
|
|
262
|
+
'session.id': 'test-session-id',
|
|
263
|
+
'user.email': 'test-user@example.com',
|
|
264
|
+
'event.name': EVENT_API_REQUEST,
|
|
265
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
266
|
+
model: 'test-model',
|
|
267
|
+
request_text: 'This is a test request',
|
|
268
|
+
prompt_id: 'prompt-id-7',
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
it('should log an API request without request_text', () => {
|
|
273
|
+
const event = new ApiRequestEvent('test-model', 'prompt-id-6');
|
|
274
|
+
logApiRequest(mockConfig, event);
|
|
275
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
276
|
+
body: 'API request to test-model.',
|
|
277
|
+
attributes: {
|
|
278
|
+
'session.id': 'test-session-id',
|
|
279
|
+
'user.email': 'test-user@example.com',
|
|
280
|
+
'event.name': EVENT_API_REQUEST,
|
|
281
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
282
|
+
model: 'test-model',
|
|
283
|
+
prompt_id: 'prompt-id-6',
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
describe('logFlashFallback', () => {
|
|
289
|
+
const mockConfig = {
|
|
290
|
+
getSessionId: () => 'test-session-id',
|
|
291
|
+
getUsageStatisticsEnabled: () => true,
|
|
292
|
+
};
|
|
293
|
+
it('should log flash fallback event', () => {
|
|
294
|
+
const event = new FlashFallbackEvent(AuthType.USE_VERTEX_AI);
|
|
295
|
+
logFlashFallback(mockConfig, event);
|
|
296
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
297
|
+
body: 'Switching to flash as Fallback.',
|
|
298
|
+
attributes: {
|
|
299
|
+
'session.id': 'test-session-id',
|
|
300
|
+
'user.email': 'test-user@example.com',
|
|
301
|
+
'event.name': EVENT_FLASH_FALLBACK,
|
|
302
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
303
|
+
auth_type: 'vertex-ai',
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
describe('logToolCall', () => {
|
|
309
|
+
const cfg1 = {
|
|
310
|
+
getSessionId: () => 'test-session-id',
|
|
311
|
+
getTargetDir: () => 'target-dir',
|
|
312
|
+
getGeminiClient: () => mockGeminiClient,
|
|
313
|
+
};
|
|
314
|
+
const cfg2 = {
|
|
315
|
+
getSessionId: () => 'test-session-id',
|
|
316
|
+
getTargetDir: () => 'target-dir',
|
|
317
|
+
getProxy: () => 'http://test.proxy.com:8080',
|
|
318
|
+
getContentGeneratorConfig: () => ({ model: 'test-model' }),
|
|
319
|
+
getModel: () => 'test-model',
|
|
320
|
+
getEmbeddingModel: () => 'test-embedding-model',
|
|
321
|
+
getWorkingDir: () => 'test-working-dir',
|
|
322
|
+
getSandbox: () => true,
|
|
323
|
+
getCoreTools: () => ['ls', 'read-file'],
|
|
324
|
+
getApprovalMode: () => 'default',
|
|
325
|
+
getTelemetryLogPromptsEnabled: () => true,
|
|
326
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
327
|
+
getFileFilteringAllowBuildArtifacts: () => false,
|
|
328
|
+
getDebugMode: () => true,
|
|
329
|
+
getMcpServers: () => ({
|
|
330
|
+
'test-server': {
|
|
331
|
+
command: 'test-command',
|
|
332
|
+
},
|
|
333
|
+
}),
|
|
334
|
+
getQuestion: () => 'test-question',
|
|
335
|
+
getToolRegistry: () => new ToolRegistry(cfg1),
|
|
336
|
+
getFullContext: () => false,
|
|
337
|
+
getUserMemory: () => 'user-memory',
|
|
338
|
+
};
|
|
339
|
+
const mockGeminiClient = new GeminiClient(cfg2);
|
|
340
|
+
const mockConfig = {
|
|
341
|
+
getSessionId: () => 'test-session-id',
|
|
342
|
+
getTargetDir: () => 'target-dir',
|
|
343
|
+
getGeminiClient: () => mockGeminiClient,
|
|
344
|
+
getUsageStatisticsEnabled: () => true,
|
|
345
|
+
getTelemetryEnabled: () => true,
|
|
346
|
+
getTelemetryLogPromptsEnabled: () => true,
|
|
347
|
+
};
|
|
348
|
+
const mockMetrics = {
|
|
349
|
+
recordToolCallMetrics: vi.fn(),
|
|
350
|
+
};
|
|
351
|
+
beforeEach(() => {
|
|
352
|
+
vi.spyOn(metrics, 'recordToolCallMetrics').mockImplementation(mockMetrics.recordToolCallMetrics);
|
|
353
|
+
mockLogger.emit.mockReset();
|
|
354
|
+
});
|
|
355
|
+
it('should log a tool call with all fields', () => {
|
|
356
|
+
const tool = new EditTool(mockConfig);
|
|
357
|
+
const call = {
|
|
358
|
+
status: 'success',
|
|
359
|
+
request: {
|
|
360
|
+
name: 'test-function',
|
|
361
|
+
args: {
|
|
362
|
+
arg1: 'value1',
|
|
363
|
+
arg2: 2,
|
|
364
|
+
},
|
|
365
|
+
callId: 'test-call-id',
|
|
366
|
+
isClientInitiated: true,
|
|
367
|
+
prompt_id: 'prompt-id-1',
|
|
368
|
+
},
|
|
369
|
+
response: {
|
|
370
|
+
callId: 'test-call-id',
|
|
371
|
+
responseParts: [{ text: 'test-response' }],
|
|
372
|
+
resultDisplay: undefined,
|
|
373
|
+
error: undefined,
|
|
374
|
+
errorType: undefined,
|
|
375
|
+
},
|
|
376
|
+
tool,
|
|
377
|
+
invocation: {},
|
|
378
|
+
durationMs: 100,
|
|
379
|
+
outcome: ToolConfirmationOutcome.ProceedOnce,
|
|
380
|
+
};
|
|
381
|
+
const event = new ToolCallEvent(call);
|
|
382
|
+
logToolCall(mockConfig, event);
|
|
383
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
384
|
+
body: 'Tool call: test-function. Decision: accept. Success: true. Duration: 100ms.',
|
|
385
|
+
attributes: {
|
|
386
|
+
'session.id': 'test-session-id',
|
|
387
|
+
'user.email': 'test-user@example.com',
|
|
388
|
+
'event.name': EVENT_TOOL_CALL,
|
|
389
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
390
|
+
function_name: 'test-function',
|
|
391
|
+
function_args: JSON.stringify({
|
|
392
|
+
arg1: 'value1',
|
|
393
|
+
arg2: 2,
|
|
394
|
+
}, null, 2),
|
|
395
|
+
duration_ms: 100,
|
|
396
|
+
success: true,
|
|
397
|
+
decision: ToolCallDecision.ACCEPT,
|
|
398
|
+
prompt_id: 'prompt-id-1',
|
|
399
|
+
tool_type: 'native',
|
|
400
|
+
error: undefined,
|
|
401
|
+
error_type: undefined,
|
|
402
|
+
metadata: undefined,
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
expect(mockMetrics.recordToolCallMetrics).toHaveBeenCalledWith(mockConfig, 'test-function', 100, true, ToolCallDecision.ACCEPT, 'native');
|
|
406
|
+
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
|
407
|
+
...event,
|
|
408
|
+
'event.name': EVENT_TOOL_CALL,
|
|
409
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
it('should log a tool call with a reject decision', () => {
|
|
413
|
+
const call = {
|
|
414
|
+
status: 'error',
|
|
415
|
+
request: {
|
|
416
|
+
name: 'test-function',
|
|
417
|
+
args: {
|
|
418
|
+
arg1: 'value1',
|
|
419
|
+
arg2: 2,
|
|
420
|
+
},
|
|
421
|
+
callId: 'test-call-id',
|
|
422
|
+
isClientInitiated: true,
|
|
423
|
+
prompt_id: 'prompt-id-2',
|
|
424
|
+
},
|
|
425
|
+
response: {
|
|
426
|
+
callId: 'test-call-id',
|
|
427
|
+
responseParts: [{ text: 'test-response' }],
|
|
428
|
+
resultDisplay: undefined,
|
|
429
|
+
error: undefined,
|
|
430
|
+
errorType: undefined,
|
|
431
|
+
},
|
|
432
|
+
durationMs: 100,
|
|
433
|
+
outcome: ToolConfirmationOutcome.Cancel,
|
|
434
|
+
};
|
|
435
|
+
const event = new ToolCallEvent(call);
|
|
436
|
+
logToolCall(mockConfig, event);
|
|
437
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
438
|
+
body: 'Tool call: test-function. Decision: reject. Success: false. Duration: 100ms.',
|
|
439
|
+
attributes: {
|
|
440
|
+
'session.id': 'test-session-id',
|
|
441
|
+
'user.email': 'test-user@example.com',
|
|
442
|
+
'event.name': EVENT_TOOL_CALL,
|
|
443
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
444
|
+
function_name: 'test-function',
|
|
445
|
+
function_args: JSON.stringify({
|
|
446
|
+
arg1: 'value1',
|
|
447
|
+
arg2: 2,
|
|
448
|
+
}, null, 2),
|
|
449
|
+
duration_ms: 100,
|
|
450
|
+
success: false,
|
|
451
|
+
decision: ToolCallDecision.REJECT,
|
|
452
|
+
prompt_id: 'prompt-id-2',
|
|
453
|
+
tool_type: 'native',
|
|
454
|
+
error: undefined,
|
|
455
|
+
error_type: undefined,
|
|
456
|
+
metadata: undefined,
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
expect(mockMetrics.recordToolCallMetrics).toHaveBeenCalledWith(mockConfig, 'test-function', 100, false, ToolCallDecision.REJECT, 'native');
|
|
460
|
+
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
|
461
|
+
...event,
|
|
462
|
+
'event.name': EVENT_TOOL_CALL,
|
|
463
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
it('should log a tool call with a modify decision', () => {
|
|
467
|
+
const call = {
|
|
468
|
+
status: 'success',
|
|
469
|
+
request: {
|
|
470
|
+
name: 'test-function',
|
|
471
|
+
args: {
|
|
472
|
+
arg1: 'value1',
|
|
473
|
+
arg2: 2,
|
|
474
|
+
},
|
|
475
|
+
callId: 'test-call-id',
|
|
476
|
+
isClientInitiated: true,
|
|
477
|
+
prompt_id: 'prompt-id-3',
|
|
478
|
+
},
|
|
479
|
+
response: {
|
|
480
|
+
callId: 'test-call-id',
|
|
481
|
+
responseParts: [{ text: 'test-response' }],
|
|
482
|
+
resultDisplay: undefined,
|
|
483
|
+
error: undefined,
|
|
484
|
+
errorType: undefined,
|
|
485
|
+
},
|
|
486
|
+
outcome: ToolConfirmationOutcome.ModifyWithEditor,
|
|
487
|
+
tool: new EditTool(mockConfig),
|
|
488
|
+
invocation: {},
|
|
489
|
+
durationMs: 100,
|
|
490
|
+
};
|
|
491
|
+
const event = new ToolCallEvent(call);
|
|
492
|
+
logToolCall(mockConfig, event);
|
|
493
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
494
|
+
body: 'Tool call: test-function. Decision: modify. Success: true. Duration: 100ms.',
|
|
495
|
+
attributes: {
|
|
496
|
+
'session.id': 'test-session-id',
|
|
497
|
+
'user.email': 'test-user@example.com',
|
|
498
|
+
'event.name': EVENT_TOOL_CALL,
|
|
499
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
500
|
+
function_name: 'test-function',
|
|
501
|
+
function_args: JSON.stringify({
|
|
502
|
+
arg1: 'value1',
|
|
503
|
+
arg2: 2,
|
|
504
|
+
}, null, 2),
|
|
505
|
+
duration_ms: 100,
|
|
506
|
+
success: true,
|
|
507
|
+
decision: ToolCallDecision.MODIFY,
|
|
508
|
+
prompt_id: 'prompt-id-3',
|
|
509
|
+
tool_type: 'native',
|
|
510
|
+
error: undefined,
|
|
511
|
+
error_type: undefined,
|
|
512
|
+
metadata: undefined,
|
|
513
|
+
},
|
|
514
|
+
});
|
|
515
|
+
expect(mockMetrics.recordToolCallMetrics).toHaveBeenCalledWith(mockConfig, 'test-function', 100, true, ToolCallDecision.MODIFY, 'native');
|
|
516
|
+
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
|
517
|
+
...event,
|
|
518
|
+
'event.name': EVENT_TOOL_CALL,
|
|
519
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
it('should log a tool call without a decision', () => {
|
|
523
|
+
const call = {
|
|
524
|
+
status: 'success',
|
|
525
|
+
request: {
|
|
526
|
+
name: 'test-function',
|
|
527
|
+
args: {
|
|
528
|
+
arg1: 'value1',
|
|
529
|
+
arg2: 2,
|
|
530
|
+
},
|
|
531
|
+
callId: 'test-call-id',
|
|
532
|
+
isClientInitiated: true,
|
|
533
|
+
prompt_id: 'prompt-id-4',
|
|
534
|
+
},
|
|
535
|
+
response: {
|
|
536
|
+
callId: 'test-call-id',
|
|
537
|
+
responseParts: [{ text: 'test-response' }],
|
|
538
|
+
resultDisplay: undefined,
|
|
539
|
+
error: undefined,
|
|
540
|
+
errorType: undefined,
|
|
541
|
+
},
|
|
542
|
+
tool: new EditTool(mockConfig),
|
|
543
|
+
invocation: {},
|
|
544
|
+
durationMs: 100,
|
|
545
|
+
};
|
|
546
|
+
const event = new ToolCallEvent(call);
|
|
547
|
+
logToolCall(mockConfig, event);
|
|
548
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
549
|
+
body: 'Tool call: test-function. Success: true. Duration: 100ms.',
|
|
550
|
+
attributes: {
|
|
551
|
+
'session.id': 'test-session-id',
|
|
552
|
+
'user.email': 'test-user@example.com',
|
|
553
|
+
'event.name': EVENT_TOOL_CALL,
|
|
554
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
555
|
+
function_name: 'test-function',
|
|
556
|
+
function_args: JSON.stringify({
|
|
557
|
+
arg1: 'value1',
|
|
558
|
+
arg2: 2,
|
|
559
|
+
}, null, 2),
|
|
560
|
+
duration_ms: 100,
|
|
561
|
+
success: true,
|
|
562
|
+
prompt_id: 'prompt-id-4',
|
|
563
|
+
tool_type: 'native',
|
|
564
|
+
decision: undefined,
|
|
565
|
+
error: undefined,
|
|
566
|
+
error_type: undefined,
|
|
567
|
+
metadata: undefined,
|
|
568
|
+
},
|
|
569
|
+
});
|
|
570
|
+
expect(mockMetrics.recordToolCallMetrics).toHaveBeenCalledWith(mockConfig, 'test-function', 100, true, undefined, 'native');
|
|
571
|
+
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
|
572
|
+
...event,
|
|
573
|
+
'event.name': EVENT_TOOL_CALL,
|
|
574
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
it('should log a failed tool call with an error', () => {
|
|
578
|
+
const call = {
|
|
579
|
+
status: 'error',
|
|
580
|
+
request: {
|
|
581
|
+
name: 'test-function',
|
|
582
|
+
args: {
|
|
583
|
+
arg1: 'value1',
|
|
584
|
+
arg2: 2,
|
|
585
|
+
},
|
|
586
|
+
callId: 'test-call-id',
|
|
587
|
+
isClientInitiated: true,
|
|
588
|
+
prompt_id: 'prompt-id-5',
|
|
589
|
+
},
|
|
590
|
+
response: {
|
|
591
|
+
callId: 'test-call-id',
|
|
592
|
+
responseParts: [{ text: 'test-response' }],
|
|
593
|
+
resultDisplay: undefined,
|
|
594
|
+
error: {
|
|
595
|
+
name: 'test-error-type',
|
|
596
|
+
message: 'test-error',
|
|
597
|
+
},
|
|
598
|
+
errorType: ToolErrorType.UNKNOWN,
|
|
599
|
+
},
|
|
600
|
+
durationMs: 100,
|
|
601
|
+
};
|
|
602
|
+
const event = new ToolCallEvent(call);
|
|
603
|
+
logToolCall(mockConfig, event);
|
|
604
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
605
|
+
body: 'Tool call: test-function. Success: false. Duration: 100ms.',
|
|
606
|
+
attributes: {
|
|
607
|
+
'session.id': 'test-session-id',
|
|
608
|
+
'user.email': 'test-user@example.com',
|
|
609
|
+
'event.name': EVENT_TOOL_CALL,
|
|
610
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
611
|
+
function_name: 'test-function',
|
|
612
|
+
function_args: JSON.stringify({
|
|
613
|
+
arg1: 'value1',
|
|
614
|
+
arg2: 2,
|
|
615
|
+
}, null, 2),
|
|
616
|
+
duration_ms: 100,
|
|
617
|
+
success: false,
|
|
618
|
+
error: 'test-error',
|
|
619
|
+
'error.message': 'test-error',
|
|
620
|
+
error_type: ToolErrorType.UNKNOWN,
|
|
621
|
+
'error.type': ToolErrorType.UNKNOWN,
|
|
622
|
+
prompt_id: 'prompt-id-5',
|
|
623
|
+
tool_type: 'native',
|
|
624
|
+
decision: undefined,
|
|
625
|
+
metadata: undefined,
|
|
626
|
+
},
|
|
627
|
+
});
|
|
628
|
+
expect(mockMetrics.recordToolCallMetrics).toHaveBeenCalledWith(mockConfig, 'test-function', 100, false, undefined, 'native');
|
|
629
|
+
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
|
630
|
+
...event,
|
|
631
|
+
'event.name': EVENT_TOOL_CALL,
|
|
632
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
describe('logMalformedJsonResponse', () => {
|
|
637
|
+
beforeEach(() => {
|
|
638
|
+
vi.spyOn(ClearcutLogger.prototype, 'logMalformedJsonResponseEvent');
|
|
639
|
+
});
|
|
640
|
+
it('logs the event to Clearcut and OTEL', () => {
|
|
641
|
+
const mockConfig = makeFakeConfig();
|
|
642
|
+
const event = new MalformedJsonResponseEvent('test-model');
|
|
643
|
+
logMalformedJsonResponse(mockConfig, event);
|
|
644
|
+
expect(ClearcutLogger.prototype.logMalformedJsonResponseEvent).toHaveBeenCalledWith(event);
|
|
645
|
+
expect(mockLogger.emit).toHaveBeenCalledWith({
|
|
646
|
+
body: 'Malformed JSON response from test-model.',
|
|
647
|
+
attributes: {
|
|
648
|
+
'session.id': 'test-session-id',
|
|
649
|
+
'user.email': 'test-user@example.com',
|
|
650
|
+
'event.name': EVENT_MALFORMED_JSON_RESPONSE,
|
|
651
|
+
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
|
652
|
+
model: 'test-model',
|
|
653
|
+
},
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
//# sourceMappingURL=loggers.test.js.map
|