@office-ai/aioncli-core 0.2.3 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16 -3
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +46 -0
- package/dist/src/agents/codebase-investigator.js +132 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/codebase-investigator.test.js +35 -0
- package/dist/src/agents/codebase-investigator.test.js.map +1 -0
- package/dist/src/agents/executor.d.ts +114 -0
- package/dist/src/agents/executor.js +779 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.js +1362 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +46 -0
- package/dist/src/agents/invocation.js +102 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.js +215 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +40 -0
- package/dist/src/agents/registry.js +105 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +160 -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 +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -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 +110 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +146 -0
- package/dist/src/agents/types.js +19 -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 +13 -1
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/codeAssist.test.d.ts +6 -0
- package/dist/src/code_assist/codeAssist.test.js +99 -0
- package/dist/src/code_assist/codeAssist.test.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +5 -1
- package/dist/src/code_assist/converter.js +39 -5
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +112 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
- package/dist/src/code_assist/experiments/client_metadata.js +50 -0
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js +99 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
- package/dist/src/code_assist/experiments/experiments.js +36 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments.test.js +92 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +13 -0
- package/dist/src/code_assist/experiments/flagNames.js +13 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
- package/dist/src/code_assist/experiments/types.d.ts +35 -0
- package/dist/src/code_assist/experiments/types.js +7 -0
- package/dist/src/code_assist/experiments/types.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +110 -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 +198 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +3 -3
- package/dist/src/code_assist/oauth2.js +252 -125
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +788 -350
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +8 -6
- package/dist/src/code_assist/server.js +41 -10
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +151 -28
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +2 -2
- package/dist/src/code_assist/setup.js +5 -3
- 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 +18 -3
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/extensions.d.ts +7 -0
- package/dist/src/commands/extensions.js +9 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/extensions.test.d.ts +6 -0
- package/dist/src/commands/extensions.test.js +19 -0
- package/dist/src/commands/extensions.test.js.map +1 -0
- package/dist/src/config/config.d.ts +282 -60
- package/dist/src/config/config.js +677 -129
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +1020 -146
- 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/defaultModelConfigs.d.ts +7 -0
- package/dist/src/config/defaultModelConfigs.js +185 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -0
- package/dist/src/config/models.d.ts +37 -0
- package/dist/src/config/models.js +72 -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 +116 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +36 -0
- package/dist/src/config/storage.js +115 -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 +48 -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 +18 -0
- package/dist/src/confirmation-bus/message-bus.js +87 -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 +170 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +49 -0
- package/dist/src/confirmation-bus/types.js +16 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
- package/dist/src/core/apiKeyCredentialStorage.js +64 -0
- package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js +71 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +50 -0
- package/dist/src/core/baseLlmClient.js +185 -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 +311 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +30 -42
- package/dist/src/core/client.js +178 -477
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +739 -617
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +7 -6
- package/dist/src/core/contentGenerator.js +59 -45
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +50 -4
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +28 -11
- package/dist/src/core/coreToolScheduler.js +493 -161
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +995 -163
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +33 -0
- package/dist/src/core/fakeContentGenerator.js +58 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.test.d.ts +6 -0
- package/dist/src/core/fakeContentGenerator.test.js +127 -0
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +61 -55
- package/dist/src/core/geminiChat.js +388 -366
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +1600 -355
- 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 +11 -4
- package/dist/src/core/logger.js +39 -30
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +62 -45
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +4 -3
- package/dist/src/core/loggingContentGenerator.js +116 -37
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/loggingContentGenerator.test.js +180 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +4 -5
- package/dist/src/core/nonInteractiveToolExecutor.js +17 -120
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +168 -84
- 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 +49 -19
- 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 +7 -1
- package/dist/src/core/prompts.js +198 -195
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +172 -104
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +18 -0
- package/dist/src/core/recordingContentGenerator.js +77 -0
- package/dist/src/core/recordingContentGenerator.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/recordingContentGenerator.test.js +101 -0
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
- 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/tokenLimits.test.d.ts +6 -0
- package/dist/src/core/tokenLimits.test.js +26 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +57 -13
- package/dist/src/core/turn.js +79 -35
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +373 -120
- 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 +181 -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 +245 -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 +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.d.ts +68 -0
- package/dist/src/hooks/hookAggregator.js +262 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -0
- package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
- package/dist/src/hooks/hookAggregator.test.js +387 -0
- package/dist/src/hooks/hookAggregator.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +46 -0
- package/dist/src/hooks/hookPlanner.js +108 -0
- package/dist/src/hooks/hookPlanner.js.map +1 -0
- package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
- package/dist/src/hooks/hookPlanner.test.js +255 -0
- package/dist/src/hooks/hookPlanner.test.js.map +1 -0
- package/dist/src/hooks/hookRegistry.d.ts +87 -0
- package/dist/src/hooks/hookRegistry.js +198 -0
- package/dist/src/hooks/hookRegistry.js.map +1 -0
- package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
- package/dist/src/hooks/hookRegistry.test.js +341 -0
- package/dist/src/hooks/hookRegistry.test.js.map +1 -0
- package/dist/src/hooks/hookRunner.d.ts +42 -0
- package/dist/src/hooks/hookRunner.js +272 -0
- package/dist/src/hooks/hookRunner.js.map +1 -0
- package/dist/src/hooks/hookRunner.test.d.ts +6 -0
- package/dist/src/hooks/hookRunner.test.js +468 -0
- package/dist/src/hooks/hookRunner.test.js.map +1 -0
- package/dist/src/hooks/hookTranslator.d.ts +113 -0
- package/dist/src/hooks/hookTranslator.js +232 -0
- package/dist/src/hooks/hookTranslator.js.map +1 -0
- package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
- package/dist/src/hooks/hookTranslator.test.js +192 -0
- package/dist/src/hooks/hookTranslator.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +384 -0
- package/dist/src/hooks/types.js +284 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/hooks/types.test.d.ts +6 -0
- package/dist/src/hooks/types.test.js +313 -0
- package/dist/src/hooks/types.test.js.map +1 -0
- 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 +52 -12
- package/dist/src/ide/detect-ide.js +51 -65
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +95 -52
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +72 -24
- package/dist/src/ide/ide-client.js +380 -84
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +539 -35
- 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 +93 -35
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +157 -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 +108 -67
- 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 +151 -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 +41 -2
- package/dist/src/index.js +44 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +5 -3
- package/dist/src/mcp/google-auth-provider.js +21 -3
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +42 -9
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +25 -18
- package/dist/src/mcp/oauth-provider.js +194 -97
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +581 -39
- 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 +58 -28
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +262 -162
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +16 -1
- package/dist/src/mcp/oauth-utils.js +68 -33
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +86 -3
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +27 -0
- package/dist/src/mcp/sa-impersonation-provider.js +113 -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 +151 -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 +145 -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 +238 -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 +35 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +246 -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 +305 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +44 -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/stream-json-formatter.d.ts +32 -0
- package/dist/src/output/stream-json-formatter.js +52 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
- package/dist/src/output/stream-json-formatter.test.js +479 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +82 -0
- package/dist/src/output/types.js +22 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/config.d.ts +31 -0
- package/dist/src/policy/config.js +199 -0
- package/dist/src/policy/config.js.map +1 -0
- package/dist/src/policy/config.test.d.ts +6 -0
- package/dist/src/policy/config.test.js +538 -0
- package/dist/src/policy/config.test.js.map +1 -0
- package/dist/src/policy/index.d.ts +9 -0
- package/dist/src/policy/index.js +10 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policies/discovered.toml +8 -0
- package/dist/src/policy/policies/read-only.toml +56 -0
- package/dist/src/policy/policies/write.toml +73 -0
- package/dist/src/policy/policies/yolo.toml +31 -0
- package/dist/src/policy/policy-engine.d.ts +39 -0
- package/dist/src/policy/policy-engine.js +158 -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 +899 -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/toml-loader.d.ts +47 -0
- package/dist/src/policy/toml-loader.js +411 -0
- package/dist/src/policy/toml-loader.js.map +1 -0
- package/dist/src/policy/toml-loader.test.d.ts +6 -0
- package/dist/src/policy/toml-loader.test.js +376 -0
- package/dist/src/policy/toml-loader.test.js.map +1 -0
- package/dist/src/policy/types.d.ts +130 -0
- package/dist/src/policy/types.js +22 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +2 -2
- package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
- package/dist/src/prompts/mcp-prompts.test.js +39 -0
- package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +1 -1
- package/dist/src/prompts/prompt-registry.js +2 -1
- package/dist/src/prompts/prompt-registry.js.map +1 -1
- package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
- package/dist/src/prompts/prompt-registry.test.js +96 -0
- package/dist/src/prompts/prompt-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +85 -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 +160 -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 +166 -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 +196 -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 +59 -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 +45 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- package/dist/src/safety/built-in.d.ts +21 -0
- package/dist/src/safety/built-in.js +106 -0
- package/dist/src/safety/built-in.js.map +1 -0
- package/dist/src/safety/built-in.test.d.ts +6 -0
- package/dist/src/safety/built-in.test.js +199 -0
- package/dist/src/safety/built-in.test.js.map +1 -0
- package/dist/src/safety/checker-runner.d.ts +48 -0
- package/dist/src/safety/checker-runner.js +208 -0
- package/dist/src/safety/checker-runner.js.map +1 -0
- package/dist/src/safety/checker-runner.test.d.ts +6 -0
- package/dist/src/safety/checker-runner.test.js +238 -0
- package/dist/src/safety/checker-runner.test.js.map +1 -0
- package/dist/src/safety/context-builder.d.ts +23 -0
- package/dist/src/safety/context-builder.js +47 -0
- package/dist/src/safety/context-builder.js.map +1 -0
- package/dist/src/safety/context-builder.test.d.ts +6 -0
- package/dist/src/safety/context-builder.test.js +49 -0
- package/dist/src/safety/context-builder.test.js.map +1 -0
- package/dist/src/safety/protocol.d.ts +88 -0
- package/dist/src/safety/protocol.js +15 -0
- package/dist/src/safety/protocol.js.map +1 -0
- package/dist/src/safety/registry.d.ts +26 -0
- package/dist/src/safety/registry.js +65 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/safety/registry.test.d.ts +6 -0
- package/dist/src/safety/registry.test.js +31 -0
- package/dist/src/safety/registry.test.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +32 -0
- package/dist/src/services/chatCompressionService.js +162 -0
- package/dist/src/services/chatCompressionService.js.map +1 -0
- package/dist/src/services/chatCompressionService.test.d.ts +6 -0
- package/dist/src/services/chatCompressionService.test.js +210 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +10 -15
- package/dist/src/services/chatRecordingService.js +43 -29
- 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 +8 -10
- package/dist/src/services/fileDiscoveryService.js +31 -53
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +94 -14
- 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 +12 -3
- package/dist/src/services/loopDetectionService.js +148 -55
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +280 -21
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
- package/dist/src/services/modelConfig.golden.test.js +42 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -0
- package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
- package/dist/src/services/modelConfig.integration.test.js +247 -0
- package/dist/src/services/modelConfig.integration.test.js.map +1 -0
- package/dist/src/services/modelConfigService.d.ts +48 -0
- package/dist/src/services/modelConfigService.js +151 -0
- package/dist/src/services/modelConfigService.js.map +1 -0
- package/dist/src/services/modelConfigService.test.d.ts +6 -0
- package/dist/src/services/modelConfigService.test.js +531 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +37 -2
- package/dist/src/services/shellExecutionService.js +361 -67
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +333 -71
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.d.ts +116 -0
- package/dist/src/telemetry/activity-monitor.js +209 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/activity-monitor.test.js +251 -0
- package/dist/src/telemetry/activity-monitor.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 +53 -5
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +581 -56
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +2 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +467 -31
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +75 -4
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +182 -6
- 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 +0 -18
- package/dist/src/telemetry/constants.js +0 -18
- 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 +116 -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 +16 -2
- package/dist/src/telemetry/index.js +25 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +25 -3
- package/dist/src/telemetry/loggers.js +333 -154
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -4
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +868 -63
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +498 -11
- package/dist/src/telemetry/metrics.js +729 -84
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +964 -101
- 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 +23 -4
- 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/semantic.d.ts +82 -0
- package/dist/src/telemetry/semantic.js +269 -0
- package/dist/src/telemetry/semantic.js.map +1 -0
- package/dist/src/telemetry/semantic.test.d.ts +6 -0
- package/dist/src/telemetry/semantic.test.js +387 -0
- package/dist/src/telemetry/semantic.test.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +41 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +19 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/trace.d.ts +46 -0
- package/dist/src/telemetry/trace.js +121 -0
- package/dist/src/telemetry/trace.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +351 -25
- package/dist/src/telemetry/types.js +1071 -63
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +4 -4
- package/dist/src/telemetry/uiTelemetry.js +14 -15
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +122 -96
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +3 -2
- package/dist/src/test-utils/config.js +1 -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/base-tool-invocation.test.d.ts +6 -0
- package/dist/src/tools/base-tool-invocation.test.js +85 -0
- package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
- 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 +10 -8
- package/dist/src/tools/edit.js +100 -79
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +429 -163
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +11 -5
- package/dist/src/tools/glob.js +58 -42
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +249 -166
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +7 -5
- package/dist/src/tools/grep.js +66 -40
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +41 -15
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +7 -5
- package/dist/src/tools/ls.js +54 -68
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +150 -293
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +52 -12
- package/dist/src/tools/mcp-client-manager.js +196 -27
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +139 -13
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +28 -24
- package/dist/src/tools/mcp-client.js +338 -351
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +380 -193
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +11 -5
- package/dist/src/tools/mcp-tool.js +66 -17
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +278 -211
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +10 -7
- package/dist/src/tools/memoryTool.js +28 -49
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +26 -13
- 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 +196 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +7 -3
- package/dist/src/tools/modifiable-tool.js +41 -19
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +70 -35
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +9 -7
- package/dist/src/tools/read-file.js +39 -60
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +103 -36
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +9 -14
- package/dist/src/tools/read-many-files.js +71 -155
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +98 -44
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +73 -0
- package/dist/src/tools/ripGrep.js +395 -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 +1305 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +19 -6
- package/dist/src/tools/shell.js +92 -56
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +176 -103
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +78 -0
- package/dist/src/tools/smart-edit.js +717 -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 +592 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +39 -1
- package/dist/src/tools/tool-error.js +54 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +17 -0
- package/dist/src/tools/tool-names.js +21 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +38 -20
- package/dist/src/tools/tool-registry.js +134 -77
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +218 -58
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +49 -17
- package/dist/src/tools/tools.js +150 -8
- 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 +14 -5
- package/dist/src/tools/web-fetch.js +90 -44
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +388 -20
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +8 -6
- package/dist/src/tools/web-search.js +40 -15
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +75 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +7 -5
- package/dist/src/tools/write-file.js +54 -54
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +237 -146
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +50 -0
- package/dist/src/tools/write-todos.js +193 -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 +16 -9
- 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/channel.d.ts +19 -0
- package/dist/src/utils/channel.js +49 -0
- package/dist/src/utils/channel.js.map +1 -0
- package/dist/src/utils/channel.test.d.ts +6 -0
- package/dist/src/utils/channel.test.js +170 -0
- package/dist/src/utils/channel.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +25 -0
- package/dist/src/utils/debugLogger.js +33 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/debugLogger.test.d.ts +6 -0
- package/dist/src/utils/debugLogger.test.js +69 -0
- package/dist/src/utils/debugLogger.test.js.map +1 -0
- package/dist/src/utils/delay.d.ts +16 -0
- package/dist/src/utils/delay.js +43 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/delay.test.d.ts +6 -0
- package/dist/src/utils/delay.test.js +88 -0
- package/dist/src/utils/delay.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +9 -8
- package/dist/src/utils/editCorrector.js +62 -34
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +52 -87
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +4 -2
- package/dist/src/utils/editor.js +56 -55
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +47 -88
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +3 -2
- package/dist/src/utils/environmentContext.js +20 -33
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +6 -34
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -1
- package/dist/src/utils/errorParsing.js +5 -33
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +0 -88
- 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 +28 -0
- package/dist/src/utils/errors.js +48 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/events.d.ts +121 -0
- package/dist/src/utils/events.js +84 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/events.test.d.ts +6 -0
- package/dist/src/utils/events.test.js +212 -0
- package/dist/src/utils/events.test.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +86 -0
- package/dist/src/utils/extensionLoader.js +208 -0
- package/dist/src/utils/extensionLoader.js.map +1 -0
- package/dist/src/utils/extensionLoader.test.d.ts +6 -0
- package/dist/src/utils/extensionLoader.test.js +154 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +1 -0
- package/dist/src/utils/fetch.js +5 -1
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +28 -12
- package/dist/src/utils/fileUtils.js +204 -81
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +426 -82
- 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.test.js +103 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.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 +12 -20
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +11 -10
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.d.ts +7 -8
- package/dist/src/utils/gitIgnoreParser.js +145 -36
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +127 -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/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +152 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +6 -0
- package/dist/src/utils/googleErrors.test.js +301 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
- package/dist/src/utils/googleQuotaErrors.js +157 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
- package/dist/src/utils/googleQuotaErrors.test.js +311 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/httpErrors.d.ts +18 -0
- package/dist/src/utils/httpErrors.js +36 -0
- package/dist/src/utils/httpErrors.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +246 -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 +51 -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 +85 -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 +155 -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 +223 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +26 -6
- package/dist/src/utils/memoryDiscovery.js +239 -40
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +365 -44
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +19 -25
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +24 -155
- 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 +10 -4
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +85 -66
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +12 -0
- package/dist/src/utils/package.js +15 -0
- package/dist/src/utils/package.js.map +1 -0
- 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/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +406 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +1 -18
- package/dist/src/utils/paths.js +133 -57
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/paths.test.js +200 -68
- package/dist/src/utils/paths.test.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 -3
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +5 -10
- package/dist/src/utils/retry.js +114 -197
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +196 -130
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.d.ts +4 -4
- package/dist/src/utils/safeJsonStringify.js +31 -7
- package/dist/src/utils/safeJsonStringify.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 +21 -3
- package/dist/src/utils/shell-utils.js +427 -159
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +250 -59
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +32 -0
- package/dist/src/utils/stdio.js +85 -0
- package/dist/src/utils/stdio.js.map +1 -0
- package/dist/src/utils/stdio.test.d.ts +6 -0
- package/dist/src/utils/stdio.test.js +47 -0
- package/dist/src/utils/stdio.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +6 -4
- package/dist/src/utils/summarizer.js +8 -9
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +32 -12
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +7 -6
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +4 -3
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +14 -0
- package/dist/src/utils/terminal.js +38 -0
- package/dist/src/utils/terminal.js.map +1 -0
- 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 +67 -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 +69 -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 +115 -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} +41 -36
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +4 -3
- package/dist/src/utils/workspaceContext.js +23 -17
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +45 -19
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -10
- 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 +0 -118
- 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/codebase-investigator.test.d.ts} +0 -0
- /package/dist/src/{utils/user_account.test.d.ts → agents/executor.test.d.ts} +0 -0
- /package/dist/src/{utils/user_id.test.d.ts → agents/invocation.test.d.ts} +0 -0
package/dist/src/core/client.js
CHANGED
|
@@ -3,97 +3,61 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { getDirectoryContextString,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { getDirectoryContextString, getInitialChatHistory, } from '../utils/environmentContext.js';
|
|
7
|
+
import { CompressionStatus } from './turn.js';
|
|
8
|
+
import { Turn, GeminiEventType } from './turn.js';
|
|
9
|
+
import { getCoreSystemPrompt } from './prompts.js';
|
|
10
10
|
import { checkNextSpeaker } from '../utils/nextSpeakerChecker.js';
|
|
11
11
|
import { reportError } from '../utils/errorReporting.js';
|
|
12
12
|
import { GeminiChat } from './geminiChat.js';
|
|
13
13
|
import { retryWithBackoff } from '../utils/retry.js';
|
|
14
14
|
import { getErrorMessage } from '../utils/errors.js';
|
|
15
|
-
import { isFunctionResponse } from '../utils/messageInspectors.js';
|
|
16
15
|
import { tokenLimit } from './tokenLimits.js';
|
|
17
|
-
import {
|
|
18
|
-
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
|
19
|
-
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
|
16
|
+
import { DEFAULT_GEMINI_FLASH_MODEL, getEffectiveModel, } from '../config/models.js';
|
|
20
17
|
import { LoopDetectionService } from '../services/loopDetectionService.js';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Returns the index of the content after the fraction of the total characters in the history.
|
|
32
|
-
*
|
|
33
|
-
* Exported for testing purposes.
|
|
34
|
-
*/
|
|
35
|
-
export function findIndexAfterFraction(history, fraction) {
|
|
36
|
-
if (fraction <= 0 || fraction >= 1) {
|
|
37
|
-
throw new Error('Fraction must be between 0 and 1');
|
|
38
|
-
}
|
|
39
|
-
const contentLengths = history.map((content) => JSON.stringify(content).length);
|
|
40
|
-
const totalCharacters = contentLengths.reduce((sum, length) => sum + length, 0);
|
|
41
|
-
const targetCharacters = totalCharacters * fraction;
|
|
42
|
-
let charactersSoFar = 0;
|
|
43
|
-
for (let i = 0; i < contentLengths.length; i++) {
|
|
44
|
-
charactersSoFar += contentLengths[i];
|
|
45
|
-
if (charactersSoFar >= targetCharacters) {
|
|
46
|
-
return i;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return contentLengths.length;
|
|
50
|
-
}
|
|
18
|
+
import { ChatCompressionService } from '../services/chatCompressionService.js';
|
|
19
|
+
import { ideContextStore } from '../ide/ideContext.js';
|
|
20
|
+
import { logContentRetryFailure, logNextSpeakerCheck, } from '../telemetry/loggers.js';
|
|
21
|
+
import { ContentRetryFailureEvent, NextSpeakerCheckEvent, } from '../telemetry/types.js';
|
|
22
|
+
import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
|
|
23
|
+
import { handleFallback } from '../fallback/handler.js';
|
|
24
|
+
import { debugLogger } from '../utils/debugLogger.js';
|
|
51
25
|
const MAX_TURNS = 100;
|
|
52
|
-
/**
|
|
53
|
-
* Threshold for compression token count as a fraction of the model's token limit.
|
|
54
|
-
* If the chat history exceeds this threshold, it will be compressed.
|
|
55
|
-
*/
|
|
56
|
-
const COMPRESSION_TOKEN_THRESHOLD = 0.7;
|
|
57
|
-
/**
|
|
58
|
-
* The fraction of the latest chat history to keep. A value of 0.3
|
|
59
|
-
* means that only the last 30% of the chat history will be kept after compression.
|
|
60
|
-
*/
|
|
61
|
-
const COMPRESSION_PRESERVE_THRESHOLD = 0.3;
|
|
62
26
|
export class GeminiClient {
|
|
63
27
|
config;
|
|
64
28
|
chat;
|
|
65
|
-
contentGenerator;
|
|
66
|
-
embeddingModel;
|
|
67
|
-
generateContentConfig = {
|
|
68
|
-
temperature: 0,
|
|
69
|
-
topP: 1,
|
|
70
|
-
};
|
|
71
29
|
sessionTurnCount = 0;
|
|
72
30
|
loopDetector;
|
|
31
|
+
compressionService;
|
|
73
32
|
lastPromptId;
|
|
33
|
+
currentSequenceModel = null;
|
|
74
34
|
lastSentIdeContext;
|
|
75
35
|
forceFullIdeContext = true;
|
|
36
|
+
/**
|
|
37
|
+
* At any point in this conversation, was compression triggered without
|
|
38
|
+
* being forced and did it fail?
|
|
39
|
+
*/
|
|
40
|
+
hasFailedCompressionAttempt = false;
|
|
76
41
|
constructor(config) {
|
|
77
42
|
this.config = config;
|
|
78
|
-
if (config.getProxy()) {
|
|
79
|
-
setGlobalDispatcher(new ProxyAgent(config.getProxy()));
|
|
80
|
-
}
|
|
81
|
-
this.embeddingModel = config.getEmbeddingModel();
|
|
82
43
|
this.loopDetector = new LoopDetectionService(config);
|
|
44
|
+
this.compressionService = new ChatCompressionService();
|
|
83
45
|
this.lastPromptId = this.config.getSessionId();
|
|
84
46
|
}
|
|
85
|
-
|
|
86
|
-
|
|
47
|
+
updateTelemetryTokenCount() {
|
|
48
|
+
if (this.chat) {
|
|
49
|
+
uiTelemetryService.setLastPromptTokenCount(this.chat.getLastPromptTokenCount());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async initialize() {
|
|
87
53
|
this.chat = await this.startChat();
|
|
54
|
+
this.updateTelemetryTokenCount();
|
|
88
55
|
}
|
|
89
|
-
|
|
90
|
-
if (!this.
|
|
56
|
+
getContentGeneratorOrFail() {
|
|
57
|
+
if (!this.config.getContentGenerator()) {
|
|
91
58
|
throw new Error('Content generator not initialized');
|
|
92
59
|
}
|
|
93
|
-
return this.
|
|
94
|
-
}
|
|
95
|
-
getUserTier() {
|
|
96
|
-
return this.contentGenerator?.userTier;
|
|
60
|
+
return this.config.getContentGenerator();
|
|
97
61
|
}
|
|
98
62
|
async addHistory(content) {
|
|
99
63
|
this.getChat().addHistory(content);
|
|
@@ -105,32 +69,16 @@ export class GeminiClient {
|
|
|
105
69
|
return this.chat;
|
|
106
70
|
}
|
|
107
71
|
isInitialized() {
|
|
108
|
-
return this.chat !== undefined
|
|
72
|
+
return this.chat !== undefined;
|
|
109
73
|
}
|
|
110
74
|
getHistory() {
|
|
111
75
|
return this.getChat().getHistory();
|
|
112
76
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
newContent.parts = newContent.parts.map((part) => {
|
|
119
|
-
if (part &&
|
|
120
|
-
typeof part === 'object' &&
|
|
121
|
-
'thoughtSignature' in part) {
|
|
122
|
-
const newPart = { ...part };
|
|
123
|
-
delete newPart
|
|
124
|
-
.thoughtSignature;
|
|
125
|
-
return newPart;
|
|
126
|
-
}
|
|
127
|
-
return part;
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return newContent;
|
|
131
|
-
})
|
|
132
|
-
: history;
|
|
133
|
-
this.getChat().setHistory(historyToSet);
|
|
77
|
+
stripThoughtsFromHistory() {
|
|
78
|
+
this.getChat().stripThoughtsFromHistory();
|
|
79
|
+
}
|
|
80
|
+
setHistory(history) {
|
|
81
|
+
this.getChat().setHistory(history);
|
|
134
82
|
this.forceFullIdeContext = true;
|
|
135
83
|
}
|
|
136
84
|
async setTools() {
|
|
@@ -141,6 +89,19 @@ export class GeminiClient {
|
|
|
141
89
|
}
|
|
142
90
|
async resetChat() {
|
|
143
91
|
this.chat = await this.startChat();
|
|
92
|
+
this.updateTelemetryTokenCount();
|
|
93
|
+
}
|
|
94
|
+
async resumeChat(history, resumedSessionData) {
|
|
95
|
+
this.chat = await this.startChat(history, resumedSessionData);
|
|
96
|
+
}
|
|
97
|
+
getChatRecordingService() {
|
|
98
|
+
return this.chat?.getChatRecordingService();
|
|
99
|
+
}
|
|
100
|
+
getLoopDetectionService() {
|
|
101
|
+
return this.loopDetector;
|
|
102
|
+
}
|
|
103
|
+
getCurrentSequenceModel() {
|
|
104
|
+
return this.currentSequenceModel;
|
|
144
105
|
}
|
|
145
106
|
async addDirectoryContext() {
|
|
146
107
|
if (!this.chat) {
|
|
@@ -151,39 +112,25 @@ export class GeminiClient {
|
|
|
151
112
|
parts: [{ text: await getDirectoryContextString(this.config) }],
|
|
152
113
|
});
|
|
153
114
|
}
|
|
154
|
-
async
|
|
115
|
+
async updateSystemInstruction() {
|
|
116
|
+
if (!this.isInitialized()) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const userMemory = this.config.getUserMemory();
|
|
120
|
+
const systemInstruction = getCoreSystemPrompt(this.config, userMemory);
|
|
121
|
+
this.getChat().setSystemInstruction(systemInstruction);
|
|
122
|
+
}
|
|
123
|
+
async startChat(extraHistory, resumedSessionData) {
|
|
155
124
|
this.forceFullIdeContext = true;
|
|
156
|
-
|
|
125
|
+
this.hasFailedCompressionAttempt = false;
|
|
157
126
|
const toolRegistry = this.config.getToolRegistry();
|
|
158
127
|
const toolDeclarations = toolRegistry.getFunctionDeclarations();
|
|
159
128
|
const tools = [{ functionDeclarations: toolDeclarations }];
|
|
160
|
-
const history =
|
|
161
|
-
{
|
|
162
|
-
role: 'user',
|
|
163
|
-
parts: envParts,
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
role: 'model',
|
|
167
|
-
parts: [{ text: 'Got it. Thanks for the context!' }],
|
|
168
|
-
},
|
|
169
|
-
...(extraHistory ?? []),
|
|
170
|
-
];
|
|
129
|
+
const history = await getInitialChatHistory(this.config, extraHistory);
|
|
171
130
|
try {
|
|
172
131
|
const userMemory = this.config.getUserMemory();
|
|
173
|
-
const systemInstruction = getCoreSystemPrompt(userMemory);
|
|
174
|
-
|
|
175
|
-
? {
|
|
176
|
-
...this.generateContentConfig,
|
|
177
|
-
thinkingConfig: {
|
|
178
|
-
includeThoughts: true,
|
|
179
|
-
},
|
|
180
|
-
}
|
|
181
|
-
: this.generateContentConfig;
|
|
182
|
-
return new GeminiChat(this.config, this.getContentGenerator(), {
|
|
183
|
-
systemInstruction,
|
|
184
|
-
...generateContentConfigWithThinking,
|
|
185
|
-
tools,
|
|
186
|
-
}, history);
|
|
132
|
+
const systemInstruction = getCoreSystemPrompt(this.config, userMemory);
|
|
133
|
+
return new GeminiChat(this.config, systemInstruction, tools, history, resumedSessionData);
|
|
187
134
|
}
|
|
188
135
|
catch (error) {
|
|
189
136
|
await reportError(error, 'Error initializing Gemini chat session.', history, 'startChat');
|
|
@@ -191,7 +138,7 @@ export class GeminiClient {
|
|
|
191
138
|
}
|
|
192
139
|
}
|
|
193
140
|
getIdeContextParts(forceFullContext) {
|
|
194
|
-
const currentIdeContext =
|
|
141
|
+
const currentIdeContext = ideContextStore.get();
|
|
195
142
|
if (!currentIdeContext) {
|
|
196
143
|
return { contextParts: [], newIdeContext: undefined };
|
|
197
144
|
}
|
|
@@ -229,7 +176,7 @@ export class GeminiClient {
|
|
|
229
176
|
'```',
|
|
230
177
|
];
|
|
231
178
|
if (this.config.getDebugMode()) {
|
|
232
|
-
|
|
179
|
+
debugLogger.log(contextParts.join('\n'));
|
|
233
180
|
}
|
|
234
181
|
return {
|
|
235
182
|
contextParts,
|
|
@@ -321,7 +268,7 @@ export class GeminiClient {
|
|
|
321
268
|
'```',
|
|
322
269
|
];
|
|
323
270
|
if (this.config.getDebugMode()) {
|
|
324
|
-
|
|
271
|
+
debugLogger.log(contextParts.join('\n'));
|
|
325
272
|
}
|
|
326
273
|
return {
|
|
327
274
|
contextParts,
|
|
@@ -329,10 +276,18 @@ export class GeminiClient {
|
|
|
329
276
|
};
|
|
330
277
|
}
|
|
331
278
|
}
|
|
332
|
-
|
|
279
|
+
_getEffectiveModelForCurrentTurn() {
|
|
280
|
+
if (this.currentSequenceModel) {
|
|
281
|
+
return this.currentSequenceModel;
|
|
282
|
+
}
|
|
283
|
+
const configModel = this.config.getModel();
|
|
284
|
+
return getEffectiveModel(this.config.isInFallbackMode(), configModel, this.config.getPreviewFeatures());
|
|
285
|
+
}
|
|
286
|
+
async *sendMessageStream(request, signal, prompt_id, turns = MAX_TURNS, isInvalidStreamRetry = false) {
|
|
333
287
|
if (this.lastPromptId !== prompt_id) {
|
|
334
288
|
this.loopDetector.reset(prompt_id);
|
|
335
289
|
this.lastPromptId = prompt_id;
|
|
290
|
+
this.currentSequenceModel = null;
|
|
336
291
|
}
|
|
337
292
|
this.sessionTurnCount++;
|
|
338
293
|
if (this.config.getMaxSessionTurns() > 0 &&
|
|
@@ -345,10 +300,19 @@ export class GeminiClient {
|
|
|
345
300
|
if (!boundedTurns) {
|
|
346
301
|
return new Turn(this.getChat(), prompt_id);
|
|
347
302
|
}
|
|
348
|
-
//
|
|
349
|
-
const
|
|
350
|
-
const
|
|
351
|
-
|
|
303
|
+
// Check for context window overflow
|
|
304
|
+
const modelForLimitCheck = this._getEffectiveModelForCurrentTurn();
|
|
305
|
+
const estimatedRequestTokenCount = Math.floor(JSON.stringify(request).length / 4);
|
|
306
|
+
const remainingTokenCount = tokenLimit(modelForLimitCheck) - this.getChat().getLastPromptTokenCount();
|
|
307
|
+
if (estimatedRequestTokenCount > remainingTokenCount * 0.95) {
|
|
308
|
+
yield {
|
|
309
|
+
type: GeminiEventType.ContextWindowWillOverflow,
|
|
310
|
+
value: { estimatedRequestTokenCount, remainingTokenCount },
|
|
311
|
+
};
|
|
312
|
+
return new Turn(this.getChat(), prompt_id);
|
|
313
|
+
}
|
|
314
|
+
const compressed = await this.tryCompressChat(prompt_id, false);
|
|
315
|
+
if (compressed.compressionStatus === CompressionStatus.COMPRESSED) {
|
|
352
316
|
yield { type: GeminiEventType.ChatCompressed, value: compressed };
|
|
353
317
|
}
|
|
354
318
|
// Prevent context updates from being sent while a tool call is
|
|
@@ -373,205 +337,109 @@ export class GeminiClient {
|
|
|
373
337
|
this.forceFullIdeContext = false;
|
|
374
338
|
}
|
|
375
339
|
const turn = new Turn(this.getChat(), prompt_id);
|
|
340
|
+
const controller = new AbortController();
|
|
341
|
+
const linkedSignal = AbortSignal.any([signal, controller.signal]);
|
|
376
342
|
const loopDetected = await this.loopDetector.turnStarted(signal);
|
|
377
343
|
if (loopDetected) {
|
|
378
344
|
yield { type: GeminiEventType.LoopDetected };
|
|
379
345
|
return turn;
|
|
380
346
|
}
|
|
381
|
-
const
|
|
347
|
+
const routingContext = {
|
|
348
|
+
history: this.getChat().getHistory(/*curated=*/ true),
|
|
349
|
+
request,
|
|
350
|
+
signal,
|
|
351
|
+
};
|
|
352
|
+
let modelToUse;
|
|
353
|
+
// Determine Model (Stickiness vs. Routing)
|
|
354
|
+
if (this.currentSequenceModel) {
|
|
355
|
+
modelToUse = this.currentSequenceModel;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
const router = await this.config.getModelRouterService();
|
|
359
|
+
const decision = await router.route(routingContext);
|
|
360
|
+
modelToUse = decision.model;
|
|
361
|
+
// Lock the model for the rest of the sequence
|
|
362
|
+
this.currentSequenceModel = modelToUse;
|
|
363
|
+
yield { type: GeminiEventType.ModelInfo, value: modelToUse };
|
|
364
|
+
}
|
|
365
|
+
const resultStream = turn.run({ model: modelToUse }, request, linkedSignal);
|
|
382
366
|
for await (const event of resultStream) {
|
|
383
367
|
if (this.loopDetector.addAndCheck(event)) {
|
|
384
368
|
yield { type: GeminiEventType.LoopDetected };
|
|
369
|
+
controller.abort();
|
|
385
370
|
return turn;
|
|
386
371
|
}
|
|
387
372
|
yield event;
|
|
373
|
+
this.updateTelemetryTokenCount();
|
|
374
|
+
if (event.type === GeminiEventType.InvalidStream) {
|
|
375
|
+
if (this.config.getContinueOnFailedApiCall()) {
|
|
376
|
+
if (isInvalidStreamRetry) {
|
|
377
|
+
// We already retried once, so stop here.
|
|
378
|
+
logContentRetryFailure(this.config, new ContentRetryFailureEvent(4, // 2 initial + 2 after injections
|
|
379
|
+
'FAILED_AFTER_PROMPT_INJECTION', modelToUse));
|
|
380
|
+
return turn;
|
|
381
|
+
}
|
|
382
|
+
const nextRequest = [{ text: 'System: Please continue.' }];
|
|
383
|
+
yield* this.sendMessageStream(nextRequest, signal, prompt_id, boundedTurns - 1, true);
|
|
384
|
+
return turn;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (event.type === GeminiEventType.Error) {
|
|
388
|
+
return turn;
|
|
389
|
+
}
|
|
388
390
|
}
|
|
389
391
|
if (!turn.pendingToolCalls.length && signal && !signal.aborted) {
|
|
390
|
-
// Check if
|
|
391
|
-
|
|
392
|
-
if (currentModel !== initialModel) {
|
|
393
|
-
// Model was switched (likely due to quota error fallback)
|
|
394
|
-
// Don't continue with recursive call to prevent unwanted Flash execution
|
|
392
|
+
// Check if next speaker check is needed
|
|
393
|
+
if (this.config.getQuotaErrorOccurred()) {
|
|
395
394
|
return turn;
|
|
396
395
|
}
|
|
397
396
|
if (this.config.getSkipNextSpeakerCheck()) {
|
|
398
397
|
return turn;
|
|
399
398
|
}
|
|
400
|
-
const nextSpeakerCheck = await checkNextSpeaker(this.getChat(), this, signal);
|
|
399
|
+
const nextSpeakerCheck = await checkNextSpeaker(this.getChat(), this.config.getBaseLlmClient(), signal, prompt_id);
|
|
401
400
|
logNextSpeakerCheck(this.config, new NextSpeakerCheckEvent(prompt_id, turn.finishReason?.toString() || '', nextSpeakerCheck?.next_speaker || ''));
|
|
402
401
|
if (nextSpeakerCheck?.next_speaker === 'model') {
|
|
403
402
|
const nextRequest = [{ text: 'Please continue.' }];
|
|
404
403
|
// This recursive call's events will be yielded out, but the final
|
|
405
404
|
// turn object will be from the top-level call.
|
|
406
|
-
yield* this.sendMessageStream(nextRequest, signal, prompt_id, boundedTurns - 1
|
|
405
|
+
yield* this.sendMessageStream(nextRequest, signal, prompt_id, boundedTurns - 1);
|
|
407
406
|
}
|
|
408
407
|
}
|
|
409
408
|
return turn;
|
|
410
409
|
}
|
|
411
|
-
async
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
try {
|
|
420
|
-
const userMemory = this.config.getUserMemory();
|
|
421
|
-
const systemInstruction = getCoreSystemPrompt(userMemory);
|
|
422
|
-
const requestConfig = {
|
|
423
|
-
abortSignal,
|
|
424
|
-
...this.generateContentConfig,
|
|
425
|
-
...config,
|
|
426
|
-
};
|
|
427
|
-
const apiCall = () => this.getContentGenerator().generateContent({
|
|
428
|
-
model: modelToUse,
|
|
429
|
-
config: {
|
|
430
|
-
...requestConfig,
|
|
431
|
-
systemInstruction,
|
|
432
|
-
responseJsonSchema: schema,
|
|
433
|
-
responseMimeType: 'application/json',
|
|
434
|
-
},
|
|
435
|
-
contents,
|
|
436
|
-
}, this.lastPromptId);
|
|
437
|
-
const result = await retryWithBackoff(apiCall, {
|
|
438
|
-
onPersistent429: async (authType, error) => await this.handleFlashFallback(authType, error),
|
|
439
|
-
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
440
|
-
});
|
|
441
|
-
let text = getResponseText(result);
|
|
442
|
-
if (!text) {
|
|
443
|
-
const error = new Error('API returned an empty response for generateJson.');
|
|
444
|
-
await reportError(error, 'Error in generateJson: API returned an empty response.', contents, 'generateJson-empty-response');
|
|
445
|
-
throw error;
|
|
446
|
-
}
|
|
447
|
-
const prefix = '```json';
|
|
448
|
-
const suffix = '```';
|
|
449
|
-
if (text.startsWith(prefix) && text.endsWith(suffix)) {
|
|
450
|
-
ClearcutLogger.getInstance(this.config)?.logMalformedJsonResponseEvent(new MalformedJsonResponseEvent(modelToUse));
|
|
451
|
-
text = text
|
|
452
|
-
.substring(prefix.length, text.length - suffix.length)
|
|
453
|
-
.trim();
|
|
454
|
-
}
|
|
455
|
-
try {
|
|
456
|
-
return JSON.parse(text);
|
|
457
|
-
}
|
|
458
|
-
catch (parseError) {
|
|
459
|
-
await reportError(parseError, 'Failed to parse JSON response from generateJson.', {
|
|
460
|
-
responseTextFailedToParse: text,
|
|
461
|
-
originalRequestContents: contents,
|
|
462
|
-
}, 'generateJson-parse');
|
|
463
|
-
throw new Error(`Failed to parse API response as JSON: ${getErrorMessage(parseError)}`);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
catch (error) {
|
|
467
|
-
if (abortSignal.aborted) {
|
|
468
|
-
throw error;
|
|
469
|
-
}
|
|
470
|
-
// Avoid double reporting for the empty response case handled above
|
|
471
|
-
if (error instanceof Error &&
|
|
472
|
-
error.message === 'API returned an empty response for generateJson.') {
|
|
473
|
-
throw error;
|
|
474
|
-
}
|
|
475
|
-
await reportError(error, 'Error generating JSON content via API.', contents, 'generateJson-api');
|
|
476
|
-
throw new Error(`Failed to generate JSON content: ${getErrorMessage(error)}`);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
async openaiGenerateJson(contents, schema, abortSignal, model, config = {}) {
|
|
410
|
+
async generateContent(modelConfigKey, contents, abortSignal) {
|
|
411
|
+
const desiredModelConfig = this.config.modelConfigService.getResolvedConfig(modelConfigKey);
|
|
412
|
+
let { model: currentAttemptModel, generateContentConfig: currentAttemptGenerateContentConfig, } = desiredModelConfig;
|
|
413
|
+
const fallbackModelConfig = this.config.modelConfigService.getResolvedConfig({
|
|
414
|
+
...modelConfigKey,
|
|
415
|
+
model: DEFAULT_GEMINI_FLASH_MODEL,
|
|
416
|
+
});
|
|
480
417
|
try {
|
|
481
418
|
const userMemory = this.config.getUserMemory();
|
|
482
|
-
const systemInstruction = getCoreSystemPrompt(userMemory);
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
};
|
|
494
|
-
const tools = [
|
|
495
|
-
{
|
|
496
|
-
functionDeclarations: [functionDeclaration],
|
|
497
|
-
},
|
|
498
|
-
];
|
|
499
|
-
const apiCall = () => this.getContentGenerator().generateContent({
|
|
500
|
-
model,
|
|
501
|
-
config: {
|
|
502
|
-
...requestConfig,
|
|
419
|
+
const systemInstruction = getCoreSystemPrompt(this.config, userMemory);
|
|
420
|
+
const apiCall = () => {
|
|
421
|
+
const modelConfigToUse = this.config.isInFallbackMode()
|
|
422
|
+
? fallbackModelConfig
|
|
423
|
+
: desiredModelConfig;
|
|
424
|
+
currentAttemptModel = modelConfigToUse.model;
|
|
425
|
+
currentAttemptGenerateContentConfig =
|
|
426
|
+
modelConfigToUse.generateContentConfig;
|
|
427
|
+
const requestConfig = {
|
|
428
|
+
...currentAttemptGenerateContentConfig,
|
|
429
|
+
abortSignal,
|
|
503
430
|
systemInstruction,
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
511
|
-
});
|
|
512
|
-
// Try to extract function call arguments
|
|
513
|
-
const functionCalls = getFunctionCalls(result);
|
|
514
|
-
if (functionCalls && functionCalls.length > 0) {
|
|
515
|
-
const functionCall = functionCalls.find((call) => call.name === 'respond_in_schema');
|
|
516
|
-
if (functionCall && functionCall.args) {
|
|
517
|
-
return functionCall.args;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
// Fallback: try to parse response text as JSON
|
|
521
|
-
let text = getResponseText(result);
|
|
522
|
-
if (!text) {
|
|
523
|
-
const error = new Error('API returned an empty response for openaiGenerateJson.');
|
|
524
|
-
await reportError(error, 'Error in openaiGenerateJson: API returned an empty response.', contents, 'openaiGenerateJson-empty-response');
|
|
525
|
-
throw error;
|
|
526
|
-
}
|
|
527
|
-
// Handle markdown wrapped JSON
|
|
528
|
-
const prefix = '```json';
|
|
529
|
-
const suffix = '```';
|
|
530
|
-
if (text.startsWith(prefix) && text.endsWith(suffix)) {
|
|
531
|
-
text = text
|
|
532
|
-
.substring(prefix.length, text.length - suffix.length)
|
|
533
|
-
.trim();
|
|
534
|
-
}
|
|
535
|
-
try {
|
|
536
|
-
return JSON.parse(text);
|
|
537
|
-
}
|
|
538
|
-
catch (parseError) {
|
|
539
|
-
await reportError(parseError, 'Failed to parse JSON response from openaiGenerateJson.', {
|
|
540
|
-
responseTextFailedToParse: text,
|
|
541
|
-
originalRequestContents: contents,
|
|
542
|
-
}, 'openaiGenerateJson-parse');
|
|
543
|
-
throw new Error(`Failed to parse API response as JSON: ${getErrorMessage(parseError)}`);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
catch (error) {
|
|
547
|
-
if (abortSignal.aborted) {
|
|
548
|
-
throw error;
|
|
549
|
-
}
|
|
550
|
-
await reportError(error, 'Error generating JSON content via OpenAI API.', contents, 'openaiGenerateJson-api');
|
|
551
|
-
throw new Error(`Failed to generate JSON content: ${getErrorMessage(error)}`);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
async generateContent(contents, generationConfig, abortSignal, model) {
|
|
555
|
-
const modelToUse = model ?? this.config.getModel();
|
|
556
|
-
const configToUse = {
|
|
557
|
-
...this.generateContentConfig,
|
|
558
|
-
...generationConfig,
|
|
559
|
-
};
|
|
560
|
-
try {
|
|
561
|
-
const userMemory = this.config.getUserMemory();
|
|
562
|
-
const systemInstruction = getCoreSystemPrompt(userMemory);
|
|
563
|
-
const requestConfig = {
|
|
564
|
-
abortSignal,
|
|
565
|
-
...configToUse,
|
|
566
|
-
systemInstruction,
|
|
431
|
+
};
|
|
432
|
+
return this.getContentGeneratorOrFail().generateContent({
|
|
433
|
+
model: currentAttemptModel,
|
|
434
|
+
config: requestConfig,
|
|
435
|
+
contents,
|
|
436
|
+
}, this.lastPromptId);
|
|
567
437
|
};
|
|
568
|
-
const
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
contents,
|
|
572
|
-
}, this.lastPromptId);
|
|
438
|
+
const onPersistent429Callback = async (authType, error) =>
|
|
439
|
+
// Pass the captured model to the centralized handler.
|
|
440
|
+
await handleFallback(this.config, currentAttemptModel, authType, error);
|
|
573
441
|
const result = await retryWithBackoff(apiCall, {
|
|
574
|
-
onPersistent429:
|
|
442
|
+
onPersistent429: onPersistent429Callback,
|
|
575
443
|
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
576
444
|
});
|
|
577
445
|
return result;
|
|
@@ -580,198 +448,31 @@ export class GeminiClient {
|
|
|
580
448
|
if (abortSignal.aborted) {
|
|
581
449
|
throw error;
|
|
582
450
|
}
|
|
583
|
-
await reportError(error, `Error generating content via API with model ${
|
|
451
|
+
await reportError(error, `Error generating content via API with model ${currentAttemptModel}.`, {
|
|
584
452
|
requestContents: contents,
|
|
585
|
-
requestConfig:
|
|
453
|
+
requestConfig: currentAttemptGenerateContentConfig,
|
|
586
454
|
}, 'generateContent-api');
|
|
587
|
-
throw new Error(`Failed to generate content with model ${
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
async generateEmbedding(texts) {
|
|
591
|
-
if (!texts || texts.length === 0) {
|
|
592
|
-
return [];
|
|
455
|
+
throw new Error(`Failed to generate content with model ${currentAttemptModel}: ${getErrorMessage(error)}`);
|
|
593
456
|
}
|
|
594
|
-
const embedModelParams = {
|
|
595
|
-
model: this.embeddingModel,
|
|
596
|
-
contents: texts,
|
|
597
|
-
};
|
|
598
|
-
const embedContentResponse = await this.getContentGenerator().embedContent(embedModelParams);
|
|
599
|
-
if (!embedContentResponse.embeddings ||
|
|
600
|
-
embedContentResponse.embeddings.length === 0) {
|
|
601
|
-
throw new Error('No embeddings found in API response.');
|
|
602
|
-
}
|
|
603
|
-
if (embedContentResponse.embeddings.length !== texts.length) {
|
|
604
|
-
throw new Error(`API returned a mismatched number of embeddings. Expected ${texts.length}, got ${embedContentResponse.embeddings.length}.`);
|
|
605
|
-
}
|
|
606
|
-
return embedContentResponse.embeddings.map((embedding, index) => {
|
|
607
|
-
const values = embedding.values;
|
|
608
|
-
if (!values || values.length === 0) {
|
|
609
|
-
throw new Error(`API returned an empty embedding for input text at index ${index}: "${texts[index]}"`);
|
|
610
|
-
}
|
|
611
|
-
return values;
|
|
612
|
-
});
|
|
613
457
|
}
|
|
614
458
|
async tryCompressChat(prompt_id, force = false) {
|
|
615
|
-
|
|
616
|
-
//
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
const threshold = contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD;
|
|
633
|
-
if (originalTokenCount < threshold * tokenLimit(model)) {
|
|
634
|
-
return null;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
let compressBeforeIndex = findIndexAfterFraction(curatedHistory, 1 - COMPRESSION_PRESERVE_THRESHOLD);
|
|
638
|
-
// Find the first user message after the index. This is the start of the next turn.
|
|
639
|
-
while (compressBeforeIndex < curatedHistory.length &&
|
|
640
|
-
(curatedHistory[compressBeforeIndex]?.role === 'model' ||
|
|
641
|
-
isFunctionResponse(curatedHistory[compressBeforeIndex]))) {
|
|
642
|
-
compressBeforeIndex++;
|
|
643
|
-
}
|
|
644
|
-
const historyToCompress = curatedHistory.slice(0, compressBeforeIndex);
|
|
645
|
-
const historyToKeep = curatedHistory.slice(compressBeforeIndex);
|
|
646
|
-
this.getChat().setHistory(historyToCompress);
|
|
647
|
-
const { text: summary } = await this.getChat().sendMessage({
|
|
648
|
-
message: {
|
|
649
|
-
text: 'First, reason in your scratchpad. Then, generate the <state_snapshot>.',
|
|
650
|
-
},
|
|
651
|
-
config: {
|
|
652
|
-
systemInstruction: { text: getCompressionPrompt() },
|
|
653
|
-
},
|
|
654
|
-
}, prompt_id);
|
|
655
|
-
this.chat = await this.startChat([
|
|
656
|
-
{
|
|
657
|
-
role: 'user',
|
|
658
|
-
parts: [{ text: summary }],
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
role: 'model',
|
|
662
|
-
parts: [{ text: 'Got it. Thanks for the additional context!' }],
|
|
663
|
-
},
|
|
664
|
-
...historyToKeep,
|
|
665
|
-
]);
|
|
666
|
-
this.forceFullIdeContext = true;
|
|
667
|
-
const { totalTokens: newTokenCount } = await this.getContentGenerator().countTokens({
|
|
668
|
-
// model might change after calling `sendMessage`, so we get the newest value from config
|
|
669
|
-
model: this.config.getModel(),
|
|
670
|
-
contents: this.getChat().getHistory(),
|
|
671
|
-
});
|
|
672
|
-
if (newTokenCount === undefined) {
|
|
673
|
-
console.warn('Could not determine compressed history token count.');
|
|
674
|
-
return null;
|
|
675
|
-
}
|
|
676
|
-
logChatCompression(this.config, makeChatCompressionEvent({
|
|
677
|
-
tokens_before: originalTokenCount,
|
|
678
|
-
tokens_after: newTokenCount,
|
|
679
|
-
}));
|
|
680
|
-
return {
|
|
681
|
-
originalTokenCount,
|
|
682
|
-
newTokenCount,
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* [PATCH:API_KEY_ROTATION] Tries to rotate API key for GEMINI/OPENAI API key authentication modes.
|
|
687
|
-
* Returns the current model name if key was rotated, null otherwise.
|
|
688
|
-
*/
|
|
689
|
-
async tryRotateApiKey(authType) {
|
|
690
|
-
// Support both GEMINI and OPENAI API key modes
|
|
691
|
-
let envKey;
|
|
692
|
-
if (authType === AuthType.USE_GEMINI) {
|
|
693
|
-
envKey = 'GEMINI_API_KEY';
|
|
694
|
-
}
|
|
695
|
-
else if (authType === AuthType.USE_OPENAI) {
|
|
696
|
-
envKey = 'OPENAI_API_KEY';
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
return null; // Not a supported API key mode
|
|
700
|
-
}
|
|
701
|
-
const newApiKey = process.env[envKey]?.trim();
|
|
702
|
-
if (!newApiKey) {
|
|
703
|
-
return null;
|
|
704
|
-
}
|
|
705
|
-
const currentConfig = this.config.getContentGeneratorConfig();
|
|
706
|
-
if (!currentConfig) {
|
|
707
|
-
return null;
|
|
708
|
-
}
|
|
709
|
-
if (currentConfig.apiKey === newApiKey) {
|
|
710
|
-
return null; // Same key, no rotation needed
|
|
711
|
-
}
|
|
712
|
-
try {
|
|
713
|
-
// Update the API key in config first
|
|
714
|
-
currentConfig.apiKey = newApiKey;
|
|
715
|
-
// Create new content generator with the new API key
|
|
716
|
-
const newContentGenerator = await createContentGenerator(currentConfig, this.config, this.config.getSessionId());
|
|
717
|
-
// Update our content generator
|
|
718
|
-
this.contentGenerator = newContentGenerator;
|
|
719
|
-
const modelName = this.config.getModel();
|
|
720
|
-
return modelName;
|
|
721
|
-
}
|
|
722
|
-
catch (_error) {
|
|
723
|
-
return null;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
// [/PATCH:API_KEY_ROTATION]
|
|
727
|
-
/**
|
|
728
|
-
* Handles falling back to Flash model when persistent 429 errors occur for OAuth users.
|
|
729
|
-
* Uses a fallback handler if provided by the config; otherwise, returns null.
|
|
730
|
-
*/
|
|
731
|
-
async handleFlashFallback(authType, error) {
|
|
732
|
-
// First try to rotate API key for GEMINI/OPENAI API key modes
|
|
733
|
-
const rotateResult = await this.tryRotateApiKey(authType);
|
|
734
|
-
if (rotateResult) {
|
|
735
|
-
return rotateResult;
|
|
736
|
-
}
|
|
737
|
-
const currentModel = this.config.getModel();
|
|
738
|
-
const fallbackModel = DEFAULT_GEMINI_FLASH_MODEL;
|
|
739
|
-
// Don't fallback if already using Flash model
|
|
740
|
-
if (currentModel === fallbackModel) {
|
|
741
|
-
return null;
|
|
742
|
-
}
|
|
743
|
-
// Check if config has a fallback handler (set by CLI package)
|
|
744
|
-
const fallbackHandler = this.config.flashFallbackHandler;
|
|
745
|
-
if (typeof fallbackHandler === 'function') {
|
|
746
|
-
try {
|
|
747
|
-
const accepted = await fallbackHandler(currentModel, fallbackModel, error);
|
|
748
|
-
if (accepted !== false && accepted !== null) {
|
|
749
|
-
// Only OAuth users need model fallback, API key users rely on key rotation
|
|
750
|
-
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
|
751
|
-
this.config.setModel(fallbackModel);
|
|
752
|
-
this.config.setFallbackMode(true);
|
|
753
|
-
return fallbackModel;
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
const currentModel = this.config.getModel();
|
|
757
|
-
return currentModel; // Continue with original model, rely on API key rotation
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
// Check if the model was switched manually in the handler
|
|
761
|
-
const newModel = this.config.getModel();
|
|
762
|
-
if (newModel === fallbackModel) {
|
|
763
|
-
return null; // Model was switched but don't continue with current prompt
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
catch (handlerError) {
|
|
767
|
-
console.warn('Flash fallback handler failed:', handlerError);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
return null;
|
|
459
|
+
// If the model is 'auto', we will use a placeholder model to check.
|
|
460
|
+
// Compression occurs before we choose a model, so calling `count_tokens`
|
|
461
|
+
// before the model is chosen would result in an error.
|
|
462
|
+
const model = this._getEffectiveModelForCurrentTurn();
|
|
463
|
+
const { newHistory, info } = await this.compressionService.compress(this.getChat(), prompt_id, force, model, this.config, this.hasFailedCompressionAttempt);
|
|
464
|
+
if (info.compressionStatus ===
|
|
465
|
+
CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
|
|
466
|
+
this.hasFailedCompressionAttempt = !force && true;
|
|
467
|
+
}
|
|
468
|
+
else if (info.compressionStatus === CompressionStatus.COMPRESSED) {
|
|
469
|
+
if (newHistory) {
|
|
470
|
+
this.chat = await this.startChat(newHistory);
|
|
471
|
+
this.updateTelemetryTokenCount();
|
|
472
|
+
this.forceFullIdeContext = true;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return info;
|
|
771
476
|
}
|
|
772
477
|
}
|
|
773
|
-
export const TEST_ONLY = {
|
|
774
|
-
COMPRESSION_PRESERVE_THRESHOLD,
|
|
775
|
-
COMPRESSION_TOKEN_THRESHOLD,
|
|
776
|
-
};
|
|
777
478
|
//# sourceMappingURL=client.js.map
|