@vybestack/llxprt-code-core 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -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 +9 -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 +68 -0
- package/dist/src/code_assist/converter.js +125 -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 +229 -0
- package/dist/src/code_assist/converter.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +20 -0
- package/dist/src/code_assist/oauth2.js +339 -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 +249 -0
- package/dist/src/code_assist/oauth2.test.js.map +1 -0
- package/dist/src/code_assist/server.d.ts +39 -0
- package/dist/src/code_assist/server.js +191 -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 +123 -0
- package/dist/src/code_assist/server.test.js.map +1 -0
- package/dist/src/code_assist/setup.d.ts +15 -0
- package/dist/src/code_assist/setup.js +67 -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 +62 -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 +212 -0
- package/dist/src/config/config.js +454 -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 +291 -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 +115 -0
- package/dist/src/config/flashFallback.test.js.map +1 -0
- package/dist/src/config/models.d.ts +8 -0
- package/dist/src/config/models.js +9 -0
- package/dist/src/config/models.js.map +1 -0
- package/dist/src/core/client.d.ts +59 -0
- package/dist/src/core/client.js +503 -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 +1006 -0
- package/dist/src/core/client.test.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +36 -0
- package/dist/src/core/contentGenerator.js +79 -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 +92 -0
- package/dist/src/core/contentGenerator.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +104 -0
- package/dist/src/core/coreToolScheduler.js +413 -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 +347 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +116 -0
- package/dist/src/core/geminiChat.js +513 -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 +424 -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 +45 -0
- package/dist/src/core/geminiRequest.js.map +1 -0
- package/dist/src/core/geminiRequest.test.d.ts +6 -0
- package/dist/src/core/geminiRequest.test.js +72 -0
- package/dist/src/core/geminiRequest.test.js.map +1 -0
- package/dist/src/core/logger.d.ts +38 -0
- package/dist/src/core/logger.js +237 -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 +387 -0
- package/dist/src/core/logger.test.js.map +1 -0
- package/dist/src/core/modelCheck.d.ts +14 -0
- package/dist/src/core/modelCheck.js +55 -0
- package/dist/src/core/modelCheck.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +12 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +93 -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 +180 -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 +418 -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 +97 -0
- package/dist/src/core/prompts.test.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +10 -0
- package/dist/src/core/tokenLimits.js +75 -0
- package/dist/src/core/tokenLimits.js.map +1 -0
- package/dist/src/core/tokenLimits.test.d.ts +6 -0
- package/dist/src/core/tokenLimits.test.js +66 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +116 -0
- package/dist/src/core/turn.js +131 -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 +237 -0
- package/dist/src/core/turn.test.js.map +1 -0
- package/dist/src/index.d.ts +57 -0
- package/dist/src/index.js +64 -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/providers/ProviderContentGenerator.d.ts +21 -0
- package/dist/src/providers/ProviderContentGenerator.js +52 -0
- package/dist/src/providers/ProviderContentGenerator.js.map +1 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.d.ts +68 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.js +549 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.js.map +1 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.d.ts +6 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js +253 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js.map +1 -0
- package/dist/src/providers/types.d.ts +82 -0
- package/dist/src/providers/types.js +7 -0
- package/dist/src/providers/types.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 +102 -0
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
- package/dist/src/services/gitService.d.ts +21 -0
- package/dist/src/services/gitService.js +102 -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 +246 -0
- package/dist/src/services/gitService.test.js.map +1 -0
- package/dist/src/services/ideContext.d.ts +124 -0
- package/dist/src/services/ideContext.js +90 -0
- package/dist/src/services/ideContext.js.map +1 -0
- package/dist/src/services/ideContext.test.d.ts +6 -0
- package/dist/src/services/ideContext.test.js +101 -0
- package/dist/src/services/ideContext.test.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +35 -0
- package/dist/src/services/loopDetectionService.js +117 -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 +232 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +35 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +424 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +47 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +123 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +20 -0
- package/dist/src/telemetry/constants.js +21 -0
- package/dist/src/telemetry/constants.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +18 -0
- package/dist/src/telemetry/index.js +20 -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 +53 -0
- package/dist/src/telemetry/integration.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +15 -0
- package/dist/src/telemetry/loggers.js +229 -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 +100 -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 +558 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +19 -0
- package/dist/src/telemetry/metrics.js +144 -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 +162 -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 +120 -0
- package/dist/src/telemetry/sdk.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry.test.js +52 -0
- package/dist/src/telemetry/telemetry.test.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +115 -0
- package/dist/src/telemetry/types.js +217 -0
- package/dist/src/telemetry/types.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.d.ts +67 -0
- package/dist/src/telemetry/uiTelemetry.js +131 -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 +412 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +7 -0
- package/dist/src/tools/diffOptions.js +10 -0
- package/dist/src/tools/diffOptions.js.map +1 -0
- package/dist/src/tools/edit.d.ts +73 -0
- package/dist/src/tools/edit.js +343 -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 +500 -0
- package/dist/src/tools/edit.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +58 -0
- package/dist/src/tools/glob.js +193 -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 +294 -0
- package/dist/src/tools/glob.test.js.map +1 -0
- package/dist/src/tools/grep.d.ts +78 -0
- package/dist/src/tools/grep.js +422 -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 +188 -0
- package/dist/src/tools/grep.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +83 -0
- package/dist/src/tools/ls.js +194 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +112 -0
- package/dist/src/tools/mcp-client.js +332 -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 +227 -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 +119 -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 +173 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +28 -0
- package/dist/src/tools/memoryTool.js +172 -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 +181 -0
- package/dist/src/tools/memoryTool.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +29 -0
- package/dist/src/tools/modifiable-tool.js +85 -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 +204 -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 +106 -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 +181 -0
- package/dist/src/tools/read-file.test.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +59 -0
- package/dist/src/tools/read-many-files.js +321 -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 +312 -0
- package/dist/src/tools/read-many-files.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +43 -0
- package/dist/src/tools/shell.js +435 -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 +407 -0
- package/dist/src/tools/shell.test.js.map +1 -0
- package/dist/src/tools/todo-read.d.ts +15 -0
- package/dist/src/tools/todo-read.js +66 -0
- package/dist/src/tools/todo-read.js.map +1 -0
- package/dist/src/tools/todo-read.test.d.ts +6 -0
- package/dist/src/tools/todo-read.test.js +158 -0
- package/dist/src/tools/todo-read.test.js.map +1 -0
- package/dist/src/tools/todo-schemas.d.ts +43 -0
- package/dist/src/tools/todo-schemas.js +16 -0
- package/dist/src/tools/todo-schemas.js.map +1 -0
- package/dist/src/tools/todo-schemas.test.d.ts +6 -0
- package/dist/src/tools/todo-schemas.test.js +152 -0
- package/dist/src/tools/todo-schemas.test.js.map +1 -0
- package/dist/src/tools/todo-store.d.ts +15 -0
- package/dist/src/tools/todo-store.js +59 -0
- package/dist/src/tools/todo-store.js.map +1 -0
- package/dist/src/tools/todo-store.test.d.ts +6 -0
- package/dist/src/tools/todo-store.test.js +175 -0
- package/dist/src/tools/todo-store.test.js.map +1 -0
- package/dist/src/tools/todo-write.d.ts +17 -0
- package/dist/src/tools/todo-write.js +98 -0
- package/dist/src/tools/todo-write.js.map +1 -0
- package/dist/src/tools/todo-write.test.d.ts +6 -0
- package/dist/src/tools/todo-write.test.js +208 -0
- package/dist/src/tools/todo-write.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +67 -0
- package/dist/src/tools/tool-registry.js +326 -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 +398 -0
- package/dist/src/tools/tool-registry.test.js.map +1 -0
- package/dist/src/tools/tools.d.ts +184 -0
- package/dist/src/tools/tools.js +88 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +29 -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 +70 -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 +120 -0
- package/dist/src/tools/web-search.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +42 -0
- package/dist/src/tools/write-file.js +248 -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 +413 -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 +22 -0
- package/dist/src/utils/bfsFileSearch.js +62 -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 +129 -0
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +53 -0
- package/dist/src/utils/editCorrector.js +546 -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 +163 -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 +293 -0
- package/dist/src/utils/editor.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 +124 -0
- package/dist/src/utils/errorReporting.test.js.map +1 -0
- package/dist/src/utils/errors.d.ts +14 -0
- package/dist/src/utils/errors.js +54 -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 +49 -0
- package/dist/src/utils/fileUtils.js +286 -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 +321 -0
- package/dist/src/utils/fileUtils.test.js.map +1 -0
- package/dist/src/utils/flashFallback.integration.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.integration.test.js +112 -0
- package/dist/src/utils/flashFallback.integration.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +14 -0
- package/dist/src/utils/generateContentResponseUtilities.js +92 -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 +273 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +30 -0
- package/dist/src/utils/getFolderStructure.js +247 -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 +298 -0
- package/dist/src/utils/getFolderStructure.test.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +20 -0
- package/dist/src/utils/gitIgnoreParser.js +64 -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 +145 -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/memoryDiscovery.d.ts +14 -0
- package/dist/src/utils/memoryDiscovery.js +219 -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 +432 -0
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.d.ts +35 -0
- package/dist/src/utils/memoryImportProcessor.js +141 -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 +170 -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 +113 -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/paths.d.ts +49 -0
- package/dist/src/utils/paths.js +145 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +22 -0
- package/dist/src/utils/quotaErrorDetection.js +67 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -0
- package/dist/src/utils/retry.d.ts +21 -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 +322 -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 +23 -0
- package/dist/src/utils/schemaValidator.js +142 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +146 -0
- package/dist/src/utils/schemaValidator.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/summarizer.d.ts +25 -0
- package/dist/src/utils/summarizer.js +80 -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/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/user_account.d.ts +9 -0
- package/dist/src/utils/user_account.js +99 -0
- package/dist/src/utils/user_account.js.map +1 -0
- package/dist/src/utils/user_account.test.d.ts +6 -0
- package/dist/src/utils/user_account.test.js +153 -0
- package/dist/src/utils/user_account.test.js.map +1 -0
- package/dist/src/utils/user_id.d.ts +11 -0
- package/dist/src/utils/user_id.js +49 -0
- package/dist/src/utils/user_id.js.map +1 -0
- package/dist/src/utils/user_id.test.d.ts +6 -0
- package/dist/src/utils/user_id.test.js +21 -0
- package/dist/src/utils/user_id.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/vybestack-llxprt-code-core-0.1.12.tgz +0 -0
- package/package.json +62 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
8
|
+
import { CoreToolScheduler, convertToFunctionResponse, } from './coreToolScheduler.js';
|
|
9
|
+
import { BaseTool, ToolConfirmationOutcome, } from '../index.js';
|
|
10
|
+
class MockTool extends BaseTool {
|
|
11
|
+
shouldConfirm = false;
|
|
12
|
+
executeFn = vi.fn();
|
|
13
|
+
constructor(name = 'mockTool') {
|
|
14
|
+
super(name, name, 'A mock tool', {});
|
|
15
|
+
}
|
|
16
|
+
async shouldConfirmExecute(_params, _abortSignal) {
|
|
17
|
+
if (this.shouldConfirm) {
|
|
18
|
+
return {
|
|
19
|
+
type: 'exec',
|
|
20
|
+
title: 'Confirm Mock Tool',
|
|
21
|
+
command: 'do_thing',
|
|
22
|
+
rootCommand: 'do_thing',
|
|
23
|
+
onConfirm: async () => { },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
async execute(params, _abortSignal) {
|
|
29
|
+
this.executeFn(params);
|
|
30
|
+
return { llmContent: 'Tool executed', returnDisplay: 'Tool executed' };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class MockModifiableTool extends MockTool {
|
|
34
|
+
constructor(name = 'mockModifiableTool') {
|
|
35
|
+
super(name);
|
|
36
|
+
this.shouldConfirm = true;
|
|
37
|
+
}
|
|
38
|
+
getModifyContext(_abortSignal) {
|
|
39
|
+
return {
|
|
40
|
+
getFilePath: () => 'test.txt',
|
|
41
|
+
getCurrentContent: async () => 'old content',
|
|
42
|
+
getProposedContent: async () => 'new content',
|
|
43
|
+
createUpdatedParams: (_oldContent, modifiedProposedContent, _originalParams) => ({ newContent: modifiedProposedContent }),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async shouldConfirmExecute(_params, _abortSignal) {
|
|
47
|
+
if (this.shouldConfirm) {
|
|
48
|
+
return {
|
|
49
|
+
type: 'edit',
|
|
50
|
+
title: 'Confirm Mock Tool',
|
|
51
|
+
fileName: 'test.txt',
|
|
52
|
+
fileDiff: 'diff',
|
|
53
|
+
onConfirm: async () => { },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
describe('CoreToolScheduler', () => {
|
|
60
|
+
it('should cancel a tool call if the signal is aborted before confirmation', async () => {
|
|
61
|
+
const mockTool = new MockTool();
|
|
62
|
+
mockTool.shouldConfirm = true;
|
|
63
|
+
const toolRegistry = {
|
|
64
|
+
getTool: () => mockTool,
|
|
65
|
+
getFunctionDeclarations: () => [],
|
|
66
|
+
tools: new Map(),
|
|
67
|
+
discovery: {},
|
|
68
|
+
registerTool: () => { },
|
|
69
|
+
getToolByName: () => mockTool,
|
|
70
|
+
getToolByDisplayName: () => mockTool,
|
|
71
|
+
getTools: () => [],
|
|
72
|
+
discoverTools: async () => { },
|
|
73
|
+
getAllTools: () => [],
|
|
74
|
+
getToolsByServer: () => [],
|
|
75
|
+
};
|
|
76
|
+
const onAllToolCallsComplete = vi.fn();
|
|
77
|
+
const onToolCallsUpdate = vi.fn();
|
|
78
|
+
const mockConfig = {
|
|
79
|
+
getSessionId: () => 'test-session-id',
|
|
80
|
+
getUsageStatisticsEnabled: () => true,
|
|
81
|
+
getDebugMode: () => false,
|
|
82
|
+
};
|
|
83
|
+
const scheduler = new CoreToolScheduler({
|
|
84
|
+
config: mockConfig,
|
|
85
|
+
toolRegistry: Promise.resolve(toolRegistry),
|
|
86
|
+
onAllToolCallsComplete,
|
|
87
|
+
onToolCallsUpdate,
|
|
88
|
+
getPreferredEditor: () => 'vscode',
|
|
89
|
+
});
|
|
90
|
+
const abortController = new AbortController();
|
|
91
|
+
const request = {
|
|
92
|
+
callId: '1',
|
|
93
|
+
name: 'mockTool',
|
|
94
|
+
args: {},
|
|
95
|
+
isClientInitiated: false,
|
|
96
|
+
prompt_id: 'prompt-id-1',
|
|
97
|
+
};
|
|
98
|
+
abortController.abort();
|
|
99
|
+
await scheduler.schedule([request], abortController.signal);
|
|
100
|
+
const _waitingCall = onToolCallsUpdate.mock
|
|
101
|
+
.calls[1][0][0];
|
|
102
|
+
const confirmationDetails = await mockTool.shouldConfirmExecute({}, abortController.signal);
|
|
103
|
+
if (confirmationDetails) {
|
|
104
|
+
await scheduler.handleConfirmationResponse('1', confirmationDetails.onConfirm, ToolConfirmationOutcome.ProceedOnce, abortController.signal);
|
|
105
|
+
}
|
|
106
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
107
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
108
|
+
.calls[0][0];
|
|
109
|
+
expect(completedCalls[0].status).toBe('cancelled');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
describe('CoreToolScheduler with payload', () => {
|
|
113
|
+
it('should update args and diff and execute tool when payload is provided', async () => {
|
|
114
|
+
const mockTool = new MockModifiableTool();
|
|
115
|
+
const toolRegistry = {
|
|
116
|
+
getTool: () => mockTool,
|
|
117
|
+
getFunctionDeclarations: () => [],
|
|
118
|
+
tools: new Map(),
|
|
119
|
+
discovery: {},
|
|
120
|
+
registerTool: () => { },
|
|
121
|
+
getToolByName: () => mockTool,
|
|
122
|
+
getToolByDisplayName: () => mockTool,
|
|
123
|
+
getTools: () => [],
|
|
124
|
+
discoverTools: async () => { },
|
|
125
|
+
getAllTools: () => [],
|
|
126
|
+
getToolsByServer: () => [],
|
|
127
|
+
};
|
|
128
|
+
const onAllToolCallsComplete = vi.fn();
|
|
129
|
+
const onToolCallsUpdate = vi.fn();
|
|
130
|
+
const mockConfig = {
|
|
131
|
+
getSessionId: () => 'test-session-id',
|
|
132
|
+
getUsageStatisticsEnabled: () => true,
|
|
133
|
+
getDebugMode: () => false,
|
|
134
|
+
};
|
|
135
|
+
const scheduler = new CoreToolScheduler({
|
|
136
|
+
config: mockConfig,
|
|
137
|
+
toolRegistry: Promise.resolve(toolRegistry),
|
|
138
|
+
onAllToolCallsComplete,
|
|
139
|
+
onToolCallsUpdate,
|
|
140
|
+
getPreferredEditor: () => 'vscode',
|
|
141
|
+
});
|
|
142
|
+
const abortController = new AbortController();
|
|
143
|
+
const request = {
|
|
144
|
+
callId: '1',
|
|
145
|
+
name: 'mockModifiableTool',
|
|
146
|
+
args: {},
|
|
147
|
+
isClientInitiated: false,
|
|
148
|
+
prompt_id: 'prompt-id-2',
|
|
149
|
+
};
|
|
150
|
+
await scheduler.schedule([request], abortController.signal);
|
|
151
|
+
const confirmationDetails = await mockTool.shouldConfirmExecute({}, abortController.signal);
|
|
152
|
+
if (confirmationDetails) {
|
|
153
|
+
const payload = { newContent: 'final version' };
|
|
154
|
+
await scheduler.handleConfirmationResponse('1', confirmationDetails.onConfirm, ToolConfirmationOutcome.ProceedOnce, abortController.signal, payload);
|
|
155
|
+
}
|
|
156
|
+
expect(onAllToolCallsComplete).toHaveBeenCalled();
|
|
157
|
+
const completedCalls = onAllToolCallsComplete.mock
|
|
158
|
+
.calls[0][0];
|
|
159
|
+
expect(completedCalls[0].status).toBe('success');
|
|
160
|
+
expect(mockTool.executeFn).toHaveBeenCalledWith({
|
|
161
|
+
newContent: 'final version',
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
describe('convertToFunctionResponse', () => {
|
|
166
|
+
const toolName = 'testTool';
|
|
167
|
+
const callId = 'call1';
|
|
168
|
+
it('should handle simple string llmContent', () => {
|
|
169
|
+
const llmContent = 'Simple text output';
|
|
170
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
171
|
+
expect(result).toEqual({
|
|
172
|
+
functionResponse: {
|
|
173
|
+
name: toolName,
|
|
174
|
+
id: callId,
|
|
175
|
+
response: { output: 'Simple text output' },
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
it('should handle llmContent as a single Part with text', () => {
|
|
180
|
+
const llmContent = { text: 'Text from Part object' };
|
|
181
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
182
|
+
expect(result).toEqual({
|
|
183
|
+
functionResponse: {
|
|
184
|
+
name: toolName,
|
|
185
|
+
id: callId,
|
|
186
|
+
response: { output: 'Text from Part object' },
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
it('should handle llmContent as a PartListUnion array with a single text Part', () => {
|
|
191
|
+
const llmContent = [{ text: 'Text from array' }];
|
|
192
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
193
|
+
expect(result).toEqual({
|
|
194
|
+
functionResponse: {
|
|
195
|
+
name: toolName,
|
|
196
|
+
id: callId,
|
|
197
|
+
response: { output: 'Text from array' },
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
it('should handle llmContent with inlineData', () => {
|
|
202
|
+
const llmContent = {
|
|
203
|
+
inlineData: { mimeType: 'image/png', data: 'base64...' },
|
|
204
|
+
};
|
|
205
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
206
|
+
expect(result).toEqual({
|
|
207
|
+
functionResponse: {
|
|
208
|
+
name: toolName,
|
|
209
|
+
id: callId,
|
|
210
|
+
response: {
|
|
211
|
+
output: 'Binary content of type image/png was processed.',
|
|
212
|
+
binaryContent: llmContent,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
it('should handle llmContent with fileData', () => {
|
|
218
|
+
const llmContent = {
|
|
219
|
+
fileData: { mimeType: 'application/pdf', fileUri: 'gs://...' },
|
|
220
|
+
};
|
|
221
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
222
|
+
expect(result).toEqual({
|
|
223
|
+
functionResponse: {
|
|
224
|
+
name: toolName,
|
|
225
|
+
id: callId,
|
|
226
|
+
response: {
|
|
227
|
+
output: 'Binary content of type application/pdf was processed.',
|
|
228
|
+
binaryContent: llmContent,
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
it('should handle llmContent as an array of multiple Parts (text and inlineData)', () => {
|
|
234
|
+
const llmContent = [
|
|
235
|
+
{ text: 'Some textual description' },
|
|
236
|
+
{ inlineData: { mimeType: 'image/jpeg', data: 'base64data...' } },
|
|
237
|
+
{ text: 'Another text part' },
|
|
238
|
+
];
|
|
239
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
240
|
+
expect(result).toEqual([
|
|
241
|
+
{
|
|
242
|
+
functionResponse: {
|
|
243
|
+
name: toolName,
|
|
244
|
+
id: callId,
|
|
245
|
+
response: { output: 'Tool execution succeeded.' },
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
...llmContent,
|
|
249
|
+
]);
|
|
250
|
+
});
|
|
251
|
+
it('should handle llmContent as an array with a single inlineData Part', () => {
|
|
252
|
+
const llmContent = [
|
|
253
|
+
{ inlineData: { mimeType: 'image/gif', data: 'gifdata...' } },
|
|
254
|
+
];
|
|
255
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
256
|
+
expect(result).toEqual({
|
|
257
|
+
functionResponse: {
|
|
258
|
+
name: toolName,
|
|
259
|
+
id: callId,
|
|
260
|
+
response: {
|
|
261
|
+
output: 'Binary content of type image/gif was processed.',
|
|
262
|
+
binaryContent: llmContent[0],
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
it('should handle llmContent as a generic Part (not text, inlineData, or fileData)', () => {
|
|
268
|
+
const llmContent = { functionCall: { name: 'test', args: {} } };
|
|
269
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
270
|
+
expect(result).toEqual({
|
|
271
|
+
functionResponse: {
|
|
272
|
+
name: toolName,
|
|
273
|
+
id: callId,
|
|
274
|
+
response: { output: 'Tool execution succeeded.' },
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
it('should handle empty string llmContent', () => {
|
|
279
|
+
const llmContent = '';
|
|
280
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
281
|
+
expect(result).toEqual({
|
|
282
|
+
functionResponse: {
|
|
283
|
+
name: toolName,
|
|
284
|
+
id: callId,
|
|
285
|
+
response: { output: '' },
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
it('should handle llmContent as an empty array', () => {
|
|
290
|
+
const llmContent = [];
|
|
291
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
292
|
+
expect(result).toEqual([
|
|
293
|
+
{
|
|
294
|
+
functionResponse: {
|
|
295
|
+
name: toolName,
|
|
296
|
+
id: callId,
|
|
297
|
+
response: { output: 'Tool execution succeeded.' },
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
]);
|
|
301
|
+
});
|
|
302
|
+
it('should handle llmContent as a Part with undefined inlineData/fileData/text', () => {
|
|
303
|
+
const llmContent = {}; // An empty part object
|
|
304
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
305
|
+
expect(result).toEqual({
|
|
306
|
+
functionResponse: {
|
|
307
|
+
name: toolName,
|
|
308
|
+
id: callId,
|
|
309
|
+
response: { output: 'Tool execution succeeded.' },
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
it('should ensure correct id when llmContent contains functionResponse without id', () => {
|
|
314
|
+
const llmContent = {
|
|
315
|
+
functionResponse: {
|
|
316
|
+
name: 'originalTool',
|
|
317
|
+
response: { output: 'Tool completed successfully' },
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
321
|
+
expect(result).toEqual({
|
|
322
|
+
functionResponse: {
|
|
323
|
+
name: toolName,
|
|
324
|
+
id: callId,
|
|
325
|
+
response: { output: 'Tool completed successfully' },
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
it('should override id when llmContent contains functionResponse with different id', () => {
|
|
330
|
+
const llmContent = {
|
|
331
|
+
functionResponse: {
|
|
332
|
+
id: 'wrong_id',
|
|
333
|
+
name: 'originalTool',
|
|
334
|
+
response: { output: 'Tool completed successfully' },
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
const result = convertToFunctionResponse(toolName, callId, llmContent);
|
|
338
|
+
expect(result).toEqual({
|
|
339
|
+
functionResponse: {
|
|
340
|
+
id: callId, // Should use the provided callId, not 'wrong_id'
|
|
341
|
+
name: toolName, // Should use the provided toolName
|
|
342
|
+
response: { output: 'Tool completed successfully' },
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
//# sourceMappingURL=coreToolScheduler.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coreToolScheduler.test.js","sourceRoot":"","sources":["../../../src/core/coreToolScheduler.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uDAAuD;AACvD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EACL,iBAAiB,EAGjB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,QAAQ,EAER,uBAAuB,GAIxB,MAAM,aAAa,CAAC;AAKrB,MAAM,QAAS,SAAQ,QAA6C;IAClE,aAAa,GAAG,KAAK,CAAC;IACtB,SAAS,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAEpB,YAAY,IAAI,GAAG,UAAU;QAC3B,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,OAAgC,EAChC,YAAyB;QAEzB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,mBAAmB;gBAC1B,OAAO,EAAE,UAAU;gBACnB,WAAW,EAAE,UAAU;gBACvB,SAAS,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;aAC1B,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAA+B,EAC/B,YAAyB;QAEzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC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gBAChB,EAAE,EAAE,MAAM,EAAE,iDAAiD;gBAC7D,IAAI,EAAE,QAAQ,EAAE,mCAAmC;gBACnD,QAAQ,EAAE,EAAE,MAAM,EAAE,6BAA6B,EAAE;aACpD;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { GenerateContentResponse, Content, GenerateContentConfig, SendMessageParameters, GenerateContentResponseUsageMetadata } from '@google/genai';
|
|
7
|
+
import { ContentGenerator } from './contentGenerator.js';
|
|
8
|
+
import { Config } from '../config/config.js';
|
|
9
|
+
/**
|
|
10
|
+
* Chat session that enables sending messages to the model with previous
|
|
11
|
+
* conversation context.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* The session maintains all the turns between user and model.
|
|
15
|
+
*/
|
|
16
|
+
export declare class GeminiChat {
|
|
17
|
+
private readonly config;
|
|
18
|
+
private readonly contentGenerator;
|
|
19
|
+
private readonly generationConfig;
|
|
20
|
+
private history;
|
|
21
|
+
private sendPromise;
|
|
22
|
+
constructor(config: Config, contentGenerator: ContentGenerator, generationConfig?: GenerateContentConfig, history?: Content[]);
|
|
23
|
+
private _getRequestTextFromContents;
|
|
24
|
+
private _logApiRequest;
|
|
25
|
+
private _logApiResponse;
|
|
26
|
+
private _logApiError;
|
|
27
|
+
/**
|
|
28
|
+
* Handles fallback to Flash model when persistent 429 errors occur for OAuth users.
|
|
29
|
+
* Uses a fallback handler if provided by the config, otherwise returns null.
|
|
30
|
+
*/
|
|
31
|
+
private handleFlashFallback;
|
|
32
|
+
/**
|
|
33
|
+
* Sends a message to the model and returns the response.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* This method will wait for the previous message to be processed before
|
|
37
|
+
* sending the next message.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link Chat#sendMessageStream} for streaming method.
|
|
40
|
+
* @param params - parameters for sending messages within a chat session.
|
|
41
|
+
* @returns The model's response.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
46
|
+
* const response = await chat.sendMessage({
|
|
47
|
+
* message: 'Why is the sky blue?'
|
|
48
|
+
* });
|
|
49
|
+
* console.log(response.text);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
sendMessage(params: SendMessageParameters, prompt_id: string): Promise<GenerateContentResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Sends a message to the model and returns the response in chunks.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* This method will wait for the previous message to be processed before
|
|
58
|
+
* sending the next message.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link Chat#sendMessage} for non-streaming method.
|
|
61
|
+
* @param params - parameters for sending the message.
|
|
62
|
+
* @return The model's response.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
67
|
+
* const response = await chat.sendMessageStream({
|
|
68
|
+
* message: 'Why is the sky blue?'
|
|
69
|
+
* });
|
|
70
|
+
* for await (const chunk of response) {
|
|
71
|
+
* console.log(chunk.text);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
sendMessageStream(params: SendMessageParameters, prompt_id: string): Promise<AsyncGenerator<GenerateContentResponse>>;
|
|
76
|
+
/**
|
|
77
|
+
* Returns the chat history.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* The history is a list of contents alternating between user and model.
|
|
81
|
+
*
|
|
82
|
+
* There are two types of history:
|
|
83
|
+
* - The `curated history` contains only the valid turns between user and
|
|
84
|
+
* model, which will be included in the subsequent requests sent to the model.
|
|
85
|
+
* - The `comprehensive history` contains all turns, including invalid or
|
|
86
|
+
* empty model outputs, providing a complete record of the history.
|
|
87
|
+
*
|
|
88
|
+
* The history is updated after receiving the response from the model,
|
|
89
|
+
* for streaming response, it means receiving the last chunk of the response.
|
|
90
|
+
*
|
|
91
|
+
* The `comprehensive history` is returned by default. To get the `curated
|
|
92
|
+
* history`, set the `curated` parameter to `true`.
|
|
93
|
+
*
|
|
94
|
+
* @param curated - whether to return the curated history or the comprehensive
|
|
95
|
+
* history.
|
|
96
|
+
* @return History contents alternating between user and model for the entire
|
|
97
|
+
* chat session.
|
|
98
|
+
*/
|
|
99
|
+
getHistory(curated?: boolean): Content[];
|
|
100
|
+
/**
|
|
101
|
+
* Clears the chat history.
|
|
102
|
+
*/
|
|
103
|
+
clearHistory(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Adds a new entry to the chat history.
|
|
106
|
+
*
|
|
107
|
+
* @param content - The content to add to the history.
|
|
108
|
+
*/
|
|
109
|
+
addHistory(content: Content): void;
|
|
110
|
+
setHistory(history: Content[]): void;
|
|
111
|
+
getFinalUsageMetadata(chunks: GenerateContentResponse[]): GenerateContentResponseUsageMetadata | undefined;
|
|
112
|
+
private processStreamResponse;
|
|
113
|
+
private recordHistory;
|
|
114
|
+
private isTextContent;
|
|
115
|
+
private isThoughtContent;
|
|
116
|
+
}
|