@vybestack/llxprt-code-core 0.1.23-nightly.250905.97906524 → 0.2.2-nightly.250908.7b895396
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/src/adapters/IStreamAdapter.d.ts +3 -3
- package/dist/src/auth/precedence.d.ts +1 -1
- package/dist/src/auth/precedence.js +9 -4
- package/dist/src/auth/precedence.js.map +1 -1
- package/dist/src/auth/types.d.ts +4 -4
- package/dist/src/code_assist/codeAssist.js +8 -6
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/setup.js +9 -7
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/config/index.d.ts +7 -0
- package/dist/src/config/index.js +8 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/core/client.d.ts +9 -21
- package/dist/src/core/client.js +55 -156
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/compression-config.d.ts +1 -1
- package/dist/src/core/compression-config.js +4 -5
- package/dist/src/core/compression-config.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +50 -15
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +51 -2
- package/dist/src/core/geminiChat.js +616 -106
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.js +70 -19
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/prompts.js +34 -26
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/turn.d.ts +1 -0
- package/dist/src/core/turn.js +8 -6
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/prompt-config/TemplateEngine.js +17 -0
- package/dist/src/prompt-config/TemplateEngine.js.map +1 -1
- package/dist/src/prompt-config/defaults/core-defaults.js +39 -32
- package/dist/src/prompt-config/defaults/core-defaults.js.map +1 -1
- package/dist/src/prompt-config/defaults/core.md +2 -0
- package/dist/src/prompt-config/defaults/provider-defaults.js +34 -27
- package/dist/src/prompt-config/defaults/provider-defaults.js.map +1 -1
- package/dist/src/prompt-config/defaults/providers/gemini/core.md +229 -43
- package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/core.md +12 -0
- package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash/core.md +12 -0
- package/dist/src/prompt-config/types.d.ts +2 -0
- package/dist/src/providers/BaseProvider.d.ts +32 -6
- package/dist/src/providers/BaseProvider.js +79 -22
- package/dist/src/providers/BaseProvider.js.map +1 -1
- package/dist/src/providers/IProvider.d.ts +9 -3
- package/dist/src/providers/LoggingProviderWrapper.d.ts +10 -3
- package/dist/src/providers/LoggingProviderWrapper.js +33 -27
- package/dist/src/providers/LoggingProviderWrapper.js.map +1 -1
- package/dist/src/providers/ProviderContentGenerator.d.ts +2 -2
- package/dist/src/providers/ProviderContentGenerator.js +9 -6
- package/dist/src/providers/ProviderContentGenerator.js.map +1 -1
- package/dist/src/providers/anthropic/AnthropicProvider.d.ts +27 -21
- package/dist/src/providers/anthropic/AnthropicProvider.js +473 -472
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.d.ts +14 -9
- package/dist/src/providers/gemini/GeminiProvider.js +202 -486
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
- package/dist/src/providers/openai/ConversationCache.d.ts +3 -3
- package/dist/src/providers/openai/IChatGenerateParams.d.ts +9 -4
- package/dist/src/providers/openai/OpenAIProvider.d.ts +44 -115
- package/dist/src/providers/openai/OpenAIProvider.js +582 -946
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/openai/buildResponsesRequest.d.ts +3 -3
- package/dist/src/providers/openai/buildResponsesRequest.js +67 -37
- package/dist/src/providers/openai/buildResponsesRequest.js.map +1 -1
- package/dist/src/providers/openai/estimateRemoteTokens.d.ts +2 -2
- package/dist/src/providers/openai/estimateRemoteTokens.js +21 -8
- package/dist/src/providers/openai/estimateRemoteTokens.js.map +1 -1
- package/dist/src/providers/openai/parseResponsesStream.d.ts +6 -2
- package/dist/src/providers/openai/parseResponsesStream.js +99 -391
- package/dist/src/providers/openai/parseResponsesStream.js.map +1 -1
- package/dist/src/providers/openai/syntheticToolResponses.d.ts +5 -5
- package/dist/src/providers/openai/syntheticToolResponses.js +102 -91
- package/dist/src/providers/openai/syntheticToolResponses.js.map +1 -1
- package/dist/src/providers/openai-responses/OpenAIResponsesProvider.d.ts +18 -20
- package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js +250 -239
- package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js.map +1 -1
- package/dist/src/providers/tokenizers/OpenAITokenizer.js +3 -3
- package/dist/src/providers/tokenizers/OpenAITokenizer.js.map +1 -1
- package/dist/src/providers/types.d.ts +1 -1
- package/dist/src/services/history/ContentConverters.d.ts +6 -1
- package/dist/src/services/history/ContentConverters.js +155 -18
- package/dist/src/services/history/ContentConverters.js.map +1 -1
- package/dist/src/services/history/HistoryService.d.ts +52 -0
- package/dist/src/services/history/HistoryService.js +245 -93
- package/dist/src/services/history/HistoryService.js.map +1 -1
- package/dist/src/services/history/IContent.d.ts +4 -0
- package/dist/src/services/history/IContent.js.map +1 -1
- package/dist/src/settings/SettingsService.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +16 -4
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/tools/IToolFormatter.d.ts +2 -2
- package/dist/src/tools/ToolFormatter.d.ts +42 -4
- package/dist/src/tools/ToolFormatter.js +151 -64
- package/dist/src/tools/ToolFormatter.js.map +1 -1
- package/dist/src/tools/doubleEscapeUtils.d.ts +57 -0
- package/dist/src/tools/doubleEscapeUtils.js +241 -0
- package/dist/src/tools/doubleEscapeUtils.js.map +1 -0
- package/dist/src/tools/read-file.js +5 -2
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/todo-schemas.d.ts +4 -4
- package/dist/src/tools/tool-registry.d.ts +8 -1
- package/dist/src/tools/tool-registry.js +79 -23
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/write-file.js +5 -2
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/types/modelParams.d.ts +12 -0
- package/dist/src/utils/bfsFileSearch.js +2 -6
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/package.json +8 -7
- package/dist/src/core/ContentGeneratorAdapter.d.ts +0 -37
- package/dist/src/core/ContentGeneratorAdapter.js +0 -58
- package/dist/src/core/ContentGeneratorAdapter.js.map +0 -1
- package/dist/src/providers/IMessage.d.ts +0 -38
- package/dist/src/providers/IMessage.js +0 -17
- package/dist/src/providers/IMessage.js.map +0 -1
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.d.ts +0 -69
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.js +0 -577
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.js.map +0 -1
@@ -3,7 +3,7 @@
|
|
3
3
|
* Copyright 2025 Vybestack LLC
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
|
-
import {
|
6
|
+
import { IContent } from '../services/history/IContent.js';
|
7
7
|
import { ServerGeminiStreamEvent } from '../core/turn.js';
|
8
8
|
/**
|
9
9
|
* Interface for adapting provider-specific streams to Gemini event format
|
@@ -11,8 +11,8 @@ import { ServerGeminiStreamEvent } from '../core/turn.js';
|
|
11
11
|
export interface IStreamAdapter {
|
12
12
|
/**
|
13
13
|
* Adapts a provider's stream format to Gemini's event stream format
|
14
|
-
* @param providerStream The provider-specific stream of
|
14
|
+
* @param providerStream The provider-specific stream of content
|
15
15
|
* @returns An async iterator of Gemini events
|
16
16
|
*/
|
17
|
-
adaptStream(providerStream: AsyncIterableIterator<
|
17
|
+
adaptStream(providerStream: AsyncIterableIterator<IContent>): AsyncIterableIterator<ServerGeminiStreamEvent>;
|
18
18
|
}
|
@@ -37,7 +37,7 @@ export declare class AuthPrecedenceResolver {
|
|
37
37
|
*/
|
38
38
|
getAuthMethodName(): Promise<string | null>;
|
39
39
|
/**
|
40
|
-
* Reads API key from a file path, handling
|
40
|
+
* Reads API key from a file path, handling tilde expansion, absolute and relative paths
|
41
41
|
*/
|
42
42
|
private readKeyFile;
|
43
43
|
/**
|
@@ -16,6 +16,7 @@
|
|
16
16
|
*/
|
17
17
|
import * as fs from 'node:fs/promises';
|
18
18
|
import * as path from 'node:path';
|
19
|
+
import * as os from 'node:os';
|
19
20
|
import { getSettingsService } from '../settings/settingsServiceInstance.js';
|
20
21
|
export class AuthPrecedenceResolver {
|
21
22
|
config;
|
@@ -145,14 +146,18 @@ export class AuthPrecedenceResolver {
|
|
145
146
|
return null;
|
146
147
|
}
|
147
148
|
/**
|
148
|
-
* Reads API key from a file path, handling
|
149
|
+
* Reads API key from a file path, handling tilde expansion, absolute and relative paths
|
149
150
|
*/
|
150
151
|
async readKeyFile(filePath) {
|
151
152
|
try {
|
153
|
+
// Handle tilde expansion for home directory
|
154
|
+
const expandedPath = filePath.startsWith('~')
|
155
|
+
? path.join(os.homedir(), filePath.slice(1))
|
156
|
+
: filePath;
|
152
157
|
// Handle relative paths from current working directory
|
153
|
-
const resolvedPath = path.isAbsolute(
|
154
|
-
?
|
155
|
-
: path.resolve(process.cwd(),
|
158
|
+
const resolvedPath = path.isAbsolute(expandedPath)
|
159
|
+
? expandedPath
|
160
|
+
: path.resolve(process.cwd(), expandedPath);
|
156
161
|
const content = await fs.readFile(resolvedPath, 'utf-8');
|
157
162
|
const key = content.trim();
|
158
163
|
if (key === '') {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"precedence.js","sourceRoot":"","sources":["../../../src/auth/precedence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CA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ACD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAwC;QACnD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,YAA0B;QAC3C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF"}
|
package/dist/src/auth/types.d.ts
CHANGED
@@ -40,13 +40,13 @@ export declare const ProviderOAuthConfigSchema: z.ZodObject<{
|
|
40
40
|
scopes: z.ZodArray<z.ZodString, "many">;
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
42
42
|
clientId: string;
|
43
|
-
provider: "
|
43
|
+
provider: "qwen" | "gemini";
|
44
44
|
scopes: string[];
|
45
45
|
authorizationEndpoint: string;
|
46
46
|
tokenEndpoint: string;
|
47
47
|
}, {
|
48
48
|
clientId: string;
|
49
|
-
provider: "
|
49
|
+
provider: "qwen" | "gemini";
|
50
50
|
scopes: string[];
|
51
51
|
authorizationEndpoint: string;
|
52
52
|
tokenEndpoint: string;
|
@@ -111,14 +111,14 @@ export declare const AuthStatusSchema: z.ZodObject<{
|
|
111
111
|
expiresIn: z.ZodOptional<z.ZodNumber>;
|
112
112
|
oauthEnabled: z.ZodOptional<z.ZodBoolean>;
|
113
113
|
}, "strip", z.ZodTypeAny, {
|
114
|
-
authType: "none" | "oauth" | "api-key";
|
115
114
|
provider: string;
|
115
|
+
authType: "none" | "oauth" | "api-key";
|
116
116
|
authenticated: boolean;
|
117
117
|
expiresIn?: number | undefined;
|
118
118
|
oauthEnabled?: boolean | undefined;
|
119
119
|
}, {
|
120
|
-
authType: "none" | "oauth" | "api-key";
|
121
120
|
provider: string;
|
121
|
+
authType: "none" | "oauth" | "api-key";
|
122
122
|
authenticated: boolean;
|
123
123
|
expiresIn?: number | undefined;
|
124
124
|
oauthEnabled?: boolean | undefined;
|
@@ -7,25 +7,27 @@ import { AuthType } from '../core/contentGenerator.js';
|
|
7
7
|
import { getOauthClient } from './oauth2.js';
|
8
8
|
import { setupUser } from './setup.js';
|
9
9
|
import { CodeAssistServer } from './server.js';
|
10
|
+
import { DebugLogger } from '../debug/index.js';
|
10
11
|
export async function createCodeAssistContentGenerator(httpOptions, authType, config, baseURL, // Add baseURL parameter
|
11
12
|
_sessionId) {
|
12
|
-
|
13
|
+
const logger = new DebugLogger('llxprt:code:assist');
|
14
|
+
logger.debug(() => `createCodeAssistContentGenerator: authType=${authType}, config=${!!config}, baseURL=${baseURL}`);
|
13
15
|
if (authType === AuthType.LOGIN_WITH_GOOGLE ||
|
14
16
|
authType === AuthType.CLOUD_SHELL) {
|
15
17
|
try {
|
16
|
-
|
18
|
+
logger.debug(() => `createCodeAssistContentGenerator: calling getOauthClient for authType ${authType}`);
|
17
19
|
const authClient = await getOauthClient(authType, config);
|
18
|
-
|
20
|
+
logger.debug(() => `createCodeAssistContentGenerator: OAuth client created, calling setupUser`);
|
19
21
|
const userData = await setupUser(authClient);
|
20
|
-
|
22
|
+
logger.debug(() => `createCodeAssistContentGenerator: setupUser completed, projectId=${userData.projectId}, userTier=${userData.userTier}`);
|
21
23
|
return new CodeAssistServer(authClient, userData.projectId, httpOptions,
|
22
24
|
// PRIVACY FIX: sessionId removed to prevent transmission to Google servers
|
23
25
|
// sessionId, // removed
|
24
26
|
userData.userTier, baseURL);
|
25
27
|
}
|
26
28
|
catch (error) {
|
27
|
-
|
28
|
-
|
29
|
+
logger.debug(() => `createCodeAssistContentGenerator: ERROR during OAuth setup: ${error}`);
|
30
|
+
logger.debug(() => `createCodeAssistContentGenerator: Error details: ${error}`);
|
29
31
|
throw error;
|
30
32
|
}
|
31
33
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"codeAssist.js","sourceRoot":"","sources":["../../../src/code_assist/codeAssist.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAo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C,KAAK,CACV,GAAG,EAAE,CACH,oEAAoE,QAAQ,CAAC,SAAS,cAAc,QAAQ,CAAC,QAAQ,EAAE,CAC1H,CAAC;YACF,OAAO,IAAI,gBAAgB,CACzB,UAAU,EACV,QAAQ,CAAC,SAAS,EAClB,WAAW;YACX,2EAA2E;YAC3E,wBAAwB;YACxB,QAAQ,CAAC,QAAQ,EACjB,OAAO,CACR,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CACV,GAAG,EAAE,CACH,+DAA+D,KAAK,EAAE,CACzE,CAAC;YACF,MAAM,CAAC,KAAK,CACV,GAAG,EAAE,CAAC,oDAAoD,KAAK,EAAE,CAClE,CAAC;YACF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;AACvD,CAAC"}
|
@@ -5,6 +5,7 @@
|
|
5
5
|
*/
|
6
6
|
import { UserTierId, } from './types.js';
|
7
7
|
import { CodeAssistServer } from './server.js';
|
8
|
+
import { DebugLogger } from '../debug/index.js';
|
8
9
|
export class ProjectIdRequiredError extends Error {
|
9
10
|
constructor() {
|
10
11
|
super('This account requires setting the GOOGLE_CLOUD_PROJECT env var. See https://goo.gle/gemini-cli-auth-docs#workspace-gca');
|
@@ -16,7 +17,8 @@ export class ProjectIdRequiredError extends Error {
|
|
16
17
|
* @returns the user's actual project id
|
17
18
|
*/
|
18
19
|
export async function setupUser(client) {
|
19
|
-
|
20
|
+
const logger = new DebugLogger('llxprt:code:setup');
|
21
|
+
logger.debug(() => `setupUser: starting setup, GOOGLE_CLOUD_PROJECT=${process.env.GOOGLE_CLOUD_PROJECT || 'undefined'}`);
|
20
22
|
const projectId = process.env.GOOGLE_CLOUD_PROJECT || undefined;
|
21
23
|
// PRIVACY FIX: sessionId parameter removed from CodeAssistServer constructor
|
22
24
|
const caServer = new CodeAssistServer(client, projectId, {}, undefined);
|
@@ -25,7 +27,7 @@ export async function setupUser(client) {
|
|
25
27
|
platform: 'PLATFORM_UNSPECIFIED',
|
26
28
|
pluginType: 'GEMINI',
|
27
29
|
};
|
28
|
-
|
30
|
+
logger.debug(() => `setupUser: created CodeAssistServer, calling loadCodeAssist`);
|
29
31
|
const loadRes = await caServer.loadCodeAssist({
|
30
32
|
cloudaicompanionProject: projectId,
|
31
33
|
metadata: {
|
@@ -33,21 +35,21 @@ export async function setupUser(client) {
|
|
33
35
|
duetProject: projectId,
|
34
36
|
},
|
35
37
|
});
|
36
|
-
|
38
|
+
logger.debug(() => `setupUser: loadCodeAssist completed, currentTier=${!!loadRes.currentTier}, cloudaicompanionProject=${loadRes.cloudaicompanionProject}`);
|
37
39
|
if (loadRes.currentTier) {
|
38
|
-
|
40
|
+
logger.debug(() => `setupUser: user has current tier: ${loadRes.currentTier.id}`);
|
39
41
|
if (!loadRes.cloudaicompanionProject) {
|
40
42
|
if (projectId) {
|
41
|
-
|
43
|
+
logger.debug(() => `setupUser: returning with project ID from env: ${projectId}`);
|
42
44
|
return {
|
43
45
|
projectId,
|
44
46
|
userTier: loadRes.currentTier.id,
|
45
47
|
};
|
46
48
|
}
|
47
|
-
|
49
|
+
logger.debug(() => `setupUser: throwing ProjectIdRequiredError - no project ID available`);
|
48
50
|
throw new ProjectIdRequiredError();
|
49
51
|
}
|
50
|
-
|
52
|
+
logger.debug(() => `setupUser: returning with project ID from response: ${loadRes.cloudaicompanionProject}`);
|
51
53
|
return {
|
52
54
|
projectId: loadRes.cloudaicompanionProject,
|
53
55
|
userTier: loadRes.currentTier.id,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/code_assist/setup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAKL,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"setup.js","sour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.0
|
5
|
+
*/
|
6
|
+
export { Config, type ConfigParameters, type RedactionConfig, ApprovalMode, type AccessibilitySettings, type BugCommandSettings, type ChatCompressionSettings, type SummarizeToolOutputSettings, type ComplexityAnalyzerSettings, type TelemetrySettings, MCPServerConfig, AuthProviderType, type SandboxConfig, type FlashFallbackHandler, type ActiveExtension, type GeminiCLIExtension, type FileFilteringOptions, DEFAULT_MEMORY_FILE_FILTERING_OPTIONS, DEFAULT_FILE_FILTERING_OPTIONS, type MCPOAuthConfig, DEFAULT_GEMINI_FLASH_MODEL, } from './config.js';
|
7
|
+
export { DEFAULT_GEMINI_FLASH_MODEL as DEFAULT_FLASH_MODEL } from './models.js';
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2025 Google LLC
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
export { Config, ApprovalMode, MCPServerConfig, AuthProviderType, DEFAULT_MEMORY_FILE_FILTERING_OPTIONS, DEFAULT_FILE_FILTERING_OPTIONS, DEFAULT_GEMINI_FLASH_MODEL, } from './config.js';
|
7
|
+
export { DEFAULT_GEMINI_FLASH_MODEL as DEFAULT_FLASH_MODEL } from './models.js';
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,MAAM,EAGN,YAAY,EAOZ,eAAe,EACf,gBAAgB,EAMhB,qCAAqC,EACrC,8BAA8B,EAE9B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,0BAA0B,IAAI,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
6
|
import { GenerateContentConfig, PartListUnion, Content, GenerateContentResponse } from '@google/genai';
|
7
|
-
import { Turn, ServerGeminiStreamEvent
|
7
|
+
import { Turn, ServerGeminiStreamEvent } from './turn.js';
|
8
8
|
import { Config } from '../config/config.js';
|
9
9
|
import { UserTierId } from '../code_assist/types.js';
|
10
10
|
import { GeminiChat } from './geminiChat.js';
|
@@ -26,20 +26,6 @@ export declare class GeminiClient {
|
|
26
26
|
private readonly MAX_TURNS;
|
27
27
|
private _pendingConfig?;
|
28
28
|
private _previousHistory?;
|
29
|
-
/**
|
30
|
-
* Threshold for compression token count as a fraction of the model's token limit.
|
31
|
-
* If the chat history exceeds this threshold, it will be compressed.
|
32
|
-
*/
|
33
|
-
private COMPRESSION_TOKEN_THRESHOLD;
|
34
|
-
/**
|
35
|
-
* The fraction of the latest chat history to keep. A value of 0.5
|
36
|
-
* means that only the last 50% of the chat history will be kept after compression.
|
37
|
-
*/
|
38
|
-
private readonly COMPRESSION_PRESERVE_THRESHOLD;
|
39
|
-
/**
|
40
|
-
* User-defined context limit override
|
41
|
-
*/
|
42
|
-
private userContextLimit?;
|
43
29
|
private readonly loopDetector;
|
44
30
|
private lastPromptId?;
|
45
31
|
private readonly complexityAnalyzer;
|
@@ -48,12 +34,7 @@ export declare class GeminiClient {
|
|
48
34
|
private readonly complexitySuggestionCooldown;
|
49
35
|
private lastSentIdeContext;
|
50
36
|
private forceFullIdeContext;
|
51
|
-
private logger;
|
52
37
|
constructor(config: Config);
|
53
|
-
/**
|
54
|
-
* Set the compression threshold and context limit overrides
|
55
|
-
*/
|
56
|
-
setCompressionSettings(compressionThreshold?: number, contextLimit?: number): void;
|
57
38
|
initialize(contentGeneratorConfig: ContentGeneratorConfig): Promise<void>;
|
58
39
|
private lazyInitialize;
|
59
40
|
getContentGenerator(): ContentGenerator;
|
@@ -86,7 +67,14 @@ export declare class GeminiClient {
|
|
86
67
|
generateJson(contents: Content[], schema: Record<string, unknown>, abortSignal: AbortSignal, model?: string, config?: GenerateContentConfig): Promise<Record<string, unknown>>;
|
87
68
|
generateContent(contents: Content[], generationConfig: GenerateContentConfig, abortSignal: AbortSignal, model?: string): Promise<GenerateContentResponse>;
|
88
69
|
generateEmbedding(texts: string[]): Promise<number[][]>;
|
89
|
-
|
70
|
+
/**
|
71
|
+
* Manually trigger chat compression
|
72
|
+
* Returns compression info if successful, null if not needed
|
73
|
+
*/
|
74
|
+
tryCompressChat(prompt_id: string, _force?: boolean): Promise<{
|
75
|
+
originalTokenCount: number;
|
76
|
+
newTokenCount: number;
|
77
|
+
} | null>;
|
90
78
|
/**
|
91
79
|
* Handles falling back to Flash model when persistent 429 errors occur for OAuth users.
|
92
80
|
* Uses a fallback handler if provided by the config; otherwise, returns null.
|
package/dist/src/core/client.js
CHANGED
@@ -4,18 +4,16 @@
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
6
|
import { getDirectoryContextString, getEnvironmentContext, } from '../utils/environmentContext.js';
|
7
|
-
import { Turn, GeminiEventType
|
8
|
-
import { getCoreSystemPromptAsync
|
7
|
+
import { Turn, GeminiEventType } from './turn.js';
|
8
|
+
import { getCoreSystemPromptAsync } from './prompts.js';
|
9
9
|
import { getResponseText } from '../utils/generateContentResponseUtilities.js';
|
10
10
|
import { reportError } from '../utils/errorReporting.js';
|
11
11
|
import { GeminiChat } from './geminiChat.js';
|
12
|
+
import { DebugLogger } from '../debug/index.js';
|
12
13
|
import { HistoryService } from '../services/history/HistoryService.js';
|
13
14
|
import { ContentConverters } from '../services/history/ContentConverters.js';
|
14
15
|
import { retryWithBackoff } from '../utils/retry.js';
|
15
16
|
import { getErrorMessage } from '../utils/errors.js';
|
16
|
-
import { isFunctionResponse } from '../utils/messageInspectors.js';
|
17
|
-
import { tokenLimit } from './tokenLimits.js';
|
18
|
-
import { COMPRESSION_TOKEN_THRESHOLD, COMPRESSION_PRESERVE_THRESHOLD, } from './compression-config.js';
|
19
17
|
import { AuthType, createContentGenerator, } from './contentGenerator.js';
|
20
18
|
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
21
19
|
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
@@ -23,7 +21,6 @@ import { LoopDetectionService } from '../services/loopDetectionService.js';
|
|
23
21
|
import { ideContext } from '../ide/ideContext.js';
|
24
22
|
import { ComplexityAnalyzer } from '../services/complexity-analyzer.js';
|
25
23
|
import { TodoReminderService } from '../services/todo-reminder-service.js';
|
26
|
-
import { DebugLogger } from '../debug/index.js';
|
27
24
|
function isThinkingSupported(model) {
|
28
25
|
if (model.startsWith('gemini-2.5'))
|
29
26
|
return true;
|
@@ -77,20 +74,6 @@ export class GeminiClient {
|
|
77
74
|
MAX_TURNS = 100;
|
78
75
|
_pendingConfig;
|
79
76
|
_previousHistory;
|
80
|
-
/**
|
81
|
-
* Threshold for compression token count as a fraction of the model's token limit.
|
82
|
-
* If the chat history exceeds this threshold, it will be compressed.
|
83
|
-
*/
|
84
|
-
COMPRESSION_TOKEN_THRESHOLD = COMPRESSION_TOKEN_THRESHOLD;
|
85
|
-
/**
|
86
|
-
* The fraction of the latest chat history to keep. A value of 0.5
|
87
|
-
* means that only the last 50% of the chat history will be kept after compression.
|
88
|
-
*/
|
89
|
-
COMPRESSION_PRESERVE_THRESHOLD = COMPRESSION_PRESERVE_THRESHOLD;
|
90
|
-
/**
|
91
|
-
* User-defined context limit override
|
92
|
-
*/
|
93
|
-
userContextLimit;
|
94
77
|
loopDetector;
|
95
78
|
lastPromptId;
|
96
79
|
complexityAnalyzer;
|
@@ -99,10 +82,8 @@ export class GeminiClient {
|
|
99
82
|
complexitySuggestionCooldown;
|
100
83
|
lastSentIdeContext;
|
101
84
|
forceFullIdeContext = true;
|
102
|
-
logger;
|
103
85
|
constructor(config) {
|
104
86
|
this.config = config;
|
105
|
-
this.logger = new DebugLogger('llxprt:core:client');
|
106
87
|
if (config.getProxy()) {
|
107
88
|
setGlobalDispatcher(new ProxyAgent(config.getProxy()));
|
108
89
|
}
|
@@ -119,19 +100,6 @@ export class GeminiClient {
|
|
119
100
|
complexitySettings.suggestionCooldownMs ?? 300000;
|
120
101
|
this.todoReminderService = new TodoReminderService();
|
121
102
|
}
|
122
|
-
/**
|
123
|
-
* Set the compression threshold and context limit overrides
|
124
|
-
*/
|
125
|
-
setCompressionSettings(compressionThreshold, contextLimit) {
|
126
|
-
if (compressionThreshold !== undefined &&
|
127
|
-
compressionThreshold > 0 &&
|
128
|
-
compressionThreshold <= 1) {
|
129
|
-
this.COMPRESSION_TOKEN_THRESHOLD = compressionThreshold;
|
130
|
-
}
|
131
|
-
if (contextLimit !== undefined && contextLimit > 0) {
|
132
|
-
this.userContextLimit = contextLimit;
|
133
|
-
}
|
134
|
-
}
|
135
103
|
async initialize(contentGeneratorConfig) {
|
136
104
|
// Preserve chat history before resetting
|
137
105
|
const previousHistory = this.chat?.getHistory();
|
@@ -259,8 +227,26 @@ export class GeminiClient {
|
|
259
227
|
this.getChat().setTools(tools);
|
260
228
|
}
|
261
229
|
async resetChat() {
|
262
|
-
//
|
263
|
-
|
230
|
+
// If chat exists, clear its history service
|
231
|
+
if (this.chat) {
|
232
|
+
const historyService = this.chat.getHistoryService();
|
233
|
+
if (historyService) {
|
234
|
+
// Clear the history service directly
|
235
|
+
historyService.clear();
|
236
|
+
}
|
237
|
+
else {
|
238
|
+
// Fallback to chat's clearHistory if no history service
|
239
|
+
this.chat.clearHistory();
|
240
|
+
}
|
241
|
+
// Reset the chat's internal state
|
242
|
+
this.forceFullIdeContext = true;
|
243
|
+
}
|
244
|
+
else {
|
245
|
+
// No chat exists yet, create one with empty history
|
246
|
+
this.chat = await this.startChat([]);
|
247
|
+
}
|
248
|
+
// Clear the stored history as well
|
249
|
+
this._previousHistory = [];
|
264
250
|
}
|
265
251
|
async addDirectoryContext() {
|
266
252
|
if (!this.chat) {
|
@@ -291,9 +277,8 @@ export class GeminiClient {
|
|
291
277
|
try {
|
292
278
|
const userMemory = this.config.getUserMemory();
|
293
279
|
const model = this.config.getModel();
|
294
|
-
|
295
|
-
|
296
|
-
}
|
280
|
+
const logger = new DebugLogger('llxprt:client:start');
|
281
|
+
logger.debug(() => `DEBUG [client.startChat]: Model from config: ${model}`);
|
297
282
|
let systemInstruction = await getCoreSystemPromptAsync(userMemory, model);
|
298
283
|
// Add environment context to system instruction
|
299
284
|
const envContextText = envParts
|
@@ -302,9 +287,7 @@ export class GeminiClient {
|
|
302
287
|
if (envContextText) {
|
303
288
|
systemInstruction = `${envContextText}\n\n${systemInstruction}`;
|
304
289
|
}
|
305
|
-
|
306
|
-
console.log('DEBUG [client.startChat]: System instruction includes Flash instructions:', systemInstruction.includes('IMPORTANT: You MUST use the provided tools'));
|
307
|
-
}
|
290
|
+
logger.debug(() => `DEBUG [client.startChat]: System instruction includes Flash instructions: ${systemInstruction.includes('IMPORTANT: You MUST use the provided tools')}`);
|
308
291
|
const generateContentConfigWithThinking = isThinkingSupported(this.config.getModel())
|
309
292
|
? {
|
310
293
|
...this.generateContentConfig,
|
@@ -465,12 +448,11 @@ export class GeminiClient {
|
|
465
448
|
}
|
466
449
|
}
|
467
450
|
async *sendMessageStream(request, signal, prompt_id, turns = this.MAX_TURNS, originalModel) {
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
}
|
451
|
+
const logger = new DebugLogger('llxprt:client:stream');
|
452
|
+
logger.debug(() => 'DEBUG: GeminiClient.sendMessageStream called');
|
453
|
+
logger.debug(() => `DEBUG: GeminiClient.sendMessageStream request: ${JSON.stringify(request, null, 2)}`);
|
454
|
+
logger.debug(() => `DEBUG: GeminiClient.sendMessageStream typeof request: ${typeof request}`);
|
455
|
+
logger.debug(() => `DEBUG: GeminiClient.sendMessageStream Array.isArray(request): ${Array.isArray(request)}`);
|
474
456
|
await this.lazyInitialize();
|
475
457
|
// Ensure chat is initialized after lazyInitialize
|
476
458
|
if (!this.chat) {
|
@@ -507,10 +489,6 @@ export class GeminiClient {
|
|
507
489
|
}
|
508
490
|
// Track the original model from the first call to detect model switching
|
509
491
|
const initialModel = originalModel || this.config.getModel();
|
510
|
-
const compressed = await this.tryCompressChat(prompt_id);
|
511
|
-
if (compressed) {
|
512
|
-
yield { type: GeminiEventType.ChatCompressed, value: compressed };
|
513
|
-
}
|
514
492
|
// Prevent context updates from being sent while a tool call is
|
515
493
|
// waiting for a response. The Gemini API requires that a functionResponse
|
516
494
|
// part from the user immediately follows a functionCall part from the model
|
@@ -728,118 +706,39 @@ export class GeminiClient {
|
|
728
706
|
return values;
|
729
707
|
});
|
730
708
|
}
|
731
|
-
|
709
|
+
/**
|
710
|
+
* Manually trigger chat compression
|
711
|
+
* Returns compression info if successful, null if not needed
|
712
|
+
*/
|
713
|
+
async tryCompressChat(prompt_id, _force = false) {
|
732
714
|
await this.lazyInitialize();
|
733
|
-
|
734
|
-
// Regardless of `force`, don't do anything if the history is empty.
|
735
|
-
if (curatedHistory.length === 0) {
|
715
|
+
if (!this.hasChatInitialized()) {
|
736
716
|
return null;
|
737
717
|
}
|
738
|
-
const
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
if (historyService) {
|
743
|
-
// Wait for any pending token calculations to complete
|
744
|
-
await historyService.recalculateTokens(model);
|
745
|
-
originalTokenCount = historyService.getTotalTokens();
|
746
|
-
}
|
747
|
-
else {
|
748
|
-
// Fallback to content generator if history service not available
|
749
|
-
const countResult = await this.getContentGenerator().countTokens({
|
750
|
-
model,
|
751
|
-
contents: curatedHistory,
|
752
|
-
});
|
753
|
-
originalTokenCount = countResult.totalTokens || 0;
|
754
|
-
}
|
718
|
+
const chat = this.getChat();
|
719
|
+
const historyService = chat.getHistoryService();
|
720
|
+
// Get current token count
|
721
|
+
const originalTokenCount = historyService.getTotalTokens();
|
755
722
|
if (originalTokenCount === 0) {
|
756
|
-
this.logger.log(() => `[Warning] Could not determine token count for model ${model}.`);
|
757
723
|
return null;
|
758
724
|
}
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
const
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
let compressBeforeIndex = Math.floor(curatedHistory.length * (1 - this.COMPRESSION_PRESERVE_THRESHOLD));
|
771
|
-
// Ensure we don't compress everything - keep at least the last 2 turns
|
772
|
-
if (compressBeforeIndex >= curatedHistory.length - 4) {
|
773
|
-
compressBeforeIndex = Math.max(0, curatedHistory.length - 4);
|
774
|
-
}
|
775
|
-
// Find the first user message after the index to ensure we don't split mid-turn
|
776
|
-
while (compressBeforeIndex < curatedHistory.length &&
|
777
|
-
(curatedHistory[compressBeforeIndex]?.role === 'model' ||
|
778
|
-
isFunctionResponse(curatedHistory[compressBeforeIndex]))) {
|
779
|
-
compressBeforeIndex++;
|
780
|
-
}
|
781
|
-
const historyToCompress = curatedHistory.slice(0, compressBeforeIndex);
|
782
|
-
const historyToKeep = curatedHistory.slice(compressBeforeIndex);
|
783
|
-
// Debug logging
|
784
|
-
this.logger.debug(() => `[Compression] Compressing ${historyToCompress.length} messages, keeping ${historyToKeep.length} messages`);
|
785
|
-
this.logger.debug(() => `[Compression] Original token count: ${originalTokenCount}`);
|
786
|
-
this.getChat().setHistory(historyToCompress);
|
787
|
-
const response = await this.getChat().sendMessage({
|
788
|
-
message: {
|
789
|
-
text: 'First, reason in your scratchpad. Then, generate the <state_snapshot>.',
|
790
|
-
},
|
791
|
-
config: {
|
792
|
-
systemInstruction: { text: getCompressionPrompt() },
|
793
|
-
},
|
794
|
-
}, prompt_id);
|
795
|
-
// Extract text from the response using the utility function
|
796
|
-
const summary = getResponseText(response);
|
797
|
-
// Debug: log the summary length
|
798
|
-
if (summary) {
|
799
|
-
this.logger.debug(() => `[Compression] Summary length: ${summary.length} characters`);
|
800
|
-
this.logger.debug(() => `[Compression] Summary preview: ${summary.substring(0, 200)}...`);
|
801
|
-
// Ensure the summary is meaningful (not just empty XML tags)
|
802
|
-
if (summary.length < 100) {
|
803
|
-
this.logger.log(() => '[Warning] [Compression] Summary appears too short, may be incomplete');
|
725
|
+
// Perform compression
|
726
|
+
try {
|
727
|
+
await chat.performCompression(prompt_id);
|
728
|
+
// Get new token count after compression
|
729
|
+
const newTokenCount = historyService.getTotalTokens();
|
730
|
+
// Check if compression actually happened
|
731
|
+
if (newTokenCount < originalTokenCount) {
|
732
|
+
return {
|
733
|
+
originalTokenCount,
|
734
|
+
newTokenCount,
|
735
|
+
};
|
804
736
|
}
|
805
737
|
}
|
806
|
-
|
807
|
-
|
808
|
-
return null;
|
809
|
-
}
|
810
|
-
this.chat = await this.startChat([
|
811
|
-
{
|
812
|
-
role: 'user',
|
813
|
-
parts: [{ text: summary }],
|
814
|
-
},
|
815
|
-
{
|
816
|
-
role: 'model',
|
817
|
-
parts: [{ text: 'Got it. Thanks for the additional context!' }],
|
818
|
-
},
|
819
|
-
...historyToKeep,
|
820
|
-
]);
|
821
|
-
this.forceFullIdeContext = true;
|
822
|
-
// Get new token count from the new HistoryService
|
823
|
-
const newHistoryService = this.getHistoryService();
|
824
|
-
let newTokenCount = 0;
|
825
|
-
if (newHistoryService) {
|
826
|
-
// Wait for recalculation to complete
|
827
|
-
await newHistoryService.recalculateTokens(model);
|
828
|
-
newTokenCount = newHistoryService.getTotalTokens();
|
829
|
-
}
|
830
|
-
else {
|
831
|
-
// Fallback
|
832
|
-
const countResult = await this.getContentGenerator().countTokens({
|
833
|
-
model: this.config.getModel(),
|
834
|
-
contents: this.getChat().getHistory(),
|
835
|
-
});
|
836
|
-
newTokenCount = countResult.totalTokens || 0;
|
738
|
+
catch (error) {
|
739
|
+
console.error('Compression failed:', error);
|
837
740
|
}
|
838
|
-
|
839
|
-
return {
|
840
|
-
originalTokenCount,
|
841
|
-
newTokenCount,
|
842
|
-
};
|
741
|
+
return null;
|
843
742
|
}
|
844
743
|
/**
|
845
744
|
* Handles falling back to Flash model when persistent 429 errors occur for OAuth users.
|