@vybestack/llxprt-code 0.4.4 → 0.4.5
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/README.md +8 -0
- package/dist/package.json +3 -3
- package/dist/src/{ui/components/ProQuotaDialog.test.d.ts → auth/oauth-manager-initialization.spec.d.ts} +1 -1
- package/dist/src/auth/oauth-manager-initialization.spec.js +206 -0
- package/dist/src/auth/oauth-manager-initialization.spec.js.map +1 -0
- package/dist/src/auth/oauth-manager.js +4 -8
- package/dist/src/auth/oauth-manager.js.map +1 -1
- package/dist/src/config/cliEphemeralSettings.d.ts +9 -0
- package/dist/src/config/cliEphemeralSettings.js +28 -0
- package/dist/src/config/cliEphemeralSettings.js.map +1 -0
- package/dist/src/config/cliEphemeralSettings.test.d.ts +6 -0
- package/dist/src/config/cliEphemeralSettings.test.js +36 -0
- package/dist/src/config/cliEphemeralSettings.test.js.map +1 -0
- package/dist/src/config/config.d.ts +1 -0
- package/dist/src/config/config.js +14 -0
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/settings.js +8 -1
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/gemini.js +106 -133
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/providers/credentialPrecedence.d.ts +22 -0
- package/dist/src/providers/credentialPrecedence.js +44 -0
- package/dist/src/providers/credentialPrecedence.js.map +1 -0
- package/dist/src/providers/credentialPrecedence.test.d.ts +6 -0
- package/dist/src/providers/credentialPrecedence.test.js +52 -0
- package/dist/src/providers/credentialPrecedence.test.js.map +1 -0
- package/dist/src/providers/oauth-provider-registration.d.ts +21 -0
- package/dist/src/providers/oauth-provider-registration.js +55 -0
- package/dist/src/providers/oauth-provider-registration.js.map +1 -0
- package/dist/src/providers/providerManagerInstance.js +19 -12
- package/dist/src/providers/providerManagerInstance.js.map +1 -1
- package/dist/src/settings/ephemeralSettings.d.ts +17 -0
- package/dist/src/settings/ephemeralSettings.js +178 -0
- package/dist/src/settings/ephemeralSettings.js.map +1 -0
- package/dist/src/ui/App.js +4 -139
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/setCommand.js +12 -184
- package/dist/src/ui/commands/setCommand.js.map +1 -1
- package/dist/src/ui/commands/setCommand.test.js +16 -0
- package/dist/src/ui/commands/setCommand.test.js.map +1 -1
- package/dist/src/ui/containers/SessionController.js +1 -60
- package/dist/src/ui/containers/SessionController.js.map +1 -1
- package/dist/src/ui/containers/SessionController.test.js +0 -101
- package/dist/src/ui/containers/SessionController.test.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.d.ts +1 -1
- package/dist/src/ui/hooks/useGeminiStream.integration.test.js +1 -3
- package/dist/src/ui/hooks/useGeminiStream.integration.test.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +1 -12
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/reducers/sessionReducer.d.ts +0 -4
- package/dist/src/ui/reducers/sessionReducer.js +0 -2
- package/dist/src/ui/reducers/sessionReducer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/src/ui/components/ProQuotaDialog.d.ts +0 -13
- package/dist/src/ui/components/ProQuotaDialog.js +0 -22
- package/dist/src/ui/components/ProQuotaDialog.js.map +0 -1
- package/dist/src/ui/components/ProQuotaDialog.test.js +0 -57
- package/dist/src/ui/components/ProQuotaDialog.test.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { GeminiOAuthProvider } from '../auth/gemini-oauth-provider.js';
|
|
7
|
+
import { QwenOAuthProvider } from '../auth/qwen-oauth-provider.js';
|
|
8
|
+
import { AnthropicOAuthProvider } from '../auth/anthropic-oauth-provider.js';
|
|
9
|
+
/**
|
|
10
|
+
* Track which OAuth providers have been registered to avoid duplicate registration
|
|
11
|
+
*/
|
|
12
|
+
let registeredProviders = new Set();
|
|
13
|
+
/**
|
|
14
|
+
* Context-aware OAuth provider registration
|
|
15
|
+
* Only registers OAuth providers when actually needed for specific providers
|
|
16
|
+
*/
|
|
17
|
+
export function ensureOAuthProviderRegistered(providerName, oauthManager, tokenStore, addItem) {
|
|
18
|
+
if (registeredProviders.has(providerName) || !oauthManager) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let oauthProvider = null;
|
|
22
|
+
switch (providerName) {
|
|
23
|
+
case 'gemini':
|
|
24
|
+
oauthProvider = new GeminiOAuthProvider(tokenStore);
|
|
25
|
+
break;
|
|
26
|
+
case 'qwen':
|
|
27
|
+
oauthProvider = new QwenOAuthProvider(tokenStore);
|
|
28
|
+
break;
|
|
29
|
+
case 'anthropic':
|
|
30
|
+
oauthProvider = new AnthropicOAuthProvider(tokenStore);
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
return; // No OAuth provider needed for this provider name
|
|
34
|
+
}
|
|
35
|
+
if (oauthProvider && addItem) {
|
|
36
|
+
oauthProvider.setAddItem?.(addItem);
|
|
37
|
+
}
|
|
38
|
+
if (oauthProvider) {
|
|
39
|
+
oauthManager.registerProvider(oauthProvider);
|
|
40
|
+
registeredProviders.add(providerName);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if an OAuth provider has been registered
|
|
45
|
+
*/
|
|
46
|
+
export function isOAuthProviderRegistered(providerName) {
|
|
47
|
+
return registeredProviders.has(providerName);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reset registered providers (mainly for testing)
|
|
51
|
+
*/
|
|
52
|
+
export function resetRegisteredProviders() {
|
|
53
|
+
registeredProviders = new Set();
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=oauth-provider-registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-provider-registration.js","sourceRoot":"","sources":["../../../src/providers/oauth-provider-registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAK7E;;GAEG;AACH,IAAI,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,YAAoB,EACpB,YAA0B,EAC1B,UAAmC,EACnC,OAGW;IAEX,IAAI,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAC3D,OAAO;IACT,CAAC;IAED,IAAI,aAAa,GAAG,IAAI,CAAC;IAEzB,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,aAAa,GAAG,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;YACpD,MAAM;QACR,KAAK,MAAM;YACT,aAAa,GAAG,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;YAClD,MAAM;QACR,KAAK,WAAW;YACd,aAAa,GAAG,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;YACvD,MAAM;QACR;YACE,OAAO,CAAC,kDAAkD;IAC9D,CAAC;IAED,IAAI,aAAa,IAAI,OAAO,EAAE,CAAC;QAC7B,aAAa,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC7C,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAoB;IAC5D,OAAO,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -9,9 +9,7 @@ import { LoadedSettings, USER_SETTINGS_PATH, } from '../config/settings.js';
|
|
|
9
9
|
import stripJsonComments from 'strip-json-comments';
|
|
10
10
|
import { OAuthManager } from '../auth/oauth-manager.js';
|
|
11
11
|
import { MultiProviderTokenStore } from '../auth/types.js';
|
|
12
|
-
import {
|
|
13
|
-
import { QwenOAuthProvider } from '../auth/qwen-oauth-provider.js';
|
|
14
|
-
import { AnthropicOAuthProvider } from '../auth/anthropic-oauth-provider.js';
|
|
12
|
+
import { ensureOAuthProviderRegistered } from './oauth-provider-registration.js';
|
|
15
13
|
/**
|
|
16
14
|
* Sanitizes API keys to remove problematic characters that cause ByteString errors.
|
|
17
15
|
* This handles cases where API key files have encoding issues or contain
|
|
@@ -96,25 +94,26 @@ export function getProviderManager(config, allowBrowserEnvironment = false, sett
|
|
|
96
94
|
const tokenStore = new MultiProviderTokenStore();
|
|
97
95
|
const oauthManager = new OAuthManager(tokenStore, loadedSettings);
|
|
98
96
|
oauthManagerInstance = oauthManager;
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const anthropicOAuthProvider = new AnthropicOAuthProvider(tokenStore);
|
|
103
|
-
oauthManager.registerProvider(geminiOAuthProvider);
|
|
104
|
-
oauthManager.registerProvider(qwenOAuthProvider);
|
|
105
|
-
oauthManager.registerProvider(anthropicOAuthProvider);
|
|
97
|
+
// CRITICAL FIX: Don't register OAuth providers upfront
|
|
98
|
+
// They should be registered on-demand when actually needed
|
|
99
|
+
// This prevents premature OAuth initialization during MCP operations
|
|
106
100
|
// Set config BEFORE registering providers so logging wrapper works
|
|
107
101
|
if (config) {
|
|
108
102
|
providerManagerInstance.setConfig(config);
|
|
109
103
|
// CRITICAL: Set provider manager on config so LoggingProviderWrapper can accumulate tokens!
|
|
110
104
|
config.setProviderManager(providerManagerInstance);
|
|
111
105
|
}
|
|
112
|
-
//
|
|
106
|
+
// Register OAuth providers on-demand when creating actual providers
|
|
107
|
+
// Gemini Provider
|
|
113
108
|
const geminiProvider = new GeminiProvider(undefined, undefined, config, oauthManager);
|
|
114
109
|
if (config) {
|
|
115
110
|
geminiProvider.setConfig(config);
|
|
116
111
|
}
|
|
117
112
|
providerManagerInstance.registerProvider(geminiProvider);
|
|
113
|
+
// Register Gemini OAuth provider when Gemini provider is created
|
|
114
|
+
if (oauthManager && tokenStore) {
|
|
115
|
+
void ensureOAuthProviderRegistered('gemini', oauthManager, tokenStore, addItem);
|
|
116
|
+
}
|
|
118
117
|
// Gemini auth configuration removed - use explicit --key/--keyfile, /key//keyfile commands, profiles, env vars, or OAuth only
|
|
119
118
|
// Always register OpenAI provider
|
|
120
119
|
// Priority: Environment variable only - no automatic keyfile loading
|
|
@@ -163,6 +162,10 @@ export function getProviderManager(config, allowBrowserEnvironment = false, sett
|
|
|
163
162
|
configurable: true,
|
|
164
163
|
});
|
|
165
164
|
providerManagerInstance.registerProvider(qwenProvider);
|
|
165
|
+
// Register Qwen OAuth provider when Qwen provider is created
|
|
166
|
+
if (oauthManager && tokenStore) {
|
|
167
|
+
void ensureOAuthProviderRegistered('qwen', oauthManager, tokenStore, addItem);
|
|
168
|
+
}
|
|
166
169
|
// Register OpenAI Responses provider (for o1, o3 models)
|
|
167
170
|
// This provider exclusively uses the /responses endpoint
|
|
168
171
|
const openaiResponsesProvider = new OpenAIResponsesProvider(openaiApiKey || undefined, // Use same API key as OpenAI
|
|
@@ -180,8 +183,12 @@ export function getProviderManager(config, allowBrowserEnvironment = false, sett
|
|
|
180
183
|
allowBrowserEnvironment,
|
|
181
184
|
};
|
|
182
185
|
const anthropicProvider = new AnthropicProvider(anthropicApiKey || undefined, // Pass undefined instead of empty string to allow OAuth fallback
|
|
183
|
-
anthropicBaseUrl, anthropicProviderConfig, oauthManager);
|
|
186
|
+
anthropicBaseUrl, anthropicProviderConfig, anthropicApiKey ? undefined : oauthManager);
|
|
184
187
|
providerManagerInstance.registerProvider(anthropicProvider);
|
|
188
|
+
// Register Anthropic OAuth provider only if no API key is available
|
|
189
|
+
if (!anthropicApiKey && oauthManager && tokenStore) {
|
|
190
|
+
void ensureOAuthProviderRegistered('anthropic', oauthManager, tokenStore, addItem);
|
|
191
|
+
}
|
|
185
192
|
// Set default provider to gemini
|
|
186
193
|
providerManagerInstance.setActiveProvider('gemini');
|
|
187
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerManagerInstance.js","sourceRoot":"","sources":["../../../src/providers/providerManagerInstance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAEL,cAAc,EACd,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"providerManagerInstance.js","sourceRoot":"","sources":["../../../src/providers/providerManagerInstance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAEL,cAAc,EACd,kBAAkB,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C;YACnD,KAAK,6BAA6B,CAChC,WAAW,EACX,YAAY,EACZ,UAAU,EACV,OAAO,CACR,CAAC;QACJ,CAAC;QAED,iCAAiC;QACjC,uBAAuB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,uBAAuB,GAAG,IAAI,CAAC;IAC/B,kBAAkB,GAAG,IAAI,CAAC;IAC1B,oBAAoB,GAAG,IAAI,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,OAAO,EAAE,kBAAkB,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare const ephemeralSettingHelp: Record<string, string>;
|
|
7
|
+
export type EphemeralSettingKey = keyof typeof ephemeralSettingHelp;
|
|
8
|
+
export interface EphemeralParseSuccess {
|
|
9
|
+
success: true;
|
|
10
|
+
value: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface EphemeralParseFailure {
|
|
13
|
+
success: false;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
export type EphemeralParseResult = EphemeralParseSuccess | EphemeralParseFailure;
|
|
17
|
+
export declare function parseEphemeralSettingValue(key: string, rawValue: string): EphemeralParseResult;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export const ephemeralSettingHelp = {
|
|
7
|
+
'context-limit': 'Maximum number of tokens for the context window (e.g., 100000)',
|
|
8
|
+
'compression-threshold': 'Fraction of context limit that triggers compression (0.0-1.0, e.g., 0.7 for 70%)',
|
|
9
|
+
'base-url': 'Base URL for API requests',
|
|
10
|
+
'tool-format': 'Tool format override for the provider',
|
|
11
|
+
'api-version': 'API version to use',
|
|
12
|
+
'custom-headers': 'Custom HTTP headers as JSON object',
|
|
13
|
+
'stream-options': 'Stream options for OpenAI API (default: { include_usage: true })',
|
|
14
|
+
streaming: 'Enable or disable streaming responses (enabled/disabled, default: enabled)',
|
|
15
|
+
'shell-replacement': 'Allow command substitution ($(), <(), backticks) in shell commands (default: false)',
|
|
16
|
+
'socket-timeout': 'Request timeout in milliseconds for local AI servers (default: 60000)',
|
|
17
|
+
'socket-keepalive': 'Enable TCP keepalive for local AI server connections (true/false, default: true)',
|
|
18
|
+
'socket-nodelay': 'Enable TCP_NODELAY concept for local AI servers (true/false, default: true)',
|
|
19
|
+
'tool-output-max-items': 'Maximum number of items/files/matches returned by tools (default: 50)',
|
|
20
|
+
'tool-output-max-tokens': 'Maximum tokens in tool output (default: 50000)',
|
|
21
|
+
'tool-output-truncate-mode': 'How to handle exceeding limits: warn, truncate, or sample (default: warn)',
|
|
22
|
+
'tool-output-item-size-limit': 'Maximum size per item/file in bytes (default: 524288 = 512KB)',
|
|
23
|
+
'max-prompt-tokens': 'Maximum tokens allowed in any prompt sent to LLM (default: 200000)',
|
|
24
|
+
emojifilter: 'Emoji filter mode (allowed, auto, warn, error)',
|
|
25
|
+
retries: 'Maximum number of retry attempts for API calls (default: varies by provider)',
|
|
26
|
+
retrywait: 'Initial delay in milliseconds between retry attempts (default: varies by provider)',
|
|
27
|
+
maxTurnsPerPrompt: 'Maximum number of turns allowed per prompt before stopping (default: 100, -1 for unlimited)',
|
|
28
|
+
};
|
|
29
|
+
const validEphemeralKeys = Object.keys(ephemeralSettingHelp);
|
|
30
|
+
export function parseEphemeralSettingValue(key, rawValue) {
|
|
31
|
+
if (!validEphemeralKeys.includes(key)) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
message: `Invalid setting key: ${key}. Valid keys are: ${validEphemeralKeys.join(', ')}`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
let parsedValue = parseValue(rawValue);
|
|
38
|
+
if (key === 'compression-threshold') {
|
|
39
|
+
const numValue = parsedValue;
|
|
40
|
+
if (typeof numValue !== 'number' || numValue <= 0 || numValue > 1) {
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
message: 'compression-threshold must be a decimal between 0 and 1 (e.g., 0.7 for 70%)',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (key === 'context-limit') {
|
|
48
|
+
const numValue = parsedValue;
|
|
49
|
+
if (typeof numValue !== 'number' ||
|
|
50
|
+
numValue <= 0 ||
|
|
51
|
+
!Number.isInteger(numValue)) {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
message: 'context-limit must be a positive integer (e.g., 100000)',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (key === 'socket-timeout') {
|
|
59
|
+
const numValue = parsedValue;
|
|
60
|
+
if (typeof numValue !== 'number' ||
|
|
61
|
+
numValue <= 0 ||
|
|
62
|
+
!Number.isInteger(numValue)) {
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
message: 'socket-timeout must be a positive integer in milliseconds (e.g., 60000)',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (key === 'socket-keepalive' || key === 'socket-nodelay') {
|
|
70
|
+
if (typeof parsedValue !== 'boolean') {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
message: `${key} must be either 'true' or 'false'`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (key === 'tool-output-max-items' ||
|
|
78
|
+
key === 'tool-output-max-tokens' ||
|
|
79
|
+
key === 'tool-output-item-size-limit' ||
|
|
80
|
+
key === 'max-prompt-tokens') {
|
|
81
|
+
const numValue = parsedValue;
|
|
82
|
+
if (typeof numValue !== 'number' ||
|
|
83
|
+
numValue <= 0 ||
|
|
84
|
+
!Number.isInteger(numValue)) {
|
|
85
|
+
return {
|
|
86
|
+
success: false,
|
|
87
|
+
message: `${key} must be a positive integer`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (key === 'maxTurnsPerPrompt') {
|
|
92
|
+
const numValue = parsedValue;
|
|
93
|
+
if (typeof numValue !== 'number' ||
|
|
94
|
+
!Number.isInteger(numValue) ||
|
|
95
|
+
(numValue !== -1 && numValue <= 0)) {
|
|
96
|
+
return {
|
|
97
|
+
success: false,
|
|
98
|
+
message: `${key} must be a positive integer or -1 for unlimited`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (key === 'tool-output-truncate-mode') {
|
|
103
|
+
const validModes = ['warn', 'truncate', 'sample'];
|
|
104
|
+
if (!validModes.includes(parsedValue)) {
|
|
105
|
+
return {
|
|
106
|
+
success: false,
|
|
107
|
+
message: `${key} must be one of: ${validModes.join(', ')}`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (key === 'emojifilter') {
|
|
112
|
+
const validModes = ['allowed', 'auto', 'warn', 'error'];
|
|
113
|
+
const value = parsedValue;
|
|
114
|
+
const normalizedValue = value.toLowerCase();
|
|
115
|
+
if (!validModes.includes(normalizedValue)) {
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
message: `Invalid emoji filter mode '${parsedValue}'. Valid modes are: ${validModes.join(', ')}`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
parsedValue = normalizedValue;
|
|
122
|
+
}
|
|
123
|
+
if (key === 'shell-replacement') {
|
|
124
|
+
if (typeof parsedValue !== 'boolean') {
|
|
125
|
+
return {
|
|
126
|
+
success: false,
|
|
127
|
+
message: `shell-replacement must be either 'true' or 'false'`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (key === 'streaming') {
|
|
132
|
+
const validModes = ['enabled', 'disabled'];
|
|
133
|
+
if (typeof parsedValue === 'boolean') {
|
|
134
|
+
parsedValue = parsedValue ? 'enabled' : 'disabled';
|
|
135
|
+
}
|
|
136
|
+
else if (typeof parsedValue === 'string' &&
|
|
137
|
+
validModes.includes(parsedValue.toLowerCase())) {
|
|
138
|
+
parsedValue = parsedValue.toLowerCase();
|
|
139
|
+
}
|
|
140
|
+
else if (typeof parsedValue === 'string' &&
|
|
141
|
+
validModes.includes(parsedValue.trim().toLowerCase())) {
|
|
142
|
+
parsedValue = parsedValue.trim().toLowerCase();
|
|
143
|
+
}
|
|
144
|
+
else if (typeof parsedValue === 'string' &&
|
|
145
|
+
['true', 'false'].includes(parsedValue.toLowerCase())) {
|
|
146
|
+
parsedValue =
|
|
147
|
+
parsedValue.toLowerCase() === 'true' ? 'enabled' : 'disabled';
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return {
|
|
151
|
+
success: false,
|
|
152
|
+
message: `Invalid streaming mode '${parsedValue}'. Valid modes are: ${validModes.join(', ')}`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { success: true, value: parsedValue };
|
|
157
|
+
}
|
|
158
|
+
function parseValue(value) {
|
|
159
|
+
if (/^-?\d+(\.\d+)?$/.test(value)) {
|
|
160
|
+
const num = Number(value);
|
|
161
|
+
if (!Number.isNaN(num)) {
|
|
162
|
+
return num;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (value.toLowerCase() === 'true') {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (value.toLowerCase() === 'false') {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
return JSON.parse(value);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=ephemeralSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ephemeralSettings.js","sourceRoot":"","sources":["../../../src/settings/ephemeralSettings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,eAAe,EACb,gEAAgE;IAClE,uBAAuB,EACrB,kFAAkF;IACpF,UAAU,EAAE,2BAA2B;IACvC,aAAa,EAAE,uCAAuC;IACtD,aAAa,EAAE,oBAAoB;IACnC,gBAAgB,EAAE,oCAAoC;IACtD,gBAAgB,EACd,kEAAkE;IACpE,SAAS,EACP,4EAA4E;IAC9E,mBAAmB,EACjB,qFAAqF;IACvF,gBAAgB,EACd,uEAAuE;IACzE,kBAAkB,EAChB,kFAAkF;IACpF,gBAAgB,EACd,6EAA6E;IAC/E,uBAAuB,EACrB,uEAAuE;IACzE,wBAAwB,EAAE,gDAAgD;IAC1E,2BAA2B,EACzB,2EAA2E;IAC7E,6BAA6B,EAC3B,+DAA+D;IACjE,mBAAmB,EACjB,oEAAoE;IACtE,WAAW,EAAE,gDAAgD;IAC7D,OAAO,EACL,8EAA8E;IAChF,SAAS,EACP,oFAAoF;IACtF,iBAAiB,EACf,6FAA6F;CAChG,CAAC;AAEF,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAkB7D,MAAM,UAAU,0BAA0B,CACxC,GAAW,EACX,QAAgB;IAEhB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,wBAAwB,GAAG,qBAAqB,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SACzF,CAAC;IACJ,CAAC;IAED,IAAI,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAEvC,IAAI,GAAG,KAAK,u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,UAAU,CAAC;QAClE,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,2BAA2B,WAAW,uBAAuB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aAC9F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAC/C,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/src/ui/App.js
CHANGED
|
@@ -46,7 +46,7 @@ import { useHistory } from './hooks/useHistoryManager.js';
|
|
|
46
46
|
import { useInputHistoryStore } from './hooks/useInputHistoryStore.js';
|
|
47
47
|
import { useTodoPausePreserver, TodoPausePreserver, } from './hooks/useTodoPausePreserver.js';
|
|
48
48
|
import process from 'node:process';
|
|
49
|
-
import { getErrorMessage, getAllLlxprtMdFilenames, ApprovalMode, isEditorAvailable,
|
|
49
|
+
import { getErrorMessage, getAllLlxprtMdFilenames, ApprovalMode, isEditorAvailable, ideContext, getSettingsService, DebugLogger, uiTelemetryService, } from '@vybestack/llxprt-code-core';
|
|
50
50
|
import { IdeIntegrationNudge, } from './IdeIntegrationNudge.js';
|
|
51
51
|
import { validateAuthMethod } from '../config/auth.js';
|
|
52
52
|
import { useLogger } from './hooks/useLogger.js';
|
|
@@ -74,7 +74,6 @@ import { ShowMoreLines } from './components/ShowMoreLines.js';
|
|
|
74
74
|
import { PrivacyNotice } from './privacy/PrivacyNotice.js';
|
|
75
75
|
import { useSettingsCommand } from './hooks/useSettingsCommand.js';
|
|
76
76
|
import { SettingsDialog } from './components/SettingsDialog.js';
|
|
77
|
-
import { ProQuotaDialog } from './components/ProQuotaDialog.js';
|
|
78
77
|
import { setUpdateHandler } from '../utils/handleAutoUpdate.js';
|
|
79
78
|
import { appEvents, AppEvent } from '../utils/events.js';
|
|
80
79
|
import { getProviderManager } from '../providers/providerManagerInstance.js';
|
|
@@ -243,16 +242,12 @@ const App = (props) => {
|
|
|
243
242
|
const ctrlDTimerRef = useRef(null);
|
|
244
243
|
const [constrainHeight, setConstrainHeight] = useState(true);
|
|
245
244
|
const [showPrivacyNotice, setShowPrivacyNotice] = useState(false);
|
|
246
|
-
const [modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError] = useState(false);
|
|
247
|
-
const [userTier, setUserTier] = useState(undefined);
|
|
248
245
|
const [ideContextState, setIdeContextState] = useState();
|
|
249
246
|
const [showEscapePrompt, setShowEscapePrompt] = useState(false);
|
|
250
247
|
const [showIdeRestartPrompt, setShowIdeRestartPrompt] = useState(false);
|
|
251
248
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
252
249
|
const [providerModels, setProviderModels] = useState([]);
|
|
253
250
|
const { showWorkspaceMigrationDialog, workspaceExtensions, onWorkspaceMigrationDialogOpen, onWorkspaceMigrationDialogClose, } = useWorkspaceMigration(settings);
|
|
254
|
-
const [isProQuotaDialogOpen, setIsProQuotaDialogOpen] = useState(false);
|
|
255
|
-
const [proQuotaDialogResolver, setProQuotaDialogResolver] = useState(null);
|
|
256
251
|
useEffect(() => {
|
|
257
252
|
const unsubscribe = ideContext.subscribeToIdeContext(setIdeContextState);
|
|
258
253
|
// Set the initial value
|
|
@@ -349,13 +344,6 @@ const App = (props) => {
|
|
|
349
344
|
settings.merged.useExternalAuth,
|
|
350
345
|
setAuthError,
|
|
351
346
|
]);
|
|
352
|
-
// Sync user tier from config when authentication changes
|
|
353
|
-
useEffect(() => {
|
|
354
|
-
// Only sync when not currently authenticating
|
|
355
|
-
if (!isAuthenticating) {
|
|
356
|
-
setUserTier(config.getGeminiClient()?.getUserTier());
|
|
357
|
-
}
|
|
358
|
-
}, [config, isAuthenticating]);
|
|
359
347
|
// Check for OAuth code needed flag
|
|
360
348
|
useEffect(() => {
|
|
361
349
|
const checkOAuthFlag = setInterval(() => {
|
|
@@ -496,111 +484,6 @@ const App = (props) => {
|
|
|
496
484
|
const interval = setInterval(updateTokenMetrics, 1000);
|
|
497
485
|
return () => clearInterval(interval);
|
|
498
486
|
}, []);
|
|
499
|
-
// Set up Flash fallback handler
|
|
500
|
-
useEffect(() => {
|
|
501
|
-
const flashFallbackHandler = async (currentModel, fallbackModel, error) => {
|
|
502
|
-
// Check if we've already switched to the fallback model
|
|
503
|
-
if (config.isInFallbackMode()) {
|
|
504
|
-
// If we're already in fallback mode, don't show the dialog again
|
|
505
|
-
return false;
|
|
506
|
-
}
|
|
507
|
-
let message;
|
|
508
|
-
const contentGenConfig = config.getContentGeneratorConfig();
|
|
509
|
-
const authType = contentGenConfig?.authType;
|
|
510
|
-
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
|
511
|
-
// Use actual user tier if available; otherwise, default to FREE tier behavior (safe default)
|
|
512
|
-
const isPaidTier = userTier === UserTierId.LEGACY || userTier === UserTierId.STANDARD;
|
|
513
|
-
// Check if this is a Pro quota exceeded error
|
|
514
|
-
if (error && isProQuotaExceededError(error)) {
|
|
515
|
-
if (isPaidTier) {
|
|
516
|
-
message = `⚡ You have reached your daily ${currentModel} quota limit.
|
|
517
|
-
⚡ You can choose to authenticate with a paid API key or continue with the fallback model.
|
|
518
|
-
⚡ To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
message = `⚡ You have reached your daily ${currentModel} quota limit.
|
|
522
|
-
⚡ You can choose to authenticate with a paid API key or continue with the fallback model.
|
|
523
|
-
⚡ To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
|
524
|
-
⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
|
525
|
-
⚡ You can switch authentication methods by typing /auth`;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
else if (error && isGenericQuotaExceededError(error)) {
|
|
529
|
-
if (isPaidTier) {
|
|
530
|
-
message = `You have reached your daily quota limit.
|
|
531
|
-
To continue, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey
|
|
532
|
-
Or you can switch to a different model using the /model command`;
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
message = `You have reached your daily quota limit.
|
|
536
|
-
To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
|
537
|
-
Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
|
538
|
-
You can switch authentication methods by typing /auth or switch to a different model using /model`;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
if (isPaidTier) {
|
|
543
|
-
// Default message for other cases (like consecutive 429s)
|
|
544
|
-
message = `You are experiencing capacity issues with ${currentModel}.
|
|
545
|
-
Possible reasons are consecutive capacity errors or reaching your daily ${currentModel} quota limit.
|
|
546
|
-
To continue, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey
|
|
547
|
-
Or you can switch to a different model using the /model command`;
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
// Default message for other cases (like consecutive 429s)
|
|
551
|
-
message = `You are experiencing capacity issues with ${currentModel}.
|
|
552
|
-
Possible reasons are consecutive capacity errors or reaching your daily ${currentModel} quota limit.
|
|
553
|
-
To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
|
554
|
-
Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
|
555
|
-
You can switch authentication methods by typing /auth or switch to a different model using /model`;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
// Add message to UI history
|
|
559
|
-
if (message) {
|
|
560
|
-
addItem({
|
|
561
|
-
type: MessageType.INFO,
|
|
562
|
-
text: message,
|
|
563
|
-
}, Date.now());
|
|
564
|
-
}
|
|
565
|
-
// For Pro quota errors, show the dialog and wait for user's choice
|
|
566
|
-
if (error && isProQuotaExceededError(error)) {
|
|
567
|
-
// Set the flag to prevent tool continuation
|
|
568
|
-
setModelSwitchedFromQuotaError(true);
|
|
569
|
-
// Set global quota error flag to prevent Flash model calls
|
|
570
|
-
config.setQuotaErrorOccurred(true);
|
|
571
|
-
// Show the ProQuotaDialog and wait for user's choice
|
|
572
|
-
const shouldContinueWithFallback = await new Promise((resolve) => {
|
|
573
|
-
setIsProQuotaDialogOpen(true);
|
|
574
|
-
setProQuotaDialogResolver(() => resolve);
|
|
575
|
-
});
|
|
576
|
-
// If user chose to continue with fallback, we don't need to stop the current prompt
|
|
577
|
-
if (shouldContinueWithFallback) {
|
|
578
|
-
// Switch to fallback model for future use
|
|
579
|
-
config.setModel(fallbackModel);
|
|
580
|
-
config.setFallbackMode(true);
|
|
581
|
-
logFlashFallback(config, new FlashFallbackEvent(config.getContentGeneratorConfig()?.authType ||
|
|
582
|
-
AuthType.USE_PROVIDER));
|
|
583
|
-
return true; // Continue with current prompt using fallback model
|
|
584
|
-
}
|
|
585
|
-
// If user chose to authenticate, stop current prompt
|
|
586
|
-
return false;
|
|
587
|
-
}
|
|
588
|
-
// For other quota errors, automatically switch to fallback model
|
|
589
|
-
// Set the flag to prevent tool continuation
|
|
590
|
-
setModelSwitchedFromQuotaError(true);
|
|
591
|
-
// Set global quota error flag to prevent Flash model calls
|
|
592
|
-
config.setQuotaErrorOccurred(true);
|
|
593
|
-
}
|
|
594
|
-
// Don't switch models - let the user decide
|
|
595
|
-
// Don't set fallback mode either
|
|
596
|
-
const contentGenConfigForEvent = config.getContentGeneratorConfig();
|
|
597
|
-
const authTypeForEvent = contentGenConfigForEvent?.authType || AuthType.USE_PROVIDER;
|
|
598
|
-
// Still log the event for telemetry
|
|
599
|
-
logFlashFallback(config, new FlashFallbackEvent(authTypeForEvent));
|
|
600
|
-
return false; // Don't continue with current prompt
|
|
601
|
-
};
|
|
602
|
-
config.setFlashFallbackHandler(flashFallbackHandler);
|
|
603
|
-
}, [config, addItem, userTier]);
|
|
604
487
|
// Terminal and UI setup
|
|
605
488
|
const { rows: terminalHeight, columns: terminalWidth } = useTerminalSize();
|
|
606
489
|
const { stdin, setRawMode } = useStdin();
|
|
@@ -694,7 +577,7 @@ You can switch authentication methods by typing /auth or switch to a different m
|
|
|
694
577
|
}
|
|
695
578
|
}
|
|
696
579
|
}, []);
|
|
697
|
-
const { streamingState, submitQuery, initError, pendingHistoryItems: pendingGeminiHistoryItems, thought, cancelOngoingRequest, } = useGeminiStream(config.getGeminiClient(), history, addItem, config, settings, setDebugMessage, handleSlashCommand, shellModeActive, getPreferredEditor, onAuthError, performMemoryRefresh,
|
|
580
|
+
const { streamingState, submitQuery, initError, pendingHistoryItems: pendingGeminiHistoryItems, thought, cancelOngoingRequest, } = useGeminiStream(config.getGeminiClient(), history, addItem, config, settings, setDebugMessage, handleSlashCommand, shellModeActive, getPreferredEditor, onAuthError, performMemoryRefresh, refreshStatic, handleUserCancel, registerTodoPause);
|
|
698
581
|
const pendingHistoryItems = useMemo(() => [...pendingSlashCommandHistoryItems, ...pendingGeminiHistoryItems], [pendingSlashCommandHistoryItems, pendingGeminiHistoryItems]);
|
|
699
582
|
// Message queue functionality removed - not implemented
|
|
700
583
|
// Update the cancel handler with message queue support
|
|
@@ -743,23 +626,6 @@ You can switch authentication methods by typing /auth or switch to a different m
|
|
|
743
626
|
const { handleInput: vimHandleInput } = useVim(buffer, handleFinalSubmit);
|
|
744
627
|
const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(streamingState, settings.merged.customWittyPhrases);
|
|
745
628
|
const showAutoAcceptIndicator = useAutoAcceptIndicator({ config, addItem });
|
|
746
|
-
const handleProQuotaChoice = useCallback((choice) => {
|
|
747
|
-
setIsProQuotaDialogOpen(false);
|
|
748
|
-
if (!proQuotaDialogResolver)
|
|
749
|
-
return;
|
|
750
|
-
const resolveValue = choice !== 'auth';
|
|
751
|
-
proQuotaDialogResolver(resolveValue);
|
|
752
|
-
setProQuotaDialogResolver(null);
|
|
753
|
-
if (choice === 'auth') {
|
|
754
|
-
openAuthDialog();
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
addItem({
|
|
758
|
-
type: MessageType.INFO,
|
|
759
|
-
text: 'Switched to fallback model. Tip: Press Ctrl+P to recall your previous prompt and submit it again if you wish.',
|
|
760
|
-
}, Date.now());
|
|
761
|
-
}
|
|
762
|
-
}, [proQuotaDialogResolver, openAuthDialog, addItem]);
|
|
763
629
|
const handleExit = useCallback((pressedOnce, setPressedOnce, timerRef) => {
|
|
764
630
|
if (pressedOnce) {
|
|
765
631
|
if (timerRef.current) {
|
|
@@ -863,8 +729,7 @@ You can switch authentication methods by typing /auth or switch to a different m
|
|
|
863
729
|
const isInputActive = (streamingState === StreamingState.Idle ||
|
|
864
730
|
streamingState === StreamingState.Responding) &&
|
|
865
731
|
!initError &&
|
|
866
|
-
!isProcessing
|
|
867
|
-
!isProQuotaDialogOpen;
|
|
732
|
+
!isProcessing;
|
|
868
733
|
const handleClearScreen = useCallback(() => {
|
|
869
734
|
clearItems();
|
|
870
735
|
clearConsoleMessagesState();
|
|
@@ -974,7 +839,7 @@ You can switch authentication methods by typing /auth or switch to a different m
|
|
|
974
839
|
], children: (item) => item }, staticKey), _jsx(OverflowProvider, { children: _jsxs(Box, { ref: pendingHistoryItemRef, flexDirection: "column", children: [pendingHistoryItems.map((item, i) => (_jsx(HistoryItemDisplay, { availableTerminalHeight: constrainHeight ? availableTerminalHeight : undefined, terminalWidth: mainAreaWidth,
|
|
975
840
|
// TODO(taehykim): It seems like references to ids aren't necessary in
|
|
976
841
|
// HistoryItemDisplay. Refactor later. Use a fake id for now.
|
|
977
|
-
item: { ...item, id: 0 }, isPending: true, config: config, isFocused: !isEditorDialogOpen, slashCommands: slashCommands }, i))), _jsx(ShowMoreLines, { constrainHeight: constrainHeight })] }) }), _jsxs(Box, { flexDirection: "column", ref: mainControlsRef, children: [updateInfo && _jsx(UpdateNotification, { message: updateInfo.message }), startupWarnings.length > 0 && (_jsx(Box, { borderStyle: "round", borderColor: Colors.AccentYellow, paddingX: 1, marginY: 1, flexDirection: "column", children: startupWarnings.map((warning, index) => (_jsx(Text, { color: Colors.AccentYellow, children: warning }, index))) })), _jsx(TodoPanel, { width: inputWidth }), showWorkspaceMigrationDialog ? (_jsx(WorkspaceMigrationDialog, { workspaceExtensions: workspaceExtensions, onOpen: onWorkspaceMigrationDialogOpen, onClose: onWorkspaceMigrationDialogClose })) : shouldShowIdePrompt && currentIDE ? (_jsx(IdeIntegrationNudge, { ide: currentIDE, onComplete: handleIdePromptComplete })) :
|
|
842
|
+
item: { ...item, id: 0 }, isPending: true, config: config, isFocused: !isEditorDialogOpen, slashCommands: slashCommands }, i))), _jsx(ShowMoreLines, { constrainHeight: constrainHeight })] }) }), _jsxs(Box, { flexDirection: "column", ref: mainControlsRef, children: [updateInfo && _jsx(UpdateNotification, { message: updateInfo.message }), startupWarnings.length > 0 && (_jsx(Box, { borderStyle: "round", borderColor: Colors.AccentYellow, paddingX: 1, marginY: 1, flexDirection: "column", children: startupWarnings.map((warning, index) => (_jsx(Text, { color: Colors.AccentYellow, children: warning }, index))) })), _jsx(TodoPanel, { width: inputWidth }), showWorkspaceMigrationDialog ? (_jsx(WorkspaceMigrationDialog, { workspaceExtensions: workspaceExtensions, onOpen: onWorkspaceMigrationDialogOpen, onClose: onWorkspaceMigrationDialogClose })) : shouldShowIdePrompt && currentIDE ? (_jsx(IdeIntegrationNudge, { ide: currentIDE, onComplete: handleIdePromptComplete })) : showIdeRestartPrompt ? (_jsx(Box, { borderStyle: "round", borderColor: Colors.AccentYellow, paddingX: 1, children: _jsx(Text, { color: Colors.AccentYellow, children: "Workspace trust has changed. Press 'r' to restart Gemini to apply the changes." }) })) : isFolderTrustDialogOpen ? (_jsx(FolderTrustDialog, { onSelect: handleFolderTrustSelect, isRestarting: isRestarting })) : shellConfirmationRequest ? (_jsx(ShellConfirmationDialog, { request: shellConfirmationRequest })) : confirmationRequest ? (_jsxs(Box, { flexDirection: "column", children: [confirmationRequest.prompt, _jsx(Box, { paddingY: 1, children: _jsx(RadioButtonSelect, { isFocused: !!confirmationRequest, items: [
|
|
978
843
|
{ label: 'Yes', value: true },
|
|
979
844
|
{ label: 'No', value: false },
|
|
980
845
|
], onSelect: handleConfirmationSelect }) })] })) : isThemeDialogOpen ? (_jsxs(Box, { flexDirection: "column", children: [_themeError && (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.AccentRed, children: _themeError }) })), _jsx(ThemeDialog, { onSelect: handleThemeSelect, onHighlight: handleThemeHighlight, settings: settings, availableTerminalHeight: constrainHeight
|