@office-ai/aioncli-core 0.2.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -3
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +11 -0
- package/dist/src/agents/codebase-investigator.js +73 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/executor.d.ts +88 -0
- package/dist/src/agents/executor.js +417 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.js +419 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +43 -0
- package/dist/src/agents/invocation.js +100 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.js +206 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +35 -0
- package/dist/src/agents/registry.js +58 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.js +146 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +36 -0
- package/dist/src/agents/subagent-tool-wrapper.js +47 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +105 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +116 -0
- package/dist/src/agents/types.js +17 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +6 -3
- package/dist/src/code_assist/codeAssist.js +12 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/converter.d.ts +4 -1
- package/dist/src/code_assist/converter.js +38 -5
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +93 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +109 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.test.d.ts +6 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js +136 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +1 -1
- package/dist/src/code_assist/oauth2.js +107 -48
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +735 -343
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +4 -4
- package/dist/src/code_assist/server.js +25 -2
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +25 -0
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +1 -1
- package/dist/src/code_assist/setup.js +1 -1
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +17 -2
- package/dist/src/config/config.d.ts +121 -25
- package/dist/src/config/config.js +298 -87
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +370 -131
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +11 -0
- package/dist/src/config/constants.js +16 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/models.d.ts +16 -0
- package/dist/src/config/models.js +29 -0
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.d.ts +6 -0
- package/dist/src/config/models.test.js +55 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +34 -0
- package/dist/src/config/storage.js +95 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +6 -0
- package/dist/src/config/storage.test.js +47 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +7 -0
- package/dist/src/confirmation-bus/index.js +8 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +17 -0
- package/dist/src/confirmation-bus/message-bus.js +81 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.test.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.test.js +164 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +38 -0
- package/dist/src/confirmation-bus/types.js +15 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +54 -0
- package/dist/src/core/baseLlmClient.js +190 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/baseLlmClient.test.d.ts +6 -0
- package/dist/src/core/baseLlmClient.test.js +316 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +28 -28
- package/dist/src/core/client.js +187 -333
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +745 -500
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +4 -4
- package/dist/src/core/contentGenerator.js +6 -7
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +1 -3
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +20 -7
- package/dist/src/core/coreToolScheduler.js +216 -53
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +564 -88
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +54 -43
- package/dist/src/core/geminiChat.js +298 -280
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +1255 -321
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiRequest.js +1 -0
- package/dist/src/core/geminiRequest.js.map +1 -1
- package/dist/src/core/logger.d.ts +4 -2
- package/dist/src/core/logger.js +4 -3
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +17 -16
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +3 -3
- package/dist/src/core/loggingContentGenerator.js +15 -16
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -5
- package/dist/src/core/nonInteractiveToolExecutor.js +14 -122
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +158 -78
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +4 -3
- package/dist/src/core/openaiContentGenerator.js +21 -14
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.test.js +1 -0
- package/dist/src/core/openaiContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +5 -0
- package/dist/src/core/prompts.js +66 -44
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +130 -1
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/subagent.d.ts +24 -18
- package/dist/src/core/subagent.js +125 -90
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +59 -44
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +37 -13
- package/dist/src/core/turn.js +63 -28
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +359 -100
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +129 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/handler.test.d.ts +6 -0
- package/dist/src/fallback/handler.test.js +130 -0
- package/dist/src/fallback/handler.test.js.map +1 -0
- package/dist/src/fallback/types.d.ts +14 -0
- package/dist/src/fallback/types.js +7 -0
- package/dist/src/fallback/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/ide/constants.d.ts +3 -0
- package/dist/src/ide/constants.js +3 -0
- package/dist/src/ide/constants.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +48 -12
- package/dist/src/ide/detect-ide.js +47 -66
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +79 -52
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +69 -23
- package/dist/src/ide/ide-client.js +372 -78
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +375 -30
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +2 -2
- package/dist/src/ide/ide-installer.js +37 -24
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +104 -26
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +35 -365
- package/dist/src/ide/ideContext.js +60 -106
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/ideContext.test.js +152 -24
- package/dist/src/ide/ideContext.test.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +7 -5
- package/dist/src/ide/process-utils.js +81 -50
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.d.ts +6 -0
- package/dist/src/ide/process-utils.test.js +158 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/ide/types.d.ts +486 -0
- package/dist/src/ide/types.js +138 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +20 -2
- package/dist/src/index.js +20 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +3 -3
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +17 -13
- package/dist/src/mcp/oauth-provider.js +81 -69
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +212 -37
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +14 -32
- package/dist/src/mcp/oauth-token-storage.js +54 -25
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +256 -162
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +9 -1
- package/dist/src/mcp/oauth-utils.js +42 -27
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +41 -1
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
- package/dist/src/mcp/sa-impersonation-provider.js +130 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +160 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +144 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +235 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/index.d.ts +11 -0
- package/dist/src/mcp/token-storage/index.js +12 -0
- package/dist/src/mcp/token-storage/index.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +31 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +190 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +254 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +38 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/output/json-formatter.d.ts +11 -0
- package/dist/src/output/json-formatter.js +30 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/json-formatter.test.d.ts +6 -0
- package/dist/src/output/json-formatter.test.js +266 -0
- package/dist/src/output/json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +20 -0
- package/dist/src/output/types.js +11 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/index.d.ts +7 -0
- package/dist/src/policy/index.js +8 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policy-engine.d.ts +30 -0
- package/dist/src/policy/policy-engine.js +92 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/policy-engine.test.d.ts +6 -0
- package/dist/src/policy/policy-engine.test.js +515 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -0
- package/dist/src/policy/stable-stringify.d.ts +58 -0
- package/dist/src/policy/stable-stringify.js +122 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- package/dist/src/policy/types.d.ts +47 -0
- package/dist/src/policy/types.js +12 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +2 -2
- package/dist/src/prompts/prompt-registry.d.ts +1 -1
- package/dist/src/routing/modelRouterService.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +70 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/modelRouterService.test.d.ts +6 -0
- package/dist/src/routing/modelRouterService.test.js +98 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +62 -0
- package/dist/src/routing/routingStrategy.js +7 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/classifierStrategy.js +173 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js +192 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
- package/dist/src/routing/strategies/compositeStrategy.js +68 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js +123 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/defaultStrategy.js +20 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js +26 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +25 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js +55 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
- package/dist/src/routing/strategies/overrideStrategy.js +28 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js +42 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +8 -14
- package/dist/src/services/chatRecordingService.js +33 -21
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +69 -25
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +10 -0
- package/dist/src/services/fileDiscoveryService.js +32 -18
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +3 -3
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +12 -1
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/fileSystemService.test.js +1 -1
- package/dist/src/services/fileSystemService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +3 -1
- package/dist/src/services/gitService.js +30 -24
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +30 -37
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +8 -2
- package/dist/src/services/loopDetectionService.js +64 -24
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +64 -13
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +36 -2
- package/dist/src/services/shellExecutionService.js +238 -47
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +197 -58
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +34 -4
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +322 -15
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +321 -11
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +51 -2
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +124 -2
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.d.ts +31 -0
- package/dist/src/telemetry/config.js +76 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/config.test.d.ts +6 -0
- package/dist/src/telemetry/config.test.js +124 -0
- package/dist/src/telemetry/config.test.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +17 -7
- package/dist/src/telemetry/constants.js +18 -7
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/file-exporters.d.ts +5 -4
- package/dist/src/telemetry/file-exporters.js +1 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +34 -0
- package/dist/src/telemetry/gcp-exporters.js +117 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/gcp-exporters.test.js +318 -0
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +6 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js +152 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +12 -2
- package/dist/src/telemetry/index.js +16 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +17 -2
- package/dist/src/telemetry/loggers.js +316 -14
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -3
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +452 -48
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +323 -12
- package/dist/src/telemetry/metrics.js +464 -83
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +583 -38
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/rate-limiter.d.ts +48 -0
- package/dist/src/telemetry/rate-limiter.js +100 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.test.d.ts +6 -0
- package/dist/src/telemetry/rate-limiter.test.js +207 -0
- package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +1 -1
- package/dist/src/telemetry/sdk.js +20 -2
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +108 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +40 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +136 -8
- package/dist/src/telemetry/types.js +233 -11
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +3 -3
- package/dist/src/telemetry/uiTelemetry.js +7 -8
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +33 -29
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +2 -1
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +66 -0
- package/dist/src/test-utils/{tools.js → mock-tool.js} +45 -29
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +1 -1
- package/dist/src/tools/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +21 -13
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +58 -22
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +6 -5
- package/dist/src/tools/edit.js +58 -40
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +192 -16
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +7 -2
- package/dist/src/tools/glob.js +42 -23
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +80 -4
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +3 -2
- package/dist/src/tools/grep.js +35 -15
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +26 -3
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +3 -2
- package/dist/src/tools/ls.js +31 -39
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +145 -280
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +8 -6
- package/dist/src/tools/mcp-client-manager.js +13 -4
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +20 -1
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +18 -21
- package/dist/src/tools/mcp-client.js +87 -120
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +32 -152
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +6 -4
- package/dist/src/tools/mcp-tool.js +51 -13
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +166 -12
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +3 -2
- package/dist/src/tools/memoryTool.js +14 -37
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +16 -4
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.d.ts +6 -0
- package/dist/src/tools/message-bus-integration.test.js +183 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +2 -2
- package/dist/src/tools/modifiable-tool.js +3 -3
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +4 -4
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +3 -2
- package/dist/src/tools/read-file.js +33 -43
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +39 -7
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +3 -2
- package/dist/src/tools/read-many-files.js +52 -107
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +64 -11
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +55 -0
- package/dist/src/tools/ripGrep.js +393 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +976 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +13 -2
- package/dist/src/tools/shell.js +42 -32
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +57 -75
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +91 -0
- package/dist/src/tools/smart-edit.js +702 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +6 -0
- package/dist/src/tools/smart-edit.test.js +542 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +18 -1
- package/dist/src/tools/tool-error.js +27 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +10 -4
- package/dist/src/tools/tool-registry.js +20 -7
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +93 -10
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +33 -16
- package/dist/src/tools/tools.js +115 -5
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +1 -2
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +3 -2
- package/dist/src/tools/web-fetch.js +14 -10
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +55 -16
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +4 -3
- package/dist/src/tools/web-search.js +31 -8
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +69 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +4 -3
- package/dist/src/tools/write-file.js +17 -18
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +108 -24
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +25 -0
- package/dist/src/tools/write-todos.js +150 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/tools/write-todos.test.d.ts +6 -0
- package/dist/src/tools/write-todos.test.js +89 -0
- package/dist/src/tools/write-todos.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +2 -2
- package/dist/src/utils/bfsFileSearch.js +13 -7
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +3 -3
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/editCorrector.d.ts +9 -8
- package/dist/src/utils/editCorrector.js +62 -19
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +33 -82
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.js +32 -45
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +62 -76
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +2 -2
- package/dist/src/utils/errorParsing.js +2 -2
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +7 -7
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errors.d.ts +25 -0
- package/dist/src/utils/errors.js +42 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/fetch.js +1 -1
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +24 -12
- package/dist/src/utils/fileUtils.js +170 -79
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +347 -29
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +2 -2
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +14 -9
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/{flashFallback.integration.test.js → flashFallback.test.js} +33 -29
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.d.ts +18 -0
- package/dist/src/utils/geminiIgnoreParser.js +61 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/geminiIgnoreParser.test.js +50 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
- package/dist/src/utils/generateContentResponseUtilities.js +1 -13
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.d.ts +2 -2
- package/dist/src/utils/getFolderStructure.js +3 -3
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +4 -4
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.d.ts +3 -7
- package/dist/src/utils/gitIgnoreParser.js +126 -35
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +69 -38
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/gitUtils.js +2 -2
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +250 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +50 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +6 -0
- package/dist/src/utils/installationManager.test.js +83 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +26 -0
- package/dist/src/utils/llm-edit-fixer.js +131 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.test.d.ts +6 -0
- package/dist/src/utils/llm-edit-fixer.test.js +186 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +7 -6
- package/dist/src/utils/memoryDiscovery.js +68 -33
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +88 -26
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +15 -22
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +16 -141
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/messageInspectors.d.ts +1 -1
- package/dist/src/utils/nextSpeakerChecker.d.ts +3 -3
- package/dist/src/utils/nextSpeakerChecker.js +8 -2
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +75 -64
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/partUtils.d.ts +22 -1
- package/dist/src/utils/partUtils.js +68 -0
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/partUtils.test.js +112 -1
- package/dist/src/utils/partUtils.test.js.map +1 -1
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +363 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +0 -17
- package/dist/src/utils/paths.js +2 -28
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/promptIdContext.d.ts +7 -0
- package/dist/src/utils/promptIdContext.js +8 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +1 -1
- package/dist/src/utils/retry.d.ts +3 -1
- package/dist/src/utils/retry.js +60 -5
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +35 -3
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +15 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +113 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -0
- package/dist/src/utils/session.js +1 -1
- package/dist/src/utils/session.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +6 -1
- package/dist/src/utils/shell-utils.js +51 -30
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +9 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/summarizer.d.ts +2 -2
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +2 -2
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +2 -2
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +25 -0
- package/dist/src/utils/terminalSerializer.js +432 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/terminalSerializer.test.d.ts +6 -0
- package/dist/src/utils/terminalSerializer.test.js +176 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +5 -0
- package/dist/src/utils/textUtils.js +14 -0
- package/dist/src/utils/textUtils.js.map +1 -1
- package/dist/src/utils/textUtils.test.d.ts +6 -0
- package/dist/src/utils/textUtils.test.js +59 -0
- package/dist/src/utils/textUtils.test.js.map +1 -0
- package/dist/src/utils/thoughtUtils.d.ts +21 -0
- package/dist/src/utils/thoughtUtils.js +39 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.test.d.ts +6 -0
- package/dist/src/utils/thoughtUtils.test.js +78 -0
- package/dist/src/utils/thoughtUtils.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +19 -0
- package/dist/src/utils/tool-utils.js +58 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +6 -0
- package/dist/src/utils/tool-utils.test.js +61 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +114 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +33 -30
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.js +13 -7
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +41 -16
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -9
- package/dist/src/core/modelCheck.d.ts +0 -14
- package/dist/src/core/modelCheck.js +0 -62
- package/dist/src/core/modelCheck.js.map +0 -1
- package/dist/src/test-utils/tools.d.ts +0 -44
- package/dist/src/test-utils/tools.js.map +0 -1
- package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
- package/dist/src/utils/user_account.d.ts +0 -9
- package/dist/src/utils/user_account.js +0 -109
- package/dist/src/utils/user_account.js.map +0 -1
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.d.ts +0 -11
- package/dist/src/utils/user_id.js +0 -49
- package/dist/src/utils/user_id.js.map +0 -1
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- /package/dist/src/{utils/flashFallback.integration.test.d.ts → agents/executor.test.d.ts} +0 -0
- /package/dist/src/{utils/user_account.test.d.ts → agents/invocation.test.d.ts} +0 -0
- /package/dist/src/{utils/user_id.test.d.ts → agents/registry.test.d.ts} +0 -0
|
@@ -5,12 +5,31 @@
|
|
|
5
5
|
*/
|
|
6
6
|
// DISCLAIMER: This is a copied version of https://github.com/googleapis/js-genai/blob/main/src/chats.ts with the intention of working around a key bug
|
|
7
7
|
// where function responses are not treated as "valid" responses: https://b.corp.google.com/issues/420354090
|
|
8
|
-
import {
|
|
8
|
+
import { GenerateContentResponse, FinishReason, ApiError, } from '@google/genai';
|
|
9
|
+
import { toParts } from '../code_assist/converter.js';
|
|
10
|
+
import { createUserContent } from '@google/genai';
|
|
9
11
|
import { retryWithBackoff } from '../utils/retry.js';
|
|
12
|
+
import { DEFAULT_GEMINI_FLASH_MODEL, getEffectiveModel, } from '../config/models.js';
|
|
13
|
+
import { hasCycleInSchema, MUTATOR_KINDS } from '../tools/tools.js';
|
|
14
|
+
import { logContentRetry, logContentRetryFailure, } from '../telemetry/loggers.js';
|
|
15
|
+
import { ChatRecordingService } from '../services/chatRecordingService.js';
|
|
16
|
+
import { ContentRetryEvent, ContentRetryFailureEvent, } from '../telemetry/types.js';
|
|
17
|
+
import { handleFallback } from '../fallback/handler.js';
|
|
10
18
|
import { isFunctionResponse } from '../utils/messageInspectors.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
19
|
+
import { partListUnionToString } from './geminiRequest.js';
|
|
20
|
+
import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
|
|
21
|
+
export var StreamEventType;
|
|
22
|
+
(function (StreamEventType) {
|
|
23
|
+
/** A regular content chunk from the API. */
|
|
24
|
+
StreamEventType["CHUNK"] = "chunk";
|
|
25
|
+
/** A signal that a retry is about to happen. The UI should discard any partial
|
|
26
|
+
* content from the attempt that just failed. */
|
|
27
|
+
StreamEventType["RETRY"] = "retry";
|
|
28
|
+
})(StreamEventType || (StreamEventType = {}));
|
|
29
|
+
const INVALID_CONTENT_RETRY_OPTIONS = {
|
|
30
|
+
maxAttempts: 2, // 1 initial call + 1 retry
|
|
31
|
+
initialDelayMs: 500,
|
|
32
|
+
};
|
|
14
33
|
/**
|
|
15
34
|
* Returns true if the response is valid, false otherwise.
|
|
16
35
|
*/
|
|
@@ -24,6 +43,16 @@ function isValidResponse(response) {
|
|
|
24
43
|
}
|
|
25
44
|
return isValidContent(content);
|
|
26
45
|
}
|
|
46
|
+
export function isValidNonThoughtTextPart(part) {
|
|
47
|
+
return (typeof part.text === 'string' &&
|
|
48
|
+
!part.thought &&
|
|
49
|
+
// Technically, the model should never generate parts that have text and
|
|
50
|
+
// any of these but we don't trust them so check anyways.
|
|
51
|
+
!part.functionCall &&
|
|
52
|
+
!part.functionResponse &&
|
|
53
|
+
!part.inlineData &&
|
|
54
|
+
!part.fileData);
|
|
55
|
+
}
|
|
27
56
|
function isValidContent(content) {
|
|
28
57
|
if (content.parts === undefined || content.parts.length === 0) {
|
|
29
58
|
return false;
|
|
@@ -84,14 +113,22 @@ function extractCuratedHistory(comprehensiveHistory) {
|
|
|
84
113
|
if (isValid) {
|
|
85
114
|
curatedHistory.push(...modelOutput);
|
|
86
115
|
}
|
|
87
|
-
else {
|
|
88
|
-
// Remove the last user input when model content is invalid.
|
|
89
|
-
curatedHistory.pop();
|
|
90
|
-
}
|
|
91
116
|
}
|
|
92
117
|
}
|
|
93
118
|
return curatedHistory;
|
|
94
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Custom error to signal that a stream completed with invalid content,
|
|
122
|
+
* which should trigger a retry.
|
|
123
|
+
*/
|
|
124
|
+
export class InvalidStreamError extends Error {
|
|
125
|
+
type;
|
|
126
|
+
constructor(message, type) {
|
|
127
|
+
super(message);
|
|
128
|
+
this.name = 'InvalidStreamError';
|
|
129
|
+
this.type = type;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
95
132
|
/**
|
|
96
133
|
* Chat session that enables sending messages to the model with previous
|
|
97
134
|
* conversation context.
|
|
@@ -101,139 +138,23 @@ function extractCuratedHistory(comprehensiveHistory) {
|
|
|
101
138
|
*/
|
|
102
139
|
export class GeminiChat {
|
|
103
140
|
config;
|
|
104
|
-
contentGenerator;
|
|
105
141
|
generationConfig;
|
|
106
142
|
history;
|
|
107
143
|
// A promise to represent the current state of the message being sent to the
|
|
108
144
|
// model.
|
|
109
145
|
sendPromise = Promise.resolve();
|
|
110
|
-
|
|
146
|
+
chatRecordingService;
|
|
147
|
+
constructor(config, generationConfig = {}, history = []) {
|
|
111
148
|
this.config = config;
|
|
112
|
-
this.contentGenerator = contentGenerator;
|
|
113
149
|
this.generationConfig = generationConfig;
|
|
114
150
|
this.history = history;
|
|
115
151
|
validateHistory(history);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
* Handles falling back to Flash model when persistent 429 errors occur for OAuth users.
|
|
119
|
-
* Uses a fallback handler if provided by the config; otherwise, returns null.
|
|
120
|
-
*/
|
|
121
|
-
async handleFlashFallback(authType, error) {
|
|
122
|
-
// Only handle fallback for OAuth users
|
|
123
|
-
if (authType !== AuthType.LOGIN_WITH_GOOGLE) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
const currentModel = this.config.getModel();
|
|
127
|
-
const fallbackModel = DEFAULT_GEMINI_FLASH_MODEL;
|
|
128
|
-
// Don't fallback if already using Flash model
|
|
129
|
-
if (currentModel === fallbackModel) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
// Check if config has a fallback handler (set by CLI package)
|
|
133
|
-
const fallbackHandler = this.config.flashFallbackHandler;
|
|
134
|
-
if (typeof fallbackHandler === 'function') {
|
|
135
|
-
try {
|
|
136
|
-
const accepted = await fallbackHandler(currentModel, fallbackModel, error);
|
|
137
|
-
if (accepted !== false && accepted !== null) {
|
|
138
|
-
this.config.setModel(fallbackModel);
|
|
139
|
-
this.config.setFallbackMode(true);
|
|
140
|
-
return fallbackModel;
|
|
141
|
-
}
|
|
142
|
-
// Check if the model was switched manually in the handler
|
|
143
|
-
if (this.config.getModel() === fallbackModel) {
|
|
144
|
-
return null; // Model was switched but don't continue with current prompt
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
console.warn('Flash fallback handler failed:', error);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
152
|
+
this.chatRecordingService = new ChatRecordingService(config);
|
|
153
|
+
this.chatRecordingService.initialize();
|
|
152
154
|
}
|
|
153
155
|
setSystemInstruction(sysInstr) {
|
|
154
156
|
this.generationConfig.systemInstruction = sysInstr;
|
|
155
157
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Sends a message to the model and returns the response.
|
|
158
|
-
*
|
|
159
|
-
* @remarks
|
|
160
|
-
* This method will wait for the previous message to be processed before
|
|
161
|
-
* sending the next message.
|
|
162
|
-
*
|
|
163
|
-
* @see {@link Chat#sendMessageStream} for streaming method.
|
|
164
|
-
* @param params - parameters for sending messages within a chat session.
|
|
165
|
-
* @returns The model's response.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```ts
|
|
169
|
-
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
170
|
-
* const response = await chat.sendMessage({
|
|
171
|
-
* message: 'Why is the sky blue?'
|
|
172
|
-
* });
|
|
173
|
-
* console.log(response.text);
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
async sendMessage(params, prompt_id) {
|
|
177
|
-
await this.sendPromise;
|
|
178
|
-
const userContent = createUserContent(params.message);
|
|
179
|
-
const requestContents = this.getHistory(true).concat(userContent);
|
|
180
|
-
let response;
|
|
181
|
-
try {
|
|
182
|
-
const apiCall = () => {
|
|
183
|
-
const modelToUse = this.config.getModel() || DEFAULT_GEMINI_FLASH_MODEL;
|
|
184
|
-
// Prevent Flash model calls immediately after quota error
|
|
185
|
-
if (this.config.getQuotaErrorOccurred() &&
|
|
186
|
-
modelToUse === DEFAULT_GEMINI_FLASH_MODEL) {
|
|
187
|
-
throw new Error('Please submit a new query to continue with the Flash model.');
|
|
188
|
-
}
|
|
189
|
-
return this.contentGenerator.generateContent({
|
|
190
|
-
model: modelToUse,
|
|
191
|
-
contents: requestContents,
|
|
192
|
-
config: { ...this.generationConfig, ...params.config },
|
|
193
|
-
}, prompt_id);
|
|
194
|
-
};
|
|
195
|
-
response = await retryWithBackoff(apiCall, {
|
|
196
|
-
shouldRetry: (error) => {
|
|
197
|
-
// Check for known error messages and codes.
|
|
198
|
-
if (error instanceof Error && error.message) {
|
|
199
|
-
if (isSchemaDepthError(error.message))
|
|
200
|
-
return false;
|
|
201
|
-
if (error.message.includes('429'))
|
|
202
|
-
return true;
|
|
203
|
-
if (error.message.match(/5\d{2}/))
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
return false; // Don't retry other errors by default
|
|
207
|
-
},
|
|
208
|
-
onPersistent429: async (authType, error) => await this.handleFlashFallback(authType, error),
|
|
209
|
-
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
210
|
-
});
|
|
211
|
-
this.sendPromise = (async () => {
|
|
212
|
-
const outputContent = response.candidates?.[0]?.content;
|
|
213
|
-
// Because the AFC input contains the entire curated chat history in
|
|
214
|
-
// addition to the new user input, we need to truncate the AFC history
|
|
215
|
-
// to deduplicate the existing chat history.
|
|
216
|
-
const fullAutomaticFunctionCallingHistory = response.automaticFunctionCallingHistory;
|
|
217
|
-
const index = this.getHistory(true).length;
|
|
218
|
-
let automaticFunctionCallingHistory = [];
|
|
219
|
-
if (fullAutomaticFunctionCallingHistory != null) {
|
|
220
|
-
automaticFunctionCallingHistory =
|
|
221
|
-
fullAutomaticFunctionCallingHistory.slice(index) ?? [];
|
|
222
|
-
}
|
|
223
|
-
const modelOutput = outputContent ? [outputContent] : [];
|
|
224
|
-
this.recordHistory(userContent, modelOutput, automaticFunctionCallingHistory);
|
|
225
|
-
})();
|
|
226
|
-
await this.sendPromise.catch(() => {
|
|
227
|
-
// Resets sendPromise to avoid subsequent calls failing
|
|
228
|
-
this.sendPromise = Promise.resolve();
|
|
229
|
-
});
|
|
230
|
-
return response;
|
|
231
|
-
}
|
|
232
|
-
catch (error) {
|
|
233
|
-
this.sendPromise = Promise.resolve();
|
|
234
|
-
throw error;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
158
|
/**
|
|
238
159
|
* Sends a message to the model and returns the response in chunks.
|
|
239
160
|
*
|
|
@@ -249,64 +170,113 @@ export class GeminiChat {
|
|
|
249
170
|
* ```ts
|
|
250
171
|
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
251
172
|
* const response = await chat.sendMessageStream({
|
|
252
|
-
*
|
|
173
|
+
* message: 'Why is the sky blue?'
|
|
253
174
|
* });
|
|
254
175
|
* for await (const chunk of response) {
|
|
255
|
-
*
|
|
176
|
+
* console.log(chunk.text);
|
|
256
177
|
* }
|
|
257
178
|
* ```
|
|
258
179
|
*/
|
|
259
|
-
async sendMessageStream(params, prompt_id) {
|
|
180
|
+
async sendMessageStream(model, params, prompt_id) {
|
|
260
181
|
await this.sendPromise;
|
|
182
|
+
let streamDoneResolver;
|
|
183
|
+
const streamDonePromise = new Promise((resolve) => {
|
|
184
|
+
streamDoneResolver = resolve;
|
|
185
|
+
});
|
|
186
|
+
this.sendPromise = streamDonePromise;
|
|
261
187
|
const userContent = createUserContent(params.message);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
contents: requestContents,
|
|
274
|
-
config: { ...this.generationConfig, ...params.config },
|
|
275
|
-
}, prompt_id);
|
|
276
|
-
};
|
|
277
|
-
// Note: Retrying streams can be complex. If generateContentStream itself doesn't handle retries
|
|
278
|
-
// for transient issues internally before yielding the async generator, this retry will re-initiate
|
|
279
|
-
// the stream. For simple 429/500 errors on initial call, this is fine.
|
|
280
|
-
// If errors occur mid-stream, this setup won't resume the stream; it will restart it.
|
|
281
|
-
const streamResponse = await retryWithBackoff(apiCall, {
|
|
282
|
-
shouldRetry: (error) => {
|
|
283
|
-
// Check for known error messages and codes.
|
|
284
|
-
if (error instanceof Error && error.message) {
|
|
285
|
-
if (isSchemaDepthError(error.message))
|
|
286
|
-
return false;
|
|
287
|
-
if (error.message.includes('429'))
|
|
288
|
-
return true;
|
|
289
|
-
if (error.message.match(/5\d{2}/))
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
return false; // Don't retry other errors by default
|
|
293
|
-
},
|
|
294
|
-
onPersistent429: async (authType, error) => await this.handleFlashFallback(authType, error),
|
|
295
|
-
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
188
|
+
// Record user input - capture complete message with all parts (text, files, images, etc.)
|
|
189
|
+
// but skip recording function responses (tool call results) as they should be stored in tool call records
|
|
190
|
+
if (!isFunctionResponse(userContent)) {
|
|
191
|
+
const userMessage = Array.isArray(params.message)
|
|
192
|
+
? params.message
|
|
193
|
+
: [params.message];
|
|
194
|
+
const userMessageContent = partListUnionToString(toParts(userMessage));
|
|
195
|
+
this.chatRecordingService.recordMessage({
|
|
196
|
+
model,
|
|
197
|
+
type: 'user',
|
|
198
|
+
content: userMessageContent,
|
|
296
199
|
});
|
|
297
|
-
// Resolve the internal tracking of send completion promise - `sendPromise`
|
|
298
|
-
// for both success and failure response. The actual failure is still
|
|
299
|
-
// propagated by the `await streamResponse`.
|
|
300
|
-
this.sendPromise = Promise.resolve(streamResponse)
|
|
301
|
-
.then(() => undefined)
|
|
302
|
-
.catch(() => undefined);
|
|
303
|
-
const result = this.processStreamResponse(streamResponse, userContent);
|
|
304
|
-
return result;
|
|
305
|
-
}
|
|
306
|
-
catch (error) {
|
|
307
|
-
this.sendPromise = Promise.resolve();
|
|
308
|
-
throw error;
|
|
309
200
|
}
|
|
201
|
+
// Add user content to history ONCE before any attempts.
|
|
202
|
+
this.history.push(userContent);
|
|
203
|
+
const requestContents = this.getHistory(true);
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
205
|
+
const self = this;
|
|
206
|
+
return (async function* () {
|
|
207
|
+
try {
|
|
208
|
+
let lastError = new Error('Request failed after all retries.');
|
|
209
|
+
for (let attempt = 0; attempt < INVALID_CONTENT_RETRY_OPTIONS.maxAttempts; attempt++) {
|
|
210
|
+
try {
|
|
211
|
+
if (attempt > 0) {
|
|
212
|
+
yield { type: StreamEventType.RETRY };
|
|
213
|
+
}
|
|
214
|
+
const stream = await self.makeApiCallAndProcessStream(model, requestContents, params, prompt_id);
|
|
215
|
+
for await (const chunk of stream) {
|
|
216
|
+
yield { type: StreamEventType.CHUNK, value: chunk };
|
|
217
|
+
}
|
|
218
|
+
lastError = null;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
lastError = error;
|
|
223
|
+
const isContentError = error instanceof InvalidStreamError;
|
|
224
|
+
if (isContentError) {
|
|
225
|
+
// Check if we have more attempts left.
|
|
226
|
+
if (attempt < INVALID_CONTENT_RETRY_OPTIONS.maxAttempts - 1) {
|
|
227
|
+
logContentRetry(self.config, new ContentRetryEvent(attempt, error.type, INVALID_CONTENT_RETRY_OPTIONS.initialDelayMs, model));
|
|
228
|
+
await new Promise((res) => setTimeout(res, INVALID_CONTENT_RETRY_OPTIONS.initialDelayMs *
|
|
229
|
+
(attempt + 1)));
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (lastError) {
|
|
237
|
+
if (lastError instanceof InvalidStreamError) {
|
|
238
|
+
logContentRetryFailure(self.config, new ContentRetryFailureEvent(INVALID_CONTENT_RETRY_OPTIONS.maxAttempts, lastError.type, model));
|
|
239
|
+
}
|
|
240
|
+
throw lastError;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
finally {
|
|
244
|
+
streamDoneResolver();
|
|
245
|
+
}
|
|
246
|
+
})();
|
|
247
|
+
}
|
|
248
|
+
async makeApiCallAndProcessStream(model, requestContents, params, prompt_id) {
|
|
249
|
+
const apiCall = () => {
|
|
250
|
+
const modelToUse = getEffectiveModel(this.config.isInFallbackMode(), model);
|
|
251
|
+
if (this.config.getQuotaErrorOccurred() &&
|
|
252
|
+
modelToUse === DEFAULT_GEMINI_FLASH_MODEL) {
|
|
253
|
+
throw new Error('Please submit a new query to continue with the Flash model.');
|
|
254
|
+
}
|
|
255
|
+
return this.config.getContentGenerator().generateContentStream({
|
|
256
|
+
model: modelToUse,
|
|
257
|
+
contents: requestContents,
|
|
258
|
+
config: { ...this.generationConfig, ...params.config },
|
|
259
|
+
}, prompt_id);
|
|
260
|
+
};
|
|
261
|
+
const onPersistent429Callback = async (authType, error) => await handleFallback(this.config, model, authType, error);
|
|
262
|
+
const streamResponse = await retryWithBackoff(apiCall, {
|
|
263
|
+
shouldRetryOnError: (error) => {
|
|
264
|
+
if (error instanceof ApiError && error.message) {
|
|
265
|
+
if (error.status === 400)
|
|
266
|
+
return false;
|
|
267
|
+
if (isSchemaDepthError(error.message))
|
|
268
|
+
return false;
|
|
269
|
+
if (error.status === 429)
|
|
270
|
+
return true;
|
|
271
|
+
if (error.status >= 500 && error.status < 600)
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
},
|
|
276
|
+
onPersistent429: onPersistent429Callback,
|
|
277
|
+
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
278
|
+
});
|
|
279
|
+
return this.processStreamResponse(model, streamResponse);
|
|
310
280
|
}
|
|
311
281
|
/**
|
|
312
282
|
* Returns the chat history.
|
|
@@ -318,7 +288,7 @@ export class GeminiChat {
|
|
|
318
288
|
* - The `curated history` contains only the valid turns between user and
|
|
319
289
|
* model, which will be included in the subsequent requests sent to the model.
|
|
320
290
|
* - The `comprehensive history` contains all turns, including invalid or
|
|
321
|
-
*
|
|
291
|
+
* empty model outputs, providing a complete record of the history.
|
|
322
292
|
*
|
|
323
293
|
* The history is updated after receiving the response from the model,
|
|
324
294
|
* for streaming response, it means receiving the last chunk of the response.
|
|
@@ -327,9 +297,9 @@ export class GeminiChat {
|
|
|
327
297
|
* history`, set the `curated` parameter to `true`.
|
|
328
298
|
*
|
|
329
299
|
* @param curated - whether to return the curated history or the comprehensive
|
|
330
|
-
*
|
|
300
|
+
* history.
|
|
331
301
|
* @return History contents alternating between user and model for the entire
|
|
332
|
-
*
|
|
302
|
+
* chat session.
|
|
333
303
|
*/
|
|
334
304
|
getHistory(curated = false) {
|
|
335
305
|
const history = curated
|
|
@@ -347,8 +317,6 @@ export class GeminiChat {
|
|
|
347
317
|
}
|
|
348
318
|
/**
|
|
349
319
|
* Adds a new entry to the chat history.
|
|
350
|
-
*
|
|
351
|
-
* @param content - The content to add to the history.
|
|
352
320
|
*/
|
|
353
321
|
addHistory(content) {
|
|
354
322
|
this.history.push(content);
|
|
@@ -356,6 +324,22 @@ export class GeminiChat {
|
|
|
356
324
|
setHistory(history) {
|
|
357
325
|
this.history = history;
|
|
358
326
|
}
|
|
327
|
+
stripThoughtsFromHistory() {
|
|
328
|
+
this.history = this.history.map((content) => {
|
|
329
|
+
const newContent = { ...content };
|
|
330
|
+
if (newContent.parts) {
|
|
331
|
+
newContent.parts = newContent.parts.map((part) => {
|
|
332
|
+
if (part && typeof part === 'object' && 'thoughtSignature' in part) {
|
|
333
|
+
const newPart = { ...part };
|
|
334
|
+
delete newPart.thoughtSignature;
|
|
335
|
+
return newPart;
|
|
336
|
+
}
|
|
337
|
+
return part;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
return newContent;
|
|
341
|
+
});
|
|
342
|
+
}
|
|
359
343
|
setTools(tools) {
|
|
360
344
|
this.generationConfig.tools = tools;
|
|
361
345
|
}
|
|
@@ -381,122 +365,156 @@ export class GeminiChat {
|
|
|
381
365
|
}
|
|
382
366
|
}
|
|
383
367
|
}
|
|
384
|
-
async *processStreamResponse(
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
let
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
368
|
+
async *processStreamResponse(model, streamResponse) {
|
|
369
|
+
const modelResponseParts = [];
|
|
370
|
+
let hasToolCall = false;
|
|
371
|
+
let hasFinishReason = false;
|
|
372
|
+
for await (const chunk of this.stopBeforeSecondMutator(streamResponse)) {
|
|
373
|
+
hasFinishReason =
|
|
374
|
+
chunk?.candidates?.some((candidate) => candidate.finishReason) ?? false;
|
|
375
|
+
if (isValidResponse(chunk)) {
|
|
376
|
+
const content = chunk.candidates?.[0]?.content;
|
|
377
|
+
if (content?.parts) {
|
|
378
|
+
if (content.parts.some((part) => part.thought)) {
|
|
379
|
+
// Record thoughts
|
|
380
|
+
this.recordThoughtFromContent(content);
|
|
381
|
+
}
|
|
382
|
+
if (content.parts.some((part) => part.functionCall)) {
|
|
383
|
+
hasToolCall = true;
|
|
399
384
|
}
|
|
385
|
+
modelResponseParts.push(...content.parts.filter((part) => !part.thought));
|
|
400
386
|
}
|
|
401
|
-
yield chunk;
|
|
402
387
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (!errorOccurred) {
|
|
409
|
-
const allParts = [];
|
|
410
|
-
for (const content of outputContent) {
|
|
411
|
-
if (content.parts) {
|
|
412
|
-
allParts.push(...content.parts);
|
|
388
|
+
// Record token usage if this chunk has usageMetadata
|
|
389
|
+
if (chunk.usageMetadata) {
|
|
390
|
+
this.chatRecordingService.recordMessageTokens(chunk.usageMetadata);
|
|
391
|
+
if (chunk.usageMetadata.promptTokenCount !== undefined) {
|
|
392
|
+
uiTelemetryService.setLastPromptTokenCount(chunk.usageMetadata.promptTokenCount);
|
|
413
393
|
}
|
|
414
394
|
}
|
|
395
|
+
yield chunk; // Yield every chunk to the UI immediately.
|
|
415
396
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
397
|
+
// String thoughts and consolidate text parts.
|
|
398
|
+
const consolidatedParts = [];
|
|
399
|
+
for (const part of modelResponseParts) {
|
|
400
|
+
const lastPart = consolidatedParts[consolidatedParts.length - 1];
|
|
401
|
+
if (lastPart?.text &&
|
|
402
|
+
isValidNonThoughtTextPart(lastPart) &&
|
|
403
|
+
isValidNonThoughtTextPart(part)) {
|
|
404
|
+
lastPart.text += part.text;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
consolidatedParts.push(part);
|
|
408
|
+
}
|
|
424
409
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
410
|
+
const responseText = consolidatedParts
|
|
411
|
+
.filter((part) => part.text)
|
|
412
|
+
.map((part) => part.text)
|
|
413
|
+
.join('')
|
|
414
|
+
.trim();
|
|
415
|
+
// Record model response text from the collected parts
|
|
416
|
+
if (responseText) {
|
|
417
|
+
this.chatRecordingService.recordMessage({
|
|
418
|
+
model,
|
|
419
|
+
type: 'gemini',
|
|
420
|
+
content: responseText,
|
|
421
|
+
});
|
|
428
422
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
423
|
+
// Stream validation logic: A stream is considered successful if:
|
|
424
|
+
// 1. There's a tool call (tool calls can end without explicit finish reasons), OR
|
|
425
|
+
// 2. There's a finish reason AND we have non-empty response text
|
|
426
|
+
//
|
|
427
|
+
// We throw an error only when there's no tool call AND:
|
|
428
|
+
// - No finish reason, OR
|
|
429
|
+
// - Empty response text (e.g., only thoughts with no actual content)
|
|
430
|
+
if (!hasToolCall && (!hasFinishReason || !responseText)) {
|
|
431
|
+
if (!hasFinishReason) {
|
|
432
|
+
throw new InvalidStreamError('Model stream ended without a finish reason.', 'NO_FINISH_REASON');
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
throw new InvalidStreamError('Model stream ended with empty response text.', 'NO_RESPONSE_TEXT');
|
|
438
436
|
}
|
|
439
437
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
438
|
+
this.history.push({ role: 'model', parts: consolidatedParts });
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Gets the chat recording service instance.
|
|
442
|
+
*/
|
|
443
|
+
getChatRecordingService() {
|
|
444
|
+
return this.chatRecordingService;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Extracts and records thought from thought content.
|
|
448
|
+
*/
|
|
449
|
+
recordThoughtFromContent(content) {
|
|
450
|
+
if (!content.parts || content.parts.length === 0) {
|
|
451
|
+
return;
|
|
443
452
|
}
|
|
444
|
-
|
|
445
|
-
|
|
453
|
+
const thoughtPart = content.parts[0];
|
|
454
|
+
if (thoughtPart.text) {
|
|
455
|
+
// Extract subject and description using the same logic as turn.ts
|
|
456
|
+
const rawText = thoughtPart.text;
|
|
457
|
+
const subjectStringMatches = rawText.match(/\*\*(.*?)\*\*/s);
|
|
458
|
+
const subject = subjectStringMatches
|
|
459
|
+
? subjectStringMatches[1].trim()
|
|
460
|
+
: '';
|
|
461
|
+
const description = rawText.replace(/\*\*(.*?)\*\*/s, '').trim();
|
|
462
|
+
this.chatRecordingService.recordThought({
|
|
463
|
+
subject,
|
|
464
|
+
description,
|
|
465
|
+
});
|
|
446
466
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Truncates the chunkStream right before the second function call to a
|
|
470
|
+
* function that mutates state. This may involve trimming parts from a chunk
|
|
471
|
+
* as well as omtting some chunks altogether.
|
|
472
|
+
*
|
|
473
|
+
* We do this because it improves tool call quality if the model gets
|
|
474
|
+
* feedback from one mutating function call before it makes the next one.
|
|
475
|
+
*/
|
|
476
|
+
async *stopBeforeSecondMutator(chunkStream) {
|
|
477
|
+
let foundMutatorFunctionCall = false;
|
|
478
|
+
for await (const chunk of chunkStream) {
|
|
479
|
+
const candidate = chunk.candidates?.[0];
|
|
480
|
+
const content = candidate?.content;
|
|
481
|
+
if (!candidate || !content?.parts) {
|
|
482
|
+
yield chunk;
|
|
451
483
|
continue;
|
|
452
484
|
}
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
// and append any other parts from the current content.
|
|
475
|
-
lastHistoryEntry.parts[0].text +=
|
|
476
|
-
consolidatedOutputContents[0].parts[0].text || '';
|
|
477
|
-
if (consolidatedOutputContents[0].parts.length > 1) {
|
|
478
|
-
lastHistoryEntry.parts.push(...consolidatedOutputContents[0].parts.slice(1));
|
|
485
|
+
const truncatedParts = [];
|
|
486
|
+
for (const part of content.parts) {
|
|
487
|
+
if (this.isMutatorFunctionCall(part)) {
|
|
488
|
+
if (foundMutatorFunctionCall) {
|
|
489
|
+
// This is the second mutator call.
|
|
490
|
+
// Truncate and return immedaitely.
|
|
491
|
+
const newChunk = new GenerateContentResponse();
|
|
492
|
+
newChunk.candidates = [
|
|
493
|
+
{
|
|
494
|
+
...candidate,
|
|
495
|
+
content: {
|
|
496
|
+
...content,
|
|
497
|
+
parts: truncatedParts,
|
|
498
|
+
},
|
|
499
|
+
finishReason: FinishReason.STOP,
|
|
500
|
+
},
|
|
501
|
+
];
|
|
502
|
+
yield newChunk;
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
foundMutatorFunctionCall = true;
|
|
479
506
|
}
|
|
480
|
-
|
|
507
|
+
truncatedParts.push(part);
|
|
481
508
|
}
|
|
482
|
-
|
|
509
|
+
yield chunk;
|
|
483
510
|
}
|
|
484
511
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
content.parts[0].text !== '');
|
|
492
|
-
}
|
|
493
|
-
isThoughtContent(content) {
|
|
494
|
-
return !!(content &&
|
|
495
|
-
content.role === 'model' &&
|
|
496
|
-
content.parts &&
|
|
497
|
-
content.parts.length > 0 &&
|
|
498
|
-
typeof content.parts[0].thought === 'boolean' &&
|
|
499
|
-
content.parts[0].thought === true);
|
|
512
|
+
isMutatorFunctionCall(part) {
|
|
513
|
+
if (!part?.functionCall?.name) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
const tool = this.config.getToolRegistry().getTool(part.functionCall.name);
|
|
517
|
+
return !!tool && MUTATOR_KINDS.includes(tool.kind);
|
|
500
518
|
}
|
|
501
519
|
}
|
|
502
520
|
/** Visible for Testing */
|